cbsref/telephonyrefplugins/atltsy/atcommand/sms/src/atsmsack.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 atsmsack.cpp
       
    15 // This contains CAtSmsAck and CAtSmsNack which is used to send 
       
    16 // positive(negative) acknowledgment
       
    17 // 
       
    18 
       
    19 //system include 
       
    20 #include <etelmm.h>
       
    21 #include <ctsy/ltsy/cctsydispatchercallback.h>
       
    22 
       
    23 //user include 
       
    24 #include "atsmsack.h"
       
    25 #include "mslogger.h"
       
    26 #include "smsatutil.h"
       
    27 
       
    28 //constant defination
       
    29 _LIT8(KSendCNMACommand,"AT+CNMA\r\n");
       
    30 _LIT8(KCNMAForNack,"AT+CNMA=2,%d\r\n");
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CAtSmsAck::CAtSmsAck
       
    34 // other items were commented in a header
       
    35 // ---------------------------------------------------------------------------
       
    36 CAtSmsAck::CAtSmsAck(CGlobalPhonemanager& aGloblePhone, 
       
    37                      CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    38                      :CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    39 	{
       
    40 	LOGTEXT(_L8("CAtSmsAck::CAtSmsAck called"));
       
    41 	}
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CAtSmsAck::~CAtSmsAck
       
    45 // other items were commented in a header
       
    46 // ---------------------------------------------------------------------------
       
    47 CAtSmsAck::~CAtSmsAck()
       
    48 	{
       
    49 	LOGTEXT(_L8("CAtSmsAck::~CAtSmsAck called"));
       
    50 	}
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CAtSmsAck::NewLC
       
    54 // other items were commented in a header
       
    55 // ---------------------------------------------------------------------------
       
    56 CAtSmsAck* CAtSmsAck::NewLC(CGlobalPhonemanager& aGloblePhone, 
       
    57                             CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    58 	{
       
    59 	CAtSmsAck* self = new (ELeave)CAtSmsAck(aGloblePhone, 
       
    60                                             aCtsyDispatcherCallback);
       
    61 	CleanupStack::PushL(self);
       
    62 	self->ConstructL();
       
    63 	return self;
       
    64 	}
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CAtSmsAck::NewL
       
    68 // other items were commented in a header
       
    69 // ---------------------------------------------------------------------------
       
    70 CAtSmsAck* CAtSmsAck::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    71                            CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    72 	{
       
    73 	CAtSmsAck* self=CAtSmsAck::NewLC(aGloblePhone, 
       
    74                                      aCtsyDispatcherCallback);
       
    75 	CleanupStack::Pop(self);
       
    76 	return self;
       
    77 	}
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CAtSmsAck::ConstructL
       
    81 // other items were commented in a header
       
    82 // ---------------------------------------------------------------------------
       
    83 void CAtSmsAck::ConstructL()
       
    84 	{
       
    85 	CAtCommandBase::ConstructL();
       
    86 	}
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CAtSmsAck::StartRequest
       
    90 // other items were commented in a header
       
    91 // ---------------------------------------------------------------------------
       
    92 void CAtSmsAck::StartRequest()
       
    93 	{
       
    94 	ExecuteCommand();
       
    95 	}
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CAtSmsAck::ExecuteCommand
       
    99 // other items were commented in a header
       
   100 // ---------------------------------------------------------------------------
       
   101 void CAtSmsAck::ExecuteCommand()
       
   102 	{
       
   103 	LOGTEXT(_L8("CAtSmsAck::ExecuteCommand called"));
       
   104 	iTxBuffer.Zero();
       
   105 	iTxBuffer.Copy( KSendCNMACommand );
       
   106 	Write();
       
   107 	}
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CAtSmsAck::EventSignal
       
   111 // other items were commented in a header
       
   112 // ---------------------------------------------------------------------------
       
   113 void CAtSmsAck::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   114 	{
       
   115 	LOGTEXT3(_L8("CAtSmsAck::EventSignal aStatus=%D iSource=%D"),aStatus,aEventSource);
       
   116 	if(aStatus == KErrNone)
       
   117 		{
       
   118 		if((aEventSource == EWriteCompletion))
       
   119 			{
       
   120 			LOGTEXT(_L8("CAtSmsNack::EventSignal,EWriteCompletion!"));
       
   121 			return;
       
   122 			}
       
   123 		aStatus = iError;
       
   124 		}
       
   125 	Complete();
       
   126 	iPhoneGlobals.iEventSignalActive = EFalse;
       
   127 	iCtsyDispatcherCallback.CallbackSmsAckSmsStoredComp(aStatus);
       
   128 	}
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CAtSmsAck::ParseResponseL
       
   132 // other items were commented in a header
       
   133 // ---------------------------------------------------------------------------
       
   134 void CAtSmsAck::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   135 	{
       
   136 	if (CurrentLine().Match(KLtsyOkString) == 0)
       
   137 		{
       
   138 		iError = KErrNone;
       
   139 		}
       
   140 	else
       
   141 		{
       
   142 		iError = KErrGeneral;
       
   143 		}
       
   144 	}
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CAtSmsNack::CAtSmsNack
       
   148 // other items were commented in a header
       
   149 // ---------------------------------------------------------------------------
       
   150 CAtSmsNack::CAtSmsNack(CGlobalPhonemanager& aGloblePhone, 
       
   151                        CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
   152                        :CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
   153 	{
       
   154 	LOGTEXT(_L8("CAtSmsNack::CAtSmsNack called"));
       
   155 	}
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CAtSmsNack::~CAtSmsNack
       
   159 // other items were commented in a header
       
   160 // ---------------------------------------------------------------------------
       
   161 CAtSmsNack::~CAtSmsNack()
       
   162 	{
       
   163 	LOGTEXT(_L8("CAtSmsNack::~CAtSmsNack called"));
       
   164 	}
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // CAtSmsNack::NewLC
       
   168 // other items were commented in a header
       
   169 // ---------------------------------------------------------------------------
       
   170 CAtSmsNack* CAtSmsNack::NewLC(CGlobalPhonemanager& aGloblePhone, 
       
   171                               CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
   172 	{
       
   173 	CAtSmsNack* self = new (ELeave)CAtSmsNack(aGloblePhone, 
       
   174                                               aCtsyDispatcherCallback);
       
   175 	CleanupStack::PushL(self);
       
   176 	self->ConstructL();
       
   177 	return self;
       
   178 	}
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CAtSmsNack::NewL
       
   182 // other items were commented in a header
       
   183 // ---------------------------------------------------------------------------
       
   184 CAtSmsNack* CAtSmsNack::NewL(CGlobalPhonemanager& aGloblePhone, 
       
   185                              CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
   186 	{
       
   187 	CAtSmsNack* self=CAtSmsNack::NewLC(aGloblePhone, 
       
   188                                        aCtsyDispatcherCallback);
       
   189 	CleanupStack::Pop(self);
       
   190 	return self;
       
   191 	}
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // CAtSmsNack::ConstructL
       
   195 // other items were commented in a header
       
   196 // ---------------------------------------------------------------------------
       
   197 void CAtSmsNack::ConstructL()
       
   198 	{
       
   199 	CAtCommandBase::ConstructL();
       
   200 	}
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CAtSmsNack::SetNackTpdu
       
   204 // other items were commented in a header
       
   205 // ---------------------------------------------------------------------------
       
   206 void CAtSmsNack::SetNackTpdu(TPtrC8 aRpError)
       
   207 	{
       
   208 	iRpError = aRpError;
       
   209 	}
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // CAtSmsNack::StartRequest
       
   213 // other items were commented in a header
       
   214 // ---------------------------------------------------------------------------
       
   215 void CAtSmsNack::StartRequest()
       
   216 	{
       
   217 	ExecuteCommand();
       
   218 	}
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // CAtSmsNack::ExecuteCommand
       
   222 // other items were commented in a header
       
   223 // ---------------------------------------------------------------------------
       
   224 void CAtSmsNack::ExecuteCommand()
       
   225 	{
       
   226 	LOGTEXT(_L8("CAtSmsNack::ExecuteCommand called"));
       
   227 	iTxBuffer.Zero();
       
   228 	TInt pduLen = iRpError.Length();
       
   229 	TBuf8<KLtsyGenericBufferSize> nackAsciiData;
       
   230 	nackAsciiData.Zero();
       
   231 	SmsAtUtil::AppendDataToAscii(nackAsciiData,iRpError);
       
   232 	iTxBuffer.Format(KCNMAForNack,pduLen);
       
   233 	iTxBuffer.Append(nackAsciiData);
       
   234 	iTxBuffer.Append(KLtsyCtrlZChar);
       
   235 	Write();
       
   236 	}
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // CAtSmsNack::EventSignal
       
   240 // other items were commented in a header
       
   241 // ---------------------------------------------------------------------------
       
   242 void CAtSmsNack::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   243 /**
       
   244  * Handle the events from the comm port
       
   245  *ValidateExpectString
       
   246  * @param aSource denotes if event is due to read, write or timeout
       
   247  */
       
   248 	{
       
   249 	LOGTEXT3(_L8("CAtSmsNack::EventSignal iStatus=%D iSource=%D"),aStatus,aEventSource);
       
   250 	if(aStatus == KErrNone)
       
   251 		{
       
   252 		if((aEventSource == EWriteCompletion))
       
   253 			{
       
   254 			LOGTEXT(_L8("CAtSmsNack::EventSignal,EWriteCompletion!"));
       
   255 			return;
       
   256 			}
       
   257 		aStatus = iError;
       
   258 		}
       
   259 	Complete();
       
   260 	iPhoneGlobals.iEventSignalActive = EFalse;
       
   261 	iCtsyDispatcherCallback.CallbackSmsAckSmsStoredComp(aStatus);
       
   262 	}
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // CAtSmsNack::ParseResponseL
       
   266 // other items were commented in a header
       
   267 // ---------------------------------------------------------------------------
       
   268 void CAtSmsNack::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   269 	{
       
   270 	if (CurrentLine().Match(KLtsyOkString) == 0)
       
   271 		{
       
   272 		iError = KErrNone;
       
   273 		}
       
   274 	else
       
   275 		{
       
   276 		iError = KErrGeneral;
       
   277 		}
       
   278 	}
       
   279 
       
   280 //End of file