sapi_sysinfo/tsrc/testing/tsysgeneral/src/tasyncaccstatus.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     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 the License "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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "tsysgeneral.h"
       
    20 #include "sysinfoservice.h"
       
    21 #include "tasyncaccstatus.h"
       
    22 #include "entitykeys.h"
       
    23 #include "watchtimer.h"
       
    24 #include <e32std.h>
       
    25 
       
    26 using namespace SysInfo;
       
    27 
       
    28 CAsyncStatus* CAsyncStatus::NewL(CStifLogger* aLog)
       
    29 	{
       
    30 	CAsyncStatus* self = new(ELeave) CAsyncStatus(aLog);
       
    31 	self->ConstructL();
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CAsyncStatus::~CAsyncStatus()
       
    36 	{
       
    37 	Cancel();
       
    38 	if(iWaitScheduler->IsStarted())
       
    39 		iWaitScheduler->AsyncStop();
       
    40 	
       
    41 	delete	iTimer;
       
    42 	delete iSysInfoService;
       
    43 	delete iWaitScheduler;
       
    44 	}
       
    45 
       
    46 void CAsyncStatus::ConstructL()
       
    47 	{
       
    48 	iSysInfoService = CSysInfoService::NewL();
       
    49 	iWaitScheduler  = new(ELeave) CActiveSchedulerWait();
       
    50 	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    51 	CActiveScheduler::Add(this);
       
    52 	}
       
    53 
       
    54 CAsyncStatus::CAsyncStatus(CStifLogger* aLog) :
       
    55 				CActive(EPriorityStandard),iLog(aLog)
       
    56 	{
       
    57 	}
       
    58 
       
    59 void CAsyncStatus::DoCancel()
       
    60 	{
       
    61 	//TRAPD(err1,iSysInfoService->GetInfoL(req1));
       
    62 	}
       
    63 
       
    64 void CAsyncStatus::RunL()
       
    65 	{
       
    66 	TestFuncL();
       
    67 	}
       
    68 
       
    69 void CAsyncStatus::Start()
       
    70 	{
       
    71 	SetActive();
       
    72 	TRequestStatus* temp = &iStatus;
       
    73 	User::RequestComplete(temp, KErrNone);
       
    74 	iWaitScheduler->Start();	
       
    75 	}
       
    76 
       
    77 TInt CAsyncStatus::Result()
       
    78 	{
       
    79 	return iResult;
       
    80 	}
       
    81 
       
    82 void CAsyncStatus::TestFuncL()
       
    83 	{
       
    84 	
       
    85 	TInt retValue = KErrNone ;
       
    86 	CSysData* input = CDriveInfo::NewL(retValue);
       
    87 	TRAPD(err,iSysInfoService->GetInfoL(KGeneral,KAccessoryStatus,1,this,input));
       
    88 	
       
    89 	if (KErrNotSupported == err)
       
    90 		{
       
    91 		TRAP(err,iSysInfoService->GetInfoL(KGeneral,KInputLanguage,1,this,input));
       
    92 		
       
    93 		if(KErrNotSupported == err)
       
    94 			{
       
    95 			TRAP(err,iSysInfoService->GetInfoL(KGeneral,KFlipStatus,1,this,input));
       
    96 			if(KErrNotSupported != err)
       
    97 				{
       
    98 				retValue = KErrGeneral ;	
       
    99 				}
       
   100 			}
       
   101 		else
       
   102 			{
       
   103 			retValue = KErrGeneral ;
       
   104 			}
       
   105 		
       
   106 		}
       
   107 	else
       
   108 		{
       
   109 		retValue = KErrGeneral ;
       
   110 		}
       
   111 	iResult = retValue ;
       
   112 	delete input ;
       
   113 	iWaitScheduler->AsyncStop();
       
   114 	}
       
   115 
       
   116 void CAsyncStatus::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
       
   117 	 					CSysData* /*aOutput*/, TInt32 /*aTransID*/,TSysRequest::TRequestType /*aType*/, TInt /*aError*/)
       
   118 	{
       
   119 
       
   120 	}
       
   121 
       
   122 void CAsyncStatus::HandleTimeOut()
       
   123 {
       
   124 }
       
   125 
       
   126 TInt TestAsyncStatus(CStifLogger* aLog )
       
   127 {
       
   128 
       
   129 	CAsyncStatus* test = CAsyncStatus::NewL(aLog);
       
   130 	
       
   131 	test->Start();
       
   132 	TInt retval = test->Result();
       
   133 	delete test;
       
   134 
       
   135 	return retval;
       
   136 }