Commits

Cédric Bonhomme committed e43fc9a

Changed the username and agent name and the list of connected clients.

Comments (0)

Files changed (3)

source/configurations/clients_informations.xml

-<?xml version="1.0" ?><clients><client><name>bob</name><password>5ed25af7b1ed23fb00122e13d7f74c4d8262acd8</password><ontology>ontoBob</ontology><pubkey>38723395226133652871487606996660680568884218896052816620080482121786369165077-44796142063839315885604999554134286106416435926357041352384991407956854635383</pubkey></client><client><name>alice</name><password>92ef57ba40706594b46425705e989cbc256d9724</password><ontology>ontoAlice</ontology><pubkey>4226379839617916115200972967138836288667954226038144740594176117603282128143-96979420560157444204666866837285905997510158302326814682483261762443509495551</pubkey></client></clients>

source/simpleGui.py

 
 __author__ = "Cedric Bonhomme"
 __version__ = "$Revision: 0.1 $"
-__date__ = "$Date: 2010/01/04 $"
+__date__ = "$Date: 2010/01/05 $"
 __copyright__ = "Copyright (c) 2010 Cedric Bonhomme"
 __license__ = "GPLv3"
 
         """
         Initializes GUI components.
         """
-        self.name = name
+        self.user_name = name
+        self.agent_name = name
         self.agent_host = agent_host
         self.ontology = agent_ontology
         self.pubkey = agent_pubkey
 
         self.master = Tk()
         self.master.protocol("WM_DELETE_WINDOW", self.onClose)
-        self.master.title("pyChatter - " + name)
+        if self.user_name:
+            self.master.title("pyChatter - " + self.user_name)
+        else:
+            self.master.title("pyChatter")
         #self.master.minsize(width = 140, height = 40)
         self.master.resizable(height = False, width = False)
 
                 tkMessageBox.showerror('Error', 'Bad entry')
                 return
 
+            self.user_name = username
+            self.agent_name = username.lower().replace(' ', '_')
+
             self.client_agent = clientAgent.ClientAgent( \
-                        username.lower() + "@" + address, password)
+                        self.agent_name + "@" + address, password)
             self.client_agent.start()
             self.client_agent.gui = self
 
 
             msg.destroy()
 
+            self.master.title("pyChatter - " + self.user_name)
+
         if self.client_agent != None:
             self.show_info('Already connected to the SPADE platform.')
             return
         msg.title('Connection to the SPADE platform')
         msg.resizable(height = False, width = False)
 
-        Label(msg, text='Username : ').grid(row = 0, column = 0)
+        Label(msg, text='Username : ').grid(row = 0, column = 0, sticky = W)
         username_entry = Entry(msg)
-        username_entry.grid(row = 0, column = 1, pady = 2)
-        username_entry.insert(0, self.name.lower())
+        username_entry.grid(row = 0, column = 1, pady = 2, sticky = W)
+        username_entry.insert(0, self.agent_name.lower())
         username_entry.focus_set()
 
-        Label(msg, text='SPADE host address : ').grid(row = 1, column = 0)
+        Label(msg, text='SPADE platform address : ').grid(row = 1, column = 0, sticky = W)
         spade_address_entry = Entry(msg)
-        spade_address_entry.grid(row = 1, column = 1, pady = 2)
+        spade_address_entry.grid(row = 1, column = 1, pady = 2, sticky = W)
         spade_address_entry.insert(0, self.agent_host)
 
-        Label(msg, text='SPADE password : ').grid(row = 2, column = 0)
+        Label(msg, text='SPADE password : ').grid(row = 2, column = 0, sticky = W)
         spade_password_entry = Entry(msg)
