Lot of fixes

This commit is contained in:
Marco Pesenti Gritti 2006-05-11 17:23:41 -04:00
parent 878714a627
commit afb9b2c97f
4 changed files with 14 additions and 13 deletions

View File

@ -1,10 +1,6 @@
sugardir = $(pythondir)/sugar sugardir = $(pythondir)/sugar
sugar_PYTHON = \ sugar_PYTHON = \
BuddyList.py \
chat.py \ chat.py \
network.py \
presence.py \
p2p.py \
richtext.py richtext.py
icondir = $(pkgdatadir) icondir = $(pkgdatadir)

View File

@ -172,8 +172,9 @@ class BuddyChat(Chat):
Chat.__init__(self, controller) Chat.__init__(self, controller)
def _start(self): def _start(self):
service_name = buddy.get_service_name() service_name = self._buddy.get_service_name()
self._stream_writer = StreamWriter(self._group, service_name) group = self._controller.get_group()
self._stream_writer = StreamWriter(group, service_name)
def activity_on_connected_to_shell(self): def activity_on_connected_to_shell(self):
Chat.activity_on_connected_to_shell(self) Chat.activity_on_connected_to_shell(self)
@ -192,7 +193,7 @@ class BuddyChat(Chat):
def activity_on_close_from_user(self): def activity_on_close_from_user(self):
Chat.activity_on_close_from_user(self) Chat.activity_on_close_from_user(self)
self._buddy.set_chat(None) del self._chats[self._buddy]
class GroupChat(Chat): class GroupChat(Chat):
@ -202,6 +203,7 @@ class GroupChat(Chat):
def __init__(self): def __init__(self):
self._act_name = "Chat" self._act_name = "Chat"
self._chats = {}
bus = dbus.SessionBus() bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser') proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser')
@ -209,6 +211,9 @@ class GroupChat(Chat):
Chat.__init__(self, self) Chat.__init__(self, self)
def get_group(self):
return self._group
def _start(self): def _start(self):
self._group = LocalGroup() self._group = LocalGroup()
self._group.add_listener(self._on_group_event) self._group.add_listener(self._on_group_event)
@ -300,9 +305,9 @@ class GroupChat(Chat):
(model, aniter) = widget.get_selection().get_selected() (model, aniter) = widget.get_selection().get_selected()
chat = None chat = None
buddy = self._buddy_list_model.get_value(aniter, self._MODEL_COL_BUDDY) buddy = self._buddy_list_model.get_value(aniter, self._MODEL_COL_BUDDY)
if buddy and not buddy.chat(): if buddy and not self._chats.has_key(buddy):
chat = BuddyChat(self, buddy) chat = BuddyChat(self, buddy)
buddy.set_chat(chat) self._chats[buddy] = chat
chat.activity_connect_to_shell() chat.activity_connect_to_shell()
def _on_group_event(self, action, buddy): def _on_group_event(self, action, buddy):
@ -342,10 +347,9 @@ class GroupChat(Chat):
self._controller.notify_new_message(self, None) self._controller.notify_new_message(self, None)
def _buddy_recv_message(self, sender, msg): def _buddy_recv_message(self, sender, msg):
chat = sender.chat() if self._chats.has_key[sender]:
if not chat:
chat = BuddyChat(self, sender) chat = BuddyChat(self, sender)
sender.set_chat(chat) self._chats[buddy] = chat
chat.activity_connect_to_shell() chat.activity_connect_to_shell()
chat.recv_message(sender, msg) chat.recv_message(sender, msg)

View File

@ -67,7 +67,6 @@ class LocalGroup(Group):
def _on_service_resolved(self, interface, protocol, name, stype, domain, def _on_service_resolved(self, interface, protocol, name, stype, domain,
host, aprotocol, address, port, txt, flags): host, aprotocol, address, port, txt, flags):
print name
if name != self._owner.get_service().get_name(): if name != self._owner.get_service().get_name():
service = Service(name, host, address, port) service = Service(name, host, address, port)
self._services[name] = service self._services[name] = service

View File

@ -1,3 +1,5 @@
import xmlrpclib
import traceback
import socket import socket
import network import network