cbsref/telephonyrefplugins/atltsy/atcommand/phone/src/atgetmodel.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 // CATGetModel
       
    15 
       
    16 #include "atgetmodel.h"
       
    17 #include "mslogger.h"
       
    18 
       
    19 
       
    20 _LIT8(KGetModelCommand,"AT+CGMM\r");
       
    21 _LIT(KSpaceSeparator," ");
       
    22 // Class CATGetModel
       
    23 // ---------------------------------------------------------------------------
       
    24 // CATGetModel::NewL
       
    25 // other items were commented in a header
       
    26 // ---------------------------------------------------------------------------
       
    27 CATGetModel* CATGetModel::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    28 	                           CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    29 	{
       
    30 	CATGetModel* self = new(ELeave) CATGetModel(aGloblePhone,aCtsyDispatcherCallback);
       
    31 	CleanupStack::PushL(self );
       
    32 	self->ConstructL();
       
    33 	CleanupStack::Pop(self );
       
    34 	return self ;
       
    35 	}
       
    36 // ---------------------------------------------------------------------------
       
    37 // CATGetModel::CATGetModel
       
    38 // other items were commented in a header
       
    39 // ---------------------------------------------------------------------------
       
    40 CATGetModel::CATGetModel(CGlobalPhonemanager& aGloblePhone, 
       
    41 	                     CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    42 		:CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    43 	{
       
    44 	}
       
    45 // ---------------------------------------------------------------------------
       
    46 // CATGetModel::ConstructL
       
    47 // other items were commented in a header
       
    48 // ---------------------------------------------------------------------------
       
    49 void CATGetModel::ConstructL()
       
    50 	{
       
    51 	CAtCommandBase::ConstructL();
       
    52 	iAtType = ELtsyAT_Phone_GetModel;
       
    53 	}
       
    54 // ---------------------------------------------------------------------------
       
    55 // CATGetModel::CATGetModel
       
    56 // other items were commented in a header
       
    57 // ---------------------------------------------------------------------------
       
    58 CATGetModel::~CATGetModel()
       
    59 	{
       
    60 	}
       
    61 // ---------------------------------------------------------------------------
       
    62 // CATGetModel::StartRequestL
       
    63 // other items were commented in a header
       
    64 // ---------------------------------------------------------------------------
       
    65 void CATGetModel::StartRequest()
       
    66 	{
       
    67 	ExecuteCommand();
       
    68 	}
       
    69 // ---------------------------------------------------------------------------
       
    70 // CATGetModel::ExecuteCommand
       
    71 // other items were commented in a header
       
    72 // ---------------------------------------------------------------------------
       
    73 void CATGetModel::ExecuteCommand( )
       
    74 	{
       
    75 	iTxBuffer.Copy(KGetModelCommand);
       
    76 	Write();
       
    77 	}
       
    78 // ---------------------------------------------------------------------------
       
    79 // CATGetModel::GetPhoneModel
       
    80 // other items were commented in a header
       
    81 // ---------------------------------------------------------------------------
       
    82 RMobilePhone::TMobilePhoneIdentityV1 CATGetModel::GetPhoneModel()
       
    83 	{
       
    84 	return iPhoneId;
       
    85 	}
       
    86 // ---------------------------------------------------------------------------
       
    87 // CATGetModel::GetErrorValue
       
    88 // other items were commented in a header
       
    89 // ---------------------------------------------------------------------------
       
    90 TInt CATGetModel::GetErrorValue()
       
    91 	{
       
    92 	return iError;
       
    93 	}
       
    94 // ---------------------------------------------------------------------------
       
    95 // CATGetModel::ParseResponseL
       
    96 // other items were commented in a header
       
    97 // ---------------------------------------------------------------------------
       
    98 void CATGetModel::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
    99 	{
       
   100 	if (CurrentLine().Match(KLtsyOkString) != 0)
       
   101 		{
       
   102 		iError = KErrGeneral;
       
   103 		return ;
       
   104 		}
       
   105 	RArray<TPtrC8> array;
       
   106 	CleanupClosePushL(array);
       
   107 	iParser->ParseRespondedBuffer(array,PrecedingLine());
       
   108 	iMoreInfoFlag = EFalse;
       
   109 	TInt Count = array.Count();
       
   110 	if (Count < 1)
       
   111 		{
       
   112 		CleanupStack::PopAndDestroy();
       
   113 		iError = KErrGeneral;
       
   114 		return ;
       
   115 		}
       
   116 	for(TInt i = 0; i < Count; i++)
       
   117 		{
       
   118 		//lex.Assign(array[2]);
       
   119 		
       
   120 		if  (iMoreInfoFlag)
       
   121 			{
       
   122 			TBuf<RMobilePhone::KPhoneModelIdSize> Data;
       
   123 			Data.Zero();
       
   124 			TInt remainingBufferSize = RMobilePhone::KPhoneModelIdSize - 
       
   125 									   iPhoneId.iModel.Length() - 1;
       
   126 			if(array[i].Length() > remainingBufferSize)
       
   127 				{
       
   128 				Data.Copy(array[i].Mid(0,remainingBufferSize));
       
   129 				}
       
   130 			else
       
   131 				{
       
   132 				Data.Copy(array[i]);
       
   133 				}
       
   134 			iPhoneId.iModel.Append(KSpaceSeparator);
       
   135 			iPhoneId.iModel.Append(Data);
       
   136 			}
       
   137 		else
       
   138 			{
       
   139 			if(array[i].Length() > RMobilePhone::KPhoneModelIdSize)
       
   140 				{
       
   141 				iPhoneId.iModel.Copy(array[i].Mid(0,RMobilePhone::KPhoneModelIdSize));
       
   142 				}
       
   143 			else
       
   144 				{
       
   145 				iPhoneId.iModel.Copy(array[i]);
       
   146 				}
       
   147 			iMoreInfoFlag = ETrue;
       
   148 			}
       
   149 		}
       
   150 	iMoreInfoFlag = EFalse;
       
   151 	CleanupStack::PopAndDestroy();
       
   152 	iError = KErrNone;
       
   153 	}
       
   154 //
       
   155 // End of file
       
   156