cbsref/telephonyrefplugins/atltsy/atcommand/pktservice/src/atgprsgetcontextaddr.cpp
branchRCL_3
changeset 19 630d2f34d719
equal deleted inserted replaced
18:17af172ffa5f 19: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 // The execution command returns a list of PDP addresses for the specified context
       
    15 // identifiers.
       
    16 // The test command returns a list of defined <cid>s
       
    17 // Defined values
       
    18 // <cid>: a numeric parameter which specifies a particular PDP context definition. 
       
    19 // If no <cid> is specified, the addresses for all defined contexts are returned.
       
    20 // <PDP_address>: a string that identifies the MT in the address space applicable 
       
    21 // to the PDP. The address may be static or dynamic. For a static address, it will 
       
    22 // be the one set by the +CGDCONT command when the context was defined. For a 
       
    23 // dynamic address it will be the one assigned during the last PDP context 
       
    24 // activation that used the context definition referred to by <cid>. 
       
    25 // <PDP_address> is omitted if none is available.
       
    26 
       
    27 #include "mslogger.h"
       
    28 #include "atgprsgetcontextaddr.h"
       
    29 
       
    30 _LIT8(KATGetContextAddress,    "AT+CGPADDR=%d\r");
       
    31 _LIT8(KATGetContextAddressStr, "+CGPADDR:");
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CATGPRSGetContextAddr::NewL
       
    35 // other items were commented in a header
       
    36 // ---------------------------------------------------------------------------
       
    37 CATGPRSGetContextAddr* CATGPRSGetContextAddr::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    38                                          CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    39 	{
       
    40 	CATGPRSGetContextAddr* self = new(ELeave) CATGPRSGetContextAddr(aGloblePhone,aCtsyDispatcherCallback);
       
    41 	CleanupStack::PushL(self );
       
    42 	self->ConstructL();
       
    43 	CleanupStack::Pop(self );
       
    44 	return self ;
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CATGPRSGetContextAddr::CATGPRSGetContextAddr
       
    49 // other items were commented in a header
       
    50 // ---------------------------------------------------------------------------
       
    51 CATGPRSGetContextAddr::CATGPRSGetContextAddr(CGlobalPhonemanager& aGloblePhone, 
       
    52                                    CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    53 		:CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    54 	{
       
    55 	}
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CATGPRSGetContextAddr::ConstructL()
       
    59 // other items were commented in a header
       
    60 // ---------------------------------------------------------------------------
       
    61 void CATGPRSGetContextAddr::ConstructL()
       
    62 	{
       
    63 	CAtCommandBase::ConstructL();
       
    64 	iAtType = ELtsyAT_Packet_GetContextAddr;
       
    65 	}
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CATGPRSGetContextAddr::~CATGPRSGetContextAddr()
       
    69 // other items were commented in a header
       
    70 // ---------------------------------------------------------------------------
       
    71 CATGPRSGetContextAddr::~CATGPRSGetContextAddr()
       
    72 	{
       
    73 	}
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CATGPRSGetContextAddr::StartRequest()
       
    77 // other items were commented in a header
       
    78 // ---------------------------------------------------------------------------
       
    79 void CATGPRSGetContextAddr::StartRequest()
       
    80 	{
       
    81 	ExecuteCommand();
       
    82 	}
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CATGPRSGetContextAddr::ExecuteCommand()
       
    86 // other items were commented in a header
       
    87 // ---------------------------------------------------------------------------
       
    88 void CATGPRSGetContextAddr::ExecuteCommand()
       
    89 	{
       
    90 	LOGTEXT(_L8("CATGPRSGetContextAddr::Start called"));
       
    91 	LOGTEXT2(_L8("iCid=%d"),iContextId);
       
    92 	iTxBuffer.Format(KATGetContextAddress,iContextId);
       
    93 	Write();
       
    94 	}
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CATGPRSGetContextAddr::SetContext
       
    98 // other items were commented in a header
       
    99 // ---------------------------------------------------------------------------
       
   100 void CATGPRSGetContextAddr::SetContext(const TInt aContextId)
       
   101 	{
       
   102 	iContextId = aContextId;
       
   103 	}
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CATGPRSGetContextAddr::GetErrorValue
       
   107 // other items were commented in a header
       
   108 // ---------------------------------------------------------------------------
       
   109 TInt CATGPRSGetContextAddr::GetErrorValue()
       
   110 	{
       
   111 	return iError;
       
   112 	}
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CATGPRSGetContextAddr::ParseResponseL
       
   116 // other items were commented in a header
       
   117 // ---------------------------------------------------------------------------
       
   118 void CATGPRSGetContextAddr::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   119 	{
       
   120 	if (CurrentLine().Match(KLtsyOkString) != 0)
       
   121 		{
       
   122 		iError = KErrGeneral;
       
   123 		return;
       
   124 		}
       
   125 	RArray<TPtrC8> array;
       
   126 	CleanupClosePushL(array);
       
   127 	iParser->ParseRespondedBuffer(array,PrecedingLine());
       
   128 	TInt Count = array.Count();
       
   129 	if (Count < 1)
       
   130 		{
       
   131 		CleanupStack::PopAndDestroy();
       
   132 		iError = KErrGeneral;
       
   133 		return ;
       
   134 		}
       
   135 	if( array[0].MatchF(KATGetContextAddressStr)==KErrNotFound)
       
   136 		{
       
   137 		CleanupStack::PopAndDestroy();
       
   138 		iError = KErrGeneral;
       
   139 		return ;
       
   140 		}
       
   141 	TInt count = iPhoneGlobals.iContextList.Count();
       
   142 	TInt i = 0;
       
   143 	//Get the context from context list
       
   144 	for(i = 0; i < count;i++)
       
   145 		{
       
   146 		if(iPhoneGlobals.iContextList[i]->iContextID == iContextId)
       
   147 			{
       
   148 			break;
       
   149 			}
       
   150 		}
       
   151 	if(Count > 2 )
       
   152 		{
       
   153 		iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iPdpAddress.Copy(array[2]);
       
   154 		iError = KErrNone;
       
   155 		}
       
   156 	else
       
   157 		{
       
   158 		iError = KErrGeneral;
       
   159 		}
       
   160 	CleanupStack::PopAndDestroy(&array);
       
   161 	}
       
   162 
       
   163 // End of file