tpsession initial import
[tpsession] / tpsession-0.1 / tpsession / tpsessionobserver.cpp
1 #include "tpsessionobserver.h"
2 #include "tpsession.h"
3 #include <TelepathyQt4/Channel>
4
5 TpSessionObserver::TpSessionObserver(const Tp::ChannelClassList &channelFilter,TpSession *session):Tp::AbstractClientObserver(channelFilter)
6 {
7     tpSession=session;
8     qDebug() << __PRETTY_FUNCTION__ ;
9 }
10
11 void TpSessionObserver::observeChannels(const Tp::MethodInvocationContextPtr<> &context,
12             const Tp::AccountPtr &account,
13             const Tp::ConnectionPtr &connection,
14             const QList<Tp::ChannelPtr> &channels,
15             const Tp::ChannelDispatchOperationPtr &dispatchOperation,
16             const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
17             const QVariantMap &observerInfo)
18 {
19     Q_UNUSED(dispatchOperation)
20     Q_UNUSED(requestsSatisfied)
21     Q_UNUSED(observerInfo)
22     Q_UNUSED(connection)
23
24     qDebug() << "TpSessionObserver::observeChannels";
25
26     foreach(Tp::ChannelPtr channel, channels) {
27     QVariantMap properties = channel->immutableProperties();
28     QString channelType = properties.value(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType")).toString();
29     if( !channelType.isNull() && !channelType.isEmpty()) {
30           qDebug() << "ChannelType=" << channelType;
31                 tpSession->createChannelListener(channelType, context, account, channel);
32             }
33     }
34 }
35