24
|
1 |
// Copyright (c) 1997-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 |
// Gets the default ServiceCentreAddress (SCA) stored in the ME (Mobile Equipment). AT+CSCA?
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "NOTIFY.H"
|
|
19 |
#include "mSMSMESS.H"
|
|
20 |
#include "mSMSCSCA.H"
|
|
21 |
#include "mSLOGGER.H"
|
|
22 |
#include "ATIO.H"
|
|
23 |
|
|
24 |
//
|
|
25 |
// Macros
|
|
26 |
//
|
|
27 |
// This macro is used to help keep un-intereting details outside of the main code
|
|
28 |
// in this file. The macro uses logging functions and always prefixes writes to the
|
|
29 |
// log with the name of the class which is implemented in this file. This macro must
|
|
30 |
// only be used by code in this file.
|
|
31 |
#ifdef __LOGDEB__
|
|
32 |
_LIT8(KLogEntry,"CATSmsGetSCAddress::%S\t%S");
|
|
33 |
#define LOCAL_LOGTEXT(function,text) {_LIT8(F,function);_LIT8(T,text);LOGTEXT3(KLogEntry,&F,&T);}
|
|
34 |
#else
|
|
35 |
#define LOCAL_LOGTEXT(function,text)
|
|
36 |
#endif
|
|
37 |
|
|
38 |
|
|
39 |
CATSmsGetSCAddress* CATSmsGetSCAddress::NewL (CATIO* aIo, CTelObject* aTelObject,
|
|
40 |
CATInit* aInit, CPhoneGlobals* aGlobals)
|
|
41 |
{
|
|
42 |
CATSmsGetSCAddress* self = new (ELeave) CATSmsGetSCAddress(aIo, aTelObject, aInit, aGlobals);
|
|
43 |
CleanupStack::PushL(self);
|
|
44 |
self->ConstructL();
|
|
45 |
CleanupStack::Pop();
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
CATSmsGetSCAddress::CATSmsGetSCAddress(CATIO* aIo, CTelObject* aTelObject,
|
|
50 |
CATInit* aInit, CPhoneGlobals* aGlobals)
|
|
51 |
:CATSmsCommands(aIo, aTelObject, aInit, aGlobals)
|
|
52 |
{}
|
|
53 |
|
|
54 |
void CATSmsGetSCAddress::Start(TTsyReqHandle aTsyReqHandle, TAny* aParam)
|
|
55 |
{
|
|
56 |
iReqHandle = aTsyReqHandle;
|
|
57 |
|
|
58 |
if (aParam!=NULL)
|
|
59 |
{
|
|
60 |
TTsySmsp* info = static_cast<TTsySmsp*>(aParam);
|
|
61 |
iSmspInfo.iBufSize = info->iBufSize;
|
|
62 |
iSmspInfo.iBufPtr = info->iBufPtr;
|
|
63 |
}
|
|
64 |
|
|
65 |
TInt ret=CATSmsCommands::RequestATCommand(EGetSCAFromPhone);
|
|
66 |
if(ret!=KErrNone)
|
|
67 |
Complete(ret);
|
|
68 |
}
|
|
69 |
|
|
70 |
void CATSmsGetSCAddress::EventSignal(TEventSource aSource)
|
|
71 |
{
|
|
72 |
LOCAL_LOGTEXT("EventSignal","");
|
|
73 |
|
|
74 |
//
|
|
75 |
// Allow base class to handle events for us
|
|
76 |
LOCAL_LOGTEXT("EventSignal","Giving base class a chance to handle the event");
|
|
77 |
CATSmsCommands::EventSignal(aSource);
|
|
78 |
|
|
79 |
//
|
|
80 |
// Check if base class has completed our request
|
|
81 |
if(CATSmsCommands::RequestATCompleted()==EGetSCAFromPhone)
|
|
82 |
{
|
|
83 |
LOCAL_LOGTEXT("EventSignal","Base class has completed request to get SCA");
|
|
84 |
LOGTEXT2(_L8("completion code: %d"),iRequestError);
|
|
85 |
|
|
86 |
if(iRequestError!=KErrNone)
|
|
87 |
{
|
|
88 |
Complete(iRequestError);
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
//
|
|
93 |
// Copy SCA from base class to our client
|
|
94 |
TRAPD(ret,CreateSmspListL());
|
|
95 |
Complete(ret);
|
|
96 |
}
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
void CATSmsGetSCAddress::Stop(TTsyReqHandle aTsyReqHandle)
|
|
101 |
//
|
|
102 |
// Attempts to halt the process
|
|
103 |
//
|
|
104 |
{
|
|
105 |
__ASSERT_ALWAYS(aTsyReqHandle == iReqHandle,Panic(EIllegalTsyReqHandle));
|
|
106 |
LOCAL_LOGTEXT("Stop","Cancelling command");
|
|
107 |
|
|
108 |
CATSmsCommands::RequestATCommandCancel();
|
|
109 |
}
|
|
110 |
|
|
111 |
void CATSmsGetSCAddress::Complete(TInt aError)
|
|
112 |
{
|
|
113 |
Complete(aError,EReadCompletion);
|
|
114 |
}
|
|
115 |
|
|
116 |
void CATSmsGetSCAddress::CreateSmspListL()
|
|
117 |
{
|
|
118 |
// Create SMSP list and return the one entry
|
|
119 |
CMobilePhoneSmspList* list=CMobilePhoneSmspList::NewL();
|
|
120 |
CleanupStack::PushL(list);
|
|
121 |
list->SetMaxNumberEntries(1);
|
|
122 |
|
|
123 |
RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry;
|
|
124 |
smspEntry.iIndex=0;
|
|
125 |
smspEntry.iValidParams=RMobileSmsMessaging::KSCAIncluded;
|
|
126 |
smspEntry.iServiceCentre=CATSmsCommands::iRequestSCA;
|
|
127 |
|
|
128 |
list->AddEntryL(smspEntry);
|
|
129 |
|
|
130 |
*(iSmspInfo.iBufPtr) = list->StoreLC(); // Stream the list to optimise the size of it.
|
|
131 |
*(iSmspInfo.iBufSize) = (*(iSmspInfo.iBufPtr))->Size(); // Store the size of the streamed list to be passed back to the client.
|
|
132 |
|
|
133 |
CleanupStack::Pop(); // pop the CBufBase allocated by StoreLC
|
|
134 |
CleanupStack::PopAndDestroy(list); // pop AND destroy the list.
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
void CATSmsGetSCAddress::Complete(TInt aError,TEventSource aSource)
|
|
139 |
{
|
|
140 |
LOCAL_LOGTEXT("Complete","Enter function");
|
|
141 |
LOGTEXT2(_L8("Error Code : %d"), aError);
|
|
142 |
|
|
143 |
CATCommands::Complete(aError,aSource);
|
|
144 |
if (iReqHandle != 0)
|
|
145 |
{
|
|
146 |
if (aError==KErrCancel)
|
|
147 |
{
|
|
148 |
CMobileSmsMessaging* smsMsg = static_cast<CMobileSmsMessaging*>(iTelObject);
|
|
149 |
// Always returns KErrNone
|
|
150 |
(void)smsMsg->CompleteSmspListCancel(iReqHandle);
|
|
151 |
}
|
|
152 |
else
|
|
153 |
iTelObject->ReqCompleted(iReqHandle, aError);
|
|
154 |
}
|
|
155 |
if (aSource==EWriteCompletion)
|
|
156 |
iIo->Read();
|
|
157 |
}
|
|
158 |
|
|
159 |
void CATSmsGetSCAddress::CompleteWithIOError(TEventSource /*aSource*/,TInt aStatus)
|
|
160 |
{
|
|
161 |
iIo->WriteAndTimerCancel(this);
|
|
162 |
iTelObject->ReqCompleted(iReqHandle, aStatus);
|
|
163 |
}
|