Mercurial > libervia-backend
annotate frontends/quick_frontend/quick_app.py @ 215:370f387a43c0
primitivus: fixed misnamed method in custom widget
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Dec 2010 17:22:32 +0100 |
parents | 7baee9bb37af |
children | 96186f36d8cb |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 helper class for making a SAT frontend | |
57 | 6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 from logging import debug, info, error | |
23 from tools.jid import JID | |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
24 from sat_bridge_frontend.DBus import DBusBridgeFrontend,BridgeExceptionNoService |
91 | 25 from optparse import OptionParser |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
26 import pdb |
0 | 27 |
70 | 28 import gettext |
29 gettext.install('sat_frontend', "../i18n", unicode=True) | |
30 | |
0 | 31 class QuickApp(): |
32 """This class contain the main methods needed for the frontend""" | |
33 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
34 def __init__(self, single_profile=True): |
0 | 35 self.rosterList = {} |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
36 self.profiles = {} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
37 self.single_profile = single_profile |
91 | 38 self.check_options() |
0 | 39 |
40 ## bridge ## | |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
41 try: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
42 self.bridge=DBusBridgeFrontend() |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
43 except BridgeExceptionNoService: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
44 print(_(u"Can't connect to SàT backend, are you sure it's launched ?")) |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
45 import sys |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
46 sys.exit(1) |
52 | 47 self.bridge.register("connected", self.connected) |
48 self.bridge.register("disconnected", self.disconnected) | |
0 | 49 self.bridge.register("newContact", self.newContact) |
50 self.bridge.register("newMessage", self.newMessage) | |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
51 self.bridge.register("newAlert", self.newAlert) |
0 | 52 self.bridge.register("presenceUpdate", self.presenceUpdate) |
72 | 53 self.bridge.register("roomJoined", self.roomJoined) |
75 | 54 self.bridge.register("roomUserJoined", self.roomUserJoined) |
55 self.bridge.register("roomUserLeft", self.roomUserLeft) | |
76 | 56 self.bridge.register("roomNewSubject", self.roomNewSubject) |
85 | 57 self.bridge.register("tarotGameStarted", self.tarotGameStarted) |
87 | 58 self.bridge.register("tarotGameNew", self.tarotGameNew) |
92 | 59 self.bridge.register("tarotGameChooseContrat", self.tarotChooseContrat) |
60 self.bridge.register("tarotGameShowCards", self.tarotShowCards) | |
61 self.bridge.register("tarotGameYourTurn", self.tarotMyTurn) | |
95 | 62 self.bridge.register("tarotGameScore", self.tarotScore) |
93 | 63 self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed) |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
64 self.bridge.register("tarotGameInvalidCards", self.tarotInvalidCards) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
65 self.bridge.register("subscribe", self.subscribe) |
0 | 66 self.bridge.register("paramUpdate", self.paramUpdate) |
67 self.bridge.register("contactDeleted", self.contactDeleted) | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
68 self.bridge.register("updatedValue", self.updatedValue, "request") |
0 | 69 self.bridge.register("askConfirmation", self.askConfirmation, "request") |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
70 self.bridge.register("actionResult", self.actionResult, "request") |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
71 self.bridge.register("actionResultExt", self.actionResult, "request") |
0 | 72 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
73 self.current_action_ids = set() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
74 self.current_action_ids_cb = {} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
75 |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
76 def check_profile(self, profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
77 """Tell if the profile is currently followed by the application""" |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
78 return profile in self.profiles.keys() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
79 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
80 def postInit(self): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
150
diff
changeset
|
81 """Must be called after initialization is done, do all automatic task (auto plug profile)""" |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
82 if self.options.profile: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
83 if not self.bridge.getProfileName(self.options.profile): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
84 error(_("Trying to plug an unknown profile (%s)" % self.options.profile)) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
85 else: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
86 self.plug_profile(self.options.profile) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
87 |
91 | 88 def check_options(self): |
89 """Check command line options""" | |
90 usage=_(""" | |
91 %prog [options] | |
92 | |
93 %prog --help for options list | |
94 """) | |
95 parser = OptionParser(usage=usage) | |
96 | |
97 parser.add_option("-p", "--profile", help=_("Select the profile to use")) | |
98 | |
99 (self.options, args) = parser.parse_args() | |
132
a86607e5cf38
quick_app: self.occupants for group chat are now managed by quick_chat. self.options.profile now support unicode
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
100 if self.options.profile: |
a86607e5cf38
quick_app: self.occupants for group chat are now managed by quick_chat. self.options.profile now support unicode
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
101 self.options.profile = self.options.profile.decode('utf-8') |
91 | 102 return args |
103 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
104 def plug_profile(self, profile_key='@DEFAULT@'): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
105 """Tell application which profile must be used""" |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
106 if self.single_profile and self.profiles: |
70 | 107 error(_('There is already one profile plugged (we are in single profile mode) !')) |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
108 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
109 profile = self.bridge.getProfileName(profile_key) |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
110 if not profile: |
70 | 111 error(_("The profile asked doesn't exist")) |
68 | 112 return |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
113 if self.profiles.has_key(profile): |
70 | 114 warning(_("The profile is already plugged")) |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
115 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
116 self.profiles[profile]={} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
117 if self.single_profile: |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
118 self.profile = profile |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
119 |
0 | 120 ###now we get the essential params### |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
121 self.profiles[profile]['whoami']=JID(self.bridge.getParamA("JabberID","Connection", profile)) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
122 autoconnect = self.bridge.getParamA("autoconnect","Connection", profile) == "true" |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
123 self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile).split() #TODO: put this in a plugin |
0 | 124 |
125 ## misc ## | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
126 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary |
0 | 127 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
128 #TODO: gof: manage multi-profiles here |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
129 if not self.bridge.isConnected(profile): |
52 | 130 self.setStatusOnline(False) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
131 else: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
132 self.setStatusOnline(True) |
0 | 133 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
134 ### now we fill the contact list ### |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
135 for contact in self.bridge.getContacts(profile): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
136 self.newContact(contact[0], contact[1], contact[2], profile) |
0 | 137 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
138 presences = self.bridge.getPresenceStatus(profile) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
139 for contact in presences: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
140 for res in presences[contact]: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
141 jabber_id = contact+('/'+res if res else '') |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
142 show = presences[contact][res][0] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
143 priority = presences[contact][res][1] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
144 statuses = presences[contact][res][2] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
145 self.presenceUpdate(jabber_id, show, priority, statuses, profile) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
146 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
147 #The waiting subscription requests |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
148 waitingSub = self.bridge.getWaitingSub(profile) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
149 for sub in waitingSub: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
150 self.subscribe(waitingSub[sub], sub, profile) |
0 | 151 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
152 #Now we open the MUC window where we already are: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
153 for room_args in self.bridge.getRoomJoined(profile): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
154 self.roomJoined(*room_args, profile=profile) |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
76
diff
changeset
|
155 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
156 for subject_args in self.bridge.getRoomSubjects(profile): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
157 self.roomNewSubject(*subject_args, profile=profile) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
158 |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
159 if autoconnect and not self.bridge.isConnected(profile_key): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
160 #Does the user want autoconnection ? |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
161 self.bridge.connect(profile_key) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
162 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
76
diff
changeset
|
163 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
164 def unplug_profile(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
165 """Tell the application to not follow anymore the profile""" |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
166 if not profile in self.profiles: |
70 | 167 warning (_("This profile is not plugged")) |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
168 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
169 self.profiles.remove(profile) |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
170 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
171 def clear_profile(self): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
172 self.profiles.clear() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
173 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
174 def connected(self, profile): |
52 | 175 """called when the connection is made""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
176 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
177 return |
70 | 178 debug(_("Connected")) |
52 | 179 self.setStatusOnline(True) |
91 | 180 |
52 | 181 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
182 def disconnected(self, profile): |
52 | 183 """called when the connection is closed""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
184 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
185 return |
70 | 186 debug(_("Disconnected")) |
52 | 187 self.CM.clear() |
188 self.contactList.clear_contacts() | |
189 self.setStatusOnline(False) | |
190 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
191 def newContact(self, JabberId, attributes, groups, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
192 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
193 return |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
194 entity=JID(JabberId) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
195 self.rosterList[entity.short]=(dict(attributes), list(groups)) |
0 | 196 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
197 def newMessage(self, from_jid, msg, type, to_jid, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
198 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
199 return |
0 | 200 sender=JID(from_jid) |
201 addr=JID(to_jid) | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
202 win = addr if sender.short == self.profiles[profile]['whoami'].short else sender |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
203 self.current_action_ids = set() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
204 self.current_action_ids_cb = {} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
205 self.chat_wins[win.short].printMessage(sender, msg, profile) |
0 | 206 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
207 def newAlert(self, msg, title, type, profile): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
208 if not self.check_profile(profile): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
209 return |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
210 assert type in ['INFO','ERROR'] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
211 self.showDialog(unicode(msg),unicode(title),type.lower()) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
212 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
213 |
0 | 214 def setStatusOnline(self, online=True): |
215 pass | |
216 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
217 def presenceUpdate(self, jabber_id, show, priority, statuses, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
218 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
219 return |
72 | 220 debug (_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") % {'jid':jabber_id, 'show':show, 'priority':priority, 'statuses':statuses, 'profile':profile}); |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
221 from_jid=JID(jabber_id) |
70 | 222 debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short}) |
0 | 223 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
224 if from_jid.short==self.profiles[profile]['whoami'].short: |
0 | 225 if not type: |
226 self.setStatusOnline(True) | |
227 elif type=="unavailable": | |
228 self.setStatusOnline(False) | |
229 return | |
230 | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
231 if show != 'unavailable': |
0 | 232 name="" |
53
6dfe5bb10008
Wix: groups in contact list, first draft
Goffi <goffi@goffi.org>
parents:
52
diff
changeset
|
233 groups = [] |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
234 if self.rosterList.has_key(from_jid.short): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
235 if self.rosterList[from_jid.short][0].has_key("name"): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
236 name=self.rosterList[from_jid.short][0]["name"] |
53
6dfe5bb10008
Wix: groups in contact list, first draft
Goffi <goffi@goffi.org>
parents:
52
diff
changeset
|
237 groups=self.rosterList[from_jid.short][1] |
0 | 238 |
239 #FIXME: must be moved in a plugin | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
240 if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']: |
70 | 241 self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short) |
0 | 242 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
243 self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
244 self.CM.add(from_jid) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
245 self.CM.update(from_jid, 'name', name) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
246 self.CM.update(from_jid, 'show', show) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
247 self.CM.update(from_jid, 'statuses', statuses) |
53
6dfe5bb10008
Wix: groups in contact list, first draft
Goffi <goffi@goffi.org>
parents:
52
diff
changeset
|
248 self.CM.update(from_jid, 'groups', groups) |
64 | 249 cache = self.bridge.getCardCache(from_jid) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
250 if cache.has_key('nick'): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
251 self.CM.update(from_jid, 'nick', cache['nick']) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
252 if cache.has_key('avatar'): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
253 self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar'])) |
72 | 254 self.contactList.replace(from_jid, self.CM.getAttr(from_jid, 'groups')) |
0 | 255 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
256 if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']: |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
257 self.profiles[profile]['onlineContact'].remove(from_jid) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
258 self.CM.remove(from_jid) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
259 if not self.CM.isConnected(from_jid): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
260 self.contactList.disconnect(from_jid) |
72 | 261 |
262 def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile): | |
263 """Called when a MUC room is joined""" | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
264 if not self.check_profile(profile): |
75 | 265 return |
266 debug (_("Room [%(room_name)s] joined by %(profile)s, users presents:%(users)s") % {'room_name':room_id+'@'+room_service, 'profile': profile, 'users':room_nicks}) | |
267 room_jid=room_id+'@'+room_service | |
79 | 268 self.chat_wins[room_jid].setUserNick(user_nick) |
75 | 269 self.chat_wins[room_jid].setType("group") |
85 | 270 self.chat_wins[room_jid].id = room_jid |
124 | 271 self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks))) |
72 | 272 |
273 | |
75 | 274 def roomUserJoined(self, room_id, room_service, user_nick, user_data, profile): |
275 """Called when an user joined a MUC room""" | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
276 if not self.check_profile(profile): |
75 | 277 return |
278 room_jid=room_id+'@'+room_service | |
279 if self.chat_wins.has_key(room_jid): | |
280 self.chat_wins[room_jid].replaceUser(user_nick) | |
76 | 281 debug (_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid}) |
75 | 282 |
283 def roomUserLeft(self, room_id, room_service, user_nick, user_data, profile): | |
284 """Called when an user joined a MUC room""" | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
285 if not self.check_profile(profile): |
75 | 286 return |
287 room_jid=room_id+'@'+room_service | |
288 if self.chat_wins.has_key(room_jid): | |
289 self.chat_wins[room_jid].removeUser(user_nick) | |
76 | 290 debug (_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid}) |
291 | |
292 def roomNewSubject(self, room_id, room_service, subject, profile): | |
293 """Called when subject of MUC room change""" | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
294 if not self.check_profile(profile): |
76 | 295 return |
296 room_jid=room_id+'@'+room_service | |
297 if self.chat_wins.has_key(room_jid): | |
298 self.chat_wins[room_jid].setSubject(subject) | |
299 debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject}) | |
85 | 300 |
90 | 301 def tarotGameStarted(self, room_jid, referee, players, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
302 if not self.check_profile(profile): |
85 | 303 return |
87 | 304 debug (_("Tarot Game Started \o/")) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
305 if self.chat_wins.has_key(room_jid): |
90 | 306 self.chat_wins[room_jid].startGame("Tarot", referee, players) |
307 debug (_("new Tarot game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee':referee, 'room_jid':room_jid, 'players':[str(player) for player in players]}) | |
87 | 308 |
309 def tarotGameNew(self, room_jid, hand, profile): | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
310 if not self.check_profile(profile): |
87 | 311 return |
312 debug (_("New Tarot Game")) | |
313 if self.chat_wins.has_key(room_jid): | |
314 self.chat_wins[room_jid].getGame("Tarot").newGame(hand) | |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
315 |
91 | 316 def tarotChooseContrat(self, room_jid, xml_data, profile): |
144
80661755ea8d
Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
317 """Called when the player has to select his contrat""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
318 if not self.check_profile(profile): |
91 | 319 return |
320 debug (_("Tarot: need to select a contrat")) | |
321 if self.chat_wins.has_key(room_jid): | |
322 self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data) | |
323 | |
92 | 324 def tarotShowCards(self, room_jid, game_stage, cards, data, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
325 if not self.check_profile(profile): |
92 | 326 return |
327 debug (_("Show cards")) | |
328 if self.chat_wins.has_key(room_jid): | |
329 self.chat_wins[room_jid].getGame("Tarot").showCards(game_stage, cards, data) | |
87 | 330 |
92 | 331 def tarotMyTurn(self, room_jid, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
332 if not self.check_profile(profile): |
92 | 333 return |
334 debug (_("My turn to play")) | |
335 if self.chat_wins.has_key(room_jid): | |
150 | 336 self.chat_wins[room_jid].getGame("Tarot").myTurn() |
93 | 337 |
95 | 338 def tarotScore(self, room_jid, xml_data, winners, loosers, profile): |
339 """Called when the game is finished and the score are updated""" | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
340 if not self.check_profile(profile): |
95 | 341 return |
342 debug (_("Tarot: score received")) | |
343 if self.chat_wins.has_key(room_jid): | |
344 self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers) | |
345 | |
93 | 346 def tarotCardsPlayed(self, room_jid, player, cards, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
347 if not self.check_profile(profile): |
93 | 348 return |
349 debug (_("Card(s) played (%(player)s): %(cards)s") % {"player":player, "cards":cards}) | |
350 if self.chat_wins.has_key(room_jid): | |
351 self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards) | |
352 | |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
353 def tarotInvalidCards(self, room_jid, phase, played_cards, invalid_cards, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
354 if not self.check_profile(profile): |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
355 return |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
356 debug (_("Cards played are not valid: %s") % invalid_cards) |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
357 if self.chat_wins.has_key(room_jid): |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
358 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
359 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
360 def _subscribe_cb(self, answer, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
361 entity, profile = data |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
362 if answer: |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
363 self.bridge.subscription("subscribed", entity.short, profile_key = profile) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
364 else: |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
365 self.bridge.subscription("unsubscribed", entity.short, profile_key = profile) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
366 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
367 def subscribe(self, type, raw_jid, profile): |
87 | 368 """Called when a subsciption management signal is received""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
369 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
370 return |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
371 entity = JID(raw_jid) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
372 if type=="subscribed": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
373 # this is a subscription confirmation, we just have to inform user |
70 | 374 self.showDialog(_("The contact %s has accepted your subscription") % entity.short, _('Subscription confirmation')) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
375 elif type=="unsubscribed": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
376 # this is a subscription refusal, we just have to inform user |
70 | 377 self.showDialog(_("The contact %s has refused your subscription") % entity.short, _('Subscription refusal'), 'error') |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
378 elif type=="subscribe": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
379 # this is a subscriptionn request, we have to ask for user confirmation |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
380 answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no', answer_cb = self._subscribe_cb, answer_data=(entity, profile)) |
0 | 381 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
382 def showDialog(self, message, title, type="info", answer_cb = None): |
0 | 383 raise NotImplementedError |
384 | |
385 def showAlert(self, message): | |
386 pass #FIXME | |
387 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
388 def paramUpdate(self, name, value, namespace, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
389 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
390 return |
70 | 391 debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace':namespace, 'name':name, 'value':value}) |
0 | 392 if (namespace,name) == ("Connection", "JabberID"): |
70 | 393 debug (_("Changing JID to %s"), value) |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
394 self.profiles[profile]['whoami']=JID(value) |
0 | 395 elif (namespace,name) == ("Misc", "Watched"): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
396 self.profiles[profile]['watched']=value.split() |
0 | 397 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
398 def contactDeleted(self, jid, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
399 if not self.check_profile(profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
400 return |
0 | 401 target = JID(jid) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
402 self.CM.remove(target) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
403 self.contactList.remove(self.CM.get_full(target)) |
0 | 404 try: |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
405 self.profiles[profile]['onlineContact'].remove(target.short) |
0 | 406 except KeyError: |
407 pass | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
408 |
71
efe81b61673c
quick app: updatedValue wrong parameter fix
Goffi <goffi@goffi.org>
parents:
70
diff
changeset
|
409 def updatedValue(self, name, data): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
410 if name == "card_nick": |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
411 target = JID(data['jid']) |
124 | 412 if target in self.contactList: |
413 self.CM.update(target, 'nick', data['nick']) | |
414 self.contactList.replace(target) | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
415 elif name == "card_avatar": |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
416 target = JID(data['jid']) |
124 | 417 if target in self.contactList: |
418 filename = self.bridge.getAvatarFile(data['avatar']) | |
419 self.CM.update(target, 'avatar', filename) | |
420 self.contactList.replace(target) | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
421 |
0 | 422 def askConfirmation(self, type, id, data): |
423 raise NotImplementedError | |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
424 |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
425 def actionResult(self, type, id, data): |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
426 raise NotImplementedError |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
427 |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
428 def onExit(self): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
429 """Must be called when the frontend is terminating""" |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
430 #TODO: mange multi-profile here |
200
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
431 try: |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
432 autodisconnect = self.bridge.getParamA("autodisconnect","Connection", self.profile) == "true" |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
433 if autodisconnect and self.bridge.isConnected(self.profile): |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
434 #Does the user want autodisconnection ? |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
435 self.bridge.disconnect(self.profile) |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
436 except: |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
437 pass |