annotate frontends/sat_bridge_frontend/DBus.py @ 22:bb72c29f3432

added action cb mechanism for buttons. Tested with a temporary new user registration button.
author Goffi <goffi@goffi.org>
date Tue, 01 Dec 2009 04:56:08 +0100
parents 6928e3cb73a8
children 53e921c8a357
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
goffi@necton2
parents:
diff changeset
6 Copyright (C) 2009 Jérôme Poisson (goffi@goffi.org)
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
goffi@necton2
parents:
diff changeset
43 def connect(self):
goffi@necton2
parents:
diff changeset
44 return self.db_comm_iface.connect()
goffi@necton2
parents:
diff changeset
45
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
46 def disconnect(self):
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
47 return self.db_comm_iface.disconnect()
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
48
0
goffi@necton2
parents:
diff changeset
49 def getContacts(self):
goffi@necton2
parents:
diff changeset
50 return self.db_comm_iface.getContacts()
goffi@necton2
parents:
diff changeset
51
goffi@necton2
parents:
diff changeset
52 def getPresenceStatus(self):
goffi@necton2
parents:
diff changeset
53 return self.db_comm_iface.getPresenceStatus()
goffi@necton2
parents:
diff changeset
54
goffi@necton2
parents:
diff changeset
55 def sendMessage(self, to, message):
goffi@necton2
parents:
diff changeset
56 return self.db_comm_iface.sendMessage(to, message)
goffi@necton2
parents:
diff changeset
57
goffi@necton2
parents:
diff changeset
58 def sendFile(self, to, path):
goffi@necton2
parents:
diff changeset
59 return self.db_comm_iface.sendFile(to, path)
goffi@necton2
parents:
diff changeset
60
goffi@necton2
parents:
diff changeset
61 def setPresence(self, to="", type="", show="", status="", priority=0):
goffi@necton2
parents:
diff changeset
62 return self.db_comm_iface.setPresence(to, type, show, status, priority)
goffi@necton2
parents:
diff changeset
63
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
64 def setParam(self, name, value, category):
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
65 return self.db_comm_iface.setParam(name, value, category)
0
goffi@necton2
parents:
diff changeset
66
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
67 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
68 return self.db_comm_iface.getParamA(name, category)
0
goffi@necton2
parents:
diff changeset
69
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
70 def getParams(self):
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
71 return self.db_comm_iface.getParams()
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
72
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
73 def getParamsForCategory(self, category):
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 1
diff changeset
74 return self.db_comm_iface.getParamsForCategory(category)
0
goffi@necton2
parents:
diff changeset
75
goffi@necton2
parents:
diff changeset
76 def getParamsCategories(self):
goffi@necton2
parents:
diff changeset
77 return self.db_comm_iface.getParamsCategories()
goffi@necton2
parents:
diff changeset
78
goffi@necton2
parents:
diff changeset
79 def getHistory(self, from_jid, to_jid, size):
goffi@necton2
parents:
diff changeset
80 return self.db_comm_iface.getHistory(from_jid, to_jid, size)
goffi@necton2
parents:
diff changeset
81
goffi@necton2
parents:
diff changeset
82 def addContact(self, jid):
goffi@necton2
parents:
diff changeset
83 return self.db_comm_iface.addContact(jid)
goffi@necton2
parents:
diff changeset
84
goffi@necton2
parents:
diff changeset
85 def delContact(self, jid):
goffi@necton2
parents:
diff changeset
86 return self.db_comm_iface.delContact(jid)
goffi@necton2
parents:
diff changeset
87
goffi@necton2
parents:
diff changeset
88 def isConnected(self):
goffi@necton2
parents:
diff changeset
89 return self.db_comm_iface.isConnected()
goffi@necton2
parents:
diff changeset
90
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
91 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
92 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
93
0
goffi@necton2
parents:
diff changeset
94 def confirmationAnswer(self, id, accepted, data):
goffi@necton2
parents:
diff changeset
95 return self.db_req_iface.confirmationAnswer(id, accepted, data)
goffi@necton2
parents:
diff changeset
96
goffi@necton2
parents:
diff changeset
97 def getProgress(self, id):
goffi@necton2
parents:
diff changeset
98 return self.db_req_iface.getProgress(id)