cbsref/telephonyrefplugins/atltsy/atcommand/generic/src/atmanager.cpp
branchRCL_3
changeset 65 630d2f34d719
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
       
     1 // Copyright (c) 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 
       
    17 // use include
       
    18 #include "atmanager.h"
       
    19 #include "activecommandstore.h"
       
    20 #include "mslogger.h"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // CAtManager::NewL
       
    24 // other items were commented in a header
       
    25 // ---------------------------------------------------------------------------	
       
    26 CAtManager* CAtManager::NewL()
       
    27 	{
       
    28 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::NewL()"));
       
    29 	CAtManager *self = CAtManager::NewLC();
       
    30 	CleanupStack::Pop(self);
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CAtManager::NewLC
       
    36 // other items were commented in a header
       
    37 // ---------------------------------------------------------------------------	
       
    38 CAtManager* CAtManager::NewLC()
       
    39 	{
       
    40 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::NewLC()"));
       
    41 	CAtManager *self = new (ELeave) CAtManager;
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL();
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CAtManager::~CAtManager
       
    49 // other items were commented in a header
       
    50 // ---------------------------------------------------------------------------	
       
    51 CAtManager::~CAtManager()
       
    52 	{
       
    53 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::~CAtManager()"));
       
    54 	
       
    55 	delete iActiveCommandStore;
       
    56 	iActiveCommandStore = NULL;
       
    57 	}
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CAtManager::CAtManager
       
    61 // other items were commented in a header
       
    62 // ---------------------------------------------------------------------------	
       
    63 CAtManager::CAtManager()
       
    64 	{
       
    65 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::CAtManager()"));
       
    66 	}
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CAtManager::ConstructL
       
    70 // other items were commented in a header
       
    71 // ---------------------------------------------------------------------------	
       
    72 void CAtManager::ConstructL()
       
    73 	{
       
    74 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::ConstructL()"));
       
    75 	iActiveCommandStore = CActiveCommandStore::NewL();
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CAtManager::SetSolicitedAtCommand
       
    80 // other items were commented in a header
       
    81 // ---------------------------------------------------------------------------	
       
    82 void CAtManager::SetSolicitedAtCommand(CAtCommandBase* aSolicitedCommand)
       
    83 	{
       
    84 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::SetSolicitedAtCommand()"));
       
    85 	iSolicitedCommand = aSolicitedCommand;
       
    86 	}
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CAtManager::GetActiveCommandStore
       
    90 // other items were commented in a header
       
    91 // ---------------------------------------------------------------------------	
       
    92 CActiveCommandStore* CAtManager::GetActiveCommandStore() const
       
    93 	{
       
    94 	return iActiveCommandStore;
       
    95 	}
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CAtManager::ReadOrWriteComplete
       
    99 // other items were commented in a header
       
   100 // ---------------------------------------------------------------------------	
       
   101 void CAtManager::ReadOrWriteComplete(TAtEventSource aEvent, TInt aStatus)
       
   102 	{
       
   103 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::AtCommandReadOrWriteComplete()"));
       
   104 	LOGTEXT3(_L8("[Ltsy] aEvent = %d, aStatus = %d"), aEvent, aStatus);
       
   105 	
       
   106     if (aEvent == EWriteCompletion)
       
   107 		{
       
   108 		if (iSolicitedCommand != NULL)
       
   109 			{
       
   110 			if(aStatus == KErrNone)
       
   111 				{
       
   112 				// add this active AT Command in the first place of the store
       
   113 				iActiveCommandStore->AddSolicitedAtCommand(iSolicitedCommand);
       
   114 				}
       
   115 			else
       
   116 				{
       
   117 				iSolicitedCommand = NULL;
       
   118 				}
       
   119 			
       
   120 			iSolicitedCommand->GenericEventSignal(aEvent, aStatus);
       
   121 			}
       
   122 		}
       
   123     else if (aEvent == EReadCompletion)
       
   124 		{
       
   125 		if (aStatus != KErrNone)
       
   126 			{
       
   127 			// check if there is active solicited AT command in the AT active command store
       
   128 			if((iActiveCommandStore->GetActiveCommandArray())[0] != NULL)
       
   129 	          {
       
   130 	          iSolicitedCommand->GenericEventSignal(aEvent, aStatus);
       
   131 	          }
       
   132 			
       
   133 			iSolicitedCommand = NULL;
       
   134 			}
       
   135 		}
       
   136     else if(aEvent == ETimeoutCompletion)
       
   137     	{
       
   138 		if(iSolicitedCommand)
       
   139 			{
       
   140 			iSolicitedCommand->GenericEventSignal(ETimeoutCompletion, aStatus);
       
   141 			iSolicitedCommand = NULL;
       
   142 			}
       
   143     	}
       
   144 	}
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CAtManager::NotifyOneLineFoundL
       
   148 // other items were commented in a header
       
   149 // ---------------------------------------------------------------------------	
       
   150 TBool CAtManager::NotifyOneLineFoundL(TInt aStatus, const TDesC8& aLineBuf)
       
   151 	{
       
   152 	LOGTEXT(_L8("[Ltsy] Starting CAtManager::NotifyOneLineFoundL()"));
       
   153 		
       
   154 	RPointerArray<CAtCommandBase>& atCommands = iActiveCommandStore->GetActiveCommandArray();
       
   155 	TInt count = atCommands.Count();
       
   156 	LOGTEXT2(_L8("[Ltsy] count = %d"), count);
       
   157 	
       
   158 	TBool atCommandFound(EFalse);
       
   159 	
       
   160 	for (TInt n = 0; !atCommandFound && n < count; n++)
       
   161 		{
       
   162 		CAtCommandBase* atCommand = atCommands[n];
       
   163 		if ((atCommand != NULL) && atCommand->MatchExpectString(aLineBuf))
       
   164 			{
       
   165 			atCommandFound = ETrue;
       
   166 			atCommand->ParseResponseL(aLineBuf);
       
   167 			atCommand->GenericEventSignal(EReadCompletion, aStatus);
       
   168 			}
       
   169 		}
       
   170 	LOGTEXT(_L8("[Ltsy] End CAtManager::NotifyOneLineFoundL()"));
       
   171 	return ETrue;
       
   172 	}
       
   173 
       
   174 // End of file