securitydialogs/lockapp/src/lockapp.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
child 23 94da73d93b58
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
     1 /*
       
     2  * Copyright (c) 2000 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: Very small version of lockapp, which simply launches Autolock
       
    15  * This is needed becauses starter has the hardcoded name "lockapp"
       
    16  *
       
    17  */
       
    18 
       
    19 // INCLUDES
       
    20 
       
    21 #include <e32svr.h>
       
    22 #include <centralrepository.h>
       
    23 
       
    24 #include <aknglobalpopupprioritycontroller.h>
       
    25 #include <apgcli.h>
       
    26 #include <apgtask.h>
       
    27 #include <eikenv.h>
       
    28 #include <e32property.h>
       
    29 #include <secuisecuritysettings.h>
       
    30 #include <coreapplicationuisdomainpskeys.h>
       
    31 
       
    32 // ----------------------------------------------------------------------------------------
       
    33 // Server startup code
       
    34 // ----------------------------------------------------------------------------------------
       
    35 static void RunServerL()
       
    36     {
       
    37     CActiveScheduler* s = new (ELeave) CActiveScheduler;
       
    38     CleanupStack::PushL(s);
       
    39     CActiveScheduler::Install(s);
       
    40 
       
    41     // start autolock instead of lockapp . This is a backup solution to use in case that not all SysAp and Avkon changes are implemented
       
    42     /* No need to check the task. A process should not run twice
       
    43      TApaTaskList taskList( CCoeEnv::Static()->WsSession() );	// can also use CCoeEnv::Static()	CEikonEnv::Static()
       
    44      const TUid KAutolockSrvAppUid = { 0x100059B5 };
       
    45      TApaTask task( taskList.FindApp( KAutolockSrvAppUid ) );
       
    46      if( !task.Exists())
       
    47      */
       
    48 
       
    49     RApaLsSession ls;
       
    50     User::LeaveIfError(ls.Connect());
       
    51     CleanupClosePushL(ls);
       
    52 
       
    53 		/************/
       
    54     _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData);
       
    55     TInt ret = RProperty::Define(KPSUidCoreApplicationUIs,
       
    56             KCoreAppUIsAutolockStatus, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
       
    57             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
       
    58 
       
    59     TInt autolockState;
       
    60     RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
       
    61     if(autolockState==EAutolockStatusUninitialized)
       
    62     	{
       
    63     	autolockState = EAutolockOff;	// not-initialized means that the unlock-query hasn't been displayed. Therefore the device should not stay locked.
       
    64     	}
       
    65     ret = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus,	
       
    66                    autolockState);	// this might re-set it. That's not bad. It will re-notify all listeners.
       
    67     RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
       
    68     RDebug::Printf("%s %s (%u) autolockState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, autolockState);
       
    69 		/************/
       
    70 
       
    71     CApaCommandLine* commandLine = CApaCommandLine::NewLC();
       
    72     commandLine->SetExecutableNameL(_L("autolock.exe"));
       
    73     commandLine->SetCommandL(EApaCommandRun);
       
    74     // Try to launch the application.        
       
    75     TInt err = ls.StartApp(*commandLine); // this migh fail
       
    76     RDebug::Printf("%s %s (%u) Start: autolock.exe err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err);
       
    77 
       
    78     CleanupStack::PopAndDestroy(2); // commandLine, ls
       
    79 
       
    80     // Initialisation complete, now signal the client
       
    81     RProcess::Rendezvous( KErrNone);
       
    82 
       
    83     // Ready to run
       
    84     CActiveScheduler::Start();
       
    85 
       
    86     // Cleanup the server and scheduler
       
    87     CleanupStack::PopAndDestroy(2);
       
    88     }
       
    89 
       
    90 // Server process entry-point
       
    91 TInt E32Main()
       
    92     {
       
    93     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    94     TInt r = KErrNoMemory;
       
    95     if (cleanup)
       
    96         {
       
    97         TRAP(r, RunServerL());
       
    98         delete cleanup;
       
    99         }
       
   100     RDebug::Printf("%s %s (%u) r=%x", __FILE__, __PRETTY_FUNCTION__,
       
   101             __LINE__, r);
       
   102     return r;
       
   103     }
       
   104 
       
   105 // End of file