cbsref/telephonyrefplugins/atltsy/atcommand/sms/src/atsmsstoreinfo.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 atsmsstoreinfo.cpp
       
    15 // This contains CAtSmsStoreInfo which is used to get sms store information
       
    16 // 
       
    17 
       
    18 //system include 
       
    19 #include <ctsy/ltsy/cctsydispatchercallback.h>
       
    20 
       
    21 //user include 
       
    22 #include "atsmsstoreinfo.h"
       
    23 #include "mslogger.h"
       
    24 #include "ltsycommondefine.h"
       
    25 #include "globalphonemanager.h"
       
    26 
       
    27 //constant defination
       
    28 _LIT8(KGetPrefMemCommand,"AT+CPMS?\r");
       
    29 _LIT8(KCPMSResponseString,"+CPMS:");
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CAtSmsStoreInfo::CAtSmsStoreInfo
       
    33 // other items were commented in a header
       
    34 // ---------------------------------------------------------------------------
       
    35 CAtSmsStoreInfo::CAtSmsStoreInfo(CGlobalPhonemanager& aGloblePhone, 
       
    36                                  CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    37                                  :CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    38 	{
       
    39 	LOGTEXT(_L8("CAtSmsStoreInfo::CAtSmsStoreInfo called"));
       
    40 	}
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CAtSmsStoreInfo::~CAtSmsStoreInfo
       
    44 // other items were commented in a header
       
    45 // ---------------------------------------------------------------------------
       
    46 CAtSmsStoreInfo::~CAtSmsStoreInfo()
       
    47 	{
       
    48 	LOGTEXT(_L8("CAtSmsStoreInfo::~CAtSmsStoreInfo called"));
       
    49 	}
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CAtSmsStoreInfo::NewLC
       
    53 // other items were commented in a header
       
    54 // ---------------------------------------------------------------------------
       
    55 CAtSmsStoreInfo* CAtSmsStoreInfo::NewLC(CGlobalPhonemanager& aGloblePhone, 
       
    56                                         CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    57     {
       
    58 	CAtSmsStoreInfo* self = new (ELeave)CAtSmsStoreInfo(aGloblePhone, 
       
    59 			                                            aCtsyDispatcherCallback);
       
    60 	CleanupStack::PushL(self);
       
    61 	self->ConstructL();
       
    62 	return self;
       
    63 	}
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CAtSmsStoreInfo::NewL
       
    67 // other items were commented in a header
       
    68 // ---------------------------------------------------------------------------
       
    69 CAtSmsStoreInfo* CAtSmsStoreInfo::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    70                                        CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    71     {
       
    72 	CAtSmsStoreInfo* self=CAtSmsStoreInfo::NewLC(aGloblePhone, 
       
    73                                                  aCtsyDispatcherCallback);
       
    74 	CleanupStack::Pop(self);
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CAtSmsStoreInfo::ConstructL
       
    80 // other items were commented in a header
       
    81 // ---------------------------------------------------------------------------
       
    82 void CAtSmsStoreInfo::ConstructL()
       
    83 	{
       
    84 	CAtCommandBase::ConstructL();
       
    85 	}
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CAtSmsStoreInfo::StartRequest
       
    89 // other items were commented in a header
       
    90 // ---------------------------------------------------------------------------
       
    91 void CAtSmsStoreInfo::StartRequest()
       
    92 	{
       
    93 	ExecuteCommand();
       
    94 	}
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CAtSmsStoreInfo::ExecuteCommand
       
    98 // other items were commented in a header
       
    99 // ---------------------------------------------------------------------------
       
   100 void CAtSmsStoreInfo::ExecuteCommand()
       
   101 	{
       
   102 	LOGTEXT(_L8("CAtSmsStoreInfo::ExecuteCommand called"));
       
   103 	iTxBuffer.Zero();
       
   104 	iTxBuffer.Copy(KGetPrefMemCommand);
       
   105 	Write();
       
   106 	}
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CAtSmsStoreInfo::EventSignal
       
   110 // other items were commented in a header
       
   111 // ---------------------------------------------------------------------------
       
   112 void CAtSmsStoreInfo::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   113 	{
       
   114 	LOGTEXT3(_L8("CAtSmsStoreInfo::EventSignal aStatus=%D iSource=%D"),aStatus,aEventSource);
       
   115 	if(aStatus == KErrNone)
       
   116 		{
       
   117 		if((aEventSource == EWriteCompletion))
       
   118 			{
       
   119 			LOGTEXT(_L8("CAtSmsStoreInfo::EventSignal,EWriteCompletion!"));
       
   120 			return;
       
   121 			}
       
   122 		aStatus = iError;
       
   123 		}
       
   124 	Complete();
       
   125 	iPhoneGlobals.iEventSignalActive = EFalse;	
       
   126 	iCtsyDispatcherCallback.CallbackPhonebookSmsStoreGetInfoComp(aStatus,iTotal,iUsed);
       
   127 	}	
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CAtSmsStoreInfo::ParseResponseL
       
   131 // other items were commented in a header
       
   132 // ---------------------------------------------------------------------------
       
   133 void CAtSmsStoreInfo::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   134 	{
       
   135 	/**
       
   136 	* Parse result of AT+CPMS? 
       
   137 	* Response:+CPMS:<mem1>,<used1>,<total1>,<mem2>,<used2>,<total2>
       
   138 	* Here only the first mem is used. mem1 is SM
       
   139 	*/
       
   140 	iError = KErrNone;
       
   141 	RArray<TPtrC8> array;
       
   142 	CleanupClosePushL(array);
       
   143 	iParser->ParseRespondedBuffer(array,Buffer());
       
   144 	if(array[0].MatchF(KAnyATCommand) != KErrNotFound)
       
   145 		{
       
   146 		array.Remove(0);
       
   147 		}
       
   148 	TInt Count = array.Count();
       
   149 	if (Count <= 1)
       
   150 		{
       
   151 		CleanupStack::PopAndDestroy();
       
   152 		iError = KErrNotFound;
       
   153 		return;
       
   154 		}
       
   155 	if(array[0].MatchF(KCPMSResponseString) == KErrNotFound)
       
   156 		{
       
   157 		CleanupStack::PopAndDestroy();
       
   158 		iError = KErrNotFound;
       
   159 		return;
       
   160 		}
       
   161 	//parse name 
       
   162 	TPtrC8 name(array[1]);
       
   163 	
       
   164 	//parse used
       
   165 	TLex8 lex(array[2]);
       
   166 	TUint16 val;
       
   167 	TInt ret = lex.Val(val,EDecimal);
       
   168 	if(ret != KErrNone)
       
   169 		{
       
   170 		CleanupStack::PopAndDestroy();
       
   171 		iError = ret;
       
   172 		return;
       
   173 		}
       
   174 	iUsed = val;
       
   175 	
       
   176 	//parse total
       
   177 	TLex8 lex1(array[3]);
       
   178 	ret = lex1.Val(val,EDecimal);
       
   179 	if(ret != KErrNone)
       
   180 		{
       
   181 		CleanupStack::PopAndDestroy();
       
   182 		iError = ret;
       
   183 		return;
       
   184 		}
       
   185 	iTotal = val;
       
   186 	iPhoneGlobals.iStoreTotal = iTotal;
       
   187 	LOGTEXT2(_L8("CAtSmsStoreInfo::CPMSResponseL\tPreferred store name=%S"),&name);
       
   188  	LOGTEXT3(_L8("CAtSmsStoreInfo::CPMSResponseL\tPreferred store used=%d, total=%d"), 
       
   189  			                                     iUsed,iTotal);
       
   190 	CleanupStack::PopAndDestroy(&array);
       
   191 	}
       
   192 
       
   193 //End of file