19 // SYSTEM INCLUDES |
19 // SYSTEM INCLUDES |
20 #include <msvapi.h> |
20 #include <msvapi.h> |
21 #include <ccsclientconversation.h> |
21 #include <ccsclientconversation.h> |
22 #include <ccsrequesthandler.h> |
22 #include <ccsrequesthandler.h> |
23 #include <ccsconversationentry.h> |
23 #include <ccsconversationentry.h> |
|
24 #include <xqservicerequest.h> |
|
25 #include <QString> |
24 |
26 |
25 //USER INCLUDES |
27 //USER INCLUDES |
26 #include "msgnotifier.h" |
28 #include "msgnotifier.h" |
27 #include "msgnotifier_p.h" |
29 #include "msgnotifier_p.h" |
28 #include "s60qconversions.h" |
30 #include "s60qconversions.h" |
29 |
31 #include "msgstorehandler.h" |
|
32 #include "msginfodefs.h" |
30 #include <QtDebug> |
33 #include <QtDebug> |
31 |
34 |
32 #define QDEBUG_WRITE(str) {qDebug() << str;} |
35 #define QDEBUG_WRITE(str) {qDebug() << str;} |
33 #define QDEBUG_WRITE_FORMAT(str, val) {qDebug() << str << val;} |
36 #define QDEBUG_WRITE_FORMAT(str, val) {qDebug() << str << val;} |
34 #define QCRITICAL_WRITE(str) {qCritical() << str;} |
37 #define QCRITICAL_WRITE(str) {qCritical() << str;} |
35 #define QCRITICAL_WRITE_FORMAT(str, val) {qCritical() << str << val;} |
38 #define QCRITICAL_WRITE_FORMAT(str, val) {qCritical() << str << val;} |
36 |
39 |
37 // ---------------------------------------------------------------------------- |
40 // ---------------------------------------------------------------------------- |
38 // MsgNotifierPrivate::MsgNotifierPrivate |
41 // MsgNotifierPrivate::MsgNotifierPrivate |
39 // @see MsgNotifierPrivate.h |
42 // @see MsgNotifierPrivate.h |
40 // ---------------------------------------------------------------------------- |
43 // ---------------------------------------------------------------------------- |
41 MsgNotifierPrivate::MsgNotifierPrivate(MsgNotifier* MsgNotifier): |
44 MsgNotifierPrivate::MsgNotifierPrivate(MsgNotifier* MsgNotifier) : |
42 q_ptr(MsgNotifier), |
45 q_ptr(MsgNotifier), mCvServer(NULL), iMsgStoreHandler(NULL) |
43 mCvServer(NULL) |
46 { |
44 { |
47 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter") |
45 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter") |
48 |
46 TRAP_IGNORE(initL()); |
49 TRAP_IGNORE(initL()); |
47 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit") |
50 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit") |
48 } |
51 } |
49 |
52 |
50 // ---------------------------------------------------------------------------- |
53 // ---------------------------------------------------------------------------- |
51 // MsgNotifierPrivate::~MsgNotifierPrivate |
54 // MsgNotifierPrivate::~MsgNotifierPrivate |
52 // @see MsgNotifierPrivate.h |
55 // @see MsgNotifierPrivate.h |
53 // ---------------------------------------------------------------------------- |
56 // ---------------------------------------------------------------------------- |
54 MsgNotifierPrivate::~MsgNotifierPrivate() |
57 MsgNotifierPrivate::~MsgNotifierPrivate() |
55 { |
58 { |
56 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Enter") |
59 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Enter") |
57 if(mCvServer) |
60 if (mCvServer) { |
58 { |
61 mCvServer->RemoveConversationListChangeEventL(this); |
59 mCvServer->RemoveConversationListChangeEventL (this); |
62 delete mCvServer; |
60 delete mCvServer; |
63 mCvServer = NULL; |
61 mCvServer = NULL; |
64 } |
62 } |
65 |
63 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Exit") |
66 if (iMsgStoreHandler) { |
|
67 delete iMsgStoreHandler; |
|
68 iMsgStoreHandler = NULL; |
|
69 } |
|
70 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Exit") |
64 } |
71 } |
65 |
72 |
66 // ---------------------------------------------------------------------------- |
73 // ---------------------------------------------------------------------------- |
67 // MsgNotifierPrivate::initL |
74 // MsgNotifierPrivate::initL |
68 // @see MsgNotifierPrivate.h |
75 // @see MsgNotifierPrivate.h |
69 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
70 void MsgNotifierPrivate::initL() |
77 void MsgNotifierPrivate::initL() |
71 { |
78 { |
72 QDEBUG_WRITE("MsgNotifierPrivate::initL : Enter") |
79 QDEBUG_WRITE("MsgNotifierPrivate::initL : Enter") |
73 |
80 |
74 mCvServer = CCSRequestHandler::NewL(); |
81 mCvServer = CCSRequestHandler::NewL(); |
75 mCvServer->RequestConversationListChangeEventL(this); |
82 mCvServer->RequestConversationListChangeEventL(this); |
76 updateIndications(); |
83 iMsgStoreHandler = new MsgStoreHandler(this, mCvServer); |
77 |
84 updateUnreadIndications(true); |
|
85 updateOutboxIndications(); |
|
86 |
78 QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit") |
87 QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit") |
79 } |
88 } |
80 |
89 |
81 // ---------------------------------------------------------------------------- |
90 // ---------------------------------------------------------------------------- |
82 // MsgNotifierPrivate::AddConversationList |
91 // MsgNotifierPrivate::AddConversationList |
83 // @see MsgNotifierPrivate.h |
92 // @see MsgNotifierPrivate.h |
84 // ---------------------------------------------------------------------------- |
93 // ---------------------------------------------------------------------------- |
85 void MsgNotifierPrivate::AddConversationList( |
94 void MsgNotifierPrivate::AddConversationList( |
86 const CCsClientConversation& aClientConversation) |
95 const CCsClientConversation& aClientConversation) |
87 { |
96 { |
88 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Enter") |
97 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Enter") |
89 |
98 |
90 processListEntry(aClientConversation); |
99 processListEntry(aClientConversation); |
91 updateIndications(); |
100 updateUnreadIndications(); |
92 |
101 |
93 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Exit") |
102 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Exit") |
94 } |
103 } |
95 |
104 |
96 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
97 // MsgNotifierPrivate::DeleteConversationList |
106 // MsgNotifierPrivate::DeleteConversationList |
98 // @see MsgNotifierPrivate.h |
107 // @see MsgNotifierPrivate.h |
99 // ---------------------------------------------------------------------------- |
108 // ---------------------------------------------------------------------------- |
100 void MsgNotifierPrivate::DeleteConversationList( |
109 void MsgNotifierPrivate::DeleteConversationList( |
101 const CCsClientConversation& /*aClientConversation*/) |
110 const CCsClientConversation& /*aClientConversation*/) |
102 { |
111 { |
103 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Enter") |
112 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Enter") |
104 updateIndications(); |
113 updateUnreadIndications(); |
105 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Exit") |
114 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Exit") |
106 } |
115 } |
107 |
116 |
108 // ---------------------------------------------------------------------------- |
117 // ---------------------------------------------------------------------------- |
109 // MsgNotifierPrivate::ModifyConversationList |
118 // MsgNotifierPrivate::ModifyConversationList |
110 // @see MsgNotifierPrivate.h |
119 // @see MsgNotifierPrivate.h |
111 // ---------------------------------------------------------------------------- |
120 // ---------------------------------------------------------------------------- |
112 void MsgNotifierPrivate:: ModifyConversationList( |
121 void MsgNotifierPrivate::ModifyConversationList(const CCsClientConversation& aClientConversation) |
113 const CCsClientConversation& aClientConversation) |
122 { |
114 { |
|
115 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Enter") |
123 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Enter") |
116 |
124 |
117 processListEntry(aClientConversation); |
125 processListEntry(aClientConversation); |
118 updateIndications(); |
126 updateUnreadIndications(); |
119 |
127 |
120 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Exit") |
128 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Exit") |
121 } |
129 } |
122 |
130 |
123 // ---------------------------------------------------------------------------- |
131 // ---------------------------------------------------------------------------- |
124 // MsgNotifierPrivate::RefreshConversationList |
132 // MsgNotifierPrivate::RefreshConversationList |
125 // @see MsgNotifierPrivate.h |
133 // @see MsgNotifierPrivate.h |
126 // ---------------------------------------------------------------------------- |
134 // ---------------------------------------------------------------------------- |
127 void MsgNotifierPrivate::RefreshConversationList() |
135 void MsgNotifierPrivate::RefreshConversationList() |
128 { |
136 { |
129 |
137 |
130 } |
138 } |
131 |
139 |
132 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
133 // MsgNotifierPrivate::processListEntry |
141 // MsgNotifierPrivate::processListEntry |
134 // @see MsgNotifierPrivate.h |
142 // @see MsgNotifierPrivate.h |
135 // ---------------------------------------------------------------------------- |
143 // ---------------------------------------------------------------------------- |
145 convEntry->ConversationDir()) |
153 convEntry->ConversationDir()) |
146 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry New Entry Attribute", |
154 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry New Entry Attribute", |
147 convEntry->IsAttributeSet(ECsAttributeNewEntryAdded)) |
155 convEntry->IsAttributeSet(ECsAttributeNewEntryAdded)) |
148 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry Unread Attribute", |
156 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry Unread Attribute", |
149 convEntry->IsAttributeSet(ECsAttributeUnread)) |
157 convEntry->IsAttributeSet(ECsAttributeUnread)) |
150 |
158 |
151 bool newFlag=convEntry->IsAttributeSet(ECsAttributeNewEntryAdded); |
|
152 |
|
153 if((convEntry->ConversationDir() == ECsDirectionIncoming) |
159 if((convEntry->ConversationDir() == ECsDirectionIncoming) |
154 && convEntry->IsAttributeSet(ECsAttributeNewEntryAdded) |
160 && convEntry->IsAttributeSet(ECsAttributeNewEntryAdded) |
155 && convEntry->IsAttributeSet(ECsAttributeUnread)) |
161 && convEntry->IsAttributeSet(ECsAttributeUnread)) |
156 { |
162 { |
157 QDEBUG_WRITE("processListEntry : Processing data for Notification") |
163 QDEBUG_WRITE("processListEntry : Processing data for Notification") |
158 |
164 |
159 NotificationData notifData; |
165 NotificationData notifData; |
160 |
166 notifData.msvEntryId = convEntry->EntryId(); |
161 notifData.mConversationId = aClientConversation.GetConversationEntryId(); |
167 notifData.mConversationId = aClientConversation.GetConversationEntryId(); |
162 notifData.mMsgType = convEntry->GetType(); |
168 notifData.mMsgType = static_cast<int>(convEntry->GetType()); |
163 |
169 |
164 HBufC* firstName = aClientConversation.GetFirstName(); |
170 HBufC* displayName = aClientConversation.GetDisplayName(); |
165 HBufC* lastName = aClientConversation.GetLastName(); |
|
166 HBufC* number = convEntry->Contact(); |
171 HBufC* number = convEntry->Contact(); |
167 HBufC* descrp = convEntry->Description(); |
172 HBufC* descrp = convEntry->Description(); |
168 |
173 |
169 if(firstName) |
174 if(displayName) |
170 { |
175 { |
171 notifData.mFirstName = |
176 notifData.mDisplayName = |
172 S60QConversions::s60DescToQString(*firstName); |
177 S60QConversions::s60DescToQString(*displayName); |
173 } |
178 } |
174 if(lastName) |
|
175 { |
|
176 notifData.mLastName = S60QConversions::s60DescToQString(*lastName); |
|
177 } |
|
178 if(number) |
179 if(number) |
179 { |
180 { |
180 notifData.mContactNum = S60QConversions::s60DescToQString(*number); |
181 notifData.mContactNum = S60QConversions::s60DescToQString(*number); |
181 } |
182 } |
182 if(descrp) |
183 if(descrp) |
191 |
192 |
192 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit") |
193 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit") |
193 } |
194 } |
194 |
195 |
195 // ---------------------------------------------------------------------------- |
196 // ---------------------------------------------------------------------------- |
196 // MsgNotifierPrivate::updateIndications |
197 // MsgNotifierPrivate::updateUnreadIndications |
197 // @see MsgNotifierPrivate.h |
198 // @see MsgNotifierPrivate.h |
198 // ---------------------------------------------------------------------------- |
199 // ---------------------------------------------------------------------------- |
199 void MsgNotifierPrivate::updateIndications() |
200 void MsgNotifierPrivate::updateUnreadIndications(bool bootup) |
200 { |
201 { |
201 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Enter") |
202 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Enter") |
202 |
203 |
203 int unreadCount(0); |
204 int unreadCount(0); |
204 TRAP_IGNORE(unreadCount = mCvServer->GetTotalUnreadCountL()); |
205 if(bootup) |
|
206 { |
|
207 TRAP_IGNORE(unreadCount = iMsgStoreHandler->GetUnreadMessageCountL()); |
|
208 } |
|
209 else |
|
210 { |
|
211 TRAP_IGNORE(unreadCount = mCvServer->GetTotalUnreadCountL()); |
|
212 } |
205 |
213 |
206 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::" |
214 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::" |
207 "updateIndications unreadCount = ",unreadCount ); |
215 "updateIndications unreadCount = ",unreadCount ); |
208 |
216 |
209 //activate or deactivate indications based on unread count |
217 //activate or deactivate indications based on unread count |
210 q_ptr->updateIndications(unreadCount); |
218 q_ptr->updateUnreadIndications(unreadCount); |
211 |
219 |
212 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Exit") |
220 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Exit") |
213 } |
221 } |
|
222 |
|
223 // ---------------------------------------------------------------------------- |
|
224 // MsgNotifierPrivate::updateOutboxIndications |
|
225 // @see MsgNotifierPrivate.h |
|
226 // ---------------------------------------------------------------------------- |
|
227 void MsgNotifierPrivate::updateOutboxIndications() |
|
228 { |
|
229 |
|
230 MsgInfo failedIndicatorData; |
|
231 MsgInfo pendingIndicatorData; |
|
232 TInt err = KErrNone; |
|
233 |
|
234 TRAP(err, iMsgStoreHandler->GetOutboxEntriesL(failedIndicatorData,pendingIndicatorData)); |
|
235 |
|
236 q_ptr->updateOutboxIndications(failedIndicatorData); |
|
237 q_ptr->updateOutboxIndications(pendingIndicatorData); |
|
238 } |
|
239 |
|
240 |
|
241 // ---------------------------------------------------------------------------- |
|
242 // MsgNotifierPrivate::displayOutboxIndications |
|
243 // @see MsgNotifierPrivate.h |
|
244 // ---------------------------------------------------------------------------- |
|
245 |
|
246 void MsgNotifierPrivate::displayOutboxIndications(MsgInfo data) |
|
247 { |
|
248 q_ptr->updateOutboxIndications(data); |
|
249 } |
|
250 |
|
251 // ---------------------------------------------------------------------------- |
|
252 // MsgNotifierPrivate::displayFailedNote |
|
253 // @see MsgNotifierPrivate.h |
|
254 // ---------------------------------------------------------------------------- |
|
255 void MsgNotifierPrivate::displayFailedNote(MsgInfo info) |
|
256 { |
|
257 // TODO: use XQAiwRequest |
|
258 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : entered") |
|
259 // change to com.nokia.symbian.messaging (servicename), IMsgErrorNotifier |
|
260 // as the service name. |
|
261 XQServiceRequest snd("messaging.com.nokia.symbian.MsgErrorNotifier", |
|
262 "displayErrorNote(QVariantList)", false); |
|
263 |
|
264 QVariantList args; |
|
265 info.mDisplayName.removeDuplicates(); |
|
266 info.mDisplayName.sort(); |
|
267 |
|
268 QString nameString; |
|
269 |
|
270 nameString.append(info.mDisplayName.at(0)); |
|
271 for(int i = 1; i < info.mDisplayName.count(); ++i){ |
|
272 nameString.append(", "); |
|
273 nameString.append(info.mDisplayName.at(i)); |
|
274 } |
|
275 |
|
276 //Even if name string is empty we shall add name into args |
|
277 QVariant nameV(nameString); |
|
278 args << nameV; |
|
279 |
|
280 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : name and contactnumber") |
|
281 |
|
282 args << info.mConversationId; |
|
283 args << info.mMessageType; |
|
284 snd << args; |
|
285 snd.send(); |
|
286 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : left") |
|
287 |
|
288 } |
|
289 |
214 //EOF |
290 //EOF |