~ci-train-bot/history-service/history-service-ubuntu-zesty-2629

« back to all changes in this revision

Viewing changes to daemon/historyservicedbus.cpp

  • Committer: Bileto Bot
  • Author(s): Gustavo Pichorim Boiko
  • Date: 2016-11-30 15:13:58 UTC
  • mfrom: (230.2.23 staging)
  • Revision ID: ci-train-bot@canonical.com-20161130151358-jy3mqj0ir0b6ncxe
Improve group chat support.

Approved by: Roberto Mier Escandón , Tiago Salem Herrmann

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2013 Canonical, Ltd.
 
2
 * Copyright (C) 2013-2016 Canonical, Ltd.
3
3
 *
4
4
 * Authors:
5
5
 *  Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
34
34
 
35
35
bool HistoryServiceDBus::connectToBus()
36
36
{
37
 
    bool ok = QDBusConnection::sessionBus().registerService(History::DBusService);
38
 
    if (!ok) {
39
 
        return false;
40
 
    }
41
 
 
42
37
    if (!mAdaptor) {
43
38
        mAdaptor = new HistoryServiceAdaptor(this);
44
39
    }
45
40
 
46
 
    return QDBusConnection::sessionBus().registerObject(History::DBusObjectPath, this);
 
41
    if (!QDBusConnection::sessionBus().registerObject(History::DBusObjectPath, this)) {
 
42
        return false;
 
43
    }
 
44
 
 
45
    return QDBusConnection::sessionBus().registerService(History::DBusService);
47
46
}
48
47
 
49
48
void HistoryServiceDBus::notifyThreadsAdded(const QList<QVariantMap> &threads)
76
75
    Q_EMIT EventsRemoved(events);
77
76
}
78
77
 
 
78
QVariantMap HistoryServiceDBus::ThreadForProperties(const QString &accountId,
 
79
                                                    int type,
 
80
                                                    const QVariantMap &properties,
 
81
                                                    int matchFlags,
 
82
                                                    bool create)
 
83
{
 
84
    return HistoryDaemon::instance()->threadForProperties(accountId,
 
85
                                                            (History::EventType) type,
 
86
                                                            properties,
 
87
                                                            (History::MatchFlags) matchFlags,
 
88
                                                            create);
 
89
}
 
90
 
79
91
QVariantMap HistoryServiceDBus::ThreadForParticipants(const QString &accountId,
80
92
                                                      int type,
81
93
                                                      const QStringList &participants,
82
94
                                                      int matchFlags,
83
95
                                                      bool create)
84
96
{
85
 
    return HistoryDaemon::instance()->threadForParticipants(accountId,
 
97
    QVariantMap properties;
 
98
    properties[History::FieldParticipants] = participants;
 
99
 
 
100
    return HistoryDaemon::instance()->threadForProperties(accountId,
86
101
                                                            (History::EventType) type,
87
 
                                                            participants,
 
102
                                                            properties,
88
103
                                                            (History::MatchFlags) matchFlags,
89
104
                                                            create);
90
105
}
91
106
 
92
107
bool HistoryServiceDBus::WriteEvents(const QList<QVariantMap> &events)
93
108
{
94
 
    qDebug() << __PRETTY_FUNCTION__;
95
 
    return HistoryDaemon::instance()->writeEvents(events);
 
109
    return HistoryDaemon::instance()->writeEvents(events, QVariantMap());
96
110
}
97
111
 
98
112
bool HistoryServiceDBus::RemoveThreads(const QList<QVariantMap> &threads)
99
113
{
100
 
    qDebug() << __PRETTY_FUNCTION__;
101
114
    return HistoryDaemon::instance()->removeThreads(threads);
102
115
}
103
116
 
104
117
bool HistoryServiceDBus::RemoveEvents(const QList<QVariantMap> &events)
105
118
{
106
 
    qDebug() << __PRETTY_FUNCTION__;
107
119
    return HistoryDaemon::instance()->removeEvents(events);
108
120
}
109
121
 
110
122
QString HistoryServiceDBus::QueryThreads(int type, const QVariantMap &sort, const QVariantMap &filter, const QVariantMap &properties)
111
123
{
112
 
    qDebug() << __PRETTY_FUNCTION__;
113
124
    return HistoryDaemon::instance()->queryThreads(type, sort, filter, properties);
114
125
}
115
126
 
116
127
QString HistoryServiceDBus::QueryEvents(int type, const QVariantMap &sort, const QVariantMap &filter)
117
128
{
118
 
    qDebug() << __PRETTY_FUNCTION__;
119
129
    return HistoryDaemon::instance()->queryEvents(type, sort, filter);
120
130
}
121
131
 
122
132
QVariantMap HistoryServiceDBus::GetSingleThread(int type, const QString &accountId, const QString &threadId, const QVariantMap &properties)
123
133
{
124
 
    qDebug() << __PRETTY_FUNCTION__;
125
134
    return HistoryDaemon::instance()->getSingleThread(type, accountId, threadId, properties);
126
135
}
127
136
 
128
137
QVariantMap HistoryServiceDBus::GetSingleEvent(int type, const QString &accountId, const QString &threadId, const QString &eventId)
129
138
{
130
 
    qDebug() << __PRETTY_FUNCTION__;
131
139
    return HistoryDaemon::instance()->getSingleEvent(type, accountId, threadId, eventId);
132
140
}
133
141