annotate frontends/src/bridge/DBus.py @ 595:1f160467f5de

Fix pep8 support in src/bridge.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:35 +0100
parents 952322b1d490
children 84a6e83157c2
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
572
ca13633d3b6b dates update
Goffi <goffi@goffi.org>
parents: 568
diff changeset
6 Copyright (C) 2009, 2010, 2011, 2012, 2013 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
480
2a072735e459 Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents: 477
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
0
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
480
2a072735e459 Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents: 477
diff changeset
16 GNU Affero General Public License for more details.
0
goffi@necton2
parents:
diff changeset
17
480
2a072735e459 Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents: 477
diff changeset
18 You should have received a copy of the GNU Affero General Public License
0
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
535
790be337cc41 bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents: 504
diff changeset
23 import dbus
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
24 from logging import debug, error
0
goffi@necton2
parents:
diff changeset
25
535
790be337cc41 bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents: 504
diff changeset
26 from dbus.mainloop.glib import DBusGMainLoop
790be337cc41 bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents: 504
diff changeset
27 DBusGMainLoop(set_as_default=True)
790be337cc41 bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents: 504
diff changeset
28
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
29 const_INT_PREFIX = "org.goffi.SAT" # Interface prefix
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
30 const_ERROR_PREFIX = const_INT_PREFIX + ".error"
360
6b5626c37909 bridge: regenerated DBus bridge
Goffi <goffi@goffi.org>
parents: 345
diff changeset
31 const_OBJ_PATH = '/org/goffi/SAT/bridge'
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
32 const_CORE_SUFFIX = ".core"
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
33 const_PLUGIN_SUFFIX = ".plugin"
360
6b5626c37909 bridge: regenerated DBus bridge
Goffi <goffi@goffi.org>
parents: 345
diff changeset
34
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
35
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
36 class BridgeExceptionNoService(Exception):
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
37 pass
0
goffi@necton2
parents:
diff changeset
38
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
39
0
goffi@necton2
parents:
diff changeset
40 class DBusBridgeFrontend(BridgeFrontend):
goffi@necton2
parents:
diff changeset
41 def __init__(self):
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
42 try:
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
43 self.sessions_bus = dbus.SessionBus()
360
6b5626c37909 bridge: regenerated DBus bridge
Goffi <goffi@goffi.org>
parents: 345
diff changeset
44 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
45 const_OBJ_PATH)
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
46 self.db_core_iface = dbus.Interface(self.db_object,
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
47 dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX)
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
48 self.db_plugin_iface = dbus.Interface(self.db_object,
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
49 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX)
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
50 except dbus.exceptions.DBusException, e:
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
51 if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
52 raise BridgeExceptionNoService
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
53 else:
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 136
diff changeset
54 raise e
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
55 #props = self.db_core_iface.getProperties()
0
goffi@necton2
parents:
diff changeset
56
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
57 def register(self, functionName, handler, iface="core"):
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
58 if iface == "core":
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
59 self.db_core_iface.connect_to_signal(functionName, handler)
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
60 elif iface == "plugin":
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
61 self.db_plugin_iface.connect_to_signal(functionName, handler)
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
62 else:
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
63 error(_('Unknown interface'))
0
goffi@necton2
parents:
diff changeset
64
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
65 def __getattribute__(self, name):
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
66 """ usual __getattribute__ if the method exists, else try to find a plugin method """
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
67 try:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
68 return object.__getattribute__(self, name)
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
69 except AttributeError:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
70 # The attribute is not found, we try the plugin proxy to find the requested method
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
71
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
72 def getPluginMethod(*args, **kwargs):
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
73 # We first check if we have an async call. We detect this in two ways:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
74 # - if we have the 'callback' and 'errback' keyword arguments
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
75 # - or if the last two arguments are callable
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
76
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
77 async = False
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
78
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
79 if kwargs:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
80 if 'callback' in kwargs and 'errback' in kwargs:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
81 async = True
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
82 _callback = kwargs.pop('callback')
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
83 _errback = kwargs.pop('errback')
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
84 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]):
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
85 async = True
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
86 args = list(args)
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
87 _errback = args.pop()
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
88 _callback = args.pop()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
89
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
90 method = getattr(self.db_plugin_iface, name)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
91
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
92 if async:
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
93 kwargs['reply_handler'] = _callback
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
94 kwargs['error_handler'] = lambda err: _errback(err._dbus_error_name[len(const_ERROR_PREFIX) + 1:])
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
95
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
96 return method(*args, **kwargs)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
97
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
98 return getPluginMethod
387
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
99 def addContact(self, entity_jid, profile_key="@DEFAULT@"):
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
100 return self.db_core_iface.addContact(entity_jid, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
101
337
4402ac630712 bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents: 336
diff changeset
102 def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
421
28e4299d4553 primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents: 413
diff changeset
103 return self.db_core_iface.asyncConnect(profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]))
28e4299d4553 primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents: 413
diff changeset
104
28e4299d4553 primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents: 413
diff changeset
105 def asyncCreateProfile(self, profile, callback=None, errback=None):
28e4299d4553 primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents: 413
diff changeset
106 return self.db_core_iface.asyncCreateProfile(profile, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]))
337
4402ac630712 bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents: 336
diff changeset
107
413
dd4caab17008 core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents: 405
diff changeset
108 def asyncGetParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
421
28e4299d4553 primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents: 413
diff changeset
109 return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])))
413
dd4caab17008 core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents: 405
diff changeset
110
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
111 def callMenu(self, category, name, menu_type, profile_key):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
112 return unicode(self.db_core_iface.callMenu(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
113
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
114 def confirmationAnswer(self, id, accepted, data, profile):
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
115 return self.db_core_iface.confirmationAnswer(id, accepted, data, profile)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
116
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
117 def connect(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
118 return self.db_core_iface.connect(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
119
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
120 def createProfile(self, profile):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
121 return self.db_core_iface.createProfile(profile)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
122
387
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
123 def delContact(self, entity_jid, profile_key="@DEFAULT@"):
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
124 return self.db_core_iface.delContact(entity_jid, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
125
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
126 def deleteProfile(self, profile):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
127 return self.db_core_iface.deleteProfile(profile)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
128
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
129 def disconnect(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
130 return self.db_core_iface.disconnect(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
131
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
132 def getConfig(self, section, name):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
133 return unicode(self.db_core_iface.getConfig(section, name))
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 362
diff changeset
134
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
135 def getContacts(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
136 return self.db_core_iface.getContacts(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
137
501
e9634d2e7b38 core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents: 492
diff changeset
138 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"):
e9634d2e7b38 core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents: 492
diff changeset
139 return self.db_core_iface.getContactsFromGroup(group, profile_key)
e9634d2e7b38 core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents: 492
diff changeset
140
504
65ecbb473cbb core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents: 501
diff changeset
141 def getEntityData(self, jid, keys, profile):
65ecbb473cbb core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents: 501
diff changeset
142 return self.db_core_iface.getEntityData(jid, keys, profile)
65ecbb473cbb core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents: 501
diff changeset
143
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
144 def getHistory(self, from_jid, to_jid, limit, between=True, profile="@NONE@", callback=None, errback=None):
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
145 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, profile, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
146
399
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 387
diff changeset
147 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"):
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 387
diff changeset
148 return unicode(self.db_core_iface.getLastResource(contact_jid, profile_key))
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 387
diff changeset
149
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
150 def getMenuHelp(self, category, name, menu_type):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
151 return unicode(self.db_core_iface.getMenuHelp(category, name, menu_type))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
152
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
153 def getMenus(self, ):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
154 return self.db_core_iface.getMenus()
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
155
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
156 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
157 return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
158
423
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
159 def getParams(self, profile_key="@DEFAULT@", callback=None, errback=None):
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
160 return unicode(self.db_core_iface.getParams(profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
161
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
162 def getParamsCategories(self, ):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
163 return self.db_core_iface.getParamsCategories()
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
164
423
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
165 def getParamsForCategory(self, category, profile_key="@DEFAULT@", callback=None, errback=None):
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
166 return unicode(self.db_core_iface.getParamsForCategory(category, profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
167
423
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
168 def getParamsUI(self, profile_key="@DEFAULT@", callback=None, errback=None):
6c20c76abdcc backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents: 421
diff changeset
169 return unicode(self.db_core_iface.getParamsUI(profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
170
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
171 def getPresenceStatus(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
172 return self.db_core_iface.getPresenceStatus(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
173
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
174 def getProfileName(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
175 return unicode(self.db_core_iface.getProfileName(profile_key))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
176
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
177 def getProfilesList(self, ):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
178 return self.db_core_iface.getProfilesList()
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
179
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
180 def getProgress(self, id, profile):
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 535
diff changeset
181 return self.db_core_iface.getProgress(id, profile)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
182
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
183 def getVersion(self, ):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
184 return unicode(self.db_core_iface.getVersion())
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
185
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
186 def getWaitingConf(self, profile_key):
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
187 return self.db_core_iface.getWaitingConf(profile_key)
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
188
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
189 def getWaitingSub(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
190 return self.db_core_iface.getWaitingSub(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
191
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
192 def isConnected(self, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
193 return self.db_core_iface.isConnected(profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
194
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
195 def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
196 return unicode(self.db_core_iface.launchAction(action_type, data, profile_key))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
197
336
953536246d9d core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents: 320
diff changeset
198 def registerNewAccount(self, login, password, email, host, port=5222):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
199 return unicode(self.db_core_iface.registerNewAccount(login, password, email, host, port))
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
200
492
9248f2c5e03e bridge: updated D-Bus frontend
Goffi <goffi@goffi.org>
parents: 480
diff changeset
201 def sendMessage(self, to_jid, message, subject='', mess_type="auto", profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
202 return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
203
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
204 def setParam(self, name, value, category, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
205 return self.db_core_iface.setParam(name, value, category, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
206
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
207 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
208 return self.db_core_iface.setPresence(to_jid, show, priority, statuses, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
209
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
210 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 365
diff changeset
211 return self.db_core_iface.subscription(sub_type, entity, profile_key)
272
1d2e0dfe7114 bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents: 267
diff changeset
212
387
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
213 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"):
e66d300c5d42 frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents: 372
diff changeset
214 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key)
345
e6047415868d Bridge: added updateContact method
Goffi <goffi@goffi.org>
parents: 337
diff changeset
215
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 92
diff changeset
216
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
217 #methods from plugins
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
218
449
961543b20806 bridge: removed default profile_key in dbus_frontend_template to avoid difficult to find bugs
Goffi <goffi@goffi.org>
parents: 435
diff changeset
219 def joinMUC(self, room_jid, nick, options, profile_key):
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
220 if options is None:
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
221 options = [('', '')] # XXX: we have to do this awful hack because python dbus need to guess the signature
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 401
diff changeset
222 return self.db_plugin_iface.joinMUC(room_jid, nick, options, profile_key)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
223
449
961543b20806 bridge: removed default profile_key in dbus_frontend_template to avoid difficult to find bugs
Goffi <goffi@goffi.org>
parents: 435
diff changeset
224 def gatewayRegister(self, action, target, data, profile_key):
595
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
225 if data is None:
1f160467f5de Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
226 data = [('', '')] # XXX: we have to do this awful hack because python dbus need to guess the signature
568
239abc5484c9 bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents: 562
diff changeset
227 return self.db_plugin_iface.gatewayRegister(action, target, data, profile_key)