annotate src/bridge/DBus.py @ 289:0e54b1b0a8c8

xml_tools: added ElementParser for raw xml -> domish.Element conversion
author Goffi <goffi@goffi.org>
date Sun, 06 Feb 2011 23:40:29 +0100
parents c25371424090
children 15c8916317d0
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
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
27 from logging import debug, info
0
goffi@necton2
parents:
diff changeset
28
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
29 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
30 const_COMM_SUFFIX = ".communication"
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
31 const_REQ_SUFFIX = ".request"
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
32
0
goffi@necton2
parents:
diff changeset
33 class DbusObject(dbus.service.Object):
goffi@necton2
parents:
diff changeset
34
goffi@necton2
parents:
diff changeset
35 def __init__(self, bus, path):
goffi@necton2
parents:
diff changeset
36 dbus.service.Object.__init__(self, bus, path)
goffi@necton2
parents:
diff changeset
37 debug("Init DbusObject...")
goffi@necton2
parents:
diff changeset
38 self.cb={}
goffi@necton2
parents:
diff changeset
39
goffi@necton2
parents:
diff changeset
40 def register(self, name, cb):
goffi@necton2
parents:
diff changeset
41 self.cb[name]=cb
goffi@necton2
parents:
diff changeset
42
goffi@necton2
parents:
diff changeset
43 ### signals ###
goffi@necton2
parents:
diff changeset
44
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
45 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
46 signature='ssa{ss}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
47 def actionResult(self, answer_type, id, data):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
48 debug ("actionResult")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
49
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
50 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
51 signature='ssa{sa{ss}}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
52 def actionResultExt(self, answer_type, id, data):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
53 debug ("actionResultExt")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
54
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
55 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
56 signature='ssa{ss}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
57 def askConfirmation(self, conf_type, id, data):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
58 debug ("askConfirmation")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
59
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
60 @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
61 signature='s')
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
62 def connected(self, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
63 debug ("connected")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
64
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 49
diff changeset
65 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
262
af3d4f11fe43 Added management of connection error
Goffi <goffi@goffi.org>
parents: 260
diff changeset
66 signature='ss')
274
c1ad04586edf Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents: 272
diff changeset
67 def connectionError(self, error_type, profile):
c1ad04586edf Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents: 272
diff changeset
68 debug ("connectionError")
0
goffi@necton2
parents:
diff changeset
69
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
70 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
71 signature='ss')
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
72 def contactDeleted(self, entity, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
73 debug ("contactDeleted")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
74
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
75 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
76 signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
77 def disconnected(self, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
78 debug ("disconnected")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
79
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
80 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
81 signature='ssss')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
82 def newAlert(self, message, title, alert_type, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
83 debug ("newAlert")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
84
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
85 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
86 signature='sa{ss}ass')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
87 def newContact(self, contact, attributes, groups, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
88 debug ("newContact")
0
goffi@necton2
parents:
diff changeset
89
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
90 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
91 signature='sssss')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
92 def newMessage(self, from_jid, message, mess_type, to_jid, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
93 debug ("newMessage")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
94
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
95 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
96 signature='ssss')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
97 def paramUpdate(self, name, value, category, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
98 debug ("paramUpdate")
0
goffi@necton2
parents:
diff changeset
99
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
100 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
101 signature='ssia{ss}s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
102 def presenceUpdate(self, entity, show, priority, statuses, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
103 debug ("presenceUpdate")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
104
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
105 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
106 signature='sss')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
107 def subscribe(self, sub_type, entity, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
108 debug ("subscribe")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
109
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
110 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
111 signature='sa{ss}')
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
112 def updatedValue(self, name, value):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
113 debug ("updatedValue")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
114
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
115
0
goffi@necton2
parents:
diff changeset
116 ### methods ###
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
117
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
118 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
119 in_signature='ss', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
120 def addContact(self, entity, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
121 debug ("addContact")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
122 return self.cb["addContact"](unicode(entity), unicode(profile_key))
0
goffi@necton2
parents:
diff changeset
123
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
124 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
125 in_signature='ssss', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
126 def callMenu(self, category, name, menu_type, profile_key):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
127 debug ("callMenu")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
128 return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
129
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
130 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
131 in_signature='sba{ss}', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
132 def confirmationAnswer(self, id, accepted, data):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
133 debug ("confirmationAnswer")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
134 return self.cb["confirmationAnswer"](unicode(id), accepted, data)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
135
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
136 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
137 in_signature='s', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
138 def connect(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
139 debug ("connect")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
140 return self.cb["connect"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
141
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
142 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
143 in_signature='s', out_signature='i')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
144 def createProfile(self, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
145 debug ("createProfile")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
146 return self.cb["createProfile"](unicode(profile))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
147
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
148 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
149 in_signature='ss', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
150 def delContact(self, entity, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
151 debug ("delContact")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
152 return self.cb["delContact"](unicode(entity), unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
153
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
154 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
155 in_signature='s', out_signature='i')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
156 def deleteProfile(self, profile):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
157 debug ("deleteProfile")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
158 return self.cb["deleteProfile"](unicode(profile))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
159
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
160 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
161 in_signature='s', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
162 def disconnect(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
163 debug ("disconnect")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
164 return self.cb["disconnect"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
165
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
166 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
167 in_signature='s', out_signature='a(sa{ss}as)')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
168 def getContacts(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
169 debug ("getContacts")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
170 return self.cb["getContacts"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
171
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
172 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
173 in_signature='ssi', out_signature='a{i(ss)}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
174 def getHistory(self, from_jid, to_jid, size):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
175 debug ("getHistory")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
176 return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
177
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
178 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
179 in_signature='sss', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
180 def getMenuHelp(self, category, name, menu_type):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
181 debug ("getMenuHelp")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
182 return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
183
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
184 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
185 in_signature='', out_signature='a(sss)')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
186 def getMenus(self, ):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
187 debug ("getMenus")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
188 return self.cb["getMenus"]()
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
189
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
190 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
191 in_signature='ssss', out_signature='s')
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
192 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
193 debug ("getParamA")
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
194 return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key))
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
195
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
196 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
197 in_signature='s', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
198 def getParams(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
199 debug ("getParams")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
200 return self.cb["getParams"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
201
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
202 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
203 in_signature='', out_signature='as')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
204 def getParamsCategories(self, ):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
205 debug ("getParamsCategories")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
206 return self.cb["getParamsCategories"]()
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
207
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
208 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
209 in_signature='ss', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
210 def getParamsForCategory(self, category, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
211 debug ("getParamsForCategory")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
212 return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
213
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
214 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
215 in_signature='s', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
216 def getParamsUI(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
217 debug ("getParamsUI")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
218 return self.cb["getParamsUI"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
219
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
220 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
221 in_signature='s', out_signature='a{sa{s(sia{ss})}}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
222 def getPresenceStatus(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
223 debug ("getPresenceStatus")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
224 return self.cb["getPresenceStatus"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
225
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
226 @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
227 in_signature='s', out_signature='s')
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
228 def getProfileName(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
229 debug ("getProfileName")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
230 return self.cb["getProfileName"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
231
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
232 @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
233 in_signature='', out_signature='as')
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
234 def getProfilesList(self, ):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
235 debug ("getProfilesList")
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
236 return self.cb["getProfilesList"]()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
237
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
238 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
239 in_signature='s', out_signature='a{ss}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
240 def getProgress(self, id):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
241 debug ("getProgress")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
242 return self.cb["getProgress"](unicode(id))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
243
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
244 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
245 in_signature='', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
246 def getVersion(self, ):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
247 debug ("getVersion")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
248 return self.cb["getVersion"]()
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
249
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
250 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
251 in_signature='s', out_signature='a{ss}')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
252 def getWaitingSub(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
253 debug ("getWaitingSub")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
254 return self.cb["getWaitingSub"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
255
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
256 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
257 in_signature='s', out_signature='b')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
258 def isConnected(self, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
259 debug ("isConnected")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
260 return self.cb["isConnected"](unicode(profile_key))
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
261
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
262 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
263 in_signature='sa{ss}s', out_signature='s')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
264 def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
265 debug ("launchAction")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
266 return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key))
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
267
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
268 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
269 in_signature='sssi', out_signature='s')
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
270 def registerNewAccount(self, login, password, host, port=5222):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
271 debug ("registerNewAccount")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
272 return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port)
0
goffi@necton2
parents:
diff changeset
273
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
274 @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
275 in_signature='sssss', out_signature='')
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
276 def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
277 debug ("sendMessage")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
278 return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
279
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 61
diff changeset
280 @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
281 in_signature='ssss', out_signature='')
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
282 def setParam(self, name, value, category, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
283 debug ("setParam")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
284 return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key))
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
285
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 101
diff changeset
286 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
287 in_signature='ssia{ss}s', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
288 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
289 debug ("setPresence")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
290 return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key))
0
goffi@necton2
parents:
diff changeset
291
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
292 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
293 in_signature='sss', out_signature='')
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
294 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
295 debug ("subscription")
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
296 return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key))
0
goffi@necton2
parents:
diff changeset
297
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 89
diff changeset
298
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
299 def __attribute_string(self, in_sign):
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
300 """Return arguments to user given a in_sign
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
301 @param in_sign: in_sign in the short form (using s,a,i,b etc)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
302 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")"""
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
303 i=0
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
304 idx=0
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
305 attr_string=""
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
306 while i<len(in_sign):
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
307 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']:
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
308 raise ParseError("Unmanaged attribute type [%c]" % in_sign[i])
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
309
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
310 attr_string += ("" if idx==0 else ", ") + ("arg_%i" % idx)
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
311 idx+=1
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 if in_sign[i] == 'a':
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
314 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
315 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
316 i+=1
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
317 continue #we have a simple type for the array
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
318 opening_car = in_sign[i]
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
319 assert(opening_car in ['{','('])
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
320 closing_car = '}' if opening_car == '{' else ')'
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
321 opening_count = 1
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
322 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
323 i+=1
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
324 if i>=len(in_sign):
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
325 raise ParseError("missing }")
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
326 if in_sign[i] == opening_car:
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
327 opening_count+=1
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
328 if in_sign[i] == closing_car:
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
329 opening_count-=1
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
330 if opening_count == 0:
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
331 break
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
332 i+=1
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
333 return attr_string
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
334
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
335 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
336 """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
337 #FIXME: Better way ???
16
0a024d5e0cd0 New account creation (in-band registration)
Goffi <goffi@goffi.org>
parents: 10
diff changeset
338 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
339
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
340 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
341 exec (code)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
342 method = locals()[name]
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
343 setattr(DbusObject, name, dbus.service.method(
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
344 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign)(method))
284
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
345 function = getattr(self, name)
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
346 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface]
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
347 func_table[function.__name__] = function #Needed for introspection
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
348
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
349 def addSignal(self, name, int_suffix, signature):
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
350 """Dynamically add a signal to Dbus Bridge"""
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
351 #FIXME: Better way ???
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
352 attributes = self.__attribute_string(signature)
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
353
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
354 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
355 exec (code)
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
356 signal = locals()[name]
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
357 setattr(DbusObject, name, dbus.service.signal(
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
358 const_INT_PREFIX+int_suffix, signature=signature)(signal))
284
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
359 function = getattr(self, name)
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
360 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface]
c25371424090 dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents: 274
diff changeset
361 func_table[function.__name__] = function #Needed for introspection
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
362
0
goffi@necton2
parents:
diff changeset
363 class DBusBridge(Bridge):
goffi@necton2
parents:
diff changeset
364 def __init__(self):
goffi@necton2
parents:
diff changeset
365 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
goffi@necton2
parents:
diff changeset
366 Bridge.__init__(self)
goffi@necton2
parents:
diff changeset
367 info ("Init DBus...")
goffi@necton2
parents:
diff changeset
368 self.session_bus = dbus.SessionBus()
10
14d7861ca59e refactoring: CONST replaced by const
Goffi <goffi@goffi.org>
parents: 7
diff changeset
369 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
0
goffi@necton2
parents:
diff changeset
370 self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge')
goffi@necton2
parents:
diff changeset
371
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
372 def actionResult(self, answer_type, id, data):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
373 self.dbus_bridge.actionResult(answer_type, id, data)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
374
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
375 def actionResultExt(self, answer_type, id, data):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
376 self.dbus_bridge.actionResultExt(answer_type, id, data)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
377
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
378 def askConfirmation(self, conf_type, id, data):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
379 self.dbus_bridge.askConfirmation(conf_type, id, data)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
380
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
381 def connected(self, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
382 self.dbus_bridge.connected(profile)
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
383
274
c1ad04586edf Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents: 272
diff changeset
384 def connectionError(self, error_type, profile):
c1ad04586edf Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents: 272
diff changeset
385 self.dbus_bridge.connectionError(error_type, profile)
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
386
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
387 def contactDeleted(self, entity, profile):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
388 self.dbus_bridge.contactDeleted(entity, profile)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
389
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
390 def disconnected(self, profile):
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
391 self.dbus_bridge.disconnected(profile)
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
392
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
393 def newAlert(self, message, title, alert_type, profile):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
394 self.dbus_bridge.newAlert(message, title, alert_type, profile)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
395
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
396 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
397 self.dbus_bridge.newContact(contact, attributes, groups, profile)
0
goffi@necton2
parents:
diff changeset
398
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
399 def newMessage(self, from_jid, message, mess_type, to_jid, profile):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
400 self.dbus_bridge.newMessage(from_jid, message, mess_type, to_jid, profile)
0
goffi@necton2
parents:
diff changeset
401
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
402 def paramUpdate(self, name, value, category, profile):
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
403 self.dbus_bridge.paramUpdate(name, value, category, profile)
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
404
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
405 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
406 self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile)
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
407
221
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
408 def subscribe(self, sub_type, entity, profile):
96186f36d8cb bridge: fixed newAlert parameters order
Goffi <goffi@goffi.org>
parents: 182
diff changeset
409 self.dbus_bridge.subscribe(sub_type, entity, profile)
0
goffi@necton2
parents:
diff changeset
410
49
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
411 def updatedValue(self, name, value):
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
412 self.dbus_bridge.updatedValue(name, value)
9c79eb49d51f DBus bridge improvment:
Goffi <goffi@goffi.org>
parents: 37
diff changeset
413
267
bdcd535e179e Bridge constructor:
Goffi <goffi@goffi.org>
parents: 266
diff changeset
414
0
goffi@necton2
parents:
diff changeset
415 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
416 debug("registering DBus bridge method [%s]", name)
0
goffi@necton2
parents:
diff changeset
417 self.dbus_bridge.register(name, callback)
goffi@necton2
parents:
diff changeset
418
7
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
419 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
420 """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
421 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
422 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
423 self.register(name, method)
c14a3a7018a5 added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents: 1
diff changeset
424
73
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
425 def addSignal(self, name, int_suffix, signature):
9d113b5471e6 Dynamic signal addition in bridge
Goffi <goffi@goffi.org>
parents: 72
diff changeset
426 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
427 setattr(DBusBridge, name, getattr(self.dbus_bridge, name))