javamanager/javabackup/midp2backup_usif/src.s60/javastoragebackuputil.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of CStorageBackupUtil
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "javastoragebackuputil.h"
       
    20 #include "midp2backupplugin.h"
       
    21 #include "midp2backupdataids.h"
       
    22 
       
    23 #include "javastorageentry.h"
       
    24 #include "javastorage.h"
       
    25 #include "javastoragenames.h"
       
    26 
       
    27 #include "logger.h"
       
    28 #include "javauid.h"
       
    29 #include "javaoslayer.h"
       
    30 #include "javacommonutils.h"
       
    31 #include "s60commonutils.h"
       
    32 #include "javasymbianoslayer.h"
       
    33 
       
    34 #include <memory>
       
    35 #include <s32mem.h>
       
    36 
       
    37 using namespace std;
       
    38 using namespace java::storage;
       
    39 using namespace java::backup;
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 CStorageBackupUtil::CStorageBackupUtil()
       
    44 {
       
    45     LOG(EBackup, EInfo, "CStorageBackupUtil constructor");
       
    46 }
       
    47 
       
    48 void CStorageBackupUtil::ConstructL()
       
    49 {
       
    50     LOG(EBackup, EInfo, "CStorageBackupUtil::ConstructL");
       
    51 
       
    52     iFirstCalltoBackupStorageData = ETrue;
       
    53     iFirstCalltoRestoreStorageData = ETrue;
       
    54 
       
    55     iBufferSpaceLeft = 0;
       
    56 
       
    57     iRemainingString = EFalse;
       
    58     iStrCount = 0;
       
    59 
       
    60     for (int tableNumber = 0; tableNumber < NUMBER_OF_TABLES; tableNumber++)
       
    61     {
       
    62         iTableSize[tableNumber] = 0;
       
    63     }
       
    64 }
       
    65 
       
    66 CStorageBackupUtil* CStorageBackupUtil::NewL()
       
    67 {
       
    68     LOG(EBackup, EInfo, "CStorageBackupUtil::NewL");
       
    69 
       
    70     CStorageBackupUtil* self = new(ELeave) CStorageBackupUtil();
       
    71     CleanupStack::PushL(self);
       
    72     self->ConstructL();
       
    73     CleanupStack::Pop();
       
    74 
       
    75     return self;
       
    76 }
       
    77 
       
    78 CStorageBackupUtil::~CStorageBackupUtil()
       
    79 {
       
    80     LOG(EBackup, EInfo, "CStorageBackupUtil Destructor");
       
    81 
       
    82     // clear the vectors to free all the heap data.
       
    83     iStringVector.clear();
       
    84 }
       
    85 
       
    86 
       
    87 void CStorageBackupUtil::BackupStorageDataL(RDesWriteStream& aStream, TBool& aBackupNotFinished, TInt& aBufferSpaceLeft)
       
    88 {
       
    89     LOG(EBackup, EInfo, "CStorageBackupUtil::BackupStorageDataL");
       
    90 
       
    91     iBufferSpaceLeft = aBufferSpaceLeft;
       
    92 
       
    93     if (iFirstCalltoBackupStorageData)
       
    94     {
       
    95         int err = FillVectorWithStorageData();
       
    96 
       
    97         if (err != KErrNone)
       
    98         {
       
    99             User::Leave(err);
       
   100         }
       
   101         LOG1(EBackup, EInfo, "Total no of rows in vector: %d", iStringVector.size());
       
   102 
       
   103         // First write the total no of rows in the vector to the stream
       
   104 
       
   105         aStream.WriteInt32L(iStringVector.size());
       
   106         iBufferSpaceLeft -= sizeof(TInt32);
       
   107 
       
   108         /* Then write the number of rows in each table to the stream.
       
   109            This will be used while writing the data to storage. */
       
   110 
       
   111         for (int tableNumber = 0; tableNumber < NUMBER_OF_TABLES; tableNumber++)
       
   112         {
       
   113             aStream.WriteInt16L(iTableSize[tableNumber]);
       
   114             iBufferSpaceLeft -= sizeof(TInt16);
       
   115         }
       
   116 
       
   117         iFirstCalltoBackupStorageData = EFalse;
       
   118     }
       
   119 
       
   120     // Now write the actual string data into the stream.
       
   121 
       
   122     while (iBufferSpaceLeft > 0 && iStrCount < iStringVector.size())
       
   123     {
       
   124         WriteStringtoStreamL(aStream, iStringVector[iStrCount]);
       
   125         LOG1(EBackup, EInfo, "StrCount = %d", iStrCount);
       
   126     }
       
   127 
       
   128     if (iStrCount >= iStringVector.size())
       
   129     {
       
   130         LOG(EBackup, EInfo, "Backup of storage data finished");
       
   131         aBackupNotFinished = EFalse;
       
   132     }
       
   133 }
       
   134 
       
   135 void CStorageBackupUtil::RestoreStorageDataL(RDesReadStream& aStream, TInt& aRestoreState, TInt& aBufferSpaceLeft)
       
   136 {
       
   137     LOG(EBackup, EInfo, "CStorageBackupUtil::RestoreStorageDataL()");
       
   138 
       
   139     iBufferSpaceLeft = aBufferSpaceLeft;
       
   140 
       
   141     if (iFirstCalltoRestoreStorageData)
       
   142     {
       
   143         // the no of strings in the stream
       
   144         iStrCount = aStream.ReadInt32L();
       
   145         iBufferSpaceLeft -= sizeof(TInt32);
       
   146 
       
   147         // read the number of rows in each table
       
   148         for (int tableNumber = 0; tableNumber < NUMBER_OF_TABLES; tableNumber++)
       
   149         {
       
   150             iTableSize[tableNumber] = aStream.ReadInt16L();
       
   151             iBufferSpaceLeft -= sizeof(TInt16);
       
   152         }
       
   153         iFirstCalltoRestoreStorageData = EFalse;
       
   154     }
       
   155 
       
   156     while (iBufferSpaceLeft > 0 && iStrCount > 0)
       
   157     {
       
   158         ReadStringfromStreamL(aStream);
       
   159     }
       
   160 
       
   161     if (iStrCount == 0)
       
   162     {
       
   163         LOG1(EBackup, EInfo, "Finished reading from stream, row count = %d", iStringVector.size());
       
   164 
       
   165 
       
   166         int err = WriteDataToStorage();
       
   167 
       
   168         if (err != KErrNone)
       
   169         {
       
   170             CleanupStack::PopAndDestroy(&aStream);
       
   171             User::Leave(KErrGeneral);
       
   172         }
       
   173 
       
   174         // Storage restore is over; Change the state 
       
   175 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   176         aRestoreState = EScr;
       
   177 #else
       
   178         aRestoreState = EAppArc;
       
   179 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   180      
       
   181         aBufferSpaceLeft = iBufferSpaceLeft;
       
   182     }
       
   183 }
       
   184 
       
   185 
       
   186 void CStorageBackupUtil::WriteStringtoStreamL(RDesWriteStream& aStream, wstring aStr)
       
   187 {
       
   188     iLenOfString = aStr.length();
       
   189 
       
   190     // if length of string is 0, do not write any string to the stream.
       
   191     if (iLenOfString == 0)
       
   192     {
       
   193         aStream.WriteInt16L(iLenOfString*2);
       
   194         iBufferSpaceLeft -= sizeof(TInt16);
       
   195         iStrCount++;
       
   196     }
       
   197 
       
   198     else
       
   199     {
       
   200         /* if space is not enough for writing the complete string,
       
   201            do not write it. Could be written next time.  */
       
   202         if (((iLenOfString*2) + sizeof(TInt16)) > iBufferSpaceLeft)
       
   203         {
       
   204             LOG(EBackup, EInfo, "Stream size is not enough to hold the string");
       
   205             // set the bufferspaceleft to zero
       
   206             iBufferSpaceLeft = 0;
       
   207         }
       
   208         // stream has enough space for the length and the string data.
       
   209         else
       
   210         {
       
   211             aStream.WriteInt16L(iLenOfString*2);
       
   212             iBufferSpaceLeft -= sizeof(TInt16);
       
   213 
       
   214             HBufC* tempstr = java::util::S60CommonUtils::wstringToDes(aStr.c_str());
       
   215             TPtrC tempStr = tempstr->Des();
       
   216             aStream.WriteL(tempStr);
       
   217             iBufferSpaceLeft -= (iLenOfString*2);
       
   218             delete tempstr;
       
   219 
       
   220             iStrCount++;
       
   221         }
       
   222     }
       
   223 }
       
   224 
       
   225 void CStorageBackupUtil::ReadStringfromStreamL(RDesReadStream& aStream)
       
   226 {
       
   227     wstring emptyString;
       
   228 
       
   229     /* if only part of the string was read last time,
       
   230        read the remaining and append it to that string.  */
       
   231     if (iRemainingString)
       
   232     {
       
   233         // if the whole string cannot be read, read part of it and store it.
       
   234         if (iLenOfString > iBufferSpaceLeft)
       
   235         {
       
   236             LOG(EBackup, EInfo, "Cant read the full string; read only part of it");
       
   237 
       
   238             HBufC* data = HBufC::NewL(iBufferSpaceLeft/2+1);
       
   239             TPtr pdata = data->Des();
       
   240 
       
   241             aStream.ReadL(pdata, iBufferSpaceLeft/2);
       
   242             iLenOfString -= iBufferSpaceLeft;
       
   243             iBufferSpaceLeft = 0;
       
   244 
       
   245             wchar_t* str = desToWstring(pdata);
       
   246             wstring stringData(str);
       
   247             iHalfReadString += stringData;
       
   248 
       
   249             delete data;
       
   250             iRemainingString = ETrue;
       
   251         }
       
   252         // else read the complete string
       
   253         else
       
   254         {
       
   255             HBufC* data = HBufC::NewL(iLenOfString/2+1);
       
   256             TPtr pdata = data->Des();
       
   257 
       
   258             aStream.ReadL(pdata, iLenOfString/2);
       
   259             iBufferSpaceLeft -= (iLenOfString);
       
   260 
       
   261             wchar_t* str = desToWstring(pdata);
       
   262             wstring stringData(str);
       
   263             iHalfReadString += stringData;
       
   264 
       
   265             iStringVector.push_back(iHalfReadString);
       
   266 
       
   267             delete data;
       
   268             iStrCount--;
       
   269             iRemainingString = EFalse;
       
   270             iHalfReadString = emptyString;
       
   271         }
       
   272     }
       
   273 
       
   274     else
       
   275     {
       
   276         iLenOfString = aStream.ReadInt16L();
       
   277         iBufferSpaceLeft -= sizeof(TInt16);
       
   278 
       
   279         if (iLenOfString > 0)
       
   280         {
       
   281             // if full string cannot be read, read only part of it.
       
   282             if (iLenOfString > iBufferSpaceLeft)
       
   283             {
       
   284                 /* if the stream does not have even part of the string,
       
   285                    just set the iRemainingFlag to ETrue so that the
       
   286                    string can be read next time. */
       
   287 
       
   288                 if (iBufferSpaceLeft == 0)
       
   289                 {
       
   290                     iRemainingString = ETrue;
       
   291                     iHalfReadString = emptyString;
       
   292                 }
       
   293                 // else stream contains part of the stream. Read it
       
   294                 else
       
   295                 {
       
   296                     LOG(EBackup, EInfo, "Cant read the full string; read only part of it");
       
   297 
       
   298                     HBufC* data = HBufC::NewL(iBufferSpaceLeft/2+1);
       
   299                     TPtr pdata = data->Des();
       
   300 
       
   301                     aStream.ReadL(pdata, iBufferSpaceLeft/2);
       
   302                     iLenOfString -= iBufferSpaceLeft;
       
   303                     iBufferSpaceLeft = 0;
       
   304 
       
   305                     wchar_t* str = desToWstring(pdata);
       
   306                     wstring stringData(str);
       
   307                     iHalfReadString = stringData;
       
   308                     delete data;
       
   309                     iRemainingString = ETrue;
       
   310                 }
       
   311             }
       
   312             // else full string can be read
       
   313             else
       
   314             {
       
   315                 HBufC* data = HBufC::NewL(iLenOfString/2+1);
       
   316                 TPtr pdata = data->Des();
       
   317 
       
   318                 aStream.ReadL(pdata, iLenOfString/2);
       
   319                 iBufferSpaceLeft -= (iLenOfString);
       
   320 
       
   321                 wchar_t* str = desToWstring(pdata);
       
   322                 wstring stringData(str);
       
   323 
       
   324                 iStringVector.push_back(stringData);
       
   325                 iStrCount--;
       
   326                 delete data;
       
   327             }
       
   328         }
       
   329         /* if length of string is 0, do not read anything from the stream;
       
   330            just push an empty string into the vector */
       
   331         else
       
   332         {
       
   333             iStringVector.push_back(emptyString);
       
   334             iStrCount--;
       
   335         }
       
   336     }
       
   337 }
       
   338 
       
   339 
       
   340 int CStorageBackupUtil::FillVectorWithStorageData()
       
   341 {
       
   342     // get data from storage
       
   343 
       
   344     LOG(EBackup, EInfo, "CStorageBackupUtil::FillVectorsWithData");
       
   345 
       
   346     auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   347     LOG(EBackup, EInfo, "Opening connection to JAVA_DATABASE");
       
   348 
       
   349     try
       
   350     {
       
   351         js->open(JAVA_DATABASE_NAME);
       
   352         LOG(EBackup, EInfo, "Opening commection succeeded");
       
   353     }
       
   354     catch (JavaStorageException jse)
       
   355     {
       
   356         ELOG1(EBackup, "Opening JAVA_DATABASE failed; %S", jse.toString().c_str());
       
   357         return KErrGeneral;
       
   358     }
       
   359 
       
   360     JavaStorageEntry attribute;
       
   361     JavaStorageApplicationEntry_t findPattern;
       
   362     JavaStorageApplicationList_t foundEntries;
       
   363 
       
   364 
       
   365     // table 1 : Application package table
       
   366     {
       
   367         LOG(EBackup, EInfo, "Read entries from APPLICATION_PACKAGE_TABLE");
       
   368 
       
   369         try
       
   370         {
       
   371             js->search(APPLICATION_PACKAGE_TABLE, findPattern, foundEntries);
       
   372             LOG(EBackup, EInfo, "Search in Java Storage succeded");
       
   373         }
       
   374         catch (JavaStorageException jse)
       
   375         {
       
   376             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   377             js->close();
       
   378             return KErrGeneral;
       
   379         }
       
   380 
       
   381         iTableSize[0] = FillVectorwithAppPackageTableData(foundEntries);
       
   382         foundEntries.clear();
       
   383 
       
   384         if (iTableSize[0] == 0)
       
   385         {
       
   386             LOG(EBackup, EInfo,  "No data in Storage; So no midlets in system;");
       
   387             return KErrGeneral;
       
   388         }
       
   389     }
       
   390 
       
   391 
       
   392     // table 2: Application table
       
   393     {
       
   394         LOG(EBackup, EInfo,  "Read entries from APPLICATION_TABLE");
       
   395 
       
   396         try
       
   397         {
       
   398             js->search(APPLICATION_TABLE, findPattern, foundEntries);
       
   399             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   400         }
       
   401         catch (JavaStorageException jse)
       
   402         {
       
   403             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   404             js->close();
       
   405             return KErrGeneral;
       
   406         }
       
   407 
       
   408         iTableSize[1] = FillVectorwithAppTableData(foundEntries);
       
   409 
       
   410         foundEntries.clear();
       
   411     }
       
   412 
       
   413     // table 3: Application package attributes table
       
   414 
       
   415     /* for this table, since there are very large number of rows,
       
   416        read the data from the table suite-by-suite
       
   417        ie. read entries for the first suite, then read entries for the
       
   418        second suite. This would prevent stack overflow  */
       
   419     {
       
   420         LOG(EBackup, EInfo,  "Read entries from APPLICATION_PACKAGE_ATTRIBUTES_TABLE");
       
   421 
       
   422         int rowCount = 0;
       
   423 
       
   424         for (int suiteNumber = 0; suiteNumber < iTableSize[0]; suiteNumber++)
       
   425         {
       
   426             attribute.setEntry(ID, iStringVector[suiteNumber*14]);
       
   427             findPattern.insert(attribute);
       
   428 
       
   429             try
       
   430             {
       
   431                 js->search(APPLICATION_PACKAGE_ATTRIBUTES_TABLE, findPattern, foundEntries);
       
   432                 LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   433             }
       
   434             catch (JavaStorageException jse)
       
   435             {
       
   436                 ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   437                 js->close();
       
   438                 return KErrGeneral;
       
   439             }
       
   440 
       
   441             rowCount += FillVectorwithAppPackageAttTableData(foundEntries);
       
   442 
       
   443             foundEntries.clear();
       
   444             findPattern.clear();
       
   445         }
       
   446         iTableSize[2] = rowCount;
       
   447     }
       
   448 
       
   449     // table 4: Midp package table
       
   450     {
       
   451         LOG(EBackup, EInfo,  "Read entries from MIDP_PACKAGE_TABLE");
       
   452 
       
   453         try
       
   454         {
       
   455             js->search(MIDP_PACKAGE_TABLE, findPattern, foundEntries);
       
   456             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   457         }
       
   458         catch (JavaStorageException jse)
       
   459         {
       
   460             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   461             js->close();
       
   462             return KErrGeneral;
       
   463         }
       
   464 
       
   465         iTableSize[3] = FillVectorwithMidpPackageTableData(foundEntries);
       
   466 
       
   467         foundEntries.clear();
       
   468     }
       
   469 
       
   470     // table 5: Midp permissions table
       
   471 
       
   472     /* for this table, since there are very large number of rows,
       
   473        read the data from the table suite-by-suite
       
   474        ie. read entries for the first suite, then read entries for the
       
   475        second suite. This would prevent stack overflow  */
       
   476     {
       
   477         LOG(EBackup, EInfo,  "Read entries from MIDP_PERMISSIONS_TABLE");
       
   478 
       
   479         int rowCount = 0;
       
   480 
       
   481         for (int suiteNumber = 0; suiteNumber < iTableSize[0]; suiteNumber++)
       
   482         {
       
   483             attribute.setEntry(ID, iStringVector[suiteNumber*14]);
       
   484             findPattern.insert(attribute);
       
   485 
       
   486             try
       
   487             {
       
   488                 js->search(MIDP_PERMISSIONS_TABLE, findPattern, foundEntries);
       
   489                 LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   490             }
       
   491             catch (JavaStorageException jse)
       
   492             {
       
   493                 ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   494                 js->close();
       
   495                 return KErrGeneral;
       
   496             }
       
   497 
       
   498             rowCount += FillVectorwithMidpPermTableData(foundEntries);
       
   499 
       
   500             foundEntries.clear();
       
   501             findPattern.clear();
       
   502         }
       
   503         iTableSize[4] = rowCount;
       
   504     }
       
   505 
       
   506     // table 6: Midp function group settings table
       
   507     {
       
   508         LOG(EBackup, EInfo,  "Read entries from MIDP_FUNC_GRP_SETTINGS_TABLE");
       
   509 
       
   510         try
       
   511         {
       
   512             js->search(MIDP_FUNC_GRP_SETTINGS_TABLE, findPattern, foundEntries);
       
   513             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   514         }
       
   515         catch (JavaStorageException jse)
       
   516         {
       
   517             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   518             js->close();
       
   519             return KErrGeneral;
       
   520         }
       
   521 
       
   522         iTableSize[5] = FillVectorwithMidpFuncGrpSetTableData(foundEntries);
       
   523 
       
   524         foundEntries.clear();
       
   525     }
       
   526 
       
   527     // table 7: push registration table
       
   528     {
       
   529         LOG(EBackup, EInfo,  "Read entries from PUSH_REGISTRATIONS_TABLE");
       
   530 
       
   531         try
       
   532         {
       
   533             js->search(PUSH_REGISTRATIONS_TABLE, findPattern, foundEntries);
       
   534             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   535         }
       
   536         catch (JavaStorageException jse)
       
   537         {
       
   538             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   539             js->close();
       
   540             return KErrGeneral;
       
   541         }
       
   542 
       
   543         iTableSize[6] = FillVectorwithPushRegTableData(foundEntries);
       
   544 
       
   545         foundEntries.clear();
       
   546     }
       
   547 
       
   548     // table 8: alarm registration table
       
   549     {
       
   550         LOG(EBackup, EInfo,  "Read entries from ALARM_REGISTRATIONS_TABLE");
       
   551 
       
   552         try
       
   553         {
       
   554             js->search(ALARM_REGISTRATIONS_TABLE, findPattern, foundEntries);
       
   555             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   556         }
       
   557         catch (JavaStorageException jse)
       
   558         {
       
   559             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   560             js->close();
       
   561             return KErrGeneral;
       
   562         }
       
   563 
       
   564         iTableSize[7] = FillVectorwithAlarmRegTableData(foundEntries);
       
   565 
       
   566         foundEntries.clear();
       
   567     }
       
   568 
       
   569     // table 9: runtime settings table
       
   570     {
       
   571         LOG(EBackup, EInfo,  "Read entries from RUNTIME_SETTINGS_TABLE");
       
   572 
       
   573         try
       
   574         {
       
   575             js->search(RUNTIME_SETTINGS_TABLE, findPattern, foundEntries);
       
   576             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   577         }
       
   578         catch (JavaStorageException jse)
       
   579         {
       
   580             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   581             js->close();
       
   582             return KErrGeneral;
       
   583         }
       
   584 
       
   585         iTableSize[8] = FillVectorwithRuntimeSetTableData(foundEntries);
       
   586 
       
   587         foundEntries.clear();
       
   588     }
       
   589 
       
   590     // table 10: pre-install table
       
   591     {
       
   592         LOG(EBackup, EInfo,  "Read entries from PREINSTALL_TABLE");
       
   593 
       
   594         try
       
   595         {
       
   596             js->search(PREINSTALL_TABLE, findPattern, foundEntries);
       
   597             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   598         }
       
   599         catch (JavaStorageException jse)
       
   600         {
       
   601             ELOG1(EBackup, "Search in Java Storage failed; %S", jse.toString().c_str());
       
   602             js->close();
       
   603             return KErrGeneral;
       
   604         }
       
   605 
       
   606         iTableSize[9] = FillVectorwithPreinstallTableData(foundEntries);
       
   607 
       
   608         foundEntries.clear();
       
   609     }
       
   610 
       
   611     // Data read from JAVA_DATABASE; So close the connection
       
   612     js->close();
       
   613 
       
   614     // table 11: ota status table
       
   615     /* Stored in another database called javaotadatabase.
       
   616        so open a new connection to that database.  */
       
   617     {
       
   618         LOG(EBackup, EInfo,  "Read entries from OTA_STATUS_TABLE");
       
   619 
       
   620         auto_ptr<JavaStorage> jos(JavaStorage::createInstance());
       
   621 
       
   622         try
       
   623         {
       
   624             jos->open(JAVA_OTA_DATABASE_NAME);
       
   625             ILOG(EBackup, "Opening connection to OTA database succeeded");
       
   626         }
       
   627         catch (JavaStorageException jse)
       
   628         {
       
   629             ELOG1(EBackup, "Opening OTA database failed: %s", jse.toString().c_str());
       
   630             return KErrGeneral;
       
   631         }
       
   632 
       
   633         try
       
   634         {
       
   635             jos->search(OTA_STATUS_TABLE, findPattern, foundEntries);
       
   636             LOG(EBackup, EInfo,  "Search in Java Storage succeded");
       
   637         }
       
   638         catch (JavaStorageException jse)
       
   639         {
       
   640             ELOG1(EBackup, "Search in Java Storage failed; %s", jse.toString().c_str());
       
   641             jos->close();
       
   642             return KErrGeneral;
       
   643         }
       
   644 
       
   645         iTableSize[10] = FillVectorwithOtaStatusTableData(foundEntries);
       
   646 
       
   647         foundEntries.clear();
       
   648         jos->close();
       
   649     }
       
   650 
       
   651     //################ printing the vectors #############
       
   652     //printVector();
       
   653     //###################################################
       
   654 
       
   655     ILOG(EBackup, "Vector filled with data");
       
   656     return KErrNone;
       
   657 }
       
   658 
       
   659 
       
   660 int CStorageBackupUtil::WriteDataToStorage()
       
   661 {
       
   662     JELOG2(EBackup);
       
   663     ILOG(EBackup, "Create instance of JAVA_DATABASE_NAME and open the database");
       
   664 
       
   665     auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   666 
       
   667     try
       
   668     {
       
   669         js->open(JAVA_DATABASE_NAME);
       
   670         ILOG(EBackup, "Opening database succeded");
       
   671     }
       
   672     catch (JavaStorageException jse)
       
   673     {
       
   674         ELOG1(EBackup, "Opening database failed: %S", jse.toString().c_str());
       
   675         return KErrGeneral;
       
   676     }
       
   677 
       
   678     try
       
   679     {
       
   680         js->startTransaction();
       
   681         ILOG(EBackup, "Transaction started");
       
   682     }
       
   683     catch (JavaStorageException jse)
       
   684     {
       
   685         ELOG1(EBackup, "startTransaction() failed: %S", jse.toString().c_str());
       
   686         js->close();
       
   687         return KErrGeneral;
       
   688     }
       
   689 
       
   690     ILOG(EBackup, "Before writing data to storage, existing data must be cleared");
       
   691 
       
   692     // call delete * from table one-by-one
       
   693     {
       
   694         JavaStorageApplicationEntry_t emptyEntry;
       
   695 
       
   696         try
       
   697         {
       
   698             js->remove(APPLICATION_PACKAGE_TABLE, emptyEntry);
       
   699             js->remove(APPLICATION_TABLE, emptyEntry);
       
   700             js->remove(APPLICATION_PACKAGE_ATTRIBUTES_TABLE, emptyEntry);
       
   701             js->remove(MIDP_PACKAGE_TABLE, emptyEntry);
       
   702             js->remove(MIDP_PERMISSIONS_TABLE, emptyEntry);
       
   703             js->remove(MIDP_FUNC_GRP_SETTINGS_TABLE, emptyEntry);
       
   704             js->remove(PUSH_REGISTRATIONS_TABLE, emptyEntry);
       
   705             js->remove(ALARM_REGISTRATIONS_TABLE, emptyEntry);
       
   706             js->remove(RUNTIME_SETTINGS_TABLE, emptyEntry);
       
   707             js->remove(PREINSTALL_TABLE, emptyEntry);
       
   708 
       
   709             ILOG(EBackup, "Data removed successfully from table");
       
   710         }
       
   711         catch (JavaStorageException jse)
       
   712         {
       
   713             ELOG1(EBackup, "Failed during removal of entries from table: %S", jse.toString().c_str());
       
   714             js->close();
       
   715             return KErrGeneral;
       
   716         }
       
   717     }
       
   718 
       
   719     JavaStorageEntry attribute;
       
   720     JavaStorageApplicationEntry_t insertEntry;
       
   721 
       
   722     ILOG(EBackup, "Start transaction for writing into the database");
       
   723 
       
   724     int count = 0;
       
   725     // table 1 : Application package table
       
   726     {
       
   727         LOG(EBackup, EInfo,  "Writing to APPLICATION_PACKAGE_TABLE");
       
   728 
       
   729         for (int rowNumber = 0; rowNumber < iTableSize[0]; rowNumber++)
       
   730         {
       
   731             attribute.setEntry(ID, iStringVector[count++]);
       
   732             insertEntry.insert(attribute);
       
   733 
       
   734             attribute.setEntry(PACKAGE_NAME, iStringVector[count++]);
       
   735             insertEntry.insert(attribute);
       
   736 
       
   737             attribute.setEntry(VENDOR, iStringVector[count++]);
       
   738             insertEntry.insert(attribute);
       
   739 
       
   740             attribute.setEntry(VERSION, iStringVector[count++]);
       
   741             insertEntry.insert(attribute);
       
   742 
       
   743             attribute.setEntry(ROOT_PATH, iStringVector[count++]);
       
   744             insertEntry.insert(attribute);
       
   745 
       
   746             attribute.setEntry(MEDIA_ID, iStringVector[count++]);
       
   747             insertEntry.insert(attribute);
       
   748 
       
   749             attribute.setEntry(INITIAL_SIZE, iStringVector[count++]);
       
   750             insertEntry.insert(attribute);
       
   751 
       
   752             attribute.setEntry(JAD_PATH, iStringVector[count++]);
       
   753             insertEntry.insert(attribute);
       
   754 
       
   755             attribute.setEntry(JAR_PATH, iStringVector[count++]);
       
   756             insertEntry.insert(attribute);
       
   757 
       
   758             attribute.setEntry(JAD_URL, iStringVector[count++]);
       
   759             insertEntry.insert(attribute);
       
   760 
       
   761             attribute.setEntry(JAR_URL, iStringVector[count++]);
       
   762             insertEntry.insert(attribute);
       
   763 
       
   764             attribute.setEntry(ACCESS_POINT, iStringVector[count++]);
       
   765             insertEntry.insert(attribute);
       
   766 
       
   767             attribute.setEntry(CONTENT_INFO, iStringVector[count++]);
       
   768             insertEntry.insert(attribute);
       
   769 
       
   770             attribute.setEntry(CONTENT_ID, iStringVector[count++]);
       
   771             insertEntry.insert(attribute);
       
   772 
       
   773             try
       
   774             {
       
   775                 js->write(APPLICATION_PACKAGE_TABLE, insertEntry);
       
   776                 ILOG(EBackup, "Writing to table succeded");
       
   777             }
       
   778             catch (JavaStorageException jse)
       
   779             {
       
   780                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   781                 js->close();
       
   782                 return KErrGeneral;
       
   783             }
       
   784             insertEntry.clear();
       
   785         }
       
   786     }
       
   787 
       
   788     // table 2: Application table
       
   789     {
       
   790         LOG(EBackup, EInfo,  "Writing to APPLICATION_TABLE");
       
   791 
       
   792         for (int rowNumber = 0; rowNumber < iTableSize[1]; rowNumber++)
       
   793         {
       
   794             attribute.setEntry(ID, iStringVector[count++]);
       
   795             insertEntry.insert(attribute);
       
   796 
       
   797             attribute.setEntry(PACKAGE_ID, iStringVector[count++]);
       
   798             insertEntry.insert(attribute);
       
   799 
       
   800             attribute.setEntry(NAME, iStringVector[count++]);
       
   801             insertEntry.insert(attribute);
       
   802 
       
   803             attribute.setEntry(MAIN_CLASS, iStringVector[count++]);
       
   804             insertEntry.insert(attribute);
       
   805 
       
   806             attribute.setEntry(AUTORUN, iStringVector[count++]);
       
   807             insertEntry.insert(attribute);
       
   808 
       
   809             try
       
   810             {
       
   811                 js->write(APPLICATION_TABLE, insertEntry);
       
   812                 ILOG(EBackup, "Writing to table succeded");
       
   813             }
       
   814             catch (JavaStorageException jse)
       
   815             {
       
   816                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   817                 js->close();
       
   818                 return KErrGeneral;
       
   819             }
       
   820             insertEntry.clear();
       
   821         }
       
   822     }
       
   823 
       
   824     // table 3: Application package attributes table
       
   825     {
       
   826         LOG(EBackup, EInfo,  "Writing to APPLICATION_PACKAGE_ATTRIBUTES_TABLE");
       
   827 
       
   828         for (int rowNumber = 0; rowNumber < iTableSize[2]; rowNumber++)
       
   829         {
       
   830             attribute.setEntry(ID, iStringVector[count++]);
       
   831             insertEntry.insert(attribute);
       
   832 
       
   833             attribute.setEntry(NAME, iStringVector[count++]);
       
   834             insertEntry.insert(attribute);
       
   835 
       
   836             attribute.setEntry(VALUE, iStringVector[count++]);
       
   837             insertEntry.insert(attribute);
       
   838 
       
   839             attribute.setEntry(TRUSTED, iStringVector[count++]);
       
   840             insertEntry.insert(attribute);
       
   841 
       
   842             try
       
   843             {
       
   844                 js->write(APPLICATION_PACKAGE_ATTRIBUTES_TABLE, insertEntry);
       
   845                 ILOG(EBackup, "Writing to table succeded");
       
   846             }
       
   847             catch (JavaStorageException jse)
       
   848             {
       
   849                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   850                 js->close();
       
   851                 return KErrGeneral;
       
   852             }
       
   853             insertEntry.clear();
       
   854         }
       
   855     }
       
   856 
       
   857     // table 4: Midp package table
       
   858     {
       
   859         LOG(EBackup, EInfo,  "Writing to MIDP_PACKAGE_TABLE");
       
   860 
       
   861         for (int rowNumber = 0; rowNumber < iTableSize[3]; rowNumber++)
       
   862         {
       
   863             attribute.setEntry(ID, iStringVector[count++]);
       
   864             insertEntry.insert(attribute);
       
   865 
       
   866             attribute.setEntry(TYPE, iStringVector[count++]);
       
   867             insertEntry.insert(attribute);
       
   868 
       
   869             attribute.setEntry(SECURITY_DOMAIN, iStringVector[count++]);
       
   870             insertEntry.insert(attribute);
       
   871 
       
   872             attribute.setEntry(SECURITY_DOMAIN_CATEGORY, iStringVector[count++]);
       
   873             insertEntry.insert(attribute);
       
   874 
       
   875             attribute.setEntry(HASH, iStringVector[count++]);
       
   876             insertEntry.insert(attribute);
       
   877 
       
   878             attribute.setEntry(CERT_HASH, iStringVector[count++]);
       
   879             insertEntry.insert(attribute);
       
   880 
       
   881             attribute.setEntry(RMS, iStringVector[count++]);
       
   882             insertEntry.insert(attribute);
       
   883 
       
   884             attribute.setEntry(VALID_CERTS, iStringVector[count++]);
       
   885             insertEntry.insert(attribute);
       
   886 
       
   887             attribute.setEntry(ON_SCREEN_KEYPAD, iStringVector[count++]);
       
   888             insertEntry.insert(attribute);
       
   889             
       
   890             attribute.setEntry(SECURITY_WARNINGS, iStringVector[count++]);
       
   891             insertEntry.insert(attribute);
       
   892 
       
   893             try
       
   894             {
       
   895                 js->write(MIDP_PACKAGE_TABLE, insertEntry);
       
   896                 ILOG(EBackup, "Writing to table succeded");
       
   897             }
       
   898             catch (JavaStorageException jse)
       
   899             {
       
   900                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   901                 js->close();
       
   902                 return KErrGeneral;
       
   903             }
       
   904             insertEntry.clear();
       
   905         }
       
   906     }
       
   907 
       
   908     // table 5: Midp permissions table
       
   909     {
       
   910         LOG(EBackup, EInfo,  "Writing to MIDP_PERMISSIONS_TABLE");
       
   911 
       
   912         for (int rowNumber = 0; rowNumber < iTableSize[4]; rowNumber++)
       
   913         {
       
   914             attribute.setEntry(ID, iStringVector[count++]);
       
   915             insertEntry.insert(attribute);
       
   916 
       
   917             attribute.setEntry(CLASS, iStringVector[count++]);
       
   918             insertEntry.insert(attribute);
       
   919 
       
   920             attribute.setEntry(NAME, iStringVector[count++]);
       
   921             insertEntry.insert(attribute);
       
   922 
       
   923             attribute.setEntry(ACTION, iStringVector[count++]);
       
   924             insertEntry.insert(attribute);
       
   925 
       
   926             attribute.setEntry(FUNCTION_GROUP, iStringVector[count++]);
       
   927             insertEntry.insert(attribute);
       
   928 
       
   929             try
       
   930             {
       
   931                 js->write(MIDP_PERMISSIONS_TABLE, insertEntry);
       
   932                 ILOG(EBackup, "Writing to table succeded");
       
   933             }
       
   934             catch (JavaStorageException jse)
       
   935             {
       
   936                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   937                 js->close();
       
   938                 return KErrGeneral;
       
   939             }
       
   940             insertEntry.clear();
       
   941         }
       
   942     }
       
   943 
       
   944     // table 6: Midp function group settings table
       
   945     {
       
   946         LOG(EBackup, EInfo,  "MIDP_FUNC_GRP_SETTINGS_TABLE");
       
   947 
       
   948         for (int rowNumber = 0; rowNumber < iTableSize[5]; rowNumber++)
       
   949         {
       
   950             attribute.setEntry(ID, iStringVector[count++]);
       
   951             insertEntry.insert(attribute);
       
   952 
       
   953             attribute.setEntry(FUNCTION_GROUP, iStringVector[count++]);
       
   954             insertEntry.insert(attribute);
       
   955 
       
   956             attribute.setEntry(ALLOWED_SETTINGS, iStringVector[count++]);
       
   957             insertEntry.insert(attribute);
       
   958 
       
   959             attribute.setEntry(CURRENT_SETTING, iStringVector[count++]);
       
   960             insertEntry.insert(attribute);
       
   961 
       
   962             attribute.setEntry(BLANKET_PROMPT, iStringVector[count++]);
       
   963             insertEntry.insert(attribute);
       
   964 
       
   965             try
       
   966             {
       
   967                 js->write(MIDP_FUNC_GRP_SETTINGS_TABLE, insertEntry);
       
   968                 ILOG(EBackup, "Writing to table succeded");
       
   969             }
       
   970             catch (JavaStorageException jse)
       
   971             {
       
   972                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
   973                 js->close();
       
   974                 return KErrGeneral;
       
   975             }
       
   976             insertEntry.clear();
       
   977         }
       
   978     }
       
   979 
       
   980     // table 7: push registration table
       
   981     {
       
   982         LOG(EBackup, EInfo,  "Writing to PUSH_REGISTRATIONS_TABLE");
       
   983 
       
   984         for (int rowNumber = 0; rowNumber < iTableSize[6]; rowNumber++)
       
   985         {
       
   986             attribute.setEntry(ID, iStringVector[count++]);
       
   987             insertEntry.insert(attribute);
       
   988 
       
   989             attribute.setEntry(URL, iStringVector[count++]);
       
   990             insertEntry.insert(attribute);
       
   991 
       
   992             attribute.setEntry(NAME, iStringVector[count++]);
       
   993             insertEntry.insert(attribute);
       
   994 
       
   995             attribute.setEntry(FILTER, iStringVector[count++]);
       
   996             insertEntry.insert(attribute);
       
   997 
       
   998             attribute.setEntry(REGISTRATION_TYPE, iStringVector[count++]);
       
   999             insertEntry.insert(attribute);
       
  1000 
       
  1001             try
       
  1002             {
       
  1003                 js->write(PUSH_REGISTRATIONS_TABLE, insertEntry);
       
  1004                 ILOG(EBackup, "Writing to table succeded");
       
  1005             }
       
  1006             catch (JavaStorageException jse)
       
  1007             {
       
  1008                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
  1009                 js->close();
       
  1010                 return KErrGeneral;
       
  1011             }
       
  1012             insertEntry.clear();
       
  1013         }
       
  1014     }
       
  1015 
       
  1016     // table 8: alarm registration table
       
  1017     {
       
  1018         LOG(EBackup, EInfo,  "Writing to ALARM_REGISTRATIONS_TABLE");
       
  1019 
       
  1020         for (int rowNumber = 0; rowNumber < iTableSize[7]; rowNumber++)
       
  1021         {
       
  1022             attribute.setEntry(ID, iStringVector[count++]);
       
  1023             insertEntry.insert(attribute);
       
  1024 
       
  1025             attribute.setEntry(ALARM_TIME, iStringVector[count++]);
       
  1026             insertEntry.insert(attribute);
       
  1027 
       
  1028             try
       
  1029             {
       
  1030                 js->write(ALARM_REGISTRATIONS_TABLE, insertEntry);
       
  1031                 ILOG(EBackup, "Writing to table succeded");
       
  1032             }
       
  1033             catch (JavaStorageException jse)
       
  1034             {
       
  1035                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
  1036                 js->close();
       
  1037                 return KErrGeneral;
       
  1038             }
       
  1039             insertEntry.clear();
       
  1040         }
       
  1041     }
       
  1042 
       
  1043 
       
  1044     // table 9: runtime settings table
       
  1045     {
       
  1046         LOG(EBackup, EInfo,  "Writing to RUNTIME_SETTINGS_TABLE");
       
  1047 
       
  1048         for (int rowNumber = 0; rowNumber < iTableSize[8]; rowNumber++)
       
  1049         {
       
  1050             attribute.setEntry(EXTENSIONS, iStringVector[count++]);
       
  1051             insertEntry.insert(attribute);
       
  1052 
       
  1053             try
       
  1054             {
       
  1055                 js->write(RUNTIME_SETTINGS_TABLE, insertEntry);
       
  1056                 ILOG(EBackup, "Writing to table succeded");
       
  1057             }
       
  1058             catch (JavaStorageException jse)
       
  1059             {
       
  1060                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
  1061                 js->close();
       
  1062                 return KErrGeneral;
       
  1063             }
       
  1064             insertEntry.clear();
       
  1065         }
       
  1066     }
       
  1067 
       
  1068     // table 10: pre-install table
       
  1069     {
       
  1070         LOG(EBackup, EInfo,  "Writing to PREINSTALL_TABLE");
       
  1071 
       
  1072         for (int rowNumber = 0; rowNumber < iTableSize[9]; rowNumber++)
       
  1073         {
       
  1074             attribute.setEntry(NAME, iStringVector[count++]);
       
  1075             insertEntry.insert(attribute);
       
  1076 
       
  1077             attribute.setEntry(VENDOR, iStringVector[count++]);
       
  1078             insertEntry.insert(attribute);
       
  1079 
       
  1080             attribute.setEntry(VERSION, iStringVector[count++]);
       
  1081             insertEntry.insert(attribute);
       
  1082 
       
  1083             attribute.setEntry(INSTALL_STATE, iStringVector[count++]);
       
  1084             insertEntry.insert(attribute);
       
  1085 
       
  1086             try
       
  1087             {
       
  1088                 js->write(PREINSTALL_TABLE, insertEntry);
       
  1089                 ILOG(EBackup, "Writing to table succeded");
       
  1090             }
       
  1091             catch (JavaStorageException jse)
       
  1092             {
       
  1093                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
  1094                 js->close();
       
  1095                 return KErrGeneral;
       
  1096             }
       
  1097             insertEntry.clear();
       
  1098         }
       
  1099     }
       
  1100 
       
  1101     ILOG(EBackup, "Data written to JAVA_DATABASE; So Commit the transaction and close the database");
       
  1102     ILOG(EBackup, "Committing the transaction");
       
  1103 
       
  1104     try
       
  1105     {
       
  1106         js->commitTransaction();
       
  1107         ILOG(EBackup, "Transaction committed successfully");
       
  1108     }
       
  1109     catch (JavaStorageException jse)
       
  1110     {
       
  1111         ELOG1(EBackup, "Committing the transaction failed: %S", jse.toString().c_str());
       
  1112         js->close();
       
  1113         return KErrGeneral;
       
  1114     }
       
  1115 
       
  1116     ILOG(EBackup, "Close the database");
       
  1117 
       
  1118     // close the JAVA_DATABASE
       
  1119     js->close();
       
  1120 
       
  1121 
       
  1122     // table 11: ota status table
       
  1123     /* stored in another database called javaotadatabase.
       
  1124        so open a new connection to that database   */
       
  1125 
       
  1126     {
       
  1127         ILOG(EBackup, "Create instance of JAVA_OTA_DATABASE_NAME and open the database");
       
  1128         auto_ptr<JavaStorage> jos(JavaStorage::createInstance());
       
  1129 
       
  1130         try
       
  1131         {
       
  1132             jos->open(JAVA_OTA_DATABASE_NAME);
       
  1133             ILOG(EBackup, "Opening database succeded");
       
  1134         }
       
  1135         catch (JavaStorageException jse)
       
  1136         {
       
  1137             ELOG1(EBackup, "Opening database failed: %S", jse.toString().c_str());
       
  1138             return KErrGeneral;
       
  1139         }
       
  1140 
       
  1141         ILOG(EBackup, "Start a transaction for writing to this database");
       
  1142 
       
  1143         try
       
  1144         {
       
  1145             jos->startTransaction();
       
  1146             ILOG(EBackup, "Transaction started");
       
  1147         }
       
  1148         catch (JavaStorageException jse)
       
  1149         {
       
  1150             ELOG1(EBackup, "startTransaction() failed: %S", jse.toString().c_str());
       
  1151             jos->close();
       
  1152             return KErrGeneral;
       
  1153         }
       
  1154 
       
  1155         ILOG(EBackup, "Before writing data to this database, existing data must be cleared");
       
  1156 
       
  1157         try
       
  1158         {
       
  1159             JavaStorageApplicationEntry_t emptyEntry;
       
  1160             jos->remove(OTA_STATUS_TABLE, emptyEntry);
       
  1161         }
       
  1162         catch (JavaStorageException jse)
       
  1163         {
       
  1164             ELOG1(EBackup, "Removing data from OTA database failed: %S", jse.toString().c_str());
       
  1165             jos->close();
       
  1166             return KErrGeneral;
       
  1167         }
       
  1168 
       
  1169         LOG(EBackup, EInfo,  "Writing to OTA_STATUS_TABLE");
       
  1170 
       
  1171         for (int rowNumber = 0; rowNumber < iTableSize[10]; rowNumber++)
       
  1172         {
       
  1173             attribute.setEntry(ID, iStringVector[count++]);
       
  1174             insertEntry.insert(attribute);
       
  1175 
       
  1176             attribute.setEntry(CREATION_TIME, iStringVector[count++]);
       
  1177             insertEntry.insert(attribute);
       
  1178 
       
  1179             attribute.setEntry(TYPE, iStringVector[count++]);
       
  1180             insertEntry.insert(attribute);
       
  1181 
       
  1182             attribute.setEntry(OTA_CODE, iStringVector[count++]);
       
  1183             insertEntry.insert(attribute);
       
  1184 
       
  1185             attribute.setEntry(URL, iStringVector[count++]);
       
  1186             insertEntry.insert(attribute);
       
  1187 
       
  1188             attribute.setEntry(LATEST_RETRY_TIME, iStringVector[count++]);
       
  1189             insertEntry.insert(attribute);
       
  1190 
       
  1191             attribute.setEntry(RETRY_COUNT, iStringVector[count++]);
       
  1192             insertEntry.insert(attribute);
       
  1193 
       
  1194             try
       
  1195             {
       
  1196                 jos->write(OTA_STATUS_TABLE, insertEntry);
       
  1197                 LOG(EBackup, EInfo,  "Writing to table succeded");
       
  1198             }
       
  1199             catch (JavaStorageException jse)
       
  1200             {
       
  1201                 ELOG1(EBackup, "Writing to table failed: %S", jse.toString().c_str());
       
  1202                 jos->close();
       
  1203                 return KErrGeneral;
       
  1204             }
       
  1205             insertEntry.clear();
       
  1206         }
       
  1207 
       
  1208         ILOG(EBackup, "Data written to JAVA_OTA_DATABASE; commit the transaction and close the database");
       
  1209         ILOG(EBackup, "Committing the transaction");
       
  1210 
       
  1211         try
       
  1212         {
       
  1213             jos->commitTransaction();
       
  1214             LOG(EBackup, EInfo, "Transaction committed successfully");
       
  1215         }
       
  1216         catch (JavaStorageException jse)
       
  1217         {
       
  1218             ELOG1(EBackup, "Committing the transaction failed: %S", jse.toString().c_str());
       
  1219             jos->close();
       
  1220             return KErrGeneral;
       
  1221         }
       
  1222 
       
  1223         LOG(EBackup, EInfo, "Close the database");
       
  1224 
       
  1225         // close the OTA_DATABASE
       
  1226         jos->close();
       
  1227     }
       
  1228 
       
  1229     LOG(EBackup, EInfo, "Data written to Storage");
       
  1230     return KErrNone;
       
  1231 }
       
  1232 
       
  1233 
       
  1234 int CStorageBackupUtil::FillVectorwithAppPackageTableData(JavaStorageApplicationList_t& foundEntries)
       
  1235 {
       
  1236     const wstring emptyString;
       
  1237     wstring str;
       
  1238 
       
  1239     JavaStorageEntry attribute;
       
  1240 
       
  1241     /* Initialise Iterators to iterate through all applications
       
  1242        matched with search patterns.  */
       
  1243     JavaStorageApplicationList_t::const_iterator applications;
       
  1244     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1245 
       
  1246     int rowsCount=0;
       
  1247     for (applications = foundEntries.begin(); applications != foundEntries.end(); applications++)
       
  1248     {
       
  1249         attribute.setEntry(ID, L"");
       
  1250         str = emptyString;
       
  1251         findIterator = (*applications).find(attribute);
       
  1252 
       
  1253         if (findIterator != (*applications).end())
       
  1254         {
       
  1255             str = (*findIterator).entryValue();
       
  1256         }
       
  1257         iStringVector.push_back(str);
       
  1258 
       
  1259         attribute.setEntry(PACKAGE_NAME, L"");
       
  1260         str = emptyString;
       
  1261         findIterator = (*applications).find(attribute);
       
  1262 
       
  1263         if (findIterator != (*applications).end())
       
  1264         {
       
  1265             str = (*findIterator).entryValue();
       
  1266         }
       
  1267         iStringVector.push_back(str);
       
  1268 
       
  1269         attribute.setEntry(VENDOR, L"");
       
  1270         str = emptyString;
       
  1271         findIterator = (*applications).find(attribute);
       
  1272 
       
  1273         if (findIterator != (*applications).end())
       
  1274         {
       
  1275             str = (*findIterator).entryValue();
       
  1276         }
       
  1277         iStringVector.push_back(str);
       
  1278 
       
  1279         attribute.setEntry(VERSION, L"");
       
  1280         str = emptyString;
       
  1281         findIterator = (*applications).find(attribute);
       
  1282 
       
  1283         if (findIterator != (*applications).end())
       
  1284         {
       
  1285             str = (*findIterator).entryValue();
       
  1286         }
       
  1287         iStringVector.push_back(str);
       
  1288 
       
  1289         attribute.setEntry(ROOT_PATH, L"");
       
  1290         str = emptyString;
       
  1291         findIterator = (*applications).find(attribute);
       
  1292 
       
  1293         if (findIterator != (*applications).end())
       
  1294         {
       
  1295             str = (*findIterator).entryValue();
       
  1296         }
       
  1297         iStringVector.push_back(str);
       
  1298 
       
  1299         attribute.setEntry(MEDIA_ID, L"");
       
  1300         str = emptyString;
       
  1301         findIterator = (*applications).find(attribute);
       
  1302 
       
  1303         if (findIterator != (*applications).end())
       
  1304         {
       
  1305             str = (*findIterator).entryValue();
       
  1306         }
       
  1307         iStringVector.push_back(str);
       
  1308 
       
  1309         attribute.setEntry(INITIAL_SIZE, L"");
       
  1310         str = emptyString;
       
  1311         findIterator = (*applications).find(attribute);
       
  1312 
       
  1313         if (findIterator != (*applications).end())
       
  1314         {
       
  1315             str = (*findIterator).entryValue();
       
  1316         }
       
  1317         iStringVector.push_back(str);
       
  1318 
       
  1319         attribute.setEntry(JAD_PATH, L"");
       
  1320         str = emptyString;
       
  1321         findIterator = (*applications).find(attribute);
       
  1322 
       
  1323         if (findIterator != (*applications).end())
       
  1324         {
       
  1325             str = (*findIterator).entryValue();
       
  1326         }
       
  1327         iStringVector.push_back(str);
       
  1328 
       
  1329         attribute.setEntry(JAR_PATH, L"");
       
  1330         str = emptyString;
       
  1331         findIterator = (*applications).find(attribute);
       
  1332 
       
  1333         if (findIterator != (*applications).end())
       
  1334         {
       
  1335             str = (*findIterator).entryValue();
       
  1336         }
       
  1337         iStringVector.push_back(str);
       
  1338 
       
  1339         attribute.setEntry(JAD_URL, L"");
       
  1340         str = emptyString;
       
  1341         findIterator = (*applications).find(attribute);
       
  1342 
       
  1343         if (findIterator != (*applications).end())
       
  1344         {
       
  1345             str = (*findIterator).entryValue();
       
  1346         }
       
  1347         iStringVector.push_back(str);
       
  1348 
       
  1349         attribute.setEntry(JAR_URL, L"");
       
  1350         str = emptyString;
       
  1351         findIterator = (*applications).find(attribute);
       
  1352 
       
  1353         if (findIterator != (*applications).end())
       
  1354         {
       
  1355             str = (*findIterator).entryValue();
       
  1356         }
       
  1357         iStringVector.push_back(str);
       
  1358 
       
  1359         attribute.setEntry(ACCESS_POINT, L"");
       
  1360         str = emptyString;
       
  1361         findIterator = (*applications).find(attribute);
       
  1362 
       
  1363         if (findIterator != (*applications).end())
       
  1364         {
       
  1365             str = (*findIterator).entryValue();
       
  1366         }
       
  1367         iStringVector.push_back(str);
       
  1368 
       
  1369         attribute.setEntry(CONTENT_INFO, L"");
       
  1370         str = emptyString;
       
  1371         findIterator = (*applications).find(attribute);
       
  1372 
       
  1373         if (findIterator != (*applications).end())
       
  1374         {
       
  1375             str = (*findIterator).entryValue();
       
  1376         }
       
  1377         iStringVector.push_back(str);
       
  1378 
       
  1379         attribute.setEntry(CONTENT_ID, L"");
       
  1380         str = emptyString;
       
  1381         findIterator = (*applications).find(attribute);
       
  1382 
       
  1383         if (findIterator != (*applications).end())
       
  1384         {
       
  1385             str = (*findIterator).entryValue();
       
  1386         }
       
  1387         iStringVector.push_back(str);
       
  1388 
       
  1389         rowsCount++;
       
  1390     }
       
  1391     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1392     return rowsCount;
       
  1393 }
       
  1394 
       
  1395 int CStorageBackupUtil::FillVectorwithAppTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1396 {
       
  1397     const wstring emptyString;
       
  1398     wstring str;
       
  1399 
       
  1400     JavaStorageEntry attribute;
       
  1401 
       
  1402     /* Initialise Iterators to iterate through all applications
       
  1403        matched with search patterns.  */
       
  1404     JavaStorageApplicationList_t::const_iterator applications;
       
  1405     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1406 
       
  1407     int rowsCount=0;
       
  1408     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1409     {
       
  1410         attribute.setEntry(ID, L"");
       
  1411         str = emptyString;
       
  1412         findIterator = (*applications).find(attribute);
       
  1413 
       
  1414         if (findIterator != (*applications).end())
       
  1415         {
       
  1416             str = (*findIterator).entryValue();
       
  1417         }
       
  1418         iStringVector.push_back(str);
       
  1419 
       
  1420         attribute.setEntry(PACKAGE_ID, L"");
       
  1421         str = emptyString;
       
  1422         findIterator = (*applications).find(attribute);
       
  1423 
       
  1424         if (findIterator != (*applications).end())
       
  1425         {
       
  1426             str = (*findIterator).entryValue();
       
  1427         }
       
  1428         iStringVector.push_back(str);
       
  1429 
       
  1430         attribute.setEntry(NAME, L"");
       
  1431         str = emptyString;
       
  1432         findIterator = (*applications).find(attribute);
       
  1433 
       
  1434         if (findIterator != (*applications).end())
       
  1435         {
       
  1436             str = (*findIterator).entryValue();
       
  1437         }
       
  1438         iStringVector.push_back(str);
       
  1439 
       
  1440         attribute.setEntry(MAIN_CLASS, L"");
       
  1441         str = emptyString;
       
  1442         findIterator = (*applications).find(attribute);
       
  1443 
       
  1444         if (findIterator != (*applications).end())
       
  1445         {
       
  1446             str = (*findIterator).entryValue();
       
  1447         }
       
  1448         iStringVector.push_back(str);
       
  1449 
       
  1450         attribute.setEntry(AUTORUN, L"");
       
  1451         str = emptyString;
       
  1452         findIterator = (*applications).find(attribute);
       
  1453 
       
  1454         if (findIterator != (*applications).end())
       
  1455         {
       
  1456             str = (*findIterator).entryValue();
       
  1457         }
       
  1458         iStringVector.push_back(str);
       
  1459 
       
  1460         rowsCount++;
       
  1461     }
       
  1462     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1463     return rowsCount;
       
  1464 }
       
  1465 
       
  1466 int CStorageBackupUtil::FillVectorwithAppPackageAttTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1467 {
       
  1468     const wstring emptyString;
       
  1469     wstring str;
       
  1470 
       
  1471     JavaStorageEntry attribute;
       
  1472 
       
  1473     /* Initialise Iterators to iterate through all applications
       
  1474        matched with search patterns.  */
       
  1475     JavaStorageApplicationList_t::const_iterator applications;
       
  1476     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1477 
       
  1478     int rowsCount=0;
       
  1479     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1480     {
       
  1481         attribute.setEntry(ID, L"");
       
  1482         str = emptyString;
       
  1483         findIterator = (*applications).find(attribute);
       
  1484 
       
  1485         if (findIterator != (*applications).end())
       
  1486         {
       
  1487             str = (*findIterator).entryValue();
       
  1488         }
       
  1489         iStringVector.push_back(str);
       
  1490 
       
  1491         attribute.setEntry(NAME, L"");
       
  1492         str = emptyString;
       
  1493         findIterator = (*applications).find(attribute);
       
  1494 
       
  1495         if (findIterator != (*applications).end())
       
  1496         {
       
  1497             str = (*findIterator).entryValue();
       
  1498         }
       
  1499         iStringVector.push_back(str);
       
  1500 
       
  1501         attribute.setEntry(VALUE, L"");
       
  1502         str = emptyString;
       
  1503         findIterator = (*applications).find(attribute);
       
  1504 
       
  1505         if (findIterator != (*applications).end())
       
  1506         {
       
  1507             str = (*findIterator).entryValue();
       
  1508         }
       
  1509         iStringVector.push_back(str);
       
  1510 
       
  1511         attribute.setEntry(TRUSTED, L"");
       
  1512         str = emptyString;
       
  1513         findIterator = (*applications).find(attribute);
       
  1514 
       
  1515         if (findIterator != (*applications).end())
       
  1516         {
       
  1517             str = (*findIterator).entryValue();
       
  1518         }
       
  1519         iStringVector.push_back(str);
       
  1520 
       
  1521         rowsCount++;
       
  1522     }
       
  1523     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1524     return rowsCount;
       
  1525 }
       
  1526 
       
  1527 int CStorageBackupUtil::FillVectorwithMidpPackageTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1528 {
       
  1529     const wstring emptyString;
       
  1530     wstring str;
       
  1531 
       
  1532     JavaStorageEntry attribute;
       
  1533 
       
  1534     /* Initialise Iterators to iterate through all applications
       
  1535        matched with search patterns.  */
       
  1536     JavaStorageApplicationList_t::const_iterator applications;
       
  1537     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1538 
       
  1539     int rowsCount=0;
       
  1540     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1541     {
       
  1542         attribute.setEntry(ID, L"");
       
  1543         str = emptyString;
       
  1544         findIterator = (*applications).find(attribute);
       
  1545 
       
  1546         if (findIterator != (*applications).end())
       
  1547         {
       
  1548             str = (*findIterator).entryValue();
       
  1549         }
       
  1550         iStringVector.push_back(str);
       
  1551 
       
  1552         attribute.setEntry(TYPE, L"");
       
  1553         str = emptyString;
       
  1554         findIterator = (*applications).find(attribute);
       
  1555 
       
  1556         if (findIterator != (*applications).end())
       
  1557         {
       
  1558             str = (*findIterator).entryValue();
       
  1559         }
       
  1560         iStringVector.push_back(str);
       
  1561 
       
  1562         attribute.setEntry(SECURITY_DOMAIN, L"");
       
  1563         str = emptyString;
       
  1564         findIterator = (*applications).find(attribute);
       
  1565 
       
  1566         if (findIterator != (*applications).end())
       
  1567         {
       
  1568             str = (*findIterator).entryValue();
       
  1569         }
       
  1570         iStringVector.push_back(str);
       
  1571 
       
  1572         attribute.setEntry(SECURITY_DOMAIN_CATEGORY, L"");
       
  1573         str = emptyString;
       
  1574         findIterator = (*applications).find(attribute);
       
  1575 
       
  1576         if (findIterator != (*applications).end())
       
  1577         {
       
  1578             str = (*findIterator).entryValue();
       
  1579         }
       
  1580         iStringVector.push_back(str);
       
  1581 
       
  1582         attribute.setEntry(HASH, L"");
       
  1583         str = emptyString;
       
  1584         findIterator = (*applications).find(attribute);
       
  1585 
       
  1586         if (findIterator != (*applications).end())
       
  1587         {
       
  1588             str = (*findIterator).entryValue();
       
  1589         }
       
  1590         iStringVector.push_back(str);
       
  1591 
       
  1592         attribute.setEntry(CERT_HASH, L"");
       
  1593         str = emptyString;
       
  1594         findIterator = (*applications).find(attribute);
       
  1595 
       
  1596         if (findIterator != (*applications).end())
       
  1597         {
       
  1598             str = (*findIterator).entryValue();
       
  1599         }
       
  1600         iStringVector.push_back(str);
       
  1601 
       
  1602         attribute.setEntry(RMS, L"");
       
  1603         str = emptyString;
       
  1604         findIterator = (*applications).find(attribute);
       
  1605 
       
  1606         if (findIterator != (*applications).end())
       
  1607         {
       
  1608             str = (*findIterator).entryValue();
       
  1609         }
       
  1610         iStringVector.push_back(str);
       
  1611 
       
  1612         attribute.setEntry(VALID_CERTS, L"");
       
  1613         str = emptyString;
       
  1614         findIterator = (*applications).find(attribute);
       
  1615 
       
  1616         if (findIterator != (*applications).end())
       
  1617         {
       
  1618             str = (*findIterator).entryValue();
       
  1619         }
       
  1620         iStringVector.push_back(str);
       
  1621 
       
  1622         attribute.setEntry(ON_SCREEN_KEYPAD, L"");
       
  1623         str = emptyString;
       
  1624         findIterator = (*applications).find(attribute);
       
  1625 
       
  1626         if (findIterator != (*applications).end())
       
  1627         {
       
  1628             str = (*findIterator).entryValue();
       
  1629         }
       
  1630         iStringVector.push_back(str);
       
  1631         
       
  1632         attribute.setEntry(SECURITY_WARNINGS, L"");
       
  1633         str = emptyString;
       
  1634         findIterator = (*applications).find(attribute);
       
  1635 
       
  1636         if (findIterator != (*applications).end())
       
  1637         {
       
  1638             str = (*findIterator).entryValue();
       
  1639         }
       
  1640         iStringVector.push_back(str);
       
  1641 
       
  1642         rowsCount++;
       
  1643     }
       
  1644     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1645     return rowsCount;
       
  1646 }
       
  1647 
       
  1648 int CStorageBackupUtil::FillVectorwithMidpPermTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1649 {
       
  1650     const wstring emptyString;
       
  1651     wstring str;
       
  1652 
       
  1653     JavaStorageEntry attribute;
       
  1654 
       
  1655     /* Initialise Iterators to iterate through all applications
       
  1656        matched with search patterns.  */
       
  1657     JavaStorageApplicationList_t::const_iterator applications;
       
  1658     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1659 
       
  1660     int rowsCount=0;
       
  1661     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1662     {
       
  1663         attribute.setEntry(ID, L"");
       
  1664         str = emptyString;
       
  1665         findIterator = (*applications).find(attribute);
       
  1666 
       
  1667         if (findIterator != (*applications).end())
       
  1668         {
       
  1669             str = (*findIterator).entryValue();
       
  1670         }
       
  1671         iStringVector.push_back(str);
       
  1672 
       
  1673         attribute.setEntry(CLASS, L"");
       
  1674         str = emptyString;
       
  1675         findIterator = (*applications).find(attribute);
       
  1676 
       
  1677         if (findIterator != (*applications).end())
       
  1678         {
       
  1679             str = (*findIterator).entryValue();
       
  1680         }
       
  1681         iStringVector.push_back(str);
       
  1682 
       
  1683         attribute.setEntry(NAME, L"");
       
  1684         str = emptyString;
       
  1685         findIterator = (*applications).find(attribute);
       
  1686 
       
  1687         if (findIterator != (*applications).end())
       
  1688         {
       
  1689             str = (*findIterator).entryValue();
       
  1690         }
       
  1691         iStringVector.push_back(str);
       
  1692 
       
  1693         attribute.setEntry(ACTION, L"");
       
  1694         str = emptyString;
       
  1695         findIterator = (*applications).find(attribute);
       
  1696 
       
  1697         if (findIterator != (*applications).end())
       
  1698         {
       
  1699             str = (*findIterator).entryValue();
       
  1700         }
       
  1701         iStringVector.push_back(str);
       
  1702 
       
  1703         attribute.setEntry(FUNCTION_GROUP, L"");
       
  1704         str = emptyString;
       
  1705         findIterator = (*applications).find(attribute);
       
  1706 
       
  1707         if (findIterator != (*applications).end())
       
  1708         {
       
  1709             str = (*findIterator).entryValue();
       
  1710         }
       
  1711         iStringVector.push_back(str);
       
  1712 
       
  1713         rowsCount++;
       
  1714     }
       
  1715     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1716     return rowsCount;
       
  1717 }
       
  1718 
       
  1719 int CStorageBackupUtil::FillVectorwithMidpFuncGrpSetTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1720 {
       
  1721     const wstring emptyString;
       
  1722     wstring str;
       
  1723 
       
  1724     JavaStorageEntry attribute;
       
  1725 
       
  1726     /* Initialise Iterators to iterate through all applications
       
  1727        matched with search patterns.  */
       
  1728     JavaStorageApplicationList_t::const_iterator applications;
       
  1729     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1730 
       
  1731     int rowsCount=0;
       
  1732     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1733     {
       
  1734         attribute.setEntry(ID, L"");
       
  1735         str = emptyString;
       
  1736         findIterator = (*applications).find(attribute);
       
  1737 
       
  1738         if (findIterator != (*applications).end())
       
  1739         {
       
  1740             str = (*findIterator).entryValue();
       
  1741         }
       
  1742         iStringVector.push_back(str);
       
  1743 
       
  1744         attribute.setEntry(FUNCTION_GROUP, L"");
       
  1745         str = emptyString;
       
  1746         findIterator = (*applications).find(attribute);
       
  1747 
       
  1748         if (findIterator != (*applications).end())
       
  1749         {
       
  1750             str = (*findIterator).entryValue();
       
  1751         }
       
  1752         iStringVector.push_back(str);
       
  1753 
       
  1754         attribute.setEntry(ALLOWED_SETTINGS, L"");
       
  1755         str = emptyString;
       
  1756         findIterator = (*applications).find(attribute);
       
  1757 
       
  1758         if (findIterator != (*applications).end())
       
  1759         {
       
  1760             str = (*findIterator).entryValue();
       
  1761         }
       
  1762         iStringVector.push_back(str);
       
  1763 
       
  1764         attribute.setEntry(CURRENT_SETTING, L"");
       
  1765         str = emptyString;
       
  1766         findIterator = (*applications).find(attribute);
       
  1767 
       
  1768         if (findIterator != (*applications).end())
       
  1769         {
       
  1770             str = (*findIterator).entryValue();
       
  1771         }
       
  1772         iStringVector.push_back(str);
       
  1773 
       
  1774         attribute.setEntry(BLANKET_PROMPT, L"");
       
  1775         str = emptyString;
       
  1776         findIterator = (*applications).find(attribute);
       
  1777 
       
  1778         if (findIterator != (*applications).end())
       
  1779         {
       
  1780             str = (*findIterator).entryValue();
       
  1781         }
       
  1782         iStringVector.push_back(str);
       
  1783 
       
  1784         rowsCount++;
       
  1785     }
       
  1786     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1787     return rowsCount;
       
  1788 }
       
  1789 
       
  1790 int CStorageBackupUtil::FillVectorwithPushRegTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1791 {
       
  1792     const wstring emptyString;
       
  1793     wstring str;
       
  1794 
       
  1795     JavaStorageEntry attribute;
       
  1796 
       
  1797     /* Initialise Iterators to iterate through all applications
       
  1798        matched with search patterns.  */
       
  1799     JavaStorageApplicationList_t::const_iterator applications;
       
  1800     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1801 
       
  1802     int rowsCount=0;
       
  1803     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1804     {
       
  1805         attribute.setEntry(ID, L"");
       
  1806         str = emptyString;
       
  1807         findIterator = (*applications).find(attribute);
       
  1808 
       
  1809         if (findIterator != (*applications).end())
       
  1810         {
       
  1811             str = (*findIterator).entryValue();
       
  1812         }
       
  1813         iStringVector.push_back(str);
       
  1814 
       
  1815         attribute.setEntry(URL, L"");
       
  1816         str = emptyString;
       
  1817         findIterator = (*applications).find(attribute);
       
  1818 
       
  1819         if (findIterator != (*applications).end())
       
  1820         {
       
  1821             str = (*findIterator).entryValue();
       
  1822         }
       
  1823         iStringVector.push_back(str);
       
  1824 
       
  1825         attribute.setEntry(NAME, L"");
       
  1826         str = emptyString;
       
  1827         findIterator = (*applications).find(attribute);
       
  1828 
       
  1829         if (findIterator != (*applications).end())
       
  1830         {
       
  1831             str = (*findIterator).entryValue();
       
  1832         }
       
  1833         iStringVector.push_back(str);
       
  1834 
       
  1835         attribute.setEntry(FILTER, L"");
       
  1836         str = emptyString;
       
  1837         findIterator = (*applications).find(attribute);
       
  1838 
       
  1839         if (findIterator != (*applications).end())
       
  1840         {
       
  1841             str = (*findIterator).entryValue();
       
  1842         }
       
  1843         iStringVector.push_back(str);
       
  1844 
       
  1845         attribute.setEntry(REGISTRATION_TYPE, L"");
       
  1846         str = emptyString;
       
  1847         findIterator = (*applications).find(attribute);
       
  1848 
       
  1849         if (findIterator != (*applications).end())
       
  1850         {
       
  1851             str = (*findIterator).entryValue();
       
  1852         }
       
  1853         iStringVector.push_back(str);
       
  1854 
       
  1855         rowsCount++;
       
  1856     }
       
  1857     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1858     return rowsCount;
       
  1859 }
       
  1860 
       
  1861 int CStorageBackupUtil::FillVectorwithAlarmRegTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1862 {
       
  1863     const wstring emptyString;
       
  1864     wstring str;
       
  1865 
       
  1866     JavaStorageEntry attribute;
       
  1867 
       
  1868     /* Initialise Iterators to iterate through all applications
       
  1869        matched with search patterns.  */
       
  1870     JavaStorageApplicationList_t::const_iterator applications;
       
  1871     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1872 
       
  1873     int rowsCount=0;
       
  1874     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1875     {
       
  1876         attribute.setEntry(ID, L"");
       
  1877         str = emptyString;
       
  1878         findIterator = (*applications).find(attribute);
       
  1879 
       
  1880         if (findIterator != (*applications).end())
       
  1881         {
       
  1882             str = (*findIterator).entryValue();
       
  1883         }
       
  1884         iStringVector.push_back(str);
       
  1885 
       
  1886         attribute.setEntry(ALARM_TIME, L"");
       
  1887         str = emptyString;
       
  1888         findIterator = (*applications).find(attribute);
       
  1889 
       
  1890         if (findIterator != (*applications).end())
       
  1891         {
       
  1892             str = (*findIterator).entryValue();
       
  1893         }
       
  1894         iStringVector.push_back(str);
       
  1895 
       
  1896         rowsCount++;
       
  1897     }
       
  1898     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1899     return rowsCount;
       
  1900 }
       
  1901 
       
  1902 int CStorageBackupUtil::FillVectorwithRuntimeSetTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1903 {
       
  1904     const wstring emptyString;
       
  1905     wstring str;
       
  1906 
       
  1907     JavaStorageEntry attribute;
       
  1908 
       
  1909     /* Initialise Iterators to iterate through all applications
       
  1910        matched with search patterns.  */
       
  1911     JavaStorageApplicationList_t::const_iterator applications;
       
  1912     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1913 
       
  1914     int rowsCount=0;
       
  1915     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1916     {
       
  1917         attribute.setEntry(EXTENSIONS, L"");
       
  1918         str = emptyString;
       
  1919         findIterator = (*applications).find(attribute);
       
  1920 
       
  1921         if (findIterator != (*applications).end())
       
  1922         {
       
  1923             str = (*findIterator).entryValue();
       
  1924         }
       
  1925         iStringVector.push_back(str);
       
  1926 
       
  1927         rowsCount++;
       
  1928     }
       
  1929     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1930     return rowsCount;
       
  1931 }
       
  1932 
       
  1933 int CStorageBackupUtil::FillVectorwithPreinstallTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1934 {
       
  1935     const wstring emptyString;
       
  1936     wstring str;
       
  1937 
       
  1938     JavaStorageEntry attribute;
       
  1939 
       
  1940     /* Initialise Iterators to iterate through all applications
       
  1941        matched with search patterns.  */
       
  1942     JavaStorageApplicationList_t::const_iterator applications;
       
  1943     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  1944 
       
  1945     int rowsCount=0;
       
  1946     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  1947     {
       
  1948         attribute.setEntry(NAME, L"");
       
  1949         str = emptyString;
       
  1950         findIterator = (*applications).find(attribute);
       
  1951 
       
  1952         if (findIterator != (*applications).end())
       
  1953         {
       
  1954             str = (*findIterator).entryValue();
       
  1955         }
       
  1956         iStringVector.push_back(str);
       
  1957 
       
  1958         attribute.setEntry(VENDOR, L"");
       
  1959         str = emptyString;
       
  1960         findIterator = (*applications).find(attribute);
       
  1961 
       
  1962         if (findIterator != (*applications).end())
       
  1963         {
       
  1964             str = (*findIterator).entryValue();
       
  1965         }
       
  1966         iStringVector.push_back(str);
       
  1967 
       
  1968         attribute.setEntry(VERSION, L"");
       
  1969         str = emptyString;
       
  1970         findIterator = (*applications).find(attribute);
       
  1971 
       
  1972         if (findIterator != (*applications).end())
       
  1973         {
       
  1974             str = (*findIterator).entryValue();
       
  1975         }
       
  1976         iStringVector.push_back(str);
       
  1977 
       
  1978         attribute.setEntry(INSTALL_STATE, L"");
       
  1979         str = emptyString;
       
  1980         findIterator = (*applications).find(attribute);
       
  1981 
       
  1982         if (findIterator != (*applications).end())
       
  1983         {
       
  1984             str = (*findIterator).entryValue();
       
  1985         }
       
  1986         iStringVector.push_back(str);
       
  1987 
       
  1988         rowsCount++;
       
  1989     }
       
  1990     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  1991     return rowsCount;
       
  1992 }
       
  1993 
       
  1994 int CStorageBackupUtil::FillVectorwithOtaStatusTableData(JavaStorageApplicationList_t& afoundEntries)
       
  1995 {
       
  1996     const wstring emptyString;
       
  1997     wstring str;
       
  1998 
       
  1999     JavaStorageEntry attribute;
       
  2000 
       
  2001     /* Initialise Iterators to iterate through all applications
       
  2002        matched with search patterns.  */
       
  2003     JavaStorageApplicationList_t::const_iterator applications;
       
  2004     JavaStorageApplicationEntry_t::const_iterator findIterator;
       
  2005 
       
  2006     int rowsCount=0;
       
  2007     for (applications = afoundEntries.begin(); applications != afoundEntries.end(); applications++)
       
  2008     {
       
  2009         attribute.setEntry(ID, L"");
       
  2010         str = emptyString;
       
  2011         findIterator = (*applications).find(attribute);
       
  2012 
       
  2013         if (findIterator != (*applications).end())
       
  2014         {
       
  2015             str = (*findIterator).entryValue();
       
  2016         }
       
  2017         iStringVector.push_back(str);
       
  2018 
       
  2019         attribute.setEntry(CREATION_TIME, L"");
       
  2020         str = emptyString;
       
  2021         findIterator = (*applications).find(attribute);
       
  2022 
       
  2023         if (findIterator != (*applications).end())
       
  2024         {
       
  2025             str = (*findIterator).entryValue();
       
  2026         }
       
  2027         iStringVector.push_back(str);
       
  2028 
       
  2029         attribute.setEntry(TYPE, L"");
       
  2030         str = emptyString;
       
  2031         findIterator = (*applications).find(attribute);
       
  2032 
       
  2033         if (findIterator != (*applications).end())
       
  2034         {
       
  2035             str = (*findIterator).entryValue();
       
  2036         }
       
  2037         iStringVector.push_back(str);
       
  2038 
       
  2039         attribute.setEntry(OTA_CODE, L"");
       
  2040         str = emptyString;
       
  2041         findIterator = (*applications).find(attribute);
       
  2042 
       
  2043         if (findIterator != (*applications).end())
       
  2044         {
       
  2045             str = (*findIterator).entryValue();
       
  2046         }
       
  2047         iStringVector.push_back(str);
       
  2048 
       
  2049         attribute.setEntry(URL, L"");
       
  2050         str = emptyString;
       
  2051         findIterator = (*applications).find(attribute);
       
  2052 
       
  2053         if (findIterator != (*applications).end())
       
  2054         {
       
  2055             str = (*findIterator).entryValue();
       
  2056         }
       
  2057         iStringVector.push_back(str);
       
  2058 
       
  2059         attribute.setEntry(LATEST_RETRY_TIME, L"");
       
  2060         str = emptyString;
       
  2061         findIterator = (*applications).find(attribute);
       
  2062 
       
  2063         if (findIterator != (*applications).end())
       
  2064         {
       
  2065             str = (*findIterator).entryValue();
       
  2066         }
       
  2067         iStringVector.push_back(str);
       
  2068 
       
  2069         attribute.setEntry(RETRY_COUNT, L"");
       
  2070         str = emptyString;
       
  2071         findIterator = (*applications).find(attribute);
       
  2072 
       
  2073         if (findIterator != (*applications).end())
       
  2074         {
       
  2075             str = (*findIterator).entryValue();
       
  2076         }
       
  2077         iStringVector.push_back(str);
       
  2078 
       
  2079         rowsCount++;
       
  2080     }
       
  2081     ILOG1(EBackup, "for loop crossed with i = %d", rowsCount);
       
  2082     return rowsCount;
       
  2083 }
       
  2084