upnpharvester/common/cmlibrary/src/cmcommonutils.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2008 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 common utility class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include <f32file.h>
       
    24 #include <bautils.h>
       
    25 #include <eikenv.h>
       
    26 #include <AknUtils.h>
       
    27 #include <commdb.h>
       
    28 #include <WlanCdbCols.h>
       
    29 #include <wlanmgmtclient.h>
       
    30 #include <pathinfo.h>
       
    31 
       
    32 #include "cmcommonutils.h"
       
    33 #include "msdebug.h"
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CmCommonUtils::LoadResourceFileL
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C TInt CmCommonUtils::LoadResourceFileL( const TDesC& aFilePath,
       
    40                                                 CEikonEnv& eikonEnv )
       
    41     {
       
    42     LOG(_L("[CmCommonUtils]\t CmCommonUtils::LoadResourceFileL"));
       
    43         
       
    44     TInt resFileOffset( 0 );
       
    45             
       
    46     RFs& fileSession = eikonEnv.FsSession();
       
    47 
       
    48     // Load resource file
       
    49     TFileName rscFileName( aFilePath );
       
    50     TInt err = CompleteWithAppPath( rscFileName );
       
    51     if ( err != KErrNone )
       
    52         {
       
    53         User::LeaveIfError( err);
       
    54         }
       
    55 
       
    56     // Get the exact filename of the resource file
       
    57     BaflUtils::NearestLanguageFile( fileSession, rscFileName );
       
    58     // Check if the resource file exists or not
       
    59     if ( !BaflUtils::FileExists( fileSession, rscFileName ) )
       
    60         {
       
    61         User::Leave( KErrNotFound );
       
    62         }
       
    63     
       
    64     TRAP( err, resFileOffset = eikonEnv.AddResourceFileL( rscFileName ) );
       
    65     if ( err != KErrNone )
       
    66         {
       
    67         // try memory card drive
       
    68         rscFileName.Copy( PathInfo::MemoryCardRootPath() );
       
    69         rscFileName.Delete( 2, 2 ); // remove '//'
       
    70         rscFileName.Append( aFilePath );
       
    71         resFileOffset = eikonEnv.AddResourceFileL( rscFileName );
       
    72         }
       
    73     
       
    74     return resFileOffset;    
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CmCommonUtils::SetWlanScanL
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C void CmCommonUtils::SetWlanScanL( const TInt aInterval )
       
    82     {
       
    83     LOG(_L("[CmCommonUtils]\t CmCommonUtils::SetWlanScanL"));
       
    84 
       
    85 #ifndef __WINS__
       
    86 
       
    87     // open commsdb
       
    88     CCommsDatabase* commsDb = CCommsDatabase::NewL();
       
    89     CleanupStack::PushL( commsDb );
       
    90 
       
    91     // open wlan table
       
    92     CCommsDbTableView* view = commsDb->OpenViewMatchingUintLC
       
    93         (
       
    94         TPtrC( WLAN_DEVICE_SETTINGS ),
       
    95         TPtrC( WLAN_DEVICE_SETTINGS_TYPE ), KWlanUserSettings
       
    96         );
       
    97 
       
    98     User::LeaveIfError( view->GotoFirstRecord() );
       
    99     User::LeaveIfError( view->UpdateRecord() );
       
   100 
       
   101     // set scan interval
       
   102     view->WriteUintL( TPtrC( WLAN_BG_SCAN_INTERVAL ), aInterval );
       
   103 
       
   104     view->WriteBoolL( TPtrC( WLAN_ALLOW_RADIO_MEASUREMENTS ), ETrue );
       
   105     view->WriteBoolL( TPtrC( WLAN_POWER_MODE ), EFalse );
       
   106     User::LeaveIfError( view->PutRecordChanges() );
       
   107 
       
   108     CleanupStack::PopAndDestroy( view );
       
   109     CleanupStack::PopAndDestroy( commsDb );
       
   110 
       
   111     CWlanMgmtClient* wlanMgmtClient = CWlanMgmtClient::NewL();
       
   112     CleanupStack::PushL( wlanMgmtClient );
       
   113     // notify about changes
       
   114     wlanMgmtClient->NotifyChangedSettings();
       
   115     CleanupStack::PopAndDestroy( wlanMgmtClient );
       
   116 #endif
       
   117     }
       
   118     
       
   119 // End of file