securitydialogs/Autolock/src/AutolockApp.cpp
changeset 17 8957df7b0072
parent 0 164170e6151a
equal deleted inserted replaced
15:318c4eab2439 17:8957df7b0072
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include    "AutolockApp.h"
    20 #include    "AutolockApp.h"
    21 #include    "AutolockDocument.h"
    21 #include    "AutolockDocument.h"
    22 #include <eikstart.h>
    22 #include <eikstart.h>
    23 
    23 #include <apgcli.h>
       
    24 #include <apgtask.h>
       
    25 #include <coemain.h>
       
    26 #include <apacmdln.h>
    24 
    27 
    25 // ================= MEMBER FUNCTIONS =======================
    28 // ================= MEMBER FUNCTIONS =======================
    26 
    29 
    27 // ---------------------------------------------------------
    30 // ---------------------------------------------------------
    28 // CAutolockApp::AppDllUid()
    31 // CAutolockApp::AppDllUid()
    39 // Creates CAutolockDocument object
    42 // Creates CAutolockDocument object
    40 // ---------------------------------------------------------
    43 // ---------------------------------------------------------
    41 //
    44 //
    42 CApaDocument* CAutolockApp::CreateDocumentL()
    45 CApaDocument* CAutolockApp::CreateDocumentL()
    43     {
    46     {
       
    47     RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
    44     return CAutolockDocument::NewL( *this );
    48     return CAutolockDocument::NewL( *this );
    45     }
    49     }
    46 
    50 
    47 // ================= OTHER EXPORTED FUNCTIONS ==============
    51 // ================= OTHER EXPORTED FUNCTIONS ==============
    48 //
    52 //
    49 
    53 
    50 LOCAL_C CApaApplication* NewApplication()
    54 LOCAL_C CApaApplication* NewApplication()
    51     {
    55     {
       
    56     	RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    57 
       
    58     TInt use_old_autolock=1;
       
    59     if(use_old_autolock)
       
    60     	{
       
    61 			// start autolocksrv instead of autolock . This is a backup solution to use in case that not all SysAp and Avkon changes are implemented
       
    62 	 	  RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
       
    63 	 	  CCoeEnv *env = CCoeEnv::Static();
       
    64 	    TApaTaskList taskList( env->WsSession() );
       
    65 	    RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    66     	const TUid KAutolockSrvAppUid = { 0xE0022E73 };
       
    67 	    TApaTask task( taskList.FindApp( KAutolockSrvAppUid ) );
       
    68 	    RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    69 	    if ( !task.Exists() )
       
    70 	        {
       
    71 	    		RDebug::Printf( "%s %s (%u) no KAutolockSrvAppUid found. Creating=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    72 	        RApaLsSession ls;                   
       
    73 	        User::LeaveIfError(ls.Connect());   
       
    74 	        CleanupClosePushL(ls);         
       
    75 	        
       
    76 	        CApaCommandLine* commandLine = CApaCommandLine::NewLC();
       
    77 	        commandLine->SetExecutableNameL( _L("autolocksrv.exe" ) );     
       
    78 	        commandLine->SetCommandL( EApaCommandRun );
       
    79 	        
       
    80 		    // Try to launch the application.        
       
    81 	        User::LeaveIfError(ls.StartApp(*commandLine));
       
    82 	    	  RDebug::Printf( "%s %s (%u) autolocksrv.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x7 );
       
    83 	        
       
    84 	        CleanupStack::PopAndDestroy(2); // commandLine, ls
       
    85 			}
       
    86 	   }
       
    87 		RDebug::Printf( "%s %s (%u) exiting=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
    52     return new CAutolockApp;
    88     return new CAutolockApp;
    53     }
    89     }
    54 
    90 
    55 GLDEF_C TInt E32Main()
    91 GLDEF_C TInt E32Main()
    56     {
    92     {
       
    93     RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    94 
    57     return EikStart::RunApplication(NewApplication);
    95     return EikStart::RunApplication(NewApplication);
    58     }
    96     }
    59 
    97 
    60 // End of File  
    98 // End of File  
    61 
    99