Exemplo n.º 1
0
    def __init__(self):
        BaseBuddyModel.__init__(self)

        client = gconf.client_get_default()
        self.props.nick = client.get_string('/desktop/sugar/user/nick')
        color = client.get_string('/desktop/sugar/user/color')
        self.props.color = XoColor(color)

        self.props.key = get_profile().pubkey

        self.connect('notify::nick', self.__property_changed_cb)
        self.connect('notify::color', self.__property_changed_cb)

        bus = dbus.SessionBus()
        bus.add_signal_receiver(
                self.__name_owner_changed_cb,
                signal_name='NameOwnerChanged',
                dbus_interface='org.freedesktop.DBus')

        bus_object = bus.get_object(dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH)
        for service in bus_object.ListNames(
                dbus_interface=dbus.BUS_DAEMON_IFACE):
            if service.startswith(CONNECTION + '.'):
                path = '/%s' % service.replace('.', '/')
                Connection(service, path, bus,
                           ready_handler=self.__connection_ready_cb)
Exemplo n.º 2
0
    def __init__(self):
        BaseBuddyModel.__init__(self)

        self.props.nick = "rgs"
        self.props.color = XoColor(None)

        # self.props.key = get_profile().pubkey
        self.props.key = "foobar"

        self.connect('notify::nick', self.__property_changed_cb)
        self.connect('notify::color', self.__property_changed_cb)
        self.connect('notify::current-activity',
                     self.__current_activity_changed_cb)

        bus = dbus.SessionBus()
        bus.add_signal_receiver(self.__name_owner_changed_cb,
                                signal_name='NameOwnerChanged',
                                dbus_interface='org.freedesktop.DBus')

        bus_object = bus.get_object(dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH)
        for service in bus_object.ListNames(
                dbus_interface=dbus.BUS_DAEMON_IFACE):
            if service.startswith(CONNECTION + '.'):
                path = '/%s' % service.replace('.', '/')
                Connection(service,
                           path,
                           bus,
                           ready_handler=self.__connection_ready_cb)
    def _get_buddy(self, cs_handle):
        '''Get a Buddy from a (possibly channel-specific) handle.'''
        # XXX This will be made redundant once Presence Service
        # provides buddy resolution

        # Get the Presence Service
        pservice = presenceservice.get_instance()

        # Get the Telepathy Connection
        tp_name, tp_path = pservice.get_preferred_connection()
        conn = Connection(tp_name, tp_path)
        group = self._text_chan[CHANNEL_INTERFACE_GROUP]
        my_csh = group.GetSelfHandle()
        if my_csh == cs_handle:
            handle = conn.GetSelfHandle()
        elif (group.GetGroupFlags()
              & CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES):
            handle = group.GetHandleOwners([cs_handle])[0]
        else:
            handle = cs_handle

            # XXX: deal with failure to get the handle owner
            assert handle != 0

        return pservice.get_buddy_by_telepathy_handle(tp_name, tp_path, handle)
Exemplo n.º 4
0
    def _add_connection(self, service_name, path):
        if path in self._connections:
            return

        try:
            Connection(service_name, path, ready_handler=self._conn_ready_cb)
        except dbus.exceptions.DBusException:
            logging.debug('%s is propably already gone.', service_name)
Exemplo n.º 5
0
 def _one_to_one_connection(self, tp_channel):
     '''Handle a private invite from a non-sugar3 XMPP client.'''
     if self.shared_activity or self.text_channel:
         return
     bus_name, connection, channel = json.loads(tp_channel)
     logger.debug('GOT XMPP: %s %s %s', bus_name, connection, channel)
     Connection(bus_name, connection, ready_handler=lambda conn:
                self._one_to_one_connection_ready_cb(
                    bus_name, channel, conn))
Exemplo n.º 6
0
 def _one_to_one_connection(self, tp_channel):
     """Handle a private invite from a non-Sugar XMPP client."""
     if self.shared_activity or self.text_channel:
         return
     bus_name, connection, channel = cjson.decode(tp_channel)
     logger.debug('GOT XMPP: %s %s %s', bus_name, connection, channel)
     Connection(
         bus_name, connection, ready_handler=lambda conn: \
         self._one_to_one_connection_ready_cb(bus_name, channel, conn))
Exemplo n.º 7
0
    def _name_owner_changed_cb(self, service, old, new):
        if service.startswith(conn_prefix):
            name = service[len(conn_prefix):]

            if old == '':
                conn = Connection(service)
                self._watch_conn(conn)
                status = connection_status[conn[CONN_INTERFACE].GetStatus()]
                print 'new connection: %s (%s)' % (name, status)
            elif new == '':
                print 'connection gone: %s' % name
Exemplo n.º 8
0
    def __init__(self, buddy, file_name, title, description, mime_type):

        presence_service = presenceservice.get_instance()
        name, path = presence_service.get_preferred_connection()
        connection = Connection(name, path,
                                ready_handler=self.__connection_ready_cb)

        BaseFileTransfer.__init__(self, connection)
        self.connect('notify::state', self.__notify_state_cb)

        self._file_name = file_name
        self._socket_address = None
        self._socket = None
        self._splicer = None
        self._output_stream = None

        self.buddy = buddy
        self.title = title
        self.file_size = os.stat(file_name).st_size
        self.description = description
        self.mime_type = mime_type
Exemplo n.º 9
0
    def _prepare_connection(self, connection_path):
        connection_name = connection_path.replace('/', '.')[1:]

        self._connection = Connection(connection_name,
                                      connection_path,
                                      ready_handler=self.__connection_ready_cb)
Exemplo n.º 10
0
 def __name_owner_changed_cb(self, name, old, new):
     if name.startswith(CONNECTION + '.') and not old and new:
         path = '/' + name.replace('.', '/')
         Connection(name, path, ready_handler=self.__connection_ready_cb)