#!/usr/bin/env python import random 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 %r' % connection.set_self_presence_finish(result) def connection_prepare_async_cb(connection, result, user_data): print 'connection_prepare_async_cb %r' % connection.prepare_finish(result) allowed_presence_statuses = connection.get_allowed_presence_statuses() if not allowed_presence_statuses: return statuses = allowed_presence_statuses.keys() random.shuffle(statuses) for status in statuses: if allowed_presence_statuses[status].may_set_on_self: print 'setting presence to %s' % allowed_presence_statuses[status].status connection.set_self_presence_async( allowed_presence_statuses[status].status, '', set_self_presence_cb, None) return def account_manager_prepare_async_cb(account_manager, result, user_data): print 'account_manager_prepare_async_cb %r' % account_manager.prepare_finish(result) for account in account_manager.get_valid_accounts(): connection = account.get_connection() if connection is None: continue connection.prepare_async( [TelepathyGLib.Connection.get_feature_quark_self_presence()], connection_prepare_async_cb, None) dbus_daemon = TelepathyGLib.DBusDaemon.dup() account_manager = TelepathyGLib.AccountManager.dup() account_manager.prepare_async(None, account_manager_prepare_async_cb, None) main_loop.run()