main.cpp 4.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/***************************************************************************
 *   Copyright (C) 2012 by David Edmundson <kde@davidedmundson.co.uk>      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
 ***************************************************************************/

20
21
22
23
24
#include <QApplication>
#include <QCommandLineParser>

#include <KAboutData>
#include <KLocalizedString>
25
#include <KDBusService>
26

David Edmundson's avatar
David Edmundson committed
27
#include "log-viewer.h"
28
#include "../ktptextui_version.h"
29
#include "debug.h"
David Edmundson's avatar
David Edmundson committed
30

31
32
#include <TelepathyQt/AccountManager>

33
34
#include <KTp/contact-factory.h>

35
36
Q_LOGGING_CATEGORY(KTP_LOGVIEWER, "ktp-logviewer")

David Edmundson's avatar
David Edmundson committed
37
38
int main(int argc, char *argv[])
{
39
    QApplication app(argc, argv);
40
    KLocalizedString::setApplicationDomain("ktp-log-viewer");
41
42
43
44
45
46
47

    KAboutData aboutData("ktp-log-viewer",
                         i18n("KDE IM Log Viewer"),
                         QStringLiteral(KTP_TEXT_UI_VERSION_STRING));
    aboutData.addAuthor(i18n("David Edmundson"), i18n("Developer"), "kde@davidedmundson.co.uk");
    aboutData.addAuthor(i18n("Daniele E. Domenichelli"), i18n("Developer"), "daniele.domenichelli@gmail.com");
    aboutData.addAuthor(i18n("Dan Vrátil"), i18n("Developer"), "dvratil@redhat.com");
48
    aboutData.setProductName("telepathy/log-viewer"); //set the correct name for bug reporting
49
    aboutData.setOrganizationDomain(QByteArray("kde.org"));
50
51
52
    aboutData.setLicense(KAboutLicense::GPL_V2);

    KAboutData::setApplicationData(aboutData);
53

54
55
56
    // register to DBus
    const KDBusService dbusService(KDBusService::Multiple);

57
    QCommandLineParser parser;
58

59
60
    QCommandLineOption accountId(QStringLiteral("accountID"), i18n("The UID of the account to preselect"));
    QCommandLineOption contactId(QStringLiteral("contactID"), i18n("The UID of the contact to preselect"));
61

62
63
    parser.addOption(accountId);
    parser.addOption(contactId);
64

65
    parser.process(app);
66
67
68
69
70
71

    Tp::registerTypes();

    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(
                                                QDBusConnection::sessionBus(),
                                                Tp::Features() << Tp::Account::FeatureCore
72
                                                    << Tp::Account::FeatureAvatar
Daniele E. Domenichelli's avatar
Daniele E. Domenichelli committed
73
                                                    << Tp::Account::FeatureProfile);
74
75
76
77
78
79
80

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

81
    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
82
83
84
85
86
87
88
89
90
                                                Tp::Features()  << Tp::Contact::FeatureAlias
                                                    << Tp::Contact::FeatureAvatarData
                                                    << Tp::Contact::FeatureSimplePresence
                                                    << Tp::Contact::FeatureCapabilities);

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

    LogViewer *logViewer = new LogViewer(accountFactory, connectionFactory, channelFactory, contactFactory);
    logViewer->show();
David Edmundson's avatar
David Edmundson committed
91

92
    return app.exec();
David Edmundson's avatar
David Edmundson committed
93
}