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