コード例 #1
0
    def __init__(self, bus_name = 'CallDemo'):
        GObject.Object.__init__(self)
        TelepathyGLib.debug_set_flags("all")
        am = TelepathyGLib.AccountManager.dup()
        self.handler = handler = TelepathyGLib.SimpleHandler.new_with_am(
            am, True, False, bus_name, True, self.handle_channels_cb)

        handler.add_handler_filter({
            TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE: TelepathyGLib.IFACE_CHANNEL_TYPE_CALL,

            TelepathyGLib.PROP_CHANNEL_TARGET_HANDLE_TYPE: int(TelepathyGLib.HandleType.CONTACT)
        })
        self.bus_name = handler.get_bus_name()

        handler.register()
コード例 #2
0
        if len(args) < 3:
            print "Execpect account argument: CM protocol settings"
            sys.exit(2)
    except getopt.GetoptError, err:
        print str(err)
        sys.exit(2)

    # Use a temporary directory for the testrun
    tempdir = tempfile.mkdtemp(prefix="phoenix-test")
    setup_run_dir(tempdir, quiet=quiet)
    if datadir != None:
        setup_data_dir(datadir, quiet)

    scrub_env()
    p = spawnbus(quiet)
    loop = GObject.MainLoop()
    t = TestCase(loop, testcontact, quiet)
    t.set_timeout(30)
    t.set_account(*args)

    Tp.debug_set_flags(os.getenv('PHOENIX_TEST_DEBUG', ''))

    m = TestManager(t)
    try:
        loop.run()
    finally:
        os.kill(p.pid, signal.SIGKILL)
        # Sleep 2 seconds so everything can die a nice death
        time.sleep(2)
        shutil.rmtree(tempdir)
        if len(args) < 3:
            print "Execpect account argument: CM protocol settings"
            sys.exit(2)
    except getopt.GetoptError, err:
        print str(err)
        sys.exit(2)

    # Use a temporary directory for the testrun
    tempdir = tempfile.mkdtemp(prefix="phoenix-test")
    setup_run_dir(tempdir, quiet=quiet)
    if datadir != None:
        setup_data_dir(datadir, quiet)

    scrub_env()
    p = spawnbus(quiet)
    loop = GObject.MainLoop()
    t = TestCase (loop, testcontact, quiet)
    t.set_timeout (30)
    t.set_account (*args)

    Tp.debug_set_flags(os.getenv('PHOENIX_TEST_DEBUG', ''))

    m = TestManager(t)
    try:
        loop.run()
    finally:
        os.kill (p.pid, signal.SIGKILL)
        # Sleep 2 seconds so everything can die a nice death
        time.sleep (2)
        shutil.rmtree(tempdir)
コード例 #4
0
    manager.prepare_finish(result)

    for account in manager.get_valid_accounts():
        connection = account.get_connection()

        # Verify account is online and received its contact list. If state is not
        # SUCCESS this means we didn't received the roster from server yet and
        # we would have to wait for the "notify:contact-list-state" signal. */
        if connection is not None and \
           connection.get_contact_list_state() == Tp.ContactListState.SUCCESS:
            contacts = connection.dup_contact_list()
            for contact in contacts:
                print "%s (%s)" % (contact.get_identifier(),
                                   contact.get_contact_groups())
    loop.quit()


if __name__ == '__main__':
    Tp.debug_set_flags(os.getenv('EXAMPLE_DEBUG', ''))

    loop = GObject.MainLoop()
    manager = Tp.AccountManager.dup()
    factory = manager.get_factory()
    factory.add_account_features([Tp.Account.get_feature_quark_connection()])
    factory.add_connection_features(
        [Tp.Connection.get_feature_quark_contact_list()])
    factory.add_contact_features([Tp.ContactFeature.CONTACT_GROUPS])

    manager.prepare_async(None, manager_prepared_cb, loop)
    loop.run()
コード例 #5
0
    def _dial_clicked(self, button):
        tree_iter = self.account_combo.get_active_iter()
        account = self.accounts[tree_iter][1]
        tree_iter = self.handler_combo.get_active_iter()
        handler = self.handlers[tree_iter][1]

        acr = Tp.AccountChannelRequest.new(
            account, {
                Tp.PROP_CHANNEL_CHANNEL_TYPE: Tp.IFACE_CHANNEL_TYPE_CALL,
                Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE: int(Tp.HandleType.CONTACT),
                Tp.PROP_CHANNEL_TARGET_ID: self.target_entry.get_text(),
                Tp.PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO: True,
            }, USER_ACTION_TIME_NOT_USER_ACTION)
        acr.create_and_observe_channel_async(handler, None,
                                             self._create_call_cb, None)

    def _create_call_cb(self, acr, result, user_data):
        channel = acr.create_and_observe_channel_finish(result)
        print("accepting channel %s" % channel)
        channel.accept_async(self._accept_cb, None)

    def _accept_cb(self, channel, result, user_data):
        channel.accept_finish(result)
        print("accepted channel %s" % channel)


if __name__ == '__main__':
    Tp.debug_set_flags("all")

    sys.exit(Dialler().run(sys.argv))
コード例 #6
0
def create_channel_cb(request, result, loop):
    try:
        (chan, context) = request.create_and_handle_channel_finish(result)

        chan.connect('incoming', tube_incoming_cb, loop)
        chan.connect('invalidated', tube_invalidated_cb, loop)

        chan.offer_async({}, offer_channel_cb, loop)

    except GObject.GError, e:
        print "Failed to create channel: %s" % e
        sys.exit(1)

if __name__ == '__main__':
    Tp.debug_set_flags(os.getenv('EXAMPLE_DEBUG', ''))

    if len(sys.argv) != 3:
        usage()

    _, account_id, contact_id = sys.argv

    account_manager = Tp.AccountManager.dup()
    account = account_manager.ensure_account("%s%s" %
        (Tp.ACCOUNT_OBJECT_PATH_BASE, account_id))

    request_dict = {
        Tp.PROP_CHANNEL_CHANNEL_TYPE:
            Tp.IFACE_CHANNEL_TYPE_STREAM_TUBE,
        Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE:
            int(Tp.HandleType.CONTACT),
コード例 #7
0
ファイル: dialler.py プロジェクト: Distrotech/telepathy-glib
        account = self.accounts[tree_iter][1]
        tree_iter = self.handler_combo.get_active_iter()
        handler = self.handlers[tree_iter][1]

        acr = Tp.AccountChannelRequest.new(account,
                {
                    Tp.PROP_CHANNEL_CHANNEL_TYPE:
                        Tp.IFACE_CHANNEL_TYPE_CALL,
                    Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE:
                        int(Tp.HandleType.CONTACT),
                    Tp.PROP_CHANNEL_TARGET_ID: self.target_entry.get_text(),
                    Tp.PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO: True,
                },
                USER_ACTION_TIME_NOT_USER_ACTION)
        acr.create_and_observe_channel_async(handler, None,
                self._create_call_cb, None)

    def _create_call_cb(self, acr, result, user_data):
        channel = acr.create_and_observe_channel_finish(result)
        print("accepting channel %s" % channel)
        channel.accept_async(self._accept_cb, None)

    def _accept_cb(self, channel, result, user_data):
        channel.accept_finish(result)
        print("accepted channel %s" % channel)

if __name__ == '__main__':
    Tp.debug_set_flags("all")

    sys.exit(Dialler().run(sys.argv))