fotaapplication/fotaserver/FotaRfsPlugin/src/RfsFotaPlugin.cpp
branchRCL_3
changeset 26 19bba8228ff0
parent 0 b497e44ab2fc
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 fotaserver component
       
    15 * 	This is part of fotaapplication.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "RfsFotaPlugin.h"
       
    23 #include "fotadebug.h"
       
    24 
       
    25 _LIT(KScriptPath, "");
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CRfsFotaPlugin::CRfsFotaPlugin()
       
    34     {
       
    35     FLOG(_L("CRfsFotaPlugin::CRfsFotaPlugin()"));
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // constructor
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CRfsFotaPlugin::CRfsFotaPlugin(TAny* /*aInitParams*/)
       
    43     {
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // destructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CRfsFotaPlugin::~CRfsFotaPlugin()
       
    51     {
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CRfsFotaPlugin::NewL
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CRfsFotaPlugin* CRfsFotaPlugin::NewL(TAny* aInitParams)
       
    59     {
       
    60     FLOG(_L("CRfsFotaPlugin::NewL()"));
       
    61     CRfsFotaPlugin* self = new (ELeave) CRfsFotaPlugin(aInitParams);
       
    62     CleanupStack::PushL(self);
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop();
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CRfsFotaPlugin::ConstructL
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CRfsFotaPlugin::ConstructL()
       
    74     {
       
    75     FLOG(_L("CRfsFotaPlugin::ConstructL()"));
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CRfsFotaPlugin::RestoreFactorySettingsL
       
    81 // Handle rfs. Must reserve disk space to keep user from filling it. 
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CRfsFotaPlugin::RestoreFactorySettingsL( const TRfsReason aType )
       
    85     {
       
    86     FLOG(_L("CRfsFotaPlugin::RestoreFactorySettingsL(%d)"), aType);
       
    87 
       
    88     if ( aType == ENormalRfs ) 
       
    89         {
       
    90         FLOG(_L(" ERROR - NORMAL RFS (Only FirstBoot RFS is ordered) "));
       
    91         }
       
    92     if ( aType == EDeepRfs   ) 
       
    93         { 
       
    94         FLOG(_L(" ERROR - DEEP   RFS (Only FirstBoot RFS is ordered) "));
       
    95         }
       
    96 
       
    97     LoadStoragePluginL ();
       
    98     iStorage->AdjustDummyStorageL () ;
       
    99 
       
   100     UnLoadStoragePluginL();
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CRfsFotaPlugin::GetScriptL
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CRfsFotaPlugin::GetScriptL( const TRfsReason /*aType*/, TDes& aPath )
       
   109     {
       
   110     FLOG(_L("CRfsFotaPlugin::GetScriptL"));
       
   111     aPath.Copy( KScriptPath);
       
   112     }
       
   113 
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CRfsFotaPlugin::ExecuteCustomCommandL
       
   117 // ---------------------------------------------------------------------------
       
   118 void CRfsFotaPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/,
       
   119                                         TDesC& /*aCommand*/ )
       
   120     {
       
   121     FLOG(_L("CRfsFotaPlugin::ExecuteCustomCommandL"));
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CRfsFotaPlugin::LoadStoragePluginL 
       
   127 // Load update storage plugin via ecom framework.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CRfsFotaPlugin::LoadStoragePluginL ()
       
   131     {
       
   132     FLOG(_L("CRfsFotaPlugin::LoadStoragePluginL"));
       
   133     if(iStorage)
       
   134         {
       
   135         UnLoadStoragePluginL ();
       
   136         }
       
   137     TUid                if_uid;
       
   138     if_uid.iUid =  (0x10207384);
       
   139     RImplInfoPtrArray   pluginArray;
       
   140     REComSession::ListImplementationsL( if_uid, pluginArray );
       
   141     CleanupClosePushL (pluginArray);
       
   142 
       
   143     if( pluginArray.Count() )
       
   144         {
       
   145         for( TInt i = 0; i < pluginArray.Count(); i++ )
       
   146             {
       
   147             CImplementationInformation* info = pluginArray[ i ];
       
   148             TUid id = info->ImplementationUid();
       
   149             delete info;
       
   150             info = NULL;
       
   151             iStorage =(CFotaStorage*) REComSession::CreateImplementationL(
       
   152                                         id , iStorageDtorKey); 
       
   153             }
       
   154         }
       
   155     else
       
   156         {
       
   157         FLOG(_L("  storage plugin not found, ERROR"));
       
   158         User::Leave ( KErrNotFound );
       
   159         }
       
   160     CleanupStack::PopAndDestroy(1); // array 
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CRfsFotaPlugin::UnLoadStoragePluginL
       
   166 // Unloads storage plugin
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CRfsFotaPlugin::UnLoadStoragePluginL ()
       
   170     {
       
   171     FLOG(_L("CRfsFotaPlugin::UnLoadStoragePluginL"));
       
   172     if(iStorage != NULL) 
       
   173         {
       
   174         delete iStorage;
       
   175         iStorage=0;
       
   176         }
       
   177     REComSession::DestroyedImplementation(iStorageDtorKey); // sets reference count of plugin to 0
       
   178     REComSession::FinalClose();
       
   179     }
       
   180 
       
   181 // End of file