Warning, file /network/ktp-auth-handler/conference-auth-observer.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Copyright (C) 2012 Rohan Garg <rohangarg@kubuntu.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  */
0018 
0019 
0020 #include "conference-auth-observer.h"
0021 
0022 #include "conference-auth-op.h"
0023 
0024 #include <KTp/telepathy-handler-application.h>
0025 
0026 #include <QDBusConnection>
0027 #include <QDebug>
0028 
0029 #include <TelepathyQt/Channel>
0030 #include <TelepathyQt/ChannelDispatchOperation>
0031 #include <TelepathyQt/MethodInvocationContext>
0032 
0033 
0034 ConferenceAuthObserver::ConferenceAuthObserver(const Tp::ChannelClassSpecList &channelFilter)
0035     : Tp::AbstractClientObserver(channelFilter)
0036 {
0037 }
0038 
0039 ConferenceAuthObserver::~ConferenceAuthObserver()
0040 {
0041 }
0042 
0043 void ConferenceAuthObserver::observeChannels(const Tp::MethodInvocationContextPtr<> &context,
0044                                              const Tp::AccountPtr &account,
0045                                              const Tp::ConnectionPtr &connection,
0046                                              const QList<Tp::ChannelPtr> &channels,
0047                                              const Tp::ChannelDispatchOperationPtr &dispatchOperation,
0048                                              const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
0049                                              const Tp::AbstractClientObserver::ObserverInfo &observerInfo)
0050 {
0051     Q_UNUSED(connection);
0052     Q_UNUSED(requestsSatisfied);
0053     Q_UNUSED(observerInfo);
0054     Q_UNUSED(dispatchOperation)
0055 
0056     Q_FOREACH (Tp::ChannelPtr channel, channels) {
0057         if (!channel->hasInterface(TP_QT_IFACE_CHANNEL_INTERFACE_PASSWORD)) {
0058             qDebug() << "Channel does not have password interface, exiting ...";
0059             continue;
0060         }
0061 
0062         KTp::TelepathyHandlerApplication::newJob();
0063         ConferenceAuthOp *auth = new ConferenceAuthOp(
0064                     account, channel);
0065         connect(auth,
0066                 SIGNAL(finished(Tp::PendingOperation*)),
0067                 SLOT(onAuthFinished(Tp::PendingOperation*)));
0068     }
0069 
0070     context->setFinished();
0071 
0072 }
0073 
0074 void ConferenceAuthObserver::onAuthFinished(Tp::PendingOperation *op)
0075 {
0076     if (op->isError()) {
0077         qWarning() << "Error in conference room auth:" << op->errorName() << "-" << op->errorMessage();
0078     }
0079 
0080     KTp::TelepathyHandlerApplication::jobFinished();
0081 }