More work on the new network stuff. Mercurial
This commit is contained in:
parent
a8437a39a9
commit
3233c69c53
26
chat/chat.py
26
chat/chat.py
@ -13,14 +13,14 @@ import sys
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import activity
|
import activity
|
||||||
|
from Group import *
|
||||||
from sugar_globals import *
|
from sugar_globals import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from sugar import activity
|
from sugar import activity
|
||||||
|
from sugar.Group import *
|
||||||
from sugar.sugar_globals import *
|
from sugar.sugar_globals import *
|
||||||
|
|
||||||
import BuddyList
|
|
||||||
import richtext
|
import richtext
|
||||||
import p2p
|
|
||||||
|
|
||||||
class Chat(activity.Activity):
|
class Chat(activity.Activity):
|
||||||
def __init__(self, controller):
|
def __init__(self, controller):
|
||||||
@ -208,17 +208,9 @@ class GroupChat(Chat):
|
|||||||
Chat.__init__(self, self)
|
Chat.__init__(self, self)
|
||||||
|
|
||||||
def _start(self):
|
def _start(self):
|
||||||
group = p2p.Group.get_instance()
|
self._group = LocalGroup()
|
||||||
|
self._group.add_listener(self._on_group_event)
|
||||||
self._buddy_list = group.get_buddy_list()
|
self._group.join()
|
||||||
self._buddy_list.add_buddy_listener(self._on_buddy_presence_event)
|
|
||||||
|
|
||||||
input_pipe = p2p.InputPipe(group, "group-chat")
|
|
||||||
input_pipe.listen(self.recv_message)
|
|
||||||
self._output_pipe = p2p.BroadcastOutputPipe(group, "group-chat")
|
|
||||||
|
|
||||||
input_pipe = p2p.InputPipe(group, "buddy-chat")
|
|
||||||
input_pipe.listen(self._buddy_recv_message)
|
|
||||||
|
|
||||||
def _create_sidebar(self):
|
def _create_sidebar(self):
|
||||||
vbox = gtk.VBox(False, 6)
|
vbox = gtk.VBox(False, 6)
|
||||||
@ -302,12 +294,12 @@ class GroupChat(Chat):
|
|||||||
buddy.set_chat(chat)
|
buddy.set_chat(chat)
|
||||||
chat.activity_connect_to_shell()
|
chat.activity_connect_to_shell()
|
||||||
|
|
||||||
def _on_buddy_presence_event(self, action, buddy):
|
def _on_group_event(self, action, buddy):
|
||||||
if action == BuddyList.ACTION_BUDDY_ADDED:
|
if action == BUDDY_JOIN:
|
||||||
aniter = self._buddy_list_model.append(None)
|
aniter = self._buddy_list_model.append(None)
|
||||||
self._buddy_list_model.set(aniter, self._MODEL_COL_NICK, buddy.nick(),
|
self._buddy_list_model.set(aniter, self._MODEL_COL_NICK, buddy.get_nick_name(),
|
||||||
self._MODEL_COL_ICON, None, self._MODEL_COL_BUDDY, buddy)
|
self._MODEL_COL_ICON, None, self._MODEL_COL_BUDDY, buddy)
|
||||||
elif action == BuddyList.ACTION_BUDDY_REMOVED:
|
elif action == BUDDY_LEAVE:
|
||||||
aniter = self._get_iter_for_buddy(buddy)
|
aniter = self._get_iter_for_buddy(buddy)
|
||||||
if aniter:
|
if aniter:
|
||||||
self._buddy_list_model.remove(aniter)
|
self._buddy_list_model.remove(aniter)
|
||||||
|
@ -33,7 +33,7 @@ class PresenceDiscovery(object):
|
|||||||
self.server.ResolveService(int(interface), int(protocol), name, stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler=reply_handler, error_handler=error_handler)
|
self.server.ResolveService(int(interface), int(protocol), name, stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler=reply_handler, error_handler=error_handler)
|
||||||
|
|
||||||
def new_service(self, interface, protocol, name, stype, domain, flags):
|
def new_service(self, interface, protocol, name, stype, domain, flags):
|
||||||
# print "Found service '%s' (%d) of type '%s' in domain '%s' on %i.%i." % (name, flags, stype, domain, interface, protocol)
|
print "Found service '%s' (%d) of type '%s' in domain '%s' on %i.%i." % (name, flags, stype, domain, interface, protocol)
|
||||||
for listener in self._service_listeners:
|
for listener in self._service_listeners:
|
||||||
listener(ACTION_SERVICE_NEW, interface, protocol, name, stype, domain, flags)
|
listener(ACTION_SERVICE_NEW, interface, protocol, name, stype, domain, flags)
|
||||||
|
|
@ -1,7 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
export PYTHONPATH=`pwd`/p2p
|
||||||
|
|
||||||
# for activity.py
|
# for activity.py
|
||||||
export PYTHONPATH=`pwd`/shell/src/
|
export PYTHONPATH=$PYTHONPATH:`pwd`/shell/src/
|
||||||
|
|
||||||
# for sugar_globals.py
|
# for sugar_globals.py
|
||||||
export PYTHONPATH=$PYTHONPATH:`pwd`/
|
export PYTHONPATH=$PYTHONPATH:`pwd`/
|
||||||
|
Loading…
Reference in New Issue
Block a user