MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9
   Home · All Classes · All Namespaces · Modules · Functions · Files

protocols/protocols.cpp

#include "protocols.h"
#include "_gen/protocols.moc.hpp"

#include <TelepathyQt4/Debug>
#include <TelepathyQt4/ConnectionManager>
#include <TelepathyQt4/PendingStringList>

#include <QCoreApplication>
#include <QDebug>

Protocols::Protocols()
    : cmWrappersFinished(0)
{
    qDebug() << "Listing names";
    connect(ConnectionManager::listNames(),
            SIGNAL(finished(Tp::PendingOperation *)),
            SLOT(onListNamesFinished(Tp::PendingOperation *)));
}

Protocols::~Protocols()
{
}

void Protocols::onListNamesFinished(PendingOperation *op)
{
    if (op->isError()) {
        qWarning() << "Error listing connection manager names -" <<
            op->errorName() << ": " << op->errorMessage();
        return;
    }

    PendingStringList *ps = qobject_cast<PendingStringList *>(op);

    qDebug() << "Supported CMs:" << ps->result();

    foreach (const QString &cmName, ps->result()) {
        CMWrapper *cmWrapper = new CMWrapper(cmName, this);
        mCMWrappers.append(cmWrapper);
        connect(cmWrapper,
                SIGNAL(finished()),
                SLOT(onCMWrapperFinished()));
    }
}

void Protocols::onCMWrapperFinished()
{
    if (++cmWrappersFinished == mCMWrappers.size()) {
        QCoreApplication::quit();
    }
}


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.6.5