/
notificationmanager.h
186 lines (153 loc) · 5.97 KB
/
notificationmanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/******************************************************************************
**
** This file is part of commhistory-daemon.
**
** Copyright (C) 2013-2016 Jolla Ltd.
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Contact: John Brooks <john.brooks@jolla.com>
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License version 2.1 as
** published by the Free Software Foundation.
**
** This library 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 Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this library; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/
#ifndef NOTIFICATIONMANAGER_H
#define NOTIFICATIONMANAGER_H
// QT includes
#include <QObject>
#include <QHash>
#include <QPair>
#include <QDBusInterface>
#include <QFile>
#include <QQueue>
#include <QMultiHash>
#include <QModelIndex>
#include <qofonomanager.h>
#include <qofonomessagewaiting.h>
#include <CommHistory/Event>
#include <CommHistory/Group>
#include <CommHistory/GroupModel>
#include <CommHistory/ContactListener>
#include <CommHistory/ContactResolver>
#include <CommHistory/Recipient>
// our includes
#include "commhistoryservice.h"
#include "personalnotification.h"
namespace Ngf {
class Client;
}
namespace RTComLogger {
typedef QPair<QString,QString> TpContactUid;
/*!
* \class NotificationManager
* \brief class responsible for showing notifications on desktop
*/
class NotificationManager : public QObject
{
Q_OBJECT
public:
typedef CommHistory::RecipientList RecipientList;
/*!
* \param QObject parent object
* \returns Notification manager singleton
*/
static NotificationManager* instance();
/*!
* \brief shows notification
* \param event to be shown
*/
void showNotification(const CommHistory::Event& event,
const QString &channelTargetId = QString(),
CommHistory::Group::ChatType chatType = CommHistory::Group::ChatTypeP2P,
const QString &details = QString());
/*!
* \brief removes notifications whose event type is in the supplied list of types
*/
void removeNotificationTypes(const QList<int> &types);
/*!
* \brief return group model with all conversations
* \returns group model pointer
*/
CommHistory::GroupModel* groupModel();
/*!
* \brief Show voicemail notification or removes it if count is 0
* \param count number of voicemails if it's known,
* a negative number if the number is unknown
*/
void showVoicemailNotification(int count);
/*!
* \brief Play class 0 SMS alert
*/
void playClass0SMSAlert();
void requestClass0Notification(const CommHistory::Event &event);
void setNotificationProperties(Notification *notification, PersonalNotification *pn, bool grouped);
public Q_SLOTS:
/*!
* \brief Removes notifications belonging to a particular account having optionally certain remote uids.
* \param accountPath Notifications of this account are to be removed.
*/
void removeNotifications(const QString &accountPath, const QList<int> &removeTypes = QList<int>());
private Q_SLOTS:
/*!
* Initialises notification manager instance
*/
void init();
void slotObservedConversationsChanged(const QList<CommHistoryService::Conversation> &conversations);
void slotInboxObservedChanged();
void slotCallHistoryObservedChanged(bool observed);
void slotGroupRemoved(const QModelIndex &index, int start, int end);
void slotGroupDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void slotNgfEventFinished(quint32 id);
void slotContactResolveFinished();
void slotContactChanged(const RecipientList &recipients);
void slotContactInfoChanged(const RecipientList &recipients);
void slotClassZeroError(const QDBusError &error);
void slotVoicemailWaitingChanged();
void slotModemAdded(QString path);
void slotModemRemoved(QString path);
void slotModemsChanged(QStringList modems);
void slotValidChanged(bool valid);
private:
NotificationManager( QObject* parent = 0);
~NotificationManager();
bool isCurrentlyObservedByUI(const CommHistory::Event& event,
const QString &channelTargetId,
CommHistory::Group::ChatType chatType);
void resolveNotification(PersonalNotification *notification);
void addNotification(PersonalNotification *notification);
void removeConversationNotifications(const CommHistory::Recipient &recipient,
CommHistory::Group::ChatType chatType);
void syncNotifications();
int pendingEventCount();
bool isFilteredInbox();
QString filteredInboxAccountPath();
bool updateEditedEvent(const CommHistory::Event &event, const QString &text);
void addModem(QString path);
QString notificationText(const CommHistory::Event &event, const QString &details);
private:
static NotificationManager* m_pInstance;
bool m_Initialised;
QList<PersonalNotification*> m_notifications;
QList<PersonalNotification*> m_unresolvedNotifications;
CommHistory::ContactResolver *m_contactResolver;
QSharedPointer<CommHistory::ContactListener> m_contactListener;
CommHistory::GroupModel *m_GroupModel;
Ngf::Client *m_ngfClient;
quint32 m_ngfEvent;
QSharedPointer<QOfonoManager> ofonoManager;
QHash<QString,QOfonoMessageWaiting*> interfaces;
#ifdef UNIT_TEST
friend class Ut_NotificationManager;
#endif
};
} // namespace RTComLogger
#endif // NOTIFICATIONMANAGER_H