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> |
24 #include <xqservicerequest.h> |
25 #include <QString> |
25 #include <QString> |
|
26 #include <w32std.h> |
|
27 #include <apgtask.h> |
|
28 #include <XQSettingsManager> |
|
29 #include <xqpublishandsubscribeutils.h> |
|
30 #include <xqsystemtoneservice.h> |
|
31 #include <xqconversions.h> |
26 |
32 |
27 //USER INCLUDES |
33 //USER INCLUDES |
28 #include "msgnotifier.h" |
34 #include "msgnotifier.h" |
29 #include "msgnotifier_p.h" |
35 #include "msgnotifier_p.h" |
30 #include "s60qconversions.h" |
|
31 #include "msgstorehandler.h" |
36 #include "msgstorehandler.h" |
32 #include "msginfodefs.h" |
37 #include "msginfodefs.h" |
33 #include <QtDebug> |
38 #include "conversationidpsconsts.h" |
34 |
39 #include "debugtraces.h" |
35 #define QDEBUG_WRITE(str) {qDebug() << str;} |
|
36 #define QDEBUG_WRITE_FORMAT(str, val) {qDebug() << str << val;} |
|
37 #define QCRITICAL_WRITE(str) {qCritical() << str;} |
|
38 #define QCRITICAL_WRITE_FORMAT(str, val) {qCritical() << str << val;} |
|
39 |
40 |
40 // ---------------------------------------------------------------------------- |
41 // ---------------------------------------------------------------------------- |
41 // MsgNotifierPrivate::MsgNotifierPrivate |
42 // MsgNotifierPrivate::MsgNotifierPrivate |
42 // @see MsgNotifierPrivate.h |
43 // @see MsgNotifierPrivate.h |
43 // ---------------------------------------------------------------------------- |
44 // ---------------------------------------------------------------------------- |
44 MsgNotifierPrivate::MsgNotifierPrivate(MsgNotifier* MsgNotifier) : |
45 MsgNotifierPrivate::MsgNotifierPrivate(MsgNotifier* MsgNotifier) : |
45 q_ptr(MsgNotifier), mCvServer(NULL), iMsgStoreHandler(NULL) |
46 q_ptr(MsgNotifier), mCvServer(NULL), iMsgStoreHandler(NULL), |
|
47 mSettingsManager(NULL),mPSUtils(NULL) |
46 { |
48 { |
47 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter") |
49 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter") |
48 |
50 |
49 TRAP_IGNORE(initL()); |
51 TRAP_IGNORE(initL()); |
50 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit") |
52 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit") |
82 mCvServer->RequestConversationListChangeEventL(this); |
101 mCvServer->RequestConversationListChangeEventL(this); |
83 iMsgStoreHandler = new MsgStoreHandler(this, mCvServer); |
102 iMsgStoreHandler = new MsgStoreHandler(this, mCvServer); |
84 updateUnreadIndications(true); |
103 updateUnreadIndications(true); |
85 updateOutboxIndications(); |
104 updateOutboxIndications(); |
86 |
105 |
|
106 mSettingsManager = new XQSettingsManager(); |
|
107 |
|
108 // define property |
|
109 mPSUtils = new XQPublishAndSubscribeUtils(*mSettingsManager); |
|
110 XQPublishAndSubscribeSettingsKey convIdKey( |
|
111 KMsgCVIdProperty, KMsgCVIdKey); |
|
112 bool success = mPSUtils->defineProperty(convIdKey, |
|
113 XQSettingsManager::TypeInt); |
|
114 |
|
115 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::initL " |
|
116 "property creation ret value",success) |
|
117 |
|
118 // write -1 initially |
|
119 success = mSettingsManager->writeItemValue(convIdKey,-1); |
|
120 |
|
121 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::initL " |
|
122 "writing ret value",success) |
|
123 |
|
124 mSts = new XQSystemToneService(); |
|
125 |
87 QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit") |
126 QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit") |
88 } |
127 } |
89 |
128 |
90 // ---------------------------------------------------------------------------- |
129 // ---------------------------------------------------------------------------- |
91 // MsgNotifierPrivate::AddConversationList |
130 // MsgNotifierPrivate::AddConversationList |
172 HBufC* descrp = convEntry->Description(); |
211 HBufC* descrp = convEntry->Description(); |
173 |
212 |
174 if(displayName) |
213 if(displayName) |
175 { |
214 { |
176 notifData.mDisplayName = |
215 notifData.mDisplayName = |
177 S60QConversions::s60DescToQString(*displayName); |
216 XQConversions::s60DescToQString(*displayName); |
178 } |
217 } |
179 if(number) |
218 if(number) |
180 { |
219 { |
181 notifData.mContactNum = S60QConversions::s60DescToQString(*number); |
220 notifData.mContactNum = XQConversions::s60DescToQString(*number); |
182 } |
221 } |
183 if(descrp) |
222 if(descrp) |
184 { |
223 { |
185 notifData.mDescription = S60QConversions::s60DescToQString(*descrp); |
224 notifData.mDescription = XQConversions::s60DescToQString(*descrp); |
186 } |
225 } |
187 |
226 |
188 q_ptr->displayNewMessageNotification(notifData); |
227 //Play new message alert tone. |
189 |
228 mSts->playTone(XQSystemToneService::SmsAlertTone); |
190 QDEBUG_WRITE("processListEntry : Notification display called") |
229 |
|
230 // check whether opened cv id and received |
|
231 // cv id are same and show notification |
|
232 if( showNotification(notifData.mConversationId )) |
|
233 { |
|
234 q_ptr->displayNewMessageNotification(notifData); |
|
235 QDEBUG_WRITE("processListEntry : Notification display called") |
|
236 } |
|
237 |
191 } |
238 } |
192 |
239 |
193 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit") |
240 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit") |
194 } |
241 } |
195 |
242 |
251 // ---------------------------------------------------------------------------- |
298 // ---------------------------------------------------------------------------- |
252 // MsgNotifierPrivate::displayFailedNote |
299 // MsgNotifierPrivate::displayFailedNote |
253 // @see MsgNotifierPrivate.h |
300 // @see MsgNotifierPrivate.h |
254 // ---------------------------------------------------------------------------- |
301 // ---------------------------------------------------------------------------- |
255 void MsgNotifierPrivate::displayFailedNote(MsgInfo info) |
302 void MsgNotifierPrivate::displayFailedNote(MsgInfo info) |
256 { |
303 { |
257 // TODO: use XQAiwRequest |
304 QDEBUG_WRITE("MsgNotifierPrivate::displayFailedNote start.") |
258 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : entered") |
305 |
259 // change to com.nokia.symbian.messaging (servicename), IMsgErrorNotifier |
306 // check whether opened cv id and received |
260 // as the service name. |
307 // cv id are same then dont show failed note |
261 XQServiceRequest snd("messaging.com.nokia.symbian.MsgErrorNotifier", |
308 if (!showNotification(info.mConversationId)) |
262 "displayErrorNote(QVariantList)", false); |
309 { |
263 |
310 return; |
264 QVariantList args; |
311 } |
|
312 |
|
313 //Even if name string is empty we shall add name into args |
|
314 QString nameString; |
|
315 |
265 info.mDisplayName.removeDuplicates(); |
316 info.mDisplayName.removeDuplicates(); |
266 info.mDisplayName.sort(); |
317 info.mDisplayName.sort(); |
267 |
318 |
268 QString nameString; |
|
269 |
|
270 nameString.append(info.mDisplayName.at(0)); |
319 nameString.append(info.mDisplayName.at(0)); |
271 for(int i = 1; i < info.mDisplayName.count(); ++i){ |
320 for (int i = 1; i < info.mDisplayName.count(); ++i) |
|
321 { |
272 nameString.append(", "); |
322 nameString.append(", "); |
273 nameString.append(info.mDisplayName.at(i)); |
323 nameString.append(info.mDisplayName.at(i)); |
274 } |
324 } |
275 |
325 |
276 //Even if name string is empty we shall add name into args |
326 // create request arguments |
277 QVariant nameV(nameString); |
327 QVariantList args; |
278 args << nameV; |
328 args << QVariant(nameString); |
279 |
|
280 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : name and contactnumber") |
|
281 |
|
282 args << info.mConversationId; |
329 args << info.mConversationId; |
283 args << info.mMessageType; |
330 args << info.mMessageType; |
|
331 |
|
332 // TODO: use XQAiwRequest |
|
333 XQServiceRequest snd("messaging.com.nokia.symbian.MsgErrorNotifier", |
|
334 "displayErrorNote(QVariantList)", false); |
|
335 |
284 snd << args; |
336 snd << args; |
285 snd.send(); |
337 snd.send(); |
286 QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : left") |
338 |
287 |
339 QDEBUG_WRITE("MsgNotifierPrivate::displayFailedNote end.") |
288 } |
340 } |
|
341 |
|
342 // ---------------------------------------------------------------------------- |
|
343 // MsgNotifierPrivate::showNotification |
|
344 // @see MsgNotifierPrivate.h |
|
345 // ---------------------------------------------------------------------------- |
|
346 bool MsgNotifierPrivate::showNotification(int receivedMsgConvId) |
|
347 { |
|
348 bool showNotification = true; |
|
349 |
|
350 RWsSession wsSession ; |
|
351 wsSession.Connect(); |
|
352 |
|
353 TApaTaskList taskList( wsSession ); |
|
354 TApaTask task = taskList.FindApp(KMsgAppUid); // find msgapp is running |
|
355 |
|
356 if(task.Exists()) |
|
357 { |
|
358 TApaTask foregndtask = taskList.FindByPos(0) ; // foreground app |
|
359 // compare window group id |
|
360 // if application is in foregorund, then check the currently |
|
361 // opened conversation is same as received one. |
|
362 if(task.WgId() == foregndtask.WgId() ) |
|
363 { |
|
364 // get the current conversation ID |
|
365 XQPublishAndSubscribeSettingsKey convIdKey( KMsgCVIdProperty, |
|
366 KMsgCVIdKey); |
|
367 QVariant value = mSettingsManager->readItemValue(convIdKey, |
|
368 XQSettingsManager::TypeInt); |
|
369 |
|
370 int openedConvId = value.toInt(); |
|
371 if( openedConvId == receivedMsgConvId) |
|
372 { |
|
373 showNotification = false; |
|
374 QDEBUG_WRITE("processListEntry : Notification not shown") |
|
375 } |
|
376 } |
|
377 } |
|
378 |
|
379 wsSession.Close(); |
|
380 return showNotification; |
|
381 } |
|
382 // ---------------------------------------------------------------------------- |
|
383 // MsgNotifierPrivate::PartialDeleteConversationList |
|
384 // @see mcsconversationclientchangeobserver.h |
|
385 // ---------------------------------------------------------------------------- |
|
386 void MsgNotifierPrivate::PartialDeleteConversationList( |
|
387 const CCsClientConversation& aClientConversation){/*empty implementation*/} |
289 |
388 |
290 //EOF |
389 //EOF |