#include <QtDBus/QtDBus> #include <QDebug> #include <QtCore/QCoreApplication> #include <telepathy-glib/interfaces.h> const char * TP_PATH_ACCOUNT_MANAGER("/org/freedesktop/Telepathy/AccountManager"); int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDBusInterface tpAccountManagerApp( TP_IFACE_ACCOUNT_MANAGER, TP_PATH_ACCOUNT_MANAGER, TP_IFACE_DBUS_PROPERTIES); if (tpAccountManagerApp.isValid()) { QDBusMessage accountList = tpAccountManagerApp.call( "Get", TP_IFACE_ACCOUNT_MANAGER, "ValidAccounts"); foreach (QVariant arg, accountList.arguments()) { QDBusArgument argument(qvariant_cast<QDBusVariant>(arg).variant().value<QDBusArgument>()); argument.beginArray(); while (!argument.atEnd()) { // Grab the account path QDBusObjectPath objectPath; argument >> objectPath; //Grab the enabled property of each account QDBusInterface tpAccount( TP_IFACE_ACCOUNT_MANAGER, objectPath.path(), TP_IFACE_DBUS_PROPERTIES); if (tpAccount.isValid()) { QDBusReply<QVariant> isEnabledProp = tpAccount.call( "Get", TP_IFACE_ACCOUNT, "Enabled"); qDebug() << (isEnabledProp.value().toBool() ? "Enabled:\t\t" : "Not enabled:\t") << objectPath.path(); } } argument.endArray(); } } return a.exec(); }
Enabled: "/org/freedesktop/Telepathy/Account/ring/tel/ring" Not enabled: "/org/freedesktop/Telepathy/Account/gabble/jabber/jamierocks_40gmail_2ecom0" Enabled: "/org/freedesktop/Telepathy/Account/sofiasip/sip/_373023190" Not enabled: "/org/freedesktop/Telepathy/Account/sofiasip/sip/_33888389_40sipgate_2eco_2euk0" Not enabled: "/org/freedesktop/Telepathy/Account/gabble/jabber/jamie_40jabber_2ejamie_2dthompson_2eco_2euk0" Not enabled: "/org/freedesktop/Telepathy/Account/gabble/jabber/qwerki_40chat_2efacebook_2ecom0" QDBusArgument: write from a read-only object