-        spade_password_entry.grid(row = 2, column = 1, pady = 2)
+        spade_password_entry.grid(row = 2, column = 1, pady = 2, sticky = W)
         spade_password_entry.insert(0, "secret")
 
         Button(msg, text="OK", \
         try:
             self.client_agent.tearDown()
             self.client_agent = None
+            self.user_name = ''
+            self.agent_name = ''
+            self.master.title('pyChatter')
         except AttributeError:
             # agent not started
             self.show_info('Not connected to the SPADE platform.')
             hashed_passwd = sha1_hash.hexdigest()
 
             self.client_agent.outgoing_message = "signin:" + \
-                                        self.name.lower() + \
+                                        self.agent_name + \
                                         ":" + hashed_passwd + \
                                         ":" + self.ontology + \
                                         ":" + pubkey
         msg.title('Signin')
         msg.resizable(height = False, width = False)
 
-        Label(msg, text='Username : ', state = DISABLED).grid(row = 0, column = 0)
+        Label(msg, text='Username : ', state = DISABLED).grid(row = 0, column = 0, sticky = W)
         username_entry = Entry(msg)
-        username_entry.grid(row = 0, column = 1, pady = 2)
-        username_entry.insert(0, self.name.lower())
-        username_entry.configure(state=DISABLED)
+        username_entry.grid(row = 0, column = 1, pady = 2, sticky = W)
+        username_entry.insert(0, self.agent_name)
+        username_entry.configure(state = DISABLED)
         username_entry.focus_set()
 
-        Label(msg, text='Password : ').grid(row = 1, column = 0)
+        Label(msg, text='Password : ').grid(row = 1, column = 0, sticky = W)
         password1_entry = Entry(msg)
-        password1_entry.grid(row = 1, column = 1, pady = 2)
+        password1_entry.grid(row = 1, column = 1, pady = 2, sticky = W)
 
-        Label(msg, text='Password : ').grid(row = 2, column = 0)
+        Label(msg, text='Password : ').grid(row = 2, column = 0, sticky = W)
         password2_entry = Entry(msg)
-        password2_entry.grid(row = 2, column = 1, pady = 2)
+        password2_entry.grid(row = 2, column = 1, pady = 2, sticky = W)
 
-        Label(msg, text='Ontology : ').grid(row = 3, column = 0)
+        Label(msg, text='Ontology : ').grid(row = 3, column = 0, sticky = W)
         ontology_entry = Entry(msg)
-        ontology_entry.grid(row = 3, column = 1, pady = 2)
+        ontology_entry.grid(row = 3, column = 1, pady = 2, sticky = W)
         ontology_entry.insert(0, self.ontology)
 
         Button(msg, text="Generate RSA key", \
             hashed_passwd = sha1_hash.hexdigest()
 
             self.client_agent.outgoing_message = "login:" + \
-                self.name.lower() + ":" + hashed_passwd
+                self.agent_name + ":" + hashed_passwd
 
             # send the answer to the authentication agent
             self.client_agent.addBehaviour(self.client_agent.SendMessageToAuthenticator(), None)
 
             msg.destroy()
 
+            self.load_rsa_keys()
+
         if self.client_agent == None:
             self.show_info('Not connected to the SPADE platform.')
             return
 
         msg = Toplevel(self.master)
-        msg.title('Login')
+        msg.title('Login - ' + self.user_name)
         msg.resizable(height = False, width = False)
 
         Label(msg, text='Enter your password : ').grid(row = 0, column = 0)
 
         for client in list_of_clients:
             if self.client_agent.getAID().getName() != client.getAID().getName():
+                name = client.getAID().getName().split('@')[0]
                 if client.getAID().getName() in self.client_agent.blocked_sender:
-                    self.listbox.insert(END, \
-                            client.getAID().getName() + " - Blocked")
+                    self.listbox.insert(END, name + " - Blocked")
                 else:
-                    self.listbox.insert(END, client.getAID().getName())
+                    self.listbox.insert(END, name)
 
 
         self.listbox.bind("<Double-Button-1>", self.connect_to_client)
         local_time = time.strftime(" [%H:%M:%S]: ", time.localtime())
 
         # set the outgoing message (plain text)
-        self.client_agent.outgoing_message = self.name + local_time + message
+        self.client_agent.outgoing_message = self.user_name + local_time + message
 
         # update the conversation zone
         self.update_conversation_zone("Me " + local_time + message)
         Load the RSA keys of the local client.
         """
         try:
-            keys = open("./security/keys" + self.name, "r")
+            keys = open("./security/keys" + self.user_name, "r")
             self.my_rsa_keys = pickle.load(keys)
             print "RSA keys loaded."
         except Exception , e:
         """
         rsa_key = rsa.RSA(nb_bits = 128)
 
-        with open("./security/keys" + self.name, "w") as pub_key:
+        with open("./security/keys" + self.user_name, "w") as pub_key:
             pickle.dump(rsa_key, pub_key)
 
     def clear_window(self):
                     help="Address of the SPADE platform")
 
 
-    parser.set_defaults(name = 'bob', \
+    parser.set_defaults(name = '', \
                         ontology = 'Chat', \
                         pub_key = '42', \
                         agent_host = '127.0.0.1')
Add a comment to this file

source/spade/user_db.xml

Binary file modified.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.