Mercurial > libervia-backend
annotate frontends/sat_bridge_frontend/DBus.py @ 51:8c67ea98ab91
frontend improved to take into account new SàT features
- quick_frontend: better use of contact management, it now manages nicks, avatars, and connected status
- quick_frontend: disconnect and remove are now 2 separate methods for contact list
- wix: new contact list using HTML items, and showing avatars. Groups are not showed for now
- wix: contact status now use tuples, to keep order, human readable status and color of contact
- wix: contact list is updated when avatar or nick is found
- wix: fixed 'question' dialog, which is renamed in 'yes/no'
- wix: action result are now ignored for unkwnown id
- sortilege refactored to work again
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 07 Jan 2010 00:17:27 +1100 |
parents | 8a438a6ff587 |
children | a5b5fb5fc9fd |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT communication bridge | |
6 Copyright (C) 2009 Jérôme Poisson (goffi@goffi.org) | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 from bridge_frontend import BridgeFrontend | |
23 import dbus, dbus.glib | |
24 | |
25 | |
26 class DBusBridgeFrontend(BridgeFrontend): | |
27 def __init__(self): | |
28 self.sessions_bus = dbus.SessionBus() | |
29 self.db_object = self.sessions_bus.get_object('org.goffi.SAT', | |
30 '/org/goffi/SAT/bridge') | |
31 self.db_comm_iface = dbus.Interface(self.db_object, | |
32 dbus_interface='org.goffi.SAT.communication') | |
33 self.db_req_iface = dbus.Interface(self.db_object, | |
34 dbus_interface='org.goffi.SAT.request') | |
35 #props = self.db_comm_iface.getProperties() | |
36 | |
37 def register(self, functionName, handler, iface="communication"): | |
38 if iface == "communication": | |
39 self.db_comm_iface.connect_to_signal(functionName, handler) | |
40 elif iface == "request": | |
41 self.db_req_iface.connect_to_signal(functionName, handler) | |
42 | |
43 def connect(self): | |
44 return self.db_comm_iface.connect() | |
45 | |
1 | 46 def disconnect(self): |
47 return self.db_comm_iface.disconnect() | |
48 | |
0 | 49 def getContacts(self): |
50 return self.db_comm_iface.getContacts() | |
51 | |
52 def getPresenceStatus(self): | |
53 return self.db_comm_iface.getPresenceStatus() | |
54 | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
55 def getWaitingSub(self): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
56 return self.db_comm_iface.getWaitingSub() |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
57 |
0 | 58 def sendMessage(self, to, message): |
59 return self.db_comm_iface.sendMessage(to, message) | |
60 | |
61 def sendFile(self, to, path): | |
62 return self.db_comm_iface.sendFile(to, path) | |
63 | |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
64 def findGateways(self, target): |
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
65 return self.db_comm_iface.findGateways(target) |
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
66 |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
67 def getProfile(self, target): |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
68 return self.db_comm_iface.getProfile(target) |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
69 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
70 def getProfileCache(self, target): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
71 return self.db_comm_iface.getProfileCache(target) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
72 |
43 | 73 def getAvatarFile(self, hash): |
74 return self.db_comm_iface.getAvatarFile(hash) | |
75 | |
30
d6b613764dd7
new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
76 def in_band_register(self, target): |
d6b613764dd7
new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
77 return self.db_comm_iface.in_band_register(target) |
d6b613764dd7
new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
78 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
79 def setPresence(self, to="", show="", priority=0, statuses={}): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
80 return self.db_comm_iface.setPresence(to, show, priority, statuses) |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
81 |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
82 def subscription(self, type, entity): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
83 return self.db_comm_iface.subscription(type, entity) |
0 | 84 |
18
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
85 def setParam(self, name, value, category): |
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
86 return self.db_comm_iface.setParam(name, value, category) |
0 | 87 |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
88 def getParamA(self, name, category): |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
89 return self.db_comm_iface.getParamA(name, category) |
0 | 90 |
18
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
91 def getParams(self): |
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
92 return self.db_comm_iface.getParams() |
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
93 |
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
94 def getParamsForCategory(self, category): |
6928e3cb73a8
refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
95 return self.db_comm_iface.getParamsForCategory(category) |
0 | 96 |
97 def getParamsCategories(self): | |
98 return self.db_comm_iface.getParamsCategories() | |
99 | |
100 def getHistory(self, from_jid, to_jid, size): | |
101 return self.db_comm_iface.getHistory(from_jid, to_jid, size) | |
102 | |
103 def addContact(self, jid): | |
104 return self.db_comm_iface.addContact(jid) | |
105 | |
106 def delContact(self, jid): | |
107 return self.db_comm_iface.delContact(jid) | |
108 | |
109 def isConnected(self): | |
110 return self.db_comm_iface.isConnected() | |
111 | |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
112 def launchAction(self, type, data): |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
113 return self.db_req_iface.launchAction(type, data) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
114 |
0 | 115 def confirmationAnswer(self, id, accepted, data): |
116 return self.db_req_iface.confirmationAnswer(id, accepted, data) | |
117 | |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
118 def gatewayRegister(self, action, target, data): |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
119 if data == None: |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
120 data = [('', '')] #XXX: we have to this awful hack because python dbus need to guess the signature |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
121 return self.db_req_iface.gatewayRegister(action, target, data) |
36 | 122 |
0 | 123 def getProgress(self, id): |
124 return self.db_req_iface.getProgress(id) |