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()
def inspect(name): cm = Tp.ConnectionManager( dbus_daemon=Tp.DBusDaemon.dup(), bus_name=Tp.CM_BUS_NAME_BASE + name, object_path=Tp.CM_OBJECT_PATH_BASE + name, ) cm.prepare_async(None, cm, loop)
def cms_cb(source, result, loop): try: cms = Tp.list_connection_managers_finish(result) for cm in cms: describe(cm) print("") finally: loop.quit()
def _one_to_one_connection_ready_cb(self, bus_name, channel, conn): '''Callback for Connection for one to one connection''' text_channel = TelepathyGLib.Channel(conn, channel) self.text_channel = TextChannelWrapper(text_channel, conn) self.text_channel.set_received_callback(self._received_cb) self.text_channel.handle_pending_messages() self.text_channel.set_closed_callback( self._one_to_one_connection_closed_cb) self._chat_is_room = False self._alert(_('On-line'), _('Private Chat')) # XXX How do we detect the sender going offline? self._entry.set_sensitive(True) self._entry.props.placeholder_text = None self._entry.grab_focus()
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)
def inspect(name): cm = Tp.ConnectionManager( dbus_daemon=Tp.DBusDaemon.dup(), bus_name=Tp.CM_BUS_NAME_BASE + name, object_path=Tp.CM_OBJECT_PATH_BASE + name, ) cm.prepare_async(None, cm, loop) def cms_cb(source, result, loop): try: cms = Tp.list_connection_managers_finish(result) for cm in cms: describe(cm) print("") finally: loop.quit() if __name__ == '__main__': loop = GObject.MainLoop() if len(sys.argv) >= 2: inspect(sys.argv[1]) else: Tp.list_connection_managers_async(Tp.DBusDaemon.dup(), cms_cb, loop) loop.run()
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()
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))
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),
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))