Mercurial > libervia-backend
annotate frontends/sat_bridge_frontend/DBus.py @ 101:783e9d6980ec
Couchsurfing plugin: first draft
SàT core: adding additionnal menu method
bridge: new methods getMenus, getMenuHelp and callMenu
wix: new menu are added on startup
CS plugin: login on CS
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Jun 2010 17:15:30 +0800 |
parents | 2503de7fb4c7 |
children | d2630fba8dfd |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT communication bridge | |
57 | 6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org) |
0 | 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 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
43 def getProfileName(self, profile_key='@DEFAULT@'): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
44 return self.db_req_iface.getProfileName(profile_key) |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
45 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
46 def getProfilesList(self): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
47 return self.db_req_iface.getProfilesList() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
48 |
68 | 49 def createProfile(self, name): |
50 return self.db_req_iface.createProfile(name) | |
51 | |
52 def deleteProfile(self, name): | |
53 return self.db_req_iface.deleteProfile(name) | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
54 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
55 def connect(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
56 return self.db_comm_iface.connect(profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
57 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
58 def disconnect(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
59 return self.db_comm_iface.disconnect(profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
60 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
61 def isConnected(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
62 return self.db_comm_iface.isConnected(profile_key) |
0 | 63 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
64 def getContacts(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
65 return self.db_comm_iface.getContacts(profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
66 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
67 def getPresenceStatus(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
68 return self.db_comm_iface.getPresenceStatus(profile_key) |
1 | 69 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
70 def getWaitingSub(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
71 return self.db_comm_iface.getWaitingSub(profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
72 |
67
0e50dd3a234a
message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents:
66
diff
changeset
|
73 def sendMessage(self, to, message, type='chat', profile_key='@DEFAULT@'): |
0e50dd3a234a
message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents:
66
diff
changeset
|
74 return self.db_comm_iface.sendMessage(to, message, type, profile_key) |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
75 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
76 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:
64
diff
changeset
|
77 return self.db_comm_iface.setPresence(to, show, priority, statuses, profile_key) |
0 | 78 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
79 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:
64
diff
changeset
|
80 return self.db_comm_iface.subscription(type, entity, profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
81 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
82 def setParam(self, name, value, category, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
83 return self.db_comm_iface.setParam(name, value, category, profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
84 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
85 def getParamA(self, name, category, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
86 return self.db_comm_iface.getParamA(name, category, profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
87 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
88 def getParams(self, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
89 return self.db_comm_iface.getParams(profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
90 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
91 def getParamsForCategory(self, category, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
92 return self.db_comm_iface.getParamsForCategory(category, profile_key) |
0 | 93 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
94 def getParamsCategories(self): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
95 return self.db_comm_iface.getParamsCategories() |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
96 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
97 def getHistory(self, from_jid, to_jid, size): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
98 return self.db_comm_iface.getHistory(from_jid, to_jid, size) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
99 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
100 def addContact(self, jid, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
101 return self.db_comm_iface.addContact(jid, profile_key) |
0 | 102 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
103 def delContact(self, jid, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
104 return self.db_comm_iface.delContact(jid, profile_key) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
105 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
106 def launchAction(self, type, data): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
107 return self.db_req_iface.launchAction(type, data) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
108 |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
109 def confirmationAnswer(self, id, accepted, data): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
110 return self.db_req_iface.confirmationAnswer(id, accepted, data) |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
111 |
101 | 112 def getProgress(self, id): |
113 return self.db_req_iface.getProgress(id) | |
114 | |
115 def getMenus(self): | |
116 return self.db_req_iface.getMenus() | |
117 | |
118 def getMenuHelp(self, category, name, type="NORMAL"): | |
119 return self.db_req_iface.getMenuHelp(category, name, type) | |
120 | |
121 def callMenu(self, category, name, type="NORMAL", profile_key='@DEFAULT@'): | |
122 return self.db_req_iface.callMenu(category, name, type, profile_key) | |
123 | |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
124 #methods from plugins |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
125 def getRoomJoined(self, profile_key='@DEFAULT@'): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
126 return self.db_comm_iface.getRoomJoined(profile_key) |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
127 |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
128 def getRoomSubjects(self, profile_key='@DEFAULT@'): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
129 return self.db_comm_iface.getRoomSubjects(profile_key) |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
72
diff
changeset
|
130 |
72 | 131 def joinMUC(self, service, roomId, nick, profile_key='@DEFAULT@'): |
132 return self.db_comm_iface.joinMUC(service, roomId, nick, profile_key) | |
133 | |
90 | 134 def tarotGameCreate(self, room_jid, players, profile_key='@DEFAULT@'): |
135 return self.db_comm_iface.tarotGameCreate(room_jid, players, profile_key) | |
136 | |
92 | 137 def tarotGameReady(self, player, referee, profile_key='@DEFAULT@'): |
138 return self.db_comm_iface.tarotGameReady(player, referee, profile_key) | |
85 | 139 |
92 | 140 def tarotGameContratChoosed(self, player, referee, contrat, profile_key='@DEFAULT@'): |
141 return self.db_comm_iface.tarotGameContratChoosed(player, referee, contrat, profile_key) | |
142 | |
143 def tarotGamePlayCards(self, player, referee, cards, profile_key='@DEFAULT@'): | |
144 return self.db_comm_iface.tarotGamePlayCards(player, referee, cards, profile_key) | |
91 | 145 |
64 | 146 def sendFile(self, to, path, profile_key='@DEFAULT@'): |
147 return self.db_comm_iface.sendFile(to, path, profile_key) | |
0 | 148 |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
149 def findGateways(self, target, profile_key='@DEFAULT@'): |
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
150 return self.db_comm_iface.findGateways(target, profile_key) |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
151 |
64 | 152 def getCard(self, target, profile_key='@DEFAULT@'): |
153 return self.db_comm_iface.getCard(target, profile_key) | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
154 |
64 | 155 def getCardCache(self, target): |
156 return self.db_comm_iface.getCardCache(target) | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
157 |
43 | 158 def getAvatarFile(self, hash): |
159 return self.db_comm_iface.getAvatarFile(hash) | |
160 | |
64 | 161 def in_band_register(self, target, profile_key='@DEFAULT@'): |
162 return self.db_comm_iface.in_band_register(target, profile_key) | |
0 | 163 |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
164 def gatewayRegister(self, action, target, data): |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
165 if data == None: |
101 | 166 data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
167 return self.db_req_iface.gatewayRegister(action, target, data) |
36 | 168 |
101 | 169 |