[Telepathy] I'm unable to create a channel

Abhijit Bera abhibera at gmail.com
Mon Nov 8 02:59:20 PST 2010


Hi

I want to create a contact list channel using the connection object. I
always get an error message: Not Implemented.

I guess I must be passing the parameters incorrectly to createChannel. Can
someone point out where I'm making mistakes?

Here is my code:

telepathytest.h

  #ifndef TELEPATHYTEST_H

#define TELEPATHYTEST_H

 #include <QObject>

#include <TelepathyQt4/AccountManager>

#include <TelepathyQt4/PendingOperation>

#include <TelepathyQt4/PendingReady>

#include <TelepathyQt4/PendingChannel>

#include <TelepathyQt4/PendingChannelRequest>

#include <TelepathyQt4/Account>

#include <TelepathyQt4/AccountSet>

 class TelepathyTest : public QObject

{

    Q_OBJECT

 public:

    TelepathyTest(QObject *parent = 0);

    ~TelepathyTest() { }

 private Q_SLOTS:

    void onAccountManagerReady(Tp::PendingOperation*);

    void bringOnline();

    void checkCurrentPresence(Tp::PendingOperation*);

    void setupConnection();

    void setupConnection(const Tp::SimplePresence &value);

    void onConnectionReady(Tp::PendingOperation*);

    void getChannel();

    void gotChannel(Tp::PendingOperation*);

 private:

    Tp::AccountManagerPtr am;

    Tp::AccountPtr account;

    Tp::ConnectionPtr conn;

};

 #endif // TELEPATHYTEST_H


telepathytest.cpp

  #include "telepathytest.h"


 TelepathyTest::TelepathyTest (QObject *parent)

    : QObject(parent),

      am(Tp::AccountManager::create())

{

    connect(am->becomeReady(),

            SIGNAL(finished(Tp::PendingOperation*)), this,

            SLOT(onAccountManagerReady(Tp::PendingOperation*)));

 }

 void TelepathyTest::onAccountManagerReady (Tp::PendingOperation *op)

{

    if (op->isError()) {

        qWarning() << "Account manager cannot become ready:" <<

            op->errorName() << "-" << op->errorMessage();

        return;

    }

     // AccountManager is now ready

    qDebug() << "Valid accounts:";

    foreach (const QString &path, am->validAccountPaths()) {

        qDebug() << " path:" << path;

    }

     qDebug() << "Getting Skype Accounts";

    QVariantMap filter;

    filter.insert(QLatin1String("protocolName"), QLatin1String("skype"));

    Tp::AccountSetPtr filteredAccountSet=am->filterAccounts(filter);

    QList <Tp::AccountPtr> accounts = filteredAccountSet->accounts();

     if (accounts.count()>0) {

        foreach (Tp::AccountPtr t, accounts) {

            qDebug() << t->nickname();

            qDebug() << t->protocolName();

             account=t;

            break;

        }

         if(account->isEnabled()) {

            qDebug()<<"Account is Enabled";

        }

         if(account->isOnline()) {

            qDebug()<<"Account is Online";

            /* Tried this also getting same error

           QVariantMap map;

            map.insert("org.freedesktop.Telepathy.Channel.ChannelType",QVariant("org.freedeskop.Telepathy.Channel.Type.ContactList"));

            map.insert("org.freedesktop.Telepathy.Channel.TargetHandleType",
QVariant(uint(3)));

            map.insert("org.freedesktop.Telepathy.Channel.TargetID",QVariant("subscribe"));

            Tp::PendingChannelRequest* pch= account->ensureChannel(map);

            connect(pch, SIGNAL(finished(Tp::PendingOperation*)),
SLOT(gotChannel(Tp::PendingOperation*)));*/

            setupConnection();

        }

        else {

             qDebug()<<"Account offline. Bringing it online";

             bringOnline();

         }

    }

}

 void TelepathyTest::bringOnline() {

    Tp::SimplePresence value;

    value.status="available";

    value.type=2;

    value.statusMessage="available";

    connect(account->setRequestedPresence(value),

             SIGNAL(finished(Tp::PendingOperation*)),this,

             SLOT(checkCurrentPresence(Tp::PendingOperation*)));

}

 void TelepathyTest::checkCurrentPresence(Tp::PendingOperation *op) {

    if(op->isError()) {

        qDebug()<<"Error Occurred. Couldn't set requested presence";

        qDebug() << op->errorName();

        qDebug() << op->errorMessage();

        return;

    }

    qDebug() << "Checking for current presence changed";

     connect(account.data(),SIGNAL(currentPresenceChanged(const
Tp::SimplePresence&)),this,

            SLOT(setupConnection(const Tp::SimplePresence&)));

}

 void TelepathyTest::setupConnection(const Tp::SimplePresence &value) {

    if(value.type==2) {

        qDebug()<<"Account is now Online";

        setupConnection();

    }

}

 void TelepathyTest::setupConnection() {

    if(account->haveConnection())  {

        qDebug()<<"Account has connection";

        conn=account->connection();

        connect(conn->becomeReady(),SIGNAL(finished(Tp::PendingOperation*)),

                SLOT(onConnectionReady(Tp::PendingOperation*)));

    }

}

 void TelepathyTest::onConnectionReady(Tp::PendingOperation *op) {

    if(op->isError()) {

        qDebug()<<"Couldn't create connection";

        qDebug() << op->errorName();

        qDebug() << op->errorMessage();

        return;

    }

     qDebug()<<"Connection is ready";

    getChannel();

}

 void TelepathyTest::getChannel() {

    // Maybe I'm passing the parameters wrong?

    QVariantMap map;

    map.insert("org.freedesktop.Telepathy.Channel.ChannelType",QVariant("org.freedeskop.Telepathy.Channel.Type.ContactList"));

    map.insert("org.freedesktop.Telepathy.Channel.TargetHandleType",
QVariant(uint(3)));

    map.insert("org.freedesktop.Telepathy.Channel.TargetID",QVariant("subscribe"));

    Tp::PendingChannel* pch = conn->createChannel(map);

    connect(pch, SIGNAL(finished(Tp::PendingOperation*)),
SLOT(gotChannel(Tp::PendingOperation*)));

}

 void TelepathyTest::gotChannel(Tp::PendingOperation*op) {

    if(op->isError()) {

        qDebug() << "Couldn't get requested channel";

        qDebug() << op->errorName();

        qDebug() << op->errorMessage();

        return;

    }

     qDebug() << "Got channel";

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/telepathy/attachments/20101108/d653f652/attachment.htm>


More information about the telepathy mailing list