cbsref/telephonyrefplugins/atltsy/atcommand/pktservice/src/atgprsconfig.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 // CActivatContextAndGetAddr
       
    15 // This command specifies PDP context parameter values for a PDP context identified 
       
    16 // by the local context identification parameter, <cid>.
       
    17 // Eleven PDP contexts can be defined through Wavecom software.
       
    18 // A special form of the set command, +CGDCONT= <cid> causes the values for context
       
    19 // number <cid> to become undefined.
       
    20 // The test command returns values supported as a compound value. If the MT supports
       
    21 // several PDP types, <PDP_type>, the parameter value ranges for each <PDP_type> are
       
    22 // returned on a separate line.
       
    23 // The read command returns the current settings for each defined context.
       
    24 // The test command returns values supported as a compound value. If the MT supports
       
    25 // several PDP types, <PDP_type), the parameter value ranges for each <PDP_type> are
       
    26 // returned on a separate line.
       
    27 // +CGDCONT=[<cid> [,<PDP_type> [,<APN>[,<PDP_addr> [,<d_comp>[,<h_comp>]]]]]]
       
    28 // Defined values
       
    29 // <cid>: (PDP Context Identifier) a numeric parameter (1-32) which specifies a particular
       
    30 // PDP context definition. The parameter is local to the TE-MT interface and is used in
       
    31 // other PDP context-related commands.
       
    32 // <PDP_type>: (Packet Data Protocol type) a string parameter which specifies the type of
       
    33 // packet data protocol
       
    34 // IP Internet Protocol
       
    35 // PPP Point to Point Protocol
       
    36 // <APN>: (Access Point Name) a string parameter, which is a logical name that is used to
       
    37 // select the GGSN or the external packet data network.
       
    38 // If the value is null or omitted, then the subscription value will be requested.
       
    39 // WAVECOM confidential ?
       
    40 // This confidential document is the property of WAVECOM and may not be copied or circulated
       
    41 // without permission
       
    42 // <PDP_address>: a string parameter that identifies the MT in the address space
       
    43 // applicable to the PDP.
       
    44 // If the value is null or omitted, then a value may be provided by the TE during the PDP
       
    45 // startup procedure or, failing that, a dynamic address will be requested.
       
    46 // The read form of the command will continue to return the null string even if an address
       
    47 // has been allocated during the PDP startup procedure. The allocated address may be
       
    48 // read using the +CGPADDR command.
       
    49 // <d_comp>: a numeric parameter that controls PDP data compression
       
    50 // 0 - off (default if value is omitted)
       
    51 // 1 ?on
       
    52 // Other values are reserved.
       
    53 // <h_comp>: a numeric parameter that controls PDP header compression
       
    54 // 0 - off (default if value is omitted)
       
    55 // 1 ?on
       
    56 // Other values are reserved.
       
    57 // other items were commented in a header
       
    58 
       
    59 #include "mslogger.h"
       
    60 #include "atgprsconfig.h"
       
    61 
       
    62 _LIT8(KIPType4	, "IP");
       
    63 _LIT8(KIPType6	, "IP");
       
    64 _LIT8(KX25		, "X25");
       
    65 _LIT8(KSetCGDCONTCommand,"AT+CGDCONT=%d,\"%S\",\"%S\"\r");
       
    66 _LIT8(KATDeleteContext1, "AT+CGDCONT=1\r");
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CATGPRSSetConfig::NewL
       
    70 //
       
    71 // ---------------------------------------------------------------------------
       
    72 CATGPRSSetConfig* CATGPRSSetConfig::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    73                                          CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    74 	{
       
    75 	CATGPRSSetConfig* self = new(ELeave) CATGPRSSetConfig(aGloblePhone,aCtsyDispatcherCallback);
       
    76 	CleanupStack::PushL(self );
       
    77 	self->ConstructL();
       
    78 	CleanupStack::Pop(self );
       
    79 	return self ;
       
    80 	}
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CATGPRSSetConfig::CATGPRSSetConfig
       
    84 // other items were commented in a header
       
    85 // ---------------------------------------------------------------------------
       
    86 CATGPRSSetConfig::CATGPRSSetConfig(CGlobalPhonemanager& aGloblePhone, 
       
    87                                    CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    88 		:CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    89 	{
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // CATGPRSSetConfig::ConstructL()
       
    94 // other items were commented in a header
       
    95 // ---------------------------------------------------------------------------
       
    96 void CATGPRSSetConfig::ConstructL()
       
    97 	{
       
    98 	CAtCommandBase::ConstructL();
       
    99 	iDeleteContext = EFalse;
       
   100 	}
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CATGPRSSetConfig::~CATGPRSSetConfig()
       
   104 // other items were commented in a header
       
   105 // ---------------------------------------------------------------------------
       
   106 CATGPRSSetConfig::~CATGPRSSetConfig()
       
   107 	{
       
   108 	}
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CATGPRSSetConfig::StartRequest()
       
   112 // other items were commented in a header
       
   113 // ---------------------------------------------------------------------------
       
   114 void CATGPRSSetConfig::StartRequest()
       
   115 	{
       
   116 	ExecuteCommand();
       
   117 	}
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // CATGPRSSetConfig::ExecuteCommand()
       
   121 // other items were commented in a header
       
   122 // ---------------------------------------------------------------------------
       
   123 void CATGPRSSetConfig::ExecuteCommand()
       
   124 	{
       
   125 	iDeleteContext = ETrue;
       
   126 	iTxBuffer.Copy(KATDeleteContext1);
       
   127 	Write();
       
   128 	}
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CATGPRSSetConfig::MakeupCGDCONT()
       
   132 // other items were commented in a header
       
   133 // ---------------------------------------------------------------------------
       
   134 TInt CATGPRSSetConfig::MakeupCGDCONT()
       
   135 	{
       
   136 	TInt count = iPhoneGlobals.iContextList.Count();
       
   137 	TInt i;
       
   138 	//Get the context location from context list
       
   139 	for(i = 0; i < count;i++)
       
   140 		{
       
   141 		if(iPhoneGlobals.iContextList[i]->iContextID == iContextId)
       
   142 			{
       
   143 			break;
       
   144 			}
       
   145 		}
       
   146 	const TInt KPDPTypeIdent=5;
       
   147 	TBuf8<KPDPTypeIdent>						pdpType;		// PDP Type identifier
       
   148 	TBuf8<RPacketContext::KGSNNameLength>		gsnName;			// Access point Name
       
   149 	TBuf8<RPacketContext::KMaxPDPAddressLength>	pdpAddress;	// PDP pre-assigned address
       
   150 	switch(iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iPdpType)
       
   151 		{
       
   152 		case RPacketContext::EPdpTypeIPv4:
       
   153 			pdpType.Format(KIPType4);
       
   154 			break;
       
   155 		case RPacketContext::EPdpTypeIPv6:
       
   156 			pdpType.Format(KIPType6);
       
   157 			break;
       
   158 		case RPacketContext::EPdpTypeX25:
       
   159 			pdpType.Format(KX25);
       
   160 			break;
       
   161 		default:
       
   162 			pdpType.Format(KIPType6);
       
   163 			break;
       
   164 		}
       
   165 
       
   166 	gsnName.Copy(iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iAccessPointName);
       
   167 	pdpAddress.Copy(iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iPdpAddress);
       
   168 
       
   169 	iTxBuffer.Format(KSetCGDCONTCommand, iContextId, &pdpType, &gsnName);
       
   170 
       
   171 	return KErrNone;
       
   172 	}
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CATGPRSSetConfig::SetContext
       
   176 // other items were commented in a header
       
   177 // ---------------------------------------------------------------------------
       
   178 void CATGPRSSetConfig::SetContext(const TInt aContextId)
       
   179 	{
       
   180 	iContextId = aContextId;
       
   181 	}
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CATGPRSSetConfig::ParseResponseL
       
   185 // other items were commented in a header
       
   186 // ---------------------------------------------------------------------------
       
   187 void CATGPRSSetConfig::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   188 	{
       
   189 	if (CurrentLine().Match(KLtsyOkString) == 0)
       
   190 		{
       
   191 		iError = KErrNone;
       
   192 		}
       
   193 	else
       
   194 		{
       
   195 		iError = KErrGeneral;
       
   196 		}
       
   197 	}
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // CATGPRSSetConfig::EventSignal
       
   201 // other items were commented in a header
       
   202 // ---------------------------------------------------------------------------
       
   203 void CATGPRSSetConfig::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   204 	{
       
   205 	if(KErrNone ==aStatus)
       
   206 		{
       
   207 		if(aEventSource == EReadCompletion)
       
   208 			{
       
   209 			aStatus = iError;
       
   210 			}
       
   211 		else
       
   212 			return;
       
   213 		}
       
   214 	if(iDeleteContext)
       
   215 		{
       
   216 		iDeleteContext = EFalse;
       
   217 		TInt ret=MakeupCGDCONT();
       
   218 		Write();
       
   219 		}
       
   220 	else
       
   221 		{
       
   222 		TInt count = iPhoneGlobals.iContextList.Count();
       
   223 		TInt i;
       
   224 		//Get the context location from context list
       
   225 		for(i = 0; i < count;i++)
       
   226 			{
       
   227 			if(iPhoneGlobals.iContextList[i]->iContextID == iContextId)
       
   228 				{
       
   229 				break;
       
   230 				}
       
   231 			}
       
   232 		iCtsyDispatcherCallback.CallbackPacketServicesSetPdpContextConfigComp(aStatus,
       
   233 						        iPhoneGlobals.iContextList[i]->iInfo.iName);
       
   234         iCtsyDispatcherCallback.CallbackPacketServicesNotifyPdpContextAddedInd(aStatus,
       
   235                                 iPhoneGlobals.iContextList[i]->iInfo.iName);
       
   236 		CAtCommandBase::Complete();
       
   237 		iPhoneGlobals.iEventSignalActive = EFalse;
       
   238 		}
       
   239 	}
       
   240 
       
   241 //
       
   242 // End of file