00001 /* 00002 * ============================================================================ 00003 * Name : CTaskManagerEngineReader from TaskManagerEngineReader.cpp 00004 * Part of : TaskManager 00005 * Created : 15/03/2006 by Forum Nokia 00006 * Version : 1.2 00007 * Copyright: Nokia Corporation 00008 * ============================================================================ 00009 */ 00010 00011 // INCLUDE FILES 00012 #include "TaskManager.pan" 00013 #include "TaskManagerEngineReader.h" 00014 00015 #include <securesocket.h> 00016 00017 // ================= MEMBER FUNCTIONS ======================= 00018 00019 // Constructor 00020 CTaskManagerEngineReader::CTaskManagerEngineReader( MEngineNotifier& aNotifier ) 00021 : CActive( EPriorityStandard ), iSocket( NULL ), iNotifier( aNotifier ) 00022 { 00023 } 00024 00025 // Destructor 00026 CTaskManagerEngineReader::~CTaskManagerEngineReader() 00027 { 00028 Cancel(); 00029 } 00030 00031 // ---------------------------------------------------- 00032 // CTaskManagerEngineReader::ConstructL() 00033 // Second-phase constructor 00034 // ---------------------------------------------------- 00035 // 00036 void CTaskManagerEngineReader::ConstructL() 00037 { 00038 CActiveScheduler::Add( this ); 00039 } 00040 00041 // ---------------------------------------------------- 00042 // CTaskManagerEngineReader::NewL() 00043 // Two-phased construction. 00044 // ---------------------------------------------------- 00045 // 00046 CTaskManagerEngineReader* CTaskManagerEngineReader::NewL( MEngineNotifier& aNotifier ) 00047 { 00048 CTaskManagerEngineReader* self = CTaskManagerEngineReader::NewLC( aNotifier ); 00049 CleanupStack::Pop( self ); 00050 return self; 00051 } 00052 00053 // ---------------------------------------------------- 00054 // CTaskManagerEngineReader::NewLC() 00055 // Two-phased construction. 00056 // ---------------------------------------------------- 00057 // 00058 CTaskManagerEngineReader* CTaskManagerEngineReader::NewLC( MEngineNotifier& aNotifier ) 00059 { 00060 CTaskManagerEngineReader* self = new (ELeave) CTaskManagerEngineReader( aNotifier ); 00061 CleanupStack::PushL( self ); 00062 self->ConstructL(); 00063 return self; 00064 } 00065 00066 // ---------------------------------------------------- 00067 // CTaskManagerEngineReader::Start() 00068 // Initiates the reader. 00069 // ---------------------------------------------------- 00070 // 00071 void CTaskManagerEngineReader::Start() 00072 { 00073 // Initiate a new read from socket into iBuffer 00074 if (!IsActive()) 00075 { 00076 IssueRead(); 00077 } 00078 } 00079 00080 // ---------------------------------------------------- 00081 // CTaskManagerEngineReader::DoCancel() 00082 // Cancels an outstanding request. 00083 // ---------------------------------------------------- 00084 // 00085 void CTaskManagerEngineReader::DoCancel() 00086 { 00087 iSocket->CancelRecv(); 00088 } 00089 00090 // ---------------------------------------------------- 00091 // CTaskManagerEngineReader::RunL() 00092 // Handles an active object’s request completion event. 00093 // ---------------------------------------------------- 00094 // 00095 void CTaskManagerEngineReader::RunL() 00096 { 00097 switch( iStatus.Int() ) 00098 { 00099 case KErrNone: 00100 { 00101 // Something was read from socket. Pass it to upper levels 00102 if( iNotifier.PackageReceivedL( iBuffer ) ) 00103 { 00104 IssueRead(); // Immediately start another read 00105 } 00106 00107 break; 00108 } 00109 default: 00110 { 00111 Panic( ETaskManagerInvalidState ); 00112 break; 00113 } 00114 } 00115 } 00116 00117 // ---------------------------------------------------- 00118 // CTaskManagerEngineReader::IssueRead() 00119 // Initiate a single new read from socket. 00120 // ---------------------------------------------------- 00121 // 00122 void CTaskManagerEngineReader::IssueRead() 00123 { 00124 // This deletion is needed for some reason in S60 3rd Edition (at least for the emulator). 00125 // Otherwise the data in iBuffer will not get replaced on successive read operations to 00126 // the secure socket. 00127 iBuffer.Delete(0, iBuffer.Length()); 00128 iSocket->RecvOneOrMore(iBuffer, iStatus, iDummyLength); 00129 SetActive(); 00130 } 00131 00132 // ---------------------------------------------------- 00133 // CTaskManagerEngineReader::SetSecureSocket() 00134 // Sets a new socket from which to read. 00135 // ---------------------------------------------------- 00136 // 00137 void CTaskManagerEngineReader::SetSecureSocket( CSecureSocket* aSocket ) 00138 { 00139 iSocket = aSocket; 00140 } 00141 00142 // End of file
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.