Changeset View
Changeset View
Standalone View
Standalone View
plugins/telephony/conversationsdbusinterface.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | * Copyright 2013 Albert Vaca <albertvaka@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef CONVERSATIONSDBUSINTERFACE_H | ||||
22 | #define CONVERSATIONSDBUSINTERFACE_H | ||||
23 | | ||||
24 | #include <QDBusAbstractAdaptor> | ||||
25 | #include <QHash> | ||||
26 | #include <QList> | ||||
27 | #include <QString> | ||||
28 | #include <QStringList> | ||||
29 | #include <QDir> | ||||
30 | #include <QPointer> | ||||
31 | | ||||
32 | #include "interfaces/conversationmessage.h" | ||||
33 | #include "interfaces/dbusinterfaces.h" | ||||
34 | | ||||
35 | class KdeConnectPlugin; | ||||
36 | class Device; | ||||
37 | | ||||
38 | class ConversationsDbusInterface | ||||
39 | : public QDBusAbstractAdaptor | ||||
40 | { | ||||
41 | Q_OBJECT | ||||
42 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.conversations") | ||||
43 | | ||||
44 | public: | ||||
45 | explicit ConversationsDbusInterface(KdeConnectPlugin* plugin); | ||||
46 | ~ConversationsDbusInterface() override; | ||||
47 | | ||||
48 | void addMessage(const ConversationMessage &message); | ||||
49 | void removeMessage(const QString& internalId); | ||||
50 | | ||||
51 | public Q_SLOTS: | ||||
52 | /** | ||||
53 | * Return a list of the threadID for all valid conversations | ||||
54 | */ | ||||
55 | QStringList activeConversations(); | ||||
56 | | ||||
57 | void requestConversation(const QString &conversationID, int start, int end); | ||||
58 | | ||||
59 | /** | ||||
60 | * Send a new message to this conversation | ||||
61 | */ | ||||
62 | void replyToConversation(const QString& conversationID, const QString& message); | ||||
63 | | ||||
64 | /** | ||||
65 | * Send the request to the Telephony plugin to update the list of conversation threads | ||||
66 | */ | ||||
67 | void requestAllConversationThreads(); | ||||
68 | | ||||
69 | Q_SIGNALS: | ||||
70 | Q_SCRIPTABLE void conversationCreated(const QString& threadID); | ||||
71 | Q_SCRIPTABLE void conversationRemoved(const QString& threadID); | ||||
72 | Q_SCRIPTABLE void conversationUpdated(const QString& threadID); | ||||
73 | Q_SCRIPTABLE void conversationMessageReceived(const QVariantMap & msg, int pos) const; | ||||
74 | | ||||
75 | private /*methods*/: | ||||
76 | QString newId(); //Generates successive identifitiers to use as public ids | ||||
77 | | ||||
78 | private /*attributes*/: | ||||
79 | const Device* m_device; | ||||
80 | KdeConnectPlugin* m_plugin; | ||||
81 | | ||||
82 | /** | ||||
83 | * Mapping of threadID to the list of messages which make up that thread | ||||
84 | */ | ||||
85 | QHash<QString, QVector<ConversationMessage>> m_conversations; | ||||
86 | | ||||
87 | /** | ||||
88 | * Mapping of threadID to the set of uIDs known in the corresponding conversation | ||||
89 | */ | ||||
90 | QHash<QString, QSet<qint32>> m_known_messages; | ||||
91 | | ||||
92 | int m_lastId; | ||||
93 | | ||||
94 | TelephonyDbusInterface m_telephonyInterface; | ||||
95 | }; | ||||
96 | | ||||
97 | #endif // CONVERSATIONSDBUSINTERFACE_H |