|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * CBtMtmUi class |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "btmtmui.h" |
|
22 #include "btmtmuidebug.h" |
|
23 |
|
24 //#include <obexmtmuilayer.h> |
|
25 #include <MuiuMsvProgressReporterOperation.h> |
|
26 #include <btcmtm.h> |
|
27 #include <mtmuidef.hrh> |
|
28 #include <mtclreg.h> |
|
29 #include <obexutilsuilayer.h> |
|
30 #include <Obexutils.rsg> |
|
31 #include <msvuids.h> |
|
32 #include <msvids.h> |
|
33 #include <obexconstants.h> |
|
34 |
|
35 |
|
36 // CONSTANTS |
|
37 const TInt KBtMtmUiToFromFieldBuffer = 80; |
|
38 const TInt KBtMtmUiConnectionTimeout = 20000000; |
|
39 const TInt KBtMtmUiConnectionPutTimeout = 0; |
|
40 const TInt KBtMtmUiObexPort = 1; |
|
41 const TInt KBtMtmUiAddressMaxLength = 3; |
|
42 |
|
43 // ENUMS |
|
44 enum TBtMtmAsyncCmds |
|
45 { |
|
46 EBtMtmCmdSend |
|
47 }; |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 // C++ default constructor can NOT contain any code, that |
|
52 // might leave. |
|
53 // |
|
54 CBtMtmUi::CBtMtmUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
55 : CBaseMtmUi( aBaseMtm, aRegisteredMtmDll ) |
|
56 { |
|
57 FLOG( _L( "[CBtMtmUi] CBtMtmUi: CBtMtmUi\t" ) ); |
|
58 } |
|
59 |
|
60 // Two-phased constructor. |
|
61 CBtMtmUi* CBtMtmUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
62 { |
|
63 FLOG( _L( "[CBtMtmUi] CBtMtmUi: NewL\t" ) ); |
|
64 CBtMtmUi* self = new( ELeave ) CBtMtmUi( aBaseMtm, aRegisteredMtmDll ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // Destructor |
|
72 CBtMtmUi::~CBtMtmUi() |
|
73 { |
|
74 FLOG( _L( "[CBtMtmUi] CBtMtmUi: ~CBtMtmUi\t" ) ); |
|
75 delete iClientRegistry; |
|
76 } |
|
77 |
|
78 // Symbian OS default constructor can leave. |
|
79 void CBtMtmUi::ConstructL() |
|
80 { |
|
81 FLOG( _L( "[CBtMtmUi] CBtMtmUi: ConstructL\t" ) ); |
|
82 CBaseMtmUi::ConstructL(); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // GetResourceFileName(...) |
|
87 // return progress status. |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CBtMtmUi::GetResourceFileName( TFileName& aFileName ) const |
|
91 { |
|
92 FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetResourceFileName\t" ) ); |
|
93 aFileName = KObexUtilsFileDrive; |
|
94 aFileName += KDC_RESOURCE_FILES_DIR; |
|
95 aFileName += KObexUtilsResourceFileName; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // QueryCapability(TUid aCapability, TInt& aResponse) |
|
100 // return capability of mtm. |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 TInt CBtMtmUi::QueryCapability(TUid aCapability, TInt& aResponse) |
|
104 { |
|
105 // Querying of menu availablility is done in syni. |
|
106 FLOG( _L( "[CBtMtmUi] CBtMtmUi: QueryCapability\t" ) ); |
|
107 if( aCapability.iUid == KUidMsvMtmUiQueryCanPrintMsgValue ) |
|
108 { |
|
109 aResponse = ETrue; |
|
110 return KErrNone; |
|
111 } |
|
112 return CBaseMtmUi::QueryCapability( aCapability, aResponse ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // InvokeSyncFunctionL(...) |
|
117 // Invoke sync -function from BaseMTM. |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CBtMtmUi::InvokeSyncFunctionL( TInt aFunctionId, |
|
121 const CMsvEntrySelection& aSelection, |
|
122 TDes8& aParameter ) |
|
123 { |
|
124 FLOG( _L( "[CBtMtmUi] CBtMtmUi: InvokeSyncFunctionL\t" ) ); |
|
125 CBaseMtmUi::InvokeSyncFunctionL( aFunctionId, aSelection, aParameter ); |
|
126 } |
|
127 |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CreateL(...) |
|
131 // Entry creation forbidden. |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 CMsvOperation* CBtMtmUi::CreateL( const TMsvEntry& /*aEntry*/, |
|
135 CMsvEntry& /*aParent*/, |
|
136 TRequestStatus& /*aStatus*/ ) |
|
137 { |
|
138 FLOG( _L( "[CBtMtmUi] CBtMtmUi: CreateL\t" ) ); |
|
139 // Entries created through utility functions. |
|
140 User::Leave( KErrNotSupported ); |
|
141 // Return value is needed for removing compilation errors |
|
142 return NULL; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // OpenL(TRequestStatus& aStatus) |
|
147 // handles opening entry. |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 CMsvOperation* CBtMtmUi::OpenL( TRequestStatus& aStatus ) |
|
151 { |
|
152 FLOG( _L( "[CBtMtmUi] CBtMtmUi: OpenL\t" ) ); |
|
153 const TMsvEntry& context = iBaseMtm.Entry().Entry(); |
|
154 const TUid type( context.iType ); |
|
155 if( ( type == KUidMsvMessageEntry ) && |
|
156 ( ( context.Parent() == KMsvSentEntryIdValue ) |
|
157 ||( context.Parent() == KMsvGlobalInBoxIndexEntryIdValue ) ) ) |
|
158 { |
|
159 // Message is in the sent folder, so can't be edited |
|
160 return ViewL( aStatus ); |
|
161 } |
|
162 return EditL( aStatus ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // OpenL(...) |
|
167 // handles opening entry using selection. |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 CMsvOperation* CBtMtmUi::OpenL( TRequestStatus& aStatus, |
|
171 const CMsvEntrySelection& aSelection ) |
|
172 { |
|
173 iBaseMtm.Entry().SetEntryL( aSelection.At(0) ); |
|
174 return OpenL( aStatus ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CloseL(TRequestStatus& aStatus) |
|
179 // Closes entry. |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 CMsvOperation* CBtMtmUi::CloseL( TRequestStatus& aStatus ) |
|
183 { |
|
184 FLOG( _L( "[CBtMtmUi] CBtMtmUi: CloseL\t" ) ); |
|
185 CMsvCompletedOperation* op = CMsvCompletedOperation::NewL( Session(), |
|
186 Type(), |
|
187 KNullDesC8, |
|
188 KMsvLocalServiceIndexEntryId, |
|
189 aStatus); |
|
190 return op; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------- |
|
194 // CloseL(TRequestStatus& aStatus) |
|
195 // Closes entry using selection. |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 CMsvOperation* CBtMtmUi::CloseL( |
|
199 TRequestStatus& aStatus, |
|
200 const CMsvEntrySelection& aSelection) |
|
201 { |
|
202 iBaseMtm.Entry().SetEntryL( aSelection.At(0) ); |
|
203 return CloseL( aStatus ); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // EditL(...) |
|
208 // Handles message sending using selection. |
|
209 // --------------------------------------------------------- |
|
210 // |
|
211 CMsvOperation* CBtMtmUi::EditL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection ) |
|
212 { |
|
213 FLOG( _L( "[BtMtmUi] CBtMtmUi: EditL 1 \t" ) ); |
|
214 iBaseMtm.Entry().SetEntryL( aSelection.At(0) ); |
|
215 return EditL( aStatus ); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // EditL(TRequestStatus& aStatus) |
|
220 // Handles message sending over Bluetooth. |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 CMsvOperation* CBtMtmUi::EditL( TRequestStatus& aStatus ) |
|
224 { |
|
225 FLOG( _L( "[BtMtmUi] CBtMtmUi: EditL 2 \t" ) ); |
|
226 TInt resourceId; |
|
227 TInt retVal=0; |
|
228 switch( iBaseMtm.Entry().Entry().iType.iUid ) |
|
229 { |
|
230 case KUidMsvMessageEntryValue: |
|
231 { |
|
232 if( iBaseMtm.Entry().Entry().Parent() != KMsvDraftEntryId && |
|
233 iBaseMtm.Entry().Entry().Parent() != KMsvGlobalOutBoxIndexEntryId ) |
|
234 { |
|
235 // Edit/"use" entries in the Inbox |
|
236 return LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() ); |
|
237 } |
|
238 else |
|
239 { |
|
240 HBufC* password = HBufC::NewL(1); |
|
241 CleanupStack::PushL( password ); // 1st push |
|
242 BaseMtm().LoadMessageL(); |
|
243 |
|
244 TBTDevAddr address; |
|
245 |
|
246 CBtClientMtm::SBtcCmdSendParams sendparams; |
|
247 sendparams.iTimeouts.iConnectTimeout = KBtMtmUiConnectionTimeout; |
|
248 sendparams.iTimeouts.iPutTimeout = KBtMtmUiConnectionPutTimeout; |
|
249 sendparams.iRemoteObexPort = KBtMtmUiObexPort; |
|
250 sendparams.iConnectPassword = password; |
|
251 |
|
252 iDiscovery = CBTEngDiscovery::NewL(this); |
|
253 CBTDevice* iDevice = CBTDevice::NewL( ); |
|
254 |
|
255 |
|
256 if ( iDiscovery->SearchRemoteDevice( iDevice ) == KErrNone ) |
|
257 { |
|
258 iWaiter.Start(); |
|
259 |
|
260 if ( iState ==KErrNone) |
|
261 { |
|
262 address = iDevice->BDAddr(); |
|
263 FLOG( _L( "[BtMtmUi] CBtMtmUi:SearchRemoteChannelL \t" ) ); |
|
264 retVal = iDiscovery->RemoteProtocolChannelQuery(address, TUUID(KBTSdpObjectPush)); |
|
265 if(retVal == KErrNone) |
|
266 { |
|
267 iWaiter.Start(); |
|
268 } |
|
269 } |
|
270 if ( retVal != KErrNone ||iState != KErrNone ) |
|
271 { |
|
272 resourceId = R_BT_DEV_NOT_AVAIL; |
|
273 TObexUtilsUiLayer::ShowInformationNoteL( resourceId ); |
|
274 CleanupStack::PopAndDestroy(3); // BtDevice, BtConnection, password |
|
275 return CMsvCompletedOperation::NewL( |
|
276 Session(), |
|
277 Type(), |
|
278 KNullDesC8, |
|
279 KMsvLocalServiceIndexEntryId, |
|
280 aStatus ); |
|
281 } |
|
282 sendparams.iRemoteObexPort = iClientChannel; |
|
283 |
|
284 TPtrC8 ptr8 = address.Des(); |
|
285 TBuf16<KBtMtmUiAddressMaxLength> convertedaddress16;//48 bits |
|
286 // Bt address conversion |
|
287 TInt i; |
|
288 for( i=0; i<3; i++ ) |
|
289 { |
|
290 TUint16 word = ptr8[( i*2 )+1]; |
|
291 word = ( TUint16 )( word << 8 ); |
|
292 word = ( TUint16 )( word + ptr8[i*2] ); |
|
293 convertedaddress16.Append( &word, 1 ); |
|
294 } |
|
295 |
|
296 BaseMtm().AddAddresseeL( convertedaddress16 ); |
|
297 } |
|
298 else |
|
299 { |
|
300 CleanupStack::PopAndDestroy(3); // BtDevice, BTConnection, password |
|
301 FLOG( _L( "[BTMTMUI] CBtMtmUi:CMsvCompletedOperation NewL\t" ) ); |
|
302 return CMsvCompletedOperation::NewL( |
|
303 Session(), |
|
304 Type(), |
|
305 KNullDesC8, |
|
306 KMsvLocalServiceIndexEntryId, |
|
307 aStatus ); |
|
308 } |
|
309 |
|
310 CMsvEntrySelection* sel = new( ELeave ) CMsvEntrySelection(); |
|
311 CleanupStack::PushL( sel ); // 4th push |
|
312 sel->AppendL( BaseMtm().Entry().EntryId() ); |
|
313 |
|
314 CMsvOperationWait* waiter = CMsvOperationWait::NewLC(); // 5th push |
|
315 |
|
316 TBuf<KBtMtmUiToFromFieldBuffer> toFrom; |
|
317 resourceId = R_BT_SEND_OUTBOX_SENDING; |
|
318 TObexUtilsUiLayer::ReadResourceL( toFrom, resourceId ); |
|
319 |
|
320 BaseMtm().SaveMessageL(); |
|
321 |
|
322 TMsvEntry newTEntry( iBaseMtm.Entry().Entry() ); |
|
323 newTEntry.iDetails.Set( toFrom ); |
|
324 newTEntry.SetVisible( ETrue ); |
|
325 newTEntry.SetInPreparation( ETrue ); |
|
326 |
|
327 iBaseMtm.Entry().ChangeL( newTEntry ); |
|
328 |
|
329 CMsvEntry* entry = |
|
330 BaseMtm().Session().GetEntryL( KMsvDraftEntryId ); |
|
331 |
|
332 CleanupStack::PushL( entry ); // 6th push |
|
333 |
|
334 CMsvOperation* moveOp = entry->MoveL( |
|
335 *sel, |
|
336 KMsvGlobalOutBoxIndexEntryId, |
|
337 waiter->iStatus ); |
|
338 |
|
339 CleanupStack::PopAndDestroy( entry ); |
|
340 |
|
341 waiter->Start(); |
|
342 CActiveScheduler::Start(); |
|
343 delete moveOp; |
|
344 |
|
345 CMsvProgressReporterOperation* reporter |
|
346 = CMsvProgressReporterOperation::NewL( Session(), aStatus ); |
|
347 CleanupStack::PushL( reporter ); // 6th push |
|
348 |
|
349 TPckgBuf<CBtClientMtm::SBtcCmdSendParams> paramBuf( sendparams ); |
|
350 |
|
351 CMsvOperation* op = BaseMtm().InvokeAsyncFunctionL( |
|
352 EBtMtmCmdSend, |
|
353 *sel, |
|
354 paramBuf, |
|
355 reporter->RequestStatus() ); |
|
356 |
|
357 // ownership of op transfered to reporter |
|
358 reporter->SetOperationL( op ); |
|
359 |
|
360 aStatus = KRequestPending; |
|
361 |
|
362 CleanupStack::Pop( reporter ); |
|
363 CleanupStack::PopAndDestroy(3); // waiter, sel, password |
|
364 return reporter; |
|
365 } |
|
366 } |
|
367 case KUidMsvServiceEntryValue: |
|
368 case KUidMsvAttachmentEntryValue: |
|
369 case KUidMsvFolderEntryValue: |
|
370 { |
|
371 User::Leave( KErrNotSupported ); |
|
372 } |
|
373 default: |
|
374 { |
|
375 break; |
|
376 } |
|
377 } |
|
378 |
|
379 CMsvCompletedOperation* op = CMsvCompletedOperation::NewL( |
|
380 Session(), |
|
381 Type(), |
|
382 KNullDesC8, |
|
383 KMsvLocalServiceIndexEntryId, |
|
384 aStatus ); |
|
385 aStatus = KRequestPending; |
|
386 return op; |
|
387 } |
|
388 |
|
389 // --------------------------------------------------------- |
|
390 // ViewL(TRequestStatus& aStatus) |
|
391 // Handles viewing of received object. |
|
392 // --------------------------------------------------------- |
|
393 // |
|
394 CMsvOperation* CBtMtmUi::ViewL( TRequestStatus& aStatus ) |
|
395 { |
|
396 FLOG( _L( "[CBtMtmUi] CBtMtmUi: ViewL\t" ) ); |
|
397 return LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() ); |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // ViewL(...) |
|
402 // Handles viewing of received object using selection. |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 CMsvOperation* CBtMtmUi::ViewL( TRequestStatus& aStatus, |
|
406 const CMsvEntrySelection& aSelection ) |
|
407 { |
|
408 FLOG( _L( "[CBtMtmUi] CBtMtmUi: ViewL 1\t" ) ); |
|
409 iBaseMtm.Entry().SetEntryL( aSelection.At(0) ); |
|
410 return ViewL( aStatus ); |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------- |
|
414 // CopyFromL(...) |
|
415 // Not supported. |
|
416 // --------------------------------------------------------- |
|
417 // |
|
418 CMsvOperation* CBtMtmUi::CopyFromL( const CMsvEntrySelection& /*aSelection*/, |
|
419 TMsvId /*aTargetId*/, |
|
420 TRequestStatus& /*aStatus*/ ) |
|
421 { |
|
422 User::Leave( KErrNotSupported ); |
|
423 // Return value is needed for removing compilation errors |
|
424 return NULL; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------- |
|
428 // MoveFromL(...) |
|
429 // Not supported. |
|
430 // --------------------------------------------------------- |
|
431 // |
|
432 CMsvOperation* CBtMtmUi::MoveFromL( const CMsvEntrySelection& /*aSelection*/, |
|
433 TMsvId /*aTargetId*/, |
|
434 TRequestStatus& /*aStatus*/ ) |
|
435 { |
|
436 User::Leave( KErrNotSupported ); |
|
437 // Return value is needed for removing compilation errors |
|
438 return NULL; |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------- |
|
442 // MoveToL(...) |
|
443 // Not supported. |
|
444 // --------------------------------------------------------- |
|
445 // |
|
446 CMsvOperation* CBtMtmUi::MoveToL( const CMsvEntrySelection& /*aSelection*/, |
|
447 TRequestStatus& /*aStatus*/) |
|
448 { |
|
449 User::Leave( KErrNotSupported ); |
|
450 // Return value is needed for removing compilation errors |
|
451 return NULL; |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------- |
|
455 // CopyToL(...) |
|
456 // Not supported. |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 CMsvOperation* CBtMtmUi::CopyToL( const CMsvEntrySelection& /*aSelection*/, |
|
460 TRequestStatus& /*aStatus*/) |
|
461 { |
|
462 User::Leave( KErrNotSupported ); |
|
463 // Return value is needed for removing compilation errors |
|
464 return NULL; |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // DisplayProgressSummary(const TDesC8& aProgress) const |
|
469 // calls leaving DisplayProgressSummaryL -function and |
|
470 // traps the error. |
|
471 // --------------------------------------------------------- |
|
472 // |
|
473 TInt CBtMtmUi::DisplayProgressSummary( const TDesC8& aProgress ) const |
|
474 { |
|
475 TInt retVal = KErrNone; |
|
476 TRAP( retVal, retVal = DisplayProgressSummaryL( aProgress ) ); |
|
477 return retVal; |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------- |
|
481 // DisplayProgressSummary(const TDesC8& aProgress) const |
|
482 // calls leaving DisplayProgressSummaryL -function and |
|
483 // traps the error. |
|
484 // --------------------------------------------------------- |
|
485 // |
|
486 TInt CBtMtmUi::DisplayProgressSummaryL( const TDesC8& aProgress ) const |
|
487 { |
|
488 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL\t" ) ); |
|
489 TInt resourceId; |
|
490 if( ( !aProgress.Length() ) || ( aProgress.Size() == sizeof( TMsvLocalOperationProgress ) ) ) |
|
491 { |
|
492 // Probably a CMsvCompletedOperation |
|
493 return KErrCancel; |
|
494 } |
|
495 TPckgBuf<TObexMtmProgress> paramPack; |
|
496 paramPack.Copy( aProgress ); |
|
497 TObexMtmProgress& progress = paramPack(); |
|
498 |
|
499 const TObexMtmProgress::TSendState progressType = progress.iSendState; |
|
500 const TInt error = progress.iError; |
|
501 if ( error == KErrInUse ) |
|
502 { |
|
503 resourceId = R_BT_DEV_NOT_AVAIL; |
|
504 TObexUtilsUiLayer::ShowInformationNoteL( resourceId ); |
|
505 return KErrNone; |
|
506 } |
|
507 |
|
508 switch( progressType ) |
|
509 { |
|
510 case TObexMtmProgress::EDisconnected: |
|
511 { |
|
512 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: EDisconnected\t" ) ); |
|
513 // Allowed to send again. |
|
514 resourceId = R_BT_DATA_SENT; |
|
515 TObexUtilsUiLayer::ShowInformationNoteL( resourceId ); |
|
516 break; |
|
517 } |
|
518 case TObexMtmProgress::ESendError: |
|
519 { |
|
520 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendError\t" ) ); |
|
521 if( error == KErrIrObexClientNoDevicesFound ) |
|
522 { |
|
523 resourceId = R_BT_DEV_NOT_AVAIL; |
|
524 TObexUtilsUiLayer::ShowInformationNoteL( resourceId ); |
|
525 } |
|
526 else |
|
527 { |
|
528 resourceId = R_BT_FAILED_TO_SEND; |
|
529 TObexUtilsUiLayer::ShowErrorNoteL( resourceId ); |
|
530 } |
|
531 break; |
|
532 } |
|
533 case TObexMtmProgress::ESendComplete: |
|
534 { |
|
535 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendComplete\t" ) ); |
|
536 break; |
|
537 } |
|
538 case TObexMtmProgress::EInitialise: |
|
539 case TObexMtmProgress::EConnect: |
|
540 case TObexMtmProgress::EConnectAttemptComplete: |
|
541 case TObexMtmProgress::ESendObject: |
|
542 case TObexMtmProgress::ESendNextObject: |
|
543 { |
|
544 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendObject\t" ) ); |
|
545 return KErrCancel; |
|
546 } |
|
547 case TObexMtmProgress::EUserCancelled: |
|
548 { |
|
549 FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: EUserCancelled\t" ) ); |
|
550 return KErrCancel; |
|
551 } |
|
552 default: |
|
553 { |
|
554 FTRACE( FPrint(_L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: Default\t %d" ), progressType ) ); |
|
555 return KErrCancel; |
|
556 } |
|
557 } |
|
558 return KErrNone; |
|
559 } |
|
560 |
|
561 |
|
562 // --------------------------------------------------------- |
|
563 // GetProgress(...) |
|
564 // return progress status. |
|
565 // --------------------------------------------------------- |
|
566 // |
|
567 TInt CBtMtmUi::GetProgress( const TDesC8& aProgress, |
|
568 TBuf<EProgressStringMaxLen>& aReturnString, |
|
569 TInt& aTotalEntryCount, |
|
570 TInt& aEntriesDone, |
|
571 TInt& aCurrentEntrySize, |
|
572 TInt& aCurrentBytesTrans ) const |
|
573 { |
|
574 TInt resourceId; |
|
575 FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetProgress\t" ) ); |
|
576 TPckgBuf<TObexMtmProgress> paramPack; |
|
577 paramPack.Copy( aProgress ); |
|
578 TObexMtmProgress& progress = paramPack(); |
|
579 const TObexMtmProgress::TSendState progressType = progress.iSendState; |
|
580 aTotalEntryCount = progress.iTotalEntryCount; |
|
581 aEntriesDone = progress.iEntriesDone; |
|
582 aCurrentEntrySize = progress.iCurrentEntrySize; |
|
583 aCurrentBytesTrans = progress.iCurrentBytesTrans; |
|
584 |
|
585 if( aTotalEntryCount > 1 ) // This is for progress bar multisending |
|
586 { |
|
587 aCurrentEntrySize = 0; |
|
588 } |
|
589 |
|
590 switch( progressType ) |
|
591 { |
|
592 case TObexMtmProgress::ENullOp: |
|
593 case TObexMtmProgress::ESendError: |
|
594 { |
|
595 aReturnString = KNullDesC; |
|
596 break; |
|
597 } |
|
598 case TObexMtmProgress::EInitialise: |
|
599 case TObexMtmProgress::EConnect: |
|
600 case TObexMtmProgress::EConnectAttemptComplete: |
|
601 { |
|
602 resourceId = R_BT_CONNECTING; |
|
603 TRAPD( retVal, TObexUtilsUiLayer::ReadResourceL( aReturnString, resourceId ) ); |
|
604 retVal=retVal; //avoid warning |
|
605 // Leave causes progress note to be empty. Not fatal |
|
606 break; |
|
607 } |
|
608 case TObexMtmProgress::ESendObject: |
|
609 case TObexMtmProgress::ESendNextObject: |
|
610 case TObexMtmProgress::ESendComplete: |
|
611 { |
|
612 resourceId = R_BT_SENDING_DATA; |
|
613 TRAPD( retVal, TObexUtilsUiLayer::ReadResourceL( aReturnString, resourceId ) ); |
|
614 // Leave causes progress note to be empty. Not fatal |
|
615 retVal=retVal; //avoid warning |
|
616 break; |
|
617 } |
|
618 case TObexMtmProgress::EDisconnected: |
|
619 { |
|
620 break; |
|
621 } |
|
622 default: |
|
623 { |
|
624 return KErrCancel; |
|
625 } |
|
626 } |
|
627 FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetProgress Done\t" ) ); |
|
628 return KErrNone; |
|
629 } |
|
630 |
|
631 // --------------------------------------------------------- |
|
632 // LaunchEditorApplicationL(...) |
|
633 // Launch viewer for selected object. The first is object's |
|
634 // recognition(document handler). |
|
635 // --------------------------------------------------------- |
|
636 // |
|
637 CMsvOperation* CBtMtmUi::LaunchEditorApplicationL( TRequestStatus& aStatus, |
|
638 CMsvSession& aSession) |
|
639 { |
|
640 FLOG( _L( "[CommonMtmUi] CBtMtmUi: LaunchEditorApplicationL\t" ) ); |
|
641 CMsvEntry* message; |
|
642 message = &iBaseMtm.Entry(); |
|
643 return TObexUtilsUiLayer::LaunchEditorApplicationOperationL( aSession, message, aStatus ); |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------- |
|
647 // GetClientMtmLC(TUid aMtmType) |
|
648 // Handles MTM registration. |
|
649 // --------------------------------------------------------- |
|
650 // |
|
651 CBaseMtm* CBtMtmUi::GetClientMtmLC( TUid aMtmType ) |
|
652 { |
|
653 FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetClientMtmLC\t" ) ); |
|
654 if( !iClientRegistry ) |
|
655 { |
|
656 iClientRegistry = CClientMtmRegistry::NewL( Session() ); |
|
657 } |
|
658 CBaseMtm* mtm = iClientRegistry->NewMtmL( aMtmType ); |
|
659 CleanupStack::PushL( mtm ); |
|
660 return mtm; |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------- |
|
664 // DeleteFromL(TUid aMtmType) |
|
665 // passes entry selection to Base for deletion. |
|
666 // --------------------------------------------------------- |
|
667 // |
|
668 CMsvOperation* CBtMtmUi::DeleteFromL( const CMsvEntrySelection& aSelection, |
|
669 TRequestStatus& aStatus ) |
|
670 { |
|
671 return CBaseMtmUi::DeleteFromL( aSelection, aStatus ); |
|
672 } |
|
673 |
|
674 // --------------------------------------------------------- |
|
675 // DeleteServiceL(...) |
|
676 // has no service, just complete it. |
|
677 // --------------------------------------------------------- |
|
678 // |
|
679 CMsvOperation* CBtMtmUi::DeleteServiceL( const TMsvEntry& /*aService*/, |
|
680 TRequestStatus& aStatus) |
|
681 { |
|
682 return CMsvCompletedOperation::NewL( |
|
683 Session(), |
|
684 Type(), |
|
685 KNullDesC8, |
|
686 KMsvLocalServiceIndexEntryId, |
|
687 aStatus); |
|
688 } |
|
689 |
|
690 // --------------------------------------------------------- |
|
691 // ReplyL(...) |
|
692 // Reply is forbidden. |
|
693 // --------------------------------------------------------- |
|
694 // |
|
695 CMsvOperation* CBtMtmUi::ReplyL( TMsvId /*aDestination*/, |
|
696 TMsvPartList /*aPartlist*/, |
|
697 TRequestStatus& /*aCompletionStatus*/ ) |
|
698 { |
|
699 User::Leave( KErrNotSupported ); |
|
700 // Return value is needed for removing compilation errors |
|
701 return NULL; |
|
702 } |
|
703 |
|
704 // --------------------------------------------------------- |
|
705 // ForwardL(...) |
|
706 // Forward is forbidden. |
|
707 // --------------------------------------------------------- |
|
708 // |
|
709 CMsvOperation* CBtMtmUi::ForwardL( TMsvId /*aDestination*/, |
|
710 TMsvPartList /*aPartList*/, |
|
711 TRequestStatus& /*aCompletionStatus*/ ) |
|
712 { |
|
713 User::Leave( KErrNotSupported ); |
|
714 // Return value is needed for removing compilation errors |
|
715 return NULL; |
|
716 } |
|
717 |
|
718 // --------------------------------------------------------- |
|
719 // CancelL(...) |
|
720 // No MS way of sending a message from the outbox, so no need to cancel. |
|
721 // Just complete it. |
|
722 // --------------------------------------------------------- |
|
723 // |
|
724 CMsvOperation* CBtMtmUi::CancelL( TRequestStatus& aStatus, |
|
725 const CMsvEntrySelection& /*aSelection*/) |
|
726 { |
|
727 return CMsvCompletedOperation::NewL( |
|
728 Session(), |
|
729 Type(), |
|
730 KNullDesC8, |
|
731 KMsvLocalServiceIndexEntryId, |
|
732 aStatus, |
|
733 KErrNone); |
|
734 } |
|
735 |
|
736 // ----------------------------------------------------------------------------- |
|
737 // CBtMtmUi::ServiceSearchComplete |
|
738 // ----------------------------------------------------------------------------- |
|
739 // |
|
740 void CBtMtmUi::ServiceSearchComplete( const RSdpRecHandleArray& /*aResult*/, |
|
741 TUint /*aTotalRecordsCount*/, TInt /*aErr */) |
|
742 { |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CBtMtmUi::AttributeSearchComplete( |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CBtMtmUi::AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, |
|
750 const RSdpResultArray& aAttr, |
|
751 TInt aErr ) |
|
752 { |
|
753 iState=aErr; |
|
754 if (aErr==KErrNone) |
|
755 { |
|
756 RSdpResultArray results=aAttr; |
|
757 iDiscovery->ParseRfcommChannel(results,iClientChannel); |
|
758 } |
|
759 iWaiter.AsyncStop(); |
|
760 } |
|
761 // ----------------------------------------------------------------------------- |
|
762 // CBtMtmUi::ServiceAttributeSearchComplete |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 void CBtMtmUi::ServiceAttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, |
|
766 const RSdpResultArray& /*aAttr*/, |
|
767 TInt /*aErr*/ ) |
|
768 { |
|
769 } |
|
770 // ----------------------------------------------------------------------------- |
|
771 // CBtMtmUi::DeviceSearchComplete |
|
772 // ----------------------------------------------------------------------------- |
|
773 // |
|
774 void CBtMtmUi::DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt aErr ) |
|
775 { |
|
776 iState=aErr; |
|
777 iWaiter.AsyncStop(); |
|
778 } |
|
779 |
|
780 // End of File |