• Skip to content
  • Skip to link menu
  • KDE API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • KTp
  • Declarative
telepathy-text-observer.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Lasath Fernando <kde@lasath.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 
20 #include "telepathy-text-observer.h"
21 #include "conversation.h"
22 
23 #include <KDebug>
24 
25 #include <TelepathyQt/AccountFactory>
26 #include <TelepathyQt/ConnectionFactory>
27 #include <TelepathyQt/ClientRegistrar>
28 
29 #include <KTp/contact-factory.h>
30 
31 
32 TelepathyTextObserver::TelepathyTextObserver(QObject *parent) :
33  QObject(parent),
34  m_handler(new ConversationsModel(this))
35 {
36  kDebug();
37  Tp::registerTypes();
38  Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
39  Tp::Account::FeatureCore);
40 
41  Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(
42  QDBusConnection::sessionBus(),
43  Tp::Features() << Tp::Connection::FeatureSelfContact
44  << Tp::Connection::FeatureCore
45  << Tp::Connection::FeatureConnected
46  );
47 
48  Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
49  channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
50 
51  Tp::Features textFeatures = Tp::Features() << Tp::TextChannel::FeatureMessageQueue
52  << Tp::TextChannel::FeatureMessageSentSignal
53  << Tp::TextChannel::FeatureChatState
54  << Tp::TextChannel::FeatureMessageCapabilities;
55  channelFactory->addFeaturesForTextChats(textFeatures);
56  channelFactory->addFeaturesForTextChatrooms(textFeatures);
57 
58  Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
59  Tp::Features() << Tp::Contact::FeatureAlias
60  << Tp::Contact::FeatureAvatarToken
61  << Tp::Contact::FeatureAvatarData
62  << Tp::Contact::FeatureCapabilities
63  << Tp::Contact::FeatureSimplePresence
64  );
65 
66  //TODO: check these to make sure I'm only requesting features I actually use.
67  m_registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
68  channelFactory, contactFactory);
69  m_registrar->registerClient(m_handler, QLatin1String("KDE.TextUi.ConversationWatcher")); //KTp.ChatPlasmoid
70 
71  m_accountManager = Tp::AccountManager::create(accountFactory, connectionFactory, channelFactory, contactFactory);
72  m_accountManager->becomeReady();
73 }
74 
75 TelepathyTextObserver::~TelepathyTextObserver()
76 {
77  kDebug() << "deleting text observer";
78 }
79 
80 ConversationsModel* TelepathyTextObserver::conversationModel() const
81 {
82  Q_ASSERT(!m_handler.isNull());
83  return m_handler.data();
84 }
85 
86 Tp::AccountManagerPtr TelepathyTextObserver::accountManager() const
87 {
88  return m_accountManager;
89 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Mar 22 2013 10:58:52 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktp-common-internals API Reference

Skip menu "ktp-common-internals API Reference"
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal