1 /* |
|
2 * Copyright (c) 2002 - 2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include <UiklafInternalCRKeys.h> |
|
25 #include <UikonInternalPSKeys.h> |
|
26 #include <Obexutils.rsg> |
|
27 #include <obex.h> |
|
28 #include "testlogger.h" |
|
29 #include "ObexServAPItest.h" |
|
30 |
|
31 #include <btengdomaincrkeys.h> |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KBufferSize = 0x4000; // 16kB |
|
35 |
|
36 // Defined to coincide with the definition in btmsgtypeuid.h |
|
37 const TUid KUidMsgTypeBt = {0x10009ED5}; |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CObexServAPItest::Delete |
|
44 // Delete here all resources allocated and opened from test methods. |
|
45 // Called from destructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 void CObexServAPItest::Delete() |
|
49 { |
|
50 delete iObexObject; |
|
51 iObexObject = NULL; |
|
52 delete iBuf; |
|
53 iBuf = NULL; |
|
54 iRFs.Close(); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CObexServAPItest::RunMethodL |
|
59 // Run specified method. Contains also table of test mothods and their names. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 TInt CObexServAPItest::RunMethodL( |
|
63 CStifItemParser& aItem ) |
|
64 { |
|
65 |
|
66 static TStifFunctionInfo const KFunctions[] = |
|
67 { |
|
68 // Copy this line for every implemented function. |
|
69 // First string is the function name used in TestScripter script file. |
|
70 // Second is the actual implementation member function. |
|
71 ENTRY( "GetFileSystemStatus", CObexServAPItest::GetFileSystemStatusL ), |
|
72 ENTRY( "GetMmcFileSystemStatus", CObexServAPItest::GetMmcFileSystemStatusL ), |
|
73 ENTRY( "GetMessageCentreDriveL", CObexServAPItest::GetMessageCentreDriveL ), |
|
74 ENTRY( "CreateDefaultMtmServiceL", CObexServAPItest::CreateDefaultMtmServiceL ), |
|
75 ENTRY( "GetCenRepKeyIntValueL", CObexServAPItest::GetCenRepKeyIntValueL ), |
|
76 ENTRY( "GetPubSubKeyIntValue", CObexServAPItest::GetPubSubKeyIntValueL ), |
|
77 ENTRY( "CreateOutBoxEntry", CObexServAPItest::CreateOutBoxEntryL ), |
|
78 ENTRY( "RemoveOutBoxEntry", CObexServAPItest::RemoveOutBoxEntryL ), |
|
79 ENTRY( "SaveObjToInbox", CObexServAPItest::SaveObjToInboxL ), |
|
80 ENTRY( "CreateEntryToInbox", CObexServAPItest::CreateEntryToInboxL ), |
|
81 ENTRY( "SaveRFileObjectToInbox", CObexServAPItest::SaveRFileObjectToInboxL ), |
|
82 ENTRY( "RemoveObjectFromInbox", CObexServAPItest::RemoveObjectL ), |
|
83 ENTRY( "GetCenRepKeyStringValueL", CObexServAPItest::GetCenRepKeyStringValueL), // JHä |
|
84 ENTRY( "CreateReceiveBufferAndRFileL", CObexServAPItest::CreateReceiveBufferAndRFileL), // JHä |
|
85 ENTRY( "RemoveTemporaryRFileL", CObexServAPItest::RemoveTemporaryRFileL), // JHä |
|
86 ENTRY( "SaveFileToFileSystemL", CObexServAPItest::SaveFileToFileSystemL), // JHä |
|
87 ENTRY( "AddEntryToInboxL", CObexServAPItest::AddEntryToInboxL), // JHä |
|
88 ENTRY( "UpdateEntryAttachmentL", CObexServAPItest::UpdateEntryAttachmentL), // JHä |
|
89 }; |
|
90 |
|
91 const TInt count = sizeof( KFunctions ) / |
|
92 sizeof( TStifFunctionInfo ); |
|
93 |
|
94 return RunInternalL( KFunctions, count, aItem ); |
|
95 |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CBtApiTest::TestCompleted |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CObexServAPItest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) |
|
103 { |
|
104 iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); |
|
105 Signal( aErr ); |
|
106 } |
|
107 |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CObexServAPItest::GetFileSystemStatusL |
|
111 // Test code for getting file system status. |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CObexServAPItest::GetFileSystemStatusL( CStifItemParser& /*aItem*/ ) |
|
116 { |
|
117 // Print to log file |
|
118 TInt retVal=TObexUtilsMessageHandler::GetFileSystemStatus(); |
|
119 if (retVal == 0 || retVal == KErrDiskFull) |
|
120 { |
|
121 TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); |
|
122 } |
|
123 else |
|
124 { |
|
125 TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); |
|
126 } |
|
127 return KErrNone; |
|
128 |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CObexServAPItest::GetMmcFileSystemStatusL |
|
133 // Test code for getting mmc file system status. |
|
134 // (other items were commented in a header). |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CObexServAPItest::GetMmcFileSystemStatusL( CStifItemParser& /*aItem*/ ) |
|
138 { |
|
139 TInt retVal=TObexUtilsMessageHandler::GetMmcFileSystemStatus(); |
|
140 if (retVal == 0 || retVal == KErrDiskFull) |
|
141 { |
|
142 TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); |
|
143 } |
|
144 else |
|
145 { |
|
146 TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); |
|
147 } |
|
148 |
|
149 return KErrNone; |
|
150 |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CObexServAPItest::GetMessageCentreDriveL |
|
155 // Test code for getting message center drive. |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 TInt CObexServAPItest::GetMessageCentreDriveL( CStifItemParser& /*aItem*/ ) |
|
160 { |
|
161 |
|
162 TInt retVal = TObexUtilsMessageHandler::GetMessageCentreDriveL(); |
|
163 if (retVal >= 0 ) |
|
164 { |
|
165 TestCompleted( KErrNone, TLFUNCLOG, _L("GetMessageCentreDrive")); |
|
166 } |
|
167 else |
|
168 { |
|
169 TestCompleted( retVal, TLFUNCLOG, _L("GetMessageCentreDrive failed")); |
|
170 } |
|
171 |
|
172 return KErrNone; |
|
173 |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CObexServAPItest::CreateDefaultMtmServiceL |
|
178 // Test code for creating Default MTM services. |
|
179 // (other items were commented in a header). |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TInt CObexServAPItest::CreateDefaultMtmServiceL( CStifItemParser& /*aItem*/ ) |
|
183 { |
|
184 |
|
185 TRAPD(error, TObexUtilsMessageHandler::CreateDefaultMtmServiceL(KUidMsgTypeBt) ); |
|
186 if (error == KErrNone) |
|
187 { |
|
188 TestCompleted( KErrNone, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); |
|
189 } |
|
190 else |
|
191 { |
|
192 TestCompleted( error, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); |
|
193 } |
|
194 return KErrNone; |
|
195 |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CObexServAPItest::GetCenRepKeyIntValueL |
|
200 // Test code for Getting CenRep key. |
|
201 // (other items were commented in a header). |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 TInt CObexServAPItest::GetCenRepKeyIntValueL( CStifItemParser& /*aItem*/ ) // JHä note: Is return code handling done right? |
|
205 { |
|
206 TInt limit=0; |
|
207 TInt error=0; |
|
208 TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyIntValueL(KCRUidUiklaf, |
|
209 KUikOODDiskCriticalThreshold, |
|
210 limit)); |
|
211 if( leaveVal != KErrNone ) |
|
212 { |
|
213 TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValueL leaves")); |
|
214 } |
|
215 else if (error == KErrNone) |
|
216 { |
|
217 TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValue return error")); |
|
218 } |
|
219 else |
|
220 { |
|
221 TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyIntValueL")); |
|
222 } |
|
223 |
|
224 return KErrNone; |
|
225 |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CObexServAPItest::GetPubSubKeyIntValueL |
|
230 // Test code for Getting PubSub key. |
|
231 // (other items were commented in a header). |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CObexServAPItest::GetPubSubKeyIntValueL( CStifItemParser& /*aItem*/ ) |
|
235 { |
|
236 TInt status = KErrNone; |
|
237 TInt retVal = KErrNone; |
|
238 |
|
239 TRAPD(leaveVal, retVal = TObexUtilsMessageHandler::GetPubSubKeyIntValue(KPSUidUikon, KUikFFSFreeLevel, status)); |
|
240 |
|
241 if( leaveVal != KErrNone ) |
|
242 { |
|
243 TestCompleted( leaveVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL leaves")); |
|
244 } |
|
245 else if (retVal == KErrNone) |
|
246 { |
|
247 TestCompleted( retVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL return error")); |
|
248 } |
|
249 else |
|
250 { |
|
251 TestCompleted( KErrNone, TLFUNCLOG, _L("GetPubSubKeyIntValue")); |
|
252 } |
|
253 |
|
254 return KErrNone; |
|
255 |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CObexServAPItest::OutBoxEntryL |
|
260 // Test code for Creating outbox entry. |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CObexServAPItest::CreateOutBoxEntryL( CStifItemParser& /*aItem*/ ) |
|
265 { |
|
266 TRAPD(error, iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( KUidMsgTypeBt, R_BT_SEND_OUTBOX_SENDING )); |
|
267 if( error != KErrNone) |
|
268 { |
|
269 TestCompleted( error, TLFUNCLOG, _L("CreateOutBoxEntryL leaves")); |
|
270 } |
|
271 else |
|
272 { |
|
273 TestCompleted( KErrNone, TLFUNCLOG, _L("CreateOutBoxEntryL")); |
|
274 } |
|
275 |
|
276 return KErrNone; |
|
277 |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CObexServAPItest::OutBoxEntryL |
|
282 // Test code for removing outbox entry. |
|
283 // (other items were commented in a header). |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CObexServAPItest::RemoveOutBoxEntryL( CStifItemParser& /*aItem*/ ) |
|
287 { |
|
288 |
|
289 TRAPD(error, TObexUtilsMessageHandler::DeleteOutboxEntryL( iMessageServerIndex )); |
|
290 if( error != KErrNone) |
|
291 { |
|
292 TestCompleted( error, TLFUNCLOG, _L("RemoveOutBoxEntryL leaves")); |
|
293 } |
|
294 else |
|
295 { |
|
296 TestCompleted( KErrNone, TLFUNCLOG, _L("RemoveOutBoxEntryL")); |
|
297 } |
|
298 return KErrNone; |
|
299 |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CObexServAPItest::SaveObjToInboxL |
|
304 // Test code for save received file to inbox. |
|
305 // (other items were commented in a header). |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 TInt CObexServAPItest::SaveObjToInboxL( CStifItemParser& /*aItem*/ ) |
|
309 { |
|
310 |
|
311 CObexBufObject* obexobject = CObexBufObject::NewL( NULL ); |
|
312 CleanupStack::PushL(obexobject); |
|
313 |
|
314 TRAP_IGNORE(TObexUtilsMessageHandler::SaveObjToInboxL(obexobject , |
|
315 KNullDesC, |
|
316 KUidMsgTypeBt )); |
|
317 TestCompleted( KErrNone, TLFUNCLOG, _L("SaveObjToInboxL leaves")); |
|
318 |
|
319 CleanupStack::PopAndDestroy(obexobject); |
|
320 return KErrNone; |
|
321 |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CObexServAPItest::CreateAndSaveObjectL |
|
326 // Test code for creating entry to inbox. |
|
327 // (other items were commented in a header). |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 TInt CObexServAPItest::CreateEntryToInboxL( CStifItemParser& /*aItem*/ ) |
|
331 { |
|
332 iFile = RFile(); |
|
333 |
|
334 if ( iObexObject) |
|
335 { |
|
336 delete iObexObject; |
|
337 iObexObject = NULL; |
|
338 } |
|
339 |
|
340 iObexObject = CObexBufObject::NewL( NULL ); |
|
341 |
|
342 TRAPD( error, TObexUtilsMessageHandler::CreateInboxAttachmentL( iObexObject, |
|
343 KUidMsgTypeBt, |
|
344 iMessageServerIndex, |
|
345 iFile)); |
|
346 |
|
347 |
|
348 iBuf = CBufFlat::NewL(1024); |
|
349 iBuf->ResizeL(1024); |
|
350 |
|
351 TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); |
|
352 |
|
353 TRAP_IGNORE( iObexObject->SetDataBufL( bufferdetails) ); |
|
354 |
|
355 |
|
356 |
|
357 iFile.Write(_L8("test")); |
|
358 iObexObject->SetNameL(_L("test.txt")); |
|
359 |
|
360 if( error != KErrNone) |
|
361 { |
|
362 TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL leaves")); |
|
363 } |
|
364 else |
|
365 { |
|
366 TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL")); |
|
367 } |
|
368 return KErrNone; |
|
369 } |
|
370 |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CObexServAPItest::CreateAndSaveObjectL |
|
374 // Test code for creating entry to inbox. |
|
375 // (other items were commented in a header). |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 TInt CObexServAPItest::SaveRFileObjectToInboxL( CStifItemParser& /*aItem*/ ) |
|
379 { |
|
380 TRAPD( error, TObexUtilsMessageHandler::SaveObjToInboxL( |
|
381 iObexObject, |
|
382 iFile, |
|
383 iMessageServerIndex)); |
|
384 |
|
385 delete iBuf; |
|
386 iBuf = NULL; |
|
387 if( error != KErrNone) |
|
388 { |
|
389 TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); |
|
390 } |
|
391 else |
|
392 { |
|
393 TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); |
|
394 } |
|
395 |
|
396 return KErrNone; |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // CObexServAPItest::RemoveObjectL |
|
401 // Test code for removing entry to inbox. |
|
402 // (other items were commented in a header). |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CObexServAPItest::RemoveObjectL( CStifItemParser& /*aItem*/ ) |
|
406 { |
|
407 TRAPD(error,TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMessageServerIndex)); |
|
408 delete iBuf; |
|
409 iBuf = NULL; |
|
410 if( error != KErrNone) |
|
411 { |
|
412 TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); |
|
413 } |
|
414 else |
|
415 { |
|
416 TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); |
|
417 } |
|
418 return KErrNone; |
|
419 } |
|
420 |
|
421 // Find out the path of the receive folder. |
|
422 TInt CObexServAPItest::GetCenRepKeyStringValueL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
423 { |
|
424 TInt error = KErrNone; |
|
425 TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, |
|
426 KLCReceiveFolder, |
|
427 iCenRepFolder)); |
|
428 if( leaveVal != KErrNone ) |
|
429 { |
|
430 TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyStringValueL leaves")); |
|
431 } |
|
432 else if (error != KErrNone) |
|
433 { |
|
434 TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyStringValueL return error")); |
|
435 } |
|
436 else |
|
437 { |
|
438 TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyStringValueL")); |
|
439 } |
|
440 |
|
441 return KErrNone; |
|
442 } |
|
443 |
|
444 // Create the receive buffer and temporary receive file. |
|
445 TInt CObexServAPItest::CreateReceiveBufferAndRFileL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
446 { |
|
447 TFileName defaultFolder; |
|
448 defaultFolder.Zero(); |
|
449 |
|
450 User::LeaveIfError(iRFs.Connect()); |
|
451 |
|
452 iFile = RFile(); // Creating an empty file. |
|
453 |
|
454 // Ensure that the object and buffer don't exist. |
|
455 // This also deletes the previous iFile object, if any existed, |
|
456 // because its handle is held by iObexObject. |
|
457 if(iObexObject) |
|
458 { |
|
459 delete iObexObject; |
|
460 iObexObject = NULL; |
|
461 } |
|
462 if( iBuf ) |
|
463 { |
|
464 delete iBuf; |
|
465 iBuf=NULL; |
|
466 } |
|
467 |
|
468 // Then create a new obex object for holding the buffer and the temp file. |
|
469 iObexObject = CObexBufObject::NewL( NULL ); |
|
470 |
|
471 defaultFolder.Append(_L("C:\\data\\")); |
|
472 defaultFolder.Append(iCenRepFolder); // Got this from central repository in GetCenRepKeyStringValueL |
|
473 |
|
474 TRAPD(error,TObexUtilsMessageHandler::CreateReceiveBufferAndRFileL( iFile, // Out: But iFile is returned as closed. |
|
475 defaultFolder, // Where to create the temp file. |
|
476 iTempFullPathFilename, // Out: Can be used to open the file later. |
|
477 iBuf, // Out: This contains the message buffer. |
|
478 KBufferSize)); |
|
479 |
|
480 // Open the file again. |
|
481 User::LeaveIfError(iFile.Open(iRFs, iTempFullPathFilename, EFileWrite)); |
|
482 |
|
483 TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); |
|
484 |
|
485 // Do we really need to trap leaves here? Maybe because of Stif? |
|
486 TRAP(error, iObexObject->SetDataBufL( bufferdetails) ); |
|
487 if (error != KErrNone) |
|
488 { |
|
489 error = KErrGeneral; |
|
490 } |
|
491 |
|
492 iFile.Write(_L8("test")); // Put some test data into the file, although it is not mandatory. |
|
493 iFile.Flush(); |
|
494 |
|
495 iObexObject->SetNameL(_L("test.txt")); |
|
496 |
|
497 // At this point we have an object in file system (iFile refers to it) |
|
498 // and an entry in Inbox which we can later refer to with iMessageServerIndex. |
|
499 |
|
500 if( error != KErrNone) |
|
501 { |
|
502 TestCompleted( error, TLFUNCLOG, _L("CreateReceiveBufferAndRFileL leaves")); |
|
503 } |
|
504 else |
|
505 { |
|
506 TestCompleted( error, TLFUNCLOG, _L("CreateReceiveBufferAndRFileL")); |
|
507 } |
|
508 |
|
509 // iFile is left open |
|
510 return KErrNone; |
|
511 } |
|
512 |
|
513 // Copy the temporary receive file to the correct place in the file system after receiving is complete. |
|
514 TInt CObexServAPItest::SaveFileToFileSystemL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
515 { |
|
516 // Create bogus device name. |
|
517 TBTDeviceName remoteDeviceName; |
|
518 remoteDeviceName.Zero(); |
|
519 remoteDeviceName.Append(_L("APITestDevice")); |
|
520 |
|
521 // The iFile must be still open after calling CreateReceiveBufferAndRFileL method |
|
522 |
|
523 TRAPD(error,TObexUtilsMessageHandler::SaveFileToFileSystemL( iObexObject, |
|
524 KUidMsgTypeBt, |
|
525 iMessageServerIndex, // This is gotten |
|
526 iTempFullPathFilename, // Contains the final path of the file |
|
527 iFile, // Handle to the temp file. |
|
528 remoteDeviceName)); |
|
529 |
|
530 if( error != KErrNone) |
|
531 { |
|
532 TestCompleted( error, TLFUNCLOG, _L("SaveFileToFileSystemL leaves")); |
|
533 } |
|
534 else |
|
535 { |
|
536 TestCompleted( error, TLFUNCLOG, _L("SaveFileToFileSystemL")); |
|
537 } |
|
538 return KErrNone; |
|
539 } |
|
540 |
|
541 // Create an entry in the Inbox and attach the file there. |
|
542 TInt CObexServAPItest::AddEntryToInboxL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
543 { |
|
544 RArray<TMsvId> tmpMsvIdArray; // Not really needed, but must be passed to the method. |
|
545 |
|
546 TRAPD(error,TObexUtilsMessageHandler::AddEntryToInboxL( iMessageServerIndex, |
|
547 iTempFullPathFilename, |
|
548 &tmpMsvIdArray)); |
|
549 |
|
550 if( error != KErrNone) |
|
551 { |
|
552 TestCompleted( error, TLFUNCLOG, _L("AddEntryToInboxL leaves")); |
|
553 } |
|
554 else |
|
555 { |
|
556 TestCompleted( error, TLFUNCLOG, _L("AddEntryToInboxL")); |
|
557 } |
|
558 return KErrNone; |
|
559 } |
|
560 |
|
561 // Replacing a broken link in Inbox with a proper link to a file. |
|
562 TInt CObexServAPItest::UpdateEntryAttachmentL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
563 { |
|
564 // Create a new file to be the replacement: |
|
565 TFileName tempFilename; |
|
566 TFileName defaultFolder; |
|
567 RFs rfs; |
|
568 RFile newFile; |
|
569 |
|
570 User::LeaveIfError(rfs.Connect()); |
|
571 CleanupClosePushL(rfs); |
|
572 |
|
573 defaultFolder.Zero(); |
|
574 defaultFolder.Append(_L("C:\\data\\")); |
|
575 defaultFolder.Append(iCenRepFolder); // Got this from central repository in GetCenRepKeyStringValueL |
|
576 User::LeaveIfError( newFile.Temp( rfs, defaultFolder, tempFilename, EFileWrite) ); |
|
577 newFile.Write(_L8("testing replacing")); |
|
578 newFile.Flush(); |
|
579 newFile.Close(); |
|
580 |
|
581 CleanupStack::PopAndDestroy(); // rfs |
|
582 |
|
583 // Then replace the attachment: |
|
584 CDummySessionObserver* sessionObs = new( ELeave )CDummySessionObserver;; |
|
585 CleanupStack::PushL( sessionObs ); |
|
586 CMsvSession* msvSession = CMsvSession::OpenSyncL( *sessionObs ); |
|
587 CleanupStack::PushL(msvSession); |
|
588 CMsvEntry* entry = msvSession->GetEntryL(iMessageServerIndex); |
|
589 CleanupStack::PushL(entry); |
|
590 TRAPD(error,TObexUtilsMessageHandler::UpdateEntryAttachmentL(tempFilename, entry)); |
|
591 |
|
592 // Cleanup: |
|
593 CleanupStack::PopAndDestroy(3); // entry, msvSession, sessionObs, |
|
594 |
|
595 // Save the path to the new file so it can be referred to later. |
|
596 iTempFullPathFilename = tempFilename; |
|
597 |
|
598 if( error != KErrNone) |
|
599 { |
|
600 TestCompleted( error, TLFUNCLOG, _L("UpdateEntryAttachmentL leaves")); |
|
601 } |
|
602 else |
|
603 { |
|
604 TestCompleted( error, TLFUNCLOG, _L("UpdateEntryAttachmentL")); |
|
605 } |
|
606 return KErrNone; |
|
607 } |
|
608 |
|
609 // Delete the temporary file. Called normally when the link is broken and the user searches for the file. |
|
610 // In test code this should be called after creating the temporary RFile and before |
|
611 // creating the Inbox entry. |
|
612 TInt CObexServAPItest::RemoveTemporaryRFileL( CStifItemParser& /*aItem*/ ) // JHä - Done |
|
613 { |
|
614 TRAPD(error,TObexUtilsMessageHandler::RemoveTemporaryRFileL(iTempFullPathFilename)); |
|
615 if( error != KErrNone) |
|
616 { |
|
617 TestCompleted( error, TLFUNCLOG, _L("RemoveTemporaryRFileL leaves")); |
|
618 } |
|
619 else |
|
620 { |
|
621 TestCompleted( error, TLFUNCLOG, _L("RemoveTemporaryRFileL")); |
|
622 } |
|
623 return KErrNone; |
|
624 } |
|
625 |
|
626 |
|
627 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
628 // None |
|
629 |
|
630 // End of File |
|