Home · All Classes · All Namespaces · Modules · Functions · Files
protocols/cm-wrapper.cpp
#include "cm-wrapper.h"
#include "_gen/cm-wrapper.moc.hpp"

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

#include <QDebug>

CMWrapper::CMWrapper(const QString &cmName, QObject *parent)
    : QObject(parent),
      mCM(ConnectionManager::create(cmName))
{
    connect(mCM->becomeReady(),
            SIGNAL(finished(Tp::PendingOperation *)),
            SLOT(onCMReady(Tp::PendingOperation *)));
}

CMWrapper::~CMWrapper()
{
}

ConnectionManagerPtr CMWrapper::cm() const
{
    return mCM;
}

void CMWrapper::onCMReady(PendingOperation *op)
{
    if (op->isError()) {
        qWarning() << "CM" << mCM->name() << "cannot become ready -" <<
            op->errorName() << ": " << op->errorMessage();
        return;
    }

    qDebug() << "CM" << mCM->name() << "ready!";
    qDebug() << "Supported protocols:";
    foreach (const QString &protocol, mCM->supportedProtocols()) {
        qDebug() << "\t" << protocol;
    }

    emit finished();
}


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