1 /* |
|
2 * Copyright (c) 2005-2009 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: PC Connectivity Plug-in implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include <obexconstantsinternal.h> |
|
23 #endif |
|
24 #include "sconpcconnplugin.h" |
|
25 #include "sconftp.h" |
|
26 #include "sconpcconnpluginutils.h" |
|
27 #include "sconservicetimer.h" |
|
28 #include "catalogspcconnectivityplugin.h" |
|
29 #include "debug.h" |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT(KSConFTPLibName, "sconftp.dll"); |
|
34 const TInt KSConFTPUidValue = 0x10009D8D; |
|
35 const TUid KSConFTPUid = {KSConFTPUidValue}; |
|
36 |
|
37 // Folder listing type from IrObex specification |
|
38 _LIT8( KSConFolderListType, "x-obex/folder-listing" ); |
|
39 // Folder listing type from IrObex specification |
|
40 _LIT8( KSConCapabilityObjectType, "x-obex/capability" ); |
|
41 // PCD types |
|
42 _LIT8( KSConPCDObjectType, "application/vnd.nokia.pcd" ); |
|
43 _LIT8( KSConPCDXMLObjectType, "application/vnd.nokia.conml+xml" ); |
|
44 _LIT8( KSConPCDWBXMLObjectType, "application/vnd.nokia.conml+wbxml" ); |
|
45 _LIT8( KSConPCDXMLObjectType2, "application/vnd.nokia.pcd+xml" ); |
|
46 _LIT8( KSConPCDWBXMLObjectType2, "application/vnd.nokia.pcd+wbxml" ); |
|
47 _LIT( K_C_ROOT, "C:\\" ); |
|
48 |
|
49 // PCD header commands |
|
50 const TInt KSCon_PCD_TAG = 0x003A; |
|
51 const TInt KSCon_PCD_CMD_COPY = 0x0037; |
|
52 const TInt KSCon_PCD_CMD_MOVE_OR_RENAME = 0x0038; |
|
53 const TInt KSCon_PCD_CMD_SET_PERMISSION = 0x0039; |
|
54 // PCD header parameters |
|
55 const TInt KSCon_PCD_PAR_FULL_PERMISSION = 0x0040; |
|
56 const TInt KSCon_PCD_PAR_READ_ONLY_PERMISSION = 0x0041; |
|
57 |
|
58 |
|
59 const TInt KSConBufSize = 262144; // 256KB |
|
60 // Time (in milliseconds) for the timer |
|
61 const TInt KSConTimeOutValue = 180000000; |
|
62 // Flags used to indicate SetPath commands |
|
63 const TInt KSConNULLSetPath = 0x00; |
|
64 |
|
65 const TInt KSConHeaderMaxLength = 256; |
|
66 |
|
67 // ============================= MEMBER FUNCTIONS =============================== |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CSConPCConnplugin::NewL() |
|
71 // Two-phase constructing |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CSConPCConnplugin* CSConPCConnplugin::NewL() |
|
75 { |
|
76 TRACE_FUNC_ENTRY; |
|
77 CSConPCConnplugin* self = new ( ELeave ) CSConPCConnplugin(); |
|
78 CleanupStack::PushL( self ); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop( self ); |
|
81 TRACE_FUNC_EXIT; |
|
82 return( self ); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSConPCConnplugin::~CSConPCConnplugin() |
|
87 // Destructor |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CSConPCConnplugin::~CSConPCConnplugin() |
|
91 { |
|
92 TRACE_FUNC_ENTRY; |
|
93 |
|
94 // Disconnect from services. |
|
95 Disconnect(); |
|
96 |
|
97 delete iBuffer; |
|
98 iBuffer = NULL; |
|
99 |
|
100 if ( iServiceTimer ) |
|
101 { |
|
102 iServiceTimer->Cancel(); |
|
103 } |
|
104 |
|
105 delete iServiceTimer; |
|
106 iServiceTimer = NULL; |
|
107 |
|
108 delete iCatalogs; |
|
109 iCatalogs = NULL; |
|
110 delete iCatalogsMimeType; |
|
111 iCatalogsMimeType = NULL; |
|
112 |
|
113 iMimeArray.Reset(); |
|
114 iMimeArray.Close(); |
|
115 |
|
116 delete iShutdownWatcher; |
|
117 iShutdownWatcher = NULL; |
|
118 |
|
119 TRACE_FUNC_EXIT; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CSConPCConnplugin::IsOBEXActive() |
|
124 // Returns active status of OBEX session |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TBool CSConPCConnplugin::IsOBEXActive() |
|
128 { |
|
129 TRACE_FUNC; |
|
130 return iSessionActive; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CSConPCConnplugin::NotifyShutdown() |
|
135 // System is shutting down |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CSConPCConnplugin::NotifyShutdown() |
|
139 { |
|
140 TRACE_FUNC; |
|
141 iShutdownInProgress = ETrue; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CSConPCConnplugin::LoadFTPDllL() |
|
146 // Loads sconftp.dll module |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CSConPCConnplugin::LoadFTPDllL() |
|
150 { |
|
151 TRACE_FUNC_ENTRY; |
|
152 // Dynamically load DLL |
|
153 User::LeaveIfError( iFTPlib.Load( KSConFTPLibName ) ); |
|
154 if ( iFTPlib.Type()[1] != KSConFTPUid ) |
|
155 { |
|
156 LOGGER_WRITE( "KSConFTPUidValue incorrect" ); |
|
157 iFTPlib.Close(); |
|
158 User::Leave( KErrNotFound ); |
|
159 } |
|
160 TSConCreateCSConFTPFunc CreateCSConFTPL = |
|
161 (TSConCreateCSConFTPFunc)iFTPlib.Lookup(1); |
|
162 iFTPHandler = (CSConFTP*)CreateCSConFTPL(); |
|
163 TRACE_FUNC_EXIT; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CSConPCConnplugin::Disconnect() |
|
168 // Closes initialized services |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CSConPCConnplugin::Disconnect() |
|
172 { |
|
173 TRACE_FUNC_ENTRY; |
|
174 |
|
175 iLinkAdapter.Close(); |
|
176 iSocketServer.Close(); |
|
177 |
|
178 //Disconnect from server |
|
179 iPCConnSession.Close(); |
|
180 iPCConnSessionConnected = EFalse; |
|
181 |
|
182 if ( iStartTimer != EFalse ) |
|
183 { |
|
184 iServiceTimer->Cancel(); |
|
185 iServiceTimer->StartTimer(); |
|
186 } |
|
187 |
|
188 delete iObject; |
|
189 iObject = NULL; |
|
190 |
|
191 if ( iFTPHandler ) |
|
192 { |
|
193 delete iFTPHandler; |
|
194 iFTPHandler = NULL; |
|
195 iFTPlib.Close(); |
|
196 } |
|
197 if ( iFileObject ) |
|
198 { |
|
199 delete iFileObject; |
|
200 iFileObject = NULL; |
|
201 } |
|
202 if ( iCatalogsConnected ) |
|
203 { |
|
204 iCatalogs->Close(); |
|
205 iCatalogsConnected = EFalse; |
|
206 iCatalogsMimeTypesExist = EFalse; |
|
207 } |
|
208 TRACE_FUNC_EXIT; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CSConPCConnplugin::ErrorIndication( TInt aError ) |
|
213 // MObexServerNotify implementation |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CSConPCConnplugin::ErrorIndication( TInt aError ) |
|
217 { |
|
218 TRACE_FUNC_ENTRY; |
|
219 LOGGER_WRITE_1( "aError : %d", aError ); |
|
220 |
|
221 if ( iFTPHandler ) |
|
222 { |
|
223 iFTPHandler->AbortFileTransfer( iObject ); |
|
224 } |
|
225 |
|
226 if ( iObject ) |
|
227 { |
|
228 delete iObject; |
|
229 iObject = NULL; |
|
230 } |
|
231 |
|
232 if ( iFileObject ) |
|
233 { |
|
234 iFileObject->Reset(); |
|
235 delete iFileObject; |
|
236 iFileObject = NULL; |
|
237 } |
|
238 |
|
239 if ( iPCConnSessionConnected ) |
|
240 { |
|
241 iPCConnSession.ResetServer(); |
|
242 } |
|
243 |
|
244 // Keep compiler happy |
|
245 (void)aError; |
|
246 |
|
247 delete iShutdownWatcher; |
|
248 iShutdownWatcher = NULL; |
|
249 |
|
250 if ( iLinkAdapter.IsOpen() ) |
|
251 { |
|
252 // Cancel ActivateActiveRequester & allow going to low power mode |
|
253 TInt err = iLinkAdapter.CancelLowPowerModeRequester(); |
|
254 LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err ); |
|
255 } |
|
256 |
|
257 TRACE_FUNC_EXIT; |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CSConPCConnplugin::AbortIndication() |
|
262 // MObexServerNotify implementation |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CSConPCConnplugin::AbortIndication() |
|
266 { |
|
267 TRACE_FUNC_ENTRY; |
|
268 |
|
269 if ( iFTPHandler ) |
|
270 { |
|
271 iFTPHandler->AbortFileTransfer( iObject ); |
|
272 } |
|
273 |
|
274 if ( iObject ) |
|
275 { |
|
276 delete iObject; |
|
277 iObject = NULL; |
|
278 } |
|
279 |
|
280 if ( iFileObject ) |
|
281 { |
|
282 iFileObject->Reset(); |
|
283 delete iFileObject; |
|
284 iFileObject = NULL; |
|
285 } |
|
286 |
|
287 if ( iPCConnSessionConnected ) |
|
288 { |
|
289 iPCConnSession.ResetServer(); |
|
290 } |
|
291 |
|
292 delete iShutdownWatcher; |
|
293 iShutdownWatcher = NULL; |
|
294 |
|
295 if ( iLinkAdapter.IsOpen() ) |
|
296 { |
|
297 // Cancel ActivateActiveRequester & allow going to low power mode |
|
298 TInt err = iLinkAdapter.CancelLowPowerModeRequester(); |
|
299 LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err ); |
|
300 } |
|
301 |
|
302 TRACE_FUNC_EXIT; |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CSConPCConnplugin::TransportUpIndication() |
|
307 // MObexServerNotify implementation |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CSConPCConnplugin::TransportUpIndication() |
|
311 { |
|
312 TRACE_FUNC; |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // CSConPCConnplugin::ObexConnectIndication( const TObexConnectInfo& |
|
317 // aRemoteInfo, const TDesC8& aInfo ) |
|
318 // MObexServerNotify implementation |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CSConPCConnplugin::ObexConnectIndication( const TObexConnectInfo& |
|
322 /*aRemoteInfo*/, const TDesC8& /*aInfo*/ ) |
|
323 { |
|
324 TRACE_FUNC_ENTRY; |
|
325 TInt err( KErrNone ); |
|
326 TInt catalogsErr( KErrNone ); |
|
327 iStartTimer = ETrue; |
|
328 |
|
329 if ( iMediaType == ESrcsMediaBT && iObexServer ) |
|
330 { |
|
331 TSockAddr remoteAddr; |
|
332 iObexServer->RemoteAddr( remoteAddr ); |
|
333 |
|
334 TBTSockAddr btSockAddr( remoteAddr ); |
|
335 TBTDevAddr devAddr = btSockAddr.BTAddr(); |
|
336 |
|
337 err = iSocketServer.Connect(); |
|
338 LOGGER_WRITE_1("iSocketServer.Connect err: %d", err ); |
|
339 if ( !err ) |
|
340 { |
|
341 err = iLinkAdapter.Open( iSocketServer, devAddr ); |
|
342 LOGGER_WRITE_1("iLinkAdapter.Open err: %d", err ); |
|
343 } |
|
344 // Ignore all BT link errors |
|
345 err = KErrNone; |
|
346 } |
|
347 |
|
348 //Connect to server |
|
349 if ( !iPCConnSessionConnected ) |
|
350 { |
|
351 LOGGER_WRITE("Try to connect to iPCConnSession"); |
|
352 err = iPCConnSession.Connect(); |
|
353 LOGGER_WRITE_1( "iPCConnSession.Connect returned : %d", err ); |
|
354 if ( err == KErrNone ) |
|
355 { |
|
356 iPCConnSessionConnected = ETrue; |
|
357 } |
|
358 } |
|
359 |
|
360 if ( err == KErrNone && !iFTPHandler ) |
|
361 { |
|
362 TRAP( err, LoadFTPDllL() ); |
|
363 LOGGER_WRITE_1( "LoadFTPDllL returned : %d", err ); |
|
364 } |
|
365 |
|
366 if ( err == KErrNone ) |
|
367 { |
|
368 iFTPHandler->SetProfile( EProprietary ); |
|
369 LOGGER_WRITE( "iServiceTimer->StopTimer()" ); |
|
370 iServiceTimer->Cancel(); |
|
371 iServiceTimer->StopTimer(); |
|
372 } |
|
373 |
|
374 if ( !iCatalogsConnected ) |
|
375 { |
|
376 LOGGER_WRITE( "CSConPCConnplugin::ObexConnectIndication() before iCatalogs->Connect()" ); |
|
377 catalogsErr = iCatalogs->Connect(); |
|
378 LOGGER_WRITE_1( "CSConPCConnplugin::ObexConnectIndication() iCatalogs->Connect() err: %d", catalogsErr ); |
|
379 if ( catalogsErr == KErrNone ) |
|
380 { |
|
381 LOGGER_WRITE( "CSConPCConnplugin::ObexConnectIndication() iCatalogs->Connect() success" ); |
|
382 iCatalogsConnected = ETrue; |
|
383 TRAPD( ret, iMimeArray = iCatalogs->SupportedMimeTypesL() ); |
|
384 if ( ret == KErrNone ) |
|
385 { |
|
386 LOGGER_WRITE_1( "iCatalogs->SupportedMimeTypesL count: %d", iMimeArray.Count() ); |
|
387 iCatalogsMimeTypesExist = ETrue; |
|
388 } |
|
389 } |
|
390 } |
|
391 TRACE_FUNC_EXIT; |
|
392 return TPCConnpluginUtils::ConvertFTPResponseCode( err ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CSConPCConnplugin::ObexDisconnectIndication( const TDesC8& ) |
|
397 // MObexServerNotify implementation |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 void CSConPCConnplugin::ObexDisconnectIndication( const TDesC8& ) |
|
401 { |
|
402 TRACE_FUNC_ENTRY; |
|
403 Disconnect(); |
|
404 TRACE_FUNC_EXIT; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CSConPCConnplugin::TransportDownIndication() |
|
409 // MObexServerNotify implementation |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 void CSConPCConnplugin::TransportDownIndication() |
|
413 { |
|
414 TRACE_FUNC_ENTRY; |
|
415 Disconnect(); |
|
416 if ( iBuffer ) |
|
417 { |
|
418 iBuffer->Reset(); |
|
419 } |
|
420 TRACE_FUNC_EXIT; |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CSConPCConnplugin::PutRequestIndication() |
|
425 // MObexServerNotify implementation |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 CObexBufObject* CSConPCConnplugin::PutRequestIndication() |
|
429 { |
|
430 TRACE_FUNC_ENTRY; |
|
431 TInt ret( KErrNone ); |
|
432 TInt err( KErrNone ); |
|
433 iPutError = KErrNone; |
|
434 |
|
435 if ( iBuffer ) |
|
436 { |
|
437 iBuffer->Reset(); |
|
438 } |
|
439 |
|
440 if ( iObject ) |
|
441 { |
|
442 delete iObject; |
|
443 iObject = NULL; |
|
444 } |
|
445 |
|
446 TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) ); |
|
447 |
|
448 if ( err != KErrNone ) |
|
449 { |
|
450 return NULL; |
|
451 } |
|
452 |
|
453 if ( !iFTPHandler ) |
|
454 { |
|
455 LOGGER_WRITE( "Creating iFTPHandler has failed" ); |
|
456 return NULL; |
|
457 } |
|
458 |
|
459 TRAP( err, ret = iFTPHandler->PutFileObjectInitL( iObject, iBuffer ) ); |
|
460 |
|
461 if ( err != KErrNone ) |
|
462 { |
|
463 LOGGER_WRITE_1( "iFTPHandler->PutFileObjectInitL() leaves: %d", err ); |
|
464 return NULL; |
|
465 } |
|
466 if ( ret != KErrNone ) |
|
467 { |
|
468 LOGGER_WRITE_1( "PutFileObjectInitL failed - returning error in next PutPacketIndication : %d", ret ); |
|
469 iPutError = ret; |
|
470 } |
|
471 iPutPacketIndicationCalled = EFalse; |
|
472 |
|
473 if ( !iShutdownWatcher ) |
|
474 { |
|
475 TRAP( err, iShutdownWatcher = CShutdownWatcher::NewL( this ) ); |
|
476 if ( err == KErrNone ) |
|
477 { |
|
478 iShutdownWatcher->StartShutdownWatcher(); |
|
479 } |
|
480 else |
|
481 { |
|
482 LOGGER_WRITE_1( "CShutdownWatcher::NewL leaves: %d", err ); |
|
483 } |
|
484 } |
|
485 |
|
486 if ( iLinkAdapter.IsOpen() ) |
|
487 { |
|
488 // request active BT mode (high power mode) |
|
489 err = iLinkAdapter.ActivateActiveRequester(); |
|
490 LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err ); |
|
491 } |
|
492 |
|
493 TRACE_FUNC_EXIT; |
|
494 return( iObject ); |
|
495 } |
|
496 |
|
497 // ----------------------------------------------------------------------------- |
|
498 // CSConPCConnplugin::PutPacketIndication() |
|
499 // MObexServerNotify implementation |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 TInt CSConPCConnplugin::PutPacketIndication() |
|
503 { |
|
504 TRACE_FUNC_ENTRY; |
|
505 TInt ret( KErrNone ); |
|
506 |
|
507 TBool catalogsMime( EFalse ); |
|
508 if ( iObject->Type().Length() > KSConHeaderMaxLength ) |
|
509 { |
|
510 LOGGER_WRITE("TypeHeader too big, return KErrNotSupported"); |
|
511 return TPCConnpluginUtils::ConvertFTPResponseCode( KErrNotSupported ); |
|
512 } |
|
513 TBuf8<KSConHeaderMaxLength> typeHeader( iObject->Type() ); |
|
514 TrimRightSpaceAndNull( typeHeader ); |
|
515 |
|
516 if ( iCatalogsConnected && IsCatalogsMimeType( TDataType( typeHeader ) ) ) |
|
517 { |
|
518 catalogsMime = ETrue; |
|
519 } |
|
520 |
|
521 if ( (TInt)iObject->Length() > 0 |
|
522 && typeHeader != KSConPCDWBXMLObjectType |
|
523 && typeHeader != KSConPCDWBXMLObjectType2 |
|
524 && !catalogsMime |
|
525 && typeHeader != KSConPCDObjectType ) |
|
526 { |
|
527 // normal file transfer |
|
528 if ( !iPutPacketIndicationCalled ) |
|
529 { |
|
530 // This is first check, need to check only once |
|
531 |
|
532 TFileName path; |
|
533 iFTPHandler->GetPath( path ); |
|
534 if ( path.CompareF( K_C_ROOT ) == 0 ) |
|
535 { |
|
536 // path forbidden |
|
537 ret = KErrAccessDenied; |
|
538 } |
|
539 else |
|
540 { |
|
541 if ( iPutError != KErrNone ) |
|
542 { |
|
543 ret = iPutError; |
|
544 LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() : PutError : %d", iPutError ); |
|
545 } |
|
546 else |
|
547 { |
|
548 // check required free space |
|
549 // if filesize is small ( <65k ) it fits into one package and its already saved to filesystem. |
|
550 // if file is larger, need to check is there enought free space in device. |
|
551 |
|
552 const TUint32 filesize = iObject->Length(); |
|
553 LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() filesize %d", filesize ); |
|
554 LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() iObject->BytesReceived() %d", iObject->BytesReceived() ); |
|
555 if ( filesize > iObject->BytesReceived() ) |
|
556 { |
|
557 LOGGER_WRITE( "CSConPCConnplugin::PutPacketIndication() : check freespace" ); |
|
558 // file does not fit into one obex packet, check is there enought free space in current drive |
|
559 if ( iFTPHandler->IsCurrentDiskSpaceBelowCritical( filesize ) ) |
|
560 { |
|
561 LOGGER_WRITE( "CSConPCConnplugin::PutPacketIndication() : returning KErrNoMemory" ); |
|
562 ret = KErrNoMemory; |
|
563 } |
|
564 } |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 if ( iShutdownInProgress ) |
|
570 { |
|
571 LOGGER_WRITE( "ShutdownInProgress, abort" ); |
|
572 ret = KErrDisconnected; |
|
573 } |
|
574 } |
|
575 |
|
576 if ( !iPutPacketIndicationCalled ) |
|
577 { |
|
578 // Need to check only once |
|
579 iPutPacketIndicationCalled = ETrue; |
|
580 |
|
581 //Check if filename is too long. |
|
582 TFileName path; |
|
583 iFTPHandler->GetPath( path ); |
|
584 if ( ret == KErrNone && path.Length() + iObject->Name().Length() > KMaxFileName ) |
|
585 { |
|
586 LOGGER_WRITE_1( "Name length overflow! : %d", path.Length() + iObject->Name().Length() ); |
|
587 ret = KErrBadName; |
|
588 } |
|
589 } |
|
590 |
|
591 if ( ret != KErrNone ) |
|
592 { |
|
593 if ( iFTPHandler ) |
|
594 { |
|
595 iFTPHandler->AbortFileTransfer( iObject ); |
|
596 } |
|
597 |
|
598 delete iObject; |
|
599 iObject = NULL; |
|
600 |
|
601 if ( iLinkAdapter.IsOpen() ) |
|
602 { |
|
603 // Cancel ActivateActiveRequester & allow going to low power mode |
|
604 TInt err = iLinkAdapter.CancelLowPowerModeRequester(); |
|
605 LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err ); |
|
606 } |
|
607 } |
|
608 |
|
609 LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication(): ret %d", ret ); |
|
610 return TPCConnpluginUtils::ConvertFTPResponseCode( ret ); |
|
611 } |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // CSConPCConnplugin::PutCompleteIndication() |
|
615 // MObexServerNotify implementation |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 TInt CSConPCConnplugin::PutCompleteIndication() |
|
619 { |
|
620 TRACE_FUNC_ENTRY; |
|
621 TInt ret( KErrNone ); |
|
622 TInt err( KErrNone ); |
|
623 |
|
624 if ( iLinkAdapter.IsOpen() ) |
|
625 { |
|
626 // Cancel ActivateActiveRequester & allow going to low power mode |
|
627 TInt err2 = iLinkAdapter.CancelLowPowerModeRequester(); |
|
628 LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err2 ); |
|
629 } |
|
630 |
|
631 if ( iObject->Type().Length() > KSConHeaderMaxLength ) |
|
632 { |
|
633 LOGGER_WRITE("TypeHeader too big, return KErrNotSupported"); |
|
634 delete iObject; |
|
635 iObject = NULL; |
|
636 |
|
637 iFTPHandler->DeleteTempFile(); |
|
638 return TPCConnpluginUtils::ConvertPCDResponseCode( KErrNotSupported ); |
|
639 } |
|
640 if ( iObject->Name().Length() > KSConHeaderMaxLength ) |
|
641 { |
|
642 LOGGER_WRITE("NameHeader too big, return KErrNotSupported"); |
|
643 delete iObject; |
|
644 iObject = NULL; |
|
645 |
|
646 iFTPHandler->DeleteTempFile(); |
|
647 return TPCConnpluginUtils::ConvertPCDResponseCode( KErrNotSupported ); |
|
648 } |
|
649 |
|
650 // check if ConML signal is received |
|
651 TBuf8<KSConHeaderMaxLength> typeHeader( iObject->Type() ); |
|
652 TBuf<KSConHeaderMaxLength> nameHeader( iObject->Name() ); |
|
653 TrimRightSpaceAndNull( typeHeader ); |
|
654 LOGGER_WRITE8_1("type: %S", &typeHeader); |
|
655 LOGGER_WRITE_1("name: %S", &nameHeader); |
|
656 LOGGER_WRITE_1("description: %S", &iObject->Description()); |
|
657 TInt size = iObject->BytesReceived(); |
|
658 TTime time = iObject->Time(); |
|
659 |
|
660 // shutdownWatcher is not needed anymore |
|
661 delete iShutdownWatcher; |
|
662 iShutdownWatcher = NULL; |
|
663 |
|
664 if ( IsCatalogsMimeType( TDataType( typeHeader ) ) ) |
|
665 { |
|
666 if ( iCatalogsConnected ) |
|
667 { |
|
668 LOGGER_WRITE( "iCatalogs->PutDataL" ); |
|
669 TRAP( err, iCatalogs->PutDataL( typeHeader, *iBuffer ) ); |
|
670 LOGGER_WRITE_1( "iCatalogs->PutDataL : %d", err ); |
|
671 if ( err == KErrServerTerminated ) |
|
672 { |
|
673 err = iCatalogs->Connect(); |
|
674 LOGGER_WRITE_1( "CSConPCConnplugin::PutCompleteIndication() iCatalogs->Connect() err: %d", err ); |
|
675 if ( err == KErrNone ) |
|
676 { |
|
677 LOGGER_WRITE( "iCatalogs->PutDataL" ); |
|
678 TRAP( err, iCatalogs->PutDataL( typeHeader, *iBuffer ) ); |
|
679 LOGGER_WRITE_1( "iCatalogs->PutDataL : %d", err ); |
|
680 } |
|
681 } |
|
682 } |
|
683 else |
|
684 { |
|
685 LOGGER_WRITE( "Catalogs mime type recognised - failing due no connection" ); |
|
686 err = KErrNotSupported; |
|
687 } |
|
688 |
|
689 delete iObject; |
|
690 iObject = NULL; |
|
691 |
|
692 iFTPHandler->DeleteTempFile(); |
|
693 return TPCConnpluginUtils::ConvertPCDResponseCode( err ); |
|
694 } |
|
695 |
|
696 if ( typeHeader == KSConPCDObjectType ) |
|
697 { |
|
698 LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication KSConPCDObjectType" ); |
|
699 err = HandlePCDObjectPut( iObject->Description(), iObject->Name() ); |
|
700 delete iObject; |
|
701 iObject = NULL; |
|
702 |
|
703 iFTPHandler->DeleteTempFile(); |
|
704 LOGGER_WRITE_1( "CSConPCConnplugin::PutCompleteIndication() end, err: %d", err ); |
|
705 return TPCConnpluginUtils::ConvertObexMoveResponseCode( err ); |
|
706 } |
|
707 |
|
708 if ( typeHeader != KSConPCDWBXMLObjectType && |
|
709 typeHeader != KSConPCDWBXMLObjectType2 ) |
|
710 { |
|
711 TObexHeaderMask validHdrs = iObject->ValidHeaders(); |
|
712 if ( ( validHdrs & KObexHdrBody ) || ( validHdrs & KObexHdrEndOfBody ) ) |
|
713 { |
|
714 LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication() normal filetransfer" ); |
|
715 LOGGER_WRITE_1( "Number of received bytes : %d", size ); |
|
716 TSConUsedMedia media( ESConNoMedia ); |
|
717 |
|
718 switch( iMediaType ) |
|
719 { |
|
720 case ESrcsMediaBT : |
|
721 media = ESConBTMedia; |
|
722 break; |
|
723 case ESrcsMediaIrDA : |
|
724 media = ESConIRMedia; |
|
725 break; |
|
726 case ESrcsMediaUSB : |
|
727 media = ESConUSBMedia; |
|
728 break; |
|
729 default : |
|
730 media = ESConNoMedia; |
|
731 break; |
|
732 } |
|
733 |
|
734 iFTPHandler->SetUsedMedia( media ); |
|
735 |
|
736 TRAP( ret, err = iFTPHandler->PutFileObjectFinalizeL( iObject ) ); |
|
737 LOGGER_WRITE_1( "PutFileObjectL() returned : %d", ret ); |
|
738 } |
|
739 else |
|
740 { |
|
741 LOGGER_WRITE( "Delete starts" ); |
|
742 TRAP( ret, err = iFTPHandler->DeleteObjectL( iObject->Name() ) ); |
|
743 LOGGER_WRITE_1( "DeleteObjectL() returned : %d", ret ); |
|
744 } |
|
745 } |
|
746 |
|
747 delete iObject; |
|
748 iObject = NULL; |
|
749 |
|
750 if ( typeHeader == KSConPCDWBXMLObjectType || |
|
751 typeHeader == KSConPCDWBXMLObjectType2 ) |
|
752 { |
|
753 LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication() ReadWBXMLDataL" ); |
|
754 TRAP( ret, err = iFTPHandler->ReadWBXMLDataL( iBuffer ) ); |
|
755 |
|
756 if ( err == KErrNone && ret == KErrNone ) |
|
757 { |
|
758 TRAP( ret, err = iPCConnSession.PutPacketL( nameHeader, |
|
759 typeHeader, iBuffer ) ); |
|
760 LOGGER_WRITE_1( "iPCConnSession.PutPacketL() leaveCode : %d", ret ); |
|
761 LOGGER_WRITE_1( "iPCConnSession.PutPacketL() returned : %d", err ); |
|
762 } |
|
763 |
|
764 iFTPHandler->DeleteTempFile(); |
|
765 |
|
766 return TPCConnpluginUtils::ConvertPCDResponseCode( err ); |
|
767 } |
|
768 |
|
769 iFTPHandler->DeleteTempFile(); |
|
770 |
|
771 TRACE_FUNC_EXIT; |
|
772 if ( ret != KErrNone ) |
|
773 { |
|
774 return TPCConnpluginUtils::ConvertFTPResponseCode( ret ); |
|
775 } |
|
776 return TPCConnpluginUtils::ConvertFTPResponseCode( err ); |
|
777 } |
|
778 |
|
779 // ----------------------------------------------------------------------------- |
|
780 // CSConPCConnplugin::GetRequestIndication( CObexBaseObject* aRequiredObject ) |
|
781 // MObexServerNotify implementation |
|
782 // ----------------------------------------------------------------------------- |
|
783 // |
|
784 CObexBufObject* CSConPCConnplugin::GetRequestIndication( CObexBaseObject* |
|
785 aRequiredObject ) |
|
786 { |
|
787 TRACE_FUNC_ENTRY; |
|
788 CObexBufObject* bufObject(NULL); |
|
789 if ( aRequiredObject->Type().Length() > KSConHeaderMaxLength ) |
|
790 { |
|
791 LOGGER_WRITE("TypeHeader too big"); |
|
792 return NULL; |
|
793 } |
|
794 if ( aRequiredObject->Name().Length() > KMaxFileName ) |
|
795 { |
|
796 LOGGER_WRITE("NameHeader is too long"); |
|
797 return NULL; |
|
798 } |
|
799 TInt ret( KErrNone ); |
|
800 TInt err( KErrNone ); |
|
801 TBuf8<KSConHeaderMaxLength> typeHeader( aRequiredObject->Type() ); |
|
802 TrimRightSpaceAndNull( typeHeader ); |
|
803 LOGGER_WRITE8_1("type: %S", &typeHeader); |
|
804 LOGGER_WRITE_1("name: %S", &aRequiredObject->Name()); |
|
805 |
|
806 iBuffer->Reset(); |
|
807 |
|
808 delete iObject; |
|
809 iObject = NULL; |
|
810 |
|
811 TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) ); |
|
812 if ( err != KErrNone ) |
|
813 { |
|
814 return NULL; |
|
815 } |
|
816 |
|
817 // Client requests folder listing |
|
818 if ( typeHeader == KSConFolderListType ) |
|
819 { |
|
820 LOGGER_WRITE( "Client requests folder listning" ); |
|
821 if ( !iFTPHandler ) |
|
822 { |
|
823 LOGGER_WRITE( "Creating iFTPHandler has failed" ); |
|
824 return NULL; |
|
825 } |
|
826 |
|
827 TRAP( err, ret = iFTPHandler->GetFolderObjectL( iObject ) ); |
|
828 LOGGER_WRITE_1( "iFTPHandler->GetFolderObjectL() returned: %d", ret ); |
|
829 if ( err == KErrNone && ret == KErrNone ) |
|
830 { |
|
831 bufObject = iObject; |
|
832 } |
|
833 else |
|
834 { |
|
835 return NULL; |
|
836 } |
|
837 } |
|
838 // Client requests capability object or ConML packet |
|
839 else if ( typeHeader == KSConCapabilityObjectType |
|
840 || typeHeader == KSConPCDWBXMLObjectType |
|
841 || typeHeader == KSConPCDWBXMLObjectType2) |
|
842 { |
|
843 LOGGER_WRITE( "Client requests capability object or ConML packet" ); |
|
844 // HandleGetPCConnObjectL will set some data to iObject, or leaves if error occurs |
|
845 TRAP( err, HandleGetPCConnObjectL( aRequiredObject->Name(), typeHeader ) ); |
|
846 |
|
847 if ( err == KErrNone ) |
|
848 { |
|
849 bufObject = iObject; |
|
850 } |
|
851 else |
|
852 { |
|
853 LOGGER_WRITE_1("Get PCConn object failed, err: %d", err); |
|
854 return NULL; |
|
855 } |
|
856 } |
|
857 // Client requests file conversion |
|
858 else if ( typeHeader == KSConPCDObjectType ) |
|
859 { |
|
860 LOGGER_WRITE("request of KSConPCDObjectType is not supported.") |
|
861 return NULL; |
|
862 } |
|
863 // catalogs |
|
864 else if ( IsCatalogsMimeType( TDataType( typeHeader ) ) ) |
|
865 { |
|
866 TRAP( err, HandleGetCatalogsObjectL( typeHeader ) ); |
|
867 if ( err == KErrNone ) |
|
868 { |
|
869 bufObject = iObject; |
|
870 } |
|
871 else |
|
872 { |
|
873 LOGGER_WRITE_1("Get catalogs object failed, err: %d", err); |
|
874 return NULL; |
|
875 } |
|
876 } |
|
877 // Client requests file |
|
878 else |
|
879 { |
|
880 LOGGER_WRITE( "Client requests file" ); |
|
881 TRAP( err, HandleGetFileObjectL( aRequiredObject->Name() ) ); |
|
882 if ( err == KErrNone ) |
|
883 { |
|
884 bufObject = (CObexBufObject*)iFileObject; |
|
885 } |
|
886 else |
|
887 { |
|
888 LOGGER_WRITE_1("Get file object failed, err: %d", err); |
|
889 return NULL; |
|
890 } |
|
891 } |
|
892 if ( bufObject && iLinkAdapter.IsOpen() ) |
|
893 { |
|
894 // request active BT mode (high power mode) |
|
895 err = iLinkAdapter.ActivateActiveRequester(); |
|
896 LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err ); |
|
897 } |
|
898 return bufObject; |
|
899 } |
|
900 |
|
901 // ----------------------------------------------------------------------------- |
|
902 // CSConPCConnplugin::GetPacketIndication() |
|
903 // MObexServerNotify implementation |
|
904 // ----------------------------------------------------------------------------- |
|
905 // |
|
906 TInt CSConPCConnplugin::GetPacketIndication() |
|
907 { |
|
908 TRACE_FUNC; |
|
909 return KErrNone; |
|
910 } |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // CSConPCConnplugin::GetCompleteIndication() |
|
914 // MObexServerNotify implementation |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 TInt CSConPCConnplugin::GetCompleteIndication() |
|
918 { |
|
919 TRACE_FUNC_ENTRY; |
|
920 if ( iLinkAdapter.IsOpen() ) |
|
921 { |
|
922 // Cancel ActivateActiveRequester & allow going to low power mode |
|
923 TInt err = iLinkAdapter.CancelLowPowerModeRequester(); |
|
924 LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err ); |
|
925 } |
|
926 |
|
927 TInt ret( KErrNone ); |
|
928 if ( iFileObject ) |
|
929 { |
|
930 iFileObject->Reset(); |
|
931 delete iFileObject; |
|
932 iFileObject = NULL; |
|
933 } |
|
934 |
|
935 LOGGER_WRITE_1( "CSConPCConnplugin::GetCompleteIndication() : returned %d", ret ); |
|
936 return ret; |
|
937 } |
|
938 |
|
939 // ----------------------------------------------------------------------------- |
|
940 // CSConPCConnplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo, |
|
941 // const TDesC8& aInfo ) |
|
942 // MObexServerNotify implementation |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 TInt CSConPCConnplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo, |
|
946 const TDesC8& /*aInfo*/ ) |
|
947 { |
|
948 TRACE_FUNC_ENTRY; |
|
949 TInt ret( KErrNone ); |
|
950 TInt err( KErrNone ); |
|
951 |
|
952 if ( !iFTPHandler ) |
|
953 { |
|
954 LOGGER_WRITE( "Creating iFTPHandler has failed" ); |
|
955 return TPCConnpluginUtils::ConvertFTPResponseCode( KErrNoMemory ); |
|
956 } |
|
957 |
|
958 if ( aPathInfo.iFlags == KSConNULLSetPath ) |
|
959 { |
|
960 TRAP( err, ret = this->iFTPHandler->CreateFolderL( aPathInfo.iName ) ); |
|
961 } |
|
962 else |
|
963 { |
|
964 TRAP( err, ret = this->iFTPHandler->SetPathL( aPathInfo.iName, |
|
965 aPathInfo.iFlags ) ); |
|
966 } |
|
967 |
|
968 if ( err != KErrNone ) |
|
969 { |
|
970 LOGGER_WRITE_1( "CSConPCConnplugin::SetPathIndication : returned %d", err ); |
|
971 return TPCConnpluginUtils::ConvertFTPResponseCode( err ); |
|
972 } |
|
973 LOGGER_WRITE_1( "CSConPCConnplugin::SetPathIndication : returned %d", ret ); |
|
974 return TPCConnpluginUtils::ConvertFTPResponseCode( ret ); |
|
975 } |
|
976 |
|
977 // ----------------------------------------------------------------------------- |
|
978 // CSConPCConnplugin::TrimRightSpaceAndNull( TDes8& aDes ) const |
|
979 // Removes spaces and nulls from the end of the string |
|
980 // ----------------------------------------------------------------------------- |
|
981 // |
|
982 void CSConPCConnplugin::TrimRightSpaceAndNull( TDes8& aDes ) const |
|
983 { |
|
984 TRACE_FUNC; |
|
985 aDes.TrimRight(); |
|
986 if ( aDes.Length() > 0 ) |
|
987 { |
|
988 if ( !aDes[aDes.Length() - 1] ) |
|
989 { |
|
990 aDes.SetLength( aDes.Length() - 1 ); |
|
991 } |
|
992 } |
|
993 } |
|
994 |
|
995 // ----------------------------------------------------------------------------- |
|
996 // CSConPCConnplugin::SetMediaType( TSrcsMediaType aMediaType ) |
|
997 // Current used transfer media (IR,USB,BT) |
|
998 // ----------------------------------------------------------------------------- |
|
999 // |
|
1000 void CSConPCConnplugin::SetMediaType( TSrcsMediaType aMediaType ) |
|
1001 { |
|
1002 TRACE_FUNC; |
|
1003 iMediaType = aMediaType; |
|
1004 } |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // CSConPCConnplugin::TBool IsCatalogsMimeType( TDataType aMime ) |
|
1007 // Checks if mime type belogs to Catalogs |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 TBool CSConPCConnplugin::IsCatalogsMimeType( TDataType aMime ) |
|
1011 { |
|
1012 TRACE_FUNC_ENTRY; |
|
1013 TBool result = EFalse; |
|
1014 |
|
1015 if ( !iCatalogsConnected |
|
1016 && aMime.Des8() != KSConPCDObjectType |
|
1017 && aMime.Des8() != KSConPCDXMLObjectType |
|
1018 && aMime.Des8() != KSConPCDWBXMLObjectType |
|
1019 && aMime.Des8() != KSConPCDXMLObjectType2 |
|
1020 && aMime.Des8() != KSConPCDWBXMLObjectType2 |
|
1021 ) |
|
1022 { |
|
1023 // Catalogs never connected and not secon mime type |
|
1024 // Try to connect to catalogs to get catalogstypes |
|
1025 TInt catalogsErr = iCatalogs->Connect(); |
|
1026 LOGGER_WRITE_1( "CSConPCConnplugin::IsCatalogsMimeType() iCatalogs->Connect() err: %d", catalogsErr ); |
|
1027 if ( catalogsErr == KErrNone ) |
|
1028 { |
|
1029 LOGGER_WRITE( "CSConPCConnplugin::IsCatalogsMimeType() iCatalogs->Connect() success" ); |
|
1030 iCatalogsConnected = ETrue; |
|
1031 TRAPD( ret, iMimeArray = iCatalogs->SupportedMimeTypesL() ); |
|
1032 if ( ret == KErrNone ) |
|
1033 { |
|
1034 LOGGER_WRITE_1( "iCatalogs->SupportedMimeTypesL count: %d", iMimeArray.Count() ); |
|
1035 iCatalogsMimeTypesExist = ETrue; |
|
1036 } |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 if ( iCatalogsMimeTypesExist ) |
|
1041 { |
|
1042 // Compare to supported values |
|
1043 for ( TInt j = 0; j < iMimeArray.Count(); j++ ) |
|
1044 { |
|
1045 if ( (*iMimeArray[j]) == aMime ) |
|
1046 { |
|
1047 LOGGER_WRITE( "CSConPCConnplugin::IsCatalogsMimeTypeL returns TRUE" ); |
|
1048 result = ETrue; |
|
1049 break; |
|
1050 } |
|
1051 } |
|
1052 } |
|
1053 TRACE_FUNC_EXIT; |
|
1054 return result; |
|
1055 } |
|
1056 |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // CSConPCConnplugin::CSConPCConnplugin() |
|
1059 // Default constructor |
|
1060 // ----------------------------------------------------------------------------- |
|
1061 // |
|
1062 CSConPCConnplugin::CSConPCConnplugin() |
|
1063 { |
|
1064 TRACE_FUNC; |
|
1065 iBuffer = NULL; |
|
1066 iObject = NULL; |
|
1067 iFileObject = NULL; |
|
1068 iSessionActive = EFalse; |
|
1069 } |
|
1070 |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // CSConPCConnplugin::ConstructL() |
|
1073 // Initializes member data |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // |
|
1076 void CSConPCConnplugin::ConstructL() |
|
1077 { |
|
1078 TRACE_FUNC_ENTRY; |
|
1079 iBuffer = CBufFlat::NewL( KSConBufSize ); |
|
1080 iObject = CObexBufObject::NewL ( iBuffer ); |
|
1081 iServiceTimer = new (ELeave) CSConServiceTimer( this, KSConTimeOutValue ); |
|
1082 iServiceTimer->ConstructL(); |
|
1083 CActiveScheduler::Add( iServiceTimer ); |
|
1084 |
|
1085 // catalogs |
|
1086 iCatalogs = CCatalogsPCConnectivityPlugin::NewL(); |
|
1087 TRACE_FUNC_EXIT; |
|
1088 } |
|
1089 |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // CSConPCConnplugin::SetObexServer( CObexServer* aObexServer ) |
|
1092 // SetObexServer |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // |
|
1095 TInt CSConPCConnplugin::SetObexServer( CObexServer* aObexServer ) |
|
1096 { |
|
1097 iObexServer = aObexServer; |
|
1098 TInt ret = iObexServer->Start(this); |
|
1099 LOGGER_WRITE_1( "CSConPCConnplugin::SetObexServer() ret: %d", ret ); |
|
1100 return ret; |
|
1101 } |
|
1102 |
|
1103 // ----------------------------------------------------------------------------- |
|
1104 // CSConPCConnplugin::HandlePCDObjectPut |
|
1105 // Handles PCD object. Used for advanced file handling. |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // |
|
1108 TInt CSConPCConnplugin::HandlePCDObjectPut( const TDesC& aDescriptionHeader, |
|
1109 const TDesC& aNameHeader ) |
|
1110 { |
|
1111 TRACE_FUNC_ENTRY; |
|
1112 TInt err( KErrNotSupported); |
|
1113 if ( aDescriptionHeader.Length() >= 3 ) |
|
1114 { |
|
1115 TInt commandTag = aDescriptionHeader[0]; |
|
1116 TInt commandID = aDescriptionHeader[1]; |
|
1117 TInt commandParam1 = aDescriptionHeader[2]; |
|
1118 |
|
1119 TPtrC destination; |
|
1120 if ( aDescriptionHeader.Length() >= 3 ) |
|
1121 { |
|
1122 destination.Set( aDescriptionHeader.Mid(3) ); |
|
1123 } |
|
1124 TPtrC source; |
|
1125 if ( aNameHeader.Length() >= 1 ) |
|
1126 { |
|
1127 // remove ":" character from beginning |
|
1128 source.Set( aNameHeader.Mid(1) ); |
|
1129 } |
|
1130 |
|
1131 if ( commandTag == KSCon_PCD_TAG ) |
|
1132 { |
|
1133 LOGGER_WRITE( "CSConPCConnplugin::HandlePCDObjectPut KSCon_PCD_TAG found" ); |
|
1134 switch (commandID) |
|
1135 { |
|
1136 case KSCon_PCD_CMD_COPY: |
|
1137 err = iFTPHandler->CopyFile( source, destination ); |
|
1138 break; |
|
1139 |
|
1140 case KSCon_PCD_CMD_MOVE_OR_RENAME: |
|
1141 err = iFTPHandler->MoveFile( source, destination ); |
|
1142 break; |
|
1143 |
|
1144 case KSCon_PCD_CMD_SET_PERMISSION: |
|
1145 if ( commandParam1 == KSCon_PCD_PAR_FULL_PERMISSION ) |
|
1146 { |
|
1147 err = iFTPHandler->SetReadOnly( source, EFalse ); |
|
1148 } |
|
1149 else if ( commandParam1 == KSCon_PCD_PAR_READ_ONLY_PERMISSION ) |
|
1150 { |
|
1151 err = iFTPHandler->SetReadOnly( source, ETrue ); |
|
1152 } |
|
1153 else |
|
1154 { |
|
1155 err = KErrNotSupported; |
|
1156 } |
|
1157 break; |
|
1158 |
|
1159 default: |
|
1160 LOGGER_WRITE( "CSConPCConnplugin::HandlePCDObjectPut unknown commandID" ); |
|
1161 err = KErrNotSupported; |
|
1162 break; |
|
1163 } |
|
1164 |
|
1165 } |
|
1166 |
|
1167 } |
|
1168 TRACE_FUNC_EXIT; |
|
1169 return err; |
|
1170 } |
|
1171 |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // CSConPCConnplugin::HandleGetPCConnObjectL |
|
1174 // Get Capbility object or ConML message from PCConnServer |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // |
|
1177 void CSConPCConnplugin::HandleGetPCConnObjectL( const TDesC& aNameHeader, |
|
1178 const TDesC8& aTypeHeader ) |
|
1179 { |
|
1180 TRACE_FUNC_ENTRY; |
|
1181 if ( !iPCConnSessionConnected ) |
|
1182 { |
|
1183 LOGGER_WRITE( "ERROR, iPCConnSession was not connected" ); |
|
1184 User::Leave( KErrNotReady ); |
|
1185 } |
|
1186 TInt err = iPCConnSession.GetPacketL( aNameHeader, aTypeHeader, iBuffer ); |
|
1187 LOGGER_WRITE_1( "iPCConnSession.GetPacketL() returned: %d", err ); |
|
1188 User::LeaveIfError( err ); |
|
1189 iObject->SetDataBufL( iBuffer ); |
|
1190 TRACE_FUNC_EXIT; |
|
1191 } |
|
1192 |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // CSConPCConnplugin::HandleGetCatalogsObjectL |
|
1195 // Get Catalogs object |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CSConPCConnplugin::HandleGetCatalogsObjectL( const TDesC8& aTypeHeader ) |
|
1199 { |
|
1200 TRACE_FUNC_ENTRY; |
|
1201 TInt err(KErrNone); |
|
1202 if ( !iCatalogsConnected ) |
|
1203 { |
|
1204 LOGGER_WRITE( "catalogs mime type recognised - failing due to no connection" ); |
|
1205 User::Leave( KErrNotReady ); |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 LOGGER_WRITE( "iCatalogs->GetDataL" ); |
|
1210 TDataType mime( aTypeHeader ); |
|
1211 TRAP( err, iCatalogs->GetDataL( mime, *iBuffer ) ); |
|
1212 LOGGER_WRITE_1( "iCatalogs->GetDataL : %d", err ); |
|
1213 if ( err == KErrServerTerminated ) |
|
1214 { |
|
1215 // server was terminated, try to reconnect |
|
1216 err = iCatalogs->Connect(); |
|
1217 LOGGER_WRITE_1( "iCatalogs->Connect() err: %d", err ); |
|
1218 User::LeaveIfError( err ); |
|
1219 LOGGER_WRITE( "iCatalogs->GetDataL" ); |
|
1220 iCatalogs->GetDataL( mime, *iBuffer ); |
|
1221 } |
|
1222 } |
|
1223 User::LeaveIfError( err ); |
|
1224 iObject->SetDataBufL( iBuffer ); |
|
1225 TRACE_FUNC_EXIT; |
|
1226 } |
|
1227 |
|
1228 // ----------------------------------------------------------------------------- |
|
1229 // CSConPCConnplugin::HandleGetFileObjectL |
|
1230 // Get file object |
|
1231 // ----------------------------------------------------------------------------- |
|
1232 // |
|
1233 void CSConPCConnplugin::HandleGetFileObjectL( const TDesC& aNameHeader ) |
|
1234 { |
|
1235 TRACE_FUNC_ENTRY; |
|
1236 delete iFileObject; |
|
1237 iFileObject = NULL; |
|
1238 iFileObject = CObexFileObject::NewL(); |
|
1239 |
|
1240 iFileObject->Reset(); |
|
1241 iFileObject->SetNameL( aNameHeader ); |
|
1242 |
|
1243 if ( !iFTPHandler ) |
|
1244 { |
|
1245 LOGGER_WRITE( "Creating iFTPHandler has failed" ); |
|
1246 User::Leave( KErrNotReady ); |
|
1247 } |
|
1248 |
|
1249 TInt err = iFTPHandler->GetFileObjectL( iFileObject ); |
|
1250 User::LeaveIfError( err ); |
|
1251 TRACE_FUNC_EXIT; |
|
1252 } |
|
1253 |
|
1254 // End of file |
|