From 79ee53921c99959173ef140d56083cfacf92f952 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 24 Apr 2006 14:18:49 -0400 Subject: [PATCH] Ignore ourselves in the buddy list --- chat/BuddyList.py | 7 ++++++- chat/chat.py | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/chat/BuddyList.py b/chat/BuddyList.py index e5fd0763..d35fa847 100644 --- a/chat/BuddyList.py +++ b/chat/BuddyList.py @@ -48,9 +48,10 @@ class Buddy(object): class BuddyList(object): """ Manage a list of buddies """ - def __init__(self): + def __init__(self, servicename): self._listeners = [] self._buddies = {} + self._servicename = servicename self._pdiscovery = presence.PresenceDiscovery() self._pdiscovery.add_service_listener(self._on_service_change) @@ -61,6 +62,10 @@ class BuddyList(object): self._listeners.append(listener) def _add_buddy(self, host, address, port, servicename, data): + # Ignore ourselves + if servicename == self._servicename: + return + if len(data) > 0 and 'name' in data.keys(): buddy = self._find_buddy_by_service_name(servicename) if not buddy: diff --git a/chat/chat.py b/chat/chat.py index 4bc1f5db..7d3d74d5 100755 --- a/chat/chat.py +++ b/chat/chat.py @@ -117,11 +117,12 @@ class ChatActivity(activity.Activity): activity.Activity.__init__(self) self._act_name = "Chat" self._pannounce = presence.PresenceAnnounce() - self._buddy_list = BuddyList.BuddyList() - self._buddy_list.add_buddy_listener(self._on_buddy_presence_event) (self._nick, self._realname) = self._get_name() + self._buddy_list = BuddyList.BuddyList(self._realname) + self._buddy_list.add_buddy_listener(self._on_buddy_presence_event) + def _create_chat(self): chat_vbox = gtk.VBox() chat_vbox.set_spacing(6)