def findConnections():
    cons = Connection.get_connections()

    for con in cons:
        watch_connection(con)
        status = statuses[con[CONNECTION].GetStatus()]
        print("Connection: %s with status %s" % (con.service_name, status))
示例#2
0
    def __init__(self, bus):
        self.bus = bus
        connections = Connection.get_connections()

        for conn in connections:
            self._watch_conn(conn)
            status = connection_status[conn[CONN_INTERFACE].GetStatus()]
            print "found connection: %s (%s)" % (conn.service_name, status)

        dbus = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
        dbus.connect_to_signal("NameOwnerChanged", self._name_owner_changed_cb)
    def __init__(self, bus):
        self.bus = bus
        connections = Connection.get_connections()

        for conn in connections:
            self._watch_conn(conn)
            status = connection_status[conn[CONN_INTERFACE].GetStatus()]
            print 'found connection: %s (%s)' % (conn.service_name, status)

        dbus = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
        dbus.connect_to_signal('NameOwnerChanged', self._name_owner_changed_cb)
示例#4
0
    def __init__(self):
        self.loop = gobject.MainLoop()

        self.con_monitors = con_monitors = set()
        for con in Connection.get_connections():
            con_monitors.add(ConnectionMonitor(con))

        bus = dbus.Bus()
        dbus_object = bus.get_object("org.freedesktop.DBus",
                                     "/org/freedesktop/DBus")
        dbus_object.connect_to_signal("NameOwnerChanged",
                                      self.change_owner_handler)
    def __init__(self, bus=None):
        gobject.GObject.__init__(self)

        if bus is None:
            self.bus = dbus.Bus()
        else:
            self.bus = bus

        # D-Bus path -> Connection
        self._connections = {}

        self.bus.add_signal_receiver(self._status_changed_cb,
            dbus_interface=CONN_INTERFACE, signal_name='StatusChanged',
            path_keyword='path')

        for conn in Connection.get_connections(bus):
            conn.call_when_ready(self._conn_ready_cb)
示例#6
0
    def __init__(self, bus=None):
        GObject.GObject.__init__(self)

        if bus is None:
            self.bus = dbus.Bus()
        else:
            self.bus = bus

        # D-Bus path -> Connection
        self._connections = {}

        self.bus.add_signal_receiver(self._status_changed_cb,
                                     dbus_interface=CONN_INTERFACE,
                                     signal_name='StatusChanged',
                                     path_keyword='path')

        for conn in Connection.get_connections(bus):
            conn.call_when_ready(self._conn_ready_cb)
    def _find_existing_connection(self):
        """Try to find an existing Telepathy connection to this server

        filters the set of connections from
            telepathy.client.Connection.get_connections
        to find a connection using our protocol with the
        "self handle" of that connection being a handle
        which matches our account (see _get_account_info)

        returns connection or None
        """
        # Search existing connections, if any, that we might be able to use
        connections = Connection.get_connections()
        for item in connections:
            if not item.object_path.startswith(self._OBJ_PATH_PREFIX):
                continue
            if item[CONN_INTERFACE].GetProtocol() != self._PROTOCOL:
                continue
            # Any Salut instance will do
            return item
        return None
        return CHANNEL_TYPE_TEXT

    def GetHandle(self):
        return (1, 1)

    def GetInterfaces(self):
        return [CHANNEL, CHANNEL_TYPE_TEXT, CHANNEL_INTERFACE_MESSAGES]


def publish_channel(name):
    bus_name = '.'.join([CHANNEL, name])
    object_path = '/' + bus_name.replace('.', '/')
    bus_name = dbus.service.BusName(bus_name, bus=dbus.SessionBus())
    global channel
    channel = FakeChannel(bus_name, object_path)

    return False

if __name__ == "__main__":
    loop = gobject.MainLoop()

    con = Connection.get_connections()[0]
    con.create_channel

    gobject.timeout_add(0, publish_channel, "MyFakeChannel")

    try:
        loop.run()
    except KeyboardInterrupt:
        loop.quit()