javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp
changeset 78 71ad690e91f5
parent 50 023eef975703
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    62 }
    62 }
    63 
    63 
    64 OS_EXPORT SmsServerConnection::~SmsServerConnection()
    64 OS_EXPORT SmsServerConnection::~SmsServerConnection()
    65 {
    65 {
    66     JELOG2(EWMA);
    66     JELOG2(EWMA);
    67     // As per internal spec the message store should be removed only when
    67 
    68     // Application is uninstalled / UnRegistered from push
       
    69     removeDir(mMessageStoreDirName);
       
    70     delete mMessage;
    68     delete mMessage;
    71     delete mFilterDes;
    69     delete mFilterDes;
    72     delete mOpenMonitor;
    70     delete mOpenMonitor;
    73 }
    71 }
    74 
    72 
   146                 //create a message store
   144                 //create a message store
   147                 const java::runtime::ApplicationInfo& appInf =
   145                 const java::runtime::ApplicationInfo& appInf =
   148                     java::runtime::ApplicationInfo::getInstance();
   146                     java::runtime::ApplicationInfo::getInstance();
   149                 const std::wstring& root = appInf.getRootPath();
   147                 const std::wstring& root = appInf.getRootPath();
   150                 LOG1(EWMA, EInfo,"SMS Store path %S",root.c_str());
   148                 LOG1(EWMA, EInfo,"SMS Store path %S",root.c_str());
   151                 error = createMessageStore(root + SMS_STORE_PATH);
   149                 // At this point mIsAppLaunched will be true if it not
       
   150                 // push connection.
       
   151                 error = createMessageStore(root + SMS_STORE_PATH , mIsAppLaunched);
   152                 mState = EReceivingMessageForNotify;
   152                 mState = EReceivingMessageForNotify;
   153                 if (KErrNone == error)
   153                 if (KErrNone == error)
   154                 {
   154                 {
   155                     error = pthread_create(&mThreadId, NULL,
   155                     error = pthread_create(&mThreadId, NULL,
   156                                            SmsServerConnection::listenThread, this);
   156                                            SmsServerConnection::listenThread, this);
   163             std::string errTxt("ERROR!!! SMS server conn : Open Failed");
   163             std::string errTxt("ERROR!!! SMS server conn : Open Failed");
   164             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   164             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   165                                 __FUNCTION__,__LINE__);
   165                                 __FUNCTION__,__LINE__);
   166         }
   166         }
   167         mOpenMonitor->wait();
   167         mOpenMonitor->wait();
   168         if (mMessagesOnStore > 0)
       
   169         {
       
   170             mListener->msgArrived();
       
   171         }
       
   172         mIsListening = true;
   168         mIsListening = true;
   173     }
   169     }
   174 }
   170 }
   175 
   171 
   176 void* SmsServerConnection::listenThread(void* aParams)
   172 void* SmsServerConnection::listenThread(void* aParams)
   372         ELOG(EWMA,"SMS : Exception while opening/reading file");
   368         ELOG(EWMA,"SMS : Exception while opening/reading file");
   373         delete[] messagePath;
   369         delete[] messagePath;
   374         readStream.close();
   370         readStream.close();
   375         return KErrGeneral;
   371         return KErrGeneral;
   376     }
   372     }
   377     catch (ExceptionBase ex)
   373     catch (ExceptionBase &ex)
   378     {
   374     {
   379         delete[] messagePath;
   375         delete[] messagePath;
   380         return KErrGeneral;
   376         return KErrGeneral;
   381     }
   377     }
   382     return KErrNone;
   378     return KErrNone;
   453             ELOG(EWMA,"SMS : Exception while creating/writing file");
   449             ELOG(EWMA,"SMS : Exception while creating/writing file");
   454             delete[] messagePath;
   450             delete[] messagePath;
   455             writeStream.close();
   451             writeStream.close();
   456             User::Leave(KErrGeneral);
   452             User::Leave(KErrGeneral);
   457         }
   453         }
   458         catch (ExceptionBase ex)
   454         catch (ExceptionBase &ex)
   459         {
   455         {
   460             User::Leave(KErrGeneral);
   456             User::Leave(KErrGeneral);
   461         }
   457         }
   462         // Record we have another SMS
   458         // Record we have another SMS
   463         if (mFirstMessageInStore == -1)
   459         if (mFirstMessageInStore == -1)