sysstatemgmt/systemstateplugins/adptplugin/src/simadaptationref.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "simadaptationref.h"
       
    17 
       
    18 /**
       
    19 Function to create new Sim Adaptation Plugin.
       
    20 
       
    21 @return	a new plugin object for Sim Adaptations.
       
    22 */
       
    23 EXPORT_C MSimAdaptation* CreateSimAdaptationRefL()
       
    24 	{
       
    25 	CSimAdaptationRef* simAdaptationRef = CSimAdaptationRef::NewL();
       
    26 	return (static_cast<MSimAdaptation*>(simAdaptationRef));
       
    27 	}
       
    28 
       
    29 CSimAdaptationRef* CSimAdaptationRef::NewL()
       
    30 	{
       
    31 	CSimAdaptationRef* self = new(ELeave) CSimAdaptationRef;
       
    32 	
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	CleanupStack::Pop();
       
    36 
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 CSimAdaptationRef::~CSimAdaptationRef()
       
    41 	{
       
    42 	delete iTimer;
       
    43 	}
       
    44 
       
    45 CSimAdaptationRef::CSimAdaptationRef()
       
    46 	{
       
    47 	}
       
    48 
       
    49 void CSimAdaptationRef::ConstructL()
       
    50 	{
       
    51 	iTimer = CSimRefAdaptationTimer::NewL();
       
    52 	}
       
    53 
       
    54 //from MSimAdaptation
       
    55 void CSimAdaptationRef::Release()
       
    56 	{
       
    57 	delete this;
       
    58 	}
       
    59 
       
    60 void CSimAdaptationRef::GetSimOwned(TDes8& /*aOwnedPckg*/, TRequestStatus& aStatus)
       
    61 	{
       
    62 	aStatus = KRequestPending;
       
    63 	TRequestStatus* pStatus = &aStatus;
       
    64 	User::RequestComplete(pStatus, KErrNone);
       
    65 	}
       
    66 
       
    67 /**
       
    68   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
       
    69   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
       
    70 */
       
    71 void CSimAdaptationRef::GetCancel()
       
    72 	{
       
    73 	}
       
    74 
       
    75 /**
       
    76   The reference implementation completes with KErrNotSupported since there is no SIM support on HRP/Techview.
       
    77   On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType.
       
    78   
       
    79   
       
    80   The above mentioned implementation is modified to facilitate testing and increase the code coverage of the Adaptation 
       
    81   server code.The modified functionality is as follows.
       
    82   
       
    83   
       
    84   Instead of completing the notification request with KErrNotSupported the it is passed to 
       
    85   CSimAdaptationRefEventHandler which is an active object wiht lower priority compared to 
       
    86   the server active object.Because of this a delay will be introduced in completing the notification
       
    87   request so that other active objects can run avoiding infinite loop and starvation of other 
       
    88   active objects,which will be the case if the notification request is immediately completed.
       
    89   This is strictly for testing purposes.On a device this call will be replaced by Sim Adaptation
       
    90   Plug-in  completing 'aTypePckg' with one of the event types in TSsmSimEventType.
       
    91 
       
    92   
       
    93   
       
    94 */
       
    95 void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus)
       
    96 	{
       
    97 	aStatus = KRequestPending;
       
    98 	iTimer->After(2000000,aStatus);
       
    99 	}
       
   100 
       
   101 /**
       
   102   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
       
   103   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
       
   104 */
       
   105 void CSimAdaptationRef::NotifyCancel()
       
   106 	{
       
   107 	if(iTimer->IsActive())
       
   108 		{
       
   109 		iTimer->Cancel();			
       
   110 		}
       
   111 	}
       
   112 
       
   113 
       
   114 
       
   115 CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput)
       
   116 	{
       
   117    	CActiveScheduler::Add(this);
       
   118 	}
       
   119 
       
   120 CSimRefAdaptationTimer::~CSimRefAdaptationTimer()
       
   121 	{
       
   122 	Cancel();	
       
   123 	}
       
   124 
       
   125 CSimRefAdaptationTimer* CSimRefAdaptationTimer::NewL()
       
   126 	{
       
   127    	CSimRefAdaptationTimer* self=new (ELeave) CSimRefAdaptationTimer();
       
   128    	CleanupStack::PushL(self);
       
   129    	self->ConstructL();
       
   130    	CleanupStack::Pop();
       
   131     return self;		
       
   132 	}
       
   133 
       
   134 void CSimRefAdaptationTimer::After(TTimeIntervalMicroSeconds32 aCancelDelay, TRequestStatus& aStatus)
       
   135 	{
       
   136 	iReqStatus = &aStatus;
       
   137 	if(!IsActive())
       
   138 	CTimer::After(aCancelDelay);	
       
   139 	}
       
   140 
       
   141 
       
   142 
       
   143 void CSimRefAdaptationTimer::DoCancel()
       
   144 	{
       
   145 	User::RequestComplete(iReqStatus, KErrCancel);	
       
   146 	CTimer::DoCancel();	
       
   147 	}
       
   148 
       
   149 
       
   150 void CSimRefAdaptationTimer::RunL()
       
   151 	{
       
   152 	User::RequestComplete(iReqStatus, KErrNone);	
       
   153 	}
       
   154 
       
   155