summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof <kkszysiu@gmail.com>2011-03-27 16:34:24 +0200
committerKrzysztof <kkszysiu@gmail.com>2011-03-27 16:34:24 +0200
commit6b867bd11721367c583f99613bde7a789a6cc281 (patch)
treea573ee84f599bc75cf7d95fd8044f830f08ddfd9
parenta9e3d509ab065abcd0743b39e5c8897146ba0296 (diff)
Revert "Some minor changes in group/contact list."
-rw-r--r--sunshine/channel/contact_list.py80
-rw-r--r--sunshine/channel/group.py2
-rw-r--r--sunshine/channel/text.py4
3 files changed, 19 insertions, 67 deletions
diff --git a/sunshine/channel/contact_list.py b/sunshine/channel/contact_list.py
index d23777f..4d3f0f5 100644
--- a/sunshine/channel/contact_list.py
+++ b/sunshine/channel/contact_list.py
@@ -101,21 +101,22 @@ def SunshineContactListChannelFactory(connection, manager, handle, props):
props[telepathy.CHANNEL_INTERFACE + '.TargetHandleType'],
props[telepathy.CHANNEL_INTERFACE + '.TargetHandle'])
- if handle.get_name() == 'stored':
- raise telepathy.errors.NotImplemented
- elif handle.get_name() == 'subscribe':
+ if handle.get_name() == 'subscribe':
channel_class = SunshineSubscribeListChannel
- elif handle.get_name() == 'publish':
- raise telepathy.errors.NotImplemented
- elif handle.get_name() == 'hide':
- raise telepathy.errors.NotImplemented
- elif handle.get_name() == 'allow':
- raise telepathy.errors.NotImplemented
- elif handle.get_name() == 'deny':
- raise telepathy.errors.NotImplemented
+ #hacky & tricky
+# elif handle.get_name() == 'publish':
+# channel_class = SunshineSubscribeListChannel
+
+# elif handle.get_name() == 'publish':
+# channel_class = ButterflyPublishListChannel
+# elif handle.get_name() == 'hide':
+# channel_class = ButterflyHideListChannel
+# elif handle.get_name() == 'allow':
+# channel_class = ButterflyAllowListChannel
+# elif handle.get_name() == 'deny':
+# channel_class = ButterflyDenyListChannel
else:
- logger.error("Unknown list type : " + handle.get_name())
- raise telepathy.errors.InvalidHandle
+ raise TypeError("Unknown list type : " + handle.get_name())
return channel_class(connection, manager, props)
@@ -127,7 +128,7 @@ class SunshineListChannel(
def __init__(self, connection, manager, props, object_path=None):
self._conn_ref = weakref.ref(connection)
- telepathy.server.ChannelTypeContactList.__init__(self, connection, manager, props, object_path=object_path)
+ telepathy.server.ChannelTypeContactList.__init__(self, connection, manager, props, object_path=None)
SunshineChannel.__init__(self, connection, props)
telepathy.server.ChannelInterfaceGroup.__init__(self)
self._populate(connection)
@@ -172,19 +173,13 @@ class SunshineSubscribeListChannel(SunshineListChannel):
supposed to receive presence notification."""
def __init__(self, connection, manager, props):
- SunshineListChannel.__init__(self, connection, manager, props,
- object_path='RosterChannel/List/subscribe')
+ SunshineListChannel.__init__(self, connection, manager, props)
self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD |
telepathy.CHANNEL_GROUP_FLAG_CAN_REMOVE, 0)
def AddMembers(self, contacts, message):
logger.info("Subscribe - AddMembers called")
for h in contacts:
- self._add(h, message)
-
-
- """
- for h in contacts:
handle = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, h)
contact_xml = ET.Element("Contact")
ET.SubElement(contact_xml, "Guid").text = str(handle.name)
@@ -208,59 +203,16 @@ class SunshineSubscribeListChannel(SunshineListChannel):
self._conn_ref().contactAdded(handle)
logger.info("Contact added.")
self._conn_ref().exportContactsFile()
- """
def RemoveMembers(self, contacts, message):
for h in contacts:
- self._remove(h)
-
- """
- for h in contacts:
handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, h)
contact = handle.contact
self._conn_ref().gadu_client.removeContact(contact, notify=True)
self.MembersChanged('', (), [handle], (), (), 0,
telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
self._conn_ref().exportContactsFile()
- """
def _filter_contact(self, contact):
return (True, False, False)
- def _add(self, handle_id, message):
- handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
- if handle.contact is not None:
- return True
-
- contact_xml = ET.Element("Contact")
- ET.SubElement(contact_xml, "Guid").text = str(handle.name)
- ET.SubElement(contact_xml, "GGNumber").text = str(handle.name)
- ET.SubElement(contact_xml, "ShowName").text = str(handle.name)
- ET.SubElement(contact_xml, "Groups")
- c = GaduContact.from_xml(contact_xml)
- self._conn_ref().gadu_client.addContact( c )
- self._conn_ref().gadu_client.notifyAboutContact( c )
- logger.info("Adding contact: %s" % (handle.name))
- self.MembersChanged('', [handle], (), (), (), 0,
- telepathy.CHANNEL_GROUP_CHANGE_REASON_INVITED)
-
- #alias and group settings for new contacts are bit tricky
- #try to set alias
- handle.contact.ShowName = self._conn_ref().get_contact_alias(handle.id)
- #and group
- if self._conn_ref().pending_contacts_to_group.has_key(handle.name):
- logger.info("Trying to add temporary group.")
- handle.contact.updateGroups(self._conn_ref().pending_contacts_to_group[handle.name])
- self._conn_ref().contactAdded(handle)
- logger.info("Contact added.")
- self._conn_ref().exportContactsFile()
-
- def _remove(self, handle_id):
- handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, h)
- contact = handle.contact
- self._conn_ref().gadu_client.removeContact(contact, notify=True)
- self.MembersChanged('', (), [handle], (), (), 0,
- telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
- self._conn_ref().exportContactsFile()
-
-
diff --git a/sunshine/channel/group.py b/sunshine/channel/group.py
index ced603a..9c9fc20 100644
--- a/sunshine/channel/group.py
+++ b/sunshine/channel/group.py
@@ -39,7 +39,7 @@ logger = logging.getLogger('Sunshine.GroupChannel')
class SunshineGroupChannel(SunshineListChannel):
- def __init__(self, connection, manager, props, object_path=None):
+ def __init__(self, connection, manager, props, object_path):
self.__pending_add = []
self.__pending_remove = []
self.conn = connection
diff --git a/sunshine/channel/text.py b/sunshine/channel/text.py
index e21159f..76a61b5 100644
--- a/sunshine/channel/text.py
+++ b/sunshine/channel/text.py
@@ -41,7 +41,7 @@ class SunshineTextChannel(SunshineChannel,
telepathy.server.ChannelInterfaceChatState,
ChannelInterfaceMessages):
- def __init__(self, conn, manager, conversation, props, object_path=None):
+ def __init__(self, conn, manager, conversation, props, object_path):
_, surpress_handler, handle = manager._get_type_requested_handle(props)
self._recv_id = 0
self._conn_ref = weakref.ref(conn)
@@ -50,7 +50,7 @@ class SunshineTextChannel(SunshineChannel,
self._pending_messages2 = {}
self.handle = handle
- telepathy.server.ChannelTypeText.__init__(self, conn, manager, props, object_path=object_path)
+ telepathy.server.ChannelTypeText.__init__(self, conn, manager, props, object_path)
SunshineChannel.__init__(self, conn, props)
telepathy.server.ChannelInterfaceChatState.__init__(self)
ChannelInterfaceMessages.__init__(self)