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