apicompatanamdw/bcdrivers/os/devicesrv/SystemSW/preconfigautomation/vibration.cpp
changeset 2 0cb2248d0edc
equal deleted inserted replaced
1:61e9400fe245 2:0cb2248d0edc
       
     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 // vibration.cpp
       
    18 //
       
    19 // Created: 09/17/08
       
    20 // Author:  
       
    21 // Copyright (c) . All rights reserved.
       
    22 //
       
    23 
       
    24 #include "CommonFramework.h"
       
    25 #include <centralrepository.h>
       
    26 #include <HWRMVibraSDKCRKeys.h>
       
    27 #include <f32file.h> 
       
    28 
       
    29 #include <mproengengine.h>
       
    30 #include <mproengprofile.h>
       
    31 #include <ProEngFactory.h>
       
    32 #include <MProEngToneSettings.h>
       
    33 // do the example
       
    34 LOCAL_C void doExampleL()
       
    35     {
       
    36     
       
    37 	_LIT(KVibraOnText,"Turned vibration settings to ON!\n");
       
    38 
       
    39 /*
       
    40 //	TUid KCRUidVibraCtrl;
       
    41 //	KCRUidVibraCtrl.iUid = (0x10200C8B);
       
    42 //	TUint32 KVibra(0x00000001);
       
    43 	TInt val(1);
       
    44 	TInt getVal(-1);
       
    45 	CRepository* repository = CRepository::NewL(KCRUidVibraCtrl);
       
    46 	//check the vibration status
       
    47 	TInt ret = repository->Get(KVibraCtrlProfileVibraEnabled,getVal);
       
    48 //	ret = repository->Set(KVibraCtrlProfileVibraEnabled,val);
       
    49 	// if vibration is OFF turn it to ON
       
    50 	if( 0 == getVal)
       
    51 	{
       
    52 		console->Printf(_L("before SET method"));		
       
    53 		TInt ret = repository->Set(KVibraCtrlProfileVibraEnabled,val);
       
    54 		console->Printf(_L("after SET method"));		
       
    55 	}
       
    56 	
       
    57 	ret = repository->Get(KVibraCtrlProfileVibraEnabled,getVal);
       
    58 	if( 1 == getVal )
       
    59 	{
       
    60 		console->Printf(KVibraOnText);	
       
    61 	}
       
    62 	delete repository;
       
    63 	
       
    64 */	
       
    65 	
       
    66 	TFileName path( _L("c:\\logs\\TestFramework\\SystemSW\\vibration_Preconfig.txt"));
       
    67 	RFile file;
       
    68 	RFs fileSession;
       
    69 	TInt err = fileSession.Connect(); 
       
    70 	
       
    71 	fileSession.MkDirAll(_L("c:\\logs\\TestFramework\\SystemSW\\"));
       
    72 	err = file.Replace(fileSession, path, EFileStreamText | EFileWrite);
       
    73 	
       
    74 	
       
    75 	file.Write(_L8("PreConfig file of vibration ON application\n"));
       
    76 	
       
    77 	
       
    78 	TBool vibraSettings(1);
       
    79 	CActiveScheduler *vibraScheduler = new(ELeave) CActiveScheduler();
       
    80 	CleanupStack::PushL(vibraScheduler );
       
    81 	CActiveScheduler::Install(vibraScheduler );
       
    82 	
       
    83 	MProEngEngine* profileEngine = ProEngFactory::NewEngineL();
       
    84 	CleanupReleasePushL( *profileEngine );
       
    85 
       
    86 	MProEngProfile* profile = profileEngine->ActiveProfileL();
       
    87 	CleanupReleasePushL( *profile );
       
    88 
       
    89 	MProEngToneSettings& sett = profile->ToneSettings();
       
    90 
       
    91 	TInt ret = sett.SetVibratingAlert( vibraSettings );
       
    92 
       
    93 	TRAPD(res,profile->CommitChangeL());
       
    94 
       
    95 	TBool retval = sett.VibratingAlert();
       
    96 	if (KErrNone == ret && retval )
       
    97 	    {
       
    98         file.Write(_L8("preconfig result : passed\n"));
       
    99 	    }
       
   100 	else
       
   101 	    {
       
   102 	    file.Write(_L8("preconfig result : failed\n"));
       
   103 	    }
       
   104 	CleanupStack::PopAndDestroy( profile );
       
   105 	CleanupStack::PopAndDestroy( profileEngine );
       
   106 	CleanupStack::PopAndDestroy(vibraScheduler );
       
   107 	file.Close();
       
   108 	fileSession.Close();
       
   109 
       
   110 	}