javaextensions/wma/sms_cbs/pushplugin/src/serverconnectionbase.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 24 0fd27995241b
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".
    80 {
    80 {
    81     JELOG2(EWMA);
    81     JELOG2(EWMA);
    82     return mMessagesOnStore;
    82     return mMessagesOnStore;
    83 }
    83 }
    84 
    84 
    85 int ServerConnectionBase::createMessageStore(std::wstring aDirectoryPath)
    85 int ServerConnectionBase::createMessageStore(std::wstring aDirectoryPath, bool aDeleteStore)
    86 {
    86 {
    87     JELOG2(EWMA);
    87     JELOG2(EWMA);
    88     aDirectoryPath += JavaCommonUtils::intToWstring(mPort);
    88     aDirectoryPath += JavaCommonUtils::intToWstring(mPort);
    89     aDirectoryPath +=L"\\" ;
    89     // If not push connection delete the message store.
    90     mMessageStoreDirName = aDirectoryPath;
    90     if (aDeleteStore)
       
    91        removeDir(aDirectoryPath);
       
    92     mMessageStoreDirName = aDirectoryPath + L"\\";
    91     LOG1(EWMA, EInfo , " Creating message store in path %S",
    93     LOG1(EWMA, EInfo , " Creating message store in path %S",
    92          mMessageStoreDirName.c_str());
    94          mMessageStoreDirName.c_str());
    93     // See if directory is present
    95     // See if directory is present
    94     if (FileUtilities::isDirectory(mMessageStoreDirName))
    96     if (FileUtilities::isDirectory(aDirectoryPath))
    95     {
    97     {
    96         std::list<std::wstring> dirList = FileUtilities::getDirContentsList
    98         std::list<std::wstring> dirList = FileUtilities::getDirContentsList
    97                                           (mMessageStoreDirName);
    99                                           (aDirectoryPath);
    98         mMessagesOnStore = dirList.size();
   100         mMessagesOnStore = dirList.size();
    99         if (mMessagesOnStore> 0)
   101         if (mMessagesOnStore> 0)
   100         {
   102         {
   101             // Get the id of the first message in the store
   103             // Get the id of the first message in the store
   102             dirList.sort();
   104             dirList.sort();
   196         std::list<std::wstring>::iterator it;
   198         std::list<std::wstring>::iterator it;
   197         if (dirList.size())
   199         if (dirList.size())
   198         {
   200         {
   199             for (it = dirList.begin(); it != dirList.end(); it++)
   201             for (it = dirList.begin(); it != dirList.end(); it++)
   200             {
   202             {
   201                 std::wstring element(aDirPath);
   203                 std::wstring element(aDirPath + L"\\");
   202                 element += *it;
   204                 element += *it;
   203                 char *fileName = JavaCommonUtils::wstringToUtf8(element);
   205                 char *fileName = JavaCommonUtils::wstringToUtf8(element);
   204                 if ((error = remove(fileName)) != 0)
   206                 if ((error = remove(fileName)) != 0)
   205                 {
   207                 {
   206                     ELOG1(EWMA, "WMA : Removing File  Failed : %s", fileName);
   208                     ELOG1(EWMA, "WMA : Removing File  Failed : %s", fileName);