cbsref/telephonyrefplugins/atltsy/atcommand/phonebook/src/atphbkstoredelete.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
child 21 4814c5a49428
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     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 atphbkstoredelete.cpp
       
    15 // This contains CAtPhbkStoreDelete which is used to delete a phonebook Entry
       
    16 // 
       
    17 
       
    18 //system include 
       
    19 #include <etelmm.h>
       
    20 #include <ctsy/ltsy/cctsydispatchercallback.h>
       
    21 
       
    22 //user include 
       
    23 #include "atphbkstoredelete.h"
       
    24 #include "mslogger.h"
       
    25 
       
    26 //constant defination
       
    27 _LIT8(KPhbkStoreDelete,"AT+CPBW=%d\r");
       
    28 _LIT8(KSelAdnPhonebook,"AT+CPBS=\"SM\"\r");
       
    29 _LIT8(KSelFdnPhonebook,"AT+CPBS=\"FD\"\r");
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CAtPhbkStoreDelete::CAtPhbkStoreDelete
       
    33 // other items were commented in a header
       
    34 // ---------------------------------------------------------------------------
       
    35 CAtPhbkStoreDelete::CAtPhbkStoreDelete(CGlobalPhonemanager& aGloblePhone, 
       
    36                                        CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    37                                        :CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    38 	{
       
    39 	LOGTEXT(_L8("CAtPhbkStoreDelete::CAtPhbkStoreDelete called"));
       
    40 	}
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CAtPhbkStoreDelete::~CAtPhbkStoreDelete
       
    44 // other items were commented in a header
       
    45 // ---------------------------------------------------------------------------
       
    46 CAtPhbkStoreDelete::~CAtPhbkStoreDelete()
       
    47 	{
       
    48 	LOGTEXT(_L8("CAtPhbkStoreDelete::~CAtPhbkStoreDelete called"));
       
    49 	}
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CAtPhbkStoreDelete::NewLC
       
    53 // other items were commented in a header
       
    54 // ---------------------------------------------------------------------------
       
    55 CAtPhbkStoreDelete* CAtPhbkStoreDelete::NewLC(CGlobalPhonemanager& aGloblePhone, 
       
    56                                               CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    57 	{
       
    58 	CAtPhbkStoreDelete* self = new (ELeave)CAtPhbkStoreDelete(aGloblePhone, 
       
    59                                                               aCtsyDispatcherCallback);
       
    60 	CleanupStack::PushL(self);
       
    61 	self->ConstructL();
       
    62 	return self;
       
    63 	}
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CAtPhbkStoreDelete::NewL
       
    67 // other items were commented in a header
       
    68 // ---------------------------------------------------------------------------
       
    69 CAtPhbkStoreDelete* CAtPhbkStoreDelete::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    70                                              CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    71 	{
       
    72 	CAtPhbkStoreDelete* self=CAtPhbkStoreDelete::NewLC(aGloblePhone, 
       
    73                                                        aCtsyDispatcherCallback);
       
    74 	CleanupStack::Pop(self);
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CAtPhbkStoreDelete::ConstructL
       
    80 // other items were commented in a header
       
    81 // ---------------------------------------------------------------------------
       
    82 void CAtPhbkStoreDelete::ConstructL()
       
    83 	{
       
    84 	CAtCommandBase::ConstructL();
       
    85 	}
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CAtPhbkStoreDelete::SetPhonebookType
       
    89 // other items were commented in a header
       
    90 // ---------------------------------------------------------------------------
       
    91 void CAtPhbkStoreDelete::SetPhonebookType(DispatcherPhonebook::TPhonebook aPhonebookType)
       
    92 	{
       
    93 	iPhoneBookType = aPhonebookType;
       
    94 	}
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CAtPhbkStoreDelete::SetDeleteIndex
       
    98 // other items were commented in a header
       
    99 // ---------------------------------------------------------------------------
       
   100 void CAtPhbkStoreDelete::SetDeleteIndex(TInt aIndex)
       
   101 	{
       
   102 	iIndex = aIndex;
       
   103 	}
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CAtPhbkStoreDelete::StartRequest
       
   107 // other items were commented in a header
       
   108 // ---------------------------------------------------------------------------
       
   109 void CAtPhbkStoreDelete::StartRequest()
       
   110 	{
       
   111 	GetMaxNumberLen();
       
   112 	ExecuteCommand();
       
   113 	}
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CAtPhbkStoreDelete::ExecuteCommand
       
   117 // other items were commented in a header
       
   118 // ---------------------------------------------------------------------------
       
   119 void CAtPhbkStoreDelete::ExecuteCommand()
       
   120 	{
       
   121 	LOGTEXT(_L8("CAtPhbkStoreDelete::ExecuteCommand called"));
       
   122 	iState = ESetStoreName;
       
   123 	iTxBuffer.Zero();	
       
   124 	if( iPhoneBookType == DispatcherPhonebook::EIccAdn )
       
   125 		{
       
   126 		iTxBuffer.Copy(KSelAdnPhonebook);
       
   127 		}
       
   128 	else if( iPhoneBookType == DispatcherPhonebook::EIccFdn )
       
   129 		{
       
   130 		iTxBuffer.Copy(KSelFdnPhonebook);
       
   131 		}
       
   132 	Write();
       
   133 	}
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CAtPhbkStoreDelete::DeleteEntry
       
   137 // other items were commented in a header
       
   138 // ---------------------------------------------------------------------------
       
   139 void CAtPhbkStoreDelete::DeleteEntry()
       
   140 	{
       
   141 	LOGTEXT(_L8("CAtPhbkStoreDelete::DeleteEntry callded"));
       
   142 	iPhoneGlobals.iEventSignalActive = ETrue;
       
   143 	iTxBuffer.Zero();
       
   144 	iTxBuffer.Format(KPhbkStoreDelete,iIndex);
       
   145 	Write();
       
   146 	}
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CAtPhbkStoreDelete::EventSignal
       
   150 // other items were commented in a header
       
   151 // ---------------------------------------------------------------------------
       
   152 void CAtPhbkStoreDelete::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   153 	{
       
   154 	LOGTEXT3(_L8("CAtPhbkStoreDelete::EventSignal aStatus=%D iSource=%D"),aStatus,aEventSource);
       
   155 	
       
   156 	if(aStatus != KErrNone)
       
   157 		{
       
   158 		Complete();
       
   159 		iPhoneGlobals.iEventSignalActive = EFalse;
       
   160 		iCtsyDispatcherCallback.CallbackPhonebookStoreDeleteEntryComp(aStatus,iPhoneBookType,iMaxLen);
       
   161 		}
       
   162 	else
       
   163 		{
       
   164 		if( aEventSource== EWriteCompletion )
       
   165 			{
       
   166 			if( iState==ESetStoreName )
       
   167 				{
       
   168 				iState = ESetStoreNameComplete;
       
   169 				}
       
   170 			else if( iState==EDeleteEntry )
       
   171 				{
       
   172 				iState = EDeleteEntryComplete;
       
   173 				}
       
   174 			}
       
   175 		else 
       
   176 			{
       
   177 			if( iState==ESetStoreNameComplete )
       
   178 				{
       
   179 				Complete();
       
   180 				iPhoneGlobals.iEventSignalActive = EFalse;
       
   181 				if( iError == KErrNone )
       
   182 					{
       
   183 					iState = EDeleteEntry;
       
   184 					DeleteEntry();
       
   185 					}
       
   186 				else
       
   187 					{
       
   188 					iCtsyDispatcherCallback.CallbackPhonebookStoreDeleteEntryComp(iError,iPhoneBookType,iMaxLen);
       
   189 					}
       
   190 				}
       
   191 			else if( iState== EDeleteEntryComplete)
       
   192 				{
       
   193 				Complete();
       
   194 				iPhoneGlobals.iEventSignalActive = EFalse;
       
   195 				iCtsyDispatcherCallback.CallbackPhonebookStoreDeleteEntryComp(iError,iPhoneBookType,iMaxLen);
       
   196 				}
       
   197 			}
       
   198 		}
       
   199 	}
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // CAtPhbkStoreDelete::ParseResponseL
       
   203 // other items were commented in a header
       
   204 // ---------------------------------------------------------------------------
       
   205 void CAtPhbkStoreDelete::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   206 	{
       
   207 	if (CurrentLine().Match(KLtsyOkString) == 0)
       
   208 		{
       
   209 		iError = KErrNone;
       
   210 		}
       
   211 	else
       
   212 		{
       
   213 		iError = KErrGeneral;
       
   214 		}
       
   215 	}
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CAtPhbkStoreDelete::GetMaxNumberLen
       
   219 // other items were commented in a header
       
   220 // ---------------------------------------------------------------------------
       
   221 void CAtPhbkStoreDelete::GetMaxNumberLen()
       
   222 	{
       
   223 	if( iPhoneBookType == DispatcherPhonebook::EIccAdn )
       
   224 		{
       
   225 		iMaxLen = iPhoneGlobals.iPhonebookStoreInfo.iAdnMaximumNumberLength;
       
   226 		}
       
   227 	else if( iPhoneBookType == DispatcherPhonebook::EIccFdn )
       
   228 		{
       
   229 		iMaxLen = iPhoneGlobals.iPhonebookStoreInfo.iFdnMaximumNumberLength;
       
   230 		}
       
   231 	}
       
   232 
       
   233 //End of file