annotate sat.tac @ 187:12544ea2951f

Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
author Goffi <goffi@goffi.org>
date Wed, 18 Aug 2010 17:27:15 +0800
parents 61f1e509e684
children 92e4ddd580ae
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
goffi@necton2
parents:
diff changeset
4 """
goffi@necton2
parents:
diff changeset
5 SAT: a jabber client
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 52
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
22 CONST = {
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
23 'client_name' : u'SàT (Salut à toi)',
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 58
diff changeset
24 'client_version' : u'0.0.2D', #Please add 'D' at the end for dev versions
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
25 'local_dir' : '~/.sat'
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
26 }
0
goffi@necton2
parents:
diff changeset
27
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 105
diff changeset
28 import gettext
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 105
diff changeset
29 gettext.install('sat', "i18n", unicode=True)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
30
2
c49345fd7737 refactoring: moved sat to sat.tac, now a twisted application so we can use twistd.
Goffi <goffi@goffi.org>
parents: 1
diff changeset
31 from twisted.application import internet, service
12
ef8060d365cb whitespace ping to avoid disconnection (was disconnected after 6 min of inactivity with openfire)
Goffi <goffi@goffi.org>
parents: 6
diff changeset
32 from twisted.internet import glib2reactor, protocol, task
0
goffi@necton2
parents:
diff changeset
33 glib2reactor.install()
goffi@necton2
parents:
diff changeset
34
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
35 from twisted.words.protocols.jabber import jid, xmlstream
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
36 from twisted.words.protocols.jabber import error as jab_error
0
goffi@necton2
parents:
diff changeset
37 from twisted.words.xish import domish
goffi@necton2
parents:
diff changeset
38
goffi@necton2
parents:
diff changeset
39 from twisted.internet import reactor
goffi@necton2
parents:
diff changeset
40 import pdb
goffi@necton2
parents:
diff changeset
41
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
42 from wokkel import client, disco, xmppim, generic, compat
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
43
0
goffi@necton2
parents:
diff changeset
44 from sat_bridge.DBus import DBusBridge
goffi@necton2
parents:
diff changeset
45 import logging
goffi@necton2
parents:
diff changeset
46 from logging import debug, info, error
goffi@necton2
parents:
diff changeset
47
goffi@necton2
parents:
diff changeset
48 import signal, sys
goffi@necton2
parents:
diff changeset
49 import os.path
goffi@necton2
parents:
diff changeset
50
goffi@necton2
parents:
diff changeset
51 from tools.memory import Memory
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
52 from tools.xml_tools import tupleList2dataForm
0
goffi@necton2
parents:
diff changeset
53 from glob import glob
goffi@necton2
parents:
diff changeset
54
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
55 try:
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
56 from twisted.words.protocols.xmlstream import XMPPHandler
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
57 except ImportError:
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
58 from wokkel.subprotocols import XMPPHandler
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
59
0
goffi@necton2
parents:
diff changeset
60
goffi@necton2
parents:
diff changeset
61 ### logging configuration FIXME: put this elsewhere ###
goffi@necton2
parents:
diff changeset
62 logging.basicConfig(level=logging.DEBUG,
goffi@necton2
parents:
diff changeset
63 format='%(message)s')
goffi@necton2
parents:
diff changeset
64 ###
goffi@necton2
parents:
diff changeset
65
goffi@necton2
parents:
diff changeset
66
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
67 sat_id = 0
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
68
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
69 def sat_next_id():
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
70 global sat_id
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
71 sat_id+=1
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
72 return "sat_id_"+str(sat_id)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
73
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
74 class SatXMPPClient(client.XMPPClient):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
75
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
76 def __init__(self, host_app, profile, user_jid, password, host=None, port=5222):
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
77 client.XMPPClient.__init__(self, user_jid, password, host, port)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
78 self.factory.clientConnectionLost = self.connectionLost
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
79 self.__connected=False
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
80 self.profile = profile
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
81 self.host_app = host_app
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
82
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
83 def _authd(self, xmlstream):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
84 print "SatXMPPClient"
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
85 client.XMPPClient._authd(self, xmlstream)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
86 self.__connected=True
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
87 info (_("********** [%s] CONNECTED **********") % self.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
88 self.streamInitialized()
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
89 self.host_app.bridge.connected(self.profile) #we send the signal to the clients
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
90
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
91 def streamInitialized(self):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
92 """Called after _authd"""
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
93 debug (_("XML stream is initialized"))
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
94 self.keep_alife = task.LoopingCall(self.xmlstream.send, " ") #Needed to avoid disconnection (specially with openfire)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
95 self.keep_alife.start(180)
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
96
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
97 self.disco = SatDiscoProtocol(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
98 self.disco.setHandlerParent(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
99 self.discoHandler = disco.DiscoHandler()
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
100 self.discoHandler.setHandlerParent(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
101
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
102 self.roster.requestRoster()
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
103
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
104 self.presence.available()
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
105
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
106 self.disco.requestInfo(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDisco) #FIXME: use these informations
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
107
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
108 def isConnected(self):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
109 return self.__connected
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
110
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
111 def connectionLost(self, connector, unused_reason):
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
112 self.__connected=False
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
113 info (_("********** [%s] DISCONNECTED **********") % self.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
114 try:
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
115 self.keep_alife.stop()
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
116 except AttributeError:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
117 debug (_("No keep_alife"))
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
118 self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients
0
goffi@necton2
parents:
diff changeset
119
goffi@necton2
parents:
diff changeset
120
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
121 class SatMessageProtocol(xmppim.MessageProtocol):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
122
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
123 def __init__(self, host):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
124 xmppim.MessageProtocol.__init__(self)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
125 self.host = host
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
126
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
127 def onMessage(self, message):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
128 debug (_(u"got message from: %s"), message["from"])
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
129 for e in message.elements():
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
130 if e.name == "body":
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
131 type = message['type'] if message.hasAttribute('type') else 'chat' #FIXME: check specs
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
132 self.host.bridge.newMessage(message["from"], e.children[0], type, profile=self.parent.profile)
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
133 self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0])
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
134 break
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
135
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
136 class SatRosterProtocol(xmppim.RosterClientProtocol):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
137
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
138 def __init__(self, host):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
139 xmppim.RosterClientProtocol.__init__(self)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
140 self.host = host
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
141
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
142 def rosterCb(self, roster):
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
143 for raw_jid, item in roster.iteritems():
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
144 self.onRosterSet(item)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
145
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
146 def requestRoster(self):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
147 """ ask the server for Roster list """
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
148 debug("requestRoster")
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
149 self.getRoster().addCallback(self.rosterCb)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
150
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
151 def removeItem(self, to):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
152 """Remove a contact from roster list"""
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
153 xmppim.RosterClientProtocol.removeItem(self, to)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
154 #TODO: check IQ result
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
155
187
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
156 #XXX: disabled (cf http://wokkel.ik.nu/ticket/56))
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
157 #def addItem(self, to):
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
158 #"""Add a contact to roster list"""
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
159 #xmppim.RosterClientProtocol.addItem(self, to)
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
160 #TODO: check IQ result"""
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
161
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
162 def onRosterSet(self, item):
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
163 """Called when a new/update roster item is received"""
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
164 #TODO: send a signal to frontends
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
165 item_attr = {'to': str(item.subscriptionTo),
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
166 'from': str(item.subscriptionFrom),
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
167 'ask': str(item.ask)
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
168 }
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
169 if item.name:
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
170 item_attr['name'] = item.name
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
171 info (_("new contact in roster list: %s"), item.jid.full())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
172 self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
173 self.host.bridge.newContact(item.jid.full(), item_attr, item.groups, self.parent.profile)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
174
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
175 def onRosterRemove(self, entity):
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
176 """Called when a roster removal event is received"""
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
177 #TODO: send a signal to frontends
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
178 print _("removing %s from roster list") % entity.full()
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
179 self.host.memory.delContact(entity, self.parent.profile)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
180
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
181 class SatPresenceProtocol(xmppim.PresenceClientProtocol):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
182
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
183 def __init__(self, host):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
184 xmppim.PresenceClientProtocol.__init__(self)
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
185 self.host = host
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
186
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
187 def availableReceived(self, entity, show=None, statuses=None, priority=0):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 69
diff changeset
188 debug (_("presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity':entity, 'show':show, 'statuses':statuses, 'priority':priority})
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
189
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
190 if statuses.has_key(None): #we only want string keys
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
191 statuses["default"] = statuses[None]
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
192 del statuses[None]
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
193
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
194 self.host.memory.addPresenceStatus(entity, show or "",
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
195 int(priority), statuses, self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
196
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
197 #now it's time to notify frontends
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
198 self.host.bridge.presenceUpdate(entity.full(), show or "",
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
199 int(priority), statuses, self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
200
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
201 def unavailableReceived(self, entity, statuses=None):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 69
diff changeset
202 debug (_("presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity':entity, 'statuses':statuses})
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
203 if statuses and statuses.has_key(None): #we only want string keys
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
204 statuses["default"] = statuses[None]
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
205 del statuses[None]
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
206 self.host.memory.addPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
207
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
208 #now it's time to notify frontends
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
209 self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
210
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
211
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
212 def available(self, entity=None, show=None, statuses=None, priority=0):
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
213 if statuses and statuses.has_key('default'):
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
214 statuses[None] = statuses['default']
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
215 del statuses['default']
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
216 xmppim.PresenceClientProtocol.available(self, entity, show, statuses, priority)
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
217
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
218 def subscribedReceived(self, entity):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
219 debug (_("subscription approved for [%s]") % entity.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
220 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
221 self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
222
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
223 def unsubscribedReceived(self, entity):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
224 debug (_("unsubscription confirmed for [%s]") % entity.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
225 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
226 self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
227
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
228 def subscribeReceived(self, entity):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
229 debug (_("subscription request for [%s]") % entity.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
230 self.host.memory.addWaitingSub('subscribe', entity.userhost(), self.parent.profile)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
231 self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
232
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
233 def unsubscribeReceived(self, entity):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
234 debug (_("unsubscription asked for [%s]") % entity.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
235 self.host.memory.addWaitingSub('unsubscribe', entity.userhost(), self.parent.profile)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
236 self.host.bridge.subscribe('unsubscribe', entity.userhost(), self.parent.profile)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
237
14
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
238 class SatDiscoProtocol(disco.DiscoClientProtocol):
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
239 def __init__(self, host):
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
240 disco.DiscoClientProtocol.__init__(self)
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
241
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
242 class SatFallbackHandler(generic.FallbackHandler):
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
243 def __init__(self, host):
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
244 generic.FallbackHandler.__init__(self)
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
245
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
246 def iqFallback(self, iq):
155
61f1e509e684 SàT: fixed exception when using unmanaged IQ
Goffi <goffi@goffi.org>
parents: 135
diff changeset
247 debug (u"iqFallback: xml = [%s], handled=%s" % (iq.toXml(), "True" if iq.handled else "False"))
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
248 generic.FallbackHandler.iqFallback(self, iq)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
249
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
250 class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
251
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
252 def __init__(self, host, jabber_host, user_login, user_pass, answer_id):
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
253 xmlstream.ConnectAuthenticator.__init__(self, jabber_host)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
254 self.host = host
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
255 self.jabber_host = jabber_host
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
256 self.user_login = user_login
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
257 self.user_pass = user_pass
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
258 self.answer_id = answer_id
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
259 print _("Registration asked for"),user_login, user_pass, jabber_host
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
260
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
261 def connectionMade(self):
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
262 print "connectionMade"
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
263
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
264 self.xmlstream.namespace = "jabber:client"
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
265 self.xmlstream.sendHeader()
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
266
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
267 iq = compat.IQ(self.xmlstream, 'set')
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
268 iq["to"] = self.jabber_host
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
269 query = iq.addElement(('jabber:iq:register', 'query'))
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
270 _user = query.addElement('username')
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
271 _user.addContent(self.user_login)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
272 _pass = query.addElement('password')
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
273 _pass.addContent(self.user_pass)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
274 reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
275
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
276 def registrationAnswer(self, answer):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
277 debug (_("registration answer: %s") % answer.toXml())
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
278 answer_type = "SUCCESS"
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
279 answer_data={"message":_("Registration successfull")}
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
280 self.host.bridge.actionResult(answer_type, self.answer_id, answer_data)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
281 self.xmlstream.sendFooter()
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
282
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 25
diff changeset
283 def registrationFailure(self, failure):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
284 info (_("Registration failure: %s") % str(failure.value))
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
285 answer_type = "ERROR"
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
286 answer_data = {}
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 25
diff changeset
287 if failure.value.condition == 'conflict':
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
288 answer_data['reason'] = 'conflict'
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
289 answer_data={"message":_("Username already exists, please choose an other one")}
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
290 else:
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
291 answer_data['reason'] = 'unknown'
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
292 answer_data={"message":_("Registration failed (%s)") % str(failure.value.condition)}
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
293 self.host.bridge.actionResult(answer_type, self.answer_id, answer_data)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
294 self.xmlstream.sendFooter()
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
295
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
296
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
297 class SAT(service.Service):
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
298
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
299 def get_next_id(self):
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
300 return sat_next_id()
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
301
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
302 def get_const(self, name):
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
303 """Return a constant"""
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
304 if not CONST.has_key(name):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
305 error(_('Trying to access an undefined constant'))
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
306 raise Exception
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
307 return CONST[name]
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
308
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
309 def set_const(self, name, value):
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
310 """Save a constant"""
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
311 if CONST.has_key(name):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
312 error(_('Trying to redefine a constant'))
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
313 raise Exception
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
314 CONST[name] = value
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
315
0
goffi@necton2
parents:
diff changeset
316 def __init__(self):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
317 #TODO: standardize callback system
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
318
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
319 local_dir = os.path.expanduser(self.get_const('local_dir'))
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
320 if not os.path.exists(local_dir):
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
321 os.makedirs(local_dir)
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
322
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
323 self.__waiting_conf = {} #callback called when a confirmation is received
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
324 self.__progress_cb_map = {} #callback called when a progress is requested (key = progress id)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
325 self.__general_cb_map = {} #callback called for general reasons (key = name)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
326 self.__private_data = {} #used for internal callbacks (key = id)
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
327 self.profiles = {}
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
328 self.plugins = {}
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
329 self.menus = {} #used to know which new menus are wanted by plugins
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
330
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
331 self.memory=Memory(self)
0
goffi@necton2
parents:
diff changeset
332 self.server_features=[] #XXX: temp dic, need to be transfered into self.memory in the future
goffi@necton2
parents:
diff changeset
333
goffi@necton2
parents:
diff changeset
334 self.bridge=DBusBridge()
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 107
diff changeset
335 self.bridge.register("getVersion", lambda: self.get_const('client_version'))
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
336 self.bridge.register("getProfileName", self.memory.getProfileName)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 58
diff changeset
337 self.bridge.register("getProfilesList", self.memory.getProfilesList)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 58
diff changeset
338 self.bridge.register("createProfile", self.memory.createProfile)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
339 self.bridge.register("deleteProfile", self.memory.deleteProfile)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
340 self.bridge.register("registerNewAccount", self.registerNewAccount)
0
goffi@necton2
parents:
diff changeset
341 self.bridge.register("connect", self.connect)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
342 self.bridge.register("disconnect", self.disconnect)
0
goffi@necton2
parents:
diff changeset
343 self.bridge.register("getContacts", self.memory.getContacts)
goffi@necton2
parents:
diff changeset
344 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
345 self.bridge.register("getWaitingSub", self.memory.getWaitingSub)
0
goffi@necton2
parents:
diff changeset
346 self.bridge.register("sendMessage", self.sendMessage)
goffi@necton2
parents:
diff changeset
347 self.bridge.register("setParam", self.setParam)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
348 self.bridge.register("getParamA", self.memory.getParamA)
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 103
diff changeset
349 self.bridge.register("getParamsUI", self.memory.getParamsUI)
0
goffi@necton2
parents:
diff changeset
350 self.bridge.register("getParams", self.memory.getParams)
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
351 self.bridge.register("getParamsForCategory", self.memory.getParamsForCategory)
0
goffi@necton2
parents:
diff changeset
352 self.bridge.register("getParamsCategories", self.memory.getParamsCategories)
goffi@necton2
parents:
diff changeset
353 self.bridge.register("getHistory", self.memory.getHistory)
goffi@necton2
parents:
diff changeset
354 self.bridge.register("setPresence", self.setPresence)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
355 self.bridge.register("subscription", self.subscription)
0
goffi@necton2
parents:
diff changeset
356 self.bridge.register("addContact", self.addContact)
goffi@necton2
parents:
diff changeset
357 self.bridge.register("delContact", self.delContact)
goffi@necton2
parents:
diff changeset
358 self.bridge.register("isConnected", self.isConnected)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
359 self.bridge.register("launchAction", self.launchAction)
0
goffi@necton2
parents:
diff changeset
360 self.bridge.register("confirmationAnswer", self.confirmationAnswer)
goffi@necton2
parents:
diff changeset
361 self.bridge.register("getProgress", self.getProgress)
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
362 self.bridge.register("getMenus", self.getMenus)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
363 self.bridge.register("getMenuHelp", self.getMenuHelp)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
364 self.bridge.register("callMenu", self.callMenu)
0
goffi@necton2
parents:
diff changeset
365
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
366 self._import_plugins()
0
goffi@necton2
parents:
diff changeset
367
goffi@necton2
parents:
diff changeset
368
goffi@necton2
parents:
diff changeset
369 def _import_plugins(self):
goffi@necton2
parents:
diff changeset
370 """Import all plugins found in plugins directory"""
goffi@necton2
parents:
diff changeset
371 #TODO: manage dependencies
goffi@necton2
parents:
diff changeset
372 plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename,glob ("plugins/plugin*.py"))]
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
373
0
goffi@necton2
parents:
diff changeset
374 for plug in plug_lst:
goffi@necton2
parents:
diff changeset
375 plug_path = 'plugins.'+plug
goffi@necton2
parents:
diff changeset
376 __import__(plug_path)
goffi@necton2
parents:
diff changeset
377 mod = sys.modules[plug_path]
goffi@necton2
parents:
diff changeset
378 plug_info = mod.PLUGIN_INFO
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
379 info (_("importing plugin: %s"), plug_info['name'])
0
goffi@necton2
parents:
diff changeset
380 self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self)
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
381 if plug_info.has_key('handler') and plug_info['handler'] == 'yes':
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
382 self.plugins[plug_info['import_name']].is_handler = True
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
383 else:
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
384 self.plugins[plug_info['import_name']].is_handler = False
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
385 #TODO: test xmppclient presence and register handler parent
0
goffi@necton2
parents:
diff changeset
386
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
387 def connect(self, profile_key = '@DEFAULT@'):
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
388 """Connect to jabber server"""
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
389
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
390 profile = self.memory.getProfileName(profile_key)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
391 if not profile_key:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
392 error (_('Trying to connect a non-exsitant profile'))
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
393 return
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
394
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
395 if (self.isConnected(profile)):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
396 info(_("already connected !"))
6
5799493fa548 connection and disconnection management
Goffi <goffi@goffi.org>
parents: 5
diff changeset
397 return
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
398 current = self.profiles[profile] = SatXMPPClient(self, profile,
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
399 jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile_key), profile),
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
400 self.memory.getParamA("Password", "Connection", profile_key = profile_key),
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
401 self.memory.getParamA("Server", "Connection", profile_key = profile_key), 5222)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
402
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
403 current.messageProt = SatMessageProtocol(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
404 current.messageProt.setHandlerParent(current)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
405
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
406 current.roster = SatRosterProtocol(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
407 current.roster.setHandlerParent(current)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
408
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
409 current.presence = SatPresenceProtocol(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
410 current.presence.setHandlerParent(current)
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
411
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
412 current.fallBack = SatFallbackHandler(self)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
413 current.fallBack.setHandlerParent(current)
14
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
414
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
415 current.versionHandler = generic.VersionHandler(self.get_const('client_name'),
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 39
diff changeset
416 self.get_const('client_version'))
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
417 current.versionHandler.setHandlerParent(current)
14
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
418
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
419 debug (_("setting plugins parents"))
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
420
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
421 for plugin in self.plugins.iteritems():
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
422 if plugin[1].is_handler:
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 69
diff changeset
423 plugin[1].getHandler(profile).setHandlerParent(current)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
424
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
425 current.startService()
2
c49345fd7737 refactoring: moved sat to sat.tac, now a twisted application so we can use twistd.
Goffi <goffi@goffi.org>
parents: 1
diff changeset
426
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
427 def disconnect(self, profile_key='@DEFAULT@'):
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
428 """disconnect from jabber server"""
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
429 if (not self.isConnected(profile_key)):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
430 info(_("not connected !"))
6
5799493fa548 connection and disconnection management
Goffi <goffi@goffi.org>
parents: 5
diff changeset
431 return
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
432 profile = self.memory.getProfileName(profile_key)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
433 info(_("Disconnecting..."))
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
434 self.profiles[profile].stopService()
6
5799493fa548 connection and disconnection management
Goffi <goffi@goffi.org>
parents: 5
diff changeset
435
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
436 def startService(self):
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
437 info("Salut à toi ô mon frère !")
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
438 self.connect()
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
439
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
440 def stopService(self):
15
218ec9984fa5 wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents: 14
diff changeset
441 self.memory.save()
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
442 info("Salut aussi à Rantanplan")
0
goffi@necton2
parents:
diff changeset
443
goffi@necton2
parents:
diff changeset
444 def run(self):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
445 debug(_("running app"))
0
goffi@necton2
parents:
diff changeset
446 reactor.run()
goffi@necton2
parents:
diff changeset
447
goffi@necton2
parents:
diff changeset
448 def stop(self):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
449 debug(_("stopping app"))
0
goffi@necton2
parents:
diff changeset
450 reactor.stop()
goffi@necton2
parents:
diff changeset
451
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
452 ## Misc methods ##
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
453
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
454 def getJidNStream(self, profile_key):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
455 """Convenient method to get jid and stream from profile key
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
456 @return: tuple (jid, xmlstream) from profile, can be None"""
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
457 profile = self.memory.getProfileName(profile_key)
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
458 if not profile or not self.profiles[profile].isConnected():
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
459 return (None, None)
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
460 return (self.profiles[profile].jid, self.profiles[profile].xmlstream)
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
461
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
462 def getClient(self, profile_key):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
463 """Convenient method to get client from profile key
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
464 @return: client or None if it doesn't exist"""
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
465 profile = self.memory.getProfileName(profile_key)
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
466 if not profile:
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
467 return None
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
468 return self.profiles[profile]
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
469
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
470 def registerNewAccount(self, login, password, server, port = 5222, id = None):
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
471 """Connect to a server and create a new account using in-band registration"""
0
goffi@necton2
parents:
diff changeset
472
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
473 next_id = id or sat_next_id() #the id is used to send server's answer
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
474 serverRegistrer = xmlstream.XmlStreamFactory(RegisteringAuthenticator(self, server, login, password, next_id))
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
475 connector = reactor.connectTCP(server, port, serverRegistrer)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
476 serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
477
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
478 return next_id
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
479
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
480 def registerNewAccountCB(self, id, data, profile):
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
481 user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
482 password = self.memory.getParamA("Password", "Connection", profile_key=profile)
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
483 server = self.memory.getParamA("Server", "Connection", profile_key=profile)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
484
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
485 if not user or not password or not server:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
486 info (_('No user or server given'))
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
487 #TODO: a proper error message must be sent to frontend
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
488 self.actionResult(id, "ERROR", {'message':_("No user, password or server given, can't register new account.")})
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
489 return
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
490
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
491 confirm_id = sat_next_id()
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
492 self.__private_data[confirm_id]=(id,profile)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
493
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
494 self.askConfirmation(confirm_id, "YES/NO",
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
495 {"message":_("Are you sure to register new account [%(user)s] to server %(server)s ?") % {'user':user, 'server':server, 'profile':profile}},
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
496 self.regisConfirmCB)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
497 print ("===============+++++++++++ REGISTER NEW ACCOUNT++++++++++++++============")
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
498 print "id=",id
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
499 print "data=",data
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
500
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
501 def regisConfirmCB(self, id, accepted, data):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
502 print _("register Confirmation CB ! (%s)") % str(accepted)
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
503 action_id,profile = self.__private_data[id]
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
504 del self.__private_data[id]
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
505 if accepted:
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
506 user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
507 password = self.memory.getParamA("Password", "Connection", profile_key=profile)
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
508 server = self.memory.getParamA("Server", "Connection", profile_key=profile)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
509 self.registerNewAccount(user, password, server, id=action_id)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
510 else:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
511 self.actionResult(action_id, "SUPPRESS", {})
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
512
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
513 def submitForm(self, action, target, fields, profile_key='@DEFAULT@'):
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
514 """submit a form
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
515 @param target: target jid where we are submitting
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
516 @param fields: list of tuples (name, value)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
517 @return: tuple: (id, deferred)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
518 """
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
519
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
520 profile = self.memory.getProfileName(profile_key)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
521 assert(profile)
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 33
diff changeset
522 to_jid = jid.JID(target)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
523
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
524 iq = compat.IQ(self.profiles[profile].xmlstream, 'set')
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
525 iq["to"] = target
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
526 iq["from"] = self.profiles[profile].jid.full()
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
527 query = iq.addElement(('jabber:iq:register', 'query'))
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
528 if action=='SUBMIT':
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
529 form = tupleList2dataForm(fields)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
530 query.addChild(form.toElement())
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
531 elif action=='CANCEL':
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
532 query.addElement('remove')
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
533 else:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
534 error (_("FIXME FIXME FIXME: Unmanaged action (%s) in submitForm") % action)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
535 raise NotImplementedError
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
536
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
537 deferred = iq.send(target)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
538 return (iq['id'], deferred)
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 33
diff changeset
539
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
540 ## Client management ##
0
goffi@necton2
parents:
diff changeset
541
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
542 def setParam(self, name, value, category, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
543 """set wanted paramater and notice observers"""
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
544 info (_("setting param: %(name)s=%(value)s in category %(category)s") % {'name':name, 'value':value, 'category':category})
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
545 self.memory.setParam(name, value, category, profile_key)
0
goffi@necton2
parents:
diff changeset
546
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
547 def isConnected(self, profile_key='@DEFAULT@'):
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
548 """Return connection status of profile
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
549 @param profile_key: key_word or profile name to determine profile name
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
550 @return True if connected
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
551 """
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
552 profile = self.memory.getProfileName(profile_key)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
553 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
554 error (_('asking connection status for a non-existant profile'))
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
555 raise Exception #TODO: raise a proper exception
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
556 if not self.profiles.has_key(profile):
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
557 return False
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
558 return self.profiles[profile].isConnected()
0
goffi@necton2
parents:
diff changeset
559
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
560 def launchAction(self, type, data, profile_key='@DEFAULT@'):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
561 """Launch a specific action asked by client
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
562 @param type: action type (button)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
563 @param data: needed data to launch the action
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
564
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
565 @return: action id for result, or empty string in case or error
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
566 """
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
567 profile = self.memory.getProfileName(profile_key)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
568 if not profile:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
569 error (_('trying to launch action with a non-existant profile'))
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
570 raise Exception #TODO: raise a proper exception
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
571 if type=="button":
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
572 try:
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 105
diff changeset
573 cb_name = data['callback_id']
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
574 except KeyError:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
575 error (_("Incomplete 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
576 return ""
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
577 id = sat_next_id()
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
578 self.callGeneralCB(cb_name, id, data, profile = profile)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
579 return id
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
580 else:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
581 error (_("Unknown action type"))
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
582 return ""
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
583
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
584
0
goffi@necton2
parents:
diff changeset
585 ## jabber methods ##
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
586
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
587 def sendMessage(self,to,msg,type='chat', profile_key='@DEFAULT@'):
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
588 #FIXME: check validity of recipient
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
589 profile = self.memory.getProfileName(profile_key)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
590 assert(profile)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
591 current_jid = self.profiles[profile].jid
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
592 debug(_("Sending jabber message to %s..."), to)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
593 message = domish.Element(('jabber:client','message'))
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
594 message["to"] = jid.JID(to).full()
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
595 message["from"] = current_jid.full()
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
596 message["type"] = type
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
597 message.addElement("body", "jabber:client", msg)
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
598 self.profiles[profile].xmlstream.send(message)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 60
diff changeset
599 self.memory.addToHistory(current_jid, current_jid, jid.JID(to), message["type"], unicode(msg))
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
600 if type!="groupchat":
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
601 self.bridge.newMessage(message['from'], unicode(msg), to=message['to'], type=type, profile=profile) #We send back the message, so all clients are aware of it
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 15
diff changeset
602
0
goffi@necton2
parents:
diff changeset
603
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
604 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
605 """Send our presence information"""
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
606 profile = self.memory.getProfileName(profile_key)
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
607 assert(profile)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
608 to_jid = jid.JID(to) if to else None
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
609 self.profiles[profile].presence.available(to_jid, show, statuses, priority)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
610
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
611 def subscription(self, subs_type, raw_jid, profile_key='@DEFAULT@'):
187
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
612 """Called to manage subscription
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
613 @param subs_type: subsciption type (cf RFC 3921)
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
614 @param raw_jid: unicode entity's jid
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
615 @param profile_key: profile"""
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
616 profile = self.memory.getProfileName(profile_key)
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
617 assert(profile)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
618 to_jid = jid.JID(raw_jid)
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
619 debug (_('subsciption request [%(subs_type)s] for %(jid)s') % {'subs_type':subs_type, 'jid':to_jid.full()})
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
620 if subs_type=="subscribe":
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
621 self.profiles[profile].presence.subscribe(to_jid)
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
622 elif subs_type=="subscribed":
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
623 self.profiles[profile].presence.subscribed(to_jid)
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
624 contact = self.memory.getContact(to_jid)
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
625 if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
626 debug(_('sending automatic "to" subscription request'))
50
daa1f01a5332 SàT improvement:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
627 self.subscription('subscribe', to_jid.userhost())
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
628 elif subs_type=="unsubscribe":
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
629 self.profiles[profile].presence.unsubscribe(to_jid)
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 79
diff changeset
630 elif subs_type=="unsubscribed":
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
631 self.profiles[profile].presence.unsubscribed(to_jid)
0
goffi@necton2
parents:
diff changeset
632
goffi@necton2
parents:
diff changeset
633
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
634 def addContact(self, to, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
635 """Add a contact in roster list"""
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
636 profile = self.memory.getProfileName(profile_key)
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
637 assert(profile)
0
goffi@necton2
parents:
diff changeset
638 to_jid=jid.JID(to)
187
12544ea2951f Core: removed addItem for roster list, according to http://wokkel.ik.nu/ticket/56
Goffi <goffi@goffi.org>
parents: 155
diff changeset
639 #self.profiles[profile].roster.addItem(to_jid) XXX: disabled (cf http://wokkel.ik.nu/ticket/56))
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
640 self.profiles[profile].presence.subscribe(to_jid)
0
goffi@necton2
parents:
diff changeset
641
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
642 def delContact(self, to, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
643 """Remove contact from roster list"""
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
644 profile = self.memory.getProfileName(profile_key)
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
645 assert(profile)
0
goffi@necton2
parents:
diff changeset
646 to_jid=jid.JID(to)
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
647 self.profiles[profile].roster.removeItem(to_jid)
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
648 self.profiles[profile].presence.unsubscribe(to_jid)
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 119
diff changeset
649 self.bridge.contactDeleted(to, profile)
0
goffi@necton2
parents:
diff changeset
650
goffi@necton2
parents:
diff changeset
651
goffi@necton2
parents:
diff changeset
652 ## callbacks ##
goffi@necton2
parents:
diff changeset
653
goffi@necton2
parents:
diff changeset
654 def serverDisco(self, disco):
goffi@necton2
parents:
diff changeset
655 """xep-0030 Discovery Protocol."""
14
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
656 for feature in disco.features:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
657 debug (_("Feature found: %s"),feature)
14
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
658 self.server_features.append(feature)
a62d7d453f22 wokkel integration, part II
Goffi <goffi@goffi.org>
parents: 13
diff changeset
659 for cat, type in disco.identities:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
660 debug (_("Identity found: [%(category)s/%(type)s] %(identity)s") % {'category':cat, 'type':type, 'identity':disco.identities[(cat,type)]})
0
goffi@necton2
parents:
diff changeset
661
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
662
0
goffi@necton2
parents:
diff changeset
663 ## Generic HMI ##
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
664
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
665 def actionResult(self, id, type, data):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
666 """Send the result of an action
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
667 @param id: same id used with action
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 102
diff changeset
668 @param type: result type ("PARAM", "SUCCESS", "ERROR", "XMLUI")
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
669 @param data: dictionary
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
670 """
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
671 self.bridge.actionResult(type, id, data)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
672
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
673 def actionResultExt(self, id, type, data):
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
674 """Send the result of an action, extended version
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
675 @param id: same id used with action
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
676 @param type: result type /!\ only "DICT_DICT" for this method
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
677 @param data: dictionary of dictionaries
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
678 """
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
679 if type != "DICT_DICT":
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
680 error(_("type for actionResultExt must be DICT_DICT, fixing it"))
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
681 type = "DICT_DICT"
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
682 self.bridge.actionResultExt(type, id, data)
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
683
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
684
0
goffi@necton2
parents:
diff changeset
685
goffi@necton2
parents:
diff changeset
686 def askConfirmation(self, id, type, data, cb):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
687 """Add a confirmation callback
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
688 @param id: id used to get answer
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
689 @param type: confirmation type ("YES/NO", "FILE_TRANSFERT")
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
690 @param data: data (depend of confirmation type)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
691 @param cb: callback called with the answer
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
692 """
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
693 if self.__waiting_conf.has_key(id):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
694 error (_("Attempt to register two callbacks for the same confirmation"))
0
goffi@necton2
parents:
diff changeset
695 else:
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
696 self.__waiting_conf[id] = cb
0
goffi@necton2
parents:
diff changeset
697 self.bridge.askConfirmation(type, id, data)
goffi@necton2
parents:
diff changeset
698
goffi@necton2
parents:
diff changeset
699
goffi@necton2
parents:
diff changeset
700 def confirmationAnswer(self, id, accepted, data):
goffi@necton2
parents:
diff changeset
701 """Called by frontends to answer confirmation requests"""
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
702 debug (_("Received confirmation answer for id [%(id)s]: %(success)s") % {'id': id, 'success':_("accepted") if accepted else _("refused")})
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
703 if not self.__waiting_conf.has_key(id):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
704 error (_("Received an unknown confirmation"))
0
goffi@necton2
parents:
diff changeset
705 else:
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
706 cb = self.__waiting_conf[id]
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
707 del self.__waiting_conf[id]
0
goffi@necton2
parents:
diff changeset
708 cb(id, accepted, data)
goffi@necton2
parents:
diff changeset
709
goffi@necton2
parents:
diff changeset
710 def registerProgressCB(self, id, CB):
goffi@necton2
parents:
diff changeset
711 """Register a callback called when progress is requested for id"""
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
712 self.__progress_cb_map[id] = CB
0
goffi@necton2
parents:
diff changeset
713
goffi@necton2
parents:
diff changeset
714 def removeProgressCB(self, id):
goffi@necton2
parents:
diff changeset
715 """Remove a progress callback"""
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
716 if not self.__progress_cb_map.has_key(id):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
717 error (_("Trying to remove an unknow progress callback"))
0
goffi@necton2
parents:
diff changeset
718 else:
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
719 del self.__progress_cb_map[id]
0
goffi@necton2
parents:
diff changeset
720
goffi@necton2
parents:
diff changeset
721 def getProgress(self, id):
goffi@necton2
parents:
diff changeset
722 """Return a dict with progress information
goffi@necton2
parents:
diff changeset
723 data['position'] : current possition
goffi@necton2
parents:
diff changeset
724 data['size'] : end_position
goffi@necton2
parents:
diff changeset
725 """
goffi@necton2
parents:
diff changeset
726 data = {}
goffi@necton2
parents:
diff changeset
727 try:
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
728 self.__progress_cb_map[id](data)
0
goffi@necton2
parents:
diff changeset
729 except KeyError:
goffi@necton2
parents:
diff changeset
730 pass
goffi@necton2
parents:
diff changeset
731 #debug("Requested progress for unknown id")
goffi@necton2
parents:
diff changeset
732 return data
goffi@necton2
parents:
diff changeset
733
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
734 def registerGeneralCB(self, name, CB):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
735 """Register a callback called for general reason"""
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
736 self.__general_cb_map[name] = CB
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
737
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
738 def removeGeneralCB(self, name):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
739 """Remove a general callback"""
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
740 if not self.__general_cb_map.has_key(name):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
741 error (_("Trying to remove an unknow general callback"))
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
742 else:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
743 del self.__general_cb_map[name]
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
744
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
745 def callGeneralCB(self, name, *args, **kwargs):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
746 """Call general function back"""
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
747 try:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
748 return self.__general_cb_map[name](*args, **kwargs)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
749 except KeyError:
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
750 error(_("Trying to call unknown function (%s)") % name)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
751 return None
0
goffi@necton2
parents:
diff changeset
752
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
753 #Menus management
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
754
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
755 def importMenu(self, category, name, callback, help_string = "", type = "NORMAL"):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
756 """register a new menu for frontends
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
757 @param category: category of the menu
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
758 @param name: menu item entry
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
759 @param callback: method to be called when menuitem is selected"""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
760 if self.menus.has_key((category,name)):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
761 error ("Want to register a menu which already existe")
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
762 return
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
763 self.menus[(category,name,type)] = {'callback':callback, 'help_string':help_string, 'type':type}
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
764
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
765 def getMenus(self):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
766 """Return all menus registered"""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
767 return self.menus.keys()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
768
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
769 def getMenuHelp(self, category, name, type="NORMAL"):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
770 """return the help string of the menu"""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
771 try:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
772 return self.menus[(category,name,type)]['help_string']
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
773 except KeyError:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
774 error (_("Trying to access an unknown menu"))
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
775 return ""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
776
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
777 def callMenu(self, category, name, type="NORMAL", profile_key='@DEFAULT@'):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
778 """return the help string of the menu"""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
779 profile = self.memory.getProfileName(profile_key)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
780 if not profile_key:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
781 error (_('Non-exsitant profile'))
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
782 return ""
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
783 if self.menus.has_key((category,name,type)):
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
784 id = self.get_next_id()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
785 self.menus[(category,name,type)]['callback'](id, profile)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
786 return id
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
787 else:
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
788 error (_("Trying to access an unknown menu (%(category)s/%(name)s/%(type)s)")%{'category':category, 'name':name,'type':type})
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
789 return ""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
790
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
791
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 90
diff changeset
792
2
c49345fd7737 refactoring: moved sat to sat.tac, now a twisted application so we can use twistd.
Goffi <goffi@goffi.org>
parents: 1
diff changeset
793 application = service.Application('SàT')
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 12
diff changeset
794 service = SAT()
2
c49345fd7737 refactoring: moved sat to sat.tac, now a twisted application so we can use twistd.
Goffi <goffi@goffi.org>
parents: 1
diff changeset
795 service.setServiceParent(application)