changeset 57:e552a67b933d

Contact update + add dedication in About dialog
author Goffi <goffi@goffi.org>
date Sun, 29 May 2011 16:07:46 +0200
parents 5fa710058e2d
children 4fa3d57f72f8
files browser_side/dialog.py browser_side/panels.py libervia.py libervia.tac
diffstat 4 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/dialog.py	Sun May 29 15:25:46 2011 +0200
+++ b/browser_side/dialog.py	Sun May 29 16:07:46 2011 +0200
@@ -226,7 +226,7 @@
         for group in _groups:
             self.list_box.addItem(group)
 
-    def setGroupsSelected(self, groups):
+    def setGroupsSelected(self, selected_groups):
         if groups:
             self.list_box.setItemTextSelection(selected_groups)
     
--- a/browser_side/panels.py	Sun May 29 15:25:46 2011 +0200
+++ b/browser_side/panels.py	Sun May 29 16:07:46 2011 +0200
@@ -112,6 +112,7 @@
 Project page: <a href="http://wiki.goffi.org/wiki/Salut_à_Toi"target="_blank">http://wiki.goffi.org/wiki/Salut_à_Toi</a><br />
 <br />
 Any help welcome :)
+<p style='font-size:x-small;text-align:center'>This project is dedicated to Roger Poisson</p>
 """)
         _dialog = dialog.GenericDialog("About", _about)
         _dialog.show()
@@ -137,7 +138,28 @@
         _dialog.show()
 
     def onUpdateContact(self):
-        pass
+        _dialog = None
+        _contacts_list = ListBox()
+
+        def updateContactCb(sender):
+            _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
+            self.host.bridge.call('updateContact', None, _jid, '', _dialog.getSelectedGroups())
+            print "contactUpdated"
+
+        def onContactChange(_list):
+            _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
+            groups = self.host.contact_panel.getContactGroups(_jid)
+            _dialog.setGroupsSelected(groups)
+
+        for contact in self.host.contact_panel.getContacts():
+            _contacts_list.addItem(contact)
+        _contacts_list.addChangeListener(onContactChange)
+        _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
+        _selected_groups = self.host.contact_panel.getContactGroups(_jid)
+        _dialog = dialog.GroupSelector([Label('Which contact do you want to update ?'), _contacts_list],
+                                       self.host.contact_panel.getGroups(), _selected_groups, updateContactCb)
+        _dialog.setHTML('<b>Updating contact</b>')
+        _dialog.show()
 
     def onRemoveContact(self):
         _dialog = None
--- a/libervia.py	Sun May 29 15:25:46 2011 +0200
+++ b/libervia.py	Sun May 29 16:07:46 2011 +0200
@@ -68,7 +68,7 @@
         LiberviaJsonProxy.__init__(self, "/json_api",
                         ["getContacts", "addContact", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus",
                          "joinMUC", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed",
-                         "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact"])
+                         "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact", "updateContact"])
 
 class BridgeSignals(LiberviaJsonProxy):
     def __init__(self):
--- a/libervia.tac	Sun May 29 15:25:46 2011 +0200
+++ b/libervia.tac	Sun May 29 16:07:46 2011 +0200
@@ -153,6 +153,11 @@
         profile = ISATSession(self.session).profile
         self.sat_host.bridge.delContact(entity, profile)
 
+    def jsonrpc_updateContact(self, entity, name, groups):
+        """Update contact's roster item"""
+        profile = ISATSession(self.session).profile
+        self.sat_host.bridge.updateContact(entity, name, groups, profile)
+
     def jsonrpc_subscription(self, sub_type, entity, name, groups):
         """Confirm (or infirm) subscription,
         and setup user roster in case of subscription"""