#!/usr/bin/env python import gobject from gi.repository import TelepathyGLib main_loop = gobject.MainLoop() def set_self_presence_cb(connection, result, user_data): print 'set_self_presence_cb' def account_manager_prepare_async_cb(account_manager, result, user_data): print 'account_manager_prepare_async_cb' if not account_manager.prepare_finish(result): raise Exception("Account manager preparation failed") for account in account_manager.get_valid_accounts(): connection = account.get_connection() if connection is None: continue allowed_presence_statuses = connection.get_allowed_presence_statuses() print allowed_presence_statuses if not allowed_presence_statuses: continue status_spec = allowed_presence_statuses.values()[0] connection.set_self_presence(status_spec.status, '', set_self_presence_cb, None) main_loop.quit() dbus_daemon = TelepathyGLib.DBusDaemon.dup() account_manager = TelepathyGLib.AccountManager.dup() account_manager.prepare_async(None, account_manager_prepare_async_cb, None) main_loop.run()