javaextensions/wma/sms_cbs/pushplugin/cbs/src.s60/cbsserverconnection.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 60 6c158198356e
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     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".
    56     JELOG2(EWMA);
    56     JELOG2(EWMA);
    57     CbsServerConnection* cbsConn = new CbsServerConnection(aUri, aFilter);
    57     CbsServerConnection* cbsConn = new CbsServerConnection(aUri, aFilter);
    58     return cbsConn;
    58     return cbsConn;
    59 }
    59 }
    60 
    60 
    61 OS_EXPORT CbsServerConnection::~CbsServerConnection()
    61 CbsServerConnection::~CbsServerConnection()
    62 {
    62 {
    63     JELOG2(EWMA);
    63     JELOG2(EWMA);
    64     removeDir(mMessageStoreDirName);
       
    65 }
    64 }
    66 
    65 
    67 void CbsServerConnection::initializeL()
    66 void CbsServerConnection::initializeL()
    68 {
    67 {
    69     JELOG2(EWMA);
    68     JELOG2(EWMA);
   126     {
   125     {
   127         User::Leave(result);
   126         User::Leave(result);
   128     }
   127     }
   129 }
   128 }
   130 
   129 
   131 OS_EXPORT void CbsServerConnection::open(ConnectionListener* aListener,
   130 void CbsServerConnection::open(ConnectionListener* aListener,
   132                                bool aIsAppLaunched)
   131                                bool aIsAppLaunched)
   133 {
   132 {
   134     JELOG2(EWMA);
   133     JELOG2(EWMA);
   135     mIsAppLaunched = aIsAppLaunched;
   134     mIsAppLaunched = aIsAppLaunched;
   136     CbsServerConnection::open(aListener);
   135     CbsServerConnection::open(aListener);
   190         }
   189         }
   191         // Create Message Store
   190         // Create Message Store
   192         const java::runtime::ApplicationInfo& appInf =
   191         const java::runtime::ApplicationInfo& appInf =
   193             java::runtime::ApplicationInfo::getInstance();
   192             java::runtime::ApplicationInfo::getInstance();
   194         const std::wstring& root = appInf.getRootPath();
   193         const std::wstring& root = appInf.getRootPath();
   195         error = createMessageStore(root + CBS_STORE_PATH);
   194         // At this point mIsAppLaunched will be true if it not push connection.
       
   195         error = createMessageStore(root + CBS_STORE_PATH, mIsAppLaunched);
   196         if (error != KErrNone)
   196         if (error != KErrNone)
   197         {
   197         {
   198             ELOG1(EWMA,"CBS : create message store failed : %d",error);
   198             ELOG1(EWMA,"CBS : create message store failed : %d",error);
   199             std::string errTxt("ERROR!!! CBS : create message store failed");
   199             std::string errTxt("ERROR!!! CBS : create message store failed");
   200             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   200             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   212             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   212             throw PushException(COMMON_SRV_CONN_PLUGIN_ERROR,errTxt,__FILE__,
   213                                 __FUNCTION__,__LINE__);
   213                                 __FUNCTION__,__LINE__);
   214         }
   214         }
   215 
   215 
   216         mOpenMonitor->wait();
   216         mOpenMonitor->wait();
   217         // If there are any messages already available in the message store
       
   218         // notify the listener
       
   219         if (mMessagesOnStore > 0)
       
   220         {
       
   221             mListener->msgArrived();
       
   222         }
       
   223         mIsListening = true;
   217         mIsListening = true;
   224     }
   218     }
   225 }
   219 }
   226 
   220 
   227 
   221 
   280         break;
   274         break;
   281     }
   275     }
   282     }
   276     }
   283 }
   277 }
   284 
   278 
   285 OS_EXPORT int CbsServerConnection::retrieveMessage(TJavaMessageParametersBuf& aCbsBuf)
   279 int CbsServerConnection::retrieveMessage(TJavaMessageParametersBuf& aCbsBuf)
   286 {
   280 {
   287     JELOG2(EWMA);
   281     JELOG2(EWMA);
   288     TCBSParametersBuf cbsParametersBuf;
   282     TCBSParametersBuf cbsParametersBuf;
   289     std::wstring path;
   283     std::wstring path;
   290     char* messagePath =0;
   284     char* messagePath =0;
   326     }
   320     }
   327     return KErrNone;
   321     return KErrNone;
   328 }
   322 }
   329 
   323 
   330 
   324 
   331 OS_EXPORT void CbsServerConnection::close()
   325 void CbsServerConnection::close()
   332 {
   326 {
   333     JELOG2(EWMA);
   327     JELOG2(EWMA);
   334     // the close and RunL are synchronized to make it SMP safe.
   328     // the close and RunL are synchronized to make it SMP safe.
   335     if (mInitialized)
   329     if (mInitialized)
   336     {
   330     {
   522             mCbsMultipageMessageId = mCbsMessageId;
   516             mCbsMultipageMessageId = mCbsMessageId;
   523             mCbsPartiallyReceived = ETrue;
   517             mCbsPartiallyReceived = ETrue;
   524         }
   518         }
   525         // Store the received page number, such that the message can
   519         // Store the received page number, such that the message can
   526         // be reconstructed in the correct order later
   520         // be reconstructed in the correct order later
   527         mCbsMessagePagesRef.AppendL(currentPage);
   521         mCbsMessagePagesRef.Append(currentPage);
   528 
   522 
   529         // Store the actual content of the message
   523         // Store the actual content of the message
   530         mCbsMessagePagesData->AppendL(messageData);
   524         mCbsMessagePagesData->AppendL(messageData);
   531 
   525 
   532         // Record which page has been received as a bitmask
   526         // Record which page has been received as a bitmask