javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp
branchRCL_3
changeset 24 0fd27995241b
parent 19 04becd199f91
child 35 85266cc22c7f
child 60 6c158198356e
--- a/javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp	Fri Apr 30 10:40:48 2010 +0300
+++ b/javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp	Tue May 11 16:07:20 2010 +0300
@@ -65,7 +65,7 @@
 {
     JELOG2(EWMA);
     // As per internal spec the message store should be removed only when
-    // Application is unintalled / UnRegistered from push
+    // Application is uninstalled / UnRegistered from push
     removeDir(mMessageStoreDirName);
     delete mMessage;
     delete mFilterDes;
@@ -109,7 +109,9 @@
             if (0 == mMessage)
             {
                 CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
+                CleanupStack::PushL(smsBuffer);
                 mMessage = CSmsMessage::NewL(mFs, CSmsPDU::ESmsDeliver, smsBuffer);
+                CleanupStack::Pop(smsBuffer);
             }
             error = pthread_mutex_init(&mMutex, 0);
             if (error == 0)
@@ -152,7 +154,6 @@
                 {
                     error = pthread_create(&mThreadId, NULL,
                                            SmsServerConnection::listenThread, this);
-                    mOpenMonitor->wait();
                 }
             }
         }
@@ -163,6 +164,7 @@
             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
                                 __FUNCTION__,__LINE__);
         }
+        mOpenMonitor->wait();
         if (mMessagesOnStore > 0)
         {
             mListener->msgArrived();
@@ -328,6 +330,7 @@
     mSocket.CancelIoctl();
     mSocket.Close();
     mSocketServer.Close();
+    mSocketServerOpened = EFalse;
 }
 
 TInt SmsServerConnection::RunError(TInt aError)
@@ -347,12 +350,13 @@
     JELOG2(EWMA);
     std::wstring path;
     path += mMessageStoreDirName;
+    char* messagePath =0;
     // Read the SMS file contents
     readStream.exceptions(std::ifstream::failbit|std::ifstream::badbit);
     try
     {
         path += JavaCommonUtils::intToWstring(mFirstMessageInStore);
-        char* messagePath = JavaCommonUtils::wstringToUtf8(path);
+        messagePath = JavaCommonUtils::wstringToUtf8(path);
         readStream.open(messagePath, std::ios::in | std::ios::binary);
         readStream.read((char*) aSmsBuf.Ptr(), mSmsParameters.Size());
         readStream.read((char*)(aSmsBuf().mData).Ptr(), aSmsBuf().mDataSize * 2);
@@ -364,11 +368,13 @@
     catch (std::ifstream::failure e)
     {
         ELOG(EWMA,"SMS : Exception while opening/reading file");
+        delete[] messagePath;
         readStream.close();
         return KErrGeneral;
     }
     catch (ExceptionBase ex)
     {
+        delete[] messagePath;
         return KErrGeneral;
     }
     return KErrNone;
@@ -443,6 +449,7 @@
         catch (std::ofstream::failure e)
         {
             ELOG(EWMA,"SMS : Exception while creating/writing file");
+            delete[] messagePath;
             writeStream.close();
             User::Leave(KErrGeneral);
         }