securitydialogs/Autolock/src/AutolockApp.cpp
branchGCC_SURGE
changeset 40 604cd42065d1
parent 29 b63e8c2d8cff
parent 38 e0432375ea67
equal deleted inserted replaced
29:b63e8c2d8cff 40:604cd42065d1
     1 /*
       
     2 * Copyright (c) 2002 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 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "AutolockApp.h"
       
    21 #include    "AutolockDocument.h"
       
    22 #include <eikstart.h>
       
    23 #include <apgcli.h>
       
    24 #include <apgtask.h>
       
    25 #include <coemain.h>
       
    26 #include <apacmdln.h>
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // CAutolockApp::AppDllUid()
       
    32 // Returns application UID
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 TUid CAutolockApp::AppDllUid() const
       
    36     {
       
    37     return KUidAutolock;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // CAutolockApp::CreateDocumentL()
       
    42 // Creates CAutolockDocument object
       
    43 // ---------------------------------------------------------
       
    44 //
       
    45 CApaDocument* CAutolockApp::CreateDocumentL()
       
    46     {
       
    47     RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    48     return CAutolockDocument::NewL( *this );
       
    49     }
       
    50 
       
    51 // ================= OTHER EXPORTED FUNCTIONS ==============
       
    52 //
       
    53 
       
    54 LOCAL_C CApaApplication* NewApplication()
       
    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 );
       
    88     return new CAutolockApp;
       
    89     }
       
    90 
       
    91 GLDEF_C TInt E32Main()
       
    92     {
       
    93     RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    94 
       
    95     return EikStart::RunApplication(NewApplication);
       
    96     }
       
    97 
       
    98 // End of File  
       
    99