Mercurial > libervia-backend
annotate frontends/src/quick_frontend/quick_app.py @ 562:0bb2e0d1c878
core, plugin XEP-0054: avatar upload:
- plugin XEP-0054: new setAvatar bridge method
- new "presence_available" trigger
- new DataError
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 28 Dec 2012 01:00:31 +0100 |
parents | 97f6a445d6e8 |
children | ca13633d3b6b |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 helper class for making a SAT frontend | |
459 | 6 Copyright (C) 2009, 2010, 2011, 2012 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
479
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
0 | 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 | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
479
diff
changeset
|
16 GNU Affero General Public License for more details. |
0 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
479
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
0 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
22 from logging import debug, info, warning, error |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
23 from sat.tools.jid import JID |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
24 from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
25 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate |
91 | 26 from optparse import OptionParser |
0 | 27 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
28 import sat_frontends.quick_frontend.constants |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
29 |
70 | 30 import gettext |
31 gettext.install('sat_frontend', "../i18n", unicode=True) | |
32 | |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
33 class QuickApp(object): |
0 | 34 """This class contain the main methods needed for the frontend""" |
35 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
36 def __init__(self, single_profile=True): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
37 self.profiles = {} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
38 self.single_profile = single_profile |
91 | 39 self.check_options() |
0 | 40 |
41 ## bridge ## | |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
42 try: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
43 self.bridge=DBusBridgeFrontend() |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
44 except BridgeExceptionNoService: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
45 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
|
46 import sys |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
47 sys.exit(1) |
52 | 48 self.bridge.register("connected", self.connected) |
49 self.bridge.register("disconnected", self.disconnected) | |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
50 self.bridge.register("connectionError", self.connectionError) |
0 | 51 self.bridge.register("newContact", self.newContact) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
52 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
|
53 self.bridge.register("newAlert", self.newAlert) |
0 | 54 self.bridge.register("presenceUpdate", self.presenceUpdate) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
55 self.bridge.register("subscribe", self.subscribe) |
0 | 56 self.bridge.register("paramUpdate", self.paramUpdate) |
57 self.bridge.register("contactDeleted", self.contactDeleted) | |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
58 self.bridge.register("entityDataUpdated", self.entityDataUpdated) |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
59 self.bridge.register("askConfirmation", self.askConfirmation) |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
60 self.bridge.register("actionResult", self.actionResult) |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
61 self.bridge.register("actionResultExt", self.actionResult) |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
62 self.bridge.register("roomJoined", self.roomJoined, "plugin") |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
63 self.bridge.register("roomLeft", self.roomLeft, "plugin") |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
64 self.bridge.register("roomUserJoined", self.roomUserJoined, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
65 self.bridge.register("roomUserLeft", self.roomUserLeft, "plugin") |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
66 self.bridge.register("roomUserChangedNick", self.roomUserChangedNick, "plugin") |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
67 self.bridge.register("roomNewSubject", self.roomNewSubject, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
68 self.bridge.register("tarotGameStarted", self.tarotGameStarted, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
69 self.bridge.register("tarotGameNew", self.tarotGameNew, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
70 self.bridge.register("tarotGameChooseContrat", self.tarotChooseContrat, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
71 self.bridge.register("tarotGameShowCards", self.tarotShowCards, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
72 self.bridge.register("tarotGameYourTurn", self.tarotMyTurn, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
73 self.bridge.register("tarotGameScore", self.tarotScore, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
74 self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
75 self.bridge.register("tarotGameInvalidCards", self.tarotInvalidCards, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
76 self.bridge.register("quizGameStarted", self.quizGameStarted, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
77 self.bridge.register("quizGameNew", self.quizGameNew, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
78 self.bridge.register("quizGameQuestion", self.quizGameQuestion, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
79 self.bridge.register("quizGamePlayerBuzzed", self.quizGamePlayerBuzzed, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
80 self.bridge.register("quizGamePlayerSays", self.quizGamePlayerSays, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
81 self.bridge.register("quizGameAnswerResult", self.quizGameAnswerResult, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
82 self.bridge.register("quizGameTimerExpired", self.quizGameTimerExpired, "plugin") |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
83 self.bridge.register("quizGameTimerRestarted", self.quizGameTimerRestarted, "plugin") |
0 | 84 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
85 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
|
86 self.current_action_ids_cb = {} |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
362
diff
changeset
|
87 self.media_dir = self.bridge.getConfig('','media_dir') |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
88 |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
89 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
|
90 """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
|
91 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
|
92 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
93 def postInit(self): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
150
diff
changeset
|
94 """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
|
95 if self.options.profile: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
96 if not self.bridge.getProfileName(self.options.profile): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
97 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
|
98 else: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
99 self.plug_profile(self.options.profile) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
100 |
91 | 101 def check_options(self): |
102 """Check command line options""" | |
103 usage=_(""" | |
104 %prog [options] | |
105 | |
106 %prog --help for options list | |
107 """) | |
108 parser = OptionParser(usage=usage) | |
109 | |
110 parser.add_option("-p", "--profile", help=_("Select the profile to use")) | |
111 | |
112 (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
|
113 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
|
114 self.options.profile = self.options.profile.decode('utf-8') |
91 | 115 return args |
116 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
524
diff
changeset
|
117 def _getParamError(self, ignore): |
414
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
118 error(_("Can't get profile parameter")) |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
119 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
120 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
|
121 """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
|
122 if self.single_profile and self.profiles: |
70 | 123 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
|
124 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
125 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
|
126 if not profile: |
70 | 127 error(_("The profile asked doesn't exist")) |
68 | 128 return |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
129 if self.profiles.has_key(profile): |
70 | 130 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
|
131 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
132 self.profiles[profile]={} |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
133 if self.single_profile: |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
134 self.profile = profile |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
135 |
0 | 136 ###now we get the essential params### |
414
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
137 self.bridge.asyncGetParamA("JabberID","Connection", profile_key=profile, |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
138 callback=lambda _jid: self.plug_profile_2(_jid, profile), errback=self._getParamError) |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
139 |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
140 def plug_profile_2(self, _jid, profile): |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
141 self.profiles[profile]['whoami'] = JID(_jid) |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
142 self.bridge.asyncGetParamA("autoconnect","Connection", profile_key=profile, |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
143 callback=lambda value: self.plug_profile_3(value=="true", profile), errback=self._getParamError) |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
144 |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
145 def plug_profile_3(self, autoconnect, profile): |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
146 self.bridge.asyncGetParamA("Watched", "Misc", profile_key=profile, |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
147 callback=lambda watched: self.plug_profile_4(watched, autoconnect, profile), errback=self._getParamError) |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
148 |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
149 def plug_profile_4(self, watched, autoconnect, profile): |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
150 if autoconnect and not self.bridge.isConnected(profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
151 #Does the user want autoconnection ? |
561
97f6a445d6e8
quick frontend: asyncConnect is now used, to be sure that roster is available before continuing profile plugging
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
152 self.bridge.asyncConnect(profile, callback=lambda: self.plug_profile_5(watched, autoconnect, profile), errback=lambda ignore: error(_('Error during autoconnection'))) |
97f6a445d6e8
quick frontend: asyncConnect is now used, to be sure that roster is available before continuing profile plugging
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
153 else: |
97f6a445d6e8
quick frontend: asyncConnect is now used, to be sure that roster is available before continuing profile plugging
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
154 self.plug_profile_5(watched, autoconnect, profile) |
97f6a445d6e8
quick frontend: asyncConnect is now used, to be sure that roster is available before continuing profile plugging
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
155 |
97f6a445d6e8
quick frontend: asyncConnect is now used, to be sure that roster is available before continuing profile plugging
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
156 def plug_profile_5(self, watched, autoconnect, profile): |
414
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
157 self.profiles[profile]['watched'] = watched.split() #TODO: put this in a plugin |
0 | 158 |
159 ## misc ## | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
160 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary |
0 | 161 |
503
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
502
diff
changeset
|
162 #TODO: manage multi-profiles here |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
163 if not self.bridge.isConnected(profile): |
52 | 164 self.setStatusOnline(False) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
165 else: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
166 self.setStatusOnline(True) |
0 | 167 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
168 ### now we fill the contact list ### |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
169 for contact in self.bridge.getContacts(profile): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
170 self.newContact(*contact, profile=profile) |
0 | 171 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
172 presences = self.bridge.getPresenceStatus(profile) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
173 for contact in presences: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
174 for res in presences[contact]: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
175 jabber_id = contact+('/'+res if res else '') |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
176 show = presences[contact][res][0] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
177 priority = presences[contact][res][1] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
178 statuses = presences[contact][res][2] |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
179 self.presenceUpdate(jabber_id, show, priority, statuses, profile) |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
180 data = self.bridge.getEntityData(contact, ['avatar','nick'], profile) |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
181 for key in ('avatar', 'nick'): |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
182 if key in data: |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
183 self.entityDataUpdated(contact, key, data[key], profile) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
184 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
185 #The waiting subscription requests |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
186 waitingSub = self.bridge.getWaitingSub(profile) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
187 for sub in waitingSub: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
188 self.subscribe(waitingSub[sub], sub, profile) |
0 | 189 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
190 #Now we open the MUC window where we already are: |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
191 for room_args in self.bridge.getRoomsJoined(profile): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
192 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
|
193 |
479 | 194 for subject_args in self.bridge.getRoomsSubjects(profile): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
195 self.roomNewSubject(*subject_args, profile=profile) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
196 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
197 #Finaly, we get the waiting confirmation requests |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
198 for confirm_id, confirm_type, data in self.bridge.getWaitingConf(profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
199 self.askConfirmation(confirm_id, confirm_type, data, profile) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
200 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
201 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
76
diff
changeset
|
202 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
203 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
|
204 """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
|
205 if not profile in self.profiles: |
70 | 206 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
|
207 return |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
208 self.profiles.remove(profile) |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
209 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
210 def clear_profile(self): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
211 self.profiles.clear() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
212 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
213 def connected(self, profile): |
52 | 214 """called when the connection is made""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
215 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
|
216 return |
70 | 217 debug(_("Connected")) |
52 | 218 self.setStatusOnline(True) |
219 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
220 def disconnected(self, profile): |
52 | 221 """called when the connection is closed""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
222 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
|
223 return |
70 | 224 debug(_("Disconnected")) |
503
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
502
diff
changeset
|
225 self.contact_list.clearContacts() |
52 | 226 self.setStatusOnline(False) |
227 | |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
228 def connectionError(self, error_type, profile): |
262
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
229 """called when something goest wrong with the connection""" |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
230 if not self.check_profile(profile): |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
231 return |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
232 debug(_("Connection Error")) |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
233 self.disconnected(profile) |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
234 if error_type == "AUTH_ERROR": |
263
bfd01aed0a3a
added "please" in password error message
Goffi <goffi@goffi.org>
parents:
262
diff
changeset
|
235 self.showDialog(_("Can't connect to account, please check your password"), _("Connection error"), "error") |
262
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
236 else: |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
237 error(_('FIXME: error_type %s not implemented') % error_type) |
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
244
diff
changeset
|
238 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
239 def newContact(self, JabberId, attributes, groups, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
240 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
|
241 return |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
242 entity=JID(JabberId) |
347
ea3e1b82dd79
core: contact deletion from roster if we have no subscription to it (behaviour may change in futur)
Goffi <goffi@goffi.org>
parents:
344
diff
changeset
|
243 _groups = list(groups) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
244 self.contact_list.replace(entity, _groups, attributes) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
245 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
246 def _newMessage(self, from_jid_s, msg, _type, to_jid_s, extra, profile): |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
247 """newMessage premanagement: a dirty hack to manage private messages |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
248 if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
249 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
|
250 return |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
251 from_jid = JID(from_jid_s) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
252 to_jid = JID(to_jid_s) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
253 |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
254 from_me = from_jid.short == self.profiles[profile]['whoami'].short |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
255 win = to_jid if from_me else from_jid |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
256 |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
257 if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC": |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
258 #we have a private message in a MUC room |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
259 #XXX: normaly we use bare jid as key, here we need the full jid |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
260 # so we cheat by replacing the "/" before the resource by |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
261 # a "@", so the jid is invalid, |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
262 new_jid = escapePrivate(win) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
263 if from_me: |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
264 to_jid = new_jid |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
265 else: |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
266 from_jid = new_jid |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
267 if new_jid not in self.contact_list: |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
268 self.contact_list.add(new_jid) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
269 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
270 self.newMessage(from_jid, to_jid, msg, _type, extra, profile) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
271 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
272 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
273 from_me = from_jid.short == self.profiles[profile]['whoami'].short |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
274 win = to_jid if from_me else from_jid |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
275 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
276 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
|
277 self.current_action_ids_cb = {} |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
278 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
279 timestamp = extra.get('archive') |
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
280 self.chat_wins[win.short].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '') |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
281 |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
282 def sendMessage(self, to_jid, message, subject='', mess_type="auto", profile_key="@DEFAULT@"): |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
283 if to_jid.startswith(const_PRIVATE_PREFIX): |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
284 to_jid = unescapePrivate(to_jid) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
285 mess_type = "chat" |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
286 self.bridge.sendMessage(to_jid, message, subject, mess_type, profile_key) |
0 | 287 |
221
96186f36d8cb
bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
288 def newAlert(self, msg, title, alert_type, profile): |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
289 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
|
290 return |
221
96186f36d8cb
bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
291 assert alert_type in ['INFO','ERROR'] |
96186f36d8cb
bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
292 self.showDialog(unicode(msg),unicode(title),alert_type.lower()) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
293 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
294 |
0 | 295 def setStatusOnline(self, online=True): |
296 pass | |
297 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
298 def presenceUpdate(self, jabber_id, show, priority, statuses, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
299 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
|
300 return |
72 | 301 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
|
302 from_jid=JID(jabber_id) |
70 | 303 debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short}) |
0 | 304 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
305 if from_jid.short==self.profiles[profile]['whoami'].short: |
0 | 306 if not type: |
307 self.setStatusOnline(True) | |
308 elif type=="unavailable": | |
309 self.setStatusOnline(False) | |
310 return | |
311 | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
312 self.contact_list.updatePresence(from_jid, show, priority, statuses) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
313 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
314 if show != 'unavailable': |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
315 |
0 | 316 #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
|
317 if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']: |
70 | 318 self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short) |
0 | 319 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
320 self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
321 |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
322 #TODO: vcard data (avatar) |
0 | 323 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
324 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
|
325 self.profiles[profile]['onlineContact'].remove(from_jid) |
72 | 326 |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
327 def roomJoined(self, room_jid, room_nicks, user_nick, profile): |
72 | 328 """Called when a MUC room is joined""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
329 if not self.check_profile(profile): |
75 | 330 return |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
331 debug (_("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s") % {'room_jid':room_jid, 'profile': profile, 'users':room_nicks}) |
79 | 332 self.chat_wins[room_jid].setUserNick(user_nick) |
75 | 333 self.chat_wins[room_jid].setType("group") |
85 | 334 self.chat_wins[room_jid].id = room_jid |
124 | 335 self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks))) |
502
debcf5dd404a
QuickFrontend, Primitivus, Wix: special entities management:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
336 self.contact_list.setSpecial(JID(room_jid), "MUC") |
72 | 337 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
338 def roomLeft(self, room_jid_s, profile): |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
339 """Called when a MUC room is left""" |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
340 if not self.check_profile(profile): |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
341 return |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
342 debug (_("Room [%(room_jid)s] left by %(profile)s") % {'room_jid':room_jid_s, 'profile': profile}) |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
343 del self.chat_wins[room_jid_s] |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
344 self.contact_list.remove(JID(room_jid_s)) |
72 | 345 |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
346 def roomUserJoined(self, room_jid, user_nick, user_data, profile): |
75 | 347 """Called when an user joined a MUC room""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
348 if not self.check_profile(profile): |
75 | 349 return |
350 if self.chat_wins.has_key(room_jid): | |
351 self.chat_wins[room_jid].replaceUser(user_nick) | |
76 | 352 debug (_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid}) |
75 | 353 |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
354 def roomUserLeft(self, room_jid, user_nick, user_data, profile): |
75 | 355 """Called when an user joined a MUC room""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
356 if not self.check_profile(profile): |
75 | 357 return |
358 if self.chat_wins.has_key(room_jid): | |
359 self.chat_wins[room_jid].removeUser(user_nick) | |
76 | 360 debug (_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid}) |
361 | |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
362 def roomUserChangedNick(self, room_jid, old_nick, new_nick, profile): |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
363 """Called when an user joined a MUC room""" |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
364 if not self.check_profile(profile): |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
365 return |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
366 if self.chat_wins.has_key(room_jid): |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
367 self.chat_wins[room_jid].changeUserNick(old_nick, new_nick) |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
368 debug (_("user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]") % {'old_nick':old_nick, 'new_nick':new_nick, 'room_jid':room_jid}) |
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
369 |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
370 def roomNewSubject(self, room_jid, subject, profile): |
76 | 371 """Called when subject of MUC room change""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
372 if not self.check_profile(profile): |
76 | 373 return |
374 if self.chat_wins.has_key(room_jid): | |
375 self.chat_wins[room_jid].setSubject(subject) | |
376 debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject}) | |
85 | 377 |
90 | 378 def tarotGameStarted(self, room_jid, referee, players, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
379 if not self.check_profile(profile): |
85 | 380 return |
87 | 381 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
|
382 if self.chat_wins.has_key(room_jid): |
90 | 383 self.chat_wins[room_jid].startGame("Tarot", referee, players) |
384 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 | 385 |
386 def tarotGameNew(self, room_jid, hand, profile): | |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
387 if not self.check_profile(profile): |
87 | 388 return |
389 debug (_("New Tarot Game")) | |
390 if self.chat_wins.has_key(room_jid): | |
391 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
|
392 |
91 | 393 def tarotChooseContrat(self, room_jid, xml_data, profile): |
144
80661755ea8d
Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
394 """Called when the player has to select his contrat""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
395 if not self.check_profile(profile): |
91 | 396 return |
397 debug (_("Tarot: need to select a contrat")) | |
398 if self.chat_wins.has_key(room_jid): | |
399 self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data) | |
400 | |
92 | 401 def tarotShowCards(self, room_jid, game_stage, cards, data, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
402 if not self.check_profile(profile): |
92 | 403 return |
404 debug (_("Show cards")) | |
405 if self.chat_wins.has_key(room_jid): | |
406 self.chat_wins[room_jid].getGame("Tarot").showCards(game_stage, cards, data) | |
87 | 407 |
92 | 408 def tarotMyTurn(self, room_jid, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
409 if not self.check_profile(profile): |
92 | 410 return |
411 debug (_("My turn to play")) | |
412 if self.chat_wins.has_key(room_jid): | |
150 | 413 self.chat_wins[room_jid].getGame("Tarot").myTurn() |
93 | 414 |
95 | 415 def tarotScore(self, room_jid, xml_data, winners, loosers, profile): |
416 """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
|
417 if not self.check_profile(profile): |
95 | 418 return |
419 debug (_("Tarot: score received")) | |
420 if self.chat_wins.has_key(room_jid): | |
421 self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers) | |
422 | |
93 | 423 def tarotCardsPlayed(self, room_jid, player, cards, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
424 if not self.check_profile(profile): |
93 | 425 return |
426 debug (_("Card(s) played (%(player)s): %(cards)s") % {"player":player, "cards":cards}) | |
427 if self.chat_wins.has_key(room_jid): | |
428 self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards) | |
429 | |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
430 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
|
431 if not self.check_profile(profile): |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
432 return |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
433 debug (_("Cards played are not valid: %s") % invalid_cards) |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
434 if self.chat_wins.has_key(room_jid): |
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
435 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
|
436 |
361 | 437 def quizGameStarted(self, room_jid, referee, players, profile): |
438 if not self.check_profile(profile): | |
439 return | |
440 debug (_("Quiz Game Started \o/")) | |
441 if self.chat_wins.has_key(room_jid): | |
442 self.chat_wins[room_jid].startGame("Quiz", referee, players) | |
443 debug (_("new Quiz 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]}) | |
444 | |
445 def quizGameNew(self, room_jid, data, profile): | |
446 if not self.check_profile(profile): | |
447 return | |
448 debug (_("New Quiz Game")) | |
449 if self.chat_wins.has_key(room_jid): | |
450 self.chat_wins[room_jid].getGame("Quiz").quizGameNew(data) | |
451 | |
452 def quizGameQuestion(self, room_jid, question_id, question, timer, profile): | |
453 """Called when a new question is asked""" | |
454 if not self.check_profile(profile): | |
455 return | |
456 debug (_(u"Quiz: new question: %s") % question) | |
457 if self.chat_wins.has_key(room_jid): | |
458 self.chat_wins[room_jid].getGame("Quiz").quizGameQuestion(question_id, question, timer) | |
459 | |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
460 def quizGamePlayerBuzzed(self, room_jid, player, pause, profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
461 """Called when a player pushed the buzzer""" |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
462 if not self.check_profile(profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
463 return |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
464 if self.chat_wins.has_key(room_jid): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
465 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerBuzzed(player, pause) |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
466 |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
467 def quizGamePlayerSays(self, room_jid, player, text, delay, profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
468 """Called when a player say something""" |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
469 if not self.check_profile(profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
470 return |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
471 if self.chat_wins.has_key(room_jid): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
472 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerSays(player, text, delay) |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
473 |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
474 def quizGameAnswerResult(self, room_jid, player, good_answer, score, profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
475 """Called when a player say something""" |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
476 if not self.check_profile(profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
477 return |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
478 if self.chat_wins.has_key(room_jid): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
479 self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResult(player, good_answer, score) |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
480 |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
481 def quizGameTimerExpired(self, room_jid, profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
482 """Called when nobody answered the question in time""" |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
483 if not self.check_profile(profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
484 return |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
485 if self.chat_wins.has_key(room_jid): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
486 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerExpired() |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
487 |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
488 def quizGameTimerRestarted(self, room_jid, time_left, profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
489 """Called when the question is not answered, and we still have time""" |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
490 if not self.check_profile(profile): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
491 return |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
492 if self.chat_wins.has_key(room_jid): |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
493 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestarted(time_left) |
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
494 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 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
|
499 else: |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
500 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
|
501 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
502 def subscribe(self, type, raw_jid, profile): |
87 | 503 """Called when a subsciption management signal is received""" |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
504 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
|
505 return |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
506 entity = JID(raw_jid) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
507 if type=="subscribed": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
508 # this is a subscription confirmation, we just have to inform user |
70 | 509 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
|
510 elif type=="unsubscribed": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
511 # this is a subscription refusal, we just have to inform user |
70 | 512 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
|
513 elif type=="subscribe": |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
514 # 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
|
515 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 | 516 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
517 def showDialog(self, message, title, type="info", answer_cb = None): |
0 | 518 raise NotImplementedError |
519 | |
520 def showAlert(self, message): | |
521 pass #FIXME | |
522 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
523 def paramUpdate(self, name, value, namespace, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
524 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
|
525 return |
70 | 526 debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace':namespace, 'name':name, 'value':value}) |
0 | 527 if (namespace,name) == ("Connection", "JabberID"): |
70 | 528 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
|
529 self.profiles[profile]['whoami']=JID(value) |
0 | 530 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
|
531 self.profiles[profile]['watched']=value.split() |
0 | 532 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
533 def contactDeleted(self, jid, profile): |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
534 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
|
535 return |
0 | 536 target = JID(jid) |
503
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
502
diff
changeset
|
537 self.contact_list.remove(target) |
0 | 538 try: |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
539 self.profiles[profile]['onlineContact'].remove(target.short) |
0 | 540 except KeyError: |
541 pass | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
542 |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
543 def entityDataUpdated(self, jid_str, key, value, profile): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
544 if not self.check_profile(profile): |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
366
diff
changeset
|
545 return |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
546 jid = JID(jid_str) |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
547 if key == "nick": |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
548 if jid in self.contact_list: |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
549 self.contact_list.setCache(jid, 'nick', value) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
550 self.contact_list.replace(jid) |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
551 elif key == "avatar": |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
552 if jid in self.contact_list: |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
553 filename = self.bridge.getAvatarFile(value) |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
554 self.contact_list.setCache(jid, 'avatar', filename) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
555 self.contact_list.replace(jid) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
556 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
557 def askConfirmation(self, confirm_id, confirm_type, data, profile): |
0 | 558 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
|
559 |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
560 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
|
561 raise NotImplementedError |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
562 |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
563 def onExit(self): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
564 """Must be called when the frontend is terminating""" |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
565 #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
|
566 try: |
414
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
567 if self.bridge.isConnected(self.profile): |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
568 if self.bridge.getParamA("autodisconnect","Connection", profile_key=self.profile) == "true": |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
569 #The user wants autodisconnection |
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
570 self.bridge.disconnect(self.profile) |
200
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
571 except: |
7baee9bb37af
quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
572 pass |