コード例 #1
0
ファイル: main.cpp プロジェクト: KDE/ktp-text-ui
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();
}