annotate src/bridge/DBus.py @ 262:af3d4f11fe43

Added management of connection error - core: connection_error signal is sent if it's impossible to connect - bridge: added connection_error signal - quick_frontend: an error_message is shown when a connection_error is received
author Goffi <goffi@goffi.org>
date Sat, 22 Jan 2011 15:53:56 +0100
parents c8406fe5e81e
children c4b84a2d2ad1
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
228
b1794cbb88e5 2011 copyright upgrade
Goffi <goffi@goffi.org>
parents: 224
diff changeset
6 Copyright (C) 2009, 2010, 2011 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
goffi@necton2
parents:
diff changeset
22
goffi@necton2
parents:
diff changeset
23 from bridge import Bridge
goffi@necton2
parents:
diff changeset
24 import dbus
goffi@necton2
parents:
diff changeset
25 import dbus.service
goffi@necton2
parents:
diff changeset
26 import dbus.mainloop.glib
goffi@necton2
parents:
diff changeset
27 import pdb
goffi@necton2
parents:
diff changeset
28 from logging import debug, info, error
goffi@necton2
parents:
diff changeset
29
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
30 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
31 const_COMM_SUFFIX = ".communication"
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
32 const_REQ_SUFFIX = ".request"
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
33
0
goffi@necton2
parents:
diff changeset
34 class DbusObject(dbus.service.Object):
goffi@necton2
parents:
diff changeset
35
goffi@necton2
parents:
diff changeset
36 def __init__(self, bus, path):
goffi@necton2
parents:
diff changeset
37 dbus.service.Object.__init__(self, bus, path)
goffi@necton2
parents:
diff changeset
38 debug("Init DbusObject...")
goffi@necton2
parents:
diff changeset
39 self.cb={}
goffi@necton2
parents:
diff changeset
40
goffi@necton2
parents:
diff changeset
41 def register(self, name, cb):
goffi@necton2
parents:
diff changeset
42 self.cb[name]=cb
goffi@necton2
parents:
diff changeset
43
goffi@necton2
parents:
diff changeset
44 ### signals ###
goffi@necton2
parents:
diff changeset
45
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
46 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
47 signature='s')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
48 def connected(self, profile):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
49 debug("Connected signal")
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
50
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
51 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
52 signature='s')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
53 def disconnected(self, profile):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
54 debug("Disconnected signal")
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
55
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
56 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
262
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
57 signature='ss')
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
58 def connection_error(self, profile, error_type):
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
59 debug("Connection_error signal")
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
60
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
61 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
62 signature='sa{ss}ass')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
63 def newContact(self, contact, attributes, groups, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
64 debug("new contact signal (%s) sended (profile: %s)", contact, profile)
0
goffi@necton2
parents:
diff changeset
65
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
66 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
67 signature='sssss')
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
68 def newMessage(self, from_jid, msg, type, to, profile):
0
goffi@necton2
parents:
diff changeset
69 debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to)
goffi@necton2
parents:
diff changeset
70
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
71 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
72 signature='ssss')
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
73 def newAlert(self, msg, title, type, profile):
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
74 debug("new alert signal (title:%s type:%s msg:%s profile:%s) sended", type, title, msg, profile)
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
75
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
76 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
77 signature='ssia{ss}s')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
78 def presenceUpdate(self, entity, show, priority, statuses, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
79 debug("presence update signal (from:%s show:%s priority:%d statuses:%s profile:%s) sended" , entity, show, priority, statuses, profile)
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
80
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
81 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
82 signature='sss')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
83 def subscribe(self, type, entity, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
84 debug("subscribe (type: [%s] from:[%s] profile:[%s])" , type, entity, profile)
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
85
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
86 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
87 signature='ssss')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
88 def paramUpdate(self, name, value, category, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
89 debug("param update signal: %s=%s in category %s (profile: %s)", name, value, category, profile)
0
goffi@necton2
parents:
diff changeset
90
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
91 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
92 signature='ss')
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
93 def contactDeleted(self, entity, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
94 debug("contact deleted signal: %s (profile: %s)", entity, profile)
0
goffi@necton2
parents:
diff changeset
95
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
96 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
0
goffi@necton2
parents:
diff changeset
97 signature='ssa{ss}')
goffi@necton2
parents:
diff changeset
98 def askConfirmation(self, type, id, data):
goffi@necton2
parents:
diff changeset
99 debug("asking for confirmation: id = [%s] type = %s data = %s", id, type, data)
goffi@necton2
parents:
diff changeset
100
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
101 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
102 signature='ssa{ss}')
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
103 def actionResult(self, type, id, data):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
104 debug("result of action: id = [%s] type = %s data = %s", id, type, data)
0
goffi@necton2
parents:
diff changeset
105
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
106 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
107 signature='ssa{sa{ss}}')
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
108 def actionResultExt(self, type, id, data):
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
109 debug("extended result of action: id = [%s] type = %s data = %s", id, type, data)
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
110
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
111 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
112 signature='sa{ss}')
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
113 def updatedValue(self, name, value):
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
114 debug("updated value: %s = %s", name, value)
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
115
0
goffi@necton2
parents:
diff changeset
116 ### methods ###
goffi@necton2
parents:
diff changeset
117
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
118
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
119 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
120 in_signature='', out_signature='s')
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
121 def getVersion(self):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
122 return self.cb["getVersion"]()
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
123
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
124 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
125 in_signature='s', out_signature='s')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
126 def getProfileName(self, profile_key):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
127 return self.cb["getProfileName"](profile_key)
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
128
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
129 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
130 in_signature='', out_signature='as')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
131 def getProfilesList(self):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
132 info ('Profile list asked')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
133 return self.cb["getProfilesList"]()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
134
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
135 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
136 in_signature='s', out_signature='i')
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
137 def createProfile(self, name):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
138 info ('Profile creation asked')
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 128
diff changeset
139 return self.cb["createProfile"](unicode(name))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
140
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
141 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
142 in_signature='s', out_signature='i')
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
143 def deleteProfile(self, name):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
144 info ('Profile deletion asked')
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
145 return self.cb["deleteProfile"](str(name))
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
146
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
147 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
148 in_signature='sssi', out_signature='s')
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
149 def registerNewAccount(self, login, password, host, port=5222):
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
150 info ("New account registration asked")
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
151 return self.cb["registerNewAccount"](login, password, host, port)
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
152
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
153 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
154 in_signature='s', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
155 def connect(self, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
156 info ("Connection asked")
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 74
diff changeset
157 return self.cb["connect"](profile_key)
0
goffi@necton2
parents:
diff changeset
158
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
159 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
160 in_signature='s', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
161 def disconnect(self, profile_key='@DEFAULT@'):
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
162 info ("Disconnection asked")
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
163 return self.cb["disconnect"](profile_key)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
164
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
165 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
166 in_signature='', out_signature='b')
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
167 def isConnected(self, profile_key='@DEFAULT@'):
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
168 info ("Connection status asked")
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
169 return self.cb["isConnected"](profile_key)
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
170
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
171 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
172 in_signature='s', out_signature='a(sa{ss}as)')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
173 def getContacts(self, profile_key='@DEFAULT@'):
0
goffi@necton2
parents:
diff changeset
174 debug("getContacts...")
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
175 return self.cb["getContacts"](profile_key)
0
goffi@necton2
parents:
diff changeset
176
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
177 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
178 in_signature='s', out_signature='a{sa{s(sia{ss})}}')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
179 def getPresenceStatus(self, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
180 debug("getPresenceStatus...")
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
181 return self.cb["getPresenceStatus"](profile_key)
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
182
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
183 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
184 in_signature='s', out_signature='a{ss}')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
185 def getWaitingSub(self, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
186 debug("getWaitingSub...")
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
187 return self.cb["getWaitingSub"](profile_key)
0
goffi@necton2
parents:
diff changeset
188
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
189 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
260
c8406fe5e81e Added SMTP server plugin, for sending messages from classic MUA \o/
Goffi <goffi@goffi.org>
parents: 228
diff changeset
190 in_signature='sssss', out_signature='')
c8406fe5e81e Added SMTP server plugin, for sending messages from classic MUA \o/
Goffi <goffi@goffi.org>
parents: 228
diff changeset
191 def sendMessage(self, to, message, subject="", type='chat', profile_key='@DEFAULT@'):
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
192 debug("sendMessage...")
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
193 print "sendtype=", type #gof
260
c8406fe5e81e Added SMTP server plugin, for sending messages from classic MUA \o/
Goffi <goffi@goffi.org>
parents: 228
diff changeset
194 self.cb["sendMessage"](to, message, subject, type, profile_key)
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
195
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
196 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
197 in_signature='ssia{ss}s', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
198 def setPresence(self, to="", show="", priority=0, statuses={}, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
199 self.cb["setPresence"](to, show, priority, statuses, profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
200
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
201 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
202 in_signature='sss', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
203 def subscription(self, type, entity, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
204 self.cb["subscription"](type, entity, profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
205
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
206 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
207 in_signature='ssss', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
208 def setParam(self, name, value, category, profile_key='@DEFAULT@'):
128
2240f34f6452 Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents: 119
diff changeset
209 self.cb["setParam"](unicode(name), unicode(value), unicode(category), profile_key)
0
goffi@necton2
parents:
diff changeset
210
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
211 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
212 in_signature='sss', out_signature='s')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
213 def getParamA(self, name, category="default", profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
214 return self.cb["getParamA"](name, category, profile_key = profile_key)
0
goffi@necton2
parents:
diff changeset
215
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
216
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
217 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
218 in_signature='s', out_signature='s')
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
219 def getParamsUI(self, profile_key='@DEFAULT@'):
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
220 return self.cb["getParamsUI"](profile_key)
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
221
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
222 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
223 in_signature='s', out_signature='s')
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
224 def getParams(self, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
225 return self.cb["getParams"](profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
226
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
227 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
228 in_signature='ss', out_signature='s')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
229 def getParamsForCategory(self, category, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
230 return self.cb["getParamsForCategory"](category, profile_key)
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
231
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
232 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
0
goffi@necton2
parents:
diff changeset
233 in_signature='', out_signature='as')
goffi@necton2
parents:
diff changeset
234 def getParamsCategories(self):
goffi@necton2
parents:
diff changeset
235 return self.cb["getParamsCategories"]()
goffi@necton2
parents:
diff changeset
236
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
237 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
0
goffi@necton2
parents:
diff changeset
238 in_signature='ssi', out_signature='a{i(ss)}')
goffi@necton2
parents:
diff changeset
239 def getHistory(self, from_jid, to_jid, size):
goffi@necton2
parents:
diff changeset
240 debug("History asked for %s", to_jid)
goffi@necton2
parents:
diff changeset
241 return self.cb["getHistory"](from_jid, to_jid, size)
goffi@necton2
parents:
diff changeset
242
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
243 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
244 in_signature='ss', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
245 def addContact(self, entity, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
246 debug("Subscription asked for %s (profile %s)", entity, profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
247 return self.cb["addContact"](entity, profile_key)
0
goffi@necton2
parents:
diff changeset
248
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
249 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
250 in_signature='ss', out_signature='')
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
251 def delContact(self, entity, profile_key='@DEFAULT@'):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
252 debug("Unsubscription asked for %s (profile %s)", entity, profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
253 return self.cb["delContact"](entity, profile_key)
0
goffi@necton2
parents:
diff changeset
254
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
255 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
135
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 128
diff changeset
256 in_signature='sa{ss}s', out_signature='s')
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 128
diff changeset
257 def launchAction(self, type, data, profile_key='@DEFAULT@'):
7452ac3818e7 Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
Goffi <goffi@goffi.org>
parents: 128
diff changeset
258 return self.cb["launchAction"](type, data, profile_key)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
259
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
260 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
0
goffi@necton2
parents:
diff changeset
261 in_signature='sba{ss}', out_signature='')
goffi@necton2
parents:
diff changeset
262 def confirmationAnswer(self, id, accepted, data):
goffi@necton2
parents:
diff changeset
263 debug("Answer for confirmation [%s]: %s", id, "Accepted" if accepted else "Refused")
goffi@necton2
parents:
diff changeset
264 return self.cb["confirmationAnswer"](id, accepted, data)
goffi@necton2
parents:
diff changeset
265
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 25
diff changeset
266
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 25
diff changeset
267 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
0
goffi@necton2
parents:
diff changeset
268 in_signature='s', out_signature='a{ss}')
goffi@necton2
parents:
diff changeset
269 def getProgress(self, id):
goffi@necton2
parents:
diff changeset
270 #debug("Progress asked for %s", id)
goffi@necton2
parents:
diff changeset
271 return self.cb["getProgress"](id)
goffi@necton2
parents:
diff changeset
272
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
273 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
274 in_signature='', out_signature='a(sss)')
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
275 def getMenus(self):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
276 return self.cb["getMenus"]()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
277
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
278 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
279 in_signature='sss', out_signature='s')
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
280 def getMenuHelp(self, category, name, type="NORMAL"):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
281 return self.cb["getMenuHelp"](category, name, type)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
282
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
283 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
284 in_signature='ssss', out_signature='s')
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
285 def callMenu(self, category, name, type, profile_key):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
286 return self.cb["callMenu"](category, name, type, profile_key)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
287
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
288 def __attribute_string(self, in_sign):
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
289 i=0
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
290 idx=0
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
291 attr_string=""
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
292 while i<len(in_sign):
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
293 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']:
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
294 raise Exception #FIXME: create an exception here (unmanaged attribute type)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
295
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
296 attr_string += ("" if idx==0 else ",") + ("arg_%i" % idx)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
297 idx+=1
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
298
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
299 if in_sign[i] == 'a':
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
300 i+=1
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
301 if in_sign[i]!='{' and in_sign[i]!='(': #FIXME: must manage tuples out of arrays
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
302 i+=1
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
303 continue #we have a simple type for the array
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
304 while (True): #we have a dict or a list of tuples
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
305 i+=1
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
306 if i>=len(in_sign):
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
307 raise Exception #FIXME: create an exception here (the '}' is not presend)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
308 if in_sign[i] == '}' or in_sign[i] == ')':
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
309 break
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
310 i+=1
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
311 return attr_string
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
312
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
313
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
314
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
315 def addMethod(self, name, int_suffix, in_sign, out_sign):
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
316 """Dynamically add a method to Dbus Bridge"""
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
317 #FIXME: Better way ???
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
318 attributes = self.__attribute_string(in_sign)
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
319
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
320 code = compile ('def '+name+' (self,'+attributes+'): return self.cb["'+name+'"]('+attributes+')', '<DBus bridge>','exec')
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
321 exec (code)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
322 method = locals()[name]
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
323 setattr(DbusObject, name, dbus.service.method(
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
324 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign)(method))
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
325
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
326 def addSignal(self, name, int_suffix, signature):
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
327 """Dynamically add a signal to Dbus Bridge"""
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
328 #FIXME: Better way ???
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
329 attributes = self.__attribute_string(signature)
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
330
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
331 code = compile ('def '+name+' (self,'+attributes+'): debug ("'+name+' signal")', '<DBus bridge>','exec')
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
332 exec (code)
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
333 signal = locals()[name]
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
334 setattr(DbusObject, name, dbus.service.signal(
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
335 const_INT_PREFIX+int_suffix, signature=signature)(signal))
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
336
0
goffi@necton2
parents:
diff changeset
337 class DBusBridge(Bridge):
goffi@necton2
parents:
diff changeset
338 def __init__(self):
goffi@necton2
parents:
diff changeset
339 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
goffi@necton2
parents:
diff changeset
340 Bridge.__init__(self)
goffi@necton2
parents:
diff changeset
341 info ("Init DBus...")
goffi@necton2
parents:
diff changeset
342 self.session_bus = dbus.SessionBus()
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
343 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
0
goffi@necton2
parents:
diff changeset
344 self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge')
goffi@necton2
parents:
diff changeset
345
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
346 def connected(self, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
347 self.dbus_bridge.connected(profile)
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
348
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
349 def disconnected(self, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
350 self.dbus_bridge.disconnected(profile)
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
351
262
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
352 def connection_error(self, profile, error_type):
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
353 self.dbus_bridge.connection_error(profile, error_type)
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
354
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
355 def newContact(self, contact, attributes, groups, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
356 self.dbus_bridge.newContact(contact, attributes, groups, profile)
0
goffi@necton2
parents:
diff changeset
357
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
358 def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'):
0
goffi@necton2
parents:
diff changeset
359 debug("sending message...")
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
360 self.dbus_bridge.newMessage(from_jid, msg, type, to, profile)
0
goffi@necton2
parents:
diff changeset
361
221
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
362 def newAlert(self, msg, title="", alert_type="INFO", profile='@NONE@'):
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
363 self.dbus_bridge.newAlert(msg, title, alert_type, profile)
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 135
diff changeset
364
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
365 def presenceUpdate(self, entity, show, priority, statuses, profile):
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
366 debug("updating presence for %s",entity)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
367 self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
368
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
369 def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
370 self.dbus_bridge.roomJoined(room_id, room_service, room_nicks, user_nick, profile)
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
371
221
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
372 def subscribe(self, sub_type, entity, profile):
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
373 debug("subscribe request for %s",entity)
221
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
374 self.dbus_bridge.subscribe(sub_type, entity, profile)
0
goffi@necton2
parents:
diff changeset
375
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
376 def paramUpdate(self, name, value, category, profile):
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
377 debug("updating param [%s] %s ", category, name)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
378 self.dbus_bridge.paramUpdate(name, value, category, profile)
0
goffi@necton2
parents:
diff changeset
379
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
380 def contactDeleted(self, entity, profile):
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
381 debug("sending contact deleted signal %s ", entity)
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
382 self.dbus_bridge.contactDeleted(entity, profile)
0
goffi@necton2
parents:
diff changeset
383
goffi@necton2
parents:
diff changeset
384 def askConfirmation(self, type, id, data):
goffi@necton2
parents:
diff changeset
385 self.dbus_bridge.askConfirmation(type, id, data)
goffi@necton2
parents:
diff changeset
386
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
387 def actionResult(self, type, id, data):
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
388 self.dbus_bridge.actionResult(type, id, data)
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
389
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
390 def actionResultExt(self, type, id, data):
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
391 self.dbus_bridge.actionResultExt(type, id, data)
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 22
diff changeset
392
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
393 def updatedValue(self, name, value):
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
394 self.dbus_bridge.updatedValue(name, value)
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
395
0
goffi@necton2
parents:
diff changeset
396 def register(self, name, callback):
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
397 debug("registering DBus bridge method [%s]", name)
0
goffi@necton2
parents:
diff changeset
398 self.dbus_bridge.register(name, callback)
goffi@necton2
parents:
diff changeset
399
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
400 def addMethod(self, name, int_suffix, in_sign, out_sign, method):
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
401 """Dynamically add a method to Dbus Bridge"""
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
402 print ("Adding method [%s] to DBus bridge" % name)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
403 self.dbus_bridge.addMethod(name, int_suffix, in_sign, out_sign)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
404 self.register(name, method)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
405
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
406 def addSignal(self, name, int_suffix, signature):
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
407 self.dbus_bridge.addSignal(name, int_suffix, signature)
74
6e3a06b4dd36 plugin xep-0045: added roomUserJoined and roomUserLeft signals
Goffi <goffi@goffi.org>
parents: 73
diff changeset
408 setattr(DBusBridge, name, getattr(self.dbus_bridge, name))
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
409