|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef EVENTLOGGERENGINE_H |
|
43 #define EVENTLOGGERENGINE_H |
|
44 #include "qmessageglobal.h" |
|
45 #include "qmessagemanager.h" |
|
46 #include "qmessageaccount.h" |
|
47 #include "qmessageaccountid.h" |
|
48 #include "qmessageaccount_p.h" |
|
49 #include "qmessageaccountfilter.h" |
|
50 #include "qmessageaccountfilter_p.h" |
|
51 #include "qmessageservice.h" |
|
52 #include "qmessage.h" |
|
53 #include "qmessagemanager.h" |
|
54 #include "maemohelpers_p.h" |
|
55 #include "qmessagestore_p.h" |
|
56 #include "qmessage_p.h" |
|
57 #include "qmessagefilter.h" |
|
58 #include "qmessagefilter_p.h" |
|
59 #include "qmessagefolderfilter_p.h" |
|
60 #include <QThread> |
|
61 #include <QObject> |
|
62 |
|
63 extern "C" { |
|
64 |
|
65 #include <glib.h> |
|
66 #include <rtcom-eventlogger/eventlogger.h> |
|
67 #include <dbus/dbus.h> |
|
68 #include <dbus/dbus-glib-lowlevel.h> |
|
69 |
|
70 }; |
|
71 |
|
72 QTM_BEGIN_NAMESPACE |
|
73 |
|
74 class EventLoggerEngine; |
|
75 |
|
76 class QueryThread : public QThread |
|
77 { |
|
78 Q_OBJECT |
|
79 |
|
80 |
|
81 public: |
|
82 QueryThread(); |
|
83 void setArgs(EventLoggerEngine *parent, const QMessageFilter &filter, const QString &body, QMessageDataComparator::MatchFlags matchFlags, const QMessageSortOrder &sortOrder, uint limit, uint offset); |
|
84 void run(); |
|
85 |
|
86 signals: |
|
87 void completed(); |
|
88 public: |
|
89 EventLoggerEngine *_parent; |
|
90 QMessageFilter _filter; |
|
91 QString _body; |
|
92 QMessageDataComparator::MatchFlags _matchFlags; |
|
93 QMessageSortOrder _sortOrder; |
|
94 uint _limit; |
|
95 uint _offset; |
|
96 |
|
97 }; |
|
98 |
|
99 |
|
100 class EventLoggerEngine:public QObject |
|
101 { |
|
102 Q_OBJECT |
|
103 |
|
104 public: |
|
105 |
|
106 explicit EventLoggerEngine(QObject *parent = 0); |
|
107 static EventLoggerEngine* instance(); |
|
108 void unregisterNotificationFilter(QMessageManager::NotificationFilterId notificationFilterId); |
|
109 QMessageManager::NotificationFilterId registerNotificationFilter(QMessageStorePrivate& aPrivateStore,const QMessageFilter &filter); |
|
110 QMessage message(const QMessageId& id); |
|
111 bool deleteMessage(const QMessageId& id); |
|
112 QMessage eventToMessage(RTComElEvent & ev); |
|
113 void notification(int eventId, QString servive,QMessageStorePrivate::NotificationType notificationType); |
|
114 static void new_event_cb(RTComEl *el,int event_id, |
|
115 const char *local_uid,const char *remote_uid,const char *remote_ebook_uid, |
|
116 const char *group_uid,const char *service,EventLoggerEngine *p); |
|
117 void newEvent(int event_id, |
|
118 const char *local_uid,const char *remote_uid,const char *remote_ebook_uid, |
|
119 const char *group_uid,const char *service); |
|
120 QMessageIdList filterAndOrderMessages(const QMessageFilter &filter, const QMessageSortOrder& sortOrder, |
|
121 QString body, QMessageDataComparator::MatchFlags matchFlags); |
|
122 |
|
123 bool filterMessages(const QMessageFilter &filter, const QMessageSortOrder& sortOrder, |
|
124 QString body, QMessageDataComparator::MatchFlags matchFlags); |
|
125 |
|
126 void addEvent(QMessage &message); |
|
127 QMessageIdList m_ids; |
|
128 |
|
129 signals: |
|
130 void messagesFound(const QMessageIdList &,bool,bool); |
|
131 void stateChanged(QMessageService::State); |
|
132 public slots: |
|
133 void reportMatchingIds(); |
|
134 void messagesFound_(const QMessageIdList &ids); |
|
135 void completed(); |
|
136 private: |
|
137 bool active; |
|
138 QMessageService::State state; |
|
139 // EventLoggerThread queryThread; |
|
140 QueryThread *queryThread; |
|
141 QMessageStorePrivate* ipMessageStorePrivate; |
|
142 void debugMessage(QMessage &message); |
|
143 RTComEl *el; |
|
144 DBusConnection * dbus; |
|
145 bool iListenForNotifications; |
|
146 QMessageManager::NotificationFilterId _filterId; |
|
147 QMap<QMessageManager::NotificationFilterId, QMessageFilter> _filters; |
|
148 |
|
149 }; |
|
150 |
|
151 QTM_END_NAMESPACE |
|
152 #endif // EVENTLOGGERENGINE_H |