32
|
1 |
/* Copyright (c) 2010 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 |
* Initial Contributors:
|
|
8 |
* Nokia Corporation - initial contribution.
|
|
9 |
*
|
|
10 |
* Contributors:
|
|
11 |
* Description :
|
|
12 |
*
|
|
13 |
*/
|
|
14 |
|
|
15 |
#include "ussdsendmessageimpl.h"
|
|
16 |
|
|
17 |
#include "cusdcommandhandler.h"
|
|
18 |
#include "debug.h"
|
|
19 |
|
|
20 |
CUSSDSendMessageImpl* CUSSDSendMessageImpl::NewL(MUSSDCallback* aCallback,
|
|
21 |
RMobileUssdMessaging& aUssdSession)
|
|
22 |
{
|
|
23 |
TRACE_FUNC_ENTRY
|
|
24 |
CUSSDSendMessageImpl* self = new(ELeave) CUSSDSendMessageImpl(aCallback, aUssdSession);
|
|
25 |
TRACE_FUNC_EXIT
|
|
26 |
return self;
|
|
27 |
}
|
|
28 |
|
|
29 |
CUSSDSendMessageImpl::CUSSDSendMessageImpl(MUSSDCallback* aCallback,
|
|
30 |
RMobileUssdMessaging& aUssdSession):
|
|
31 |
CActive(CActive::EPriorityStandard),
|
|
32 |
iCallback(aCallback),
|
|
33 |
iUssdSession(aUssdSession)
|
|
34 |
{
|
|
35 |
TRACE_FUNC_ENTRY
|
|
36 |
CActiveScheduler::Add(this);
|
|
37 |
TRACE_FUNC_EXIT
|
|
38 |
}
|
|
39 |
|
|
40 |
void CUSSDSendMessageImpl::RunL()
|
|
41 |
{
|
|
42 |
TRACE_FUNC_ENTRY
|
|
43 |
iCallback->HandleSendMessageComplete(iStatus.Int());
|
|
44 |
TRACE_FUNC_EXIT
|
|
45 |
}
|
|
46 |
|
|
47 |
void CUSSDSendMessageImpl::DoCancel()
|
|
48 |
{
|
|
49 |
TRACE_FUNC_ENTRY
|
|
50 |
iUssdSession.CancelAsyncRequest(EMobileUssdMessagingSendMessage);
|
|
51 |
TRACE_FUNC_EXIT
|
|
52 |
}
|
|
53 |
|
|
54 |
TInt CUSSDSendMessageImpl::SendUSSDCmd(const TDesC8& aCmd,
|
|
55 |
RMobileUssdMessaging::TMobileUssdAttributesV1& aUSSDAttribute)
|
|
56 |
{
|
|
57 |
TRACE_FUNC_ENTRY
|
|
58 |
TInt retCode = KErrNone;
|
|
59 |
if(!IsActive())
|
|
60 |
{
|
|
61 |
// Get USSD messaging caps
|
|
62 |
RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps;
|
|
63 |
RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps);
|
|
64 |
|
|
65 |
iUssdSession.GetCaps(ussdCapsPckg);
|
|
66 |
ussdCaps=ussdCapsPckg();
|
|
67 |
|
|
68 |
if(ussdCaps.iUssdFormat != RMobileUssdMessaging::KCapsPackedString)
|
|
69 |
{
|
|
70 |
retCode = KErrArgument;
|
|
71 |
}
|
|
72 |
else
|
|
73 |
{
|
|
74 |
// we only support packed strings?
|
|
75 |
aUSSDAttribute.iFormat = RMobileUssdMessaging::EFormatPackedString;
|
|
76 |
TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUSSDAttribute);
|
|
77 |
iUssdSession.SendMessage(iStatus, aCmd, msgAttributes);
|
|
78 |
SetActive();
|
|
79 |
}
|
|
80 |
}
|
|
81 |
else
|
|
82 |
{
|
|
83 |
retCode = KErrInUse;
|
|
84 |
}
|
|
85 |
TRACE_FUNC_EXIT
|
|
86 |
return retCode;
|
|
87 |
}
|
|
88 |
|
|
89 |
CUSSDSendMessageImpl::~CUSSDSendMessageImpl()
|
|
90 |
{
|
|
91 |
TRACE_FUNC_ENTRY
|
|
92 |
Cancel();
|
|
93 |
TRACE_FUNC_EXIT
|
|
94 |
}
|