Esempio n. 1
0
int main(int argc, char *argv[])
{
    KLocalizedString::setApplicationDomain("ktp-text-ui");

    Kdelibs4ConfigMigrator migrator(QLatin1String("ktp-text-ui"));
    migrator.setConfigFiles(QStringList() << QLatin1String("ktp-text-uirc"));
    migrator.setUiFiles(QStringList() << QLatin1String("chatwindow.rc"));
    migrator.migrate();

    // KAboutData is in telepathy-chat-ui.cpp, read there why

    Tp::registerTypes();
    KTp::registerOtrTypes();

    Tp::SharedPtr<TelepathyChatUi> app(new TelepathyChatUi(argc, argv));

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
    channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);

    Tp::Features textFeatures = Tp::Features() << Tp::TextChannel::FeatureMessageQueue
                                               << Tp::TextChannel::FeatureMessageSentSignal
                                               << Tp::TextChannel::FeatureChatState
                                               << Tp::TextChannel::FeatureMessageCapabilities;
    channelFactory->addFeaturesForTextChats(textFeatures);
    channelFactory->addFeaturesForTextChatrooms(textFeatures);
    channelFactory->addFeaturesForOutgoingFileTransfers(Tp::OutgoingFileTransferChannel::FeatureCore);

    Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(KTp::accountFactory(), KTp::connectionFactory(), channelFactory, KTp::contactFactory());

    Tp::AbstractClientPtr handler = Tp::AbstractClientPtr(app);
    registrar->registerClient(handler, QLatin1String(KTP_TEXTUI_CLIENT_NAME));

    return app->exec();
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    ObserverApp *oa = new ObserverApp();

    Tp::registerTypes();

    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
                                            Tp::Features() << Tp::Account::FeatureCore
                                            << Tp::Account::FeatureAvatar
                                            << Tp::Account::FeatureProfile);

    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
            Tp::Features() << Tp::Connection::FeatureCore
            << Tp::Connection::FeatureSelfContact
            << Tp::Connection::FeatureRoster);

    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                           << Tp::Contact::FeatureAvatarData
                                           << Tp::Contact::FeatureSimplePresence
                                           << Tp::Contact::FeatureCapabilities);

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());





    Tp::AccountManagerPtr m_accountManager = Tp::AccountManager::create(accountFactory, connectionFactory, channelFactory, contactFactory);
    QObject::connect(m_accountManager->becomeReady(), &Tp::PendingOperation::finished, &app, [=](Tp::PendingOperation *op) {

        qDebug() << "Manager ready, setting client registrar";

        Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
        channelFactory->addFeaturesForTextChats(Tp::Features() << Tp::Channel::FeatureCore << Tp::TextChannel::FeatureMessageQueue << Tp::TextChannel::FeatureMessageSentSignal << Tp::TextChannel::FeatureMessageCapabilities);

        oa->channelWatcherObserver = Tp::SharedPtr<KTp::TextChannelObserver>(new KTp::TextChannelObserver());

        oa->clientRegistrar = Tp::ClientRegistrar::create(m_accountManager->accountFactory(),
                              m_accountManager->connectionFactory(),
                              channelFactory,
                              m_accountManager->contactFactory());

        qDebug() << oa->clientRegistrar->registerClient(Tp::AbstractClientPtr::dynamicCast(oa->channelWatcherObserver), QLatin1String("KDE.Mobile.Logger"));
    });

    return app.exec();
}