Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-06-08 15:31:03 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-08 15:31:03 (GMT)
commit4e1f2f216cbd4b1cbb432110d784d310366c561e (patch)
tree984b82dadd0473cc39b52c5a9ef42d1cf71a0cde
parent6efca4fec0309201e5c58b78f215ec97c1391ea4 (diff)
server_plugin: batch "contact online" events
-rw-r--r--src/server_plugin.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 165b6d5..137f684 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -548,25 +548,27 @@ class ServerPlugin(gobject.GObject):
handle, err)
self._contact_offline(handle)
- def _contact_online(self, handle):
- """Handle a contact coming online"""
- if (handle not in self._subscribe_members and
- handle not in self._subscribe_local_pending and
- handle not in self._subscribe_remote_pending):
- # it's probably a channel-specific handle - can't create a Buddy
- # object for those yet
- return
-
- self._online_contacts[handle] = None
- if handle == self._conn[CONN_INTERFACE].GetSelfHandle():
- jid = self._conn[CONN_INTERFACE].InspectHandles(
- HANDLE_TYPE_CONTACT, [handle])[0]
- self._online_contacts[handle] = jid
- # ignore network events for Owner property changes since those
- # are handled locally
- return
+ def _contacts_online(self, handles):
+ """Handle contacts coming online"""
+ relevant = []
- self._contact_online_request_properties(handle, 1)
+ for handle in handles:
+ if handle == self.self_handle:
+ jid = self._conn[CONN_INTERFACE].InspectHandles(
+ HANDLE_TYPE_CONTACT, [handle])[0]
+ self._online_contacts[handle] = jid
+ # ignore network events for Owner property changes since those
+ # are handled locally
+ elif (handle in self._subscribe_members or
+ handle in self._subscribe_local_pending or
+ handle in self._subscribe_remote_pending):
+ relevant.append(handle)
+ # else it's probably a channel-specific handle - can't create a
+ # Buddy object for those yet
+
+ for handle in relevant:
+ self._online_contacts[handle] = None
+ self._contact_online_request_properties(handle, 1)
def _subscribe_members_changed_cb(self, message, added, removed,
local_pending, remote_pending,
@@ -605,6 +607,10 @@ class ServerPlugin(gobject.GObject):
def _presence_update_cb(self, presence):
"""Send update for online/offline status of presence"""
+
+ now_online = []
+ now_offline = []
+
for handle in presence:
timestamp, statuses = presence[handle]
online = handle in self._online_contacts
@@ -620,9 +626,13 @@ class ServerPlugin(gobject.GObject):
handle, jid, olstr, status)
if not online and status in ["available", "away", "brb",
"busy", "dnd", "xa"]:
- self._contact_online(handle)
+ now_online.append(handle)
elif status in ["offline", "invisible"]:
- self._contact_offline(handle)
+ now_offline.append(handle)
+
+ self._contacts_online(now_online)
+ for handle in now_offline:
+ self._contact_offline(handle)
def _request_avatar_cb(self, handle, new_avatar_token, avatar, mime_type):
jid = self._online_contacts[handle]