sapi_sysinfo/tsrc/testing/tsysmanualtest/src/tmemnot.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:   tsysinfoaccessorystatus
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /*#include "tsysmanualtest.h"
       
    20 #include "tmemnot.h"
       
    21 #include "entitykeys.h"
       
    22 
       
    23 using namespace SysInfo;
       
    24 
       
    25 
       
    26 CCriticalMemNot* CCriticalMemNot::NewL(CStifLogger* aLog, TInt aDrive, TInt aTestId)
       
    27 	{
       
    28 	CCriticalMemNot* self = new(ELeave) CCriticalMemNot(aLog,aDrive, aTestId);
       
    29 	self->ConstructL();
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 CCriticalMemNot::~CCriticalMemNot()
       
    34 	{
       
    35 	Cancel();
       
    36 	
       
    37 	if(iWaitScheduler->IsStarted())
       
    38 		iWaitScheduler->AsyncStop();
       
    39 	
       
    40 	if(iSysInfoService)
       
    41 		delete iSysInfoService;
       
    42 	
       
    43 	if(iWaitScheduler)
       
    44 		delete iWaitScheduler;
       
    45 	
       
    46 	if(iTimer)
       
    47 		delete iTimer;
       
    48 	}
       
    49 
       
    50 void CCriticalMemNot::ConstructL()
       
    51 	{
       
    52 	iSysInfoService = CSysInfoService::NewL();
       
    53 	iWaitScheduler = new(ELeave) CActiveSchedulerWait();
       
    54 	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    55 	CActiveScheduler::Add(this);
       
    56 	}
       
    57 
       
    58 CCriticalMemNot::CCriticalMemNot(CStifLogger* aLog,TInt aDrive, TInt aTestId) :
       
    59 CActive(EPriorityStandard),iResult(-1),iLog(aLog),iDrive(aDrive), iTestId(aTestId), iCount(0)
       
    60 	{
       
    61 	}
       
    62 
       
    63 void CCriticalMemNot::DoCancel()
       
    64 	{
       
    65 
       
    66 	}
       
    67 
       
    68 void CCriticalMemNot::RunL()
       
    69 	{
       
    70 	if(iTestId == ETestCriticalMem)
       
    71 		{
       
    72 		TestFunc() ;	
       
    73 		}
       
    74 	else
       
    75 		{
       
    76 		TestFunc1() ;
       
    77 		}	
       
    78 	}
       
    79 
       
    80 void CCriticalMemNot::Start()
       
    81 	{
       
    82 	SetActive();
       
    83 	TRequestStatus* temp = &iStatus;
       
    84 	User::RequestComplete(temp, KErrNone);
       
    85 	iWaitScheduler->Start();	
       
    86 	}
       
    87 
       
    88 TInt CCriticalMemNot::Result()
       
    89 	{
       
    90 	return iResult;
       
    91 	}
       
    92 
       
    93 
       
    94 void CCriticalMemNot::TestFunc()
       
    95 	{
       
    96 
       
    97 	const TTimeIntervalMicroSeconds32 threeMin(180000000);
       
    98 	CDriveInfo* driveInfo = CDriveInfo::NewL(iDrive) ;
       
    99     CSysData* sysData ;
       
   100    	   	
       
   101     iLog->Log(_L8("expDrive : %d"),iDrive) ;	
       
   102     
       
   103     TRAPD(leaveCode, iSysInfoService->GetInfoL(KMemory,KDriveInfo,sysData,driveInfo)) ;
       
   104     
       
   105     if(KErrNone == leaveCode)
       
   106 	    {
       
   107 	    CDriveInfo *status = (CDriveInfo*)sysData ;
       
   108 	    TRAPD(err1,iSysInfoService->GetNotificationL(KMemory,KCriticalMemory,1000,this,status));
       
   109 		iTimer->After(threeMin);
       
   110 	    delete sysData ;
       
   111 	    } 
       
   112 	else
       
   113 		{
       
   114 		iResult = KErrGeneral ;	
       
   115 		iWaitScheduler->AsyncStop();
       
   116 		}
       
   117 	
       
   118 	delete driveInfo ;
       
   119 	return ;
       
   120 	}
       
   121 
       
   122 
       
   123 void CCriticalMemNot::TestFunc1()
       
   124 	{
       
   125 
       
   126 	const TTimeIntervalMicroSeconds32 threeMin(180000000);
       
   127    	   	
       
   128     iLog->Log(_L8("expDrive : %d"),iDrive) ;	
       
   129         
       
   130     TRAPD(err1,iSysInfoService->GetNotificationL(KMemory,KMemoryCard,1001,this));
       
   131 	
       
   132 	iTimer->After(threeMin);
       
   133 
       
   134 	return ;
       
   135 	}
       
   136 void CCriticalMemNot::HandleResponseL(const TDesC& aEntity,const TDesC& aKey, 
       
   137 									CSysData* aResponse, TInt32 aTransID, 
       
   138 									TInt aError)
       
   139 	{
       
   140 
       
   141 	if(aError == KErrNone) 
       
   142 		{
       
   143 		if(aTransID == 1000)
       
   144 			{
       
   145 		/*	TInt expIpLanguage = 58 ;
       
   146 			
       
   147 			const CStatus* data = (CStatus*)aResponse ;
       
   148 			TInt IpLang = data->Status() ;
       
   149 			
       
   150 			if(IpLang == expIpLanguage)
       
   151 				{
       
   152 				iResult = KErrNone ;
       
   153 				}
       
   154 			iLog->Log(_L8("IpLanguage : %d"),IpLang) ;
       
   155 		
       
   156 			delete aResponse ;
       
   157 			iWaitScheduler->AsyncStop() ;
       
   158 			}
       
   159 			
       
   160 		else if(aTransID == 1001)
       
   161 			{
       
   162 			iCount++ ;
       
   163 			TInt expRemStatus = 0 ;
       
   164 			TInt expInsStatus = 1 ;
       
   165 			const CStatus* data = (CStatus*)aResponse ;
       
   166 			TInt retStatus = data->Status() ;
       
   167 			if((iCount==1) && (retStatus!=expRemStatus))
       
   168 				{
       
   169 				iResult = KErrGeneral ;
       
   170 				iWaitScheduler->AsyncStop() ;		
       
   171 				}
       
   172 			else if((iCount==2) && (retStatus!=expInsStatus))
       
   173 				{
       
   174 				
       
   175 				iResult = KErrGeneral ;
       
   176 				iWaitScheduler->AsyncStop() ;
       
   177 				}
       
   178 			else if(iCount==2)
       
   179 				{
       
   180 				iResult = KErrNone ;
       
   181 				iWaitScheduler->AsyncStop() ;
       
   182 				}
       
   183 			delete aResponse ;
       
   184 			
       
   185 			}
       
   186 			
       
   187 			}
       
   188 	
       
   189 	else
       
   190 		{
       
   191 		iResult = KErrGeneral ;
       
   192 		iWaitScheduler->AsyncStop() ;
       
   193 		}
       
   194 		
       
   195 	}
       
   196 	
       
   197 
       
   198 
       
   199 void CCriticalMemNot::HandleTimeOut()
       
   200 {
       
   201 	iLog->Log(_L("CCriticalMemNot TimeOut reached...")) ;
       
   202 	iSysInfoService->Cancel(1000) ;
       
   203 	iSysInfoService->Cancel(1001) ;
       
   204 	iResult = KErrGeneral ;
       
   205 	iWaitScheduler->AsyncStop() ;
       
   206 }
       
   207 
       
   208 
       
   209 */