annotate frontends/sat_bridge_frontend/DBus.py @ 65:d35c5edab53f

SàT: multi-profile: memory & dbus bridge's methods profile management /!\ profiles not managed yet for dbus signals
author Goffi <goffi@goffi.org>
date Sun, 31 Jan 2010 15:57:03 +1100
parents d46f849664aa
children 8147b4f40809
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 communication bridge
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 51
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
goffi@necton2
parents:
diff changeset
22 from bridge_frontend import BridgeFrontend
goffi@necton2
parents:
diff changeset
23 import dbus, dbus.glib
goffi@necton2
parents:
diff changeset
24
goffi@necton2
parents:
diff changeset
25
goffi@necton2
parents:
diff changeset
26 class DBusBridgeFrontend(BridgeFrontend):
goffi@necton2
parents:
diff changeset
27 def __init__(self):
goffi@necton2
parents:
diff changeset
28 self.sessions_bus = dbus.SessionBus()
goffi@necton2
parents:
diff changeset
29 self.db_object = self.sessions_bus.get_object('org.goffi.SAT',
goffi@necton2
parents:
diff changeset
30 '/org/goffi/SAT/bridge')
goffi@necton2
parents:
diff changeset
31 self.db_comm_iface = dbus.Interface(self.db_object,
goffi@necton2
parents:
diff changeset
32 dbus_interface='org.goffi.SAT.communication')
goffi@necton2
parents:
diff changeset
33 self.db_req_iface = dbus.Interface(self.db_object,
goffi@necton2
parents:
diff changeset
34 dbus_interface='org.goffi.SAT.request')
goffi@necton2
parents:
diff changeset
35 #props = self.db_comm_iface.getProperties()
goffi@necton2
parents:
diff changeset
36
goffi@necton2
parents:
diff changeset
37 def register(self, functionName, handler, iface="communication"):
goffi@necton2
parents:
diff changeset
38 if iface == "communication":
goffi@necton2
parents:
diff changeset
39 self.db_comm_iface.connect_to_signal(functionName, handler)
goffi@necton2
parents:
diff changeset
40 elif iface == "request":
goffi@necton2
parents:
diff changeset
41 self.db_req_iface.connect_to_signal(functionName, handler)
goffi@necton2
parents:
diff changeset
42
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
43 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
44 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
45
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
46 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
47 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
48
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
49 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
50 return self.db_comm_iface.isConnected(profile_key)
0
goffi@necton2
parents:
diff changeset
51
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
52 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
53 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
54
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
55 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
56 return self.db_comm_iface.getPresenceStatus(profile_key)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
57
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
58 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
59 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
60
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
61 def sendMessage(self, to, message, 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.sendMessage(to, message, profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
63
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
64 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
65 return self.db_comm_iface.setPresence(to, show, priority, statuses, profile_key)
0
goffi@necton2
parents:
diff changeset
66
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
67 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
68 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
69
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
70 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
71 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
72
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
73 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
74 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
75
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
76 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
77 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
78
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
79 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
80 return self.db_comm_iface.getParamsForCategory(category, profile_key)
0
goffi@necton2
parents:
diff changeset
81
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
82 def getParamsCategories(self):
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.getParamsCategories(profile_key)
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 43
diff changeset
84
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
85 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
86 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
87
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
88 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
89 return self.db_comm_iface.addContact(jid, profile_key)
0
goffi@necton2
parents:
diff changeset
90
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
91 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
92 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
93
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
94 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
95 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
96
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
97 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
98 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
99
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
100 #methods from plugins
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
101 def sendFile(self, to, path, profile_key='@DEFAULT@'):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
102 return self.db_comm_iface.sendFile(to, path, profile_key)
0
goffi@necton2
parents:
diff changeset
103
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
104 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
105 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
106
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
107 def getCard(self, target, profile_key='@DEFAULT@'):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
108 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
109
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
110 def getCardCache(self, target):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
111 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
112
43
8a438a6ff587 Wix: added avatar in profile
Goffi <goffi@goffi.org>
parents: 42
diff changeset
113 def getAvatarFile(self, hash):
8a438a6ff587 Wix: added avatar in profile
Goffi <goffi@goffi.org>
parents: 42
diff changeset
114 return self.db_comm_iface.getAvatarFile(hash)
8a438a6ff587 Wix: added avatar in profile
Goffi <goffi@goffi.org>
parents: 42
diff changeset
115
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
116 def in_band_register(self, target, profile_key='@DEFAULT@'):
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
117 return self.db_comm_iface.in_band_register(target, profile_key)
0
goffi@necton2
parents:
diff changeset
118
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
119 def gatewayRegister(self, action, target, data):
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
120 if data == None:
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
121 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
122 return self.db_req_iface.gatewayRegister(action, target, data)
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 30
diff changeset
123
0
goffi@necton2
parents:
diff changeset
124 def getProgress(self, id):
goffi@necton2
parents:
diff changeset
125 return self.db_req_iface.getProgress(id)