messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
--- a/messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp	Tue Jul 06 14:12:40 2010 +0300
+++ b/messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp	Wed Aug 18 09:45:25 2010 +0300
@@ -26,9 +26,12 @@
 #include <w32std.h>
 #include <apgtask.h> 
 #include <XQSettingsManager>
+#include <xqaiwrequest.h>
+#include <xqappmgr.h>
 #include <xqpublishandsubscribeutils.h>
 #include <xqsystemtoneservice.h>
 #include <xqconversions.h>
+#include <QThreadPool>
 
 //USER INCLUDES
 #include "msgnotifier.h"
@@ -48,7 +51,7 @@
 {
     QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter")
 
-    TRAP_IGNORE(initL());
+    initL();
     QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit")
 }
 
@@ -60,7 +63,7 @@
 {
     QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Enter")
     if (mCvServer) {
-        mCvServer->RemoveConversationListChangeEventL(this);
+        TRAP_IGNORE(mCvServer->RemoveConversationListChangeEventL(this));
         delete mCvServer;
         mCvServer = NULL;
     }
@@ -103,10 +106,11 @@
     updateUnreadIndications(true); 
     updateOutboxIndications();
 
-    mSettingsManager = new XQSettingsManager();
+    QT_TRYCATCH_LEAVING(mSettingsManager = new XQSettingsManager());
     
     // define property
-    mPSUtils = new XQPublishAndSubscribeUtils(*mSettingsManager);
+    QT_TRYCATCH_LEAVING(mPSUtils = new XQPublishAndSubscribeUtils(*mSettingsManager));
+    
     XQPublishAndSubscribeSettingsKey convIdKey(
             KMsgCVIdProperty, KMsgCVIdKey);
     bool success = mPSUtils->defineProperty(convIdKey, 
@@ -121,7 +125,7 @@
     QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::initL "
                            "writing ret value",success)
     
-    mSts = new XQSystemToneService();
+    QT_TRYCATCH_LEAVING(mSts = new XQSystemToneService());
     
     QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit")
 }
@@ -133,12 +137,12 @@
 void MsgNotifierPrivate::AddConversationList(
                   const CCsClientConversation& aClientConversation)
 {
-    QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Enter")
+    QCRITICAL_WRITE("MsgNotifierPrivate::AddConversationList : Enter")
 
     processListEntry(aClientConversation);
     updateUnreadIndications();
 
-    QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Exit")
+    QCRITICAL_WRITE("MsgNotifierPrivate::AddConversationList : Exit")
 }
 
 // ----------------------------------------------------------------------------
@@ -159,12 +163,12 @@
 // ----------------------------------------------------------------------------
 void MsgNotifierPrivate::ModifyConversationList(const CCsClientConversation& aClientConversation)
 {
-    QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Enter")
+    QCRITICAL_WRITE("MsgNotifierPrivate::ModifyConversationList : Enter")
 
     processListEntry(aClientConversation);
     updateUnreadIndications();
 
-    QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Exit")
+    QCRITICAL_WRITE("MsgNotifierPrivate::ModifyConversationList : Exit")
 }
 
 // ----------------------------------------------------------------------------
@@ -183,7 +187,7 @@
 void MsgNotifierPrivate::processListEntry(
         const CCsClientConversation& aClientConversation)
     {
-    QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Enter")
+    QCRITICAL_WRITE("MsgNotifierPrivate::processListEntry : Enter")
     
     CCsConversationEntry* convEntry = 
                                  aClientConversation.GetConversationEntry();
@@ -237,7 +241,7 @@
        
         }
     
-    QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit")
+    QCRITICAL_WRITE("MsgNotifierPrivate::processListEntry : Exit")
     }
 
 // ----------------------------------------------------------------------------
@@ -384,6 +388,82 @@
 // @see mcsconversationclientchangeobserver.h
 // ----------------------------------------------------------------------------
 void MsgNotifierPrivate::PartialDeleteConversationList(
-        const CCsClientConversation& aClientConversation){/*empty implementation*/}
+        const CCsClientConversation& /*aClientConversation*/){/*empty implementation*/}
+
+
+// ----------------------------------------------------------------------------
+// MsgNotifierPrivate::ShowClass0Message
+// @see msgnotifier_p.h
+// ----------------------------------------------------------------------------
+
+void MsgNotifierPrivate::ShowClass0Message(Class0Info& class0Info)
+{
+    QCRITICAL_WRITE("flashmsgnotifier BEGIN");
+    QThreadPool::globalInstance()->start(new Class0SmsServiceTask(class0Info));
+    QCRITICAL_WRITE("flashmsgnotifier END");
+}
+
+
+
+
+// ----------------------------------------------------------------------------
+// Class0SmsServiceTask::Class0SmsServiceTask
+// @see msgnotifier_p.h
+// ----------------------------------------------------------------------------  
+Class0SmsServiceTask::Class0SmsServiceTask(Class0Info& class0Info):
+mClass0info(class0Info)
+     {     
+     }
+
+// ----------------------------------------------------------------------------
+// Class0SmsServiceTask::~Class0SmsServiceTask
+// @see msgnotifier_p.h
+// ----------------------------------------------------------------------------   
+Class0SmsServiceTask::~Class0SmsServiceTask()
+     {     
+     }
+     
+// ----------------------------------------------------------------------------
+// Class0SmsServiceTask::run
+// @see msgnotifier_p.h
+// ----------------------------------------------------------------------------   
+void Class0SmsServiceTask::run()
+     {
+   	  QList<QVariant> args;
+      QString serviceName("flashmsgnotifier");
+      QString interfaceName("com.nokia.symbian.IFlashMsgNotifier");
+      QString operation("displayFlashMsg(QByteArray)");
+      XQAiwRequest* request;
+      XQApplicationManager appManager;
+
+      request = appManager.create(interfaceName, operation, false); //non-embedded
+
+      if ( request == NULL )
+      {
+          QCRITICAL_WRITE("flashmsgnotifier request == NULL");
+          return; 
+      }
+
+      QByteArray ba; 
+      QDataStream stream(&ba, QIODevice::ReadWrite);
+      stream << mClass0info.body;
+      stream << mClass0info.address;
+      stream << mClass0info.alias;
+      stream << mClass0info.time;     
+      stream << mClass0info.messageId;
+       
+      args << ba;
+      request->setArguments(args);    
+       
+      if(!request->send())
+      {
+         QString lastErr;
+          lastErr = request->lastErrorMessage();
+          QDEBUG_WRITE_FORMAT("flashmsgnotifier launch failed", lastErr);
+      }
+       
+      QCRITICAL_WRITE("flashmsgnotifier END");
+      delete request;  
+     }
 
 //EOF