first release
[groupsms] / sms / 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     Q_FOREACH( Tp::ChannelPtr channel, channels )
27     {
28         QVariantMap properties = channel->immutableProperties();
29         QString channelType = properties.value(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType")).toString();
30         if( !channelType.isNull() && !channelType.isEmpty())
31         {
32             qDebug() << "ChannelType=" << channelType;
33             tpSession->createChannelListener(channelType, context, account, channel);
34         }
35     }
36 }
37