Fixed a bunch of issues reported by pylint
This commit is contained in:
parent
ecf81ba35f
commit
f0af49616c
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,8 +2,6 @@ import pygtk
|
|||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
import sugar.env
|
|
||||||
|
|
||||||
class AddressEntry(gtk.HBox):
|
class AddressEntry(gtk.HBox):
|
||||||
def __init__(self, callback):
|
def __init__(self, callback):
|
||||||
gtk.HBox.__init__(self)
|
gtk.HBox.__init__(self)
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
|
from xml.sax import saxutils
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
import geckoembed
|
import geckoembed
|
||||||
import urllib
|
|
||||||
|
|
||||||
from sugar.shell import activity
|
from sugar.shell import activity
|
||||||
from sugar.browser import NotificationBar
|
from sugar.browser import NotificationBar
|
||||||
from sugar.browser import NavigationToolbar
|
from sugar.browser import NavigationToolbar
|
||||||
|
|
||||||
_BROWSER_ACTIVITY_TYPE = "_web_browser_olpc._udp"
|
|
||||||
|
|
||||||
class BrowserActivity(activity.Activity):
|
class BrowserActivity(activity.Activity):
|
||||||
SOLO = 1
|
SOLO = 1
|
||||||
FOLLOWING = 2
|
FOLLOWING = 2
|
||||||
LEADING = 3
|
LEADING = 3
|
||||||
|
|
||||||
def __init__(self, uri):
|
def __init__(self, group, uri):
|
||||||
activity.Activity.__init__(self)
|
activity.Activity.__init__(self)
|
||||||
|
|
||||||
self.uri = uri
|
self.uri = uri
|
||||||
|
self._group = group
|
||||||
self._mode = BrowserActivity.SOLO
|
self._mode = BrowserActivity.SOLO
|
||||||
|
|
||||||
def _update_shared_location(self):
|
def _update_shared_location(self):
|
||||||
@ -84,14 +85,14 @@ class BrowserActivity(activity.Activity):
|
|||||||
self._setup_shared(self.uri)
|
self._setup_shared(self.uri)
|
||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
print 'Publish %s' % self.get_id()
|
print 'Publish %s' % self.activity_get_id()
|
||||||
|
|
||||||
def get_embed(self):
|
def get_embed(self):
|
||||||
return self.embed
|
return self.embed
|
||||||
|
|
||||||
def share(self):
|
def share(self):
|
||||||
url = self.embed.get_address()
|
address = self.embed.get_address()
|
||||||
self._model = self._group.get_store().create_model(url)
|
self._model = self._group.get_store().create_model(address)
|
||||||
self._model.set_value('owner', self._group.get_owner().get_nick_name())
|
self._model.set_value('owner', self._group.get_owner().get_nick_name())
|
||||||
self._update_shared_location()
|
self._update_shared_location()
|
||||||
self.set_mode(BrowserActivity.LEADING)
|
self.set_mode(BrowserActivity.LEADING)
|
||||||
@ -100,8 +101,8 @@ class BrowserActivity(activity.Activity):
|
|||||||
proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
|
proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
|
||||||
chat_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
|
chat_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
|
||||||
|
|
||||||
escaped_title = urllib.quote(self.embed.get_title())
|
escaped_title = saxutils.escape(self.embed.get_title())
|
||||||
escaped_url = urllib.quote(url)
|
escaped_address = saxutils.escape(address)
|
||||||
chat_shell.send_text_message('<richtext><link href="' + escaped_address +
|
chat_shell.send_text_message('<richtext><link href="' + escaped_address +
|
||||||
'">' + escaped_title + '</link></richtext>')
|
'">' + escaped_title + '</link></richtext>')
|
||||||
|
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
import dbus
|
import dbus
|
||||||
import geckoembed
|
import geckoembed
|
||||||
import threading
|
import pygtk
|
||||||
import gobject
|
pygtk.require('2.0')
|
||||||
|
import gtk
|
||||||
|
|
||||||
import sugar.env
|
import sugar.env
|
||||||
|
|
||||||
from sugar.browser.BrowserActivity import BrowserActivity
|
from sugar.browser.BrowserActivity import BrowserActivity
|
||||||
|
|
||||||
class BrowserShell(dbus.service.Object):
|
class BrowserShell(dbus.service.Object):
|
||||||
def __init__(self, object_path = '/com/redhat/Sugar/Browser'):
|
def __init__(self, bus_name, object_path = '/com/redhat/Sugar/Browser'):
|
||||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||||
|
|
||||||
geckoembed.set_profile_path(sugar.env.get_user_dir())
|
geckoembed.set_profile_path(sugar.env.get_user_dir())
|
||||||
self.__browsers = []
|
self.__browsers = []
|
||||||
|
|
||||||
def start():
|
def start(self):
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
||||||
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
||||||
@ -30,6 +31,6 @@ class BrowserShell(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
||||||
def open_browser(self, uri):
|
def open_browser(self, uri):
|
||||||
browser = BrowserActivity(uri)
|
browser = BrowserActivity(None, uri)
|
||||||
self.__browsers.append(browser)
|
self.__browsers.append(browser)
|
||||||
browser.connect_to_shell()
|
browser.connect_to_shell()
|
||||||
|
@ -1,44 +1,31 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import base64
|
|
||||||
import sha
|
import sha
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
import threading
|
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gobject, pango
|
import gtk, gobject, pango
|
||||||
|
|
||||||
from sugar.shell import activity
|
|
||||||
from sugar.presence import Buddy
|
|
||||||
from sugar.presence.Service import Service
|
|
||||||
from sugar.p2p.Stream import Stream
|
|
||||||
from sugar.p2p import network
|
|
||||||
from sugar.session.LogWriter import LogWriter
|
|
||||||
from sugar.chat.sketchpad.Toolbox import Toolbox
|
from sugar.chat.sketchpad.Toolbox import Toolbox
|
||||||
from sugar.chat.sketchpad.SketchPad import SketchPad
|
from sugar.chat.sketchpad.SketchPad import SketchPad
|
||||||
from sugar.chat.Emoticons import Emoticons
|
from sugar.chat.Emoticons import Emoticons
|
||||||
import sugar.env
|
|
||||||
|
|
||||||
import richtext
|
import richtext
|
||||||
|
|
||||||
PANGO_SCALE = 1024 # Where is this defined?
|
PANGO_SCALE = 1024 # Where is this defined?
|
||||||
|
|
||||||
CHAT_SERVICE_TYPE = "_olpc_chat._tcp"
|
|
||||||
CHAT_SERVICE_PORT = 6100
|
|
||||||
|
|
||||||
GROUP_CHAT_SERVICE_TYPE = "_olpc_group_chat._udp"
|
|
||||||
GROUP_CHAT_SERVICE_ADDRESS = "224.0.0.221"
|
|
||||||
GROUP_CHAT_SERVICE_PORT = 6200
|
|
||||||
|
|
||||||
class Chat(gtk.Window):
|
class Chat(gtk.Window):
|
||||||
|
SERVICE_TYPE = "_olpc_chat._tcp"
|
||||||
|
SERVICE_PORT = 6100
|
||||||
|
|
||||||
def __init__(self, controller):
|
def __init__(self, controller):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
#Buddy.recognize_buddy_service_type(CHAT_SERVICE_TYPE)
|
#Buddy.recognize_buddy_service_type(Chat.SERVICE_TYPE)
|
||||||
self._controller = controller
|
self._controller = controller
|
||||||
self._stream_writer = None
|
self._stream_writer = None
|
||||||
self._emt_popup = None
|
self._emt_popup = None
|
||||||
@ -144,7 +131,7 @@ class Chat(gtk.Window):
|
|||||||
|
|
||||||
return chat_vbox, self._editor.get_buffer()
|
return chat_vbox, self._editor.get_buffer()
|
||||||
|
|
||||||
def __get_browser_shell():
|
def __get_browser_shell(self):
|
||||||
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')
|
||||||
self._browser_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.BrowserShell')
|
self._browser_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.BrowserShell')
|
||||||
@ -287,7 +274,7 @@ class Chat(gtk.Window):
|
|||||||
if icon:
|
if icon:
|
||||||
rise = int(icon.get_height() / 4) * -1
|
rise = int(icon.get_height() / 4) * -1
|
||||||
|
|
||||||
chat_service = buddy.get_service(CHAT_SERVICE_TYPE)
|
chat_service = buddy.get_service(Chat.SERVICE_TYPE)
|
||||||
hash_string = "%s-%s" % (nick, chat_service.get_address())
|
hash_string = "%s-%s" % (nick, chat_service.get_address())
|
||||||
sha_hash = sha.new()
|
sha_hash = sha.new()
|
||||||
sha_hash.update(hash_string)
|
sha_hash.update(hash_string)
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
from sugar.chat.Chat import Chat
|
from sugar.chat.Chat import Chat
|
||||||
|
from sugar.presence.Service import Service
|
||||||
|
from sugar.p2p.Stream import Stream
|
||||||
|
|
||||||
|
GROUP_CHAT_SERVICE_TYPE = "_olpc_group_chat._udp"
|
||||||
|
GROUP_CHAT_SERVICE_ADDRESS = "224.0.0.221"
|
||||||
|
GROUP_CHAT_SERVICE_PORT = 6200
|
||||||
|
|
||||||
class GroupChat(Chat):
|
class GroupChat(Chat):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -9,7 +15,7 @@ class GroupChat(Chat):
|
|||||||
return self._group
|
return self._group
|
||||||
|
|
||||||
def new_buddy_writer(self, buddy):
|
def new_buddy_writer(self, buddy):
|
||||||
service = buddy.get_service(CHAT_SERVICE_TYPE)
|
service = buddy.get_service(Chat.SERVICE_TYPE)
|
||||||
return self._buddy_stream.new_writer(service)
|
return self._buddy_stream.new_writer(service)
|
||||||
|
|
||||||
def _start(self):
|
def _start(self):
|
||||||
@ -17,15 +23,16 @@ class GroupChat(Chat):
|
|||||||
|
|
||||||
# Group controls the Stream for incoming messages for
|
# Group controls the Stream for incoming messages for
|
||||||
# specific buddy chats
|
# specific buddy chats
|
||||||
buddy_service = Service(name, CHAT_SERVICE_TYPE, CHAT_SERVICE_PORT)
|
buddy_service = Service(name, Chat.SERVICE_TYPE, Chat.SERVICE_PORT)
|
||||||
self._buddy_stream = Stream.new_from_service(buddy_service, self._group)
|
self._buddy_stream = Stream.new_from_service(buddy_service, self._group)
|
||||||
self._buddy_stream.set_data_listener(getattr(self, "_buddy_recv_message"))
|
self._buddy_stream.set_data_listener(getattr(self, "_buddy_recv_message"))
|
||||||
buddy_service.register(self._group)
|
buddy_service.register(self._group)
|
||||||
|
|
||||||
# Group chat Stream
|
# Group chat Stream
|
||||||
group_service = Service(name, GROUP_CHAT_SERVICE_TYPE,
|
group_service = Service(name,
|
||||||
GROUP_CHAT_SERVICE_PORT,
|
GROUP_CHAT_SERVICE_TYPE,
|
||||||
GROUP_CHAT_SERVICE_ADDRESS)
|
GROUP_CHAT_SERVICE_PORT,
|
||||||
|
GROUP_CHAT_SERVICE_ADDRESS)
|
||||||
self._group.add_service(group_service)
|
self._group.add_service(group_service)
|
||||||
|
|
||||||
self._group_stream = Stream.new_from_service(group_service, self._group)
|
self._group_stream = Stream.new_from_service(group_service, self._group)
|
||||||
@ -37,9 +44,10 @@ class GroupChat(Chat):
|
|||||||
|
|
||||||
def _buddy_recv_message(self, buddy, msg):
|
def _buddy_recv_message(self, buddy, msg):
|
||||||
if not self._chats.has_key(buddy):
|
if not self._chats.has_key(buddy):
|
||||||
chat = BuddyChat(self, buddy)
|
# chat = BuddyChat(self, buddy)
|
||||||
self._chats[buddy] = chat
|
# self._chats[buddy] = chat
|
||||||
chat.connect_to_shell()
|
# chat.connect_to_shell()
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
chat = self._chats[buddy]
|
chat = self._chats[buddy]
|
||||||
chat.recv_message(buddy, msg)
|
chat.recv_message(buddy, msg)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from sugar.p2p import network
|
from sugar.p2p import network
|
||||||
from sugar.p2p.Service import Service
|
from sugar.presence.Service import Service
|
||||||
|
|
||||||
class Notifier:
|
class Notifier:
|
||||||
TYPE = "_olpc_model_notification._udp"
|
TYPE = "_olpc_model_notification._udp"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
from sugar.p2p.Service import Service
|
from sugar.presence.Service import Service
|
||||||
from sugar.p2p.Notifier import Notifier
|
from sugar.p2p.Notifier import Notifier
|
||||||
from sugar.p2p.model.AbstractModel import AbstractModel
|
from sugar.p2p.model.AbstractModel import AbstractModel
|
||||||
from sugar.p2p import network
|
from sugar.p2p import network
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import pwd
|
|
||||||
import os
|
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
@ -9,7 +7,6 @@ import gtk, gobject
|
|||||||
from sugar.p2p import Stream
|
from sugar.p2p import Stream
|
||||||
from sugar.p2p import network
|
from sugar.p2p import network
|
||||||
|
|
||||||
|
|
||||||
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
|
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,13 +111,13 @@ class PresenceService(gobject.GObject):
|
|||||||
self._service_advs = []
|
self._service_advs = []
|
||||||
|
|
||||||
# Main activity UID to filter services on
|
# Main activity UID to filter services on
|
||||||
self._activity_uids = []
|
self._activity_uid = None
|
||||||
|
|
||||||
self._bus = dbus.SystemBus()
|
self._bus = dbus.SystemBus()
|
||||||
self._server = dbus.Interface(self._bus.get_object(avahi.DBUS_NAME,
|
self._server = dbus.Interface(self._bus.get_object(avahi.DBUS_NAME,
|
||||||
avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
|
avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
|
||||||
|
|
||||||
def start(self):
|
def start(self, activity_uid=None):
|
||||||
"""Start the presence service by kicking off service discovery."""
|
"""Start the presence service by kicking off service discovery."""
|
||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
if self._started:
|
if self._started:
|
||||||
@ -126,6 +126,10 @@ class PresenceService(gobject.GObject):
|
|||||||
self._started = True
|
self._started = True
|
||||||
self._lock.release()
|
self._lock.release()
|
||||||
|
|
||||||
|
if activity_uid and not util.validate_activity_uid(activity_uid):
|
||||||
|
raise ValueError("activity uid must be a valid UID string.")
|
||||||
|
self._activity_uid = activity_uid
|
||||||
|
|
||||||
# Always browse .local
|
# Always browse .local
|
||||||
self._new_domain_cb(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local")
|
self._new_domain_cb(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local")
|
||||||
|
|
||||||
@ -280,9 +284,11 @@ class PresenceService(gobject.GObject):
|
|||||||
|
|
||||||
# If we care about the service right now, resolve it
|
# If we care about the service right now, resolve it
|
||||||
resolve = False
|
resolve = False
|
||||||
if uid in self._activity_uids:
|
if self._activity_uid and self._activity_uid == uid:
|
||||||
if stype in self._allowed_service_types:
|
if stype in self._allowed_service_types:
|
||||||
resolve = True
|
resolve = True
|
||||||
|
elif not self._activity_uid:
|
||||||
|
resolve = True
|
||||||
if self._is_special_service_type(stype):
|
if self._is_special_service_type(stype):
|
||||||
resolve = True
|
resolve = True
|
||||||
if resolve:
|
if resolve:
|
||||||
@ -383,11 +389,6 @@ class PresenceService(gobject.GObject):
|
|||||||
if stype in self._allowed_service_types:
|
if stype in self._allowed_service_types:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Decompose service type if we can
|
|
||||||
(uid, stype) = Service._decompose_service_type(stype)
|
|
||||||
if uid and util.validate_activity_uid(uid):
|
|
||||||
if uid not in self._activity_uids:
|
|
||||||
self._activity_uids.append(uid)
|
|
||||||
self._allowed_service_types.append(stype)
|
self._allowed_service_types.append(stype)
|
||||||
|
|
||||||
# Find unresolved services that match the service type
|
# Find unresolved services that match the service type
|
||||||
@ -403,53 +404,24 @@ class PresenceService(gobject.GObject):
|
|||||||
raise RuntimeError("presence service must be started first.")
|
raise RuntimeError("presence service must be started first.")
|
||||||
if not type(stype) == type(""):
|
if not type(stype) == type(""):
|
||||||
raise ValueError("service type must be a string.")
|
raise ValueError("service type must be a string.")
|
||||||
|
if name in self._allowed_service_types:
|
||||||
# Decompose service type if we can
|
|
||||||
(uid, stype) = Service._decompose_service_type(stype)
|
|
||||||
if uid and util.validate_activity_uid(uid):
|
|
||||||
if uid in self._activity_uids:
|
|
||||||
self._activity_uids.remove(uid)
|
|
||||||
if stype in self._allowed_service_types:
|
|
||||||
self._allowed_service_types.remove(stype)
|
self._allowed_service_types.remove(stype)
|
||||||
|
|
||||||
def join_shared_activity(self, service):
|
def join_group(self, group):
|
||||||
"""Convenience function to join a group and notify other buddies
|
"""Convenience function to join a group and notify other buddies
|
||||||
that you are a member of it."""
|
that you are a member of it."""
|
||||||
if not isinstance(service, Service.Service):
|
if not isinstance(group, Group.Group):
|
||||||
raise ValueError("service was not a valid service object.")
|
raise ValueError("group was not a valid group.")
|
||||||
|
gservice = group.get_service()
|
||||||
self.register_service(service)
|
self.register_service(service)
|
||||||
|
|
||||||
def share_activity(self, activity, stype, properties={}, address=None, port=None):
|
|
||||||
"""Convenience function to share an activity with other buddies."""
|
|
||||||
uid = activity.get_id()
|
|
||||||
owner_nick = self._owner.get_nick_name()
|
|
||||||
real_stype = "_%s_%s" % (uid, stype)
|
|
||||||
if address and type(address) != type(""):
|
|
||||||
raise ValueError("address must be a valid string.")
|
|
||||||
if not address:
|
|
||||||
# Use random currently unassigned multicast address
|
|
||||||
address = "232.%d.%d.%d" % (random.randint(0, 254), random.randint(1, 254),
|
|
||||||
random.randint(1, 254))
|
|
||||||
|
|
||||||
if port and (type(port) != type(1) or port <= 1024 or port >= 65535):
|
|
||||||
raise ValueError("port must be a number between 1024 and 65535")
|
|
||||||
if not port:
|
|
||||||
# random port #
|
|
||||||
port = random.randint(5000, 65535)
|
|
||||||
|
|
||||||
service = Service.Service(name=owner_nick, stype=real_stype, domain="local",
|
|
||||||
address=address, port=port, properties=properties)
|
|
||||||
# Publish it to the world
|
|
||||||
self.register_service(service)
|
|
||||||
return service
|
|
||||||
|
|
||||||
def register_service(self, service):
|
def register_service(self, service):
|
||||||
"""Register a new service, advertising it to other Buddies on the network."""
|
"""Register a new service, advertising it to other Buddies on the network."""
|
||||||
if not self._started:
|
if not self._started:
|
||||||
raise RuntimeError("presence service must be started first.")
|
raise RuntimeError("presence service must be started first.")
|
||||||
|
|
||||||
rs_name = service.get_name()
|
rs_name = service.get_name()
|
||||||
rs_stype = service.get_network_type()
|
rs_stype = service.get_type()
|
||||||
rs_port = service.get_port()
|
rs_port = service.get_port()
|
||||||
if type(rs_port) != type(1) and (rs_port <= 1024 or rs_port > 65536):
|
if type(rs_port) != type(1) and (rs_port <= 1024 or rs_port > 65536):
|
||||||
raise ValueError("invalid service port.")
|
raise ValueError("invalid service port.")
|
||||||
@ -472,7 +444,7 @@ class PresenceService(gobject.GObject):
|
|||||||
# should un-register it an re-register with the correct info
|
# should un-register it an re-register with the correct info
|
||||||
if str(exc) == "Local name collision":
|
if str(exc) == "Local name collision":
|
||||||
pass
|
pass
|
||||||
self.track_service_type(service.get_network_type())
|
self.track_service_type(rs_stype)
|
||||||
return group
|
return group
|
||||||
|
|
||||||
def get_buddy_by_nick_name(self, nick_name):
|
def get_buddy_by_nick_name(self, nick_name):
|
||||||
|
@ -69,8 +69,6 @@ def is_multicast_address(address):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
_ACTIVITY_UID_TAG = "ActivityUID"
|
|
||||||
|
|
||||||
class Service(object):
|
class Service(object):
|
||||||
"""Encapsulates information about a specific ZeroConf/mDNS
|
"""Encapsulates information about a specific ZeroConf/mDNS
|
||||||
service as advertised on the network."""
|
service as advertised on the network."""
|
||||||
@ -103,16 +101,7 @@ class Service(object):
|
|||||||
self.set_port(port)
|
self.set_port(port)
|
||||||
self._properties = {}
|
self._properties = {}
|
||||||
self.set_properties(properties)
|
self.set_properties(properties)
|
||||||
|
|
||||||
# Ensure that an ActivityUID tag, if given, matches
|
|
||||||
# what we expect from the service type
|
|
||||||
if self._properties.has_key(_ACTIVITY_UID_TAG):
|
|
||||||
prop_uid = self._properties[_ACTIVITY_UID_TAG]
|
|
||||||
if (prop_uid and not uid) or (prop_uid != uid):
|
|
||||||
raise ValueError("ActivityUID property specified, but the service type's activity UID didn't match it.")
|
|
||||||
self._activity_uid = uid
|
self._activity_uid = uid
|
||||||
if uid and not self._properties.has_key(_ACTIVITY_UID_TAG):
|
|
||||||
self._properties[_ACTIVITY_UID_TAG] = uid
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
"""Return the service's name, usually that of the
|
"""Return the service's name, usually that of the
|
||||||
@ -152,10 +141,6 @@ class Service(object):
|
|||||||
"""Return the service's service type."""
|
"""Return the service's service type."""
|
||||||
return self._stype
|
return self._stype
|
||||||
|
|
||||||
def get_network_type(self):
|
|
||||||
"""Return the full service type, including activity UID."""
|
|
||||||
return self._real_stype
|
|
||||||
|
|
||||||
def get_port(self):
|
def get_port(self):
|
||||||
return self._port
|
return self._port
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import dbus
|
import dbus
|
||||||
import gobject
|
|
||||||
|
|
||||||
class LogWriter:
|
class LogWriter:
|
||||||
def __init__(self, application):
|
def __init__(self, application):
|
||||||
|
@ -3,7 +3,6 @@ pygtk.require('2.0')
|
|||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from sugar.p2p.Stream import Stream
|
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
|
|
||||||
class PresenceWindow(gtk.Window):
|
class PresenceWindow(gtk.Window):
|
||||||
@ -94,9 +93,10 @@ class PresenceWindow(gtk.Window):
|
|||||||
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 self._chats.has_key(buddy):
|
if buddy and not self._chats.has_key(buddy):
|
||||||
chat = BuddyChat(self, buddy)
|
#chat = BuddyChat(self, buddy)
|
||||||
self._chats[buddy] = chat
|
#self._chats[buddy] = chat
|
||||||
chat.connect_to_shell()
|
#chat.connect_to_shell()
|
||||||
|
pass
|
||||||
|
|
||||||
def __buddy_icon_changed_cb(self, buddy):
|
def __buddy_icon_changed_cb(self, buddy):
|
||||||
it = self._get_iter_for_buddy(buddy)
|
it = self._get_iter_for_buddy(buddy)
|
||||||
|
@ -268,7 +268,7 @@ class Activity(object):
|
|||||||
else:
|
else:
|
||||||
self._activity_object.set_has_changes(False)
|
self._activity_object.set_has_changes(False)
|
||||||
|
|
||||||
def get_id(self):
|
def activity_get_id(self):
|
||||||
return self._activity_id
|
return self._activity_id
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
@ -156,8 +156,9 @@ class ActivityHost(dbus.service.Object):
|
|||||||
for c in data:
|
for c in data:
|
||||||
# Work around for a bug in dbus < 0.61 where integers
|
# Work around for a bug in dbus < 0.61 where integers
|
||||||
# are not correctly marshalled
|
# are not correctly marshalled
|
||||||
if c < 0: c += 256
|
if c < 0:
|
||||||
pixstr += chr(c)
|
c += 256
|
||||||
|
pixstr += chr(c)
|
||||||
|
|
||||||
pixbuf = gtk.gdk.pixbuf_new_from_data(pixstr, colorspace, has_alpha, bits_per_sample, width, height, rowstride)
|
pixbuf = gtk.gdk.pixbuf_new_from_data(pixstr, colorspace, has_alpha, bits_per_sample, width, height, rowstride)
|
||||||
#print pixbuf
|
#print pixbuf
|
||||||
@ -408,4 +409,5 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
gtk.main()
|
gtk.main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
print 'Ctrl+c pressed, exiting...'
|
||||||
pass
|
pass
|
||||||
|
@ -2,6 +2,7 @@ import time
|
|||||||
import sha
|
import sha
|
||||||
import random
|
import random
|
||||||
import binascii
|
import binascii
|
||||||
|
import string
|
||||||
|
|
||||||
def _stringify_sha(sha_hash):
|
def _stringify_sha(sha_hash):
|
||||||
"""Convert binary sha1 hash data into printable characters."""
|
"""Convert binary sha1 hash data into printable characters."""
|
||||||
|
Loading…
Reference in New Issue
Block a user