annotate frontends/src/quick_frontend/quick_app.py @ 1103:a096b8579a3c

frontends: signals are managed in a more generic way
author Goffi <goffi@goffi.org>
date Mon, 11 Aug 2014 19:10:24 +0200
parents 11e2bb20e896
children 6053fb8a6466
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
4 # helper class for making a SAT frontend
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 776
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
10 # (at your option) any later version.
0
goffi@necton2
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
15 # GNU Affero General Public License for more details.
0
goffi@necton2
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
goffi@necton2
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 767
diff changeset
20 from sat.core.i18n import _
627
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
21 import sys
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
22 from sat.core.log import getLogger
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
23 log = getLogger(__name__)
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents: 223
diff changeset
24 from sat.tools.jid import JID
627
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
25 from sat_frontends.bridge.DBus import DBusBridgeFrontend
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
26 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
27 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
28 from optparse import OptionParser
0
goffi@necton2
parents:
diff changeset
29
1019
6a16ec17a458 better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
30 from sat_frontends.quick_frontend.constants import Const as C
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
31
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
32
524
0bb595eff25b primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents: 513
diff changeset
33 class QuickApp(object):
0
goffi@necton2
parents:
diff changeset
34 """This class contain the main methods needed for the frontend"""
goffi@necton2
parents:
diff changeset
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
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
39 self.check_options()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
40
0
goffi@necton2
parents:
diff changeset
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:
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
43 self.bridge = DBusBridgeFrontend()
165
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 ?"))
627
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
46 sys.exit(1)
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
47 except BridgeInitError:
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
48 print(_(u"Can't init bridge"))
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 159
diff changeset
49 sys.exit(1)
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
50 self.registerSignal("connected")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
51 self.registerSignal("disconnected")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
52 self.registerSignal("newContact")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
53 self.registerSignal("newMessage", self._newMessage)
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
54 self.registerSignal("newAlert")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
55 self.registerSignal("presenceUpdate")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
56 self.registerSignal("subscribe")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
57 self.registerSignal("paramUpdate")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
58 self.registerSignal("contactDeleted")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
59 self.registerSignal("entityDataUpdated")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
60 self.registerSignal("askConfirmation")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
61 self.registerSignal("actionResult")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
62 self.registerSignal("actionResultExt", self.actionResultHandler)
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
63 self.registerSignal("roomJoined", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
64 self.registerSignal("roomLeft", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
65 self.registerSignal("roomUserJoined", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
66 self.registerSignal("roomUserLeft", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
67 self.registerSignal("roomUserChangedNick", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
68 self.registerSignal("roomNewSubject", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
69 self.registerSignal("tarotGameStarted", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
70 self.registerSignal("tarotGameNew", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
71 self.registerSignal("tarotGameChooseContrat", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
72 self.registerSignal("tarotGameShowCards", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
73 self.registerSignal("tarotGameYourTurn", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
74 self.registerSignal("tarotGameScore", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
75 self.registerSignal("tarotGameCardsPlayed", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
76 self.registerSignal("tarotGameInvalidCards", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
77 self.registerSignal("quizGameStarted", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
78 self.registerSignal("quizGameNew", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
79 self.registerSignal("quizGameQuestion", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
80 self.registerSignal("quizGamePlayerBuzzed", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
81 self.registerSignal("quizGamePlayerSays", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
82 self.registerSignal("quizGameAnswerResult", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
83 self.registerSignal("quizGameTimerExpired", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
84 self.registerSignal("quizGameTimerRestarted", iface="plugin")
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
85 self.registerSignal("chatStateReceived", iface="plugin")
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
86
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
87 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
88 self.current_action_ids_cb = {}
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
89 self.media_dir = self.bridge.getConfig('', 'media_dir')
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
90
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
91 def registerSignal(self, functionName, handler=None, iface="core"):
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
92 """Register a handler for a signal
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
93
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
94 @param functionName: name of the signal to handle
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
95 @param handler: method to call when the signal arrive, None for calling an automaticaly named handler (functionName + 'Handler')
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
96 @param iface: interface of the bridge to use
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
97
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
98 """
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
99 if handler is None:
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
100 handler = getattr(self, "%s%s" % (functionName, 'Handler'))
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
101 def signalReceived(*args, **kwargs):
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
102 profile = kwargs.get('profile', None)
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
103 if profile is not None and not self.check_profile(profile):
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
104 return # we ignore signal for profiles we don't manage
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
105 handler(*args, **kwargs)
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
106 self.bridge.register(functionName, signalReceived, iface)
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
107
125
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
108 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
109 """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
110 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
111
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 117
diff changeset
112 def postInit(self):
159
2fa58703f1b7 Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents: 150
diff changeset
113 """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
114 if self.options.profile:
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
115 if not self.bridge.getProfileName(self.options.profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
116 log.error(_("Trying to plug an unknown profile (%s)" % self.options.profile))
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 117
diff changeset
117 else:
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 117
diff changeset
118 self.plug_profile(self.options.profile)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 117
diff changeset
119
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
120 def check_options(self):
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
121 """Check command line options"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
122 usage = _("""
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
123 %prog [options]
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
124
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
125 %prog --help for options list
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
126 """)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
127 parser = OptionParser(usage=usage)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
128
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
129 parser.add_option("-p", "--profile", help=_("Select the profile to use"))
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
130
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
131 (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
132 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
133 self.options.profile = self.options.profile.decode('utf-8')
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
134 return args
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
135
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 524
diff changeset
136 def _getParamError(self, ignore):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
137 log.error(_("Can't get profile parameter"))
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
138
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
139 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
140 """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
141 if self.single_profile and self.profiles:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
142 log.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
143 return
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
144 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
145 if not profile:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
146 log.error(_("The profile asked doesn't exist"))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
147 return
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
148 if profile in self.profiles:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
149 log.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
150 return
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
151 self.profiles[profile] = {}
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
152 if self.single_profile:
1093
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
153 self.profile = profile # FIXME: must be refactored (multi profiles are not managed correclty)
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
154 raw_menus = self.bridge.getMenus("", C.NO_SECURITY_LIMIT )
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
155 menus = self.profiles[profile]['menus'] = {}
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
156 for raw_menu in raw_menus:
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
157 id_, type_, path, path_i18n = raw_menu
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
158 menus_data = menus.setdefault(type_, [])
11e2bb20e896 core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
159 menus_data.append((id_, path, path_i18n))
1034
5197600a1e13 quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents: 1019
diff changeset
160 self.launchAction(C.AUTHENTICATE_PROFILE_ID, {'caller': 'plug_profile'}, profile_key=profile)
5197600a1e13 quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents: 1019
diff changeset
161
5197600a1e13 quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents: 1019
diff changeset
162 def plug_profile_1(self, profile):
0
goffi@necton2
parents:
diff changeset
163 ###now we get the essential params###
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
164 self.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile,
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
165 callback=lambda _jid: self.plug_profile_2(_jid, profile), errback=self._getParamError)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
166
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
167 def plug_profile_2(self, _jid, profile):
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
168 self.profiles[profile]['whoami'] = JID(_jid)
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
169 self.bridge.asyncGetParamA("autoconnect", "Connection", profile_key=profile,
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
170 callback=lambda value: self.plug_profile_3(value == "true", profile), errback=self._getParamError)
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
171
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
172 def plug_profile_3(self, autoconnect, profile):
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
173 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
174 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
175
1060
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
176 def asyncConnect(self, profile, callback=None, errback=None):
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
177 if not callback:
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
178 callback = lambda dummy: None
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
179 if not errback:
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
180 def errback(failure):
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
181 log.error(_(u"Can't connect profile [%s]") % failure)
1074
a47995155e55 frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents: 1063
diff changeset
182 if failure.module.startswith('twisted.words.protocols.jabber') and failure.condition == "not-authorized":
a47995155e55 frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents: 1063
diff changeset
183 self.launchAction(C.CHANGE_XMPP_PASSWD_ID, {}, profile_key=profile)
a47995155e55 frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents: 1063
diff changeset
184 else:
a47995155e55 frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents: 1063
diff changeset
185 self.showDialog(failure.message, failure.fullname, 'error')
1060
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
186 self.bridge.asyncConnect(profile, callback=callback, errback=errback)
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
187
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
188 def plug_profile_4(self, watched, autoconnect, profile):
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
189 if autoconnect and not self.bridge.isConnected(profile):
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
190 #Does the user want autoconnection ?
1060
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
191 self.asyncConnect(profile, callback=lambda dummy: self.plug_profile_5(watched, autoconnect, profile))
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
192 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
193 self.plug_profile_5(watched, autoconnect, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
194
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
195 def plug_profile_5(self, watched, autoconnect, profile):
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
196 self.profiles[profile]['watched'] = watched.split() # TODO: put this in a plugin
0
goffi@necton2
parents:
diff changeset
197
goffi@necton2
parents:
diff changeset
198 ## misc ##
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
199 self.profiles[profile]['onlineContact'] = set() # FIXME: temporary
0
goffi@necton2
parents:
diff changeset
200
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
201 #TODO: manage multi-profiles here
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
202 if not self.bridge.isConnected(profile):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
203 self.setStatusOnline(False)
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
204 else:
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
205 self.setStatusOnline(True)
0
goffi@necton2
parents:
diff changeset
206
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
207 ### now we fill the contact list ###
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
208 for contact in self.bridge.getContacts(profile):
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
209 self.newContactHandler(*contact, profile=profile)
0
goffi@necton2
parents:
diff changeset
210
943
71926ec2114d core (memory): entities cache improvments:
Goffi <goffi@goffi.org>
parents: 917
diff changeset
211 presences = self.bridge.getPresenceStatuses(profile)
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
212 for contact in presences:
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
213 for res in presences[contact]:
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
214 jabber_id = contact + ('/' + res if res else '')
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
215 show = presences[contact][res][0]
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
216 priority = presences[contact][res][1]
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
217 statuses = presences[contact][res][2]
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
218 self.presenceUpdateHandler(jabber_id, show, priority, statuses, profile)
917
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
219 data = self.bridge.getEntityData(contact, ['avatar', 'nick'], profile)
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
220 for key in ('avatar', 'nick'):
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
221 if key in data:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
222 self.entityDataUpdatedHandler(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
223
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
224 #The waiting subscription requests
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
225 waitingSub = self.bridge.getWaitingSub(profile)
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
226 for sub in waitingSub:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
227 self.subscribeHandler(waitingSub[sub], sub, profile)
0
goffi@necton2
parents:
diff changeset
228
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
229 #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
230 for room_args in self.bridge.getRoomsJoined(profile):
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
231 self.roomJoinedHandler(*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
232
479
4b62ce15a5f8 quickapp: fixed typo
Goffi <goffi@goffi.org>
parents: 459
diff changeset
233 for subject_args in self.bridge.getRoomsSubjects(profile):
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
234 self.roomNewSubjectHandler(*subject_args, profile=profile)
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
235
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
236 #Finaly, we get the waiting confirmation requests
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
237 for confirm_id, confirm_type, data in self.bridge.getWaitingConf(profile):
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
238 self.askConfirmationHandler(confirm_id, confirm_type, data, profile)
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
239
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
240 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
241 """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
242 if not profile in self.profiles:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
243 log.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
244 return
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
245 self.profiles.remove(profile)
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
246
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
247 def clear_profile(self):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
248 self.profiles.clear()
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
249
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
250 def connectedHandler(self, profile):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
251 """called when the connection is made"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
252 log.debug(_("Connected"))
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
253 self.setStatusOnline(True)
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
254
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
255 def disconnectedHandler(self, profile):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
256 """called when the connection is closed"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
257 log.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
258 self.contact_list.clearContacts()
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
259 self.setStatusOnline(False)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
260
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
261 def newContactHandler(self, JabberId, attributes, groups, profile):
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
262 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
263 _groups = list(groups)
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
264 self.contact_list.replace(entity, _groups, attributes)
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
265
513
8ee9113d307b core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents: 510
diff changeset
266 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
267 """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
268 if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped"""
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
269 from_jid = JID(from_jid_s)
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
270 to_jid = JID(to_jid_s)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
271
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
272 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
273 win = to_jid if from_me else from_jid
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
274
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
275 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
276 #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
277 #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
278 # so we cheat by replacing the "/" before the resource by
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
279 # a "@", so the jid is invalid,
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
280 new_jid = escapePrivate(win)
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
281 if from_me:
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
282 to_jid = new_jid
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
283 else:
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
284 from_jid = new_jid
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
285 if new_jid not in self.contact_list:
1058
0a9986452bba frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents: 1043
diff changeset
286 self.contact_list.add(new_jid, [C.GROUP_NOT_IN_ROSTER])
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
287
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
288 self.newMessageHandler(from_jid, to_jid, msg, _type, extra, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
289
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
290 def newMessageHandler(self, from_jid, to_jid, msg, _type, extra, profile):
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
291 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
292 win = to_jid if from_me else from_jid
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
293
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
294 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
295 self.current_action_ids_cb = {}
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
296
513
8ee9113d307b core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents: 510
diff changeset
297 timestamp = extra.get('archive')
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
298 self.chat_wins[win.bare].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
299
776
f89173f44850 frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents: 771
diff changeset
300 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key="@NONE@"):
1019
6a16ec17a458 better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
301 if to_jid.startswith(C.PRIVATE_PREFIX):
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
302 to_jid = unescapePrivate(to_jid)
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
303 mess_type = "chat"
776
f89173f44850 frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents: 771
diff changeset
304 if callback is None:
f89173f44850 frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents: 771
diff changeset
305 callback = lambda: None
f89173f44850 frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents: 771
diff changeset
306 if errback is None:
1063
6ec513ad92c2 frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents: 1060
diff changeset
307 errback = lambda failure: self.showDialog(failure.fullname, failure.message, "error")
776
f89173f44850 frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents: 771
diff changeset
308 self.bridge.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
0
goffi@necton2
parents:
diff changeset
309
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
310 def newAlertHandler(self, msg, title, alert_type, profile):
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
311 assert alert_type in ['INFO', 'ERROR']
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
312 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
313
737
378af36155c2 frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents: 736
diff changeset
314 def setStatusOnline(self, online=True, show="", statuses={}):
378af36155c2 frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents: 736
diff changeset
315 raise NotImplementedError
0
goffi@necton2
parents:
diff changeset
316
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
317 def presenceUpdateHandler(self, jabber_id, show, priority, statuses, profile):
737
378af36155c2 frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents: 736
diff changeset
318
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
319 log.debug(_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]")
735
682933ca304c frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents: 698
diff changeset
320 % {'jid': jabber_id, 'show': show, 'priority': priority, 'statuses': statuses, 'profile': profile})
682933ca304c frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents: 698
diff changeset
321 from_jid = JID(jabber_id)
0
goffi@necton2
parents:
diff changeset
322
767
318acc83a392 quick_frontend: fix presence/status update (do not share between different resources)
souliane <souliane@mailoo.org>
parents: 737
diff changeset
323 if from_jid == self.profiles[profile]['whoami']:
735
682933ca304c frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents: 698
diff changeset
324 if show == "unavailable":
682933ca304c frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents: 698
diff changeset
325 self.setStatusOnline(False)
682933ca304c frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents: 698
diff changeset
326 else:
737
378af36155c2 frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents: 736
diff changeset
327 self.setStatusOnline(True, show, statuses)
0
goffi@necton2
parents:
diff changeset
328 return
goffi@necton2
parents:
diff changeset
329
917
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
330 presences = self.profiles[profile].setdefault('presences', {})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
331
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
332 if show != 'unavailable':
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
333
0
goffi@necton2
parents:
diff changeset
334 #FIXME: must be moved in a plugin
955
cad958239b5c quick frontends: first connection fixes
Goffi <goffi@goffi.org>
parents: 943
diff changeset
335 if from_jid.bare in self.profiles[profile].get('watched',[]) and not from_jid.bare in self.profiles[profile]['onlineContact']:
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
336 self.showAlert(_("Watched jid [%s] is connected !") % from_jid.bare)
0
goffi@necton2
parents:
diff changeset
337
917
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
338 presences[jabber_id] = {'show': show, 'priority': priority, 'statuses': statuses}
955
cad958239b5c quick frontends: first connection fixes
Goffi <goffi@goffi.org>
parents: 943
diff changeset
339 self.profiles[profile].setdefault('onlineContact',set()).add(from_jid) # FIXME onlineContact is useless with CM, must be removed
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
340
501
e9634d2e7b38 core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents: 480
diff changeset
341 #TODO: vcard data (avatar)
0
goffi@necton2
parents:
diff changeset
342
955
cad958239b5c quick frontends: first connection fixes
Goffi <goffi@goffi.org>
parents: 943
diff changeset
343 if show == "unavailable" and from_jid in self.profiles[profile].get('onlineContact',set()):
917
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
344 try:
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
345 del presences[jabber_id]
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
346 except KeyError:
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
347 pass
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
348 self.profiles[profile]['onlineContact'].remove(from_jid)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
349
917
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
350 # check if the contact is connected with another resource, use the one with highest priority
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
351 jids = [jid for jid in presences if JID(jid).bare == from_jid.bare]
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
352 if jids:
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
353 max_jid = max(jids, key=lambda jid: presences[jid]['priority'])
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
354 data = presences[max_jid]
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
355 max_priority = data['priority']
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
356 if show == "unavailable": # do not check the priority here, because 'unavailable' has a dummy one
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
357 from_jid = JID(max_jid)
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
358 show, priority, statuses = data['show'], data['priority'], data['statuses']
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
359 if not jids or priority >= max_priority:
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
360 # case 1: not jids means all resources are disconnected, send the 'unavailable' presence
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
361 # case 2: update (or confirm) with the values of the resource which takes precedence
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
362 self.contact_list.updatePresence(from_jid, show, priority, statuses)
a9401694d2dc bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents: 907
diff changeset
363
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
364 def roomJoinedHandler(self, room_jid, room_nicks, user_nick, profile):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 71
diff changeset
365 """Called when a MUC room is joined"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
366 log.debug(_("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s") % {'room_jid': room_jid, 'profile': profile, 'users': room_nicks})
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
367 self.chat_wins[room_jid].setUserNick(user_nick)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
368 self.chat_wins[room_jid].setType("group")
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 79
diff changeset
369 self.chat_wins[room_jid].id = room_jid
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
370 self.chat_wins[room_jid].setPresents(list(set([user_nick] + room_nicks)))
685
0b9bd47dffcd primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents: 643
diff changeset
371 self.contact_list.setSpecial(JID(room_jid), "MUC", show=True)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 71
diff changeset
372
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
373 def roomLeftHandler(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
374 """Called when a MUC room is left"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
375 log.debug(_("Room [%(room_jid)s] left by %(profile)s") % {'room_jid': room_jid_s, 'profile': profile})
510
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
376 del self.chat_wins[room_jid_s]
886754295efe quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents: 507
diff changeset
377 self.contact_list.remove(JID(room_jid_s))
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 71
diff changeset
378
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
379 def roomUserJoinedHandler(self, room_jid, user_nick, user_data, profile):
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
380 """Called when an user joined a MUC room"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
381 if room_jid in self.chat_wins:
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
382 self.chat_wins[room_jid].replaceUser(user_nick)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
383 log.debug(_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick': user_nick, 'room_jid': room_jid})
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
384
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
385 def roomUserLeftHandler(self, room_jid, user_nick, user_data, profile):
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
386 """Called when an user joined a MUC room"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
387 if room_jid in self.chat_wins:
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
388 self.chat_wins[room_jid].removeUser(user_nick)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
389 log.debug(_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick': user_nick, 'room_jid': room_jid})
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
390
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
391 def roomUserChangedNickHandler(self, room_jid, old_nick, new_nick, profile):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 504
diff changeset
392 """Called when an user joined a MUC room"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
393 if room_jid in self.chat_wins:
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 504
diff changeset
394 self.chat_wins[room_jid].changeUserNick(old_nick, new_nick)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
395 log.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})
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 504
diff changeset
396
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
397 def roomNewSubjectHandler(self, room_jid, subject, profile):
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
398 """Called when subject of MUC room change"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
399 if room_jid in self.chat_wins:
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
400 self.chat_wins[room_jid].setSubject(subject)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
401 log.debug(_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid': room_jid, "subject": subject})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
402
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
403 def tarotGameStartedHandler(self, room_jid, referee, players, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
404 log.debug(_("Tarot Game Started \o/"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
405 if room_jid in self.chat_wins:
90
4020931569b8 Tarot Game: session initialization
Goffi <goffi@goffi.org>
parents: 89
diff changeset
406 self.chat_wins[room_jid].startGame("Tarot", referee, players)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
407 log.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]})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
408
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
409 def tarotGameNewHandler(self, room_jid, hand, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
410 log.debug(_("New Tarot Game"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
411 if room_jid in self.chat_wins:
87
66d784082930 Tarot game
Goffi <goffi@goffi.org>
parents: 86
diff changeset
412 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
413
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
414 def tarotGameChooseContratHandler(self, room_jid, xml_data, profile):
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents: 132
diff changeset
415 """Called when the player has to select his contrat"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
416 log.debug(_("Tarot: need to select a contrat"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
417 if room_jid in self.chat_wins:
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
418 self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
419
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
420 def tarotGameShowCardsHandler(self, room_jid, game_stage, cards, data, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
421 log.debug(_("Show cards"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
422 if room_jid in self.chat_wins:
92
2503de7fb4c7 Tarot game: chien/écart stage
Goffi <goffi@goffi.org>
parents: 91
diff changeset
423 self.chat_wins[room_jid].getGame("Tarot").showCards(game_stage, cards, data)
87
66d784082930 Tarot game
Goffi <goffi@goffi.org>
parents: 86
diff changeset
424
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
425 def tarotGameYourTurnHandler(self, room_jid, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
426 log.debug(_("My turn to play"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
427 if room_jid in self.chat_wins:
150
63d20bda5754 Primitivus: Tarot game
Goffi <goffi@goffi.org>
parents: 144
diff changeset
428 self.chat_wins[room_jid].getGame("Tarot").myTurn()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
429
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
430 def tarotGameScoreHandler(self, room_jid, xml_data, winners, loosers, profile):
95
be206a3d1a9b Tarot game: score calculation
Goffi <goffi@goffi.org>
parents: 93
diff changeset
431 """Called when the game is finished and the score are updated"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
432 log.debug(_("Tarot: score received"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
433 if room_jid in self.chat_wins:
95
be206a3d1a9b Tarot game: score calculation
Goffi <goffi@goffi.org>
parents: 93
diff changeset
434 self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers)
be206a3d1a9b Tarot game: score calculation
Goffi <goffi@goffi.org>
parents: 93
diff changeset
435
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
436 def tarotGameCardsPlayedHandler(self, room_jid, player, cards, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
437 log.debug(_("Card(s) played (%(player)s): %(cards)s") % {"player": player, "cards": cards})
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
438 if room_jid in self.chat_wins:
93
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 92
diff changeset
439 self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
440
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
441 def tarotGameInvalidCardsHandler(self, room_jid, phase, played_cards, invalid_cards, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
442 log.debug(_("Cards played are not valid: %s") % invalid_cards)
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
443 if room_jid in self.chat_wins:
99
63c9067a1499 Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents: 95
diff changeset
444 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
445
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
446 def quizGameStartedHandler(self, room_jid, referee, players, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
447 log.debug(_("Quiz Game Started \o/"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
448 if room_jid in self.chat_wins:
361
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents: 347
diff changeset
449 self.chat_wins[room_jid].startGame("Quiz", referee, players)
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
450 log.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]})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
451
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
452 def quizGameNewHandler(self, room_jid, data, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
453 log.debug(_("New Quiz Game"))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
454 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
455 self.chat_wins[room_jid].getGame("Quiz").quizGameNewHandler(data)
361
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents: 347
diff changeset
456
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
457 def quizGameQuestionHandler(self, room_jid, question_id, question, timer, profile):
361
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents: 347
diff changeset
458 """Called when a new question is asked"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
459 log.debug(_(u"Quiz: new question: %s") % question)
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
460 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
461 self.chat_wins[room_jid].getGame("Quiz").quizGameQuestionHandler(question_id, question, timer)
361
141eeb7cd9e6 Quizz game: first draft
Goffi <goffi@goffi.org>
parents: 347
diff changeset
462
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
463 def quizGamePlayerBuzzedHandler(self, room_jid, player, pause, profile):
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
464 """Called when a player pushed the buzzer"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
465 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
466 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerBuzzedHandler(player, pause)
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
467
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
468 def quizGamePlayerSaysHandler(self, room_jid, player, text, delay, profile):
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
469 """Called when a player say something"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
470 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
471 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerSaysHandler(player, text, delay)
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
472
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
473 def quizGameAnswerResultHandler(self, room_jid, player, good_answer, score, profile):
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
474 """Called when a player say something"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
475 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
476 self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResultHandler(player, good_answer, score)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
477
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
478 def quizGameTimerExpiredHandler(self, room_jid, profile):
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
479 """Called when nobody answered the question in time"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
480 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
481 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerExpiredHandler()
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
482
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
483 def quizGameTimerRestartedHandler(self, room_jid, time_left, profile):
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
484 """Called when the question is not answered, and we still have time"""
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
485 if room_jid in self.chat_wins:
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
486 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestartedHandler(time_left)
362
208107419b17 Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents: 361
diff changeset
487
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
488 def chatStateReceivedHandler(self, from_jid_s, state, profile):
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
489 """Callback when a new chat state is received.
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
490 @param from_jid_s: JID of the contact who sent his state, or '@ALL@'
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
491 @param state: new state (string)
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
492 @profile: current profile
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
493 """
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
494
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
495 if from_jid_s == '@ALL@':
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
496 target = '@ALL@'
1019
6a16ec17a458 better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
497 nick = C.ALL_OCCUPANTS
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
498 else:
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
499 from_jid = JID(from_jid_s)
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
500 target = from_jid.bare
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
501 nick = from_jid.resource
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
502
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
503 for bare in self.chat_wins.keys():
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
504 if target == '@ALL' or target == bare:
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
505 chat_win = self.chat_wins[bare]
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
506 if chat_win.type == 'one2one':
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
507 chat_win.updateChatState(state)
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
508 elif chat_win.type == 'group':
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
509 chat_win.updateChatState(state, nick=nick)
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 906
diff changeset
510
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 165
diff changeset
511 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
512 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
513 if answer:
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
514 self.bridge.subscription("subscribed", entity.bare, profile_key=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
515 else:
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
516 self.bridge.subscription("unsubscribed", entity.bare, profile_key=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
517
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
518 def subscribeHandler(self, type, raw_jid, profile):
87
66d784082930 Tarot game
Goffi <goffi@goffi.org>
parents: 86
diff changeset
519 """Called when a subsciption management signal is received"""
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
520 entity = JID(raw_jid)
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
521 if type == "subscribed":
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
522 # this is a subscription confirmation, we just have to inform user
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
523 self.showDialog(_("The contact %s has accepted your subscription") % entity.bare, _('Subscription confirmation'))
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
524 elif type == "unsubscribed":
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
525 # this is a subscription refusal, we just have to inform user
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
526 self.showDialog(_("The contact %s has refused your subscription") % entity.bare, _('Subscription refusal'), 'error')
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
527 elif type == "subscribe":
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
528 # this is a subscriptionn request, we have to ask for user confirmation
943
71926ec2114d core (memory): entities cache improvments:
Goffi <goffi@goffi.org>
parents: 917
diff changeset
529 self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.bare, _('Subscription confirmation'), 'yes/no', answer_cb=self._subscribe_cb, answer_data=(entity, profile))
0
goffi@necton2
parents:
diff changeset
530
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
531 def showDialog(self, message, title, type="info", answer_cb=None):
0
goffi@necton2
parents:
diff changeset
532 raise NotImplementedError
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
533
0
goffi@necton2
parents:
diff changeset
534 def showAlert(self, message):
goffi@necton2
parents:
diff changeset
535 pass #FIXME
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
536
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
537 def paramUpdateHandler(self, name, value, namespace, profile):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
538 log.debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace': namespace, 'name': name, 'value': value})
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
539 if (namespace, name) == ("Connection", "JabberID"):
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 955
diff changeset
540 log.debug(_("Changing JID to %s") % value)
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
541 self.profiles[profile]['whoami'] = JID(value)
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
542 elif (namespace, name) == ("Misc", "Watched"):
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
543 self.profiles[profile]['watched'] = value.split()
0
goffi@necton2
parents:
diff changeset
544
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
545 def contactDeletedHandler(self, jid, profile):
0
goffi@necton2
parents:
diff changeset
546 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
547 self.contact_list.remove(target)
0
goffi@necton2
parents:
diff changeset
548 try:
688
f7878ad3c846 tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents: 685
diff changeset
549 self.profiles[profile]['onlineContact'].remove(target.bare)
0
goffi@necton2
parents:
diff changeset
550 except KeyError:
goffi@necton2
parents:
diff changeset
551 pass
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 28
diff changeset
552
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
553 def entityDataUpdatedHandler(self, jid_str, key, value, 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
554 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
555 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
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
565 def askConfirmationHandler(self, confirm_id, confirm_type, data, profile):
0
goffi@necton2
parents:
diff changeset
566 raise NotImplementedError
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
567
1103
a096b8579a3c frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents: 1093
diff changeset
568 def actionResultHandler(self, type, id, data):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
569 raise NotImplementedError
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
570
1060
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
571 def launchAction(self, callback_id, data=None, profile_key="@NONE@"):
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
572 """ Launch a dynamic action
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
573 @param callback_id: id of the action to launch
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
574 @param data: data needed only for certain actions
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
575 @param profile_key: %(doc_profile_key)s
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
576
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
577 """
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
578 raise NotImplementedError
aa15453ec54d core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents: 1058
diff changeset
579
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
580 def onExit(self):
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
581 """Must be called when the frontend is terminating"""
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
582 #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
583 try:
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
584 if self.bridge.isConnected(self.profile):
906
1cbae66fa725 quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 811
diff changeset
585 if self.bridge.getParamA("autodisconnect", "Connection", profile_key=self.profile) == "true":
414
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
586 #The user wants autodisconnection
f6f94e21c642 Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents: 405
diff changeset
587 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
588 except:
7baee9bb37af quick_frontend: fixed disconnect, and removed autojoin of muc room put for dev
Goffi <goffi@goffi.org>
parents: 183
diff changeset
589 pass