menucontentsrv/src/menuutil.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "menuutil.h"
       
    21 #include "menulogger.h"
       
    22 
       
    23 #include <s32strm.h>
       
    24 #include <e32property.h>
       
    25 #include <connect/sbdefs.h>
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // MenuUtil::ExternalizeL
       
    31 // ---------------------------------------------------------
       
    32 //
       
    33 void MenuUtil::ExternalizeL
       
    34 ( const RArray<TInt>& aArray, RWriteStream& aStream )
       
    35     {
       
    36     aStream.WriteInt32L( aArray.Count() );
       
    37     for ( TInt i = 0; i < aArray.Count(); i++ )
       
    38         {
       
    39         aStream.WriteInt32L( aArray[i] );
       
    40         }
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------
       
    44 // MenuUtil::InternalizeL
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 void MenuUtil::InternalizeL
       
    48 ( RArray<TInt>& aArray, RReadStream& aStream )
       
    49     {
       
    50     TInt count = aStream.ReadInt32L();
       
    51     for ( TInt i = 0; i < count; i++ )
       
    52         {
       
    53         aArray.AppendL( aStream.ReadInt32L() );
       
    54         }
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // MenuUtil::ExternalizeL
       
    59 // ---------------------------------------------------------
       
    60 //
       
    61 void MenuUtil::ExternalizeL
       
    62 ( const RArray<TUid>& aArray, RWriteStream& aStream )
       
    63     {
       
    64     aStream.WriteInt32L( aArray.Count() );
       
    65     for ( TInt i = 0; i < aArray.Count(); i++ )
       
    66         {
       
    67         aStream.WriteInt32L( aArray[i].iUid );
       
    68         }
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // MenuUtil::InternalizeL
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void MenuUtil::InternalizeL
       
    76 ( RArray<TUid>& aArray, RReadStream& aStream )
       
    77     {
       
    78     TInt count = aStream.ReadInt32L();
       
    79     for ( TInt i = 0; i < count; i++ )
       
    80         {
       
    81         aArray.AppendL( TUid::Uid(aStream.ReadInt32L()) );
       
    82         }
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // MenuUtil::ExternalizeL
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 void MenuUtil::ExternalizeL
       
    90 ( const RArray<TMenuItem>& aArray, RWriteStream& aStream )
       
    91     {
       
    92     aStream.WriteInt32L( aArray.Count() );
       
    93     for ( TInt i = 0; i < aArray.Count(); i++ )
       
    94         {
       
    95         aArray[i].ExternalizeL( aStream );
       
    96         }
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------
       
   100 // MenuUtil::InternalizeL
       
   101 // ---------------------------------------------------------
       
   102 //
       
   103 void MenuUtil::InternalizeL
       
   104 ( RArray<TMenuItem>& aArray, RReadStream& aStream )
       
   105     {
       
   106     TMenuItem hdr;
       
   107     TInt count = aStream.ReadInt32L();
       
   108     for ( TInt i = 0; i < count; i++ )
       
   109         {
       
   110         hdr.InternalizeL( aStream );
       
   111         aArray.AppendL( hdr );
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------
       
   116 // MenuUtil::BackupInProgressL
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 TBool MenuUtil::BackupInProgressL()
       
   120     {
       
   121     TBool backupInProgress( EFalse );
       
   122     TInt backupRestoreStatus( 0 );
       
   123     const TInt err = RProperty::Get( KUidSystemCategory, 
       
   124         					         conn::KUidBackupRestoreKey,
       
   125         					         backupRestoreStatus );
       
   126 
       
   127     if( err )
       
   128         {
       
   129         CLOG_WRITE_FORMAT8( "B&R error: %d", err );
       
   130         if( KErrNotFound != err )
       
   131             {
       
   132             User::Leave( err );
       
   133             }
       
   134         }
       
   135     else
       
   136     	{
       
   137     	CLOG_WRITE_FORMAT8( "B&R status: 0x%x", backupRestoreStatus );
       
   138 	    if( backupRestoreStatus == conn::EBURUnset || 
       
   139 	        backupRestoreStatus & conn::EBURNormal ||
       
   140 	        (backupRestoreStatus & conn::KBackupIncTypeMask) == conn::ENoBackup)
       
   141 	        {
       
   142 	        backupInProgress = EFalse;
       
   143 	        }
       
   144 	    else
       
   145 	        {
       
   146 	        backupInProgress = ETrue;
       
   147 	        }
       
   148     	}
       
   149     	
       
   150     return backupInProgress;
       
   151     }
       
   152 
       
   153 //  End of File