From 5e47ab69eda6e54c5111ba4d3180617bf00ccab4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 6 Jun 2004 15:54:30 +0000 Subject: [PATCH] we can now set our priority --- core/core.py | 9 +- plugins/gtkgui/config.py | 23 ++- plugins/gtkgui/gtkgui.glade | 269 +++++++++++++++++++++++++++++++++++- plugins/gtkgui/gtkgui.py | 13 +- 4 files changed, 299 insertions(+), 15 deletions(-) diff --git a/core/core.py b/core/core.py index adbea7b5a..5c8d62c07 100644 --- a/core/core.py +++ b/core/core.py @@ -305,12 +305,11 @@ class GajimCore: con = self.connect(ev[1]) if self.connected[ev[1]]: #send our presence - p = common.jabber.Presence() - p.setShow(ev[2][0]) - p.setStatus(ev[2][1]) + type = 'available' if ev[2][0] == 'invisible': - p.setType('invisible') - con.send(p) + type = 'invisible' + prio = str(self.cfgParser.tab[ev[1]]['priority']) + con.sendPresence(type, prio, ev[2][0], ev[2][1]) self.hub.sendPlugin('STATUS', ev[1], ev[2][0]) #ask our VCard iq = common.jabber.Iq(type="get") diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index 68a4ebf36..b1b025c6d 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -354,6 +354,8 @@ class accountPreference_Window: self.xml.get_widget("entry_password").set_text(infos['password']) if infos.has_key('ressource'): self.xml.get_widget("entry_ressource").set_text(infos['ressource']) + if infos.has_key('priority'): + self.xml.get_widget("entry_priority").set_text(str(infos['priority'])) if infos.has_key('use_proxy'): self.xml.get_widget("checkbutton_proxy").set_active(infos['use_proxy']) if infos.has_key('proxyhost'): @@ -367,6 +369,8 @@ class accountPreference_Window: """When save button is clicked : Save informations in config file""" entryPass = self.xml.get_widget("entry_password") entryRessource = self.xml.get_widget("entry_ressource") + entryPriority = self.xml.get_widget("entry_priority") + prio = entryPriority.get_text() check = self.xml.get_widget("checkbutton") entryName = self.xml.get_widget("entry_name") entryJid = self.xml.get_widget("entry_jid") @@ -395,6 +399,12 @@ class accountPreference_Window: except ValueError: warning_Window(_("Proxy Port must be a port number")) return 0 + if prio != '': + try: + prio = string.atoi(prio) + except ValueError: + warning_Window(_("Priority must be a number")) + return 0 (login, hostname) = string.split(jid, '@') #if we are modifying an account if self.modify: @@ -419,8 +429,9 @@ class accountPreference_Window: self.plugin.send('ACC_CHG', self.account, name) self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ 'password': entryPass.get_text(), 'ressource': \ - entryRessource.get_text(), 'use_proxy': useProxy, 'proxyhost': \ - entryProxyhost.get_text(), 'proxyport': proxyPort} + entryRessource.get_text(), 'priority' : prio, 'use_proxy': \ + useProxy, 'proxyhost': entryProxyhost.get_text(), 'proxyport': \ + proxyPort} self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts)) #refresh accounts window if self.plugin.windows.has_key('accounts'): @@ -437,15 +448,15 @@ class accountPreference_Window: #if we neeed to register a new account if check.get_active(): self.plugin.send('NEW_ACC', None, (hostname, login, \ - entryPass.get_text(), name, entryRessource.get_text(), \ + entryPass.get_text(), name, entryRessource.get_text(), prio, \ checkProxy.get_active(), entryProxyhost.get_text(), \ entryProxyport.get_text())) check.set_active(FALSE) return self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ 'password': entryPass.get_text(), 'ressource': \ - entryRessource.get_text(), 'use_proxy': useProxy, 'proxyhost': \ - entryProxyhost.get_text(), 'proxyport': proxyPort} + entryRessource.get_text(), 'priority' : prio, 'use_proxy': useProxy, \ + 'proxyhost': entryProxyhost.get_text(), 'proxyport': proxyPort} self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts)) #update variables self.plugin.windows[name] = {'infos': {}, 'chats': {}} @@ -557,6 +568,8 @@ class accounts_Window: infos['password'] = self.plugin.accounts[account]["password"] if self.plugin.accounts[account].has_key("ressource"): infos['ressource'] = self.plugin.accounts[account]["ressource"] + if self.plugin.accounts[account].has_key("priority"): + infos['priority'] = self.plugin.accounts[account]["priority"] if self.plugin.accounts[account].has_key("use_proxy"): infos['use_proxy'] = self.plugin.accounts[account]["use_proxy"] if self.plugin.accounts[account].has_key("proxyhost"): diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index c1122586e..50c98277a 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -2,6 +2,7 @@ + True @@ -13,6 +14,11 @@ 300 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -333,6 +339,11 @@ 300 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -354,6 +365,7 @@ True True GTK_RELIEF_NORMAL + True @@ -363,6 +375,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -424,6 +440,7 @@ True True GTK_RELIEF_NORMAL + True @@ -433,6 +450,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -513,6 +534,7 @@ Anonymous <id@server/res> True GTK_RELIEF_NONE + True @@ -549,6 +571,8 @@ True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD False @@ -582,6 +606,8 @@ True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD True @@ -621,6 +647,11 @@ 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -676,6 +707,10 @@ 0.5 0 1 + 0 + 0 + 0 + 0 @@ -690,6 +725,7 @@ gtk-new True GTK_RELIEF_NORMAL + True @@ -707,6 +743,7 @@ gtk-delete True GTK_RELIEF_NORMAL + True @@ -722,6 +759,7 @@ False True GTK_RELIEF_NORMAL + True @@ -731,6 +769,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -807,6 +849,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -890,6 +937,10 @@ Yann Le Boulanger (asterix@crans.org) 0.5 0.2 1 + 0 + 0 + 0 + 0 @@ -898,6 +949,7 @@ Yann Le Boulanger (asterix@crans.org) gtk-close True GTK_RELIEF_NORMAL + True @@ -920,6 +972,11 @@ Yann Le Boulanger (asterix@crans.org) False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -997,7 +1054,7 @@ Yann Le Boulanger (asterix@crans.org) 5 True - 4 + 5 2 False 5 @@ -1145,6 +1202,7 @@ Yann Le Boulanger (asterix@crans.org) Register new account True GTK_RELIEF_NORMAL + True False False True @@ -1159,6 +1217,51 @@ Yann Le Boulanger (asterix@crans.org) + + + + True + Priority: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + True + True + True + 0 + 5 + True + * + False + + + 1 + 2 + 4 + 5 + + + False @@ -1412,6 +1515,7 @@ Yann Le Boulanger (asterix@crans.org) Use proxy True GTK_RELIEF_NORMAL + True False False True @@ -1565,6 +1669,7 @@ on the server. Edit personal details... True GTK_RELIEF_NORMAL + True @@ -1668,6 +1773,7 @@ on the server. gtk-save True GTK_RELIEF_NORMAL + True @@ -1680,6 +1786,7 @@ on the server. gtk-close True GTK_RELIEF_NORMAL + True @@ -1702,6 +1809,11 @@ on the server. False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -1808,6 +1920,8 @@ on the server. True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD True @@ -1875,6 +1989,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -1884,6 +1999,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -1943,6 +2062,7 @@ on the server. gtk-cancel True GTK_RELIEF_NORMAL + True @@ -1965,6 +2085,11 @@ on the server. False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -1986,6 +2111,7 @@ on the server. gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -1998,6 +2124,7 @@ on the server. gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -2045,6 +2172,11 @@ on the server. 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -2088,6 +2220,8 @@ on the server. True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD False @@ -2132,6 +2266,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2141,6 +2276,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2198,6 +2337,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2207,6 +2347,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2264,6 +2408,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2273,6 +2418,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2344,6 +2493,11 @@ on the server. 250 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -2404,6 +2558,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2413,6 +2568,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2470,6 +2629,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2479,6 +2639,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2550,6 +2714,11 @@ on the server. 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -2619,6 +2788,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2628,6 +2798,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2685,6 +2859,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -2694,6 +2869,10 @@ on the server. 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2763,6 +2942,11 @@ on the server. True True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -2784,6 +2968,7 @@ on the server. gtk-close True GTK_RELIEF_NORMAL + True -7 @@ -2859,6 +3044,11 @@ on the server. False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -2886,6 +3076,7 @@ on the server. True True GTK_RELIEF_HALF + True @@ -2942,6 +3133,7 @@ on the server. True True GTK_RELIEF_HALF + True @@ -2998,6 +3190,7 @@ on the server. True True GTK_RELIEF_HALF + True @@ -3244,6 +3437,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -3269,6 +3463,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -3294,6 +3489,7 @@ on the server. True True GTK_RELIEF_NORMAL + True @@ -3393,6 +3589,7 @@ on the server. messages True GTK_RELIEF_NORMAL + True False False True @@ -3413,6 +3610,7 @@ messages when NOT onlie True GTK_RELIEF_NORMAL + True False False True @@ -3432,6 +3630,7 @@ when NOT onlie checkbutton5 True GTK_RELIEF_NORMAL + True False False True @@ -3524,6 +3723,7 @@ when NOT onlie Auto Away After True GTK_RELIEF_NORMAL + True False False True @@ -3591,6 +3791,7 @@ when NOT onlie Auto eXtanded Away After True GTK_RELIEF_NORMAL + True False False True @@ -3743,6 +3944,7 @@ when NOT onlie gtk-cancel True GTK_RELIEF_NORMAL + True @@ -3755,6 +3957,7 @@ when NOT onlie gtk-ok True GTK_RELIEF_NORMAL + True @@ -3777,6 +3980,11 @@ when NOT onlie False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -3798,6 +4006,7 @@ when NOT onlie gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -3852,6 +4061,8 @@ when NOT onlie True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD True @@ -3948,6 +4159,11 @@ when NOT onlie False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -4402,6 +4618,7 @@ when NOT onlie Add -> True GTK_RELIEF_NORMAL + True @@ -4414,6 +4631,7 @@ when NOT onlie <- Remove True GTK_RELIEF_NORMAL + True @@ -5332,6 +5550,8 @@ when NOT onlie True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE False @@ -5390,6 +5610,7 @@ when NOT onlie gtk-close True GTK_RELIEF_NORMAL + True @@ -5412,6 +5633,11 @@ when NOT onlie False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -6266,6 +6492,8 @@ when NOT onlie True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True @@ -6323,6 +6551,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6332,6 +6561,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6389,6 +6622,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6398,6 +6632,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6455,6 +6693,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6464,6 +6703,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6535,6 +6778,11 @@ when NOT onlie 350 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -6556,6 +6804,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6565,6 +6814,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6622,6 +6875,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6631,6 +6885,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6690,6 +6948,7 @@ when NOT onlie gtk-go-forward True GTK_RELIEF_NORMAL + True @@ -6700,6 +6959,7 @@ when NOT onlie True True GTK_RELIEF_NORMAL + True @@ -6709,6 +6969,10 @@ when NOT onlie 0.5 0 0 + 0 + 0 + 0 + 0 @@ -6768,6 +7032,7 @@ when NOT onlie gtk-close True GTK_RELIEF_NORMAL + True @@ -6793,6 +7058,8 @@ when NOT onlie True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 8babe0125..bc175ec21 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -690,6 +690,8 @@ class roster_Window: infos['password'] = self.plugin.accounts[account]["password"] if self.plugin.accounts[account].has_key("ressource"): infos['ressource'] = self.plugin.accounts[account]["ressource"] + if self.plugin.accounts[account].has_key("priority"): + infos['priority'] = self.plugin.accounts[account]["priority"] if self.plugin.accounts[account].has_key("use_proxy"): infos['use_proxy'] = self.plugin.accounts[account]["use_proxy"] if self.plugin.accounts[account].has_key("proxyhost"): @@ -1280,7 +1282,7 @@ class plugin: #It must be an agent if not self.roster.contacts[ev[1]].has_key(ji): user1 = user(ji, ji, ['Agents'], ev[2][1], \ - ev[2][2], 'from', resource) + ev[2][2], 'from', resource, 0) self.roster.contacts[ev[1]][ji] = [user1] self.roster.add_user_to_roster(ji, ev[1]) else: @@ -1328,10 +1330,13 @@ class plugin: warning_Window(_("error contacting %s") % ev[2][0]) else: agentRegistration_Window(ev[2][0], ev[2][1], self, ev[1]) - #('ACC_OK', account, (hostname, login, pasword, name, ressource)) + #('ACC_OK', account, (hostname, login, pasword, name, ressource, prio, + #use_proxy, proxyhost, proxyport)) elif ev[0] == 'ACC_OK': - self.accounts[ev[2][3]] = {'ressource': ev[2][4], \ - 'password': ev[2][2], 'hostname': ev[2][0], 'name': ev[2][1]} + self.accounts[ev[2][3]] = {'name': ev[2][1], 'hostname': ev[2][0],\ + 'password': ev[2][2], 'ressource': ev[2][4], 'priority': \ + ev[2][5], 'use_proxy': ev[2][6], 'proxyhost': ev[2][7], \ + 'proxyport': ev[2][8]} self.send('CONFIG', None, ('accounts', self.accounts)) self.windows[name] = {'infos': {}, 'chats': {}} self.queues[name] = {}