View Single Post
Posts: 249 | Thanked: 277 times | Joined on May 2010 @ Brighton, UK
#5
Given that I don't really care about anything from telepathy other than property twiddling, I decided to try alternate ways of working with DBus, and am quite happy with Qt's QtDBus API.

I've got this now (I've used the PHP markup for the highlighting):
PHP Code:
#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 argcchar *argv[])
{
    
QCoreApplication a(argcargv);

    
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 argaccountList.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<QVariantisEnabledProp tpAccount.call(
                        
"Get",
                        
TP_IFACE_ACCOUNT,
                        
"Enabled");
                    
qDebug() << (isEnabledProp.value().toBool() ? "Enabled:\t\t" "Not enabled:\t") << objectPath.path();
                }
            }
            
argument.endArray();
        }
    }

    return 
a.exec();

...but get a weird warning that I'm going to treat as an error:
Code:
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
...this comes from the call to "argument.endArray();". The error goes away when I remove the call, but the documentation says it's required to match up with the call to "argument.beginArray();".

Something new to ponder, though I'll happily take any answers anyone has to offer