presetserver/rfspluginsrc/Psrfsplugin.cpp
changeset 0 09774dfdd46b
child 14 896e9dbc5f19
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:  Preset Server RFS ECOM plugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "psdebug.h"
       
    20 #include "psrfsplugin.h"
       
    21 #include <bautils.h>
       
    22 
       
    23 _LIT( KPSDatabaseFileName, "pspresets.db" );    // File name of the preset database.
       
    24 #if defined __SERIES60_30__ || defined __SERIES60_31__
       
    25 _LIT( KPSDatabasePath, "\\data\\" );    // File name of the preset database.
       
    26 #else
       
    27 _LIT( KPSDatabasePath, "\\private\\10281cb5\\" );            // File name of the preset database.
       
    28 #endif
       
    29 
       
    30 // ======== LOCAL FUNCTIONS ========
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Two-phased constructor.
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CPSRfsPlugin* CPSRfsPlugin::NewL( TAny* aInitParams )
       
    39     {
       
    40     CPSRfsPlugin* self = new ( ELeave ) CPSRfsPlugin( aInitParams );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Constructor.
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CPSRfsPlugin::CPSRfsPlugin( TAny* /*aInitParams*/ )
       
    52     {
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Second-phase constructor.
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CPSRfsPlugin::ConstructL()
       
    60     {
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Destructor.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CPSRfsPlugin::~CPSRfsPlugin()
       
    68     {
       
    69     // Base class handles the ECOM cleanup.
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // From base class CRFSPlugin
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void CPSRfsPlugin::RestoreFactorySettingsL( const TRfsReason aType )
       
    77     {
       
    78     PSDEBUG(" *** CPSRfsPlugin::RestoreFactorySettingsL - Enter" );
       
    79     if ( aType == ENormalRfs )
       
    80         {
       
    81         PSDEBUG(" *** CPSRfsPlugin::RestoreFactorySettingsL - Deleting Preset Server files" );
       
    82 
       
    83         TFileName databaseFullName( KPSDatabaseFileName );
       
    84          
       
    85         RFs fsSession;
       
    86         User::LeaveIfError( fsSession.Connect() );
       
    87         CleanupClosePushL( fsSession );
       
    88         
       
    89         TInt err = ResolveDrive( fsSession, databaseFullName, KPSDatabasePath() );
       
    90         
       
    91         if ( err == KErrNone )
       
    92             {
       
    93             err = fsSession.Delete( databaseFullName );
       
    94             PSDEBUG3(" *** CPSRfsPlugin::RestoreFactorySettingsL - Deleted preset database (file = %S, err = %d)", &databaseFullName, err );
       
    95             }
       
    96         else
       
    97             {
       
    98             PSDEBUG2(" *** CPSRfsPlugin::RestoreFactorySettingsL - err = %d)", err );
       
    99             }
       
   100         CleanupStack::PopAndDestroy( &fsSession );
       
   101         }
       
   102     else
       
   103         {
       
   104         PSDEBUG2(" *** CPSRfsPlugin::RestoreFactorySettingsL - RFS type (%d) not supported", static_cast<TInt>( aType ) );
       
   105         }
       
   106     PSDEBUG(" *** CPSRfsPlugin::RestoreFactorySettingsL - Exit" );
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // From base class CRFSPlugin
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CPSRfsPlugin::GetScriptL( const TRfsReason /*aType*/, TDes& aPath )
       
   114     {
       
   115     aPath.Zero();
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // From base class CRFSPlugin
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CPSRfsPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/, TDesC& /*aCommand*/ )
       
   123     {
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // ResolveDrive
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 TInt CPSRfsPlugin::ResolveDrive( RFs& aFs, TFileName& aFileName, const TFileName& aPath )
       
   131     {
       
   132     PSDEBUG3( "*** CPSRfsPlugin::ResolveDrive( aFileName = %S, aPath = %s )", &aFileName, &aPath );
       
   133 
       
   134     TFindFile finder( aFs );
       
   135     TInt err = finder.FindByDir( aFileName, aPath );
       
   136     if ( err )
       
   137         {
       
   138         PSDEBUG3( "*** CPSRfsPlugin::ResolveDrive - File '%S%S' not found!", &aPath, &aFileName );
       
   139         return KErrNotFound;
       
   140         }
       
   141     
       
   142     aFileName.Copy( finder.File() );
       
   143     PSDEBUG2("*** CPSRfsPlugin::ResolveDrive( aFileName = %S )", &aFileName );
       
   144     return KErrNone;
       
   145     }
       
   146 // ======== GLOBAL FUNCTIONS ========
       
   147