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 "cusdreadwriteimp.h" |
|
16 |
|
17 #include "cusdcommandhandler.h" |
|
18 #include "debug.h" |
|
19 |
|
20 CCUSSDReadMessageImpl* CCUSSDReadMessageImpl::NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession) |
|
21 { |
|
22 TRACE_FUNC_ENTRY |
|
23 CCUSSDReadMessageImpl* self = new(ELeave) CCUSSDReadMessageImpl(aCallback, aUssdSession); |
|
24 TRACE_FUNC_EXIT |
|
25 return self; |
|
26 } |
|
27 |
|
28 CCUSSDReadMessageImpl::CCUSSDReadMessageImpl(MUSSDCallback* aCallback, |
|
29 RMobileUssdMessaging& aUssdSession): |
|
30 CActive(CActive::EPriorityStandard), |
|
31 iCallback(aCallback), |
|
32 iUssdSession(aUssdSession) |
|
33 { |
|
34 TRACE_FUNC_ENTRY |
|
35 CActiveScheduler::Add(this); |
|
36 TRACE_FUNC_EXIT |
|
37 } |
|
38 |
|
39 CCUSSDReadMessageImpl::~CCUSSDReadMessageImpl() |
|
40 { |
|
41 TRACE_FUNC_ENTRY |
|
42 Cancel(); |
|
43 TRACE_FUNC_EXIT |
|
44 } |
|
45 |
|
46 void CCUSSDReadMessageImpl::RunL() |
|
47 { |
|
48 TRACE_FUNC_ENTRY |
|
49 iCallback->HandleReadMessageComplete(iStatus.Int()); |
|
50 TRACE_FUNC_EXIT |
|
51 } |
|
52 |
|
53 void CCUSSDReadMessageImpl::DoCancel() |
|
54 { |
|
55 TRACE_FUNC_ENTRY |
|
56 iUssdSession.CancelAsyncRequest(EMobileUssdMessagingReceiveMessage); |
|
57 TRACE_FUNC_EXIT |
|
58 } |
|
59 |
|
60 TInt CCUSSDReadMessageImpl::ReadUSSDMessage(TDes8& aReceivedData, |
|
61 RMobileUssdMessaging::TMobileUssdAttributesV1& aUssdReadAttribute) |
|
62 { |
|
63 TRACE_FUNC_ENTRY |
|
64 |
|
65 TInt retCode = KErrNone; |
|
66 if(!IsActive()) |
|
67 { |
|
68 TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUssdReadAttribute); |
|
69 iUssdSession.ReceiveMessage(iStatus, aReceivedData, msgAttributes); |
|
70 SetActive(); |
|
71 } |
|
72 else |
|
73 { |
|
74 retCode = KErrInUse; |
|
75 } |
|
76 |
|
77 TRACE_FUNC_EXIT |
|
78 return retCode; |
|
79 } |
|
80 |
|
81 CCUSSDSendMessageImpl* CCUSSDSendMessageImpl::NewL(MUSSDCallback* aCallback, |
|
82 RMobileUssdMessaging& aUssdSession) |
|
83 { |
|
84 TRACE_FUNC_ENTRY |
|
85 CCUSSDSendMessageImpl* self = new(ELeave) CCUSSDSendMessageImpl(aCallback, aUssdSession); |
|
86 TRACE_FUNC_EXIT |
|
87 return self; |
|
88 } |
|
89 |
|
90 CCUSSDSendMessageImpl::CCUSSDSendMessageImpl(MUSSDCallback* aCallback, |
|
91 RMobileUssdMessaging& aUssdSession): |
|
92 CActive(CActive::EPriorityStandard), |
|
93 iCallback(aCallback), |
|
94 iUssdSession(aUssdSession) |
|
95 { |
|
96 TRACE_FUNC_ENTRY |
|
97 CActiveScheduler::Add(this); |
|
98 TRACE_FUNC_EXIT |
|
99 } |
|
100 |
|
101 void CCUSSDSendMessageImpl::RunL() |
|
102 { |
|
103 TRACE_FUNC_ENTRY |
|
104 iCallback->HandleSendMessageComplete(iStatus.Int()); |
|
105 TRACE_FUNC_EXIT |
|
106 } |
|
107 |
|
108 void CCUSSDSendMessageImpl::DoCancel() |
|
109 { |
|
110 TRACE_FUNC_ENTRY |
|
111 iUssdSession.CancelAsyncRequest(EMobileUssdMessagingSendMessage); |
|
112 TRACE_FUNC_EXIT |
|
113 } |
|
114 |
|
115 TInt CCUSSDSendMessageImpl::HandleSendUSSDCmd(const TDesC8& aCmd, |
|
116 RMobileUssdMessaging::TMobileUssdAttributesV1& aUSSDAttribute) |
|
117 { |
|
118 TRACE_FUNC_ENTRY |
|
119 TInt retCode = KErrNone; |
|
120 if(!IsActive()) |
|
121 { |
|
122 // Get USSD messaging caps |
|
123 RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps; |
|
124 RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps); |
|
125 |
|
126 iUssdSession.GetCaps(ussdCapsPckg); |
|
127 ussdCaps=ussdCapsPckg(); |
|
128 |
|
129 if(ussdCaps.iUssdFormat != RMobileUssdMessaging::KCapsPackedString) |
|
130 { |
|
131 retCode = KErrArgument; |
|
132 } |
|
133 else |
|
134 { |
|
135 // we only support packed strings? |
|
136 aUSSDAttribute.iFormat = RMobileUssdMessaging::EFormatPackedString; |
|
137 TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUSSDAttribute); |
|
138 iUssdSession.SendMessage(iStatus, aCmd, msgAttributes); |
|
139 SetActive(); |
|
140 } |
|
141 } |
|
142 else |
|
143 { |
|
144 retCode = KErrInUse; |
|
145 } |
|
146 TRACE_FUNC_EXIT |
|
147 return retCode; |
|
148 } |
|
149 |
|
150 CCUSSDSendMessageImpl::~CCUSSDSendMessageImpl() |
|
151 { |
|
152 TRACE_FUNC_ENTRY |
|
153 Cancel(); |
|
154 TRACE_FUNC_EXIT |
|
155 } |
|