|
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 // |
|
15 |
|
16 #include "mmtsy.h" |
|
17 #include "testdef.h" |
|
18 #include "ETELMM.H" |
|
19 #include <et_clsvr.h> |
|
20 #include "Dmmlog.h" |
|
21 |
|
22 |
|
23 // |
|
24 // CLineDMmTsy |
|
25 // |
|
26 CLineDMmTsy* CLineDMmTsy::NewL(CPhoneDMmTsy *aPhone,CPhoneFactoryDummyBase* aFac) |
|
27 { |
|
28 |
|
29 CLineDMmTsy* line=new(ELeave) CLineDMmTsy(aPhone,aFac); |
|
30 CleanupStack::PushL(line); |
|
31 line->ConstructL(); |
|
32 CleanupStack::Pop(); |
|
33 return line; |
|
34 } |
|
35 |
|
36 CLineDMmTsy::CLineDMmTsy(CPhoneDMmTsy *aPhone, CPhoneFactoryDummyBase* aFac) |
|
37 :CLineDummyBase(aFac), iPhone(aPhone) |
|
38 {} |
|
39 |
|
40 void CLineDMmTsy::ConstructL() |
|
41 { |
|
42 CLineDummyBase::ConstructL(); |
|
43 LOGTEXT(_L8("CLineDMmTsy created")); |
|
44 } |
|
45 |
|
46 |
|
47 CLineDMmTsy::~CLineDMmTsy() |
|
48 { |
|
49 LOGTEXT(_L8("CLineDMmTsy destroyed")); |
|
50 } |
|
51 |
|
52 |
|
53 CTelObject* CLineDMmTsy::OpenNewObjectByNameL(const TDesC& aName) |
|
54 { |
|
55 // An existing call opened by a client - client provides name of call to open |
|
56 if((aName.Compare(DMMTSY_CALL_NAME1)==KErrNone) || |
|
57 (aName.Compare(DMMTSY_CALL_NAME2)==KErrNone) || |
|
58 (aName.Compare(DMMTSY_CALL_NAME3)==KErrNone)) |
|
59 |
|
60 return REINTERPRET_CAST(CTelObject*,CCallDMmTsy::NewL(iPhone,FacPtr())); |
|
61 |
|
62 return NULL; |
|
63 } |
|
64 |
|
65 CTelObject* CLineDMmTsy::OpenNewObjectL(TDes& aNewName) |
|
66 { |
|
67 // A new call opened by a client will have its name allocated by the TSY |
|
68 aNewName.Append(_L("Call")); |
|
69 aNewName.AppendNum(++iCallObjectCount); |
|
70 |
|
71 return CCallDMmTsy::NewL(iPhone,FacPtr()); |
|
72 } |
|
73 |
|
74 |
|
75 CTelObject::TReqMode CLineDMmTsy::ReqModeL(const TInt aIpc) |
|
76 { |
|
77 // ReqModeL is called from the server's CTelObject::ReqAnalyserL |
|
78 // in order to check the type of request it has |
|
79 |
|
80 // The following are example request types for this dummy TSY |
|
81 // All TSYs do not have to have these request types but they have been given |
|
82 // "sensible" values in this test code |
|
83 |
|
84 CTelObject::TReqMode ret=0; |
|
85 switch (aIpc) |
|
86 { |
|
87 // |
|
88 // Non-flow control requests |
|
89 // |
|
90 case EMobileLineGetMobileLineStatus: |
|
91 break; |
|
92 // |
|
93 // Notification Requests |
|
94 // |
|
95 case EMobileLineNotifyMobileLineStatusChange: |
|
96 ret=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
97 break; |
|
98 // |
|
99 // Cancel Requests |
|
100 // |
|
101 case EMobileLineNotifyMobileLineStatusChangeCancel: |
|
102 User::Leave(KErrNotSupported); |
|
103 break; |
|
104 |
|
105 default: |
|
106 ret=CLineBase::ReqModeL(aIpc); |
|
107 break; |
|
108 } |
|
109 return ret; |
|
110 } |
|
111 |
|
112 |
|
113 TInt CLineDMmTsy::RegisterNotification(const TInt aIpc) |
|
114 { |
|
115 // RegisterNotification is called when the server recognises that this notification |
|
116 // is being posted for the first time on this sub-session object. |
|
117 |
|
118 // It enables the TSY to "turn on" any regular notification messages that it may |
|
119 // receive from the phone |
|
120 |
|
121 switch (aIpc) |
|
122 { |
|
123 case EMobileLineNotifyMobileLineStatusChange: |
|
124 LOGTEXT(_L8("CLineDMmTsy: RegisterNotification - Line Status Change ")); |
|
125 return KErrNone; |
|
126 default: |
|
127 // Unknown or invalid sms IPC |
|
128 return KErrNotSupported; |
|
129 } |
|
130 } |
|
131 |
|
132 TInt CLineDMmTsy::DeregisterNotification(const TInt aIpc) |
|
133 { |
|
134 // DeregisterNotification is called when the server recognises that this notification |
|
135 // will not be posted again because the last client to have a handle on this sub-session |
|
136 // object has just closed the handle. |
|
137 |
|
138 // It enables the TSY to "turn off" any regular notification messages that it may |
|
139 // receive from the phone |
|
140 |
|
141 switch (aIpc) |
|
142 { |
|
143 case EMobileLineNotifyMobileLineStatusChange: |
|
144 LOGTEXT(_L8("CLineDMmTsy: DeregisterNotification - Line Status Change")); |
|
145 return KErrNone; |
|
146 default: |
|
147 // Unknown or invalid sms IPC |
|
148 return KErrNotSupported; |
|
149 } |
|
150 } |
|
151 |
|
152 TInt CLineDMmTsy::NumberOfSlotsL(const TInt aIpc) |
|
153 { |
|
154 // NumberOfSlotsL is called by the server when it is registering a new notification |
|
155 // It enables the TSY to tell the server how many buffer slots to allocate for |
|
156 // "repost immediately" notifications that may trigger before clients collect them |
|
157 |
|
158 TInt numberOfSlots=1; |
|
159 switch (aIpc) |
|
160 { |
|
161 case EMobileLineNotifyMobileLineStatusChange: |
|
162 LOGTEXT(_L8("CLineDMmTsy: Registered with 5 slots")); |
|
163 numberOfSlots=5; |
|
164 break; |
|
165 default: |
|
166 // Unknown or invalid Phone IPC |
|
167 User::Leave(KErrNotSupported); |
|
168 break; |
|
169 } |
|
170 return numberOfSlots; |
|
171 } |
|
172 |
|
173 TInt CLineDMmTsy::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc, |
|
174 const TDataPackage& aPackage) |
|
175 { |
|
176 // ExtFunc is called by the server when it has a "extended", i.e. non-core ETel request |
|
177 // for the TSY to process |
|
178 // A request handle, request type and request data are passed to the TSY |
|
179 |
|
180 TAny* dataPtr=aPackage.Ptr1(); |
|
181 |
|
182 // The request data has to extracted from TDataPackage and the TAny* pointers have to |
|
183 // be "cast" to the expected request data type |
|
184 |
|
185 switch (aIpc) |
|
186 { |
|
187 // |
|
188 // Non-flow control requests |
|
189 // |
|
190 case EMobileLineGetMobileLineStatus: |
|
191 return GetMobileLineStatus(aTsyReqHandle, |
|
192 REINTERPRET_CAST(RMobileCall::TMobileCallStatus*, dataPtr)); |
|
193 |
|
194 // |
|
195 // Notification Requests |
|
196 // |
|
197 case EMobileLineNotifyMobileLineStatusChange: |
|
198 return NotifyMobileLineStatusChange(aTsyReqHandle, |
|
199 REINTERPRET_CAST(RMobileCall::TMobileCallStatus*, dataPtr)); |
|
200 |
|
201 // |
|
202 // Cancel Requests |
|
203 // |
|
204 case EMobileLineNotifyMobileLineStatusChangeCancel: |
|
205 return NotifyMobileLineStatusChangeCancel(aTsyReqHandle); |
|
206 |
|
207 default: |
|
208 return KErrNotSupported; |
|
209 } |
|
210 } |
|
211 |
|
212 TInt CLineDMmTsy::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle) |
|
213 { |
|
214 // CancelService is called by the server when it is "cleaning-up" any still outstanding |
|
215 // asynchronous requests before closing a client's sub-session. |
|
216 // This will happen if a client closes its R-class handle without cancelling outstanding |
|
217 // asynchronous requests. |
|
218 |
|
219 switch (aIpc) |
|
220 { |
|
221 // |
|
222 // Cancel Requests |
|
223 // |
|
224 case EMobileLineNotifyMobileLineStatusChange: |
|
225 return NotifyMobileLineStatusChangeCancel(aTsyReqHandle); |
|
226 default: |
|
227 return CLineBase::CancelService(aIpc,aTsyReqHandle); |
|
228 } |
|
229 } |
|
230 |
|
231 TInt CLineDMmTsy::GetCaps(const TTsyReqHandle aTsyReqHandle,RLine::TCaps* aCaps) |
|
232 { |
|
233 //set the aux voice bit |
|
234 aCaps->iFlags |= DMMTSY_MOBILE_LINE_AUX_VOICE; |
|
235 |
|
236 ReqCompleted(aTsyReqHandle,KErrNone); |
|
237 return KErrNone; |
|
238 } |
|
239 |
|
240 |
|
241 /***********************************************************************************/ |
|
242 // |
|
243 // The following methods are called from ExtFunc and/or CancelService. |
|
244 // Each of these will process a TSY request or cancel a TSY request |
|
245 // Here, example values are returned or checked within this dummy TSY in order to ensure |
|
246 // that the integrity of the data passed to/from client is maintained |
|
247 // |
|
248 /***********************************************************************************/ |
|
249 |
|
250 TInt CLineDMmTsy::GetMobileLineStatus(const TTsyReqHandle aTsyReqHandle,RMobileCall::TMobileCallStatus* aStatus) |
|
251 { |
|
252 LOGTEXT(_L8("CLineDMmTsy::GetMobileLineStatus called")); |
|
253 *aStatus=DMMTSY_CALL_STATUS1; |
|
254 ReqCompleted(aTsyReqHandle,KErrNone); |
|
255 return KErrNone; |
|
256 } |
|
257 |
|
258 TInt CLineDMmTsy::NotifyMobileLineStatusChange(const TTsyReqHandle aTsyReqHandle, RMobileCall::TMobileCallStatus* aStatus) |
|
259 { |
|
260 if (!iNotifyMobileLineStatusChange++) |
|
261 { |
|
262 LOGTEXT(_L8("CLineDMmTsy::NotifyMobileLineStatusChange called")); |
|
263 *aStatus=DMMTSY_CALL_STATUS2; |
|
264 iPhone->AddDelayedReq(aTsyReqHandle,this); |
|
265 } |
|
266 return KErrNone; |
|
267 } |
|
268 |
|
269 TInt CLineDMmTsy::NotifyMobileLineStatusChangeCancel(const TTsyReqHandle aTsyReqHandle) |
|
270 { |
|
271 LOGTEXT(_L8("CLineDMmTsy::NotifyMobileLineStatusChangeCancel called")); |
|
272 iPhone->RemoveDelayedReq(aTsyReqHandle); |
|
273 ReqCompleted(aTsyReqHandle,KErrCancel); |
|
274 return KErrNone; |
|
275 } |
|
276 |