summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Mjelva <morten.mjelva@gmail.com>2010-04-19 19:42:37 +0200
committerJonny Lamb <jonny.lamb@collabora.co.uk>2010-04-22 11:31:50 +0100
commit323f383e6446089042c5108685c346bbeb6ce2cb (patch)
tree1cdb607ff394e999ccfabc005e11fbf5fdf7c6e6
parent1c392909d48aa9bd993eca3a5378134555fce1ef (diff)
added Account and AccountManager class
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/client/Makefile.am2
-rw-r--r--src/client/__init__.py2
-rw-r--r--src/client/account.py48
-rw-r--r--src/client/accountmgr.py48
4 files changed, 100 insertions, 0 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 7050c13..19e87fa 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -1,5 +1,7 @@
clientdir = $(pythondir)/telepathy/client
client_PYTHON = \
+ accountmgr.py \
+ account.py \
channel.py \
connmgr.py \
conn.py \
diff --git a/src/client/__init__.py b/src/client/__init__.py
index 909f667..a598ab4 100644
--- a/src/client/__init__.py
+++ b/src/client/__init__.py
@@ -19,6 +19,8 @@
from telepathy.client.interfacefactory import InterfaceFactory
from telepathy.client.managerregistry import ManagerRegistry
+from telepathy.client.accountmgr import AccountManager
+from telepathy.client.account import Account
from telepathy.client.connmgr import ConnectionManager
from telepathy.client.conn import Connection
from telepathy.client.channel import Channel
diff --git a/src/client/account.py b/src/client/account.py
new file mode 100644
index 0000000..66bf260
--- /dev/null
+++ b/src/client/account.py
@@ -0,0 +1,48 @@
+# telepathy-python - Base classes defining the interfaces of the Telepathy framework
+#
+# Copyright (C) 2005, 2006 Collabora Limited
+# Copyright (C) 2005, 2006 Nokia Corporation
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import dbus
+
+from telepathy.client.interfacefactory import (InterfaceFactory,
+ default_error_handler)
+from telepathy.interfaces import ACCOUNT, ACCOUNT_MANAGER
+
+class Account(InterfaceFactory):
+ def __init__(self, object_path, bus=None, ready_handler=None,
+ error_handler=default_error_handler):
+ if not bus:
+ bus = dbus.Bus()
+
+ self.service_name = ACCOUNT_MANAGER
+ self.object_path = object_path
+ self._ready_handler = ready_handler
+ self._error_cb = error_handler
+ object = bus.get_object(self.service_name, self.object_path)
+ InterfaceFactory.__init__(self, object, ACCOUNT)
+
+ self[dbus.PROPERTIES_IFACE].Get(
+ ACCOUNT,
+ 'Interfaces',
+ reply_handler=self._get_interfaces_cb,
+ error_handler=self._error_cb)
+
+ def _get_interfaces_cb(self, interfaces):
+ self.get_valid_interfaces().update(interfaces)
+ if self._ready_handler:
+ self._ready_handler(self)
diff --git a/src/client/accountmgr.py b/src/client/accountmgr.py
new file mode 100644
index 0000000..472099e
--- /dev/null
+++ b/src/client/accountmgr.py
@@ -0,0 +1,48 @@
+# telepathy-python - Base classes defining the interfaces of the Telepathy framework
+#
+# Copyright (C) 2005, 2006 Collabora Limited
+# Copyright (C) 2005, 2006 Nokia Corporation
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import dbus
+
+from telepathy.client.interfacefactory import (InterfaceFactory,
+ default_error_handler)
+from telepathy.interfaces import ACCOUNT_MANAGER
+
+class AccountManager(InterfaceFactory):
+ def __init__(self, bus=None, ready_handler=None,
+ error_handler=default_error_handler):
+ if not bus:
+ bus = dbus.Bus()
+
+ self.service_name = ACCOUNT_MANAGER
+ self.object_path = '/org/freedesktop/Telepathy/AccountManager'
+ self._ready_handler = ready_handler
+ self._error_cb = error_handler
+ object = bus.get_object(self.service_name, self.object_path)
+ InterfaceFactory.__init__(self, object, ACCOUNT_MANAGER)
+
+ self[dbus.PROPERTIES_IFACE].Get(
+ ACCOUNT_MANAGER,
+ 'Interfaces',
+ reply_handler=self._get_interfaces_cb,
+ error_handler=self._error_cb)
+
+ def _get_interfaces_cb(self, interfaces):
+ self.get_valid_interfaces().update(interfaces)
+ if self._ready_handler:
+ self._ready_handler(self)