Commits

ced...@debian  committed 35163d0

Added comments. Sanity checks

  • Participants
  • Parent commits e1bc77e

Comments (0)

Files changed (3)

File source/authenticationAgent.py

 
 class AuthenticationAgent(spade.Agent.Agent):
     """
+    This class represent the authentication agent.
+    This agent is in charge of serving request of
+    client agent.
+    Responsibilities:
+     - manage the XML file of known client agents;
+     - provides informations (ontology, public key) to a client about an other client.
     """
 
     class ReceiveMessage(spade.Behaviour.Behaviour):
 
     def search_agent_into_df(self, service_name = None, service_type = None):
         """
-        Search for a client agent according to its service name or
-        service type.
+        Search for a client agent according to its service name.
         """
         dad = spade.DF.DfAgentDescription()
         ds = spade.DF.ServiceDescription()

File source/clientAgent.py

     """
     class ReceiveMessageFromAuthenticator(spade.Behaviour.Behaviour):
         """
+        This class is in charge of receiving requested answer from the
+        authentication agent.
         """
         def onStart(self):
             """
 
         def _process(self):
             """
+            Analyse and process the anwser.
             """
             self.msg = None
 
                     print "Logging in !"
 
                 elif command[0] == "newinterlocutor":
-                    print command
                     self.myAgent.gui.add_client(command[1], command[2], command[3])
 
     class SendMessageToAuthenticator(spade.Behaviour.OneShotBehaviour):
         """
+        This class is in charge of sending request to the authentication agent.
+        Requests:
+         - ask for registration as a new client;
+         - ask for informations (ontology, public key) about an other client.
         """
         def onStart(self):
             print "Starting", self.__class__.__name__, "behaviour"
 
         def _process(self):
             """
-            Send the message to all recipients.
+            Send the request to the authentication agent.
             """
             # First, form the receiver AID
             receiver = self.myAgent.search_agent_into_df( \

File source/simpleGui.py

                 username = username_entry.get()
                 password1 = password1_entry.get()
                 password2 = password2_entry.get()
+                self.ontology = ontology_entry.get()
             except ValueError:
                 tkMessageBox.showerror('Error', 'Bad entry')
                 return
         msg.title('Signin')
         msg.resizable(height = False, width = False)
 
-        Label(msg, text='Username : ').grid(row = 0, column = 0)
+        Label(msg, text='Username : ', state=DISABLED).grid(row = 0, column = 0)
         username_entry = Entry(msg)
         username_entry.grid(row = 0, column = 1, pady = 2)
+        username_entry.insert(0, self.name.lower())
         username_entry.focus_set()
 
         Label(msg, text='Password : ').grid(row = 1, column = 0)
         password2_entry = Entry(msg)
         password2_entry.grid(row = 2, column = 1, pady = 2)
 
+        Label(msg, text='Ontology : ').grid(row = 3, column = 0)
+        ontology_entry = Entry(msg)
+        ontology_entry.grid(row = 3, column = 1, pady = 2)
+        ontology_entry.insert(0, self.ontology)
+
         Button(msg, text="OK", \
-            command = execute).grid(row = 3, columnspan = 2, pady = 2)
+            command = execute).grid(row = 4, columnspan = 2, pady = 2)
 
         ## sets the focus window (for Windows)
         msg.focus_set()
     def connect_to_client(self, event = None, client = None):
         """
         Get the selected client (interlocutor) in the listbox.
+        And ask to the authentication agent for informations avout
+        the selected client.
         """
         if client is None:
             try:
             except IndexError:
                 pass
         if client not in self.client_agent.receiver.keys():
-            # if client is not already an interlocutor
-            # Ask for information to the authenticationAgent
+            # If client is not already an interlocutor
+            # ask for information to the authenticationAgent
             # set the outgoing message
             self.client_agent.outgoing_message = "addinterlocutor:" + client
 
             # send the answer to the authentication agent
             self.client_agent.addBehaviour(self.client_agent.SendMessageToAuthenticator(), None)
+            # we are asking for the ontology and pubkey of the
+            # selected client. The answer is managed in the
+            # method "add_client"
 
 
             self.client_agent.gui = self
 
             #tkMessageBox.showinfo('Information', 'Connected with ' + client)
         else:
+            # If the selected client is already an interlocutor
+            # remove it from the dic of interlocutors
             #tkMessageBox.showinfo('Information', 'Already connected with ' + client)
             del self.client_agent.receiver[client]
             self.update_connection_info_label()
 
     def add_client(self, client, ontology, pubkey):
         """
-        The method is called when the authentication agent
+        The method is called by clienAgent when the authentication agent
         has given the requested informations about the new
         interlocutor.
         """
-        # add the new interlocutor to the list of interlocutors
+        # add the new interlocutor to the dic of interlocutors
         self.client_agent.receiver[client] = (ontology, \
                                                     pubkey)
         # update the connection info label
 
     def receive_message(self, acl_msg):
         """
+        Called by clientAgent when a new message
+        from another clent arrives. Test if the client
+        is already an interlocutor. If not, propose to add
+        this client in the dic of interlocutors.
         """
         name = acl_msg.getSender().getName().split('@')[0]
         if name in self.client_agent.receiver.keys():