# HG changeset patch # User hgs # Date 1272058051 -10800 # Node ID 64b3172ba34724289ea20ab1fccd46f5bd368ec3 # Parent ce4f184690c96773986fb280bb096a7e799eaf3a 201011 diff -r ce4f184690c9 -r 64b3172ba347 localconnectivityservice/group/bld.inf --- a/localconnectivityservice/group/bld.inf Sat Apr 24 00:11:33 2010 +0300 +++ b/localconnectivityservice/group/bld.inf Sat Apr 24 00:27:31 2010 +0300 @@ -24,10 +24,7 @@ #include "../obexsendservices/group/bld.inf" #include "../obexreceiveservices/group/bld.inf" #include "../dun/group/bld.inf" -#include "../lccustomplugin/group/bld.inf" #include "../lcstylustap/group/bld.inf" -#include "../legacymodemplugin/group/bld.inf" -#include "../modematplugin/group/bld.inf" #include "../generichid/group/bld.inf" #include "../headset/group/bld.inf" diff -r ce4f184690c9 -r 64b3172ba347 localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp --- a/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp Sat Apr 24 00:11:33 2010 +0300 +++ b/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp Sat Apr 24 00:27:31 2010 +0300 @@ -86,91 +86,102 @@ CMsvAttachment* attachInfo = store->AttachmentManagerL().GetAttachmentInfoL(0); CleanupStack::PushL(attachInfo); // 3rd push - + TDataType dataType = attachInfo->MimeType(); - - TInt error = KErrNone; - TBool isCompleteSelf = EFalse; + TFileName filePath; + filePath = attachInfo->FilePath(); - RFile attachFile; - TRAP( error, attachFile = store->AttachmentManagerL().GetAttachmentFileL(0)); - TFileName fullName; - attachFile.FullName(fullName); - attachFile.Close(); + TInt error = KErrNone; + TBool isCompleteSelf = EFalse; + CEikonEnv* eikEnv = CEikonEnv::Static(); + + if ( attachInfo->Type() == CMsvAttachment::EMsvFile ) + { + RFile attachFile; + TRAP( error, attachFile = store->AttachmentManagerL().GetAttachmentFileL(0)); + if ( error == KErrNone ) + { + CleanupClosePushL(attachFile); // 4th push + CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 5th push + TAiwGenericParam paramSave(EGenericParamAllowSave, ETrue); + paramList->AppendL( paramSave ); + + if ( eikEnv ) + { + iDocumentHandler = CDocumentHandler::NewL( eikEnv->Process() ); + iDocumentHandler->SetExitObserver( this ); + TRAP( error, iDocumentHandler->OpenFileEmbeddedL(attachFile, dataType, *paramList)); + }// eikEnv + CleanupStack::PopAndDestroy(2); // paramList, attachFile + } + }// EMsvFile - if ( KErrNone == error ) + if ( attachInfo->Type() == CMsvAttachment::EMsvLinkedFile ) { - CleanupClosePushL(attachFile); // 4th push - CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 5th push + CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 4th push TAiwGenericParam paramSave(EGenericParamFileSaved, ETrue); paramList->AppendL( paramSave ); - - if ( CEikonEnv::Static() ) + + if ( eikEnv ) { - // Launches an application in embedded mode - iDocumentHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ); + + iDocumentHandler = CDocumentHandler::NewL( eikEnv->Process() ); iDocumentHandler->SetExitObserver( this ); RFile64 shareableFile; - TRAP( error, iDocumentHandler->OpenTempFileL(fullName,shareableFile)); + TRAP( error, iDocumentHandler->OpenTempFileL(filePath,shareableFile)); if ( error == KErrNone) { - TRAP( error, iDocumentHandler->OpenFileEmbeddedL( shareableFile, dataType, *paramList )); + TRAP( error, iDocumentHandler->OpenFileEmbeddedL( shareableFile, dataType, *paramList)); } shareableFile.Close(); - } - - - if ( error == KErrNotSupported ) - // If file is not supported, we open the file manager at file location. - { - // Launchs file manager at default folder - delete iDocumentHandler; - iDocumentHandler = NULL; - - TInt sortMethod = 2; // 0 = 'By name', 1 = 'By type', - // 2 = 'Most recent first' and 3 = 'Largest first' - TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( fullName, - sortMethod, - ETrue )); // ETrue -> launch file manager in embedded mode. - isCompleteSelf = ETrue; - } // KErrNotSupported - - // Set message to READ - // - TMsvEntry entry = aMessage->Entry(); - entry.SetUnread( EFalse ); - aMessage->ChangeL( entry ); - CleanupStack::PopAndDestroy(2); // paramList, attachFile - - } // KErrNone + if ( error == KErrNotFound ) + { + error = KErrNone; + TFileName fileName; + if (LocateFileL(fileName, filePath)) + { + // Update the entry + TRAP(error, TObexUtilsMessageHandler::UpdateEntryAttachmentL(fileName,aMessage)); + if ( error == KErrNone ) + { + // Show a confirmation note + CAknGlobalNote* note = CAknGlobalNote::NewLC(); + HBufC* stringholder = StringLoader::LoadLC( R_BT_SAVED_LINK_UPDATED ); + note->ShowNoteL(EAknGlobalConfirmationNote, *stringholder); + CleanupStack::PopAndDestroy(2); //note and stringholder + } + } + isCompleteSelf = ETrue; + } // KErrNotFound + } // eikEnv + + else if ( error == KErrNotSupported ) + { + delete iDocumentHandler; + iDocumentHandler = NULL; + + const TInt sortMethod = 2; // 0 = 'By name', 1 = 'By type', + // 2 = 'Most recent first' and 3 = 'Largest first' + TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( filePath, + sortMethod, + ETrue )); // ETrue -> launch file manager in embedded mode. + isCompleteSelf = ETrue; + } // KErrNotSupported + + CleanupStack::PopAndDestroy(); // paramList + } // EMsvLinkedFile - else // Error != KErrNone, broken link found. - // Lets fix it by selecting the right file. - { - error = KErrNone; - TFileName fileName; - TFileName oldFileName = attachInfo->FilePath(); - // select file - // - if (LocateFileL(fileName, oldFileName)) - { - // Update the entry - TRAP(error, TObexUtilsMessageHandler::UpdateEntryAttachmentL(fileName,aMessage)); - if ( error == KErrNone ) - { - // Show a confirmation note - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - HBufC* stringholder = StringLoader::LoadLC( R_BT_SAVED_LINK_UPDATED ); - note->ShowNoteL(EAknGlobalConfirmationNote, *stringholder); - CleanupStack::PopAndDestroy(2); //note and stringholder - } - } - isCompleteSelf = ETrue; - } // !KErrNone - + + // Set message to READ + TMsvEntry entry = aMessage->Entry(); + entry.SetUnread( EFalse ); + aMessage->ChangeL( entry ); + User::LeaveIfError ( error ); CleanupStack::PopAndDestroy(3); // attachInfo, store, attachEntry + + iObserverRequestStatus = KRequestPending; // CMsvOperation (observer) iStatus = KRequestPending; // CMsvOperation SetActive(); @@ -180,6 +191,7 @@ HandleServerAppExit( error ); } } + // ----------------------------------------------------------------------------- // Destructor // ----------------------------------------------------------------------------- diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/Bmarm/ObexServAPItestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/Bmarm/ObexServAPItestu.def Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/Bwins/ObexServAPItestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/Bwins/ObexServAPItestu.def Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/conf/obexservapitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/conf/obexservapitest.cfg Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +[Test] +title Get file system status +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetFileSystemStatus +delete Message_Handler_Tester +[Endtest] +[Test] +title Get MMC file system status +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetMmcFileSystemStatus +delete Message_Handler_Tester +[Endtest] +[Test] +title Get message center drive +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetMessageCentreDriveL +delete Message_Handler_Tester +[Endtest] +[Test] +title Create default mtm service +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateDefaultMtmServiceL +delete Message_Handler_Tester +[Endtest] +[Test] +title Get cenrep key int value +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyIntValueL +delete Message_Handler_Tester +[Endtest] +[Test] +title Get PubSub key int value +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetPubSubKeyIntValue +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and remove outpox entry +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateOutBoxEntry +Message_Handler_Tester RemoveOutBoxEntry +delete Message_Handler_Tester +[Endtest] +[Test] +title Crate and remove outpox entry +create obexservapitest Message_Handler_Tester +Message_Handler_Tester SaveObjToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Save object to inbox +create obexservapitest Message_Handler_Tester +Message_Handler_Tester SaveObjToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and save attacment +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateEntryToInbox +Message_Handler_Tester SaveRFileObjectToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and Remove attacment +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateEntryToInbox +Message_Handler_Tester RemoveObjectFromInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Get CenRep key string value +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyStringValueL +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and delete receive buffer and RFile +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyStringValueL +Message_Handler_Tester CreateReceiveBufferAndRFileL +Message_Handler_Tester RemoveTemporaryRFileL +delete Message_Handler_Tester +[Endtest] +[Test] +title Save receive buffer and RFile to inbox +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyStringValueL +Message_Handler_Tester CreateReceiveBufferAndRFileL +Message_Handler_Tester SaveFileToFileSystemL +Message_Handler_Tester AddEntryToInboxL +delete Message_Handler_Tester +[Endtest] +[Test] +title Update the previous Inbox entry +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyStringValueL +Message_Handler_Tester CreateReceiveBufferAndRFileL +Message_Handler_Tester SaveFileToFileSystemL +Message_Handler_Tester AddEntryToInboxL +Message_Handler_Tester UpdateEntryAttachmentL +delete Message_Handler_Tester +[Endtest] diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/eabi/ObexServAPItestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/eabi/ObexServAPItestu.def Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/group/bld.inf Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS +// Specify the source file followed by its destination here +// copy will be used to copy the source file to its destination +// If there's no destination then the source file will be copied +// to the same name in /epoc32/include +// Example: +/* +/agnmodel/inc/AGMCOMON.H +*/ + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' +obexservapitest.mmp + +PRJ_MMPFILES + +// End of File \ No newline at end of file diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/group/obexservapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/group/obexservapitest.mmp Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,63 @@ +/*TYPE TESTCLASS*//* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + +#if defined(__S60_) + // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET obexservapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE ObexServAPItest.def + +SOURCEPATH ../src +SOURCE ObexServAPItest.cpp +SOURCE ObexServAPItestBlocks.cpp +SOURCE testlogger.cpp + + +USERINCLUDE ../inc + +#if defined(__S60_) + // OSEXT_LAYER_SYSTEMINCLUDE + MW_LAYER_SYSTEMINCLUDE +#else + //SYSTEMINCLUDE /epoc32/include + //SYSTEMINCLUDE /epoc32/include/internal +#endif + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY sysutil.lib +LIBRARY obexutils.lib +LIBRARY irobex.lib +LIBRARY efsrv.lib +LIBRARY msgs.lib + +LANG SC + +// End of File diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/group/obexservapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/group/obexservapitest.pkg Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,65 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; +; Installation file for STIF +; + +; Languages +&EN + +; Provide value for uid +#{"obexservapitest"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 5.1 +[0x10283160], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\udeb\obexservapitest.dll"-"c:\Sys\Bin\obexservapitest.dll" + +"..\conf\obexservapitest.cfg"-"e:\testing\conf\obexservapitest.cfg" +"..\init\obexservapitest.ini"-"e:\testing\init\obexservapitest.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None + diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/inc/ObexServAPItest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/inc/ObexServAPItest.h Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +#ifndef OBEXSERVAPITEST_H +#define OBEXSERVAPITEST_H + +// INCLUDES +#include +#include +#include +#include +#include "testlogger.h" + + +// FORWARD DECLARATIONS +class CObexServAPItest; + + +// CLASS DECLARATION + +/** +* CObexServAPItest test class for STIF Test Framework TestScripter. +*/ +NONSHARABLE_CLASS(CObexServAPItest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CObexServAPItest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CObexServAPItest(); + + public: // New functions + + + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + + + private: + + /** + * C++ default constructor. + */ + CObexServAPItest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ); + + /** + * Test methods are listed below. + */ + + /** + * Test code for getting file system status. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetFileSystemStatusL( CStifItemParser& aItem ); + + /** + * Test code for getting mmc file system status. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetMmcFileSystemStatusL( CStifItemParser& aItem ); + + /** + * Test code for getting message center drive. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetMessageCentreDriveL( CStifItemParser& aItem ); + + /** + * Test code for creating Default MTM services. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateDefaultMtmServiceL( CStifItemParser& aItem ); + + /** + * Test code for Getting CenRep key. . + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetCenRepKeyIntValueL( CStifItemParser& aItem ); + + /** + * Test code for Getting PubSub key. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetPubSubKeyIntValueL( CStifItemParser& aItem ); + + /** + * Test code for Creating outbox entry. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateOutBoxEntryL( CStifItemParser& aItem ); + + /** + * Test code for removing outbox entry. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt RemoveOutBoxEntryL( CStifItemParser& aItem ); + + /** + * Test code for save received file to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt SaveObjToInboxL( CStifItemParser& aItem ); + + /** + * Test code for creating entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateEntryToInboxL( CStifItemParser& aItem ); + + /** + * Test code for creating entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt SaveRFileObjectToInboxL( CStifItemParser& aItem ); + + /** + * Test code for removing entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt RemoveObjectL( CStifItemParser& aItem ); + + TInt CObexServAPItest::GetCenRepKeyStringValueL( CStifItemParser& aItem ); + TInt CObexServAPItest::CreateReceiveBufferAndRFileL( CStifItemParser& aItem ); + TInt CObexServAPItest::SaveFileToFileSystemL( CStifItemParser& aItem ); + TInt CObexServAPItest::AddEntryToInboxL( CStifItemParser& aItem ); + TInt CObexServAPItest::UpdateEntryAttachmentL( CStifItemParser& aItem ); + TInt CObexServAPItest::RemoveTemporaryRFileL( CStifItemParser& aItem ); + + private: // Data + + /** + * A dummy class for opening CMsvSession. + */ + class CDummySessionObserver : public CBase , public MMsvSessionObserver + { + public: + void HandleSessionEventL( TMsvSessionEvent/*aEvent*/, + TAny* /*aArg1*/, + TAny* /*aArg2*/, + TAny* /*aArg3*/ ) {}; + }; + + + + TMsvId iMessageServerIndex; + CObexBufObject* iObexObject; + RFs iRFs; + RFile iFile; + CBufFlat* iBuf; + CObexTestLogger* iTestLogger; + TFileName iCenRepFolder; + TFileName iTempFullPathFilename; + }; + +#endif // OBEXSERVAPITEST_H + +// End of File diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/inc/testlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/inc/testlogger.h Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef BTTESTLOGGER_H +#define BTTESTLOGGER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CStifLogger; +class CTestModuleIf; + +#define TLFUNCLOG (TUint8*) __FUNCTION__ + +// CLASS DECLARATION + +NONSHARABLE_CLASS( CObexTestLogger ) : public CBase +{ + public: + + static CObexTestLogger* NewL(const CTestModuleIf* aTestModuleIf); + virtual ~CObexTestLogger(); + + public: // Data used by functions + + enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; + + public: // New functions + + TBool GetEnabled() const; + CStifLogger* GetLogger() const; + const CTestModuleIf* GetTestModuleIf() const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; + TInt LogNewLine() const; + void SetEnabled(TBool aEnabled); + void SetLogger(CStifLogger* aLog); + void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); + + public: // Functions from base classes + + private: // New functions + + TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; + TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; + static TPtrC GetPrefix(TLogLevel aLevel); + TInt CheckLogFile(); + void LogHeadSectionL(); + void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; + + private: // Constructors + + CObexTestLogger(const CTestModuleIf* aTestModuleIf); + void ConstructL(); + + public: // Data + static const TInt KPrefixLength; + + private: // Data + + TBool iEnabled; + CStifLogger* iLog; + const CTestModuleIf* iTestModuleIf; + }; + +#endif // BTTESTLOGGER_H + diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/init/obexservapitest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/init/obexservapitest.ini Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,233 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + # 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= obexServApiTest_TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +#UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= e:\testing\conf\obexservapitest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/rom/obexservapitest.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/rom/obexservapitest.iby Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image description file for project bteng +* +*/ + +#ifndef BTENGAPITEST_IBY +#define BTENGAPITEST_IBY + +#include + +file=ABI_DIR\BUILD_DIR\ObexServAPItest.dll SHARED_LIB_DIR\ObexServAPItest.dll + +#endif // BTENGAPITEST_IBY diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/src/ObexServAPItest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/src/ObexServAPItest.cpp Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include "ObexServAPItest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CObexServAPItest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CObexServAPItest::CObexServAPItest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::ConstructL() + { + + iTestLogger = CObexTestLogger::NewL( &TestModuleIf() ); + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CObexServAPItest* CObexServAPItest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CObexServAPItest* self = new (ELeave) CObexServAPItest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CObexServAPItest::~CObexServAPItest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iTestLogger; + iTestLogger = NULL; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CObexServAPItest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/src/ObexServAPItestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/src/ObexServAPItestBlocks.cpp Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,630 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include "testlogger.h" +#include "ObexServAPItest.h" + +#include + +// CONSTANTS +const TInt KBufferSize = 0x4000; // 16kB + +// Defined to coincide with the definition in btmsgtypeuid.h +const TUid KUidMsgTypeBt = {0x10009ED5}; + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CObexServAPItest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::Delete() + { + delete iObexObject; + iObexObject = NULL; + delete iBuf; + iBuf = NULL; + iRFs.Close(); + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "GetFileSystemStatus", CObexServAPItest::GetFileSystemStatusL ), + ENTRY( "GetMmcFileSystemStatus", CObexServAPItest::GetMmcFileSystemStatusL ), + ENTRY( "GetMessageCentreDriveL", CObexServAPItest::GetMessageCentreDriveL ), + ENTRY( "CreateDefaultMtmServiceL", CObexServAPItest::CreateDefaultMtmServiceL ), + ENTRY( "GetCenRepKeyIntValueL", CObexServAPItest::GetCenRepKeyIntValueL ), + ENTRY( "GetPubSubKeyIntValue", CObexServAPItest::GetPubSubKeyIntValueL ), + ENTRY( "CreateOutBoxEntry", CObexServAPItest::CreateOutBoxEntryL ), + ENTRY( "RemoveOutBoxEntry", CObexServAPItest::RemoveOutBoxEntryL ), + ENTRY( "SaveObjToInbox", CObexServAPItest::SaveObjToInboxL ), + ENTRY( "CreateEntryToInbox", CObexServAPItest::CreateEntryToInboxL ), + ENTRY( "SaveRFileObjectToInbox", CObexServAPItest::SaveRFileObjectToInboxL ), + ENTRY( "RemoveObjectFromInbox", CObexServAPItest::RemoveObjectL ), + ENTRY( "GetCenRepKeyStringValueL", CObexServAPItest::GetCenRepKeyStringValueL), // JHä + ENTRY( "CreateReceiveBufferAndRFileL", CObexServAPItest::CreateReceiveBufferAndRFileL), // JHä + ENTRY( "RemoveTemporaryRFileL", CObexServAPItest::RemoveTemporaryRFileL), // JHä + ENTRY( "SaveFileToFileSystemL", CObexServAPItest::SaveFileToFileSystemL), // JHä + ENTRY( "AddEntryToInboxL", CObexServAPItest::AddEntryToInboxL), // JHä + ENTRY( "UpdateEntryAttachmentL", CObexServAPItest::UpdateEntryAttachmentL), // JHä + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + + // ----------------------------------------------------------------------------- +// CBtApiTest::TestCompleted +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) + { + iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); + Signal( aErr ); + } + + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetFileSystemStatusL +// Test code for getting file system status. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetFileSystemStatusL( CStifItemParser& /*aItem*/ ) + { + // Print to log file + TInt retVal=TObexUtilsMessageHandler::GetFileSystemStatus(); + if (retVal == 0 || retVal == KErrDiskFull) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetMmcFileSystemStatusL +// Test code for getting mmc file system status. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetMmcFileSystemStatusL( CStifItemParser& /*aItem*/ ) + { + TInt retVal=TObexUtilsMessageHandler::GetMmcFileSystemStatus(); + if (retVal == 0 || retVal == KErrDiskFull) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetMessageCentreDriveL +// Test code for getting message center drive. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetMessageCentreDriveL( CStifItemParser& /*aItem*/ ) + { + + TInt retVal = TObexUtilsMessageHandler::GetMessageCentreDriveL(); + if (retVal >= 0 ) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetMessageCentreDrive")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("GetMessageCentreDrive failed")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateDefaultMtmServiceL +// Test code for creating Default MTM services. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateDefaultMtmServiceL( CStifItemParser& /*aItem*/ ) + { + + TRAPD(error, TObexUtilsMessageHandler::CreateDefaultMtmServiceL(KUidMsgTypeBt) ); + if (error == KErrNone) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetCenRepKeyIntValueL +// Test code for Getting CenRep key. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetCenRepKeyIntValueL( CStifItemParser& /*aItem*/ ) // JHä note: Is return code handling done right? + { + TInt limit=0; + TInt error=0; + TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyIntValueL(KCRUidUiklaf, + KUikOODDiskCriticalThreshold, + limit)); + if( leaveVal != KErrNone ) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValueL leaves")); + } + else if (error == KErrNone) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValue return error")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyIntValueL")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetPubSubKeyIntValueL +// Test code for Getting PubSub key. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetPubSubKeyIntValueL( CStifItemParser& /*aItem*/ ) + { + TInt status = KErrNone; + TInt retVal = KErrNone; + + TRAPD(leaveVal, retVal = TObexUtilsMessageHandler::GetPubSubKeyIntValue(KPSUidUikon, KUikFFSFreeLevel, status)); + + if( leaveVal != KErrNone ) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL leaves")); + } + else if (retVal == KErrNone) + { + TestCompleted( retVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL return error")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetPubSubKeyIntValue")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::OutBoxEntryL +// Test code for Creating outbox entry. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateOutBoxEntryL( CStifItemParser& /*aItem*/ ) + { + TRAPD(error, iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( KUidMsgTypeBt, R_BT_SEND_OUTBOX_SENDING )); + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("CreateOutBoxEntryL leaves")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("CreateOutBoxEntryL")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::OutBoxEntryL +// Test code for removing outbox entry. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RemoveOutBoxEntryL( CStifItemParser& /*aItem*/ ) + { + + TRAPD(error, TObexUtilsMessageHandler::DeleteOutboxEntryL( iMessageServerIndex )); + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("RemoveOutBoxEntryL leaves")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("RemoveOutBoxEntryL")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::SaveObjToInboxL +// Test code for save received file to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::SaveObjToInboxL( CStifItemParser& /*aItem*/ ) + { + + CObexBufObject* obexobject = CObexBufObject::NewL( NULL ); + CleanupStack::PushL(obexobject); + + TRAP_IGNORE(TObexUtilsMessageHandler::SaveObjToInboxL(obexobject , + KNullDesC, + KUidMsgTypeBt )); + TestCompleted( KErrNone, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + + CleanupStack::PopAndDestroy(obexobject); + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateAndSaveObjectL +// Test code for creating entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateEntryToInboxL( CStifItemParser& /*aItem*/ ) + { + iFile = RFile(); + + if ( iObexObject) + { + delete iObexObject; + iObexObject = NULL; + } + + iObexObject = CObexBufObject::NewL( NULL ); + + TRAPD( error, TObexUtilsMessageHandler::CreateInboxAttachmentL( iObexObject, + KUidMsgTypeBt, + iMessageServerIndex, + iFile)); + + + iBuf = CBufFlat::NewL(1024); + iBuf->ResizeL(1024); + + TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); + + TRAP_IGNORE( iObexObject->SetDataBufL( bufferdetails) ); + + + + iFile.Write(_L8("test")); + iObexObject->SetNameL(_L("test.txt")); + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL")); + } + return KErrNone; + } + + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateAndSaveObjectL +// Test code for creating entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::SaveRFileObjectToInboxL( CStifItemParser& /*aItem*/ ) + { + TRAPD( error, TObexUtilsMessageHandler::SaveObjToInboxL( + iObexObject, + iFile, + iMessageServerIndex)); + + delete iBuf; + iBuf = NULL; + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::RemoveObjectL +// Test code for removing entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RemoveObjectL( CStifItemParser& /*aItem*/ ) + { + TRAPD(error,TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMessageServerIndex)); + delete iBuf; + iBuf = NULL; + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); + } + return KErrNone; + } + +// Find out the path of the receive folder. +TInt CObexServAPItest::GetCenRepKeyStringValueL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + TInt error = KErrNone; + TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, + KLCReceiveFolder, + iCenRepFolder)); + if( leaveVal != KErrNone ) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyStringValueL leaves")); + } + else if (error != KErrNone) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyStringValueL return error")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyStringValueL")); + } + + return KErrNone; + } + +// Create the receive buffer and temporary receive file. +TInt CObexServAPItest::CreateReceiveBufferAndRFileL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + TFileName defaultFolder; + defaultFolder.Zero(); + + User::LeaveIfError(iRFs.Connect()); + + iFile = RFile(); // Creating an empty file. + + // Ensure that the object and buffer don't exist. + // This also deletes the previous iFile object, if any existed, + // because its handle is held by iObexObject. + if(iObexObject) + { + delete iObexObject; + iObexObject = NULL; + } + if( iBuf ) + { + delete iBuf; + iBuf=NULL; + } + + // Then create a new obex object for holding the buffer and the temp file. + iObexObject = CObexBufObject::NewL( NULL ); + + defaultFolder.Append(_L("C:\\data\\")); + defaultFolder.Append(iCenRepFolder); // Got this from central repository in GetCenRepKeyStringValueL + + TRAPD(error,TObexUtilsMessageHandler::CreateReceiveBufferAndRFileL( iFile, // Out: But iFile is returned as closed. + defaultFolder, // Where to create the temp file. + iTempFullPathFilename, // Out: Can be used to open the file later. + iBuf, // Out: This contains the message buffer. + KBufferSize)); + + // Open the file again. + User::LeaveIfError(iFile.Open(iRFs, iTempFullPathFilename, EFileWrite)); + + TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); + + // Do we really need to trap leaves here? Maybe because of Stif? + TRAP(error, iObexObject->SetDataBufL( bufferdetails) ); + if (error != KErrNone) + { + error = KErrGeneral; + } + + iFile.Write(_L8("test")); // Put some test data into the file, although it is not mandatory. + iFile.Flush(); + + iObexObject->SetNameL(_L("test.txt")); + + // At this point we have an object in file system (iFile refers to it) + // and an entry in Inbox which we can later refer to with iMessageServerIndex. + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("CreateReceiveBufferAndRFileL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("CreateReceiveBufferAndRFileL")); + } + + // iFile is left open + return KErrNone; + } + +// Copy the temporary receive file to the correct place in the file system after receiving is complete. +TInt CObexServAPItest::SaveFileToFileSystemL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + // Create bogus device name. + TBTDeviceName remoteDeviceName; + remoteDeviceName.Zero(); + remoteDeviceName.Append(_L("APITestDevice")); + +// The iFile must be still open after calling CreateReceiveBufferAndRFileL method + + TRAPD(error,TObexUtilsMessageHandler::SaveFileToFileSystemL( iObexObject, + KUidMsgTypeBt, + iMessageServerIndex, // This is gotten + iTempFullPathFilename, // Contains the final path of the file + iFile, // Handle to the temp file. + remoteDeviceName)); + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("SaveFileToFileSystemL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("SaveFileToFileSystemL")); + } + return KErrNone; + } + +// Create an entry in the Inbox and attach the file there. +TInt CObexServAPItest::AddEntryToInboxL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + RArray tmpMsvIdArray; // Not really needed, but must be passed to the method. + + TRAPD(error,TObexUtilsMessageHandler::AddEntryToInboxL( iMessageServerIndex, + iTempFullPathFilename, + &tmpMsvIdArray)); + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("AddEntryToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("AddEntryToInboxL")); + } + return KErrNone; + } + +// Replacing a broken link in Inbox with a proper link to a file. +TInt CObexServAPItest::UpdateEntryAttachmentL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + // Create a new file to be the replacement: + TFileName tempFilename; + TFileName defaultFolder; + RFs rfs; + RFile newFile; + + User::LeaveIfError(rfs.Connect()); + CleanupClosePushL(rfs); + + defaultFolder.Zero(); + defaultFolder.Append(_L("C:\\data\\")); + defaultFolder.Append(iCenRepFolder); // Got this from central repository in GetCenRepKeyStringValueL + User::LeaveIfError( newFile.Temp( rfs, defaultFolder, tempFilename, EFileWrite) ); + newFile.Write(_L8("testing replacing")); + newFile.Flush(); + newFile.Close(); + + CleanupStack::PopAndDestroy(); // rfs + + // Then replace the attachment: + CDummySessionObserver* sessionObs = new( ELeave )CDummySessionObserver;; + CleanupStack::PushL( sessionObs ); + CMsvSession* msvSession = CMsvSession::OpenSyncL( *sessionObs ); + CleanupStack::PushL(msvSession); + CMsvEntry* entry = msvSession->GetEntryL(iMessageServerIndex); + CleanupStack::PushL(entry); + TRAPD(error,TObexUtilsMessageHandler::UpdateEntryAttachmentL(tempFilename, entry)); + + // Cleanup: + CleanupStack::PopAndDestroy(3); // entry, msvSession, sessionObs, + + // Save the path to the new file so it can be referred to later. + iTempFullPathFilename = tempFilename; + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("UpdateEntryAttachmentL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("UpdateEntryAttachmentL")); + } + return KErrNone; + } + +// Delete the temporary file. Called normally when the link is broken and the user searches for the file. +// In test code this should be called after creating the temporary RFile and before +// creating the Inbox entry. +TInt CObexServAPItest::RemoveTemporaryRFileL( CStifItemParser& /*aItem*/ ) // JHä - Done + { + TRAPD(error,TObexUtilsMessageHandler::RemoveTemporaryRFileL(iTempFullPathFilename)); + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("RemoveTemporaryRFileL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("RemoveTemporaryRFileL")); + } + return KErrNone; + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// End of File diff -r ce4f184690c9 -r 64b3172ba347 shortlinkconn_plat/obex_service_utils_api/tsrc/src/testlogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shortlinkconn_plat/obex_service_utils_api/tsrc/src/testlogger.cpp Sat Apr 24 00:27:31 2010 +0300 @@ -0,0 +1,530 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// INCLUDES + +#include "testlogger.h" + +#include +#include + +#include +#include +#include + +// RDebug +#include + +const TInt CObexTestLogger::KPrefixLength = 8; +// Timestamp string length +const TInt KTimeStampStrLen = 21; +// Extended Timestamp string length +const TInt KExtTimeStampStrLen = 40; +// Extended time stamp +typedef TBuf TExtTimeStamp; +// Logging path +_LIT( KObexServAPITestSystemLogPath, "e:\\logs\\ObexServAPItest\\" ); +// Log file +_LIT( KObexServAPITestSystemLogFile, "ObexServAPItest.html" ); +// Log file +_LIT( KObexServAPITestSystemLogFullName, "\\logs\\ObexServAPItest\\ObexServAPItest%x.html" ); +// Time stamp format string +_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); +// Date format string +_LIT( KFormatDate, "%F%D %N %Y" ); +// HTML header section +_LIT( KHtmlHeadSection, "\n\nObex Message Handler Test System results\n\n\n\n\n\n" ); +// HTML code which will display the statistics +_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); +// HTML identifier for test case start +_LIT( KHtmlTestCaseStart, "
" ); +// Test case result logging +_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); +// JavaScript function for calculating test result +#define KJSSECTION _L( "" ) + +// Construction and destruction. + +// ----------------------------------------------------------------------------- +// CObexTestLogger::NewL +// Static constructor to constructor builder objects. +// ----------------------------------------------------------------------------- +// +CObexTestLogger* CObexTestLogger::NewL(const CTestModuleIf* aTestModuleIf) + { + CObexTestLogger* self = new (ELeave) CObexTestLogger(aTestModuleIf); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::CObexTestLogger +// Constructor. +// ----------------------------------------------------------------------------- +// +CObexTestLogger::CObexTestLogger(const CTestModuleIf* aTestModuleIf) + : CBase(), + iEnabled(ETrue), + iTestModuleIf(aTestModuleIf) + { + } + +// ----------------------------------------------------------------------------- +// CTestLogger::ConstructL +// 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::ConstructL() + { + TInt err = CheckLogFile(); + iLog = CStifLogger::NewL( KObexServAPITestSystemLogPath, KObexServAPITestSystemLogFile, + CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); + if( err == KErrNotFound ) + { // Add info & HTML markup to the beginning of the log file. + LogHeadSectionL(); + } + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::~CObexTestLogger +// Destructor. +// ----------------------------------------------------------------------------- +// +CObexTestLogger::~CObexTestLogger() + { + delete iLog; + } + +// Member functions. + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetLogger +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +CStifLogger* CObexTestLogger::GetLogger() const + { + return iLog; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetTestModuleIf +// Returns a pointer to current STIF test module interface. +// ----------------------------------------------------------------------------- +// +const CTestModuleIf* CObexTestLogger::GetTestModuleIf() const + { + return iTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList( aLogText, args ); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Append log prefix to the output buffer. + buffer.Insert( 0, GetPrefix( aLevel ) ); + + // Log a timestamp + TStifLoggerTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Log a timestamp + TStifLoggerTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const + { + TExtTimeStamp func; + func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer + + Log( CObexTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::LogNewLine() const + { + if (!iEnabled) + { + return KErrNone; + } + TExtTimeStamp time; + TRAPD( err, LogTimeStampL( time ) ); + if( !err ) + { + time.Insert( 0, KHtmlTestCaseStart ); + err = iLog->Log( time ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetEnabled +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetEnabled(TBool aEnabled) + { + iEnabled = aEnabled; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetLogger +// Sets a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetLogger(CStifLogger* aLog) + { + iLog = aLog; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetTestModuleIf +// Sets a pointer to current STIF test module. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) + { + iTestModuleIf = aTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(aLevel, _L(""), log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(0, aCategory, log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetPrefix +// Returns the prefix for a given logging level. +// ----------------------------------------------------------------------------- +// +TPtrC CObexTestLogger::GetPrefix(TLogLevel aLevel) + { + // Select a prefix for a log level and return a pointer to it. + switch(aLevel) + { + case ETLError: + { + TPtrC logPrefix = _L("ERROR : "); + return logPrefix; + } + case ETLInfo: + case ETLResult: + { + TPtrC logPrefix = _L("INFO : "); + return logPrefix; + } + case ETLDebug: + { + TPtrC logPrefix = _L("DEBUG : "); + return logPrefix; + } + default: + { + // Return a null pointer. + return TPtrC(); + } + + } + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::CheckLogFile +// Check if a log file is already existing, otherwise HTML formatting +// should be added. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::CheckLogFile() + { + RThread thread; + TInt id = thread.Id(); + TBuf file; + file.Format( KObexServAPITestSystemLogFullName, id ); + RFs fs; + TInt err = fs.Connect(); + TBool open = EFalse; + if( !err ) + { + err = fs.IsFileOpen( file, open ); + } + fs.Close(); + return err; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogTimeStamp +// Log HTML head section and general information in a newly created logfile. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::LogHeadSectionL() + { + iLog->Log( KHtmlHeadSection ); + iLog->Log( KJSSECTION ); + TBuf version( _L( "Version unknown!" ) ); + (void) SysUtil::GetSWVersion( version ); + TStifLoggerTimeStamp8 date; + LogTimeStampL( date, EFalse ); + TStifLoggerTimeStamp8 time; + LogTimeStampL( time ); + TPtrC timePtr( time.Mid( 6, 13 ) ); + iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogTimeStamp +// Format a timestamp for logging. +// If aTime is set to false, the (formatted) date is returned. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const + { + TTime time; + time.HomeTime(); // Get time and format it + if( aTime ) + { + time.FormatL( aBuf, KFormatTimeStamp ); + } + else + { + time.FormatL( aBuf, KFormatDate ); + } + }