cbsref/telephonyrefplugins/atltsy/atcommand/generic/src/globalphonemanager.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 // @file globlephonemanager.cpp
       
    15 // This contains CGlobalPhonemanager which manage the global phone status and call info manager.
       
    16 // 
       
    17 
       
    18 // user include
       
    19 #include "globalphonemanager.h"
       
    20 #include "atmanager.h"
       
    21 #include "commengine.h"
       
    22 #include "tsyconfg.h"
       
    23 #include "mslogger.h"
       
    24 #include "requestbase.h"
       
    25 #include "ltsycallinformationmanager.h"
       
    26 #include "athangupcommandrecords.h"
       
    27 
       
    28 #if defined (__WINS__)
       
    29 _LIT(KPDDName,"ECDRV");
       
    30 _LIT(KLDDName,"ECOMM");
       
    31 #else
       
    32 _LIT(KPDDName,"EUART1");
       
    33 #if defined (PDD2_NAME)
       
    34 _LIT(KPDD2Name,"EUART2");
       
    35 #endif
       
    36 _LIT(KLDDName,"ECOMM");
       
    37 #endif
       
    38 
       
    39 //define constant value
       
    40 const TInt KLtsyDefaultSecondsToWaitForCarrier=40;
       
    41 const TInt KLtsyCommReadPriority = 10;
       
    42 const TInt KLtsyCommWritePriority = 20;
       
    43 const TInt KLtsyChatBufferSize = 400;
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CGlobalPhonemanager::NewL
       
    47 // other items were commented in a header
       
    48 // ---------------------------------------------------------------------------
       
    49 CGlobalPhonemanager* CGlobalPhonemanager::NewL()
       
    50 	{
       
    51 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::NewL()"));
       
    52 	
       
    53 	CGlobalPhonemanager *self = CGlobalPhonemanager::NewLC();
       
    54 	CleanupStack::Pop(self);
       
    55 	return self;
       
    56 	}
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CGlobalPhonemanager::NewLC
       
    60 // other items were commented in a header
       
    61 // ---------------------------------------------------------------------------
       
    62 CGlobalPhonemanager* CGlobalPhonemanager::NewLC()
       
    63 	{
       
    64 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::NewLC()"));
       
    65 	
       
    66 	CGlobalPhonemanager *self = new (ELeave) CGlobalPhonemanager;
       
    67 	CleanupStack::PushL(self);
       
    68 	self->ConstructL();
       
    69 	return self;
       
    70 	}
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CGlobalPhonemanager::~CGlobalPhonemanager
       
    74 // other items were commented in a header
       
    75 // ---------------------------------------------------------------------------
       
    76 CGlobalPhonemanager::~CGlobalPhonemanager()
       
    77 	{
       
    78 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::~CGlobalPhonemanager()"));
       
    79 
       
    80 	delete iConfiguration;
       
    81 	delete iAtManager;
       
    82 	delete iCommEngine;
       
    83 	delete iActiveIpcRequest;
       
    84 	iContextList.ResetAndDestroy();
       
    85 	}
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CGlobalPhonemanager::CGlobalPhonemanager
       
    89 // other items were commented in a header
       
    90 // ---------------------------------------------------------------------------
       
    91 CGlobalPhonemanager::CGlobalPhonemanager()
       
    92 	{
       
    93 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::CGlobalPhonemanager()"));
       
    94 	}
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CGlobalPhonemanager::ConstructL
       
    98 // other items were commented in a header
       
    99 // ---------------------------------------------------------------------------
       
   100 void CGlobalPhonemanager::ConstructL()
       
   101 	{
       
   102 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::ConstructL()"));
       
   103 	
       
   104 	InitL();
       
   105 	}
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CGlobalPhonemanager::InitL
       
   109 // other items were commented in a header
       
   110 // ---------------------------------------------------------------------------
       
   111 void CGlobalPhonemanager::InitL()
       
   112 	{
       
   113 	LOGTEXT(_L8("[Ltsy] Starting CGlobalPhonemanager::InitL()"));
       
   114 	
       
   115 	// initialize the status of phone
       
   116 	iPhoneStatus.iLocalNetworkSel.iMethod = RMobilePhone::ENetworkSelectionUnknown;
       
   117 	iPhoneStatus.iModemDetected = RPhone::EDetectedUnknown;
       
   118 	iPhoneStatus.iDataAndFaxFlags = RPhone::KCapsUnknown;
       
   119 	iPhoneStatus.iWaitForCarrierTime = KLtsyDefaultSecondsToWaitForCarrier;
       
   120 	iPhoneStatus.iRegistrationStatus = RMobilePhone::ERegistrationUnknown;
       
   121 	iPhoneStatus.iPortAccess = EPortAccessAllowed;
       
   122 	iPhoneStatus.iMode = RPhone::EModeUnknown;
       
   123 	iPhoneStatus.iDataAndFaxFlags = RPhone::KCapsUnknown;
       
   124 	iPhoneStatus.iInitStatus = EPhoneNotInitialised;
       
   125 	iPhoneStatus.iGprsMaxNumContexts = 1;
       
   126 	iPhoneStatus.iMode=RPhone::EModeOnlineCommand;
       
   127 	
       
   128 	//Create the call information manager
       
   129 	iCallInfoManager = CLtsyCallInformationManager::NewL();
       
   130 	
       
   131 	// load physical device driver
       
   132 	TInt r = User::LoadPhysicalDevice(KPDDName);
       
   133 	if (r != KErrNone && r != KErrAlreadyExists)
       
   134 		{
       
   135 		User::Leave(r);
       
   136 		}
       
   137 	
       
   138 	// load logical device driver
       
   139 	r = User::LoadLogicalDevice(KLDDName);
       
   140 	if (r != KErrNone && r != KErrAlreadyExists)
       
   141 		{
       
   142 		User::Leave(r);
       
   143 		}
       
   144 		
       
   145 	// create the AT Manager
       
   146 	iAtManager = CAtManager::NewL();
       
   147 	
       
   148 	// create the Comm Engine which handle 
       
   149 	iCommEngine = CCommEngine::NewL(KLtsyChatBufferSize,KLtsyCommReadPriority,KLtsyCommWritePriority,iPhoneStatus.iPortAccess);
       
   150 	
       
   151 	// Set Comm Engine observer		
       
   152 	iCommEngine->SetCommEngineObserver(iAtManager);
       
   153 	iCommEngine->SetCommReadLineNotify(iAtManager);
       
   154 	
       
   155 	// create a CommDB configration helper class
       
   156 	iConfiguration = CTsyConfig::NewL();
       
   157 	
       
   158 	TFileName csy;
       
   159 	TName port;	
       
   160 	LOGTEXT(_L8("[Ltsy] Getting CSY from CommDB"));
       
   161 	User::LeaveIfError(iConfiguration->ConfigModemStringL(TPtrC(KCDTypeNameCsyName),csy));
       
   162 
       
   163 	LOGTEXT(_L8("[Ltsy] Getting PORT from CommDB"));
       
   164 	User::LeaveIfError(iConfiguration->ConfigModemStringL(TPtrC(KCDTypeNamePortName),port));
       
   165 	
       
   166 	// Open serial port by shared mode
       
   167 	User::LeaveIfError(iCommEngine->CommOpen(csy, port, ECommShared));
       
   168 	
       
   169 	// Configure Port
       
   170 	TCommConfig tConfigPckg;
       
   171 	
       
   172 	// Get the port configuration
       
   173 	LOGTEXT(_L8("[Ltsy] Setting Port Config"));	
       
   174 	User::LeaveIfError(iConfiguration->PortConfig(tConfigPckg,EConfigTypeInit));
       
   175 
       
   176 	LOGTEXT(_L8("[Ltsy] CommEngine Configure Port"));
       
   177 	User::LeaveIfError(iCommEngine->ConfigurePort(tConfigPckg));
       
   178 	
       
   179 	// issue reading from baseband
       
   180 	iCommEngine->Read();
       
   181 	
       
   182 	// Reset the context list
       
   183 	iContextList.Reset();
       
   184 	}
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // CGlobalPhonemanager::CheckGlobalPhoneStatus
       
   188 // other items were commented in a header
       
   189 // ---------------------------------------------------------------------------
       
   190 TInt CGlobalPhonemanager::CheckGlobalPhoneStatus()
       
   191 	{
       
   192 	if(EPhoneInitialised == iPhoneStatus.iInitStatus)
       
   193 		{
       
   194 		if (iEventSignalActive)
       
   195 			{
       
   196 			return  KErrInUse;
       
   197 			}
       
   198 		else
       
   199 			{
       
   200 			DeleteLastActiveRequest();
       
   201 			return KErrNone;
       
   202 			}
       
   203 		}
       
   204 	else
       
   205 		{
       
   206 		return iPhoneStatus.iInitStatus;
       
   207 		}
       
   208 	}
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CGlobalPhonemanager::SetActiveRequest
       
   212 // other items were commented in a header
       
   213 // ---------------------------------------------------------------------------
       
   214 void CGlobalPhonemanager::SetActiveRequest(CRequestBase* aCurActiveRequest)
       
   215 	{
       
   216 	iActiveIpcRequest = aCurActiveRequest;
       
   217 	}
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CGlobalPhonemanager::DeleteLastActiveRequest
       
   221 // other items were commented in a header
       
   222 // ---------------------------------------------------------------------------
       
   223 void CGlobalPhonemanager::DeleteLastActiveRequest()
       
   224 	{
       
   225 	delete iActiveIpcRequest;
       
   226 	iActiveIpcRequest = NULL;
       
   227 	}
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // CGlobalPhonemanager::GetCallInfoManager
       
   231 // other items were commented in a header
       
   232 // ---------------------------------------------------------------------------
       
   233 CLtsyCallInformationManager& CGlobalPhonemanager::GetCallInfoManager()
       
   234 	{
       
   235 	return (*iCallInfoManager);
       
   236 	}
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // CGlobalPhonemanager::CurrentActiveRequest
       
   240 // other items were commented in a header
       
   241 // ---------------------------------------------------------------------------
       
   242 CRequestBase* CGlobalPhonemanager::CurrentActiveRequest()
       
   243     {
       
   244     return iActiveIpcRequest;
       
   245     }
       
   246 
       
   247 // End of file