# HG changeset patch # User William Roberts # Date 1279813076 -3600 # Node ID 7409e6184c90bfa1e6ccbe3a42441e4799bf1cfd # Parent 6f8759468fd4bcd720a12ddaa26d0a55e2ababeb# Parent 834e27cad5104eef751610cf13b9ac713139b0aa Catchup to latest Symbian^4 diff -r 6f8759468fd4 -r 7409e6184c90 genericpositioningplugins/group/bld.inf --- a/genericpositioningplugins/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/genericpositioningplugins/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -18,13 +18,13 @@ #include PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE #include "../locationnpppsy/group/bld.inf" #include "../locationsuplpsy/group/bld.inf" PRJ_EXPORTS -../cenrep/10282266_s60.cre z:/private/10202be9/10282266_s60.cre +//../cenrep/10282266_s60.cre z:/private/10202be9/10282266_s60.cre ../cenrep/1028224B_s60.cre z:/private/10202be9/1028224B_s60.cre ../rom/prifw_cenrep.iby CORE_MW_LAYER_IBY_EXPORT_PATH(prifw_cenrep.iby) diff -r 6f8759468fd4 -r 7409e6184c90 genericpositioningplugins/locationnpppsy/group/bld.inf --- a/genericpositioningplugins/locationnpppsy/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/genericpositioningplugins/locationnpppsy/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -18,7 +18,7 @@ #include PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS ../rom/nla_npppsy.iby CORE_MW_LAYER_IBY_EXPORT_PATH(nla_npppsy.iby) diff -r 6f8759468fd4 -r 7409e6184c90 genericpositioningplugins/locationnpppsy/inc/npppsysingletonhandler.h --- a/genericpositioningplugins/locationnpppsy/inc/npppsysingletonhandler.h Tue Jun 15 11:38:32 2010 +0100 +++ b/genericpositioningplugins/locationnpppsy/inc/npppsysingletonhandler.h Thu Jul 22 16:37:56 2010 +0100 @@ -51,7 +51,7 @@ * status. * @reuturn the pointer the the singleton handler */ - static CNppPsySingletonHandler* CNppPsySingletonHandler::GetInstanceL( + static CNppPsySingletonHandler* GetInstanceL( MPositionerStatus& aStatusInterface ); /** diff -r 6f8759468fd4 -r 7409e6184c90 group/bld.inf --- a/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -17,7 +17,7 @@ PRJ_PLATFORMS -WINSCW ARMV5 +WINSCW ARMV5 GCCE #include "../genericpositioningplugins/group/bld.inf" #include "../landmarks/group/bld.inf" diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/group/bld.inf --- a/landmarks/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -19,7 +19,7 @@ PRJ_PLATFORMS -WINSCW ARMV5 +WINSCW ARMV5 GCCE #include "../locationlandmarks/group/bld.inf" diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/dbmanclientlib/group/bld.inf --- a/landmarks/locationlandmarks/dbmanclientlib/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/locationlandmarks/dbmanclientlib/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -20,7 +20,7 @@ #include PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/dbmanclientlib/src/EPos_HPosLmDatabaseInfo.cpp --- a/landmarks/locationlandmarks/dbmanclientlib/src/EPos_HPosLmDatabaseInfo.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/locationlandmarks/dbmanclientlib/src/EPos_HPosLmDatabaseInfo.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -254,9 +254,16 @@ sizeof(TInt) + aDatabaseUri.Size(); +#if defined(__GCCE__) + // allocate memory + return User::AllocL(_FOFF(HPosLmDatabaseInfo, + iBuffer) + requiredBufferSize * sizeof (typeof(iBuffer))); +#else // allocate memory return User::AllocL(_FOFF_DYNAMIC(HPosLmDatabaseInfo, - iBuffer[requiredBufferSize])); + iBuffer[requiredBufferSize])); +#endif + } diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/internalservices/group/bld.inf --- a/landmarks/locationlandmarks/internalservices/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/locationlandmarks/internalservices/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -43,10 +43,8 @@ ../inc/EPos_CPosLmSettingsHandler.h |../../../inc/epos_cposlmsettingshandler.h ../inc/EPos_PosLmLongTextColHandler.h |../../../inc/epos_poslmlongtextcolhandler.h -../data/101FE99B.txt /epoc32/release/winscw/udeb/z/private/10202be9/101fe99b.txt PRJ_MMPFILES -//gnumakefile epos_landmarksglobalcategories_icons.mk EPos_LmInternalServices.mmp EPos_LandmarksGlobalCategories.mmp diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/localaccess/inc/epos_cposlmlocaldatabase.h --- a/landmarks/locationlandmarks/localaccess/inc/epos_cposlmlocaldatabase.h Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/locationlandmarks/localaccess/inc/epos_cposlmlocaldatabase.h Thu Jul 22 16:37:56 2010 +0100 @@ -360,7 +360,7 @@ * full information. * @return The landmark. */ - CPosLandmark* CPosLmLocalDatabase::ReadLmLC( + CPosLandmark* ReadLmLC( TPosLmItemId aLandmarkId, TBool aIsPartial ); diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/server/group/bld.inf --- a/landmarks/locationlandmarks/server/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/landmarks/locationlandmarks/server/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -25,7 +25,7 @@ // Internal APIs ../inc/EPos_PosLmServerCommon.h |../../../inc/epos_poslmservercommon.h -../data/backup_registration.xml /epoc32/data/z/private/101fdf81/backup_registration.xml +../data/backup_registration.xml z:/private/101fdf81/backup_registration.xml PRJ_MMPFILES EPos_LandmarksServer.mmp diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/Bmarm/LandMarksTestModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/Bmarm/LandMarksTestModuleu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/Bwins/LandMarksTestModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/Bwins/LandMarksTestModuleu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/Script/lmtm.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/Script/lmtm.bat Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,23 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of the License "Symbian Foundation License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +md e:\results + +md e:\results\LandMarksTestModule + +ATSINTERFACE.EXE -testmodule testscripter -config c:\testframework\LandMarksTestModule1.cfg + +copy c:\Logs\TestFramework\TestReport.txt e:\results\LandMarksTestModule\TestReport_LandMarksTestModule1.txt diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/ABLD.BAT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/ABLD.BAT Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,31 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of the License "Symbian Foundation License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@ECHO OFF + +REM Bldmake-generated batch file - ABLD.BAT +REM ** DO NOT EDIT ** + +perl -S ABLD.PL "\work\mrt\TestProvider\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9 +if errorlevel==1 goto CheckPerl +goto End + +:CheckPerl +perl -v >NUL +if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed? +goto End + +:End diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/BC34B3.tmp Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/BC34B3.tmp has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/FT_DbManPluginsTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/FT_DbManPluginsTest.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#include + +TARGET dbmanpluginstest.dll +TARGETTYPE PLUGIN // From SOS9.0 +UID 0x10009D8D 0x04440010 + +//VENDORID VID_DEFAULT +CAPABILITY ALL -TCB + +SOURCEPATH ../src +SOURCE DbManPluginsTestMain.cpp +SOURCE CDbManTestPluginBase.cpp + +SOURCEPATH ../resource +start resource 04440010.rss +#ifdef SYMBIAN_SECURE_ECOM +TARGET dbmanpluginstest.rsc +#endif +end + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + +SYSTEMINCLUDE /epoc32/include + + + +USERINCLUDE ../inc +USERINCLUDE ../src + +LIBRARY euser.lib +LIBRARY bafl.lib +LIBRARY ecom.lib +LIBRARY eposlmdbmanlib.lib +LIBRARY FT_lmservlib.lib +EXPORTUNFROZEN +SMPSAFE + +// END OF FILE + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/FT_DbManPluginsTest.mmp~RF1991061f.TMP diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Build info file for Landmarks Database Management Provider +* +*/ + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS + + +PRJ_MMPFILES +FT_DbManPluginsTest.mmp + + + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/dbmanpluginstest_UID_.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/group/dbmanpluginstest_UID_.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,21 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +// Makmake-generated uid source file +#include +#pragma data_seg(".SYMBIAN") +__EMULATOR_IMAGE_HEADER2(0x10000079,0x10009d8d,0x04440010,EPriorityForeground,0x000ffffeu,0x00000000u,0x04440010,0,0x00010000,0) +#pragma data_seg() diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/CDbManTestPluginBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/CDbManTestPluginBase.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,351 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CDBMANTESTPLUGINBASE_H +#define CDBMANTESTPLUGINBASE_H + +// INCLUDES +#include + +// CLASS DECLARATION + +class CDbManTestPluginBase : public CPosLmDatabaseManagerPluginBase + { + public: + + /** + * Destructor. + */ + ~CDbManTestPluginBase(); + + + static CDbManTestPluginBase* NewL(TAny* aConstructionParams); + + + public: // Functions from base classes. + + /** + * Lists the URIs to all landmark databases handled by this + * plug-in. + * + * The client takes ownership of the returned array. + * + * If no databases are found, an empty array is returned. + * + * This function requires @p ReadUserData capability. + * + * @since Series 60 3.0 + * @return The list of database URIs. + */ + CDesCArray* ListDatabasesLC(); + + /** + * Lists information about each landmark database handled by this + * plug-in. + * + * The client specifies an array which is populated by this function. + * The client takes ownership of all information objects in the array. + * + * If no databases are found, the input array is not modified. + * + * This function requires @p ReadUserData capability. + * + * @since Series 60 3.0 + * @param aDatabaseInfoArray On return, contains information about + * the landmark databases. + */ + void ListDatabasesL( + /* OUT */ RPointerArray& aDatabaseInfoArray + ); + + /** + * Registers a landmark database. + * + * The landmark database is then returned when listing landmark + * databases. + * + * Some protocols like "file" does not allow registering of databases + * and will leave with error code @p KErrNotSupported. To add a + * "file"-protocol database, the client must call @ref CreateDatabaseL. + * + * The client supplies an information object containing the URI of the + * database to register. The information object can also contain + * database settings, e.g. a display name for the database. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since Series 60 3.0 + * @param aDatabaseInfo Information about the landmark database to + * register. + * @par Leave codes: + * @p KErrNotSupported The protocol specified in the URI is not + * supported by this plug-in or the protocol does not allow + * registering landmark databases.\n + * @p KErrArgument The URI is incorrect.\n + * @p KErrAlreadyExists The database already exists in the registry. + */ + void RegisterDatabaseL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * Unregisters a landmark database. + * + * After this, the landmark database will not be returned when listing + * landmark databases. + * + * Some protocols like "file" does not allow unregistering of databases + * and will leave with error code @p KErrNotSupported. To remove a + * "file"-protocol database, the client must call @ref DeleteDatabaseL. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the database to register. + * @par Leave codes: + * @p KErrNotSupported The protocol specified in the URI is not + * supported by this plug-in or the protocol does not allow + * unregistering landmark databases.\n + * @p KErrArgument The URI is incorrect. + */ + void UnregisterDatabaseL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * Unregisters all landmark database which are accessed through this + * plug-in + * + * After this, the landmark databases will not be returned when listing + * landmark databases. + * + * Some protocols like "file" does not allow unregistering of databases + * and will leave with error code @p KErrNotSupported. To remove a + * "file"-protocol database, the client must call @ref DeleteDatabaseL. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since Series 60 3.0 + * @par Leave codes: + * @p KErrNotSupported This plug-in does not allow unregistering + * landmark databases. + */ + void UnregisterAllDatabasesL(); + + /** + * Modifies the settings for a landmark database. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the database to modify settings for. + * @param aDatabaseSettings The new settings for the database. + * @par Leave codes: + * @p KErrNotSupported The protocol specified in the URI is not + * supported by this plug-in.\n + * @p KErrNotFound The specified database is not found. + */ + void ModifyDatabaseSettingsL( + /* IN */ const TDesC& aDatabaseUri, + /* IN */ const TPosLmDatabaseSettings& aDatabaseSettings + ); + + /** + * Retrieve information about a landmark database. + * + * This function requires @p ReadUserData capability. + * + * @since Series 60 3.0 + * @param aDatabaseInfo An information object containing the URI of the + * landmark database. On return, the object contains information about + * the landmark database, including any database settings. + * @par Leave codes: + * @p KErrNotSupported The protocol specified in the URI is not + * supported by this plug-in.\n + * @p KErrNotFound The specified database is not found. + */ + void GetDatabaseInfoL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * Checks if the specified landmark database exists. + * + * The database to check is specified by passing a URI to this function. + * URI construction is described in the class description for + * @ref CPosLmDatabaseManager. + * + * This function requires @p ReadUserData capability. If the database is + * remote, @p NetworkServices capability is also needed. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the database which should be checked + * for existence. + * @return @p ETrue if the database exists, otherwise @p EFalse. + * @par Leave codes: + * @p KErrArgument The URI is incorrect or the protocol specified in the + * URI is not supported by this plug-in.\n + */ + TBool DatabaseExistsL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * Creates a landmark database. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. If the database is remote, @p NetworkServices + * capability is also needed. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the new database. + * @par Leave codes: + * @p KErrNotSupported The operation is not supported by the plug-in.\n + * @p KErrArgument The URI is incorrect or the protocol specified in the + * URI is not supported by this plug-in.\n + * @p KErrAlreadyExists There is already a database at this URI. + */ + void CreateDatabaseL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * Deletes a landmark database. + * + * The database to delete is specified by passing a URI to this + * function. URI construction is described in the class description for + * @ref CPosLmDatabaseManager. The URI must specify the protocol which + * is handled by this database manager plug-in. + * + * If the specified database does not exist, the call is ignored. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. If the database is remote, @p NetworkServices + * capability is also needed. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the database to delete. + * @par Leave codes: + * @p KErrNotSupported The operation is not supported by the plug-in.\n + * @p KErrArgument The URI is incorrect or the protocol specified in the + * URI is not supported by this plug-in.\n + * @p KErrInUse The database is in use by some client.\n + * @p KErrAccessDenied The database is read-only. + */ + void DeleteDatabaseL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * Copies a landmark database to a new location. + * + * Database locations are specified as URIs. URI construction is + * described in the class description for @ref CPosLmDatabaseManager. + * The target and source URIs must specify the protocol which is handled + * by this database manager plug-in. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. If the database is remote, @p NetworkServices + * capability is also needed. + * + * @since Series 60 3.0 + * @param aSourceUri The URI of the database to copy. + * @param aTargetUri The URI of the new database location. + * @par Leave codes: + * @p KErrNotSupported The operation is not supported by the plug-in.\n + * @p KErrArgument A URI is incorrect or the protocol specified in a + * URI is not supported by this plug-in.\n + * @p KErrInUse There is a write-lock on the database, e.g. some client + * is currently modifying the database.\n + * @p KErrNotFound There is no database at the source URI.\n + */ + void CopyDatabaseL( + /* IN */ const TDesC& aSourceUri, + /* IN */ const TDesC& aTargetUri + ); + + + /** + * Retrieves the type of media where a landmark database resides. + * + * This function does not validate the URI. If the URI is invalid, this + * function will just return @p EMediaUnknown. + * + * @since Series 60 3.0 + * @param aDatabaseUri The URI of the database to check media for. + * @return Type of storage media. + */ + TMediaType DatabaseMedia( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * Retrieves the drive letter for the drive where a landmark database + * resides. + * + * If the landmark database is remote or otherwise the drive letter is + * not applicable, 0 is returned. + * + * This function does not validate the URI. If the URI is invalid, this + * function will just return 0. + * + * @param aDatabaseUri The URI of the database to check drive letter + * for. + * @return The drive letter, or 0 if drive letter is not applicable. + */ + TChar DatabaseDrive( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * From CPosLmDatabaseManagerPluginBase + * + * @since Series 60 3.0 + * @return Pointer to the protocol descriptor, e.g. "file" + */ + TPtrC Protocol(); + + protected: + + CDbManTestPluginBase(); + + private: + + TInt FindUri(const TDesC& aUri); + + // By default, prohibit copy constructor + CDbManTestPluginBase( + const CDbManTestPluginBase& ); + // Prohibit assigment operator + CDbManTestPluginBase& operator=( + const CDbManTestPluginBase& ); + + private: // Data + + RPointerArray iDatabases; + + }; + +#endif // CDBMANTESTPLUGINBASE_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_CPosLmDatabaseManagerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_CPosLmDatabaseManagerImpl.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSLMDATABASEMANAGERIMPL_H +#define CPOSLMDATABASEMANAGERIMPL_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include "FT_RPosLandmarkServer.h" +#include "EPos_RPosLmDatabaseEventListener.h" + +// FORWARD DECLARATIONS +class CPosLmSettingsHandler; +class CPosLmDbManPluginStore; +class CPosLmDatabaseManagerPluginBase; + +// CLASS DECLARATION + +/** +* This class is used to manage landmark databases. It implements the common +* database management methods in @refCPosLmDatabaseManager and loads +* protocol-specific database management provider implementations. +* +* @p CPosLmDatabaseManagerImpl contains functions for listing registering, +* unregistering, creating, deleting, copying landmark databases, etc. +* It also has functions for managing the default landmark database. The +* client can listen to events related to database management. +* +* @lib eposlmdbmanprov.lib +* @since Series 60 3.0 +* @version $Revision: 1.1 $, $Date: 2005/03/07 15:36:15 $ +*/ +class CPosLmDatabaseManagerImpl : public CPosLmDatabaseManager + { + public: + + /** + * Two-phased constructor. + * + * @since Series 60 3.0 + */ + static CPosLmDatabaseManagerImpl* NewL(); + + /** + * Destructor. + * + * @since Series 60 3.0 + */ + virtual ~CPosLmDatabaseManagerImpl(); + + public: // Functions from base classes + + /** + * From CPosLmDatabaseManager. + * + * @return The URI of the default landmark database. The client takes + * ownership of the descriptor object. + */ + HBufC* DefaultDatabaseUriLC(); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the database which should be set as + * default. + */ + void SetDefaultDatabaseUriL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aEvent Contains the event information when an event + * occurs. + * @param aStatus Is completed with @p KErrNone if an event + * occurs or an error code if some error is encountered. + */ + void NotifyDatabaseEvent( + /* OUT */ TPosLmDatabaseEvent& aEvent, + /* OUT */ TRequestStatus& aStatus + ); + + /** + * From CPosLmDatabaseManager. + * + * @return @p KErrNone if the request was successfully cancelled, + * otherwise a system wide error code. + */ + TInt CancelNotifyDatabaseEvent(); + + /** + * From CPosLmDatabaseManager. + * + * @return The database URI associated with the event. The client takes + * ownership of the descriptor object. + */ + HBufC* DatabaseUriFromLastEventLC(); + + /** + * From CPosLmDatabaseManager. + * + * @param aProtocol The protocol for which database URIs should be + * listed. If no protocol is specified, i.e. if an empty string is + * specified, all known database URIs are listed. + * @return The list of database URIs. + */ + CDesCArray* ListDatabasesLC( + /* IN */ const TDesC& aProtocol = KNullDesC + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseInfoArray On return, contains information about + * the landmark databases. Any objects which are in the array when + * it is passed to this function are not be removed. + * @param aProtocol The protocol for which database URIs should be + * listed. If no protocol is specified, i.e. if an empty string is + * specified, all known database URIs are listed. + */ + void ListDatabasesL( + /* OUT */ RPointerArray& aDatabaseInfoArray, + /* IN */ const TDesC& aProtocol = KNullDesC + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseInfo Information about the landmark database to + * register. + */ + void RegisterDatabaseL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the database to register. + */ + void UnregisterDatabaseL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aProtocol The protocol to unregister all databases for. + */ + void UnregisterAllDatabasesL( + /* IN */ const TDesC& aProtocol + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the database to modify settings for. + * @param aDatabaseSettings The new settings for the database. + */ + void ModifyDatabaseSettingsL( + /* IN */ const TDesC& aDatabaseUri, + /* IN */ const TPosLmDatabaseSettings& aDatabaseSettings + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseInfo An information object containing the URI of the + * landmark database. On return, the object contains information about + * the landmark database, including any database settings. + */ + void GetDatabaseInfoL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the database which should be checked + * for existence. + * @return @p ETrue if the database exists, otherwise @p EFalse. + */ + TBool DatabaseExistsL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the new database. + */ + void CreateDatabaseL( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aDatabaseUri The URI of the database to delete. + */ + void DeleteDatabaseL( + /* IN */ const TDesC& aDatabaseUri + ); + + /** + * From CPosLmDatabaseManager. + * + * @param aSourceUri The URI of the database to copy. + * @param aTargetUri The URI of the new database location. + */ + void CopyDatabaseL( + /* IN */ const TDesC& aSourceUri, + /* IN */ const TDesC& aTargetUri + ); + + protected: + + /** + * C++ default constructor. + */ + CPosLmDatabaseManagerImpl(); + + private: + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Validates URI and extracts protocol. + * Leaves with @p KErrArgument if the protocol is empty or + * does not exist. + */ + static const TPtrC GetProtocolFromUriL( + /* IN */ const TDesC& aUri + ); + + /** + * Validates URI, i.e. checks that there is a protocol separator + * and the protocol part is not empty. + * Leaves with @p KErrArgument if the protocol is empty or + * does not exist. + */ + static void ValidateUriL( + /* IN */ const TDesC& aUri + ); + + /** + * Returns @p ETrue if database URI starts with "file". + */ + TBool IsLocalDatabase( + /* IN */ const TDesC& aUri + ); + + /** + * Retrieves the default database display name from the resource file. + */ + HBufC* DefaultDatabaseDisplayNameL(); + + /** + * Fills in default flag, database drive and media type in + * each object in the array. Helper for the list method. + */ + void FillInDbInfoListL( + /* IN/OUT */ RPointerArray& aDatabaseInfoArray, + /* IN */ CPosLmDatabaseManagerPluginBase* aPlugin + ); + + /** + * Fills in default flag, database drive and media type in + * the object. Helper for the list method. + */ + void FillInDbInfo( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo, + /* IN */ CPosLmDatabaseManagerPluginBase* aPlugin, + /* IN */ const TDesC& aDefaultDbUri + ); + + + // By default, prohibit copy constructor + CPosLmDatabaseManagerImpl( const CPosLmDatabaseManagerImpl& ); + // Prohibit assigment operator + CPosLmDatabaseManagerImpl& operator= ( const CPosLmDatabaseManagerImpl& ); + + private: // Data + + CPosLmSettingsHandler* iSettingsHandler; + CPosLmDbManPluginStore* iPlugins; + RPosLandmarkServer iSession; + RPosLmDatabaseEventListener iEventListener; + HBufC* iDefaultDatabaseDisplayName; + + }; + +#endif // CPOSLMDATABASEMANAGERIMPL_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_LandmarksDbManagerUids.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_LandmarksDbManagerUids.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* +*/ + + +#ifndef LANDMARKSDBMANAGERUIDS_H +#define LANDMARKSDBMANAGERUIDS_H + +// Landmark Database Manager interface UID +#define KPosLmDbManagerIfUid 0x101FDF79 + +// Landmark Database Manager implementation UID +#define KPosLmDbManagerImplUid 0x101FDF7C + +// Landmark Database Manager Base interface UID +#define KPosLmDbManagerBaseIfUid 0x101FE975 + +// Local Landmarks Database Management Provider implementaton UID +#define KPosLmLocalDbManagerImplUid 0x101FE976 + + +#endif // LANDMARKSDBMANAGERUIDS_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_RPosLandmarkServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/inc/FT_RPosLandmarkServer.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,285 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* +*/ + + +#ifndef RPOSLANDMARKSERVER_H +#define RPOSLANDMARKSERVER_H + +// INCLUDES +#include +#include +#include +#include +#include + +// FORWARD DECLARATIONS +class CPosLandmarkServerExtension; + +// CLASS DECLARATION + +/** +* Client API for the landmark server. +* +* @lib eposlmservlib.lib +* @since S60 3.0 +* @version $Revision: 1.4 $, $Date: 2005/07/07 13:40:03 $ +*/ +class RPosLandmarkServer : public RSessionBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + IMPORT_C RPosLandmarkServer(); + + public: // New functions + + + /** + * Connect to the landmark server. + * + * The server is started if it is not already running. + * + * This function requires @p ReadUserData capability. + * + * @since S60 3.0 + * @return @p KErrNone if successful, otherwise a system-wide error + * code. + */ + IMPORT_C TInt Connect(); + + /** + * Closes the session to the server + * + * @since S60 3.0 + */ + IMPORT_C void Close(); + + /** + * Lists all URIs in the server's database registry for a certain + * protocol. + * + * The client specifies a protocol string as input to this function. + * The function only returns a list of the databases which are + * accessed through this protocol. + * + * The client takes ownership of the returned array. + * + * This function requires @p ReadUserData capability. + * + * @since S60 3.0 + * @param aProtocol The protocol for which database URIs should be + * listed. + * @return The list of database URIs. + */ + IMPORT_C CDesCArray* ListDatabasesLC( + /* IN */ const TDesC& aProtocol + ); + + /** + * Lists information about each landmark database in the + * server's database registry. + * + * The client specifies a protocol string as input to this function. + * The function only returns information about the databases + * which are accessed through this protocol. + * + * The client specifies an array which is populated by this function. + * The client takes ownership of all information objects in the array. + * + * This function requires @p ReadUserData capability. + * + * @since S60 3.0 + * @param aDatabaseInfoArray On return, contains information about + * the landmark databases. Any objects which are in the array when + * it is passed to this function will be not be removed. + * @param aProtocol The protocol for which database URIs should be + * listed. + */ + IMPORT_C void ListDatabasesL( + /* OUT */ RPointerArray& aDatabaseInfoArray, + /* IN */ const TDesC& aProtocol = KNullDesC + ); + + /** + * Registers a landmark database. + * + * The landmark database is then returned when listing landmark + * databases. + * + * The client supplies an information object containing the URI of the + * database to register. The information object can also contain + * database settings, e.g. a display name for the database. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since S60 3.0 + * @param aDatabaseInfo Information about the landmark database to + * register. + * @return @p KErrNone if successful.\n + * @p KErrArgument if the URI is incorrect.\n + * @p KErrAlreadyExists if the database has already been registered. + */ + IMPORT_C TInt RegisterDatabase( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * Unregisters a landmark database. + * + * After this, the landmark database will not be returned when listing + * landmark databases. + * + * If the database has not been registered, nothing happens. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since S60 3.0 + * @param aDatabaseUri The URI of the database to unregister. + * @param aDriveLetter The drive where the database resides. If + * drive is not applicable, 0 should be specified. + * @return @p KErrNone if successful.\n + * @p KErrArgument if the URI is incorrect. + */ + IMPORT_C TInt UnregisterDatabase( + /* IN */ const TDesC& aDatabaseUri, + /* IN */ TChar aDriveLetter = 0 + ); + + /** + * Unregisters all landmark databases which are accessed through a + * certain protocol. + * + * After this, the landmark databases will not be returned when listing + * landmark databases. + * + * If the protocol is not known or if there are no databases for + * the protocol, nothing happens. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since S60 3.0 + * @param aProtocol The protocol to unregister all databases for. + * @return @p KErrNone if successful, otherwise a system-wide error + * code. + */ + IMPORT_C TInt UnregisterAllDatabases( + /* IN */ const TDesC& aProtocol + ); + + /** + * Modifies the settings for a landmark database. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since S60 3.0 + * @param aDatabaseUri The URI of the database to modify settings for. + * @param aDatabaseSettings The new settings for the database. + * @param aDriveLetter The drive where the database resides. If + * drive is not applicable, 0 should be specified. + * @return @p KErrNone if successful.\n + * @p KErrArgument if the URI is incorrect.\n + * @p KErrNotFound if the URI does not exist in the registry. + */ + IMPORT_C TInt ModifyDatabaseSettings( + /* IN */ const TDesC& aDatabaseUri, + /* IN */ const TPosLmDatabaseSettings& aDatabaseSettings, + /* IN */ TChar aDriveLetter = 0 + ); + + /** + * Retrieve information about a landmark database. + * + * This function requires @p ReadUserData capability. + * + * @since S60 3.0 + * @param aDatabaseInfo An information object containing the URI of the + * landmark database. On return, the object contains information about + * the landmark database, including any database settings. + * @return @p KErrNone if successful.\n + * @p KErrArgument if the URI is incorrect.\n + * @p KErrNotFound if the URI does not exist in the registry. + */ + IMPORT_C TInt GetDatabaseInfo( + /* IN/OUT */ HPosLmDatabaseInfo& aDatabaseInfo + ); + + /** + * Reports a database management event. + * + * The event is distributed to all listening clients. + * + * A database URI can be specified to indicate which database the + * event is about. + * + * This function requires @p ReadUserData and @p WriteUserData + * capabilities. + * + * @since S60 3.0 + * @param aEvent Event information + * @param aDatabaseUri The URI of the database which the event is about. + * @return @p KErrNone if successful, otherwise a system-wide error + * code. + */ + IMPORT_C TInt ReportEvent( + /* IN */ const TPosLmDatabaseEvent& aEvent, + /* IN */ const TDesC& aDatabaseUri = KNullDesC + ); + + private: + + HBufC8* SendMessageLC( + /* IN */ TInt aFunction, + /* IN */ const TDesC& aDes, + /* IN */ TInt aLength, + /* IN/OUT */ TInt& aAllocLength + ); + + void PopulateArrayL( + /* OUT */ RPointerArray& aDatabaseInfoArray, + /* IN */ HBufC8* aBuffer + ); + + void PopulateArrayL( + /* OUT */ CDesCArray* aArray, + /* IN */ HBufC8* aBuffer + ); + + void FreeResources(); + + static void FreeRsc(TAny* aParam); + /** + * Starts the server. + * + * @return KErrNone on success, otherwise any system wide error. + */ + TInt StartServer(); + + private: // Data + + CPosLandmarkServerExtension* iExtension; + }; + +#endif // RPOSLANDMARKSERVER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/resource/04440010.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/resource/04440010.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 0444 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "RegistryInfo.rh" +#include "FT_LandmarksDbManagerUids.hrh" + +// RESOURCE DEFINITIONS +// ----------------------------------------------------------------------------- +// +// r_dbmantestprov +// ECOM registry information for Database Management Provider test plugins +// +// ----------------------------------------------------------------------------- +// +RESOURCE REGISTRY_INFO r_dbmantestprov + { + dll_uid = 0x04440010; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KPosLmDbManagerBaseIfUid; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x04440011; + version_no = 1; + display_name = "Protocol 1"; + default_data = "p1"; // supports p1 protocol + } + }; + } + }; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/CDbManTestPluginBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/CDbManTestPluginBase.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,322 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +// INCLUDE FILES +//#include +#include "CDbManTestPluginBase.h" +#include "FT_RPosLandmarkServer.h" + + +// CONSTANTS +_LIT(KPluginProtocol, "test"); + +// MEMBER FUNCTIONS + +// Destructor +CDbManTestPluginBase::~CDbManTestPluginBase() + { + iDatabases.ResetAndDestroy(); + } + +CDbManTestPluginBase::CDbManTestPluginBase() + { + } + +// ----------------------------------------------------------------------------- +// CDbManTestPluginBase::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CDbManTestPluginBase* CDbManTestPluginBase::NewL(TAny* aConstructionParams) + { + CDbManTestPluginBase* self = new( ELeave ) CDbManTestPluginBase; + CleanupStack::PushL(self); + self->BaseConstructL(aConstructionParams); + CleanupStack::Pop(self); + return self; + + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::ListDatabasesLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CDesCArray* CDbManTestPluginBase::ListDatabasesLC() + { + TInt count = iDatabases.Count(); + CDesCArrayFlat* result = + new(ELeave) CDesCArrayFlat(count == 0 ? 1 : count); + CleanupStack::PushL(result); + + for (TInt i = 0; i < count; i++) + { + result->AppendL(iDatabases[i]->DatabaseUri()); + } + return result; + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::ListDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::ListDatabasesL( + RPointerArray& aDatabaseInfoArray + ) + { + TInt count = iDatabases.Count(); + + for (TInt i = 0; i < count; i++) + { + HPosLmDatabaseInfo* tmpDbInfo = + HPosLmDatabaseInfo::NewLC(*(iDatabases[i])); + aDatabaseInfoArray.AppendL(tmpDbInfo); + CleanupStack::Pop(tmpDbInfo); + } + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::RegisterDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::RegisterDatabaseL( + HPosLmDatabaseInfo& aDatabaseInfo + ) + { + if (DatabaseExistsL(aDatabaseInfo.DatabaseUri())) + { + User::Leave(KErrAlreadyExists); + } + HPosLmDatabaseInfo* tmpDbInfo = + HPosLmDatabaseInfo::NewLC(aDatabaseInfo); + iDatabases.AppendL(tmpDbInfo); + CleanupStack::Pop(tmpDbInfo); + + TPosLmDatabaseEvent event; + event.iEventType = EPosLmDbDatabaseRegistered; + Session().ReportEvent(event, aDatabaseInfo.DatabaseUri()); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::UnregisterDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::UnregisterDatabaseL( + const TDesC& aDatabaseUri + ) + { + TInt index = FindUri(aDatabaseUri); + User::LeaveIfError(index); + delete iDatabases[index]; + iDatabases.Remove(index); + + TPosLmDatabaseEvent event; + event.iEventType = EPosLmDbDatabaseUnregistered; + Session().ReportEvent(event, aDatabaseUri); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::UnregisterAllDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::UnregisterAllDatabasesL() + { + iDatabases.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::ModifyDatabaseSettingsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::ModifyDatabaseSettingsL( + const TDesC& aDatabaseUri, + const TPosLmDatabaseSettings& aDatabaseSettings + ) + { + TInt index = FindUri(aDatabaseUri); + User::LeaveIfError(index); + iDatabases[index]->Settings() = aDatabaseSettings; + + TPosLmDatabaseEvent event; + event.iEventType = EPosLmDbSettingsModified; + Session().ReportEvent(event, aDatabaseUri); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::GetDatabaseInfoL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::GetDatabaseInfoL( + HPosLmDatabaseInfo& aDatabaseInfo + ) + { + TInt index = FindUri(aDatabaseInfo.DatabaseUri()); + User::LeaveIfError(index); + HPosLmDatabaseInfo* dbInfo = iDatabases[index]; + aDatabaseInfo.Settings() = dbInfo->Settings(); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::DatabaseExistsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CDbManTestPluginBase::DatabaseExistsL( + const TDesC& aDatabaseUri + ) + { + return FindUri(aDatabaseUri) >= 0 ? ETrue : EFalse; + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::CreateDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::CreateDatabaseL( + HPosLmDatabaseInfo& aDatabaseInfo + ) + { + // Do nothing + //RegisterDatabaseL(aDatabaseInfo); + // + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::DeleteDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::DeleteDatabaseL( + const TDesC& aDatabaseUri + ) + { + UnregisterDatabaseL(aDatabaseUri); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::CopyDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CDbManTestPluginBase::CopyDatabaseL( + const TDesC& aSourceUri, + const TDesC& aTargetUri + ) + { + TInt srcIndex = FindUri(aSourceUri); + User::LeaveIfError(srcIndex); + TInt trgIndex = FindUri(aTargetUri); + if (trgIndex >= 0) + { + User::Leave(KErrAlreadyExists); + } + HPosLmDatabaseInfo* trgInfo = + HPosLmDatabaseInfo::NewLC(aTargetUri); + iDatabases.AppendL(trgInfo); + CleanupStack::Pop(trgInfo); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::DatabaseMedia +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TMediaType CDbManTestPluginBase::DatabaseMedia( + const TDesC& /* aDatabaseUri */ + ) + { + return EMediaRemote; + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::DatabaseDrive +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TChar CDbManTestPluginBase::DatabaseDrive( + const TDesC& /* aDatabaseUri */ + ) + { + return 'U'; + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::Protocol +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TPtrC CDbManTestPluginBase::Protocol() + { + return TPtrC(KPluginProtocol); + } + +// --------------------------------------------------------- +// CDbManTestPluginBase::FindUri +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CDbManTestPluginBase::FindUri(const TDesC& aUri) + { + TInt index; + TInt count = iDatabases.Count(); + TBool found = EFalse; + + for (index = 0; index < count && !found; index++) + { + if (aUri.Compare(iDatabases[index]->DatabaseUri()) == 0) + { + found = ETrue; + } + } + index--; + + if (!found) + { + index = KErrNotFound; + } + return index; + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/DbManPluginsTestMain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/DbManPluginsTestMain.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDE FILES +#include +#include "FT_LandmarksDbManagerUids.hrh" +//#include "CDbManTestPlugin1.h" +#include "CDbManTestPluginBase.h" +//#include "CDbManTestPlugin2.h" +//#include "CDbManTestPlugin3.h" + +// ==================== LOCAL FUNCTIONS ==================== + +// Define the interface UIDs +const TImplementationProxy KPosLmLocalImplTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x04440011, CDbManTestPluginBase::NewL), + //IMPLEMENTATION_PROXY_ENTRY(0x04440012, CDbManTestPlugin2::NewL), + //IMPLEMENTATION_PROXY_ENTRY(0x04440013, CDbManTestPlugin3::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KPosLmLocalImplTable) / sizeof(TImplementationProxy); + + return KPosLmLocalImplTable; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/FT_LmDbManProviderMain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/TestProvider/src/FT_LmDbManProviderMain.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Provider. +* +*/ + + +// INCLUDE FILES +#include +#include "FT_LandmarksDbManagerUids.hrh" +#include "FT_CPosLmDatabaseManagerImpl.h" + +// ==================== LOCAL FUNCTIONS ==================== + +// Define the interface UIDs +const TImplementationProxy KPosLmLocalImplTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KPosLmDbManagerImplUid, CPosLmDatabaseManagerImpl::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KPosLmLocalImplTable) / sizeof(TImplementationProxy); + + return KPosLmLocalImplTable; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/conf/LandMarksTestModule1.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/conf/LandMarksTestModule1.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,617 @@ + +[Test] +title TP1 +create LandMarksTestModule foobar +foobar FT_CPosTp1 +delete foobar +[Endtest] + + + +[Test] +title TP3 +create LandMarksTestModule foobar +foobar FT_CPosTp3 +delete foobar +[Endtest] + +[Test] +title TP4 +create LandMarksTestModule foobar +foobar FT_CPosTp4 +delete foobar +[Endtest] + +[Test] +title TP5 +create LandMarksTestModule foobar +foobar FT_CPosTp5 +delete foobar +[Endtest] + +[Test] +title TP6 +create LandMarksTestModule foobar +foobar FT_CPosTp6 +delete foobar +[Endtest] + + +[Test] +title TP7 +create LandMarksTestModule foobar +foobar FT_CPosTp7 +delete foobar +[Endtest] + +[Test] +title TP8 +create LandMarksTestModule foobar +foobar FT_CPosTp8 +delete foobar +[Endtest] + +[Test] +title TP9 +create LandMarksTestModule foobar +foobar FT_CPosTp9 +delete foobar +[Endtest] + +[Test] +title TP10 +create LandMarksTestModule foobar +foobar FT_CPosTp10 +delete foobar +[Endtest] + + +[Test] +title TP11 +create LandMarksTestModule foobar +foobar FT_CPosTp11 +delete foobar +[Endtest] + +[Test] +title TP12 +create LandMarksTestModule foobar +foobar FT_CPosTp12 +delete foobar +[Endtest] + +[Test] +title TP13 +create LandMarksTestModule foobar +foobar FT_CPosTp13 1 +delete foobar +[Endtest] + + +[Test] +title TP18 +create LandMarksTestModule foobar +foobar FT_CPosTp18 +delete foobar +[Endtest] + + +[Test] +title TP19 +create LandMarksTestModule foobar +foobar FT_CPosTp19 +delete foobar +[Endtest] + + +[Test] +title TP20 +create LandMarksTestModule foobar +foobar FT_CPosTp20 +delete foobar +[Endtest] + + + +[Test] +title TP21 +create LandMarksTestModule foobar +foobar FT_CPosTp21 +delete foobar +[Endtest] + + + + +[Test] +title TP23 +create LandMarksTestModule foobar +foobar FT_CPosTp23 +delete foobar +[Endtest] + + + +[Test] +title TP24 +create LandMarksTestModule foobar +foobar FT_CPosTp24 +delete foobar +[Endtest] + + +[Test] +title TP25 +create LandMarksTestModule foobar +foobar FT_CPosTp25 +delete foobar +[Endtest] + + + +[Test] +title TP26 +create LandMarksTestModule foobar +foobar FT_CPosTp26 +delete foobar +[Endtest] + + + +[Test] +title TP28 +create LandMarksTestModule foobar +foobar FT_CPosTp28 +delete foobar +[Endtest] + + +[Test] +title TP35 +create LandMarksTestModule foobar +foobar FT_CPosTp35 +delete foobar +[Endtest] + + +[Test] +title TP36 +create LandMarksTestModule foobar +foobar FT_CPosTp36 +delete foobar +[Endtest] + +[Test] +title TP37 +create LandMarksTestModule foobar +foobar FT_CPosTp37 +delete foobar +[Endtest] + +[Test] +title TP38 +create LandMarksTestModule foobar +foobar FT_CPosTp38 +delete foobar +[Endtest] + +[Test] +title TP42 +create LandMarksTestModule foobar +foobar FT_CPosTp42 +delete foobar +[Endtest] + +[Test] +title TP43 +create LandMarksTestModule foobar +foobar FT_CPosTp43 +delete foobar +[Endtest] + +[Test] +title TP44 +create LandMarksTestModule foobar +foobar FT_CPosTp44 +delete foobar +[Endtest] + +[Test] +title TP45 +create LandMarksTestModule foobar +foobar FT_CPosTp45 +delete foobar +[Endtest] + + +[Test] +title TP47 +create LandMarksTestModule foobar +foobar FT_CPosTp47 +delete foobar +[Endtest] + + + +[Test] +title TP48 +create LandMarksTestModule foobar +foobar FT_CPosTp48 +delete foobar +[Endtest] + + +[Test] +title TP51 +create LandMarksTestModule foobar +foobar FT_CPosTp51 +delete foobar +[Endtest] + +[Test] +title TP52 +create LandMarksTestModule foobar +foobar FT_CPosTp52 +delete foobar +[Endtest] + + +[Test] +title TP100 +create LandMarksTestModule foobar +foobar FT_CPosTp100 +delete foobar +[Endtest] + +[Test] +title TP101 +create LandMarksTestModule foobar +foobar FT_CPosTp101 +delete foobar +[Endtest] + +[Test] +title TP102 +create LandMarksTestModule foobar +foobar FT_CPosTp102 +delete foobar +[Endtest] + + +[Test] +title TP103 +create LandMarksTestModule foobar +foobar FT_CPosTp103 +delete foobar +[Endtest] + +[Test] +title TP104 +create LandMarksTestModule foobar +foobar FT_CPosTp104 +delete foobar +[Endtest] + +[Test] +title TP106 +create LandMarksTestModule foobar +foobar FT_CPosTp106 +delete foobar +[Endtest] + +[Test] +title TP116 +create LandMarksTestModule foobar +foobar FT_CPosTp116 +delete foobar +[Endtest] + +[Test] +title TP117 +create LandMarksTestModule foobar +foobar FT_CPosTp117 +delete foobar +[Endtest] + + +[Test] +title TP119 +create LandMarksTestModule foobar +foobar FT_CPosTp119 +delete foobar +[Endtest] + +[Test] +title TP120 +create LandMarksTestModule foobar +foobar FT_CPosTp120 +delete foobar +[Endtest] + + +[Test] +title TP121 +create LandMarksTestModule foobar +foobar FT_CPosTp121 +delete foobar +[Endtest] + + + +[Test] +title TP122 +create LandMarksTestModule foobar +foobar FT_CPosTp122 +delete foobar +[Endtest] + + + +[Test] +title TP123 +create LandMarksTestModule foobar +foobar FT_CPosTp123 +delete foobar +[Endtest] + + + +[Test] +title TP124 +create LandMarksTestModule foobar +foobar FT_CPosTp124 +delete foobar +[Endtest] + + + +[Test] +title TP125 +create LandMarksTestModule foobar +foobar FT_CPosTp125 +delete foobar +[Endtest] + +[Test] +title TP126 +create LandMarksTestModule foobar +foobar FT_CPosTp126 +delete foobar +[Endtest] + +[Test] +title TP130 +create LandMarksTestModule foobar +foobar FT_CPosTp130 +delete foobar +[Endtest] + + + +[Test] +title TP131 +create LandMarksTestModule foobar +foobar FT_CPosTp131 +delete foobar +[Endtest] + + +[Test] +title TP132 +create LandMarksTestModule foobar +foobar FT_CPosTp132 +delete foobar +[Endtest] + + + +[Test] +title TP133 +create LandMarksTestModule foobar +foobar FT_CPosTp133 +delete foobar +[Endtest] + +[Test] +title TP134 +create LandMarksTestModule foobar +foobar FT_CPosTp134 +delete foobar +[Endtest] + + +[Test] +title TP135 +create LandMarksTestModule foobar +foobar FT_CPosTp135 +delete foobar +[Endtest] + + + +[Test] +title TP136 +create LandMarksTestModule foobar +foobar FT_CPosTp136 +delete foobar +[Endtest] + + + +[Test] +title TP137 +create LandMarksTestModule foobar +foobar FT_CPosTp137 +delete foobar +[Endtest] + + +[Test] +title TP139 +create LandMarksTestModule foobar +foobar FT_CPosTp139 +delete foobar +[Endtest] + + + +[Test] +title TP141 +create LandMarksTestModule foobar +foobar FT_CPosTp141 +delete foobar +[Endtest] + +[Test] +title TP143 - Counters +create LandMarksTestModule foobar +foobar FT_CPosTp143 +delete foobar +[Endtest] + +[Test] +title TP144 +create LandMarksTestModule foobar +foobar FT_CPosTp144 +delete foobar +[Endtest] + +[Test] +title TP145 +create LandMarksTestModule foobar +foobar FT_CPosTp145 +delete foobar +[Endtest] + +[Test] +title TP146 +create LandMarksTestModule foobar +foobar FT_CPosTp146 +delete foobar +[Endtest] + +[Test] +title TP147 +create LandMarksTestModule foobar +foobar FT_CPosTp147 +delete foobar +[Endtest] + +[Test] +title TP148 +create LandMarksTestModule foobar +foobar FT_CPosTp148 +delete foobar +[Endtest] + +[Test] +title TP149 +create LandMarksTestModule foobar +foobar FT_CPosTp149 +delete foobar +[Endtest] + +[Test] +title TP150 +create LandMarksTestModule foobar +foobar FT_CPosTp150 +delete foobar +[Endtest] + +[Test] +title TP151 +create LandMarksTestModule foobar +foobar FT_CPosTp151 +delete foobar +[Endtest] + +[Test] +title TP152 +create LandMarksTestModule foobar +foobar FT_CPosTp152 +delete foobar +[Endtest] + +[Test] +title TP153 +create LandMarksTestModule foobar +foobar FT_CPosTp153 +delete foobar +[Endtest] + +[Test] +title TP154 +create LandMarksTestModule foobar +foobar FT_CPosTp154 +delete foobar +[Endtest] + +[Test] +title TP155 +create LandMarksTestModule foobar +foobar FT_CPosTp155 +delete foobar +[Endtest] + +[Test] +title TP156 +create LandMarksTestModule foobar +foobar FT_CPosTp156 +delete foobar +[Endtest] + +[Test] +title TP157 +create LandMarksTestModule foobar +foobar FT_CPosTp157 +delete foobar +[Endtest] + +[Test] +title TP158 +create LandMarksTestModule foobar +foobar FT_CPosTp158 +delete foobar +[Endtest] + +[Test] +title TP159 +create LandMarksTestModule foobar +foobar FT_CPosTp159 +delete foobar +[Endtest] + +[Test] +title TP160 +create LandMarksTestModule foobar +foobar FT_CPosTp160 +delete foobar +[Endtest] + +[Test] +title TP161 +create LandMarksTestModule foobar +foobar FT_CPosTp161 +delete foobar +[Endtest] + +[Test] +title TP162 +create LandMarksTestModule foobar +foobar FT_CPosTp162 +delete foobar +[Endtest] + +[Test] +title TP163 +create LandMarksTestModule foobar +foobar FT_CPosTp163 +delete foobar +[Endtest] + +[Test] +title TP164 +create LandMarksTestModule foobar +foobar FT_CPosTp164 +delete foobar +[Endtest] diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/552410208-landmarksDb.xls Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/552410208-landmarksDb.xls has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/CompositelandmarksDb.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/CompositelandmarksDb.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,110 @@ +#CategoryId CategoryName Icon name Icon index Id In Categories LandmarkName CoverageRadius Description Icon name Icon index Street PostalCode City LocationName Country Media Link 1 Media Link 2 Lat Long Hor. Acc Vert. Acc +1 Pizzeria z:\\system\\test\\landmarkstestsicon.mbm 1 1 1 LOG 1 jadajadjada ikon slask 1 Halmstad Drivhuset Plan7 html/text/http://www.idg.se/to.html1 html/text/https://www.aftonbladet.s 45,5 -44,5 10 10 +2 Hamburgerbar z:\\system\\test\\landmarkstestsicon.mbm 1 2 1 LOG11 2 jadajadjada ikon snask 1 Berghemsgatan 2 531 37 Kållered Västra Götaland Sverige html/text/http://www.idg.se/to.html2 html/text/https://www.aftonbladet.se 46 44 14 10 +3 Kinarestaurang z:\\system\\test\\landmarkstestsicon.mbm 1 3 2 God 23 ikon skask 1 431 31 Mölndal Västra Götaland Sverige1 html/text/http://www.idg.se/to.html3 html/text/https://www.aftonbladet.se 45 45 11 10 +4 Garaget z:\\system\\test\\landmarkstestsicon.mbm 1 4 2 vegetariskt 5 jadajadjada ikon spask 1 Berghemsgatan 10 Mölndal Västra Götaland Sverige1 html/text/http://www.idg.se/to.html4 html/text/https://www.aftonbladet.se -45,5 -44,5 0 10 +5 Bilverkstad z:\\system\\test\\landmarkstestsicon.mbm 2 5 3 Inte sa bra 6 jadajadjada Berghemsgatan 4 431 31 Västra Götaland Sverige1 html/text/http://www.idg.se/to.html5 html/text/https://www.aftonbladet.se -46,105 46,105 0 10 +6 Pasta Restaurang z:\\system\\test\\landmarkstestsicon.mbm 2 6 3 Dyrt 7 jadajadjada ikon PelleFant 2 Berghemsgatan 7 431 31 Mölndal Sverige1 html/text/http://www.idg.se/to.html6 html/text/https://www.aftonbladet.se 70 70 180 10 +7 Bilia 2 7 1-3,14-17 Billigt 8 jadajadjada ikon Abibblan 2 Berghemsgatan 6 431 31 Mölndal Västra Götaland html/text/http://www.idg.se/to.html7 html/text/https://www.aftonbladet.se 63 23 18 10 +8 VolksWagen sddsa 2 8 3 Medel 1 MLFW ikon bibblan123 2 Berghemsgatan 8 431 31 Mölndal Västra Götaland Sverige1 html/text/http://www.idg.se/to.html8 5 37,6 37,6 10 +9 Taxi Göteborg dasdsada 2 9 3 Medel2 1 jadajadjada ikon bibblan123 2 Berghemsgatan 5 431 31 Mölndal Västra Götaland Sverige1 html/text/http://www.idg.se/to.html9 5 37,6 37,6 10 +10 Taxi dsa 2 10 3 MLFW2 1 MLFW ikon PelleFant 2 Berghemsgatan 9 431 31 Mölndal Västra Götaland Sverige1 html/text/http://www.idg.se/to.html10 html/text/http://www.idg.se -1 -81 25 0 +11 Stadsbibliotek aaa 2 11 MLFW 1 aaaaaa ikon PelleFant 2 MLFW 351 25 HalmstadA BSverige1 html/text/http://www.idg.se/to.html11 html/text/http://www.idg.se 0 -67 48 0 +12 Systembolag aaa 3 12 3 GatesB 1 bbbbbbb ikon PelleFant 3 PastaGatan L MLFW HalmstadB BSverige2 html/text/http://www.idg.se/to.html12 html/text/http://www.hotmail.com 1 -81 7 0 +13 Nokia Kontor aaa 3 13 3 Text'''1 1 ccccccc ikon PelleFant 3 PastaGatan N MLFW MLFW BSverige3 html/text/http://www.idg.se/to.html13 html/text/http://www.idg.se 45 -45 18 0 +14 TietoEnator kontor aaa 3 14 5 GatesF 1 dddddddd ikon PelleFant 3 MLFW 351 29 HalmstadJ BSverige4 html/text/http://www.idg.se/to.html14 html/text/http://www.idg.se -1 -80 168 0 +15 Thai Restaurang bbb 3 15 5 xStekt 1 MLFW ikon PelleFant 3 Berghemsgatan 11 431 31 Mölndal Västra Götaland html/text/http://www.idg.se/to.html15 html/text/http://www.idg.se -5 25 +16 McDonalds bbb 3 16 3 Akorthus 1 fffffffffffffffff ikon PelleFant 3 AStora biblioteksgatan 24 A123 45 AStorGöteborg AÖstra Götaland html/text/http://www.idg.se/to.html16 html/text/http://www.idg.se 1 -81 12 50 +17 BurgerKing bbb 3 17 17 Stadskortxhus 1 ggghhhhhh ikon PelleFant 3 Stora biblioteksgatan 25 321 32 StorGöteborg123 Östra Götaland123 html/text/http://www.idg.se/to.html17 html/text/http://www.idg.se 57 11 11 9 +18 Frisör bbb 3 18 18 enat?r 1 iiiijjjjjj ikon PelleFant 3 Stora biblioteksgatan 25 321 32 StorGöteborg123 Östra Götaland123 html/text/http://www.idg.se/to.html18 html/text/http://www.idg.se 0 -80,5 10,2 1,5 +19 Hunddagis bbb 4 19 19 enator 1 kkkkklll Gårdaikonen 4 Berghemsgatan 1 Finland html/text/http://www.idg.se/to.html19 23 23 10,2 1,5 +20 Veterinär bbb 4 20 21 LOG2 1 mmmm Gårdaikonen 4 Berghemsgatan 2 431 32 Mölndal Västra Götaland html/text/http://www.idg.se/to.html20 html/text/https://www.aftonbladet.se -1 80 10,2 1,5 +21 Kyrkogård bbb 4 21 19 LOG3 1 nnnxnnn Gårdaikonen 4 Berghemsgatan 3 431 33 Mölndal Västra Götaland html/text/http://www.idg.se/to.html21 html/text/https://www.aftonbladet.se 1 80 25 300 +22 Museum bbb 4 22 22 LOG4 1 ooooooo Gårdaikonen 4 Berghemsgatan 4 431 34 Mölndal Västra Götaland html/text/http://www.idg.se/to.html22 html/text/http://www.idg.se -1 81 10,2 1,55 +23 Dagis bbb 4 23 23 LOG5 1 ppppppx Gårdaikonen 4 Berghemsgatan 5 431 35 Mölndal Västra Götaland html/text/http://www.idg.se/to.html23 html/text/https://www.aftonbladet.se 1 81 18 120 +24 StadsPark bbb 4 24 24 LOG6 1 asd Gårdaikonen 4 Berghemsgxatan 6 431 36 Mölndal Västra Götaland html/text/http://www.idg.se/to.html24 html/text/http://www.idg.se 0 80,5 168,9 7000 +25 Sjukhus bbb 4 25 25 x 1 r Gårdaikonen 4 Berghemsgatan 7 x431 37 Mölndal Västra Götaland html/text/http://www.idg.se/to.html25 html/text/https://www.aftonbladet.se -84 12,4 12,5 10 +26 Läkare bbb 5 26 26 LOG8 1 x Gårdaikonen 5 Berghemsgatan 8 431 38 xMölndal Västra Götaland html/text/http://www.idg.se/to.html26 html/text/https://www.aftonbladet.se 5 25 59 2000 + 27 11-17 LOG9 1 ttttt Gårdaikonen 5 Berghemsgatan 9 431 39 Mölndal x Västra Götaland html/text/http://www.idg.se/to.html27 html/text/https://www.aftonbladet.se -84 12 + 28 11 LOG10 1 v Gårdaikonen 5 Berghemsgatan 10 431 40 Mölndal Västra Götalandx html/text/http://www.idg.se/to.html28 html/text/https://www.aftonbladet.se 10 14 13,9 6000 + 29 26 Unique 1 Gårdaikonen 5 256 78 Mölndal Daanmark html/text/http://www.idg.se/to.html29 html/text/https://www.aftonbladet.se 45,5 -0,5 0 1200 + 30 26 Text'1 1 Unique Gårdaikonen 5 256 78 Götet Daanmark html/text/http://www.idg.se/to.html30 html/text/https://wwwx.aftonbladet.se 45,5 0 0 112 + 31 26 Text1 1 Focus Torget1 56 Unique 256 78 Mölndal Daanmark html/text/http://www.idg.se/to.html31 html/text/https://www.aftonbladet.se 45,5 0,5 0 0 + 32 Text2 1 Focus Torget1 6 256 78 Unique Daanmark html/text/http://www.idg.se/to.html32 html/text/https://www.aftonbladet.se 89 -15 0 0 + 33 26 Text3 1 Focus Torget1 6 256 78 Götet Daanmark html/text/http://www.idg.se/to.html33 html/text/https://www.aftonbladet.se 5 37,6 0 0 + 34 26 Text4 1 Focus Torget1 66 256 78 Götet Daanmark html/text/http://www.idg.se/to.html34 html/text/http://www.idg.se 63 23 18 0 + 35 26 Text5 1 Focus Torget1 6 256 78 Götet Daanmark html/text/http://www.idg.se/to.html35 html/text/https://www.aftonbladet.se -84,2 -2,67 168,9 0 + 36 Text6 1 Focus Torget1 6 256 78 Götet Daanmark html/text/http://www.idg.se/to.html36 html/text/http://www.idg.se 5 37,6 37,6 0 + 37 26 Text7 1 Focus Torget1 6 256 78 Götet Daanmark html/text/http://www.idg.se/to.html37 o 5 37,6 37,6 0 + 38 26 Text8 1 256 78 Götet Daanmark html/text/http://www.idg.se/to.html38 html/text/http://www.idg.se 5 37,6 0 0 + 39 Text9 1 256 78 Götet Daanmark html/text/http://www.idg.se/to.html39 5 25 59 2000 + 40 26 Text10 1 256 78 Götet Daanmark html/text/http://www.idg.se/to.html40 0 180 168,9 4500 + 41 26 q 1 256 78 Götet Daanmark html/text/http://www.idg.se/to.html41 -1 180 37,6 2 + 42 26 asd 1 256 78 html/text/http://www.idg.se/to.html42 1 180 37,6 1 + 43 asdf 1 256 78 html/text/http://www.idg.se/to.html43 0 -179 + 44 26 dfdsf 1 256 78 html/text/http://www.idg.se/to.html44 0 179 + 45 26 Several 1 Several Several 1 Several Several Several Several Several html/text/http://www.idg.se/to.html45 Several -1 -179 + 46 26 oki 1 aaa aaa html/text/http://www.idg.se/to.html46 -1 179 + 47 26 abab 1 oki aaa html/text/http://www.idg.se/to.html47 1 -179 + 48 26 Nokia 1 aaa aaa oki html/text/http://www.idg.se/to.html48 1 179 + 49 26 aba 1 Nokia aaa aaa aaa html/text/http://www.idg.se/to.html49 -25 34 + 50 26 aca 1 aaa aaa Noki html/text/http://www.idg.se/to.html50 65 -76,6 + 51 1 PellesPizza 1 IconName1 Berghemsgatan1 Sverige html/text/http://www.idg.se/to.html51 12,89 156 + 52 19 Kalles Hundgård 1 IconName2 Berghemsgatan2 Sverige html/text/http://www.idg.se/to.html52 -45 -1 12 50 + 53 21 Sjömanskyrkan 1 IconName3 Berghemsgatan3 Sverige html/text/http://www.idg.se/to.html53 25,05 -5,5 13 49 + 54 14 TE, Gårda 10 IconName4 Berghemsgatan4 Sverige html/text/http://www.idg.se/to.html54 -45 -5 14 48 + 55 14 TE, Eriksberg 20 IconName5 Berghemsgatan5 Sverige html/text/http://www.idg.se/to.html55 -35 0 15 47 + 56 TE, Lund 30 IconName6 Berghemsgatan6 Sverige html/text/http://www.idg.se/to.html56 -25 5 16 46 + 57 14 TE, Karlstad 40 IconName7 Berghemsgatan7 Sverige html/text/http://www.idg.se/to.html57 -15 10 + 58 14 TE, Kista 50 IconName8 Berghemsgatan8 Sverige html/text/http://www.idg.se/to.html58 -5 15 + 59 14 TE, Stockholm 60 IconName9 Berghemsgatan9 Sverige html/text/http://www.idg.se/to.html59 5 20 + 60 14 TE, Oulu 70 IconName10 Berghemsgatan10 Finland html/text/http://www.idg.se/to.html60 15 25 + 61 14 TE, Tampere 80 IconName11 Berghemsgatan11 Finland html/text/http://www.idg.se/to.html61 25 30 + 62 13 Nokia, Köpenhamn 1 IconName12 Berghemsgatan12 Danmark html/text/http://www.idg.se/to.html62 90 1 + 63 13 Nokia, Stockholm 1 IconName13 Berghemsgatan13 Sverige html/text/http://www.idg.se/to.html63 90 -180 + 64 13 Oulu 1 IconName14 Berghemsgatan14 Sverige html/text/http://www.idg.se/to.html64 67 123 + 65 13 Tampere 5 IconName15 Berghemsgatan15 Sverige html/text/http://www.idg.se/to.html65 67 123 + 66 13 Helsinki 10 IconName16 Berghemsgatan16 Sverige html/text/http://www.idg.se/to.html66 67 123 + 67 13 Bengtfors 15 IconName17 Berghemsgatan17 Sverige html/text/http://www.idg.se/to.html67 67 123 + 68 13 Karlstad 20 IconName18 Berghemsgatan18 Sverige html/text/http://www.idg.se/to.html68 67 123 + 69 13 Mölndal 25 IconName19 Berghemsgatan19 Sverige html/text/http://www.idg.se/to.html69 67 123 + 70 13 Göteborg 30 IconName20 Berghemsgatan20 Sverige html/text/http://www.idg.se/to.html70 67 123 + 71 13 PallesPalör 35 IconName21 Berghemsgatan21 Sverige html/text/http://www.idg.se/to.html71 89 0 + 72 26 Läkare utan gränser 1 IconName22 Berghemsgatan22 Sverige html/text/http://www.idg.se/to.html72 179 120,58 + 73 26 Mölndal 1 IconName23 Berghemsgatan23 Sverige html/text/http://www.idg.se/to.html73 -89 -180 + 74 26 Läkargruppen 1 IconName24 Berghemsgatan24 Sverige html/text/http://www.idg.se/to.html74 -89 180 + 75 26 Läkarhuset 1 IconName25 Berghemsgatan25 Sverige html/text/http://www.idg.se/to.html75 -90 180 + 76 26 Sahlgrenska 1 IconName26 Berghemsgatan26 Sverige html/text/http://www.idg.se/to.html76 -90 -180 + 77 26 östra sjukhuset 1 IconName27 Berghemsgatan27 Sverige html/text/http://www.idg.se/to.html77 -90 0 + 78 20 Blå stjärnan 1 IconName28 Berghemsgatan28 Sverige html/text/http://www.idg.se/to.html78 -89 0 + 79 10 MiniTaxi 1 IconName29 Berghemsgatan29 Sverige html/text/http://www.idg.se/to.html79 137 36,65 + 80 10 GöteborgsTaxi 1 IconName30 Berghemsgatan30 Sverige html/text/http://www.idg.se/to.html80 -89 20 + 81 10 LandvetterTaxi 1 IconName31 Berghemsgatan31 Sverige html/text/http://www.idg.se/to.html81 -89 -20 + 82 10 TaxiStockholm 1 IconName32 Berghemsgatan32 Sverige html/text/http://www.idg.se/to.html82 -90 20 + 83 10 SvartTaxi 1 IconName33 Berghemsgatan33 Sverige html/text/http://www.idg.se/to.html83 113 -11,31 + 84 22 Länsmuseumet 1 IconName34 Berghemsgatan34 Sverige html/text/http://www.idg.se/to.html84 107 -23,3 + 85 22 Sjöfartsmuseumet 1 IconName35 Berghemsgatan35 Sverige html/text/http://www.idg.se/to.html85 0 0 + 86 22 KinaMuseumet 1 IconName36 Berghemsgatan36 Sverige html/text/http://www.idg.se/to.html86 -0,5 0 + 87 22 Naturhistoriska 1 IconName37 Berghemsgatan37 Sverige html/text/http://www.idg.se/to.html87 0,5 0 + 88 Etnogfrafiska 1 IconName38 Berghemsgatan38 Sverige html/text/http://www.idg.se/to.html88 0 0,5 + 89 22 TekniskaMuseumet 1 IconName39 Berghemsgatan39 Sverige html/text/http://www.idg.se/to.html89 0 -0,5 + 90 23 Krokslätts dagis 1 IconName40 Berghemsgatan40 Sverige html/text/http://www.idg.se/to.html90 0,5 0,5 + 91 23 Centrum dagiset 1 IconName41 Berghemsgatan41 Sverige html/text/http://www.idg.se/to.html91 0,5 -0,5 + 92 Dagis Majorna 1 IconName42 Berghemsgatan42 Sverige html/text/http://www.idg.se/to.html92 -0,5 0,5 + 93 23 Lackarbäcks daghem 1 IconName43 Berghemsgatan43 Sverige html/text/http://www.idg.se/to.html93 -0,5 -0,5 + 94 23 Saab dagis 1 IconName44 Berghemsgatan44 Sverige html/text/http://www.idg.se/to.html94 47 -143,2 + 95 23 TE dagis 1 IconName45 Berghemsgatan45 Sverige html/text/http://www.idg.se/to.html95 41 -155,19 + 96 23 TietoEnator Lekstugan 1 IconName46 Berghemsgatan46 Sverige html/text/http://www.idg.se/to.html96 11,00005 11,00005 + 97 18 Panache 1 IconName47 Berghemsgatan47 Sverige html/text/http://www.idg.se/to.html97 29 32 + 98 18 Börjessons herrfrisör 1 IconName48 Berghemsgatan48 Sverige html/text/http://www.idg.se/to.html98 23 4 + 99 18 Modefrisörerna 1 IconName49 Berghemsgatan49 Sverige html/text/http://www.idg.se/to.html99 17 55 + 100 18 krokslätts frisörerna 1 IconName50 Berghemsgatan50 Sverige html/text/http://www.idg.se/to.html100 11 66 + 101 12 Gårda 1 IconName51 Berghemsgatan51 Sverige html/text/http://www.idg.se/to.html101 5 77 + 102 12 Mölndal 1 IconName52 Berghemsgatan52 Sverige html/text/http://www.idg.se/to.html102 -1 88 + 103 Kållered 1 IconName53 Berghemsgatan53 Sverige html/text/http://www.idg.se/to.html103 -7 56,56 + 104 12 Nordstan 1 IconName54 Berghemsgatan54 Sverige html/text/http://www.idg.se/to.html104 -13 54,45 + 105 12 Munkebäck 1 IconName55 Berghemsgatan55 Sverige html/text/http://www.idg.se/to.html105 17,0005 17,0005 +# +# +# +# diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EMPTY_EPOSLMGLOBALCATEGORIES.R01 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EMPTY_EPOSLMGLOBALCATEGORIES.R01 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMASYNCOPS.RSC Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMASYNCOPS.RSC has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R01 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R01 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R02 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R02 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R03 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMGLOBALCATEGORIES.R03 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMINTSERVICES_198KB.RSC Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMINTSERVICES_198KB.RSC has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMINTSERVICES_453KB.RSC Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLMINTSERVICES_453KB.RSC has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_020.LDB Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_020.LDB has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_040.LDB Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_040.LDB has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_060.LDB Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_060.LDB has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_080.LDB Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_080.LDB has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_105.LDB Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/EPOSLM_105.LDB has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/LmRecognizerData.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/LmRecognizerData.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,33 @@ +#Note that when saving from Excel additional " charachters may be added, thus causing the test to fail +#Buffer Result Mime Comment + " # ECertain lmx OK + " # ECertain gpx OK + # EProbable lmx OK + # EProbable gpx OK + # EProbable lmx OK + # EProbable gpx OK +< xmlns:n="http://www.nokia.com/schemas/location/landmarks/" # EProbable lmx link not in same tag as lmx +< xmlns:n="http://www.topografix.com/GPX/" # EProbable gpx link not in same tag as lmx +, at end of tag + < *lm:lMx*> # None none Capitals + < *lm:lmx*> # None none space in tag + < *lmx*> # None none wrong prolog + < *gpx*> # None none wrong prolog +Thomas, < *lmx*> # None none wrong start +Thomas, < *gpx*> # None none wrong start + < *lm:lmx*> # None none white spaces + < *gps:gpx*> # None none white spaces +<*lmx> # None none wrong prolog +<*gpx> # None none wrong prolog +<*lmx>" # None none wrong prolog +<*gpx>" # None none wrong prolog + " # ECertain lmx OK + " # ECertain gpx OK + # EProbable lmx OK + # EProbable gpx OK + # EProbable lmx OK + # EProbable gpx OK +< xmlns:n="http://www.nokia.com/schemas/location/landmarks/" # EProbable lmx link not in same tag as lmx +< xmlns:n="http://www.topografix.com/GPX/" # EProbable gpx link not in same tag as lmx +, at end of tag + < *lm:lMx*> # None none Capitals + < *lm:lmx*> # None none space in tag + < *lmx*> # None none wrong prolog + < *gpx*> # None none wrong prolog +Thomas, < *lmx*> # None none wrong start +Thomas, < *gpx*> # None none wrong start + < *lm:lmx*> # None none white spaces + < *gps:gpx*> # None none white spaces +<*lmx> # None none wrong prolog +<*gpx> # None none wrong prolog +<*lmx>" # None none wrong prolog +<*gpx>" # None none wrong prolog + Û / @ P Ø@i  0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc  ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  @ *€   Û / î  @ p 8Ai  0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc  ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  @ +€ €     1  k  " @ `Ai  0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc  ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmt_lmcat lmc_lmid$lmc_catid + @ >€ + ¯ Û / î  k "    @ ° ŒAi  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc  ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath @ +€ € %   h ö Y @ §Ai  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath 3€ € %   K ö Y + @ ÄAi  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmi_catid $lmc_catid  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath R€  I Û / î  k "    ö Y + ) @ åAi  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmi_catid $lmc_catid  ,lmi_glcatid ,lmc_glcatid  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath #€ €    ƒ  c @ Bi  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmi_catid $lmc_catid  ,lmi_glcatid ,lmc_glcatid  ,lmi_catname ,lmc_catname|  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath +€ €     ¯  c  @ %Bi  +0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmi_catid $lmc_catid  ,lmi_glcatid ,lmc_glcatid  ,lmi_catname ,lmc_catname|  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath (lmi_iconid (lmc_iconid  3€ €       c   ä B 0 @ 1  @   A @  + @ f€  Ÿ  ‘ b î  k "    ö Y q ) c ä ` @ 1  @ A @ @ ;€ € € ¶   I  A   !  € B p B p B p @ q  @@ @ A @0 0 A @     A @  + @ p€    A  î   —    ö Y ! æ Æ ¦ ä ‘ “ • @ q  @ A @ A @ A @ @ [€ €  +       ‘  à  À      € € € € @   SBi  0lmt_landmark lmc_lmidlmc_lat lmc_long lmc_alt lmc_hacc lmc_vacc (lmc_covrad (lmc_iconid (lmc_iconnr lmc_name lmc_desc   lmi_lmid  lmc_lmid ,lmt_lmfield lmc_lmid4lmc_fieldtype0lmc_fieldstr  lmt_cat $lmc_catid,lmc_glcatid (lmc_iconid (lmc_iconnr ,lmc_catname |,lmc_namemod  $lmi_catid $lmc_catid  ,lmi_glcatid ,lmc_glcatid  ,lmi_catname ,lmc_catname|  $lmt_lmcat lmc_lmid$lmc_catid + lmt_icon(lmc_iconid0lmc_iconpath (lmi_iconid (lmc_iconid  0lmt_settings0lmc_language lmc_init   @ p€  €   A  î   ‘    ö Y ! à À   ä Ô p € B q  r  s  t  u  v  w  x  y z + { | } ~    B q ¸ r p s (# t à. u ˜: v PF w R x À] y xi z 0u { è€ |  Œ } X˜ ~ ¤  ȯ B q A c c o m m o d a t i o n r B u s i n e s s @ r  @` ` A ÀÀ@PB ÀÀ@PB@P P A p§@ p§@@@ @  A ð? ð?@  , ¸ \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP131Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP131Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP13_EPOSLMGLOBALCATEGORIES.R06 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP13_EPOSLMGLOBALCATEGORIES.R06 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP13_eposlmglobalcategoriesR06.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP13_eposlmglobalcategoriesR06.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include "EPos_LmCatLanguages.hrh" + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// POS_LM_CATEGORY_SPECIFICATION +// Global category specification. +// +// ----------------------------------------------------------------------------- +// + +RESOURCE POS_LM_CATEGORY_SPECIFICATION glcategories + { + icon_files = + { + "c:\\system\\data\\test13_1.mbm", + "c:\\system\\data\\test13_2.mbm", + "c:\\system\\data\\test13_3.mbm", + "c:\\system\\data\\test13_4.mbm", + "c:\\system\\data\\test13_5.mbm", + "c:\\system\\data\\test13_6.mbm", + "c:\\system\\data\\test13_7.mbm", + "c:\\system\\data\\test13_8.mbm", + "c:\\system\\data\\test13_9.mbm", + "c:\\system\\data\\test13_10.mbm", + "c:\\system\\data\\test13_11.mbm", + "c:\\system\\data\\test13_12.mbm", + "c:\\system\\data\\test13_13.mbm", + "c:\\system\\data\\test13_14.mbm", + "c:\\system\\data\\test13_15.mbm", + "c:\\system\\data\\test13_16.mbm" + }; + + categories = + { + POS_LM_CATEGORY_INFO + { + category_id = 3000; + category_name = "Hotel"; + icon_index = 0; + icon_mask_index = 0; + icon_file_index = 0; + }, + POS_LM_CATEGORY_INFO + { + category_id = 6000; + category_name = "Affärer"; + icon_index = 1; + icon_mask_index = 1; + icon_file_index = 1; + }, + POS_LM_CATEGORY_INFO + { + category_id = 9000; + category_name = "Kommunikationer"; + icon_index = 2; + icon_mask_index = 2; + icon_file_index = 2; + }, + POS_LM_CATEGORY_INFO + { + category_id = 12000; + category_name = "Läroverks Institut"; + icon_index = 3; + icon_mask_index = 3; + icon_file_index = 3; + }, + POS_LM_CATEGORY_INFO + { + category_id = 15000; + category_name = "Nöje"; + icon_index = 4; + icon_mask_index = 4; + icon_file_index = 4; + }, + POS_LM_CATEGORY_INFO + { + category_id = 18000; + category_name = "Mat & Dryck"; + icon_index = 5; + icon_mask_index = 5; + icon_file_index = 5; + }, + POS_LM_CATEGORY_INFO + { + category_id = 21000; + category_name = "Geografiskt Område"; + icon_index = 6; + icon_mask_index = 6; + icon_file_index = 6; + }, + POS_LM_CATEGORY_INFO + { + category_id = 24000; + category_name = "Utomhus aktiviteter"; + icon_index = 7; + icon_mask_index = 7; + icon_file_index = 7; + }, + POS_LM_CATEGORY_INFO + { + category_id = 27000; + category_name = "Människor"; + icon_index = 8; + icon_mask_index = 8; + icon_file_index = 8; + }, + POS_LM_CATEGORY_INFO + { + category_id = 30000; + category_name = "Kommunala Tjänster"; + icon_index = 9; + icon_mask_index = 9; + icon_file_index = 9; + }, + POS_LM_CATEGORY_INFO + { + category_id = 33000; + category_name = "Kyrkor"; + icon_index = 10; + icon_mask_index = 10; + icon_file_index = 10; + }, + POS_LM_CATEGORY_INFO + { + category_id = 36000; + category_name = "Handel"; + icon_index = 11; + icon_mask_index = 11; + icon_file_index = 11; + }, + POS_LM_CATEGORY_INFO + { + category_id = 39000; + category_name = "Turistande"; + icon_index = 12; + icon_mask_index = 12; + icon_file_index = 12; + }, + POS_LM_CATEGORY_INFO + { + category_id = 42000; + category_name = "Sport"; + icon_index = 13; + icon_mask_index = 13; + icon_file_index = 13; + }, +/* Do not include this one + POS_LM_CATEGORY_INFO + { + category_id = 45000; + category_name = "Transporter"; + }, +*/ + POS_LM_CATEGORY_INFO + { + category_id = 48000; + category_name = "Kinarestaurang"; + icon_index = 14; + icon_mask_index = 14; + icon_file_index = 14; + }, + POS_LM_CATEGORY_INFO + { + category_id = 51000; + category_name = "BallongFärder"; + icon_index = 15; + icon_mask_index = 15; + icon_file_index = 15; + } + }; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP1Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP1Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP25Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP25Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP4Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP4Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP8Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/TP8Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/Tp116Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/Tp116Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/Tp28Test.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/Tp28Test.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/compositeeposlm.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/compositeeposlm.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/corrupt_EPOSLMGLOBALCATEGORIES.R06 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/corrupt_EPOSLMGLOBALCATEGORIES.R06 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposEmpty.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposEmpty.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_1000_LMs.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_1000_LMs.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_5000_LMs.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_5000_LMs.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_tp13.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlm_tp13.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmasyncops.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmasyncops.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* transaction for an aysynchronous operation. +* +*/ + + +// INCLUDES +#include + +// RESOURCE SIGNATURE +RESOURCE RSS_SIGNATURE { } + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_ADD_CAT_TO_LMS_OP +// Number of landmarks to change with addition of new category within each +// transaction for the CPosLmLocalCategoryManager::AddCategoryToLandmarksL +// operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_add_cat_to_lms_op + { + value="5"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_REMOVE_LMS_OP +// Number of landmarks to remove within each transaction for the +// CPosLmLocalDatabase::RemoveLandmarksL operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_remove_lms_op + { + value="5"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_REMOVE_ALL_LMS_OP +// Number of landmarks to remove within each transaction for the +// CPosLmLocalDatabase::RemoveAllLandmarksL operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_remove_all_lms_op + { + value="5"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_REMOVE_CAT_OP +// Deletes a category from all landmarks in one transaction (one SQL query). +// Because of this there is no need for setting a value of removing a single +// category (reserved for future changes). +// Limits: value = 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_remove_cat_op + { + value="0"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_REMOVE_CATS_OP +// Number of categories to remove within each transaction for the +// CPosLmLocalCategoryManager::RemoveCategoriesL operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_remove_cats_op + { + value="-2"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_REMOVE_CAT_FROM_LMS_OP +// Number of landmarks to change with removal of category within each +// transaction for the CPosLmLocalCategoryManager::RemoveCategoryFromLandmarksL +// operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_remove_cat_from_lms_op + { + value="5"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_READ_PARTIAL_LMS_OP +// Number of partial landmarks to read before notifying the observer. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_read_partial_lms_op + { + value="5"; + } + +// ----------------------------------------------------------------------------- +// +// R_POS_LM_LOCAL_RESET_GLOBAL_CATEGORIES_OP +// Number of global categories to reset within each transaction for the +// CPosLmLocalCategoryManager::ResetGlobalCategoriesL operation. +// Limits: value > 0 +// +// ----------------------------------------------------------------------------- + +RESOURCE NUMBER_INT32 r_pos_lm_local_reset_global_categories_op + { + value="3"; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR01.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR01.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include "EPos_LmCatLanguages.hrh" + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// POS_LM_CATEGORY_SPECIFICATION +// Global category specification. +// +// ----------------------------------------------------------------------------- +// + +RESOURCE POS_LM_CATEGORY_SPECIFICATION glcategories + { + icon_files = + { + "c:\\system\\data\\test1.mbm", + "c:\\system\\data\\test2.mbm", + "c:\\system\\data\\test3.mbm" + }; + + categories = + { + POS_LM_CATEGORY_INFO + { + category_id = 1; + category_name = Restaurant; + icon_index = 1; + icon_mask_index = 2; + }, + POS_LM_CATEGORY_INFO + { + category_id = 2; + category_name = Bar; + icon_index = 2; + icon_mask_index = 1; + }, + POS_LM_CATEGORY_INFO + { + category_id = 3; + category_name = "Gas station"; + icon_index = 5; + icon_mask_index = 2; + }, + POS_LM_CATEGORY_INFO + { + category_id = 4; + category_name = Hotel; + icon_index = 2; + icon_mask_index = 2; + }, + POS_LM_CATEGORY_INFO + { + category_id = 5; + category_name = Shop; + }, + POS_LM_CATEGORY_INFO + { + category_id = 6; + category_name = Sight; + }, + POS_LM_CATEGORY_INFO + { + category_id = 7; + category_name = "Sports ground"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 8; + category_name = Garage; + }, + POS_LM_CATEGORY_INFO + { + category_id = 9; + category_name = "Car park"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 10; + category_name = "Bus stop"; + } + }; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR02.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR02.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include "EPos_LmCatLanguages.hrh" + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// POS_LM_CATEGORY_SPECIFICATION +// Global category specification. +// +// ----------------------------------------------------------------------------- +// + +RESOURCE POS_LM_CATEGORY_SPECIFICATION glcategories + { + icon_files = + { + "c:\\system\\data\\test1.mbm", + "c:\\system\\data\\test2.mbm", + "c:\\system\\data\\test3.mbm" + }; + + categories = + { + POS_LM_CATEGORY_INFO + { + category_id = 1; + category_name = Restaurant; + icon_index = 1; + icon_mask_index = 0; + }, + POS_LM_CATEGORY_INFO + { + category_id = 2; + category_name = Bar; + icon_index = 2; + icon_mask_index = 2; + icon_file_index = 1; + }, + POS_LM_CATEGORY_INFO + { + category_id = 3; + category_name = "Gas station"; + icon_index = 5; + icon_mask_index = 2; + }, + POS_LM_CATEGORY_INFO + { + category_id = 4; + category_name = Hotel; + icon_index = 2; + icon_mask_index = 1; + }, + POS_LM_CATEGORY_INFO + { + category_id = 5; + category_name = Shop; + }, + POS_LM_CATEGORY_INFO + { + category_id = 6; + category_name = Sight; + }, + POS_LM_CATEGORY_INFO + { + category_id = 9; + category_name = "Car park"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 10; + category_name = "Bus stop"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 11; + category_name = Pools; + }, + POS_LM_CATEGORY_INFO + { + category_id = 12; + category_name = "Shopping streets"; + } + }; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR03.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmglobalcategoriesR03.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include "EPos_LmCatLanguages.hrh" + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// POS_LM_CATEGORY_SPECIFICATION +// Global category specification. +// +// ----------------------------------------------------------------------------- +// + +RESOURCE POS_LM_CATEGORY_SPECIFICATION glcategories + { + icon_files = + { + }; + + categories = + { + POS_LM_CATEGORY_INFO + { + category_id = 202; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901201"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 203; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901202"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 204; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901203"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 205; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901204"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 206; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901205"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 207; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901206"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 208; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901207"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 209; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901208"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 210; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901209"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 211; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901210"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 212; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901211"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 213; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901212"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 214; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901213"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 215; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901214"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 216; + category_name = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901215"; + } + }; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmnearestsearch.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/eposlmnearestsearch.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/landmarksDb.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/landmarksDb.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,110 @@ +#CategoryId CategoryName Icon name Icon index Id In Categories LandmarkName CoverageRadius Description Icon name Icon index Street PostalCode City LocationName Country Media Link 1 Media Link 2 Lat Long Hor. Acc Vert. Acc +1 Pizzeria z:\\system\\test\\landmarkstestsicon.mbm 1 1 1 LOG 40 jadajadjada ikon slask 1 Halmstad Drivhuset Plan7 Don't forget field medialinks https://www.aftonbladet.s 45,5 -44,5 10 10 +2 Hamburgerbar z:\\system\\test\\landmarkstestsicon.mbm 1 2 1 LOG11 jadajadjada ikon snask 1 Berghemsgatan 2 531 37 Kållered Västra Götaland Sverige will be automatically set to no. https://www.aftonbladet.se 46 44 14 10 +3 Kinarestaurang z:\\system\\test\\landmarkstestsicon.mbm 1 3 2 God 40 ikon skask 1 431 31 Mölndal Västra Götaland Sverige1 medialinks. https://www.aftonbladet.se 45 45 11 10 +4 Garaget z:\\system\\test\\landmarkstestsicon.mbm 1 4 2 vegetariskt 40 jadajadjada ikon spask 1 Berghemsgatan 10 Mölndal Västra Götaland Sverige1 url=http://www.come.co/to.html https://www.aftonbladet.se -45,5 -44,5 0 10 +5 Bilverkstad z:\\system\\test\\landmarkstestsicon.mbm 2 5 3 Inte sa bra 40 jadajadjada Berghemsgatan 4 431 31 Västra Götaland Sverige1 url=http://www.come.do/to.html https://www.aftonbladet.se -46,105 46,105 0 10 +6 Pasta Restaurang z:\\system\\test\\landmarkstestsicon.mbm 2 6 3 Dyrt 50 jadajadjada ikon PelleFant 2 Berghemsgatan 7 431 31 Mölndal Sverige1 url=http://www.pelle.com/pel.html https://www.aftonbladet.se 70 70 180 10 +7 Bilia 2 7 1-3,14-17 Billigt 50 jadajadjada ikon Abibblan 2 Berghemsgatan 6 431 31 Mölndal Västra Götaland url=http://www.pelle.com/pel.html https://www.aftonbladet.se 63 23 18 10 +8 VolksWagen sddsa 2 8 3 Medel 50 MLFW ikon bibblan123 2 Berghemsgatan 8 431 31 Mölndal Västra Götaland Sverige1 5 37,6 37,6 10 +9 Taxi Göteborg dasdsada 2 9 3 Medel2 50 jadajadjada ikon bibblan123 2 Berghemsgatan 5 431 31 Mölndal Västra Götaland Sverige1 url=http://www.bibblan.com/bibl.html 5 37,6 37,6 10 +10 Taxi dsa 2 10 3 MLFW2 50 MLFW ikon PelleFant 2 Berghemsgatan 9 431 31 Mölndal Västra Götaland Sverige1 url=http://www.bibblan.com/bibl.html http://www.idg.se -1 -81 25 0 +11 Stadsbibliotek aaa 2 11 3 MLFW 60 aaaaaa ikon PelleFant 2 MLFW 351 25 HalmstadA BSverige1 url=http://www.pelle.com/pel.html http://www.idg.se 0 -67 48 0 +12 Systembolag aaa 3 12 3 GatesB 60 bbbbbbb ikon PelleFant 3 PastaGatan L MLFW HalmstadB BSverige2 url=http://www.pelle.com/pel.html http://www.hotmail.com 1 -81 7 0 +13 Nokia Kontor aaa 3 13 3 Text'''1 60 ccccccc ikon PelleFant 3 PastaGatan N MLFW MLFW BSverige3 url=http://www.pelle.com/pel.html http://www.idg.se 45 -45 18 0 +14 TietoEnator kontor aaa 3 14 5 GatesF 60 dddddddd ikon PelleFant 3 MLFW 351 29 HalmstadJ BSverige4 url=http://www.svt.se http://www.idg.se -1 -80 168 0 +15 Thai Restaurang bbb 3 15 5 xStekt 70 MLFW ikon PelleFant 3 Berghemsgatan 11 431 31 Mölndal Västra Götaland url=http://www.pelle.com/pel.html http://www.idg.se -5 25 +16 McDonalds bbb 3 16 3 Akorthus 70 fffffffffffffffff ikon PelleFant 3 AStora biblioteksgatan 24 A123 45 AStorGöteborg AÖstra Götaland url=http://www.pelle.com/pel.html http://www.idg.se 1 -81 12 50 +17 BurgerKing bbb 3 17 17 Stadskortxhus 70 ggghhhhhh ikon PelleFant 3 Stora biblioteksgatan 25 321 32 StorGöteborg123 Östra Götaland123 url=http://www.pelle.com/pel.html http://www.idg.se 57 11 11 9 +18 Frisör bbb 3 18 18 enat?r 70 iiiijjjjjj ikon PelleFant 3 Stora biblioteksgatan 25 321 32 StorGöteborg123 Östra Götaland123 url=http://www.pelle.com/pel.html http://www.idg.se 0 -80,5 10,2 1,5 +19 Hunddagis bbb 4 19 19 enator 70 kkkkklll Gårdaikonen 4 Berghemsgatan 1 Finland url=http://www.pelle.com/pel.html 23 23 10,2 1,5 +20 Veterinär bbb 4 20 21 LOG2 70 mmmm Gårdaikonen 4 Berghemsgatan 2 431 32 Mölndal Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se -1 80 10,2 1,5 +21 Kyrkogård bbb 4 21 19 LOG3 70 nnnxnnn Gårdaikonen 4 Berghemsgatan 3 431 33 Mölndal Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se 1 80 25 300 +22 Museum bbb 4 22 22 LOG4 70 ooooooo Gårdaikonen 4 Berghemsgatan 4 431 34 Mölndal Västra Götaland url=http://www.gårda.com/sb.html http://www.idg.se -1 81 10,2 1,55 +23 Dagis bbb 4 23 23 LOG5 70 ppppppx Gårdaikonen 4 Berghemsgatan 5 431 35 Mölndal Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se 1 81 18 120 +24 StadsPark bbb 4 24 24 LOG6 70 asd Gårdaikonen 4 Berghemsgxatan 6 431 36 Mölndal Västra Götaland url=http://www.gårda.com/sb.html http://www.idg.se 0 80,5 168,9 7000 +25 Sjukhus bbb 4 25 25 x 70 r Gårdaikonen 4 Berghemsgatan 7 x431 37 Mölndal Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se -84 12,4 12,5 10 +26 Läkare bbb 5 26 26 LOG8 70 x Gårdaikonen 5 Berghemsgatan 8 431 38 xMölndal Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se 5 25 59 2000 + 27 11-17 LOG9 70 ttttt Gårdaikonen 5 Berghemsgatan 9 431 39 Mölndal x Västra Götaland url=http://www.gårda.com/sb.html https://www.aftonbladet.se -84 12 + 28 11 LOG10 70 v Gårdaikonen 5 Berghemsgatan 10 431 40 Mölndal Västra Götalandx url=http://www.gårda.com/sb.html https://www.aftonbladet.se 10 14 13,9 6000 + 29 26 Unique 80 Gårdaikonen 5 256 78 Mölndal Daanmark url=http://www.gårda.com/xsb.html https://www.aftonbladet.se 45,5 -0,5 0 1200 + 30 26 Text'1 80 Unique Gårdaikonen 5 256 78 Götet Daanmark url=http://www.gårda.com/sb.html https://wwwx.aftonbladet.se 45,5 0 0 112 + 31 26 Text1 80 Focus Torget1 56 Unique 256 78 Mölndal Daanmark url=http://www.gårda.com/sb.html https://www.aftonbladet.se 45,5 0,5 0 0 + 32 26 Text2 80 Focus Torget1 6 256 78 Unique Daanmark z:\gårda\ikon https://www.aftonbladet.se 89 -15 0 0 + 33 26 Text3 80 Focus Torget1 6 256 78 Götet Daanmark z:\gårda\ikon https://www.aftonbladet.se 5 37,6 0 0 + 34 26 Text4 80 Focus Torget1 66 256 78 Götet Daanmark z:\gårda\ikon http://www.idg.se 63 23 18 0 + 35 26 Text5 80 Focus Torget1 6 256 78 Götet Daanmark z:\gårda\ikon https://www.aftonbladet.se -84,2 -2,67 168,9 0 + 36 26 Text6 80 Focus Torget1 6 256 78 Götet Daanmark z:\gårda\ikon http://www.idg.se 5 37,6 37,6 0 + 37 26 Text7 80 Focus Torget1 6 256 78 Götet Daanmark z:\gårda\ikon o 5 37,6 37,6 0 + 38 26 Text8 80 256 78 Götet Daanmark z:\gårda\ikon http://www.idg.se 5 37,6 0 0 + 39 26 Text9 80 256 78 Götet Daanmark 5 25 59 2000 + 40 26 Text10 80 256 78 Götet Daanmark 0 180 168,9 4500 + 41 26 q 80 256 78 Götet Daanmark -1 180 37,6 2 + 42 26 asd 80 256 78 1 180 37,6 1 + 43 26 asdf 256 78 0 -179 + 44 26 dfdsf 256 78 0 179 + 45 26 Several Several Several 1 Several Several Several Several Several Several Several -1 -179 + 46 26 oki aaa aaa -1 179 + 47 26 abab oki aaa 1 -179 + 48 26 Nokia aaa aaa oki 1 179 + 49 26 aba Nokia aaa aaa aaa + 50 26 aca aaa aaa Noki + 51 1 PellesPizza IconName1 Berghemsgatan1 Sverige + 52 19 Kalles Hundgård IconName2 Berghemsgatan2 Sverige -45 -1 12 50 + 53 21 Sjömanskyrkan IconName3 Berghemsgatan3 Sverige 25,05 -5,5 13 49 + 54 14 TE, Gårda IconName4 Berghemsgatan4 Sverige -45,5 0 14 48 + 55 14 TE, Eriksberg IconName5 Berghemsgatan5 Sverige -46 1 15 47 + 56 14 TE, Lund IconName6 Berghemsgatan6 Sverige 19,95 78 16 46 + 57 14 TE, Karlstad IconName7 Berghemsgatan7 Sverige 45 -44 + 58 14 TE, Kista IconName8 Berghemsgatan8 Sverige 25,05 19,5 + 59 14 TE, Stockholm IconName9 Berghemsgatan9 Sverige 10,05 24,5 + 60 14 TE, Oulu IconName10 Berghemsgatan10 Finland 89 -180 + 61 14 TE, Tampere IconName11 Berghemsgatan11 Finland 89 180 + 62 13 Nokia, Köpenhamn IconName12 Berghemsgatan12 Danmark 90 1 + 63 13 Nokia, Stockholm IconName13 Berghemsgatan13 Sverige 90 -180 + 64 13 Oulu IconName14 Berghemsgatan14 Sverige 90 0 + 65 13 Tampere IconName15 Berghemsgatan15 Sverige 89 0 + 66 13 Helsinki IconName16 Berghemsgatan16 Sverige -19,95 59,5 + 67 13 Bengtfors IconName17 Berghemsgatan17 Sverige 89 20 + 68 13 Karlstad IconName18 Berghemsgatan18 Sverige 89 -20 + 69 13 Mölndal IconName19 Berghemsgatan19 Sverige 90 20 + 70 13 Göteborg IconName20 Berghemsgatan20 Sverige 90 0 + 71 13 PallesPalör IconName21 Berghemsgatan21 Sverige 89 0 + 72 26 Läkare utan gränser IconName22 Berghemsgatan22 Sverige 179 120,58 + 73 26 Mölndal IconName23 Berghemsgatan23 Sverige -89 -180 + 74 26 Läkargruppen IconName24 Berghemsgatan24 Sverige -89 180 + 75 26 Läkarhuset IconName25 Berghemsgatan25 Sverige -90 180 + 76 26 Sahlgrenska IconName26 Berghemsgatan26 Sverige -90 -180 + 77 26 östra sjukhuset IconName27 Berghemsgatan27 Sverige -90 0 + 78 20 Blå stjärnan IconName28 Berghemsgatan28 Sverige -89 0 + 79 10 MiniTaxi IconName29 Berghemsgatan29 Sverige 137 36,65 + 80 10 GöteborgsTaxi IconName30 Berghemsgatan30 Sverige -89 20 + 81 10 LandvetterTaxi IconName31 Berghemsgatan31 Sverige -89 -20 + 82 10 TaxiStockholm IconName32 Berghemsgatan32 Sverige -90 20 + 83 10 SvartTaxi IconName33 Berghemsgatan33 Sverige 113 -11,31 + 84 22 Länsmuseumet IconName34 Berghemsgatan34 Sverige 107 -23,3 + 85 22 Sjöfartsmuseumet IconName35 Berghemsgatan35 Sverige 0 0 + 86 22 KinaMuseumet IconName36 Berghemsgatan36 Sverige -0,5 0 + 87 22 Naturhistoriska IconName37 Berghemsgatan37 Sverige 0,5 0 + 88 22 Etnogfrafiska IconName38 Berghemsgatan38 Sverige 0 0,5 + 89 22 TekniskaMuseumet IconName39 Berghemsgatan39 Sverige 0 -0,5 + 90 23 Krokslätts dagis IconName40 Berghemsgatan40 Sverige 0,5 0,5 + 91 23 Centrum dagiset IconName41 Berghemsgatan41 Sverige 0,5 -0,5 + 92 23 Dagis Majorna IconName42 Berghemsgatan42 Sverige -0,5 0,5 + 93 23 Lackarbäcks daghem IconName43 Berghemsgatan43 Sverige -0,5 -0,5 + 94 23 Saab dagis IconName44 Berghemsgatan44 Sverige 47 -143,2 + 95 23 TE dagis IconName45 Berghemsgatan45 Sverige 41 -155,19 + 96 23 TietoEnator Lekstugan IconName46 Berghemsgatan46 Sverige 11,00005 11,00005 + 97 18 Panache IconName47 Berghemsgatan47 Sverige 29 32 + 98 18 Börjessons herrfrisör IconName48 Berghemsgatan48 Sverige 23 4 + 99 18 Modefrisörerna IconName49 Berghemsgatan49 Sverige 17 55 + 100 18 krokslätts frisörerna IconName50 Berghemsgatan50 Sverige 11 66 + 101 12 Gårda IconName51 Berghemsgatan51 Sverige 5 77 + 102 12 Mölndal IconName52 Berghemsgatan52 Sverige -1 88 + 103 12 Kållered IconName53 Berghemsgatan53 Sverige -7 56,56 + 104 12 Nordstan IconName54 Berghemsgatan54 Sverige -13 54,45 + 105 12 Munkebäck IconName55 Berghemsgatan55 Sverige 17,0005 17,0005 +# +# +# +# diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbAreaSearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbAreaSearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,185 @@ +#SouthLat NorthLat WestLong EastLong ErrorCode Redefined SearchResult Comment +45 46,00 -45,00 -44,00 0 1,13,57 NV globe +45 46,00 44,00 45,00 0 2,3 NE globe +-46,00 -45,00 -45,00 -44,00 0 4 SW globe +-46,11 -46,10 46,10 46,11 0 5 SE globe +# +-1,00 1,00 -81,00 -80,00 0 10,12,14,16,18 W crossing 0 latitude +-1,00 1,00 80,00 81,00 0 20-24 E crossing 0 latitude +45,00 46,00 -1,00 1,00 0 29-31 N crossing 0 longitude +-46,00 -45,00 -1,00 1,00 0 52,54,55 E crossing 0 latitude +# +89,00 90,00 -180,00 180,00 0 32,60-65,67-71 North pole +89,00 90,00 20,00 -20,00 0 60,61,63,67,68,69 Nort Pole expect a ^ +89,00 90,00 -20,00 20,00 0 32,62,64,65,67-71 Nort Pole ^ +# +-90,00 -89,00 -180,00 180,00 0 73-78,80-82 South pole +-90,00 -89,00 20,00 -20,00 0 73-76,80-82 South pole expect a ^ +-90,00 -89,00 -20,00 20,00 0 77,78,80-82 South pole ^ +# +-1,00 1,00 -1,00 1,00 0 85-93 Crossing 0 latitude and 0 longitude +0,00 1,00 -1,00 0,00 0 1 85,87,89,91 +-1,00 1,00 179,00 -179,00 0 40-48 Crossing 0 latitude and 180 longitude +# +19,00 20,00 78,00 78,00 0 56 WestLong =EastLong +19,00 20,00 78,11235 78,11235 0 WestLong =EastLong +# +-20,00 -19,99 16,00 16,01 0 +17,00 17,001 17,00 17,001 0 105 100*100 square +11,00 11,0001 11,00 11,0001 0 96 10*10 square +# +-91,00 -90,00 13,00 14,00 -6 +45,00 44,99 13,00 14,00 -6 +85,00 91,00 13,00 14,00 -6 +78,00 79,00 -181,00 -179,00 -6 +-45,00 -44,00 181,00 179,00 -6 +23,00 24,00 -179,00 -181,00 -6 +23,00 24,00 179,00 181,00 -6 +# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCatLandmarkSearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCatLandmarkSearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,181 @@ +#CategoryName Category Id LmSearchResult (Id's) Redefined seach Comment +Pizzeria 1 1-2,7,51 +Hamburgerbar 2 3-4,7 +Kinarestaurang 3 5-13,16 +Garaget 4 +Bilverkstad 5 14-15 +Pasta Restaurang 6 +Bilia 7 +VolksWagen 8 +Taxi Göteborg 9 +Taxi 10 79-83 +Stadsbibliotek 11 27-28 +Systembolag 12 27,101-105 +Nokia Kontor 13 27,62-71 +TietoEnator kontor 14 7,27,54-61 +Thai Restaurang 15 7,27 +McDonalds 16 7,27 +BurgerKing 17 7,17,27 +Frisör 18 18,97-100 +Hunddagis 19 19,21,52 +Veterinär 20 78 +Kyrkogård 21 20,53 +Museum 22 22,84-89 +Dagis 23 23,90-96 +StadsPark 24 24 +Sjukhus 25 25 +Läkare 26 26,29-50,72-77 +TietoEnator kontor 14 7,27,54-61 +TietoEnator kontor 14 7,27,54-61 1 +Thai Restaurang 15 7 1 +TietoEnator kontor 14 7,27,54-61 +Thai Restaurang 15 7,27 1 +TietoEnator kontor 14 7,27,54-61 +BurgerKing 17 7,27 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCategorySearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCategorySearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,125 @@ +#TextCriteria CategorySearchResult (Id's) Redefined seach Comment +* 1-26 +* 1-26 +** 1-26 +* 1-26 1 +Frisör 18 +? +Unique +T* 9,10,14,15 +N* 13 +*oki* 13 +Noki? +Nokia? +Nok* 13 +x +enat?r +Text'1 +Text'''1 +*Enator* 14 +*estaurang 3,6,15 +*ontor 13,14 1 +Nokia* 13 +*okia +Nokia? +Tax? 10 +T??? 10 +???? 10 +# +# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCompositeSearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbCompositeSearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,84 @@ +# TEXT TextCriteria Attributes (bitmask) PositionFields Comment +# AREA SouthLat NorthLat WestLong EastLong ErrorCode Comment +# CATEGORY CategoryName Category Id Comment +# NEAREST Index Latitude Longitude UseCoverageRadius MaxDistance Comment +# IDLIST Ids Comment +# RESULT LmSearchResultIds Redefined search Comment +# SEPARATOR Separates a composite search +# +#>>>>>>>>>>>>>>1<<<<<<<<<<<<< +AREA -90 90 -180 180 +TEXT * +CATEGORY Taxi 10 +RESULT 79-83 +SEPARATOR +#>>>>>>>>>>>>>>2<<<<<<<<<<<<< +AREA -90 90 -180 180 +TEXT Te* +IDLIST 33,35,37,38,48-54 +RESULT 33,35,37,38,54 +SEPARATOR +#>>>>>>>>>>>>>>3<<<<<<<<<<<<< +AREA -80 80 -180 180 +NEAREST -45,5 -44,5 0 300 +TEXT * +RESULT 4 +SEPARATOR +#>>>>>>>>>>>>>>4<<<<<<<<<<<<< +AREA -80 80 -180 180 +NEAREST -45,5 -44,5 1 10 +TEXT * +RESULT 4 +SEPARATOR +#>>>>>>>>>>>>>>5<<<<<<<<<<<<< +TEXT * +# Search for uncatetegorized landmarks +CATEGORY +RESULT 11,32,36,39,43,56,88,92,103 +SEPARATOR +#>>>>>>>>>>>>>>6<<<<<<<<<<<<< +NEAREST 45 45 0 300 +TEXT * +RESULT 3 +SEPARATOR +#>>>>>>>>>>>>>>7<<<<<<<<<<<<< +IDLIST 82-95,105 +TEXT * +CATEGORY Taxi 10 +RESULT 82,83 +SEPARATOR +#>>>>>>>>>>>>>>8<<<<<<<<<<<<< +TEXT * +CATEGORY Taxi 10 +RESULT 79-83 +SEPARATOR +#>>>>>>>>>>>>>>9<<<<<<<<<<<<< +TEXT Sv* 0x0021 401,404,406,408,409 +IDLIST 1-85 +RESULT 83 1 +SEPARATOR +#>>>>>>>>>>>>>>10<<<<<<<<<<<<< +IDLIST 1-24,45 +TEXT Pelle* 0x0021 +RESULT +SEPARATOR +#>>>>>>>>>>>>>>11<<<<<<<<<<<<< Note that La* also founds Lä, Lå +IDLIST 1-105 +TEXT La* 0x0021 +RESULT 72,74,75,81,84,93 +SEPARATOR +# +#>>>>>>>>>>>>>>12<<<<<<<<<<<<< +IDLIST 1-105 +TEXT * 0x0021 +CATEGORY 26 +AREA -90 10 -180 180 +NEAREST -84,2 -2,67 1 10 +RESULT 35 +SEPARATOR +# +#>>>>>>>>>>>>>>13<<<<<<<<<<<<< +TEXT vegetariskt 0x0021 +RESULT 4 +SEPARATOR +# diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbNearestSearch.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbNearestSearch.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,255 @@ +#LandmarkId Lat Long Coverage radius Comment Earth radius Distance to #1 Distance to #2 Distance to #3 Distance to #4 Distance to #5 Distance to #6 Distance to #7 Distance to #8 Distance to #9 Distance to #10 Distance to #11 Distance to #12 Distance to #13 Distance to #14 Distance to #15 Distance to #16 Distance to #17 Distance to #18 Distance to #19 Distance to #20 +1 59 18 10 6371010 0 5242849,306 6726499,853 444780,4047 6657988,273 3179522,311 6746270,233 6746270,233 6746270,233 8754746,717 8765401,845 839088,753 16600956 13268847,98 3447048,137 16568070,08 444780,4047 6876240,873 6876240,873 6881699,191 +2 12 13 10 5242849,306 0 1880092,384 4801299,905 1969934,453 2952874,753 1959411,776 1959411,776 1959411,776 4303424,735 4310977,898 4447804,047 11366716,59 18055706,44 8673217,892 11341900,32 4801299,905 2116602,56 2116602,56 2120432,31 +3 12 13,00001 10,5 5242849,24 1,08 1880093,161 4801299,825 1969935,317 2952874,081 1959412,584 1959412,584 1959412,584 4303425,524 4310978,685 4447804,047 11366716,61 18055705,63 8673217,892 11341900,32 4801299,825 2116603,366 2116603,366 2120433,115 +4 12 13,0001 10 5242848,64 10,8762218 1880100,159 4801299,1103 1969943,098 2952868,036 1959419,858 1959419,858 1959419,858 4303432,624 4310985,771 4447804,047 11366716,78 18055698,35 8673217,892 11341900,32 4801299,11 2116610,626 2116610,626 2120440,362 +5 12,00001 13 10 5242848,197 1,107128048 1880093,161 4801298,796 1969935,127 2952873,878 1959412,52 1959412,52 1959412,52 4303425,501 4310978,665 4447802,935 11366717,7 18055705,69 8673216,78 11341901,43 4801298,796 2116603,306 2116603,306 2120433,057 +6 0,001 0,001 100 6746140,607 1959254,585 111083,9617 6331418,596 157249,6947 4893842,046 157,253626 157,253626 157,253626 2345326,538 2353064,742 5908617,126 10007672,22 20014960,96 10007447,91 10007670,3 6331418,596 157406,8817 157406,8817 161385,8107 +7 0,01 0,01 100 6744974,009 1957839,871 110088,7654 6330228,87 157257,3694 4892431,525 1572,536195 1572,536195 1572,536195 2346741,608 2354479,719 5907458,296 10008690,29 20013545,68 10006447,15 10008671,06 6330228,87 158822,1643 158822,1643 162800,6742 +8 0,001 0 100 6746160,906 1959335,409 111195,1568 6331442,111 157171,015 4893913,966 111,1951053 111,1951053 111,1951053 2345249,287 2352987,77 5908636,374 10007670,28 20015007,02 10007447,91 10007670,3 6331442,111 157328,2805 157328,2805 161309,1491 +9 -0,02 0 100 6748456,77 1960939,795 111217,3357 6333724,404 158830,0661 4895695,05 2223,902024 2223,902024 2223,902024 2343570,242 2351303,089 5910936,23 10005335,54 20012894,31 10009783,01 10005335,2 6333724,404 155684,9114 155684,9114 159625,4332 +10 0 1,04 100 6725731,124 1876984,859 4447,804047 6307749,85 252615,5308 4819844,893 115642,9052 115642,9052 115642,9052 2426872,52 2434325,503 5889494,49 10009577,24 19899475,31 10007559,11 10007559,11 6307749,85 252615,5308 252615,5308 255110,597 +11 0 -0,03 1000 6746879,687 1961837,727 114530,9542 6332256,807 154908,9624 4896156,872 3335,853035 3335,853035 3335,853035 2342852,908 2350599,484 5909323,955 10007500,89 20011782,36 10007559,11 10007559,11 6332256,807 154908,9624 154908,9624 158946,568 +12 -0,01 0,01 10000 6747160,579 1959367,855 110088,7654 6332402,524 158822,1643 4894127,834 1572,536195 1572,536195 1572,536195 2345142,559 2352875,305 5909648,677 10006466,73 20013545,68 10008671,06 10006447,15 6332402,524 157257,3694 157257,3694 161197,7974 +13 -0,01 -0,02 6747769,658 1961792,028 113424,4532 6333108,099 156481,3163 4896285,287 2486,39804 2486,39804 2486,39804 2342824,623 2350565,73 5910226,244 10006408,51 20012631,81 10008671,06 10006447,15 6333108,099 154892,8798 154892,8798 158891,9809 +14 55 18,0001 444780,4048 4801300,7 6308643,159 6,377655644 6247287,593 2783666,395 6331553,143 6331553,143 6331553,143 8380367,281 8390891,544 469514,466 16156386,43 13683565,07 3891828,541 16123289,67 6,377655644 6464113,809 6464113,809 6469537,573 +15 55,002 18 444558,0145 4801520,563 6308849,281 222,3902106 6247489,705 2783863,993 6331757,514 6331757,514 6331757,514 8380550,458 8391074,795 469662,1277 16156608,54 13683360,7 3891606,151 16123512,06 222,3902106 6464316,771 6464316,771 6469740,555 +16 55,01 18 1000 443668,4537 4802403,194 6309682,694 1111,951006 6248308,154 2784642,055 6332584,409 6332584,409 6332584,409 8381297,045 8391821,663 470271,9243 16157497,72 13682533,8 3890716,59 16124401,62 1111,951006 6465138,403 6465138,403 6470562,264 +17 1 81 8405977,84 7592934,844 8895779,19 8234948,892 9116311,394 6178074,48 9006956,881 9006956,881 9006956,881 10680751,21 10680636,22 8434890,116 10228579,76 11008161,33 9896364,005 10118754,21 8234948,892 9120230,559 9120230,559 9120342,498 +18 0 -80,5 10493037,7 10388227,13 9062400,746 10548342,45 8840190,384 12113298,8 8951205,645 8951205,645 8951205,645 7381867,639 7383174,345 10247071,42 9897889,13 11063912,57 10007559,11 10007559,11 10548342,45 8840190,384 8840190,384 8840208,817 +19 0 0,1 6744245,572 1951344,059 100075,5911 6329205,251 165298,8067 4886812,703 11119,51012 11119,51012 11119,51012 2352907,523 2360617,918 5906828,185 10007753,17 20003998,7 10007559,11 10007559,11 6329205,251 165298,8067 165298,8067 169088,3961 +20 -1 80 8549935,397 7534450,155 8784601,607 8365199,925 9009075,192 6235166,042 8895779,19 8895779,19 8895779,19 10515587,42 10515147,01 8550134,848 10005870,15 11119339,02 10118754,21 9896364,005 8365199,925 9005145,798 9005145,798 9005063,319 +21 1 -1,001 1000 6658009,827 1970020,91 248729,1599 6247310,084 111,1781233 4883175,07 157328,2686 157328,2686 157328,2686 2352853,344 2361118,717 5819482,501 10116794,81 19857789,94 9896364,005 10118754,21 6247310,084 222390,2302 222390,2302 227949,9845 +22 0,999 -0,999 200 6658075,806 1969917,912 248480,5504 6247368,457 157,2416757 4883109,951 157092,3864 157092,3864 157092,3864 2352912,537 2361177,13 5819549,874 10116687,51 19858025,83 9896475,2 10118643,01 6247368,457 222279,0351 222279,0351 227838,7894 +23 1 -1,002 6658031,381 1970107,371 248828,6247 6247335,075 222,3563277 4883249,109 157406,9483 157406,9483 157406,9483 2352781,377 2361047,024 5819503,422 10116792,87 19857711,26 9896364,005 10118754,21 6247335,075 222390,3135 222390,3135 227950,0659 +24 1,01 -1 6656897,419 1969235,542 249128,7875 6246201,598 1111,95101 4882271,546 158037,7921 158037,7921 158037,7921 2353772,942 2362040,36 5818369,493 10117908,53 19857080,42 9895252,054 10119866,16 6246201,598 223502,1534 223502,1534 229061,9084 +25 1,01 -1,02 1488 6657328,734 1970965,737 251115,7971 6246701,67 2486,092063 4883752,698 159610,1869 159610,1869 159610,1869 2352334,613 2360607,509 5818788,198 10117869,73 19855508,03 9895252,054 10119866,16 6246701,67 223513,2161 223513,2161 229072,7026 +26 5 25 6034601,244 1531328,507 2722622,271 5595094,778 2920515,557 3089469,621 2831421,555 2831421,555 2831421,555 4936186,789 4940672,651 5341947,646 10610455,95 17183696,66 9451583,6 10563534,61 5595094,778 2964013,219 2964013,219 2965291,378 +27 -15 -15 1000 8754746,717 4303424,735 2423681,4 8380363,813 2352925,313 7235492,363 2345169,308 2345169,308 2345169,308 0 11119,51012 7924786,668 8311097,422 17669948,9 11675485,62 8339632,588 8380363,813 2187944,693 2187944,693 2183945,098 +28 -14,9 -15 1000 8744091,905 4295884,638 2416244,361 8369840,075 2344682,727 7227382,472 2337457,125 2337457,125 2337457,125 11119,51012 22239,02024 7914197,995 8322215,235 17677661,09 11664366,11 8350752,098 8369840,075 2180223,397 2180223,397 2176238,285 +29 -15 -14,8 1000 8748618,545 4287675,777 2407782,693 8373445,93 2338590,261 7220816,338 2329771,233 2329771,233 2329771,233 21481,24327 24184,10739 7918250,997 8311472,947 17685346,98 11675485,62 8339632,588 8373445,93 2172569,251 2172569,251 2168542,658 +30 -15 -15,2 1000 8760906,734 4319228,505 2439674,426 8387317,005 2367377,873 7250200,464 2360671,513 2360671,513 2360671,513 21481,24327 24184,10739 7931363,092 8310722,242 17654446,7 11675485,62 8339632,588 8387317,005 2203431,659 2203431,659 2199458,866 +31 0,532 0,53 6677448,59 1875950,34 78934,2415 6261374,359 177894,5288 4810769,197 83501,22271 83501,22271 83501,22271 2428660,922 2436394,314 5840417,486 10067734,41 19931616,99 9948403,312 10066714,9 6261374,359 240750,7596 240750,7596 244715,824 +32 89 -15 3354284,524 8575085,16 9900671,927 3798993,778 9788473,186 6373809,825 9900153,251 9900153,251 9900153,251 11564290,52 11575410,03 4127514,782 19838687,52 10114964,96 111195,1012 19903923,11 3798993,778 10010861,41 10010861,41 10016421,11 +33 32,0002 32 1000 3179500,838 2952890,362 4822687,564 2783648,478 4883114,806 22,23922369 4894013,155 4894013,155 4894013,155 7235506,307 7243620,44 2704435,409 13624308,23 15121105,06 6449293,629 13565824,58 2783648,478 5050747,872 5050747,872 5054981,361 +34 54 23,005 634783,882 4752849,437 6335638,325 341682,6316 6289792,285 2548523,94 6365429,705 6365429,705 6365429,705 8476703,415 8487022,461 704774,0083 16054406,83 13649688,51 4003023,642 16012094,57 341682,6316 6503059,843 6503059,843 6508396,517 +35 31,99 32 2000 3180595,93 2952094,417 4821937,418 2784719,977 4882412,43 1111,951014 4893279,637 4893279,637 4893279,637 7234795,196 7242908,167 2705426,272 13623174,22 15121838,57 6450427,819 13564690,39 2784719,977 5050016,809 5050016,809 5054249,609 +36 5,5 37,6 6181285,063 2796529,349 4109071,53 5776442,598 4312958,48 3003683,719 4218876,239 4218876,239 4218876,239 6227083,65 6230430,03 5642931,917 10686916,44 15796241,97 9395986,049 10619132,16 5776442,598 4346870,94 4346870,94 4347838,485 +37 5 37,6 6235657,044 2812923,628 4102273,061 5830366,2 4308152,908 3058366,121 4212316,554 4212316,554 4212316,554 6206176,51 6209419,252 5695417,694 10631324,26 15802801,66 9451583,6 10563534,61 5830366,2 4339028,578 4339028,578 4339920,98 +38 0 0,01 6746067,292 1958603,701 110083,1502 6331315,694 158037,7921 4893279,637 1111,95101 1111,95101 1111,95101 2345941,962 2353677,392 5908553,484 10007578,51 20014006,26 10007559,11 10007559,11 6331315,694 158037,7921 158037,7921 161997,4024 +39 0,01 0,01 6744974,009 1957839,871 110088,7654 6330228,87 157257,3694 4892431,525 1572,536195 1572,536195 1572,536195 2346741,608 2354479,719 5907458,296 10008690,29 20013545,68 10006447,15 10008671,06 6330228,87 158822,1643 158822,1643 162800,6742 +40 0,02 0 6744083,709 1957885,048 111217,3357 6329377,201 155684,9114 4892302,828 2223,902024 2223,902024 2223,902024 2346769,345 2354512,918 5906555,568 10009782,67 20012894,31 10005335,2 10009783,01 6329377,201 158830,0661 158830,0661 162846,3604 +41 0 -0,001 6746290,532 1959492,599 111306,2963 6331574,308 157171,0269 4894070,691 111,1951053 111,1951053 111,1951053 2345092,057 2352830,55 5908765,139 10007557,17 20015007,02 10007559,11 10007559,11 6331574,308 157171,0269 157171,0269 161151,9445 +42 -0,003 -0,001 6746618,512 1959721,711 111306,7961 6331900,348 157407,2198 4894325,108 351,6297846 351,6297846 351,6297846 2344852,128 2352589,816 5909093,688 10007223,63 20014766,58 10007892,69 10007225,52 6331900,348 156935,1876 156935,1876 160910,4133 +43 0,004 -0,004 6745914,136 1959429,686 111640,7675 6331210,149 156620,6136 4893947,257 629,0144755 629,0144755 629,0144755 2345180,289 2352920,691 5908384,83 10007996,06 20014489,2 10007114,33 10008003,89 6331210,149 157250,9338 157250,9338 161245,2183 +44 -0,004 -0,005 6746809,045 1960121,361 111751,9617 6332103,101 157172,6479 4894697,59 711,9960426 711,9960426 711,9960426 2344463,137 2352201,672 5909280,208 10007104,69 20014406,22 10008003,89 10007114,33 6332103,101 156542,0126 156542,0126 160523,1268 +45 -0,003 0,003 6746537,321 1959398,471 110862,0177 6331806,292 157721,389 4894037,448 471,760859 471,760859 471,760859 2345161,178 2352897,752 5909016,706 10007231,39 20014646,45 10007892,69 10007225,52 6331806,292 157250,2997 157250,2997 161217,7525 +46 -89 -90 16600956 11366716,59 10009499,63 16156386,24 10116796,75 13624286 10007559,11 10007559,11 10007559,11 8311097,422 8299979,61 15813531,66 0 10007559,11 19903923,11 111195,1012 16156386,24 9894440,413 9894440,413 9888881,505 +47 -89 -89,8 16600583,48 11366337,95 10009111,55 16156014,15 10116408,7 13623954,58 10007170,98 10007170,98 10007170,98 8310722,242 8299604,427 15813151,53 388,1242177 10007947,23 19903923,11 111195,1012 16156014,15 9894052,358 9894052,358 9888493,45 +48 179 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +49 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +51 -0,004 1 6726937,925 1880410,371 444,780401 6309076,672 248828,9832 4823016,082 111195,9906 111195,9906 111195,9906 2423371,392 2430834,066 5890645,522 10009054,92 19903922,22 10008003,89 10007114,33 6309076,672 248431,0631 248431,0631 250957,9198 +52 -0,004 2 6708233,683 1804370,9 111195,9906 6287389,649 351754,6893 4752917,693 222390,647 222390,647 222390,647 2504252,84 2511449,861 5873533,24 10010994,85 19792727,56 10008003,89 10007114,33 6287389,649 351473,2442 351473,2442 353262,9062 +53 -0,004 3 6690605,702 1732029,554 222390,647 6266939,057 458555,4026 4684099,917 333585,5998 333585,5998 333585,5998 2587272,039 2594212,711 5857860,928 10012933,6 19681532,61 10008003,89 10007114,33 6266939,057 458339,4668 458339,4668 459712,3049 +54 -0,004 4 6674064,346 1663869,042 333585,5998 6247738,854 567045,8079 4616622,121 444780,6267 444780,6267 444780,6267 2672229,289 2678923,16 5843641,38 10014870,58 19570337,59 10008003,89 10007114,33 6247738,854 566871,1206 566871,1206 567980,6707 +55 -0,004 5 6658619,431 1600423,887 444780,6267 6229802,296 676413,3585 4550545,951 555975,6833 555975,6833 555975,6833 2758945,08 2765401,754 5830886,315 10016805,2 19459142,53 10008003,89 10007114,33 6229802,296 676266,8408 676266,8408 677196,1273 +56 -0,004 6 6644280,201 1542276,375 555975,6833 6213141,909 786292,1239 4485935,327 667170,7548 667170,7548 667170,7548 2847258,251 2853487,241 5819606,339 10018736,86 19347947,46 10008003,89 10007114,33 6213141,909 786166,0012 786166,0012 786964,4574 +57 -0,004 7 6631055,309 1490047,062 667170,7548 6197769,448 896494,1503 4422856,399 778365,8347 778365,8347 778365,8347 2937024,207 2943034,833 5809810,906 10020664,99 19236752,38 10008003,89 10007114,33 6197769,448 896383,4491 896383,4491 897082,7303 +58 -0,004 8 6618952,795 1444378,302 778365,8347 6183695,864 1006913,303 4361377,49 889560,9199 889560,9199 889560,9199 3028113,237 3033914,547 5801508,284 10022588,99 19125557,29 10008003,89 10007114,33 6183695,864 1006814,657 1006814,657 1007436,198 +59 -0,004 9 6607980,07 1405909,739 889560,9199 6170931,273 1117485,218 4301569,009 1000756,009 1000756,009 1000756,009 3120408,948 3126009,67 5794705,52 10024508,28 19014362,2 10008003,89 10007114,33 6170931,273 1117396,248 1117396,248 1117955,212 +60 -0,004 10 6598143,893 1375245,864 1000756,009 6159484,926 1228168,635 4243503,328 1111951,1 1111951,1 1111951,1 3213806,843 3219215,348 5789408,419 10026422,27 18903167,11 10008003,89 10007114,33 6159484,926 1228087,597 1228087,597 1228595,094 +61 -0,004 11 6589450,361 1352917,574 1111951,1 6149365,181 1338935,899 4187254,632 1223146,193 1223146,193 1223146,193 3308213,023 3313437,31 5785621,519 10028330,38 18791972,02 10008003,89 10007114,33 6149365,181 1338861,478 1338861,478 1339325,889 +62 -0,004 12 6581904,888 1339341,905 1223146,193 6140579,472 1449767,789 4132898,728 1334341,287 1334341,287 1334341,287 3403543,029 3408590,713 5783348,074 10030232,03 18680776,92 10008003,89 10007114,33 6140579,472 1449698,971 1449698,971 1450126,767 +63 -0,004 13 6575512,196 1334785,995 1334341,287 6133134,296 1560650,535 4080512,812 1445536,383 1445536,383 1445536,383 3499720,799 3504599,115 5782590,042 10032126,64 18569581,83 10008003,89 10007114,33 6133134,296 1560586,518 1560586,518 1560982,802 +64 -0,004 14 6570276,299 1339341,905 1445536,383 6127035,182 1671574,013 4030175,193 1556731,479 1556731,479 1556731,479 3596677,745 3601393,55 5783348,074 10034013,63 18458386,73 10008003,89 10007114,33 6127035,182 1671514,156 1671514,156 1671883,019 +65 -0,004 15 6566200,496 1352917,574 1556731,479 6122286,681 1782530,617 3981964,975 1667926,576 1667926,576 1667926,576 3694351,933 3698911,716 5785621,519 10035892,44 18347191,64 10008003,89 10007114,33 6122286,681 1782474,397 1782474,397 1782819,171 +66 -0,004 16 6563287,364 1375245,864 1667926,576 6118892,345 1893514,521 3935961,688 1779121,673 1779121,673 1779121,673 3792687,348 3797097,247 5789408,419 10037762,47 18235996,54 10008003,89 10007114,33 6118892,345 1893461,507 1893461,507 1893784,939 +67 -0,004 17 6561538,746 1405909,739 1779121,673 6116854,723 2004521,188 3892244,872 1890316,771 1890316,771 1890316,771 3891633,259 3895899,068 5794705,52 10039623,18 18124801,44 10008003,89 10007114,33 6116854,723 2004471,02 2004471,02 2004775,403 +68 -0,004 18 6560955,75 1444378,302 1890316,771 6116175,345 2115547,031 3850893,614 2001511,869 2001511,869 2001511,869 3991143,642 3995270,833 5801508,284 10041473,98 18013606,34 10008003,89 10007114,33 6116175,345 2115499,407 2115499,407 2115786,673 +69 -0,004 19 6561538,746 1490047,062 2001511,869 6116854,723 2226589,181 3811986,043 2112706,967 2112706,967 2112706,967 4091176,681 4095170,416 5809810,906 10043314,33 17902411,24 10008003,89 10007114,33 6116854,723 2226543,841 2226543,841 2226815,635 +70 -0,004 20 6563287,364 1542276,375 2112706,967 6118892,345 2337645,309 3775598,779 2223902,066 2223902,066 2223902,066 4191694,318 4195559,468 5819606,339 10045143,64 17791216,15 10008003,89 10007114,33 6118892,345 2337602,033 2337602,033 2337859,766 +71 -0,004 21 6566200,496 1600423,887 2223902,066 6122286,681 2448713,512 3741806,349 2335097,165 2335097,165 2335097,165 4292661,863 4296403,023 5830886,315 10046961,38 17680021,05 10008003,89 10007114,33 6122286,681 2448672,108 2448672,108 2448916,997 +72 -0,004 22 6570276,299 1663869,042 2335097,165 6127035,182 2559792,216 3710680,568 2446292,264 2446292,264 2446292,264 4394047,643 4397669,147 5843641,38 10048766,98 17568825,95 10008003,89 10007114,33 6127035,182 2559752,516 2559752,516 2559985,623 +73 -0,004 23 6575512,196 1732029,554 2446292,264 6133134,296 2670880,106 3682289,906 2557487,364 2557487,364 2557487,364 4495822,697 4499328,631 5857860,928 10050559,9 17457630,85 10008003,89 10007114,33 6133134,296 2670841,966 2670841,966 2671064,217 +74 -0,004 24 6581904,888 1804370,9 2557487,364 6140579,472 2781976,081 3656698,841 2668682,463 2668682,463 2668682,463 4597960,494 4601354,718 5873533,24 10052339,59 17346435,75 10008003,89 10007114,33 6140579,472 2781939,371 2781939,371 2782151,584 +75 -0,004 25 6589450,361 1880410,371 2668682,463 6149365,181 2893079,205 3633967,211 2779877,563 2779877,563 2779877,563 4700436,7 4703722,853 5890645,522 10054105,5 17235240,65 10008003,89 10007114,33 6149365,181 2893043,813 2893043,813 2893246,708 +76 -0,004 26 6598143,893 1959717,276 2779877,563 6159484,926 3004188,683 3614149,583 2891072,662 2891072,662 2891072,662 4803228,955 4806410,473 5909183,957 10055857,11 17124045,55 10008003,89 10007114,33 6159484,926 3004154,507 3004154,507 3004348,728 +77 -0,004 27 6607980,07 2041910,662 2891072,662 6170931,273 3115303,832 3597294,651 3002267,762 3002267,762 3002267,762 4906316,683 4909396,811 5929133,744 10057593,86 17012850,45 10008003,89 10007114,33 6170931,273 3115270,781 3115270,781 3115456,901 +78 -0,004 28 6618952,795 2126655,59 3002267,762 6183695,864 3226424,064 3583444,67 3113462,862 3113462,862 3113462,862 5009680,921 5012662,723 5950479,156 10059315,25 16901655,35 10008003,89 10007114,33 6183695,864 3226392,057 3226392,057 3226570,589 +79 -0,004 29 6631055,309 2213658,745 3113462,862 6197769,448 3337548,867 3572634,959 3224657,962 3224657,962 3224657,962 5113304,168 5116190,538 5973203,584 10061020,74 16790460,25 10008003,89 10007114,33 6197769,448 3337517,831 3337517,831 3337689,237 +80 -0,004 30 6644280,201 2302663,864 3224657,962 6213141,909 3448677,797 3564893,463 3335853,062 3335853,062 3335853,062 5217170,244 5219963,918 5997289,596 10062709,81 16679265,15 10008003,89 10007114,33 6213141,909 3448647,666 3448647,666 3448812,364 +81 -0,004 31 6658619,431 2393447,304 3335853,062 6229802,296 3559810,464 3560240,404 3447048,162 3447048,162 3447048,162 5321264,172 5323967,736 6022718,987 10064381,95 16568070,05 10008003,89 10007114,33 6229802,296 3559781,179 3559781,179 3559939,546 +82 -0,004 32 6674064,346 2485813,915 3447048,162 6247738,854 3670946,526 3558688,018 3558243,263 3558243,263 3558243,263 5425572,068 5428187,968 6049472,837 10066036,65 16456874,95 10008003,89 10007114,33 6247738,854 3670918,032 3670918,032 3671070,411 +83 -0,004 33 6690605,702 2579593,31 3558243,263 6266939,057 3782085,681 3560240,404 3669438,363 3669438,363 3669438,363 5530081,043 5532611,59 6077531,564 10067673,4 16345679,85 10008003,89 10007114,33 6266939,057 3782057,927 3782057,927 3782204,633 +84 -0,004 34 6708233,683 2674636,549 3669438,363 6287389,649 3893227,66 3564893,463 3780633,463 3780633,463 3780633,463 5634779,111 5637226,495 6106874,981 10069291,71 16234484,75 10008003,89 10007114,33 6287389,649 3893200,602 3893200,602 3893341,918 +85 -0,004 35 6726937,925 2770813,237 3780633,463 6309076,672 4004372,226 3572634,959 3891828,563 3891828,563 3891828,563 5739655,116 5742021,408 6137482,351 10070891,09 16123289,65 10008003,89 10007114,33 6309076,672 4004345,821 4004345,821 4004482,01 +86 -0,004 36 6746707,539 2868008,998 3891828,563 6331985,512 4115519,165 3583444,67 4003023,664 4003023,664 4003023,664 5844698,656 5846985,817 6169332,439 10072471,04 16012094,55 10008003,89 10007114,33 6331985,512 4115493,375 4115493,375 4115624,677 +87 -0,004 37 6767531,134 2966123,296 4003023,664 6356100,932 4226668,288 3597294,651 4114218,764 4114218,764 4114218,764 5949900,021 5952109,906 6202403,569 10074031,08 15900899,45 10008003,89 10007114,33 6356100,932 4226643,078 4226643,078 4226769,713 +88 -0,004 38 6789396,839 3065067,563 4114218,764 6381407,114 4337819,423 3614149,583 4225413,865 4225413,865 4225413,865 6055250,132 6057384,499 6236673,677 10075570,75 15789704,35 10008003,89 10007114,33 6381407,114 4337794,759 4337794,759 4337916,931 +89 -0,004 39 6812292,331 3164763,585 4225413,865 6407887,696 4448972,415 3633967,211 4336608,965 4336608,965 4336608,965 6160740,492 6162801,005 6272120,356 10077089,57 15678509,25 10008003,89 10007114,33 6407887,696 4448948,268 4448948,268 4449066,165 +90 -0,004 40 6836204,859 3265142,127 4336608,965 6435525,812 4560127,127 3656698,841 4447804,066 4447804,066 4447804,066 6266363,135 6268351,371 6308720,916 10078587,07 15567314,15 10008003,89 10007114,33 6435525,812 4560103,468 4560103,468 4560217,264 +91 -0,004 41 6861121,267 3366141,752 4447804,066 6464304,134 4671283,431 3682289,906 4558999,166 4558999,166 4558999,166 6372110,582 6374028,034 6346452,42 10080062,8 15456119,05 10008003,89 10007114,33 6464304,134 4671260,234 4671260,234 4671370,09 +92 -0,004 42 6887028,019 3467707,805 4558999,166 6494204,909 4782441,214 3710680,568 4670194,267 4670194,267 4670194,267 6477975,806 6479823,889 6385291,742 10081516,32 15344923,95 10008003,89 10007114,33 6494204,909 4782418,454 4782418,454 4782524,52 +93 -0,004 43 6913911,228 3569791,547 4670194,267 6525209,995 4893600,371 3741806,349 4781389,367 4781389,367 4781389,367 6583952,193 6585732,245 6425215,601 10082947,18 15233728,84 10008003,89 10007114,33 6525209,995 4893578,025 4893578,025 4893680,439 +94 -0,004 44 6941756,676 3672349,408 4781389,367 6557300,907 5004760,806 3775598,779 4892584,468 4892584,468 4892584,468 6690033,507 6691746,798 6466200,609 10084354,94 15122533,74 10008003,89 10007114,33 6557300,907 5004738,854 5004738,854 5004837,746 +95 -0,004 45 6970549,842 3775342,347 4892584,468 6590458,843 5115922,434 3811986,043 5003779,569 5003779,569 5003779,569 6796213,866 6797861,596 6508223,311 10085739,17 15011338,64 10008003,89 10007114,33 6590458,843 5115900,855 5115900,855 5115996,346 +96 -0,004 46 7000275,926 3878735,297 5003779,569 6624664,732 5227085,175 3850893,614 5114974,669 5114974,669 5114974,669 6902487,709 6904071,016 6551260,219 10087099,46 14900143,54 10008003,89 10007114,33 6624664,732 5227063,95 5227063,95 5227156,152 +97 -0,004 47 7030919,869 3982496,687 5114974,669 6659899,262 5338248,955 3892244,872 5226169,77 5226169,77 5226169,77 7008849,774 7010369,734 6595287,849 10088435,39 14788948,44 10008003,89 10007114,33 6659899,262 5338228,067 5338228,067 5338317,084 +98 -0,004 48 7062466,384 4086598,031 5226169,77 6696142,915 5449413,707 3935961,688 5337364,87 5337364,87 5337364,87 7115295,076 7116752,706 6640282,755 10089746,54 14677753,34 10008003,89 10007114,33 6696142,915 5449393,138 5449393,138 5449479,07 +99 -0,004 49 7094899,97 4191013,571 5337364,87 6733376,004 5560579,369 3981964,975 5448559,971 5448559,971 5448559,971 7221818,882 7223215,144 6686221,56 10091032,53 14566558,24 10008003,89 10007114,33 6733376,004 5560559,104 5560559,104 5560642,043 +100 -0,004 50 7128204,944 4295719,96 5448559,971 6771578,7 5671745,883 4030175,193 5559755,072 5559755,072 5559755,072 7328416,694 7329752,498 6733080,982 10092292,96 14455363,14 10008003,89 10007114,33 6771578,7 5671725,908 5671725,908 5671805,939 +101 -0,004 51 7162365,453 4400696 5559755,072 6810731,064 5782913,197 4080512,812 5670950,173 5670950,173 5670950,173 7435084,233 7436360,438 6780837,862 10093527,44 14344168,04 10008003,89 10007114,33 6810731,064 5782893,498 5782893,498 5782970,702 +102 -0,004 52 7197365,503 4505922,397 5670950,173 6850813,079 5894081,262 4132898,728 5782145,273 5782145,273 5782145,273 7541817,42 7543034,834 6829469,189 10094735,6 14232972,94 10008003,89 10007114,33 6850813,079 5894061,824 5894061,824 5894136,277 +103 -0,004 53 7233188,974 4611381,562 5782145,273 6891804,671 6005250,031 4187254,632 5893340,374 5893340,374 5893340,374 7648612,36 7649771,748 6878952,119 10095917,07 14121777,84 10008003,89 10007114,33 6891804,671 6005230,842 6005230,842 6005302,616 +104 -0,004 54 7269819,642 4717057,423 5893340,374 6933685,743 6116419,462 4243503,328 6004535,475 6004535,475 6004535,475 7755465,331 7756567,41 6929263,999 10097071,5 14010582,74 10008003,89 10007114,33 6933685,743 6116400,511 6116400,511 6116469,672 +105 -0,004 55 7307241,197 4822935,27 6004535,475 6976436,191 6227589,516 4301569,009 6115730,576 6115730,576 6115730,576 7862372,767 7863418,213 6980382,381 10098198,52 13899387,64 10008003,89 10007114,33 6976436,191 6227570,791 6227570,791 6227637,402 +106 -0,004 56 7345437,261 4929001,615 6115730,576 7020035,933 6338760,155 4361377,49 6226925,676 6226925,676 6226925,676 7969331,251 7970320,698 7032285,037 10099297,8 13788192,54 10008003,89 10007114,33 7020035,933 6338741,645 6338741,645 6338805,766 +107 -0,004 57 7384391,404 5035244,065 6226925,676 7064464,928 6449931,346 4422856,399 6338120,777 6338120,777 6338120,777 8076337,498 8077271,541 7084949,979 10100369 13676997,43 10008003,89 10007114,33 7064464,928 6449913,04 6449913,04 6449974,726 +108 -0,004 58 7424087,161 5141651,217 6338120,777 7109703,198 6561103,055 4485935,327 6449315,878 6449315,878 6449315,878 8183388,348 8184267,543 7138355,465 10101411,79 13565802,33 10008003,89 10007114,33 7109703,198 6561084,944 6561084,944 6561144,247 +109 -0,004 59 7464508,047 5248212,558 6449315,878 7155730,841 6672275,252 4550545,951 6560510,979 6560510,979 6560510,979 8290480,757 8291305,622 7192480,011 10102425,86 13454607,23 10008003,89 10007114,33 7155730,841 6672257,326 6672257,326 6672314,296 +110 -0,004 60 7505637,571 5354918,38 6560510,979 7202528,054 6783447,909 4616622,121 6671706,08 6671706,08 6671706,08 8397611,784 8398382,801 7247302,404 10103410,9 13343412,13 10008003,89 10007114,33 7202528,054 6783430,159 6783430,159 6783484,842 +111 -0,004 61 7547459,248 5461759,704 6671706,08 7250075,146 6894620,998 4684099,917 6782901,18 6782901,18 6782901,18 8504778,585 8505496,201 7302801,701 10104366,61 13232217,03 10008003,89 10007114,33 7250075,146 6894603,416 6894603,416 6894655,856 +112 -0,004 62 7589956,616 5568728,213 6782901,18 7298352,552 7005794,495 4752917,693 6894096,281 6894096,281 6894096,281 8611978,405 8612643,033 7358957,244 10105292,69 13121021,93 10008003,89 10007114,33 7298352,552 7005777,071 7005777,071 7005827,309 +113 -0,004 63 7633113,243 5675816,188 6894096,281 7347340,845 7116968,375 4823016,082 7005291,382 7005291,382 7005291,382 8719208,567 8719820,588 7415748,658 10106188,86 13009826,83 10008003,89 10007114,33 7347340,845 7116951,102 7116951,102 7116999,177 +114 -0,004 64 7676912,738 5783016,456 7005291,382 7397020,75 7228142,616 4894338 7116486,483 7116486,483 7116486,483 8826466,47 8827026,232 7473155,858 10107054,86 12898631,73 10008003,89 10007114,33 7397020,75 7228125,487 7228125,487 7228171,434 +115 -0,004 65 7721338,765 5890322,341 7116486,483 7447373,15 7339317,196 4966828,625 7227681,584 7227681,584 7227681,584 8933749,578 8934257,397 7531159,048 10107890,41 12787436,63 10008003,89 10007114,33 7447373,15 7339300,203 7339300,203 7339344,057 +116 -0,004 66 7766375,048 5997727,619 7227681,584 7498379,099 7450492,096 5040435,367 7338876,685 7338876,685 7338876,685 9041055,414 9041511,576 7589738,726 10108695,26 12676241,53 10008003,89 10007114,33 7498379,099 7450475,23 7450475,23 7450517,024 +117 -0,004 67 7812005,38 6105226,48 7338876,685 7550019,828 7561667,294 5115107,822 7450071,785 7450071,785 7450071,785 9148381,557 9148786,317 7648875,679 10109469,17 12565046,43 10008003,89 10007114,33 7550019,828 7561650,551 7561650,551 7561690,314 +118 -0,004 68 7858213,634 6212813,492 7450071,785 7602276,751 7672842,775 5190797,724 7561266,886 7561266,886 7561266,886 9255725,631 9256079,214 7708550,986 10110211,9 12453851,33 10008003,89 10007114,33 7602276,751 7672826,145 7672826,145 7672863,907 +119 -0,004 69 7904983,764 6320483,568 7561266,886 7655131,473 7784018,518 5267458,886 7672461,987 7672461,987 7672461,987 9363085,3 9363387,903 7768746,015 10110923,23 12342656,22 10008003,89 10007114,33 7655131,473 7784001,997 7784001,997 7784037,783 +120 -0,004 70 7952299,816 6428231,938 7672461,987 7708565,791 7895194,509 5345047,138 7783657,088 7783657,088 7783657,088 9470458,268 9470710,058 7829442,421 10111602,93 12231461,12 10008003,89 10007114,33 7708565,791 7895178,09 7895178,09 7895211,924 +121 -0,004 71 8000145,93 6536054,123 7783657,088 7762561,7 8006370,73 5423520,258 7894852,189 7894852,189 7894852,189 9577842,267 9578043,383 7890622,138 10112250,8 12120266,02 10008003,89 10007114,33 7762561,7 8006354,407 8006354,407 8006386,313 +122 -0,004 72 8048506,347 6643945,912 7894852,189 7817101,395 8117547,167 5502837,903 8006047,29 8006047,29 8006047,29 9685235,054 9685385,607 7952267,383 10112866,64 12009070,92 10008003,89 10007114,33 7817101,395 8117530,933 8117530,933 8117560,934 +123 -0,004 73 8097365,411 6751903,337 8006047,29 7872167,276 8228723,804 5582961,538 8117242,391 8117242,391 8117242,391 9792634,407 9792734,48 8014360,646 10113450,27 11897875,82 10008003,89 10007114,33 7872167,276 8228707,654 8228707,654 8228735,769 +124 -0,004 74 8146707,574 6859922,655 8117242,391 7927741,942 8339900,628 5663854,36 8228437,492 8228437,492 8228437,492 9900038,118 9900087,766 8076884,683 10114001,51 11786680,72 10008003,89 10007114,33 7927741,942 8339884,555 8339884,555 8339910,803 +125 -0,004 75 8196517,397 6968000,334 8228437,492 7983808,198 8451077,624 5745481,231 8339632,592 8339632,592 8339632,592 10007443,99 10007443,24 8139822,516 10114520,18 11675485,62 10008003,89 10007114,33 7983808,198 8451061,624 8451061,624 8451086,021 +126 -0,004 76 8246779,555 7076133,028 8339632,592 8040349,052 8562254,78 5827808,6 8450827,693 8450827,693 8450827,693 10114849,83 10114798,68 8203157,423 10115006,14 11564290,52 10008003,89 10007114,33 8040349,052 8562238,846 8562238,846 8562261,409 +127 -0,004 77 8297478,834 7184317,572 8450827,693 8097347,713 8673432,082 5910804,435 8562022,794 8562022,794 8562022,794 10222253,44 10222151,87 8266872,932 10115459,23 11453095,42 10008003,89 10007114,33 8097347,713 8673416,21 8673416,21 8673436,953 +128 -0,004 78 8348600,136 7292550,96 8562022,794 8154787,592 8784609,517 5994438,151 8673217,895 8673217,895 8673217,895 10329652,63 10329500,57 8330952,813 10115879,31 11341900,32 10008003,89 10007114,33 8154787,592 8784593,702 8784593,702 8784612,639 +129 -0,004 79 8400128,48 7400830,336 8673217,895 8212652,297 8895787,075 6078680,542 8784412,996 8784412,996 8784412,996 10437045,18 10436842,57 8395381,074 10116266,26 11230705,22 10008003,89 10007114,33 8212652,297 8895771,311 8895771,311 8895788,453 +130 -0,004 80 8452048,997 7509152,983 8784412,996 8270925,633 9006964,743 6163503,714 8895608,097 8895608,097 8895608,097 10544428,89 10544175,59 8460141,951 10116619,96 11119510,12 10008003,89 10007114,33 8270925,633 9006949,024 9006949,024 9006964,384 +131 -0,004 81 8504346,936 7617516,311 8895608,097 8329591,596 9118142,509 6248881,023 9006803,198 9006803,198 9006803,198 10651801,49 10651497,39 8525219,897 10116940,3 11008315,01 10008003,89 10007114,33 8329591,596 9118126,832 9118126,832 9118140,417 +132 -0,004 82 8557007,658 7725917,846 9006803,198 8388634,37 9229320,363 6334787,006 9117998,299 9117998,299 9117998,299 10759160,73 10758805,64 8590599,581 10117227,18 10897119,91 10008003,89 10007114,33 8388634,37 9229304,721 9229304,721 9229316,542 +133 -0,004 83 8610016,638 7834355,225 9117998,299 8448038,327 9340498,292 6421197,328 9229193,4 9229193,4 9229193,4 10866504,31 10866098,04 8656265,875 10117480,51 10785924,81 10008003,89 10007114,33 8448038,327 9340482,682 9340482,682 9340492,745 +134 -0,004 84 8663359,465 7942826,181 9229193,4 8507788,015 9451676,287 6508088,72 9340388,501 9340388,501 9340388,501 10973829,89 10973372,21 8722203,845 10117700,23 10674729,71 10008003,89 10007114,33 8507788,015 9451660,703 9451660,703 9451669,014 +135 -0,004 85 8717021,833 8051328,543 9340388,501 8567868,161 9562854,336 6595438,922 9451583,601 9451583,601 9451583,601 11081135,09 11080625,75 8788398,745 10117886,25 10563534,61 10008003,89 10007114,33 8567868,161 9562838,773 9562838,773 9562845,339 +136 -0,004 86 8770989,548 8159860,222 9451583,601 8628263,658 9674032,43 6683226,636 9562778,702 9562778,702 9562778,702 11188417,49 11187856,21 8854836,006 10118038,53 10452339,51 10008003,89 10007114,33 8628263,658 9674016,883 9674016,883 9674021,707 +137 -0,004 87 8825248,519 8268419,207 9562778,702 8688959,567 9785210,556 6771431,466 9673973,803 9673973,803 9673973,803 11295674,62 11295061,07 8921501,229 10118157,02 10341144,41 10008003,89 10007114,33 8688959,567 9785195,022 9785195,022 9785198,107 +138 -0,004 88 8879784,756 8377003,559 9673973,803 8749941,108 9896388,706 6860033,878 9785168,904 9785168,904 9785168,904 11402903,94 11402237,78 8988380,173 10118241,68 10229949,31 10008003,89 10007114,33 8749941,108 9896373,179 9896373,179 9896374,527 +139 -0,004 89 8934584,37 8485611,404 9785168,904 8811193,651 10007566,87 6949015,146 9896364,005 9896364,005 9896364,005 11510102,84 11509383,68 9055458,749 10118292,49 10118754,21 10008003,89 10007114,33 8811193,651 10007551,34 10007551,34 10007550,96 +140 -0,004 90 8989633,568 8594240,929 9896364,005 8872702,717 10118745,03 7038357,312 10007559,11 10007559,11 10007559,11 11617268,64 11616496,08 9122723,011 10118309,43 10007559,11 10008003,89 10007114,33 8872702,717 10118729,51 10118729,51 10118727,38 +141 -0,004 91 9044918,648 8702890,375 10007559,11 8934453,964 10229923,19 7128043,144 10118754,21 10118754,21 10118754,21 11724398,6 11723572,19 9190159,142 10118292,49 9896364,005 10008003,89 10007114,33 8934453,964 10229907,66 10229907,66 10229903,79 +142 -0,004 92 9100425,997 8811558,03 10118754,21 8996433,187 10341101,33 7218056,093 10229949,31 10229949,31 10229949,31 11831489,86 11830609,11 9257753,452 10118241,68 9785168,904 10008003,89 10007114,33 8996433,187 10341085,78 10341085,78 10341080,18 +143 -0,004 93 9156142,088 8920242,231 10229949,31 9058626,306 10452279,44 7308380,254 10341144,41 10341144,41 10341144,41 11938539,48 11937603,88 9325492,361 10118157,02 9673973,803 10008003,89 10007114,33 9058626,306 10452263,88 10452263,88 10452256,53 +144 -0,004 94 9212053,473 9028941,354 10341144,41 9121019,361 10563457,51 7399000,334 10452339,51 10452339,51 10452339,51 12045544,42 12044553,41 9393362,396 10118038,53 9562778,702 10008003,89 10007114,33 9121019,361 10563441,93 10563441,93 10563432,83 +145 -0,004 95 9268146,78 9137653,808 10452339,51 9183598,509 10674635,53 7489901,612 10563534,61 10563534,61 10563534,61 12152501,51 12151454,49 9461350,176 10117886,25 9451583,601 10008003,89 10007114,33 9183598,509 10674619,92 10674619,92 10674609,08 +146 -0,004 96 9324408,709 9246378,039 10563534,61 9246350,009 10785813,49 7581069,909 10674729,71 10674729,71 10674729,71 12259407,47 12258303,81 9529442,41 10117700,23 9340388,501 10008003,89 10007114,33 9246350,009 10785797,85 10785797,85 10785785,25 +147 -0,004 97 9380826,029 9355112,516 10674729,71 9309260,221 10896991,38 7672491,554 10785924,81 10785924,81 10785924,81 12366258,88 12365097,9 9597625,877 10117480,51 9229193,4 10008003,89 10007114,33 9309260,221 10896975,7 10896975,7 10896961,33 +148 -0,004 98 9437385,568 9463855,737 10785924,81 9372315,599 11008169,19 7764153,358 10897119,91 10897119,91 10897119,91 12473052,17 12471833,16 9665887,428 10117227,18 9117998,299 10008003,89 10007114,33 9372315,599 11008153,47 11008153,47 11008137,32 +149 -0,004 99 9494074,214 9572606,217 10897119,91 9435502,676 11119346,9 7856042,578 11008315,01 11008315,01 11008315,01 12579783,61 12578505,8 9734213,969 10116940,3 9006803,198 10008003,89 10007114,33 9435502,676 11119331,14 11119331,14 11119313,21 +150 -0,004 100 9550878,909 9681362,491 11008315,01 9498808,068 11230524,51 7948146,899 11119510,12 11119510,12 11119510,12 12686449,31 12685111,89 9802592,451 10116619,96 8895608,097 10008003,89 10007114,33 9498808,068 11230508,69 11230508,69 11230488,97 +151 -0,004 101 9607786,639 9790123,103 11119510,12 9562218,456 11341702 8040454,4 11230705,22 11230705,22 11230705,22 12793045,19 12791647,3 9871009,867 10116266,26 8784412,996 10008003,89 10007114,33 9562218,456 11341686,13 11341686,13 11341664,59 +152 -0,004 102 9664784,435 9898886,612 11230705,22 9625720,584 11452879,37 8132953,531 11341900,32 11341900,32 11341900,32 12899566,95 12898107,69 9939453,236 10115879,31 8673217,895 10008003,89 10007114,33 9625720,584 11452863,43 11452863,43 11452840,07 +153 -0,004 103 9721859,365 10007651,58 11341900,32 9689301,252 11564056,59 8225633,094 11453095,42 11453095,42 11453095,42 13006010,11 13004488,5 10007909,6 10115459,23 8562022,794 10008003,89 10007114,33 9689301,252 11564040,59 11564040,59 11564015,39 +154 -0,004 104 9778998,529 10116416,58 11453095,42 9752947,304 11675233,66 8318482,213 11564290,52 11564290,52 11564290,52 13112369,93 13110784,96 10076366 10115006,14 8450827,693 10008003,89 10007114,33 9752947,304 11675217,58 11675217,58 11675190,53 +155 -0,004 105 9836189,054 10225180,17 11564290,52 9816645,624 11786410,56 8411490,318 11675485,62 11675485,62 11675485,62 13218641,41 13216992,01 10144809,49 10114520,18 8339632,592 10008003,89 10007114,33 9816645,624 11786394,41 11786394,41 11786365,49 +156 -0,004 106 9893418,089 10333940,91 11675485,62 9880383,126 11897587,28 8504647,119 11786680,72 11786680,72 11786680,72 13324819,29 13323104,32 10213227,11 10114001,51 8228437,492 10008003,89 10007114,33 9880383,126 11897571,04 11897571,04 11897540,23 +157 -0,004 107 9950672,798 10442697,38 11786680,72 9944146,75 12008763,81 8597942,592 11897875,82 11897875,82 11897875,82 13430898,01 13429116,26 10281605,87 10113450,27 8117242,391 10008003,89 10007114,33 9944146,75 12008747,48 12008747,48 12008714,76 +158 -0,004 108 10007940,36 10551448,1 11897875,82 10007923,45 12119940,12 8691366,954 12009070,92 12009070,92 12009070,92 13536871,68 13535021,88 10349932,78 10112866,64 8006047,29 10008003,89 10007114,33 10007923,45 12119923,7 12119923,7 12119889,05 +159 -0,004 109 10065207,95 10660191,62 12009070,92 10071700,18 12231116,21 8784910,648 12120266,02 12120266,02 12120266,02 13642734,05 13640814,87 10418194,77 10112250,8 7894852,189 10008003,89 10007114,33 10071700,18 12231099,69 12231099,69 12231063,08 +160 -0,004 110 10122462,75 10768926,45 12120266,02 10135463,92 12342292,07 8878564,323 12231461,12 12231461,12 12231461,12 13748478,52 13746488,54 10486378,77 10111602,93 7783657,088 10008003,89 10007114,33 10135463,92 12342275,44 12342275,44 12342236,84 +161 -0,004 111 10179691,94 10877651,09 12231461,12 10199201,6 12453467,66 8972318,82 12342656,22 12342656,22 12342656,22 13854098,03 13852035,76 10554471,61 10110923,23 7672461,987 10008003,89 10007114,33 10199201,6 12453450,92 12453450,92 12453410,32 +162 -0,004 112 10236882,68 10986364,01 12342656,22 10262900,18 12564642,98 9066165,151 12453851,33 12453851,33 12453851,33 13959585,12 13957448,98 10622460,07 10110211,9 7561266,886 10008003,89 10007114,33 10262900,18 12564626,12 12564626,12 12564583,48 +163 -0,004 113 10294022,12 11095063,66 12453851,33 10326546,56 12675818,01 9160094,486 12565046,43 12565046,43 12565046,43 14064931,81 14062720,14 10690330,87 10109469,17 7450071,785 10008003,89 10007114,33 10326546,56 12675801,02 12675801,02 12675756,31 +164 -0,004 114 10351097,39 11203748,44 12565046,43 10390127,63 12786992,73 9254098,135 12676241,53 12676241,53 12676241,53 14170129,6 14167840,63 10758070,63 10108695,26 7338876,685 10008003,89 10007114,33 10390127,63 12786975,6 12786975,6 12786928,79 +165 -0,004 115 10408095,58 11312416,73 12676241,53 10453630,23 12898167,11 9348167,536 12787436,63 12787436,63 12787436,63 14275169,39 14272801,27 10825665,87 10107890,41 7227681,584 10008003,89 10007114,33 10453630,23 12898149,84 12898149,84 12898100,9 +166 -0,004 116 10465003,77 11421066,88 12787436,63 10517041,16 13009341,14 9442294,237 12898631,73 12898631,73 12898631,73 14380041,48 14377592,25 10893103,01 10107054,86 7116486,483 10008003,89 10007114,33 10517041,16 13009323,72 13009323,72 13009272,61 +167 -0,004 117 10521808,99 11529697,16 12898631,73 10580347,17 13120514,8 9536469,883 13009826,83 13009826,83 13009826,83 14484735,44 14482203,03 10960368,35 10106188,86 7005291,382 10008003,89 10007114,33 10580347,17 13120497,21 13120497,21 13120443,89 +168 -0,004 118 10578498,21 11638305,83 13009826,83 10643534,94 13231688,05 9630686,199 13121021,93 13121021,93 13121021,93 14589240,12 14586622,34 11027448,1 10105292,69 6894096,281 10008003,89 10007114,33 10643534,94 13231670,3 13231670,3 13231614,73 +169 -0,004 119 10635058,39 11746891,07 13121021,93 10706591,08 13342860,89 9724934,981 13232217,03 13232217,03 13232217,03 14693543,53 14690838,06 11094328,28 10104366,61 6782901,18 10008003,89 10007114,33 10706591,08 13342842,96 13342842,96 13342785,09 +170 -0,004 120 10691476,41 11855451 13232217,03 10769502,13 13454033,27 9819208,078 13343412,13 13343412,13 13343412,13 14797632,75 14794837,16 11160994,83 10103410,9 6671706,08 10008003,89 10007114,33 10769502,13 13454015,16 13454015,16 13453954,95 +171 -0,004 121 10747739,1 11963983,69 13343412,13 10832254,53 13565205,17 9913497,38 13454607,23 13454607,23 13454607,23 14901493,91 14898605,59 11227433,49 10102425,86 6560510,979 10008003,89 10007114,33 10832254,53 13565186,87 13565186,87 13565124,27 +172 -0,004 122 10803833,23 12072487,14 13454607,23 10894834,65 13676376,57 10007794,8 13565802,33 13565802,33 13565802,33 15005112 15002128,23 11293629,87 10101411,79 6449315,878 10008003,89 10007114,33 10894834,65 13676358,06 13676358,06 13676293,01 +173 -0,004 123 10859745,49 12180959,25 13565802,33 10957228,76 13787547,42 10102092,28 13676997,43 13676997,43 13676997,43 15108470,84 15105388,72 11359569,4 10100369 6338120,777 10008003,89 10007114,33 10957228,76 13787528,7 13787528,7 13787461,15 +174 -0,004 124 10915462,52 12289397,85 13676997,43 11019422,99 13898717,7 10196381,74 13788192,54 13788192,54 13788192,54 15211552,91 15208369,38 11425237,32 10099297,8 6226925,676 10008003,89 10007114,33 11019422,99 13898698,75 13898698,75 13898628,64 +175 -0,004 125 10970970,86 12397800,68 13788192,54 11081403,4 14009887,37 10290655,09 13899387,64 13899387,64 13899387,64 15314339,24 15311051,05 11490618,72 10098198,52 6115730,576 10008003,89 10007114,33 11081403,4 14009868,18 14009868,18 14009795,45 +176 -0,004 126 11026256,99 12506165,37 13899387,64 11143155,9 14121056,39 10384904,24 14010582,74 14010582,74 14010582,74 15416809,24 15413412,96 11555698,45 10097071,5 6004535,475 10008003,89 10007114,33 11143155,9 14121036,95 14121036,95 14120961,53 +177 -0,004 127 11081307,3 12614489,47 14010582,74 11204666,29 14232224,71 10479121,02 14121777,84 14121777,84 14121777,84 15518940,52 15515432,51 11620461,19 10095917,07 5893340,374 10008003,89 10007114,33 11204666,29 14232205,01 14232205,01 14232126,83 +178 -0,004 128 11136108,07 12722770,37 14121777,84 11265920,23 14343392,3 10573297,23 14232972,94 14232972,94 14232972,94 15620708,75 15617085,14 11684891,39 10094735,6 5782145,273 10008003,89 10007114,33 11265920,23 14343372,33 14343372,33 14343291,3 +179 -0,004 129 11190645,53 12831005,37 14232972,94 11326903,23 14454559,11 10667424,61 14344168,04 14344168,04 14344168,04 15722087,36 15718344,07 11748973,28 10093527,44 5670950,173 10008003,89 10007114,33 11326903,23 14454538,84 14454538,84 14454454,89 +180 -0,004 130 11244905,77 12939191,6 14344168,04 11387600,67 14565725,07 10761494,79 14455363,14 14455363,14 14455363,14 15823047,39 15819180,08 11812690,87 10092292,96 5559755,072 10008003,89 10007114,33 11387600,67 14565704,51 14565704,51 14565617,55 +181 -0,004 131 11298874,81 13047326,08 14455363,14 11447997,76 14676890,15 10855499,33 14566558,24 14566558,24 14566558,24 15923557,13 15919561,22 11876027,93 10091032,53 5448559,971 10008003,89 10007114,33 11447997,76 14676869,26 14676869,26 14676779,2 +182 -0,004 132 11352538,55 13155405,63 14566558,24 11508079,56 14788054,26 10949429,65 14677753,34 14677753,34 14677753,34 16023581,88 16019452,48 11938967,99 10089746,54 5337364,87 10008003,89 10007114,33 11508079,56 14788033,04 14788033,04 14787939,77 +183 -0,004 133 11405882,81 13263426,92 14677753,34 11567830,97 14899217,36 11043277,08 14788948,44 14788948,44 14788948,44 16123083,55 16118815,51 12001494,33 10088435,39 5226169,77 10008003,89 10007114,33 11567830,97 14899195,78 14899195,78 14899099,21 +184 -0,004 134 11458893,27 13371386,4 14788948,44 11627236,71 15010379,36 11137032,79 14900143,54 14900143,54 14900143,54 16222020,31 16217608,16 12063589,95 10087099,46 5114974,669 10008003,89 10007114,33 11627236,71 15010357,41 15010357,41 15010257,42 +185 -0,004 135 11511555,52 13479280,36 14900143,54 11686281,34 15121540,19 11230687,78 15011338,64 15011338,64 15011338,64 16320346,1 16315784,04 12125237,63 10085739,17 5003779,569 10008003,89 10007114,33 11686281,34 15121517,84 15121517,84 15121414,31 +186 -0,004 136 11563855,03 13587104,82 15011338,64 11744949,21 15232699,76 11324232,9 15122533,74 15122533,74 15122533,74 16418010,16 16413292,06 12186419,85 10084354,94 4892584,468 10008003,89 10007114,33 11744949,21 15232677 15232677 15232569,79 +187 -0,004 137 11615777,18 13694855,57 15122533,74 11803224,52 15343857,98 11417658,8 15233728,84 15233728,84 15233728,84 16514956,46 16510075,83 12247118,82 10082947,18 4781389,367 10008003,89 10007114,33 11803224,52 15343834,78 15343834,78 15343723,77 +188 -0,004 138 11667307,19 13802528,15 15233728,84 11861091,26 15455014,74 11510955,92 15344923,95 15344923,95 15344923,95 16611123,04 16606073,01 12307316,48 10081516,32 4670194,267 10008003,89 10007114,33 11861091,26 15454991,09 15454991,09 15454876,11 +189 -0,004 139 11718430,21 13910117,78 15344923,95 11918533,23 15566169,94 11604114,48 15456119,05 15456119,05 15456119,05 16706441,26 16701214,62 12366994,48 10080062,8 4558999,166 10008003,89 10007114,33 11918533,23 15566145,8 15566145,8 15566026,69 +190 -0,004 140 11769131,25 14017619,38 15456119,05 11975534,03 15677323,45 11697124,47 15567314,15 15567314,15 15567314,15 16800835,04 16795424,17 12426134,18 10078587,07 4447804,066 10008003,89 10007114,33 11975534,03 15677298,79 15677298,79 15677175,38 +191 -0,004 141 11819395,21 14125027,54 15567314,15 12032077,09 15788475,13 11789975,58 15678509,25 15678509,25 15678509,25 16894219,89 16888616,79 12484716,67 10077089,57 4336608,965 10008003,89 10007114,33 12032077,09 15788449,92 15788449,92 15788322,03 +192 -0,004 142 11869206,88 14232336,44 15678509,25 12088145,6 15899624,84 11882657,25 15789704,35 15789704,35 15789704,35 16986501,88 16980698,19 12542722,73 10075570,75 4225413,865 10008003,89 10007114,33 12088145,6 15899599,05 15899599,05 15899466,46 +193 -0,004 143 11918550,92 14339539,87 15789704,35 12143722,58 16010772,39 11975158,61 15900899,45 15900899,45 15900899,45 17077576,48 17071563,47 12600132,85 10074031,08 4114218,764 10008003,89 10007114,33 12143722,58 16010745,99 16010745,99 16010608,48 +194 -0,004 144 11967411,91 14446631,15 15900899,45 12198790,82 16121917,61 12067468,46 16012094,55 16012094,55 16012094,55 17167327,28 17161095,91 12656927,24 10072471,04 4003023,664 10008003,89 10007114,33 12198790,82 16121890,55 16121890,55 16121747,88 +195 -0,004 145 12015774,28 14553603,13 16012094,55 12253332,92 16233060,28 12159575,26 16123289,65 16123289,65 16123289,65 17255624,53 17249165,49 12713085,81 10070891,09 3891828,563 10008003,89 10007114,33 12253332,92 16233032,53 16233032,53 16232884,44 +196 -0,004 146 12063622,39 14660448,1 16123289,65 12307331,29 16344200,18 12251467,07 16234484,75 16234484,75 16234484,75 17342323,63 17335627,42 12768588,17 10069291,71 3780633,463 10008003,89 10007114,33 12307331,29 16344171,69 16344171,69 16344017,88 +197 -0,004 147 12110940,46 14767157,73 16234484,75 12360768,1 16455337,03 12343131,6 16345679,85 16345679,85 16345679,85 17427263,41 17420320,42 12823413,68 10067673,4 3669438,363 10008003,89 10007114,33 12360768,1 16455307,75 16455307,75 16455147,92 +198 -0,004 148 12157712,65 14873723,08 16345679,85 12413625,37 16566470,55 12434556,09 16456874,95 16456874,95 16456874,95 17510264,34 17503065,05 12877541,39 10066036,65 3558243,263 10008003,89 10007114,33 12413625,37 16566440,42 16566440,42 16566274,21 +199 -0,004 149 12203922,98 14980134,43 16456874,95 12465884,88 16677600,38 12525727,37 16568070,05 16568070,05 16568070,05 17591126,76 17583661,87 12930950,07 10064381,95 3447048,162 10008003,89 10007114,33 12465884,88 16677569,34 16677569,34 16677396,39 +200 -0,004 150 12249555,43 15086381,29 16568070,05 12517528,23 16788726,16 12616631,76 16679265,15 16679265,15 16679265,15 17669628,97 17661889,69 12983618,24 10062709,81 3335853,062 10008003,89 10007114,33 12517528,23 16788694,15 16788694,15 16788514,02 +201 -0,004 151 12294593,84 15192452,26 16679265,15 12568536,84 16899847,43 12707255,08 16790460,25 16790460,25 16790460,25 17745525,57 17737503,89 13035524,17 10061020,74 3224657,962 10008003,89 10007114,33 12568536,84 16899814,38 16899814,38 16899626,61 +202 -0,004 152 12339022,03 15298334,97 16790460,25 12618891,93 17010963,71 12797582,62 16901655,35 16901655,35 16901655,35 17818545,99 17810235,12 13086645,84 10059315,25 3113462,862 10008003,89 10007114,33 12618891,93 17010929,53 17010929,53 17010733,6 +203 -0,004 153 12382823,7 15404015,94 16901655,35 12668574,56 17122074,4 12887599,09 17012850,45 17012850,45 17012850,45 17888393,51 17879788,3 13136961,04 10057593,86 3002267,762 10008003,89 10007114,33 12668574,56 17122039,01 17122039,01 17121834,34 +204 -0,004 154 12425982,52 15509480,47 17012850,45 12717565,61 17233178,84 12977288,58 17124045,55 17124045,55 17124045,55 17954745 17945842,54 13186447,31 10055857,11 2891072,662 10008003,89 10007114,33 12717565,61 17233142,13 17233142,13 17232928,09 +205 -0,004 155 12468482,09 15614712,52 17124045,55 12765845,79 17344276,25 13066634,55 17235240,65 17235240,65 17235240,65 18017251,7 18008051,93 13235081,99 10054105,5 2779877,563 10008003,89 10007114,33 12765845,79 17344238,11 17344238,11 17344013,95 +206 -0,004 156 12510305,99 15719694,5 17235240,65 12813395,69 17455365,7 13155619,76 17346435,75 17346435,75 17346435,75 18075541,49 18066047,9 13282842,25 10052339,59 2668682,463 10008003,89 10007114,33 12813395,69 17455326 17455326 17455090,91 +207 -0,004 157 12551437,75 15824407,15 17346435,75 12860195,72 17566446,1 13244226,27 17457630,85 17457630,85 17457630,85 18129222,96 18119443,37 13329705,05 10050559,9 2557487,364 10008003,89 10007114,33 12860195,72 17566404,7 17566404,7 17566157,74 +208 -0,004 158 12591860,87 15928829,29 17457630,85 12906226,2 17677516,18 13332435,34 17568825,95 17568825,95 17568825,95 18177891,82 18167839,04 13375647,23 10048766,98 2446292,264 10008003,89 10007114,33 12906226,2 17677472,9 17677472,9 17677213,01 +209 -0,004 159 12631558,87 16032937,59 17568825,95 12951467,32 17788574,37 13420227,45 17680021,05 17680021,05 17680021,05 18221139,76 18210832,23 13420645,52 10046961,38 2335097,165 10008003,89 10007114,33 12951467,32 17788529,03 17788529,03 17788254,98 +210 -0,004 160 12670515,26 16136706,33 17680021,05 12995899,17 17899618,81 13507582,2 17791216,15 17791216,15 17791216,15 18258566,08 18248028,35 13464676,53 10045143,64 2223902,066 10008003,89 10007114,33 12995899,17 17899571,18 17899571,18 17899281,54 +211 -0,004 161 12708713,56 16240107,03 17791216,15 13039501,77 18010647,19 13594478,3 17902411,24 17902411,24 17902411,24 18289791,67 18279054,5 13507716,8 10043314,33 2112706,967 10008003,89 10007114,33 13039501,77 18010597,02 18010597,02 18010290,14 +212 -0,004 162 12746137,36 16343108,16 17902411,24 13082255,08 18121656,7 13680893,49 18013606,34 18013606,34 18013606,34 18314474,76 18303574,93 13549742,86 10041473,98 2001511,869 10008003,89 10007114,33 13082255,08 18121603,69 18121603,69 18121277,62 +213 -0,004 163 12782770,25 16445674,69 18013606,34 13124139,01 18232643,81 13766804,5 18124801,44 18124801,44 18124801,44 18332327,29 18321306,94 13590731,19 10039623,18 1890316,771 10008003,89 10007114,33 13124139,01 18232587,59 18232587,59 18232240,02 +214 -0,004 164 12818595,94 16547767,6 18124801,44 13165133,46 18343604,06 13852186,99 18235996,54 18235996,54 18235996,54 18343130,34 18332035,86 13630658,36 10037762,47 1779121,673 10008003,89 10007114,33 13165133,46 18343544,2 18343544,2 18343172,36 +215 -0,004 165 12853598,2 16649343,36 18235996,54 13205218,32 18454531,69 13937015,52 18347191,64 18347191,64 18347191,64 18346746,91 18335627,4 13669500,95 10035892,44 1667926,576 10008003,89 10007114,33 13205218,32 18454467,68 18454467,68 18454068,21 +216 -0,004 166 12887760,9 16750353,28 18347191,64 13244373,51 18565419,24 14021263,43 18458386,73 18458386,73 18458386,73 18343130,34 18332035,86 13707235,68 10034013,63 1556731,479 10008003,89 10007114,33 13244373,51 18565350,42 18565350,42 18564919,21 +217 -0,004 167 12921068,04 16850742,74 18458386,73 13282579,02 18676256,73 14104902,83 18569581,83 18569581,83 18569581,83 18332327,29 18321306,94 13743839,43 10032126,64 1445536,383 10008003,89 10007114,33 13282579,02 18676182,31 18676182,31 18675714,21 +218 -0,004 168 12953503,77 16950450,35 18569581,83 13319814,89 18787030,62 14187904,53 18680776,92 18680776,92 18680776,92 18314474,76 18303574,93 13779289,24 10030232,03 1334341,287 10008003,89 10007114,33 13319814,89 18786949,58 18786949,58 18786438,06 +219 -0,004 169 12985052,4 17049406,92 18680776,92 13356061,3 18897721,96 14270237,92 18791972,02 18791972,02 18791972,02 18289791,67 18279054,5 13813562,43 10028330,38 1223146,193 10008003,89 10007114,33 13356061,3 18897632,99 18897632,99 18897069,63 +220 -0,004 170 13015698,44 17147534,3 18791972,02 13391298,55 19008303,55 14351871 18903167,11 18903167,11 18903167,11 18258566,08 18248028,35 13846636,57 10026422,27 1111951,1 10008003,89 10007114,33 13391298,55 19008204,91 19008204,91 19007578,5 +221 -0,004 171 13045426,57 17244743,98 18903167,11 13425507,13 19118734,76 14432770,19 19014362,2 19014362,2 19014362,2 18221139,76 18210832,23 13878489,61 10024508,28 1000756,009 10008003,89 10007114,33 13425507,13 19118624,06 19118624,06 19117919,34 +222 -0,004 172 13074221,76 17340935,46 19014362,2 13458667,71 19228952,21 14512900,37 19125557,29 19125557,29 19125557,29 18177891,82 18167839,04 13909099,85 10022588,99 889560,9199 10008003,89 10007114,33 13458667,71 19228826,09 19228826,09 19228021,46 +223 -0,004 173 13102069,18 17435994,45 19125557,29 13490761,21 19338851,37 14592224,73 19236752,38 19236752,38 19236752,38 18129222,96 18119443,37 13938446,06 10020664,99 778365,8347 10008003,89 10007114,33 13490761,21 19338704,85 19338704,85 19337768,45 +224 -0,004 174 13128954,32 17529790,6 19236752,38 13521768,84 19448247,09 14670704,74 19347947,46 19347947,46 19347947,46 18075541,49 18066047,9 13966507,48 10018736,86 667170,7548 10008003,89 10007114,33 13521768,84 19448072,4 19448072,4 19446954,48 +225 -0,004 175 13154862,96 17622175,04 19347947,46 13551672,1 19556778,75 14748300,05 19459142,53 19459142,53 19459142,53 18017251,7 18008051,93 13993263,94 10016805,2 555975,6833 10008003,89 10007114,33 13551672,1 19556562,81 19556562,81 19555179,85 +226 -0,004 176 13179781,2 17712977,44 19459142,53 13580452,85 19663644,97 14824968,44 19570337,59 19570337,59 19570337,59 17954745 17945842,54 14018695,84 10014870,58 444780,6267 10008003,89 10007114,33 13580452,85 19663363,52 19663363,52 19661561,29 +227 -0,004 177 13203695,51 17802002,69 19570337,59 13608093,33 19766687,15 14900665,73 19681532,61 19681532,61 19681532,61 17888393,51 17879788,3 14042784,25 10012933,6 333585,5998 10008003,89 10007114,33 13608093,33 19766289,23 19766289,23 19763746,69 +228 -0,004 178 13226592,72 17889027,19 19681532,61 13634576,2 19858182,8 14975345,73 19792727,56 19792727,56 19792727,56 17818545,99 17810235,12 14065510,97 10010994,85 222390,647 10008003,89 10007114,33 13634576,2 19857553,74 19857553,74 19853567,21 +229 -0,004 179 13248460,09 17973794,7 19792727,56 13659884,59 19904367,89 15048960,18 19903922,22 19903922,22 19903922,22 17745525,57 17737503,89 14086858,55 10009054,92 111195,9906 10008003,89 10007114,33 13659884,59 19903478,33 19903478,33 19897918,58 +230 -0,004 180 13269285,29 18056011,89 19903922,22 13684002,14 19858182,8 15121458,66 20014673,43 20014673,43 20014673,43 17669628,97 17661889,69 14106810,39 10007114,39 444,780401 10008003,89 10007114,33 13684002,14 19857553,74 19857553,74 19853567,21 +231 1 1 6616998,631 1802230,908 111195,1012 6199731,305 222356,3278 4737290,961 157249,6281 157249,6281 157249,6281 2502396,932 2510125,377 5780469,209 10120677,8 19857868,58 9896364,005 10118754,21 6199731,305 314499,2562 314499,2562 318454,5485 +232 2 2 6488454,864 1645089,172 248629,7051 6068688,46 351517,2925 4580630,66 314475,2987 314475,2987 314475,2987 2659604,169 2667324,155 5653200,605 10233795,92 19700642,91 9785168,904 10229949,31 6068688,46 471724,9241 471724,9241 475672,7783 +233 3 3 6360668,664 1488018,069 400863,2537 5938459,261 497016,924 4424038,172 471653,0288 471653,0288 471653,0288 2816767,439 2824480,271 5526991,391 10346912,9 19543465,18 9673973,802 10341144,41 5938459,261 628902,635 628902,635 632847,6364 +234 4 3 6250896,665 1414799,079 497198,7813 5829206,616 555595,928 4339320,116 555812,8141 555812,8141 555812,8141 2897403,955 2905335,234 5416910,521 10458091,05 19459305,4 9562778,701 10452339,51 5829206,616 711812,4839 711812,4839 716164,8262 +235 5 3 6141158,077 1346700,128 598699,0435 5720006,385 628519,155 4255623,327 648155,2615 648155,2615 648155,2615 2979874,321 2988007,303 5306864,158 10569269,15 19366962,95 9451583,6 10563534,61 5720006,385 801575,8867 801575,8867 806211,1301 +236 6 3 6031454,984 1284535,957 703130,9174 5610861,929 711388,9706 4173010,731 745646,4517 745646,4517 745646,4517 3064029,828 3072349,159 5196854,642 10680447,2 19269471,76 9340388,499 10674729,71 5610861,929 896135,6706 896135,6706 900971,1763 +237 7 3 5921789,615 1229207,467 809360,3904 5501776,866 801124,5902 4091549,448 846509,3133 846509,3133 846509,3133 3149734,757 3158226,375 5086884,512 10791625,19 19168608,9 9229193,398 10785924,81 5501776,866 994124,0676 994124,0676 999104,6074 +238 8 3 5812164,356 1181675,372 916762,7785 5392755,092 895664,7245 4011311,033 949670,1358 949670,1358 949670,1358 3236865,365 3245516,407 4976956,523 10902803,11 19065448,08 9117998,297 10897119,92 5392755,092 1094620,662 1094620,662 1099708,68 +239 9 3 5702581,769 1142912,926 1024969,424 5283800,812 993638,9046 3932371,725 1054454,664 1054454,664 1054454,664 3325308,904 3334107,606 4867073,675 11013980,94 18960663,55 9006803,195 11008315,02 5283800,812 1196993,839 1196993,839 1202163,244 +240 10 3 5593044,605 1113836,178 1133750,063 5174918,575 1094124,973 3854812,681 1160423,105 1160423,105 1160423,105 3414962,666 3423898,273 4757239,236 11125158,67 18854695,11 8895608,094 11119510,12 5174918,575 1300800,577 1300800,577 1306032,84 +241 11 3 5483555,826 1095216,903 1242953,991 5066113,305 1196490,187 3778720,21 1267278,48 1267278,48 1267278,48 3505733,09 3514795,767 4647456,778 11236336,3 18747839,73 8784412,993 11230705,22 5066113,305 1405723,286 1405723,286 1411004,967 +242 12 3 5374118,625 1087592,366 1352478,668 4957390,345 1300290,779 3704185,972 1374813,978 1374813,978 1374813,978 3597534,923 3606715,677 4537730,212 11347513,8 18640304,23 8673217,892 11341900,32 4957390,345 1511529,552 1511529,552 1516850,705 +243 13 3 5264736,453 1091193,08 1462252,013 4848755,506 1405208,661 3631307,165 1482881,62 1482881,62 1482881,62 3690290,45 3699581,05 4428063,829 11458691,18 18532236,59 8562022,791 11453095,42 4848755,506 1618046,014 1618046,014 1623399,147 +244 14 3 5155413,04 1105909,399 1572221,931 4740215,115 1511011,074 3560186,663 1591372,977 1591372,977 1591372,977 3783928,781 3793321,691 4318462,348 11569868,41 18423745,24 8450827,689 11564290,52 4740215,115 1725141,088 1725141,088 1730520,461 +245 15 3 5046152,432 1131307,589 1682349,864 4631776,076 1617524,417 3490933,107 1700206,915 1700206,915 1700206,915 3878385,202 3887873,517 4208930,972 11681045,48 18314911,3 8339632,588 11675485,62 4631776,076 1832713,303 1832713,303 1838114,452 +246 16 3 4936959,023 1166690,184 1792606,678 4523445,94 1724616,933 3423660,928 1809321,593 1809321,593 1809321,593 3973600,588 3983177,976 4099475,453 11792222,38 18205796,62 8228437,487 11786680,72 4523445,94 1940683,275 1940683,275 1946102,683 +247 17 3 4827837,591 1211182,39 1902969,963 4415232,982 1832187,025 3358490,286 1918669,09 1918669,09 1918669,09 4069520,868 4079181,515 3990102,162 11903399,1 18096449,12 8117242,386 11897875,83 4415232,982 2048988,087 2048988,087 2054422,946 +248 18 3 4718793,347 1263822,375 2013422,199 4307146,29 1940155,22 3295546,916 2028211,728 2028211,728 2028211,728 4166096,541 4175835,105 3880818,182 12014575,63 17986906,48 8006047,285 12009070,93 4307146,29 2157577,272 2157577,272 2163025,318 +249 19 3 4609831,983 1323638,289 2123949,499 4199195,866 2048458,528 3234961,844 2137919,488 2137919,488 2137919,488 4263282,24 4273093,809 3771631,402 12125751,94 17877198,72 7894852,184 12120266,03 4199195,866 2266409,916 2266409,916 2271869,299 +250 20 3 4500959,731 1389703,702 2234540,713 4091392,745 2157046,432 3176870,966 2247768,168 2247768,168 2247768,168 4361036,342 4370916,39 3662550,642 12236928,02 17767350,04 7783657,082 12231461,13 4091392,745 2375452,512 2375452,512 2380921,712 +251 21 3 4392183,425 1461171,02 2345186,789 3983749,133 2265877,973 3121414,466 2357738,048 2357738,048 2357738,048 4459320,612 4469264,968 3553585,789 12348103,85 17657380,16 7672461,981 12342656,23 3983749,133 2484677,376 2484677,376 2490155,131 +252 22 3 4283510,581 1537286,876 2455880,301 3876278,562 2374919,615 3068736,046 2467812,901 2467812,901 2467812,901 4558099,886 4568104,7 3444747,968 12459279,43 17547305,31 7561266,88 12453851,33 3876278,562 2594061,441 2594061,441 2599546,694 +253 23 3 4174949,484 1617394,942 2566615,1 3768996,075 2484143,649 3018981,966 2577979,255 2577979,255 2577979,255 4657341,785 4667403,5 3336049,733 12570454,73 17437138,96 7450071,779 12565046,43 3768996,075 2703585,341 2703585,341 2709077,2 +254 24 3 4066509,284 1700931,074 2677386,053 3661918,443 2593526,986 2972299,864 2688225,837 2688225,837 2688225,837 4757016,456 4767131,781 3227505,31 12681629,73 17326892,37 7338876,678 12676241,53 3661918,443 2813232,698 2813232,698 2818730,408 diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbNearestSearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbNearestSearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,26 @@ +#Index Latitude Longitude UseCoverageRadius MaxDistance ErrorCode Redefined MaxSearchResult SearchResult (Not used) Comment +1 59 18 0 1-254 All lm's in db +2 12 13 11 0 1,2,5,4 Low max distance +3 0 1 3334 0 No landmarks within range +4 55 18 1 300 0 14,16,15 Use of coverage radius +# +5 1 -1 1 1000 0 21,22,25 Use of coverage radius > distance +6 32 32 1 50 0 33,35 Use of overlapping coverage radius > distance +7 0 0 3000 0 Lm's in all diretions within 3km +8 0 0 1000 0 1 6,8,41-45 Redefined with less MaxDistance +# +9 0 0 3000 0 1 6,8,41-45 Redefined with greater MaxDistance +10 -15 -15 1500 0 +11 -15,1 -15 1 1500 0 Redefined with use coverage radius +# +12 52 13 0 10 Max Search result +13 -89 -90 5000 0 50 Max search Result > search result +14 0 180 0 +# +15 90 0 0 Nort pole +16 -90 0 0 South pole +17 55 18 0 +# +18 -1 -1 0 +19 -1 -1 1 500000 0 20 +20 -1,05 -1 0 1 19 diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbSearchResult.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/lmDbSearchResult.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,184 @@ +#TextCriteria Attributes (bitmask) PositionFields LmSearchResult (Id's) Redefined seach Comment +* 0X0021 1-105 Maka sure Pos. fields an id's are comma seperated with no extra space inbetween +* 0x0001 1-105 +* 0x0020 1-105 +? 0x0000 1-7,9-38,41,45 All field searched -> medialinks field will contain one character if any media link set. +? 0x0001 25,41 +? 0x0000 401 +? 0x0000 404,406 +? 0x0000 803 37 +Unique 0x0021 406 29-31 +Götet 0x0021 404 30 1 The search is performed on the previous result. +Several 0x0001 45 +MLFW 0x0021 401,404,406,408,409 8,10-15 +MLFW 0x0021 8,10,11,15 1 The search is performed on the previous result. +MLFW 0x0021 8,10,11,15 +adx 0x0021 401,404,406,408,409 +*oki* 0x0021 401,404,406,408,409 46-50,62-63 +Noki? 0x0021 401,404,406,408,409 48,49 +Nokia? 0x0021 401,404,406,408,409 +Nok* 0x0021 401,404,406,408,409 48-50,62-63 +*okia 0x0021 401,404,406,408,409 48,49 +# +# +# +# +x 0x0000 25-27 All attributes and fields is searched +q 0x0001 41 +enat?r 0x0001 18,19 +Daanmark 0x0000 401 29-41 +veg??ariskt 0x0001 4 +Text'1 0x0001 30 +Text'''1 0x0001 13 +Kalles* 0x0001 52 +Kalles Hundgård 0x0001 52 +kalles* 0x0001 52 Tests Symbian TR in TeamTrack INC043475 will fail until the TR is solved +kalles Hundgård 0x0001 52 Tests Symbian TR in TeamTrack INC043475 will fail until the TR is solved +# ENoAttribute = 0x0000 Country = 401 +# ELandmarkName= 0x0001 000001 City = 404 +# EPosition= 0x0002 000010 Street = 406 +# ECoverageRadius = 0x0004 000100 LocationName = 408 +# ECategoryInfo= 0x0008 001000 PostalCode = 409 +# EIcon= 0x0010 010000 MediaLinks = 800 +# EDescription= 0x0020 100000 MediaLinkStart = 801 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/testlm.ldb Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/testlm.ldb has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname.R01 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname.R01 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname.R06 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname.R06 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname_en.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname_en.loc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +//r: +//v: +//i:LOCALISATION_TARGET = s60,s90 +//i:Default Landmark database name, that can be displayed on UI. + +// LOCALISATION STRINGS +//b:-1 +//e:-1 +//f:EDialogLabelFont +//s: +//w: +//d:Display name of the default landmark database. +//l:list_single_pane_1 +// +#define qtn_poslm_default_database_display_name "TP105 Default Landmarks" + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname_sw.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp105_eposlmdefaultdbname_sw.loc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +//r: +//v: +//i:LOCALISATION_TARGET = s60,s90 +//i:Default Landmark database name, that can be displayed on UI. + +// LOCALISATION STRINGS +//b:-1 +//e:-1 +//f:EDialogLabelFont +//s: +//w: +//d:Display name of the default landmark database. +//l:list_single_pane_1 +// + +// Used for creating a localised swedish default name resource file, used +// in landmarktest TP105 +#define qtn_poslm_default_database_display_name "Mina små landmarks" + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp13_EPOSLMGLOBALCATEGORIES.R01 Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp13_EPOSLMGLOBALCATEGORIES.R01 has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp13_eposlmglobalcategoriesR01.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/databases/landmarks/tp13_eposlmglobalcategoriesR01.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include "EPos_LmCatLanguages.hrh" + +// RESOURCE DEFINITIONS + +// ----------------------------------------------------------------------------- +// +// POS_LM_CATEGORY_SPECIFICATION +// Global category specification. +// +// ----------------------------------------------------------------------------- +// + +RESOURCE POS_LM_CATEGORY_SPECIFICATION glcategories + { + icon_files = + { + }; + + categories = + { + POS_LM_CATEGORY_INFO + { + category_id = 3000; + category_name = "Accommodation"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 6000; + category_name = "Business"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 9000; + category_name = "Communication"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 12000; + category_name = "Educational institute"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 15000; + category_name = "Entertainment"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 18000; + category_name = "Food & Beverage"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 21000; + category_name = "Geographical Area"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 24000; + category_name = "Outdoor activities"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 27000; + category_name = "People"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 30000; + category_name = "Public service"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 33000; + category_name = "Religious places"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 36000; + category_name = "Shopping"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 39000; + category_name = "Sightseeing"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 42000; + category_name = "Sports"; + }, + POS_LM_CATEGORY_INFO + { + category_id = 45000; + category_name = "Transport"; + } + }; + } + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/eabi/LandMarksTestModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/eabi/LandMarksTestModuleu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,199 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI13CSearchResult @ 2 NONAME ; ## + _ZTI14CActiveLmEvent @ 3 NONAME ; ## + _ZTI15CRecognizerData @ 4 NONAME ; ## + _ZTI17CAreaSearchResult @ 5 NONAME ; ## + _ZTI17CSearchResultBase @ 6 NONAME ; ## + _ZTI18CActiveLmOperation @ 7 NONAME ; ## + _ZTI19CTP116ActiveLmEvent @ 8 NONAME ; ## + _ZTI19CTP117ActiveLmEvent @ 9 NONAME ; ## + _ZTI20CMatchIteratorTester @ 10 NONAME ; ## + _ZTI20CNearestSearchResult @ 11 NONAME ; ## + _ZTI21CCategorySearchResult @ 12 NONAME ; ## + _ZTI22CCompositeSearchResult @ 13 NONAME ; ## + _ZTI24CNearestSearchResultTp35 @ 14 NONAME ; ## + _ZTI26CLandmarkTestProcedureBase @ 15 NONAME ; ## + _ZTI29CCategoryLandmarkSearchResult @ 16 NONAME ; ## + _ZTI7CPosTp1 @ 17 NONAME ; ## + _ZTI7CPosTp3 @ 18 NONAME ; ## + _ZTI7CPosTp4 @ 19 NONAME ; ## + _ZTI7CPosTp5 @ 20 NONAME ; ## + _ZTI7CPosTp6 @ 21 NONAME ; ## + _ZTI7CPosTp7 @ 22 NONAME ; ## + _ZTI7CPosTp8 @ 23 NONAME ; ## + _ZTI7CPosTp9 @ 24 NONAME ; ## + _ZTI8CPosTp10 @ 25 NONAME ; ## + _ZTI8CPosTp11 @ 26 NONAME ; ## + _ZTI8CPosTp12 @ 27 NONAME ; ## + _ZTI8CPosTp13 @ 28 NONAME ; ## + _ZTI8CPosTp18 @ 29 NONAME ; ## + _ZTI8CPosTp19 @ 30 NONAME ; ## + _ZTI8CPosTp20 @ 31 NONAME ; ## + _ZTI8CPosTp21 @ 32 NONAME ; ## + _ZTI8CPosTp23 @ 33 NONAME ; ## + _ZTI8CPosTp24 @ 34 NONAME ; ## + _ZTI8CPosTp25 @ 35 NONAME ; ## + _ZTI8CPosTp26 @ 36 NONAME ; ## + _ZTI8CPosTp28 @ 37 NONAME ; ## + _ZTI8CPosTp35 @ 38 NONAME ; ## + _ZTI8CPosTp36 @ 39 NONAME ; ## + _ZTI8CPosTp37 @ 40 NONAME ; ## + _ZTI8CPosTp38 @ 41 NONAME ; ## + _ZTI8CPosTp42 @ 42 NONAME ; ## + _ZTI8CPosTp43 @ 43 NONAME ; ## + _ZTI8CPosTp44 @ 44 NONAME ; ## + _ZTI8CPosTp45 @ 45 NONAME ; ## + _ZTI8CPosTp47 @ 46 NONAME ; ## + _ZTI8CPosTp48 @ 47 NONAME ; ## + _ZTI8CPosTp51 @ 48 NONAME ; ## + _ZTI8CPosTp52 @ 49 NONAME ; ## + _ZTI9CPosTp100 @ 50 NONAME ; ## + _ZTI9CPosTp101 @ 51 NONAME ; ## + _ZTI9CPosTp102 @ 52 NONAME ; ## + _ZTI9CPosTp103 @ 53 NONAME ; ## + _ZTI9CPosTp104 @ 54 NONAME ; ## + _ZTI9CPosTp116 @ 55 NONAME ; ## + _ZTI9CPosTp117 @ 56 NONAME ; ## + _ZTI9CPosTp120 @ 57 NONAME ; ## + _ZTI9CPosTp121 @ 58 NONAME ; ## + _ZTI9CPosTp122 @ 59 NONAME ; ## + _ZTI9CPosTp123 @ 60 NONAME ; ## + _ZTI9CPosTp124 @ 61 NONAME ; ## + _ZTI9CPosTp125 @ 62 NONAME ; ## + _ZTI9CPosTp126 @ 63 NONAME ; ## + _ZTI9CPosTp130 @ 64 NONAME ; ## + _ZTI9CPosTp131 @ 65 NONAME ; ## + _ZTI9CPosTp132 @ 66 NONAME ; ## + _ZTI9CPosTp133 @ 67 NONAME ; ## + _ZTI9CPosTp134 @ 68 NONAME ; ## + _ZTI9CPosTp135 @ 69 NONAME ; ## + _ZTI9CPosTp136 @ 70 NONAME ; ## + _ZTI9CPosTp137 @ 71 NONAME ; ## + _ZTI9CPosTp141 @ 72 NONAME ; ## + _ZTIN26CLandmarkTestProcedureBase15COnTheFlyTesterE @ 73 NONAME ; ## + _ZTV13CSearchResult @ 74 NONAME ; ## + _ZTV14CActiveLmEvent @ 75 NONAME ; ## + _ZTV15CRecognizerData @ 76 NONAME ; ## + _ZTV17CAreaSearchResult @ 77 NONAME ; ## + _ZTV17CSearchResultBase @ 78 NONAME ; ## + _ZTV18CActiveLmOperation @ 79 NONAME ; ## + _ZTV19CTP116ActiveLmEvent @ 80 NONAME ; ## + _ZTV19CTP117ActiveLmEvent @ 81 NONAME ; ## + _ZTV20CMatchIteratorTester @ 82 NONAME ; ## + _ZTV20CNearestSearchResult @ 83 NONAME ; ## + _ZTV21CCategorySearchResult @ 84 NONAME ; ## + _ZTV22CCompositeSearchResult @ 85 NONAME ; ## + _ZTV24CNearestSearchResultTp35 @ 86 NONAME ; ## + _ZTV26CLandmarkTestProcedureBase @ 87 NONAME ; ## + _ZTV29CCategoryLandmarkSearchResult @ 88 NONAME ; ## + _ZTV7CPosTp1 @ 89 NONAME ; ## + _ZTV7CPosTp3 @ 90 NONAME ; ## + _ZTV7CPosTp4 @ 91 NONAME ; ## + _ZTV7CPosTp5 @ 92 NONAME ; ## + _ZTV7CPosTp6 @ 93 NONAME ; ## + _ZTV7CPosTp7 @ 94 NONAME ; ## + _ZTV7CPosTp8 @ 95 NONAME ; ## + _ZTV7CPosTp9 @ 96 NONAME ; ## + _ZTV8CPosTp10 @ 97 NONAME ; ## + _ZTV8CPosTp11 @ 98 NONAME ; ## + _ZTV8CPosTp12 @ 99 NONAME ; ## + _ZTV8CPosTp13 @ 100 NONAME ; ## + _ZTV8CPosTp18 @ 101 NONAME ; ## + _ZTV8CPosTp19 @ 102 NONAME ; ## + _ZTV8CPosTp20 @ 103 NONAME ; ## + _ZTV8CPosTp21 @ 104 NONAME ; ## + _ZTV8CPosTp23 @ 105 NONAME ; ## + _ZTV8CPosTp24 @ 106 NONAME ; ## + _ZTV8CPosTp25 @ 107 NONAME ; ## + _ZTV8CPosTp26 @ 108 NONAME ; ## + _ZTV8CPosTp28 @ 109 NONAME ; ## + _ZTV8CPosTp35 @ 110 NONAME ; ## + _ZTV8CPosTp36 @ 111 NONAME ; ## + _ZTV8CPosTp37 @ 112 NONAME ; ## + _ZTV8CPosTp38 @ 113 NONAME ; ## + _ZTV8CPosTp42 @ 114 NONAME ; ## + _ZTV8CPosTp43 @ 115 NONAME ; ## + _ZTV8CPosTp44 @ 116 NONAME ; ## + _ZTV8CPosTp45 @ 117 NONAME ; ## + _ZTV8CPosTp47 @ 118 NONAME ; ## + _ZTV8CPosTp48 @ 119 NONAME ; ## + _ZTV8CPosTp51 @ 120 NONAME ; ## + _ZTV8CPosTp52 @ 121 NONAME ; ## + _ZTV9CPosTp100 @ 122 NONAME ; ## + _ZTV9CPosTp101 @ 123 NONAME ; ## + _ZTV9CPosTp102 @ 124 NONAME ; ## + _ZTV9CPosTp103 @ 125 NONAME ; ## + _ZTV9CPosTp104 @ 126 NONAME ; ## + _ZTV9CPosTp116 @ 127 NONAME ; ## + _ZTV9CPosTp117 @ 128 NONAME ; ## + _ZTV9CPosTp120 @ 129 NONAME ; ## + _ZTV9CPosTp121 @ 130 NONAME ; ## + _ZTV9CPosTp122 @ 131 NONAME ; ## + _ZTV9CPosTp123 @ 132 NONAME ; ## + _ZTV9CPosTp124 @ 133 NONAME ; ## + _ZTV9CPosTp125 @ 134 NONAME ; ## + _ZTV9CPosTp126 @ 135 NONAME ; ## + _ZTV9CPosTp130 @ 136 NONAME ; ## + _ZTV9CPosTp131 @ 137 NONAME ; ## + _ZTV9CPosTp132 @ 138 NONAME ; ## + _ZTV9CPosTp133 @ 139 NONAME ; ## + _ZTV9CPosTp134 @ 140 NONAME ; ## + _ZTV9CPosTp135 @ 141 NONAME ; ## + _ZTV9CPosTp136 @ 142 NONAME ; ## + _ZTV9CPosTp137 @ 143 NONAME ; ## + _ZTV9CPosTp141 @ 144 NONAME ; ## + _ZTVN26CLandmarkTestProcedureBase15COnTheFlyTesterE @ 145 NONAME ; ## + _ZTI7CPosTp2 @ 146 NONAME + _ZTI9CPosTp106 @ 147 NONAME + _ZTI9CPosTp118 @ 148 NONAME + _ZTI9CPosTp119 @ 149 NONAME + _ZTI9CPosTp143 @ 150 NONAME + _ZTI9CPosTp144 @ 151 NONAME + _ZTI9CPosTp145 @ 152 NONAME + _ZTI9CPosTp146 @ 153 NONAME + _ZTI9CPosTp147 @ 154 NONAME + _ZTI9CPosTp148 @ 155 NONAME + _ZTI9CPosTp149 @ 156 NONAME + _ZTI9CPosTp150 @ 157 NONAME + _ZTI9CPosTp151 @ 158 NONAME + _ZTI9CPosTp152 @ 159 NONAME + _ZTI9CPosTp153 @ 160 NONAME + _ZTI9CPosTp154 @ 161 NONAME + _ZTI9CPosTp155 @ 162 NONAME + _ZTI9CPosTp156 @ 163 NONAME + _ZTI9CPosTp157 @ 164 NONAME + _ZTI9CPosTp158 @ 165 NONAME + _ZTI9CPosTp159 @ 166 NONAME + _ZTI9CPosTp160 @ 167 NONAME + _ZTI9CPosTp161 @ 168 NONAME + _ZTI9CPosTp162 @ 169 NONAME + _ZTI9CPosTp163 @ 170 NONAME + _ZTI9CPosTp164 @ 171 NONAME + _ZTV7CPosTp2 @ 172 NONAME + _ZTV9CPosTp106 @ 173 NONAME + _ZTV9CPosTp118 @ 174 NONAME + _ZTV9CPosTp119 @ 175 NONAME + _ZTV9CPosTp143 @ 176 NONAME + _ZTV9CPosTp144 @ 177 NONAME + _ZTV9CPosTp145 @ 178 NONAME + _ZTV9CPosTp146 @ 179 NONAME + _ZTV9CPosTp147 @ 180 NONAME + _ZTV9CPosTp148 @ 181 NONAME + _ZTV9CPosTp149 @ 182 NONAME + _ZTV9CPosTp150 @ 183 NONAME + _ZTV9CPosTp151 @ 184 NONAME + _ZTV9CPosTp152 @ 185 NONAME + _ZTV9CPosTp153 @ 186 NONAME + _ZTV9CPosTp154 @ 187 NONAME + _ZTV9CPosTp155 @ 188 NONAME + _ZTV9CPosTp156 @ 189 NONAME + _ZTV9CPosTp157 @ 190 NONAME + _ZTV9CPosTp158 @ 191 NONAME + _ZTV9CPosTp159 @ 192 NONAME + _ZTV9CPosTp160 @ 193 NONAME + _ZTV9CPosTp161 @ 194 NONAME + _ZTV9CPosTp162 @ 195 NONAME + _ZTV9CPosTp163 @ 196 NONAME + _ZTV9CPosTp164 @ 197 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/ABLD.BAT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/ABLD.BAT Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,31 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of the License "Symbian Foundation License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@ECHO OFF + +REM Bldmake-generated batch file - ABLD.BAT +REM ** DO NOT EDIT ** + +perl -S ABLD.PL "\work\mrt\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9 +if errorlevel==1 goto CheckPerl +goto End + +:CheckPerl +perl -v >NUL +if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed? +goto End + +:End diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandMarksTestModule.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandMarksTestModule.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + +#include + +TARGET LandMarksTestModule.dll +TARGETTYPE dll +UID 0x1000008D 0x101F4FF4 + +CAPABILITY ALL -TCB + + + +//TARGETPATH ?target_path +DEFFILE LandMarksTestModule.def + +SOURCEPATH ../src +SOURCE LandMarksTestModule.cpp +SOURCE LandMarksTestModuleBlocks.cpp + +//Sorce for the Tp5 +SOURCE FT_CLandmarkTestProcedureBase.cpp +SOURCE FT_CSearchResult.cpp +SOURCE FT_CAreaSearchResult.cpp +SOURCE FT_CCategorySearchResult.cpp +SOURCE FT_CCategoryLandmarkSearchResult.cpp +SOURCE FT_CSearchResultBase.cpp +SOURCE FT_CCompositeSearchResult.cpp +SOURCE FT_DatabaseUtility.cpp + +//Source for Testprocedures + +SOURCE FT_CPosTp1.cpp +SOURCE FT_CPosTp2.cpp +SOURCE FT_CPosTp3.cpp +SOURCE FT_CPosTp4.cpp +SOURCE FT_CPosTp5.cpp +SOURCE FT_CPosTp6.cpp +SOURCE FT_CPosTp7.cpp +SOURCE FT_CPosTp8.cpp +SOURCE FT_CPosTp9.cpp + +SOURCE FT_CPosTp10.cpp +SOURCE FT_CPosTp11.cpp +SOURCE FT_CPosTp12.cpp +SOURCE FT_CPosTp13.cpp +SOURCE FT_CPosTp18.cpp +SOURCE FT_CPosTp19.cpp + +SOURCE FT_CPosTp20.cpp +SOURCE FT_CPosTp21.cpp +SOURCE FT_CPosTp23.cpp +SOURCE FT_CPosTp24.cpp +SOURCE FT_CPosTp25.cpp +SOURCE FT_CPosTp26.cpp +SOURCE FT_CPosTp28.cpp + +SOURCE FT_CPosTp35.cpp +SOURCE FT_CPosTp36.cpp +SOURCE FT_CPosTp37.cpp +SOURCE FT_CPosTp38.cpp + +SOURCE FT_CPosTp42.cpp +SOURCE FT_CPosTp43.cpp +SOURCE FT_CPosTp44.cpp +SOURCE FT_CPosTp45.cpp +SOURCE FT_CPosTp47.cpp +SOURCE FT_CPosTp48.cpp + +SOURCE FT_CPosTp51.cpp +SOURCE FT_CPosTp52.cpp + +SOURCE FT_CPosTp100.cpp +SOURCE FT_CPosTp101.cpp +SOURCE FT_CPosTp102.cpp +SOURCE FT_CPosTp103.cpp +SOURCE FT_CPosTp104.cpp +SOURCE FT_CPosTp106.cpp + +SOURCE FT_CPosTp116.cpp +SOURCE FT_CPosTp117.cpp +SOURCE FT_CPosTp118.cpp +SOURCE FT_CPosTp119.cpp + +SOURCE FT_CPosTp120.cpp +SOURCE FT_CPosTp121.cpp +SOURCE FT_CPosTp122.cpp +SOURCE FT_CPosTp123.cpp +SOURCE FT_CPosTp124.cpp +SOURCE FT_CPosTp125.cpp +SOURCE FT_CPosTp126.cpp + +SOURCE FT_CPosTp130.cpp +SOURCE FT_CPosTp131.cpp +SOURCE FT_CPosTp132.cpp +SOURCE FT_CPosTp133.cpp +SOURCE FT_CPosTp134.cpp +SOURCE FT_CPosTp135.cpp +SOURCE FT_CPosTp136.cpp +SOURCE FT_CPosTp137.cpp +SOURCE FT_CPosTp139.cpp + +SOURCE FT_CPosTp141.cpp +SOURCE FT_CPosTp143.cpp + +SOURCE FT_CPosTp144.cpp +SOURCE FT_CPosTp145.cpp +SOURCE FT_CPosTp146.cpp +SOURCE FT_CPosTp147.cpp + +SOURCE FT_CPosTp148.cpp +SOURCE FT_CPosTp149.cpp +SOURCE FT_CPosTp150.cpp +SOURCE FT_CPosTp151.cpp +SOURCE FT_CPosTp152.cpp +SOURCE FT_CPosTp153.cpp +SOURCE FT_CPosTp154.cpp +SOURCE FT_CPosTp155.cpp +SOURCE FT_CPosTp156.cpp +SOURCE FT_CPosTp157.cpp +SOURCE FT_CPosTp158.cpp +SOURCE FT_CPosTp159.cpp +SOURCE FT_CPosTp160.cpp + +SOURCE FT_CPosTp161.cpp +SOURCE FT_CPosTp162.cpp +SOURCE FT_CPosTp163.cpp +SOURCE FT_CPosTp164.cpp +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /Epoc32/Include/ecom +SYSTEMINCLUDE /Epoc32/Include/xml + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib + +//Landmarks Lib +//Added for testing -- Start +LIBRARY edbms.lib + +//Added for testing -- End + +LIBRARY eposlandmarks.lib +LIBRARY Lbs.lib +LIBRARY eposlmdbmanlib.lib +LIBRARY eposlmsearchlib.lib +LIBRARY ws32.lib +LIBRARY eposlmmultidbsearch.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY estor.lib + +LIBRARY apmime.lib // CApaDataRecognizerType used in TP42 +LIBRARY apgrfx.lib // RApaLsSession used in TP42 + + +LIBRARY centralrepository.lib charconv.lib + + + +SMPSAFE + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandMarksTestModule_DoxyFile.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandMarksTestModule_DoxyFile.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,222 @@ +# Doxyfile 1.4.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = LandMarksTestModule +PROJECT_NUMBER = +OUTPUT_DIRECTORY = Z:\S60\stiftestframework\LandMarksTestModule\ +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = NO +GENERATE_TESTLIST = NO +GENERATE_BUGLIST = NO +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = Z:\S60\stiftestframework\LandMarksTestModule\ +FILE_PATTERNS = *.h \ + *.rh \ + *.hrh +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = NO +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = YES +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = YES +TOC_EXPAND = YES +DISABLE_INDEX = YES +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = YES +RTF_OUTPUT = Doc +COMPACT_RTF = YES +RTF_HYPERLINKS = YES +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = NONSHARABLE_CLASS +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.pkg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,440 @@ +; +; 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 the License "Symbian Foundation License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; +;; +; Installation file for t_locsysuiconsole application +; +;Languages +&EN +; +; UID is the app's UID +; +#{"Poison FT LandmarkTests"},(0x01ffff73),2,0,0,TYPE=SA +; +; Localised Vendor name +%{"Nokia-EN"} + +; Unique Vendor name +:"Nokia" +; +;#{"Poison FT LandmarkTests"},(0x01ffff73),1,0,0 +; Files to install and to where + +"\Epoc32\Release\ARMV5\urel\LandMarksTestModule.dll"-"!:\sys\bin\LandMarksTestModule.dll" +"..\conf\LandMarksTestModule1.cfg"-"C:\TestFramework\LandMarksTestModule1.cfg" +"..\init\TestFramework.ini"-"C:\Data\TestFramework.ini" +"..\Script\lmtm.bat"-"C:\lmtm.bat" + + +;This is the test provider, used in TP135 and TP116 +"\Epoc32\Release\ARMV5\urel\FT_lmservlib.dll"-"!:\sys\bin\FT_lmservlib.dll" +"\Epoc32\Release\ARMV5\urel\dbmanpluginstest.dll"-"!:\sys\bin\dbmanpluginstest.dll" +"\Epoc32\data\z\resource\plugins\dbmanpluginstest.RSC"-"!:\resource\plugins\dbmanpluginstest.RSC" + +;Files needed for Tp1 +"..\databases\landmarks\TP1Test.ldb"-"c:\system\test\TestData\TP1Test.ldb" + +;Files needed for Tp4 +"..\databases\landmarks\TP4Test.ldb"-"c:\system\test\TestData\TP4Test.ldb" + +;Files needed for Tp8 +"..\databases\landmarks\TP8Test.ldb"-"c:\system\test\TestData\TP8Test.ldb" + + +;Files needed for Tp10 +"..\databases\landmarks\TP10Test.ldb"-"c:\system\test\TestData\TP10Test.ldb" + + + +;Test data files +"..\databases\landmarks\eposlm.ldb"-"c:\system\test\TestData\eposlm.ldb" +"..\databases\landmarks\testlm.ldb"-"c:\system\test\TestData\testlm.ldb" +"..\databases\landmarks\landmarksDb.txt"-"c:\system\test\TestData\landmarksDb.txt" +"..\databases\landmarks\lmDbSearchResult.txt"-"c:\system\test\TestData\lmDbSearchResult.txt" +"..\databases\landmarks\lmDbAreaSearchResult.txt"-"c:\system\test\TestData\lmDbAreaSearchResult.txt" +"..\databases\landmarks\LmDbCategorySearchResult.txt"-"c:\system\test\TestData\LmDbCategorySearchResult.txt" +"..\databases\landmarks\LmDbCatLandmarkSearchResult.txt"-"c:\system\test\TestData\LmDbCatLandmarkSearchResult.txt" +"..\databases\landmarks\eposlmglobalcategories.r01"-"c:\system\test\TestData\eposlmglobalcategories.r01" +"..\databases\landmarks\eposlmglobalcategories.r02"-"c:\system\test\TestData\eposlmglobalcategories.r02" +"..\databases\landmarks\eposlmglobalcategories.r03"-"c:\system\test\TestData\eposlmglobalcategories.r03" +"..\databases\landmarks\SRVeposdamaged.ldb"-"c:\system\test\TestData\SRVeposdamaged.ldb" +"..\databases\landmarks\EPOSLMASYNCOPS.RSC"-"c:\system\test\TestData\EPOSLMASYNCOPS.RSC" +"..\databases\landmarks\SRVeposcontact.ldb"-"c:\system\test\TestData\SRVeposcontact.ldb" +"..\databases\landmarks\SRVepostext.ldb"-"c:\system\test\TestData\SRVepostext.ldb" +"..\databases\landmarks\eposEmpty.ldb"-"c:\system\test\TestData\eposEmpty.ldb" +"..\databases\landmarks\lmDbNearestSearchResult.txt"-"c:\system\test\TestData\lmDbNearestSearchResult.txt" +"..\databases\landmarks\lmDbNearestSearch.txt"-"c:\system\test\TestData\lmDbNearestSearch.txt" +"..\databases\landmarks\eposlmnearestsearch.ldb"-"c:\system\test\TestData\eposlmnearestsearch.ldb" +"..\databases\landmarks\lmDbCompositeSearchResult.txt"-"c:\system\test\TestData\lmDbCompositeSearchResult.txt" +"..\databases\landmarks\compositeeposlm.ldb"-"c:\system\test\TestData\compositeeposlm.ldb" +"..\databases\landmarks\LmRecognizerData.txt"-"c:\system\test\TestData\LmRecognizerData.txt" +"..\databases\landmarks\LmRecognizerDataFile.txt"-"c:\system\test\TestData\LmRecognizerDataFile.txt" +"..\databases\landmarks\eposlm_1000_LMs.ldb"-"c:\system\test\TestData\eposlm_1000_LMs.ldb" +"..\databases\landmarks\eposlm_5000_LMs.ldb"-"c:\system\test\TestData\eposlm_5000_LMs.ldb" +"..\databases\landmarks\eposlmintservices_198KB.rsc"-"c:\system\test\TestData\eposlmintservices_198KB.rsc" +"..\databases\landmarks\eposlmintservices_453KB.rsc"-"c:\system\test\TestData\eposlmintservices_453KB.rsc" + +;Files needed in TP13 +;"..\databases\landmarks\TP13_EPOSLMGLOBALCATEGORIES.R06"-"c:\system\test\TestData\TP13_EPOSLMGLOBALCATEGORIES.R06" +;"..\databases\landmarks\TP13_EPOSLMGLOBALCATEGORIES.R01"-"c:\system\test\TestData\TP13_EPOSLMGLOBALCATEGORIES.R01" +"..\databases\landmarks\eposlm_tp13.ldb"-"c:\system\test\TestData\eposlm_tp13.ldb" + +;Files needed in Tp25 +"..\databases\landmarks\TP25Test.ldb"-"c:\system\test\TestData\TP25Test.ldb" +;Files needed in Tp28 +"..\databases\landmarks\Tp28Test.ldb"-"c:\system\test\TestData\Tp28Test.ldb" + +;Files needed in Tp131 +"..\databases\landmarks\TP131Test.ldb"-"c:\system\test\TestData\TP131Test.ldb" +;Files needed for Tp116 +"..\databases\landmarks\TP116Test.ldb"-"c:\system\test\TestData\TP116Test.ldb" + + +;Correct trace file +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP47Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP47Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP148Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP148Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP149Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP149Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP150Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP150Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP151Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP151Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP152Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP152Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP153Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP153Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP154Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP154Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP155Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP155Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP156Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP156Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP157Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP157Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP158Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP158Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP159Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP159Trace.txt" +"..\databases\landmarks\XML_Files\CorrectFileFor_LandmarksTP160Trace.txt"-"c:\system\test\TestData\CorrectFileFor_LandmarksTP160Trace.txt" + +;XML files needed in TP47 +"..\databases\landmarks\XML_Files\Tp47Data_With_MIME_Name.xml"-"c:\system\test\TestData\Tp47Data_With_MIME_Name.xml" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField3.xml"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField3.xml" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField2.xml"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField2.xml" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField1.xml"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField1.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataTagInTag1.xml"-"c:\system\test\TestData\Tp47ErronousXMLDataTagInTag1.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLFileEmptyCollection.xml"-"c:\system\test\TestData\Tp47ErronousXMLFileEmptyCollection.xml" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongLatitudeField.xml"-"c:\system\test\TestData\Tp47XMLWithLongLatitudeField.xml" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongName.xml"-"c:\system\test\TestData\Tp47XMLWithLongName.xml" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongCategoryName.xml"-"c:\system\test\TestData\Tp47XMLWithLongCategoryName.xml" +"..\databases\landmarks\XML_Files\TP47_UTF-8.xml"-"c:\system\test\TestData\TP47_UTF-8.xml" +"..\databases\landmarks\XML_Files\TP47_UTF-16-bigEndian.xml"-"c:\system\test\TestData\TP47_UTF-16-bigEndian.xml" +"..\databases\landmarks\XML_Files\TP47_UTF-16-littleEndian.xml"-"c:\system\test\TestData\TP47_UTF-16-littleEndian.xml" +"..\databases\landmarks\XML_Files\TP47_UTF-Chinese.xml"-"c:\system\test\TestData\TP47_UTF-Chinese.xml" +"..\databases\landmarks\XML_Files\Tp47DataUTF8.xml"-"c:\system\test\TestData\Tp47DataUTF8.xml" +"..\databases\landmarks\XML_Files\Tp47DataUTF16.xml"-"c:\system\test\TestData\Tp47DataUTF16.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousFileNoXML2.xml"-"c:\system\test\TestData\Tp47ErronousFileNoXML2.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousFileNoXML1.xml"-"c:\system\test\TestData\Tp47ErronousFileNoXML1.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataUnclosedTag2.xml"-"c:\system\test\TestData\Tp47ErronousXMLDataUnclosedTag2.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataUnclosedTag1.xml"-"c:\system\test\TestData\Tp47ErronousXMLDataUnclosedTag1.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataRepeatedTag.xml"-"c:\system\test\TestData\Tp47ErronousXMLDataRepeatedTag.xml" +"..\databases\landmarks\XML_Files\Tp47Mall.xml"-"c:\system\test\TestData\Tp47Mall.xml" +"..\databases\landmarks\XML_Files\Tp47XMLDataTestInput1.xml"-"c:\system\test\TestData\Tp47XMLDataTestInput1.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLNoEndTag2.xml"-"c:\system\test\TestData\Tp47ErrounousXMLNoEndTag2.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLNoEndTag1.xml"-"c:\system\test\TestData\Tp47ErrounousXMLNoEndTag1.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataWrongOrder3.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataWrongOrder3.xml" +"..\databases\landmarks\XML_Files\Tp47UnknownTags.xml"-"c:\system\test\TestData\Tp47UnknownTags.xml" +"..\databases\landmarks\XML_Files\Tp47UnknownTrees.xml"-"c:\system\test\TestData\Tp47UnknownTrees.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataWrongOrder2.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataWrongOrder2.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields3.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields3.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataWrongOrder1.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataWrongOrder1.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields2.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields2.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields1.xml"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields1.xml" +"..\databases\landmarks\XML_Files\Tp47SeveralLandmarkCollection.xml"-"c:\system\test\TestData\Tp47SeveralLandmarkCollection.xml" +"..\databases\landmarks\XML_Files\Tp47SeveralLandmark.xml"-"c:\system\test\TestData\Tp47SeveralLandmark.xml" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLData.xml"-"c:\system\test\TestData\Tp47ErrounousXMLData.xml" +;"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataMissingLMPrefix.xml"-"c:\system\test\TestData\Tp47ErronousXMLDataMissingLMPrefix.xml" +"..\databases\landmarks\XML_Files\Tp47EmptyMediaLink.xml"-"c:\system\test\TestData\Tp47EmptyMediaLink.xml" +"..\databases\landmarks\XML_Files\Tp47EmptyCoordinates.xml"-"c:\system\test\TestData\Tp47EmptyCoordinates.xml" +"..\databases\landmarks\XML_Files\Tp47EmptyAdresseInfo.xml"-"c:\system\test\TestData\Tp47EmptyAdresseInfo.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag1.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag1.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag2.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag2.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag3.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag3.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag4.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag4.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag5.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag5.xml" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag6.xml"-"c:\system\test\TestData\Tp47ErronousTextInTag6.xml" + +"..\databases\landmarks\XML_Files\Tp47Data_With_MIME_Name.gpx"-"c:\system\test\TestData\Tp47Data_With_MIME_Name.gpx" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField3.gpx"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField3.gpx" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField2.gpx"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField2.gpx" +"..\databases\landmarks\XML_Files\Tp47UsingXMLTagAsDataField1.gpx"-"c:\system\test\TestData\Tp47UsingXMLTagAsDataField1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataTagInTag1.gpx"-"c:\system\test\TestData\Tp47ErronousXMLDataTagInTag1.gpx" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongLatitudeField.gpx"-"c:\system\test\TestData\Tp47XMLWithLongLatitudeField.gpx" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongName.gpx"-"c:\system\test\TestData\Tp47XMLWithLongName.gpx" +"..\databases\landmarks\XML_Files\Tp47XMLWithLongCategoryName.gpx"-"c:\system\test\TestData\Tp47XMLWithLongCategoryName.gpx" +"..\databases\landmarks\XML_Files\TP47_UTF-8.gpx"-"c:\system\test\TestData\TP47_UTF-8.gpx" +"..\databases\landmarks\XML_Files\TP47_UTF-16-bigEndian.gpx"-"c:\system\test\TestData\TP47_UTF-16-bigEndian.gpx" +"..\databases\landmarks\XML_Files\TP47_UTF-16-littleEndian.gpx"-"c:\system\test\TestData\TP47_UTF-16-littleEndian.gpx" +"..\databases\landmarks\XML_Files\TP47_UTF-Chinese.gpx"-"c:\system\test\TestData\TP47_UTF-Chinese.gpx" +"..\databases\landmarks\XML_Files\Tp47DataUTF8.gpx"-"c:\system\test\TestData\Tp47DataUTF8.gpx" +"..\databases\landmarks\XML_Files\Tp47DataUTF16.gpx"-"c:\system\test\TestData\Tp47DataUTF16.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousFileNoXML2.gpx"-"c:\system\test\TestData\Tp47ErronousFileNoXML2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousFileNoXML1.gpx"-"c:\system\test\TestData\Tp47ErronousFileNoXML1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataUnclosedTag2.gpx"-"c:\system\test\TestData\Tp47ErronousXMLDataUnclosedTag2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataUnclosedTag1.gpx"-"c:\system\test\TestData\Tp47ErronousXMLDataUnclosedTag1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousXMLDataRepeatedTag.gpx"-"c:\system\test\TestData\Tp47ErronousXMLDataRepeatedTag.gpx" +"..\databases\landmarks\XML_Files\Tp47Mall.gpx"-"c:\system\test\TestData\Tp47Mall.gpx" +"..\databases\landmarks\XML_Files\Tp47XMLDataTestInput1.gpx"-"c:\system\test\TestData\Tp47XMLDataTestInput1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLNoEndTag2.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLNoEndTag2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLNoEndTag1.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLNoEndTag1.gpx" +"..\databases\landmarks\XML_Files\Tp47UnknownTags.gpx"-"c:\system\test\TestData\Tp47UnknownTags.gpx" +"..\databases\landmarks\XML_Files\Tp47UnknownTrees.gpx"-"c:\system\test\TestData\Tp47UnknownTrees.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataWrongOrder2.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLDataWrongOrder2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields3.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields3.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataWrongOrder1.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLDataWrongOrder1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields2.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLDataMissingFields1.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLDataMissingFields1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErrounousXMLData.gpx"-"c:\system\test\TestData\Tp47ErrounousXMLData.gpx" +"..\databases\landmarks\XML_Files\Tp47EmptyMediaLink.gpx"-"c:\system\test\TestData\Tp47EmptyMediaLink.gpx" +"..\databases\landmarks\XML_Files\Tp47EmptyCoordinates.gpx"-"c:\system\test\TestData\Tp47EmptyCoordinates.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag1.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag1.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag2.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag2.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag3.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag3.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag4.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag4.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag5.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag5.gpx" +"..\databases\landmarks\XML_Files\Tp47ErronousTextInTag6.gpx"-"c:\system\test\TestData\Tp47ErronousTextInTag6.gpx" + +;KML files needed in TP47 +"..\databases\landmarks\XML_Files\Tp47KML.kml"-"c:\system\test\TestData\Tp47KML.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile1.kml"-"c:\system\test\TestData\Tp47KMLfile1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile2.kml"-"c:\system\test\TestData\Tp47KMLfile2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile3.kml"-"c:\system\test\TestData\Tp47KMLfile3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile4.kml"-"c:\system\test\TestData\Tp47KMLfile4.kml" +"..\databases\landmarks\XML_Files\Tp47KMLlongName.kml"-"c:\system\test\TestData\Tp47KMLlongName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLNameCaps.kml"-"c:\system\test\TestData\Tp47KMLNameCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousNameTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousNameTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousNameTagPosition1.kml"-"c:\system\test\TestData\Tp47KMLErroneousNameTagPosition1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousNameTagPosition2.kml"-"c:\system\test\TestData\Tp47KMLErroneousNameTagPosition2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyName.kml"-"c:\system\test\TestData\Tp47KMLEmptyName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingNameTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingNameTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingNameTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingNameTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLNameWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLNameWithSpecialCharacters1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLNameWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLNameWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyPhoneNumber.kml"-"c:\system\test\TestData\Tp47KMLEmptyPhoneNumber.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousPhoneNumberTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousPhoneNumberTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousPhoneNumberTagPosition.kml"-"c:\system\test\TestData\Tp47KMLErroneousPhoneNumberTagPosition.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongPhoneNumer.kml"-"c:\system\test\TestData\Tp47KMLLongPhoneNumer.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPhoneTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingPhoneTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPhoneTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingPhoneTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPhoneNumberCaps.kml"-"c:\system\test\TestData\Tp47KMLPhoneNumberCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPhoneNumberWithText.kml"-"c:\system\test\TestData\Tp47KMLPhoneNumberWithText.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPhoneNumberWithText.kml"-"c:\system\test\TestData\Tp47KMLPhoneNumberWithText.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPhoneNumberWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLPhoneNumberWithSpecialCharacters1.kml" + +"..\databases\landmarks\XML_Files\Tp47KMLPhoneNumberWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLPhoneNumberWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyPoint.kml"-"c:\system\test\TestData\Tp47KMLEmptyPoint.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousPointTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousPointTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousPointTagPosition.kml"-"c:\system\test\TestData\Tp47KMLErroneousPointTagPosition.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPointTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingPointTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPointTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingPointTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPointCaps.kml"-"c:\system\test\TestData\Tp47KMLPointCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPointCaps.kml"-"c:\system\test\TestData\Tp47KMLPointCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPointTag1.kml"-"c:\system\test\TestData\Tp47KMLPointTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPointTag2.kml"-"c:\system\test\TestData\Tp47KMLPointTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPointTag3.kml"-"c:\system\test\TestData\Tp47KMLPointTag3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyDescription.kml"-"c:\system\test\TestData\Tp47KMLEmptyDescription.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDescriptionWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLDescriptionWithSpecialCharacters1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDescriptionWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLDescriptionWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDescriptionCaps.kml"-"c:\system\test\TestData\Tp47KMLDescriptionCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongDescription.kml"-"c:\system\test\TestData\Tp47KMLLongDescription.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousDescriptionTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousDescriptionTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousDescriptionTagposition.kml"-"c:\system\test\TestData\Tp47KMLErroneousDescriptionTagposition.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingDescriptionTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingDescriptionTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingDescriptionTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingDescriptionTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDescriptionWithCDATA.kml"-"c:\system\test\TestData\Tp47KMLDescriptionWithCDATA.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousFolderTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousFolderTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLFolderCaps.kml"-"c:\system\test\TestData\Tp47KMLFolderCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingFolderTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingFolderTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingFolderTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingFolderTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyFolderName.kml"-"c:\system\test\TestData\Tp47KMLEmptyFolderName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongFolderName.kml"-"c:\system\test\TestData\Tp47KMLLongFolderName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLFolderNameWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLFolderNameWithSpecialCharacters1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLFolderNameWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLFolderNameWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDocumentNameWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLDocumentNameWithSpecialCharacters1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDocumentNameWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLDocumentNameWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyDocumentName.kml"-"c:\system\test\TestData\Tp47KMLEmptyDocumentName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongDocumentName.kml"-"c:\system\test\TestData\Tp47KMLLongDocumentName.kml" +"..\databases\landmarks\XML_Files\Tp47KMLDocumentCaps.kml"-"c:\system\test\TestData\Tp47KMLDocumentCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousDocumentTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousDocumentTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingDocumentTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingDocumentTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingDocumentTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingDocumentTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLAddressCaps.kml"-"c:\system\test\TestData\Tp47KMLAddressCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLAddressWithSpecialCharacters1.kml"-"c:\system\test\TestData\Tp47KMLAddressWithSpecialCharacters1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLAddressWithSpecialCharacters2.kml"-"c:\system\test\TestData\Tp47KMLAddressWithSpecialCharacters2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyAddress1.kml"-"c:\system\test\TestData\Tp47KMLEmptyAddress1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyAddress2.kml"-"c:\system\test\TestData\Tp47KMLEmptyAddress2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongAddress1.kml"-"c:\system\test\TestData\Tp47KMLLongAddress1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongAddress2.kml"-"c:\system\test\TestData\Tp47KMLLongAddress2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongAddress3.kml"-"c:\system\test\TestData\Tp47KMLLongAddress3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousAddressTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousAddressTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousAddressTagPosition.kml"-"c:\system\test\TestData\Tp47KMLErroneousAddressTagPosition.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingAddressTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingAddressTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingAddressTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingAddressTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinateCaps.kml"-"c:\system\test\TestData\Tp47KMLCoordinateCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMoreCoordinates.kml"-"c:\system\test\TestData\Tp47KMLMoreCoordinates.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinateTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinateTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinateTagPosition.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinateTagPosition.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates1.kml"-"c:\system\test\TestData\Tp47KMLCoordinates1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates2.kml"-"c:\system\test\TestData\Tp47KMLCoordinates2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates3.kml"-"c:\system\test\TestData\Tp47KMLCoordinates3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates4.kml"-"c:\system\test\TestData\Tp47KMLCoordinates4.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates5.kml"-"c:\system\test\TestData\Tp47KMLCoordinates5.kml" +"..\databases\landmarks\XML_Files\Tp47KMLCoordinates6.kml"-"c:\system\test\TestData\Tp47KMLCoordinates6.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongCoordinates1.kml"-"c:\system\test\TestData\Tp47KMLLongCoordinates1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLLongCoordinates2.kml"-"c:\system\test\TestData\Tp47KMLLongCoordinates2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingCoordinateTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingCoordinateTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingCoordinateTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingCoordinateTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates1.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates2.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates3.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates4.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates4.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates5.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates5.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates6.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates6.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyCoordinates7.kml"-"c:\system\test\TestData\Tp47KMLEmptyCoordinates7.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinates1.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinates1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinates2.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinates2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinates3.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinates3.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinates4.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinates4.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousCoordinates5.kml"-"c:\system\test\TestData\Tp47KMLErroneousCoordinates5.kml" +"..\databases\landmarks\XML_Files\Tp47KMLNegativeCoordinates.kml"-"c:\system\test\TestData\Tp47KMLNegativeCoordinates.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousTextWithinPlacemark.kml"-"c:\system\test\TestData\Tp47KMLErroneousTextWithinPlacemark.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyfile1.kml"-"c:\system\test\TestData\Tp47KMLEmptyfile1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyfile2.kml"-"c:\system\test\TestData\Tp47KMLEmptyfile2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLInvalidfile.kml"-"c:\system\test\TestData\Tp47KMLInvalidfile.kml" +"..\databases\landmarks\XML_Files\Tp47KMLPlacemarkCaps.kml"-"c:\system\test\TestData\Tp47KMLPlacemarkCaps.kml" +"..\databases\landmarks\XML_Files\Tp47KMLErroneousPlacemarkTag.kml"-"c:\system\test\TestData\Tp47KMLErroneousPlacemarkTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPlacemarkTag1.kml"-"c:\system\test\TestData\Tp47KMLMissingPlacemarkTag1.kml" +"..\databases\landmarks\XML_Files\Tp47KMLMissingPlacemarkTag2.kml"-"c:\system\test\TestData\Tp47KMLMissingPlacemarkTag2.kml" +"..\databases\landmarks\XML_Files\Tp47KMLEmptyPlacemarkTag.kml"-"c:\system\test\TestData\Tp47KMLEmptyPlacemarkTag.kml" +"..\databases\landmarks\XML_Files\Tp47KMLGandhi Museum.kml"-"c:\system\test\TestData\Tp47KMLGandhi Museum.kml" +"..\databases\landmarks\XML_Files\Tp47KMLhilton hotels near new york (1 - 10).kml"-"c:\system\test\TestData\Tp47KMLhilton hotels near new york (1 - 10).kml" +"..\databases\landmarks\XML_Files\Tp47KMLIndus Heritage Centre, India.kml"-"c:\system\test\TestData\Tp47KMLIndus Heritage Centre, India.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile5.kml"-"c:\system\test\TestData\Tp47KMLfile5.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile6.kml"-"c:\system\test\TestData\Tp47KMLfile6.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile7.kml"-"c:\system\test\TestData\Tp47KMLfile7.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile8.kml"-"c:\system\test\TestData\Tp47KMLfile8.kml" +"..\databases\landmarks\XML_Files\Tp47KMLfile9.kml"-"c:\system\test\TestData\Tp47KMLfile9.kml" + +;KMZ test files +"..\databases\landmarks\XML_Files\Tp148KMZFile.kmz"-"c:\system\test\TestData\Tp148KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp149KMZFile.kmz"-"c:\system\test\TestData\Tp149KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp150KMZFile.kmz"-"c:\system\test\TestData\Tp150KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp151KMZFile.kmz"-"c:\system\test\TestData\Tp151KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp152KMZFile.kmz"-"c:\system\test\TestData\Tp152KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp153KMZFile.kmz"-"c:\system\test\TestData\Tp153KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp154KMZFile.kmz"-"c:\system\test\TestData\Tp154KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp155KMZFile.kmz"-"c:\system\test\TestData\Tp155KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp156KMZFile.kmz"-"c:\system\test\TestData\Tp156KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp157KMZFile.kmz"-"c:\system\test\TestData\Tp157KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp158KMZFile.kmz"-"c:\system\test\TestData\Tp158KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp159KMZFile.kmz"-"c:\system\test\TestData\Tp159KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp160KMZFile.kmz"-"c:\system\test\TestData\Tp160KMZFile.kmz" +"..\databases\landmarks\XML_Files\Tp163KMZ.kmz"-"c:\system\test\TestData\Tp163KMZ.kmz" +"..\databases\landmarks\XML_Files\Tp164KMZ.kmz"-"c:\system\test\TestData\Tp164KMZ.kmz" + +;KML test files +"..\databases\landmarks\XML_Files\Tp161KML.kml"-"c:\system\test\TestData\Tp161KML.kml" +"..\databases\landmarks\XML_Files\Tp162KML.kml"-"c:\system\test\TestData\Tp162KML.kml" + +;XML files needed in TP43 +"..\databases\landmarks\XML_Files\Tp43EncodeOutput_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutput_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputIncMode_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputIncMode_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputCollectionData1_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputCollectionData1_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputCollectionData2_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputCollectionData2_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputEmptyCollectionData_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputEmptyCollectionData_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputEmptyCollectionData2_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputEmptyCollectionData2_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputLongCollectionField_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputLongCollectionField_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputErrorScenario4_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputErrorScenario4_Correct.xml" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputErrorScenario5_Correct.xml"-"c:\system\test\TestData\Tp43EncodeOutputErrorScenario5_Correct.xml" + +"..\databases\landmarks\XML_Files\Tp43EncodeOutput_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutput_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputIncMode_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputIncMode_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputCollectionData1_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputCollectionData1_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputCollectionData2_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputCollectionData2_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputEmptyCollectionData_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputEmptyCollectionData_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputEmptyCollectionData2_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputEmptyCollectionData2_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputLongCollectionField_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputLongCollectionField_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputErrorScenario4_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputErrorScenario4_Correct.gpx" +"..\databases\landmarks\XML_Files\Tp43EncodeOutputErrorScenario5_Correct.gpx"-"c:\system\test\TestData\Tp43EncodeOutputErrorScenario5_Correct.gpx" + +;XML files needed in TP52 +"..\databases\landmarks\XML_Files\Tp52QuotedXMLTag1.xml"-"c:\system\test\TestData\Tp52QuotedXMLTag1.xml" +"..\databases\landmarks\XML_Files\Tp52QuotedXMLTag1.gpx"-"c:\system\test\TestData\Tp52QuotedXMLTag1.gpx" + +;XML files needed in TP45 +"..\databases\landmarks\XML_Files\TP45-DefOptions.xml"-"c:\system\test\TestData\TP45-DefOptions.xml" +"..\databases\landmarks\XML_Files\TP45-IncCategories.xml"-"c:\system\test\TestData\TP45-IncCategories.xml" +"..\databases\landmarks\XML_Files\TP45-ExcCategories.xml"-"c:\system\test\TestData\TP45-ExcCategories.xml" +"..\databases\landmarks\XML_Files\TP45-OneLandmark.xml"-"c:\system\test\TestData\TP45-OneLandmark.xml" +"..\databases\landmarks\XML_Files\TP45-TwoLandmarks.xml"-"c:\system\test\TestData\TP45-TwoLandmarks.xml" +"..\databases\landmarks\XML_Files\TP45-TwoLandmarksWithCollData.xml"-"c:\system\test\TestData\TP45-TwoLandmarksWithCollData.xml" + +;XML file with all the landmarks in the generated datanase +"..\databases\landmarks\XML_Files\AllGeneratedLandmarks.xml"-"c:\system\test\TestData\AllGeneratedLandmarks.xml" + +;XML file with needed by TP53 +"..\databases\landmarks\XML_Files\TP53-CategoriesNotInDb.xml"-"c:\system\test\TestData\TP53-CategoriesNotInDb.xml" +"..\databases\landmarks\XML_Files\TP53-OneLandmark.xml"-"c:\system\test\TestData\TP53-OneLandmark.xml" +"..\databases\landmarks\XML_Files\TP53-Categories.xml"-"c:\system\test\TestData\TP53-Categories.xml" +"..\databases\landmarks\XML_Files\TP53-Category.xml"-"c:\system\test\TestData\TP53-Category.xml" +"..\databases\landmarks\XML_Files\TP53-GlobalCategory.xml"-"c:\system\test\TestData\TP53-GlobalCategory.xml" +"..\databases\landmarks\XML_Files\TP53-LandmarksOneCategory.xml"-"c:\system\test\TestData\TP53-LandmarksOneCategory.xml" +"..\databases\landmarks\XML_Files\TP53-LandmarkCategories.xml"-"c:\system\test\TestData\TP53-LandmarkCategories.xml" +"..\databases\landmarks\XML_Files\TP53-LandmarksCategories.xml"-"c:\system\test\TestData\TP53-LandmarksCategories.xml" +"..\databases\landmarks\XML_Files\TP53-Compact.xml"-"c:\system\test\TestData\TP53-Compact.xml" + +;XML files needed in TP49 +"..\databases\landmarks\XML_Files\Tp49ImportInput.xml"-"c:\system\test\TestData\Tp49ImportInput.xml" +"..\databases\landmarks\XML_Files\Tp49ImportInputSyntaxError.xml"-"c:\system\test\TestData\Tp49ImportInputSyntaxError.xml" + +;XML files needed in TP55 +"..\databases\landmarks\XML_Files\TP55-DiskFullDuringExportImport.xml"-"c:\system\test\TestData\TP55-DiskFullDuringExportImport.xml" + +;XML files needed in TP56 +"..\databases\landmarks\XML_Files\TP56-LandmarksFromThreeDatabases.xml"-"c:\system\test\TestData\TP56-LandmarksFromThreeDatabases.xml" + +;XML files needed in TP76 +"..\databases\landmarks\corrupt_EPOSLMGLOBALCATEGORIES.R06"-"c:\system\test\TestData\corrupt_EPOSLMGLOBALCATEGORIES.R06" + +;Invalid database file needed in TP118 +"..\databases\landmarks\TP118HALFLMDB_2.LDB"-"c:\system\test\TestData\TP118HALFLMDB_2.LDB" + +;File used in TP100 +"..\databases\landmarks\XML_Files\TP100-LandmarksFromThreeDatabases.xml"-"c:\system\test\TestData\TP100-LandmarksFromThreeDatabases.xml" + +;File used in TP80 +;"..\databases\landmarks\01234567890123456789012345678901234567890123456789012345678901234567890123456789_COMPOSITEEPOSLM.LDB"-"c:\system\test\TestData\01234567890123456789012345678901234567890123456789012345678901234567890123456789_COMPOSITEEPOSLM.LDB" + +;File used in TP105 +"..\databases\landmarks\tp105_eposlmdefaultdbname.R06"-"c:\system\test\TestData\tp105_eposlmdefaultdbname.R06" +"..\databases\landmarks\tp105_eposlmdefaultdbname.R01"-"c:\system\test\TestData\tp105_eposlmdefaultdbname.R01" + +; Databases used for multi searching +"..\databases\landmarks\EPOSLM_020.LDB"-"c:\system\test\testdata\EPOSLM_020.LDB" +"..\databases\landmarks\EPOSLM_040.LDB"-"c:\system\test\testdata\EPOSLM_040.LDB" +"..\databases\landmarks\EPOSLM_060.LDB"-"c:\system\test\testdata\EPOSLM_060.LDB" +"..\databases\landmarks\EPOSLM_080.LDB"-"c:\system\test\testdata\EPOSLM_080.LDB" +"..\databases\landmarks\EPOSLM_105.LDB"-"c:\system\test\testdata\EPOSLM_105.LDB" + +"..\databases\landmarks\eposlm_1000_LMs.ldb"-"c:\system\test\testdata\eposlm_1000_LMs.ldb" +"..\databases\landmarks\eposlm_5000_LMs.ldb"-"c:\system\test\testdata\eposlm_5000_LMs.ldb" + +;File used in TP136 +"..\databases\landmarks\XML_Files\TP136.xml"-"c:\system\test\TestData\TP136.xml" +"..\databases\landmarks\XML_Files\TP136.gpx"-"c:\system\test\TestData\TP136.gpx" + +;File used in TP137 +"..\databases\landmarks\XML_Files\TP137.xml"-"c:\system\test\TestData\TP137.xml" +"..\databases\landmarks\XML_Files\TP137.gpx"-"c:\system\test\TestData\TP137.gpx" diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.sis Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.sis has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.sisx Binary file landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTestModule_5_0.sisx has changed diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTests_gnumakefile.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/LandmarkTests_gnumakefile.mk Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,89 @@ +# +# Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Symbian Foundation License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Top makefile for Poison functiontests +# + +# runs after 'abld makefile' +MAKMAKE: + @echo *** DEBUG: MAKMAKE ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after 'abld library' +LIB: + @echo *** DEBUG: LIB ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after 'abld resource' +RESOURCE: + @echo *** DEBUG: RESOURCE ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after 'abld target' +BLD: + @echo *** DEBUG: BLD ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after 'abld final' +ifeq ($(PLATFORM),WINS) +FINAL: COPY_TESTDATA + @echo *** DEBUG: FINAL ${PLATFORM} ${CFG} ${TO_ROOT} +else +ifeq ($(PLATFORM),WINSCW) +FINAL: COPY_TESTDATA + @echo *** DEBUG: FINAL ${PLATFORM} ${CFG} ${TO_ROOT} +#Create c:\resource directory + -@mkdir \EPOC32\${PLATFORM}\c\resource +else +FINAL: + @echo *** DEBUG: FINAL ${PLATFORM} ${CFG} ${TO_ROOT} +endif +endif + +# runs when called from +COPY_TESTDATA: +# Create testdata directory if it does not exist + -@mkdir \EPOC32\winscw\c\system\TEST\TestData + @echo Copying all testdata files needed by LandmarkTests, copy to ${PLATFORM} $(CFG) + +# Copy all landmarks databases to testdata + + copy ..\databases\landmarks\* \EPOC32\winscw\c\system\TEST\TestData + + copy ..\databases\landmarks\XML_files\* \EPOC32\winscw\c\system\TEST\TestData + + @echo *** DEBUG: COPY_TESTDATA ${PLATFORM} ${CFG} ${TO_ROOT} + @echo ......Done copying + +# ??? +RELEASABLES: + @echo *** DEBUG: RELEASABLES ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after clean operations +CLEAN: + @echo *** DEBUG: CLEAN ${PLATFORM} ${CFG} ${TO_ROOT} + +# runs after clean operations +CLEANLIB: + @echo *** DEBUG:CLEANLIB ${PLATFORM} ${CFG} ${TO_ROOT} + +# only runs during 'abld freeze' +FREEZE: + @echo *** DEBUG: FREEZE ${PLATFORM} ${CFG} ${TO_ROOT} + +# only runs when -savespace is specified. +SAVESPACE: + @echo *** DEBUG: SAVESPACE ${PLATFORM} ${CFG} ${TO_ROOT} + +# Generic target. Catches everything else (unknown targets etc.) +%: + @echo *** DEBUG: GENERIC $@ ${PLATFORM} ${CFG} ${TO_ROOT} + +# End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// BLD.INF +// Component description file + +PRJ_PLATFORMS +//WINSCW ARMV5 +DEFAULT + +PRJ_EXPORTS +../init/TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework.ini +../conf/LandMarksTestModule1.cfg /epoc32/winscw/c/TestFramework/LandMarksTestModule1.cfg + +PRJ_TESTMMPFILES +../Testprovider/ServerClientLib/group/FT_LmServerClientLibrary.mmp +../Testprovider/group/FT_DbManPluginsTest.mmp +LandMarksTestModule.mmp +gnumakefile LandmarkTests_gnumakefile.mk + +PRJ_MMPFILES + + + +// Specify Extension makefile +// diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/EPos_LandmarksErrors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/EPos_LandmarksErrors.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* +*/ + + +#ifndef LANDMARKSERRORS_H +#define LANDMARKSERRORS_H + +// INCLUDES +#include +#include + +// CONSTANTS +_LIT(KPosLandmarksClientPanic,"Landmarks Client"); + +/** + * Landmarks panic codes + * + */ +enum TPositionLandmarksClientPanic + { + EPosInvalidPositionFieldId = 0 + /** A client has specified a position field ID that is invalid for + the landmark. */, + EPosNoneOrMultipleLandmarkAttributeSet = 1 + /** A client has specified none or multiple landmark attributes. */, + EPosSpecifiedIntervalLiesOutsideIteratedSet = 2 + /** A client has specified an interval that lies partially outside the + iterated set. */, + EPosNaNCoordinate = 3 + /** A client has specified a coordinate with latitude and/or longitude set + to NaN. */, + EPosInvalidLandmarkAttribute = 4 + /** A client has specified a landmark attribute that is invalid. */, + EPosInvalidValueSpecifiedInResourceFile = 5 + /** An invalid value has been detected in a resource file. */, + EPosInvalidPartialReadParameters = 6 + /** Invalid partial read parameters have been detected. */, + EPosInvalidRequestedPositionFields = 7 + /** Invalid requested position fields have been detected. */, + EPosNegativeValue = 8 + /** A negative value has been detected. */, + EPosInvalidOperationMode = 9 + /** Invalid operation mode. Caused by mixed calls to NextStep and ExecuteL + for an CPosLmOperation object or subsequent calls to NextStep. */, + EPosInvalidEnumValue = 10 + /** Invalid enum value. */, + EPosLmProtocolBreak = 11 + /** The protocol of CPosLandmarkEncoder/CPosLandmarkParser is not + followed. */, + EPosLmInvalidArgument = 12 + /** A client has passed an invalid argument. */, + EPosInvalidIndex = 14 + /** A client has specified an invalid index. */, + EPosInvalidItemType = 15 + /** A client has specified an invalid item type. */, + EPosSearchOperationInUse = 16 + /** A client has tried to set/unset display data during an ongoing search. + */ + }; + +// FUNCTION PROTOTYPES +IMPORT_C GLDEF_C void Panic(const TDesC& aCategory, TInt aReason); + +#endif // LANDMARKSERRORS_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CAreaSearchResult.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CAreaSearchResult.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +#ifndef CAREASEARCHRESULT_H +#define CAREASEARCHRESULT_H + +// INCLUDES +#include +#include + +#include "Ft_CSearchResultBase.h" + + + +class CAreaSearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CAreaSearchResult* NewL(const TDesC& aDes); + + /** + * Destructor. + */ + ~CAreaSearchResult(); + + public: + + TReal64 SouthLat() const; + + TReal64 NorthLat() const; + + TReal64 WestLong() const; + + TReal64 EastLong() const; + + TInt ErrorCode() const; + + void Print(TDes& aDes); + + private: + + CAreaSearchResult(); + + void ConstructL(const TDesC& aDes); + + + private: + + // By default, prohibit copy constructor + CAreaSearchResult(const CAreaSearchResult&); + // Prohibit assigment operator + CAreaSearchResult& operator=(const CAreaSearchResult&); + + private: // Data + + enum TValueIndex + { + ESouthLat =0, + ENorthLat =1, + EWestLong =2, + EEastLong =3, + EErrorCode =4, + ERedefined =5, + ESearchResult =6 + }; + + TInt iErrorCode; + + TReal64 iSouthLat; + TReal64 iNorthLat; + TReal64 iWestLong; + TReal64 iEastLong; + + }; + +#endif // CAREASEARCHRESULT_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCategoryLandmarkSearchResult.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCategoryLandmarkSearchResult.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +#ifndef CCategoryLandmarkSearchResult_H +#define CCategoryLandmarkSearchResult_H + +// INCLUDES +#include +#include + +#include "Ft_CSearchResultBase.h" + + + +class CCategoryLandmarkSearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCategoryLandmarkSearchResult* NewL(const TDesC& aDes); + + /** + * Destructor. + */ + ~CCategoryLandmarkSearchResult(); + + public: + + TPtrC CategoryName() const; + + TPosLmItemId CategoryId() const; + + const RArray& PositionFields() const; + + private: + + CCategoryLandmarkSearchResult(); + + void ConstructL(const TDesC& aDes); + + + private: + + // By default, prohibit copy constructor + CCategoryLandmarkSearchResult(const CCategoryLandmarkSearchResult&); + // Prohibit assigment operator + CCategoryLandmarkSearchResult& operator=(const CCategoryLandmarkSearchResult&); + + + + void Print(); + + + + private: // Data + + enum TValueIndex + { + ECategoryName =0, + ECategoryId =1, + ELmSearchResult =2, + ERedefined =3 + }; + + HBufC* iCategoryName; + RArray iPositionFields; + TPosLmItemId iCategoryId; + + }; + +#endif // CCategorySearchResult_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCategorySearchResult.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCategorySearchResult.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CCategorySearchResult_H +#define CCategorySearchResult_H + +// INCLUDES +#include +#include + +#include "Ft_CSearchResultBase.h" + + + +class CCategorySearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCategorySearchResult* NewL(const TDesC& aDes); + + /** + * Destructor. + */ + ~CCategorySearchResult(); + + public: + + TPtrC TextCriteria() const; + + const RArray& PositionFields() const; + + private: + + CCategorySearchResult(); + + void ConstructL(const TDesC& aDes); + + + private: + + // By default, prohibit copy constructor + CCategorySearchResult(const CCategorySearchResult&); + // Prohibit assigment operator + CCategorySearchResult& operator=(const CCategorySearchResult&); + + void ParsePositionFields(const TDesC& aDes); + + void Print(); + + TBool Equals32(const TReal aValue1, const TReal aValue2, const TReal aAccuracy); + + private: // Data + + enum TValueIndex + { + ETextCriteria =0, + ELmSearchResult =1, + ERedefined =2 + }; + + HBufC* iTextCriteria; + RArray iPositionFields; + + }; + +#endif // CCategorySearchResult_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCompositeSearchResult.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CCompositeSearchResult.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CCOMPOSITESEARCHRESULT_H +#define CCOMPOSITESEARCHRESULT_H + +// INCLUDES +#include +#include +#include "Ft_CSearchResultBase.h" +#include + + +class CPosLmCompositeCriteria; +// CONSTANTS + + +class CCompositeSearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCompositeSearchResult* NewL(CStifLogger* aLog); + + /** + * Destructor. + */ + ~CCompositeSearchResult(); + + public: + + TBool GetCompositeSearchResultsL(CPosLmCompositeCriteria& aComposite); + + //RArray& GetSearchResult(); + + public: // data + RArray iResultIds; + + TReal64 iSouthLat; + TReal64 iNorthLat; + TReal64 iWestLong; + TReal64 iEastLong; + + private: + + CCompositeSearchResult(); + + void ConstructL(CStifLogger* aLog); + + TInt ReadLn(RFile& aFile, TDes& aDes); + + void ParseAreaL(const TDesC& aDes); + + void ParseTextL(const TDesC& aDes); + + void ParseCategoryL(const TDesC& aDes); + + void ParseNearestL(const TDesC& aDes); + + void ParseIdListL(const TDesC& aDes); + + void ParseResultL(const TDesC& aDes); + + void ExtractIdFields(const TDesC& aDes, RArray& aList); + + private: + + // By default, prohibit copy constructor + CCompositeSearchResult(const CCompositeSearchResult&); + // Prohibit assigment operator + CCompositeSearchResult& operator=(const CCompositeSearchResult&); + + private: // Data + + enum TAreaValueIndex + { + ESouthLat =1, + ENorthLat =2, + EWestLong =3, + EEastLong =4, + }; + + enum TCategoryValueIndex + { + ECategoryName =1, + ECategoryId =2, + }; + + enum TTextValueIndex + { + ETextCriteria =1, + EAttributes =2, + EPositionFields =3, + }; + + enum TNearestValueIndex + { + ELatitude =1, + ELongitude =2, + EUseCoverageRadius =3, + EMaxDistance =4, + }; + + enum TIdListValueIndex + { + ELmIdList =1, + }; + + enum TResultValueIndex + { + ELmResultIdList =1, + ERedefined =2 + }; + + + // Test log, used for debug text + CStifLogger* iLog; + + RFs iFileSession; + RFile iFile; + + HBufC* iTextCriteria; + HBufC* iCategoryName; + TInt iCategoryId; + + CPosLandmark::TAttributes iTextAttributes; + + RArray iIdList; + RArray iPositionList; + + TReal64 iLatitude; + TReal64 iLongitude; + TBool iUseCoverageRadius; + TReal32 iMaxDistance; + + TBool iTextEnabled; + TBool iAreaEnabled; + TBool iNearestEnabled; + TBool iCategoryEnabled; + TBool iIdListEnabled; + + TInt iTestCounter; + + }; + +#endif // CCompositeSearchResult_H + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CLandmarkTestProcedureBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CLandmarkTestProcedureBase.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,523 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CLANDMARKTESTPROCEDUREBASE_H +#define CLANDMARKTESTPROCEDUREBASE_H + +// INCLUDES +//#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "FT_CSearchResult.h" +#include "FT_CAreaSearchResult.h" +#include "FT_CCategorySearchResult.h" +#include "FT_CCategoryLandmarkSearchResult.h" + +#include +#include + +// Global category IDs as defined by Global Category API specification +// Global category identifier when used for searching +const TInt KAccommodation = 3000; //Hotel, Camping site +const TInt KBusiness = 6000; //Bank, Factory, Office +const TInt KCommunication = 9000; //Internet Access Point, Public Telephone, Wireless LAN Hot Spot +const TInt KEducational = 12000;// School, College +const TInt KEntertainment = 15000;// Amusement park, Cinema, Concert hall, Night club +const TInt KFoodBeverage = 18000; //Fast food, Restaurant, Café, Bar +const TInt KGeographicalArea = 21000;//City, City center, Town +const TInt KOutdoorActivities = 24000; //Camping site, Fishing place, Hunting, National park, Playground +const TInt KPeople = 27000;// My home, My friend's home, Father's summer cottage, Child's school +const TInt KPublicService = 30000; //Tourist information office, Government office, Library, Post office, Hospital, Police +const TInt KReligiousPlaces = 33000; //Church, Mosque +const TInt KShopping = 36000; //Market place, Pharmacy, Shop, Shopping center +const TInt KSightseeing = 39000; //Monument, Mountain top, Museum +const TInt KSports = 42000 ; //Bowling, Golf course, Ice hockey hall, Stadium +const TInt KTransport = 45000; //Airport, Bus stop, Harbor, Railway station, Rest area + +// CONSTANTS +_LIT(KAccessErr, "Access methods should return 'Not initialized' when db has been created"); +_LIT(KInitErr, "Method InitializedNeeded should return ETrue after db has been created"); +_LIT8(KLmxMimeType, "application/vnd.nokia.landmarkcollection+xml"); +_LIT8(KGpxMimeType, "application/gps+xml"); +_LIT8(KKmlMimeType,"application/vnd.google-earth.kml+xml"); +_LIT8(KKmzMimeType,"application/vnd.google-earth.kmz"); +_LIT(KLmxFileExt,".lmx"); +_LIT(KGpxFileExt,".gpx"); +_LIT(KXmlFileExt,".xml"); + +const TInt KMsgBufSize = 255; +const TInt KMaxLineLength = 1024; + +// FORWARD DECLARATIONS +class CPosLmMultiDbSearch; +class CPosLmSearchCriteria; + +// DATA TYPES +typedef RArray RIdArray; + +// CLASS DECLARATION +class CPosLandmarkCategory; +class CActiveLmOperation; + +class CLandmarkTestProcedureBase :public CBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CLandmarkTestProcedureBase(TInt aModuleId, CStifLogger* iLog ); + + /** + * Destructor. + */ + ~CLandmarkTestProcedureBase(); + + /** + * Initialises the test. + * By default does nothing. + */ + virtual void InitTestL(); + + /** + * Executes the test. + * By default does nothing. + */ + virtual void StartL(); + + /** + * Executes the test. + * By default does nothing. + */ + virtual void StartL( CStifItemParser& ) {}; + + /** + * Cleans up after a test. + * Always called, even if the test leaves. + * By default does nothing. + */ + virtual void CloseTest(); + + + public: // Functions from base classes + + + static TInt ReadLn(RFile& aFile, TDes& aDes); + + static void ResetAndDestroyHBufCArray( TAny* aPointer ); + + protected: // New functions + + static void Trace(TBuf8 msg) ; + + /** + * Removes the default landmark database if exists + */ + void RemoveDefaultDbL(); + + /** + * Removes all existing landmark databases + */ + void RemoveAllLmDatabasesL(); + + /** + * Compare two landmarks. + * Should only be used when they are expected to be equal. + */ + void CompareLandmarksL(const CPosLandmark& aSource, const CPosLandmark& aTarget); + + /** + * Compare two categories. + * Should only be used when they are expected to be equal. + */ + void CompareCategoriesL( + const TPosLmItemId& aSourceId, + const TPosLmItemId& aTargetId); + + void CompareCategoriesL( + const CPosLandmarkCategory& aSource, + const CPosLandmarkCategory& aTarget); + + + TInt CompareXMLCategoriesL( + const CPosLandmarkCategory& aSource, + const CPosLandmarkCategory& aTarget, TBool aDebug=EFalse); + + TInt CompareXMLLandmarksL(const CPosLandmark& aSource, const CPosLandmark& aTarget, TBool aDebug=EFalse); + + /** + * Creates a caategory with all attributes set + * @param the category name + */ + CPosLandmarkCategory* CreateCategoryLC(const TDesC& aName); + + /** + * Creates a landmarks with all attributes set + * @param the landmark name + */ + CPosLandmark* CreateLandmarkLC(const TDesC& aName); + + /** + * Opens the landmarks database and initializes it if necearry + * @return the landmarks database + */ + CPosLandmarkDatabase* OpenDatabaseLC(); + + /** + * Creates a category and adds it to the database + * @return the category id + */ + TPosLmItemId CreateCategoryL(const TDesC& aName); + + /** + * Adds some fields to a landmark + * @param the landmark + */ + void AddFieldsL(CPosLandmark* aLandmark); + + void AddFields2L(CPosLandmark* aLandmark); + + void AddFields3L(CPosLandmark* aLandmark); + + TInt CompareL(const TDesC& aFileName); + + TInt CompareL(const TDesC& aSourceFileName, const TDesC& aTargetFileName); + + /* + * Create landmark with name, coordinate, coverage radius, icon set + */ + CPosLandmark* CreateXMLLandmarkLC(const TDesC& aName); + + + /** + * Add all fields to a landmark that is encoded to XML + */ + void AddAllXMLFieldsL(CPosLandmark* aLandmark); + + /** + * Add all fields to a landmark that is encoded to XML + * All fields are empty (_L("")) + */ + void AddAllEmptyXMLFieldsL(CPosLandmark* aLandmark); + + /** + * Writes the content of the buffer to the specified file + * Removes the file if allready exists + */ + void WriteBufferToFileL(const CBufBase* aBuffer, const TDesC& aFileName); + + void CheckDefaultDbExistL(); + + CPosLandmarkDatabase* BackupDbFileL(); + + CPosLandmarkDatabase* RestoreDbFileL(); + + void CopyDbFileL(const TDesC& aFileName); + + void CopyTestDbFileL(const TDesC& aFileName); + + CPosLandmarkDatabase* UseGeneratedDbFileL(); + + /** + * Copy the landmarks db used for composite testing + * to correct path + */ + CPosLandmarkDatabase* UseCompositeLandmarksDbFileL(); + + CPosLandmarkDatabase* UseGlobalCategoriesL(); + + CPosLandmarkDatabase* UseEmptyDbFileL(); + + void RemoveGlobalCategoriesL(); + + void AppendSearchResultsL(); + + void AppendAreaSearchResultsL(); + + void AppendCategoryLandmarkSearchResultsL(); + + void AppendCategorySearchResultsL(); + + const RPointerArray& SearchResults(); + + const RPointerArray& AreaSearchResults(); + + void PrintLandmark(const CPosLandmark& aLandmark, TDes& aPrint); + + void LandmarksSortL(RArray& aArray, const TPosLmSortPref& aSortPref); + + void CategoriesSortL(RArray& aArray, CPosLmCategoryManager::TCategorySortPref aSortPref); + + void LogToFileL(const TDesC& aFileName, TBuf8 aMsg); + + void RunAsyncOperationLD(CPosLmOperation* aOperation); + + void RunAsyncOperationL(CPosLmOperation* aOperation); + + void RunAsyncOperationByWaitForReqL(CPosLmOperation* aOperation); + + void RunAsyncOperationAndCancelLD(CPosLmOperation* aOperation); + + void RunAsyncOperationAndCancelInCallbackLD(CPosLmOperation* aOperation, TReal32 aThreshold = 0.3); + + /** + * Deletes a file from the file system + * @aFile the file name + */ + void DeleteFileL(const TDesC& aFile); + + /** + * Makes sure that the empty file ErrRd is created in c:\system\bootdata + * if it is not already created. Should be called by all panic tests + * before any panic occurs. + */ + void MakeSurePanicDebugFileExistsL(); + + /** + * Used as a callback method to cancel a operation after some + * steps have been executed. + * @param self + */ + TInt static CancelTest(TAny* aSelf); + + void AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode=KErrGeneral); + + /** + * Checks if the server with name aServerName is alive + */ + TBool ServerAlive(const TDesC& aServerName); + + CDesCArray* ListLandmarkDbsL(); + + void ReadGlobalCategoriesFromResourceL( + RArray& aCatIds, + RPointerArray& aCatNames, + TInt aMaxNum = 0); + + void CreateCorrectXmlFileL( const TDesC& aSampleFile, TFileName& aFileName ); + + HBufC* GetGlobalCategoryFromResourceLC( TPosLmGlobalCategory aGlobalId ); + + HBufC* ReadDefaultDatabaseNameFromResourceLC(); + + /** + * Escapes the string with characters not supported in XML. + * + * @param aStrToEscape The string to escape. + * @return An escaped string. + */ + HBufC* EscapeStringToXmlLC( + /* IN */ const TDesC& aStrToEscape + ); + + void EscapeString( + /* IN/OUT */ TDes& aStrToEscape, + /* IN */ const TDesC& aFromStr, + /* IN */ const TDesC& aToStr + ); + + TInt CalculateEscapedStringSize( + /* IN */ const TDesC& aStrToEscape + ); + + TInt CalculateIncrease( + /* IN */ const TDesC& aStrToEscape, + /* IN */ const TDesC& aFromStr, + /* IN */ const TDesC& aToStr + ); + + + public: + + //RWsSession iWs; + TInt iModuleId; + + protected: // Data + + class COnTheFlyTester : public CActive + { + public: + + static COnTheFlyTester* NewLC(); + ~COnTheFlyTester(); + void StartSearchCampaignL( + CPosLmMultiDbSearch* aSearcher, + const RIdArray& aExpectedMatches, + CPosLmSearchCriteria* aSearchCriteria); + TInt Err() {return iErr;} + void GetErrMsg(TPtrC& aErrMsg) {aErrMsg.Set(iBuf);} + + protected: + + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + + private: + + COnTheFlyTester(); + void VerifyOnTheFlyDataL(TBool aIsFinished = EFalse); + + private: // Data + + CPosLmMultiDbSearch* iSearcher; + TInt iErr; + TInt iNrOfOldItems; + CPosLmOperation* iOperation; + TReal32 iProgress; + CPosLmDisplayData* iDisplayData; + TBuf<200> iBuf; + const RIdArray* iExpectedMatches; + + }; + + enum TExecutionMode + { + ESynchronous = 0, + EAsynchronous, + EWaitForRequest + }; + + const TTimeIntervalMicroSeconds32 KFirstDelayTime; + const TTimeIntervalMicroSeconds32 KIntervalTime; + + CPosLandmarkDatabase* iDatabase; + CPosLandmarkSearch* iLandmarkSearch; + CPosLmMultiDbSearch* iLmMultiSearch; + + // Search + RPointerArray iSearchResults; + RPointerArray iAreaSearchResults; + RPointerArray iCategoryLandmarkSearchResults; + RPointerArray iCategorySearchResults; + + CPosLmOperation* iOperation; + // Use this method when using CActiveLmOperation class from multiple threads + // this is due to that it is not possible to use the iLog from different threads + // set to ETrue is used from multiple threads + + TBool iUseLogFromThreadIsDisabled; + CStifLogger* iLog; + RFs iFileSession; + private: // Data + + //TUint iCallbacks; + + + }; + +class MProgressObserver + { + public: // New functions + + /** + * Notifies the progress of the execution of a CPosLmOperation object. + * + * @param sProgress the progress of the operation + */ + virtual void NotifyProgress(TReal aProgress) = 0; + + }; + +class CActiveLmOperation : public CActive + { + public: + + /** + * C++ constructor. + */ + CActiveLmOperation( + CStifLogger* aLog, + TBool aUseLogFromThreadIsDisabled = EFalse, + TReal32 aThreshold = 0.3); + + /** + * Destructor. + */ + ~CActiveLmOperation(); + + public: + + void Start(CPosLmOperation* aOperation, MProgressObserver* aObserver = NULL); + + void CheckOperationL(); + + void DeleteOperationD(); + + TInt Status() const; + + TReal Progress() const; + + CPosLmOperation* Operation(); + + void SetCancelTest(); + + TReal32 Threshold(); + + TReal32 DeltaProgress(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + + private: + + + private: // data + + CPosLmOperation* iOperation; + + TReal32 iPassedProgress; + TReal32 iLastProgress; + TReal32 iDeltaProgress; + TReal32 iThreshold; + + TBool iAsyncProgressErr; + TBool iPassedProgressErr; + + TBool iCancelTest; + + TBool iUseLogFromThreadIsDisabled; + + MProgressObserver* iObserver; + CStifLogger* iLog; + }; + + +#endif // CLANDMARKTESTPROCEDUREBASE_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP26.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP26.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp26_H +#define CPOSTp26_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 26 +*/ +class CPosTp26 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp26(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iGlobalErr = KErrGeneral;iNrSearchRounds=0;}; + /** + * Destructor. + */ + ~CPosTp26() {}; + + public: // Functions from base classes + + + void CloseTest(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: // New functions + + /** + * Test to do a iterate landmark search using the CPosLmTextCriteria criteria + */ + void DoLandmarkSearchL(const RPointerArray& aSearchResults); + + /** + * Test to do a iterate category landmark search using the CPosLmCatNameCriteria criteria + */ + void DoLandmarkCategorySearchL(const RPointerArray& aSearchResults); + + private: // Data + + + TInt iGlobalErr; + TInt iNrSearchRounds; + }; + +#endif // CPOSTp26_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP27.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP27.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp27_H +#define CPOSTp27_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 27 +*/ +class CPosTp27 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp27(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) + {iGlobalErr = KErrNone;iNrSearchRounds=0;iBreakSearch=-1; + iCancelOrDelete = EFalse;iHandleOperationDisabled=EFalse; + iDebug=ETrue;iProgress=100;}; + + /** + * Destructor. + */ + ~CPosTp27() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From MPosLmAsyncObserver + * Called to report progress of an asynchronous landmarko peration. + * @param aOperation The object which handles the asyncronous operation. + */ + void HandleOperationProgress(CPosLmOperation* aOperation); + + + static TInt StopActiveSchedulerWait(TAny* aSelf); + + private: // New functions + + /** + * Test to cancel a landmark category search + * + */ + void CancelLandmarkCategorySearch(); + + /** + * Test to cancel a landmark search + * + */ + void CancelLandmarkSearch(); + + private: // Data + + RFs iFileServer; + RFile iFile; + TInt iGlobalErr; + TInt iNrSearchRounds; + TInt iBreakSearch; + TBool iCancelOrDelete; + TBool iHandleOperationDisabled; + TBool iDebug; + CPeriodic* iPeriodicTimer; + TReal32 iProgress; + + }; + +#endif // CPOSTp27_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP28.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP28.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPosTp28_H +#define CPosTp28_H + +// INCLUDES + +#include "FT_CLandmarkTestProcedureBase.h" + +class CActiveLmEvent; +// CLASS DECLARATION + +/** +* Test procedure 28 +*/ +class CPosTp28 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp28(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp28() {}; + + public: // Functions from base classes + + + + void CloseTest(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: // New functions + + /** + * Test logging of landmark events + */ + void LandmarkEventTest(); + + void LandmarkEventQueueTest(); + + + private: // Data + + CActiveLmEvent* iActiveLmEvent; + CPosLmCategoryManager* iCategoryManager; + }; + +class CActiveLmEvent : public CActive + { + public: + + static CActiveLmEvent* NewL(CStifLogger* aLog); + + /** + * Destructor. + */ + ~CActiveLmEvent(); + + public: + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + private: + + /** + * C++ constructor. + */ + CActiveLmEvent(CStifLogger* aLog); + + void ConstructL(); + + void VerifyEvent(); + + void VerifyMergedEvent(); + + void AssertCorrectEvent(TPosLmEventType aExpectedEventType, + TPosLmEventType aEventType, + TPosLmItemId aExpectedLandMarkItemId, + TPosLmItemId aLandMarkItemId); + + private: // data + + friend class CPosTp28; + + CStifLogger* iLog; + CPosLandmarkDatabase* iDatabase; + + + + TPosLmEvent iEvent; + TInt iEventNumber; + TInt iMergedEventNumber; + TInt iGlobalErr; + + TBool iQueueTest; + + TPosLmItemId iLandmarkId; + TPosLmItemId iLandmarkId2; + TPosLmItemId iLandmarkId3; + TPosLmItemId iLandmarkId4; + + TPosLmItemId iCategoryId; + TPosLmItemId iCategoryId2; + TPosLmItemId iNonExistingCategoryId; + TPosLmItemId iDeleteCategoryId; + }; + +#endif // CPosTp28_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP29.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP29.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp29_H +#define CPOSTp29_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 29 +*/ +class CPosTp29 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp29() : CLandmarkTestProcedureBase(29) {iGlobalErr = KErrGeneral;}; + + /** + * Destructor. + */ + ~CPosTp29() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CUtfwTestBase + */ + void InitTestL(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: // New functions + + void ReInitTestL(); + + void TestCriticalLevelL(); + + void ConsumeDiscSpace1L(TInt aSizeLimit); + + void ConsumeDiscSpace2L(TInt aSizeLimit); + + void DeleteFile2L(); + + void RemoveAllLandmarksL(); + + void DoOutOfDiskTestL(TBool aSync); + + void InitiateCriticalLevelL(); + + void CopyResourceFileL(const TDesC& aResourceFile = KNullDesC); + + void TryRestoreResourceFile(); + + private: // Data + + RFs iFileServer; + RFile iFile1; + RFile iFile2; + TInt iGlobalErr; + TInt iCriticalLevel; + TInt iCriticalThreshold; + + CPosLandmarkDatabase* iLandmarksDb; + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp29_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP54.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP54.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp54_H +#define CPOSTp54_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 54 +*/ +class CPosTp54 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp54() : CLandmarkTestProcedureBase(54) {}; + + /** + * Destructor. + */ + ~CPosTp54() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CUtfwTestBase + */ + void InitTestL(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: // New functions + + /** + * Returns the execution time in milliseconds + */ + TInt64 ExecutionTimeSynchL(TBool aIsSorted); + + /** + * Returns the longest execution time of a RunL call in milliseconds + */ + TInt64 ExecutionTimeAsynchL(TBool aIsSorted); + + TBool VerifyResult( + TInt64 aExecTime, + TInt aNrOfLandmarks, + TBool aSorted, + TInt64 aLimit, + TBool aSynch); + + TInt64 TestIteratorSynchL(const TDesC& aDatabase, TBool aIsSorted); + + TInt64 TestIteratorAsynchL(const TDesC& aDatabase, TBool aIsSorted); + + void RecreateDatabaseL(const TDesC& aDatabase); + + TInt64 ExecuteLmOp(CPosLmOperation* aOp, TInt& aResult); + + void CreateLargeDbs(TInt aNrOfItems); + + private: // Data + + }; + +#endif // CPOSTp54_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP55.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTP55.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP55_H +#define CPOSTP55_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 55 +*/ +class CPosTp55 : public CLandmarkTestProcedureBase, +public MProgressObserver + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp55() : CLandmarkTestProcedureBase(55) {}; + + /** + * Destructor. + */ + ~CPosTp55() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CUtfwTestBase + */ + void InitTestL(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From MProgressObserver + * Notifies the progress of the execution of a CPosLmOperation object. + * + * @param sProgress the progress of the operation + */ + void NotifyProgress(TReal aProgress); + + private: // New functions + + void TestCriticalLevelL(); + + void RecreateAndOpenFilesL(); + + void ExportLandmarksTestL(); + + void ImportLandmarksTestL(TBool aCriticalLevelPassed); + + void ConsumeDiskSpaceL(RFile& aFile, TInt aSizeLimit); + + /** + * Imports landmarks from an XML file or a buffer to the database. + * + * @param aInputFile file to import from. KNullDesC if buffer is to be + * used as target. + * @param aInputBuffer buffer to import landmarks from. NULL if not used. + * @param aArrayOfIds to export when calling ExportLandmarksL(). NULL + * if encoder is to be used stand-alone. + * @param aExecuteIncrementally ETrue if CPosLmOperations should be + * executed incrementally, EFalse if CPosLmOperations should be + * synchronously. + * @param aTestBeyondCriticalLevel ETrue if critical level is passed, EFalse otherwise + */ + void ImportLandmarksL( + const TDesC& aInputFile, + RArray* aArrayOfIds, + TBool aExecuteIncrementally, + TBool aTestBeyondCriticalLevel); + + void InitiateCriticalLevelL(); + + void LogVolumeInfoL(); + + void DeleteFileL(const TDesC& aFile); + + void FillFile3L(); + + HBufC8* CreateInputBufferL(); + + void ReInitializeEncoderEtcL(); + + TInt ExecuteLmOperationL(TBool aExecuteIncrementally); + + void SetOutputBufferL(); + + void AddCollectionDataToEncoderL(); + + void AddLandmarksToEncoderL(TBool aAddAll); + + void ExportWithExportLandmarksMethodL( + RArray& aArrayOfIds, + TBool aExecuteIncrementally); + + void FinalizeEncoderL(TBool aExecuteIncrementally); + + void PopulateArrayL( + RArray& aArray, + TBool aDoAddAllLms); + + void CopyResourceFileL(const TDesC& aResourceFile = KNullDesC); + + void TryRestoreResourceFile(); + + private: // Data + + RFs iFileServer; + RFile iFile1; + RFile iFile2; + RFile iFile3; + RFile iXmlOutputFile; + TInt iCriticalLevel; + TInt iCriticalThreshold; + TInt iSizeLimit1; + TInt iSizeLimit2; + TBuf<150> iMsg; + TInt iProgress; + + CBufBase* iOutputBuffer; + HBufC8* iInputBuffer; + CPosLandmarkEncoder* iLandmarkEncoder; + CPosLandmarkParser* iLandmarkParser; + CPosLmOperation* iOperation; + CActiveLmOperation* iOperationWrapper; + }; + +#endif // CPOSTP55_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp1.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp1.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP1_H +#define CPOSTP1_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + + + +/** +* Test procedure 1 +*/ +class CPosTp1 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp1(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp1() {}; + + public: // Functions from base classes + + + void StartL(); + + private: + + /** + * Tests if it is possible to instantiate the db when it is locked + */ + void VerifyLockedDatabaseL(); + + }; + +#endif // CPOSTP1_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp10.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp10.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP10_H +#define CPOSTP10_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + + + +/** +* Test procedure 10 +*/ +class CPosTp10 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp10(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp10() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + void AddCategoriesL(); + + void ReadCategoriesL(); + + void UpdateCategoriesL(); + + void AddLandmarksL(); + + void AddCategoriesToLandmarksL(); + + void AddCategoriesToLandmarksAsyncL(); + + void AddCategoriesToLandmarksUsingWaitForReqL(); + + void AddCategoriesToLandmarksAsyncAndCancelL(const TBool& aInCallback=EFalse); + + void CheckLandmarksL(); + + void CheckRemovedL(const TInt startIndex, const TInt stopIndex); + + void RemoveCategoryL(); + + void RemoveCategoryAsyncL(); + + void RemoveCategoryUsingWaitForReqL(); + + void RemoveCategoryAsyncAndCancelL(const TBool& aInCallback=EFalse); + + void RemoveSetOfCategoriesL(); + + void RemoveSetOfCategoriesAsyncL(); + + void RemoveSetOfCategoriesUsingWaitForReqL(); + + void RemoveSetOfCategoriesAsyncAndCancelL(const TBool& aInCallback=EFalse); + + void RemoveCategoryFromSetOfLandmarksL(); + + void RemoveCategoryFromSetOfLandmarksAsyncL(); + + void RemoveCategoryFromSetOfLandmarksUsingWaitForReqL(); + + void RemoveCategoryFromSetOfLandmarksAsyncAndCancelL(const TBool& aInCallback=EFalse); + + void RemovedFromLandmarksInternalL(TPosLmItemId aCategoryId); + + void ReadCategoryL(TPosLmItemId aCategoryId); + + void AddCategoriesToLandmarksAsyncErrCheckL(); + + /** + * Test LMREQ121 + */ + void TestMissingCategories1L(); + + /** + * Test LMREQ121 + */ + void TestMissingCategories2L(); + + void CompareTwoCategoriesL(TInt aIndex); + + CPosLandmarkDatabase* BackupTp10DbFileL(); + + CPosLandmarkDatabase* RestoreTp10DbFileL(); + + + private: // data + + CPosLmCategoryManager* iCategoryManager; + RPointerArray iCategories; + RPointerArray iLandmarks; + + }; + +#endif // CPOSTP1_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp100.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp100.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP100_H +#define CPOSTP100_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 100 +*/ +class CPosTp100 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp100(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp100() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void TestOpenSpecificDbL(); + + void TestOpenDbL(const TDesC& aDbURI); + + void TestMultipleExportL(); + + void CreateDatabasesL(); + + void TestLockedDatabaseL(); + + }; + +#endif // CPOSTP100_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp101.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp101.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP101_H +#define CPOSTP101_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + + + +/** +* Test procedure 101 +*/ +class CPosTp101 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp101(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp101() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void VerifySetOfDatabasesL(); + + void VerifyDatabaseL(CDesCArray* aLmUris, CDesCArray* aNewLmUris = NULL); + + void CheckDatabasesL( + CDesCArray* aExpectedLmUris, + TUint aExpectedMaxMatches = KPosLmMaxNumOfMatchesUnlimited + ); + + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL(const RPointerArray& aSearchResults); + + void GetLmIdsL( + TInt aDbId, + RArray aSearchResults, + RArray& aLmIdForADb + ); + + void CheckEqualsLmsL( + TPosLmItemId aSource, + TPosLmItemId aTarget + ); + + void OnTheFlySearchL(); + + void SearchAndDeleteL( + const RPointerArray& aSearchResults + ); + + void SearchAndRenameL( + const RPointerArray& aSearchResults + ); + + void SearchAndCancelL(const TBool& aInCallback = EFalse); + + void SearchWithMaximumL( + const RPointerArray& aSearchResults + ); + + + CDesCArray* CreateDatabasesL( + TInt aNrOfLmDbs, + TInt aLmPerDb, + TInt aLastId, + TBool aDebug = EFalse + ); + + private: + + CDesCArray* iDbArray; + + }; + +#endif // CPOSTP56_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp102.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp102.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP102_H +#define CPOSTP102_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + + +/** +* Test procedure 102 +*/ +class CPosTp102 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + //CPosTp102() : CLandmarkTestProcedureBase(102) {}; + CPosTp102(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp102() {}; + + public: // Functions from base classes + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * Verify the number of existing landmark databases + */ + void VerifyNrOfDatabasesL(TInt aExpNrOfDatabases, const TDesC& aDatabaseUri=KNullDesC); + + /** + * Create a new landmark database using DBMS api (instead of the Landmarks API) + */ + void CreateDatabaseL(const TDesC& aUri); + + void TestDifferentUrisL(); + + }; + +#endif // CPOSTP102_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp103.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp103.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP103_H +#define CPOSTP103_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 103 +*/ +class CPosTp103 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp103(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp103() {}; + + public: // Functions from base classes + + + void StartL(); + + void CloseTest(); + + private: + + /** + * Verify the number of existing landmark databases + */ + void VerifyNrOfDatabasesL(TInt aExpNrOfDatabases, const TDesC& aDatabaseUri=KNullDesC); + + /** + * + */ + void TestPartCopyDatabasesL(); + + }; + +#endif // CPOSTP103_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp104.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp104.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp104_H +#define CPOSTp104_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + + + +/** +* Test procedure 104 +*/ +class CPosTp104 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp104(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp104() {delete iDbMan; delete iRepository; delete iLandmarksDb;}; + + public: // Functions from base classes + + + void CloseTest(); + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void TestSetUriL( + const TDesC& aUriString, + TInt aExpectedErrorCode + ); + void ArgumentTestsL(); + + CPosLmDatabaseManager* iDbMan; + CRepository* iRepository; + CPosLandmarkDatabase* iLandmarksDb; + + }; + +#endif // CPOSTp104_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp105.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp105.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp105_H +#define CPOSTp105_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION + +/** +* Test procedure 105 +*/ +class CPosTp105 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp105() : CLandmarkTestProcedureBase(105) {}; + + /** + * Destructor. + */ + ~CPosTp105() {delete iDbMan;}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + void CloseTest(); + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void CheckDisplayNameL(const TDesC& aLanguage, const TDesC& aDisplayName); + + void CopyResourceFileL(const TDesC& aResourceNr); + + void RemoveResourceFileL(const TDesC& aResourceNr); + + private: + + CPosLmDatabaseManager* iDbMan; + + }; + +#endif // CPOSTp105_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp106.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp106.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp106_H +#define CPOSTp106_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include + +// CLASS DECLARATION + +/** +* Test procedure 50 +*/ +class CPosTp106 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp106(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp106() {}; + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static void RunTestL(TAny* aData); + + void CreateAndListDatabasesL(TInt index); + + void CopyDatabasesL(TInt index); + + void DeleteDatabasesL(); + + void SetAndGetUriL(TInt index); + + void GetDisplayNameL(); + + void CheckIfExistL(TInt index); + + private: // Functions + + void StartMultipleClientsL(TUint aNoClients); + + void CreateThreadsL(const TUint aNoThreads); + + private: // data + + TTime iStart; + TTime iStop; + + enum TTestStep + { + Step1 =0, + Step2 =1, + Step3 =2, + Step4 =3, + Step5 =4, + Step6 =5 + }; + + TInt iTestStep; + + RArray iThreads; + TInt iThreadIndex; + TInt iThreadNum; + }; + + + +#endif // CPOSTp106_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp107.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp107.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +#ifndef CPosTp666_H +#define CPosTp666_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// FORWARD DECLARATION + +// CLASS DECLARATION + +/** +* Test procedure 666 +* +*/ +class CPosTp666 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp666() : CLandmarkTestProcedureBase(666) {}; + + /** + * Destructor. + */ + ~CPosTp666(); + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * + */ + void GetName(TDes& aName) const; + + /** + * From CPosTestProcedureBase + * Not used here. See StartL(TInt aIndex) + */ + void StartL(); + + private: + + void SetupTestPartL(TInt aIndex); + + void SetupTestEnvironmentL(); + + }; + +#endif // CPosTp666_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp108.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp108.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +#ifndef CPosTp667_H +#define CPosTp667_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// FORWARD DECLARATION + +// CLASS DECLARATION + +/** +* Test procedure 667 +* +*/ +class CPosTp667 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp667() : CLandmarkTestProcedureBase(667) {}; + + /** + * Destructor. + */ + ~CPosTp667(); + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * + */ + void GetName(TDes& aName) const; + + /** + * From CPosTestProcedureBase + * Not used here. See StartL(TInt aIndex) + */ + void StartL(); + + private: + + void SetupTestPartL(TInt aIndex); + + void SetupTestEnvironmentL(); + + }; + +#endif // CPosTp667_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp109.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp109.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +#ifndef CPosTp668_H +#define CPosTp668_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// FORWARD DECLARATION + +// CLASS DECLARATION + +/** +* Test procedure 668 +* +*/ +class CPosTp668 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp668() : CLandmarkTestProcedureBase(668) {}; + + /** + * Destructor. + */ + ~CPosTp668(); + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * + */ + void GetName(TDes& aName) const; + + /** + * From CPosTestProcedureBase + * Not used here. See StartL(TInt aIndex) + */ + void StartL(); + + private: + + void SetupTestPartL(TInt aIndex); + + void SetupTestEnvironmentL(); + + }; + +#endif // CPosTp668_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp11.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp11.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP11_H +#define CPOSTP11_H + +// INCLUDES + +#include +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 11 +*/ +class CPosTp11 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + // CPosTp11() : CLandmarkTestProcedureBase(11) {}; + CPosTp11(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp11() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + /* void GetName( + TDes& aName + ) const; + */ + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + + void AddCategoriesL(); + + void AddLandmarksL(); + + void IterateCategoriesL(); + + void IterateSetOfCategoriesL(); + + void CheckIteratorItemsL(CPosLmItemIterator& iter); + + CPosLandmarkCategory* InternalGet(TPosLmItemId id); + + void IterateSortedCategoriesL(); + + void IterateReferencedCategoriesL(); + + void IterateReferencedSortedCategoriesL(); + + // Added for BC testing + void MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ); + + + private: // data + + CPosLmCategoryManager* iCategoryManager; + RPointerArray iCategories; + RArray iReferencedCategories; + RPointerArray iLandmarks; + }; + +#endif // CPOSTP11_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp111.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp111.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP111_H +#define CPOSTP111_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLmDatabaseManager; +class CRepository; + +/** +* Test procedure 111 +*/ +class CPosTp111 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp111() : CLandmarkTestProcedureBase(111) {}; + + /** + * Destructor. + */ + ~CPosTp111() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + TBool FindResourceFilesL(); + + TBool FindServerResourceFilesL(); + + TBool FindEcomPluginsL(); + + TBool FindLibrariesL(); + + void TestCentralRepositoryL(); + + void FindFileL(const TDesC& aFile, TInt& aNrOfMatches, TDes& aPath); + + TBool FindFilesAndVerifyPathL( + const CDesCArray& aFileNames, + const TDesC& aExpectedPath); + + void VerifyDefaultDbUriL( + const TDesC& aExpectedUri, + CPosLmDatabaseManager* aDbMan); + + void VerifyDefaultDbUriL( + const TDesC& aExpectedUri, + CRepository* aRepository); + + }; + +#endif // CPOSTP111_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp114.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp114.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp114_H +#define CPOSTp114_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION +class CPosTp114BackupListener; +class MUtfwLog; + +/** +* Test procedure 114 +*/ +class CPosTp114 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp114() : CLandmarkTestProcedureBase(114) {}; + + /** + * Destructor. + */ + ~CPosTp114() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + TBool FileExistL(); + + void PrepareForRestoreTestL(); + + void InitBackupTestL(); + + TBool CheckDbAfterRestoreL(); + + private: + //CPosTp114BackupListener* iBackupListener; + + }; + +/** +* CPosTp114BackupListener +*/ +class CPosTp114BackupListener : public CActive + { + public: // Constructors and destructor + + // Two-phased constructor. + static CPosTp114BackupListener* NewL(MUtfwLog* aLog); + + /** + * C++ Destructor + */ + ~CPosTp114BackupListener(); + + void StartCheckingL(); + + protected: // Functions from base classes + + /** + * From CActive. + * Active Object event handler. + */ + void RunL(); + + /** + * From CActive. + * Active Object cancel handler. + */ + void DoCancel(); + + private: + + /** + * C++ Constructor + */ + CPosTp114BackupListener(); + + void ConstructL(MUtfwLog* aLog); + + TBool IsBackupRunning(); + + private: + + MUtfwLog* iLog; + RProperty iProperty; + TBool iBackupIsRunning; +}; + +#endif // CPOSTp114_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp116.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp116.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP116_H +#define CPOSTP116_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION +class CTP116ActiveLmEvent; + +/** +* Test procedure 116 +*/ + + +class CPosTp116 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp116(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp116() {}; + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void LandmarkEventTestL(); + + private: + + CTP116ActiveLmEvent* iActiveLmEvent; + + }; + +class CTP116ActiveLmEvent : public CActive + { + public: + + static CTP116ActiveLmEvent* NewL(CStifLogger* aLog); + + /** + * Destructor. + */ + ~CTP116ActiveLmEvent(); + + public: + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + private: + + /** + * C++ constructor. + */ + CTP116ActiveLmEvent(CStifLogger* aLog); + + void ConstructL(); + + void VerifyEvent(TPosLmDatabaseEvent event); + + TInt GetErrors(); + + void SetExpectedDatabase(const TDesC& aDatabaseUri); + + private: // data + + friend class CPosTp116; + + CStifLogger* iLog; + CPosLmDatabaseManager* iManager; + TPosLmDatabaseEvent iEvent; + + TInt iExpectedEvent; + TBuf<255> iExpectedDatabase; + + + TInt iGlobalErr; + + TBool iQueueTest; + + }; + +#endif // CPOSTP116_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp117.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp117.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP117_H +#define CPOSTP117_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +#include +// CLASS DECLARATION +class CTP117ActiveLmEvent; + +/** +* Test procedure 117 +*/ +class CPosTp117 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp117(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp117() {}; + + public: // Functions from base classes + + + /** + * + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + // Use this enum to define if the thread should exit with panic or leave + enum ExitType {ExitPanic, ExitLeave}; + + static void RunPanicTestL(TAny* aData); + + private: + void LandmarkEventTestL(); + + void LandmarkQueuedEvenTestL(); + + void LandmarkQueuedEvenTest2L(); + + void CreateThreadL(); + + void ResumeThreadAndVerifyExit(); + + private: + + CTP117ActiveLmEvent* iActiveLmEvent; + TInt iErrorsFound; + + RThread iThread; + TInt iExpectedErrorCode; + ExitType iExpectedExitType; + TInt iTestCase; + + }; + +class CTP117ActiveLmEvent : public CActive + { + public: + + static CTP117ActiveLmEvent* NewL(CStifLogger* aLog); + + /** + * Destructor. + */ + ~CTP117ActiveLmEvent(); + + public: + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + /** + * From CActive. + * + * Handles request completion event. + */ + TInt RunError(TInt aError); + + /** + * + */ + void CallNotifyDatabaseEvent(); + + void VerifyEventL(); + + TInt GetErrors(); + + void CallDatabaseUriFromLastEventLC(); + + private: + + /** + * C++ constructor. + */ + CTP117ActiveLmEvent(CStifLogger* aLog); + + void ConstructL(); + + void SetExpectedDatabase(const TDesC& aDatabaseUri); + + + private: // data + + friend class CPosTp117; + + CStifLogger* iLog; + + CPosLmDatabaseManager* iManager; + + + + TPosLmDatabaseEvent iEvent; + + TInt iExpectedEvent; + + TBuf<255> iExpectedDatabase; + + + TInt iGlobalErr; + + TBool iQueueTest; + TBool iCheckUri; + }; +#endif // CPOSTP117_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp118.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp118.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP118_H +#define CPOSTP118_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 118 +*/ +class CPosTp118 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp118(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp118() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void DeleteTp118FilesL(); + + private: + + TBool VerifyList(CDesCArray* aList, const TDesC& aDbName); + + void CreateLandmarksInDbL(const TDesC& aDbName, TInt aIndex=0); + + void DropTableL(const TDesC& aDbName, const TDesC& aTable); + + void DropIndexL(const TDesC& aDbName, const TDesC& aTable, const TDesC& aIndex); + + void AlterTableL(const TDesC& aDbName); + + void CheckLandmarkDbL(CPosLandmarkDatabase* aDb); + + private: + CDesCArray* iDatabases; + + }; + +#endif // CPOSTP118_H + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp119.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp119.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP119_H +#define CPOSTP119_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// FORWARD DECLARATIONS +class CPosLmMultiDbSearch; + +// DATA TYPES +enum TTp119SortOrder + { + ENoSort = 0, + EAsc, + EDesc + }; + +// CLASS DECLARATION + +/** +* Test procedure 119 +*/ +class CPosTp119 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp119(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp119() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void SearchAllDbsL(CDesCArray* aDbUris, TTp119SortOrder aSortOrder); + void SearchAllButOneL(CDesCArray* aDbUris); + void SearchOneDbL(CDesCArray* aDbUris); + void SearchNonExistingDbL(CDesCArray* aDbUris); + + void SearchInvalidURIDbL(CDesCArray* aDbUris); + + void SearchDbMultipleTimesL(CDesCArray* aDbUris); + void TestMaxNrOfMatchesL(CDesCArray* aDbUris); + void TestMatchIteratorL(CDesCArray* aDbUris); + + void SearchForLandmarksL( + CPosLmMultiDbSearch* aSearcher, + TTp119SortOrder aSortOrder, + TBool aRefined); + + TUint VerifyResultL( + CPosLmMultiDbSearch* aSearcher, + CDesCArray& aDbUris, + TTp119SortOrder aSortOrder); + + void RemoveDatabaseL(const TDesC& aFile); + + void VerifyDbsToSearchL( + CPosLmMultiDbSearch* aMultiSearcher, + CDesCArray* aDbUris); + + private: // Data + + }; + +#endif // CPOSTP119_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp12.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp12.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP12_H +#define CPOSTP12_H + +// INCLUDES +#include "EPos_LandmarksErrors.h" + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 12 +*/ +class CPosTp12 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp12(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp12() {}; + + public: + + static void RunPanicTestL(TAny* aData); + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + private: + + void CreateThreadL(); + + void ResumeThreadAndVerifyExit(); + + void ResourceFilePanicTestL(); + + CPosLandmarkDatabase* UseInvalidResourceFileL(); + + void RestoreResourceFileL(); + + + + private: + + RThread iThread; + TPositionLandmarksClientPanic iExpectedPanicCode; + TInt iTestCase; + TInt iTreadCounter; + }; + +#endif // CPOSTP12_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp120.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp120.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP120_H +#define CPOSTP120_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 23 +*/ +class CPosTp120 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp120(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp120() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + CPosLmAreaCriteria* AreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong); + + + void CheckDatabasesL( + CDesCArray* aExpectedLmUris, + TUint aExpectedMaxMatches = KPosLmMaxNumOfMatchesUnlimited + ); + + void GetLmIdsL( + TInt aDbId, + RArray aSearchResults, + RArray& aLmIdForADb + ); + + void CheckEqualsLmsL( + TPosLmItemId aSource, + TPosLmItemId aTarget + ); + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL(const RPointerArray& aSearchResults); + + void OnTheFlySearchL(); + + void SearchAndDeleteL(); + + void SearchAndRenameL(); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + void SearchWithMaximumL(); + + CDesCArray* CreateDatabasesL( + TInt aNrOfLmDbs, + TInt aLmPerDb, + TInt aLastId, + TBool aDebug = EFalse + ); + + private: + + CDesCArray* iDbArray; + + }; + +#endif // CPOSTP120_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp121.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp121.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP121_H +#define CPOSTP121_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// FORWARD DECLARATIONS +class CPosLmMultiDbSearch; +class CPosLmCategoryCriteria; + +// CLASS DECLARATION + +/** +* Test procedure 121 +*/ +class CPosTp121 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp121(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp121() {}; + + public: // Functions from base classes + + void CloseTest(); + + + void InitTestL(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + enum TTp121SortOrder + { + ESortNone, + ESortAscending, + ESortDescending + }; + + void TestSearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode = ESynchronous, + TTp121SortOrder aSortOrder = ESortNone); + + void SearchNonExistingL(TExecutionMode aExecutionMode); + + void SearchForLandmarksInGlobalCategoriesL(TExecutionMode aExecutionMode); + + void AddLandmarksToGlobalCategoriesL(); + + void TestMaximumNrOfMatchesL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void TestLeaveCodesL(); + + void SearchAndCancelL(); + + void ValidateIdL(TPosLmItemId aId, TInt aDbIndex); + + void ValidateTotalNrOfMatchesL( + TUint aRetrievedNrOfMatches, + TUint aExpectedNrOfMatches, + const TDesC& aCategoryName); + + void ValidateSearchResultsL( + CCategoryLandmarkSearchResult* aExpectedSearchResult, + CPosLmMultiDbSearch* aMultiDbSearcher, + TTp121SortOrder aSortOrder = ESortNone); + + void ValidateSearchResultsL( + const RIdArray& aExpectedIds, + CPosLmMultiDbSearch* aMultiDbSearcher, + TInt aNrOfExpectedErrors = 0); + + void SearchL( + CPosLmCategoryCriteria* aCatSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch = EFalse, + TTp121SortOrder aSortOrder = ESortNone); + + void TestResetSearchAttributesL(); + + void TestCaseInsensitiveL(); + + void TestWildCardsL(); + + void TestRefinedSearchL(TExecutionMode aExecutionMode); + + void TestDatabaseListL(const RIdArray& aExpectedMatches); + + void TestOnTheFlySearchL(const RIdArray& aExpectedMatches); + + TInt NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher); + + private: + + TUint iRestaurantId1; + TUint iRestaurantId2; + TUint iGasStationId1; + TUint iGasStationId2; + TUint iGarageId1; + CDesCArray* iDatabases; + CPosLmMultiDbSearch* iMultiDbSearch; + TInt iNrOfDatabases; + + }; + +#endif // CPOSTP121_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp122.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp122.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,255 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP122_H +#define CPOSTP122_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// FORWARD DECLARATIONS +class CPosLmMultiDbSearch; +class CNearestSearchResult; +// CLASS DECLARATION + +/** +* Test procedure 122 +*/ +class CPosTp122 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp122(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound = KErrNone;}; + /** + * Destructor. + */ + ~CPosTp122() {}; + + public: // Functions from base classes + + + + void CloseTest(); + + + void InitTestL(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + enum TTp122SortOrder + { + ESortNone, + ESortAscending, + ESortDescending + }; + + void AppendNearestSearchResultsL(); + + void TestLeaveCodesL(); + + void CancelTestL(const RPointerArray& aSearchResults, + TBool aCancelInCallback); + + void StartSearchOperationL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode = ESynchronous, + TTp122SortOrder aSortOrder = ESortNone, + TInt aNrOfSearches = 0); + + void SearchL( + CPosLmNearestCriteria* aNearestSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch = EFalse, + TTp122SortOrder aSortOrder = ESortNone); + + void TestMaximumNrOfMatchesL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode, TTp122SortOrder aSortOrder); + + void ValidateTotalNrOfMatchesL( + TUint aRetrievedNrOfMatches, + TUint aExpectedNrOfMatches); + + TInt NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher); + + void TestOnTheFlySearchL(const RPointerArray& aSearchResults); + + void ValidateIdL(TPosLmItemId aId, TInt aDbIndex); + + void PrepareDatabasesL(); + + void CheckSearchResultL(CNearestSearchResult& aSearchResult, TTp122SortOrder aSortOrder); + + void PrintLm(CPosLandmarkDatabase* db); + + void DoLastTestPartL(const RPointerArray& aSearchResults); + + void CheckDbL(); + + void SetupLimits(); + + private: + + CDesCArray* iDatabases; + CPosLmMultiDbSearch* iMultiDbSearch; + TInt iNrOfDatabases; + + RPointerArray iNearestSearchResults; + TInt iErrorsFound; + + CPosLmDisplayData* iDisplayData; + TBool iPartial; + + TUint iIdDb1Min; + TUint iIdDb1Max; + TUint iIdDb2Min; + TUint iIdDb2Max; + TUint iIdDb3Min; + TUint iIdDb3Max; + TUint iIdDb4Min; + TUint iIdDb4Max; + TUint iIdDb5Min; + TUint iIdDb5Max; + + }; + +// Commented for testing -- Moved these class defines to FT_CPosTp35.h + +class TSearchResult + { + public: + + TSearchResult(); + + TSearchResult(const TPosLmItemId& aId, const TReal32& aDistance); + + TReal64 Distance() const; + + TPosLmItemId Id() const; + + private: + friend class CPosTp122; + + TReal32 iDistance; + TPosLmItemId iId; + + }; + + + +class CNearestSearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CNearestSearchResult* NewL( + const TDesC& aDes, + const TInt& aIndex, + RFs& aFileSession); + + /** + * Destructor. + */ + ~CNearestSearchResult(); + + public: + + TReal64 Latitude() const; + + TReal64 Longitude() const; + + TBool UseCoverageRadius() const; + + TReal32 MaxDistance() const; + + TInt ErrorCode() const; + + void Print(TDes& aDes); + + void PrintDistances(TDes& aPrint); + + private: + + /** + * Constructor. + */ + CNearestSearchResult(RFs& aFileSession); + + void ConstructL(const TDesC& aDes, const TInt& aIndex); + + void AppendDistancesL(const TInt& aIndex); + + void ParseDistanceL(const TDesC& aDes, const TInt& aIndex, const TPosLmItemId& aId); + + void SortDistances(); + + private: + + // By default, prohibit copy constructor + CNearestSearchResult(const CNearestSearchResult&); + // Prohibit assigment operator + CNearestSearchResult& operator=(const CNearestSearchResult&); + + private: // Data + + friend class CPosTp122; + + enum TValueIndex + { + ELatitude =1, + ELongitude =2, + EUseCoverageRadius =3, + EMaxDistance =4, + EErrorCode =5, + ERedefined =6, + EMaxSearchResult =7, + ESearchResult =8 + }; + + TInt iErrorCode; + TReal64 iLatitude; + TReal64 iLongitude; + TBool iUseCoverageRadius; + TReal32 iMaxDistance; + TInt iMaxSearchResult; + + RArray iDistances; + + CPosLandmarkDatabase* iDatabase; + RFs& iFileSession; + }; + + +#endif // CPOSTP122_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp123.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp123.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP123_H +#define CPOSTP123_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// FORWARD DECLARATIONS +class CPosLmDatabaseManager; +class CPosLmMultiDbSearch; + +// CLASS DECLARATION + +/** +* Test procedure 123 +*/ +class CPosTp123 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp123(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp123() {}; + + public: // Functions from base classes + + + void CloseTest(); + + void InitTestL(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + enum TSearchCriterion + { + ENoCriterion, + ELocalCategoryId, + EGlobalCategoryId, + ECategoryName + }; + + void TestSearchL( + TBool aExecuteSync, + TSearchCriterion aCriterion, + TInt aNrOfHits, + TBool aSorted); + + void TestSearchCategoriesL(TBool aExecuteSync); + + void RemoveCategoriesFromLandmarksL(TInt aNrOfLandmarks); + + void SearchForUncategorizedLMsL(TInt aNrOfHits, TBool aSorted = EFalse); + + void RemoveCategoryFromDbL(TPosLmItemId aCategoryId, const TDesC& aDbUri); + + void VerifySearchResultL(TInt aNrOfHits, TBool aSorted); + + void VerifySortOrderL(CPosLmItemIterator* aIter, CPosLandmarkDatabase* aDb); + + private: + + RArray iIdArrays; + TBuf<200> iBuf; + CDesCArray* iDatabases; + TInt iNrOfDatabases; + CPosLmMultiDbSearch* iLandmarkSearch; + + }; + +#endif // CPOSTP123_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp124.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp124.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp124_H +#define CPOSTp124_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +// CLASS DECLARATION +class CPosLandmarkDatabase; +class CPosLmCompositeCriteria; +class CPosLmMultiDbSearch; +class CCompositeSearchResult; +//class TCoordinate; + +/** +* Test procedure 124 +*/ +class CPosTp124 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp124(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound = KErrNone;}; + /** + * Destructor. + */ + ~CPosTp124() {}; + + public: // Functions from base classes + + + + /** + * Always called even if test leaves, + * after test completion + */ + void CloseTest(); + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + + void InitTestL(); + + private: + + enum TTp124SortOrder + { + ESortNone, + ESortAscending, + ESortDescending, + ESortDistance + }; + + /* + * Use the file lmDbCompositeSearchResult.txt and parse + * all test combinations, perform all tests and check for correct result + */ + void StartLandmarksCompositeTestL(TExecutionMode aExecutionMode, TTp124SortOrder aSortOrder); + + /** + * Prints debug information about the composite search object + */ + void PrintCompositeInfo(CPosLmCompositeCriteria* aComposite); + + /** + * Test that it is possible to search for categories using the + * CPosLmCatNameCriteria class in a StartCategorySearchL search + */ + void TestCategoryCompositeSearchL(); + + /** + * Perform a test with a composite object used in a composite landmark search + */ + void TestCompositeInCompositeL(); + + /** + * Perform a test with two different text arguments combined in a composite landmark search + */ + void TestSeveralTextArgumentsL(); + + /** + * Test to add and remove search arguments to the CPosLmCompositeCriteria object + */ + void TestAddAndRemoveL(); + + /** + * Test that no result is returned if setting the aSearchOnlyPreviousMatches to ETrue + * and there is no previous result + */ + void TestWithNoPreviousResultL(); + + /** + * Test cancel of a composite search + */ + void CancelTestL(const TBool& aCancelInCallback); + + void LandmarksSortL(RArray& aArray, TTp124SortOrder aSortOrder); + + void SearchL( + CPosLmCompositeCriteria* aCompositeSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch = EFalse, + TTp124SortOrder aSortOrder = ESortNone); + + /** + * Test with different sort order scenarios, test sortpref for landmark and category + * also test with nearest + */ + void TestWithSortOrderLandmarksL(TExecutionMode aExecutionMode, + TTp124SortOrder aSortOrder); + + void TestWithSortOrderNearestL(TExecutionMode aExecutionMode, TTp124SortOrder aSortOrder); + + void PrepareDatabasesL(); + + void SetupLimits(); + + void PrintLm(CPosLandmarkDatabase* db); + + void ValidateIdL(TPosLmItemId aId, TInt aDbIndex); + + void ValidateSearchResultsL( + RIdArray& aExpectedIds, + TTp124SortOrder aSortOrder, + TInt aNrOfExpectedErrors = 0); + + TInt NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher); + + TBool CheckCompositeForIdListL(CPosLmCompositeCriteria* aComposite); + + void TestWithIdListAndCompositeL(); + + void TestOnTheFlySearchL(); + + void TestLessDbsToSearchL(); + + void CompositeStressTestL(TInt aStartNr, TInt aTotalNr); + + private: + + TUint iIdDb1Min; + TUint iIdDb1Max; + TUint iIdDb2Min; + TUint iIdDb2Max; + TUint iIdDb3Min; + TUint iIdDb3Max; + TUint iIdDb4Min; + TUint iIdDb4Max; + TUint iIdDb5Min; + TUint iIdDb5Max; + + TInt iErrorsFound; + + CDesCArray* iDatabases; + CPosLmMultiDbSearch* iMultiDbSearch; + TInt iNrOfDatabases; + /** + * contains inital db count afte removal of all db + */ + TInt iDbCount; + CPosLmDisplayData* iDisplayData; + TCoordinate iCoord; + + }; + +#endif // CPOSTp124_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp125.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp125.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp125_H +#define CPOSTp125_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include +//#include + +// CLASS DECLARATION + +/** +* Test procedure 125 +*/ +class CPosTp125 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp125(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp125() {delete iLandmarksMultiDbSearch; + delete iDbArray;}; + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithMaximumL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchAfterAddedCategoryL(); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + /** + * Include the global categories when searching + */ + void SearchGlobalL(const RPointerArray& aSearchResults, const TBool& aSync=EFalse); + + /** + * All categories are included in all databases. Remove so there are no duplicates. + */ + void RemoveExtraCategoriesL(); + + void RemoveCategoryL(CPosLmCategoryManager* aCatMan, + TPosLmItemId aCatId); + + + void AssertThatIdIsInCorrectDbL(TInt aDbIndex, TInt aId); + + void SetupDbArrayL(); + + void SortResultsL(RArray& aArray, + CDesCArrayFlat*& aResultArray); + + void InvertArrayL(CDesCArrayFlat*& aArray); + + void TestDuplicateGlobalCategoriesL(const RPointerArray& aSearchResults, const TBool& aSync=EFalse); + + // data members + private: + + CDesCArrayFlat* iDbArray; + CPosLmMultiDbSearch* iLandmarksMultiDbSearch; + + }; + +#endif // CPOSTp125_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp126.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp126.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp126_H +#define CPOSTp126_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include +#include "EPos_LandmarksErrors.h" + +enum TEnumStep + { + EStepZeroMaxMatches = 0, + EStepNegativeMaxMatches, + EStepUnlimitedMaxMatches, + EStepOutOfBoundsDatabaseUriPtr, + EStepOutOfBoundsGetSearchError, + EStepTooBigValueMatchIteratorL, + EStepTooBigValueNumOfMatches, + EStepIllegalSortPrefLMa, + EStepIllegalSortPrefLMb, + EStepIllegalSortPrefLMc, + EStepIllegalSortPrefLMd, + EStepIllegalSortPrefCat, + EStepNULLSearch1, + EStepNULLSearch2, + EStepNULLSearch3, + EStepNULLSearch4 + }; + +// CLASS DECLARATION + +/** +* Test procedure 126 +*/ +class CPosTp126 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp126(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp126() {delete iLandmarksMultiDbSearch; + iThread.Close();}; + + static void RunPanicTestL(TAny* aData); + + public: // Functions from base classes + + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void CreateThreadL(); + void ResumeThreadAndVerifyExitL(); + void ResourceFilePanicTestL(); + + // data members + private: + + CPosLmMultiDbSearch* iLandmarksMultiDbSearch; + RThread iThread; + TPositionLandmarksClientPanic iExpectedPanicCode; + + TEnumStep iStep; + }; + +#endif // CPOSTp126_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp127.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp127.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP127_H +#define CPOSTP127_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosTp127; + +// Data types +struct TThreadParam + { + void (*iTestFunction)(TDes*); + TDes* iMessage; + RThread* iThread; + }; + +class CThreadMonitor : public CActive + { + public: + + static CThreadMonitor* NewL(RThread* aThread); + + ~CThreadMonitor(); + + protected: + + void DoCancel(); + + void RunL(); + + private: + + CThreadMonitor(RThread* aThread); + + void ConstructL(); + + private: + + RThread* iThread; + + }; + +/** +* Test procedure 127 +*/ +class CPosTp127 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp127() : CLandmarkTestProcedureBase(127) {}; + + /** + * Destructor. + */ + ~CPosTp127() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called before StartL() + */ + void InitTestL(); + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + public: // New functions + + static void MultipleDbCategorySearchL(TDes* aMessage); + + static void MultipleDbLandmarkSearchL(TDes* aMessage); + + static void MultipleDbLandmarkWithoutCategorySearchL(TDes* aMessage); + + static void LockDatabaseL(TDes* aMessage); + + static void DbManagementL(TDes* aMessage); + + static void DbAccessL(TDes* aMessage); + + static void SingleDbSearchL(TDes* aMessage); + + static void MultipleDbSearchL(TDes* aMessage); + + static void CopyLockedDatabaseL(TDes* aMessage); + + static void CopyDatabaseL(TDes* aMessage); + + private: + + TBool ResumeThreadsAndVerifyExitL(const RArray& aThreadParams); + + TBool MultipleDbSearchClientsL(TBool aLockDb); + + TBool MultipleLmClientsL(); + + TBool VerifyInUseWhenCopyL(); + + TBool VerifyCopyStressL(); + + private: + + TBuf<100> iBuf; + + }; + +#endif // CPOSTP127_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp13.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp13.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP13_H +#define CPOSTP13_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + + + +enum TStifDialogType + { + EStifDialogTypeYesNo, + EStifDialogTypeOk, + EStifDialogTypeOkCancel, + EStifDialogTypeRetryCancel, + EStifDialogTypeYesNoCancel + }; +// CLASS DECLARATION + +/** +* Test procedure 13 +*/ +class CPosTp13 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp13(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound = KErrNone;}; + /** + * Destructor. + */ + ~CPosTp13() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(CStifItemParser&); + + + void CloseTest(); + + private: + + void ListCategoriesL( CPosLmCategoryManager& aCatMan ); + + void FindLandmarksL( + CPosLandmarkDatabase& aDb, + TPosLmItemId aCategoryId, + RArray& aLmIds ); + + CPosLandmark* FindLandmarkLC( CPosLandmarkDatabase& aDb, const TDesC& aName ); + + private: + TInt iErrorsFound; + }; + +#endif // CPOSTP13_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp130.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp130.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP130_H +#define CPOSTP130_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include "FT_CPosTp119.h" + +// FORWARD DECLARATIONS +class CPosLmMultiDbSearch; + +// DATA TYPES +class CMatchIteratorTester : public CActive + { + public: // Constructors and destructor + + static CMatchIteratorTester* NewLC( + CDesCArray* aDbUris, CStifLogger* iLog); + ~CMatchIteratorTester(); + + public: // Functions from base classes + + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + + public: // New Functions + + void RunTestL( + CPosLmMultiDbSearch* aMultiSearcher, + CPosLmOperation* aSearchOperation, + RPointerArray& aExpectedResult); + TInt Result() const; + void GetErrorMsg(TPtrC& aMsg) const; + + private: + + // Constructor + CMatchIteratorTester( CDesCArray* aDbUris, CStifLogger* aLog ); + + void VerifyIteratorsL(TInt aResult); + void CompareIteratorsL(CPosLmItemIterator& aNewIter, CPosLmItemIterator& aOldIter); + void SetErrorAndLeaveL(const TDesC& aErrMsg); + + private: // Data + + HBufC* iErrorMsg; + TInt iResult; + TReal32 iProgress; + CDesCArray* iDbUris; + CPosLmOperation* iOperation; + RPointerArray iIterators; + CPosLmMultiDbSearch* iMultiSearcher; + RPointerArray* iExpectedResult; + CStifLogger* iLog; + }; + +// CLASS DECLARATION + +/** +* Test procedure 130 +*/ +class CPosTp130 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + //CPosTp130() : CLandmarkTestProcedureBase(130) {}; + CPosTp130(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp130() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Initializes the test in the module + */ + virtual void InitTestL(); + + /** + * From CLandmarkTestProcedureBase + * Closes the test in the module + */ + virtual void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void SearchForLandmarksL(); + void SearchForCategoriesL(); + void VerifyIteratorsL(RArray& aNrOfExpectedItems, TBool aLm); + void TestErrorCodesL(); + void TestMatchIteratorL(TBool aSearchLm); + + void InitExpectedResultsL( const TDesC& aDbName, RIdArray& aArray, TBool aSearchLm ); + + private: // Data + + CDesCArray* iDbUris; + CPosLmMultiDbSearch* iDbSearcher; + RPointerArray iExpectedLmResult; // contains expected matches when search patern is *e* + RPointerArray iExpectedCatResult; // contains expected matches when search patern is *e* + + }; + +#endif // CPOSTP130_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp131.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp131.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP131_H +#define CPOSTP131_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 131 +*/ +class CPosTp131 : public CLandmarkTestProcedureBase, public MProgressObserver + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp131(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iAscendedSorted = ETrue;iErrorsFound=KErrNone;iPartialFlag=EFalse;}; + /** + * Destructor. + */ + ~CPosTp131() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + /** + * From MProgressObserver + * Notifies the progress of the execution of a CPosLmOperation object. + * + * @param sProgress the progress of the operation + */ + void NotifyProgress(TReal aProgress); + + private: + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL(const RPointerArray& aSearchResults); + + void SearchPartialLandmarksL(const RPointerArray& aSearchResults); + + void CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr); + + void CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const CPosLandmark::TAttributes& aAttr, + const RArray& aReqFields); + + void CheckResetL(const RPointerArray& aSearchResults); + + void CancelTestL(const RPointerArray& aSearchResults); + + void LandmarksSortL(RArray& aArray, const TPosLmSortPref& aSortPref); + + void ExecuteLmOpL(); + + private: + + CPosLmDisplayData* iDisplayData; + TBool iAscendedSorted; + TInt iErrorsFound; + TBool iPartialFlag; + }; + +#endif // CPOSTP131_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp132.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp132.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP132_H +#define CPOSTP132_H + +// INCLUDES +#include "EPos_LandmarksErrors.h" + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 132 +*/ +class CPosTp132 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp132(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp132() {}; + + public: + + /** + * Includes both Panic testing and testing of correct leave codes + */ + static void RunPanicTestL(TAny* aData); + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + /** + * Used as a callback method to unset display data + * from landmark search + * @param self + */ + TInt static UnsetTest(TAny* aSelf); + + /** + * Used as a callback method to unset display data + * from landmark multidb search + * @param self + */ + TInt static UnsetMultiSearch(TAny* aSelf); + + private: + + void CreateThreadL(); + + void ResumeThreadAndVerifyExit(); + + void RunLeaveTestL(); + + public: + // Use this enum to define if the thread should exit with panic or leave or return normally + enum ExitType {ExitPanic, ExitLeave, ExitNormal}; + + private: + + RThread iThread; + TInt iExpectedErrorCode; + ExitType iExpectedExitType; + TInt iTestCase; + TInt iErrorsFound; + }; + +#endif // CPOSTP132_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp133.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp133.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP133_H +#define CPOSTP133_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLmMultiDbSearch; +/** +* Test procedure 133 +*/ +class CPosTp133 : public CLandmarkTestProcedureBase, public MProgressObserver + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp133(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iLastNrOfDisplayData=0;iAscendedSorted = ETrue;iErrorsFound=KErrNone;iPartialFlag=EFalse;}; + /** + * Destructor. + */ + ~CPosTp133() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + /** + * From MProgressObserver + * Notifies the progress of the execution of a CPosLmOperation object. + * + * @param sProgress the progress of the operation + */ + void NotifyProgress(TReal aProgress); + + private: + + void DoSearchL( + const RPointerArray& aSearchResults, CDesCArray* aDbUris, + TExecutionMode aExecutionMode); + + void SearchPartialLandmarksL(TInt aWhatIndexToSerrachFor, + const RPointerArray& aSearchResults, + CDesCArray* aDbUris); + + void CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr); + + void CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const CPosLandmark::TAttributes& aAttr, + const RArray& aReqFields); + + void SearchPartialWithoutNameL(const RPointerArray& aSearchResults, + CDesCArray* aDbUris); + + void CheckResetL(const RPointerArray& aSearchResults, CDesCArray* aDbUris); + + void CancelTestL(const RPointerArray& aSearchResults, + CDesCArray* aDbUris, TBool aCancelInCallback); + + void LandmarksSortL(RArray& aArray, const TPosLmSortPref& aSortPref); + + /** + * Execute search operation, add testclass as observer + */ + void ExecuteLmOpL(); + + /** + * Execute search operation but cancel in callback, add testclass as observer + */ + void ExecuteLmOpInCallbackL(); + + private: + + CPosLmDisplayData* iDisplayData; + TBool iAscendedSorted; + TInt iErrorsFound; + TBool iPartialFlag; + CPosLmMultiDbSearch* iMultiLandmarkSearch; + TInt iLastNrOfDisplayData; + RArray* iJustNowSearchResults; + }; + +#endif // CPOSTP133_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp134.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp134.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp134_H +#define CPOSTp134_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + + +// CLASS DECLARATION +const TInt KTopTest = 17; +/** +* Test procedure 134 +*/ +class CPosTp134 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp134(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp134() {iDbArray.ResetAndDestroy(); + delete iDbMan;}; + + public: // Functions from base classes + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void CheckInfoL( + HPosLmDatabaseInfo* aDbInfo, + TInt aTestNr + ); + void SetupExpectedResultsL(); + + void CheckUriLengthL( + const TDesC& aUri, + TInt aExpectedErrorCode + ); + + + // data members + private: + CPosLmDatabaseManager* iDbMan; + + TChar iDbDrive[KTopTest]; + TMediaType iMediaType[KTopTest]; + TBool iDefaultDb[KTopTest]; + TBuf<50> iDbUri[KTopTest]; + TBuf<10> iProtocol[KTopTest]; + TBuf<25> iDbName[KTopTest]; + TBool iAttrSet[KTopTest]; + RPointerArray iDbArray; + TInt iErrorsFound; + }; + +#endif // CPOSTp134_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp135.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp135.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP135_H +#define CPOSTP135_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +/** +* Test procedure 135 +*/ +class CPosTp135 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp135(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp135() {}; + + public: // Functions from base classes + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void VerifyDbListL(CDesCArray* aDbArray); + + void VerifyDbInfoListL(RPointerArray aDbInfoList, RPointerArray aDbInfoList2); + + private: + CDesCArray* iDbArray; + TInt iErrorsFound; + + }; + +#endif // CPOSTP135_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp136.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp136.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp136_H +#define CPOSTp136_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 136 +*/ +class CPosTp136 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp136(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp136() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportL(const TDesC& aFile, const TDesC8& aMime); + + void TestParseL(const TDesC& aFile, const TDesC8& aMime); + + TInt iErrorsFound; + }; + + +#endif // CPOSTp136_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp137.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp137.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp137_H +#define CPOSTp137_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 137 +*/ +class CPosTp137 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp137(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp137() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime); + + void TestImport1L(const TDesC& aFile, const TDesC8& aMime); + + void CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList); + + private: + + CPosLandmarkParser* iLandmarkParser; + TInt iErrorsFound; + }; + + +#endif // CPOSTp137_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp139.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp139.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP139_H +#define CPOSTP139_H + +// INCLUDES +#include + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 24 +*/ +class CPosTp139 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp139(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp139() {}; + + + public: + + void GetSortAttribute(); + + + }; + +#endif // CPosTp139_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp141.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp141.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP141_H +#define CPOSTP141_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 141 +*/ +class CPosTp141 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp141(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp141() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + private: + + + void TestInvalidPositionFieldsL(); + }; + +#endif // CPOSTP141_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp143.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp143.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPosTp143_H +#define CPosTp143_H + +#include +#include "FT_CLandmarkTestProcedureBase.h" + +/** +* Test procedure 143 +*/ +class CPosTp143 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp143(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp143() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + + void AddLandmarksL(); + + void CheckCountersL(); + + private: // data + + RPointerArray iLandmarks; + }; + +#endif // CPosTp143_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp144.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp144.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP144_H +#define CPOSTP144_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include "lcfsbucommondefinitions.h" + + + +/** +* Test procedure 144 +*/ +class CPosTp144 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp144(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp144() {}; + + public: // Functions from base classes + + + void StartL(); + + private: + + void DumpBuffer(const TDesC8& aBuffer); + // check serialization + void CheckLmSerializationL(); + + CPosLandmark* CreateDummyLandmarkLC(); + void CompareLandmarks(CPosLandmark& aLm1, CPosLandmark& aLm2); + void CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2); + + void CheckLmSerialization_SubL(CPosLandmark* lm); + + private: + // common variables used in tests + TInt iErrorCounter; + + + }; + +#endif // CPOSTP144_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp145.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp145.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP145_H +#define CPOSTP145_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include "lcfsbucommondefinitions.h" + + + +/** +* Test procedure 145 +*/ +class CPosTp145 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp145(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp145() {}; + + public: // Functions from base classes + + + void StartL(); + + private: + + //void DumpBuffer(const TDesC8& aBuffer); + // check category serialization + void CheckLmCatSerializationL(); + void CheckLmCatSerialization_SubL(CPosLandmarkCategory* aTest); + void CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2); + CPosLandmarkCategory* CreateDummyCategoryLC(); + void CompareCategoriesL(CPosLandmarkCategory& aCat1, CPosLandmarkCategory& aCat2); + + private: + // common variables used in tests + TInt iErrorCounter; + + + }; + +#endif // CPOSTP145_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp146.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp146.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP146_H +#define CPOSTP146_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include "lcfsbucommondefinitions.h" + + + +/** +* Test procedure 146 +*/ +class CPosTp146 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp146(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp146() {}; + + public: // Functions from base classes + + + void StartL(); + + private: + + + // check serialization invalid + void CheckLmCatSerializationInvalidL(); + CPosLandmark* CreateDummyLandmarkLC(); + CPosLandmarkCategory* CreateDummyCategoryLC(); + + + private: + // common variables used in tests + TInt iErrorCounter; + + + }; + +#endif // CPOSTP146_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp147.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp147.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP147_H +#define CPOSTP147_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include "lcfsbucommondefinitions.h" + + + +/** +* Test procedure 147 +*/ +class CPosTp147 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp147(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp147() {}; + + public: // Functions from base classes + + + void StartL(); + + private: + + + // check serialization memory + void CheckSerializationMemoryL(); + CPosLandmark* CreateDummyLandmarkLC(); + CPosLandmarkCategory* CreateDummyCategoryLC(); + void CheckLmSerialization_MemoryL(); + void CheckLmCatSerialization_MemoryL(); + + + + private: + // common variables used in tests + TInt iErrorCounter; + + + }; + +#endif // CPOSTP147_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp148.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp148.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp148_H +#define CPOSTp148_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 148 +*/ +class CPosTp148 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp148(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp148() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp148_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp149.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp149.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp149_H +#define CPOSTp149_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 149 +*/ +class CPosTp149 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp149(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp149() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp149_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp15.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp15.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP15_H +#define CPOSTP15_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 15 +*/ +class CPosTp15 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp15() : CLandmarkTestProcedureBase(15) {}; + + /** + * Destructor. + */ + ~CPosTp15() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void TestInitializeDatabaseL(const TBool aSyncronously=EFalse); + + void TestInitializeWithUserWaitForL(); + + void TestInitializeDatabaseAndCancelL(); + }; + +#endif // CPOSTP15_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp150.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp150.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp150_H +#define CPOSTp150_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 150 +*/ +class CPosTp150 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp150(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp150() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp150_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp151.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp151.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp151_H +#define CPOSTp151_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 151 +*/ +class CPosTp151 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp151(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp151() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp151_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp152.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp152.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp152_H +#define CPOSTp152_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 152 +*/ +class CPosTp152 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp152(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp152() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp152_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp153.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp153.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp153_H +#define CPOSTp153_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 153 +*/ +class CPosTp153 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp153(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp153() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp153_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp154.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp154.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp154_H +#define CPOSTp154_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 154 +*/ +class CPosTp154 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp154(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp154() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp154_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp155.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp155.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp155_H +#define CPOSTp155_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 155 +*/ +class CPosTp155 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp155(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp155() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp155_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp156.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp156.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp156_H +#define CPOSTp156_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 156 +*/ +class CPosTp156 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp156(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp156() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp156_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp157.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp157.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp157_H +#define CPOSTp157_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 157 +*/ +class CPosTp157 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp157(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp157() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp157_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp158.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp158.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp158_H +#define CPOSTp158_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 158 +*/ +class CPosTp158 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp158(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp158() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp158_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp159.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp159.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp159_H +#define CPOSTp159_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 159 +*/ +class CPosTp159 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp159(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp159() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp159_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp16.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp16.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP16_H +#define CPOSTP16_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 16 +*/ +class CPosTp16 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp16() : CLandmarkTestProcedureBase(16) {}; + + /** + * Destructor. + */ + ~CPosTp16() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + CPosLandmarkDatabase* UseCorruptDbL(); + CPosLandmarkDatabase* UseTextDbL(); + CPosLandmarkDatabase* UseContactDbL(); + + // check that global categories are automatically inserter into lm db + // when recovering database + void CheckGlobalCategoriesL(); + + void SetupGlobalCategoriesL(); + + private: + RArray iGlobalCategoryIds; + RArray iGlobalCategoryNames; + }; + +#endif // CPOSTP16_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp160.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp160.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp160_H +#define CPOSTp160_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 160 +*/ +class CPosTp160 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp160(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp160() {}; + + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp160_H + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp161.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp161.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp161_H +#define CPOSTp161_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 161 +*/ +class CPosTp161 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp161(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp161() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportL(const TDesC& aFile, const TDesC8& aMime); + + void TestParseL(const TDesC& aFile, const TDesC8& aMime); + + TInt iErrorsFound; + }; + + +#endif // CPOSTp161_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp162.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp162.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp162_H +#define CPOSTp162_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 162 +*/ +class CPosTp162 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp162(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp162() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime); + + void TestImport1L(const TDesC& aFile, const TDesC8& aMime); + + void CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList); + + private: + + CPosLandmarkParser* iLandmarkParser; + TInt iErrorsFound; + }; + + +#endif // CPOSTp162_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp163.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp163.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp163_H +#define CPOSTp163_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 163 +*/ +class CPosTp163 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp163(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp163() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportL(const TDesC& aFile, const TDesC8& aMime); + + void TestParseL(const TDesC& aFile, const TDesC8& aMime); + + TInt iErrorsFound; + }; + + +#endif // CPOSTp163_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp164.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp164.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp164_H +#define CPOSTp164_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 164 +*/ +class CPosTp164 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp164(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp164() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime); + + void TestImport1L(const TDesC& aFile, const TDesC8& aMime); + + void CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList); + + private: + + CPosLandmarkParser* iLandmarkParser; + TInt iErrorsFound; + }; + + +#endif // CPOSTp164_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp17.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp17.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP17_H +#define CPOSTP17_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 17 +*/ +class CPosTp17 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp17() : CLandmarkTestProcedureBase(17) {}; + + /** + * Destructor. + */ + ~CPosTp17() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void SetupTestDataL(); + + private: // Data + + RArray iFootprints; + + RArray iDllNames; + + }; + +#endif // CPOSTP17_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp18.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp18.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP18_H +#define CPOSTP18_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// CLASS DECLARATION + + +/** +* Test procedure 18 +*/ +class CPosTp18 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp18(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp18() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestAllPartialAttributesL(); + + void TestPartialPositionFieldsL(); + + void PreparePartialLandmarksL(); + + void PreparePartialLandmarksAsyncL(TExecutionMode aExecutionMode); + + void PreparePartialLandmarksAsyncAndCancelL(const TBool& aInCallback=EFalse); + + void AppendFields(RArray& aArray); + + CPosLandmark* GetPartialLandmarkLC(const TPosLmItemId aId, + const CPosLmPartialReadParameters& partialParam); + + void CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const CPosLandmark::TAttributes& aAttr); + + void CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const RArray& aReqFields, + const RArray& aAvailFields); + + void CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr); + + private: // data + CArrayPtr* iArrayPtr; + + }; + +#endif // CPOSTP18_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp19.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp19.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP19_H +#define CPOSTP19_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 19 +*/ +class CPosTp19 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp19(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp19() {}; + + public: // Functions from base classes + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void TestGetByNameL(); + + void ReadLandmarksDbFileL(); + + void ParseCategoryL(const TDesC& aDes); + + void SetupGlobalCategoriesL(); + + void TestGetGlobalL(); + + void AddCategoriesL( TInt aNumofCats ); + + void VerifyAddedCategoriesL(); + + private: // Data + + enum TValueIndex + { + ECategoryId =0, + ECategoryName =1 + }; + + CPosLmCategoryManager* iCategoryManager; + RArray iCategoryIds; + RArray iGlobalCategoryIds; + + RPointerArray iCategoryNames; + RPointerArray iGlobalCategoryNames; + RPointerArray iCategories; + }; + +#endif // CPOSTP19_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp2.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP2_H +#define CPOSTP2_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +// CLASS DECLARATION + + +/** +* Test procedure 2 +*/ +class CPosTp2 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp2(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp2() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void WaitForEcomL(); + + }; + +#endif // CPOSTP1_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp20.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp20.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP20_H +#define CPOSTP20_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 20 +*/ +class CPosTp20 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp20(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp20() {}; + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + CPosLandmarkDatabase* ReplaceGlobalCategoriesL(); + + void SetupGlobalCategoriesL(); + + //setup the default categories. english version + //how to test russian?? + + void VerifyGlobalCategoriesL(TBool aCheck = ETrue); + + void RenameAndDeleteGlobalL(); + + void RemoveAllCategoriesL(); + + + // Added for BC testing + void UpdateGlobalCategoriesInDb(); + + + + + private: // Data + + CPosLmCategoryManager* iCategoryManager; + + RArray iGlobalCategoryIds; + + + RPointerArray iGlobalCategoryNames; + RArray iGlobalCategoryTestNames; + + TPosLmItemId iLmId; + TPosLmItemId iCategoryId; + }; + +#endif // CPOSTP20_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp21.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp21.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp21_H +#define CPOSTp21_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 21 +*/ +class CPosTp21 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + //CPosTp21() : CLandmarkTestProcedureBase(21) {}; + CPosTp21(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp21() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + /* void GetName( + TDes& aName + ) const; + */ + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void SearchL( + const RPointerArray& aSearchResults, + TBool aNameOrId=EFalse, + TExecutionMode aExecutionMode = ESynchronous); + + void SearchNonExistingL(TExecutionMode aExecutionMode); + + void SearchForLandmarksInGlobalCategoriesL(TExecutionMode aExecutionMode); + + void AddLandmarksToGlobalCategoriesL(); + + void SearchWithSortOrderL(); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + void TestSearchPatternLengthL(); + + // Added for BC testing + + void AddCategoriesL(); + + void AddLandmarksL(); + + // Added for testing (Should be made common metod in BaseClass ??) + void MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ); + + private: + TUint iRestaurantId1; + TUint iRestaurantId2; + TUint iGasStationId1; + TUint iGasStationId2; + TUint iGarageId1; + + // Added for BC testing + CPosLmCategoryManager* iCategoryManager; + RPointerArray iCategories; + //RArray iReferencedCategories; + RPointerArray iReferencedCategories; + RPointerArray iLandmarks; + + }; + +#endif // CPOSTp21_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp23.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp23.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP23_H +#define CPOSTP23_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 23 +*/ +class CPosTp23 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp23(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp23() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + private: + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL(const RPointerArray& aSearchResults); + + /** + * Verify error report "ESLI-62DBXR Landmarks - Sort order is not correctly implemented" + */ + void VerifySortOrderL(); + + void SearchAndDeleteL(const RPointerArray& aSearchResults); + + void SearchAndRenameL(const RPointerArray& aSearchResults); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + void TestMaxLengthL(); + + void TestInvalidPositionFieldsL(); + }; + +#endif // CPOSTP23_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp24.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp24.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP24_H +#define CPOSTP24_H + +// INCLUDES +#include + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 24 +*/ +class CPosTp24 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp24(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp24() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void SearchL(TExecutionMode aExecutionMode); + + void SearchWithSortOrderL(); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + static CPosLmAreaCriteria* NewLmAreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong); + + }; + +#endif // CPOSTP24_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp25.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp25.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp25_H +#define CPOSTp25_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +// CLASS DECLARATION + +/** +* Test procedure 23 +*/ +class CPosTp25 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp25(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp25() {}; + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithMaximumL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchWithSortOrderL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode); + + void SearchAfterAddedCategoryL(); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + void TestSearchPatternLengthL(); + + /** + * Include the global categories when searching + */ + void SearchGlobalL(const RPointerArray& aSearchResults, const TBool& aSync=EFalse); + + /** + * Verify error report "ESLI-62DBXR Landmarks - Sort order is not correctly implemented" + */ + void VerifySortOrderL(); + + }; + +#endif // CPOSTp25_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp3.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp3.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP3_H +#define CPOSTP3_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 3 +*/ +class CPosTp3 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp3(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp3() {}; + + public: // Functions from base classes + + void StartL(); + + private: + void TestOpenDbL(const TDesC& aDbURI); + }; + +#endif // CPOSTP3_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp30.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp30.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP30_H +#define CPOSTP30_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include + +// CLASS DECLARATION + +/** +* Test procedure 30 +*/ +class CPosTp30 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp30() : CLandmarkTestProcedureBase(30) {}; + + /** + * Destructor. + */ + ~CPosTp30() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static void RunTestL(TAny* aData); + + private: // Functions + + void StartMultipleClientsL(TUint aNoClients); + + void CreateThreadsL(const TUint aNoThreads); + + private: // data + + RArray iThreads; + TInt iThreadIndex; + + TBool iRemoveTest; + TBool iAsyncSearch; + }; + + + +#endif // CPOSTP30_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp31.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp31.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP31_H +#define CPOSTP31_H + +// INCLUDES + +#include +#include + + +#include "FT_CLandmarkTestProcedureBase.h" + + + +// CLASS DECLARATION + + +/** +* Test procedure 31 +*/ +class CPosTp31 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp31() : CLandmarkTestProcedureBase(31) {}; + + /** + * Destructor. + */ + ~CPosTp31() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + + public: + + static void RunReceiveEventsTestL(TAny* aData); + + static void CreateEventsTestL(TAny* aData); + + void LogError(const TDesC& aError); + + void CheckEvent(const TInt aThreadIndex, + const TPosLmEventType aExpectedEventType, + const TPosLmEventType aEventType, + const TPosLmItemId aExpectedItemId, + const TPosLmItemId aItemId); + + + private: // Functions + + void CreateThreadsL(); + + private: // data + + RArray iThreads; + TInt iErrors; + TBuf<4095> iErrorLog; + TInt iThreadIndex; + }; + +class CEventObserver : public CActive + { + public: // Constructors and destructor + + static CEventObserver* NewL(CPosTp31* aTp31, TInt aThreadIndex); + + /** + * Destructor. + */ + ~CEventObserver(); + + public: // Functions from base classes + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + void StartTimer(); + + private: + + /** + * C++ constructor. + */ + CEventObserver(CPosTp31* aTp31, TInt aThreadIndex); + + void ConstructL(); + + + + static TInt TimeoutCheck(TAny* aSelf); + + private: // Data + + CPosTp31* iTp31; + TInt iEventNumber; + TInt iThreadIndex; + TPosLmEvent iEvent; + CPosLandmarkDatabase* iDatabase; + CPeriodic* iPeriodicTimer; + TCallBack iCallback; + + + + }; + +#endif // CPOSTP31_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp33.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp33.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP33_H +#define CPOSTP33_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + + +// CLASS DECLARATION + + +//constants +/** +* Test procedure 33 +*/ +class CPosTp33 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp33() : CLandmarkTestProcedureBase(33) {}; + + /** + * Destructor. + */ + ~CPosTp33() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + static void RunTestL(TAny* aData); + + private: + + /** + * Opening and closing the landmark database serveral times fast + */ + void StressTestL(); + + /** + * TBD + */ + void ThreadTestL(); + + void StartMultipleClientsL(TUint aNoClients); + + void CreateThreadsL(const TUint aNoThreads); + + void KillTestL(); + + void ListAllServers(const TDesC& aServerName); + + void ListAllProcesses(const TDesC& aProcessName); + + void ListAllThreads(const TDesC& aThreadName); + + /** + * Prints the Landmark heap to the logfile. + */ + void MonitorHeapL(TBool aSetMaxHeap = EFalse); + + /** + * Get heap size for specified thread + * using the RThread::GetRamSizes() method on TARGET + */ + TInt GetHeapSizeL(const TDesC& aThreadName, TInt& aSize, TInt& aUsed); + + private: + + RArray iThreads; + TInt iThreadIndex; + CPosLandmarkDatabase* iLmd1; + CPosLandmarkDatabase* iLmd2; + TInt iMaxHeap; + }; + + + +#endif // CPOSTP33_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp34.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp34.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP34_H +#define CPOSTP34_H + +// INCLUDES +#include + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 34 +*/ +class CPosTp34 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp34() : CLandmarkTestProcedureBase(34) {}; + + /** + * Destructor. + */ + ~CPosTp34() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void CheckSearchResultL(CSearchResult& aSearchResult, + CPosLandmarkSearch& aLandmarkSearch, + CPosLmTextCriteria& aTextCriteria); + + private: // Data + + + + + }; + +#endif // CPOSTP34_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp35.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp35.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP35_H +#define CPOSTP35_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +class CNearestSearchResultTp35; + + +// CLASS DECLARATION + +/** +* Test procedure 35 +*/ +class CPosTp35 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp35(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp35() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + + void CheckSearchResultL(CNearestSearchResultTp35& aSearchResult); + + private: + + void SearchL(const TBool& aSync=EFalse); + + void SearchAndCancelL(const TBool& aInCallback=EFalse); + + void AppendNearestSearchResultsL(); + + CPosLandmarkDatabase* UseNearestSearchGeneratedDbFileL(); + + void SearchWithSortOrderL(); + + private: + + + RPointerArray iNearestSearchResults; + + }; + + +class TSearchResultTp35 + { + public: + + TSearchResultTp35(); + + TSearchResultTp35(const TPosLmItemId& aId, const TReal32& aDistance); + + TReal64 Distance() const; + + TPosLmItemId Id() const; + + private: + friend class CPosTp35; + + + TReal32 iDistance; + TPosLmItemId iId; + + }; + +class CNearestSearchResultTp35 : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CNearestSearchResultTp35* NewL( + const TDesC& aDes, + const TInt& aIndex, + RFs& aFileSession); + + /** + * Destructor. + */ + CNearestSearchResultTp35::~CNearestSearchResultTp35(); + + public: + + TReal64 Latitude() const; + + TReal64 Longitude() const; + + TBool UseCoverageRadius() const; + + TReal32 MaxDistance() const; + + TInt ErrorCode() const; + + void Print(TDes& aDes); + + void PrintDistances(TDes& aPrint); + + private: + + /** + * Constructor. + */ + CNearestSearchResultTp35(RFs& aFileSession); + + void ConstructL(const TDesC& aDes, const TInt& aIndex); + + void AppendDistancesL(const TInt& aIndex); + + void ParseDistanceL(const TDesC& aDes, const TInt& aIndex, const TPosLmItemId& aId); + + void SortDistances(); + + private: + + // By default, prohibit copy constructor + CNearestSearchResultTp35(const CNearestSearchResultTp35&); + // Prohibit assigment operator + CNearestSearchResultTp35& operator=(const CNearestSearchResultTp35&); + + private: // Data + + friend class CPosTp35; + + enum TValueIndex + { + ELatitude =1, + ELongitude =2, + EUseCoverageRadius =3, + EMaxDistance =4, + EErrorCode =5, + ERedefined =6, + EMaxSearchResult =7, + ESearchResult =8 + }; + + TInt iErrorCode; + TReal64 iLatitude; + TReal64 iLongitude; + TBool iUseCoverageRadius; + TReal32 iMaxDistance; + TInt iMaxSearchResult; + + RArray iDistances; + + CPosLandmarkDatabase* iDatabase; + RFs& iFileSession; + }; + +#endif // CPOSTP35_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp36.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp36.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp36_H +#define CPOSTp36_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 1 +*/ +class CPosTp36 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp36(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp36() {}; + + public: // Functions from base classes + + + /** + * Always called even if test leaves, + * after test completion + */ + void CloseTest(); + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + /** + * + */ + void DoTestL(TBool aSync, TInt aTestNr, TInt aNrOfHits); + + /** + * + */ + void DoSearchForCategoryL(TBool aSync); + + /** + * + */ + void RemoveCategoriesFromLandmarksL(TInt aNrOfLandmarks); + + /** + * + */ + TInt GetNrOfLandmarksL(); + + private: + RArray iArray; + + }; + +#endif // CPOSTp36_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp37.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp37.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp37_H +#define CPOSTp37_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 1 +*/ +class CPosTp37 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp37(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound = KErrNone;}; + /** + * Destructor. + */ + ~CPosTp37() {}; + + public: // Functions from base classes + + + + /** + * From CUtfwTestBase. Always called even if test leaves, + * after test completion + */ + void CloseTest(); + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * Test to mix CPosLmCatNameCriteria and CPosLmIdListCriteria + * in a StartCategorySearchL search, should leave + * Test to mix CPosLmCatNameCriteria and CPosLmIdListCriteria + * in a StartLandmarkSearchL search, should leave + */ + void TestCompositeAndCategoryL(TInt aTestNr); + + /** + * Test that it is not possible to mix landmark search and a landmark category search + * in a composite object. + * + * Test that it is not possible perform a search if the composite object + * does not have any arguments + */ + void DoErrorTestL(TInt aTestNr); + + /** + * Test that it is not possible to use only one ID List + * without any other search arguments + */ + void DoErrorTest3L(TInt aTestNr); + + /** + * Test that it is not possible to use several ID Lists + * in a composite search + */ + void DoErrorTest4L(TInt aTestNr); + + private: + TInt iErrorsFound; + + }; + +#endif // CPOSTp37_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp38.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp38.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp38_H +#define CPOSTp38_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkDatabase; +class CPosLmCompositeCriteria; +/** +* Test procedure 1 +*/ +class CPosTp38 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp38(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp38() {}; + + public: // Functions from base classes + + + + /** + * Always called even if test leaves, + * after test completion + */ + void CloseTest(); + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /* + * Use the file lmDbCompositeSearchResult.txt and parse + * all test combinations, perform all tests and check for correct result + */ + void StartLandmarksCompositeTestL(); + + /** + * Prints debug information about the composite search object + */ + void PrintCompositeInfo(CPosLmCompositeCriteria* aComposite); + + /** + * Test that it is possible to search for categories using the + * CPosLmCatNameCriteria class in a StartCategorySearchL search + */ + void TestCategoryCompositeSearchL(); + + /** + * Perform a test with a composite object used in a composite landmark search + */ + void TestCompositeInCompositeL(); + + /** + * Perform a test with two CPosLmCategoryCriteria objects + */ + void TestTwoLmCategoryCriteriaL(); + + /** + * Perform a test with two different text arguments combined in a composite landmark search + * with AND composition + */ + void TestSeveralTextArgumentsL(); + /** + * Perform a test with two different text arguments combined in a composite landmark search + * with OR composition + */ + void TestSeveralTextArgumentsWithORL(); + /** + * Test to check sort order when using OR composite criteria + */ + + void TestSortOrderWithORL(); + + /** + * Test to add and remove search arguments to the CPosLmCompositeCriteria object + */ + void TestAddAndRemoveL(); + + /** + * Test that no result is returned if setting the aSearchOnlyPreviousMatches to ETrue + * and there is no previous result + */ + void TestWithNoPreviousResultL(TInt aTestNr); + + /** + * Test cancel of a composite search + */ + void SearchAndCancelL(const TBool& aInCallback); + + /** + * Test with different sort order scenarios, test sortpref for landmark and category + * also test with nearest + */ + void TestWithSortOrderLandmarksL(); + + void TestWithSortOrderCategoriesL(); + + void TestWithSortOrderNearestL(); + + }; + +#endif // CPOSTp38_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp39.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp39.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP39_H +#define CPOSTP39_H + +// INCLUDES + +#include +#include + + +#include "FT_CLandmarkTestProcedureBase.h" + + +// CLASS DECLARATION + + +/** +* Test procedure 39 +*/ +class CPosTp39 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp39() : CLandmarkTestProcedureBase(39) {}; + + /** + * Destructor. + */ + ~CPosTp39() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + + public: + + static void RunEventsListenerL(TAny* aData); + + static void RunEventsGeneratorL(TAny* aData); + + void LogError(const TDesC& aError); + + void CheckEvent(const TInt aThreadIndex, + const TPosLmEventType aExpectedEventType, + const TPosLmEventType aEventType, + const TPosLmItemId aExpectedItemId, + const TPosLmItemId aItemId); + + + private: // Functions + + void SetupGlobalCategoriesL(); + + void CreateThreadsL(); + + TInt GetHeapSizeL(const TDesC& aThreadName, TInt& aHeapSize, TInt& aStackSize); + + private: // data + + RArray iThreads; + TInt iErrors; + TBuf<4095> iErrorLog; + TInt iThreadIndex; + }; + +class CEventObserverTp39 : public CActive + { + public: // Constructors and destructor + + static CEventObserverTp39* NewL(CPosTp39* aTp39, TInt aThreadIndex); + + /** + * Destructor. + */ + ~CEventObserverTp39(); + + public: // Functions from base classes + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + void StartTimer(); + + private: + + /** + * C++ constructor. + */ + CEventObserverTp39(CPosTp39* aTp39, TInt aThreadIndex); + + void ConstructL(); + + static TInt StopEventNotification(TAny* aSelf); + + private: // Data + + CPosTp39* iTp39; + TInt iEventNumber; + TInt iThreadIndex; + TPosLmEvent iEvent; + CPosLandmarkDatabase* iDatabase; + CPeriodic* iPeriodicTimer; + TCallBack iCallback; + + + + }; + +#endif // CPOSTP39_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp4.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp4.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP4_H +#define CPOSTP4_H + + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 4 +*/ +class CPosTp4 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp4(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp4() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void TestCompactL(TExecutionMode aExecutionMode); + + }; + +#endif // CPOSTP4_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp40.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp40.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp40_H +#define CPOSTp40_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 1 +*/ +class CPosTp40 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp40() : CLandmarkTestProcedureBase(40) {}; + + /** + * Destructor. + */ + ~CPosTp40() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + // Test error report ESLI-5ZYMPM + void TestPart1L(); + // Test error report ESLI-62FGEV + void TestPart2L(); + }; + +#endif // CPOSTp40_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp41.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp41.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp41_H +#define CPOSTp41_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + + +/** +* Test procedure 41 +*/ +class CPosTp41 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp41() : CLandmarkTestProcedureBase(41) {}; + + /** + * Destructor. + */ + ~CPosTp41() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + + /** + * This part verifies error report "ESLI-5ZDH4N Landmarks - Empty descriptors" + */ + void VerifyEmptyLandmarksL(); + + /** + * Check that landmark read from db has correct name and desc + */ + void CheckLandmarkL(TPosLmItemId aId, TDesC& aName, TDesC& aDesc); + + private: // data + + }; + +#endif // CPOSTp41_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp42.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp42.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP42_H +#define CPOSTP42_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + + +//CONSTANTA +const TInt NOLANDMARKNUMBER = 123; +// CLASS DECLARATION + +class CRecognizerData; + +/** +* Test procedure 42 +*/ +class CPosTp42 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp42(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp42() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + private: + + void TestWithBufferL(); + + void TestWithFileL(); + + void TestWithEmptyFileL(); + + void TestWithLargeFilesL(const TDesC& msg, TInt aExpCode); + + void CreateFileL( const TDesC& msg, TFileName& aFileName ); + + void CheckResultL(TDataRecognitionResult aExpectedResult, TDataRecognitionResult aResult); + + private: + RPointerArray iDataToRecognize; + TInt iErrorsFound; + + }; + +#endif // CPOSTP42_H + +/** +* Data class only used with TP42 to hold information +* read from the file i,e the data to be recongnized and +* the expected result. +*/ +class CRecognizerData: public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CRecognizerData* NewL(const TDesC& aDes); + + /** + * Destructor. + */ + ~CRecognizerData(); + + public: + + TPtrC RecognizerData() const; + + const TDataRecognitionResult& ExpectedResult() const; + + private: + + CRecognizerData(); + + void ConstructL(const TDesC& aDes); + + private: + // By default, prohibit copy constructor + CRecognizerData(const CRecognizerData&); + // Prohibit assigment operator + CRecognizerData& operator=(const CRecognizerData&); + + void ParseResult(const TDesC& aDes); + void ParseType(const TDesC& aDes); + + + private: // Data + + enum TValueIndex + { + ETextBuffer = 0, + EResult = 1, + EType = 2 + }; + HBufC* iRecognizerData; + TDataRecognitionResult iExpectedResult; + + }; + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp43.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp43.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP43_H +#define CPOSTP43_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkEncoder; +class CPosLandmarkParser; + +/** +* Test procedure 43 +*/ +class CPosTp43 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp43(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp43() {}; + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void TestErrorScenariosL(); + + /** + * Test that CPosLandmarkEncoder::SetOutputFileL leaves with + * KErrAlreadyExists if file already exists + */ + void ErrorScenario1L(); + + /** + * Test that CPosLandmarkEncoder::SetOutputFileL is opened in exclusive mode + */ + void ErrorScenario2L(); + + /** + * Test that CPosLandmarkEncoder::AddCollectionDataL leaves with KErrAlreadyExists if + * collection ID is used twice (or more) + */ + void ErrorScenario3L(); + + /** + * Test that it is not possible to set collection data "out-of-range" from TPosLmCollectionDataId + * (will be silently ignored) + * Test that it is possible to set collection meta data, + * the data will however not be encoded to the XML file (silently ignored) + */ + void ErrorScenario4L(); + + /** + * Test that it is possible to use XML tags as name/description/ etc + * verify that they are correct enocded + */ + void ErrorScenario5L(); + + /** + * Create all landmark items that should be encoded with the encoder + */ + void CreateEncoderPartsL(); + + + /** + * Check the data (XML) created by the eoncoder + */ + void ParseAndCheckDataFromEncoderL(const TDesC& aFile, const TDesC& aCollectionName, + const TDesC& aCollectiondDescription ,const TDesC8& aBuffer); + + /** + * Used for debugging + */ + void PrintParsedDataFromEncoderL(const TDesC& aFile, /*const TDesC& aCollectionName, + const TDesC& aCollectiondDescription, */const TDesC8& aBuffer); + + void PrintLandmarkIdFieldsL(const CPosLandmark& aLandmark); + + /** + * Test with long collection data field + */ + void TestLongCollectionFieldsL(TBool aUseFile); + + /** + * Compare two files + */ + void CompareTwoFilesL(const TDesC16& aCorrectFile, const TDesC16& aFile); + + /** + * Test with long filename as file output + */ + void TestWithLongFileNameL(); + + + void SetupGlobalCategoriesL(); + + + private: + CPosLandmarkEncoder* iLandmarkEncoder; + CPosLandmarkParser* iLandmarkParser; + RPointerArray iLandmarks; + TInt iErrorsFound; + RArray iGlobalCategoryIds; + RArray iGlobalCategoryNames; + RArray iGlobalCategoryTestNames; + + + }; + +#endif // CPOSTP43_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp44.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp44.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp44_H +#define CPOSTp44_H + +// INCLUDES +#include "EPos_LandmarksErrors.h" + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 44 +*/ +class CPosTp44 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp44(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp44() {}; + + public: + + /** + * Includes both Panic testing and testing of correct leave codes + */ + static void RunPanicTestL(TAny* aData); + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static TInt DeleteEncoderCallback(TAny* aSelf); + + private: + + void CreateThreadL(); + + void ResumeThreadAndVerifyExit(); + + void RunLeaveTestL(); + + public: + enum ExitType {ExitPanic, ExitLeave}; + + private: + + RThread iThread; + TInt iExpectedErrorCode; + ExitType iExpectedExitType; + TInt iTestCase; + }; + +#endif // CPOSTp44_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp45.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp45.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPosTp45_H +#define CPosTp45_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +//CONSTANTS + +// CLASS DECLARATION +class CPosLandmarkEncoder; + +/** +* Test procedure 45 +*/ +class CPosTp45 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp45(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp45() {}; + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + + void ExportLandmarksL( const TDesC& aFileName, + RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions); + + void ExportLandmarksIncL( const TDesC& aFileName, + RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions, + TBool aUseWaitForRequest); + + void ExportWithCollectionDataL(RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions); + + void ExportAndCancelL( const TDesC& aFileName, + const TBool& aInCallback, + CPosLandmarkDatabase::TTransferOptions aTransferOptions); + + void VerifyCancelL(const TDesC& aFileName, const TInt aMaxExported); + + void AddLandmarksL(); + + void AddCategoriesL(); + + void RenameGlobalCategoryL(); + + void TestErrorCodesL(); + + void DeleteFile(const TDesC& aFile); + + /** + * Test to export to a file with long filename (more than 255 characters) + */ + void ExportToFileWithLongFileNameL(); + + // Added for BC testing + void MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ); + + void SetupGlobalCategoriesL(); + + private: + + CPosLmCategoryManager* iCategoryManager; + RPointerArray iCategories; + RArray iGlobalCategoryIds; + RArray iGlobalCategoryNames; + RArray iGlobalCategoryTestNames; + + CPosLandmarkEncoder* iLandmarkEncoder; + + CBufBase* iBuffer; + + TBool iLogToFile; + + }; + +#endif // CPosTp45_H + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp46.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp46.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP46_H +#define CPOSTP46_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include + +// CLASS DECLARATION + +/** +* Test procedure 46 +*/ +class CPosTp46 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp46() : CLandmarkTestProcedureBase(46) {}; + + /** + * Destructor. + */ + ~CPosTp46() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static void RunTestL(TAny* aData); + + private: // Functions + + void RemoveFilesL(); + + void StartMultipleClientsL(TUint aNoClients); + + void CreateThreadsL(const TUint aNoThreads); + + private: // data + + enum TTestStep + { + ESync =0, + EInc =1, + EImportStarted =2, + EImportCancelled =3 + }; + + TInt iTestStep; + + RArray iThreads; + TInt iThreadIndex; + + }; + + + +#endif // CPOSTP46_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp47.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp47.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp47_H +#define CPOSTp47_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosLandmarkEncoder; +/** +* Test procedure 47 +*/ +class CPosTp47 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp47(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp47() {}; + + public: // Functions from base classes + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * Create XML data files used in this test + * The files then need to be manually changed + * aUseFile if data should be written to XML file + * if EFalse data is written to buffer (and then to a buffer file) + */ + void CreateXMLData(TBool aUseFile); + + /** + * Check XML data created in CreateXMLData + */ + void CheckXMLData(TBool aUseFile); + + /** + * + * @aFile the file name + */ + void PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType); + + void PrintLandmarkFieldsL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + void PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag=EFalse); + + /** + * Check that the parser does not support + * building index for parsed landmarks + */ + void CheckIndexNotSupportedL(); + + /** + * Check that cancel of parse is correct + */ + void DoCancelTestL(); + + + /** + * Trace to trace file + */ + void TraceL(const TDesC& msg); + + // Added for BC testing + void MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ); + + private: + CPosLandmarkParser* iLandmarkParser; + + CPosLandmarkEncoder* iLandmarkEncoder; + + RPointerArray iLandmarks; + + TInt iErrorsFound; + + CBufBase* iEncoderBuffer; + + CPosLmCategoryManager* iCategoryManager; + + }; + +#endif // CPOSTp47_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp48.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp48.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP48_H +#define CPOSTP48_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; + +/** +* Test procedure 48 +*/ +class CPosTp48 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp48(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp48() {}; + + public: // Functions from base classes + + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * Do the import of landmarks + */ + void ImportLandmarksL(TBool aSync, TBool aParseDone, TUint aTransferOption, const RArray& aLandmarkSubSet, TBool aDoParse=EFalse, TBool aCancel=EFalse); + + /** + * Prepare landmarkdb for test + */ + void ResetLandmarksDbL(); + + /** + * Create data used for this test + */ + void CreateXMLDataL(); + + + /** + * List all landmarks in db + */ + void ListLandmarksDbL(); + + /** + * Check that imported landmarks has been added to database + */ + void CheckLandmarksDatabaseL(TUint aTransferOption); + + void PrintLandmarkIdFieldsL(const CPosLandmark& aLandmark); + + /** + * Helper method, removing all associated categories from a landmark that should be "saved" + * in the iLandmarks array + */ + void RemoveCategoriesFromLandmarkL(CPosLandmark& aLandmark); + + /** + * Try to set a long file name as input + */ + void ImportFromFileWithLongFileNameL(); + + /** + * Helper method to check that a global category exists + and another does not + */ + void CheckGlobalCategoryExistL(const TDesC& aShouldExistName, const TDesC& aShouldNotExistName); + + /** + * Does the acutal test + */ + void DoTestL(TBool aFile, TBool aFullParse=EFalse, TBool aDoParse=EFalse, TBool aCancel=EFalse); + + /** + * Change input method after parse + */ + void DoTestChangeInputMethodL(); + + private: + CPosLandmarkParser* iLandmarkParser; + CPosLandmarkEncoder* iLandmarkEncoder; + RPointerArray iLandmarks; + TInt iErrorsFound; + CBufBase* iEncoderBuffer; + + + + }; + +#endif // CPOSTp48_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp49.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp49.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP49_H +#define CPOSTP49_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + + +// CLASS DECLARATION + +class CDatabaseClient; + +/** +* Test procedure 49 +*/ +class CPosTp49 : public CLandmarkTestProcedureBase, public MProgressObserver + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp49() : CLandmarkTestProcedureBase(49) {}; + + /** + * Destructor. + */ + ~CPosTp49() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Initializes a test before StartL is called. + */ + void InitTestL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + /** + * From MProgressObserver + */ + void NotifyProgress(TReal aProgress); + + private: + + void ImportAllLandmarksL(); + TInt ImportSomeLandmarksL(); + void VerifyImportedLandmarksL(TInt aNrOfExpectedItems); + void ParseLandmarksContentL(); + void RemoveThreeLandmarksL(); + void SetupPreConditionsL(); + void ExecuteLmOpL(TInt aExpectedResult, TBool aObserveProgress = EFalse); + void FetchIteratorL(); + void RecreateParserL(const TDesC& aFileName); + void StartImportLandmarksL(); + void CreateNameArrayL(TInt aNrOfItems); + + private: + + // Contains the IDs of the improted landmarks + RArray iImportedLandmarkIds; + + // Contains the IDs of imported landmarks that have been removed + RArray iRemovedLandmarkIds; + + // The parser that parses the xml file to import + CPosLandmarkParser* iLandmarkParser; + + // The iterator that is to be tested + CPosLmItemIterator* iIterator; + + // An array containing the names of the imported landmarks + CDesCArray* iLandmarkNames; + + // Indicates when it is time to fetch iterator of imported landmarks. + TReal iProgressInterruptLevel; + + }; + +#endif // CPOSTP49_H + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp5.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp5.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP5_H +#define CPOSTP5_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// CLASS DECLARATION + +/** +* Test procedure 5 +*/ +class CPosTp5 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + + CPosTp5(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp5() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void CheckGetMethodsL(CPosLandmark* aLandmark); + + void CheckRemoveMethodsL(CPosLandmark* aLandmark); + + void CheckRemovedL(CPosLandmark* aLandmark); + + void CheckPositionFieldL(const CPosLandmark& aLandmark, const TUint16 aId); + + void CheckFieldsMaxLengthL(); + + void CheckNaNErrorL(); + + }; + +#endif // CPOSTP51_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp50.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp50.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP50_H +#define CPOSTP50_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include + +// CLASS DECLARATION + +/** +* Test procedure 50 +*/ +class CPosTp50 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp50() : CLandmarkTestProcedureBase(50) {}; + + /** + * Destructor. + */ + ~CPosTp50() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static void RunTestL(TAny* aData); + + private: // Functions + + void StartMultipleClientsL(TUint aNoClients); + + void CreateThreadsL(const TUint aNoThreads); + + void ExportLandmarksL(); + + void TestESLI_64LLU3L(); + + private: // data + + enum TTestStep + { + ESync =0, + EInc =1, + EReadLockTaken =2, + ESearchCancelled =3 + }; + + TInt iTestStep; + + RArray iThreads; + TInt iThreadIndex; + + }; + + + +#endif // CPOSTP50_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp51.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp51.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp51_H +#define CPOSTp51_H + +// INCLUDES +#include "EPos_LandmarksErrors.h" + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 51 +*/ +class CPosTp51 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp51(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp51() {}; + + public: + + /** + * Includes both Panic testing and testing of correct leave codes + */ + static void RunPanicTestL(TAny* aData); + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + private: + + void CreateThreadL(); + + void ResumeThreadAndVerifyExitL(); + + void RunLeaveTestL(); + + void ListAllServers(); + + public: + // Use this enum to define if the thread should exit with panic or leave + enum ExitType {ExitPanic, ExitLeave}; + + private: + + RThread iThread; + TInt iExpectedErrorCode; + ExitType iExpectedExitType; + TInt iTestCase; + + TPtrC8 iMimeType; + TInt iThreadCounter; + TInt iErrorsFound; + }; + +#endif // CPOSTp51_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp52.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp52.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP52_H +#define CPOSTP52_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION +class CPosLandmarkParser; + +/** +* Test procedure 48 +*/ +class CPosTp52 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp52(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {iErrorsFound=KErrNone;}; + /** + * Destructor. + */ + ~CPosTp52() {}; + + public: // Functions from base classes + + + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + /** + * Do the import of landmarks + */ + TInt ImportLandmarksL(TBool aSync, TUint aTransferOption); + + /** + * Prepare landmarkdb for test + */ + void ResetLandmarksDbL(); + + /** + * Get nr of landmarks in lm db + */ + TInt GetNrOfLandmarksL(); + + /** + * Import landmarks from test, both sync and async + */ + void DoTestL( + const TDesC& aTestFile, + const TDesC8& aMimeType, + TInt aExpectedErrorCode, + TInt aExpNrImportedLandmarks=0); + + /** + * Check landmark in lm db + */ + void CheckLongLandmarkNameL(); + + /** + * Check landmark category in lm db + */ + void CheckLongCategoryNameL(TInt aNumExpectedCategories); + + private: + CPosLandmarkParser* iLandmarkParser; + TInt iErrorsFound; + + }; + +#endif // CPOSTp52_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp53.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp53.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPosTp53_H +#define CPosTp53_H + +// INCLUDES + +#include "FT_CLandmarkTestProcedureBase.h" + +class CActiveLmImportEvent; + +// CLASS DECLARATION + +/** +* Test procedure 53 +*/ +class CPosTp53 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp53() : CLandmarkTestProcedureBase(53) {}; + + /** + * Destructor. + */ + ~CPosTp53() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + */ + void CloseTest(); + + /** + * From CPosTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: // New functions + + /** + * Tests logging of landmark events + */ + void LandmarkImportEventTestL(); + + /** + * Test Compact during import + */ + void LandmarkImportCompactTestL(); + + void ImportLandmarksL(const TDesC& aFileName, CPosLandmarkDatabase::TTransferOptions aTransferOptions); + + void AddCategoriesL(); + + private: // Data + + CActiveLmImportEvent* iActiveLmEvent; + CPosLandmarkParser* iParser; + }; + +class CActiveLmImportEvent : public CActive + { + public: + + static CActiveLmImportEvent* NewL(MUtfwLog* aLog); + + /** + * Destructor. + */ + ~CActiveLmImportEvent(); + + public: + + void Start(); + + /** + * From CActive + * Handles request completion event. + */ + void DoCancel(); + + /** + * From CActive. + * + * Handles request completion event. + */ + void RunL(); + + private: + + /** + * C++ constructor. + */ + CActiveLmImportEvent(MUtfwLog* aLog); + + void ConstructL(); + + void VerifyEvent(); + + void AssertCorrectEvent(TPosLmEventType aExpectedEventType, + TPosLmEventType aEventType, + TPosLmItemId aExpectedLandMarkItemId, + TPosLmItemId aLandMarkItemId); + + private: // data + + friend class CPosTp53; + + MUtfwLog* iLog; + CPosLandmarkDatabase* iDatabase; + + TPosLmEvent iEvent; + TInt iEventNumber; + + TInt iGlobalErr; + + }; + +#endif // CPosTp53_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp56.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp56.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP56_H +#define CPOSTP56_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 56 +*/ +class CPosTp56 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp56() : CLandmarkTestProcedureBase(56) {}; + + /** + * Destructor. + */ + ~CPosTp56() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void TestOpenSpecificDbL(); + + void TestOpenDbL(const TDesC& aDbURI); + + void CopyTestDbL(); + + void TestMultipleExportL(); + + void CreateDatabasesL(); + + void TestLockedDatabaseL(); + + + }; + +#endif // CPOSTP56_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp57.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp57.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP57_H +#define CPOSTP57_H + +// INCLUDES +#include + +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 57 +*/ +class CPosTp57 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp57() : CLandmarkTestProcedureBase(57) {}; + + /** + * Destructor. + */ + ~CPosTp57() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + void CloseTest(); + + private: + + void CreateDatabasesL(); + + void SearchWithTextCriteriaL(); + + void SearchWithAreaCriteriaL(); + + static CPosLmAreaCriteria* NewLmAreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong); + }; + +#endif // CPOSTP56_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp58.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp58.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP58_H +#define CPOSTP58_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// CLASS DECLARATION +class CPosLandmarkParser; + +/** +* Test procedure 58 +*/ +class CPosTp58 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp58() : CLandmarkTestProcedureBase(58) {}; + + /** + * Destructor. + */ + ~CPosTp58() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called before StartL() + */ + void InitTestL(); + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + public: // New functions + + /** + * Creates, initializes and opens the default landmark database + */ + CPosLandmarkDatabase* InitDbLC(); + + /** + * Executes the import test thread + */ + static void RunImportTestL(TAny* aData); + + /** + * Executes the thread killing thread + */ + static void RunThreadKillerL(RThread* aThread); + + /** + * Does the import of landmarks + */ + void ImportLandmarksL(const RArray* aLandmarkSubSet); + + public: + + // Use this enum to define which test case to execute + enum TTestCase + { + ETestImportAllLandmarks, + ETestImportSubsetOfLandmarks + }; + + private: + + void ResumeThreadsAndVerifyExitL(); + + /** + * Returns ETrue if any errors are encountered, EFalse otherwise. + */ + TBool VerifyThreadExitResults( + TExitType aKillerThreadExitType, + TExitType aImportThreadExitType, + const TExitCategoryName& aImportThreadExitCategory, + TInt aImportThreadExitReason); + + private: + + TInt iExpectedErrorCode; + TTestCase iTestCase; + + }; + +#endif // CPOSTp58_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp6.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp6.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP6_H +#define CPOSTP6_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 6 +*/ +class CPosTp6 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp6(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp6() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + void CheckGetMethodsL(CPosLandmarkCategory* aCategory, const TDesC& aName); + + void CheckRemoveMethodsL(CPosLandmarkCategory* aCategory); + + void CheckRemovedL(CPosLandmarkCategory* aCategory); + + void CheckFieldsMaxLengthL(); + + void CheckEmptyCategoryNameL(); + + void CheckSetIconL(); + + }; + +#endif // CPOSTP6_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp7.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp7.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP7_H +#define CPOSTP7_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include + +// CLASS DECLARATION + +/** +* Test procedure 7 +*/ +class CPosTp7 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp7(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp7() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Always called, even if the test leaves + */ + void CloseTest(); + + static void RunTestL(TAny* aData); + + private: // Functions + + void CreateThreadsL(); + + private: // data + + RArray iThreads; + + TInt iThreadIndex; + TBool iOneSucces; + + }; + + + +#endif // CPOSTP7_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp76.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp76.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp76_H +#define CPOSTp76_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 76 +*/ +class CPosTp76 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp76() : CLandmarkTestProcedureBase(76) {}; + + /** + * Destructor. + */ + ~CPosTp76() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + void CloseTest(); + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + /** + * Use a corrupt global categories resource file + */ + void TestCorruptGlobalCategoriesFileL(); + + }; + +#endif // CPOSTp76_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp77.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp77.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP77_H +#define CPOSTP77_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// CLASS DECLARATION +class CPosLandmarkParser; + +/** +* Test procedure 77 +*/ +class CPosTp77 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp77() : CLandmarkTestProcedureBase(77) {}; + + /** + * Destructor. + */ + ~CPosTp77() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called before StartL() + */ + void InitTestL(); + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + public: // New functions + + /** + * Creates, initializes and opens the default landmark database + */ + CPosLandmarkDatabase* InitDbLC(); + + /** + * Executes the bad client test thread + */ + static void RunBadClientTestL(TAny* aData); + + /** + * Executes the thread killing thread + */ + static void RunThreadKillerL(TAny* aData); + + public: + + // Use this enum to define which test case to execute + enum TTestCase + { + ETestNotifyDbEvent, + ETestNotifyDbEvent2, + ETestInitialize, + ETestInitialize2, + ETestWriteLock, + ETestRegisterUri + }; + + private: + + void ResumeThreadsAndVerifyExitL(); + + /** + * Returns ETrue if any errors are encountered, EFalse otherwise. + */ + TBool VerifyThreadExitResultsL(TInt aBadThreadExitReason); + + /** + * Returns ETrue if any errors are encountered, EFalse otherwise. + */ + TBool VerifyLmServerIsAliveL(CPosLandmarkDatabase* aDb); + + public: + + RThread iBadThread; + TTimeIntervalMicroSeconds32 iTimeToWait; + + private: + + TInt iExpectedErrorCode; + TTestCase iTestCase; + TExitType iBadThreadExitType, iKillerThreadExitType; + TExitCategoryName iBadThreadExitCategory, iKillerThreadExitCategory; + TInt iBadThreadExitReason, iKillerThreadExitReason; + TTimeIntervalMicroSeconds32 iLastTimeToWait; + TBuf<100> iBuf; + + }; + +#endif // CPOSTP77_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp78.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp78.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP78_H +#define CPOSTP78_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION +class CPosLandmarkParser; +class CPosTp78; + +// Data types +struct TThreadParam + { + void (*iTestFunction)(TDes*); + TDes* iMessage; + }; + +class CThreadMonitor : public CActive + { + public: + + static CThreadMonitor* NewL(RThread* aThread); + + ~CThreadMonitor(); + + protected: + + void DoCancel(); + + void RunL(); + + private: + + CThreadMonitor(RThread* aThread); + + void ConstructL(); + + private: + + RThread* iThread; + + }; + +/** +* Test procedure 78 +*/ +class CPosTp78 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp78() : CLandmarkTestProcedureBase(78) {}; + + /** + * Destructor. + */ + ~CPosTp78() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called before StartL() + */ + void InitTestL(); + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + public: // New functions + + /** + * Creates and initializes the default landmark database + */ + void InitDbL(); + + /** + * Executes the open database test thread + */ + static void RunOpenDbTestL(TDes* aMessage); + + /** + * Executes the add remove LM test thread + */ + static void RunAddRemoveLmTestL(TDes* aMessage); + + /** + * Executes the import export LM test thread + */ + static void RunImportExportLmTestL(TDes* aMessage); + + /** + * Executes the database event test thread + */ + static void RunDbEventTestL(TDes* aMessage); + + /** + * Executes the read and update test thread + */ + static void RunReadAndUpdateTestL(TDes* aMessage); + + /** + * Function called from RunReadAndUpdateTestL + */ + static void UpdateLandmarksL(CPosLandmarkDatabase* aDb, TPosLmItemId aId, TDes* aMessage); + + private: + + void ResumeThreadsAndVerifyExitL(); + + private: + + TBuf<100> iBuf; + + }; + +#endif // CPOSTP78_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp79.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp79.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP79_H +#define CPOSTP79_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include +#include + +// CLASS DECLARATION +class CPosLandmarkParser; + +/** +* Test procedure 79 +*/ +class CPosTp79 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp79() : CLandmarkTestProcedureBase(79) {}; + + /** + * Destructor. + */ + ~CPosTp79() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called before StartL() + */ + void InitTestL(); + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + public: // New functions + + /** + * Creates and initializes the default landmark database + */ + void InitDbL(); + + /** + * Executes the search test thread + */ + static void RunSearchTestL(TDes* aMessage); + + /** + * Executes the add remove categories test thread + */ + static void RunAddRemoveCatsTestL(TDes* aMessage); + + /** + * Executes the read and update test thread + */ + static void RunReadAndUpdateTestL(TDes* aMessage); + + private: + + void ResumeThreadsAndVerifyExitL(); + + private: + + TBuf<100> iBuf; + + }; + +#endif // CPOSTP79_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp8.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp8.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP8_H +#define CPOSTP8_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" +#include + +// CLASS DECLARATION + +/** +* Test procedure 8 +*/ +class CPosTp8 : public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp8(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + /** + * Destructor. + */ + ~CPosTp8() {}; + + public: // Functions from base classes + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + + private: + void AddLandmarksL(CPosLandmarkDatabase* aDatabase); + + void UpdateLandmarksL(CPosLandmarkDatabase* aDatabase); + + void ReadLandmarksL(CPosLandmarkDatabase* aDatabase); + + void RemoveLandmarksL(CPosLandmarkDatabase* aDatabase); + + void RemoveLandmarksAsyncL(CPosLandmarkDatabase* aDatabase); + + void RemoveLandmarksAsyncWithWaitForReqL(CPosLandmarkDatabase* aDatabase); + + void CheckRemovedL(const TInt startIndex, const TInt stopIndex); + + void RemoveSetOfLandmarksL(CPosLandmarkDatabase* aDatabase); + + void ReadLandmarkL(TPosLmItemId aCategoryId); + + void RemoveLandmarksAsyncAndCancelL(); + + void CheckLandmarkNameMaxLengthL(); + + CPosLandmarkDatabase* BackupTp8DbFileL(); + + CPosLandmarkDatabase* RestoreTp8DbFileL(); + + private: //data + + RPointerArray iLandmarks; + + }; + +#endif // CPOSTP8_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp80.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp80.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTp80_H +#define CPOSTp80_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 80 +*/ +class CPosTp80 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp80() : CLandmarkTestProcedureBase(80) {}; + + /** + * Destructor. + */ + ~CPosTp80() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CUtfwTestBase + * Always called, even if test leaves + */ + void CloseTest(); + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void DeleteTestDbL(); + + }; + +#endif // CPOSTp80_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp81.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp81.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP81_H +#define CPOSTP81_H + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + +/** +* Test procedure 81 +*/ +class CPosTp81 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CPosTp81() : CLandmarkTestProcedureBase(81) {}; + + /** + * Destructor. + */ + ~CPosTp81() {}; + + public: // Functions from base classes + + /** + * From CUtfwTestBase + * Retrieves the test module name + * @param aName The name of the test module. + */ + void GetName( + TDes& aName + ) const; + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + private: + + void TestDifferentNamesL(); + + }; + +#endif // CPOSTp81_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp9.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CPosTp9.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef CPOSTP9_H +#define CPOSTP9_H + +// INCLUDES +#include +#include "FT_CLandmarkTestProcedureBase.h" + +// CLASS DECLARATION + + +/** +* Test procedure 9 +*/ +class CPosTp9 :public CLandmarkTestProcedureBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + + CPosTp9(TInt tpno, CStifLogger* aLog) : CLandmarkTestProcedureBase(tpno, aLog) {}; + + /** + * Destructor. + */ + ~CPosTp9() {}; + + public: // Functions from base classes + + + /** + * From CLandmarkTestProcedureBase + * Runs the test in the module + */ + void StartL(); + + /** + * From CLandmarkTestProcedureBase + * Cleans up after a test. + * Always called, even if the test leaves. + */ + void CloseTest(); + + private: + + void AddLandmarksL(); + + void IterateLandmarksL(); + + void IterateSetOfLandmarksL(); + + void IterateSortedLandmarksL(); + + CPosLandmark* InternalGet(TPosLmItemId id); + + void CheckIteratorArgL(const CPosLandmark::TAttributes& aAttr); + + + + private: // data + + RPointerArray iLandmarks; + }; + +#endif // CPOSTP9_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CSearchResult.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CSearchResult.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +#ifndef CSEARCHRESULT_H +#define CSEARCHRESULT_H + +// INCLUDES +#include +#include + +#include "Ft_CSearchResultBase.h" + +class CSearchResult : public CSearchResultBase + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CSearchResult* NewL(const TDesC& aDes); + + /** + * Destructor. + */ + ~CSearchResult(); + + public: + + TPtrC TextCriteria() const; + + const RArray& PositionFields() const; + + private: + + CSearchResult(); + + void ConstructL(const TDesC& aDes); + + + private: + + // By default, prohibit copy constructor + CSearchResult(const CSearchResult&); + // Prohibit assigment operator + CSearchResult& operator=(const CSearchResult&); + + void ParsePositionFields(const TDesC& aDes); + + void Print(); + + TBool Equals32(const TReal aValue1, const TReal aValue2, const TReal aAccuracy); + + private: // Data + + enum TValueIndex + { + ETextCriteria =0, + EAttributes =1, + EPositionFields =2, + ELmSearchResult =3, + ERedefined =4 + }; + + HBufC* iTextCriteria; + + RArray iPositionFields; + + }; + +#endif // CSEARCHRESULT_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CSearchResultBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_CSearchResultBase.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +#ifndef CSEARCHRESULTBASE_H +#define CSEARCHRESULTBASE_H + +// INCLUDES +#include +#include + + + +class CSearchResultBase : public CBase + { + + public: // Constructors and destructor + + CSearchResultBase(); + + /** + * Destructor. + */ + virtual ~CSearchResultBase(); + + public: + + RArray& SearchResult(); + + TBool FindSearchResult(const TPosLmItemId aId); + + TBool Redefined() const; + + TUint Attributes() const; + + protected: + + void ParseSearchResult(const TDesC& aDes); + + void ParseAttributesL(const TDesC& aDes); + + private: + + // By default, prohibit copy constructor + CSearchResultBase(const CSearchResultBase&); + // Prohibit assigment operator + CSearchResultBase& operator=(const CSearchResultBase&); + + protected: // Data + + TBool iRedefined; + + TUint32 iAttributes; + + RArray iSearchResult; + + private: // Data + + + }; + +#endif // CSearchResultBase_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_DatabaseUtility.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_DatabaseUtility.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef FT_DATABASEUTILITY_H +#define FT_DATABASEUTILITY_H + +// INCLUDES +#include + +// CONSTANTS +const TInt KPosLmSqlStatementMaxLen = 256; +_LIT(KPosLmSqlAll, "*"); +_LIT(KPosLmSqlSelect, "SELECT %S FROM %S"); + +// Table names +_LIT(KPosLmLandmarkTable, "lmt_landmark"); +_LIT(KPosLmLandmarkFieldTable, "lmt_lmfield"); +_LIT(KPosLmCategoryTable, "lmt_cat"); +_LIT(KPosLmLandmarkCategoryTable, "lmt_lmcat"); +_LIT(KPosLmIconTable, "lmt_icon"); +_LIT(KPosLmSettingsTable, "lmt_settings"); + +// COLUMN NAMES: Landmark table +_LIT(KPosLmLandmarkIdCol, "lmc_lmid"); +_LIT(KPosLmLatitudeCol, "lmc_lat"); +_LIT(KPosLmLongitudeCol, "lmc_long"); +_LIT(KPosLmAltitudeCol, "lmc_alt"); +_LIT(KPosLmHorizAccCol, "lmc_hacc"); +_LIT(KPosLmVertAccCol, "lmc_vacc"); +_LIT(KPosLmCoverageRadiusCol, "lmc_covrad"); +_LIT(KPosLmIconIdCol, "lmc_iconid"); +_LIT(KPosLmIconPicNrCol, "lmc_iconnr"); +_LIT(KPosLmMaskPicNrCol, "lmc_masknr"); +_LIT(KPosLmNameCol, "lmc_name"); +_LIT(KPosLmNDescCol, "lmc_desc"); + +// COLUMN NAMES: Landmark Field +// KPosLmLandmarkIdCol declared above +_LIT(KPosLmFieldTypeCol, "lmc_fieldtype"); +_LIT(KPosLmFieldStringCol, "lmc_fieldstr"); + +// COLUMN NAMES: Category table +_LIT(KPosLmCategoryIdCol, "lmc_catid"); +_LIT(KPosLmGlobalCategoryIdCol, "lmc_glcatid"); +// KPosLmIconIdCol declared above +// KPosLmIconPicNrCol declared above +_LIT(KPosLmCategoryNameCol, "lmc_catname"); +_LIT(KPosLmCategoryNameModifiedCol, "lmc_namemod"); + +// COLUMN NAMES: Landmark-Category table +// KPosLmLandmarkIdCol declared above +// KPosLmCategoryIdCol declared above + +// COLUMN NAMES: Icon table +// KPosLmIconIdCol declared above +_LIT(KPosLmIconPathCol, "lmc_iconpath"); + +// COLUMN NAMES: Landmark settings table +_LIT(KPosLmLanguageCol, "lmc_language"); +_LIT(KPosLmInitFlagCol, "lmc_init"); + +// INDEXES: Landmark table +_LIT(KPosLmLandmarkIdIndex, "lmi_lmid"); + +// INDEXES: Category table +_LIT(KPosLmCategoryIdIndex, "lmi_catid"); +_LIT(KPosLmGlobalCategoryIdIndex, "lmi_glcatid"); +_LIT(KPosLmCategoryNameIndex, "lmi_catname"); + +// INDEXES: Icon table +_LIT(KPosLmIconIdIndex, "lmi_iconid"); + +// CLASS DECLARATION +class RDbNamedDatabase; + +/** +* Utility function for landmark database. +*/ +class FTDatabaseUtility + { + + public: // New functions + + /** + * Removes the protocol (i.e. "file://") from the URI. This function + * assumes that the protocol is present first in the specified URI. + * + * @param aUri A URI. On out it contains the URI without the protocol. + */ + IMPORT_C static void RemoveProtocolFromUriL( + /* IN/OUT */ TPtrC& aDbUri + ); + + static void CreateDatabaseL(const TDesC& aDbpath, TBool aReplaceDatabase= EFalse, TBool aWrongId=EFalse, TBool aCreateInvalidIndex=EFalse); + + + private: + + static void CreateTablesL(RDbNamedDatabase& aDb, TBool aCreateInvalidIndex); + + static void CreateLandmarkTableL(RDbNamedDatabase& aDb, TBool aCreateInvalidIndex); + + static void CreateLandmarkFieldTableL(RDbNamedDatabase& aDb); + + static void CreateCategoryTableL(RDbNamedDatabase& aDb, TBool aCreateInvalidIndex); + + static void CreateLmCategoryTableL(RDbNamedDatabase& aDb); + + static void CreateIconTableL(RDbNamedDatabase& aDb); + + static void CreateSettingsTableL(RDbNamedDatabase& aDb); + + static void CreateIndexesL(RDbNamedDatabase& aDb); + + static void CreateIndexL(RDbNamedDatabase& aDb,const TDesC& aIndex, + const TDesC& aTable, + const TDesC& aColumn, + TBool aUnique + ); + + static void SetCounterToOneL(RDbNamedDatabase& aDb,const TDesC& aTable); + + }; + +#endif // FT_DATABASEUTILITY_H + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_LandmarkConstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/FT_LandmarkConstants.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,185 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#ifndef LANDMARKCONSTANTS_H +#define LANDMARKCONSTANTS_H + +#include + +// CONSTANTS + + +const TUint KTimeout = 10000000; + + +const TReal32 KHorizontalAcc = 10; +const TReal32 KVerticalAcc = 30; +const TReal64 KLatitude = 65.3; +const TReal64 KLongitude = 11.3; +const TReal32 KAltitude = 2; +const TReal32 KCoverageRadius = 50; + +_LIT(KMediaLinks, "3"); +_LIT(KMediaLink1, "https://www.aftonbladet.se"); +_LIT(KMediaLink2, "http://www.idg.se"); +_LIT(KMediaLink3, "http://www.svt.se"); +_LIT(KCountry, "Sweden"); + +_LIT(KHorizontalSpeed, "126"); +_LIT(KOrientation, "10"); + +_LIT(KMediaLinks2, "2"); +_LIT(KMediaLink4, "https://www.hotmail.com"); +_LIT(KMediaLink5, "http://www.sdsadsad.se"); + +_LIT(KXMLMediaLink1, "html/text/http://www.enator.se"); +_LIT(KXMLMediaLink2, "http://www.sdsadsad.se"); +_LIT(KXMLMediaLink3, "mailto:sergey@nokia.com"); +_LIT(KXMLMediaLink4, "news:comp.infosystems.www.servers.unix"); +_LIT(KXMLMediaLink5, "html/text/http://www.awdawdawd.se"); +_LIT(KXMLMediaLink6, "http://www.glassbilen.se"); +_LIT(KXMLMediaLink7, "//http://www.testofparsing.se"); +_LIT(KXMLMediaLink8, "text/plain/mailto:jani@nokia.com"); +_LIT(KXMLMediaLink9, "application/wordperfect 5.1/z://some_application.exe"); +_LIT(KXMLMediaLink10, "text/plain/news:comp.infosystems.www.servers.dos"); +_LIT(KXMLMediaLink11, "z:/some_link_to_somewhere1"); +_LIT(KXMLMediaLink12, "z://some_link_to_somewhere2"); +_LIT(KXMLMediaLink13, "text/link/z://some_link_to_somewhere3"); +_LIT(KXMLMediaLink14, "image/png/some_png_file.html"); + +//This is not exported, (ignored due to parsing) +//_LIT(KXMLMediaLink13, "z:\\some_link_to_somewhere3"); + +_LIT(KCountry2, "Finland"); +_LIT(KHorizontalSpeed2, "1"); +_LIT(KOrientation2, "120"); +_LIT(KLast, "Laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaast"); + +const TUint KNoPosFields = 7; +const TInt KNoCategories = 3; + +_LIT(KMbmFileName, "c:\\system\\test\\landmarkstestsicon.mbm"); +const TInt KIconIndex = 0; // EMbmLandmarkstestsiconTelogo_25x20i; +const TInt KIconMaskIndex = 0; + +const TReal32 KHorizontalAcc2 = 10; +const TReal32 KVerticalAcc2 = 30; +const TReal64 KLatitude2 = 45.3; +const TReal64 KLongitude2 = 21.2; +const TReal32 KAltitude2 = 2000; +const TReal32 KCoverageRadius2 = 360; + +_LIT(KMbmFileName2, "c:\\system\\test\\landmarkstestsicon.mbm"); +const TInt KIconIndex2 = 323; // EMbmLandmarkstestsiconTelogo_25x20i; + + +// Address Capabilities +_LIT(KCountryCode,"SE"); +_LIT(KState, "-"); +_LIT(KCounty, "County??"); +_LIT(KCity, "Gothenborg"); +_LIT(KDistrict,"Gårda"); +_LIT(KStreet, "Vädursgatan 6"); +_LIT(KStreetExtension, ""); +_LIT(KLocationName, "TietoEnator"); +_LIT(KPostalCode, "412 50"); +_LIT(KLocality, "Gårda"); +_LIT(KCrossing1, "Fabriksgatan"); +_LIT(KCrossing2, "Åvägen"); + +// Building Capabilities +_LIT(KBuildingName, "BuildingName"); +_LIT(KBuildingFloor, "7"); +_LIT(KBuildingRoom, "Yellow"); +_LIT(KBuildingZone, "BuildingZone"); +_LIT(KBuildingTelephone, "031444444"); + +_LIT(KName, "Micke's Pub"); +_LIT(KName2, "Drivhuset"); +_LIT(KCategoryName, "Pub"); +_LIT(KCategoryName2, "Resturant"); + +_LIT(KDescription, "jada jada jada jada jada jada jada jada jada jada jada"); +//_LIT(KDescription, "jada"); +_LIT(KDescription2, "asddsadsads gg"); + +//const TPosLmGlobalCategory KGlobalCategoryId = 123; + +const TInt KNoMultipleClients=5; + +const TInt KNoAddRequests=10; + +_LIT(KDefaultDb, "eposlm.ldb"); +_LIT(KTp25TestDb, "TP25Test.ldb"); +_LIT(KTp131TestDb, "TP131Test.ldb"); +_LIT(KTp1TestDb, "TP1Test.ldb"); +_LIT(KTp4TestDb, "TP4Test.ldb"); +_LIT(KTp10TestDb, "TP10Test.ldb"); +_LIT(KTp8TestDb, "TP8Test.ldb"); +_LIT(KDefaultDbPath, "c:\\system\\data\\"); +_LIT(KEmptyCopyPath, "c:\\system\\data\\eposEmpty.ldb"); +_LIT(KDb20, "EPOSLM_020.LDB"); +_LIT(KDb40, "EPOSLM_040.LDB"); +_LIT(KDb60, "EPOSLM_060.LDB"); +_LIT(KDb80, "EPOSLM_080.LDB"); +_LIT(KDb105, "EPOSLM_105.LDB"); +_LIT(KDbNamePath, "c:\\private\\100012a5\\DBS_101FE978_EPOSLM_%d.LDB"); +_LIT(KDbName, "eposlm_%d.ldb"); + +// Note: This is defined in landmarks +_LIT(KLmDbPath, "c:\\private\\100012a5\\DBS_101FE978_"); +_LIT(KLmFullDefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_EPOSLM.LDB"); +_LIT(KLmTp25DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP25TEST.LDB"); +_LIT(KLmTp131DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP131TEST.LDB"); +_LIT(KLmTp1DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP1TEST.LDB"); +_LIT(KLmTp4DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP4TEST.LDB"); +_LIT(KLmTp8DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP8TEST.LDB"); +_LIT(KLmTp10DefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP10TEST.LDB"); + +_LIT(KTestPath, "c:\\system\\test\\testdata\\"); + +_LIT(KLandmarksEmptyDb, "eposEmpty.ldb"); + +_LIT(KGlobalCategoryResFileWINS, "c:\\resource\\EPOSLMGLOBALCATEGORIES.R01"); +_LIT(KGlobalCategoryResFileROM, "c:\\resource\\EPOSLMGLOBALCATEGORIES.R01"); +_LIT(KGlobalCategoryResFileCOPY, "c:\\resource\\COPY_EPOSLMGLOBALCATEGORIES.R01"); + +#ifdef __WINS__ +_LIT(KCopyDbPath, "c:\\"); +_LIT(KLandmarksDb, "c:\\system\\test\\TestData\\eposlm.ldb"); + +_LIT(KCopiedDb, "c:\\eposlm.ldb"); +_LIT(KCompositeLandmarksDb, "c:\\system\\test\\TestData\\compositeeposlm.ldb"); +_LIT(K1000LandmarksDb, "eposlm_1000_LMs.ldb"); +_LIT(K5000LandmarksDb, "eposlm_5000_LMs.ldb"); +#else +_LIT(KCopiedDb, "c:\\system\\test\\eposlm.ldb"); +_LIT(KCopyDbPath, "c:\\system\\test\\"); +_LIT(KLandmarksDb, "c:\\system\\test\\TestData\\eposlm.ldb"); +_LIT(KCompositeLandmarksDb, "c:\\system\\test\\TestData\\compositeeposlm.ldb"); + +_LIT(K1000LandmarksDb, "eposlm_1000_LMs.ldb"); +_LIT(K5000LandmarksDb, "eposlm_5000_LMs.ldb"); +#endif + +#endif // LANDMARKCONSTANTS_H + +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/LandMarksTestModule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/LandMarksTestModule.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,229 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef LANDMARKSTESTMODULE_H +#define LANDMARKSTESTMODULE_H + +// INCLUDES +#include +#include +#include + + +#include "FT_CLandmarkTestProcedureBase.h" + +// Logging path +_LIT( KLandMarksTestModuleLogPath, "\\logs\\testframework\\LandMarksTestModule\\" ); +// Log file +_LIT( KLandMarksTestModuleLogFile, "LandMarksTestModule.txt" ); + + +class CLandMarksTestModule; + + +// CLASS DECLARATION + +/** +* CLandMarksTestModule test class for STIF Test Framework TestScripter. +*/ +NONSHARABLE_CLASS(CLandMarksTestModule) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CLandMarksTestModule* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CLandMarksTestModule(); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + private: + + /** + * C++ default constructor. + */ + CLandMarksTestModule( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Frees all resources allocated from test methods. + */ + void Delete(); + + /** + * Test methods are listed below. + */ + void RunTestProcedureL( + CLandmarkTestProcedureBase* tp, + CStifItemParser* aItem = NULL ); + + template + TInt TestProcedure( TInt aId, CStifItemParser& ); + + TInt FT_CPosTp1( CStifItemParser& aItem ); + TInt FT_CPosTp2( CStifItemParser& aItem ); + TInt FT_CPosTp3( CStifItemParser& aItem ); + TInt FT_CPosTp4( CStifItemParser& aItem ); + TInt FT_CPosTp5( CStifItemParser& aItem ); + TInt FT_CPosTp6( CStifItemParser& aItem ); + TInt FT_CPosTp7( CStifItemParser& aItem ); + TInt FT_CPosTp8( CStifItemParser& aItem ); + TInt FT_CPosTp9( CStifItemParser& aItem ); + + TInt FT_CPosTp10( CStifItemParser& aItem ); + TInt FT_CPosTp11( CStifItemParser& aItem ); + TInt FT_CPosTp12( CStifItemParser& aItem ); + TInt FT_CPosTp13( CStifItemParser& aItem ); +// TInt FT_CPosTp15( CStifItemParser& aItem ); +// TInt FT_CPosTp16( CStifItemParser& aItem ); +// TInt FT_CPosTp17( CStifItemParser& aItem ); + TInt FT_CPosTp18( CStifItemParser& aItem ); + TInt FT_CPosTp19( CStifItemParser& aItem ); + + TInt FT_CPosTp20( CStifItemParser& aItem ); + TInt FT_CPosTp21( CStifItemParser& aItem ); + TInt FT_CPosTp23( CStifItemParser& aItem ); + TInt FT_CPosTp24( CStifItemParser& aItem ); + TInt FT_CPosTp25( CStifItemParser& aItem ); + TInt FT_CPosTp26( CStifItemParser& aItem ); +// TInt FT_CPosTp27( CStifItemParser& aItem ); + TInt FT_CPosTp28( CStifItemParser& aItem ); +// TInt FT_CPosTp29( CStifItemParser& aItem ); + +// TInt FT_CPosTp30( CStifItemParser& aItem ); +// TInt FT_CPosTp31( CStifItemParser& aItem ); +// TInt FT_CPosTp33( CStifItemParser& aItem ); +// TInt FT_CPosTp34( CStifItemParser& aItem ); + TInt FT_CPosTp35( CStifItemParser& aItem ); + TInt FT_CPosTp36( CStifItemParser& aItem ); + TInt FT_CPosTp37( CStifItemParser& aItem ); + TInt FT_CPosTp38( CStifItemParser& aItem ); +// TInt FT_CPosTp39( CStifItemParser& aItem ); + +// TInt FT_CPosTp40( CStifItemParser& aItem ); +// TInt FT_CPosTp41( CStifItemParser& aItem ); + TInt FT_CPosTp42( CStifItemParser& aItem ); + TInt FT_CPosTp43( CStifItemParser& aItem ); + TInt FT_CPosTp44( CStifItemParser& aItem ); + TInt FT_CPosTp45( CStifItemParser& aItem ); +// TInt FT_CPosTp46( CStifItemParser& aItem ); + TInt FT_CPosTp47( CStifItemParser& aItem ); + TInt FT_CPosTp48( CStifItemParser& aItem ); +// TInt FT_CPosTp49( CStifItemParser& aItem ); + +// TInt FT_CPosTp50( CStifItemParser& aItem ); + TInt FT_CPosTp51( CStifItemParser& aItem ); + TInt FT_CPosTp52( CStifItemParser& aItem ); +// TInt FT_CPosTp53( CStifItemParser& aItem ); +// TInt FT_CPosTp54( CStifItemParser& aItem ); +// TInt FT_CPosTp55( CStifItemParser& aItem ); +// TInt FT_CPosTp56( CStifItemParser& aItem ); +// TInt FT_CPosTp57( CStifItemParser& aItem ); +// TInt FT_CPosTp58( CStifItemParser& aItem ); + +// TInt FT_CPosTp76( CStifItemParser& aItem ); +// TInt FT_CPosTp77( CStifItemParser& aItem ); +// TInt FT_CPosTp78( CStifItemParser& aItem ); +// TInt FT_CPosTp79( CStifItemParser& aItem ); + +// TInt FT_CPosTp80( CStifItemParser& aItem ); +// TInt FT_CPosTp81( CStifItemParser& aItem ); + + TInt FT_CPosTp100( CStifItemParser& aItem ); + TInt FT_CPosTp101( CStifItemParser& aItem ); + TInt FT_CPosTp102( CStifItemParser& aItem ); + TInt FT_CPosTp103( CStifItemParser& aItem ); + TInt FT_CPosTp104( CStifItemParser& aItem ); +// TInt FT_CPosTp105( CStifItemParser& aItem ); + TInt FT_CPosTp106( CStifItemParser& aItem ); +// TInt FT_CPosTp107( CStifItemParser& aItem ); +// TInt FT_CPosTp108( CStifItemParser& aItem ); +// TInt FT_CPosTp109( CStifItemParser& aItem ); + +// TInt FT_CPosTp111( CStifItemParser& aItem ); +// TInt FT_CPosTp114( CStifItemParser& aItem ); + TInt FT_CPosTp116( CStifItemParser& aItem ); + TInt FT_CPosTp117( CStifItemParser& aItem ); + TInt FT_CPosTp118( CStifItemParser& aItem ); + TInt FT_CPosTp119( CStifItemParser& aItem ); + + TInt FT_CPosTp120( CStifItemParser& aItem ); + TInt FT_CPosTp121( CStifItemParser& aItem ); + TInt FT_CPosTp122( CStifItemParser& aItem ); + TInt FT_CPosTp123( CStifItemParser& aItem ); + TInt FT_CPosTp124( CStifItemParser& aItem ); + TInt FT_CPosTp125( CStifItemParser& aItem ); + TInt FT_CPosTp126( CStifItemParser& aItem ); +// TInt FT_CPosTp127( CStifItemParser& aItem ); + + TInt FT_CPosTp130( CStifItemParser& aItem ); + TInt FT_CPosTp131( CStifItemParser& aItem ); + TInt FT_CPosTp132( CStifItemParser& aItem ); + TInt FT_CPosTp134( CStifItemParser& aItem ); + TInt FT_CPosTp133( CStifItemParser& aItem ); + TInt FT_CPosTp135( CStifItemParser& aItem ); + TInt FT_CPosTp136( CStifItemParser& aItem ); + TInt FT_CPosTp137( CStifItemParser& aItem ); + TInt FT_CPosTp139( CStifItemParser& aItem ); + + TInt FT_CPosTp141( CStifItemParser& aItem ); + TInt FT_CPosTp143( CStifItemParser& aItem ); + TInt FT_CPosTp144( CStifItemParser& aItem ); + TInt FT_CPosTp145( CStifItemParser& aItem ); + TInt FT_CPosTp146( CStifItemParser& aItem ); + TInt FT_CPosTp147( CStifItemParser& aItem ); + + TInt FT_CPosTp148( CStifItemParser& aItem ); + TInt FT_CPosTp149( CStifItemParser& aItem ); + TInt FT_CPosTp150( CStifItemParser& aItem ); + TInt FT_CPosTp151( CStifItemParser& aItem ); + TInt FT_CPosTp152( CStifItemParser& aItem ); + TInt FT_CPosTp153( CStifItemParser& aItem ); + TInt FT_CPosTp154( CStifItemParser& aItem ); + TInt FT_CPosTp155( CStifItemParser& aItem ); + TInt FT_CPosTp156( CStifItemParser& aItem ); + TInt FT_CPosTp157( CStifItemParser& aItem ); + TInt FT_CPosTp158( CStifItemParser& aItem ); + TInt FT_CPosTp159( CStifItemParser& aItem ); + TInt FT_CPosTp160( CStifItemParser& aItem ); + TInt FT_CPosTp161( CStifItemParser& aItem ); + TInt FT_CPosTp162( CStifItemParser& aItem ); + TInt FT_CPosTp163( CStifItemParser& aItem ); + TInt FT_CPosTp164( CStifItemParser& aItem ); + }; + +#endif // LANDMARKSTESTMODULE_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/lcfsbucommondefinitions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/inc/lcfsbucommondefinitions.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,339 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef _LCF_SBU_COMMON_DEFINITIONS_H_ +#define _LCF_SBU_COMMON_DEFINITIONS_H_ + +/////////////////////////////////////////////////////// +// +// SBu Common Definitions +// +/////////////////////////////////////////////////////// + +/** + $File: LcfSBuCommonDefitions.h + $Author: burnevsk $ + $Date: 2004/10/18 08:14:23 $ + $Revision: 1.6 $ +*/ + +/////////////////////////////////////////////////////// +// +// Constants +// +/////////////////////////////////////////////////////// + + +#include +#include +#include + +#define DEF_LCFPSY1_MODULEID 0x03133002 +#define DEF_LCFPSY2_MODULEID 0x03133004 +#define DEF_LCFPSY3_MODULEID 0x03133006 +#define DEF_LCFPSYSLOW4_MODULEID 0x03133008 +#define DEF_LCFPSY6_MODULEID 0x0313300c + +const TInt KLcfPsy1UidValue = DEF_LCFPSY1_MODULEID; +const TInt KLcfPsy3UidValue = DEF_LCFPSY3_MODULEID; +const TInt KLcfPsy6UidValue = DEF_LCFPSY6_MODULEID; + +const TInt KSecondsToMicro = 1000*1000; + +// Show service formt +_LIT(KShowServiceFormat, "Name: %S \nType: %d \n Id: %S"); + +// time value formatting +_LIT(KTimeSpec, "%H:%T:%S:%C"); + +// default requestors +_LIT(KServiceName, "Lcf.Service"); +_LIT(KServiceId, "Lcf.ServiceId"); + +_LIT(KContactName, "Lcf.Contact"); +_LIT(KPhone, "+79217654321"); + +_LIT(KFieldNamePhone, "Phone"); +_LIT(KFieldNameEmail, "Email"); +_LIT(KFieldNameUrl, "Url"); + +/////////////////////////////////////////////////////// +// +// Other text +// +/////////////////////////////////////////////////////// + +// Indicate not yet implemented +_LIT(KNotImplemented, "Not yet implemented"); + +//_LIT(KBadRequestResult, "Wrong location request result (result=%d, expected=%d)"); +//_LIT(KBadDiagNum, "Wrong number of events in Notifier (count=%d, expected=%d)"); +//_LIT(KBadLcfResult, "Wrong notifier event result (result=%d, expected=%d)"); + +_LIT(KBadDiagVerifEventNum, "Wrong number of Verification events in Notifier"); +_LIT(KBadDiagNotifEventNum, "Wrong number of Notification events in Notifier"); + +/////////////////////////////////////////////////////// +// +// Here are macros for error logging +// Those imply that are called from within of +// CUtfwTestBase-derived class's function (they use iLog member) +// +/////////////////////////////////////////////////////// + +// LEAVES with _error_ if _condition_ is true +#define LEAVE(condition, error) \ + if (condition) { \ + errStr.Format(_L("%s (line %d)"), _S(error), __LINE__); \ + iLog->Log(errStr); \ + User::Leave(KErrGeneral); \ + } + +// if _error_ is descritor +#define LEAVE_DES(condition, error_des) \ + if (condition) { \ + errStr.Format(_L("%S (line %d)"), &error_des, __LINE__); \ + iLog->Log(errStr); \ + User::Leave(KErrGeneral); \ + } + +// Must be included in the begging of function definition +// in order to use following ("ERROR") macros +// (The string buffer needs to be defined once, otherwise, +// in case when a lot of errors are checked, stack may be +// overflown, and copilation will fail) +#define DECLARE_ERROR_STR TBuf<160> errStr; +#define DECLARE_MESSAGE_STR TBuf<160> message; + +#define DECLARE_ERROR_LOGGING DECLARE_ERROR_STR DECLARE_MESSAGE_STR + +#define START_ERROR_LOGGING iErrorCounter = 0; + +// Logs a message, which is defined as "..." constant +#define LOG(msg) \ + { \ + errStr.Format(_L("%s (line %d)"), _S(msg), __LINE__); \ + iLog->Log(errStr); \ + } +#define LOG_DES(msg_des) \ + { \ + errStr.Format(_L("%S (line %d)"), &msg_des, __LINE__); \ + iLog->Log(errStr); \ + } + +#define LOG_FORMAT_1(_format, _param) \ + message.Format(_format, _param); \ + LOG_DES(message); + +#define LOG_FORMAT_2(_format, _param1, _param2) \ + message.Format(_format, _param, _param2); \ + LOG_DES(message); + +#define LOG_IIF(condition, msg1, msg2) \ + if (condition) LOG(msg1) else LOG(msg2) + +// Logs an error, which is defined as "..." constant +#define ERR(error) \ + { \ + errStr.Format(_L("%s (line %d)"), _S(error), __LINE__); \ + iLog->Log(errStr); \ + iErrorCounter++; \ + } +#define ERR_DES(error) \ + { \ + errStr.Format(_L("%S (line %d)"), &error, __LINE__); \ + iLog->Log(errStr); \ + iErrorCounter++; \ + } + +// Logs an _error_ if _condition_ is true +#define ERROR(condition, error) \ + if (condition) ERR(error) + +// Logs an error, which defined as descriptor +#define ERROR_DES(condition, error_des) \ + if (condition) ERR_DES(error_des) + +#define ERROR_1(condition, msg_fmt_des, param1) \ + message.Format(msg_fmt_des, param1); \ + ERROR_DES(condition, message); + +#define ERROR_2(condition, msg_fmt_des, param1, param2) \ + message.Format(msg_fmt_des, param1, param2); \ + ERROR_DES(condition, message); + +#define ERROR_3(condition, msg_fmt_des, param1, param2, param3) \ + message.Format(msg_fmt_des, param1, param2, param3); \ + ERROR_DES(condition, message); + +#define IF_ERROR(error_code, msg) \ + { TInt32 _err = error_code; \ + ERROR_2(_err != KErrNone, _L("%s (error=%d)"), _S(msg), _err); } + +#define IF_ERROR_DES(error_code, msg_des) \ + { TInt32 _err = error_code; \ + ERROR_2(_err != KErrNone, _L("%S (error=%d)"), &msg_des, _err); } + +#define CHECK_EQUAL(_actual, _expected, _msg) \ + ERROR_3(_actual != _expected, _L("%s (actual=%d, expected=%d)"), _S(_msg), _actual, _expected); + +#define CHECK_EQUAL_DES(_actual, _expected, _msg_des) \ + ERROR_3(_actual != _expected, _L("%S (actual=%d, expected=%d)"), &_msg_des, _actual, _expected); + +// Leaves if there were errors generated by ERROR macros +// (put it at the end of you test function) +#define LEAVE_IF_ERRORS() \ + if (iErrorCounter > 0) { \ + errStr.Format(_L("There were %d errors in the test, see previous messages!"), iErrorCounter); \ + iLog->Log(errStr); \ + User::Leave(KErrGeneral); \ + } + +#define PAUSE_MS(_microseconds) \ + User::After(TTimeIntervalMicroSeconds32(_microseconds)); +#define PAUSE(_seconds) \ + PAUSE_MS(_seconds * KSecondsToMicro) + +class TWatch +{ + public: + TWatch() { RestartWatch(); }; + void RestartWatch() { iTime.UniversalTime(); iLastTick = iTime; }; + void Tick() { iLastTick.UniversalTime(); }; + TTimeIntervalMicroSeconds ElapsedTotal() + { + TTime now; + now.UniversalTime(); + return now.MicroSecondsFrom(iTime); + }; + TTimeIntervalMicroSeconds ElapsedFromTick() + { + TTime now; + now.UniversalTime(); + return now.MicroSecondsFrom(iLastTick); + }; + TTime Time() {return iTime; }; + private: + TTime iTime; + TTime iLastTick; +}; + +class TThreadUtility +{ + public: + typedef void (*TThreadFunctionL)(TAny* aPtr); + + struct TOptions + { + TThreadFunctionL ThreadFunctionL; + TAny* parameters; + }; + + static TInt ThreadFunction(TAny* aPtr) + { + CTrapCleanup* cs = CTrapCleanup::New(); + if (cs == NULL) + { + return KErrNoMemory; + } + + // new ActiveScheduler + CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; + CActiveScheduler::Install(scheduler); + + TOptions* options = reinterpret_cast(aPtr); + TRAPD(err, (*options->ThreadFunctionL)(options->parameters)); + + delete scheduler; + delete cs; + User::Exit(err); + return err; + }; + + void CreateL(const TDesC& aThreadName, TOptions* aOptions) + { + iName.Set(aThreadName); + User::LeaveIfError( iThread.Create(aThreadName, + TThreadUtility::ThreadFunction, + KDefaultStackSize, + KMinHeapSize, + 10 * KMinHeapSize, + aOptions, + EOwnerProcess)); + }; + void CreateReuseHeapL(const TDesC& aThreadName, TOptions* aOptions) + { + iName.Set(aThreadName); + User::LeaveIfError( iThread.Create(aThreadName, + TThreadUtility::ThreadFunction, + KDefaultStackSize, + &User::Heap(), + aOptions, + EOwnerProcess)); + }; + void Start() + { + iThread.Resume(); + }; + void Stop() + { + iThread.Suspend(); + }; + + TInt Wait() + { + TRequestStatus threadStatus; + if (iThread.ExitType() == EExitPending) // still executing + { + iThread.Logon(threadStatus); + User::WaitForRequest(threadStatus); + } + return iThread.ExitReason(); + }; + + const RThread Handle() + { + return iThread; + }; + + void Format(TDes& aMessage) + { + TExitCategoryName category = iThread.ExitCategory(); + _LIT(KThreadFormat, "Thread %S, Reason %d, ExitType %d, ExitName %S"); + aMessage.Format(KThreadFormat, + &iName, iThread.ExitReason(), iThread.ExitType(), &category); + }; + + // used if class destroyed + void Close() + { + if (iThread.Handle()) + { + if (iThread.ExitType() == EExitPending) // still executing + { + iThread.Kill(KErrNone); + } + iThread.Close(); + } + }; + + protected: + RThread iThread; + TPtrC iName; +}; + +#endif // _LCF_SBU_COMMON_DEFINITIONS_H_ diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/init/TestFramework.ini Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,172 @@ +# +# This is STIFTestFramework 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. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +[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= YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= NormalCases.txt +# TestCaseFile= SmokeCases.txt +# TestCaseFile= 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= c:\testframework\LandMarksTestModule1.cfg +[End_Module] + +#Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= testcases1.cfg +#TestCaseFile= testcases2.cfg +#TestCaseFile= manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework 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. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +EmulatorBasePath= C:\ +EmulatorFormat= TXT # Possible values: TXT or HTML +EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +HardwareBasePath= C:\ +HardwareFormat= TXT # Possible values: TXT or HTML +HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # 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 + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CAreaSearchResult.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CAreaSearchResult.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include "FT_CAreaSearchResult.h" + +//CONSTANTS +const TInt KMaxFieldLength = 80; + +// C++ Constructor +CAreaSearchResult::CAreaSearchResult() + { + } + +CAreaSearchResult* CAreaSearchResult::NewL(const TDesC& aDes) + { + CAreaSearchResult* self = new(ELeave) CAreaSearchResult; + CleanupStack::PushL(self); + self->ConstructL(aDes); + CleanupStack::Pop(); + return self; + } + +// C++ destructor +CAreaSearchResult::~CAreaSearchResult() + { + + } + +void CAreaSearchResult::ConstructL(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt redefined=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ESouthLat: + val.Val(iSouthLat, TChar(',')); + break; + case ENorthLat: + val.Val(iNorthLat, TChar(',')); + break; + case EWestLong: + val.Val(iWestLong, TChar(',')); + break; + case EEastLong: + val.Val(iEastLong, TChar(',')); + break; + case EErrorCode: + val.Val(iErrorCode); + break; + case ESearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + + } + +// --------------------------------------------------------- +// CAreaSearchResult::SouthLat +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CAreaSearchResult::SouthLat() const + { + return iSouthLat; + } + +// --------------------------------------------------------- +// CAreaSearchResult::NortLat() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CAreaSearchResult::NorthLat() const + { + return iNorthLat; + } + +// --------------------------------------------------------- +// CAreaSearchResult::WestLong() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CAreaSearchResult::WestLong() const + { + return iWestLong; + } + +// --------------------------------------------------------- +// CAreaSearchResult::EastLong() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CAreaSearchResult::EastLong() const + { + return iEastLong; + } + +// --------------------------------------------------------- +// CAreaSearchResult::ErrorCode() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CAreaSearchResult::ErrorCode() const + { + return iErrorCode; + } + +// --------------------------------------------------------- +// CAreaSearchResult::Print() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CAreaSearchResult::Print(TDes& aPrint) + { + + + TChar del(','); + + TBuf info; + _LIT(KPosInfo, "SouthLat=%g, NortLat=%g, WestLong=%g, EastLong=%g"); + + info.Format(KPosInfo, iSouthLat, iNorthLat, iWestLong, iEastLong); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KRedefined, "Redefined=%d"); + info.Format(KRedefined, iRedefined); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KErrorCode, "ErrorCode = %d"); + info.Format(KErrorCode, iErrorCode); + aPrint.Append(info); + aPrint.Append(del); + + aPrint.Append(_L("Search result = ")); + + for (TInt i=0; i +#include +#include +#include "FT_CCategoryLandmarkSearchResult.h" + +//CONSTANTS +const TInt KMaxFieldLength = 80; +const TInt KMaxLineLength=255; + +//const TReal KReal32Accuracy = 5.96E-8; +/* +const TReal KAccuracyHigh = 5.96E-8; +const TReal KAccuracyMedium = 4E-5; +const TReal KAccuracyLow = 4E-3; +*/ + +// C++ Constructor +CCategoryLandmarkSearchResult::CCategoryLandmarkSearchResult() + { + } + +CCategoryLandmarkSearchResult* CCategoryLandmarkSearchResult::NewL(const TDesC& aDes) + { + CCategoryLandmarkSearchResult* self = new(ELeave) CCategoryLandmarkSearchResult; + CleanupStack::PushL(self); + self->ConstructL(aDes); + CleanupStack::Pop(); + return self; + } + +// C++ destructor +CCategoryLandmarkSearchResult::~CCategoryLandmarkSearchResult() + { + delete iCategoryName; + iCategoryName = NULL; + + iPositionFields.Close(); + } + +void CCategoryLandmarkSearchResult::ConstructL(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt redefined=0; + TInt id=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + + switch(index) + { + case ECategoryName: + iCategoryName = token.AllocL(); + break; +/* case EAttributes: + ParseAttributesL(token); + break; +*/ + case ECategoryId: + //iTextCriteria = token.AllocL(); + val.Val(id); + iCategoryId = id; + break; +/* + case EPositionFields: + ParsePositionFields(token); + break; +*/ + case ELmSearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + //Print(); + } + +// --------------------------------------------------------- +// CCategoryLandmarkSearchResult::ParsePositionFields() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +/* +void CCategoryLandmarkSearchResult::ParsePositionFields(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt value=0; + + while (!(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == ',' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + TLex val(token); + val.Val(value); + iPositionFields.Append(value); + + if (line.Peek() == ',') + { + line.Inc(); + line.Mark(); + } + } + } + } +*/ +// --------------------------------------------------------- +// CCategoryLandmarkSearchResult::Print() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCategoryLandmarkSearchResult::Print() + { + TBuf print; + + TChar del(','); + + print.Append(*iCategoryName); + print.Append(del); + + TBuf info; + _LIT(KAttrInfo, "%x"); + info.Format(KAttrInfo, iAttributes); + print.Append(info); + print.Append(del); + + _LIT(KIntInfo, "%d"); + TInt i=0; + for (i=0; i& CCategoryLandmarkSearchResult::PositionFields() const + { + return iPositionFields; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CCategorySearchResult.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CCategorySearchResult.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include "FT_CCategorySearchResult.h" + +//CONSTANTS +const TInt KMaxFieldLength = 80; +const TInt KMaxLineLength=255; + +// C++ Constructor +CCategorySearchResult::CCategorySearchResult() + { + } + +CCategorySearchResult* CCategorySearchResult::NewL(const TDesC& aDes) + { + CCategorySearchResult* self = new(ELeave) CCategorySearchResult; + CleanupStack::PushL(self); + self->ConstructL(aDes); + CleanupStack::Pop(); + return self; + } + +// C++ destructor +CCategorySearchResult::~CCategorySearchResult() + { + delete iTextCriteria; + iTextCriteria = NULL; + + iPositionFields.Close(); + } + +void CCategorySearchResult::ConstructL(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt redefined=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ETextCriteria: + iTextCriteria = token.AllocL(); + break; + case ELmSearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } + + +// --------------------------------------------------------- +// CCategorySearchResult::ParsePositionFields() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCategorySearchResult::ParsePositionFields(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt value=0; + + while (!(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == ',' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + TLex val(token); + val.Val(value); + iPositionFields.Append(value); + + if (line.Peek() == ',') + { + line.Inc(); + line.Mark(); + } + } + } + } + +// --------------------------------------------------------- +// CCategorySearchResult::Print() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCategorySearchResult::Print() + { + TBuf print; + + TChar del(','); + + print.Append(*iTextCriteria); + print.Append(del); + + TBuf info; + _LIT(KAttrInfo, "%x"); + info.Format(KAttrInfo, iAttributes); + print.Append(info); + print.Append(del); + + _LIT(KIntInfo, "%d"); + TInt i=0; + for (i=0; i& CCategorySearchResult::PositionFields() const + { + return iPositionFields; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CCompositeSearchResult.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CCompositeSearchResult.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,644 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FT_CCompositeSearchResult.h" + +#include + +//CONSTANTS +const TInt KMaxLineLength=255; + +// C++ Constructor +CCompositeSearchResult::CCompositeSearchResult() + { + } + +CCompositeSearchResult* CCompositeSearchResult::NewL(CStifLogger* aLog) + { + CCompositeSearchResult* self = new(ELeave) CCompositeSearchResult; + CleanupStack::PushL(self); + self->ConstructL(aLog); + CleanupStack::Pop(); + return self; + } + +// C++ destructor +CCompositeSearchResult::~CCompositeSearchResult() + { + iFile.Close(); + iFileSession.Close(); + + iResultIds.Close(); + iIdList.Close(); + iPositionList.Close(); + + delete iTextCriteria; + iTextCriteria = NULL; + + delete iCategoryName; + iCategoryName = NULL; + + } + +void CCompositeSearchResult::ConstructL(CStifLogger* aLog) + { + iLog = aLog; + + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmDbCompositeSearchResult.txt"); + + User::LeaveIfError(iFileSession.Connect()); + User::LeaveIfError(iFile.Open(iFileSession, KFileTestValues, EFileRead)); + iTextEnabled = EFalse; + iAreaEnabled = EFalse; + iNearestEnabled = EFalse; + iCategoryEnabled = EFalse; + iIdListEnabled = EFalse; + } + +// --------------------------------------------------------- +// CCompositeSearchResult::GetCompositeSearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +TBool CCompositeSearchResult::GetCompositeSearchResultsL(CPosLmCompositeCriteria& aComposite) + { + TBuf line; + TBool done = EFalse; + + iTextEnabled = EFalse; + iAreaEnabled = EFalse; + iNearestEnabled = EFalse; + iCategoryEnabled = EFalse; + iIdListEnabled = EFalse; + + iResultIds.Close(); + iIdList.Close(); + iPositionList.Close(); + + delete iTextCriteria; + iTextCriteria = NULL; + + delete iCategoryName; + iCategoryName = NULL; + + iCategoryId = 0; + iRedefined = 0; + iUseCoverageRadius = EFalse; + iMaxDistance = -1; + + iSouthLat=0;iNorthLat=0;iWestLong=0;iEastLong=0; + iTestCounter++; + + TBuf<50> buf; + buf.Format(_L(">>>>>>>>>>>>Test Round %d<<<<<<<<<<"), iTestCounter); + iLog->Log(buf); + + aComposite.ClearArguments(); + + while (ReadLn(iFile, line) != KErrEof && !done) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + // Found "# TEXT" line + if (lex.Peek() == 'T') + { + ParseTextL(line); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(*iTextCriteria); + textCriteria->SetAttributesToSearch(iTextAttributes); + textCriteria->SetPositionFieldsToSearchL(iPositionList); + + aComposite.AddArgument(textCriteria); + CleanupStack::Pop(textCriteria); + iTextEnabled = ETrue; + } + // Found "# AREA" line + else if (lex.Peek() == 'A') + { + ParseAreaL(line); + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(iSouthLat, + iNorthLat, + iWestLong, + iEastLong + ); + + aComposite.AddArgument(areaCriteria); + CleanupStack::Pop(areaCriteria); + iAreaEnabled = ETrue; + } + // Found "# CATEGORY" line + else if (lex.Peek() == 'C') + { + ParseCategoryL(line); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + if (iCategoryId>0) + { + iLog->Log(_L("SetCategoryItemId")); + catSearchCriteria->SetCategoryItemId(iCategoryId); + } + if (iCategoryName != NULL) + { + iLog->Log(_L("SetCategoryNameL")); + catSearchCriteria->SetCategoryNameL(*iCategoryName); + } + aComposite.AddArgument(catSearchCriteria); + CleanupStack::Pop(catSearchCriteria); + iCategoryEnabled = ETrue; + } + // Found "# NEAREST" line + else if (lex.Peek() == 'N') + { + ParseNearestL(line); + TCoordinate coord(iLatitude, iLongitude); + + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, iUseCoverageRadius); + if (iMaxDistance > 0) + { + nearestCriteria->SetMaxDistance(iMaxDistance); + } + nearestCriteria->SetUseCoverageRadius(iUseCoverageRadius); + aComposite.AddArgument(nearestCriteria); + CleanupStack::Pop(nearestCriteria); + + iNearestEnabled = ETrue; + } + // Found "# IDLIST" line + else if (lex.Peek() == 'I') + { + ParseIdListL(line); + RArray list; + CleanupClosePushL(list); + + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + + for (TInt i=0;iSetLandmarkIdsL(list); + + aComposite.AddArgument(idList); + CleanupStack::Pop(idList); + CleanupStack::PopAndDestroy(&list); + iIdListEnabled = ETrue; + } + // Found "# RESULT" line + else if (lex.Peek() == 'R') + { + ParseResultL(line); + } + // Found "# SEPARATOR" line + else if (lex.Peek() == 'S') + { + done = ETrue; + } + } + } + + if (done != EFalse) return EFalse; + else return ETrue; + + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ReadLn +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CCompositeSearchResult::ReadLn(RFile& aFile, TDes& aDes) + { + aDes = KNullDesC; + TBuf8 line; + + TInt err = aFile.Read(line); + if (line.Length() == 0) + { + return KErrEof; + } + if (err) + { + return err; + } + + // Find line feed + TInt i = 0; + TLex8 fileData; + fileData.Assign(line); + while (fileData.Peek() != '\n' && !(fileData.Peek()).Eos()) + { + fileData.Inc(); + if (++i == KMaxLineLength) + { + // In case no carriage return or end of string characters are present. + break; + } + } + + // Update file position + TInt diff = -(line.Length() - i - 1); + aFile.Seek(ESeekCurrent, diff); + + // Convert to 16-bit + line.SetLength(i); + aDes.Copy(line); + + return KErrNone; + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ParseAreaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ParseAreaL(const TDesC& aDes) + { + iLog->Log(_L("ParseAreaL")); + TLex line(aDes); + line.Mark(); + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ESouthLat: + val.Val(iSouthLat, TChar(',')); + break; + case ENorthLat: + val.Val(iNorthLat, TChar(',')); + break; + case EWestLong: + val.Val(iWestLong, TChar(',')); + break; + case EEastLong: + val.Val(iEastLong, TChar(',')); + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ParseNearestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ParseNearestL(const TDesC& aDes) + { + iLog->Log(_L("ParseNearestL")); + TLex line(aDes); + line.Mark(); + TInt useCoverageRadius = 0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ELatitude: + val.Val(iLatitude, TChar(',')); + break; + case ELongitude: + val.Val(iLongitude, TChar(',')); + break; + case EUseCoverageRadius: + val.Val(useCoverageRadius); + if (useCoverageRadius == 1) + { + iUseCoverageRadius = ETrue; + } + break; + case EMaxDistance: + val.Val(iMaxDistance); + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ParseTextL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ParseTextL(const TDesC& aDes) + { + iLog->Log(_L("ParseTextL")); + TLex line(aDes); + line.Mark(); + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + + switch(index) + { + case ETextCriteria: + iTextCriteria = token.AllocL(); + break; + case EAttributes: + ParseAttributesL(token); + iTextAttributes = iAttributes; + break; + case EPositionFields: + ExtractIdFields(token, iPositionList); + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ParseCategoryL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ParseCategoryL(const TDesC& aDes) + { + iLog->Log(_L("ParseCategoryL")); + TLex line(aDes); + line.Mark(); + TInt tmp; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + + switch(index) + { + case ECategoryName: + iCategoryName = token.AllocL(); + break; + case ECategoryId: + val.Val(tmp); + iCategoryId = tmp; + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ParseIdListL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ParseIdListL(const TDesC& aDes) + { + iLog->Log(_L("ParseIdListL")); + TLex line(aDes); + line.Mark(); + + RArray list; + CleanupClosePushL(list); + TInt i=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + //TLex val(token); + + switch(index) + { + case ELmIdList: + ExtractIdFields(token, list); + for (i=0;iLog(_L("ParseResultL")); + TLex line(aDes); + line.Mark(); + TInt redefined=0; + + RArray list; + CleanupClosePushL(list); + TInt i=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + + switch(index) + { + case ELmResultIdList: + ExtractIdFields(token, list); + for (i=0;iLog(_L("REDEFINED")); + iRedefined = ETrue; + } + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + CleanupStack::PopAndDestroy(&list); + } + +// --------------------------------------------------------- +// CCompositeSearchResult::ExtractIdFields() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CCompositeSearchResult::ExtractIdFields(const TDesC& aDes, RArray& aList) + { + iLog->Log(_L("ExtractIdFields")); + TLex line(aDes); + line.Mark(); + TInt startValue=0; + TInt endValue=0; + while (!(line.Peek()).Eos()) + { + line.Inc(); + + if (line.Peek() == ',' || line.Peek() == '-' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + TLex val(token); + val.Val(startValue); + iSearchResult.Append(startValue); + aList.Append(startValue); + + if (line.Peek() == '-') + { + line.Inc(); + line.Mark(); + while (line.Peek() != ',' && !(line.Peek()).Eos()) + { + line.Inc(); + } + TPtrC endToken = line.MarkedToken(); + TLex endVal(endToken); + endVal.Val(endValue); + for (TInt i=startValue+1; i<=endValue; i++) + { + aList.Append(i); + } + } + if (line.Peek() == ',') + { + line.Inc(); + line.Mark(); + } + } + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CLandmarkTestProcedureBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CLandmarkTestProcedureBase.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,2974 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + + +// INCLUDES +#include "FT_CLandmarkTestProcedureBase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KBufSize=100; +const TInt KMaxFieldLength = 80; + +const TInt KFirstNextStepLogLimit = 100000; //µs + +// CONSTANTS +_LIT(KLt, "<"); +_LIT(KGt, ">"); +_LIT(KAmp, "&"); +_LIT(KApos, "'"); +_LIT(KQuot, "\""); + +_LIT(KLtXmlStr, "<"); +_LIT(KGtXmlStr, ">"); +_LIT(KAmpXmlStr, "&"); +_LIT(KAposXmlStr, "'"); +_LIT(KQuotXmlStr, """); + +// ================= MEMBER FUNCTIONS ======================= + + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// + + + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CLandmarkTestProcedureBase::CLandmarkTestProcedureBase( + TInt aModuleId, CStifLogger* aLog) + : iModuleId(aModuleId), + KFirstDelayTime(5000), + KIntervalTime(5000), + iLog(aLog) + { + iUseLogFromThreadIsDisabled = EFalse; + iFileSession.Connect(); + } + + + +// Destructor +CLandmarkTestProcedureBase::~CLandmarkTestProcedureBase() + { + iSearchResults.ResetAndDestroy(); + iAreaSearchResults.ResetAndDestroy(); + + iCategorySearchResults.ResetAndDestroy(); + iCategoryLandmarkSearchResults.ResetAndDestroy(); + iFileSession.Close(); + ReleaseLandmarkResources(); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::InitTestL() + { + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::StartL() + { + iLog->Log(_L("StartL not overridden")); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CloseTest() + { + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RemoveAllLmDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RemoveAllLmDatabasesL() + { + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt count = dbArray->Count(); + + for (TInt i=0;iLog((*dbArray)[i]); + TRAPD(error,dbManager->DeleteDatabaseL((*dbArray)[i])); + if (error != KErrNone) + { + if( error == KErrInUse ) + { + iLog->Log(_L("Cannot delete database since it is in use")); + } + else + { + iLog->Log(_L("Delete database leaves with error = %d"),error); + User::Leave( error); + } + + } + } + + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + iLog->Log(_L("DeleteAllDatabasesL Done")); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RemoveDefaultDb +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RemoveDefaultDbL() + { + + + + iLog->Log(_L("In CLandmarkTestProcedureBase::RemoveDefaultDbL() ")); + + + // Retrieve default db from db manager and then delete + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + + CleanupStack::PushL(manager); + + HBufC* defaultDbUri; + defaultDbUri = manager->DefaultDatabaseUriLC(); + + TRAPD(err, manager->DeleteDatabaseL(*defaultDbUri)); + if (err != KErrNone && err != KErrNotFound) + { + if( err == KErrInUse) + { + iLog->Log(_L("Cannot delete database since it is in use")); + } + else + { + iLog->Log(_L("Delete of the default landmarks database failed with %d"),err); + User::Leave(err); + } + } + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + + + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CreateCategoryLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkCategory* CLandmarkTestProcedureBase::CreateCategoryLC(const TDesC& aName) + { + _LIT(KGetCategoryNameErr, "GetCategory name returns incorrect error code"); + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + + TInt err=0; + TPtrC name; + err=category->GetCategoryName(name); + AssertTrueSecL(err == KErrNotFound, KGetCategoryNameErr); + + category->SetCategoryNameL(aName); + + category->SetIconL(KMbmFileName, KIconIndex, KIconMaskIndex); + + return category; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CreateLandmarkLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmark* CLandmarkTestProcedureBase::CreateLandmarkLC(const TDesC& aName) + { + _LIT(KGetNameErr, "GetLandmarks name returns incorrect error code"); + _LIT(KFirstPositionFieldIdErr, "FirstPositionFieldId returns incorrect id"); + + + CPosLandmark* landmark = CPosLandmark::NewLC(); + TInt err=0; + TPtrC name; + err=landmark->GetLandmarkName(name); + AssertTrueSecL(err == KErrNotFound, KGetNameErr); + + landmark->SetLandmarkNameL(aName); + + TCoordinate coord(KLatitude, KLongitude, KAltitude); + TLocality loc(coord, KHorizontalAcc, KVerticalAcc); + TTime time; + time.UniversalTime(); + TPosition pos(loc, time); + landmark->SetPositionL(pos); + + landmark->SetIconL(KMbmFileName, KIconIndex, KIconMaskIndex); + landmark->SetLandmarkDescriptionL(KDescription); + landmark->SetCoverageRadius(KCoverageRadius); + + AssertTrueSecL(landmark->FirstPositionFieldId()==EPositionFieldNone, KFirstPositionFieldIdErr); + + AddFieldsL(landmark); + + _LIT(KCategoryName, "%S Category %d"); + for(TInt i=0; i name; + HBufC* tmp = aName.Alloc(); + name.Format(KCategoryName,tmp,i); + delete tmp; + landmark->AddCategoryL(CreateCategoryL(name)); + } + return landmark; + + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AddFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AddFieldsL(CPosLandmark* aLandmark) + { + _LIT(KPositionFieldNoneErr, "SetPositionFieldL should return KErrArgumnet with EPositionFieldNone"); + + aLandmark->SetPositionFieldL(EPositionFieldCountry, KCountry); + aLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, KHorizontalSpeed); + // Removed from LBSFieldsIds.h + + aLandmark->SetPositionFieldL(EPositionFieldMediaLinks, KMediaLinks); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMediaLink1); + + TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; + aLandmark->SetPositionFieldL(++tmp, KMediaLink2); + aLandmark->SetPositionFieldL(++tmp, KMediaLink3); + + aLandmark->SetPositionFieldL(EPositionFieldIdLast, KOrientation); + + TRAPD(err, aLandmark->SetPositionFieldL(EPositionFieldNone, KMediaLink3)); + AssertTrueSecL(err == KErrArgument, KPositionFieldNoneErr); + + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AddFields2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AddFields2L(CPosLandmark* aLandmark) + { + aLandmark->SetPositionFieldL(EPositionFieldCountry, KCountry2); + aLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, KHorizontalSpeed2); + // Removed from LBSFieldsIds.h + + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMediaLinks2); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+1, KMediaLink4); + + TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; + aLandmark->SetPositionFieldL(++tmp, KMediaLink5); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AddFields3L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AddFields3L(CPosLandmark* aLandmark) + { + aLandmark->SetPositionFieldL(EPositionFieldCountryCode, KCountryCode); + aLandmark->SetPositionFieldL(EPositionFieldState, KState); + aLandmark->SetPositionFieldL(EPositionFieldCity, KCity); + aLandmark->SetPositionFieldL(EPositionFieldDistrict, KDistrict); + aLandmark->SetPositionFieldL(EPositionFieldStreet, KStreet); + aLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KStreetExtension); + aLandmark->SetPositionFieldL(EPositionFieldLocationName, KLocationName); + aLandmark->SetPositionFieldL(EPositionFieldPostalCode, KPostalCode); + aLandmark->SetPositionFieldL(EPositionFieldLocality, KLocality); + aLandmark->SetPositionFieldL(EPositionFieldCrossing1, KCrossing1); + aLandmark->SetPositionFieldL(EPositionFieldCrossing2, KCrossing2); + aLandmark->SetPositionFieldL(EPositionFieldBuildingName, KBuildingName); + aLandmark->SetPositionFieldL(EPositionFieldBuildingFloor, KBuildingFloor); + aLandmark->SetPositionFieldL(EPositionFieldBuildingRoom, KBuildingRoom); + aLandmark->SetPositionFieldL(EPositionFieldBuildingZone, KBuildingZone); + aLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KBuildingTelephone); + } + + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CreateXMLLandmarkLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmark* CLandmarkTestProcedureBase::CreateXMLLandmarkLC(const TDesC& aName) + { + _LIT(KGetNameErr, "GetLandmarks name returns incorrect error code"); + _LIT(KFirstPositionFieldIdErr, "FirstPositionFieldId returns incorrect id"); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + + TInt err=0; + TPtrC name; + err=landmark->GetLandmarkName(name); + AssertTrueSecL(err == KErrNotFound, KGetNameErr); + + landmark->SetLandmarkNameL(aName); + + TCoordinate coord(KLatitude, KLongitude, KAltitude); + TLocality loc(coord, KHorizontalAcc, KVerticalAcc); + TTime time; + time.UniversalTime(); + TPosition pos(loc, time); + landmark->SetPositionL(pos); + + landmark->SetIconL(KMbmFileName, KIconIndex, KPosLmIconMaskNotUsed); + + landmark->SetLandmarkDescriptionL(KDescription); + + landmark->SetCoverageRadius(KCoverageRadius); + + AssertTrueSecL(landmark->FirstPositionFieldId()==EPositionFieldNone, KFirstPositionFieldIdErr); + + return landmark; + } + + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AddAllXMLFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AddAllXMLFieldsL(CPosLandmark* aLandmark) + { + aLandmark->SetPositionFieldL(EPositionFieldCountry, KCountry2); + aLandmark->SetPositionFieldL(EPositionFieldCountryCode, KCountryCode); + aLandmark->SetPositionFieldL(EPositionFieldState, KState); + aLandmark->SetPositionFieldL(EPositionFieldCounty, KCounty); + aLandmark->SetPositionFieldL(EPositionFieldCity, KCity); + aLandmark->SetPositionFieldL(EPositionFieldDistrict, KDistrict); + aLandmark->SetPositionFieldL(EPositionFieldPostalCode, KPostalCode); + + aLandmark->SetPositionFieldL(EPositionFieldCrossing1, KCrossing1); + aLandmark->SetPositionFieldL(EPositionFieldCrossing2, KCrossing2); + aLandmark->SetPositionFieldL(EPositionFieldStreet, KStreet); + + aLandmark->SetPositionFieldL(EPositionFieldBuildingName, KBuildingName); + aLandmark->SetPositionFieldL(EPositionFieldBuildingFloor, KBuildingFloor); + aLandmark->SetPositionFieldL(EPositionFieldBuildingRoom, KBuildingRoom); + aLandmark->SetPositionFieldL(EPositionFieldBuildingZone, KBuildingZone); + + aLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KStreetExtension); + aLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KBuildingTelephone); + + // Set number of medialink fields + aLandmark->SetPositionFieldL(EPositionFieldMediaLinks, _L("13")); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KXMLMediaLink1); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+1, KXMLMediaLink2); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+2, KXMLMediaLink3); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+3, KXMLMediaLink4); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+4, KXMLMediaLink5); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+5, KXMLMediaLink6); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+6, KXMLMediaLink7); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+7, KXMLMediaLink8); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+8, KXMLMediaLink9); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+9, KXMLMediaLink10); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+10, KXMLMediaLink11); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+11, KXMLMediaLink12); + aLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart+12, KXMLMediaLink13); + + + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AddAllXMLFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AddAllEmptyXMLFieldsL(CPosLandmark* aLandmark) + { + aLandmark->SetPositionFieldL(EPositionFieldCountry, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldCountryCode, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldState, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldCounty, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldCity, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldDistrict, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldPostalCode, _L("")); + + aLandmark->SetPositionFieldL(EPositionFieldCrossing1, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldCrossing2, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldStreet, _L("")); + + aLandmark->SetPositionFieldL(EPositionFieldBuildingName, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldBuildingFloor, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldBuildingRoom, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldBuildingZone, _L("")); + + aLandmark->SetPositionFieldL(EPositionFieldStreetExtension, _L("")); + aLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, _L("")); + + aLandmark->SetPositionFieldL(EPositionFieldMediaLinks, _L("0")); + + + aLandmark->SetLandmarkDescriptionL(_L("")); + + + } + +//--------------------------------------------------------- +// CLandmarkTestProcedureBase::WriteBufferToFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CLandmarkTestProcedureBase::WriteBufferToFileL(const CBufBase* aBuffer, const TDesC& aFile) + { + iFileSession.Delete(aFile); + + RFile file; + file.Create(iFileSession, aFile, EFileWrite); + CleanupClosePushL(file); + + RFileWriteStream stream(file); + CleanupClosePushL(stream); + + TInt pos=0; + TInt size = aBuffer->Size(); + TInt length; + if (size < 255 ) + { + length = size; + } + else + { + length = 255; + } + + while (pos < size) + { + TBuf8<255> xml; + + aBuffer->Read(pos, xml, length); + + stream.WriteL(xml); + + pos += 255; + + if (pos + 255 > size ) + { + length = size - pos; + } + } + + CleanupStack::PopAndDestroy(2, &file); + } + +//--------------------------------------------------------- +// CLandmarkTestProcedureBase::CreateCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TPosLmItemId CLandmarkTestProcedureBase::CreateCategoryL(const TDesC& aName) + { + _LIT(KCategoryIdErr, "Category id is incorrect"); + + CPosLandmarkDatabase* lmd = OpenDatabaseLC(); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + TPosLmItemId id=0; + + + + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(aName); + + id = cm->AddCategoryL(*lmc); + + AssertTrueSecL(id == lmc->CategoryId(), KCategoryIdErr); + CleanupStack::PopAndDestroy(lmc); + + + CleanupStack::PopAndDestroy(2, lmd); + + return id; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::OpenLandmarkDatabaseLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::OpenDatabaseLC() + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + CPosLmOperation* op = lmd->InitializeL(); // Synchronous since no argument + op->ExecuteL(); + delete op; + } + return lmd; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CompareLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CompareLandmarksL(const CPosLandmark& aSource, const CPosLandmark& aTarget) + { + _LIT(KCompareIdErr, "Landmark id's are not equal"); + _LIT(KComparePositionErr, "Landmark positions are not equal"); + _LIT(KComparePositionErr1, "Landmark longitude are not equal"); + _LIT(KComparePositionErr2, "Landmark latitude are not equal"); + _LIT(KComparePositionErr3, "Landmark horizontal accuracy are not equal"); + _LIT(KComparePositionErr4, "Landmark vertical accuracy are not equal"); + _LIT(KComparePositionErr5, "Landmark altitude are not equal"); + _LIT(KCompareNameErr, "Landmark names are not equal"); + _LIT(KCompareCoverageRadiusErr, "Landmark coverage radiuses are not equal"); + _LIT(KCompareIconErr, "Landmark icons are not equal"); + _LIT(KCompareDescErr, "Landmark descriptions are not equal"); + _LIT(KCompareNoPositionFieldsErr, "Landmark no positioning fields are not equal"); + _LIT(KComparePositionFieldIdErr, "Position field id's are not equal"); + _LIT(KComparePositionFieldErr, "Position fields are not equal"); + _LIT(KCompareNumOfCategoriesErr, "Number of categories is not equal"); + _LIT(KCompareSetOfCategoriesErr, "Set of categories is not equal"); + + TInt sourceErr, targetErr; + TPtrC sourceName; + sourceErr=aSource.GetLandmarkName(sourceName); + + TPtrC targetName; + targetErr=aTarget.GetLandmarkName(targetName); + + AssertTrueSecL(targetErr == sourceErr, KCompareNameErr); + if (!sourceErr) + { + AssertTrueSecL(sourceName.Compare(targetName) == KErrNone, KCompareNameErr); + AssertTrueSecL(aSource.LandmarkId() == aTarget.LandmarkId(), KCompareIdErr); + } + + TLocality sourceLoc, targetLoc; + sourceErr = aSource.GetPosition(sourceLoc); + targetErr = aTarget.GetPosition(targetLoc); + AssertTrueSecL(sourceErr == targetErr, KComparePositionErr); + if (!sourceErr) + { + // Difference between WINS and WINSCW/TARGET + // For WINS comparing TReal NaN == NaN evaluates to true + // but for TARGET and WINSCW it evaluates to false + TRealX vertAcc(sourceLoc.VerticalAccuracy()); + TRealX targetVertAcc(targetLoc.VerticalAccuracy()); + TRealX horAcc(sourceLoc.HorizontalAccuracy()); + TRealX targetHorAcc(targetLoc.HorizontalAccuracy()); + TRealX horAlt(sourceLoc.Altitude()); + TRealX targetHorAlt(targetLoc.Altitude()); + + AssertTrueSecL(sourceLoc.Longitude() == targetLoc.Longitude(),KComparePositionErr1); + AssertTrueSecL(sourceLoc.Latitude() == targetLoc.Latitude(), KComparePositionErr2); + + AssertTrueSecL((horAcc.IsNaN() && targetHorAcc.IsNaN()) || horAcc == targetHorAcc, KComparePositionErr3); + AssertTrueSecL((vertAcc.IsNaN() && targetVertAcc.IsNaN()) || vertAcc == targetVertAcc, KComparePositionErr4); + AssertTrueSecL((targetHorAlt.IsNaN() && horAlt.IsNaN()) || horAlt == targetHorAlt , KComparePositionErr5); + } + + TReal32 sourceR, targetR; + sourceErr = aSource.GetCoverageRadius(sourceR); + targetErr = aTarget.GetCoverageRadius(targetR); + AssertTrueSecL(sourceErr == targetErr, KCompareCoverageRadiusErr); + if (!sourceErr) + { + AssertTrueSecL(sourceR == targetR, KCompareCoverageRadiusErr); + } + + TPtrC sourceMbmFileName, targetMbmFileName; + TInt sourceIndex, targetIndex; + TInt sourceMaskIndex, targetMaskIndex; + + sourceErr = aSource.GetIcon(sourceMbmFileName, sourceIndex, sourceMaskIndex); + targetErr = aTarget.GetIcon(targetMbmFileName, targetIndex, targetMaskIndex); + + AssertTrueSecL(sourceErr == targetErr, KCompareIconErr); + if (!sourceErr) + { + AssertTrueSecL(sourceMbmFileName.Compare(targetMbmFileName) == KErrNone, KCompareIconErr); + AssertTrueSecL(sourceIndex == targetIndex, KCompareIconErr); + } + + TPtrC sourceDesc, targetDesc; + sourceErr = aSource.GetLandmarkDescription(sourceDesc); + targetErr = aTarget.GetLandmarkDescription(targetDesc); + AssertTrueSecL(sourceErr == targetErr, KCompareDescErr); + if (!sourceErr) + { + AssertTrueSecL(sourceDesc.Compare(targetDesc) == KErrNone, KCompareDescErr); + } + + AssertTrueSecL(aSource.NumOfAvailablePositionFields() == aTarget.NumOfAvailablePositionFields(), KCompareNoPositionFieldsErr); + + TPositionFieldId sourceFieldId = aSource.FirstPositionFieldId(); + TPositionFieldId targetFieldId = aTarget.FirstPositionFieldId(); + AssertTrueSecL(sourceFieldId == targetFieldId, KComparePositionFieldIdErr); + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue, targetValue; + + aSource.GetPositionField(sourceFieldId, sourceValue); + aTarget.GetPositionField(targetFieldId, targetValue); + + AssertTrueSecL(sourceValue.Compare(targetValue) == KErrNone, KComparePositionFieldErr); + + sourceFieldId = aSource.NextPositionFieldId(sourceFieldId); + targetFieldId = aTarget.NextPositionFieldId(targetFieldId); + + AssertTrueSecL(sourceFieldId == targetFieldId, KComparePositionFieldIdErr); + } + + RArray sourceCategories; + CleanupClosePushL(sourceCategories); + RArray targetCategories; + CleanupClosePushL(targetCategories); + + aSource.GetCategoriesL(sourceCategories); + aTarget.GetCategoriesL(targetCategories); + + AssertTrueSecL(sourceCategories.Count() == targetCategories.Count(), KCompareNumOfCategoriesErr); + + for(TInt i=0; i= 0, KCompareSetOfCategoriesErr ); + } + CleanupStack::PopAndDestroy(2, &sourceCategories); + } + +// --------------------------------------------------------- +// CPSYTesterTestProcedureBase::CompareCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CompareCategoriesL( + const TPosLmItemId& aSourceId, + const TPosLmItemId& aTargetId) + { + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(cm); + + CPosLandmarkCategory* source = cm->ReadCategoryLC(aSourceId); + CPosLandmarkCategory* target = cm->ReadCategoryLC(aTargetId); + + CompareCategoriesL(*source, *target); + + + CleanupStack::PopAndDestroy(3); + } + +// --------------------------------------------------------- +// CPSYTesterTestProcedureBase::CompareCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CompareCategoriesL( + const CPosLandmarkCategory& aSource, + const CPosLandmarkCategory& aTarget) + { + _LIT(KCompareCategoryNameErr, "Category names are not equal"); + _LIT(KCompareCategoryIdErr, "Category id's are not equal"); + _LIT(KCompareGlobalCategoryIdErr, "Category global id's are not equal"); + _LIT(KCompareCategoryIconErr, "Category icons are not equal"); + + TInt sourceErr, targetErr; + TPtrC sourceName, targetName; + sourceErr = aSource.GetCategoryName(sourceName); + targetErr = aTarget.GetCategoryName(targetName); + + AssertTrueSecL(sourceErr == targetErr, KCompareCategoryNameErr); + AssertTrueSecL(sourceName.Compare(targetName) == KErrNone, KCompareCategoryNameErr); + + AssertTrueSecL(aSource.CategoryId() == aTarget.CategoryId(), KCompareCategoryIdErr); + AssertTrueSecL(aSource.GlobalCategory() == aTarget.GlobalCategory(), KCompareGlobalCategoryIdErr); + + TPtrC sourceMbmFileName, targetMbmFileName; + TInt sourceIndex, targetIndex; + TInt sourceMaskIndex, targetMaskIndex; + + sourceErr = aSource.GetIcon(sourceMbmFileName, sourceIndex, sourceMaskIndex); + targetErr = aTarget.GetIcon(targetMbmFileName, targetIndex, targetMaskIndex); + + AssertTrueSecL(sourceErr == targetErr, KCompareCategoryIconErr); + if (!sourceErr) + { + AssertTrueSecL(sourceMbmFileName.Compare(targetMbmFileName) == KErrNone, KCompareCategoryIconErr); + AssertTrueSecL(sourceIndex == targetIndex, KCompareCategoryIconErr); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CompareXMLLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CompareXMLLandmarksL(const CPosLandmark& aSource, const CPosLandmark& aTarget, TBool aDebug) + { + _LIT(KComparePositionErr, "Landmark positions are not equal"); + _LIT(KComparePositionErr1, "Landmark longitude are not equal"); + _LIT(KComparePositionErr2, "Landmark latitude are not equal"); + _LIT(KComparePositionErr3, "Landmark horizontal accuracy are not equal"); + _LIT(KComparePositionErr4, "Landmark vertical accuracy are not equal"); + _LIT(KComparePositionErr5, "Landmark altitude are not equal"); + _LIT(KCompareNameErr, "Landmark names are not equal, src %S, trg %S"); + _LIT(KCompareCoverageRadiusErr, "Landmark coverage radiuses are not equal"); + _LIT(KCompareDescErr, "Landmark descriptions are not equal"); + _LIT(KCompareNoPositionFieldsErr, "ERROR: Landmark nr of positioning fields are not equal"); + _LIT(KComparePositionFieldIdErr, "ERROR: Position field id's are not equal, src '%d', trg '%d'"); + _LIT(KComparePositionFieldErr, "ERROR: Position fields are not equal, src '%S', trg '%S'"); + + if (aDebug) iLog->Log(_L("CompareXMLLandmarksL")); + + TInt errorsFound = KErrNone; + + TInt sourceErr, targetErr; + TPtrC sourceName; + sourceErr=aSource.GetLandmarkName(sourceName); + //iLog->Log(sourceName); + + TPtrC targetName; + targetErr=aTarget.GetLandmarkName(targetName); + //iLog->Log(targetName); + + AssertTrueSecL(targetErr == sourceErr, KCompareNameErr); + if (!sourceErr) + { + if (sourceName.Compare(targetName) != KErrNone) + { + iLog->Log(KCompareNameErr, &sourceName, &targetName); + } + } + + TLocality sourceLoc, targetLoc; + sourceErr = aSource.GetPosition(sourceLoc); + targetErr = aTarget.GetPosition(targetLoc); + AssertTrueSecL(sourceErr == targetErr, KComparePositionErr); + if (!sourceErr) + { + // Difference between WINS and WINSCW/TARGET + // For WINS comparing TReal NaN == NaN evaluates to true + // but for TARGET and WINSCW it evaluates to false + TRealX vertAcc(sourceLoc.VerticalAccuracy()); + TRealX targetVertAcc(targetLoc.VerticalAccuracy()); + TRealX horAcc(sourceLoc.HorizontalAccuracy()); + TRealX targetHorAcc(targetLoc.HorizontalAccuracy()); + TRealX horAlt(sourceLoc.Altitude()); + TRealX targetHorAlt(targetLoc.Altitude()); + + AssertTrueSecL(sourceLoc.Longitude() == targetLoc.Longitude(),KComparePositionErr1); + AssertTrueSecL(sourceLoc.Latitude() == targetLoc.Latitude(), KComparePositionErr2); + + AssertTrueSecL((horAcc.IsNaN() && targetHorAcc.IsNaN()) || horAcc == targetHorAcc, KComparePositionErr3); + AssertTrueSecL((vertAcc.IsNaN() && targetVertAcc.IsNaN()) || vertAcc == targetVertAcc, KComparePositionErr4); + AssertTrueSecL((targetHorAlt.IsNaN() && horAlt.IsNaN()) || horAlt == targetHorAlt , KComparePositionErr5); + } + + TReal32 sourceR, targetR; + sourceErr = aSource.GetCoverageRadius(sourceR); + targetErr = aTarget.GetCoverageRadius(targetR); + AssertTrueSecL(sourceErr == targetErr, KCompareCoverageRadiusErr); + if (!sourceErr) + { + AssertTrueSecL(sourceR == targetR, KCompareCoverageRadiusErr); + } + TPtrC sourceDesc, targetDesc; + sourceErr = aSource.GetLandmarkDescription(sourceDesc); + targetErr = aTarget.GetLandmarkDescription(targetDesc); + AssertTrueSecL(sourceErr == targetErr, KCompareDescErr); + if (!sourceErr) + { + AssertTrueSecL(sourceDesc.Compare(targetDesc) == KErrNone, KCompareDescErr); + } + + if (aSource.NumOfAvailablePositionFields() != aTarget.NumOfAvailablePositionFields()) + { + iLog->Log(KCompareNoPositionFieldsErr); + errorsFound++; + //PrintLandmarkFieldsL(aSource); + //PrintLandmarkFieldsL(aTarget); + } + + TPositionFieldId sourceFieldId = aSource.FirstPositionFieldId(); + TPositionFieldId targetFieldId = aTarget.FirstPositionFieldId(); + + if (sourceFieldId != targetFieldId) + { + iLog->Log(KComparePositionFieldIdErr); + errorsFound++; + } + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue, targetValue; + + HBufC* buf1 = NULL; + HBufC* buf2 = NULL; + + aSource.GetPositionField(sourceFieldId, sourceValue); + aTarget.GetPositionField(sourceFieldId, targetValue); + + // Remove // from string starting with // + // The encoder adds "//" to medialinks with unknown mimetype + if (sourceValue.Find(_L("//")) == 0) + { + TPtrC sourceValue2 = sourceValue.Mid(2); + buf1 = sourceValue2.Alloc(); + } + else buf1 = sourceValue.Alloc(); + CleanupStack::PushL(buf1); + + // Remove // from string starting with // + // The encoder adds "//" to medialinks with unknown mimetype + if (targetValue.Find(_L("//")) == 0) + { + TPtrC targetValue2 = targetValue.Mid(2); + buf2 = targetValue2.Alloc(); + } + else buf2 = targetValue.Alloc(); + CleanupStack::PushL(buf2); + + // Check if strings are equal + if (buf1->Des().Compare(buf2->Des())) + { + iLog->Log(KComparePositionFieldErr, sourceFieldId, &sourceValue, &targetValue); + errorsFound++; + } + + CleanupStack::PopAndDestroy(buf2); + CleanupStack::PopAndDestroy(buf1); + + sourceFieldId = aSource.NextPositionFieldId(sourceFieldId); + } + + return errorsFound; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CompareXMLCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CompareXMLCategoriesL( + const CPosLandmarkCategory& aSource, + const CPosLandmarkCategory& aTarget, TBool /*aDebug*/) + { + _LIT(KCompareCategoryNameErr1, "ERROR: Category names not correct found"); + _LIT(KCompareCategoryNameErr2, "ERROR: Category names are not equal"); + TInt errorsFound = KErrNone; + iLog->Log(_L("CompareXMLCategoriesL")); + + TInt sourceErr, targetErr; + TPtrC sourceName, targetName; + sourceErr = aSource.GetCategoryName(sourceName); + targetErr = aTarget.GetCategoryName(targetName); + + AssertTrueSecL(sourceErr == targetErr, KCompareCategoryNameErr1); + iLog->Log(_L("Source %S, target %S"), &sourceName, &targetName); + + if (sourceName.Compare(targetName) != KErrNone) + { + iLog->Log(KCompareCategoryNameErr2); + errorsFound++; + } + + if (aSource.GlobalCategory() != aTarget.GlobalCategory()) + { + iLog->Log(KCompareCategoryNameErr2); + errorsFound++; + } + + iLog->Log(_L("CompareXMLCategoriesL Done")); + return errorsFound; + } + + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AssertTrueSecL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode) + { + if (!aCondition) + { + TBuf buf; + buf.Format(aErrorMsg, aErrorCode); + // Necessary to separate the case when aErrorCode==KErrNone + + if (aErrorCode == KErrNone) + { + iLog->Log(buf); + User::Leave(KErrNone); + + } + else + { + iLog->Log(buf); + User::Leave(aErrorCode); + } + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CheckDefaultDbExitsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CheckDefaultDbExistL() + { + _LIT(KDefaultDbMissingErr, "Default landmarks db is missing, open returns %d"); + + RFile file; + TInt err = file.Open(iFileSession, KDefaultDb, EFileRead); + file.Close(); + AssertTrueSecL(err==KErrNone, KDefaultDbMissingErr, err); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::BackupDbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::BackupDbFileL() + { + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(buf)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(*defaultDbUri, buf); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RestoreDbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::RestoreDbFileL() + { + + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(*defaultDbUri)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(buf, *defaultDbUri); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CopyDbFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + + +void CLandmarkTestProcedureBase::CopyDbFileL(const TDesC& aFileName) + { + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(aFileName); + + + TInt err = fileMan->Copy(srcPath, KLmFullDefaultDbPath, CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CopyTestDbFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CopyTestDbFileL(const TDesC& aFileName) + { + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + TBuf<150> destPath; + + srcPath.Append(KTestPath); + srcPath.Append(aFileName); + + destPath.Append(KLmDbPath); + destPath.Append(aFileName); + + TInt err = fileMan->Copy(srcPath, destPath, CFileMan::EOverWrite); + if (err != KErrNone) iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::UseGeneratedDbFile +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::UseGeneratedDbFileL() + { + CopyDbFileL(KDefaultDb); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KDefaultDb); + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDb); + if ( db->IsInitializingNeeded() ) + { + TRAPD( err, ExecuteAndDeleteLD( db->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + + return db; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::UseCompositeLandmarksDbFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::UseCompositeLandmarksDbFileL() + { + iLog->Log(_L("UseCompositeLandmarksDbFileL")); + + + _LIT(KDbFile, "compositeeposlm.ldb"); + CopyTestDbFileL(KDbFile); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + // This db must exist + manager->SetDefaultDatabaseUriL(KDbFile); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(KDbFile); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::UseEmptyDbFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::UseEmptyDbFileL() + { + + CopyTestDbFileL(KLandmarksEmptyDb); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + // This db must exist + manager->SetDefaultDatabaseUriL(KLandmarksEmptyDb); + CleanupStack::PopAndDestroy(manager); + + return CPosLandmarkDatabase::OpenL(KLandmarksEmptyDb); + + } + + +// --------------------------------------------------------- +// CPosLandmarkDatabase::UseGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CLandmarkTestProcedureBase::UseGlobalCategoriesL() + { + _LIT(KGlobalCategoryResFile, "c:\\system\\test\\testdata\\EPOSLMGLOBALCATEGORIES.R01"); + + _LIT(KGlobalCategoryResPath, "c:\\resource\\"); + + iLog->Log(_L("UseGlobalCategoriesL")); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + TInt err = KErrNone; + //check if landmark is flashed + TInt Value=BaflUtils::FileExists(iFileSession, KGlobalCategoryResFileROM); + // if (!BaflUtils::FileExists(fs, KGlobalCategoryResFileROM)) + if(!Value) + { + iLog->Log(_L("Landmark is NOT flashed, rename global categories")); + //Landmark is not flashed rename the file before copy a own defiend file. + //since landmark is not flashed the file should exist hence leaving if it is not found! + + err = fileMan->Rename(KGlobalCategoryResFileWINS, KGlobalCategoryResFileCOPY, CFileMan::EOverWrite); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("ErrCode: from fileMan->Rename %d"),err); + iLog->Log(buf); + } + + } + else + { + iLog->Log(_L("Landmark is flashed, copy global categories")); + } + + // Recurse copy -> Create directory if it does not exist and overwrite file if it exists + err = fileMan->Copy(KGlobalCategoryResFile, KGlobalCategoryResPath, CFileMan::EOverWrite); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("ErrCode: from fileMan->Copy %d"),err); + iLog->Log(buf); + } + + CleanupStack::PopAndDestroy(fileMan); + + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RemoveGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RemoveGlobalCategoriesL() + { + + _LIT(KGlobalCategoryResFile, "c:\\resource\\EPOSLMGLOBALCATEGORIES.R01"); + + iLog->Log(_L("RemoveGlobalCategoriesL")); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + TInt err = KErrNone; + + //check if the global category file exist in rom + //if landmarks is flushed it is just okej to remove + //any global gategory files in on the c drive. + if (BaflUtils::FileExists(iFileSession, KGlobalCategoryResFileROM)) + { + iLog->Log(_L("Landmark is flashed, delete global categories")); + //in this case it is same just to remove it form c if it exists: + if (BaflUtils::FileExists(iFileSession, KGlobalCategoryResFile)) + { + err = fileMan->Delete(KGlobalCategoryResFile); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("ErrCode: from fileMan->Delete %d"),err); + iLog->Log(buf); + } + } + } + else + { + iLog->Log(_L("Landmark is NOT flashed, delete global categories and rename the old file")); + //If a copy exist this should be used, but if it does not + //exist the file is not removed since it is hard to know + //if anything has gone wrong. + if(BaflUtils::FileExists(iFileSession, KGlobalCategoryResFileCOPY)) + { + //first delete the used file, if it exist + if (BaflUtils::FileExists(iFileSession, KGlobalCategoryResFile)) + { + + err = fileMan->Delete(KGlobalCategoryResFile); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("ErrCode: from fileMan->Delete %d"),err); + iLog->Log(buf); + } + } + //Rename the copy file + + err = fileMan->Rename(KGlobalCategoryResFileCOPY, KGlobalCategoryResFile, CFileMan::EOverWrite); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("ErrCode: from fileMan->Rename %d"),err); + iLog->Log(buf); + } + } + } + iLog->Log(_L("RemoveGlobalCategoriesL Done in CLandmarkTestProcedureBase")); + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::Trace +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::Trace(TBuf8 aMsg) + { + _LIT(KFileTrace, "c:\\LandmarksTestsTrace.txt"); + _LIT8(KEnd,"\r\n"); + + RFs fs; + fs.Connect(); + + RFile file; + TInt err = file.Open(fs, KFileTrace, EFileWrite); + + if ( err ) + { + err = file.Create(fs, KFileTrace, EFileWrite); + } + + if ( !err ) + { + TInt pos = 0; + file.Seek( ESeekEnd, pos ); + file.Write( aMsg ); + file.Write( KEnd() ); + } + + file.Close(); + fs.Close(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AppendSearchResultsL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CLandmarkTestProcedureBase::AppendSearchResultsL() + { + if (iSearchResults.Count() == 0 ) + { + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmDbSearchResult.txt"); + + RFile file; + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + CleanupClosePushL(file); + + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + CSearchResult* searchResult = CSearchResult::NewL(line); + CleanupStack::PushL(searchResult); + + User::LeaveIfError(iSearchResults.Append(searchResult)); + CleanupStack::Pop(searchResult); + } + } + CleanupStack::PopAndDestroy(&file); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AppendAreaSearchResultsL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CLandmarkTestProcedureBase::AppendAreaSearchResultsL() + { + if (iSearchResults.Count() == 0) + { + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\lmDbAreaSearchResult.txt"); + + RFile file; + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + CleanupClosePushL(file); + + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + CAreaSearchResult* searchResult = CAreaSearchResult::NewL(line); + CleanupStack::PushL(searchResult); + + User::LeaveIfError(iAreaSearchResults.Append(searchResult)); + CleanupStack::Pop(searchResult); + } + } + CleanupStack::PopAndDestroy(&file); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AppendCategoryLandmarkSearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CLandmarkTestProcedureBase::AppendCategoryLandmarkSearchResultsL() + { + if (iCategoryLandmarkSearchResults.Count() == 0 ) + { + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmDbCatLandmarkSearchResult.txt"); + + RFile file; + TInt err = file.Open(iFileSession, KFileTestValues, EFileRead); + AssertTrueSecL( err == KErrNone, _L("AppendCategoryLandmarkSearchResultsL file error")); + CleanupClosePushL(file); + + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + CCategoryLandmarkSearchResult* oneLineResult = CCategoryLandmarkSearchResult::NewL(line); + CleanupStack::PushL(oneLineResult); + + User::LeaveIfError(iCategoryLandmarkSearchResults.Append(oneLineResult)); + CleanupStack::Pop(oneLineResult); + + } + } + + CleanupStack::PopAndDestroy(&file); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AppendCategorySearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CLandmarkTestProcedureBase::AppendCategorySearchResultsL() + { + if (iCategorySearchResults.Count() == 0 ) + { + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmDbCategorySearchResult.txt"); + + RFile file; + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + CleanupClosePushL(file); + + + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + CCategorySearchResult* oneLineResult = CCategorySearchResult::NewL(line); + CleanupStack::PushL(oneLineResult); + + User::LeaveIfError(iCategorySearchResults.Append(oneLineResult)); + CleanupStack::Pop(oneLineResult); + //iLog->Log(line); + } + } + + CleanupStack::PopAndDestroy(&file); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::SeachResults +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +const RPointerArray& CLandmarkTestProcedureBase::SearchResults() + { + return iSearchResults; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::AreaSeachResults +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +const RPointerArray& CLandmarkTestProcedureBase::AreaSearchResults() + { + return iAreaSearchResults; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::ReadLn +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::ReadLn(RFile& aFile, TDes& aDes) + { + aDes = KNullDesC; + TBuf8 line; + + TInt err = aFile.Read(line); + if (line.Length() == 0) + { + return KErrEof; + } + if (err) + { + return err; + } + + // Find line feed + TInt i = 0; + TLex8 fileData; + fileData.Assign(line); + while (fileData.Peek() != '\n' && !(fileData.Peek()).Eos()) + { + fileData.Inc(); + if (++i == KMaxLineLength) + { + // In case no carriage return or end of string characters are present. + break; + } + } + + // Update file position + TInt diff = -(line.Length() - i - 1); + aFile.Seek(ESeekCurrent, diff); + + // Convert to 16-bit + line.SetLength(i); + aDes.Copy(line); + + return KErrNone; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CompareL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CompareL( + const TDesC& aSourceFileName, + const TDesC& aTargetFileName) + { + _LIT(KCompareErr, "Compared file %S is not equal to %S"); + _LIT(KLineErr, "Line %S is different to line %S"); + + iLog->Log(_L("CompareL: source file '%S' with target file '%S'"), &aSourceFileName, &aTargetFileName ); + + RFile targetFile, sourceFile; + + TInt err = KErrNone; + err = sourceFile.Open(iFileSession, aSourceFileName, EFileRead); + if ( err ) + { + iLog->Log(_L("Failed to open source file '%S', err % d"), &aSourceFileName, err ); + User::Leave( err ); + } + CleanupClosePushL(sourceFile); + + err = targetFile.Open(iFileSession, aTargetFileName, EFileRead); + if ( err ) + { + iLog->Log(_L("Failed to open target file '%S', err % d"), &aTargetFileName, err ); + User::Leave( err ); + } + CleanupClosePushL(targetFile); + + TBuf<255> sourceLine; + TBuf<255> targetLine; + + while (ReadLn(sourceFile, sourceLine) != KErrEof) + { + ReadLn(targetFile, targetLine); + + if (sourceLine.Compare(targetLine) != 0) + { + TBuf<255> info; + info.Format(KCompareErr, &aSourceFileName, &aTargetFileName); + iLog->Log(info); + + info.Format(KLineErr, &targetLine, &sourceLine); + iLog->Log(info); + + err = KErrGeneral; + break; + } + } + + CleanupStack::PopAndDestroy(&targetFile); + CleanupStack::PopAndDestroy(&sourceFile); + return err; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CompareL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CompareL(const TDesC& aFileName) + { + _LIT(KTargetPath, "c:\\"); + + _LIT(KSourcePath, "c:\\system\\test\\testdata\\"); + + TBuf<100> target; + target.Append(KTargetPath); + target.Append(aFileName); + + TBuf<100> source; + source.Append(KSourcePath); + source.Append(aFileName); + + return CompareL(source, target); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::PrintLandmark +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::PrintLandmark(const CPosLandmark& aLandmark, TDes& aPrint) + { + + + TChar del(','); + + _LIT(KIntInfo, "%d"); + TBuf info; + TPosLmItemId id = aLandmark.LandmarkId(); + if (id != 0) + { + info.Format(KIntInfo, id); + aPrint.Append(info); + } + aPrint.Append(del); + + RArray lmcats; + // How to do this in test code, with non leaving function? // fran + CleanupClosePushL(lmcats); + TRAPD(error, aLandmark.GetCategoriesL(lmcats)); + + if (error == KErrNone) + { + _LIT(KStart, "{"); + _LIT(KStop, "}"); + aPrint.Append(KStart); + for (TInt i=0; i& aArray, + const TPosLmSortPref& aSortPref) + { + RPointerArray landmarks; + CleanupClosePushL(landmarks); + + for (TInt i=0; iReadLandmarkLC(aArray[i]); + landmarks.Append(lm); + CleanupStack::Pop(lm); + } + + TLinearOrder order(InternalLandmarksSortL); + landmarks.Sort(order); + + aArray.Reset(); + + if (aSortPref.SortOrder() == TPosLmSortPref::EAscending) + { + for (TInt j=0; jLandmarkId()); + } + } + else + { + for (TInt k=landmarks.Count()-1; k>=0; k--) + { + aArray.Append(landmarks[k]->LandmarkId()); + } + } + landmarks.ResetAndDestroy(); + CleanupStack::PopAndDestroy(&landmarks); + } + + +// --------------------------------------------------------- +// InternalCategorySortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt InternalCategorySortL(const CPosLandmarkCategory& aSource, const CPosLandmarkCategory& aTarget) + { + TPtrC sourceName, targetName; + + User::LeaveIfError(aSource.GetCategoryName(sourceName)); + User::LeaveIfError(aTarget.GetCategoryName(targetName)); + + return sourceName.CompareC(targetName); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CategoriesSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CategoriesSortL(RArray& aArray, + CPosLmCategoryManager::TCategorySortPref aSortPref) + { + RPointerArray categories; + CleanupClosePushL(categories); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + for (TInt i=0; iReadCategoryLC(aArray[i]); + categories.Append(cat); + CleanupStack::Pop(cat); + } + + TLinearOrder order(InternalCategorySortL); + categories.Sort(order); + + aArray.Reset(); + + if (aSortPref == CPosLmCategoryManager::ECategorySortOrderNameAscending) + { + for (TInt j=0; jCategoryId()); + } + } + else + { + for (TInt k=categories.Count()-1; k>=0; k--) + { + aArray.Append(categories[k]->CategoryId()); + } + } + categories.ResetAndDestroy(); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(&categories); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::LogToFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::LogToFileL(const TDesC& aFileName, TBuf8 aMsg) + { + _LIT8(KEnd,"\r\n"); + + BaflUtils::EnsurePathExistsL( iFileSession, aFileName ); + + RFile file; + TInt err = file.Open(iFileSession, aFileName, EFileWrite); + if ( err ) + { + err = file.Create(iFileSession, aFileName, EFileWrite); + } + + if ( !err ) + { + TInt pos = 0; + file.Seek( ESeekEnd, pos ); + file.Write( aMsg ); + file.Write( KEnd ); + } + + file.Close(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RunAsyncOperationLD +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RunAsyncOperationLD(CPosLmOperation* aOperation) + { + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog, iUseLogFromThreadIsDisabled); + CleanupStack::PushL(activeLmOperation); + + activeLmOperation->Start(aOperation); + + CActiveScheduler::Start(); + + activeLmOperation->CheckOperationL(); + activeLmOperation->DeleteOperationD(); + + CleanupStack::PopAndDestroy(activeLmOperation); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RunAsyncOperationLD +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RunAsyncOperationL( + CPosLmOperation* aOperation) + { + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog, iUseLogFromThreadIsDisabled); + CleanupStack::PushL(activeLmOperation); + + activeLmOperation->Start(aOperation); + + CActiveScheduler::Start(); + + activeLmOperation->CheckOperationL(); + + CleanupStack::PopAndDestroy(activeLmOperation); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RunAsyncOperationByWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RunAsyncOperationByWaitForReqL( + CPosLmOperation* aOperation) + { + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress = 0; + + while (status == KPosLmOperationNotComplete) + { + aOperation->NextStep(status, progress); + User::WaitForRequest(status); + } + + _LIT(KStatusError, "Executing CPosLmOperation by using User::WaitForRequest() failed with %d"); + AssertTrueSecL(status.Int() == KErrNone, KStatusError, status.Int()); + + _LIT(KProgError, "Progress not 1.0 but %d when executing CPosLmOperation with User::WaitForRequest()"); + AssertTrueSecL(progress == 1.0, KProgError, (TInt) (progress * 100)); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RunAsyncOperationAndCancelLD +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RunAsyncOperationAndCancelLD(CPosLmOperation* aOperation) + { + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog, iUseLogFromThreadIsDisabled); + CleanupStack::PushL(activeLmOperation); + + activeLmOperation->Start(aOperation); + + activeLmOperation->DeleteOperationD(); + + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(activeLmOperation); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::RunAsyncOperationAndCancelInCallbackLD +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::RunAsyncOperationAndCancelInCallbackLD( + CPosLmOperation* aOperation, + TReal32 aThreshold) + { + if (aThreshold > 0) + { + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation( + iLog, iUseLogFromThreadIsDisabled, aThreshold); + CleanupStack::PushL(activeLmOperation); + + TCallBack callback(CancelTest, activeLmOperation); + + CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); + CleanupStack::PushL(periodicTimer); + + periodicTimer->Start(1, 1, callback); + + activeLmOperation->SetCancelTest(); + activeLmOperation->Start(aOperation); + + CActiveScheduler::Start(); + + periodicTimer->Cancel(); + + if (activeLmOperation->Operation()) + { + // In case of no cancel + activeLmOperation->DeleteOperationD(); + if (activeLmOperation->DeltaProgress() < 1 - aThreshold) + { + iLog->Log(_L("Test was never cancelled!")); + } + } + + CleanupStack::PopAndDestroy(2, activeLmOperation); + } + else + { + // Cancel immediately + RunAsyncOperationAndCancelLD(aOperation); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::CancelTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CancelTest(TAny* aSelf) + { + CActiveLmOperation* activeLmOperation = static_cast(aSelf); + + if (activeLmOperation->Progress() >= activeLmOperation->Threshold()) + { + activeLmOperation->DeleteOperationD(); + } + + return 0; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::DeleteFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::DeleteFileL(const TDesC& aFile) + { + TInt err = iFileSession.Delete(aFile); + + TBuf<512> buf; + + if (err == KErrNone) + { + _LIT(KDebugText, "DeleteFileL: Specified file '%S' has been deleted"); + buf.Format(KDebugText, &aFile, err); + iLog->Log(buf); + } + else + { + _LIT(KErrText, "DeleteFileL: Specified file '%S' could not be deleted, error %d"); + buf.Format(KErrText, &aFile, err); + iLog->Log(buf); + switch ( err ) + { + case KErrNotFound: + case KErrPathNotFound: + break; + default: + User::Leave(err); + break; + } + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::ServerAliveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::MakeSurePanicDebugFileExistsL() + { + _LIT(KFileName, "c:\\system\\bootdata\\ErrRd"); + _LIT(KFilePath, "c:\\system\\bootdata\\"); + + TInt res = iFileSession.MkDirAll(KFilePath); + if (res != KErrAlreadyExists && res != KErrNone) + { + iLog->Log(_L("Problem creating directory c:\\system\\bootdata\\")); + User::Leave(res); + } + + RFile panicDebugFile; + res = panicDebugFile.Create(iFileSession, KFileName, EFileRead); + CleanupClosePushL(panicDebugFile); + + if (res != KErrAlreadyExists && res != KErrNone) + { + iLog->Log(_L("Problem creating file c:\\system\\bootdata\\ErrRd")); + User::Leave(res); + } + + CleanupStack::PopAndDestroy(&panicDebugFile); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::ServerAliveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CLandmarkTestProcedureBase::ServerAlive(const TDesC& aServerName) + { + TFindServer find(aServerName); + TFullName name; + if (find.Next(name) == KErrNone) // server found + { + TBuf<100> buf; + buf.Append(_L("Found server: ")); + buf.Append(name); + iLog->Log(buf); + return ETrue; + } + else + { + return EFalse; + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::ListLandmarkDbsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CDesCArray* CLandmarkTestProcedureBase::ListLandmarkDbsL() + { + CPosLmDatabaseManager* dbman = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbman); + CDesCArray* dbs = dbman->ListDatabasesLC(); + CleanupStack::Pop(dbs); + CleanupStack::PopAndDestroy(dbman); + return dbs; + } + +// ----------------------------------------------------------------------------- +// CActiveLmOperation::CActiveLmOperation +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CActiveLmOperation::CActiveLmOperation( + CStifLogger* aLog, + TBool aUseLogFromThreadIsDisabled, + TReal32 aThreshold) +: CActive(EPriorityNormal), + iThreshold(aThreshold), + iUseLogFromThreadIsDisabled(aUseLogFromThreadIsDisabled), + iLog(aLog) + { + CActiveScheduler::Add(this); + } + + +// Destructor +CActiveLmOperation::~CActiveLmOperation() + { + Cancel(); + + } + +// --------------------------------------------------------- +// CActiveLmOperation::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmOperation::Start( + CPosLmOperation* aOperation, + MProgressObserver* aObserver) + { + iOperation = aOperation; + iObserver = aObserver; + + TTime start, stop; + start.UniversalTime(); + iOperation->NextStep(iStatus, iPassedProgress); + stop.UniversalTime(); + + TInt64 usec = (stop.Int64() - start.Int64()); + + TBuf8 msg; + _LIT8(KTrace, "First next step took %d µs"); + msg.Format(KTrace, usec); + // Dont log if used from different threads + // ex TP30,TP31 + // Log if step took more than 0.1 seconds + if (!iUseLogFromThreadIsDisabled && usec > KFirstNextStepLogLimit) + { + iLog->Log(msg); + } + + SetActive(); + } + +// --------------------------------------------------------- +// CActiveLmOperation::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmOperation::RunL() + { + if (iPassedProgress < iLastProgress) + { + iAsyncProgressErr = ETrue; + } + + iDeltaProgress = iPassedProgress - iLastProgress; + iLastProgress = iPassedProgress; + if (iObserver) + { + iObserver->NotifyProgress(iPassedProgress); + } + + if (iStatus == KPosLmOperationNotComplete && iOperation) + { + if (iLastProgress == 1.0) + { + iPassedProgressErr = ETrue; + } + + iOperation->NextStep(iStatus, iPassedProgress); + + if (iCancelTest) + { + User::After(1); + } + + SetActive(); + } + else + { + if (iStatus == KErrNone && iPassedProgress != 1.0) + { + iPassedProgressErr = ETrue; + } + + iLastProgress = 0; + CActiveScheduler::Stop(); + } + + + } + +// --------------------------------------------------------- +// CActiveLmOperation::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmOperation::DoCancel() + { + + } + +// --------------------------------------------------------- +// CActiveLmOperation::CheckOperationL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmOperation::CheckOperationL() + { + _LIT(KAsyncStatusErr, "Status incorrect in RunL = %d"); + _LIT(KAsyncProgressErr, "Progress not updated in RunL"); + _LIT(KPassedProgressErr, "Passed Progress is not updated correctly in RunL"); + + if (iAsyncProgressErr) + { + iLog->Log(KAsyncProgressErr); + User::Leave(KErrGeneral); + } + + if (iPassedProgressErr) + { + iLog->Log(KPassedProgressErr); + User::Leave(KErrGeneral); + } + + if (iStatus != KErrNone) + { + if (!iUseLogFromThreadIsDisabled) + { + TBuf<100> info; + info.Format(KAsyncStatusErr, iStatus.Int()); + iLog->Log(info); + } + User::Leave(iStatus.Int()); + } + + iAsyncProgressErr = iPassedProgressErr = EFalse; + + } + +// --------------------------------------------------------- +// CActiveLmOperation::DeleteOperationD +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CActiveLmOperation::DeleteOperationD() + { + delete iOperation; + iOperation = NULL; + } + +// --------------------------------------------------------- +// CActiveLmOperation::Status +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CActiveLmOperation::Status() const + { + return iStatus.Int(); + } + +// --------------------------------------------------------- +// CActiveLmOperation::Progress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal CActiveLmOperation::Progress() const + { + return iLastProgress; + } + +// --------------------------------------------------------- +// CActiveLmOperation::Operation +// +// (other items were commented in a header). +// --------------------------------------------------------- +CPosLmOperation* CActiveLmOperation::Operation() + { + return iOperation; + } + +//--------------------------------------------------------- +// CActiveLmOperation::SetCancelTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmOperation::SetCancelTest() + { + iCancelTest = ETrue; + } + +//--------------------------------------------------------- +// CActiveLmOperation::Threshold +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal32 CActiveLmOperation::Threshold() + { + return iThreshold; + } + +//--------------------------------------------------------- +// CActiveLmOperation::DeltaProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal32 CActiveLmOperation::DeltaProgress() + { + return iDeltaProgress; + } + +// <---------------- inner class COnTheFlyTester (utility class for testing multiDbSearch) ----------------> + +// Constructor +CLandmarkTestProcedureBase::COnTheFlyTester::COnTheFlyTester() : CActive(CActive::EPriorityStandard) + { + CActiveScheduler::Add(this); + } + +// Desctructor +CLandmarkTestProcedureBase::COnTheFlyTester::~COnTheFlyTester() + { + delete iDisplayData; + delete iOperation; + Cancel(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::NewLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CLandmarkTestProcedureBase::COnTheFlyTester* CLandmarkTestProcedureBase::COnTheFlyTester::NewLC() + { + CLandmarkTestProcedureBase::COnTheFlyTester* self = new (ELeave) CLandmarkTestProcedureBase::COnTheFlyTester; + CleanupStack::PushL(self); + return self; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::StartSearchCampaignL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::COnTheFlyTester::StartSearchCampaignL( + CPosLmMultiDbSearch* aSearcher, + const RIdArray& aExpectedMatches, + CPosLmSearchCriteria* aSearchCriteria) + { + iSearcher = aSearcher; + iExpectedMatches = &aExpectedMatches; + + // Set DisplayData + delete iDisplayData; + iDisplayData = NULL; + iDisplayData = CPosLmDisplayData::NewL(); + CPosLmPartialReadParameters* partialReadParams = CPosLmPartialReadParameters::NewLC(); + partialReadParams->SetRequestedAttributes(CPosLandmark::ELandmarkName); + iDisplayData->SetPartialReadParametersL(*partialReadParams); + iSearcher->SetDisplayData(*iDisplayData); + CleanupStack::PopAndDestroy(partialReadParams); + + // Start search + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + delete iOperation; + iOperation = NULL; + iOperation = iSearcher->StartLandmarkSearchL(*aSearchCriteria, sortPref); + iOperation->NextStep(iStatus, iProgress); + SetActive(); + + CActiveScheduler::Start(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::COnTheFlyTester::RunL() + { + iErr = iStatus.Int(); + switch (iErr) + { + case KPosLmOperationNotComplete: + VerifyOnTheFlyDataL(); + iOperation->NextStep(iStatus, iProgress); + SetActive(); + break; + + case KErrNone: + VerifyOnTheFlyDataL(ETrue); + CActiveScheduler::Stop(); + break; + + default: + User::Leave(iErr); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::COnTheFlyTester::DoCancel() + { + delete iOperation; + iOperation = NULL; + CActiveScheduler::Stop(); + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::RunError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::COnTheFlyTester::RunError(TInt aError) + { + iErr = aError; + CActiveScheduler::Stop(); + return KErrNone; + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::COnTheFlyTester::VerifyOnTheFlyDataL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::COnTheFlyTester::VerifyOnTheFlyDataL(TBool aIsFinished) + { + // No errors should have occurred + if (iSearcher->NumOfSearchErrors() != 0) + { + iBuf = _L("iSearcher->NumOfSearchErrors() != 0"); + User::Leave(KErrGeneral); + } + + // Verify that number of found matches does not decrease + TInt nrOfItems = iDisplayData->Count(); + if (nrOfItems < iNrOfOldItems) + { + iBuf = _L("nrOfItems < iNrOfOldItems"); + User::Leave(KErrGeneral); + } + iNrOfOldItems = nrOfItems; + + // Verify sort order + for (TInt i = 0; i < nrOfItems; i++) + { + CPosLmDisplayItem& displayItem = iDisplayData->DisplayItem(i); + if (displayItem.DisplayItemType() != CPosLmDisplayItem::ELandmarkItem) + { + iBuf = _L("Wrong displayItemType"); + User::Leave(KErrGeneral); + } + if (i < nrOfItems - 1) + { + TPtrC name1, name2; + displayItem.Landmark().GetLandmarkName(name1); + iDisplayData->DisplayItem(i + 1).Landmark().GetLandmarkName(name2); + if (name1.CompareC(name2) > 0) + { + iBuf.Format(_L("%S is greater than %S"), &name1, &name2); + User::Leave(KErrGeneral); + } + } + } + + // When completed, the expected number of matches should have been found + if (aIsFinished) + { + TInt totNrOfMatches = iSearcher->TotalNumOfMatches(); + TInt expectedNrOfHits = iExpectedMatches->Count(); + if (totNrOfMatches != expectedNrOfHits) + { + iBuf.Format(_L("Wrong number of landmarks returned when searching for landmarks, found: %d expected %d"), totNrOfMatches, expectedNrOfHits); + User::Leave(KErrGeneral); + } + for (TInt i = 0; i < expectedNrOfHits; i++) + { + TInt found = iExpectedMatches->Find(iDisplayData->DisplayItem(i).Landmark().LandmarkId()); + if (found == KErrNotFound) + { + iBuf.Format(_L("Non-qualified landmark was found")); + User::Leave(KErrNotFound); + } + TPtrC name; + iDisplayData->DisplayItem(i).Landmark().GetLandmarkName(name); + } + } + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::ReadGlobalCategoriesFromResourceL( + RArray& aCatIds, + RPointerArray& aCatNames, + TInt aMaxNum ) + { + _LIT(KGlobalCategoryResourceFile, "z:\\Resource\\eposlmglobalcategories.rsc"); + const TInt KPosLmGlCatResourceOffset = 1; + + TFileName filename(KGlobalCategoryResourceFile); + BaflUtils::NearestLanguageFile( iFileSession, filename ); + + CResourceFile* resFile = CResourceFile::NewLC( iFileSession, filename, 0, 0 ); + + RResourceReader reader; + reader.OpenLC( resFile, KPosLmGlCatResourceOffset ); + + // Read the size of the icon path array. + TInt size = reader.ReadInt8L(); + + // read icon paths + for (TInt i = 0; i < size; i++) + { + HBufC* path = reader.ReadHBufCL(); + delete path; + } + + // read category data + size = reader.ReadInt16L(); + if ( aMaxNum > 0 ) + { + size = Min( size, aMaxNum ); + } + + for (TInt i = 0; i < size; i++) + { + TInt id = reader.ReadUint32L(); + aCatIds.Append( id ); + HBufC* name = reader.ReadHBufCL(); + aCatNames.Append( name ); + + //iLog->Log(_L("Localized category: id: %d, name: '%S'"), id, name); + + reader.ReadInt32L(); + reader.ReadInt32L(); + reader.ReadInt8L(); + } + CleanupStack::PopAndDestroy( &reader ); + CleanupStack::PopAndDestroy( resFile ); + } + + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::ResetAndDestroyHBufCArray( TAny* aPointer ) + { + RPointerArray* array = ( RPointerArray* ) aPointer; + array->ResetAndDestroy(); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CLandmarkTestProcedureBase::CreateCorrectXmlFileL( const TDesC& aSampleFile, TFileName& aFileName ) + { + _LIT( KTargetFolder, "c:\\documents\\" ); + _LIT( KNewFileSuffix, ".localized" ); + + iLog->Log(_L("Making localized XML file out of '%S'"), &aSampleFile ); + + RFileReadStream source; + TInt err = source.Open( iFileSession, aSampleFile, EFileRead ); + if ( err ) + { + iLog->Log(_L("Failed to open source file '%S', err %d"), &aSampleFile, err ); + User::Leave( err ); + } + CleanupClosePushL( source ); + + TParse parse; + parse.Set( aSampleFile, 0, 0 ); + aFileName = KTargetFolder; + aFileName.Append( parse.Name() ); + aFileName.Append( KNewFileSuffix ); + aFileName.Append( parse.Ext() ); + + RFile target; + err = target.Replace( iFileSession, aFileName, EFileRead ); + if ( err ) + { + iLog->Log(_L("Failed to create target file '%S', err %d"), &aFileName, err ); + User::Leave( err ); + } + CleanupClosePushL( target ); + + // Replace Global Category macros with correct strings + + RArray globalIds; + RPointerArray names; + CleanupStack::PushL( TCleanupItem( CLandmarkTestProcedureBase::ResetAndDestroyHBufCArray, &names ) ); + ReadGlobalCategoriesFromResourceL( globalIds, names ); + + const TChar KIdStart = '{'; + const TChar KIdEnd = '}'; + //category name length should be <= 124 + _LIT( KGlobalCategoryMacro, "__GLOBAL_CAT_{" ); + + TBuf8<1024> line8; + while ( !err ) + { + TRAP( err, source.ReadL( line8, TChar('\n') ) ); + if ( !err ) + { + HBufC* line16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( line8 ); + CleanupStack::PushL( line16 ); + TPtr line( line16->Des() ); + + TInt macroStart = line.Find( KGlobalCategoryMacro ); + if ( macroStart != KErrNotFound ) + { + // find global categoryid in the macro + TInt idStart = line.Locate( KIdStart ); + TInt idEnd = line.Locate( KIdEnd ); + + TLex idStr( line.Mid( idStart + 1, idEnd - idStart - 1 ) ); + + TUint globalId = 0; + idStr.Val( globalId ); + + // find localized string for the category + TInt idIndex = globalIds.Find( globalId ); + + // put it to the file instead of macro + if ( idIndex >= 0 ) + { + HBufC* des = EscapeStringToXmlLC(*(names[idIndex])); + + + if(des->Length() > (idEnd - macroStart + 1)) + { + TInt diffrence = des->Length() - (idEnd - macroStart + 1); + HBufC* diffStr = HBufC::NewLC(diffrence * 2); + TPtr ptr(diffStr->Des()); + TInt i=0; + for(i=0; iReAllocL(line.MaxLength() + i); + TPtr newPtr(line16->Des()); + newPtr.Insert(idEnd, ptr); + newPtr.Replace( macroStart, (idEnd + i) - macroStart + 1, des->Des() ); + HBufC8* newLine8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( newPtr ); + target.Write( *newLine8 ); + delete newLine8; + CleanupStack::PopAndDestroy( diffStr ); + } + else + { + line.Replace( macroStart, idEnd - macroStart + 1, des->Des() ); + HBufC8* newLine8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( line ); + target.Write( *newLine8 ); + delete newLine8; + } + CleanupStack::PopAndDestroy(des); + } + + + } + else + { + target.Write( line8 ); + } + + CleanupStack::PopAndDestroy( line16 ); + } + else + { + iLog->Log(_L("Stopped reading from '%S' with code %d"), &aSampleFile, err ); + } + } + + target.Flush(); + CleanupStack::PopAndDestroy(); // names + CleanupStack::PopAndDestroy( &target ); + CleanupStack::PopAndDestroy( &source ); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +HBufC* CLandmarkTestProcedureBase::GetGlobalCategoryFromResourceLC( TPosLmGlobalCategory aGlobalId ) + { + HBufC* name = NULL; + RArray catIds; + RPointerArray catNames; + + CleanupClosePushL( catIds ); + CleanupStack::PushL( TCleanupItem( ResetAndDestroyHBufCArray, &catNames )); + + ReadGlobalCategoriesFromResourceL( catIds, catNames ); + TInt idIndex = catIds.Find( aGlobalId ); + if ( idIndex >= 0 ) + { + name = catNames[idIndex]; + catNames.Remove( idIndex ); + } + else + { + iLog->Log(_L("Global category %d not found"), aGlobalId ); + User::Leave( KErrNotFound ); + } + CleanupStack::PopAndDestroy(); //catNames + CleanupStack::PopAndDestroy( &catIds ); + + CleanupStack::PushL( name ); + return name; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +HBufC* CLandmarkTestProcedureBase::ReadDefaultDatabaseNameFromResourceLC() + { + _LIT(KDatabaseNameResourceFile, "z:\\resource\\eposlmdefaultdbname.rsc"); + const TInt KNameResourceOffset = 2; + + TFileName filename( KDatabaseNameResourceFile ); + BaflUtils::NearestLanguageFile( iFileSession, filename ); + + CResourceFile* resFile = CResourceFile::NewLC( iFileSession, filename, 0, 0 ); + + RResourceReader reader; + reader.OpenLC( resFile, KNameResourceOffset ); + + HBufC* name = reader.ReadHBufCL(); + + CleanupStack::PopAndDestroy( &reader ); + CleanupStack::PopAndDestroy( resFile ); + + CleanupStack::PushL( name ); + return name; + } + +// ----------------------------------------------------------------------------- +// PosLmConverterUtils::EscapeStringToXmlLC +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +HBufC* CLandmarkTestProcedureBase::EscapeStringToXmlLC( + const TDesC& aStrToEscape) + { + HBufC* string = HBufC::NewLC(CalculateEscapedStringSize(aStrToEscape)); + string->Des().Copy(aStrToEscape); + + // Must start with &, because when escaping other characters & will be + // added to the string. + TPtr ptr = string->Des(); + EscapeString(ptr, KAmp, KAmpXmlStr); + EscapeString(ptr, KLt, KLtXmlStr); + EscapeString(ptr, KGt, KGtXmlStr); + EscapeString(ptr, KApos, KAposXmlStr); + EscapeString(ptr, KQuot, KQuotXmlStr); + + return string; + } + + // ----------------------------------------------------------------------------- +// PosLmConverterUtils::EscapeString +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLandmarkTestProcedureBase::EscapeString( + TDes& aStrToEscape, + const TDesC& aFromStr, + const TDesC& aToStr) + { + TPtrC ptr(aStrToEscape); + TInt lastPos = 0; + + // Find first occurence of the escape string. + TInt pos = ptr.Find(aFromStr); + + while (pos != KErrNotFound) + { + aStrToEscape.Replace(pos+lastPos, aFromStr.Length(), aToStr); + + // Move ptr forward past the inserted aToStr in aStrToEscape + pos += aToStr.Length(); + lastPos += pos; + ptr.Set(aStrToEscape.Right(aStrToEscape.Length() - lastPos)); + + // Find next occurence of the escape string. + pos = ptr.Find(aFromStr); + } + } + +// ----------------------------------------------------------------------------- +// PosLmConverterUtils::CalculateEscapedStringSize +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CalculateEscapedStringSize( + const TDesC& aStrToEscape) + { + return aStrToEscape.Length() + + CalculateIncrease(aStrToEscape, KAmp, KAmpXmlStr) + + CalculateIncrease(aStrToEscape, KLt, KLtXmlStr) + + CalculateIncrease(aStrToEscape, KGt, KGtXmlStr) + + CalculateIncrease(aStrToEscape, KApos, KAposXmlStr) + + CalculateIncrease(aStrToEscape, KQuot, KQuotXmlStr); + } + +// ----------------------------------------------------------------------------- +// PosLmConverterUtils::CalculateIncrease +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CLandmarkTestProcedureBase::CalculateIncrease( + const TDesC& aStrToEscape, + const TDesC& aFromStr, + const TDesC& aToStr) + { + TPtrC ptr(aStrToEscape); + TInt occurrences = 0; + + // Find first occurence of the escape string. + TInt pos = ptr.Find(aFromStr); + + while (pos != KErrNotFound) + { + ++occurrences; + + // Move ptr forward past the found occurence. + ptr.Set(ptr.Right(ptr.Length() - (pos + aFromStr.Length()))); + + // Find next occurence of the escaped string. + pos = ptr.Find(aFromStr); + } + + // Return the increased (or decreased) size impact on the string to escape. + return occurrences*(aToStr.Length() - aFromStr.Length()); + } diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP26.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP26.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp26.h" + +#include +#include +#include +#include + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp26::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp26::CloseTest() + { + delete iLandmarkSearch; + iLandmarkSearch = NULL; + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp26::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp26::StartL() + { + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + AppendSearchResultsL(); + + iLog->Log(_L("DoLandmarkSearchL(iSearchResults);")); + DoLandmarkSearchL(iSearchResults); + + AppendCategorySearchResultsL(); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + iLog->Log(_L("DoLandmarkCategorySearchL(iCategorySearchResults);")); + DoLandmarkCategorySearchL(iCategorySearchResults); + } + +// --------------------------------------------------------- +// CPosTp26::DoLandmarkCategorySearch +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp26::DoLandmarkCategorySearchL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + _LIT(KWrongIdErr, "Wrong id returned from iterator after reset"); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + // Use wildcard * as search pattern + nameCriteria->SetSearchPatternL(aSearchResults[0]->TextCriteria()); + + ExecuteAndDeleteLD(iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if ((TUint)(aSearchResults[0]->SearchResult()).Count() != iLandmarkSearch->NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[0]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Name criteria: ")); + iLog->Log(nameCriteria->SearchPattern()); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + // Get the first category in list, id1 + TPosLmItemId id1 = iter->NextL(); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(id1); + TPtrC name; + cat->GetCategoryName(name); + iLog->Log(_L("First time")); + iLog->Log(name); + CleanupStack::PopAndDestroy(cat); + + //Reset iterator and make sure that id1 is returned again + iter->Reset(); + TPosLmItemId id11 = iter->NextL(); + AssertTrueSecL(id1 == id11, KWrongIdErr); + + iLog->Log(_L("******************")); + // Iterate through whole iterator + while (id11 != KPosLmNullItemId) + { + AssertTrueSecL(aSearchResults[0]->FindSearchResult(id11), KNotFoundErr, id11); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(id11); + TPtrC name; + cat->GetCategoryName(name); + iLog->Log(name); + CleanupStack::PopAndDestroy(cat); + id11 = iter->NextL(); + } + iLog->Log(_L("******************")); + RArray lmIdArray; + CleanupClosePushL(lmIdArray); + + // Get a sequence of items from the iterated set + // lmIdArray should be reset in GetItemIdsL + // Use some magic numbers here, check landmarksDb.xls for more info + iter->GetItemIdsL(lmIdArray, 5, 10); + TInt nr = lmIdArray.Count(); + for (TInt j=0;jFindSearchResult(lmIdArray[j]), KNotFoundErr); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(lmIdArray[j]); + TPtrC name; + cat->GetCategoryName(name); + iLog->Log(name); + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&lmIdArray); + CleanupStack::PopAndDestroy(2, nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp26::DoLandmarkSearch +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp26::DoLandmarkSearchL(const RPointerArray& aSearchResults) + { + iLog->Log(_L("DoLandmarkSearch()")); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed asyncronously"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed asyncronously"); + _LIT(KNumOfMatchesInIteratorErr, "Wrong number of matches in iterator"); + _LIT(KWrongIdErr, "Wrong id returned from iterator after reset"); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + TBuf<150> buf; + _LIT(KDebug, "Searching for "); + + // Put this RArray outside loop so that if reset of the array is missing in the code + // it will be noticed + RArray lmIdArray; + CleanupClosePushL(lmIdArray); + + for(TInt i=0; iSetTextL(aSearchResults[i]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[i]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[i]->PositionFields()); + + buf.Zero(); + buf.Append(KDebug); + buf.Append(aSearchResults[i]->TextCriteria()); + iLog->Log(buf); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[i]->Redefined()); + RunAsyncOperationLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + buf.Zero(); + buf.Format(_L("Found %d nr of matches, should found %d nr of matches"), iLandmarkSearch->NumOfMatches(), (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(buf); + TUint nrOfMatches = iLandmarkSearch->NumOfMatches(); + AssertTrueSecL((TUint)(aSearchResults[i]->SearchResult()).Count() == nrOfMatches, KNumOfMatchesErr); + + TPosLmItemId id1 = iter->NextL(); + TPosLmItemId id = KPosLmNullItemId; + if (id1 != KPosLmNullItemId) + { + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id1); + CleanupStack::PopAndDestroy(lm); + // Reset the iterator and make sure that the first id is returned again + iter->Reset(); + id = iter->NextL(); + } + + AssertTrueSecL(id1 == id, KWrongIdErr); + TUint counter=0; + while (id != KPosLmNullItemId) + { + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr); + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + counter++; + } + TUint nrInIterator = iter->NumOfItemsL(); + if (nrOfMatches != counter || nrOfMatches != nrInIterator) + { + + iLog->Log(KNumOfMatchesInIteratorErr); + User::Leave(-1); + } + + // Get a sequence of items and check ids + TInt startIndex = 0; + // Just to get some different starting index depending on nr of ids + if (nrOfMatches>2) startIndex = 2; + if (nrOfMatches>5) startIndex = 5; + if (nrOfMatches>20) startIndex = 20; + + // Do this if there are some matches + if (nrOfMatches-startIndex>0) + { + buf.Zero(); + buf.Format(_L("GetItemIdsL from index %d nr of items index %d"), startIndex, nrOfMatches-startIndex); + iLog->Log(buf); + // lmIdArray should be reset in GetItemIdsL + iter->GetItemIdsL(lmIdArray, startIndex, nrOfMatches-startIndex); + + TInt nr = lmIdArray.Count(); + for (TInt j=0;jFindSearchResult(lmIdArray[j]), KNotFoundErr); + CPosLandmark* lm = iDatabase->ReadLandmarkLC(lmIdArray[j]); + CleanupStack::PopAndDestroy(lm); + } + } + + CleanupStack::PopAndDestroy(2, textCriteria); + } // end for + CleanupStack::PopAndDestroy(&lmIdArray); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP27.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP27.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,368 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp27.h" +#include +#include +#include +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp27::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp27::CloseTest() + { + delete iPeriodicTimer; + iPeriodicTimer = NULL; + + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp27::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp27::StartL() + { + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + CPosLmOperation* op = iDatabase->InitializeL(); + delete op; + } + + CancelLandmarkCategorySearch(); + + CancelLandmarkSearch(); + + AssertTrueSecL(iGlobalErr != KErrNone, _L("Errors found in TP27")); + } + +// --------------------------------------------------------- +// CPosTp27::CancelLandmarkCategorySearch +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp27::CancelLandmarkCategorySearch() + { + iLog->Log(_L("CancelLandmarkCategorySearch")); + CPosLmCatNameCriteria* searchCriteria = CPosLmCatNameCriteria::NewLC(); + + // Use name specified in test landmarksdb + searchCriteria->SetSearchPatternL(_L("Taxi")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase, this); + // Get maximum number of search attempts + iLandmarkSearch->StartCategorySearchL(*searchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + iHandleOperationDisabled = ETrue; + // Get the maximum of needed search rounds until search is complete + TInt MaxNrOfSearchRounds = iNrSearchRounds; + + // First test to cancel the search before it even has started + // use the callback StopActiveSchedulerWait to stop the active scheduler + // just to make sure that no HandleOperationProgress take place + iNrSearchRounds = 0; + iLandmarkSearch->StartCategorySearchL(*searchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + iLandmarkSearch->Cancel(); + + TCallBack callback(StopActiveSchedulerWait, this); + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + TTimeIntervalMicroSeconds32 stopTime = TTimeIntervalMicroSeconds32(4000000); // 4 sec + iPeriodicTimer->Start(stopTime, stopTime, callback); + iHandleOperationDisabled = ETrue; + iActiveSchedulerWait->Start(); + + delete iPeriodicTimer; + iPeriodicTimer = NULL; + + iLog->Log(_L("Starting")); + TInt i=0; + for (i=0; i<=MaxNrOfSearchRounds; i++) + { + iNrSearchRounds = 0; + iBreakSearch = i; + // Set to 100 so that it differs from progress the first time + iProgress=100; + iLog->Log(_L("StartCategorySearchL->")); + iLandmarkSearch->StartCategorySearchL(*searchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + + iLog->Log(_L("After iActiveSchedulerWait->Start() inside for loop")); + iHandleOperationDisabled = ETrue; + + // Check if anything was found + CPosLmItemIterator* iterator = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iterator); + + TInt numOfItems = 0; + numOfItems = iLandmarkSearch->NumOfMatches(); + + RArray ids; + CleanupClosePushL(ids); + + if (numOfItems != 0) + { + iLog->Log(_L("Found something")); + // Maybe we should check this item + iterator->GetItemIdsL(ids, 0, numOfItems); + } + + CleanupStack::PopAndDestroy(&ids); + CleanupStack::PopAndDestroy(iterator); + } + + iNrSearchRounds=0; + iBreakSearch = -1; + iCancelOrDelete = ETrue; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("This time, delete the search object to cancel the search")); + for (i=0; i<=MaxNrOfSearchRounds; i++) + { + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase, this); + // Set to 100 so that it differs from progress the first time + iProgress=100; + iNrSearchRounds = 0; + iBreakSearch = i; + iLog->Log(_L("StartCategorySearchL2->")); + iLandmarkSearch->StartCategorySearchL(*searchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + iHandleOperationDisabled = ETrue; + iLog->Log(_L("After iActiveSchedulerWait->Start() inside for loop")); + } + iHandleOperationDisabled = EFalse; + CleanupStack::PopAndDestroy(searchCriteria); + + iCancelOrDelete = EFalse; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp27::CancelLandmarkSearch +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp27::CancelLandmarkSearch() + { + iLog->Log(_L("CancelLandmarkSearch")); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + textCriteria->SetAttributesToSearch(attr); + // Use name specified in test landmarksdb + textCriteria->SetTextL(_L("enator")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase, this); + iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + iHandleOperationDisabled = ETrue; + + // Get the maximum of needed search rounds until search is complete + TInt MaxNrOfSearchRounds = iNrSearchRounds; + + // First test to cancel the search before it even has started + // use the callback StopActiveSchedulerWait to stop the active scheduler + // just to make sure that no HandleOperationProgress take place + iNrSearchRounds = 0; + iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + iLandmarkSearch->Cancel(); + + TCallBack callback(StopActiveSchedulerWait, this); + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + TTimeIntervalMicroSeconds32 stopTime = TTimeIntervalMicroSeconds32(4000000); // 4 sec + iPeriodicTimer->Start(stopTime, stopTime, callback); + iHandleOperationDisabled = ETrue; + iActiveSchedulerWait->Start(); + + delete iPeriodicTimer; + iPeriodicTimer = NULL; + + iLog->Log(_L("Starting")); + TInt i=0; + for (i=0; i<=MaxNrOfSearchRounds; i++) + { + iNrSearchRounds = 0; + iBreakSearch = i; + // Set to 100 so that it differs from progress the first time + iProgress=100; + iLog->Log(_L("StartLandmarkSearchL->")); + iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + + iLog->Log(_L("After iActiveSchedulerWait->Start() inside for loop")); + iHandleOperationDisabled = ETrue; + + // Check if anything was found + CPosLmItemIterator* iterator = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iterator); + + TInt numOfItems = 0; + numOfItems = iLandmarkSearch->NumOfMatches(); + + RArray ids; + CleanupClosePushL(ids); + + if (numOfItems != 0) + { + iLog->Log(_L("Found something")); + iterator->GetItemIdsL(ids, 0, numOfItems); + } + + CleanupStack::PopAndDestroy(&ids); + CleanupStack::PopAndDestroy(iterator); + } + + iNrSearchRounds=0; + iBreakSearch = -1; + iCancelOrDelete = ETrue; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("This time, delete the search object to cancel the search")); + for (i=0; i<=MaxNrOfSearchRounds; i++) + { + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase, this); + // Set to 100 so that it differs from progress the first time + iProgress=100; + iNrSearchRounds = 0; + iBreakSearch = i; + iLog->Log(_L("StartLandmarkSearchL2->")); + iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + iHandleOperationDisabled = EFalse; + iActiveSchedulerWait->Start(); + iHandleOperationDisabled = ETrue; + iLog->Log(_L("After iActiveSchedulerWait->Start() inside for loop")); + } + iHandleOperationDisabled = EFalse; + CleanupStack::PopAndDestroy(textCriteria); + + iCancelOrDelete = EFalse; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + + +// --------------------------------------------------------- +// CPosTp27::StopActiveSchedulerWait +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp27::StopActiveSchedulerWait(TAny* aSelf) + { + //do not forget to cancel the timer + CPosTp27* self = static_cast (aSelf); + self->iPeriodicTimer->Cancel(); + self->iActiveSchedulerWait->AsyncStop(); + return KErrNone; + } + +// --------------------------------------------------------- +// CPosTp27::HandleOperationProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp27::HandleOperationProgress(CPosLmOperation* aOperation) + { + //if (iDebug) iLog->Log(_L("HandleOperationProgress")); + + // If no HandleOperationProgress should occur, eg no search is started + if (iHandleOperationDisabled) + { + iLog->Log(_L("ERROR: No HandleOperationProgress should occur")); + iGlobalErr++; + } + else + { + // If progress is 100%, always stop the search + // Check that progress is moving + TReal32 progress = aOperation->Progress(); + if (iProgress == progress) + { + iLog->Log(_L("MyError:Progressindicator not moving")); + iGlobalErr++; + } + iProgress = progress; + TBuf<50> buf; + buf.Format(_L("****Progress %f"), progress); + if (iDebug) iLog->Log(buf); + + // Not sure about this condition, is it ok to compare TReal32 like this + if (progress == 1) + { + if (iDebug) iLog->Log(_L("Stopping")); + iActiveSchedulerWait->AsyncStop(); + return; + } + + if (iNrSearchRounds == iBreakSearch) + { + if (!iCancelOrDelete) + { + if (iDebug) iLog->Log(_L("Cancelling")); + aOperation->Cancel(); + iActiveSchedulerWait->AsyncStop(); + if (aOperation->Status() != KErrCancel) + { + TBuf<50> buf; + buf.Format(_L("MyError: Wrong status, should be KErrCancel, but was %d"), aOperation->Status()); + iLog->Log(buf); + iGlobalErr++; + } + } + else + { + if (iDebug) iLog->Log(_L("Cancel by deleting search object")); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iActiveSchedulerWait->AsyncStop(); + } + } + iNrSearchRounds++; + } + } +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP28.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP28.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,620 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp28.h" +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KMaxQueueSize = 5; +_LIT(KTp28TestDb, "Tp28Test.ldb"); +_LIT(KTp28LmFullDefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP28TEST.LDB"); + +// --------------------------------------------------------- +// CPosTp28::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp28::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + delete iCategoryManager; + iCategoryManager=NULL; + delete iActiveLmEvent; + iActiveLmEvent = NULL; + } + +// --------------------------------------------------------- +// CPosTp28::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp28::StartL() + { + // copy the test db to the private database path + + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp28TestDb); + + TInt err = fileMan->Copy(srcPath, KTp28LmFullDefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp28TestDb); + CleanupStack::PopAndDestroy(manager); + + iDatabase = CPosLandmarkDatabase::OpenL(KTp28TestDb); + if (iDatabase->IsInitializingNeeded()) + { + TRAPD( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL(err == KErrNone, _L("Init db failed")); + } + + + + iActiveLmEvent = CActiveLmEvent::NewL(iLog); + + LandmarkEventTest(); + + delete iActiveLmEvent; + iActiveLmEvent = NULL; + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(KTp28TestDb); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + + iActiveLmEvent = CActiveLmEvent::NewL(iLog); + + LandmarkEventQueueTest(); + + if (iActiveLmEvent->iGlobalErr != KErrNone) + { + + iLog->Log(_L("Errors found in TP28")); + User::Leave(-1); + + } + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkEventTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp28::LandmarkEventTest() + { + + iActiveLmEvent->Start(); + + ///////////////////////////////////////////// + // Add three landmarks #1 #2 #3 + ///////////////////////////////////////////// + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("Zu Hause")); + CPosLandmark* landmark2 = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("Zu Hause jetzt")); + CPosLandmark* landmark3 = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("Nicht Zu Hause")); + + iActiveLmEvent->iLandmarkId = iDatabase->AddLandmarkL(*landmark); + iActiveLmEvent->iLandmarkId2 = iDatabase->AddLandmarkL(*landmark2); + iActiveLmEvent->iLandmarkId3 = iDatabase->AddLandmarkL(*landmark3); + + CleanupStack::PopAndDestroy(landmark3); + CleanupStack::PopAndDestroy(landmark2); + + ///////////////////////////////////////////// + // Update landmark #4 + ///////////////////////////////////////////// + landmark->SetLandmarkNameL(_L("Nicht zu Hause")); + iDatabase->UpdateLandmarkL(*landmark); + + ///////////////////////////////////////////// + // Remove landmark #5 + ///////////////////////////////////////////// + iDatabase->RemoveLandmarkL(iActiveLmEvent->iLandmarkId); + + CActiveScheduler::Start(); + + ///////////////////////////////////////////// + // Add removed landmark again #6 + ///////////////////////////////////////////// + iActiveLmEvent->iLandmarkId4 = iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Remove a set of landmarks sync #7 + ///////////////////////////////////////////// + RArray array; + CleanupClosePushL(array); + User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId)); + User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId2)); + User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId3)); + ExecuteAndDeleteLD(iDatabase->RemoveLandmarksL(array)); + + //array.Reset(); + + CleanupStack::PopAndDestroy(&array); + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Add new category #8 + ///////////////////////////////////////////// + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("My Category")); + + iActiveLmEvent->iCategoryId = categoryManager->AddCategoryL(*category); + + AssertTrueSecL(iActiveLmEvent->iCategoryId == category->CategoryId(), _L("CATEGORY ERROR")); + + ///////////////////////////////////////////// + // Update category #9 + ///////////////////////////////////////////// + categoryManager->UpdateCategoryL(*category); + + ///////////////////////////////////////////// + // Delete a non-existing category #10 + ///////////////////////////////////////////// + iActiveLmEvent->iNonExistingCategoryId = 998; + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(iActiveLmEvent->iNonExistingCategoryId)); + + ///////////////////////////////////////////// + // Delete a category that exists in several landmarks #11 + ///////////////////////////////////////////// + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(iActiveLmEvent->iDeleteCategoryId)); + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Delete several categories + ///////////////////////////////////////////// + CPosLmItemIterator* iter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(iter); + const TInt startIndex=1; + const TInt numOfItems=5; + RArray ids; + CleanupClosePushL(ids); + iter->GetItemIdsL(ids, startIndex, numOfItems); + ExecuteAndDeleteLD(categoryManager->RemoveCategoriesL(ids)); + + CleanupStack::PopAndDestroy(2, iter); //ids + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Add new category to several landmarks + ///////////////////////////////////////////// + CPosLandmarkCategory* newCategory = CPosLandmarkCategory::NewLC(); + newCategory->SetCategoryNameL(_L("My New Category")); + iActiveLmEvent->iCategoryId2= categoryManager->AddCategoryL(*newCategory); + CleanupStack::PopAndDestroy(newCategory); + + iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + const TInt addStartIndex=5; + const TInt addNumOfItems=7; + CleanupClosePushL(ids); + iter->GetItemIdsL(ids, addStartIndex, addNumOfItems); + + ExecuteAndDeleteLD(categoryManager->AddCategoryToLandmarksL(iActiveLmEvent->iCategoryId2, ids)); + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Delete a category in several landmarks + ///////////////////////////////////////////// + ExecuteAndDeleteLD(categoryManager->RemoveCategoryFromLandmarksL(iActiveLmEvent->iCategoryId2, ids)); + + CleanupStack::PopAndDestroy(4, categoryManager); // iter, ids, category + + CActiveScheduler::Start(); + ///////////////////////////////////////////// + // Remove all landmarks + ///////////////////////////////////////////// + ExecuteAndDeleteLD(iDatabase->RemoveAllLandmarksL()); + + CActiveScheduler::Start(); // For notifier + + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkEventQueueTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp28::LandmarkEventQueueTest() + { + + TInt i=0; + iActiveLmEvent->iQueueTest = ETrue; + iActiveLmEvent->Start(); + + ///////////////////////////////////////////// + // Add one landmark #1 + ////////////////////////////////////////////// + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("TP28 event queue")); + iActiveLmEvent->iLandmarkId = iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + CActiveScheduler::Start(); + + ///////////////////////////////////////////// + // Add 6 landmarks #2 + ///////////////////////////////////////////// + _LIT(KLmName, "LmTP28"); + for (i=0; i <= KMaxQueueSize; i++) + { + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(KLmName); + iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + } + + iActiveLmEvent->Start(); + CActiveScheduler::Start(); + + ///////////////////////////////////////////// + // Updates landmark 6 times #3 + ///////////////////////////////////////////// + for (i=0; i <= KMaxQueueSize; i++) + { + CPosLandmark* landmark = iDatabase->ReadLandmarkLC(iActiveLmEvent->iLandmarkId); + iDatabase->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + } + + iActiveLmEvent->Start(); + CActiveScheduler::Start(); + + ///////////////////////////////////////////// + // Add 3 landmarks and 3 categories #4, #5 #6 #7 + ///////////////////////////////////////////// + + for (i=0; i < 3; i++) + { + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(KLmName); + iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + } + + _LIT(KCategoryName, "TP28 Category %d"); + for (i =0; i < 3; i++) + { + TBuf<100> name; + name.Format(KCategoryName, i); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(name); + if (i == 0) + { + iActiveLmEvent->iCategoryId = iCategoryManager->AddCategoryL(*category); + } + else + { + iCategoryManager->AddCategoryL(*category); + } + CleanupStack::PopAndDestroy(category); + } + + + iActiveLmEvent->Start(); + CActiveScheduler::Start(); + + } + + +// ----------------------------------------------------------------------------- +// CActiveLmEvent::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CActiveLmEvent* CActiveLmEvent::NewL(CStifLogger* aLog) + { + CActiveLmEvent* self = new(ELeave) CActiveLmEvent(aLog); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CActiveLmEvent::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CActiveLmEvent::ConstructL() + { + iDatabase = CPosLandmarkDatabase::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CActiveLmEvent::CActiveLmEvent +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// + +CActiveLmEvent::CActiveLmEvent(CStifLogger* aLog) : + CActive(EPriorityNormal), + iLog(aLog) + { + CActiveScheduler::Add(this); + } + +// Destructor +CActiveLmEvent::~CActiveLmEvent() + { + Cancel(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CActiveLmEvent::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::Start() + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + + SetActive(); + } + +// --------------------------------------------------------- +// CActiveLmEvent::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::RunL() + { + + if (iQueueTest) + { + VerifyMergedEvent(); + } + else + { + VerifyEvent(); + } + + if (!iQueueTest) + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + } + +// --------------------------------------------------------- +// CActiveLmOperation::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::DoCancel() + { + iDatabase->CancelNotifyDatabaseEvent(); + } + +// --------------------------------------------------------- +// CActiveLmEvent::VerifyEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::VerifyEvent() + { + + iEventNumber++; + switch (iEventNumber) + { + // Added three landmarks + case 1: AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); + break; + case 2: AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId2, iEvent.iLandmarkItemId); + break; + case 3: AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId3, iEvent.iLandmarkItemId); + break; + // Updated landmark + case 4: AssertCorrectEvent(EPosLmEventLandmarkUpdated, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); + break; + // Deleted landmark + case 5: AssertCorrectEvent(EPosLmEventLandmarkDeleted, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Added removed landmark again + case 6: AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId4, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Deleted several landmarks + case 7: AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Added new category + case 8: AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, iCategoryId, iEvent.iLandmarkItemId); + break; + //Updated category + case 9: AssertCorrectEvent(EPosLmEventCategoryUpdated, iEvent.iEventType, iCategoryId, iEvent.iLandmarkItemId); + break; + // Deleted non existing category + case 10: AssertCorrectEvent(EPosLmEventCategoryDeleted, iEvent.iEventType, iNonExistingCategoryId, iEvent.iLandmarkItemId); + break; + // Deleted existing category + case 11: AssertCorrectEvent(EPosLmEventCategoryDeleted, iEvent.iEventType, iDeleteCategoryId, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Deleted several categories + case 12: AssertCorrectEvent(EPosLmEventCategoryUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Added new category + case 13: AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, iCategoryId2, iEvent.iLandmarkItemId); + break; + // Added created category to several landmarks + case 14: AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Removed category from several landmarks + case 15: AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + // Removed all landmarks + case 16: AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + default: + iLog->Log(_L("Unexpected event received")); + ++iGlobalErr; + break; + } + + } + +//--------------------------------------------------------- +// CActiveLmEvent::VerifyMergedEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::VerifyMergedEvent() + { + ++iMergedEventNumber; + switch (iMergedEventNumber) + { + case 1: + AssertCorrectEvent( + EPosLmEventLandmarkCreated, + iEvent.iEventType, + iLandmarkId, + iEvent.iLandmarkItemId); + + CActiveScheduler::Stop(); + break; + case 2: + case 3: + AssertCorrectEvent( + EPosLmEventLandmarkUnknownChanges, + iEvent.iEventType, + 0, + iEvent.iLandmarkItemId); + + CActiveScheduler::Stop(); + break; + case 4: + AssertCorrectEvent( + EPosLmEventLandmarkUnknownChanges, + iEvent.iEventType, + 0, + iEvent.iLandmarkItemId); + Start(); + break; + case 5: + case 6: + case 7: + AssertCorrectEvent(EPosLmEventCategoryCreated, + iEvent.iEventType, + iCategoryId++, + iEvent.iLandmarkItemId); + + if (iMergedEventNumber == 7) + { + CActiveScheduler::Stop(); + } + else + { + Start(); + } + break; + default: + _LIT(KError,"Unexpected event received, %d\r\n"); + TBuf<200> error; + error.Format(KError, iEvent.iEventType); + iLog->Log(error); + iGlobalErr++; + Start(); + break; + } + } + +// --------------------------------------------------------- +// CActiveLmEvent::AssertCorrectEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmEvent::AssertCorrectEvent( + TPosLmEventType aExpectedEventType, + TPosLmEventType aEventType, + TPosLmItemId aExpectedLandMarkItemId, + TPosLmItemId aLandMarkItemId) + { + if (aExpectedEventType != aEventType) + { + _LIT(KError,"Unexpected eventtype. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aExpectedEventType, aEventType); + iLog->Log(error); + iGlobalErr++; + } + if (aExpectedLandMarkItemId != aLandMarkItemId) + { + _LIT(KError,"Unexpected item id. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aExpectedLandMarkItemId, aLandMarkItemId); + iLog->Log(error); + iGlobalErr++; + } + + } + + +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP29.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP29.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1011 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp29.h" +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +// CONSTANTS +_LIT(KFile1, "c:\\documents\\Tp29_1.txt"); +_LIT(KFile2, "c:\\documents\\Tp29_2.txt"); +//_LIT(KPosResourceFile, "\\resource\\eposlmintservices.rsc"); +//const TInt KOneK = 1024; + +// Size limit defined in "eposlmintservices.rss" to 250 kilobytes (kilo defined as 1024) +//const TInt KMaxSize = 250000; +// This is for KFile1, "fill" a file with contents until KSizeLimit1 limit is reached +const TInt KSizeLimitOffset1 = 350000; +// This is for KFile2, "fill" a file with contents until KSizeLimit2 limit is reached +const TInt KSizeLimitOffset2 = 50000; // In bytes: 250000 bytes + 50000 bytes +_LIT(KInternalServicesResFileRom, "z:\\resource\\eposlmintservices.rsc"); +_LIT(KInternalServicesResFileBackup, "c:\\resource\\copy_of_eposlmintservices.rsc"); +_LIT(KInternalServicesResFileCdrive, "c:\\resource\\eposlmintservices.rsc"); +//_LIT(KInternalServicesLargeResFile, "c:\\system\\test\\testdata\\eposlmintservices_453KB.rsc"); +//_LIT(KInternalServicesSmallResFile, "c:\\system\\test\\testdata\\eposlmintservices_198KB.rsc"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp29::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp29 - Out of disk"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp29::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::CloseTest() + { + delete iLandmarksDb; + iLandmarksDb = NULL; + + delete iCategoryManager; + iCategoryManager = NULL; + + //TryRestoreResourceFile(); + + iFile1.Close(); + iFile2.Close(); + iFileServer.Delete(KFile1); + iFileServer.Delete(KFile2); + iFileServer.Close(); + } + +// --------------------------------------------------------- +// CPosTp29::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::InitTestL() + { + // File setup, create two files + User::LeaveIfError(iFileServer.Connect()); + + // Try to restore if previous execution of Tp55 panicked or was killed. + //TryRestoreResourceFile(); + } + +// --------------------------------------------------------- +// CPosTp29::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::StartL() + { +#ifdef __WINS__ + _LIT(KNotSupported, "Test case is not supported on WINS, exucute it on target!"); + LogErrorAndLeave(KNotSupported); +#else + + //Retreive threshold from centralrepository + CRepository* repository = CRepository::NewLC(KCRUidUiklaf); + User::LeaveIfError(repository->Get(KUikOODDiskCriticalThreshold, iCriticalThreshold)); + CleanupStack::PopAndDestroy(repository); + + TBuf<100> buf; + buf.Format(_L("Critical threshold from central repository %d"), iCriticalThreshold); + iLog->Put(buf); + + // Test import/export LMs when critical level is set to MLFW defined value. + InitiateCriticalLevelL(); + ReInitTestL(); + TestCriticalLevelL(); + + /* + // Test import/export LMs when critical level is set to a large value. + iLog->Put(_L("\r\nRedefining critical level to 453 KB and running all tests again....")); + CopyResourceFileL(KInternalServicesLargeResFile); + InitiateCriticalLevelL(); + ReInitTestL(); + TestCriticalLevelL(); + + // Test import/export LMs when critical level is set to a small value. + iLog->Put(_L("\r\nRedefining critical level to 198 KB and running all tests again....")); + CopyResourceFileL(KInternalServicesSmallResFile); + InitiateCriticalLevelL(); + ReInitTestL(); + TestCriticalLevelL(); + */ +#endif + } + +// --------------------------------------------------------- +// CPosTp29::ReInitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::ReInitTestL() + { + iGlobalErr = KErrNone; + iFile1.Close(); + iFile2.Close(); + + CFileMan* fileMan = CFileMan::NewL(iFileServer); + fileMan->Delete(KFile1); + fileMan->Delete(KFile2); + delete fileMan; + + User::LeaveIfError(iFile1.Create(iFileServer, KFile1, EFileWrite)); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + } + +// --------------------------------------------------------- +// CPosTp29::TestCriticalLevelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::TestCriticalLevelL() + { + + TTime startTime; + TTime stopTime; + + startTime.UniversalTime(); + + RemoveDefaultDbL(); + + iLog->Put(_L("CPosLandmarkDatabase::OpenL();")); + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + if (iLandmarksDb->IsInitializingNeeded()) + { + iLog->Put(_L("iLandmarksDb->InitializeL")); + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + + iLog->Put(_L("CPosLmCategoryManager::NewL;")); + iCategoryManager = CPosLmCategoryManager::NewL(*iLandmarksDb); + + // Asynchronous + iLog->Put(_L("DoOutOfDiskTestL Asynchronous")); +// iSearchCallback=ETrue; + DoOutOfDiskTestL(ETrue); + // iSearchCallback=EFalse; + + // Delete "out-of-disk" file + iFile1.Close(); + iFileServer.Delete(KFile1); + iFile2.Close(); + iFileServer.Delete(KFile2); + TInt err = iFile1.Open(iFileServer, KFile1, EFileWrite); + if (err == KErrNotFound) + { + err = iFile1.Create(iFileServer, KFile1, EFileWrite); + } + User::LeaveIfError(err); + + err = iFile2.Open(iFileServer, KFile2, EFileWrite); + if (err == KErrNotFound) + { + err = iFile2.Create(iFileServer, KFile2, EFileWrite); + } + User::LeaveIfError(err); + + // Synchronous + iLog->Put(_L("DoOutOfDiskTestL Synchronous")); + DoOutOfDiskTestL(EFalse); + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + //TInt64 resse = executionTime.Int64()/1000000; + + TInt resse = executionTime.Int64()/1000000; + + TBuf<50> buf; + buf.Zero(); + buf.Format(_L("TP29 took %d seconds"), resse); + iLog->Put(buf); + } + +// --------------------------------------------------------- +// CPosTp29::DoOutOfDiskTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::DoOutOfDiskTestL(TBool aSync) + { + TVolumeInfo volumeInfo; + TBuf<200> buf; + CPosLmOperation* op = NULL; + + _LIT(KUID,"Unique ID: %08x\r\n"); + _LIT(KSize,"Size: %d bytes\r\n"); + _LIT(KFree,"Free space: %d bytes\r\n"); + //_LIT(KVolName,"Volume name: %S\r\n"); + + TInt err=iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) iLog->Put(_L("Error from iFileServer")); + + buf.AppendFormat(KUID, volumeInfo.iUniqueID); + buf.AppendFormat(KSize, volumeInfo.iSize); + buf.AppendFormat(KFree, volumeInfo.iFree); + //buf.AppendFormat(KVolName, &volumeInfo.iName); + iLog->Put(buf); + + TTime startTime; + TTime stopTime; + + // Just in case + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + RArray lmIdArray; + CleanupClosePushL(lmIdArray); + + // 1) Create a low disc space situation + startTime.UniversalTime(); + ConsumeDiscSpace1L(iCriticalLevel + KSizeLimitOffset1); + ConsumeDiscSpace2L(iCriticalLevel + KSizeLimitOffset2); + + err=iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) iLog->Put(_L("Error from iFileServer")); + buf.AppendFormat(KUID, volumeInfo.iUniqueID); + buf.AppendFormat(KSize, volumeInfo.iSize); + buf.AppendFormat(KFree, volumeInfo.iFree); + iLog->Put(buf); + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("ConsumeDiscSpaceL took %d seconds"), resse); + iLog->Put(buf); + + // 2) Add Landmarks until "disk full" error occur + if (iLandmarksDb->IsInitializingNeeded()) + { + iLog->Put(_L("InitializeL")); + // Synchronous + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("LandMarkName1")); + iLog->Put(_L("Adding landmark1")); + lmIdArray.Append(iLandmarksDb->AddLandmarkL(*landmark)); + CleanupStack::Pop(landmark); + + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("LandMarkName2")); + iLog->Put(_L("Adding landmark2")); + lmIdArray.Append(iLandmarksDb->AddLandmarkL(*landmark)); + CleanupStack::Pop(landmark); + err = KErrNone; + TPosLmItemId idde; + TInt i=0; + + startTime.UniversalTime(); + iLog->Put(_L("Adding landmark until KErrDiskFull.....1")); + // some while loop adding landmarks here until "disk full" error occur!!! + while (err != KErrDiskFull) + { + buf.Zero(); + buf.Format(_L("Land Mark___________%d"), i++); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(buf); + TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark)); + if (err == KErrNone) + { + lmIdArray.Append(idde); + } + else if (err == KErrLocked) + { + iLog->Put(_L("KErrLocked when adding 1")); + User::After(100000); + } + CleanupStack::Pop(landmark); + } + stopTime.UniversalTime(); + executionTime = stopTime.MicroSecondsFrom(startTime); + resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("Added %d nr of landmarks, took %d seconds"), i, resse); + iLog->Put(buf); + + // Check that the filesize limit has not been exceeded + err=iFileServer.Volume(volumeInfo, EDriveC); + buf.Zero(); + buf.AppendFormat(KFree, volumeInfo.iFree); + iLog->Put(buf); + if (volumeInfo.iFree < iCriticalLevel) + { + LogErrorAndLeave(_L("The max size limit has been exceeded!!!")); + } + + //Check that the added landmarks can be read + iLog->Put(_L("Check that it is possible to read landmark")); + TInt nrOfLandmarks = lmIdArray.Count(); + TInt p=0; + for (p=0;pReadLandmarkLC(lmIdArray[p]); + CleanupStack::Pop(landmark); + } + + // 3) Remove two landmarks and compress landmarks db + TInt nr = lmIdArray.Count()-1; + TPosLmItemId id = lmIdArray[nr]; + iLog->Put(_L("Removing landmark1")); + lmIdArray.Remove(nr); + TRAP(err, iLandmarksDb->RemoveLandmarkL(id)); + if (err == KErrDiskFull) + { + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + iLandmarksDb->RemoveLandmarkL(id); + iLog->Put(_L("DiskFull when removing1")); + } + + nr = lmIdArray.Count() - 1; + id = lmIdArray[nr]; + iLog->Put(_L("Removing landmark2")); + lmIdArray.Remove(nr); + iLandmarksDb->RemoveLandmarkL(id); + TRAP(err, iLandmarksDb->RemoveLandmarkL(id)); + if (err == KErrDiskFull) + { + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + iLandmarksDb->RemoveLandmarkL(id); + iLog->Put(_L("DiskFull when removing2")); + } + err = KErrNone; + iLog->Put(_L("Compacting")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + startTime.UniversalTime(); + iLog->Put(_L("Adding landmark until KErrDiskFull.....2")); + // 4) Add landmarks until "disk full" error occur!!! + while (err != KErrDiskFull) + { + buf.Zero(); + buf.Format(_L("Land Mark___________%d"), i++); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(buf); + //iLog->Put(_L("Adding landmark id to idArray")); + TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark)); + if (err == KErrNone) + { + lmIdArray.Append(idde); + } + else if (err == KErrLocked) + { + iLog->Put(_L("KErrLocked when adding 2")); + User::After(100000); + } + CleanupStack::Pop(landmark); + } + + stopTime.UniversalTime(); + executionTime = stopTime.MicroSecondsFrom(startTime); + resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("Added %d nr of landmarks, took %d seconds"), i, resse); + iLog->Put(buf); + + iLog->Put(_L("Check that it is possible to read landmark")); + //Check that the added landmarks can be read + nrOfLandmarks = lmIdArray.Count(); + for (p=0;pReadLandmarkLC(lmIdArray[p]); + CleanupStack::Pop(landmark); + } + + iLog->Put(_L("Remove all landmarks")); + err = KErrNone; + // 5) Remove all landmarks and compact database + if (!aSync) + { + TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL()); + if (err == KErrNone) + { + ExecuteAndDeleteLD(op); + } + else if (err == KErrDiskFull) + { + iLog->Put(_L("KErrDiskFull when removing all landmarks")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + // Delete KFile2 to free more space on disc, method also open connection to iFile2 again + DeleteFile2L(); + + iLog->Put(_L("Removing after Compact sync")); + TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL()); + if (err == KErrDiskFull) + { + iLog->Put(_L("KErrDiskFull when Removing all landmarks after compact1")); + RemoveAllLandmarksL(); + } + else + { + ExecuteAndDeleteLD(op); + } + } + } + else + { + iLog->Put(_L("Before RemoveAllLandmarksL(this)")); + TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL()); + + if (err == KErrNone) + { + //***iActiveSchedulerWait->Start(); + //***delete op; op=NULL; + RunAsyncOperationLD(op); + } + else if (err == KErrDiskFull) + { + iLog->Put(_L("KErrDiskFull when removing all landmarks")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + // Delete KFile2 to free more space on disc, method also open connection to iFile2 again + DeleteFile2L(); + + iLog->Put(_L("Removing after Compact async")); + TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL()); + if (err == KErrDiskFull) + { + iLog->Put(_L("KErrDiskFull when removing all landmarks after compact2")); + RemoveAllLandmarksL(); + } + else + { + //***iActiveSchedulerWait->Start(); + //***delete op; op=NULL; + RunAsyncOperationLD(op); + } + } + iLog->Put(_L("After RemoveAllLandmarksL(this)")); + } + + ConsumeDiscSpace2L(iCriticalLevel + KSizeLimitOffset2); + + if (err == KErrDiskFull) iLog->Put(_L("KErrDiskFull when RemoveAllLandmarksL")); + iLog->Put(_L("Compacting")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + lmIdArray.Reset(); + i=0; + err = KErrNone; + startTime.UniversalTime(); + iLog->Put(_L("Adding landmarkcategories until KErrDiskFull.....")); + + // 6) Add LandmarkCategories until "disk full" error occur + while (err != KErrDiskFull) + { + buf.Zero(); + buf.Format(_L("Landmark Category _________ %d"), i++); + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(buf); + lmc->SetIconL(_L("Pelles Icon"), 111, KPosLmIconMaskNotUsed); + + TRAP(err, idde = iCategoryManager->AddCategoryL(*lmc)); + if (err == KErrNone) + { + lmIdArray.Append(idde); + } + else if (err== KErrLocked) + { + iLog->Put(_L("KErrLocked when adding category")); + User::After(100000); + } + CleanupStack::PopAndDestroy(lmc); + } + + stopTime.UniversalTime(); + executionTime = stopTime.MicroSecondsFrom(startTime); + + resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("Added %d nr of landmarkcategories, took %d seconds"), i, resse); + iLog->Put(buf); + + //Check that the added landmarkcategories can be read + TInt nrOfCategories = lmIdArray.Count(); + for (p=0;pReadCategoryLC(lmIdArray[p]); + CleanupStack::Pop(lmc); + } + + // 7) Remove two categories and compress landmarks db + nr = lmIdArray.Count()-1; + id = lmIdArray[nr]; + iLog->Put(_L("Removing landmarkcategory1")); + lmIdArray.Remove(nr); + op=NULL; + TRAP(err, op = iCategoryManager->RemoveCategoryL(id)); + if (err == KErrDiskFull) + { + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + ExecuteAndDeleteLD(iCategoryManager->RemoveCategoryL(id)); + iLog->Put(_L("KErrDiskFull when removing landmarkcategory1")); + } + + if (err == KErrNone) + { + ExecuteAndDeleteLD(op); + } + else + { + delete op; + op = NULL; + } + + TBuf<50> buffe; + buffe.Format(_L("1) Err after RemoveCategoryL: %d"), err); + iLog->Put(buffe); + + nr = lmIdArray.Count()-1; + id = lmIdArray[nr]; + iLog->Put(_L("Removing landmarkcategory2")); + lmIdArray.Remove(nr); + + if (!aSync) + { + TRAP(err, op = iCategoryManager->RemoveCategoryL(id)); + if (err == KErrDiskFull) + { + delete op; + op = NULL; + iLog->Put(_L("KErrDiskFull when removing landmarkcategory2")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + iLog->Put(_L("After compact before removing landmarkcategory2")); + ExecuteAndDeleteLD(iCategoryManager->RemoveCategoryL(id)); + } + else if (err == KErrNone) + { + ExecuteAndDeleteLD(op); + } + else if (err == KErrLocked) + { + iLog->Put(_L("KErrLocked returned from iCategoryManager->RemoveCategoryL")); + delete op; + op = NULL; + } + } + else + { + TRAP(err, op = iCategoryManager->RemoveCategoryL(id)); + if (err == KErrNone) + { + //***iActiveSchedulerWait->Start(); + //***delete op; + RunAsyncOperationLD(op); + } + else if (err == KErrDiskFull) + { + delete op; + op = NULL; + iLog->Put(_L("KErrDiskFull when removing landmarkcategory2 async")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + iLog->Put(_L("After compact before removing landmarkcategory2 async")); + op = iCategoryManager->RemoveCategoryL(id); + + //***iActiveSchedulerWait->Start(); + //***delete op; + RunAsyncOperationLD(op); + } + else if (err == KErrLocked) + { + delete op; + op = NULL; + iLog->Put(_L("KErrLocked returned from iCategoryManager->RemoveCategoryL")); + } + } + + buffe.Zero(); + buffe.Format(_L("2) Err after RemoveCategoryL: %d"), err); + iLog->Put(buffe); + + iLog->Put(_L("Compacting")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + iLog->Put(_L("After Compacting")); + + lmIdArray.Reset(); + i=0; + err = KErrNone; + + startTime.UniversalTime(); + // 8) Add LandmarkCategories until "disk full" error occur + while (err != KErrDiskFull) + { + buf.Zero(); + buf.Format(_L("LandmarkCategory %d"), i++); + + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(buf); + lmc->SetIconL(_L("PellesIcon"), 111, KPosLmIconMaskNotUsed); + iLog->Put(buf); + + TRAP(err, idde = iCategoryManager->AddCategoryL(*lmc)); + if (err == KErrNone) + { + lmIdArray.Append(idde); + } + else if (err == KErrLocked) + { + iLog->Put(_L("KerrLocked when addCategory")); + User::After(100000); + } + CleanupStack::PopAndDestroy(lmc); + } + stopTime.UniversalTime(); + executionTime = stopTime.MicroSecondsFrom(startTime); + + resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("Added %d nr of landmarkcategories, took %d seconds"), i, resse); + iLog->Put(buf); + + // 9) Remove all categories and compact db + // sync method + // XXXX add async check here + iLog->Put(_L("Removing all categories")); + TRAP(err, iCategoryManager->RemoveCategoriesL(lmIdArray)); + if (err == KErrDiskFull) iLog->Put(_L("KErrDiskFull when RemoveCategoriesL")); + iLog->Put(_L("Compacting")); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + + // 10) Consume more space then the limit specified in resource file + ConsumeDiscSpace1L(iCriticalLevel - KSizeLimitOffset2); + + // 11) Try to add a landmark + buf.Zero(); + buf.Format(_L("LandMark%d"), i++); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(buf); + + TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark)); + if (err != KErrDiskFull) + { + buf.Zero(); + buf.Format(_L("Should leave with KErrDiskFull instead %d"), err); + //LogErrorAndLeave(buf); + LogErrorAndLeave(buf); + } + CleanupStack::PopAndDestroy(landmark); + CleanupStack::PopAndDestroy(&lmIdArray); + } + + +// --------------------------------------------------------- +// CPosTp29::RemoveAllLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::RemoveAllLandmarksL() + { + iLog->Put(_L("CPosTp29::RemoveAllLandmarksL")); + CPosLmItemIterator* iter = iLandmarksDb->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TInt counter=0; + TTime startTime; + TTime stopTime; + TPosLmItemId id = iter->NextL(); + + startTime.UniversalTime(); + + while (id != KPosLmNullItemId) + { + TRAPD(err, iLandmarksDb->RemoveLandmarkL(id)); + if (err == KErrDiskFull) + { + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + iLog->Put(_L(":-( DiskFull when removing single landmark entry !!!")); + iLandmarksDb->RemoveLandmarkL(id); + } + else if (err == KErrLocked) + { + iLog->Put(_L("KErrLocked when removing landmark")); + User::After(100000); + } + id = iter->NextL(); + counter++; + } + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt64 resse = executionTime.Int64()/1000000; + TBuf<50> buf; + buf.Zero(); + buf.Format(_L("Removing %d nr of landmarks, took %d seconds"), counter, resse); + iLog->Put(buf); + + CleanupStack::PopAndDestroy(iter); + } + +// --------------------------------------------------------- +// CPosTp29::DeleteFile2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::DeleteFile2L() + { + iFile2.Close(); + iFileServer.Delete(KFile2); + TInt err = iFile2.Open(iFileServer, KFile2, EFileWrite); + if (err == KErrNotFound) + { + err = iFile2.Create(iFileServer, KFile2, EFileWrite); + } + } + +// --------------------------------------------------------- +// CPosTp29::ConsumeDiscSpace1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::ConsumeDiscSpace1L(TInt aSizeLimit) + { + TInt err = KErrNone; + + // Approx 2160 bytes + _LIT8(KNonsense, "nonsensenonsensenonsensenonsensenonsensenon \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +sensenonsensenonsensenonsensenonsensenonsensenonsense"); + + TVolumeInfo volumeInfo; + err=iFileServer.Volume(volumeInfo, EDriveC); + + // Fill file fast + HBufC8* bigBuf = (&KNonsense)->AllocLC(); + while (volumeInfo.iFree > aSizeLimit) + { + err = iFile1.Write(*bigBuf); + if (err != KErrNone) iLog->Put(_L("Problem writing")); + err = iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) iLog->Put(_L("Problem voluming")); + } + + CleanupStack::PopAndDestroy(1); // bigBuf + } + +// --------------------------------------------------------- +// CPosTp29::ConsumeDiscSpace2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::ConsumeDiscSpace2L(TInt aSizeLimit) + { + iLog->Put(_L("ConsumeDiscSpace2L")); + TInt err = KErrNone; + + // Approx 2160 bytes + _LIT8(KNonsense, "nonsensenonsensenonsensenonsensenonsensenon \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense \ +sensenonsensenonsensenonsensenonsensenonsensenonsense"); + + TVolumeInfo volumeInfo; + err=iFileServer.Volume(volumeInfo, EDriveC); + + // Fill file fast + HBufC8* bigBuf = (&KNonsense)->AllocLC(); + while (volumeInfo.iFree > aSizeLimit) + { + err = iFile2.Write(*bigBuf); + if (err != KErrNone) iLog->Put(_L("Problem writing")); + err = iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) iLog->Put(_L("Problem voluming")); + } + + CleanupStack::PopAndDestroy(1); // bigBuf + } + +// --------------------------------------------------------- +// CPosTp29::InitiateCriticalLevelL +// Extracts Critical Dsik Level. (value is extracted from an MLFW +// resource file that can reside on any drive) +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::InitiateCriticalLevelL() + { + iLog->Put(_L("InitiateCriticalLevelL")); + /* + // Find drive that the resource file resides on. + TFindFile* filefinder = new (ELeave) TFindFile(iFileServer); + CleanupStack::PushL(filefinder); + TParse* fileparser = new (ELeave) TParse; + CleanupStack::PushL(fileparser); + fileparser->Set(KPosResourceFile, NULL, NULL); + User::LeaveIfError( + filefinder->FindByDir(fileparser->NameAndExt(), fileparser->DriveAndPath())); + + // Open resource file + RResourceFile resFile; + resFile.OpenL(iFileServer, filefinder->File()); + CleanupClosePushL(resFile); + + // Allocate the critical level as a buffer + //TInt R_POS_LANDMARK_INTERNAL_CRITICAL_DISK_LEVEL = 250; + HBufC8* resourceBuffer = resFile.AllocReadLC(iCriticalThreshold); + + // Convert the buffer to an int + TResourceReader resReader; + resReader.SetBuffer(resourceBuffer); + iCriticalLevel = KOneK * resReader.ReadInt16(); + CleanupStack::PopAndDestroy(4, filefinder); + */ + + //iCriticalLevel = iCriticalThreshold * KOneK; + iCriticalLevel = iCriticalThreshold; + + TBuf<50> msg; + msg.Format(_L("CriticalLevel = %d"), iCriticalLevel); + iLog->Put(msg); + } + +// --------------------------------------------------------- +// CPosTp29::CopyResourceFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::CopyResourceFileL(const TDesC& aResourceFile) + { + // Release all landmark references to make DLLs be unloaded. + delete iLandmarksDb; + iLandmarksDb = NULL; + + CFileMan* fileMan = CFileMan::NewL(iFileServer); + CleanupStack::PushL(fileMan); + + // Check if landmark is flashed + if (!BaflUtils::FileExists(iFileServer, KInternalServicesResFileRom)) + { + iLog->Put(_L("Landmark is NOT flashed, backing up eposlmintservices.rsc by renaming it bofore copying rsc-file.")); + // Landmark FW is not flashed. Rename the file before copying an own defiend file. + // Since landmark FW is not flashed the file should exist hence leaving if it is not found! + User::LeaveIfError(fileMan->Rename(KInternalServicesResFileCdrive, KInternalServicesResFileBackup, CFileMan::EOverWrite)); + } + else + { + iLog->Put(_L("Landmark framework is flashed, copying global categories to c:")); + } + + User::LeaveIfError(fileMan->Copy(aResourceFile, KInternalServicesResFileCdrive, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CPosTp29::TryRestoreResourceFile +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp29::TryRestoreResourceFile() + { + iLog->Put(_L("TryRestoreResourceFile")); + CFileMan* fileMan = NULL; + TRAPD(err, fileMan = CFileMan::NewL(iFileServer)); + User::LeaveIfError(err); + if (fileMan) + { + // Try to restore the backup up rsc-file (only possible when LM FW is not flashed. + TInt result = fileMan->Copy(KInternalServicesResFileBackup, KInternalServicesResFileCdrive, CFileMan::EOverWrite); + if (result == KErrNotFound) + { + if (BaflUtils::FileExists(iFileServer, KInternalServicesResFileRom)) + { + // LM FW is flashed. We need to remove the rsc-file on c: + fileMan->Delete(KInternalServicesResFileCdrive); + } + } + delete fileMan; + } + } + +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP54.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP54.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,536 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp54.h" +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include + + +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp54::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp54::GetName(TDes& aName) const + { + _LIT(KTestName, "TP54 - Sorted DB Iterator"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp54::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp54::CloseTest() + { + iLog->Put(_L("CloseTest")); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp54::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp54::InitTestL() + { + } + +// --------------------------------------------------------- +// CPosTp54::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp54::StartL() + { + // All times in this test are measured in milliseconds + TBool wholeTestSuccessful = ETrue; + TBool subTestSuccessful; + TBool isSorted = ETrue; + TBool isSynch = ETrue; + TInt nrOfLms = 1000; + TInt64 execTime; + TInt64 maxExecTime; +/* +Use function below for creating landmark dbs with 1000 and 5000 landmarks +Note: Only name and position is set + +/* +CreateLargeDbs(1000); +CleanupStack::PopAndDestroy(); + +CreateLargeDbs(5000); +CleanupStack::PopAndDestroy(); +*/ + +// Measure 1000 sorted landmarks synchronously + iLog->Put(_L("\nTesting retrieving 1000 sorted landmarks using LandmarkIteratorL()")); + maxExecTime = 5000; + RecreateDatabaseL(K1000LandmarksDb); + execTime = ExecutionTimeSynchL(isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, isSorted, maxExecTime, isSynch); + if (wholeTestSuccessful) + { +// We are not allowed to leave because of this. Error report ESLI-653HBG was ignored +// wholeTestSuccessful = subTestSuccessful; + } + +// Measure 1000 unsorted landmarks synchronously + iLog->Put(_L("\nTesting retrieving 1000 unsorted landmarks using LandmarkIteratorL()")); + maxExecTime = 1000; + RecreateDatabaseL(K1000LandmarksDb); + execTime = ExecutionTimeSynchL(!isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, !isSorted, maxExecTime, isSynch); + if (wholeTestSuccessful) + { +// We are not allowed to leave because of this. Error report ESLI-653HBG was ignored +// wholeTestSuccessful = subTestSuccessful; + } + +// Measure 5000 sorted landmarks synchronously + iLog->Put(_L("\nTesting retrieving 5000 sorted landmarks using LandmarkIteratorL()")); + nrOfLms = 5000; + maxExecTime = 10000; + RecreateDatabaseL(K5000LandmarksDb); + execTime = ExecutionTimeSynchL(isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, isSorted, maxExecTime, isSynch); + if (wholeTestSuccessful) + { +// We are not allowed to leave because of this. Error report ESLI-653HBG was ignored +// wholeTestSuccessful = subTestSuccessful; + } + +// Measure 5000 unsorted landmarks synchronously + iLog->Put(_L("\nTesting retrieving 5000 unsorted landmarks using LandmarkIteratorL()")); + maxExecTime = 5000; + RecreateDatabaseL(K5000LandmarksDb); + execTime = ExecutionTimeSynchL(!isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, !isSorted, maxExecTime, isSynch); + if (wholeTestSuccessful) + { +// We are not allowed to leave because of this. Error report ESLI-653HBG was ignored +// wholeTestSuccessful = subTestSuccessful; + } + +// Measure 1000 sorted landmarks asynchronously + iLog->Put(_L("\nTesting retrieving 1000 sorted landmarks using the search API")); + nrOfLms = 1000; + maxExecTime = 5000; + RecreateDatabaseL(K1000LandmarksDb); + execTime = ExecutionTimeAsynchL(isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, isSorted, maxExecTime, !isSynch); + + if (wholeTestSuccessful) + { + wholeTestSuccessful = subTestSuccessful; + } + +// Measure 1000 unsorted landmarks asynchronously + iLog->Put(_L("\nTesting retrieving 1000 unsorted landmarks using the search API")); + maxExecTime = 1000; + RecreateDatabaseL(K1000LandmarksDb); + execTime = ExecutionTimeAsynchL(!isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, !isSorted, maxExecTime, !isSynch); + if (wholeTestSuccessful) + { + wholeTestSuccessful = subTestSuccessful; + } + +// Measure 5000 sorted landmarks asynchronously + iLog->Put(_L("\nTesting retrieving 5000 sorted landmarks using the search API")); + nrOfLms = 5000; + maxExecTime = 10000; + RecreateDatabaseL(K5000LandmarksDb); + execTime = ExecutionTimeAsynchL(isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, isSorted, maxExecTime, !isSynch); + if (wholeTestSuccessful) + { + wholeTestSuccessful = subTestSuccessful; + } + +// Measure 5000 unsorted landmarks asynchronously + iLog->Put(_L("\nTesting retrieving 5000 unsorted landmarks using the search API")); + maxExecTime = 5000; + RecreateDatabaseL(K5000LandmarksDb); + execTime = ExecutionTimeAsynchL(!isSorted); + subTestSuccessful = VerifyResult(execTime, nrOfLms, !isSorted, maxExecTime, !isSynch); + if (wholeTestSuccessful) + { + wholeTestSuccessful = subTestSuccessful; + } + + if (!wholeTestSuccessful) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp54::ExecutionTimeSynchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt64 CPosTp54::ExecutionTimeSynchL(TBool aIsSorted) + { + TTime startTime; + TTime stopTime; + CPosLmItemIterator* iterator = NULL; + + if (aIsSorted) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + // The method to measure + startTime.UniversalTime(); + iterator = iDatabase->LandmarkIteratorL(sortPref); + stopTime.UniversalTime(); + } + else + { + // The method to measure + startTime.UniversalTime(); + iterator = iDatabase->LandmarkIteratorL(); + stopTime.UniversalTime(); + } + delete iterator; + + TTimeIntervalMicroSeconds execTime = + stopTime.MicroSecondsFrom(startTime); + return execTime.Int64() / 1000; // return execution time in milliseconds + } + +// --------------------------------------------------------- +// CPosTp54::ExecutionTimeAsynchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt64 CPosTp54::ExecutionTimeAsynchL(TBool aIsSorted) + { + // Create a landmark searcher + CPosLandmarkSearch* lmSearcher = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(lmSearcher); + + // Create search criteria, search by name. + CPosLmTextCriteria* searchCriteria = CPosLmTextCriteria::NewLC(); + searchCriteria->SetTextL(_L("*")); + searchCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + + CPosLmOperation* searchOp = NULL; + if (aIsSorted) + { + // Create search operation, sort ascending by name + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + searchOp = lmSearcher->StartLandmarkSearchL(*searchCriteria, sortPref); + } + else + { + // Create search operation, without sorting + searchOp = lmSearcher->StartLandmarkSearchL(*searchCriteria); + } + + TInt res(0); + TTimeIntervalMicroSeconds longestExecTimeSoFar = ExecuteLmOp(searchOp, res); + AssertTrueSecL(res == KErrNone, _L("Searching did not result in KErrNone but in %d."), res); + + // Get the iterator + TTime startTime, stopTime; + startTime.UniversalTime(); + CPosLmItemIterator* iterator = lmSearcher->MatchIteratorL(); + stopTime.UniversalTime(); + delete iterator; + + TTimeIntervalMicroSeconds execTime = stopTime.MicroSecondsFrom(startTime); + if (execTime > longestExecTimeSoFar) + { + longestExecTimeSoFar = execTime; + } + + CleanupStack::PopAndDestroy(2, lmSearcher); + return longestExecTimeSoFar.Int64() / 1000; // return execution time in milliseconds + } + +// --------------------------------------------------------- +// CPosTp54::VerifyResult +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp54::VerifyResult( + TInt64 aExecTime, + TInt aNrOfLandmarks, + TBool aSorted, + TInt64 aLimit, + TBool aSynch) + { + _LIT(KOups, "Ouppps! "); + _LIT(KSynch, "%SRetrieving %d %S landmarks using %S took %d milliseconds"); + _LIT(KAsynch, "%SLongest execution time in RunL() took %d milliseconds when retrieving %d %S landmarks using %S."); + _LIT(KSorted, "sorted"); + _LIT(KUnSorted, "UNsorted"); + _LIT(KSynchIterator, "CPosLandmarkDatabse::LandmarkIteratorL()"); + _LIT(KAsynchSearch, "LM search API"); + TBool testSucessful; + TInt time = aExecTime; + // Present result + TBuf<200> buf; + + if (aExecTime > aLimit) + { + aSorted + ? aSynch + ? buf.Format(KSynch, &KOups, aNrOfLandmarks, &KSorted, &KSynchIterator, time) + : buf.Format(KAsynch, &KOups, time, aNrOfLandmarks, &KSorted, &KAsynchSearch) + : aSynch + ? buf.Format(KSynch, &KOups, aNrOfLandmarks, &KUnSorted, &KSynchIterator, time) + : buf.Format(KAsynch, &KOups, time, aNrOfLandmarks, &KUnSorted, &KAsynchSearch); + + iLog->PutError(buf); + testSucessful = EFalse; + } + else + { + aSorted + ? aSynch + // XXX ? buf.Format(KSynch, &KNullDesC, aNrOfLandmarks, &KSorted, &KSynchIterator, aExecTime.Low()) + ? buf.Format(KSynch, &KNullDesC, aNrOfLandmarks, &KSorted, &KSynchIterator, time) + //XXX : buf.Format(KAsynch, &KNullDesC, aExecTime.Low(), aNrOfLandmarks, &KSorted, &KAsynchSearch) + : buf.Format(KAsynch, &KNullDesC, time, aNrOfLandmarks, &KSorted, &KAsynchSearch) + : aSynch + //? buf.Format(KSynch, &KNullDesC, aNrOfLandmarks, &KUnSorted, &KSynchIterator, aExecTime.Low()) + //: buf.Format(KAsynch, &KNullDesC, aExecTime.Low(), aNrOfLandmarks, &KUnSorted, &KAsynchSearch); + ? buf.Format(KSynch, &KNullDesC, aNrOfLandmarks, &KUnSorted, &KSynchIterator, time) + : buf.Format(KAsynch, &KNullDesC, time, aNrOfLandmarks, &KUnSorted, &KAsynchSearch); + + iLog->Put(buf); + testSucessful = ETrue; + } + + return testSucessful; + } + +// --------------------------------------------------------- +// CPosTp54::TestIteratorSynchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt64 CPosTp54::TestIteratorSynchL(const TDesC& aDatabase, TBool aIsSorted) + { + RecreateDatabaseL(aDatabase); + + return ExecutionTimeSynchL(aIsSorted); + } + +// --------------------------------------------------------- +// CPosTp54::TestIteratorAsynchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt64 CPosTp54::TestIteratorAsynchL(const TDesC& aDatabase, TBool aIsSorted) + { + RecreateDatabaseL(aDatabase); + + return ExecutionTimeAsynchL(aIsSorted); + } + +// --------------------------------------------------------- +// CPosTp54::RecreateDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp54::RecreateDatabaseL(const TDesC& aDatabase) + { + delete iDatabase; + iDatabase = NULL; + CopyDbFileL(aDatabase); + iDatabase = CPosLandmarkDatabase::OpenL(KDefaultDb); + } + +// --------------------------------------------------------- +// CPosTp54::ExecuteLmOp +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt64 CPosTp54::ExecuteLmOp(CPosLmOperation* aOp, TInt& aResult) + { + TReal32 progress(0); + TRequestStatus status(KPosLmOperationNotComplete); + TTime startTime; + TTime stopTime; + TTimeIntervalMicroSeconds longestExecTimeSoFar(0); + + while (status.Int() == KPosLmOperationNotComplete) + { + startTime.UniversalTime(); + aOp->NextStep(status, progress); + User::WaitForRequest(status); + stopTime.UniversalTime(); + + TTimeIntervalMicroSeconds execTime = stopTime.MicroSecondsFrom(startTime); + if (execTime > longestExecTimeSoFar) + { + longestExecTimeSoFar = execTime; + } + _LIT(KExecTime, "Progress = %d%%. Execution of NextStep took %d µs"); + TBuf<100> buf; + //buf.Format(KExecTime, (TInt) (progress * 100), execTime.Int64().Low()); + buf.Format(KExecTime, (TInt) (progress * 100), execTime.Int64()); +// iLog->Put(buf); + } + + aResult = status.Int(); + return longestExecTimeSoFar.Int64(); + } + + +// --------------------------------------------------------- +// CPosTp54::CreateLargeDbs +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp54::CreateLargeDbs(TInt aNrOfItems) + { + + TTime startTime; + TTime stopTime; + + iLog->Put(_L("RemoveAllLmDatabasesL();")); + RemoveAllLmDatabasesL(); + startTime.UniversalTime(); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + if (db->IsInitializingNeeded()) + { + iLog->Put(_L("IsInitializingNeeded()")); + ExecuteAndDeleteLD(db->InitializeL()); + } + + CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catManager); + TInt j = 0; + + while (j < aNrOfItems) + { + TTime seedTime; + seedTime.UniversalTime(); + + TInt64 seed = seedTime.Int64(); + TBuf<150> name; + TReal randNr = Math::FRand(seed); + + TUint bokstav1 = (randNr*25)+65; + randNr = Math::FRand(seed); + TUint bokstav2 = (randNr*25)+65; + + //Create a landmark name that contains of two random characters+"NearestSearch"+iCounter + name.Format(_L("%c%cLandmark Nr %d"),bokstav1, bokstav2, j); + CPosLandmark* landmark = CPosLandmark::NewLC(); + + landmark->SetLandmarkNameL(name); + + /* + HBufC* desc = HBufC::NewLC(4095); + TPtr descPtr = desc->Des(); + for (TInt k = 0; k < 16; k++) + { + descPtr.Append(name); + } + descPtr = descPtr.Left(4095); + landmark->SetLandmarkDescriptionL(descPtr); + CleanupStack::PopAndDestroy(desc); + + */ +/* + // Update coverage radius + TReal32 radius = 345345345; + landmark->SetCoverageRadius(radius); + // Update street + landmark->SetPositionFieldL(EPositionFieldStreet, name); + // Update postal code + landmark->SetPositionFieldL(EPositionFieldPostalCode, name); + // Update city + landmark->SetPositionFieldL(EPositionFieldCity, name); + + // Update country + landmark->SetPositionFieldL(EPositionFieldCountry, name); +*/ + TReal latitude(123), longitude(321); + TReal32 altitude(54), horAcc(1), verAcc(12); + TCoordinate coordinate(latitude, longitude, altitude); + TLocality newLocation(coordinate, horAcc, verAcc); + landmark->SetPositionL(newLocation); + + db->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + /* + if (j<100) + { + // Add category + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + + _LIT(KCatName, "Category nr %d"); + TBuf<100> nameCategory; + nameCategory.Format(KCatName, j); + category->SetCategoryNameL(nameCategory); + catManager->AddCategoryL(*category); + + CleanupStack::PopAndDestroy(category); + } + */ + j++; + } + ExecuteAndDeleteLD(db->CompactL()); + stopTime.UniversalTime(); + CleanupStack::PopAndDestroy(2, db); + + TTimeIntervalMicroSeconds execTime = stopTime.MicroSecondsFrom(startTime); + + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + TBuf<100> buf; + buf.Format(_L("Create %d nr of landmarks took %d seconds"), aNrOfItems, resse); + iLog->Put(buf); + + } +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP55.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP55.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1156 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp55.h" +#include "FT_LandmarkConstants.h" +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS +_LIT(KFile1, "c:\\documents\\Tp55_1.txt"); +_LIT(KFile2, "c:\\documents\\Tp55_2.txt"); +_LIT(KFile3, "c:\\documents\\Tp55_3.txt"); +const TInt KOneK = 1024; +const TInt KNrOfLandmarksToExport = 10; +//_LIT(KPosResourceFile, "\\resource\\eposlmintservices.rsc"); +#ifdef __WINS__ +_LIT(KXmlInputFile, "z:\\system\\test\\testdata\\TP55-DiskFullDuringExportImport.xml"); +#else +_LIT(KXmlInputFile, "c:\\system\\test\\testdata\\TP55-DiskFullDuringExportImport.xml"); +#endif +_LIT(KXmlOutputFile, "c:\\documents\\TP55-ExportedLandmarks.xml"); +_LIT(KXmlBufferDumpFile, "c:\\documents\\BufferDump.xml"); +_LIT(KInternalServicesResFileRom, "z:\\resource\\eposlmintservices.rsc"); +_LIT(KInternalServicesResFileBackup, "c:\\resource\\copy_of_eposlmintservices.rsc"); +_LIT(KInternalServicesResFileCdrive, "c:\\resource\\eposlmintservices.rsc"); +//_LIT(KInternalServicesLargeResFile, "c:\\system\\test\\testdata\\eposlmintservices_453KB.rsc"); +//_LIT(KInternalServicesSmallResFile, "c:\\system\\test\\testdata\\eposlmintservices_198KB.rsc"); + +// Approx 2141 bytes +_LIT8(KNonsense, "nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense\ +sensenonsensenonsensenonsensenonsensenonsensenonsense"); + +_LIT8(K64B, "nonsensenonsensenonsensenonsensenonsensenonsensenonsensenonsense"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp55::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp55 - Disk Full Checking during Import/Export"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp55::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + delete iOperationWrapper; + delete iLandmarkEncoder; + delete iLandmarkParser; + delete iOutputBuffer; + delete iInputBuffer; + + iFile1.Close(); + iFile2.Close(); + iFile3.Close(); + iFileServer.Delete(KFile1); + iFileServer.Delete(KFile2); + iFileServer.Delete(KFile3); + + //TryRestoreResourceFile(); + + iXmlOutputFile.Close(); + iFileServer.Delete(KXmlOutputFile); + iFileServer.Delete(KXmlBufferDumpFile); + + iFileServer.Close(); + } + +// --------------------------------------------------------- +// CPosTp55::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::InitTestL() + { + // File setup, create two files + User::LeaveIfError(iFileServer.Connect()); + + // Try to restore if previous execution of Tp55 panicked or was killed. + //TryRestoreResourceFile(); + + iOperationWrapper = new (ELeave) CActiveLmOperation(iLog); + } + +// --------------------------------------------------------- +// CPosTp55::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::StartL() + { + // Retreive threshold from centralrepository + CRepository* repository = CRepository::NewLC(KCRUidUiklaf); + User::LeaveIfError(repository->Get(KUikOODDiskCriticalThreshold, iCriticalThreshold)); + CleanupStack::PopAndDestroy(repository); + + // Test import/export LMs when critical level is set to MLFW defined value. + InitiateCriticalLevelL(); + TestCriticalLevelL(); + +/* + // Test import/export LMs when critical level is set to a large value. + iLog->Put(_L("\r\nRedefining critical level to 453 KB and running all tests again....")); + CopyResourceFileL(KInternalServicesLargeResFile); + InitiateCriticalLevelL(); + TestCriticalLevelL(); + + // Test import/export LMs when critical level is set to a small value. + iLog->Put(_L("\r\nRedefining critical level to 198 KB and running all tests again....")); + CopyResourceFileL(KInternalServicesSmallResFile); + InitiateCriticalLevelL(); + TestCriticalLevelL(); + */ + } + +// --------------------------------------------------------- +// CPosTp55::NotifyProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::NotifyProgress(TReal aProgress) + { + iProgress = (TInt) (aProgress * 100); +// iMsg.Format(_L("Progress = %d"), iProgress); +// iLog->Put(iMsg); +// LogVolumeInfoL(); + } + +// --------------------------------------------------------- +// CPosTp55::TestCriticalLevelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::TestCriticalLevelL() + { + // Restore disk space + RecreateAndOpenFilesL(); + + // ************ 1. Open database ************ + delete iDatabase; + iDatabase = NULL; + iDatabase = UseGeneratedDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // ************ 2. Fill up disk space ************ + iLog->Put(_L("Consuming disk space...")); + ConsumeDiskSpaceL(iFile1, iCriticalLevel + 3 * KOneK); + LogVolumeInfoL(); + +//// Test importing landmarks + iLog->Put(_L("Testing Importing...")); + iLog->Put(_L("-- Testing import below critical level")); + TBool testBeyondCriticalLevel = ETrue; + ImportLandmarksTestL(!testBeyondCriticalLevel); + + // ************ 11. Repeat steps 3-10 ************ + iLog->Put(_L("\r\n-- Testing import beyond critical level")); + ExecuteAndDeleteLD(iDatabase->CompactL()); + iLog->Put(_L("Consuming disk space...")); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + LogVolumeInfoL(); + ImportLandmarksTestL(testBeyondCriticalLevel); + + // Restore disk space + RecreateAndOpenFilesL(); + + // Use suitable database for exporting LMs + delete iDatabase; + iDatabase = NULL; + iDatabase = UseGeneratedDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // ************ 12. Fill up disk space ************ + iLog->Put(_L("Consuming disk space...")); + ConsumeDiskSpaceL(iFile1, iSizeLimit1); + LogVolumeInfoL(); + +//// Test importing landmarks + iLog->Put(_L("Testing Exporting...")); + ExportLandmarksTestL(); + } + +// --------------------------------------------------------- +// CPosTp55::RecreateAndOpenFilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::RecreateAndOpenFilesL() + { + iLog->Put(_L("Removing large files...")); + + // Delete files + iFile1.Close(); + iFileServer.Delete(KFile1); + iFile2.Close(); + iFileServer.Delete(KFile2); + iFile3.Close(); + iFileServer.Delete(KFile3); + + // Create and open files + User::LeaveIfError(iFile1.Create(iFileServer, KFile1, EFileWrite)); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + User::LeaveIfError(iFile3.Create(iFileServer, KFile3, EFileWrite)); + } + +// --------------------------------------------------------- +// CPosTp55::ExportLandmarksTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ExportLandmarksTestL() + { + TInt result(0); + TBool doAddAllLandmarks = ETrue; + TBool doExecuteIncrementally = ETrue; + +//// Testing Disk full during addition of LMs to encoder + iLog->Put(_L("\r\n--- Testing Disk full during addition of LMs to encoder")); + + // 13. ************ Export to file using encoder stand-alone ************ + iLog->Put(_L("------ Export to file incrementally using encoder stand-alone")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + AddLandmarksToEncoderL(doAddAllLandmarks); + + // ************ Export to buffer incrementally using encoder stand-alone ************ +// iLog->Put(_L("------ Export to buffer incrementally using encoder stand-alone")); +// Not tested here since it does not result in KErrDiskFull but in KErrNoMemory. Time-consuming test +/* ReInitializeEncoderEtcL(); + delete iOutputBuffer; + iOutputBuffer = NULL; + iOutputBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + AddCollectionDataToEncoderL(); + while (result == KErrNone) + { + TRAP(result, AddLandmarksToEncoderL(!doAddAllLandmarks)); + iMsg.Format(_L("Size of output buffer: %d"), iOutputBuffer->Size()); + iLog->Put(iMsg); + } + iMsg.Format(_L("Export to buffer left with error code %d"), result); + iLog->Put(iMsg); + */ + +//// Testing Disk full during ExportLandmarksL() + iLog->Put(_L("\r\n--- Testing Disk full during ExportLandmarksL()")); + + // Create array of all IDs in database + RArray itemIds; + CleanupClosePushL(itemIds); + PopulateArrayL(itemIds, doAddAllLandmarks); + + // ************ 14. Export to file incrementally using ExportLandmarksL() ************ + iLog->Put(_L("------ Export to file incrementally using ExportLandmarksL()")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + ExportWithExportLandmarksMethodL(itemIds, doExecuteIncrementally); + + // ************ 15. Export to file synchronously using ExportLandmarksL() ************ + iLog->Put(_L("------ Export to file synchronously using ExportLandmarksL()")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + ExportWithExportLandmarksMethodL(itemIds, !doExecuteIncrementally); + + // ************ Export to buffer incrementally using ExportLandmarksL() ************ +// iLog->Put(_L("------ Export to buffer incrementally using ExportLandmarksL()")); +// Not tested here since it does not result in KErrDiskFull but in KErrNoMemory. Time-consuming test + + // ************ Export to buffer synchronously ExportLandmarksL() ************ +// iLog->Put(_L("------ Export to buffer synchronously ExportLandmarksL() ------")); +// Not tested here since it does not result in KErrDiskFull but in KErrNoMemory. Time-consuming test + + CleanupStack::PopAndDestroy(&itemIds); + +//// Testing Disk full during finalizing of encoder + iLog->Put(_L("\r\n--- Testing Disk full during finalizing of encoder")); + + // ************ 16. Export to file using encoder stand-alone and finalizing incrementally ************ + iLog->Put(_L("------ Export to file using encoder stand-alone and finalizing incrementally")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + AddLandmarksToEncoderL(!doAddAllLandmarks); + FillFile3L(); // Fill up disk space so much that next call to FinalizeL results in KErrDiskFull. + FinalizeEncoderL(doExecuteIncrementally); + + // ************ 17. Export to file using encoder stand-alone and finalizing synchronously ************ + iLog->Put(_L("------ Export to file using encoder stand-alone and finalizing synchronously")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + AddLandmarksToEncoderL(!doAddAllLandmarks); + FillFile3L(); // Fill up disk space so much that next call to FinalizeL results in KErrDiskFull. + FinalizeEncoderL(!doExecuteIncrementally); + + // Create array of some IDs in database + CleanupClosePushL(itemIds); + PopulateArrayL(itemIds, !doAddAllLandmarks); + + // ************ 18. Export to file using ExportLandmarksL() and finalizing incrementally ************ + iLog->Put(_L("------ Export to file using ExportLandmarksL() and finalizing incrementally")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + ExportWithExportLandmarksMethodL(itemIds, doExecuteIncrementally); + FillFile3L(); // Fill up disk space so much that next call to FinalizeL results in KErrDiskFull. + FinalizeEncoderL(doExecuteIncrementally); + + // ************ 19. Export to file using ExportLandmarksL() and finalizing synchronously ************ + iLog->Put(_L("------ Export to file using ExportLandmarksL() and finalizing synchronously")); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + ExportWithExportLandmarksMethodL(itemIds, !doExecuteIncrementally); + FillFile3L(); // Fill up disk space so much that next call to FinalizeL results in KErrDiskFull. + FinalizeEncoderL(!doExecuteIncrementally); + + CleanupStack::PopAndDestroy(&itemIds); + +//// Testing when disk is already full + iLog->Put(_L("\r\n--- Testing when disk is already full")); + TVolumeInfo volumeInfoBeforeTest, volumeInfoAfterTest; + + // ************ 20. CPosLandmarkEncoder::SetOutPutFileL() ************ + iLog->Put(_L("------ CPosLandmarkEncoder::SetOutPutFileL()")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + User::LeaveIfError(iFileServer.Volume(volumeInfoBeforeTest, EDriveC)); + TRAP(result, iLandmarkEncoder->SetOutputFileL(KXmlOutputFile)); + User::LeaveIfError(iFileServer.Volume(volumeInfoAfterTest, EDriveC)); + + // Verify + _LIT(KSetFile1, "SetOutPutFileL() didn't result in KErrDiskFull but in %d"); + AssertTrueSecL(result == KErrDiskFull, KSetFile1, result); + iLog->Put(_L("SetOutputFileL() left with KErrDiskFull")); + _LIT(KSetFile2, "SetOutPutFileL() consumed disk space even if critical level has been passed. %d"); + AssertTrueSecL(volumeInfoBeforeTest.iFree == volumeInfoAfterTest.iFree, KSetFile2); + + // ************ 21. CPosLandmarkEncoder::AddLandmarkL() ************ + iLog->Put(_L("------ CPosLandmarkEncoder::AddLandmarkL()")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + CPosLmItemIterator* iterator = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iterator); + CPosLandmark* landmark = iDatabase->ReadLandmarkLC(iterator->NextL()); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + User::LeaveIfError(iFileServer.Volume(volumeInfoBeforeTest, EDriveC)); + TRAP(result, iLandmarkEncoder->AddLandmarkL(*landmark)); + User::LeaveIfError(iFileServer.Volume(volumeInfoAfterTest, EDriveC)); + CleanupStack::PopAndDestroy(2, iterator); + + // Verify + _LIT(KAddLmErr1, "Adding LM to encoder didn't result in KErrDiskFull but in %d when beyond critical level"); + AssertTrueSecL(result == KErrDiskFull, KAddLmErr1, result); + iLog->Put(_L("AddLandmarkL() left with KErrDiskFull")); + _LIT(KAddLmErr2, "AddLandmarkL() consumed disk space even if critical level has been passed. %d"); + AssertTrueSecL(volumeInfoBeforeTest.iFree == volumeInfoAfterTest.iFree, KAddLmErr2); + + // ************ 22. CPosLandmarkEncoder::FinalizeL() ************ + iLog->Put(_L("------ CPosLandmarkEncoder::FinalizeL()")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + AddLandmarksToEncoderL(!doAddAllLandmarks); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + delete iOperation; + iOperation = NULL; + User::LeaveIfError(iFileServer.Volume(volumeInfoBeforeTest, EDriveC)); + TRAP(result, iOperation = iLandmarkEncoder->FinalizeEncodingL()); + User::LeaveIfError(iFileServer.Volume(volumeInfoAfterTest, EDriveC)); + + // Verify + _LIT(KFinalizeErr1, "FinalizeL() didn't result in KErrDiskFull but in %d"); + AssertTrueSecL(result == KErrDiskFull, KFinalizeErr1, result); + iLog->Put(_L("FinalizeEncodingL() left with KErrDiskFull")); + _LIT(KFinalizeErr2, "FinalizeL() consumed disk space even if critical level has been passed. %d"); + AssertTrueSecL(volumeInfoBeforeTest.iFree == volumeInfoAfterTest.iFree, KFinalizeErr2); + + // ************ 23. CPosLandmarkEncoder::SetOutPutFileL() - Bonus test 1 ************ + iLog->Put(_L("------ CPosLandmarkEncoder::SetOutPutFileL() - Bonus test 1")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + TRAP(result, iLandmarkEncoder->SetOutputFileL(KXmlOutputFile)); + + // Verify + AssertTrueSecL(result == KErrDiskFull, KSetFile1, result); + iLog->Put(_L("SetOutputFileL() left with KErrDiskFull")); + + // Try it again + TRAP(result, iLandmarkEncoder->SetOutputFileL(KXmlOutputFile)); + + // Verify + _LIT(KSetFile3, "SetOutPutFileL() didn't result in KErrAlreadyExists but in %d"); + AssertTrueSecL(result == KErrAlreadyExists, KSetFile3, result); + iLog->Put(_L("SetOutputFileL() left with KErrAlreadyExists")); + + // ************ 24. CPosLandmarkEncoder::FinalizeL() - Bonus test 2 ************ + // This test tests if it is possible to finalize when adding LMs to encoder has + // been interrupted due to KErrDiskFull. + iLog->Put(_L("------ CPosLandmarkEncoder::FinalizeL() - Bonus test 2")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + iLandmarkEncoder->SetOutputFileL(KXmlOutputFile); + AddCollectionDataToEncoderL(); + + // Add landmarks will result in KErrDiskFull + AddLandmarksToEncoderL(doAddAllLandmarks); + + // Restore some disk space + iFile1.Close(); + DeleteFileL(KFile1); + + // Try to finalize + delete iOperation; + iOperation = NULL; + TRAP(result, ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL())); + AssertTrueSecL(result == KErrNone, _L("FinalizeL() left with %d"), result); + iLog->Put(_L("FinalizeL() successful")); + + // ************ CPosLandmarkEncoder::SetOutPutFileL() - Bonus test 3 ************ +// Not tested here since this is a panic test. (Not tested anywhere else) +/* iLog->Put(_L("------ CPosLandmarkEncoder::SetOutPutFileL() - Bonus test 3")); + iFile2.Close(); + DeleteFileL(KFile2); + ReInitializeEncoderEtcL(); + User::LeaveIfError(iFile2.Create(iFileServer, KFile2, EFileWrite)); + ConsumeDiskSpaceL(iFile2, iSizeLimit2); + TRAP(result, iLandmarkEncoder->SetOutputFileL(KXmlOutputFile)); + + // Verify + AssertTrueSecL(result == KErrDiskFull, KSetFile1, result); + iLog->Put(_L("SetOutputFileL() left with KErrDiskFull")); + + // Free some disc space and try to finish the export operation. (AddLandmarksL will panic with EPosLmProtocolBreak) + iFile2.Close(); + DeleteFileL(KFile2); + AddLandmarksToEncoderL(!doAddAllLandmarks); + FinalizeEncoderL(doExecuteIncrementally);*/ + } + +// --------------------------------------------------------- +// CPosTp55::ImportLandmarksTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ImportLandmarksTestL(TBool aCriticalLevelPassed) + { + delete iInputBuffer; + iInputBuffer = NULL; + iInputBuffer = CreateInputBufferL(); + TBool doExecuteIncrementally = ETrue; + + // ************ 3. Import all LMs in XML file incrementally ************ + iLog->Put(_L("---- Import all LMs in XML file incrementally")); + ImportLandmarksL(KXmlInputFile, NULL, doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 4. Import all LMs in XML file synchronously ************ + iLog->Put(_L("---- Import all LMs in XML file synchronously")); + ImportLandmarksL(KXmlInputFile, NULL, !doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 5. Import all LMs in XML buffer incrementally ************ + iLog->Put(_L("---- Import all LMs in XML buffer incrementally")); + ImportLandmarksL(KNullDesC, NULL, doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 6. Import all LMs in XML buffer synchronously ************ + iLog->Put(_L("---- Import all LMs in XML buffer synchronously")); + ImportLandmarksL(KNullDesC, NULL, !doExecuteIncrementally, aCriticalLevelPassed); + + // Create array of ids to Import (subset of all landmarks in the input file/buffer) + RArray itemIds; + CleanupClosePushL(itemIds); + for (TInt i = 10; i < 60; i++) + { + User::LeaveIfError(itemIds.Append(i)); + } + + // ************ 7. Import a subset of LMs in XML file incrementally ************ + iLog->Put(_L("---- Import a subset of LMs in XML file incrementally")); + ImportLandmarksL(KXmlInputFile, &itemIds, doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 8. Import a subset of LMs in XML file synchronously ************ + iLog->Put(_L("---- Import a subset of LMs in XML file synchronously")); + ImportLandmarksL(KXmlInputFile, &itemIds, !doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 9. Import a subset of LMs in XML buffer incrementally ************ + iLog->Put(_L("---- Import a subset of LMs in XML buffer incrementally")); + ImportLandmarksL(KNullDesC, &itemIds, doExecuteIncrementally, aCriticalLevelPassed); + + // ************ 10. Import a subset of LMs in XML buffer synchronously ************ + iLog->Put(_L("---- Import a subset of LMs in XML buffer synchronously")); + ImportLandmarksL(KNullDesC, &itemIds, !doExecuteIncrementally, aCriticalLevelPassed); + + CleanupStack::PopAndDestroy(&itemIds); + + iFile2.Close(); + DeleteFileL(KFile2); + } + +// --------------------------------------------------------- +// CPosTp55::ConsumeDiskSpaceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ConsumeDiskSpaceL( + RFile& aFile, TInt aSizeLimit) + { + TInt err(KErrNone); + + TVolumeInfo volumeInfo; + err=iFileServer.Volume(volumeInfo, EDriveC); + + // Fill file fast + HBufC8* bigBuf = (&KNonsense)->AllocLC(); + while (volumeInfo.iFree > aSizeLimit) + { + err = aFile.Write(*bigBuf); + if (err != KErrNone) iLog->Put(_L("Problem writing")); + err = iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) iLog->Put(_L("Problem voluming")); + } + + CleanupStack::PopAndDestroy(bigBuf); + } + +// --------------------------------------------------------- +// CPosTp55::ImportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ImportLandmarksL( + const TDesC& aInputFile, + RArray* aArrayOfIds, + TBool aExecuteIncrementally, + TBool aTestBeyondCriticalLevel) + { + // Recreate parser + delete iLandmarkParser; + iLandmarkParser = NULL; + + // to minimize risk of KErrLocked + User::After(500000); + iLog->Put(_L("Compacting")); + ExecuteAndDeleteLD(iDatabase->CompactL()); + User::After(500000); + + iLandmarkParser = CPosLandmarkParser::NewL(KMimeType); + + iProgress = 0; + TBool useInputFile = aInputFile != KNullDesC; + TBool importSubset = aArrayOfIds != NULL; + TInt result(KErrNone); + + // Prepare and set output for exported LMs + if (useInputFile) + { + iLog->Put(_L("SetInputFileL")); + iLandmarkParser->SetInputFileL(aInputFile); + } + else // use buffer as output + { + iLog->Put(_L("SetInputBuffer")); + iLandmarkParser->SetInputBuffer(*iInputBuffer); + } + + // Sample the db size + CPosLandmarkDatabase::TSize dbSizeBeforeImport; + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, dbSizeBeforeImport = iDatabase->SizeL()); + if (err == KErrLocked) + { + iLog->Put(_L("KErrLocked from iDatabase->SizeL()")); + User::After(100000); + } + } + + // Start importing LMs. + delete iOperation; + iOperation = NULL; + if (importSubset) + { + iLog->Put(_L("ImportLandmarksL")); + iOperation = iDatabase->ImportLandmarksL( + *iLandmarkParser, *aArrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + } + else + { + iLog->Put(_L("ImportLandmarksL")); + iOperation = iDatabase->ImportLandmarksL( + *iLandmarkParser, CPosLandmarkDatabase::EDefaultOptions); + } + + // Execute importing LMs + iLog->Put(_L("ExecuteLmOperationL")); + result = ExecuteLmOperationL(aExecuteIncrementally); + + // Check result + _LIT(KErrMsg, "ImportLandmarksL() didn't result in KErrDiskFull but in %d"); + AssertTrueSecL(result == KErrDiskFull, KErrMsg, result); + + if (aTestBeyondCriticalLevel) + { + // Sample the db size + TInt err2 = KErrLocked; + CPosLandmarkDatabase::TSize dbSizeAfterImport; + while (err2 == KErrLocked) + { + TRAP(err2, dbSizeAfterImport = iDatabase->SizeL()); + if (err2 == KErrLocked) + { + iLog->Put(_L("KErrLocked from iDatabase->SizeL(2)")); + User::After(100000); + } + } + + TBool dbSizeIsConstant = dbSizeAfterImport.iFileSize == dbSizeBeforeImport.iFileSize; + _LIT(KErrMsg, "Database size has changed when importing landmarks beyond critical level"); + if (!dbSizeIsConstant) + { + LogErrorAndLeave(KErrMsg); + } + iLog->Put(_L("Size of database untouched when importing landmarks beyond critical level")); + } + else + { + if (aExecuteIncrementally) + { + _LIT(KFormat, "Got KErrDiskFull after importing %d%% of the landmarks."); + iMsg.Format(KFormat, iProgress); + } + else + { + _LIT(KFormat, "Got KErrDiskFull when importing landmarks synchronously"); + iMsg.Copy(KFormat()); + } + iLog->Put(iMsg); + } + } + +// --------------------------------------------------------- +// CPosTp55::InitiateCriticalLevelL +// Initiates iCriticalLevel. (value of iCriticalLevel is extracted from an MLFW +// resource file that can reside on any drive) +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::InitiateCriticalLevelL() + { + iLog->Put(_L("InitiateCriticalLevelL")); + /* + // Find drive that the resource file resides on. + TFindFile* filefinder = new (ELeave) TFindFile(iFileServer); + CleanupStack::PushL(filefinder); + TParse* fileparser = new (ELeave) TParse; + CleanupStack::PushL(fileparser); + fileparser->Set(KPosResourceFile, NULL, NULL); + User::LeaveIfError( + filefinder->FindByDir(fileparser->NameAndExt(), fileparser->DriveAndPath())); + + // Open resource file + RResourceFile resFile; + resFile.OpenL(iFileServer, filefinder->File()); + CleanupClosePushL(resFile); + + // Allocate the critical level as a buffer + //TInt R_POS_LANDMARK_INTERNAL_CRITICAL_DISK_LEVEL = 250; + HBufC8* resourceBuffer = resFile.AllocReadLC(iCriticalThreshold); + + // Convert the buffer to an int + TResourceReader resReader; + resReader.SetBuffer(resourceBuffer); + iCriticalLevel = KOneK * resReader.ReadInt16(); + CleanupStack::PopAndDestroy(4, filefinder); + */ + iCriticalLevel = iCriticalThreshold; + iSizeLimit1 = iCriticalLevel + 18 * KOneK; // Do not mess with this value! + iSizeLimit2 = iCriticalLevel - 20 * KOneK; + + iMsg.Format(_L("CriticalLevel = %d, limit1 = %d, limit2 = %d "), iCriticalLevel, iSizeLimit1, iSizeLimit2); + iLog->Put(iMsg); + } + +// --------------------------------------------------------- +// CPosTp55::LogVolumeInfoL +// Initiates iCriticalLevel. (value of iCriticalLevel is extracted from an MLFW +// resource file that can reside on any drive) +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::LogVolumeInfoL() + { + _LIT(KUID,"Unique ID: %08x\r\n"); + _LIT(KSize,"Size: %d bytes\r\n"); + _LIT(KFree,"Free space: %d bytes\r\n"); + + TVolumeInfo volumeInfo; + TInt err = iFileServer.Volume(volumeInfo, EDriveC); + if (err != KErrNone) + LogErrorAndLeave(_L("Error from iFileServer")); + + iMsg.Zero(); + iMsg.AppendFormat(KUID, volumeInfo.iUniqueID); + iMsg.AppendFormat(KSize, volumeInfo.iSize); + iMsg.AppendFormat(KFree, volumeInfo.iFree); + iLog->Put(_L("\r\nMemory info:")); + iLog->Put(iMsg); + } + +// --------------------------------------------------------- +// CPosTp55::DeleteFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::DeleteFileL(const TDesC& aFile) + { + TInt err = iFileServer.Delete(aFile); + + if (err != KErrNone && err != KErrNotFound) + { + _LIT(KErrText, "DeleteFileL(): The file %S could not be deleted, errorcode %d"); + iMsg.Format(KErrText, &aFile, err); + LogErrorAndLeave(iMsg, err); + } + } + +// --------------------------------------------------------- +// CPosTp55::FillFile3L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::FillFile3L() + { + iFile3.Close(); + iFileServer.Delete(KFile3); + User::LeaveIfError(iFile3.Create(iFileServer, KFile3, EFileWrite)); + + TVolumeInfo volumeInfo; + User::LeaveIfError(iFileServer.Volume(volumeInfo, EDriveC)); + while (volumeInfo.iFree > iCriticalLevel + 512) + { + User::LeaveIfError(iFile3.Write(K64B)); + User::LeaveIfError(iFileServer.Volume(volumeInfo, EDriveC)); + } + } + +// --------------------------------------------------------- +// CPosTp55::CreateInputBufferL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +HBufC8* CPosTp55::CreateInputBufferL() + { + RFile inputFile; + User::LeaveIfError(inputFile.Open(iFileServer, KXmlInputFile, EFileRead)); + CleanupClosePushL(inputFile); + + TInt fileSize; + User::LeaveIfError(inputFile.Size(fileSize)); + HBufC8* buffer = HBufC8::NewLC(fileSize); + + // Copy file contents to buffer + TPtr8 writableBuffer = buffer->Des(); + User::LeaveIfError(inputFile.Read(writableBuffer, fileSize)); + + CleanupStack::Pop(buffer); + CleanupStack::PopAndDestroy(&inputFile); + return buffer; + } + +// --------------------------------------------------------- +// CPosTp55::ReInitializeEncoderEtcL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ReInitializeEncoderEtcL() + { + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KMimeType); + + DeleteFileL(KXmlOutputFile); + DeleteFileL(KXmlBufferDumpFile); + iFile3.Close(); + DeleteFileL(KFile3); + + iProgress = 0; + } + +// --------------------------------------------------------- +// CPosTp55::ReInitializeEncoderEtcL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp55::ExecuteLmOperationL( + TBool aExecuteIncrementally) + { + TInt result(0); + + if (aExecuteIncrementally) + { + // Execute the finalizing incrementally. + iOperationWrapper->Start(iOperation, this); + CActiveScheduler::Start(); + result = iOperationWrapper->iStatus.Int(); + } + else + { + TRAP(result, iOperation->ExecuteL()); + } + + return result; + } + +// --------------------------------------------------------- +// CPosTp55::SetOutputBufferL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::SetOutputBufferL() + { + delete iOutputBuffer; + iOutputBuffer = NULL; + iOutputBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + } + +// --------------------------------------------------------- +// CPosTp55::AddCollectionDataToEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::AddCollectionDataToEncoderL() + { + // Add long collection name to encoder + HBufC* collectionName = HBufC::NewLC(2 * KNonsense().Length()); + collectionName->Des().Copy(KNonsense); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, *collectionName); + + // Add long collection desc to encoder + HBufC* collectionDesc = HBufC::NewLC(3 * collectionName->Length()); + collectionDesc->Des().Append(*collectionName); + collectionDesc->Des().Append(*collectionName); + collectionDesc->Des().Append(*collectionName); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, *collectionDesc); + CleanupStack::PopAndDestroy(2, collectionName); + } + +// --------------------------------------------------------- +// CPosTp55::AddLandmarksToEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::AddLandmarksToEncoderL(TBool aAddAll) + { + // Add landmarks to export to encoder manually. + TInt result(0); + CPosLmItemIterator* iterator = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iterator); + TInt maxNrOfLMs = (aAddAll) ? iterator->NumOfItemsL() : KNrOfLandmarksToExport; + for (TInt i = 0; i < maxNrOfLMs && result != KErrDiskFull; i++) + { + CPosLandmark* landmark = iDatabase->ReadLandmarkLC(iterator->NextL()); + TRAP(result, iLandmarkEncoder->AddLandmarkL(*landmark)); + if (result == KErrLocked) + { + iLog->Put(_L("KErrLocked when AddLandmarkL in AddLandmarksToEncoderL")); + User::After(100000); + } + CleanupStack::PopAndDestroy(landmark); + iProgress = (TInt) (100 * i / maxNrOfLMs); + } + CleanupStack::PopAndDestroy(iterator); + + if (aAddAll) + { + if (result == KErrDiskFull) + { + iMsg.Format(_L("Got KErrDiskFull after adding %d%% of the landmarks to the encoder."), iProgress); + iLog->Put(iMsg); + } + else + { + _LIT(KAddLmErr, "Didn't get EKrrDiskFull but %d when adding LMs to encoder"); + LogVolumeInfoL(); + LogErrorAndLeave(KAddLmErr); + } + } + else + { + _LIT(KAddLmErr, "Didn't get EKrrNone but %d when adding LMs to encoder"); + AssertTrueSecL(result == KErrNone, KAddLmErr, result); + } + } + +// --------------------------------------------------------- +// CPosTp55::ExportWithExportLandmarksMethodL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::ExportWithExportLandmarksMethodL( + RArray& aArrayOfIds, + TBool aExecuteIncrementally) + { + delete iOperation; + iOperation = NULL; + iOperation = iDatabase->ExportLandmarksL( + *iLandmarkEncoder, aArrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + TInt result = ExecuteLmOperationL(aExecuteIncrementally); + + if (aArrayOfIds.Count() == KNrOfLandmarksToExport) // not all of the LMs have been added + { + // Check that KErrDiskFull is not returned + _LIT(KErrMsg, "Expected KErrNone from ExportLandmarksL() but got %d."); + AssertTrueSecL(result == KErrNone, KErrMsg, result); + } + else // We should have gotten KErrDiskFull when adding LMs to encoder. + { + _LIT(KErrMsg, "ExportLandmarksL() didn't result in KErrDiskFull but in %d"); + AssertTrueSecL(result == KErrDiskFull, KErrMsg, result); + if (aExecuteIncrementally) + { + iMsg.Format(_L("Got KErrDiskFull after adding %d%% of the landmarks to the encoder."), iProgress); + } + else + { + iMsg = _L("Got KErrDiskFull when exporting landmarks synchronously"); + } + iLog->Put(iMsg); + } + } + +// --------------------------------------------------------- +// CPosTp55::FinalizeEncoderL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::FinalizeEncoderL( + TBool aExecuteIncrementally) + { + delete iOperation; + iOperation = NULL; + TRAPD(result, iOperation = iLandmarkEncoder->FinalizeEncodingL()); + if (result == KErrNone) + { + result = ExecuteLmOperationL(aExecuteIncrementally); + + // Check that KErrDiskFull is returned + _LIT(KErrMsg, "FinalizeL() didn't result in KErrDiskFull but in %d"); + AssertTrueSecL(result == KErrDiskFull, KErrMsg, result); + iLog->Put(_L("Execution of FinalizeEncodingL() left with KErrDiskFull")); + } + else + { + AssertTrueSecL(result == KErrDiskFull, _L("FinalizeEncodingL() left with %d"), result); + iLog->Put(_L("FinalizeEncodingL() left with KErrDiskFull")); + } + } + +// --------------------------------------------------------- +// CPosTp55::FinalizeEncoderL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::PopulateArrayL( + RArray& aArray, + TBool aDoAddAllLms) + { + CPosLmItemIterator* iterator = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iterator); + TInt nrOfLms = aDoAddAllLms ? iterator->NumOfItemsL() : KNrOfLandmarksToExport; + for (TInt i = 0; i < nrOfLms; i++) + { + CPosLandmark* landmark = iDatabase->ReadLandmarkLC(iterator->NextL()); + User::LeaveIfError(aArray.Append(landmark->LandmarkId())); + CleanupStack::PopAndDestroy(landmark); + } + CleanupStack::PopAndDestroy(iterator); + } + +// --------------------------------------------------------- +// CPosTp55::CopyResourceFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::CopyResourceFileL(const TDesC& aResourceFile) + { + // Release all landmark references to make DLLs be unloaded. + delete iDatabase; + iDatabase = NULL; + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + delete iOperation; + iOperation = NULL; + + CFileMan* fileMan = CFileMan::NewL(iFileServer); + CleanupStack::PushL(fileMan); + + // Check if landmark is flashed + if (!BaflUtils::FileExists(iFileServer, KInternalServicesResFileRom)) + { + iLog->Put(_L("Landmark is NOT flashed, backing up eposlmintservices.rsc by renaming it bofore copying rsc-file.")); + // Landmark FW is not flashed. Rename the file before copying an own defiend file. + // Since landmark FW is not flashed the file should exist hence leaving if it is not found! + User::LeaveIfError(fileMan->Rename(KInternalServicesResFileCdrive, KInternalServicesResFileBackup, CFileMan::EOverWrite)); + } + else + { + iLog->Put(_L("Landmark framework is flashed, copying global categories to c:")); + } + + User::LeaveIfError(fileMan->Copy(aResourceFile, KInternalServicesResFileCdrive, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CPosTp55::TryRestoreResourceFile +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp55::TryRestoreResourceFile() + { + CFileMan* fileMan = NULL; + TRAPD(err, fileMan = CFileMan::NewL(iFileServer)); + if (fileMan) + { + // Try to restore the backup up rsc-file (only possible when LM FW is not flashed. + TInt result = fileMan->Copy(KInternalServicesResFileBackup, KInternalServicesResFileCdrive, CFileMan::EOverWrite); + if (result == KErrNotFound) + { + if (BaflUtils::FileExists(iFileServer, KInternalServicesResFileRom)) + { + // LM FW is flashed. We need to remove the rsc-file on c: + fileMan->Delete(KInternalServicesResFileCdrive); + } + } + delete fileMan; + } + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp1.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp1.h" +#include +#include +#include "FT_LandmarkConstants.h" + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp1::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp1::StartL() + { + _LIT(KUriErr, "Incorrect URI is returned from the API"); + _LIT(KDefaultDbUri, "file://C:eposlm.ldb"); + + // Init test part + RemoveAllLmDatabasesL(); + + + // End init test part + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + iLog->Log(_L("CPosLandmarkDatabase::OpenL done")); + CleanupStack::PushL(lmd); + + // Check that THAN-65NHQW has been corrected by doing a ExecuteAndDeleteLD(lmd->InitializeL()) followed by + + if (lmd->IsInitializingNeeded()) + { + iLog->Log(_L("IsInitializingNeeded()")); + ExecuteAndDeleteLD(lmd->InitializeL()); + RunAsyncOperationLD(lmd->InitializeL()); + } + else + { + iLog->Log(_L("IsInitializingNeeded() Not needed")); + ExecuteAndDeleteLD(lmd->InitializeL()); + RunAsyncOperationLD(lmd->InitializeL()); + } + + + CleanupStack::PopAndDestroy(lmd); + + VerifyLockedDatabaseL(); + + } + +// --------------------------------------------------------- +// CPosTp1::VerifyLockedDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp1::VerifyLockedDatabaseL() + { + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + // copy the test db to the private path + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp1TestDb); + + TInt err = fileMan->Copy(srcPath, KLmTp1DefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp1TestDb); + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(KTp1TestDb); + CleanupStack::PushL(db1); + if (db1->IsInitializingNeeded()) + { + TRAPD( err, ExecuteAndDeleteLD( db1->InitializeL() ) ); + AssertTrueSecL(err == KErrNone, _L("Init db failed")); + } + + + + // Take read lock + RArray ids; + CleanupClosePushL(ids); + User::LeaveIfError(ids.Append(1)); + User::LeaveIfError(ids.Append(3)); + User::LeaveIfError(ids.Append(4)); + User::LeaveIfError(ids.Append(6)); + User::LeaveIfError(ids.Append(7)); + User::LeaveIfError(ids.Append(9)); + User::LeaveIfError(ids.Append(24)); + User::LeaveIfError(ids.Append(14)); + User::LeaveIfError(ids.Append(66)); + User::LeaveIfError(ids.Append(61)); + User::LeaveIfError(ids.Append(14)); + CPosLmOperation* operation = db1->PreparePartialLandmarksL(ids); + CleanupStack::PushL(operation); + TReal32 progress(0); + TRequestStatus status; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle + operation->NextStep(status, progress); + CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(); + iLog->Log(_L("CPosLandmarkDatabase::OpenL done")); + delete db2; + User::WaitForRequest(status); + + // Release read lock + CleanupStack::PopAndDestroy(operation); + + // Take write lock + operation = db1->RemoveAllLandmarksL(); + CleanupStack::PushL(operation); + progress = 0; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle - should result in KErrLocked + operation->NextStep(status, progress); + db2 = NULL; + TRAPD(err1, db2 = CPosLandmarkDatabase::OpenL()); + delete db2; + User::WaitForRequest(status); + AssertTrueSecL(err1 == KErrLocked, _L("OpenL() didn't result in KErrLocked but in %d"), err1); + + CleanupStack::PopAndDestroy(3, db1); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp10.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp10.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1465 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp10.h" +#include +#include +#include +#include +#include + +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KNoCategoriesTp10 = 100; +const TInt KNoLandmarksTp10 = 100; + +const TInt KAddStartIndex=5; +const TInt KAddEndIndex=20; +const TInt KAddCategoryIndex=8; + +const TInt KAddStartIndexAsync=21; +const TInt KAddEndIndexAsync=82; +const TInt KAddCategoryIndexAsync=10; + +const TInt KRemoveStartIndex=85; +const TInt KRemoveEndIndex=95; + +const TInt KRemoveStartIndexAsync=75; +const TInt KRemoveEndIndexAsync=84; + +const TInt KRemoveSetStartIndex=50; +const TInt KRemoveSetEndIndex=74; + +const TInt KRemoveSetStartIndexAsync=0; +const TInt KRemoveSetEndIndexAsync=49; + + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp10::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::StartL() + { + _LIT(KLogFileName, "c:\\documents\\TP10TimeMeasurements.txt"); + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + // Test LMREQ121 below + TestMissingCategories1L(); + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + TestMissingCategories2L(); + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + // copy the test db to the private path + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp10TestDb); + + TInt err = fileMan->Copy(srcPath, KLmTp10DefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp10TestDb); + CleanupStack::PopAndDestroy(manager); + + iDatabase= CPosLandmarkDatabase::OpenL(KTp10TestDb); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); // Synchronous since no argument + } + + TTime start, stop, totalStart, totalStop; + totalStart.UniversalTime(); + + start.UniversalTime(); + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + stop.UniversalTime(); + + TInt64 msec = (stop.Int64() - start.Int64()); + TBuf8 msg; + _LIT8(KTrace, "CPosLmCategoryManager::NewL = %d usec"); + msg.Format(KTrace, msec); + LogToFileL(KLogFileName, msg); + +// Add Category + start.UniversalTime(); + AddCategoriesL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace2, "AddCategoriesL = %d msec"); + msg.Format(KTrace2, msec); + LogToFileL(KLogFileName, msg); + +// Read Category + start.UniversalTime(); + ReadCategoriesL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace3, "ReadCategoriesL = %d msec"); + msg.Format(KTrace3, msec); + LogToFileL(KLogFileName, msg); + +// Update Category + start.UniversalTime(); + UpdateCategoriesL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace4, "UpdateCategoriesL = %d msec"); + msg.Format(KTrace4, msec); + LogToFileL(KLogFileName, msg); + + ReadCategoriesL(); + AddLandmarksL(); + +// Add Categories to LM synch + start.UniversalTime(); + AddCategoriesToLandmarksL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace5, "AddCategoriesToLandmarksL = %d msec"); + msg.Format(KTrace5, msec); + LogToFileL(KLogFileName, msg); + +// Add Categories to LM asynch + start.UniversalTime(); + AddCategoriesToLandmarksAsyncL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace6, "AddCategoriesToLandmarksAsyncL = %d msec"); + msg.Format(KTrace6, msec); + LogToFileL(KLogFileName, msg); + + AddCategoriesToLandmarksAsyncErrCheckL(); + +// Add Categories to LM using WaitForReq + start.UniversalTime(); + AddCategoriesToLandmarksUsingWaitForReqL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace6b, "AddCategoriesToLandmarksUsingWaitForReqL = %d msec"); + msg.Format(KTrace6b, msec); + LogToFileL(KLogFileName, msg); + + AddCategoriesToLandmarksAsyncErrCheckL(); + +// Remove Category synchronously + ExecuteAndDeleteLD(iDatabase->CompactL()); + start.UniversalTime(); + RemoveCategoryL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace7, "RemoveCategoryL = %d msec"); + msg.Format(KTrace7, msec); + LogToFileL(KLogFileName, msg); + +// Remove Category asynchronously + start.UniversalTime(); + RemoveCategoryAsyncL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace8, "RemoveCategoryAsyncL = %d msec"); + msg.Format(KTrace8, msec); + LogToFileL(KLogFileName, msg); + +// Remove Category using WaitForRequest + start.UniversalTime(); + RemoveCategoryUsingWaitForReqL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace8b, "RemoveCategoryUsingWaitForReqL = %d msec"); + msg.Format(KTrace8b, msec); + LogToFileL(KLogFileName, msg); + +// Remove set of categories synchronously + start.UniversalTime(); + RemoveSetOfCategoriesL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace9, "RemoveSetOfCategoriesL = %d msec"); + msg.Format(KTrace9, msec); + LogToFileL(KLogFileName, msg); + +// Remove set of categories asynchronously + start.UniversalTime(); + RemoveSetOfCategoriesAsyncL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace10, "RemoveSetOfCategoriesAsyncL = %d msec"); + msg.Format(KTrace10, msec); + LogToFileL(KLogFileName, msg); + +// Remove set of categories using WaitForRequest + start.UniversalTime(); + RemoveSetOfCategoriesUsingWaitForReqL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace10b, "RemoveSetOfCategoriesUsingWaitForReqL = %d msec"); + msg.Format(KTrace10b, msec); + LogToFileL(KLogFileName, msg); + +// Remove category from set of landmarks synchronously + iCategories.ResetAndDestroy(); + AddCategoriesL(); + AddCategoriesToLandmarksL(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + start.UniversalTime(); + RemoveCategoryFromSetOfLandmarksL(); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace11, "RemoveCategoryFromSetOfLandmarksL = %d msec"); + msg.Format(KTrace11, msec); + LogToFileL(KLogFileName, msg); + +// Remove category from set of landmarks asynchronously + start.UniversalTime(); + RemoveCategoryFromSetOfLandmarksAsyncL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace12, "RemoveCategoryFromSetOfLandmarksAsyncL = %d msec"); + msg.Format(KTrace12, msec); + LogToFileL(KLogFileName, msg); + +// Remove category from set of landmarks using User::WaitForRequest() + start.UniversalTime(); + RemoveCategoryFromSetOfLandmarksUsingWaitForReqL(); + stop.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace12b, "RemoveCategoryFromSetOfLandmarksUsingWaitForReqL = %d msec"); + msg.Format(KTrace12b, msec); + LogToFileL(KLogFileName, msg); + + AddCategoriesToLandmarksL(); + delete iDatabase; + iDatabase=NULL; + delete iCategoryManager; + iCategoryManager = NULL; + + iLog->Log(_L("BEFORE : BackupDbFileL")); + iDatabase = BackupTp10DbFileL(); + iLog->Log(_L("AFTER : BackupDbFileL")); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + + // Cancel tests immediately + iLog->Log(_L("TESTS BELOW ARE TESTING CANCEL")); + AddCategoriesToLandmarksAsyncAndCancelL(); + RemoveCategoryAsyncAndCancelL(); + RemoveSetOfCategoriesAsyncAndCancelL(); + RemoveCategoryFromSetOfLandmarksAsyncAndCancelL(); + + // Cancel tests after a while + iLog->Log(_L("TESTS BELOW ARE CANCEL IN CALLBACK")); + delete iDatabase; + iDatabase=NULL; + + + iLog->Log(_L("BEFORE : RestoreDbFileL")); + iDatabase = RestoreTp10DbFileL(); + iLog->Log(_L("AFTER : RestoreDbFileL")); + + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + delete iCategoryManager; + iCategoryManager = NULL; + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + + ExecuteAndDeleteLD(iDatabase->CompactL()); + AddCategoriesToLandmarksAsyncAndCancelL(ETrue); + RemoveCategoryAsyncAndCancelL(ETrue); + RemoveSetOfCategoriesAsyncAndCancelL(ETrue); + delete iDatabase; + iDatabase=NULL; + iDatabase = RestoreTp10DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + delete iCategoryManager; + iCategoryManager = NULL; + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->CompactL()); + RemoveCategoryFromSetOfLandmarksAsyncAndCancelL(ETrue); + + + totalStop.UniversalTime(); + msec = (totalStop.Int64() - totalStart.Int64())/1000; + _LIT8(KTrace13, "Complete test case = %d msec"); + msg.Format(KTrace13, msec); + LogToFileL(KLogFileName, msg); + + } + +// --------------------------------------------------------- +// CPosTp10::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::CloseTest() + { + iCategories.ResetAndDestroy(); + iCategories.Close(); + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + delete iDatabase; + iDatabase=NULL; + delete iCategoryManager; + iCategoryManager=NULL; + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesL() + { + iLog->Log(_L("Adding and copying categories")); + _LIT(KAlreadyExistErr, "A category with the same name is already added so add should return KErrAlreadyExists"); + _LIT(KNoNameErr, "The Category has no name so add should return KErrArgument"); + + _LIT(KCategoryName, "CategoryTP10 - %d"); + + TInt index=0; + while (index < KNoCategoriesTp10) + { + TBuf<100> name; + name.Format(KCategoryName, ++index); + CPosLandmarkCategory* category = CreateCategoryLC(name); + + CPosLandmarkCategory* copy = CPosLandmarkCategory::NewLC(*category); + name.Format(KCategoryName, ++index); + copy->SetCategoryNameL(name); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewL(); + CleanupStack::PushL(category2); + name.Format(KCategoryName, ++index); + category2->SetCategoryNameL(name); + + CPosLandmarkCategory* copy2 = CPosLandmarkCategory::NewL(*category2); + CleanupStack::PushL(copy2); + name.Format(KCategoryName, ++index); + copy2->SetCategoryNameL(name); + + ExecuteAndDeleteLD(iDatabase->CompactL()); + iCategoryManager->AddCategoryL(*category); + iCategoryManager->AddCategoryL(*copy); + iCategoryManager->AddCategoryL(*category2); + iCategoryManager->AddCategoryL(*copy2); + + CPosLandmarkCategory* category3 = CPosLandmarkCategory::NewLC(); + category3->SetCategoryNameL(name); + + TInt err = 0; + TRAP(err, iCategoryManager->AddCategoryL(*category3)); + AssertTrueSecL(err == KErrAlreadyExists, KAlreadyExistErr); + CleanupStack::PopAndDestroy(category3); + + CPosLandmarkCategory* category4 = CPosLandmarkCategory::NewLC(); + TRAP(err, iCategoryManager->AddCategoryL(*category3)); + AssertTrueSecL(err == KErrArgument, KNoNameErr); + CleanupStack::PopAndDestroy(category4); + + iCategories.Append(category); + iCategories.Append(copy); + iCategories.Append(category2); + iCategories.Append(copy2); + + CleanupStack::Pop(4); + } + } + +// --------------------------------------------------------- +// CPosTp10::CompareTwoCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::CompareTwoCategoriesL(TInt aIndex) + { + CPosLandmarkCategory* category = iCategoryManager->ReadCategoryLC(iCategories[aIndex]->CategoryId()); + CompareCategoriesL(*iCategories[aIndex], *category); + CleanupStack::PopAndDestroy(category); + } + +// --------------------------------------------------------- +// CPosTp10::ReadCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::ReadCategoriesL() + { + iLog->Log(_L("Reading categories")); + _LIT(KReadNotFoundErr, "The category id doesn't exist so ReadCategory should return not found"); + + for (TInt i = 0; iLog(_L("KErrLocked from CompareTwoCategoriesL, try again")); + User::After(100000); + } + } + } + + TPosLmItemId id = 5123321; + + CPosLandmarkCategory* category=NULL; + TRAPD(err, category=iCategoryManager->ReadCategoryLC(id)); + delete category; + AssertTrueSecL(err == KErrNotFound, KReadNotFoundErr); + } + +// --------------------------------------------------------- +// CPosTp10::UpdateCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::UpdateCategoriesL() + { + iLog->Log(_L("Updating categories")); + _LIT(KCategoryNameNotSetErr, "UpdateCategory does not leave with KErrArgumenet when name is not set"); + _LIT(KCategoryExistsErr, "UpdateCategory does not leave with KErrAlreadyExist"); + + TInt err; + ExecuteAndDeleteLD(iDatabase->CompactL()); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + TRAP(err, iCategoryManager->UpdateCategoryL(*category)); + AssertTrueSecL(err == KErrArgument, KCategoryNameNotSetErr); + CleanupStack::PopAndDestroy(category); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewLC(*iCategories[0]); + + TPtrC nameThatExist; + User::LeaveIfError(iCategories[1]->GetCategoryName(nameThatExist)); + category2->SetCategoryNameL(nameThatExist); + TRAP(err, iCategoryManager->UpdateCategoryL(*category2)); + AssertTrueSecL(err == KErrAlreadyExists, KCategoryExistsErr); + CleanupStack::PopAndDestroy(category2); + + _LIT(KUpdatedCategoryName, "UpdatedCategoryTP10 - %d"); + + for (TInt i = 0; i name; + name.Format(KUpdatedCategoryName, i); + iCategories[i]->SetCategoryNameL(name); + iCategories[i]->SetIconL(KMbmFileName2, KIconIndex2, KPosLmIconMaskNotUsed); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iCategoryManager->UpdateCategoryL(*iCategories[i])); + } + + } + } + +// --------------------------------------------------------- +// CPosTp10::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddLandmarksL() + { + iLog->Log(_L("Adding landmarks")); + _LIT(KLmName, "LmTP10 - %d"); + _LIT(KLmDescription, "LmTP10Description - %d"); + + for (TInt i=0; i<(KNoLandmarksTp10); i++) + { + TBuf<100> lmName; + lmName.Format(KLmName,i); + TBuf<100> lmDesc; + lmDesc.Format(KLmDescription,i); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + landmark->SetLandmarkDescriptionL(lmDesc); + + landmark->AddCategoryL(iCategories[i]->CategoryId()); + + TInt err=KErrLocked; + while (err==KErrLocked) + { + TRAP(err, iDatabase->AddLandmarkL(*landmark)); + } + iLandmarks.Append(landmark); + CleanupStack::Pop(); + } + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesToSetOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesToLandmarksL() + { + iLog->Log(_L("Adding categories to landmarks")); + + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + for(TInt i=KAddStartIndex; i<=KAddEndIndex; i++) + { + landmarksIds.Append(iLandmarks[i]->LandmarkId()); + iLandmarks[i]->AddCategoryL(iCategories[KAddCategoryIndex]->CategoryId()); + } + + // Add some invalid as well + landmarksIds.Append(2000); + landmarksIds.Append(3000); + + TInt err=KErrLocked; + while (err==KErrLocked) + { + TRAP( err, ExecuteAndDeleteLD(iCategoryManager->AddCategoryToLandmarksL( + iCategories[KAddCategoryIndex]->CategoryId(), + landmarksIds)) ); + } + + CleanupStack::PopAndDestroy(&landmarksIds); + CheckLandmarksL(); + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesToSetOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesToLandmarksAsyncL() + { + iLog->Log(_L("Adding categories to landmarks asynchronously")); + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + + for(TInt i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + landmarksIds.Append(iLandmarks[i]->LandmarkId()); + iLandmarks[i]->AddCategoryL(iCategories[KAddCategoryIndexAsync]->CategoryId()); + } + + + RunAsyncOperationLD(iCategoryManager->AddCategoryToLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + landmarksIds + )); + CheckLandmarksL(); + + CleanupStack::PopAndDestroy(&landmarksIds); + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesToLandmarksUsingWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesToLandmarksUsingWaitForReqL() + { + iLog->Log(_L("AddCategoriesToLandmarksUsingWaitForReqL")); + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + + for(TInt i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + landmarksIds.Append(iLandmarks[i]->LandmarkId()); + iLandmarks[i]->AddCategoryL(iCategories[KAddCategoryIndexAsync]->CategoryId()); + } + + CPosLmOperation* op = iCategoryManager->AddCategoryToLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + landmarksIds); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + + CheckLandmarksL(); + + CleanupStack::PopAndDestroy(&landmarksIds); + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesToSetOfLandmarksAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesToLandmarksAsyncAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("Adding categories to landmarks asyncronously and cancel")); + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + + for(TInt i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + landmarksIds.Append(iLandmarks[i]->LandmarkId()); + iLandmarks[i]->AddCategoryL(iCategories[KAddCategoryIndexAsync]->CategoryId()); + } + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iCategoryManager->AddCategoryToLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + landmarksIds + )); + } + else + { + RunAsyncOperationAndCancelLD(iCategoryManager->AddCategoryToLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + landmarksIds + )); + } + + CleanupStack::PopAndDestroy(&landmarksIds); + } + +// --------------------------------------------------------- +// CPosTp10::AddCategoriesToLandmarksAsyncErrCheckL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::AddCategoriesToLandmarksAsyncErrCheckL() + { + iLog->Log(_L("Adding category not in db to landmarks async.")); + + _LIT(KNotFoundErr, "AddCategoryToLandmarksL is not returning -1 for a category id not in db"); + + TPosLmItemId idNotInDb = 5123321; + + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + + landmarksIds.Append(iLandmarks[0]->LandmarkId()); + + TRAPD(err, iOperation = iCategoryManager->AddCategoryToLandmarksL(idNotInDb, landmarksIds)); + + AssertTrueSecL(err == KErrNotFound, KNotFoundErr); + + + iOperation = NULL; + CleanupStack::PopAndDestroy(&landmarksIds); + } + +// --------------------------------------------------------- +// CPosTp10::CheckLandmarks +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::CheckLandmarksL() + { + for (TInt i = 0; iReadLandmarkLC(iLandmarks[i]->LandmarkId()); + CompareLandmarksL(*iLandmarks[i], *lm); + CleanupStack::PopAndDestroy(); // lm + } + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryL() + { + iLog->Log(_L("Removing categories")); + + TInt i=0; + for (i=0; iAddCategoryL(iCategories[KRemoveStartIndex]->CategoryId()); + if (i % 2) + { + TInt index = 1+KRemoveStartIndex; + iLandmarks[i]->AddCategoryL(iCategories[index]->CategoryId()); + } + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveStartIndex; i <= KRemoveEndIndex; i++) + { + ExecuteAndDeleteLD(iCategoryManager->RemoveCategoryL(iCategories[i]->CategoryId())); + } + CheckRemovedL(KRemoveStartIndex, KRemoveEndIndex); + } + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryAsyncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryAsyncL() + { + iLog->Log(_L("Removing categories asyncronously")); + TInt i=0; + for (i=0; iAddCategoryL(iCategories[KRemoveStartIndexAsync]->CategoryId()); + if (i % 2) + { + TInt index = 1+KRemoveStartIndexAsync; + iLandmarks[i]->AddCategoryL(iCategories[index]->CategoryId()); + } + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveStartIndexAsync; i <= KRemoveEndIndexAsync; i++) + { + RunAsyncOperationLD(iCategoryManager->RemoveCategoryL(iCategories[i]->CategoryId())); + } + CheckRemovedL(KRemoveStartIndexAsync, KRemoveEndIndexAsync); + } + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryUsingWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryUsingWaitForReqL() + { + iLog->Log(_L("Removing categories using User::WaitForRequest")); + TInt i=0; + for (i=0; iAddCategoryL(iCategories[KRemoveStartIndexAsync]->CategoryId()); + if (i % 2) + { + TInt index = 1+KRemoveStartIndexAsync; + iLandmarks[i]->AddCategoryL(iCategories[index]->CategoryId()); + } + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveStartIndexAsync; i <= KRemoveEndIndexAsync; i++) + { + CPosLmOperation* op = iCategoryManager->RemoveCategoryL(iCategories[i]->CategoryId()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + CheckRemovedL(KRemoveStartIndexAsync, KRemoveEndIndexAsync); + } + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryAsyncAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryAsyncAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("Removing categories asyncronously and cancel")); + TInt i=0; + for (i=0; iAddCategoryL(iCategories[KRemoveStartIndexAsync]->CategoryId()); + if (i % 2) + { + TInt index = 1+KRemoveStartIndexAsync; + iLandmarks[i]->AddCategoryL(iCategories[index]->CategoryId()); + } + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveStartIndexAsync; i <= KRemoveEndIndexAsync; i++) + { + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iCategoryManager->RemoveCategoryL(iCategories[i]->CategoryId())); + } + else + { + RunAsyncOperationAndCancelLD(iCategoryManager->RemoveCategoryL(iCategories[i]->CategoryId())); + } + } + } + } + +// --------------------------------------------------------- +// CPosTp10::RemoveSetOfCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveSetOfCategoriesL() + { + iLog->Log(_L("Removing set of categories")); + + RArray ids; + CleanupClosePushL(ids); + + for (TInt i=KRemoveSetStartIndex; i<=KRemoveSetEndIndex; i++) + { + ids.Append(iCategories[i]->CategoryId()); + } + + for (TInt j=0; j<2; j++) + { + ExecuteAndDeleteLD(iCategoryManager->RemoveCategoriesL(ids)); + + CheckRemovedL(KRemoveSetStartIndex, KRemoveSetEndIndex); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveSetOfCategoriesAsyncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveSetOfCategoriesAsyncL() + { + iLog->Log(_L("Removing set of categories asyncronously")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KRemoveSetStartIndexAsync; i<=KRemoveSetEndIndexAsync; i++) + { + ids.Append(iCategories[i]->CategoryId()); + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveSetStartIndexAsync; i <= KRemoveSetEndIndexAsync; i++) + { + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, RunAsyncOperationLD(iCategoryManager->RemoveCategoriesL(ids))); + } + } + CheckRemovedL(KRemoveSetStartIndexAsync, KRemoveSetEndIndexAsync); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveSetOfCategoriesUsingWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveSetOfCategoriesUsingWaitForReqL() + { + iLog->Log(_L("Removing set of categories using User::WaitForRequest")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KRemoveSetStartIndexAsync; i<=KRemoveSetEndIndexAsync; i++) + { + ids.Append(iCategories[i]->CategoryId()); + } + + // Add some unvalid ids as well + ids.Append(222); + ids.Append(223); + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveSetStartIndexAsync; i <= KRemoveSetEndIndexAsync; i++) + { + CPosLmOperation* op = iCategoryManager->RemoveCategoriesL(ids); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + CheckRemovedL(KRemoveSetStartIndexAsync, KRemoveSetEndIndexAsync); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveSetOfCategoriesAsyncAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveSetOfCategoriesAsyncAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("Removing set of categories asyncronously and cancel")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KRemoveSetStartIndexAsync; i<=KRemoveSetEndIndexAsync; i++) + { + ids.Append(iCategories[i]->CategoryId()); + } + + for (TInt j=0; j<2; j++) + { + for (i = KRemoveSetStartIndexAsync; i <= KRemoveSetEndIndexAsync; i++) + { + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iCategoryManager->RemoveCategoriesL(ids)); + } + else + { + RunAsyncOperationAndCancelLD(iCategoryManager->RemoveCategoriesL(ids)); + } + } + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryFromSetOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryFromSetOfLandmarksL() + { + iLog->Log(_L("Removing set of categories from landmarks")); + RArray ids; + CleanupClosePushL(ids); + + for (TInt i = KAddStartIndex; i<=KAddEndIndex; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + + iLandmarks[i]->RemoveCategory(iCategories[KAddCategoryIndex]->CategoryId()); + } + // Append some non-existing as well + ids.Append(666); + ids.Append(667); + + for (TInt j=0; j<2; j++) + { + ExecuteAndDeleteLD( + iCategoryManager->RemoveCategoryFromLandmarksL( + iCategories[KAddCategoryIndex]->CategoryId(), + ids)); + + CheckLandmarksL(); + } + + // Test that RemoveCategoryFromLandmarksL leaves with KErrNotFound if + // category is not found + TRAPD(err, iCategoryManager->ReadCategoryLC(123456)); + if (err != KErrNotFound) + { + iLog->Log(_L("ReadCategoryLC should leave with KErrNotFound")); + User::Leave(err); + + } + TRAP(err, iOperation = iCategoryManager->RemoveCategoryFromLandmarksL(123456 ,ids)); + if (err == KErrNone) + { + delete iOperation; + iOperation = NULL; + iLog->Log(_L("RemoveCategoryFromLandmarksL should leave with KErrNotFound")); + User::Leave(err); + } + if (err != KErrNotFound) + { + iLog->Log(_L("RemoveCategoryFromLandmarksL should leave with KErrNotFound")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryFromSetOfLandmarksAsyncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryFromSetOfLandmarksAsyncL() + { + iLog->Log(_L("Removing set of categories from landmarks asyncronously")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + for (TInt j=0; j<2; j++) + { + + for (i = KAddStartIndexAsync; i <= KAddEndIndexAsync; i++) + { + RunAsyncOperationLD(iCategoryManager->RemoveCategoryFromLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + ids + )); + } + CheckLandmarksL(); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryFromSetOfLandmarksUsingWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryFromSetOfLandmarksUsingWaitForReqL() + { + iLog->Log(_L("Removing set of categories from landmarks using User::WaitForRequest()")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + for (TInt j=0; j<2; j++) + { + + for (i = KAddStartIndexAsync; i <= KAddEndIndexAsync; i++) + { + CPosLmOperation* op = iCategoryManager->RemoveCategoryFromLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + ids); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + CheckLandmarksL(); + } + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::RemoveCategoryFromSetOfLandmarksAsyncAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemoveCategoryFromSetOfLandmarksAsyncAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("Removing set of categories from landmarks asyncronously and cancel")); + RArray ids; + CleanupClosePushL(ids); + + TInt i=0; + for (i=KAddStartIndexAsync; i<=KAddEndIndexAsync; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + for (TInt j=0; j<2; j++) + { + for (i = KAddStartIndexAsync; i <= KAddEndIndexAsync; i++) + { + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD( + iCategoryManager->RemoveCategoryFromLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + ids + )); + } + else + { + RunAsyncOperationAndCancelLD( + iCategoryManager->RemoveCategoryFromLandmarksL( + iCategories[KAddCategoryIndexAsync]->CategoryId(), + ids + )); + } + } + } + + CleanupStack::PopAndDestroy(&ids); + } + +// --------------------------------------------------------- +// CPosTp10::CheckRemoved +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::CheckRemovedL(const TInt aStartIndex, const TInt aStopIndex) + { + _LIT(KRemoveNotFoundErr, "Category has not been removed"); + _LIT(KRemoveFoundErr, "Category should not been removed"); + + for (TInt i = 0; i<=aStopIndex; i++) + { + TRAPD(err, ReadCategoryL(iCategories[i]->CategoryId())); + if (i >= aStartIndex && i <= aStopIndex) + { + AssertTrueSecL(err == KErrNotFound, KRemoveNotFoundErr); + RemovedFromLandmarksInternalL(iCategories[i]->CategoryId()); + } + else + { + AssertTrueSecL(err == KErrNone, KRemoveFoundErr); + } + } + + CheckLandmarksL(); + + } + +// --------------------------------------------------------- +// CPosTp10::RemovedFromLandmarksInternalL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::RemovedFromLandmarksInternalL(TPosLmItemId aCategoryId) + { + for (TInt i = 0; i < iLandmarks.Count(); i++) + { + iLandmarks[i]->RemoveCategory(aCategoryId); + } + } + +// --------------------------------------------------------- +// CPosTp10::ReadCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::ReadCategoryL(TPosLmItemId aCategoryId) + { + CPosLandmarkCategory* lmc = iCategoryManager->ReadCategoryLC(aCategoryId); + CleanupStack::PopAndDestroy(lmc); + } + +// --------------------------------------------------------- +// CPosTp10::TestMissingCategories1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::TestMissingCategories1L() + { + iLog->Log(_L("TestMissingCategories1L")); + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + // copy the test db to the private path + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp10TestDb); + + TInt err = fileMan->Copy(srcPath, KLmTp10DefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp10TestDb); + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KTp10TestDb); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + ExecuteAndDeleteLD(lmd->CompactL()); + + // Remove categories 1,2,3 (Pizzeria, Hamburgerbar, Kinarestaurang) + // Landmark with id=7 "Billigt" contains categories: 1,2,3 and 14-17 + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(categoryManager); + + CPosLandmark* lm = lmd->ReadLandmarkLC(7); + + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(1)); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(2)); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(3)); + + // Change landmark name and update landmark, the server must not crash + lm->SetLandmarkNameL(_L("NyttBilligtNamn")); + + lmd->UpdateLandmarkL(*lm); + + CleanupStack::PopAndDestroy(lm); + lm = lmd->ReadLandmarkLC(7); + + RArray categories; + CleanupClosePushL(categories); + lm->GetCategoriesL(categories); + + // Now list all categories belonging to this landmark + // verify that the removed categories 1,2,3 are no longer referred from this landmark + // Should now only contain 14-17 + if (categories.Count() != 4) + { + iLog->Log(_L("Wrong number of categories")); + User::Leave(-1); + } + + for (TInt i=0;iLog(_L("Wrong number of categories")); + User::Leave(-1); + } + } + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(lm); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(lmd); + } + +// --------------------------------------------------------- +// CPosTp10::TestMissingCategories2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp10::TestMissingCategories2L() + { + iLog->Log(_L("TestMissingCategories2L")); + + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + // copy the test db to the private path + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp10TestDb); + + TInt err = fileMan->Copy(srcPath, KLmTp10DefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp10TestDb); + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KTp10TestDb); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + ExecuteAndDeleteLD(lmd->CompactL()); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(categoryManager); + + // Now create a landmark containing some categories, before adding this landmark to + // the database remove some of the categories from the landmarks database + CPosLandmark* lm = CreateXMLLandmarkLC(_L("PelleFantLandmark")); + // Add categories with id=7, id=14 and id=10 to this landmark + lm->AddCategoryL(7); + lm->AddCategoryL(14); + lm->AddCategoryL(10); + + //Then remove categories id=14 and id=7 from the landmark db + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(14)); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(7)); + + TPosLmItemId id = lmd->AddLandmarkL(*lm); + + CleanupStack::PopAndDestroy(lm); + + lm = lmd->ReadLandmarkLC(id); + + RArray categories; + CleanupClosePushL(categories); + lm->GetCategoriesL(categories); + + // Now list all categories belonging to this landmark + if (categories.Count() != 1) + { + TBuf<50> buf; + buf.Format(_L("Wrong number of categories, was %d should be %d"), categories.Count(), 1); + for (TInt j=0;j buffe; + buffe.Format(_L("%d Category id: %d"), j, categories[j]); + iLog->Log(buffe); + } + iLog->Log(buf); + User::Leave(KErrNone); + } + + for (TInt i=0;iLog(_L("Wrong number of categories")); + User::Leave(-1); + } + } + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(lm); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(lmd); + + } + +// --------------------------------------------------------- +// CPosTp10::BackupTp10DbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp10::BackupTp10DbFileL() + { + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + manager->SetDefaultDatabaseUriL(KTp10TestDb); + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(buf)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(*defaultDbUri, buf); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp10::RestoreTp10DbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp10::RestoreTp10DbFileL() + { + + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + manager->SetDefaultDatabaseUriL(KTp10TestDb); + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(*defaultDbUri)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(buf, *defaultDbUri); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp100.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp100.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,383 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp100.h" +#include +#include +#include +#include "FT_LandmarkConstants.h" + + +// CONSTANTS + +_LIT(KDb1, "eposlm1.ldb"); +_LIT(KDb2, "eposlm2.ldb"); +_LIT(KDb3, "eposlm3.ldb"); + +_LIT(KDbUri1, "file://c:eposlm.ldb"); +_LIT(KDbUri2, "c:eposlm.ldb"); +_LIT(KDbUri3, "eposlm.ldb"); +_LIT(KDbUri4, "file://eposlm.ldb"); +_LIT(KDbUri5, "testlm.ldb"); + +// Use hardcoded path here +_LIT(KDbUri6, "c:\\private\\100012a5\\DBS_101FE978_eposlm.ldb"); +// Use hardcoded path here +_LIT(KDbUri7, "file://c:\\private\\100012a5\\DBS_101FE978_eposlm.ldb"); + +_LIT(KDbUri8, "eposlm"); +_LIT(KDbUri9, "c:eposlm"); +_LIT(KDbUri10, "file://c:eposlm"); + +_LIT(KDbUri11, "file://c:XXXX.ldb"); +_LIT(KDbUri12, "http://c:eposlm.ldb"); +_LIT(KDbUri13, ""); + +_LIT(KDbUri14, "file://\\eposlm.ldb"); // UNC +_LIT(KDbUri15, "\\eposlm.ldb"); + +// File on media that does not exist +_LIT(KDbUri16, "file://R:eposlm.ldb"); + +_LIT(KTestDb, "testlm.ldb"); + +// Will need to be changed to the secure dbms path when security is implemented + + +_LIT(KExportFileFullPath, "c:\\TP100-LandmarksFromThreeDatabases.xml"); +_LIT(KExportFile, "TP100-LandmarksFromThreeDatabases.xml"); + +// ================= MEMBER FUNCTIONS ======================= + + + +// --------------------------------------------------------- +// CPosTp100::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::StartL() + { + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDefaultDb); + manager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + // This db must exist + manager->SetDefaultDatabaseUriL(KDefaultDb); + + + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + delete lmd; + + TestOpenSpecificDbL(); + + TestMultipleExportL(); + + TestLockedDatabaseL(); + } + +// --------------------------------------------------------- +// CPosTp100::TestMultipleExportL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::TestMultipleExportL() + { + iLog->Log(_L("TestMultipleExportL()")); + CreateDatabasesL(); + iLog->Log(_L("1")); + + CPosLandmarkDatabase* lmd1 = CPosLandmarkDatabase::OpenL(KDb1); + CleanupStack::PushL(lmd1); + iLog->Log(_L("2")); + CPosLandmarkDatabase* lmd2 = CPosLandmarkDatabase::OpenL(KDb2); + CleanupStack::PushL(lmd2); + iLog->Log(_L("3")); + CPosLandmarkDatabase* lmd3 = CPosLandmarkDatabase::OpenL(KDb3); + CleanupStack::PushL(lmd3); + ExecuteAndDeleteLD(lmd3->CompactL()); + iLog->Log(_L("4")); + CPosLandmark* lm = CreateXMLLandmarkLC(_L("TP100 - LM with all fields set")); + AddAllXMLFieldsL(lm); + iLog->Log(_L("5")); + lmd1->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + iLog->Log(_L("6")); + CPosLandmark* lm2 = CreateXMLLandmarkLC(_L("TP100 - LM2")); + lmd2->AddLandmarkL(*lm2); + CleanupStack::PopAndDestroy(lm2); + iLog->Log(_L("7")); + CPosLandmark* lm3 = CreateXMLLandmarkLC(_L("TP100 - LM3")); + iLog->Log(_L("8")); + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd3); + CleanupStack::PushL(cm); + iLog->Log(_L("9")); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("category")); + + TPosLmItemId id = cm->AddCategoryL(*category); + CleanupStack::PopAndDestroy(2, cm); + iLog->Log(_L("10")); + lm3->AddCategoryL(id); + iLog->Log(_L("11")); + + iLog->Log(_L("12")); + lmd3->AddLandmarkL(*lm3); + CleanupStack::PopAndDestroy(lm3); + iLog->Log(_L("13")); + + CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + CleanupStack::PushL(encoder); + + encoder->SetOutputFileL(KExportFileFullPath); + + CPosLmItemIterator* iter = lmd1->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + ExecuteAndDeleteLD(lmd1->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions)); + + RunAsyncOperationLD(lmd2->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions)); + + ExecuteAndDeleteLD(lmd3->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories)); + + ExecuteAndDeleteLD(encoder->FinalizeEncodingL()); + + CleanupStack::PopAndDestroy(6, lmd1); + + TInt err = CompareL(KExportFile); + AssertTrueSecL(err == KErrNone, _L("The exported file is not equal to file exported prevoius release")); + } + +// --------------------------------------------------------- +// CPosTp100::CreateDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::CreateDatabasesL() + { + iLog->Log(_L("CreateDatabasesL()")); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CleanupStack::PopAndDestroy(lmd); + + TInt res = iFileSession.Delete(KExportFileFullPath); + if (res != KErrNone && res != KErrNotFound) + { + iLog->Log(_L("File could not be deleted")); + User::Leave(res); + + } + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + TBuf<150> destPath; + + srcPath.Append(KLmDbPath); + srcPath.Append(KDefaultDb); + + // Copy file eposlm.ldb to three databases + destPath.Append(KLmDbPath); + destPath.Append(KDb1); + User::LeaveIfError(fileMan->Copy(srcPath, destPath, CFileMan::EOverWrite)); + + destPath.Zero(); + destPath.Append(KLmDbPath); + destPath.Append(KDb2); + User::LeaveIfError(fileMan->Copy(srcPath, destPath, CFileMan::EOverWrite)); + + destPath.Zero(); + destPath.Append(KLmDbPath); + destPath.Append(KDb3); + User::LeaveIfError(fileMan->Copy(srcPath, destPath, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + } + +// --------------------------------------------------------- +// CPosTp100::TestOpenSpecificDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::TestOpenSpecificDbL() + { + _LIT(KHttpErr, "http is not a supported protocol"); + _LIT(KURIErr, "Not a valid URI"); + _LIT(KArgumentErr, "An empty descr is not a valid URI"); + + iLog->Log(_L("TestOpenSpecificDbL()")); + + TestOpenDbL(KDbUri1); + TestOpenDbL(KDbUri2); + TestOpenDbL(KDbUri3); + TestOpenDbL(KDbUri4); + + // Copy to secure area + CopyTestDbFileL(KTestDb); + + TestOpenDbL(KDbUri5); + + TRAPD(err, TestOpenDbL(KDbUri6)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri7)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri8)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri9)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri10)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri11)); + AssertTrueSecL(err == KErrNotFound, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri12)); + AssertTrueSecL(err == KErrNotSupported, KHttpErr); + + TRAP(err, TestOpenDbL(KDbUri13)) + AssertTrueSecL(err == KErrArgument, KArgumentErr); + + TRAP(err, TestOpenDbL(KDbUri14)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri15)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri16)); + AssertTrueSecL(err == KErrNotReady, KURIErr); + } + +// --------------------------------------------------------- +// CPosTp100::TestOpenDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::TestOpenDbL(const TDesC& aDbURI) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(aDbURI); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CleanupStack::PopAndDestroy(lmd); + } + +// --------------------------------------------------------- +// CPosTp100::TestLockedDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp100::TestLockedDatabaseL() + { + iLog->Log(_L("TestLockedDatabaseL()")); + + CPosLandmarkDatabase* db1 = UseGeneratedDbFileL(); + CleanupStack::PushL(db1); + + // Take read lock + RArray ids; + CleanupClosePushL(ids); + User::LeaveIfError(ids.Append(1)); + User::LeaveIfError(ids.Append(3)); + User::LeaveIfError(ids.Append(4)); + User::LeaveIfError(ids.Append(6)); + User::LeaveIfError(ids.Append(7)); + User::LeaveIfError(ids.Append(9)); + User::LeaveIfError(ids.Append(24)); + User::LeaveIfError(ids.Append(14)); + User::LeaveIfError(ids.Append(66)); + User::LeaveIfError(ids.Append(61)); + User::LeaveIfError(ids.Append(14)); + CPosLmOperation* operation = db1->PreparePartialLandmarksL(ids); + CleanupStack::PushL(operation); + TReal32 progress(0); + TRequestStatus status; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle + operation->NextStep(status, progress); + CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(KDbUri1); + delete db2; + User::WaitForRequest(status); + + // Release read lock + CleanupStack::PopAndDestroy(operation); + + // Take write lock + operation = db1->RemoveAllLandmarksL(); + CleanupStack::PushL(operation); + progress = 0; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle - should result in KErrLocked + operation->NextStep(status, progress); + db2 = NULL; + TRAPD(err, db2 = CPosLandmarkDatabase::OpenL(KDbUri1)); + delete db2; + User::WaitForRequest(status); + AssertTrueSecL(err == KErrLocked, _L("OpenL() didn't result in KErrLocked but in %d"), err); + + CleanupStack::PopAndDestroy(3, db1); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp101.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp101.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1245 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp101.h" +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include + +// CONSTANTS +const TInt KNrOfDbs = 5; +const TInt KLmPerDb = 20; +const TInt KTotLms = 105; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp101::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + delete iDbArray; + + delete iLmMultiSearch; + iLmMultiSearch = NULL; + + iSearchResults.ResetAndDestroy(); + + REComSession::FinalClose(); + } + +// --------------------------------------------------------- +// CPosTp101::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::StartL() + { + // Split databases, NrOfDBs db, LmPerDb lm in each, TotLms is last lm id from original db, debug + iDbArray = CreateDatabasesL(KNrOfDbs, KLmPerDb, KTotLms); //, ETrue); + + + // Check setting of databases is correct + // Should be move to TC119 - Multi Db - Extended testing + VerifySetOfDatabasesL(); + + // Constructing a lm multi search + iLmMultiSearch = CPosLmMultiDbSearch::NewL(*iDbArray); + + // Check that iterator is NOT NULL before search has started (and that iterator is empty) + for (TInt i=0;iCount();i++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(i); + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == 0, _L("Iterator should be empty")); + CleanupStack::PopAndDestroy(iter); + } + + // Read search information from file + AppendSearchResultsL(); + + // Do the search testing + iLog->Log(_L("Testing multi db search with criterias read from LmDbSearchResult.txt syncronously")); + SearchL(iSearchResults, ESynchronous); + + iLog->Log(_L("Testing multi db search with criterias read from LmDbSearchResult.txt asyncronously")); + SearchL(iSearchResults, EAsynchronous); + + // Not possible to use User::WaitForRequest when using Multi Db search! + // iLog->Log(_L("Testing multi db search with criterias read from LmDbSearchResult.txt asyncronously using User::WaitForRequest")); + // SearchL(SearchResults(), EWaitForRequest); + + iLog->Log(_L("Testing search with a defined sortorder")); + SearchWithSortOrderL(iSearchResults); + + iLog->Log(_L("Testing search and cancel")); + SearchAndCancelL(); + + iLog->Log(_L("Testing maximum number of matches")); + SearchWithMaximumL(iSearchResults); + + iLog->Log(_L("Testing searching on the fly")); + OnTheFlySearchL(); + + iLog->Log(_L("Testing search after a landmark has been removed")); + SearchAndDeleteL(iSearchResults); + + iLog->Log(_L("Testing search after landmarks have been renamed")); + SearchAndRenameL(iSearchResults); + + + // Test specific Text Criteria error case + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetAttributesToSearch(attr); + textCriteria->SetTextL(_L("")); + + _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); + TRAPD(err, iLmMultiSearch->StartLandmarkSearchL(*textCriteria)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + + CleanupStack::PopAndDestroy(textCriteria); + + delete iLmMultiSearch; + iLmMultiSearch = NULL; + // Constructing a lm multi search + iLmMultiSearch = CPosLmMultiDbSearch::NewL(*iDbArray); + + // Check that iterator is NOT NULL before search has started (and that iterator is empty) + for (TInt i=0;iCount();i++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(i); + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == 0, _L("Iterator should be empty")); + CleanupStack::PopAndDestroy(iter); + } + } + +// --------------------------------------------------------- +// CPosTp101::VerifySetOfDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::VerifySetOfDatabasesL() + { + // Testing error situations for multi db search + _LIT(KEmptyError, "KErrArgument should be returned when no db's are specified."); + CDesCArray* emptyArray = new (ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(emptyArray); + TRAPD(err, CPosLmMultiDbSearch::NewL(*emptyArray)); + AssertTrueSecL(err == KErrArgument, KEmptyError); + + CDesCArray* duplicateArray = new (ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(duplicateArray); + + duplicateArray->AppendL(_L("eposlm.ldb")); + duplicateArray->AppendL(_L("c:eposlm.ldb")); + duplicateArray->AppendL(_L("file://c:eposlm.ldb")); + + VerifyDatabaseL(duplicateArray); + + duplicateArray->Reset(); + duplicateArray->AppendL(_L("eposlm.ldb")); + duplicateArray->AppendL(_L("eposlm.ldb")); + duplicateArray->AppendL(_L("eposlm.ldb")); + + VerifyDatabaseL(duplicateArray); + + CDesCArray* dupArray = new (ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(dupArray); + dupArray->AppendL(_L("eposlm.ldb")); + dupArray->AppendL(_L("eposlm.ldb")); + dupArray->AppendL(_L("eposlm.ldb")); + dupArray->AppendL(_L("eposlm.ldb")); + + VerifyDatabaseL(duplicateArray, dupArray); + + dupArray->Reset(); + dupArray->AppendL(_L("eposlm.ldb")); + dupArray->AppendL(_L("eposlm.ldb")); + + VerifyDatabaseL(duplicateArray, dupArray); + + CleanupStack::PopAndDestroy(dupArray); + CleanupStack::PopAndDestroy(duplicateArray); + + // Check setting of empty databases + iLmMultiSearch = CPosLmMultiDbSearch::NewL(*iDbArray); + + TRAP(err, iLmMultiSearch->SetDatabasesToSearchL(*emptyArray)); + AssertTrueSecL(err == KErrArgument, KEmptyError); + CleanupStack::PopAndDestroy(emptyArray); + delete iLmMultiSearch; + + VerifyDatabaseL(iDbArray); + } + +// --------------------------------------------------------- +// CPosTp101::VerifyDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::VerifyDatabaseL( + CDesCArray* aLmUris, + CDesCArray* aNewLmUris) + { + iLmMultiSearch = CPosLmMultiDbSearch::NewL(*aLmUris); + CheckDatabasesL(aLmUris); + + if (aNewLmUris) + { + iLmMultiSearch->SetDatabasesToSearchL(*aNewLmUris); + CheckDatabasesL(aNewLmUris); + } + + delete iLmMultiSearch; + } + +// --------------------------------------------------------- +// CPosTp101::CheckDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::CheckDatabasesL( + CDesCArray* aExpectedLmUris, + TUint aExpectedMaxMatches) + { + CDesCArray* dbToSearch = iLmMultiSearch->DatabasesToSearchL(); + CleanupStack::PushL(dbToSearch); + + _LIT(KWrongNrDatabases, "Wrong number of databases to search!"); + AssertTrueSecL(aExpectedLmUris != dbToSearch, KWrongNrDatabases); + AssertTrueSecL(aExpectedLmUris->Count() == dbToSearch->Count(), KWrongNrDatabases); + CleanupStack::PopAndDestroy(dbToSearch); + + AssertTrueSecL(aExpectedLmUris->Count() == iLmMultiSearch->NumOfDatabasesToSearch(), + KWrongNrDatabases); + for (TInt i=0; iCount(); i++) + { + AssertTrueSecL(aExpectedLmUris->MdcaPoint(i) == iLmMultiSearch->DatabaseUriPtr(i), + KWrongNrDatabases); + } + + _LIT(KWrongNrMatches, "Wrong number of max matches!"); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == aExpectedMaxMatches, + KWrongNrMatches); + } + +// --------------------------------------------------------- +// CPosTp101::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + _LIT(KSearchNr, "Multi search test #%d executed ok."); + + for(TInt i=0; iSetTextL(aSearchResults[i]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[i]->Attributes()); + + textCriteria->SetPositionFieldsToSearchL(aSearchResults[i]->PositionFields()); + + CPosLmOperation* operation = + iLmMultiSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[i]->Redefined()); + CleanupStack::PushL(operation); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(operation); + CleanupStack::Pop(operation); + break; + case EAsynchronous: + RunAsyncOperationLD(operation); + CleanupStack::Pop(operation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(operation); + CleanupStack::PopAndDestroy(operation); + break; + } + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + // Check total number of matches + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != + iLmMultiSearch->TotalNumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLmMultiSearch->TotalNumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + RArray lmids; + CleanupClosePushL(lmids); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr); + User::LeaveIfError(lmids.Append(id)); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + } + + AssertTrueSecL(aSearchResults[i]->SearchResult().Count() == lmids.Count(), + _L("Expected number of hits and found hits don't match")); + + for (TInt k=0; kFindSearchResult(lmids[k]), KNotFoundErr); + } + + CleanupStack::PopAndDestroy(&lmids); // lmids + + CleanupStack::PopAndDestroy(textCriteria); + + TBuf<100> buf; + buf.Format(KSearchNr, i); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp101::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchWithSortOrderL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed syncronously"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + + iLog->Log(aSearchResults[j]->TextCriteria()); + + for (TInt i=0; i<4; i++) + { + switch (i) + { + //**** sync + case 0: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 1: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 2: + //**** async + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + RunAsyncOperationLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 3: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + RunAsyncOperationLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + //**** asych with User::WaitForRequest() + case 4: + { + CPosLmOperation* op = iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + case 5: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmOperation* op = iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + } + } + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + // Check total number of matches + if ((TUint)(aSearchResults[j]->SearchResult()).Count() != + iLmMultiSearch->TotalNumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[j]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLmMultiSearch->TotalNumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + RArray* searchResults = &aSearchResults[j]->SearchResult(); + for (TInt n=0; nNumOfDatabasesToSearch(); n++) + { + RArray lmids; + CleanupClosePushL(lmids); + GetLmIdsL(n, *searchResults, lmids); + + iDatabase = CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(n)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + LandmarksSortL(lmids, sortPref); + + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(n); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TInt lmid = 0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CheckEqualsLmsL(id, lmids[lmid]); + + id = iter->NextL(); + ++lmid; + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + + CleanupStack::PopAndDestroy(&lmids); + } + + } + + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp101::GetLmIdsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::GetLmIdsL( + TInt aDbId, + RArray aSearchResults, + RArray& aLmIdForADb) + { + TInt startId = aDbId * KLmPerDb + 1; + TInt stopId = 0; + + if (aDbId == KNrOfDbs - 1) + { + stopId = KTotLms; + } + else + { + stopId = (aDbId+1) * KLmPerDb; + } + + for (TInt i=0; i= startId && aSearchResults[i] <= stopId) + { + User::LeaveIfError(aLmIdForADb.Append(aSearchResults[i])); + } + } + } + +// --------------------------------------------------------- +// CPosTp101::CheckEqualsLmsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::CheckEqualsLmsL( + TPosLmItemId aSource, + TPosLmItemId aTarget) + { + _LIT(KSortorderErr, "The sortorder is incorrect"); + + if (aSource != aTarget) + { + // Check if same name then don't Leave + CPosLandmark* source = iDatabase->ReadLandmarkLC(aSource); + CPosLandmark* target = iDatabase->ReadLandmarkLC(aTarget); + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + if (EFalse) + { + // For debugging purposes + TBuf<100> buf; + buf.Append(_L("Name:")); + buf.Append(sourceName); + buf.Append(targetName); + iLog->Log(buf); + } + + AssertTrueSecL(!sourceName.CompareC(targetName), KSortorderErr, aSource); + CleanupStack::PopAndDestroy(2, source); // target, source + } + } + +// --------------------------------------------------------- +// CPosTp101::OnTheFlySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::OnTheFlySearchL() + { + TInt KTestIndex = 4; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(iSearchResults[KTestIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(iSearchResults[KTestIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(iSearchResults[KTestIndex]->PositionFields()); + + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + onTheFlyTester->StartSearchCampaignL(iLmMultiSearch, + iSearchResults[KTestIndex]->SearchResult(), + textCriteria); + + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + iLog->Log(msg); + User::Leave(result); + } + + CleanupStack::PopAndDestroy(2, textCriteria); + + iLmMultiSearch->UnsetDisplayData(); + } + +// --------------------------------------------------------- +// CPosTp101::SearchAndDeleteL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchAndDeleteL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + const TInt KTestIndex = 11; + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(aSearchResults[KTestIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[KTestIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[KTestIndex]->PositionFields()); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + + RArray* searchResults = &aSearchResults[KTestIndex]->SearchResult(); + + TPosLmItemId lmid = (*searchResults)[0]; + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + iDatabase->RemoveLandmarkL(lmid); + searchResults->Remove(0); + searchResults->Compress(); + delete iDatabase; + iDatabase = NULL; + + // Search + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria, sortPref, ETrue)); + + // Check result + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint)searchResults->Count() == iLmMultiSearch->TotalNumOfMatches(), + KNumOfMatchesErr); + + RArray lmids; + CleanupClosePushL(lmids); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(aSearchResults[KTestIndex]->FindSearchResult(id), KNotFoundErr); + User::LeaveIfError(lmids.Append(id)); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + } + + AssertTrueSecL(aSearchResults[KTestIndex]->SearchResult().Count() == lmids.Count(), + _L("Expected number of hits and found hits don't match")); + + for (TInt k=0; kFindSearchResult(lmids[k]), KNotFoundErr); + } + + CleanupStack::PopAndDestroy(&lmids); // lmids + + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp101::SearchAndRenameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchAndRenameL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + const TInt KTestIndex=4; + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(aSearchResults[KTestIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[KTestIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[KTestIndex]->PositionFields()); + + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + + RArray* searchResults = &aSearchResults[KTestIndex]->SearchResult(); + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint) searchResults->Count() == + iLmMultiSearch->TotalNumOfMatches(), KNumOfMatchesErr); + + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + + _LIT(KLmName, "l"); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + iDatabase = + CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(j)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(aSearchResults[KTestIndex]->FindSearchResult(id), + KNotFoundErr); + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + + TBuf<30> lmName; + lmName = KLmName; + lm->SetLandmarkNameL(lmName); + iDatabase->UpdateLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + } + + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria, sortPref, ETrue)); + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint) searchResults->Count() == + iLmMultiSearch->TotalNumOfMatches(), KNumOfMatchesErr); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + iDatabase = + CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(j)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(aSearchResults[KTestIndex]->FindSearchResult(id), + KNotFoundErr); + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + + TPtrC16 lmName; + lm->GetLandmarkName(lmName); + AssertTrueSecL(lmName == KLmName, _L("Wrong landmark name")); + + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + } + + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp101::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchAndCancelL(const TBool& aInCallback) + { + // Test search with one criteria + const TInt KIndex=0; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(iSearchResults[KIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(iSearchResults[KIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(iSearchResults[KIndex]->PositionFields()); + + if (aInCallback) + { + TReal threshold = 0; + for (TReal i=0; i<100; i+=10) + { + threshold = i/100; + RunAsyncOperationAndCancelInCallbackLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, iSearchResults[KIndex]->Redefined()), threshold); + + _LIT(KCancelNr, "Multi search test, cancel after progress %f, canceled ok."); + TBuf<100> buf; + buf.Format(KCancelNr, threshold); + iLog->Log(buf); + } + } + else + { + RunAsyncOperationAndCancelLD(iLmMultiSearch->StartLandmarkSearchL( + *textCriteria, iSearchResults[KIndex]->Redefined())); + } + + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp101::SearchWithMaximumL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp101::SearchWithMaximumL( + const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchWithMaximumL is performed"); + + // Test search with one criteria + const TInt KTestIndex = 0; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(iSearchResults[KTestIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(iSearchResults[KTestIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(iSearchResults[KTestIndex]->PositionFields()); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + + // First get the maximum number of matches + TInt maxMatches = KNrOfDbs; + iLmMultiSearch->SetMaxNumOfMatches(maxMatches); + _LIT(KErrNrOfMatches, "Number of matches is incorrect"); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + RArray* searchResults = &aSearchResults[KTestIndex]->SearchResult(); + TInt totalMatches = iLmMultiSearch->TotalNumOfMatches(); + + // Check database array + CheckDatabasesL(iDbArray, maxMatches); + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + // Check that nr is not expected number of results + AssertTrueSecL((TUint) searchResults->Count() != + totalMatches, KNumOfMatchesErr); + + for (TInt n=0; nNumOfDatabasesToSearch(); n++) + { + RArray lmids; + CleanupClosePushL(lmids); + GetLmIdsL(n, *searchResults, lmids); + + iDatabase = CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(n)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + LandmarksSortL(lmids, sortPref); + + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(n); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == iLmMultiSearch->NumOfMatches(n), + KNumOfMatchesErr); + + TInt lmid = 0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CheckEqualsLmsL(id, lmids[lmid]); + + id = iter->NextL(); + ++lmid; + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + + CleanupStack::PopAndDestroy(&lmids); + } + + // Test max matches again + TInt incMatches = 2; + maxMatches = maxMatches + incMatches; + iLmMultiSearch->SetMaxNumOfMatches(maxMatches); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*textCriteria)); + + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + TInt reTotalMatches = iLmMultiSearch->TotalNumOfMatches(); + + AssertTrueSecL(reTotalMatches != totalMatches, + _L("Total number of matches should not be that same.")); + + // Check database array + CheckDatabasesL(iDbArray, maxMatches); + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + // Check that nr is not expected number of results + AssertTrueSecL((TUint) searchResults->Count() != + reTotalMatches, KNumOfMatchesErr); + + CleanupStack::PopAndDestroy(textCriteria); + + // Unset max number of matches to normal/unlimited again + iLmMultiSearch->SetMaxNumOfMatches(); + } + +// --------------------------------------------------------- +// CPosTp101::CreateDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CDesCArray* CPosTp101::CreateDatabasesL(TInt aNrOfLmDbs, TInt aLmPerDb, + TInt aLastId, TBool aDebug) + { + + CDesCArray* iDbArray = new (ELeave) CDesCArrayFlat(aNrOfLmDbs); + CleanupStack::PushL(iDbArray); + + RemoveDefaultDbL(); + + // Populate default db + iDatabase = UseGeneratedDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + ExecuteAndDeleteLD(iDatabase->CompactL()); + delete iDatabase; + iDatabase = NULL; + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + // Create databases + TInt i=0; + for (i=1; i < aNrOfLmDbs; i++) + { + TBuf<100> db; + db.Format(KDbNamePath, i * aLmPerDb); + + iFileSession.Delete(db); + User::LeaveIfError(fileMan->Copy(KLmFullDefaultDbPath, db, CFileMan::EOverWrite)); + } + CleanupStack::PopAndDestroy(fileMan); + + for (TInt db=0; db < aNrOfLmDbs; db++) + { + TInt dbform = db; + if (db == aNrOfLmDbs) + { + dbform = aNrOfLmDbs - 1; + } + + CPosLandmarkDatabase* lmd = NULL; + TBuf<100> name; + if (db == 0) + { + _LIT(KDefLmDb, "eposlm.ldb"); + name = KDefLmDb; + lmd = CPosLandmarkDatabase::OpenL(); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + } + else + { + name.Format(KDbName, dbform * aLmPerDb); + lmd = CPosLandmarkDatabase::OpenL(name); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + } + CleanupStack::PushL(lmd); + // Append db name to array + iDbArray->AppendL(name); + + if (aDebug) + { + iLog->Log(name); + } + + TInt startItemid = dbform * aLmPerDb + 1; + TInt stopItemid = dbform * aLmPerDb + aLmPerDb; + if (dbform == aNrOfLmDbs - 1) + { + stopItemid = aLastId; + } + + for (TInt lmid=1; lmid <= aLastId; lmid++) + { + TBuf<100> lmidbuf; + + if (aDebug) + { + _LIT(KLmId, "Landmark with LmId: %d"); + lmidbuf.Format(KLmId, lmid); + iLog->Log(lmidbuf); + } + + if (lmid < startItemid || lmid > stopItemid) + { + if (aDebug) + { + _LIT(KDelLmId, "Removing LmId: %d"); + lmidbuf.Format(KDelLmId, lmid); + iLog->Log(lmidbuf); + } + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, lmd->RemoveLandmarkL(lmid)); + } + } + } + + // Compact database + ExecuteAndDeleteLD(lmd->CompactL()); + CleanupStack::PopAndDestroy(lmd); + } + + // Log/print landmark databases. + if (aDebug) + { + // DEBUG + for (i=0; i < aNrOfLmDbs; i++) + { + TBuf<100> dbNo; + dbNo.Format(_L(" -------- Printing Db %d --------------"), i); + iLog->Log(dbNo); + + CPosLandmarkDatabase* lmd = NULL; + if (i == 0) + { + _LIT(KDbDefName, "Default Lm DB"); + iLog->Log(KDbDefName); + lmd = CPosLandmarkDatabase::OpenL(); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + else + { + TInt dbform = i; + if (i == 5) + { + dbform = 4; + } + + TBuf<100> db; + db.Format(KDbName, dbform * aLmPerDb); + iLog->Log(db); + + lmd = CPosLandmarkDatabase::OpenL(db); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + CleanupStack::PushL(lmd); + CPosLmCategoryManager* lmcat = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(lmcat); + + CPosLmItemIterator* iter = lmd->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + _LIT(KNrLms, "Nr of Lms: %d"); + TBuf<20> lms; + lms.Format(KNrLms, iter->NumOfItemsL()); + iLog->Log(lms); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = lmd->ReadLandmarkLC(id); + + TBuf<255> info; + PrintLandmark(*lm, info); + iLog->Log(info); + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(iter); + + CPosLmItemIterator* catiter = lmcat->CategoryIteratorL(); + CleanupStack::PushL(catiter); + + _LIT(KNrLmCats, "Nr of Lm Cats: %d"); + TBuf<20> lmcats; + lmcats.Format(KNrLmCats, catiter->NumOfItemsL()); + iLog->Log(lmcats); + + id = catiter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmarkCategory* cat = lmcat->ReadCategoryLC(id); + + TBuf<255> info; + // PrintLandmark(*lm, info); + _LIT(KCatId, "Category id: %d"); + _LIT(KCatGlobalId, "Global Category id: %d"); + _LIT(KCatName, "Category name: %S"); + + info.Format(KCatId, cat->CategoryId()); + iLog->Log(info); + + info.Format(KCatGlobalId, cat->GlobalCategory()); + iLog->Log(info); + + TPtrC catname; + TInt err = cat->GetCategoryName(catname); + info.Format(KCatName, &catname); + iLog->Log(info); + + CleanupStack::PopAndDestroy(cat); + + id = catiter->NextL(); + } + + + CleanupStack::PopAndDestroy(3, lmd); // catiter, lmcat + } + } + + CleanupStack::Pop(iDbArray); + return iDbArray; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp102.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp102.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,806 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp102.h" +#include +#include +#include "FT_DatabaseUtility.h" +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp102::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp102::CloseTest() + { + iLog->Log(_L("CloseTest")); + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("RemoveAllLmDatabasesL() leaved")); + + } + +// --------------------------------------------------------- +// CPosTp102::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp102::StartL() + { + _LIT(KDatabase1, "Tp102_Database1.ldb"); + _LIT(KDatabaseUri1, "file://C:Tp102_Database1.ldb"); + _LIT(KDatabase1MissingProtocol, "C:Tp102_Database1.ldb"); + _LIT(KDatabase1MissingDrive, "Tp102_Database1.ldb"); + _LIT(KDatabase1MissingExtension, "C:Tp102_Database1"); + _LIT(KDatabase1FullPath, "c:\\private\\100012a5\\DBS_101FE978_Tp102_Database1.ldb"); + _LIT(KRemoteDatabaseUri, "http://c:eposlm.ldb"); + _LIT(KDatabase3, "C:Tp102_DBMS_Database3.ldb"); + _LIT(KDatabaseUri3, "file://C:Tp102_DBMS_Database3.ldb"); + // Change here if path to private area ever changes + _LIT(KDatabase4FullPath, "c:\\private\\100012a5\\DBS_101FE978_Tp102_DefaultDatabase.ldb"); + _LIT(KDatabase4, "Tp102_DefaultDatabase.ldb"); + _LIT(KDatabaseUri4, "file://C:Tp102_DefaultDatabase.ldb"); + + _LIT(KDatabaseUri5, "file://R:NonExistingDrive.ldb"); + +#ifdef __WINS__ + // D on wins + _LIT(KDbOnMedia, "D:TP102EPOSLM.LDB"); + _LIT(KDbOnMediaUri, "file://D:TP102EPOSLM.LDB"); + + _LIT(KDbOnMedia2, "D:TP102EPOSLM_2.LDB"); + _LIT(KDbOnMedia2Uri, "file://D:TP102EPOSLM_2.LDB"); + _LIT(KDbOnMedia2MissingDrive, "file://TP102EPOSLM_2.LDB"); +#else + + _LIT(KDbOnMedia, "F:TP102EPOSLM.LDB"); + _LIT(KDbOnMediaUri, "file://F:TP102EPOSLM.LDB"); + + _LIT(KDbOnMedia2, "F:TP102EPOSLM_2.LDB"); + _LIT(KDbOnMedia2Uri, "file://F:TP102EPOSLM_2.LDB"); + _LIT(KDbOnMedia2MissingDrive, "file://TP102EPOSLM_2.LDB"); +#endif + + _LIT(KEmptyURI, ""); + + iLog->Log(_L("Warning: this test case requires E: drive")); + + TInt err=KErrNone; + + RemoveAllLmDatabasesL(); + // Create defaultdb + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); + dbManager->CreateDatabaseL(*dbInfo4); + CleanupStack::PopAndDestroy(dbInfo4); + dbManager->SetDefaultDatabaseUriL(KDatabase4); + + // 1) Remove all landmark db + RemoveAllLmDatabasesL(); + + // check the count of databases that could not be delted since they were in use + CDesCArray* dbList = dbManager->ListDatabasesLC(); + TInt count = dbList->Count(); + + + // 2) Verify no *.ldb files on file system + VerifyNrOfDatabasesL(count); + + // 3) Check default db + HBufC* defaultDbUri; + defaultDbUri = dbManager->DefaultDatabaseUriLC(); + + // 4) List all database, should return 0 + VerifyNrOfDatabasesL(count); + + // 5) Check that database does not exist + if (dbManager->DatabaseExistsL(KDatabaseUri1)) + { + + iLog->Log(_L("This database should not exist")); + User::Leave(-1); + } + + // 6) Create a new database using db api + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + dbManager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + + // 7) List dbs, should contain db created in step6 + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + if (dbArray->Count() != count+1) + { + iLog->Log(_L("Database does not contain the last created db")); + User::Leave(-1); + } + + iLog->Log((*dbArray)[0]); + // 8) Check that dabase does not exist + if (!dbManager->DatabaseExistsL(KDatabaseUri1)) + { + + iLog->Log(_L("This database should exist")); + User::Leave(-1); + } + CleanupStack::PopAndDestroy(dbArray); + + // 9) + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(KDatabaseUri1); + CleanupStack::PushL(db1); + if (db1->IsInitializingNeeded()) + { + iLog->Log(_L("db1->InitializeL")); + ExecuteAndDeleteLD(db1->InitializeL()); + } + CleanupStack::PopAndDestroy(db1); + + + CleanupStack::PopAndDestroy(defaultDbUri); + + // 11) Open the default db + CPosLandmarkDatabase* defaultDatabase = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(defaultDatabase); + + iLog->Log(_L("12) List all databases")); + // 12) List all databases + TInt verifyDbCount = count +2; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri4); + + // 13) + iLog->Log(_L("13) Does defaultDB exist")); + if (!dbManager->DatabaseExistsL(KDatabaseUri4)) + { + + iLog->Log(_L("The default database should have been created")); + User::Leave(-1); + } + + // 14) Try to delete the physical file while db is open + + // Fix this path + err = iFileSession.Delete(KDatabase4FullPath); + if (err != KErrInUse) + { + + iLog->Log(_L("It was possible to delete default db from file system")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(defaultDatabase); + + // 15) Create a landmark database using the DBMS API + iLog->Log(_L("15) Create a landmark database using the DBMS API")); + FTDatabaseUtility::CreateDatabaseL(KDatabase3); + // 16) + verifyDbCount = count +3; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri3); + + // 17) Create a database on a removable media + iLog->Log(_L("17) Create a database on a removable media")); + HPosLmDatabaseInfo* dbInfoMedia = HPosLmDatabaseInfo::NewLC(KDbOnMedia); + dbManager->CreateDatabaseL(*dbInfoMedia); + CleanupStack::PopAndDestroy(dbInfoMedia); + + // 18) Verify database + verifyDbCount = count + 4; + VerifyNrOfDatabasesL(verifyDbCount, KDbOnMediaUri); + + // 19) Retrieve the display name for the default db, it should be different from actual the filename + iLog->Log(_L("19) Retrieve the display name for the default db, it should be different from actual the filename")); + HBufC* defUri = dbManager->DefaultDatabaseUriLC(); + HPosLmDatabaseInfo* dbInfoReadback = HPosLmDatabaseInfo::NewLC(*defUri); + dbManager->GetDatabaseInfoL(*dbInfoReadback); + TPosLmDatabaseSettings settings = dbInfoReadback->Settings(); + TPtrC name1 = settings.DatabaseName(); + CleanupStack::PopAndDestroy(dbInfoReadback); + CleanupStack::PopAndDestroy(defUri); + + + // 20) Set a new db as default + dbManager->SetDefaultDatabaseUriL(KDbOnMediaUri); + + // 21) Retrieve the display name for the new default db, should be the same as in step 19 + iLog->Log(_L("21) Retrieve the display name for the new default db, should be the same as in step 19")); + dbInfoReadback = HPosLmDatabaseInfo::NewLC(KDbOnMediaUri); + dbManager->GetDatabaseInfoL(*dbInfoReadback); + TPosLmDatabaseSettings settings2 = dbInfoReadback->Settings(); + TPtrC name2 = settings2.DatabaseName(); + CleanupStack::PopAndDestroy(dbInfoReadback); + + if (name1.Compare(name2) != 0) + { + iLog->Log(_L("Names does not match")); + User::Leave(-1); + } + + _LIT(KFileColonSlashSlash, "file://"); + _LIT(KCColonSomeTestDbDotLdb, "c:SomeTestDb.ldb"); + _LIT(KFileColonSlashSlashSomeTestDb2DotLdb, "file://SomeTestDb2.ldb"); + _LIT(KCColonSomeTestDb3DotDoc, "c:SomeTestDb3.doc"); + _LIT(KEmptyString, ""); + _LIT(KFileColonSlahSlashCColonDotLdb, "file://C:.LDB"); + _LIT(KVeryLongString, "c:\\SomeVeryLongFilename1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.ldb"); + + HPosLmDatabaseInfo* dbInfoFileColonSlashSlash = HPosLmDatabaseInfo::NewLC(KFileColonSlashSlash); + HPosLmDatabaseInfo* dbInfoCColonSomeTestDbDotLdb = HPosLmDatabaseInfo::NewLC(KCColonSomeTestDbDotLdb); + HPosLmDatabaseInfo* dbInfoFileColonSlashSlashSomeTestDb2DotLdb = HPosLmDatabaseInfo::NewLC(KFileColonSlashSlashSomeTestDb2DotLdb); + HPosLmDatabaseInfo* dbInfoCColonSomeTestDb3DotDoc = HPosLmDatabaseInfo::NewLC(KCColonSomeTestDb3DotDoc); + HPosLmDatabaseInfo* dbInfoEmptyString = HPosLmDatabaseInfo::NewLC(KEmptyString); + HPosLmDatabaseInfo* dbInfoFileColonSlahSlashCColonDotLdb = HPosLmDatabaseInfo::NewLC(KFileColonSlahSlashCColonDotLdb); + HPosLmDatabaseInfo* dbInfoVeryLongString = HPosLmDatabaseInfo::NewLC(KVeryLongString); + + + // 22) Createa db with same name as an existing + dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + TRAP(err, dbManager->CreateDatabaseL(*dbInfo1)); + CleanupStack::PopAndDestroy(dbInfo1); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("22 Should leave with KErrAlreadyExist")); + User::Leave(err); + } + + // 23) Create a new database using the db management API with a nonsense URI + TRAP(err, dbManager->CreateDatabaseL(*dbInfoFileColonSlashSlash)); + if (err != KErrArgument) + { + iLog->Log(_L("23 Should leave with KErrArgument")); + User::Leave(err); + } + + // 24) Create a new database using the db management API with a URI specifying a remote database + HPosLmDatabaseInfo* dbInfoRem = HPosLmDatabaseInfo::NewLC(KRemoteDatabaseUri); + TRAP(err, dbManager->CreateDatabaseL(*dbInfoRem)); + CleanupStack::PopAndDestroy(dbInfoRem); + + if (err != KErrNotSupported) + { + iLog->Log(_L("24 Should leave with KErrNotSupported")); + User::Leave(err); + } + + // 25) Create a new database using the db management API with a URI with missing protocol + TRAP(err, dbManager->CreateDatabaseL(*dbInfoCColonSomeTestDbDotLdb)); + if (err != KErrNone) + { + iLog->Log(_L("25 Should NOT leave")); + User::Leave(err); + } + + // 26) Create a new database using the db management API with a URI with missing drive + TRAP(err, dbManager->CreateDatabaseL(*dbInfoFileColonSlashSlashSomeTestDb2DotLdb)); + if (err != KErrNone) + { + iLog->Log(_L("26 Should NOT leave")); + User::Leave(err); + } + + // 27) Create a new database using the db management API with a URI that does not end with *.ldb + TRAP(err, dbManager->CreateDatabaseL(*dbInfoCColonSomeTestDb3DotDoc)); + if (err != KErrArgument) + { + iLog->Log(_L("27 Should leave with KErrArgument")); + User::Leave(err); + } + + // 28) Create a new database using the db management API with a URI containing the path to the database file + HPosLmDatabaseInfo* dbInfoUri1 = HPosLmDatabaseInfo::NewLC(KDatabaseUri1); + TRAP(err, dbManager->CreateDatabaseL(*dbInfoUri1)); + CleanupStack::PopAndDestroy(dbInfoUri1); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("28 Should leave with KErrAlreadyExist")); + User::Leave(err); + } + + // 29) Create a new database using the db management API with an empty URI + TRAP(err, dbManager->CreateDatabaseL(*dbInfoEmptyString)); + if (err != KErrArgument) + { + iLog->Log(_L("29 Should leave with KErrArgument")); + User::Leave(err); + } + + // 29b) Create a new database using the db management API with an empty URI (containing file://c:.ldb) + TRAP(err, dbManager->CreateDatabaseL(*dbInfoFileColonSlahSlashCColonDotLdb)); + if (err != KErrArgument) + { + iLog->Log(_L("29b Should leave with KErrArgument")); + User::Leave(err); + } + + // 30) Create a new database using the db management API with a URI that is longer than allowed + TRAP(err, dbManager->CreateDatabaseL(*dbInfoVeryLongString)); + if (err != KErrArgument) + { + iLog->Log(_L(" Should leave with KErrArgument")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(dbInfoVeryLongString); + CleanupStack::PopAndDestroy(dbInfoFileColonSlahSlashCColonDotLdb); + CleanupStack::PopAndDestroy(dbInfoEmptyString); + CleanupStack::PopAndDestroy(dbInfoCColonSomeTestDb3DotDoc); + CleanupStack::PopAndDestroy(dbInfoFileColonSlashSlashSomeTestDb2DotLdb); + CleanupStack::PopAndDestroy(dbInfoCColonSomeTestDbDotLdb); + CleanupStack::PopAndDestroy(dbInfoFileColonSlashSlash); + + // 31 Try to delete an existing db + dbManager->DeleteDatabaseL(KDatabaseUri1); + // 32) Check that it is deleted from file system + iLog->Log(_L("Trap error below:")); + verifyDbCount = count + 5; + TRAP(err, VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri1)); + if (err != KErrNotFound) + { + iLog->Log(_L("32 Should not be found")); + User::Leave(err); + } + + // 33) Delete same file again, according to header file, nothing should happen + // when the file does not exist + TRAP(err, dbManager->DeleteDatabaseL(KDatabaseUri1)); + if (err != KErrNone) + { + iLog->Log(_L("33 DeleteDatbaseL, nothing should happen")); + User::Leave(err); + } + iLog->Log(_L("After DeleteDatabaseL")); + + CFileMan* fileMan = NULL; + fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + dbManager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + verifyDbCount = count +6; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri1); + // 34 Set an existing non-default db to be read-only (attribute found in F32FILE.H) + err = fileMan->Attribs(KDatabase1FullPath, KEntryAttReadOnly, KEntryAttNormal, TTime(0)); + if (err != KErrNone) + { + iLog->Log(_L("Attributes could not be changed for KDatabase1FullPath")); + User::Leave(err); + } + + // 35) Try to delete db with read only + TRAP(err, dbManager->DeleteDatabaseL(KDatabaseUri1)); + if (err != KErrAccessDenied) + { + iLog->Log(_L("35 Err delete of KDatabaseUri1")); + User::Leave(err); + } + + // Change back to writeable (attribute found in F32FILE.H) + err = fileMan->Attribs(KDatabase1FullPath, KEntryAttNormal, KEntryAttReadOnly, TTime(0)); + if (err != KErrNone) + { + iLog->Log(_L("Attributes could not be changed KDatabase1FullPath")); + User::Leave(err); + } + + // 36) Take a read lock on a db by using a search operation + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KDatabaseUri1); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(landmarkSearch); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + iOperation = landmarkSearch->StartLandmarkSearchL(*textCriteria, EFalse); + + // 37) Try to delete db with read lock + TRAP(err, dbManager->DeleteDatabaseL(KDatabaseUri1)); + if (err != KErrInUse) + { + iLog->Log(_L("37) Err delete of Read Locked KDatabaseUri1")); + User::Leave(err); + } + + ExecuteAndDeleteLD(iOperation); + + // 38) List databases + verifyDbCount = count + 6; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri1); + + //39) Take a write lock on a db by trying to delete all landmarks operations + iOperation = lmd->RemoveAllLandmarksL(); + // 40) Try to delete db with write lock + TRAP(err, dbManager->DeleteDatabaseL(KDatabaseUri1)); + if (err != KErrInUse) + { + iLog->Log(_L("40) Err delete of Write Locked KDatabaseUri1")); + User::Leave(err); + } + + ExecuteAndDeleteLD(iOperation); + + // 41) List databases + verifyDbCount = count + 6; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri1); + + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + CleanupStack::PopAndDestroy(lmd); + + CleanupStack::PopAndDestroy(fileMan); + + // 42) Try to delete a non-existing URI + TRAP(err, dbManager->DeleteDatabaseL(_L("c:\\NonsenseURI"))); + if (err != KErrArgument) + { + + iLog->Log(_L("42: Should leave with KErrArgument11")); + User::Leave(err); + } + + // 43) Try to delete a remote URI + TRAP(err, dbManager->DeleteDatabaseL(KRemoteDatabaseUri)); + if (err!=KErrNotSupported) + { + iLog->Log(_L("43) Err KRemoteDatabaseUri")); + User::Leave(err); + } + + // 44) Try to delete a local db specifying URI with missing protocol + dbManager->DeleteDatabaseL(KDatabase1MissingProtocol); + + // 45) List databases + verifyDbCount = count + 5; + VerifyNrOfDatabasesL(verifyDbCount); + + // 46) Try to delete a db on removable media excluding drive in URI + // Since the DeleteDatabaseL just returns if the db is not found, verify that no db has been removed + + HPosLmDatabaseInfo* dbInfoMedia2 = HPosLmDatabaseInfo::NewLC(KDbOnMedia2); + dbManager->CreateDatabaseL(*dbInfoMedia2); + CleanupStack::PopAndDestroy(dbInfoMedia2); + verifyDbCount = count +6; + VerifyNrOfDatabasesL(verifyDbCount, KDbOnMedia2Uri); + TRAP(err , dbManager->DeleteDatabaseL(KDbOnMedia2MissingDrive)); + + if (err != KErrNone) + { + TBuf<100> buffe; + buffe.Format(_L("46) Wrong error when deleting KDbOnMedia2MissingDrive, was %d should be %d"), err, KErrNone); + + iLog->Log(buffe); + User::Leave(err); + } + verifyDbCount = count + 6; + VerifyNrOfDatabasesL(verifyDbCount, KDbOnMedia2Uri); + + // 47) Try to delete a db on c drive excluding drive in URI + iLog->Log(_L("47) Try to delete a db on c drive excluding drive in URI")); + dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + TRAP(err, dbManager->CreateDatabaseL(*dbInfo1)); + CleanupStack::PopAndDestroy(dbInfo1); + if (err != KErrNone && err != KErrAlreadyExists) + { + iLog->Log(_L("Problem creating file KDatabase1")); + User::Leave(err); + } + TRAP(err, dbManager->DeleteDatabaseL(KDatabase1MissingDrive)); + if (err != KErrNone) + { + iLog->Log(_L("Wrong errro when deleting file")); + User::Leave(err); + } + verifyDbCount = count + 6; + VerifyNrOfDatabasesL(verifyDbCount); + + dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + dbManager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + verifyDbCount = count +7; + VerifyNrOfDatabasesL(verifyDbCount, KDatabaseUri1); + + // 48) Try to delete a db with URI that does not end with .ldb + iLog->Log(_L("48) Try to delete a db with URI that does not end with .ldb")); + TRAP(err, dbManager->DeleteDatabaseL(KDatabase1MissingExtension)); + if (err != KErrArgument) + { + iLog->Log(_L("48) Wrong error when deleting KDatabase1MissingExtension")); + User::Leave(err); + } + + // 49) Try to delete a database with a URI that includes the path to the database + iLog->Log(_L("49) Try to delete a database with a URI that includes the path to the database")); + TRAP(err, dbManager->DeleteDatabaseL(KDatabase1FullPath)); + if (err != KErrArgument) + { + iLog->Log(_L("Wrong error when deleting KDatabase1FullPath")); + User::Leave(err); + } + verifyDbCount = count +7; + VerifyNrOfDatabasesL(verifyDbCount); + + // 50 Delete with empty URI + iLog->Log(_L("50) ")); + TRAP(err, dbManager->DeleteDatabaseL(KEmptyURI)); + if (err != KErrArgument) + { + iLog->Log(_L("Wrong error when deleting KEmptyURI")); + User::Leave(err); + } + + // 51) Try to delete a db with URI that is longer than allowed + iLog->Log(_L("51) ")); + TRAP(err, dbManager->DeleteDatabaseL(_L("SomeVeryLongFilename1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.ldb"))); + if (err != KErrArgument) + { + iLog->Log(_L("Wrong error when deleting long filename file")); + User::Leave(err); + } + + // 52) Try to delete the existing default db + iLog->Log(_L("52) ")); + dbManager->SetDefaultDatabaseUriL(KDatabase1); + dbManager->DeleteDatabaseL(KDatabase1); + + // 53) List databases + iLog->Log(_L("53) ")); + verifyDbCount = count +6; + VerifyNrOfDatabasesL(verifyDbCount); + + // 54 Create db on drive that does not exist + HPosLmDatabaseInfo* dbInfoUri5 = HPosLmDatabaseInfo::NewLC(KDatabaseUri5); + TRAP(err, dbManager->CreateDatabaseL(*dbInfoUri5)); + CleanupStack::PopAndDestroy(dbInfoUri5); + if (err != KErrNotReady) + { + iLog->Log(_L("54) Wrong error when creating db on media that does not exist")); + User::Leave(err); + } + verifyDbCount = count +6; + VerifyNrOfDatabasesL(verifyDbCount); + + // 55 Delete db on drive that does not exist + TRAP(err, dbManager->DeleteDatabaseL(KDatabaseUri5)); + if (err != KErrNotReady) + { + iLog->Log(_L("55) Wrong error when deleting db on media that does not exist")); + User::Leave(err); + } + + _LIT(KLongFileName, "file://C:ABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRST.ldb"); + + // 56 Create db with long filename + HPosLmDatabaseInfo* dbInfoLong = HPosLmDatabaseInfo::NewLC(KLongFileName); + TRAP(err, dbManager->CreateDatabaseL(*dbInfoLong)); + CleanupStack::PopAndDestroy(dbInfoLong); + if (err != KErrArgument) + { + iLog->Log(_L("57) Wrong error when creating db with long filename")); + User::Leave(err); + } + verifyDbCount = count +6; + VerifyNrOfDatabasesL(verifyDbCount); + + // 57) Check that database with long filename does not exist + if (dbManager->DatabaseExistsL(KLongFileName)) + { + //LogErrorAndLeave(_L("Database with long filename should not exist")); + iLog->Log(_L("57) Database with long filename should not exist")); + User::Leave(-1); + } + + // 58) Check error ESLI-6ARN66, delete a db with strange filename + HPosLmDatabaseInfo* dbInfoWeird = + HPosLmDatabaseInfo::NewLC(_L("file://c:!#¤%&()=+`´^¨~'§½-_,;.{}[]$£@0123456789åäöÅÄÖ.ldb")); + dbManager->CreateDatabaseL(*dbInfoWeird); + CleanupStack::PopAndDestroy(dbInfoWeird); + verifyDbCount = count +7; + VerifyNrOfDatabasesL(verifyDbCount); + + CleanupStack::PopAndDestroy(dbList); + CleanupStack::PopAndDestroy(dbManager); + + TRAP(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) + { + + iLog->Log(_L("RemoveAllLmDatabasesL should not leave with error")); + User::Leave(err); + } + + TestDifferentUrisL(); + + } + +// --------------------------------------------------------- +// CPosTp102::TestDifferentUrisL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp102::TestDifferentUrisL() + { + iLog->Log(_L("TestDifferentUrisL")); + _LIT(KDbUri1, "file://:://c:::en helt \" sjuk .ldb databas\".ldb.ldb.ldb"); + _LIT(KDbUri2, "file://c:en helt sjuk databas.ldb"); + _LIT(KDbUri3, "file:///c:en helt sjuk databas.ldb"); + _LIT(KDbUri4, "file://c::en helt sjuk databas.ldb"); + _LIT(KDbUri5, "file://c:en helt sjuk .ldb databas.ldb"); + _LIT(KDbUri6, "file://c:en helt sjuk databas.ldb.ldb.ldb"); + _LIT(KDbUri7, "file://c:en helt \" sjuk databas.ldb"); + _LIT(KDbUri8, "file://c:en helt < sjuk databas.ldb"); + _LIT(KDbUri9, "file://c:en helt > sjuk databas.ldb"); + _LIT(KDbUri10, "file://c:en helt | sjuk databas.ldb"); + _LIT(KDbUri11, "file://c:en helt / sjuk databas.ldb"); + _LIT(KDbUri12, "file://c:en helt ? sjuk databas.ldb"); + _LIT(KDbUri13, "file://c:en helt \\ sjuk databas.ldb"); + _LIT(KDbUri14, "file://c:en helt : sjuk databas.ldb"); + // Below tested separately in step 58) + //_LIT(KDbUri15, "file://c:!#¤%&()=+`´^¨~'§½-_,;.{}[]$£@0123456789åäöÅÄÖ.ldb"); + _LIT(KDbUri16, "file://c:qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM.ldb"); + _LIT(KDbUri17, "file://en otroligt helt sjuk databas.ldb"); + _LIT(KDbUri18, "c:en helsjuk databas.ldb"); + _LIT(KDbUri19, "file://c:\\system\\data\\en helt sjuk databas.ldb"); + _LIT(KDbUri20, "file://c:.ldb"); + _LIT(KDbUri21, "file://c:filename"); + _LIT(KDbUri22, "file://c:filename.dip"); + _LIT(KDbUri23, "file://c:filename. ldb"); + _LIT(KDbUri24, "file://c:*.ldb"); + _LIT(KDbUri25, "file://allan:en helt sjuk databas.ldb"); + _LIT(KDbUri26, "file://g:en helt sjuk databas.ldb"); + _LIT(KDbUri27, "file://c:filename.ldb"); + _LIT(KDbUri28, "file://c:012345678901234567890123456789012345678901234567890123456789.ldb"); + + const TInt KNrOfUris = 8; + const TDesC* listOfUris[] = {&KDbUri2, &KDbUri5, &KDbUri6 + , &KDbUri16 , &KDbUri17, &KDbUri18 + , &KDbUri27, &KDbUri28 + }; + /* &KDbUri1*/ + + const TInt KNrOfNonWorkingUris = 19; + const TDesC* listOfUrisNonWorking[] = {&KDbUri1, &KDbUri3 ,&KDbUri4, &KDbUri7, &KDbUri8, &KDbUri9 + , &KDbUri10, &KDbUri11, &KDbUri12, &KDbUri13, &KDbUri14, &KDbUri19, &KDbUri20, &KDbUri21 + , &KDbUri22, &KDbUri23, &KDbUri24, &KDbUri25, &KDbUri26}; + + TInt errorList[] = {KErrArgument, KErrBadName, KErrBadName, KErrBadName, KErrBadName ,KErrBadName,KErrBadName, + KErrBadName, KErrBadName, KErrArgument, KErrBadName, KErrArgument, KErrArgument, + KErrArgument, KErrArgument,KErrArgument, KErrBadName, KErrBadName, KErrNotReady}; + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + RemoveAllLmDatabasesL(); + TBuf<100> buf; + // get the count of dbs that have notbeen deleted isnce they are in use + CDesCArray* dbArray1 = dbManager->ListDatabasesLC(); + TInt count = dbArray1->Count(); + TInt verifyDbcount; + + for (TInt i=0;iLog(_L("Creating db:")); + iLog->Log(*listOfUris[i]); + TRAPD(err, dbManager->CreateDatabaseL(*dbInfo)); + if (err != KErrNone) + { + buf.Format(_L("Failed with err %d"), err); + iLog->Log(buf); + User::Leave(err); + } + else + { + iLog->Log(_L("Db created...")); + } + CleanupStack::PopAndDestroy(dbInfo); + verifyDbcount = count + i+1; + VerifyNrOfDatabasesL(verifyDbcount); + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + + buf.Format(_L("DB count %d"), nr); + iLog->Log(buf); + CleanupStack::PopAndDestroy(dbArray); + } + + for (TInt i=0;iLog(_L("Trying to create db:")); + iLog->Log(*listOfUrisNonWorking[i]); + TRAPD(err, dbManager->CreateDatabaseL(*dbInfo)); + if (err != errorList[i]) + { + buf.Format(_L("Failed with err %d should be %d"), err, errorList[i]); + iLog->Log(buf); + + iLog->Log(buf); + User::Leave(err); + } + CleanupStack::PopAndDestroy(dbInfo); + verifyDbcount = count + KNrOfUris; + VerifyNrOfDatabasesL(verifyDbcount); + } + + CleanupStack::PopAndDestroy(dbArray1); + CleanupStack::PopAndDestroy(dbManager); + iLog->Log(_L("TestDifferentUrisL")); + } + +// --------------------------------------------------------- +// CPosTp102::VerifyNrOfDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp102::VerifyNrOfDatabasesL(TInt aExpNrOfDatabases, const TDesC& aDatabaseUri) + { + iLog->Log(_L("VerifyNrOfDatabasesL")); + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + if (nr != aExpNrOfDatabases) + { + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + + TBuf<100> buf; + buf.Format(_L("Wrong number of databases, was %d, should be %d"), nr, aExpNrOfDatabases); + + iLog->Log(buf); + User::Leave(-1); + } + + TBool found = EFalse; + if (aDatabaseUri != KNullDesC) + { + for (TInt i=0;iLog((*dbArray)[i]); + if ((*dbArray)[i].Compare(aDatabaseUri) == KErrNone) + { + found = ETrue; + } + } + } + + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + + if (aDatabaseUri != KNullDesC && !found) + { + iLog->Log(_L("Database was not found")); + User::Leave(KErrNotFound); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp103.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp103.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,435 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp103.h" +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp103::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp103::CloseTest() + { + iLog->Log(_L("CloseTest")); + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("RemoveAllLmDatabasesL() leaved")); + } + +// --------------------------------------------------------- +// CPosTp103::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp103::StartL() + { + // TInt expNrOfDbs = 0; + + RemoveAllLmDatabasesL(); + + TestPartCopyDatabasesL(); + } + +// --------------------------------------------------------- +// CPosTp103::TestPartCopyDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp103::TestPartCopyDatabasesL() + { + iLog->Log(_L("TestPartCopyDatabasesL")); + + _LIT(KDbName1, "TP103_Database1.ldb"); + _LIT(KDbNameNonExisting, "NonExisting_TP103_Database1.ldb"); + _LIT(KDbNameCopy1, "file://C:TP103_DATABASE1COPY1.LDB"); + _LIT(KDbNameCopy5, "file://C:TP103_DATABASE2COPY5.LDB"); + _LIT(KDbNameCopy6, "file://C:TP103_DATABASE2COPY6.LDB"); + + _LIT(KDbName7MissingDrive, "file://TP103_DATABASE7.LDB"); + _LIT(KDbName7, "file://C:TP103_DATABASE7.LDB"); + + // DB on drive that does no exist + _LIT(KDbName8, "file://R:TP103_DATABASE8.LDB"); + _LIT(KDbName8_1, "file://C:TP103_DATABASE8_1.LDB"); + + _LIT(KDefaultCopyDb, "CopyOfDefaultDb.ldb"); + _LIT(KDefaultCopyDbUri, "file://C:CopyOfDefaultDb.ldb"); + + _LIT(KDbSourceNameMissingExtension, "file://C:TP103_DATABASE2COPY6"); + _LIT(KDbTargetNameMissingExtension, "file://C:TP103_DATABASE2COPY_666"); + + _LIT(KRemoteDatabaseUri, "http://RemoteLmDb.ldb"); + +#ifdef __WINS__ + // D on wins + _LIT(KDbNameCopy2, "file://D:TP103_DATABASE1COPY2.LDB"); + _LIT(KDbNameCopy2MissingDrive, "file://TP103_DATABASE1COPY2.LDB"); + _LIT(KDbNameCopy3, "file://D:TP103_DATABASE1COPY3.LDB"); +#else + _LIT(KDbNameCopy2, "file://F:TP103_DATABASE1COPY2.LDB"); + _LIT(KDbNameCopy2MissingDrive, "file://TP103_DATABASE1COPY2.LDB"); + _LIT(KDbNameCopy3, "file://F:TP103_DATABASE1COPY3.LDB"); +#endif + _LIT(KDbNameCopy4, "file://C:TP103_DATABASE1COPY4.LDB"); + + _LIT(KDbNameEmptyUri1, ""); + _LIT(KDbNameEmptyUri2, "file://c"); + + _LIT(KDummyDb, "file://SomeDummyDbName.ldb"); + TInt err = KErrNone; + + iLog->Log(_L("Warning: this test case requires E: drive")); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // check the count of databases that could not be delted since they were in use + CDesCArray* dbList = dbManager->ListDatabasesLC(); + TInt count = dbList->Count(); + TInt verifyDbcount; + + // 1) Create a new database + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDbName1); + dbManager->CreateDatabaseL(*dbInfo1); + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(KDbName1); + CleanupStack::PopAndDestroy(dbInfo1); + CleanupStack::PushL(db1); + if (db1->IsInitializingNeeded()) + { + iLog->Log(_L("db1->InitializeL")); + ExecuteAndDeleteLD(db1->InitializeL()); + } + CleanupStack::PopAndDestroy(db1); + + // 2) Copy db to file system, include file:// in URI + dbManager->CopyDatabaseL(KDbName1, KDbNameCopy1); + + // 3) Copy db to removable media, include file:// in URI + dbManager->CopyDatabaseL(KDbName1, KDbNameCopy2); + + // 4) Copy the db on removable media to removable media + dbManager->CopyDatabaseL(KDbNameCopy2, KDbNameCopy3); + + // 5) Copy the db from removable media to c drive + dbManager->CopyDatabaseL(KDbNameCopy2, KDbNameCopy4); + + // 6) Verify that the four databases (copied in step 2-5) exists + if (!dbManager->DatabaseExistsL(KDbNameCopy1)) + { + iLog->Log(_L("DatabaseCopy1 should exist")); + User::Leave(-1); + } + if (!dbManager->DatabaseExistsL(KDbNameCopy2)) + { + iLog->Log(_L("DatabaseCopy2 should exist")); + User::Leave(-1); + } + if (!dbManager->DatabaseExistsL(KDbNameCopy3)) + { + iLog->Log(_L("DatabaseCopy3 should exist")); + User::Leave(-1); + } + if (!dbManager->DatabaseExistsL(KDbNameCopy4)) + { + iLog->Log(_L("DatabaseCopy4 should exist")); + User::Leave(-1); + } + + // 7) Repat step 5, but this time should the target of the copy operation exist + TRAP(err, dbManager->CopyDatabaseL(KDbNameCopy2, KDbNameCopy4)); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("CopyDatabaseL should leave with KErrAlreadyExists")); + User::Leave(err); + } + + // 8) Take a read lock (using a search operation) on db and try to copy it + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KDbNameCopy2); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(landmarkSearch); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + iOperation = landmarkSearch->StartLandmarkSearchL(*textCriteria, EFalse); + + // Try to copy db with read lock + TRAP(err, dbManager->CopyDatabaseL(KDbNameCopy2, KDbNameCopy5)); + if (err != KErrInUse) + { + iLog->Log(_L("8) Copy should leave with KErrInUse")); + User::Leave(err); + } + ExecuteAndDeleteLD(iOperation); + + // 9) Take a write lock on db and try to copy it + iOperation = lmd->RemoveAllLandmarksL(); + TRAP(err, dbManager->CopyDatabaseL(KDbNameCopy2, KDbNameCopy6)); + if (err != KErrLocked) iLog->Log(_L("9) Copy should leave with KErrLocked")); + ExecuteAndDeleteLD(iOperation); + + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + CleanupStack::PopAndDestroy(lmd); + + // 10) Try to copy a database that does not exist + TRAP(err, dbManager->CopyDatabaseL(KDbNameNonExisting, _L("DummyTarget.ldb"))); + if (err != KErrNotFound) + { + iLog->Log(_L("10) CopyDatabaseL should leave with KErrNotFound")); + User::Leave(err); + } + + // 11) Try to copy an existing db to a nonexisting path/target + TRAP(err, dbManager->CopyDatabaseL(KDbName1, _L("c://pelle//DummyTarget.ldb"))); + if (err != KErrArgument) + { + iLog->Log(_L("11) CopyDatabaseL should leave with KErrNotFound")); + User::Leave(err); + } + + // 12) Try to copy an existing db to remote path/target + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KRemoteDatabaseUri)); + if (err != KErrArgument) //LogErrorAndLeave(_L("12) CopyDatabaseL should leave with KErrBadName")); + { + iLog->Log(_L("12) CopyDatabaseL should leave with KErrBadName")); + User::Leave(err); + } + + // 13) Try to copy a db on c drive without specifying a drive in the source uri + dbManager->CopyDatabaseL(KDbName1, KDbNameCopy5); + verifyDbcount = count +6; + VerifyNrOfDatabasesL(verifyDbcount, KDbNameCopy5); + + // 14) Try to copy a db on removable media drive without specifying the drive in the source uri + TRAP(err, dbManager->CopyDatabaseL(KDbNameCopy2MissingDrive, KDummyDb)); + if (err != KErrNotFound) + { + iLog->Log(_L(" CopyDatabaseL should leave with KErrNotFound")); + User::Leave(err); + } + + // 15) Try to copy a db on removable media drive without specifying the drive in the target uri + if (!dbManager->DatabaseExistsL(KDbNameCopy2)) + { + iLog->Log(_L("DatabaseCopy2 should exist")); + User::Leave(KErrNone); + } + TRAP(err, dbManager->CopyDatabaseL(KDbNameCopy2, KDbName7MissingDrive)); + if (err != KErrNone) + { + iLog->Log(_L("KDbNameCopy2 should be copied")); + User::Leave(err); + } + verifyDbcount = count + 7; + VerifyNrOfDatabasesL(verifyDbcount, KDbName7); + + // 16) Try to copy without .ldb in source URI + TRAP(err, dbManager->CopyDatabaseL(KDbSourceNameMissingExtension, _L("DummyTarget.ldb"))); + if (err != KErrArgument) + { + iLog->Log(_L("CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + + // 17) Try to copy without .ldb in target URI + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KDbTargetNameMissingExtension)); + if (err != KErrArgument) + { + iLog->Log(_L("CopyDatabaseL should leave with XXX")); + User::Leave(err); + } + + // 18) Try to copy db to itself + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KDbName1)); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("CopyDatabaseL should leave with KErrAlreadyExists")); + User::Leave(err); + } + + // 19) Try to copy db to itself XXX Should be removed, same as step18 + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KDbName1)); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("CopyDatabaseL should leave with KErrAlreadyExists")); + User::Leave(err); + } + + // 20) Try to copy db with empty target URI + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KDbNameEmptyUri1)); + if (err != KErrArgument) + { + iLog->Log(_L("20a) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + TRAP(err, dbManager->CopyDatabaseL(KDbName1, KDbNameEmptyUri2)); + if (err != KErrArgument) + { + iLog->Log(_L("20b) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + + // 21) Try to copy db with empty source URI + TRAP(err, dbManager->CopyDatabaseL(KDbNameEmptyUri1, KDummyDb)); + if (err != KErrArgument) + { + iLog->Log(_L("21a) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + TRAP(err, dbManager->CopyDatabaseL(KDbNameEmptyUri2, KDummyDb)); + if (err != KErrArgument) + { + iLog->Log(_L("21b) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + + // 22) Try to copy db with target URI that is longer than allowed + TRAP(err, dbManager->CopyDatabaseL(_L("c:\\SomeVeryLongFilename1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.ldb"), KDummyDb)); + if (err != KErrArgument) + { + iLog->Log(_L("22) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + + // 23) Try to copy db with source URI that is longer than allowed + TRAP(err, dbManager->CopyDatabaseL(KDbName1, _L("c:\\SomeVeryLongFilename1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.ldb"))); + if (err != KErrArgument) + { + iLog->Log(_L("23) CopyDatabaseL should leave with KErrArgument")); + User::Leave(err); + } + + // 24) Try to copy the default db + dbManager->SetDefaultDatabaseUriL(KDbName7); + HBufC* defaultDbUri; + defaultDbUri = dbManager->DefaultDatabaseUriLC(); + dbManager->CopyDatabaseL(*defaultDbUri, KDefaultCopyDb); + + verifyDbcount = count + 8; + VerifyNrOfDatabasesL(verifyDbcount, KDefaultCopyDbUri); + + // 25) Delete default db and then copy a new db to its location + dbManager->DeleteDatabaseL(*defaultDbUri); + dbManager->CopyDatabaseL(KDefaultCopyDbUri, *defaultDbUri); + verifyDbcount = count + 8; + VerifyNrOfDatabasesL(verifyDbcount , KDefaultCopyDbUri); + VerifyNrOfDatabasesL(verifyDbcount , *defaultDbUri); + + // 26) Try to copy a db on a drive that does not exist + TRAP(err, dbManager->CopyDatabaseL(KDbName8, KDbName8_1)); + if (err != KErrNotReady) + { + iLog->Log(_L("26) CopyDatabaseL should leave with KErrNotReady")); + User::Leave(err); + } + VerifyNrOfDatabasesL(verifyDbcount, KDefaultCopyDbUri); + + // 27) Try to copy defaultdb to db with long filenames + _LIT(KLongFileName, "file://C:ABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRST.ldb"); + + TRAP(err, dbManager->CopyDatabaseL(KDefaultCopyDbUri, KLongFileName)); + if (err != KErrArgument) + { + iLog->Log(_L("27) CopyDatabaseL should leave")); + User::Leave(err); + } + + VerifyNrOfDatabasesL(verifyDbcount); + + // 28) Try to copy db with long file name + TRAP(err, dbManager->CopyDatabaseL(KLongFileName, _L("SomeDummyFile.ldb"))); + if (err != KErrArgument) + { + iLog->Log(_L("28) CopyDatabaseL should leave ")); + User::Leave(err); + } + VerifyNrOfDatabasesL(verifyDbcount); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(dbList); + CleanupStack::PopAndDestroy(dbManager); + } + +// --------------------------------------------------------- +// CPosTp103::VerifyNrOfDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp103::VerifyNrOfDatabasesL(TInt aExpNrOfDatabases, const TDesC& aDatabaseUri) + { + iLog->Log(_L("VerifyNrOfDatabasesL")); + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + if (nr != aExpNrOfDatabases) + { + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + + TBuf<100> buf; + buf.Format(_L("Wrong number of databases, was %d, should be %d"), nr, aExpNrOfDatabases); + + iLog->Log(buf); + User::Leave(-1); + } + + TBool found = EFalse; + if (aDatabaseUri != KNullDesC) + { + for (TInt i=0;iLog((*dbArray)[i]); + if ((*dbArray)[i].Compare(aDatabaseUri) == KErrNone) + { + found = ETrue; + } + } + } + + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + + if (aDatabaseUri != KNullDesC && !found) + { + iLog->Log(_L("Database was not found")); + User::Leave(KErrNotFound); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp104.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp104.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,529 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp104.h" +#include +#include "FT_LandmarkConstants.h" +#include + +// CONSTANTS +const TUint32 KLandmarkDefaultUri = 0x00000001; +const TUid KCRUidLandmarks = {0x101FE99B}; + +// _LIT(KSettingsFileInRom, "c:\\system\\data\\cenrep\\[101FE99B].txt"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp104::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp104::StartL() + { + _LIT(KLmA, "LandmarkA"); + _LIT(KLmB, "LandmarkB"); + _LIT(KLmC, "LandmarkC"); + _LIT(KNonExistingDb, "nonexistingdb.ldb"); + _LIT(KLogAboutToSetDefaultDB, "About to set default landmark DB to a non existing DB."); + _LIT(KLogAboutToDeleteAllDbs, "About to delete all landmark DBs"); + _LIT(KLogAboutToReadBackLmA, "About to read back landmark A"); + _LIT(KLogAboutToReadBackLmB, "About to read back landmark B"); + _LIT(KLogAboutToReadBackLmC, "About to read back landmark C"); + _LIT(KErrorNonExisting, "Was able to set an non-existing DB as default."); + _LIT(KLandmarksDbB, "lmdb104b.ldb"); + _LIT(KLandmarksDbBFull, "file://c:lmdb104b.ldb"); + _LIT(KErrorWrongDefaultDB, "Unexpected default database"); + _LIT(KCopyOfDefaultDB, "lmdb104copy.ldb"); + _LIT(KFailedToDeleteDB, "Failed to delete default database"); + _LIT(KLogAboutToSetLmDbBAsDefault, "About to set landmarks DB B as default DB."); + _LIT(KOriginalDb, "file://c:eposlm.ldb"); + + #ifdef __WINS__ + _LIT(KRemovableMediaDB, "d:removabledb.ldb"); + #else + _LIT(KRemovableMediaDB, "f:removabledb.ldb"); + #endif + + _LIT(KNr01, "01"); + _LIT(KNr02, "02"); + _LIT(KNr03, "03"); + _LIT(KNr04, "04"); + _LIT(KNr05, "05"); + _LIT(KNr06, "06"); + _LIT(KNr07, "07"); + _LIT(KNr08, "08"); + + _LIT(KNr10, "10"); + _LIT(KNr11, "11"); + _LIT(KNr12, "12"); + _LIT(KNr13, "13"); + _LIT(KNr14, "14"); + _LIT(KNr15, "15"); + _LIT(KNr16, "16"); + _LIT(KNr17, "17"); + _LIT(KNr18, "18"); + _LIT(KNr19, "19"); + _LIT(KNr20, "20"); + _LIT(KNr21, "21"); + _LIT(KNr22, "22"); + _LIT(KNr23, "23"); + _LIT(KNr24, "24"); + _LIT(KNr25, "25"); + _LIT(KNr26, "26"); + + iLog->Log(_L("Warning: this test case requires E: drive")); + + iRepository = CRepository::NewL(KCRUidLandmarks); + iDbMan = CPosLmDatabaseManager::NewL(); + + RemoveAllLmDatabasesL(); + ArgumentTestsL(); + TInt err; + + + TBuf16 defaultUriRep; + //NCentralRepositoryConstants::KMaxUnicodeStringLength + User::LeaveIfError(iRepository->Get(KLandmarkDefaultUri, defaultUriRep)); + + + + // 3 + iLog->Log(KNr03); + // Open and initialize default db + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + + + // Add landmark A to DB: + CPosLandmark* lmA = CreateXMLLandmarkLC(KLmA); + TPosLmItemId lmAId = iLandmarksDb->AddLandmarkL(*lmA); + CleanupStack::PopAndDestroy(lmA); + User::After(2000000); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + // User::After(2000000); + // Check that it was actually added: + iLog->Log(KLogAboutToReadBackLmA); + lmA = iLandmarksDb->ReadLandmarkLC(lmAId); + iLog->Log(KLogAboutToReadBackLmA); + CleanupStack::PopAndDestroy(lmA); + + // 4 + iLog->Log(KNr04); + // Test to set a non-existing db as default: + iLog->Log(KLogAboutToSetDefaultDB); + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KNonExistingDb)); + + if (err != KErrNotFound) + { + + iLog->Log(KErrorNonExisting); + User::Leave(err); + } + + // 5 + iLog->Log(KNr05); + // Create a new db and add a landmark to it: + delete iLandmarksDb; + iLandmarksDb = NULL; + HPosLmDatabaseInfo* dbInfoB = HPosLmDatabaseInfo::NewLC(KLandmarksDbB); + iDbMan->CreateDatabaseL(*dbInfoB); + CleanupStack::PopAndDestroy(dbInfoB); + iLandmarksDb = CPosLandmarkDatabase::OpenL(KLandmarksDbB); + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + + CPosLandmark* lmB = CreateXMLLandmarkLC(KLmB); + TPosLmItemId lmBId = iLandmarksDb->AddLandmarkL(*lmB); + User::After(2000000); + CleanupStack::PopAndDestroy(lmB); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + + // Read back the landmark: + iLog->Log(KLogAboutToReadBackLmB); + lmB = iLandmarksDb->ReadLandmarkLC(lmBId); + CleanupStack::PopAndDestroy(lmB); + delete iLandmarksDb; + iLandmarksDb = NULL; + + // 6 + iLog->Log(KNr06); + // Set the new DB as default, and check that it worked OK: + iLog->Log(KLogAboutToSetLmDbBAsDefault); + iDbMan->SetDefaultDatabaseUriL(KLandmarksDbB); + HBufC* defaultURI = iDbMan->DefaultDatabaseUriLC(); + + // 7 + iLog->Log(KNr07); + if (defaultURI->Des().CompareF(KLandmarksDbBFull)) + { + + iLog->Log(KErrorWrongDefaultDB); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(defaultURI); + + // 8 + iLog->Log(KNr08); + // Open the default DB and try to find the landmark that was added before: + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + if (iLandmarksDb->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + + iLog->Log(KLogAboutToReadBackLmB); + lmB = iLandmarksDb->ReadLandmarkLC(lmBId); + CleanupStack::PopAndDestroy(lmB); + delete iLandmarksDb; + iLandmarksDb = NULL; + + // 9 + iLog->Log(KNr01); + // Change the default db: + iDbMan->SetDefaultDatabaseUriL(defaultUriRep); + defaultURI = iDbMan->DefaultDatabaseUriLC(); + + if (defaultURI->Des().CompareF(defaultUriRep)) + { + + iLog->Log(KErrorWrongDefaultDB); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(defaultURI); + + // 10 + iLog->Log(KNr10); + // Open the default DB and check that it contains landmark A: + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + if (iLandmarksDb->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + iLog->Log(KLogAboutToReadBackLmA); + lmA = iLandmarksDb->ReadLandmarkLC(lmAId); + CleanupStack::PopAndDestroy(lmA); + + delete iLandmarksDb; + iLandmarksDb = NULL; + + + // ********************** Test Copy ********************** + // 11 + iLog->Log(KNr11); + // Copy the default DB: + iDbMan->CopyDatabaseL(defaultUriRep, KCopyOfDefaultDB); + + // 12 + iLog->Log(KNr12); + + // 13 + iLog->Log(KNr13); + // Check which DB that is the default: + defaultURI = iDbMan->DefaultDatabaseUriLC(); + if (defaultURI->Des().CompareF(defaultUriRep)) + { + + iLog->Log(KErrorWrongDefaultDB); + User::Leave(-1); + } + CleanupStack::PopAndDestroy(defaultURI); + + // 14 + iLog->Log(KNr14); + iDbMan->SetDefaultDatabaseUriL(KCopyOfDefaultDB); + + // Open the default DB and check that it contains landmark A: + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + if (iLandmarksDb->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + iLog->Log(KLogAboutToReadBackLmA); + lmA = iLandmarksDb->ReadLandmarkLC(lmAId); + CleanupStack::PopAndDestroy(lmA); + + // 15 + delete iLandmarksDb; + iLandmarksDb = NULL; + iLog->Log(KNr15); + + // Create a landmarks DB on the memory card: + HPosLmDatabaseInfo* dbInfoRemMedia = HPosLmDatabaseInfo::NewLC(KRemovableMediaDB); + iDbMan->CreateDatabaseL(*dbInfoRemMedia); + CleanupStack::PopAndDestroy(dbInfoRemMedia); + + iLandmarksDb = CPosLandmarkDatabase::OpenL(KRemovableMediaDB); + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + + // Add a landmark to it: + CPosLandmark* lmC = CreateXMLLandmarkLC(KLmC); + TPosLmItemId lmCId = iLandmarksDb->AddLandmarkL(*lmC); + CleanupStack::PopAndDestroy(lmC); + User::After(200000); + ExecuteAndDeleteLD(iLandmarksDb->CompactL()); + delete iLandmarksDb; + iLandmarksDb = NULL; + + // 16 + iLog->Log(KNr16); + iDbMan->SetDefaultDatabaseUriL(KRemovableMediaDB); + + iLandmarksDb = CPosLandmarkDatabase::OpenL(); + if (iLandmarksDb->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iLandmarksDb->InitializeL()); + } + + // Check that landmark C exists: + iLog->Log(KLogAboutToReadBackLmC); + lmC = iLandmarksDb->ReadLandmarkLC(lmCId); + CleanupStack::PopAndDestroy(lmC); + + delete iLandmarksDb; + iLandmarksDb = NULL; + + // URI Testing: + _LIT(KTestDB104A, "file://c:TestDb104a.ldb"); + _LIT(KTestDB104B, "file://c:TestDb104b.ldb"); + #ifdef __WINS__ + _LIT(KTestDB104MMC, "file://d:TestDbMMC.ldb"); + #else + _LIT(KTestDB104MMC, "file://f:TestDbMMC.ldb"); + #endif + + // Create some testdb:s + HPosLmDatabaseInfo* dbInfo104A = HPosLmDatabaseInfo::NewLC(KTestDB104A); + HPosLmDatabaseInfo* dbInfo104B = HPosLmDatabaseInfo::NewLC(KTestDB104B); + HPosLmDatabaseInfo* dbInfo104MMC = HPosLmDatabaseInfo::NewLC(KTestDB104MMC); + iDbMan->CreateDatabaseL(*dbInfo104A); + iDbMan->CreateDatabaseL(*dbInfo104B); + iDbMan->CreateDatabaseL(*dbInfo104MMC); + CleanupStack::PopAndDestroy(dbInfo104MMC); + CleanupStack::PopAndDestroy(dbInfo104B); + CleanupStack::PopAndDestroy(dbInfo104A); + + + _LIT(KNonsenseURI, "&t87%(s!,uy.poffd"); + _LIT(KNotEndingWithLdbURI, "file://c:TestDb104a"); + _LIT(KEmptyURI, ""); + _LIT(KLongerThanAllowedURI, "longdatabaseewjktgjfkdnbnbfjghskwuwrqtrccxbdhfbbjgnmglkytiyitiugjqoiwiejakxngjhdygrgdskhdhdbxvafarqtwyrjgjtihjkjbnbjyhkjltoyouiylhjrnbmdngfhurtwgewvetqwsahdgfey4756eyrg8328yrgfgggbbnnmnkjgjdhajaqiwuwueytriutiiiutuithjhgergfbfhgnbmbmnmklkrjsfadadeqwyteutiyibnvcbxvdafsdgdhey.ldb"); // more than 256 (KMaxUnicodeStringLength) + _LIT(KCorrectURI, "file://c:TestDb104b.ldb"); + _LIT(KCorrectButWithoutDriveURI, "file://TestDb104a.LDB"); + _LIT(KOnMmcButWithoutDriveURI, "file://TestDb104c.ldb"); + _LIT(KRemoteURI, "http://www.landmarks.com/dbs/remote104.ldb"); + _LIT(KNoProtocolURI, "c:TestDb104b.ldb"); + + // 17 + iLog->Log(KNr17); + TestSetUriL(KNonsenseURI, KErrArgument); + // 18 + iLog->Log(KNr18); + TestSetUriL(KNotEndingWithLdbURI, KErrArgument); + // 19 + iLog->Log(KNr19); + TestSetUriL(KEmptyURI, KErrArgument); + // 20 + iLog->Log(KNr20); + TestSetUriL(KLongerThanAllowedURI, KErrArgument); + // 21 + iLog->Log(KNr21); + TestSetUriL(KCorrectURI, KErrNone); + // 22 + iLog->Log(KNr22); + TestSetUriL(KCorrectButWithoutDriveURI, KErrNone); + // 23 + iLog->Log(KNr23); + TestSetUriL(KOnMmcButWithoutDriveURI, KErrNotFound); + // 24 + iLog->Log(KNr24); + TestSetUriL(KRemoteURI, KErrNotSupported); + // 25 + iLog->Log(KNr25); + TestSetUriL(KNoProtocolURI, KErrNone); + // 26 + iLog->Log(KNr26); + TestSetUriL(KNoProtocolURI, KErrNone); + + delete iDbMan; + iDbMan = NULL; + + delete iLandmarksDb; + iLandmarksDb = NULL; + + delete iRepository; + iRepository = NULL; + } + +// --------------------------------------------------------- +// CPosTp104::TestSetUriL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp104::TestSetUriL(const TDesC& aUriString, TInt aExpectedErrorCode) + { + TRAPD(err,iDbMan->SetDefaultDatabaseUriL(aUriString)); + if (err != aExpectedErrorCode) + { + _LIT(KErrorText, "Received wrong error code when setting URI. Expected %d, Received %d"); + TBuf<100> buf; + buf.Format(KErrorText, aExpectedErrorCode, err); + + iLog->Log(buf); + User::Leave(err); + } + } + +// --------------------------------------------------------- +// CPosTp104::ArgumentTests +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp104::ArgumentTestsL() + { + _LIT(KErrorWrongCode, "Didn't receive correct error code"); + _LIT(KMaxLengthString64, "1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString64Bad, "x1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString66, "c:2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString66Bad, "c:x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString71, "file://3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString71Bad, "file://x3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString73, "file://c:4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString73Bad, "file://c:x4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + TInt err = 0; + + // Should work OK: + HPosLmDatabaseInfo* dbInfo64 = HPosLmDatabaseInfo::NewLC(KMaxLengthString64); + HPosLmDatabaseInfo* dbInfo64Bad = HPosLmDatabaseInfo::NewLC(KMaxLengthString64Bad); + HPosLmDatabaseInfo* dbInfo66 = HPosLmDatabaseInfo::NewLC(KMaxLengthString66); + HPosLmDatabaseInfo* dbInfo66Bad = HPosLmDatabaseInfo::NewLC(KMaxLengthString66Bad); + HPosLmDatabaseInfo* dbInfo71 = HPosLmDatabaseInfo::NewLC(KMaxLengthString71); + HPosLmDatabaseInfo* dbInfo71Bad = HPosLmDatabaseInfo::NewLC(KMaxLengthString71Bad); + HPosLmDatabaseInfo* dbInfo73 = HPosLmDatabaseInfo::NewLC(KMaxLengthString73); + HPosLmDatabaseInfo* dbInfo73Bad = HPosLmDatabaseInfo::NewLC(KMaxLengthString73Bad); + + iDbMan->CreateDatabaseL(*dbInfo64); + iDbMan->CreateDatabaseL(*dbInfo66); + iDbMan->CreateDatabaseL(*dbInfo71); + iDbMan->CreateDatabaseL(*dbInfo73); + + + + TRAP(err, iDbMan->CreateDatabaseL(*dbInfo64Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->CreateDatabaseL(*dbInfo66Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->CreateDatabaseL(*dbInfo71Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->CreateDatabaseL(*dbInfo73Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + + CleanupStack::PopAndDestroy(dbInfo73Bad); + CleanupStack::PopAndDestroy(dbInfo73); + CleanupStack::PopAndDestroy(dbInfo71Bad); + CleanupStack::PopAndDestroy(dbInfo71); + CleanupStack::PopAndDestroy(dbInfo66Bad); + CleanupStack::PopAndDestroy(dbInfo66); + CleanupStack::PopAndDestroy(dbInfo64Bad); + CleanupStack::PopAndDestroy(dbInfo64); + +///////////////////////////////////////////////////////////////////// + // Should work OK: + iDbMan->DatabaseExistsL(KMaxLengthString64); + iDbMan->DatabaseExistsL(KMaxLengthString66); + iDbMan->DatabaseExistsL(KMaxLengthString71); + iDbMan->DatabaseExistsL(KMaxLengthString73); + + TRAP(err, iDbMan->DatabaseExistsL(KNullDesC)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + + TRAP(err, iDbMan->DatabaseExistsL(KMaxLengthString64Bad)); + AssertTrueSecL(err == KErrNone, KErrorWrongCode); + TRAP(err, iDbMan->DatabaseExistsL(KMaxLengthString66Bad)); + AssertTrueSecL(err == KErrNone, KErrorWrongCode); + TRAP(err, iDbMan->DatabaseExistsL(KMaxLengthString71Bad)); + AssertTrueSecL(err == KErrNone, KErrorWrongCode); + TRAP(err, iDbMan->DatabaseExistsL(KMaxLengthString73Bad)); + AssertTrueSecL(err == KErrNone, KErrorWrongCode); + +///////////////////////////////////////////////////////////////////// + + // Should work OK: + iDbMan->SetDefaultDatabaseUriL(KMaxLengthString64); + iDbMan->SetDefaultDatabaseUriL(KMaxLengthString66); + iDbMan->SetDefaultDatabaseUriL(KMaxLengthString71); + iDbMan->SetDefaultDatabaseUriL(KMaxLengthString73); + + // Should not work: + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KNullDesC)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KMaxLengthString64Bad)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCode); + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KMaxLengthString66Bad)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCode); + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KMaxLengthString71Bad)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCode); + TRAP(err, iDbMan->SetDefaultDatabaseUriL(KMaxLengthString73Bad)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCode); + +///////////////////////////////////////////////////////////////////// + // Should work OK: + iDbMan->DeleteDatabaseL(KMaxLengthString64); + iDbMan->DeleteDatabaseL(KMaxLengthString66); + iDbMan->DeleteDatabaseL(KMaxLengthString71); + iDbMan->DeleteDatabaseL(KMaxLengthString73); + + // Should not work: + + TRAP(err, iDbMan->DeleteDatabaseL(KMaxLengthString64Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->DeleteDatabaseL(KMaxLengthString66Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->DeleteDatabaseL(KMaxLengthString71Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + TRAP(err, iDbMan->DeleteDatabaseL(KMaxLengthString73Bad)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCode); + + } + +// --------------------------------------------------------- +// CPosTp104::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp104::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDbMan; + iDbMan = NULL; + + delete iLandmarksDb; + iLandmarksDb = NULL; + + delete iRepository; + iRepository = NULL; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp105.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp105.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,334 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp105.h" +#include +#include "FT_LandmarkConstants.h" +#include +#include + +// CONSTANTS + +_LIT(KResourceFileROM, "z:\\resource\\eposlmdefaultdbname.R"); +_LIT(KResourceFile, "c:\\resource\\eposlmdefaultdbname.R"); +_LIT(KResourceFileCOPY, "c:\\resource\\COPY_eposlmdefaultdbname.R"); + +#ifdef __WINS__ + _LIT(KResourceFileTEST, "z:\\system\\test\\testdata\\tp105_eposlmdefaultdbname.R"); +#else + _LIT(KResourceFileTEST, "c:\\system\\test\\testdata\\tp105_eposlmdefaultdbname.R"); +#endif + +_LIT(KDefaultName_En, "TP105 Default Landmarks"); +_LIT(KDefaultName_Sw, "Mina små landmarks"); +_LIT(KEnglish, "English"); +_LIT(KSwedish, "Swedish"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp105::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp105::StartL() + { +#ifdef __WINS__ + _LIT(KNotSupported, "Test case is not supported on WINS, execute on target!"); + LogErrorAndLeave(KNotSupported); +#endif + _LIT(KCancelled, "Test cancelled"); + _LIT(KLangChanged, "Have you changed the language to swedish in the phone ? (Should be English currently.)"); + _LIT(KChangeLang, "Change language to Swedish in phone (you will need to reboot the phone)"); + _LIT(KWrongLanguageEnglish, "Wrong language on phone, should be English"); + _LIT(KWrongLanguageSwedish, "Wrong language on phone, should be Swedish"); + + /* +LMREQ200: Display Name for Default Database +If the display name has not been set for the default database, +a localized default display name shall be used. The localized display name +is read from a resource file and it is language dependent. +If the user changes language for the phone, the localized display name shall change accordingly. +*/ + + TUtfwUserAnswer answer = iUserInfo->ShowDialog(KLangChanged, EUtfwDialogTypeYesNo, EFalse); + //TUtfwUserAnswer answer = EUtfwUserAnswerNo; + if(answer == EUtfwUserAnswerNo) + { + RemoveAllLmDatabasesL(); + // Copy the default display name resource file with english name to + // c:\\resource + // This file should be used when language is english + CopyResourceFileL(_L("01")); + + // Create a database and set it to be default + // Since the display name has not been set for this db it should be read + // from localiased resource file + _LIT(KDB, "TP105_Db.ldb"); + iDbMan = CPosLmDatabaseManager::NewL(); + HPosLmDatabaseInfo* dbInfo01 = HPosLmDatabaseInfo::NewLC(KDB); + iDbMan->CreateDatabaseL(*dbInfo01); + CleanupStack::PopAndDestroy(dbInfo01); + iDbMan->SetDefaultDatabaseUriL(KDB); + + delete iDbMan; + iDbMan = NULL; + + TBuf<50> buf; + TInt lang = User::Language(); + buf.Format(_L("***** Language %d ******"), lang); + iLog->Put(buf); + + if (lang != 1) + { + LogErrorAndLeave(KWrongLanguageEnglish, KErrGeneral); + } + + CheckDisplayNameL(KEnglish, KDefaultName_En); + + answer = iUserInfo->ShowDialog(KChangeLang, EUtfwDialogTypeOkCancel, EFalse); + //answer = EUtfwUserAnswerOk; + AssertTrueSecL(answer == EUtfwUserAnswerOk, KCancelled, KErrCancel); + } + else + { + TInt lang = User::Language(); + TBuf<50> buf; + buf.Format(_L("***** Language %d ******"), lang); + iLog->Put(buf); + + if (lang != 6) + { + LogErrorAndLeave(KWrongLanguageSwedish, KErrGeneral); + } + + // Copy the default display name resource file with swedish name to + // c:\\resource + // This file should be used when language is changed into swedish + CopyResourceFileL(_L("06")); + + CheckDisplayNameL(KSwedish, KDefaultName_Sw); + + _LIT(KTestSucceeded, "Localization test for displayname succeeded!"); + //iUserInfo->ShowDialog(KTestSucceeded, EUtfwDialogTypeOk, EFalse); + + // Remove both swedish and english test resource files + // used in this test, also restores the original resource files + RemoveResourceFileL(_L("01")); + RemoveResourceFileL(_L("06")); + iLog->Put(KTestSucceeded); + } + } + +// --------------------------------------------------------- +// CPosTp105::CheckDisplayNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp105::CheckDisplayNameL(const TDesC& aLanguage, const TDesC& aDisplayName) + { + iLog->Put(_L("CheckDisplayNameL")); + _LIT(KQuestionFormat, "Does the language look like %S?: %S"); + _LIT(KErrLangError, "The language of the displayname is not correct."); + _LIT(KMatchCriteria, "://"); + _LIT(KErrMatch, "Error. Displayname matches filename."); + _LIT(KErrMatchUri, "Error. Displayname matches URI."); + _LIT(KErrMatchDisplay, "Error. Displayname does not match localised name"); + + // Get the display name: + iDbMan = CPosLmDatabaseManager::NewL(); + HBufC* defaultUri = iDbMan->DefaultDatabaseUriLC(); + + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(defaultUri->Des()); + + iDbMan->GetDatabaseInfoL(*dbInfo); + + TPosLmDatabaseSettings settings = dbInfo->Settings(); + TPtrC defaultDisplayName = settings.DatabaseName(); + CleanupStack::PopAndDestroy(dbInfo); + + TInt stringPos = defaultUri->Find(KMatchCriteria); + TBuf<50> uriFileName = defaultUri->Right(defaultUri->Length() - (stringPos + 5)); + + AssertTrueSecL(uriFileName != defaultDisplayName, KErrMatch); + AssertTrueSecL(defaultUri->Des() != defaultDisplayName, KErrMatchUri); + AssertTrueSecL(defaultDisplayName.CompareC(aDisplayName) == 0, KErrMatchDisplay); + + iLog->Put(defaultDisplayName); + iLog->Put(uriFileName); + iLog->Put(defaultUri->Des()); + + TBuf<100> question; + question.Format(KQuestionFormat, &aLanguage, &defaultDisplayName); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(question, EUtfwDialogTypeYesNo, EFalse); + CleanupStack::PopAndDestroy(defaultUri); + //TUtfwUserAnswer answer = EUtfwUserAnswerYes; + AssertTrueSecL(answer == EUtfwUserAnswerYes, KErrLangError); + + delete iDbMan; + iDbMan = NULL; + + } + +// --------------------------------------------------------- +// CPosTp105::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp105::CloseTest() + { + iLog->Put(_L("CloseTest")); + + delete iDbMan; + iDbMan = NULL; + + } + +// --------------------------------------------------------- +// CPosTp105::CopyResourceFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp105::CopyResourceFileL(const TDesC& aResourceNr) + { + iLog->Put(_L("CopyResourceFileL")); + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + TBuf<55> pathROM; + TBuf<55> pathWINS; + TBuf<55> pathCOPY; + TBuf<55> pathTEST; + + pathROM.Append(KResourceFileROM); + pathWINS.Append(KResourceFile); + pathCOPY.Append(KResourceFileCOPY); + pathTEST.Append(KResourceFileTEST); + + pathROM.Append(aResourceNr); + pathWINS.Append(aResourceNr); + pathCOPY.Append(aResourceNr); + pathTEST.Append(aResourceNr); + + iLog->Put(pathROM); + //check if landmark is flashed + if (!BaflUtils::FileExists(fs, pathROM)) + { + iLog->Put(_L("Landmark is NOT flashed, rename resource file")); + //Landmark is not flashed rename the file before copy a own defiend file. + //since landmark is not flashed the file should exist hence leaving if it is not found! + iLog->Put(pathWINS); + iLog->Put(pathCOPY); + + TInt err = fileMan->Rename(pathWINS, pathCOPY, CFileMan::EOverWrite); + if (err != KErrNone && err != KErrNotFound) + iLog->Put(_L("Problem renaming original global categories file")); + } + else + { + iLog->Put(_L("Landmark is flashed, copy resource file")); + } + iLog->Put(pathTEST); + iLog->Put(pathWINS); + + User::LeaveIfError(fileMan->Copy(pathTEST, pathWINS, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + iLog->Put(_L("CopyResourceFileL Done")); + } + +// --------------------------------------------------------- +// CPosTp105::RemoveResourceFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp105::RemoveResourceFileL(const TDesC& aResourceNr) + { + iLog->Put(_L("RemoveResourceFileL")); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + TBuf<55> pathROM; + TBuf<55> pathWINS; + TBuf<55> pathCOPY; + TBuf<55> pathTEST; + + pathROM.Append(KResourceFileROM); + pathWINS.Append(KResourceFile); + pathCOPY.Append(KResourceFileCOPY); + pathTEST.Append(KResourceFileTEST); + + pathROM.Append(aResourceNr); + pathWINS.Append(aResourceNr); + pathCOPY.Append(aResourceNr); + pathTEST.Append(aResourceNr); + + //check if the default display name resource file exist in rom + //if landmarks is flashed it is just okej to remove + // file in on the c drive. + iLog->Put(pathROM); + if (BaflUtils::FileExists(fs, pathROM)) + { + iLog->Put(_L("Landmark is flashed, delete resource file")); + //in this case it is same just to remove it form c if it exists: + iLog->Put(pathWINS); + if (BaflUtils::FileExists(fs, pathWINS)) + { + User::LeaveIfError(fileMan->Delete(pathWINS)); + } + } + else + { + iLog->Put(_L("Landmark is NOT flashed, delete resource file and rename the old file")); + //If a copy exist this should be used, but if it does not + //exist the file is not removed since it is hard to know + //if anything has gone wrong. + iLog->Put(pathCOPY); + iLog->Put(pathWINS); + if(BaflUtils::FileExists(fs, pathCOPY)) + { + //first delete the used file, if it exist + if (BaflUtils::FileExists(fs, pathWINS)) + { + User::LeaveIfError(fileMan->Delete(pathWINS)); + } + //Rename the copy file + User::LeaveIfError(fileMan->Rename(pathCOPY, pathWINS, CFileMan::EOverWrite)); + } + } + CleanupStack::PopAndDestroy(2); + iLog->Put(_L("RemoveResourceFileL Done")); + } + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp106.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp106.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,580 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include + +#include +#include +#include + +#include "FT_CPosTp106.h" + +// Nr of simultaneous clients (threads) +const TInt KNoMultipleClients = 5; + +// Nr of created dbs +const TInt KNrOfDBs=25; +const TInt KCheckIfExistDBs=10; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp106::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::CloseTest() + { + iLog->Log(_L("CloseTest")); + for (TInt i=0; iLog(_L("Error when deleting all lm dbs")); + + } + +// --------------------------------------------------------- +// CPosTp106::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::StartL() + { + MakeSurePanicDebugFileExistsL(); + + RemoveAllLmDatabasesL(); + + iUseLogFromThreadIsDisabled = ETrue; + + TBuf<150> buf; + + _LIT(KTrace1, "Create %d x %d (=%d) nr of dbs took = %d msec"); + _LIT(KTrace2, "Copy %d x %d (=%d) nr of dbs took = %d msec"); + _LIT(KTrace3, "Get and Set default URI for %d x %d (=%d) nr of dbs took = %d msec"); + _LIT(KTrace4, "Get display name for %d x %d (=%d) nr of dbs took = %d msec"); + _LIT(KTrace5, "Check if db exist for %d x %d (=%d) nr of dbs took = %d msec"); + _LIT(KTrace6, "Delete %d x %d (=%d) nr of dbs took = %d msec"); + + iTestStep=Step1; + StartMultipleClientsL(KNoMultipleClients); + TInt64 msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace1, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + iTestStep=Step2; + StartMultipleClientsL(KNoMultipleClients); + msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace2, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + iTestStep=Step3; + StartMultipleClientsL(KNoMultipleClients); + msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace3, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + iTestStep=Step4; + StartMultipleClientsL(KNoMultipleClients); + msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace4, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + iTestStep=Step5; + StartMultipleClientsL(KNoMultipleClients); + msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace5, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + iTestStep=Step6; + StartMultipleClientsL(KNoMultipleClients); + msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(KTrace6, KNrOfDBs, KNoMultipleClients, KNrOfDBs*KNoMultipleClients, msec); + iLog->Log(buf); + + } + +// --------------------------------------------------------- +// CPosTp106::StartMultipleClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::StartMultipleClientsL(const TUint aNoClients) + { + _LIT(KMultipleErr, "Error %d from thread %d"); + _LIT(KPanicErr, "Thread %d has panicked or is alive"); + _LIT(KSuccess, "Thread %d is successful"); + + CreateThreadsL(aNoClients); + + RArray statuses; + CleanupClosePushL(statuses); + + // Start measuring time + iStart.UniversalTime(); + + for (TUint j=0; j info; + + if (exitReason != KErrNone) + { + errors++; + info.Format(KMultipleErr, exitReason, i+1); + } + else + { + info.Format(KSuccess, i+1); + } + iLog->Log(info); + + AssertTrueSecL(iThreads[i].ExitType() == EExitKill, KPanicErr, i+1); + AssertTrueSecL(exitReason == KErrNone || exitReason == KErrLocked, info); + } + + // Stop measuring time + iStop.UniversalTime(); +/* + if (iTestStep != EReadLockTaken) + { + AssertTrueSecL(errors == KNoMultipleClients - 1, KAllErr); + } + else + { + // All imports should have failed since the started search should have taken a read lock + AssertTrueSecL(errors == KNoMultipleClients, KAllNotFailedErr); + } + */ + + for (i=0; i(aData); + TInt index = ++self->iThreadIndex; + + TBuf<100> info; + _LIT(KInfo2, "Thread %d before execute"); + info.Format(KInfo2, index); + RDebug::Print(info); + + switch (self->iTestStep) + { + case Step1: + self->CreateAndListDatabasesL(index); + break; + case Step2: + self->CopyDatabasesL(index); + break; + case Step3: + self->SetAndGetUriL(index); + break; + case Step4: + self->GetDisplayNameL(); + break; + case Step5: + self->CheckIfExistL(index); + break; + case Step6: + self->DeleteDatabasesL(); + break; + } + + _LIT(KInfo3, "Thread %d after execute"); + info.Format(KInfo3, index); + RDebug::Print(info); + } + +// --------------------------------------------------------- +// CPosTp106::CreateAndListDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::CreateAndListDatabasesL(TInt index) + { + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + _LIT(KLmName, "Thread_%d_LmDbIndex%d.ldb"); + _LIT(KLmURI, "file://C:Thread_%d_LmDbIndex%d.ldb"); + TBuf<50> lmDbName; + TBuf<50> lmDbUri; + TInt i=0; + TInt NrOfFoundDbs=0; + // Create KNrOfDBs nr of landmark dbs + + HPosLmDatabaseInfo* dbInfo = NULL; + for (i=0;iCreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + /* + This increases the filesize to much + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(lmDbName); + CleanupStack::PushL(db); + + if (db->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(db->InitializeL()); + } + CleanupStack::PopAndDestroy(db); + */ + } + + // List all dbs + CDesCArray* dbArray = manager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + + // Check that at least KNrOfDBs nr of dbs exist + if (nr < KNrOfDBs) User::Panic(_L("Wrong Nr"), -666); + + // Check that all created dbs are listed + for (TInt j=0;j lmDbName; + TBuf<50> lmDbNameCopy; + TBuf<50> lmDbUriCopy; + TInt i=0; + TInt NrOfFoundDbs=0; + // Create KNrOfDBs nr of landmark dbs + for (i=0;iCopyDatabaseL(lmDbName, lmDbNameCopy); + } + + // List all dbs + CDesCArray* dbArray = manager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + + // Check that at least all copied dbs are listed + for (TInt j=0;j lmDbUri; + TBuf<50> lmDbUriCopy; + + CDesCArray* dbArray = manager->ListDatabasesLC(); + TInt nr = dbArray->Count(); + + // Delete all created dbs and copied dbs + for (TInt j=0;jDeleteDatabaseL((*dbArray)[j])); + } + + /* + // Delete all created dbs and copied dbs + for (TInt j=0;jDeleteDatabaseL(lmDbUriCopy); + manager->DeleteDatabaseL(lmDbUri); + } + */ + + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(manager); + } + +// --------------------------------------------------------- +// CPosTp106::SetAndGetUriL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::SetAndGetUriL(TInt /*index*/) + { + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + _LIT(KLmURI, "file://C:Thread_%d_LmDbIndex%d.ldb"); + + // Try to set (and get) defaultdb to dbs created by first thread + TBuf<50> name; + + // index = 0; + for (TInt j=0;jSetDefaultDatabaseUriL(name); + + HBufC* defaultName = manager->DefaultDatabaseUriLC(); + + // TBD Maybe some other client has succeeded in changing the default name already + if (defaultName->Compare(name) != KErrNone) + { + User::Panic(_L("WrongDefaultDb"), -671); + } + CleanupStack::PopAndDestroy(defaultName); + } + CleanupStack::PopAndDestroy(manager); + } + +// --------------------------------------------------------- +// CPosTp106::GetDisplayNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::GetDisplayNameL() + { + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // Get display name for default db + for (TInt j=0;jDefaultDatabaseUriLC(); + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(dbUri->Des()); + TPosLmDatabaseSettings settings = dbInfo->Settings(); + TPtrC displayName = settings.DatabaseName(); + CleanupStack::PopAndDestroy(2); + } + + CleanupStack::PopAndDestroy(manager); + } + +// --------------------------------------------------------- +// CPosTp106::CheckIfExistL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::CheckIfExistL(TInt index) + { + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + _LIT(KLmURICopy, "file://C:Thread_%d_LmDbIndex%d_Copy.ldb"); + _LIT(KLmURI, "file://C:Thread_%d_LmDbIndex%d.ldb"); + + _LIT(KLmNonExistingURI, "file://C:THREAD_%d_PELLE_%d.LDB"); + + TBuf<50> lmDbUri; + TBuf<50> lmDbUriCopy; + TBuf<50> lmDbNonExistingUri; + + TInt j=0; + // Check that some created dbs and copied dbs exist + // Check that non existing db does not exist + + // Check files created by first thread only + index=1; + + for (j=0;jDatabaseExistsL(lmDbUriCopy); + if (!res) User::Panic(_L("DbNotExist"), -668); + + // Should exist + res = manager->DatabaseExistsL(lmDbUri); + if (!res) User::Panic(_L("DbNotExist"), -669); + + // Should NOT exist + res = manager->DatabaseExistsL(lmDbNonExistingUri); + if (res) User::Panic(_L("DbExist"), -670); + } + + CleanupStack::PopAndDestroy(manager); + } + +// --------------------------------------------------------- +// ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp106::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp106::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp106::CreateThreadsL(const TUint aNoThreads) + { + _LIT(KThreadName, "Tp106testthread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TUint i=0; i name; + name.Format(KThreadName, 1 + iThreadNum++); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp107.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp107.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDE FILES +#include "FT_CPosTp666.h" + +#include +#include +#include +#include + +// CONSTANTS +_LIT(KSetCapPath, "c:\\sys\\bin\\setcap.exe"); +// Nr of tests in this TP +const TInt KNrOfTests = 4; + +// ================= MEMBER FUNCTIONS ======================= + +// Destructor +CPosTp666::~CPosTp666() + { + } + +// --------------------------------------------------------- +// CPosTp666::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +void CPosTp666::GetName(TDes& aName) const + { + _LIT(KTestName0, "SetCap-TP107"); + aName = KTestName0; + } + +// --------------------------------------------------------- +// CPosTp666::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp666::StartL() + { + iLog->Put(_L("StartL")); + + SetupTestPartL(0); + SetupTestPartL(1); + SetupTestPartL(2); + SetupTestPartL(3); + } + +// --------------------------------------------------------- +// CPosTp666::SetupTestPartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp666::SetupTestPartL(TInt aIndex) + { + iLog->Put(_L("StartL(TInt aIndex)")); +/* +#ifdef __WINS__ + _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); + LogErrorAndLeave(KNotOnWins); + +#endif +*/ +TBuf<20> capability; +switch (aIndex) +{ + case 0: + iLog->Put(_L("Part1")); + capability.Zero(); + // Set to all cap but readuserdata and writeuserdata + capability.Append(_L("27FFF")); + break; + + case 1: + iLog->Put(_L("Part2")); + // Set to Set to all cap but writeuserdata + capability.Append(_L("2FFFF")); + break; + + case 2: + iLog->Put(_L("Part3")); + // Set to Set to all cap but readuserdata + capability.Append(_L("37FFF")); + break; + + case 3: + iLog->Put(_L("Part4")); + // Set to only readuserdata and writeuserdata + capability.Append(_L("18000")); + break; + + default: + iLog->Put(_L("Default")); + LogErrorAndLeave(_L("We should never come here")); + break; +} + // Only for target, on winscw use bat-script + RProcess execlient; + RFile file; + RFs fileSession; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + CleanupClosePushL(file); + CFileMan* fileMan = CFileMan::NewL(fileSession); + CleanupStack::PushL(fileMan); + + TBuf<100> buf; + + buf.Append(_L("CapabilityTests.exe ")); + buf.Append(capability); + buf.Append(_L(" CapabilityTests_tmp.exe")); + + // Make call to SetCap + TInt result = execlient.Create(KSetCapPath, + //_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"), + buf, + TUidType(KNullUid, KNullUid, KNullUid)); + User::LeaveIfError(result); + execlient.Resume(); //make the execlient visible + User::After(800000); //Wait 0.8 s + + execlient.Close(); //Close handle to exe-client + + // now move file CapabilityTests_tmp.exe to CapabilityTests.exe + TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); + if (err != KErrNone) + { + iLog->Put(_L("Move problem")); + LogErrorAndLeave(_L("Move problem"), err); + } + + CleanupStack::PopAndDestroy(fileMan); //fileMan + CleanupStack::PopAndDestroy(&file); //file + CleanupStack::PopAndDestroy(&fileSession); //fileSession + + // Prepare test conditions + SetupTestEnvironmentL(); + + buf.Zero(); + buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); + //if(answer == EUtfwUserAnswerNo) + } + +// --------------------------------------------------------- +// CPosTp666::SetupTestEnvironmentL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp666::SetupTestEnvironmentL() + { + iLog->Put(_L("SetupTestEnvironmentL")); + + // Setup start conditions for compatibility test + _LIT(KDefaultDb, "file://c:eposlm.ldb"); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // Remove all landmark databases + CDesCArray* uris = dbManager->ListDatabasesL(); + CleanupStack::PushL(uris); + for (TInt i = 0; i < uris->Count(); i++) + { + dbManager->DeleteDatabaseL((*uris)[i]); + } + CleanupStack::PopAndDestroy(uris); + + // Create and initialize a default database + dbManager->CreateDatabaseL(KDefaultDb); + dbManager->SetDefaultDatabaseL(KDefaultDb); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + ExecuteAndDeleteLD(database->InitializeL()); + + // Add 5 landmarks - will generate ids 1 - 5 + const TInt KFive = 5; + for (TInt j = 0; j < KFive; j++) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("Landmark")); + database->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + + // Add 5 categories + CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catManager); + for (TInt k = 0; k < KFive; k++) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + TBuf<15> name; + name = _L("Category "); + name.AppendNum(k); + category->SetCategoryNameL(name); + catManager->AddCategoryL(*category); + CleanupStack::PopAndDestroy(category); + } + + CleanupStack::PopAndDestroy(3, dbManager); + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp108.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp108.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,239 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDE FILES +#include "FT_CPosTp667.h" + +#include +#include +#include +#include + +// CONSTANTS +_LIT(KSetCapPath, "c:\\sys\\bin\\setcap.exe"); +// Nr of tests in this TP +const TInt KNrOfTests = 6; + +// ================= MEMBER FUNCTIONS ======================= + +// Destructor +CPosTp667::~CPosTp667() + { + } + +// --------------------------------------------------------- +// CPosTp667::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +void CPosTp667::GetName(TDes& aName) const + { + _LIT(KTestName0, "SetCap-TP108"); + aName = KTestName0; + } + +// --------------------------------------------------------- +// CPosTp667::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp667::StartL() + { + iLog->Put(_L("StartL")); + + SetupTestPartL(0); + SetupTestPartL(1); + SetupTestPartL(2); + SetupTestPartL(3); + SetupTestPartL(4); + SetupTestPartL(5); + } + +// --------------------------------------------------------- +// CPosTp667::SetupTestPartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp667::SetupTestPartL(TInt aIndex) + { + iLog->Put(_L("StartL(TInt aIndex)")); +/* +#ifdef __WINS__ + _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); + LogErrorAndLeave(KNotOnWins); + +#endif +*/ +TBuf<20> capability; +switch (aIndex) +{ + case 0: + iLog->Put(_L("Part1")); + capability.Zero(); + // Set to no capablities at all + capability.Append(_L("0")); + break; + + case 1: + iLog->Put(_L("Part2")); + // Set to ReadUserData + capability.Append(_L("8000")); + break; + + case 2: + iLog->Put(_L("Part3")); + // Set to WriteUserData + capability.Append(_L("10000")); + break; + + case 3: + iLog->Put(_L("Part4")); + // Set to ReadUserData and WriteUserData + capability.Append(_L("18000")); + break; + + case 4: + iLog->Put(_L("Part5")); + // Set to WriteDeviceData + capability.Append(_L("20")); + break; + + case 5: + iLog->Put(_L("Part6")); + // Set to ReadUserData, WriteUserData and WriteDeviceData + capability.Append(_L("18020")); + break; + + default: + iLog->Put(_L("Default")); + LogErrorAndLeave(_L("We should never come here")); + break; +} + // Only for target, on winscw use bat-script + RProcess execlient; + RFile file; + RFs fileSession; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + CleanupClosePushL(file); + CFileMan* fileMan = CFileMan::NewL(fileSession); + CleanupStack::PushL(fileMan); + + TBuf<100> buf; + + buf.Append(_L("CapabilityTests.exe ")); + buf.Append(capability); + buf.Append(_L(" CapabilityTests_tmp.exe")); + + // Make call to SetCap + TInt result = execlient.Create(KSetCapPath, + //_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"), + buf, + TUidType(KNullUid, KNullUid, KNullUid)); + User::LeaveIfError(result); + execlient.Resume(); //make the execlient visible + User::After(800000); //Wait 0.8 s + + execlient.Close(); //Close handle to exe-client + + // now move file CapabilityTests_tmp.exe to CapabilityTests.exe + TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); + if (err != KErrNone) + { + iLog->Put(_L("Move problem")); + LogErrorAndLeave(_L("Move problem"), err); + } + + CleanupStack::PopAndDestroy(fileMan); //fileMan + CleanupStack::PopAndDestroy(&file); //file + CleanupStack::PopAndDestroy(&fileSession); //fileSession + + // Prepare test conditions + SetupTestEnvironmentL(); + + buf.Zero(); + buf.Format(_L("SetCap done, Now Execute CapabilityTest TP108, part %d"), aIndex+1); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); + //if(answer == EUtfwUserAnswerNo) + } + +// --------------------------------------------------------- +// CPosTp667::SetupTestEnvironmentL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp667::SetupTestEnvironmentL() + { + iLog->Put(_L("SetupTestEnvironmentL")); + + // Setup start conditions for compatibility test + _LIT(KDefaultDb, "file://c:eposlm.ldb"); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // Remove all landmark databases + CDesCArray* uris = dbManager->ListDatabasesL(); + CleanupStack::PushL(uris); + for (TInt i = 0; i < uris->Count(); i++) + { + dbManager->DeleteDatabaseL((*uris)[i]); + } + CleanupStack::PopAndDestroy(uris); + + // Create and initialize a default database + dbManager->CreateDatabaseL(KDefaultDb); + dbManager->SetDefaultDatabaseL(KDefaultDb); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + ExecuteAndDeleteLD(database->InitializeL()); + + // Add 5 landmarks - will generate ids 1 - 5 + const TInt KFive = 5; + for (TInt j = 0; j < KFive; j++) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("Landmark")); + database->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + + // Add 5 categories + CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catManager); + for (TInt k = 0; k < KFive; k++) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + TBuf<15> name; + name = _L("Category "); + name.AppendNum(k); + category->SetCategoryNameL(name); + catManager->AddCategoryL(*category); + CleanupStack::PopAndDestroy(category); + } + + CleanupStack::PopAndDestroy(3, dbManager); + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp109.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp109.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDE FILES +#include "FT_CPosTp668.h" + +#include +#include +#include +#include + +// CONSTANTS +_LIT(KSetCapPath, "c:\\sys\\bin\\setcap.exe"); +// Nr of tests in this TP +const TInt KNrOfTests = 12; + +// ================= MEMBER FUNCTIONS ======================= + +// Destructor +CPosTp668::~CPosTp668() + { + } + +// --------------------------------------------------------- +// CPosTp668::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +void CPosTp668::GetName(TDes& aName) const + { + _LIT(KTestName0, "SetCap-TP109"); + aName = KTestName0; + } + +// --------------------------------------------------------- +// CPosTp668::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp668::StartL() + { + iLog->Put(_L("StartL")); + + SetupTestPartL(0); + SetupTestPartL(1); + SetupTestPartL(2); + SetupTestPartL(3); + SetupTestPartL(4); + SetupTestPartL(5); + SetupTestPartL(6); + SetupTestPartL(7); + SetupTestPartL(8); + SetupTestPartL(9); + SetupTestPartL(10); + SetupTestPartL(11); + } + +// --------------------------------------------------------- +// CPosTp668::SetupTestPartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp668::SetupTestPartL(TInt aIndex) + { + iLog->Put(_L("StartL(TInt aIndex)")); +/* +#ifdef __WINS__ + _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); + LogErrorAndLeave(KNotOnWins); + +#endif +*/ +TBuf<20> capability; +switch (aIndex) +{ + case 0: + iLog->Put(_L("Part1")); + capability.Zero(); + // Set to no capabilites at all + capability.Append(_L("0")); + break; + + case 1: + iLog->Put(_L("Part2")); + // Set to All capabilities of CAP_CLIENT_DLL but ReadUserData + capability.Append(_L("37FFE")); + break; + + case 2: + iLog->Put(_L("Part3")); + // Set to All capabilities of CAP_CLIENT_DLL but WriteUserData + capability.Append(_L("2FFFE")); + break; + + case 3: + iLog->Put(_L("Part4")); + // Set to All capabilities of CAP_CLIENT_DLL but WriteUserData and ReadUserData + capability.Append(_L("27FFE")); + break; + + case 4: + iLog->Put(_L("Part5")); + // Set to all capabilities of CAP_CLIENT_DLL + capability.Append(_L("3FFFE")); + break; + + case 5: + iLog->Put(_L("Part6")); + // Set to Only TCB + capability.Append(_L("1")); + break; + + case 6: + iLog->Put(_L("Part7")); + // Set to All capabilities but CAP_RECOGNIZER_DLL and TCB + capability.Append(_L("3FEFE")); + break; + + case 7: + iLog->Put(_L("Part8")); + // Set to Only CAP_RECOGNIZER_DLL + capability.Append(_L("100")); + break; + + case 8: + iLog->Put(_L("Part9")); + // Set to Only CAP_RECOGNIZER_DLL and ReadUserData + capability.Append(_L("8100")); + break; + + case 9: + iLog->Put(_L("Part10")); + // Set to All capabilities but CAP_SERVER_DLL and TCB + capability.Append(_L("ECE")); + break; + + case 10: + iLog->Put(_L("Part11")); + // Set to CAP_SERVER_DLL + capability.Append(_L("3F130")); + break; + + case 11: + iLog->Put(_L("Part12")); + // Set to CAP_SERVER_DLL and CommDD + capability.Append(_L("3F132")); + break; + + default: + iLog->Put(_L("Default")); + LogErrorAndLeave(_L("We should never come here")); + break; +} + // Only for target, on winscw use bat-script + RProcess execlient; + RFile file; + RFs fileSession; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + CleanupClosePushL(file); + CFileMan* fileMan = CFileMan::NewL(fileSession); + CleanupStack::PushL(fileMan); + + TBuf<100> buf; + + buf.Append(_L("CapabilityTests.exe ")); + buf.Append(capability); + buf.Append(_L(" CapabilityTests_tmp.exe")); + + // Make call to SetCap + TInt result = execlient.Create(KSetCapPath, + buf, + TUidType(KNullUid, KNullUid, KNullUid)); + User::LeaveIfError(result); + execlient.Resume(); //make the execlient visible + User::After(800000); //Wait 0.8 s + + execlient.Close(); //Close handle to exe-client + + // now move file CapabilityTests_tmp.exe to CapabilityTests.exe + TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); + if (err != KErrNone) + { + iLog->Put(_L("Move problem")); + LogErrorAndLeave(_L("Move problem"), err); + } + + CleanupStack::PopAndDestroy(fileMan); //fileMan + CleanupStack::PopAndDestroy(&file); //file + CleanupStack::PopAndDestroy(&fileSession); //fileSession + + // Prepare test conditions + SetupTestEnvironmentL(); + + buf.Zero(); + buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); + //if(answer == EUtfwUserAnswerNo) + } + +// --------------------------------------------------------- +// CPosTp668::SetupTestEnvironmentL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp668::SetupTestEnvironmentL() + { + iLog->Put(_L("SetupTestEnvironmentL")); + + // Setup start conditions for compatibility test + _LIT(KDefaultDb, "file://c:eposlm.ldb"); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // Remove all landmark databases + CDesCArray* uris = dbManager->ListDatabasesL(); + CleanupStack::PushL(uris); + for (TInt i = 0; i < uris->Count(); i++) + { + dbManager->DeleteDatabaseL((*uris)[i]); + } + CleanupStack::PopAndDestroy(uris); + + // Create and initialize a default database + dbManager->CreateDatabaseL(KDefaultDb); + dbManager->SetDefaultDatabaseL(KDefaultDb); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + ExecuteAndDeleteLD(database->InitializeL()); + + // Add 5 landmarks - will generate ids 1 - 5 + const TInt KFive = 5; + for (TInt j = 0; j < KFive; j++) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("Landmark")); + database->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + + // Add 5 categories + CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catManager); + for (TInt k = 0; k < KFive; k++) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + TBuf<15> name; + name = _L("Category "); + name.AppendNum(k); + category->SetCategoryNameL(name); + catManager->AddCategoryL(*category); + CleanupStack::PopAndDestroy(category); + } + + CleanupStack::PopAndDestroy(3, dbManager); + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp11.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp11.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,435 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp11.h" +#include +#include +#include +#include + +//CONSTANTS +const TInt KNoCategoriesTp11 = 100; +const TInt KNoLandmarksTp11 = 100; + +_LIT(KCategoryIteratorNumOfItemsErr, "The iterator returns incorrect number of items"); +_LIT(KCategoryIteratorIdErr, "A category id not in the database returned from the iterator"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp11::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::StartL() + { + iLog->Log(_L("***** Testing CPosCategoryManager::CategoryIteratorL() and CPosCategoryManager::ReferencedCategoryIteratorL()***** ")); + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + iLog->Log(_L("ExecuteAndDeleteLD(iDatabase->InitializeL())")); + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L("Default database opened and initialized ")); + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + MakeEmptyLmDatabaseL( *iDatabase, *iCategoryManager); + + iLog->Log(_L("Deleting all landmarks and categories to create empty database Done")); + + AddCategoriesL(); + AddLandmarksL(); + + iLog->Log(_L("** 1: Testing CPosCategoryManager::CategoryIteratorL() (Iteration of categories)")); + IterateCategoriesL(); + + iLog->Log(_L("** 2: Testing CPosCategoryManager::ReferencedCategoryIteratorL() (Iteration of referenced categories)")); + + IterateReferencedCategoriesL(); + + iLog->Log(_L("** 3: Testing CPosCategoryManager::CategoryIteratorL() (Iteration of categories)")); + IterateSetOfCategoriesL(); + + iLog->Log(_L("** 4: Testing CPosCategoryManager::CategoryIteratorL() (Iteration of Sorted categories)")); + IterateSortedCategoriesL(); + + iLog->Log(_L("** 5: Testing CPosCategoryManager::ReferencedCategoryIteratorL() (Iteration of Sorted referenced categories)")); + IterateReferencedSortedCategoriesL(); + + delete iDatabase; + iDatabase = NULL; + + // Remove lm db + RemoveDefaultDbL(); + } + +// --------------------------------------------------------- +// CPosTp11::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::CloseTest() + { + iLog->Log(_L("CloseTest")); + iCategories.ResetAndDestroy(); + iCategories.Close(); + + iReferencedCategories.Close(); + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase = NULL; + + delete iCategoryManager; + iCategoryManager = NULL; + } + + +// --------------------------------------------------------- +// CPosTp11::AddCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::AddCategoriesL() + { + _LIT(KName, "CategoryTP11 - %d"); + TInt err=KErrLocked; + for (TInt i=0; i categoryName; + categoryName.Format(KName,i); + + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(categoryName); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iCategoryManager->AddCategoryL(*lmc)); + } + + iCategories.Append(lmc); + CleanupStack::Pop(lmc); + } + iLog->Log(_L("Adding categories to database done ")); + } + +// --------------------------------------------------------- +// CPosTp11::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::AddLandmarksL() + { + _LIT(KLmName, "LmTP11 - %d"); + TInt err = KErrLocked; + for (TInt i=0; i lmName; + lmName.Format(KLmName,i); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + + if (i % 2) + { + landmark->AddCategoryL(iCategories[i]->CategoryId()); + iReferencedCategories.Append(*iCategories[i]); + } + + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iDatabase->AddLandmarkL(*landmark)); + } + iLandmarks.Append(landmark); + CleanupStack::Pop(landmark); + } + iLog->Log(_L("Adding categories to landmarks and adding landmarks to database done ")); + } + + +// --------------------------------------------------------- +// CPosTp11::IterateCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::IterateCategoriesL() + { + CPosLmItemIterator* iter = iCategoryManager->CategoryIteratorL(); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)iCategories.Count(), KCategoryIteratorNumOfItemsErr); + + CheckIteratorItemsL(*iter); + + iter->Reset(); + + CheckIteratorItemsL(*iter); + + CleanupStack::PopAndDestroy(iter); + } + +// --------------------------------------------------------- +// CPosTp11::IterateReferencedCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::IterateReferencedCategoriesL() + { + CPosLmItemIterator* iter = iCategoryManager->ReferencedCategoryIteratorL(); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)(iCategories.Count()/2), KCategoryIteratorNumOfItemsErr); + + CheckIteratorItemsL(*iter); + + iter->Reset(); + + CheckIteratorItemsL(*iter); + + CleanupStack::PopAndDestroy(iter); + } + +// --------------------------------------------------------- +// CPosTp11::CheckIteratorItemsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::CheckIteratorItemsL(CPosLmItemIterator& iter) + { + TPosLmItemId id = iter.NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmarkCategory* source = InternalGet(id); + AssertTrueSecL(source != NULL, KCategoryIteratorIdErr); + CPosLandmarkCategory* target = iCategoryManager->ReadCategoryLC(id); + CompareCategoriesL(*source, *target); + CleanupStack::PopAndDestroy(target); + id = iter.NextL(); + } + } + +// --------------------------------------------------------- +// CPosTp11::IterateSetOfCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::IterateSetOfCategoriesL() + { + CPosLmItemIterator* iter = iCategoryManager->CategoryIteratorL(); + CleanupStack::PushL(iter); + + const TInt startIndex=11; + const TInt numOfItems=34; + + RArray ids; + CleanupClosePushL(ids); + + iter->GetItemIdsL(ids, startIndex, numOfItems); + + AssertTrueSecL(ids.Count() == numOfItems, KCategoryIteratorNumOfItemsErr); + + for (TInt i=0; iReadCategoryLC(ids[i]); + CompareCategoriesL(*source, *target); + CleanupStack::PopAndDestroy(target); + } + + CleanupStack::PopAndDestroy(2, iter); + + } + +// --------------------------------------------------------- +// InternalSort +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt InternalSortL(const CPosLandmarkCategory& aSource, const CPosLandmarkCategory& aTarget) + { + TPtrC sourceName, targetName; + + User::LeaveIfError(aSource.GetCategoryName(sourceName)); + User::LeaveIfError(aTarget.GetCategoryName(targetName)); + + return sourceName.Compare(targetName); + } + +// --------------------------------------------------------- +// CPosTp11::IterateSortedCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::IterateSortedCategoriesL() + { + + TLinearOrder order(InternalSortL); + iCategories.Sort(order); + + CPosLmItemIterator* iter = iCategoryManager->CategoryIteratorL( + CPosLmCategoryManager::ECategorySortOrderNameDescending); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)iCategories.Count(), KCategoryIteratorNumOfItemsErr); + + TInt lastIndex=iCategories.Count()-1; + for (TInt i=lastIndex; i>=0; i--) + { + CPosLandmarkCategory* target = iCategoryManager->ReadCategoryLC(iter->NextL()); + + CompareCategoriesL(*iCategories[i], *target); + CleanupStack::PopAndDestroy(target); + } + CleanupStack::PopAndDestroy(iter); + + iter = iCategoryManager->CategoryIteratorL( + CPosLmCategoryManager::ECategorySortOrderNameAscending); + CleanupStack::PushL(iter); + + for (TInt j=0; j < iCategories.Count(); j++) + { + CPosLandmarkCategory* target = iCategoryManager->ReadCategoryLC(iter->NextL()); + + CompareCategoriesL(*iCategories[j], *target); + CleanupStack::PopAndDestroy(target); + } + + CleanupStack::PopAndDestroy(iter); + + } + +// --------------------------------------------------------- +// CPosTp11::IterateReferencedSortedCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp11::IterateReferencedSortedCategoriesL() + { + TLinearOrder order(InternalSortL); + + iReferencedCategories.Sort(order); + + CPosLmItemIterator* iter = iCategoryManager->ReferencedCategoryIteratorL( + CPosLmCategoryManager::ECategorySortOrderNameDescending); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)(iCategories.Count()/2), KCategoryIteratorNumOfItemsErr); + + TInt lastIndex=iReferencedCategories.Count()-1; + for (TInt i=lastIndex; i>=0; i--) + { + CPosLandmarkCategory* target = iCategoryManager->ReadCategoryLC(iter->NextL()); + + CompareCategoriesL(iReferencedCategories[i], *target); + CleanupStack::PopAndDestroy(target); + } + + CleanupStack::PopAndDestroy(iter); + + iter = iCategoryManager->ReferencedCategoryIteratorL( + CPosLmCategoryManager::ECategorySortOrderNameAscending); + CleanupStack::PushL(iter); + + for (TInt j=0; j < iReferencedCategories.Count(); j++) + { + CPosLandmarkCategory* target = iCategoryManager->ReadCategoryLC(iter->NextL()); + + CompareCategoriesL(iReferencedCategories[j], *target); + CleanupStack::PopAndDestroy(target); + } + + CleanupStack::PopAndDestroy(iter); + } + +// --------------------------------------------------------- +// CPosT11::InternalGet +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkCategory* CPosTp11::InternalGet(TPosLmItemId id) + { + for (TInt i=0; iCategoryId() == id) + { + return iCategories[i]; + } + } + + return NULL; + } + +// --------------------------------------------------------- +// CPosT11::CreateEmptyLmDatabaseL() +// --------------------------------------------------------- +// +void CPosTp11::MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ) + { + + CPosLmOperation* operation1 = aLdb.RemoveAllLandmarksL(); + //Remove all landmarks from default db : Sync call + ExecuteAndDeleteLD( operation1 ); + + RArray catArray; + CleanupClosePushL( catArray ); + + // Get all the categories from the database and delete them if necessary + CPosLmItemIterator* iter = aCatMgr.CategoryIteratorL(); + CleanupStack::PushL( iter ); + + TUint count = iter->NumOfItemsL(); + if ( count > 0 ) + { // can only be called if there are some items + iter->GetItemIdsL( catArray, 0, count ); + } + + // Remove all the categories here Sync call + ExecuteAndDeleteLD(aCatMgr.RemoveCategoriesL( catArray )); + CleanupStack::PopAndDestroy( 2 ); // catArray, iter + } + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp111.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp111.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,462 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp111.h" +#include +#include +#include + +// CONSTANTS +const TUid KCRUidLandmarks = {0x101FE99B}; +const TUint32 KLandmarkDefaultUri = 0x00000001; +_LIT(KFactoryDbUri, "file://c:eposlm.ldb"); +//_LIT(KRepositoryFile, "c:\\private\\10202BE9\\[101FE99B].txt"); // 10202BE9 = SID for Central repository +_LIT(KRepositoryFile, "c:\\private\\10202BE9\\101FE99B.txt"); // 10202BE9 = SID for Central repository + +// Resource files +//_LIT(KDefaultDbNameRsc, "eposlmdefaultdbname.rsc"); +//_LIT(KDefaultDbRsc, "eposlmdefaultdb.rsc"); +_LIT(KCompactDbLevelRsc, "eposlmcompactdblevel.rsc"); +//_LIT(KInternalServicesRsc, "eposlmintservices.rsc"); +_LIT(KGlobalCategoriesRsc, "eposlmglobalcategories.r01"); +_LIT(KAsynchOperationsRsc, "eposlmasyncops.rsc"); + +// Resource files owned by process +_LIT(KLmServerRsc, "eposlmserver.rsc"); + +// ECom plugins +//_LIT(KConverterRsc, "101FDF85.rsc"); +//_LIT(KLocalAccessProvRsc, "101FDF89.rsc"); +//_LIT(KLocalDbManagerProvRsc, "101FE977.rsc"); +//_LIT(KLocalSearchProvRsc, "101FDF86.rsc"); + +// Libraries +_LIT(KLandmarksDll, "eposlandmarks.dll"); +_LIT(KLocalSearchDll, "eposlmsearchlib.dll"); +_LIT(KXmlConverterDll, "eposlmconverter.dll"); +_LIT(KDbManagerDll, "eposlmdbmanlib.dll"); +_LIT(KIntServicesDll, "eposlmintservices.dll"); +_LIT(KLocalAccessDll, "eposlmlocalaccess.dll"); +_LIT(KLocalAccessProvDll, "eposlmlocalaccessprovider.dll"); +_LIT(KLocalDbManProvDll, "eposlmlocaldbmanprovider.dll"); +_LIT(KLocalSearchProvDll, "eposlmlocalsearchprovider.dll"); +_LIT(KMultiDbSearchDll, "eposlmmultidbsearch.dll"); +_LIT(KRecognizer, "eposlmrecognizer.dll"); +_LIT(KLmServer, "eposlmserver.exe"); +// KDummyDll should not be found! Only used to generate language sensitive +// resource file for global categories. Removed during build process. +// _LIT(KDummyDll, "eposlandmarks_dummy.dll"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp111::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::GetName(TDes& aName) const + { + _LIT(KTestName, "TP111 - Data caging and central repository"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp111::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::StartL() + { +#ifdef __WINS__ + LogErrorAndLeave(_L("This is a target test! Emulator execution is not supported."), KErrNotSupported); +#endif + + // TC step 1 + iLog->Put(_L("TC step 1")); + TBool testSuccessful = FindResourceFilesL(); + + // TC step 2 + iLog->Put(_L("TC step 2")); + TBool subTestSuccessful = FindServerResourceFilesL(); + if (testSuccessful) + { + testSuccessful = subTestSuccessful; + } + + // TC step 3 + /* + iLog->Put(_L("TC step 3")); + subTestSuccessful = FindEcomPluginsL(); + if (testSuccessful) + { + testSuccessful = subTestSuccessful; + } + */ + + // TC step 4 + iLog->Put(_L("TC step 4")); + subTestSuccessful = FindLibrariesL(); + if (testSuccessful) + { + testSuccessful = subTestSuccessful; + } + + // TC steps 5-13 + iLog->Put(_L("TC step 5-13")); + TestCentralRepositoryL(); + + // Summarize + if (!testSuccessful) + { + LogErrorAndLeave(_L("Test failed with errors")); + } + } + +// --------------------------------------------------------- +// CPosTp111::FindResourceFilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp111::FindResourceFilesL() + { + iLog->Put(_L("FindResourceFilesL")); + CDesCArray* rscFiles = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(rscFiles); + //rscFiles->AppendL(KDefaultDbNameRsc); + //rscFiles->AppendL(KDefaultDbRsc); + rscFiles->AppendL(KCompactDbLevelRsc); + //rscFiles->AppendL(KInternalServicesRsc); + rscFiles->AppendL(KGlobalCategoriesRsc); + rscFiles->AppendL(KAsynchOperationsRsc); + + _LIT(KExpectedPath, "\\resource\\"); + + TBool result = FindFilesAndVerifyPathL(*rscFiles, KExpectedPath); + + CleanupStack::PopAndDestroy(rscFiles); + return result; + } + +// --------------------------------------------------------- +// CPosTp111::FindServerResourceFilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp111::FindServerResourceFilesL() + { + iLog->Put(_L("FindServerResourceFilesL")); + CDesCArray* rscFiles = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(rscFiles); + rscFiles->AppendL(KLmServerRsc); + + // To be updated when SID is known + _LIT(KExpectedPath, "\\private\\101FDF81\\"); + + TBool result = FindFilesAndVerifyPathL(*rscFiles, KExpectedPath); + + CleanupStack::PopAndDestroy(rscFiles); + return result; + } + +// --------------------------------------------------------- +// CPosTp111::FindEcomPluginsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp111::FindEcomPluginsL() + { + iLog->Put(_L("FindEcomPluginsL")); + CDesCArray* ecomPlugins = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(ecomPlugins); + //ecomPlugins->AppendL(KConverterRsc); + //ecomPlugins->AppendL(KLocalAccessProvRsc); + //ecomPlugins->AppendL(KLocalDbManagerProvRsc); + //ecomPlugins->AppendL(KLocalSearchProvRsc); + + // To be updated with correct SID + _LIT(KExpectedPath, "\\private\\101FDF81\\import\\"); // 101FDF81 = SID for LM srv + + TBool result = FindFilesAndVerifyPathL(*ecomPlugins, KExpectedPath); + + CleanupStack::PopAndDestroy(ecomPlugins); + return result; + } + + +// --------------------------------------------------------- +// CPosTp111::FindLibrariesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp111::FindLibrariesL() + { + iLog->Put(_L("FindLibrariesL")); + CDesCArray* libraries = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(libraries); + libraries->AppendL(KLandmarksDll); + libraries->AppendL(KLocalSearchDll); + libraries->AppendL(KXmlConverterDll); + libraries->AppendL(KDbManagerDll); + libraries->AppendL(KIntServicesDll); + libraries->AppendL(KLocalAccessDll); + libraries->AppendL(KLocalAccessProvDll); + libraries->AppendL(KLocalDbManProvDll); + libraries->AppendL(KLocalSearchProvDll); + libraries->AppendL(KMultiDbSearchDll); + libraries->AppendL(KRecognizer); + libraries->AppendL(KLmServer); + + _LIT(KExpectedPath, "\\sys\\bin\\"); + + TBool result = FindFilesAndVerifyPathL(*libraries, KExpectedPath); + + CleanupStack::PopAndDestroy(libraries); + return result; + } + +// --------------------------------------------------------- +// CPosTp111::TestCentralRepositoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::TestCentralRepositoryL() + { + iLog->Put(_L("TestCentralRepositoryL")); + _LIT(KDbUri, "file://c:landmarks.ldb"); + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + + // 5. Set default database + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDbUri); + TRAPD(err, dbMan->CreateDatabaseL(*dbInfo)); + CleanupStack::PopAndDestroy(dbInfo); + if (err != KErrNone && err != KErrAlreadyExists) + { + LogErrorAndLeave(_L("Creating db failed"), err); + } + dbMan->SetDefaultDatabaseUriL(KDbUri); + + // 6. Retrieve default db using LMFW + VerifyDefaultDbUriL(KDbUri, dbMan); + + // 7. Retrieve default db using central repository + CRepository* repository = CRepository::NewLC(KCRUidLandmarks); + VerifyDefaultDbUriL(KDbUri, repository); + + // 8. Reset central repository + User::LeaveIfError(repository->Reset(KLandmarkDefaultUri)); + + // 9. Retrieve default db using LMFW + VerifyDefaultDbUriL(KFactoryDbUri, dbMan); + + // 10. Retrieve default db using central repository + VerifyDefaultDbUriL(KFactoryDbUri, repository); + + // 11. Remove central repository file on c: + RFs fileServer; + User::LeaveIfError(fileServer.Connect()); + CleanupClosePushL(fileServer); + CFileMan* fileMan = CFileMan::NewL(fileServer); + CleanupStack::PushL(fileMan); + err = fileMan->Delete(KRepositoryFile); + if (err != KErrNone && err != KErrNotFound) + { + LogErrorAndLeave(_L("Unable to delete repository file"), err); + } + CleanupStack::PopAndDestroy(2, &fileServer); + + // 12. Retrieve default db using LMFW + VerifyDefaultDbUriL(KFactoryDbUri, dbMan); + + // 13. Retrieve default db using central repository + VerifyDefaultDbUriL(KFactoryDbUri, repository); + + CleanupStack::PopAndDestroy(2, dbMan); + } + +// --------------------------------------------------------- +// CPosTp111::FindFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::FindFileL(const TDesC& aFile, TInt& aNrOfMatches, TDes& aPath) + { + iLog->Put(_L("FindFileL")); + TBuf<200> msg; + RFs fileServer; + User::LeaveIfError(fileServer.Connect()); + CleanupClosePushL(fileServer); + TDriveList driveList; + fileServer.DriveList(driveList); + CDirScan* scanner = CDirScan::NewLC(fileServer); + + // Search all drives for the file. + aNrOfMatches = 0; + aPath = KNullDesC; + for (TInt i = EDriveA; i <= EDriveZ; i++) + { + // Investigate if drive exists on this terminal. + if (driveList[i]) + { + TChar driveLetter; + RFs::DriveToChar(i, driveLetter); + TBuf<4> root; + root.Append(driveLetter); + root.Append(_L(":\\")); + scanner->SetScanDataL(root, KEntryAttNormal, ESortByName|EAscending); + + // List all files in each folder on the drive + CFileList* files = NULL; + scanner->NextL(files); + while (files) + { + CleanupStack::PushL(files); + TPtrC currentFolder = scanner->FullPath(); + _LIT(KSearching, "Searching for file %S in folder %S"); + msg.Format(KSearching, &aFile, ¤tFolder); + iLog->Put(msg); + + // Search the currentFolder for the specified file + TFindFile fileSearcher(fileServer); + TInt res = fileSearcher.FindByDir(aFile, currentFolder); + if (res == KErrNone) + { + _LIT(KFileFound, "Found file %S in %S"); + msg.Format(KFileFound, &aFile, ¤tFolder); + iLog->Put(msg); + + aNrOfMatches++; + aPath = currentFolder; + } + + CleanupStack::PopAndDestroy(files); + files = NULL; + scanner->NextL(files); + } + } + } + + CleanupStack::PopAndDestroy(2, &fileServer); + } + +// --------------------------------------------------------- +// CPosTp111::FindFilesAndVerifyPathL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp111::FindFilesAndVerifyPathL( + const CDesCArray& aFileNames, + const TDesC& aExpectedPath) + { + iLog->Put(_L("FindFileL")); + TBool successful = ETrue; + TBuf<100> msg; + TBool nrOfMatches = 0; + TBuf<200> path; + + for (TInt i = 0; i < aFileNames.Count(); i++) + { + TPtrC fileName = aFileNames[i]; + FindFileL(fileName, nrOfMatches, path); + if (path.Length() == 0) + { + _LIT(KFormat, "File %S not found."); + msg.Format(KFormat, &fileName); + iLog->PutError(msg); + successful = EFalse; + } + else + { + if (nrOfMatches > 1) + { + _LIT(KFormat, "Found %d copies of file %S."); + msg.Format(KFormat, nrOfMatches, &fileName); + iLog->PutError(msg); + successful = EFalse; + } + else + { + if (aExpectedPath != path) + { + _LIT(KFormat, "Found file %S at the wrong place, %S"); + msg.Format(KFormat, &fileName, &path); + iLog->PutError(msg); + successful = EFalse; + } + } + } + } + + return successful; + } + +// --------------------------------------------------------- +// CPosTp111::VerifyDefaultDbUriL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::VerifyDefaultDbUriL( + const TDesC& aExpectedUri, + CPosLmDatabaseManager* aDbMan) + { + HBufC* dbUriFromLMFW = aDbMan->DefaultDatabaseUriLC(); + if (*dbUriFromLMFW != aExpectedUri) + { + TBuf<100> msg; + _LIT(KFormat, "Unexpected db uri from LMFW, %S != %S"); + msg.Format(KFormat, dbUriFromLMFW, &aExpectedUri); + LogErrorAndLeave(msg); + } + CleanupStack::PopAndDestroy(dbUriFromLMFW); + } + +// --------------------------------------------------------- +// CPosTp111::VerifyDefaultDbUriL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp111::VerifyDefaultDbUriL( + const TDesC& aExpectedUri, + CRepository* aRepository) + { + TBuf16 dbUriFromRep; + User::LeaveIfError(aRepository->Get(KLandmarkDefaultUri, dbUriFromRep)); + if (dbUriFromRep != aExpectedUri) + { + TBuf<100> msg; + _LIT(KFormat, "Unexpected db uri from repository, %S != %S"); + msg.Format(KFormat, dbUriFromRep, &aExpectedUri); + LogErrorAndLeave(msg); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp114.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp114.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,544 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp114.h" +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp114::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp114::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp114 - Landmark database backup/restore"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp114::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp114::CloseTest() + { + iLog->Put(_L("CloseTest")); + } + +/** +* Performes the test by connecting to the landmarks server + +Test LMREQ152: Landmarks DB backup +Backup and restore of all Landmarks databases using the system backup shall be possible. +The clients are responsible for release of databases during backup/restore. +A database directly accessed by a client will not be possible to backup/restore. + +*/ +// --------------------------------------------------------- +// CPosTp114::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp114::StartL() + { + TBool backupTest = FileExistL(); + + iLog->Put(_L("DoTestL")); + + CPosTp114BackupListener* backupListener = CPosTp114BackupListener::NewL(iLog); + CleanupStack::PushL(backupListener); + + if (backupTest) + { + iLog->Put(_L("Backup Test")); + // Backup part + InitBackupTestL(); + } + else + { + iLog->Put(_L("Restore Test")); + iLog->Put(_L("Connnect to eposlmserver")); + // Restore part + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + //TInt count = dbArray->Count(); + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + } + + // Check landmark server + _LIT(KPosLandmarksServerName, "*eposlmserver*"); + + User::After(5000000); // XXX Add some time here + TBool result = ETrue; + TBool alive = ServerAlive(KPosLandmarksServerName); + if(alive) iLog->Put(_L("ERROR: Server is stil alive")); + + + if (backupTest) + { + _LIT(KStartBackup, "Now start backup but first press OK"); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(KStartBackup, EUtfwDialogTypeOk, EFalse); + + if(answer == EUtfwUserAnswerOk) + { + backupListener->StartCheckingL(); + User::After(10000000); // Wait some time here so that backup is really finished + } + } + else + { + _LIT(KStartRestore, "Now start restore, but first press OK"); + TUtfwUserAnswer answer = iUserInfo->ShowDialog(KStartRestore, EUtfwDialogTypeOk, EFalse); + + if(answer == EUtfwUserAnswerOk) + { + backupListener->StartCheckingL(); + User::After(10000000); // Wait some time here so that restore is really finished + } + } + + if (backupTest) + { + // Prepare dbs for restore part + PrepareForRestoreTestL(); + } + else + { + // Check correct dbs and landmarks restored + result = CheckDbAfterRestoreL(); + } + + backupListener->Cancel(); + CleanupStack::PopAndDestroy(backupListener); + + if (!result) LogErrorAndLeave(_L("Errors found when restoring")); + } + +// --------------------------------------------------------- +// CPosTp114::CheckDbAfterRestoreL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp114::CheckDbAfterRestoreL() + { + // Check that three landmark dbs exist + // Check that all dbs contain three landmarks + _LIT(DB1, "file://C:backupDb1.ldb"); + _LIT(DB2, "file://C:backupDb2.ldb"); + _LIT(DB3, "file://C:backupDb3.ldb"); + + iLog->Put(_L("CheckDbAfterRestoreL")); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + TBool result = ETrue; + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt count = dbArray->Count(); + //AssertTrueL(count == 3, _L("Wrong nr of dbs after restore")); + if (count != 3) + { + iLog->Put(_L("ERROR: Wrong nr of dbs after restore")); + result = EFalse; + } + + TInt pos; + + if (dbArray->Find(DB1, pos) != 0 || + dbArray->Find(DB2, pos) != 0 || + dbArray->Find(DB3, pos) != 0) + { + iLog->Put(_L("Could not find db")); + result = EFalse; + } + + CleanupStack::PopAndDestroy(dbArray); + CleanupStack::PopAndDestroy(dbManager); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(DB1); + CleanupStack::PushL(db); + + CPosLmItemIterator* iter = db->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TInt numberOfElements = iter->NumOfItemsL(); + if (numberOfElements != 3) + { + iLog->Put(_L("Wrong number of landmarks in DB1 ")); + result = EFalse; + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(db); + + return result; + } + +// --------------------------------------------------------- +// CPosTp114::InitBackupTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp114::InitBackupTestL() + { + iLog->Put(_L("InitBackupTestL")); + // Use this part to create three landmark dbs with some landmarks + _LIT(DB1, "backupDb1.ldb"); + _LIT(DB2, "backupDb2.ldb"); + _LIT(DB3, "backupDb3.ldb"); + + // Firts remove all landmark dbs + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + CDesCArray* dbArray = dbManager->ListDatabasesLC(); + TInt count = dbArray->Count(); + + for (TInt i=0;iDeleteDatabaseL((*dbArray)[i]); + } + + CleanupStack::PopAndDestroy(dbArray); + + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(DB1); + dbManager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + + dbInfo = HPosLmDatabaseInfo::NewLC(DB2); + dbManager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + + dbInfo = HPosLmDatabaseInfo::NewLC(DB3); + dbManager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + + // Add landmarks to db1 + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(DB1); + CleanupStack::PushL(db); + if (db->IsInitializingNeeded()) ExecuteAndDeleteLD(db->InitializeL()); + + CPosLandmark* lm1 = CPosLandmark::NewLC(); + lm1->SetLandmarkNameL(_L("TP114_Db1_Lm1")); + db->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + CPosLandmark* lm2 = CPosLandmark::NewLC(); + lm2->SetLandmarkNameL(_L("TP114_Db1_Lm2")); + db->AddLandmarkL(*lm2); + CleanupStack::PopAndDestroy(lm2); + CPosLandmark* lm3 = CPosLandmark::NewLC(); + lm3->SetLandmarkNameL(_L("TP114_Db1_Lm3")); + db->AddLandmarkL(*lm3); + CleanupStack::PopAndDestroy(lm3); + ExecuteAndDeleteLD(db->CompactL()); + CleanupStack::PopAndDestroy(db); + + // Add landmarks to db2 + db = CPosLandmarkDatabase::OpenL(DB2); + CleanupStack::PushL(db); + if (db->IsInitializingNeeded()) ExecuteAndDeleteLD(db->InitializeL()); + + lm1 = CPosLandmark::NewLC(); + lm1->SetLandmarkNameL(_L("TP114_Db2_Lm1")); + db->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + lm2 = CPosLandmark::NewLC(); + lm2->SetLandmarkNameL(_L("TP114_Db2_Lm2")); + db->AddLandmarkL(*lm2); + CleanupStack::PopAndDestroy(lm2); + lm3 = CPosLandmark::NewLC(); + lm3->SetLandmarkNameL(_L("TP114_Db2_Lm3")); + db->AddLandmarkL(*lm3); + CleanupStack::PopAndDestroy(lm3); + ExecuteAndDeleteLD(db->CompactL()); + CleanupStack::PopAndDestroy(db); + + // Add landmarks to db3 + db = CPosLandmarkDatabase::OpenL(DB3); + CleanupStack::PushL(db); + if (db->IsInitializingNeeded()) ExecuteAndDeleteLD(db->InitializeL()); + + lm1 = CPosLandmark::NewLC(); + lm1->SetLandmarkNameL(_L("TP114_Db3_Lm1")); + db->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + lm2 = CPosLandmark::NewLC(); + lm2->SetLandmarkNameL(_L("TP114_Db3_Lm2")); + db->AddLandmarkL(*lm2); + CleanupStack::PopAndDestroy(lm2); + lm3 = CPosLandmark::NewLC(); + lm3->SetLandmarkNameL(_L("TP114_Db3_Lm3")); + db->AddLandmarkL(*lm3); + CleanupStack::PopAndDestroy(lm3); + ExecuteAndDeleteLD(db->CompactL()); + CleanupStack::PopAndDestroy(db); + + CleanupStack::PopAndDestroy(dbManager); + iLog->Put(_L("InitBackupTestL Done")); + } + +// --------------------------------------------------------- +// CPosTp114::PrepareForRestoreTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp114::PrepareForRestoreTestL() + { + _LIT(DB1, "backupDb1.ldb"); + _LIT(DB2, "backupDb2.ldb"); + + iLog->Put(_L("PrepareForRestoreTestL")); + + // Remove db2 and remove some landmarks from db1 + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + //dbManager->DeleteDatabaseL(DB2); + DeleteFileL(_L("c:\\private\\100012a5\\DBS_101FE978_backupDb2.ldb")); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(DB1); + CleanupStack::PushL(db); + + CPosLmItemIterator* iter = db->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements-1)); + + ExecuteAndDeleteLD(db->RemoveLandmarksL(arrayOfIds)); + TBuf<100> buf; + buf.Format(_L("Removing %d nr of landmarks from db1"), arrayOfIds.Count()); + iLog->Put(buf); + + CleanupStack::PopAndDestroy(&arrayOfIds); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(db); + CleanupStack::PopAndDestroy(dbManager); + + iLog->Put(_L("PrepareForRestoreTestL Done")); + } + +// --------------------------------------------------------- +// CPosTp114::FileExistL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp114::FileExistL() + { + _LIT(KIniFile, "c:\\TP114backupTest.ini"); + + RFs fileserver; + RFile file; + TBool exist = EFalse; + + User::LeaveIfError(fileserver.Connect()); + TInt err = file.Open(fileserver, KIniFile, EFileWrite); + if (err == KErrNotFound) + { + TInt err = file.Create(fileserver, KIniFile, EFileWrite); + exist = ETrue; + file.Close(); + iLog->Put(_L("File has been created")); + } + else + { + file.Close(); + TInt err = fileserver.Delete(KIniFile); + if (err != KErrNone) + { + TBuf<50> buf; + buf.Format(_L("Could not delete c:\\TP114backupTest.ini, err %d"), err); + iLog->Put(buf); + } + else + { + iLog->Put(_L("File has been deleted")); + } + + exist = EFalse; + } + + fileserver.Close(); + return exist; + } + + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener +// +// ----------------------------------------------------------------------------- +// +CPosTp114BackupListener::CPosTp114BackupListener() + : CActive(EPriorityLow) + { + } + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CPosTp114BackupListener::ConstructL(MUtfwLog* aLog) + { + TUid categoryUid; + categoryUid.iUid = KUidSystemCategoryValue; + User::LeaveIfError(iProperty.Attach(categoryUid, + conn::KUidBackupRestoreKey)); + CActiveScheduler::Add(this); + iLog = aLog; + iBackupIsRunning = EFalse; + + // initial subscription and process current property value + RunL(); + } + +// Two-phased constructor +CPosTp114BackupListener* CPosTp114BackupListener::NewL(MUtfwLog* aLog) + { + CPosTp114BackupListener* self = + new (ELeave) CPosTp114BackupListener; + CleanupStack::PushL(self); + self->ConstructL(aLog); + + CleanupStack::Pop(self); + return self; + } + +// Destructor +CPosTp114BackupListener::~CPosTp114BackupListener() + { + Cancel(); + iProperty.Close(); + } + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener::RunL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CPosTp114BackupListener::RunL() + { + iLog->Put(_L("RunL")); + // resubscribe before processing new value to prevent missing updates. + iProperty.Subscribe(iStatus); + SetActive(); + + if (IsBackupRunning()) + { + iLog->Put(_L("Backup (Restore) is Running....")); + iBackupIsRunning = ETrue; + } + + //Check if back to normal (after backup/restore) + if (!IsBackupRunning() && iBackupIsRunning) + { + iLog->Put(_L("After backup/restore")); + iBackupIsRunning = EFalse; + CActiveScheduler::Stop(); + } + } + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener::StartCheckingL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CPosTp114BackupListener::StartCheckingL() + { + CActiveScheduler::Start(); + } + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener::IsBackupRunning +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TBool CPosTp114BackupListener::IsBackupRunning() + { + TBool backupIsRunning = EFalse; + TInt value = 0; + TInt err = iProperty.Get(value); + + if (err == KErrNone) + { + // Use mask to get rid of unwanted info + TInt partType = conn::KBURPartTypeMask & value; + + // The values EBURUnset or EBURNormal mean + // that no backup/restore is ongoing. + if (partType == conn::EBURUnset || partType == conn::EBURNormal) + { + backupIsRunning = EFalse; + } + else + { + backupIsRunning = ETrue; + } + } + else if (err == KErrNotFound) + { + // If property is not found, assume that no backup is in progress + backupIsRunning = EFalse; + } + else + { + // Some other error occured. In this case, + // assume that backup is running. + backupIsRunning = ETrue; + } + + return backupIsRunning; + } + +// ----------------------------------------------------------------------------- +// CPosTp114BackupListener::DoCancel +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CPosTp114BackupListener::DoCancel() + { + iLog->Put(_L("DoCancel")); + iProperty.Cancel(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp116.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp116.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,546 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp116.h" +#include +#include +#include +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp116::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp116::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iActiveLmEvent; + iActiveLmEvent = NULL; + } + +// --------------------------------------------------------- +// CPosTp116::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp116::StartL() + { + // First remove all landmark databases + RemoveAllLmDatabasesL(); + + // Start test + LandmarkEventTestL(); + + // Remove all landmark databases + RemoveAllLmDatabasesL(); + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkEventTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp116::LandmarkEventTestL() + { + iLog->Log(_L("LandmarkEventTestL")); + + // _LIT(KDatabase, "file://c:eposlm.ldb"); + _LIT(KDatabase, "file://c:Tp116Test.ldb"); + _LIT(KDatabase1, "file://c:Tp116LmDb_1.ldb"); + +#ifdef __WINS__ + // For WINS use C drive + _LIT(KDatabase1_OnMedia, "file://c:Tp116LmDb_1_OnMedia.ldb"); + _LIT(KDatabase2_OnMedia, "file://c:Tp116LmDb_2_OnMedia.ldb"); +#else + //Media card must therefore be inserted + _LIT(KDatabase1_OnMedia, "file://F:Tp116LmDb_1_OnMedia.ldb"); + _LIT(KDatabase2_OnMedia, "file://F:Tp116LmDb_2_OnMedia.ldb"); +#endif + + _LIT(KDatabase2, "file://c:Tp116LmDb_2.ldb"); + _LIT(KDatabase3, "file://c:Tp116LmDb_3.ldb"); + _LIT(KDatabase4, "file://c:Tp116LmDb_4.ldb"); + + _LIT(KDatabase5, "file://c:Tp116DummyLmDb_5.ldb"); + _LIT(KDatabase6, "file://c:Tp116DummyLmDb_6.ldb"); + _LIT(KDatabase7, "file://c:Tp116DummyLmDb_7.ldb"); + _LIT(KDatabase8, "file://c:Tp116DummyLmDb_8.ldb"); + _LIT(KDatabase9, "file://c:Tp116DummyLmDb_9.ldb"); + _LIT(KDatabase10, "file://c:Tp116DummyLmDb_10.ldb"); + _LIT(KDatabase11, "file://c:Tp116DummyLmDb_11.ldb"); + _LIT(KDatabase12, "file://c:Tp116DummyLmDb_12.ldb"); + _LIT(KDatabase13, "file://c:Tp116LmDb_13.ldb"); + _LIT(KDatabase14, "file://c:Tp116LmDb_14.ldb"); + + _LIT(KRemoteDb1, "test://RemoteDb1.ldb"); + _LIT(KRemoteDbName1, "RemoteDb1New"); + _LIT(KNonExistingDb, "ANonExistingDb.ldb"); + + TInt err = KErrNone; + iLog->Log(_L("Warning: this test case requires E: drive")); + + iActiveLmEvent = CTP116ActiveLmEvent::NewL(iLog); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDatabase); + manager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + + // This db must exist, set here so that when setting default db next it is different from before + // otherwise no event + manager->SetDefaultDatabaseUriL(KDatabase); + + // 1) iActiveLmEvent will listen for multiple database events + iActiveLmEvent->Start(); + + iLog->Log(_L("2) EDatabaseCreated ")); + // 2) Create a landmark database, db1 on the c: drive + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + manager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + + //iActiveLmEvent->iExpectedEvent = CPosLmDatabaseManager::EDatabaseCreated; + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + + iActiveLmEvent->SetExpectedDatabase(KDatabase1); + CActiveScheduler::Start(); + + iLog->Log(_L("3) ENewDefaultDbLocation ")); + // 3) Set the defaultdb to point at the newly created db + manager->SetDefaultDatabaseUriL(KDatabase1); + iActiveLmEvent->iExpectedEvent = EPosLmDbNewDefaultDbLocation; + iActiveLmEvent->SetExpectedDatabase(KDatabase1); + CActiveScheduler::Start(); + + + iLog->Log(_L("5) EDatabaseCreated ")); + // 5) Copy db1 to media drive + manager->CopyDatabaseL(KDatabase1, KDatabase1_OnMedia); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase1_OnMedia); + CActiveScheduler::Start(); + + iLog->Log(_L("6) EDatabaseDeleted ")); + // 6) Delete copied db from media card + manager->DeleteDatabaseL(KDatabase1_OnMedia); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase1_OnMedia); + CActiveScheduler::Start(); + + iLog->Log(_L("7) EDatabaseCreated - EDatabaseDeleted")); + // 7) Move db1 to media drive as db1_2-> First copy it and then delete (in same operation phase) + manager->CopyDatabaseL(KDatabase1, KDatabase2_OnMedia); + manager->DeleteDatabaseL(KDatabase1); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase2_OnMedia); + CActiveScheduler::Start(); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase1); + CActiveScheduler::Start(); + + iLog->Log(_L("8) EDatabaseCreated")); + //8) Create a db, db2, on media card + + HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); + manager->CreateDatabaseL(*dbInfo2); + CleanupStack::PopAndDestroy(dbInfo2); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + iLog->Log(_L("9) ENewDefaultDbLocation")); + // 9) Set the defaultdb to point at the newly created db + manager->SetDefaultDatabaseUriL(KDatabase2); + iActiveLmEvent->iExpectedEvent = EPosLmDbNewDefaultDbLocation; + iActiveLmEvent->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + iLog->Log(_L("9b) EPosLmDbSettingsModified")); + // 9b) Set the defaultdb to point at the newly created db + HPosLmDatabaseInfo* dbInfoChange = HPosLmDatabaseInfo::NewLC(KDatabase2); + TPosLmDatabaseSettings settings = dbInfo2->Settings(); + _LIT(KNewDbName, "TP116 Disp Name"); + TPosLmDatabaseName bufName(KNewDbName); + settings.SetDatabaseName(bufName); + manager->ModifyDatabaseSettingsL(KDatabase2, settings); + CleanupStack::PopAndDestroy(dbInfoChange); + + iActiveLmEvent->iExpectedEvent = EPosLmDbSettingsModified; + iActiveLmEvent->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + iLog->Log(_L("10) EDatabaseDeleted")); + // 10) Delete db2 from media card + manager->DeleteDatabaseL(KDatabase2); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + iLog->Log(_L("11) EDatabaseCreated")); + // 11) Copy db1_2 to C:\ as db1_3 + manager->CopyDatabaseL(KDatabase2_OnMedia, KDatabase3); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase3); + CActiveScheduler::Start(); + + iLog->Log(_L("12) EDatabaseDeleted")); + // 12) Move db1_2 from media to C:\ drive as db1_4 -> First + // copy it and then delete (in same operation phase) + manager->CopyDatabaseL(KDatabase2_OnMedia, KDatabase4); + manager->DeleteDatabaseL(KDatabase2_OnMedia); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase2_OnMedia); + CActiveScheduler::Start(); + + iLog->Log(_L("13) ENewDefaultDbLocation")); + // 13) Set the defaultdb to point at db1_4 + manager->SetDefaultDatabaseUriL(KDatabase4); + iActiveLmEvent->iExpectedEvent = EPosLmDbNewDefaultDbLocation; + iActiveLmEvent->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + + iLog->Log(_L("14) EDatabaseDeleted")); + // 14) Delete db1_4 + manager->DeleteDatabaseL(KDatabase4); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + + iLog->Log(_L("15) --------- ")); + // Try to create a queue of events that is bigger than the internal queue buffer + // should causes unknown event to happen and no databaseUri + HPosLmDatabaseInfo* dbInfo13 = HPosLmDatabaseInfo::NewLC(KDatabase13); + manager->CreateDatabaseL(*dbInfo13); + CleanupStack::PopAndDestroy(dbInfo13); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase13); + iActiveLmEvent->iQueueTest = ETrue; + CActiveScheduler::Start(); + + HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); + HPosLmDatabaseInfo* dbInfo5 = HPosLmDatabaseInfo::NewLC(KDatabase5); + HPosLmDatabaseInfo* dbInfo6 = HPosLmDatabaseInfo::NewLC(KDatabase6); + HPosLmDatabaseInfo* dbInfo7 = HPosLmDatabaseInfo::NewLC(KDatabase7); + HPosLmDatabaseInfo* dbInfo8 = HPosLmDatabaseInfo::NewLC(KDatabase8); + HPosLmDatabaseInfo* dbInfo9 = HPosLmDatabaseInfo::NewLC(KDatabase9); + + manager->CreateDatabaseL(*dbInfo4); + manager->CreateDatabaseL(*dbInfo5); + manager->DeleteDatabaseL(KDatabase4); + manager->CopyDatabaseL(KDatabase5, KDatabase10); + manager->CreateDatabaseL(*dbInfo6); + manager->DeleteDatabaseL(KDatabase5); + manager->CreateDatabaseL(*dbInfo7); + manager->DeleteDatabaseL(KDatabase6); + manager->CopyDatabaseL(KDatabase10, KDatabase11); + manager->CreateDatabaseL(*dbInfo8); + manager->DeleteDatabaseL(KDatabase7); + manager->CreateDatabaseL(*dbInfo9); + manager->CopyDatabaseL(KDatabase10, KDatabase12); + manager->DeleteDatabaseL(KDatabase9); + manager->DeleteDatabaseL(KDatabase8); + + CleanupStack::PopAndDestroy(dbInfo9); + CleanupStack::PopAndDestroy(dbInfo8); + CleanupStack::PopAndDestroy(dbInfo7); + CleanupStack::PopAndDestroy(dbInfo6); + CleanupStack::PopAndDestroy(dbInfo5); + CleanupStack::PopAndDestroy(dbInfo4); + + // Check for unknown + iActiveLmEvent->iExpectedEvent = EPosLmDbUnknownEvent; + iActiveLmEvent->SetExpectedDatabase(KNullDesC); + iActiveLmEvent->Start(); + CActiveScheduler::Start(); + + iActiveLmEvent->iQueueTest = EFalse; + + TInt errorsFound = iActiveLmEvent->GetErrors(); + + iActiveLmEvent->DoCancel(); + + iActiveLmEvent->Start(); + + iLog->Log(_L("16) EDatabaseCreated ")); + // 16) Check correct event after unknown event + // Note: This does not work, new events are added to the queue after unknown event, so instead we + // cancel the event handling + HPosLmDatabaseInfo* dbInfo14 = HPosLmDatabaseInfo::NewLC(KDatabase14); + manager->CreateDatabaseL(*dbInfo14); + CleanupStack::PopAndDestroy(dbInfo14); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase14); + CActiveScheduler::Start(); + + errorsFound = iActiveLmEvent->GetErrors(); + + iActiveLmEvent->DoCancel(); + delete iActiveLmEvent; + iActiveLmEvent = NULL; + iActiveLmEvent = CTP116ActiveLmEvent::NewL(iLog); + + // Start listening + iActiveLmEvent->Start(); + + iLog->Log(_L("17) --------- ")); + // 17) Test that event handling is working for "remote" provider (use the test provider) + // as well + HPosLmDatabaseInfo* db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); + manager->CreateDatabaseL(*db1); + // Register remote db + manager->RegisterDatabaseL(*db1); + + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KRemoteDb1); + CActiveScheduler::Start(); + + iLog->Log(_L("18) --------- ")); + // 18) Test that event handling is working for "remote" provider (use the test provider) + // as well + // Modify Settings + TPosLmDatabaseSettings remoteSettings = db1->Settings(); + TPosLmDatabaseName remoteName(KRemoteDbName1); + remoteSettings.SetDatabaseName(remoteName); + manager->ModifyDatabaseSettingsL(KRemoteDb1, remoteSettings); + + iActiveLmEvent->iExpectedEvent = EPosLmDbSettingsModified; + iActiveLmEvent->SetExpectedDatabase(KRemoteDb1); + CActiveScheduler::Start(); + CleanupStack::PopAndDestroy(db1); + + iLog->Log(_L("19) --------- ")); + // 19) Test that event handling is working for "remote" provider (use the test provider) + // as well + // Unregister remote db + manager->UnregisterDatabaseL(KRemoteDb1); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseUnregistered; + iActiveLmEvent->SetExpectedDatabase(KRemoteDb1); + CActiveScheduler::Start(); + + iLog->Log(_L("20) --------- ")); + // 20) Set the defaultdb to point at a non-existing db + TRAP(err, manager->SetDefaultDatabaseUriL(KNonExistingDb)); + if (err != KErrNotFound) + { + iLog->Log(_L("SetDefaultDatabaseL(KNonExistingDb) should leave with KErrNotFound")); + User::Leave(err); + } + iLog->Log(_L("20 Done")); + + CleanupStack::PopAndDestroy(manager); + + errorsFound += iActiveLmEvent->GetErrors(); + + delete iActiveLmEvent; + iActiveLmEvent = NULL; + + if (errorsFound != KErrNone) + { + iLog->Log(_L("Errors were found in TP116")); + User::Leave(-1); + } + + } + +// ----------------------------------------------------------------------------- +// CTP116ActiveLmEvent::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CTP116ActiveLmEvent* CTP116ActiveLmEvent::NewL(CStifLogger* aLog) + { + CTP116ActiveLmEvent* self = new(ELeave) CTP116ActiveLmEvent(aLog); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CTP116ActiveLmEvent::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CTP116ActiveLmEvent::ConstructL() + { + iManager = CPosLmDatabaseManager::NewL(); + } + +// ----------------------------------------------------------------------------- +// CTP116ActiveLmEvent::CTP116ActiveLmEvent +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// + +CTP116ActiveLmEvent::CTP116ActiveLmEvent(CStifLogger* aLog) : + CActive(EPriorityNormal), + iLog(aLog) + { + CActiveScheduler::Add(this); + iGlobalErr=KErrNone; + iQueueTest = EFalse; + } + +// Destructor +CTP116ActiveLmEvent::~CTP116ActiveLmEvent() + { + Cancel(); + delete iManager; + iManager = NULL; + } + +// --------------------------------------------------------- +// CTP116ActiveLmEvent::SetExpectedDatabase +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP116ActiveLmEvent::SetExpectedDatabase(const TDesC& aDatabaseUri) + { + iExpectedDatabase.Zero(); + + iExpectedDatabase.Append(aDatabaseUri); + } + +// --------------------------------------------------------- +// CTP116ActiveLmEvent::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP116ActiveLmEvent::Start() + { + // Get ready for event + iManager->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CTP116ActiveLmEvent::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP116ActiveLmEvent::RunL() + { + iLog->Log(_L("CTP116ActiveLmEvent::RunL")); + + TPosLmDatabaseEvent event = iEvent; + VerifyEvent(event); + if (!iQueueTest) + { + // Get ready for next event + iManager->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + } + +// --------------------------------------------------------- +// CActiveLmOperation::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP116ActiveLmEvent::DoCancel() + { + iLog->Log(_L("CTP116ActiveLmEvent::DoCancel")); + iManager->CancelNotifyDatabaseEvent(); + } + +// --------------------------------------------------------- +// CActiveLmOperation::GetErrors +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CTP116ActiveLmEvent::GetErrors() + { + return iGlobalErr; + } + +// --------------------------------------------------------- +// CTP116ActiveLmEvent::VerifyEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP116ActiveLmEvent::VerifyEvent(TPosLmDatabaseEvent event) + { + iLog->Log(_L("CTP116ActiveLmEvent::VerifyEvent")); + TBuf<150> buffe; + + buffe.Format(_L("VerifyEvent Event: %d "), event.iEventType); + iLog->Log(buffe); + + // Verify event here + if (event.iEventType != iExpectedEvent) + { + buffe.Zero(); + buffe.Format(_L("ERROR: Wrong event: exp %d got %d"),iExpectedEvent, event.iEventType); + iLog->Log(buffe); + iGlobalErr++; + } + + if (event.iEventType != EPosLmDbUnknownEvent) + { + + HBufC16* dbUri = iManager->DatabaseUriFromLastEventLC(); + buffe.Zero(); + buffe.Format(_L("Event: %d URI %S"), event.iEventType, dbUri); + iLog->Log(buffe); + + if (iExpectedDatabase.CompareC(*dbUri) != 0) + { + iLog->Log(_L("ERROR: Wrong db name")); + buffe.Zero(); + buffe.Append(_L("Should be ")); + buffe.Append(iExpectedDatabase); + iLog->Log(buffe); + iGlobalErr++; + } + CleanupStack::PopAndDestroy(dbUri); + } + else + { + buffe.Format(_L("EUnknownEvent Event: %d "), event.iEventType); + iLog->Log(buffe); + } + + CActiveScheduler::Stop(); + + iLog->Log(_L("VerifyEvent Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp117.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp117.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,724 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp117.h" +#include +#include +#include + +//#include +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp117::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iActiveLmEvent; + iActiveLmEvent = NULL; + + iThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp117::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::StartL() + { + + // Remove all landmark databases + RemoveAllLmDatabasesL(); + LandmarkQueuedEvenTestL(); + + // Remove all landmark databases + RemoveAllLmDatabasesL(); + LandmarkQueuedEvenTest2L(); + + // Remove all landmark databases + RemoveAllLmDatabasesL(); + // Start test + LandmarkEventTestL(); + + // Remove all landmark databases + RemoveAllLmDatabasesL(); + + // Pancic test + iActiveLmEvent = CTP117ActiveLmEvent::NewL(iLog); + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 1")); + iTestCase = 1; + /* EPosEventNotifierAlreadyHasOutstandingRequest defined in EPos_LandmarksServerPanics.h */ + iExpectedErrorCode = 2; + ResumeThreadAndVerifyExit(); + + delete iActiveLmEvent; + iActiveLmEvent = NULL; + + + if (iErrorsFound != KErrNone) + { + + iLog->Log(_L("Errors found in TP117")); + User::Leave(-1); + + } + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkQueuedEvenTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::LandmarkQueuedEvenTestL() + { + iLog->Log(_L(">>>>>>>>>>LandmarkQueuedEvenTestL<<<<<<<<<")); + + _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); + _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); + _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); + _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); + + CTP117ActiveLmEvent* client1 = CTP117ActiveLmEvent::NewL(iLog); + CleanupStack::PushL(client1); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // Creates db2, which should exist (deleted below) + client1->Start(); + HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); + manager->CreateDatabaseL(*dbInfo2); + CleanupStack::PopAndDestroy(dbInfo2); + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + // *********Start test************* + iLog->Log(_L("*********Start test*************")); + // 1) Enable client1 + client1->Start(); + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase1); + + // 2) Client2 creates a database, db1 + iLog->Log(_L("Client2 creates a database, db1")); + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + manager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + + // 3) Client1 NotifyDatabaseEvent, should be event from create operation in step2 + iLog->Log(_L("Client1 will get EDatabaseCreated event")); + CActiveScheduler::Start(); + + iLog->Log(_L("Delete, Copy, Create db")); + //4) Client2 deletes db2 + manager->DeleteDatabaseL(KDatabase2); + + //5) Client2 copies db1 to db3 + manager->CopyDatabaseL(KDatabase1, KDatabase3); + + //6) Client2 creates db4 + HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); + manager->CreateDatabaseL(*dbInfo4); + CleanupStack::PopAndDestroy(dbInfo4); + + // 7) Client1 NotifyDatabaseEvent, should be event from delete operation in step4 + iLog->Log(_L("7) Client1 NotifyDatabaseEvent")); + client1->Start(); + // Dont check URI here + client1->iCheckUri = EFalse; + client1->iExpectedEvent = EPosLmDbDatabaseUnregistered; + client1->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + // 8) Client1 NotifyDatabaseEvent, should be event from copy operation in step5 + iLog->Log(_L("8) Client1 NotifyDatabaseEvent")); + client1->Start(); + // Dont check URI here + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase3); + CActiveScheduler::Start(); + + // 9) Client1 NotifyDatabaseEvent, should be event from create operation in step6 + iLog->Log(_L("9) Client1 NotifyDatabaseEvent")); + // Check URI here + client1->iCheckUri = ETrue; + client1->Start(); + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + + iErrorsFound+=client1->GetErrors(); + + CleanupStack::PopAndDestroy(manager); + CleanupStack::PopAndDestroy(client1); + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkQueuedEvenTest2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::LandmarkQueuedEvenTest2L() + { + iLog->Log(_L(">>>>>>>>>>LandmarkQueuedEvenTest2L>>>>>>>>>>")); + + _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); + _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); + _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); + _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); + _LIT(KDatabase5, "c:Tp117DummyLmDb_5.ldb"); + + CTP117ActiveLmEvent* client1 = CTP117ActiveLmEvent::NewL(iLog); + CleanupStack::PushL(client1); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // Creates db2, which should exist (deleted below) + client1->Start(); + HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); + manager->CreateDatabaseL(*dbInfo2); + CleanupStack::PopAndDestroy(dbInfo2); + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + // *********Start test************* + iLog->Log(_L("*********Start test*************")); + // 1) Enable client1 + client1->Start(); + client1->iExpectedEvent = EPosLmDbDatabaseRegistered; + client1->SetExpectedDatabase(KDatabase1); + + // 2) Client2 creates a database, db1 + iLog->Log(_L("Client2 creates a database, db1")); + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + manager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + + // 3) Client1 NotifyDatabaseEvent, should be event from create operation in step2 + iLog->Log(_L("Client1 will get EDatabaseCreated event")); + CActiveScheduler::Start(); + + iLog->Log(_L("Delete, Copy, Create, Delete, Copy, Delete")); + //4) Client2 deletes db2 + manager->DeleteDatabaseL(KDatabase2); + + //5) Client2 copies db1 to db3 + manager->CopyDatabaseL(KDatabase1, KDatabase3); + + //6) Client2 creates db4 + HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); + manager->CreateDatabaseL(*dbInfo4); + CleanupStack::PopAndDestroy(dbInfo4); + + //7) Client2 deletes db3 + manager->DeleteDatabaseL(KDatabase3); + + //8) Client2 copies db2 to db5 + manager->CopyDatabaseL(KDatabase1, KDatabase5); + + //7) Client2 deletes db2 + manager->DeleteDatabaseL(KDatabase5); + + // 9) Client1 NotifyDatabaseEvent, should be unknown event since too many events in queue + // After unknown event the queue should be empty again, verified in step10 + iLog->Log(_L("9) Client1 NotifyDatabaseEvent")); + client1->Start(); + client1->iExpectedEvent = EPosLmDbUnknownEvent; + client1->SetExpectedDatabase(KNullDesC); + CActiveScheduler::Start(); + + //10) Client1 deletes db4 + client1->Start(); + iLog->Log(_L("10) Client1 NotifyDatabaseEvent")); + manager->DeleteDatabaseL(KDatabase4); + client1->iExpectedEvent = EPosLmDbDatabaseUnregistered; + client1->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + + iErrorsFound+=client1->GetErrors(); + + CleanupStack::PopAndDestroy(manager); + CleanupStack::PopAndDestroy(client1); + } + +// --------------------------------------------------------- +// CPosTp28::LandmarkEventTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::LandmarkEventTestL() + { + iLog->Log(_L(">>>>>>>>>>LandmarkEventTestL<<<<<<<<<<<<<<")); + + _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); + _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); + _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); + _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); + + _LIT(KDatabase5, "c:Tp117DummyLmDb_5.ldb"); + _LIT(KDatabase6, "c:Tp117DummyLmDb_6.ldb"); + + iActiveLmEvent = CTP117ActiveLmEvent::NewL(iLog); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // 1) Just do something to cause an event + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); + manager->CreateDatabaseL(*dbInfo1); + CleanupStack::PopAndDestroy(dbInfo1); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase1); + CActiveScheduler::Start(); + + iLog->Log(_L("Test 1_1")); + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); + manager->CreateDatabaseL(*dbInfo2); + CleanupStack::PopAndDestroy(dbInfo2); + + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase2); + CActiveScheduler::Start(); + + iLog->Log(_L("Cancel NotifyDatabaseEvent 1")); + // Cancel NotifyDatabaseEvent + iActiveLmEvent->Start(); + iActiveLmEvent->Cancel(); + iActiveLmEvent->Start(); + iActiveLmEvent->Cancel(); + + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo3 = HPosLmDatabaseInfo::NewLC(KDatabase3); + manager->CreateDatabaseL(*dbInfo3); + CleanupStack::PopAndDestroy(dbInfo3); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase3); + CActiveScheduler::Start(); + + iLog->Log(_L("Cancel NotifyDatabaseEvent 2")); + // Cancel NotifyDatabaseEvent + iActiveLmEvent->Start(); + iActiveLmEvent->Cancel(); + iActiveLmEvent->Cancel(); + + iLog->Log(_L("Test event after cancel")); + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); + manager->CreateDatabaseL(*dbInfo4); + CleanupStack::PopAndDestroy(dbInfo4); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase4); + CActiveScheduler::Start(); + + iLog->Log(_L("Test to call DatabaseUriFromLastEventLC before events occurr")); + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo5 = HPosLmDatabaseInfo::NewLC(KDatabase5); + manager->CreateDatabaseL(*dbInfo5); + CleanupStack::PopAndDestroy(dbInfo5); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase5); + iActiveLmEvent->CallDatabaseUriFromLastEventLC(); + // Need to cancel this notifyDatabaseEvent call + iActiveLmEvent->Cancel(); + + iLog->Log(_L("Test event3 after DatabaseUriFromLastEventLC")); + iActiveLmEvent->Start(); + HPosLmDatabaseInfo* dbInfo6 = HPosLmDatabaseInfo::NewLC(KDatabase6); + manager->CreateDatabaseL(*dbInfo6); + CleanupStack::PopAndDestroy(dbInfo6); + iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; + iActiveLmEvent->SetExpectedDatabase(KDatabase6); + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(manager); + + iErrorsFound+=iActiveLmEvent->GetErrors(); + + delete iActiveLmEvent; + iActiveLmEvent = NULL; + } + +// --------------------------------------------------------- +// CPosTp117::ResumeThreadAndVerifyExit +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::ResumeThreadAndVerifyExit() + { + iLog->Log(_L("ResumeThreadAndVerifyExit")); + _LIT(KPanicErr, "Method didn't Panic when expected"); + _LIT(KPanicCodeErr, "Paniced with unexpected panic code"); + _LIT(KLeaveErr, "Method didn't end correctly"); + _LIT(KLeaveCodeErr, "Unexpected leave error"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + + User::WaitForRequest(status); + + // Used for debugging + TBuf<100> buf; + buf.Format(_L("ExitType %d Exit reason %d"), iThread.ExitType(), iThread.ExitReason()); + iLog->Log(buf); + + if (iExpectedExitType == ExitPanic) + { + AssertTrueSecL(iThread.ExitType() == EExitPanic, KPanicErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KPanicCodeErr); + } + else if (iExpectedExitType == ExitLeave) + { + AssertTrueSecL(iThread.ExitType() == EExitKill, KLeaveErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KLeaveCodeErr); + } + iThread.Close(); + } + + +// --------------------------------------------------------- +// CPosTp117::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp117::RunPanicTestL(TAny* /*aData*/) + { + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + TPosLmDatabaseEvent event; + TRequestStatus status; + manager->NotifyDatabaseEvent(event, status); + + // TBD There might be timing problems on target + User::After(100000); + // The second call causes Panic EPosEventNotifierAlreadyHasOutstandingRequest + manager->NotifyDatabaseEvent(event, status); + User::After(100000); + + CleanupStack::PopAndDestroy(manager); + + } + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp117::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp117::CreateThreadL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp117::CreateThreadL() + { + _LIT(KThreadName, "Tp117 test thread"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + TInt err=0; + err = iThread.Create(KThreadName, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + } + +// ----------------------------------------------------------------------------- +// CTP117ActiveLmEvent::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CTP117ActiveLmEvent* CTP117ActiveLmEvent::NewL(CStifLogger* aLog) + { + CTP117ActiveLmEvent* self = new(ELeave) CTP117ActiveLmEvent(aLog); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CTP117ActiveLmEvent::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CTP117ActiveLmEvent::ConstructL() + { + iManager = CPosLmDatabaseManager::NewL(); + } + +// ----------------------------------------------------------------------------- +// CTP117ActiveLmEvent::CTP117ActiveLmEvent +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// + +CTP117ActiveLmEvent::CTP117ActiveLmEvent(CStifLogger* aLog) : + CActive(EPriorityNormal), + iLog(aLog) + { + CActiveScheduler::Add(this); + iGlobalErr=KErrNone; + iCheckUri = ETrue; + } + +// Destructor +CTP117ActiveLmEvent::~CTP117ActiveLmEvent() + { + Cancel(); + delete iManager; + iManager = NULL; + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::SetExpectedDatabase +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::SetExpectedDatabase(const TDesC& aDatabaseUri) + { + iExpectedDatabase.Zero(); + iExpectedDatabase.Append(_L("file://")); + iExpectedDatabase.Append(aDatabaseUri); + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::CallNotifyDatabaseEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::CallNotifyDatabaseEvent() + { + iLog->Log(_L("CallNotifyDatabaseEvent")); + iManager->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::CallDatabaseUriFromLastEventLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::CallDatabaseUriFromLastEventLC() + { + iLog->Log(_L("CallDatabaseUriFromLastEventLC")); + TRAPD(err, + CleanupStack::PopAndDestroy(iManager->DatabaseUriFromLastEventLC())); + if (err !=KErrNone) + { + if (err == KErrNotFound) + { + iLog->Log(_L("DatabaseUriFromLastEventLC leaved with KErrNotFound")); + } + else + { + iLog->Log(_L("DatabaseUriFromLastEventLC leaved with error")); + } + } + else + { + // No error from second call to DatabaseUriFromLastEventLC + + } + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::Start +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::Start() + { + iLog->Log(_L("CTP117ActiveLmEvent::Start")); + // Get ready for event + iManager->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::RunL() + { + iLog->Log(_L("CTP117ActiveLmEvent::RunL")); + VerifyEventL(); + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::RunError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CTP117ActiveLmEvent::RunError(TInt aError) + { + iLog->Log(_L("CTP117ActiveLmEvent::RunError")); + TBuf<100> buf; + buf.Format(_L("Errorcode in RunError: %d"), aError); + iLog->Log(buf); + iGlobalErr++; + //Error in RunL + Cancel(); + CActiveScheduler::Stop(); + return aError; + } + +// --------------------------------------------------------- +// CActiveLmOperation::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::DoCancel() + { + iLog->Log(_L("CTP117ActiveLmEvent::DoCancel")); + iManager->CancelNotifyDatabaseEvent(); + iLog->Log(_L("CTP117ActiveLmEvent::DoCancel Done")); + } + +// --------------------------------------------------------- +// CActiveLmOperation::GetErrors +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CTP117ActiveLmEvent::GetErrors() + { + return iGlobalErr; + } + +// --------------------------------------------------------- +// CTP117ActiveLmEvent::VerifyEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CTP117ActiveLmEvent::VerifyEventL() + { + iLog->Log(_L("CTP117ActiveLmEvent::VerifyEvent")); + + TBuf<150> buffe; + + buffe.Format(_L("VerifyEvent Event: %d "), iEvent.iEventType); + iLog->Log(buffe); + + // Verify event here + if (iEvent.iEventType != iExpectedEvent) + { + buffe.Zero(); + buffe.Format(_L("ERROR: Wrong event: exp %d got %d"),iExpectedEvent, iEvent.iEventType); + iLog->Log(buffe); + iGlobalErr++; + } + + // Only do check of DatabaseUriFromLastEventLC when event is differet from unknown + // because when this event occurs the uri is not set + if (iCheckUri && iEvent.iEventType != EPosLmDbUnknownEvent) + { + HBufC16* dbUri = iManager->DatabaseUriFromLastEventLC(); + buffe.Zero(); + buffe.Format(_L("Event: %d URI %S"), iEvent.iEventType, dbUri); + iLog->Log(buffe); + + if (iExpectedDatabase.CompareC(*dbUri) != 0) + { + iLog->Log(_L("ERROR: Wrong db name")); + buffe.Zero(); + buffe.Append(_L("Should be ")); + buffe.Append(iExpectedDatabase); + iLog->Log(buffe); + iGlobalErr++; + } + CleanupStack::PopAndDestroy(dbUri); + + // Call DatabaseUriFromLastEventLC again + TRAPD(err, + CleanupStack::PopAndDestroy(iManager->DatabaseUriFromLastEventLC())); + if (err !=KErrNone) + { + if (err == KErrNotFound) + { + iLog->Log(_L("Second call to DatabaseUriFromLastEventLC leaved with KErrNotFound")); + } + else + { + iLog->Log(_L("Second call to DatabaseUriFromLastEventLC leaved with error")); + } + } + else + { + // No error from second call to DatabaseUriFromLastEventLC + + } + } + else + { + iLog->Log(_L("URI was not checked")); + } + + CActiveScheduler::Stop(); + + iLog->Log(_L("VerifyEvent Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp118.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp118.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,751 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp118.h" +#include +#include +#include +#include "FT_DatabaseUtility.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp118::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::CloseTest() + { + iLog->Log(_L("CloseTest")); + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("RemoveAllLmDatabasesL() leaved")); + + TRAP(err, DeleteTp118FilesL()); + if (err != KErrNone) iLog->Log(_L("DeleteTp118FilesL() leaved")); + + delete iDatabases; + iDatabases=NULL; + } + +// --------------------------------------------------------- +// CPosTp118::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::StartL() + { + TInt err = KErrNone; + // Remove all databases + RemoveAllLmDatabasesL(); + + DeleteTp118FilesL(); + TBuf<100> buf; + + CPosLandmarkDatabase* lmd = NULL; + + iLog->Log(_L("1) Create a valid landmark db")); + // 1) Create a valid landmark db, it should be listed + FTDatabaseUtility::CreateDatabaseL(_L("c:TP118.ldb")); + + // 2) List an verify that db created in step 1 is listed + iLog->Log(_L("2) Verify that db created in step1 is listed:")); + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + + TInt res = VerifyList(iDatabases, _L("file://C:TP118.ldb")); + AssertTrueSecL(res, _L("file://C:TP118.LDB was not found")); + CleanupStack::PopAndDestroy(dbManager); + + // 3) Create a valid landmark db, but without correct file extension + iLog->Log(_L("3) Create a valid landmark db, but without correct file extension")); + FTDatabaseUtility::CreateDatabaseL(_L("c:TP118_NoExtension"), EFalse); + dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // 4) List all databases and verify that db created in step 3 is not listed + iLog->Log(_L("List all databases and verify that db created in step 3 is not listed")); + delete iDatabases; iDatabases=NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + + res = VerifyList(iDatabases, _L("file://c:TP118_NoExtension")); + AssertTrueSecL(!res, _L("file://c:TP118_NoExtension should not have been found")); + CleanupStack::PopAndDestroy(dbManager); + + // 5) Create lm db without correct secure id + iLog->Log(_L("5) Create lm db without correct secure id")); + FTDatabaseUtility::CreateDatabaseL(_L("c:TP118_WrongId.ldb"), ETrue, ETrue); + dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // 6) List all databases and verify that db created in step 5 is not listed + iLog->Log(_L("6) List all databases and verify that db created in step 5 is not listed")); + delete iDatabases; iDatabases=NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + + res = VerifyList(iDatabases, _L("c:TP118_WrongId.ldb")); + AssertTrueSecL(!res, _L("file://c:TP118_WrongId.ldb should not have been found")); + CleanupStack::PopAndDestroy(dbManager); + + // 7 Create lm db with invalid landmarks tables + iLog->Log(_L("7) Create lm db with invalid landmarks tables")); + FTDatabaseUtility::CreateDatabaseL(_L("C:TP118_INVALIDTABLES.ldb"), ETrue, EFalse, ETrue); + dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // 8) List all databases and verify that db created in step 7 is listed + iLog->Log(_L("8) List all databases and verify that db created in step 7 is listed")); + delete iDatabases; iDatabases=NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + res = VerifyList(iDatabases, _L("file://C:TP118_INVALIDTABLES.ldb")); + AssertTrueSecL(res, _L("file://C:TP118_INVALIDTABLES.ldb should have been found")); + CleanupStack::PopAndDestroy(dbManager); + + // CleanupStack::PopAndDestroy(dbManager); + // This causes DBMS to panic UTFW (this TestProgram) + // Adds landmarks but needed tables are already removed + // CreateLandmarksInDbL(_L("C:TP118_INVALIDTABLES.LDB")); + + /* + ///////////////////////////////////////////// + // Add extra test here, set this db to default + iLog->Log(_L("SetDefaultDatabaseL")); + dbManager->SetDefaultDatabaseL(_L("C:TP118_INVALIDTABLES.LDB")); + CleanupStack::PopAndDestroy(dbManager); + + // Try to open defaultdb which is the db created in step18 + // Check that the default db is re-created when it is corrupt + CPosLandmarkDatabase* lmdb = NULL; + TRAP(err, lmdb = CPosLandmarkDatabase::OpenL()); + if (err == KErrNone) + { + CleanupStack::PushL(lmdb); + CheckLandmarkDbL(lmdb); + CleanupStack::PopAndDestroy(lmdb); + //This causes DBMS to panic UTFW (this TestProgram) + // Adds landmarks but needed tables are already removed + CreateLandmarksInDbL(_L("C:TP118_INVALIDTABLES.LDB")); + } + else + { + LogErrorAndLeave(_L("OpenL should not leave with err"), err); + } + */ + ///////////////////////////////////////////// + + // 9) Try to open db created in step7 + iLog->Log(_L("9) Open db created in step 7")); + lmd = CPosLandmarkDatabase::OpenL(_L("file://C:TP118_INVALIDTABLES.ldb")); + CleanupStack::PushL(lmd); + CheckLandmarkDbL(lmd); + CleanupStack::PopAndDestroy(lmd); + + // 10) Drop table in db + iLog->Log(_L("10) Create db and then drop tables in db")); + dbManager=CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + _LIT(KDropTableLmDb, "C:TP118_DROPTABLELMDB.ldb"); + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDropTableLmDb); + dbManager->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + + CreateLandmarksInDbL(KDropTableLmDb); + DropTableL(KDropTableLmDb, KPosLmLandmarkTable); + + delete iDatabases; iDatabases=NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + res = VerifyList(iDatabases, _L("file://C:TP118_DROPTABLELMDB.ldb")); + AssertTrueSecL(res, _L("C:TP118_DropTableLmDb.ldb was not found")); + CleanupStack::PopAndDestroy(dbManager); + + // 11) Try to open db created in step10 + iLog->Log(_L("11) Open db created in step 10")); + lmd = CPosLandmarkDatabase::OpenL(_L("file://C:TP118_DROPTABLELMDB.ldb")); + + // Error when opening db + CleanupStack::PushL(lmd); + TRAP(err, CheckLandmarkDbL(lmd)); + AssertTrueSecL(err == KErrNotFound, _L("11) CheckLandmarkDbL did not leave with KErrNotFound")); + + CleanupStack::PopAndDestroy(lmd); + // Try to add landmarks to this db + // Leaves with KErrNotFound + //CreateLandmarksInDbL(_L("C:TP118_DROPTABLELMDB.LDB"),1); + + // 12) DropIndexL + iLog->Log(_L("Step12: DropIndexL")); + dbManager=CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + _LIT(KTP118_DROPINDEXLMDB_LDB, "C:TP118_DROPINDEXLMDB.ldb"); + HPosLmDatabaseInfo* dbInfoDrop = HPosLmDatabaseInfo::NewLC(KTP118_DROPINDEXLMDB_LDB); + dbManager->CreateDatabaseL(*dbInfoDrop); + CleanupStack::PopAndDestroy(dbInfoDrop); + + CreateLandmarksInDbL(_L("C:TP118_DROPINDEXLMDB.ldb")); + iLog->Log(_L("12) DropIndex")); + DropIndexL(_L("C:TP118_DROPINDEXLMDB.LDB"), KPosLmCategoryTable, KPosLmGlobalCategoryIdIndex); + CleanupStack::PopAndDestroy(dbManager); + + // 13) Try to open db created in step12 + iLog->Log(_L("13) Open db created in step 12")); + lmd = CPosLandmarkDatabase::OpenL(_L("C:TP118_DROPINDEXLMDB.ldb")); + + CleanupStack::PushL(lmd); + CheckLandmarkDbL(lmd); + CleanupStack::PopAndDestroy(lmd); + // Try to add landmarks to this db + CreateLandmarksInDbL(_L("C:TP118_DROPINDEXLMDB.LDB"), 1); + + // 14) + iLog->Log(_L("14) DropIndex")); + dbManager=CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + _LIT(KTP118_DROPINDEXLMDB2_LDB, "C:TP118_DROPINDEXLMDB2.ldb"); + HPosLmDatabaseInfo* dbInfoDrop2 = HPosLmDatabaseInfo::NewLC(KTP118_DROPINDEXLMDB2_LDB); + dbManager->CreateDatabaseL(*dbInfoDrop2); + CleanupStack::PopAndDestroy(dbInfoDrop2); + + CreateLandmarksInDbL(_L("C:TP118_DROPINDEXLMDB2.ldb")); + DropIndexL(_L("C:TP118_DROPINDEXLMDB2.LDB"), KPosLmLandmarkTable, KPosLmLandmarkIdIndex); + CleanupStack::PopAndDestroy(dbManager); + + // 15) Try to open db created in step13 + iLog->Log(_L("15) Open db created in step 14")); + lmd = CPosLandmarkDatabase::OpenL(_L("C:TP118_DROPINDEXLMDB2.ldb")); + + CleanupStack::PushL(lmd); + CheckLandmarkDbL(lmd); + CleanupStack::PopAndDestroy(lmd); + // Try to add landmarks to this db + CreateLandmarksInDbL(_L("C:TP118_DROPINDEXLMDB2.ldb"), 1); + + //////////// + // 16) Create an ordinary database with some landmarks and then remove some parts of the binary file + // Create db by manually removing some parts with notepad + /* + //Use this part to create db "TP118HalfLmDb.ldb" containing some landmarks, then use notepad to remove + // some parts from physical file + dbManager=CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + dbManager->CreateDatabaseL(_L("TP118HalfLmDb.ldb")); + CreateLandmarksInDbL(_L("TP118HalfLmDb.ldb")); + CleanupStack::PopAndDestroy(dbManager); + */ + // Use corrupted file + iLog->Log(_L("16) Use corrupted file")); + CopyTestDbFileL(_L("TP118HALFLMDB_2.ldb")); + + dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + delete iDatabases; iDatabases = NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + + res = VerifyList(iDatabases, _L("file://C:TP118HALFLMDB_2.ldb")); + AssertTrueSecL(res, _L("file://C:TP118HALFLMDB_2.LDB should have been found")); + CleanupStack::PopAndDestroy(dbManager); + + // 17) Try to open db created in step16m it should not be possible + // Before it returned KErrCorrupt(?) but now with Mars wk21 SDK it returns KErrNotSupported + CPosLandmarkDatabase* someLmDb = NULL; + TRAP(err, someLmDb = CPosLandmarkDatabase::OpenL(_L("TP118HalfLmDb_2.ldb"))); + if (err == KErrNone) + { + CleanupStack::PushL(someLmDb); + ExecuteAndDeleteLD(someLmDb->InitializeL()); + CleanupStack::PopAndDestroy(someLmDb); + AssertTrueSecL(EFalse,_L("OpenL should leave with error")); + } + else + { + buf.Format(_L("OpenL leaved with %d"), err); + iLog->Log(buf); + } + + // 18) Use same file as in 16 and set this file to default db + iLog->Log(_L("Use same file as in 16 and set this file to default db")); + CopyTestDbFileL(_L("TP118HALFLMDB_2.LDB")); + dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + iLog->Log(_L("SetDefaultDatabaseL")); + dbManager->SetDefaultDatabaseUriL(_L("Tp118HALFLMDB_2.ldb")); + CleanupStack::PopAndDestroy(dbManager); + + // 19) Try to open defaultdb which is the db created in step18 + // Before Mars wk21 SDK the default db is re-created when it is corrupt + // but now instead KErrNotSUpported is returned + iLog->Log(_L("Try to open defaultdb which is the db created in step18")); + TRAP(err, someLmDb = CPosLandmarkDatabase::OpenL()); + + if (err == KErrNone) + { + CleanupStack::PushL(someLmDb); + CheckLandmarkDbL(someLmDb); + CleanupStack::PopAndDestroy(someLmDb); + // Try to add landmarks to this db + CreateLandmarksInDbL(_L("Tp118HALFLMDB_2.ldb")); + } + else + { + //LogErrorAndLeave(_L("OpenL should not leave with err"), err); + buf.Format(_L("open defaultdb leaved with %d"), err); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp118::CheckLandmarkDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::CheckLandmarkDbL(CPosLandmarkDatabase* aDb) + { + iLog->Log(_L("CheckLandmarkDbL")); + + if (aDb->IsInitializingNeeded()) ExecuteAndDeleteLD(aDb->InitializeL()); + + CPosLmItemIterator* iter = aDb->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TInt size = iter->NumOfItemsL(); + TBuf<100> buf; + buf.Format(_L("DB contains %d nr of landmarks"), size); + iLog->Log(buf); + + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = aDb->ReadLandmarkLC(id); + TPtrC name; + lm->GetLandmarkName(name); + // Debugging iLog->Log(name); + id = iter->NextL(); + CleanupStack::PopAndDestroy(lm); + } + + // Try to get an non existing landmark + CPosLandmark* lm = NULL; + TRAPD(err, lm = aDb->ReadLandmarkLC(123456)); + if (err != KErrNotFound) + { + CleanupStack::PopAndDestroy(lm); + CleanupStack::PopAndDestroy(iter); + AssertTrueSecL(EFalse,_L("ReadLandmarkLC should leave with KErrNotFound")); + } + + CleanupStack::PopAndDestroy(iter); + + // Check categories + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*aDb); + CleanupStack::PushL(categoryManager); + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + + TInt catCount = catIter->NumOfItemsL(); + + buf.Format(_L("Found %d nr of categories items in db"), catCount); + iLog->Log(buf); + + id = catIter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(id); + TPtrC name; + cat->GetCategoryName(name); + // Debugging iLog->Log(name); + CleanupStack::PopAndDestroy(cat); + id = catIter->NextL(); + } + + CleanupStack::PopAndDestroy(catIter); + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp118::DeleteTp118FilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::DeleteTp118FilesL() + { + iLog->Log(_L("DeleteTp118FilesL")); + RFs fs; + TInt err = fs.Connect(); + AssertTrueSecL(err == KErrNone, _L("fs.Connect returned with error"), err); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + // delete all TP118 files + err = fileMan->Delete(_L("c:\\private\\100012a5\\*TP118*.*")); + AssertTrueSecL(err == KErrNone || err == KErrNotFound, _L("CFileMan could not delete files1"), err); + + err = fileMan->Delete(_L("c:\\private\\100012a5\\*TP118*")); + AssertTrueSecL(err == KErrNone || err == KErrNotFound, _L("CFileMan could not delete files2"), err); + + CleanupStack::PopAndDestroy(1); //fileMan + CleanupStack::PopAndDestroy(1); //fs + iLog->Log(_L("DeleteTp118FilesL Done")); + + } + +// --------------------------------------------------------- +// CPosTp118::CreateLandmarksInDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::CreateLandmarksInDbL(const TDesC& aDbName, TInt aIndex) + { + iLog->Log(_L("CreateLandmarksInDbL")); + const TInt KNrOfLandmarks = 50; + const TInt KNrOfCategories = 10; + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(aDbName); + CleanupStack::PushL(lmd); + + ExecuteAndDeleteLD(lmd->InitializeL()); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + RArray arr; + CleanupClosePushL(arr); + TInt i=0; + TBuf<150> buf; + + // Create categories + for (i=0; iSetCategoryNameL(buf); + TPosLmItemId id=0; + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, id = cm->AddCategoryL(*category)); + } + arr.Append(id); + CleanupStack::PopAndDestroy(category); + } + + // Create landmarks and attach every category to every landmark + for (i=0;iSetLandmarkNameL(buf); + lm1->SetLandmarkDescriptionL(_L("SomeVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription")); + for (TInt j=0;jAddCategoryL(arr[j]); + } + TInt err = KErrLocked; + while (err==KErrLocked) + { + TRAP(err, lmd->AddLandmarkL(*lm1)); + } + + CleanupStack::PopAndDestroy(lm1); + } + + CleanupStack::PopAndDestroy(&arr); + + CleanupStack::PopAndDestroy(cm); + + ExecuteAndDeleteLD(lmd->CompactL()); + CleanupStack::PopAndDestroy(lmd); + + } + +// --------------------------------------------------------- +// CPosTp118::VerifyList +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp118::VerifyList(CDesCArray* aList, const TDesC& aDbName) + { + TBool found = EFalse; + TInt count = aList->Count(); + TBuf<100> buf; + buf.Format(_L("Found %d nr of dbs"), count); + iLog->Log(buf); + for (TInt i=0;iLog((*aList)[i]); + if ((*aList)[i].Compare(aDbName) == KErrNone) + { + found = ETrue; + } + } + return found; + } + +// --------------------------------------------------------- +// CPosTp118::DropTableL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::DropTableL(const TDesC& aDbName, const TDesC& aTable) + { + /* + // Incremental + iLog->Log(_L("DropTableL")); + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + if (err != KErrNone) LogErrorAndLeave(_L("Database could not be opened"), err); + + RDbIncremental dbInc; + CleanupClosePushL(dbInc); + + TInt step = 100; + err = dbInc.DropTable(db, aTable, step); + if (err != KErrNone) LogErrorAndLeave(_L("DropTable could not be performed"), err); + + while (step > 50) + { + buf.Format(_L("ProgressStep %d "), step); + iLog->Log(buf); + dbInc.Next(step); + } + + dbInc.Close(); + db.Close(); + + CleanupStack::PopAndDestroy(&dbInc); + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + */ + + iLog->Log(_L("DropTableL")); + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + AssertTrueSecL(err == KErrNone, _L("Database could not be opened"), err); + err = db.DropTable(aTable); + AssertTrueSecL(err == KErrNone, _L("DropTable could not be performed"), err); + db.Close(); + + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + + } + +// --------------------------------------------------------- +// CPosTp118::AlterTableL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::AlterTableL(const TDesC& aDbName) + { + iLog->Log(_L("AlterTableL")); + // Incremental + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + AssertTrueSecL(err == KErrNone, _L("Database could not be opened"), err); + + RDbIncremental dbInc; + CleanupClosePushL(dbInc); + + + CDbColSet* newColumns = CDbColSet::NewLC(); + + TDbCol col(KPosLmIconIdCol, EDbColUint32); + col.iAttributes = col.EAutoIncrement; + newColumns->AddL(col); + + newColumns->AddL(TDbCol(KPosLmIconPathCol, EDbColLongText, KMaxFileName)); + //User::LeaveIfError(aDb.CreateTable(KPosLmIconTable, *columns)); + + TInt step = 100; + err = dbInc.AlterTable(db, KPosLmIconTable, *newColumns, step); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("AlterTable could not be performed, err %d"), err); + iLog->Log(buf); + } + else + { + + while (step > 1) + { + buf.Format(_L("ProgressStep %d "), step); + iLog->Log(buf); + dbInc.Next(step); + } + } + dbInc.Close(); + db.Close(); + + CleanupStack::PopAndDestroy(newColumns); + CleanupStack::PopAndDestroy(&dbInc); + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + /* + + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + if (err != KErrNone) LogErrorAndLeave(_L("Database could not be opened"), err); + + + CDbColSet* newColumns = CDbColSet::NewLC(); + + TDbCol col(KPosLmIconIdCol, EDbColUint32); + col.iAttributes = col.EAutoIncrement; + newColumns->AddL(col); + + newColumns->AddL(TDbCol(KPosLmIconPathCol, EDbColLongText, KMaxFileName)); + //User::LeaveIfError(aDb.CreateTable(KPosLmIconTable, *columns)); + + TInt step = 100; + err = db.AlterTable(KPosLmIconTable, *newColumns); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("AlterTable could not be performed, err %d"), err); + iLog->Log(buf); + } + + db.Close(); + + CleanupStack::PopAndDestroy(newColumns); + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + */ + } + + +// --------------------------------------------------------- +// CPosTp118::DropIndexL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp118::DropIndexL(const TDesC& aDbName, const TDesC& aTable, const TDesC& aIndex) + { + iLog->Log(_L("DropIndexL()")); + + //Incremental + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + AssertTrueSecL(err == KErrNone, _L("Database could not be opened"), err); + + RDbIncremental dbInc; + CleanupClosePushL(dbInc); + + TInt step = 100; + err = dbInc.DropIndex(db, aIndex, aTable, step); + AssertTrueSecL(err == KErrNone, _L("DropIndex could not be performed"), err); + + while (step > 1) + { + buf.Format(_L("ProgressStep %d "), step); + iLog->Log(buf); + dbInc.Next(step); + } + + CleanupStack::PopAndDestroy(&dbInc); + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + + /* + RDbs dbSession; + CleanupClosePushL(dbSession); + User::LeaveIfError(dbSession.Connect()); + + RDbNamedDatabase db; + CleanupClosePushL(db); + TBuf<100> buf; + + TInt err = db.Open(dbSession, aDbName ,KPosLmDbSecureFormat); + if (err != KErrNone) LogErrorAndLeave(_L("Database could not be opened"), err); + + TInt step = 100; + err = db.DropIndex(aIndex, aTable); + if (err != KErrNone) LogErrorAndLeave(_L("DropIndex could not be performed"), err); + + CleanupStack::PopAndDestroy(&db); + CleanupStack::PopAndDestroy(&dbSession); + */ + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp119.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp119.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,622 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp119.h" +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include +#include "badesca.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp119::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::StartL() + { + // PrepareDatabases + const TInt KNrOfDatabases = 5; + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + // List databases + // TBool searchRefined = ETrue; + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbUris = dbMan->ListDatabasesLC(); + CleanupStack::Pop(dbUris); + AssertTrueSecL(dbUris->Count() == KNrOfDatabases, _L("Wrong number of test databases!")); + CleanupStack::PopAndDestroy(dbMan); + CleanupStack::PushL(dbUris); + + // 1-2. Search in all databases + SearchAllDbsL(dbUris, ENoSort); + + // 3-4. Remove one of the databases and re-search + RemoveDatabaseL(_L("c:\\private\\100012a5\\DBS_101FE978_EPOSLM_080.LDB")); + SearchAllButOneL(dbUris); + + // 5-6. Restore all ofthe databases but one and re-search + RemoveDatabaseL(_L("c:\\private\\100012a5\\DBS_101FE978_EPOSLM_105.LDB")); + RemoveDatabaseL(_L("c:\\private\\100012a5\\DBS_101FE978_EPOSLM_040.LDB")); + RemoveDatabaseL(_L("c:\\private\\100012a5\\DBS_101FE978_EPOSLM_020.LDB")); + SearchOneDbL(dbUris); + + // 7-8. Restore all ofthe databases and re-search + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + SearchAllDbsL(dbUris, EAsc); + + // 9. Test SetMaxNumOfMatches + TestMaxNrOfMatchesL(dbUris); + + // 10. Test MatchIteratorL + TestMatchIteratorL(dbUris); + + // 11-12. Search all + one non-existing + SearchNonExistingDbL(dbUris); + + // 13. Search database multiple times + SearchDbMultipleTimesL(dbUris); + + // 14-15. Search all + one non-existing + one with invalid URI + SearchInvalidURIDbL(dbUris); + + CleanupStack::PopAndDestroy(dbUris); + } + +// --------------------------------------------------------- +// CPosTp119::SearchAllDbsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchAllDbsL(CDesCArray* aDbUris, TTp119SortOrder aSortOrder) + { + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, aSortOrder, !searchRefined); + + // Verify Result - no errors should have occurred and all databases should return matches + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, aSortOrder); + AssertTrueSecL(searchErrors == 0, _L("Found %d search errors"), searchErrors); + for (TInt i = 0; i < aDbUris->Count(); i++) + { + AssertTrueSecL(multiSearcher->NumOfMatches(i) > 0, _L("Found no matches")); + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::SearchAllButOneL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchAllButOneL(CDesCArray* aDbUris) + { + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, EAsc, !searchRefined); + + // Verify Result - KErrNotFound for the removed database (eposlm_80.ldb) - Matches from all but this. + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, EAsc); + AssertTrueSecL(searchErrors == 1, _L("Found %d search errors"), searchErrors); + CPosLmMultiDbSearch::TSearchError searchErr; + multiSearcher->GetSearchError(0, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotFound, _L("Expected KErrNotFound but got %d"), searchErr.iErrorCode); + TBuf<64> uriWithError((*aDbUris)[searchErr.iDatabaseIndex]); + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError == _L("file://c:eposlm_080.ldb"), _L("Error from wrong database")); + for (TInt i = 0; i < aDbUris->Count(); i++) + { + if (i != searchErr.iDatabaseIndex) + { + AssertTrueSecL(multiSearcher->NumOfMatches(i) > 0, _L("Found no matches")); + } + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::SearchOneDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchOneDbL(CDesCArray* aDbUris) + { + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, EAsc, !searchRefined); + + // Verify Result - Only matches from the one (eposlm_60.ldb) remaining. KErrNotFound from the others + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, EAsc); + AssertTrueSecL(searchErrors == 4, _L("Found %d search errors"), searchErrors); + for (TInt i = 0; i < searchErrors; i++) + { + CPosLmMultiDbSearch::TSearchError searchErr; + multiSearcher->GetSearchError(i, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotFound, _L("Expected KErrNotFound but got %d"), searchErr.iErrorCode); + TBuf<64> uriWithError((*aDbUris)[searchErr.iDatabaseIndex]); + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError != _L("file://c:eposlm_60.ldb"), _L("Eror from wong database")); + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::SearchNonExistingDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchNonExistingDbL(CDesCArray* aDbUris) + { + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + _LIT(KNonExistingDb, "file://pellefant.ldb"); + aDbUris->AppendL(KNonExistingDb); + multiSearcher->SetDatabasesToSearchL(*aDbUris); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, EAsc, !searchRefined); + + // Verify Result - one error from the non-existing should have been returned. + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, EAsc); + AssertTrueSecL(searchErrors == 1, _L("Found %d search errors"), searchErrors); + CPosLmMultiDbSearch::TSearchError searchErr; + multiSearcher->GetSearchError(0, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotFound, _L("Expected KErrNotFound but got %d"), searchErr.iErrorCode); + TBuf<64> uriWithError = (*aDbUris)[searchErr.iDatabaseIndex]; + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError == KNonExistingDb, _L("Error from wrong database")); + for (TInt i = 0; i < aDbUris->Count(); i++) + { + if (i != searchErr.iDatabaseIndex) + { + AssertTrueSecL(multiSearcher->NumOfMatches(i) > 0, _L("Found no matches")); + } + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::SearchInvalidURIDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchInvalidURIDbL(CDesCArray* aDbUris) + { + iLog->Log(_L("SearchInvalidURIDbL")); + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + _LIT(KNonExistingDb, "file://pellefant.ldb"); + aDbUris->AppendL(KNonExistingDb); + _LIT(KRemoteURI, "http://kallekanin.ldb"); + aDbUris->AppendL(KRemoteURI); + _LIT(KInvalidDrive, "file://r:nonexistingdrive.ldb"); + aDbUris->AppendL(KInvalidDrive); + + multiSearcher->SetDatabasesToSearchL(*aDbUris); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, EAsc, !searchRefined); + + // Verify Result - three errors should be returned + iLog->Log(_L("Verify Result - three errors should be returned")); + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, EAsc); + AssertTrueSecL(searchErrors == 3, _L("Found %d search errors"), searchErrors); + CPosLmMultiDbSearch::TSearchError searchErr; + TInt id1; + TInt id2; + TInt id3; + + multiSearcher->GetSearchError(0, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotFound, _L("Expected KErrNotFound but got %d"), searchErr.iErrorCode); + + TBuf<64> uriWithError = (*aDbUris)[searchErr.iDatabaseIndex]; + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError == KNonExistingDb, _L("Error from wrong database1")); + id1 = searchErr.iDatabaseIndex; + + multiSearcher->GetSearchError(1, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotSupported, _L("Expected KErrNotSupported but got %d"), searchErr.iErrorCode); + uriWithError.Zero(); + uriWithError = (*aDbUris)[searchErr.iDatabaseIndex]; + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError == KRemoteURI, _L("Error from wrong database2")); + id2 = searchErr.iDatabaseIndex; + + // KErrNotReady from dbs on non existing drives + multiSearcher->GetSearchError(2, searchErr); + AssertTrueSecL(searchErr.iErrorCode == KErrNotReady, _L("Expected KErrNotReady but got %d"), searchErr.iErrorCode); + uriWithError.Zero(); + uriWithError = (*aDbUris)[searchErr.iDatabaseIndex]; + uriWithError.LowerCase(); + AssertTrueSecL(uriWithError == KInvalidDrive, _L("Error from wrong database3")); + id3 = searchErr.iDatabaseIndex; + + for (TInt i=0; i < aDbUris->Count(); i++) + { + if (i != id1 && i != id2 && i != id3) + { + AssertTrueSecL(multiSearcher->NumOfMatches(i) > 0, _L("Found no matches")); + } + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::SearchDbMultipleTimesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchDbMultipleTimesL(CDesCArray* aDbUris) + { + // Remove all dbs but the first + aDbUris->Delete(1, aDbUris->Count() - 1); + + // 13. Repeat the same database multiple times (3 in this case) + aDbUris->AppendL((*aDbUris)[0]); + aDbUris->AppendL((*aDbUris)[0]); + + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + VerifyDbsToSearchL(multiSearcher, aDbUris); + + TBool searchRefined = ETrue; + SearchForLandmarksL(multiSearcher, EAsc, !searchRefined); + + // Verify Result - doubles should have been found + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, EAsc); + AssertTrueSecL(searchErrors == 0, _L("Found %d search errors"), searchErrors); + for (TInt i = 0; i < aDbUris->Count(); i++) + { + AssertTrueSecL(multiSearcher->NumOfMatches(i) > 0, _L("Found no matches")); + } + for (TInt i = 0; i < aDbUris->Count(); i++) + { + // Log landmark names to identify doublets + CPosLmItemIterator* iter = multiSearcher->MatchIteratorL(i); + if (iter) + { + CleanupStack::PushL(iter); + _LIT(KFormat, "Printing landmark names from db %S"); + TBuf<100> buf; + TPtrC dbName = (*aDbUris)[i]; + buf.Format(KFormat, &dbName); + iLog->Log(buf); + TPosLmItemId id = iter->NextL(); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*aDbUris)[i]); + CleanupStack::PushL(db); + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = db->ReadLandmarkLC(id); + TPtrC name; + lm->GetLandmarkName(name); + iLog->Log(name); + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(2, iter); + } + } + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::TestMaxNrOfMatchesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::TestMaxNrOfMatchesL(CDesCArray* aDbUris) + { + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*aDbUris); + CleanupStack::PushL(multiSearcher); + TInt nrOfDbs = aDbUris->Count(); + TInt maxNrOfMatches = 4; + TBool searchRefined = ETrue; + TInt fetchedMaxNrOfMatches = multiSearcher->MaxNumOfMatches(); + AssertTrueSecL(fetchedMaxNrOfMatches == KPosLmMaxNumOfMatchesUnlimited, _L("Not unlimited number of matches by default.")); + multiSearcher->SetMaxNumOfMatches(maxNrOfMatches); + fetchedMaxNrOfMatches = multiSearcher->MaxNumOfMatches(); + AssertTrueSecL(fetchedMaxNrOfMatches == maxNrOfMatches, _L("Unexpected maxNrOfMatches")); + + // Test normal flow + SearchForLandmarksL(multiSearcher, ENoSort, !searchRefined); + TUint searchErrors = VerifyResultL(multiSearcher, *aDbUris, ENoSort); + AssertTrueSecL(searchErrors == 0, _L("Found %d search errors"), searchErrors); + for (TInt i = 0; i < nrOfDbs; i++) + { + CPosLmItemIterator* iter = multiSearcher->MatchIteratorL(i); + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == maxNrOfMatches, _L("Wrong number of matches")); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(multiSearcher->TotalNumOfMatches() == nrOfDbs * maxNrOfMatches, _L("Wrong number of total matches")); + + // Test resetting of max nr of matches during search - should not affect ongoing search + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*e*")); + textCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, searchRefined); + CleanupStack::PushL(operation); + + // Update maxNrOfMatches twice + TInt oldMaxNrOfMatches = maxNrOfMatches; + maxNrOfMatches--; + multiSearcher->SetMaxNumOfMatches(maxNrOfMatches); + maxNrOfMatches--; + multiSearcher->SetMaxNumOfMatches(maxNrOfMatches); + fetchedMaxNrOfMatches = multiSearcher->MaxNumOfMatches(); + AssertTrueSecL(fetchedMaxNrOfMatches == maxNrOfMatches, _L("Unexpected maxNrOfMatches")); + + operation->ExecuteL(); + CleanupStack::PopAndDestroy(operation); + CleanupStack::PopAndDestroy(textCriteria); + + searchErrors = VerifyResultL(multiSearcher, *aDbUris, ENoSort); + AssertTrueSecL(searchErrors == 0, _L("Found %d search errors"), searchErrors); + for (TInt i = 0; i < nrOfDbs; i++) + { + CPosLmItemIterator* iter = multiSearcher->MatchIteratorL(i); + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == oldMaxNrOfMatches, _L("Wrong number of matches")); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(multiSearcher->TotalNumOfMatches() == nrOfDbs * oldMaxNrOfMatches, _L("Wrong number of total matches")); + + // Test new search - the new maxNrOfMatches should have effect + SearchForLandmarksL(multiSearcher, ENoSort, !searchRefined); + searchErrors = VerifyResultL(multiSearcher, *aDbUris, ENoSort); + AssertTrueSecL(searchErrors == 0, _L("Found %d search errors"), searchErrors); + fetchedMaxNrOfMatches = multiSearcher->MaxNumOfMatches(); + AssertTrueSecL(fetchedMaxNrOfMatches == maxNrOfMatches, _L("Unexpected maxNrOfMatches")); + for (TInt i = 0; i < nrOfDbs; i++) + { + CPosLmItemIterator* iter = multiSearcher->MatchIteratorL(i); + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == maxNrOfMatches, _L("Wrong number of matches")); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(multiSearcher->TotalNumOfMatches() == nrOfDbs * maxNrOfMatches, _L("Wrong number of total matches")); + + CleanupStack::PopAndDestroy(multiSearcher); + } + +// --------------------------------------------------------- +// CPosTp119::TestMatchIteratorL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::TestMatchIteratorL(CDesCArray* /*aDbUris*/) + { + // Moved to TP130 + } + +// --------------------------------------------------------- +// CPosTp119::SearchForLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::SearchForLandmarksL( + CPosLmMultiDbSearch* aSearcher, + TTp119SortOrder aSortOrder, + TBool aRefined) + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*e*")); + textCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + + CPosLmOperation* operation = NULL; + if (aSortOrder == ENoSort) + { + operation = aSearcher->StartLandmarkSearchL(*textCriteria, aRefined); + } + else + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + if (aSortOrder == EDesc) + { + sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + } + operation = aSearcher->StartLandmarkSearchL(*textCriteria, sortPref, aRefined); + } + + CleanupStack::PushL(operation); + operation->ExecuteL(); + CleanupStack::PopAndDestroy(operation); + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp119::VerifyResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TUint CPosTp119::VerifyResultL( + CPosLmMultiDbSearch* aSearcher, + CDesCArray& aDbUris, + TTp119SortOrder aSortOrder) + { + TUint searchErrors = aSearcher->NumOfSearchErrors(); + for (TUint j = 0; j < searchErrors; j++) + { + CPosLmMultiDbSearch::TSearchError searchErr; + aSearcher->GetSearchError(j, searchErr); + TBuf<100> buf; + _LIT(KFormat, "Got error code %d from database nr%d : %S"); + TPtrC uri = aDbUris[searchErr.iDatabaseIndex]; + buf.Format(KFormat, searchErr.iErrorCode,searchErr.iDatabaseIndex, &uri); + iLog->Log(buf); + } + + // Verify sort order + if (aSortOrder != ENoSort) + { + for (TInt i = 0; i < aDbUris.Count(); i++) + { + CPosLmItemIterator* iterator = aSearcher->MatchIteratorL(i); + CleanupStack::PushL(iterator); + if (iterator && iterator->NumOfItemsL() > 0) + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(aDbUris[i]); + CleanupStack::PushL(db); + TPosLmItemId currentId = iterator->NextL(); + while (currentId != KPosLmNullItemId) + { + TPosLmItemId nextId = iterator->NextL(); + if (nextId != KPosLmNullItemId) + { + CPosLandmark* currentLM = db->ReadLandmarkLC(currentId); + CPosLandmark* nextLM = db->ReadLandmarkLC(nextId); + TPtrC currentName, nextName; + currentLM->GetLandmarkName(currentName); + nextLM->GetLandmarkName(nextName); + TInt order = nextName.CompareC(currentName); + if (aSortOrder == EAsc) + { + AssertTrueSecL(order >= 0, _L("Wrong sort order (not ascending)")); + } + else // aSortOrder == EDesc + { + AssertTrueSecL(order <= 0, _L("Wrong sort order (not descending)")); + } + CleanupStack::PopAndDestroy(2, currentLM); + } + currentId = nextId; + } + CleanupStack::PopAndDestroy(db); + } + CleanupStack::PopAndDestroy(iterator); + } + } + + return searchErrors; + } + +// --------------------------------------------------------- +// CPosTp119::RemoveDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::RemoveDatabaseL(const TDesC& aFile) + { + RFs fileServer; + User::LeaveIfError(fileServer.Connect()); + CleanupClosePushL(fileServer); + CFileMan* fileMan = CFileMan::NewL(fileServer); + CleanupStack::PushL(fileMan); + User::LeaveIfError(fileMan->Delete(aFile)); + CleanupStack::PopAndDestroy(2, &fileServer); + } + +// --------------------------------------------------------- +// CPosTp119::VerifyDbsToSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp119::VerifyDbsToSearchL( + CPosLmMultiDbSearch* aMultiSearcher, + CDesCArray* aDbUris) + { + CDesCArray* dbToSearch = aMultiSearcher->DatabasesToSearchL(); + CleanupStack::PushL(dbToSearch); + + // Verify that lengths of specified array and retrived array match + AssertTrueSecL(aDbUris->Count() == dbToSearch->Count(), _L("aDbUris->Count() != dbToSearch->Count()")); + + // Verify that length of specified array equals retrived length + AssertTrueSecL(aDbUris->Count() == aMultiSearcher->NumOfDatabasesToSearch(), _L("aDbUris->Count() != aMultiSearcher->NumOfDatabasesToSearch()")); + + for (TInt i = 0; i < aDbUris->Count(); i++) + { + TInt pos, pos2; + + // Verify that specified db can be found in retrieved list. + TInt err = dbToSearch->Find((*aDbUris)[i], pos); + + // Verify that retrieved db URI can be found in specified list + TInt err2 = aDbUris->Find(aMultiSearcher->DatabaseUriPtr(i), pos2); + + // Error handling + if (err != KErrNone || err2 != KErrNone) + { + // No match found + iLog->Log(_L("Didn't find expected db in db list")); + User::Leave(err); + } + else + { + dbToSearch->Delete(pos); + } + } + + // Verify that no more db exist in search list + AssertTrueSecL(dbToSearch->Count() == 0, _L("More dbs to search than expected")); + + CleanupStack::PopAndDestroy(dbToSearch); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp12.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp12.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,946 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp12.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include + +// CONSTANTS + +const TInt KNoLandmarksPanicCodes = 11; +const TInt KTestCaseCategoryIterator = 0; +const TInt KTestCaseLandmarkIterator = 1; + +const TInt KTestCasePartialAttributes1 = 2; +const TInt KTestCasePartialAttributes2 = 3; + +const TInt KTestCaseSortPrefNoAttribute = 4; +const TInt KTestCaseSortPrefSeveralAttribute = 5; + +const TInt KTestCaseNegativeMatches = 6; +const TInt KTestCaseNegativeDistance = 7; +const TInt KTestCaseNegativeRadius = 8; + +const TInt KTestCaseCompositeSearch1 = 9; +const TInt KTestCaseCompositeSearch2 = 10; +const TInt KTestCaseCompositeSearch3 = 11; +const TInt KTestCaseCompositeSearch4 = 12; + +const TInt KTestCaseDuplicateNotifyDatabaseEvent = 13; + +const TInt KTestCaseIncorrectCompositeType1 = 14; +const TInt KTestCaseIncorrectCompositeType2 = 15; +const TInt KTestCaseIncorrectCompositeType3 = 16; +const TInt KTestCaseIncorrectCompositeType4 = 17; + +const TInt KTestCaseInvalidOperationMode1 = 18; +const TInt KTestCaseInvalidOperationMode2 = 19; +const TInt KTestCaseInvalidOperationMode3 = 20; +const TInt KTestCaseInvalidOperationMode4 = 21; + +const TInt KTestCaseInvalidAttributes1 = 22; +const TInt KTestCaseInvalidAttributes2 = 23; + +const TInt KTestCaseCompositeSearch5 = 24; +const TInt KTestCaseCompositeSearch6 = 25; +const TInt KTestCaseCompositeSearch7 = 26; +const TInt KTestCaseCompositeSearch8 = 26; + +const TInt KTestCaseCategoryIteratorSortPref = 27; +const TInt KTestCaseReferencedCategoryIteratorSortPref = 28; + +const TInt KTestCaseCategorySearchSortPref = 29; +const TInt KTestCaseLandmarkSortPref = 30; +const TInt KTestCaseLandmarkSortPref2 = 31; +const TInt KTestCaseLandmarkSearchinvalidAttribute = 32; +const TInt KTestCaseLandmarkSearchinvalidAttribute2 = 33; + +const TInt KTestCaseInvalidRequestedPositionFields1 = 34; +const TInt KTestCaseInvalidRequestedPositionFields2 = 35; + +const TInt KTestCaseZeroMatches = 36; + +const TInt KTestLandmarkSetIconTest1 = 37; +const TInt KTestLandmarkSetIconTest2 = 38; +const TInt KTestCategorySetIconTest1 = 41; +const TInt KTestCategorySetIconTest2 = 42; + +_LIT(KResourceFilePath, "c:\\resource\\"); +_LIT(KResourceFile, "c:\\resource\\EPOSLMASYNCOPS.RSC"); +_LIT(KTempResourceFile, "c:\\resource\\TEMP_EPOSLMASYNCOPS.RSC"); + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp12::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp12::StartL() + { + MakeSurePanicDebugFileExistsL(); + RemoveDefaultDbL(); + TBuf<100> buf; + + + for (TInt i=0; i(i); + buf.Format(_L("Expected Panic code %d"), iExpectedPanicCode); + iLog->Log(buf); + + if (iExpectedPanicCode == EPosSpecifiedIntervalLiesOutsideIteratedSet) + { + iTestCase=KTestCaseCategoryIterator; + ResumeThreadAndVerifyExit(); + iTestCase=KTestCaseLandmarkIterator; + } + else if (iExpectedPanicCode == EPosInvalidPartialReadParameters) + { + iTestCase=KTestCasePartialAttributes1; + ResumeThreadAndVerifyExit(); + iTestCase=KTestCasePartialAttributes2; + } + else if (iExpectedPanicCode == EPosInvalidRequestedPositionFields) + { + iTestCase=KTestCaseInvalidRequestedPositionFields1; + ResumeThreadAndVerifyExit(); + iTestCase=KTestCaseInvalidRequestedPositionFields2; + } + else if (iExpectedPanicCode == EPosNoneOrMultipleLandmarkAttributeSet) + { + iTestCase=KTestCaseSortPrefNoAttribute; + ResumeThreadAndVerifyExit(); + iTestCase=KTestCaseSortPrefSeveralAttribute; + } + else if (iExpectedPanicCode == EPosNegativeValue) + { + iTestCase=KTestCaseNegativeDistance; + ResumeThreadAndVerifyExit(); + iTestCase=KTestCaseNegativeRadius; + } + else if (iExpectedPanicCode == EPosInvalidEnumValue) + { + iTestCase = KTestCaseIncorrectCompositeType1; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseIncorrectCompositeType2; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseIncorrectCompositeType3; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseIncorrectCompositeType4; + } + else if (iExpectedPanicCode == EPosInvalidOperationMode) + { + // Excerpt from EPos_LandmarksErrors.h: + // "Invalid operation mode. Caused by mixed calls to NextStep and ExecuteL + // for an CPosLmOperation object or subsequent calls to NextStep" + iTestCase = KTestCaseInvalidOperationMode1; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseInvalidOperationMode2; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseInvalidOperationMode3; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseInvalidOperationMode4; + } + else if (iExpectedPanicCode == EPosInvalidLandmarkAttribute) + { + iTestCase = KTestCaseInvalidAttributes1; + ResumeThreadAndVerifyExit(); + iTestCase = KTestCaseInvalidAttributes2; + } + + else //added for testing + { + continue; + } + + ResumeThreadAndVerifyExit(); + } + + iLog->Log(_L("Tests below causes a USER-130 panic to be raised")); + // Tests below causes a USER-130 panic to be raised + iExpectedPanicCode = static_cast(130); + + iTestCase = KTestCaseCompositeSearch1; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch2; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch3; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch4; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch5; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch6; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch7; + ResumeThreadAndVerifyExit(); + + iTestCase = KTestCaseCompositeSearch8; + ResumeThreadAndVerifyExit(); + + // Test below should raise a EPosEventNotifierAlreadyHasOutstandingRequest (2) panic + // defined in EPos_LandmarksServerPanics.h + // Since other testparts check for the same panic number change it to something else + // and then change it to the correct number (2) in the thread function + iLog->Log(_L("Test below should raise a EPosEventNotifierAlreadyHasOutstandingRequest (2) panic")); + iExpectedPanicCode = static_cast(222); + iTestCase = KTestCaseDuplicateNotifyDatabaseEvent; + ResumeThreadAndVerifyExit(); + + // Test that when using invalid CPosLmCategoryManager::TCategorySortPref in CategoryIteratorL + // causes a panic + iLog->Log(_L("Test that when using invalid CPosLmCategoryManager::TCategorySortPref causes a panic")); + iExpectedPanicCode = EPosInvalidEnumValue; + iTestCase = KTestCaseCategoryIteratorSortPref; + ResumeThreadAndVerifyExit(); + + // Test that when using invalid CPosLmCategoryManager::TCategorySortPref in ReferencedCategoryIteratorL + // causes a panic + iLog->Log(_L("Test that when using invalid CPosLmCategoryManager::TCategorySortPref causes a panic")); + iExpectedPanicCode = EPosInvalidEnumValue; + iTestCase = KTestCaseReferencedCategoryIteratorSortPref; + ResumeThreadAndVerifyExit(); + + // Test that setting SetMaxNumOfMatches to a negative value causes a panic + iLog->Log(_L("Test that setting SetMaxNumOfMatches to a negative value causes a panic")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestCaseNegativeMatches; + ResumeThreadAndVerifyExit(); + + // Test that setting SetMaxNumOfMatches to 0 causes a panic + iLog->Log(_L("Test that setting SetMaxNumOfMatches to 0 causes a panic")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestCaseZeroMatches; + ResumeThreadAndVerifyExit(); + + // Test starting a landmark category search with invalid SortPref panics + iLog->Log(_L("Test starting a landmark category search with invalid SortPref panics")); + iExpectedPanicCode = EPosInvalidEnumValue; + iTestCase = KTestCaseCategorySearchSortPref; + ResumeThreadAndVerifyExit(); + + // Test that it is not possible to create an invalid SortPref + iLog->Log(_L("Test that it is not possible to create an invalid SortPref")); + iExpectedPanicCode = EPosInvalidEnumValue; + iTestCase = KTestCaseLandmarkSortPref; + ResumeThreadAndVerifyExit(); + + // Test that it is not possible to set a SortPref to invalid values + iLog->Log(_L("Test that it is not possible to set a SortPref to invalid values")); + iExpectedPanicCode = EPosInvalidEnumValue; + iTestCase = KTestCaseLandmarkSortPref2; + ResumeThreadAndVerifyExit(); + + // Test that searching with an invalid attribute panics + iLog->Log(_L("Test that it is not possible to set a SortPref with incorrect attributes")); + iExpectedPanicCode = EPosNoneOrMultipleLandmarkAttributeSet; + iTestCase = KTestCaseLandmarkSearchinvalidAttribute; + ResumeThreadAndVerifyExit(); + + // Test that it is not possible to set a SortPref with incorrect + // attributes + iLog->Log(_L("Test that searching with an invalid attribute panics")); + iExpectedPanicCode = EPosNoneOrMultipleLandmarkAttributeSet; + iTestCase = KTestCaseLandmarkSearchinvalidAttribute2; + ResumeThreadAndVerifyExit(); + + // Test that Landmark->SetIcon with invalid index panics + iLog->Log(_L("Test that Landmark->SetIcon with invalid index panics")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestLandmarkSetIconTest1; + ResumeThreadAndVerifyExit(); + + // Test that Landmark->SetIcon with invalid maskindex panics + iLog->Log(_L("Test that Landmark->SetIcon with invalid maskindex panics")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestLandmarkSetIconTest2; + ResumeThreadAndVerifyExit(); + + // Test that Category->SetIcon with invalid index panics + iLog->Log(_L("Test that Category->SetIcon with invalid index panics")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestCategorySetIconTest1; + ResumeThreadAndVerifyExit(); + + // Test that Category->SetIcon with invalid maskindex panics + iLog->Log(_L("Test that Category->SetIcon with invalid maskindex panics")); + iExpectedPanicCode = EPosLmInvalidArgument; + iTestCase = KTestCategorySetIconTest2; + ResumeThreadAndVerifyExit(); + + } + +// --------------------------------------------------------- +// CPosTp12::ResumeThreadAndVerifyExit +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp12::ResumeThreadAndVerifyExit() + { + iLog->Log(_L("ResumeThreadAndVerifyExit")); + _LIT(KPanicErr, "Method didn't Panic when expected"); + _LIT(KPanicCodeErr, "Paniced with unexpected panic code"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + + User::WaitForRequest(status); + + // Used for debugging + TBuf<100> buf; + buf.Format(_L("ExitType %d Exit reason %d"), iThread.ExitType(), iThread.ExitReason()); + iLog->Log(buf); + + AssertTrueSecL(iThread.ExitType() == EExitPanic, KPanicErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedPanicCode, KPanicCodeErr); + + iThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp12::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp12::CloseTest() + { + iLog->Log(_L("CloseTest")); + iThread.Close(); + TRAPD(err, RestoreResourceFileL()); + if (err != KErrNone) iLog->Log(_L("Error in CloseTest")); + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp12::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp12::RunPanicTestL(TAny* aData) + { + CPosTp12* self = reinterpret_cast(aData); + + + if(self->iExpectedPanicCode == EPosInvalidValueSpecifiedInResourceFile) + { + self->ResourceFilePanicTestL(); + } + + RArray ids; + CleanupClosePushL(ids); + + CPosLandmarkDatabase* lmd = self->OpenDatabaseLC(); + CPosLandmark* lm = CPosLandmark::NewLC(); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + if (self->iExpectedPanicCode == EPosInvalidPositionFieldId) + { + lm->NextPositionFieldId(TUint16(222)); + } + else if (self->iExpectedPanicCode == EPosSpecifiedIntervalLiesOutsideIteratedSet) // CategoryIterator + { + if (self->iTestCase == KTestCaseCategoryIterator) + { + CPosLmItemIterator* iter = cm->CategoryIteratorL(); + CleanupStack::PushL(iter); + const TInt KCategories=20; + _LIT(KName, "CategoryTP12 - %d"); + for (TInt i=0; i categoryName; + categoryName.Format(KName,i); + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(categoryName); + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, cm->AddCategoryL(*lmc)); + } + CleanupStack::Pop(lmc); + } + + const TInt KStartIndex=5; + const TInt KNumOfItems=16; + iter->GetItemIdsL(ids, KStartIndex, KNumOfItems); + CleanupStack::PopAndDestroy(iter); + } + else if (self->iTestCase == KTestCaseLandmarkIterator) + { + CPosLmItemIterator* iterLm = lmd->LandmarkIteratorL(); + CleanupStack::PushL(iterLm); + const TInt KLmStartIndex=0; + const TInt KLmNumOfItems=1; + iterLm->GetItemIdsL(ids, KLmStartIndex, KLmNumOfItems); + CleanupStack::PopAndDestroy(iterLm); + } + } + else if (self->iExpectedPanicCode == EPosNoneOrMultipleLandmarkAttributeSet) + { + if (self->iTestCase == KTestCaseSortPrefNoAttribute) + { + TPosLmSortPref sortPref(CPosLandmark::ENoAttribute); + sortPref.SortOrder(); + } + else if (self->iTestCase == KTestCaseSortPrefSeveralAttribute) + { + TUint32 attr = CPosLandmark::ELandmarkName | CPosLandmark::EPosition; + TPosLmSortPref sortPref(attr); + sortPref.SortOrder(); + } + //Test that searching for landmarks with invalid attributes panics + else if (self->iTestCase == KTestCaseLandmarkSearchinvalidAttribute) + { + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(landmarkSearch); + // Invalid attribute, (correct ascended sorted) + TPosLmSortPref sortPref((TUint32)5); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Library*")); + CPosLmOperation* operation = landmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref); + CleanupStack::PushL(operation); + ExecuteAndDeleteLD(operation); + CleanupStack::PopAndDestroy(operation); + } + //Test that it is not possible to set a TPosLmSortPref with invalid attributes + else if (self->iTestCase == KTestCaseLandmarkSearchinvalidAttribute2) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + sortPref.SetSortByLandmarkAttribute((TUint32)5, TPosLmSortPref::EAscending); + } + } + else if (self->iExpectedPanicCode == EPosNaNCoordinate) + { + TCoordinate coord; + CPosLmNearestCriteria* lmnc = CPosLmNearestCriteria::NewLC(coord); + + CleanupStack::PopAndDestroy(lmnc); + } + else if (self->iExpectedPanicCode == EPosInvalidLandmarkAttribute) + { + if (self->iTestCase == KTestCaseInvalidAttributes1) + { + // Test with incorrect attributes + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetAttributesToSearch(CPosLandmark::EIcon); + CleanupStack::PopAndDestroy(textCriteria); + } + else if (self->iTestCase == KTestCaseInvalidAttributes2) + { + // Test with invalid attributes + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetAttributesToSearch(5); + CleanupStack::PopAndDestroy(textCriteria); + } + } + else if (self->iExpectedPanicCode == EPosInvalidPartialReadParameters) + { + CPosLmPartialReadParameters* partialParam = lmd->PartialReadParametersLC(); + if (self->iTestCase == KTestCasePartialAttributes1) + { + TUint attr = 348764; + partialParam->SetRequestedAttributes(attr); + } + else if (self->iTestCase == KTestCasePartialAttributes2) + { + TUint attr = CPosLandmark::ELandmarkName| + CPosLandmark::EPosition| + CPosLandmark::ECoverageRadius| + CPosLandmark::ECategoryInfo| + CPosLandmark::EIcon| + CPosLandmark::EDescription; + // attr equals 63 (see EPos_CPosLmPartialReadParameters.cpp) + partialParam->SetRequestedAttributes(attr+1); + } + CleanupStack::PopAndDestroy(partialParam); + } + else if (self->iExpectedPanicCode == EPosInvalidRequestedPositionFields) + { + CPosLmPartialReadParameters* partialParam = lmd->PartialReadParametersLC(); + RArray reqFields; + CleanupClosePushL(reqFields); + + if (self->iTestCase == KTestCaseInvalidRequestedPositionFields1) + { + // Test with index outside allowed interval + TInt outside = EPositionFieldIdLast; + reqFields.Append(++outside); + partialParam->SetRequestedPositionFields(reqFields); + } + else if (self->iTestCase == KTestCaseInvalidRequestedPositionFields2) + { + // Test with index outside allowed interval + TInt outside = EPositionFieldIdLast; + + reqFields.Append(EPositionFieldCountry); + reqFields.Append(EPositionFieldCity); + reqFields.Append(++outside); + + partialParam->SetRequestedPositionFields(reqFields); + } + CleanupStack::PopAndDestroy(&reqFields); + CleanupStack::PopAndDestroy(partialParam); + } + else if (self -> iExpectedPanicCode == EPosNegativeValue) + { + if (self->iTestCase == KTestCaseNegativeDistance) + { + TCoordinate corr(19,20,10); + CPosLmNearestCriteria* criteria = CPosLmNearestCriteria::NewLC(corr, ETrue); + criteria -> SetMaxDistance (-1); //should panic + CleanupStack::PopAndDestroy(criteria); + } + else if (self ->iTestCase == KTestCaseNegativeRadius) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + lm -> SetCoverageRadius(-1); // should panic + CleanupStack::PopAndDestroy(lm); + } + } + else if (self->iExpectedPanicCode == 130) + { + // The index supplied to method CPosLmCompositeCriteria::Argument must be in the + // interval [0, NumOfArguments - 1] otherwise cause a USER-130 Panic to be raised + if (self->iTestCase == KTestCaseCompositeSearch1) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Panic test 1, invalid position, should raise USER-130 panic + /*CPosLmSearchCriteria& comp1 = */ composite->Argument(0); + } + else if (self->iTestCase == KTestCaseCompositeSearch2 || self->iTestCase == KTestCaseCompositeSearch3) + { + CPosLandmarkSearch* search = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(search); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + //CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + //nameCriteria->SetSearchPatternL(_L("*")); + + CPosLmTextCriteria* textCriteria1 = CPosLmTextCriteria::NewLC(); + textCriteria1->SetTextL(_L("*")); + + TInt err = composite->AddArgument(textCriteria1); + if (err != KErrNone) User::Leave(666); + CleanupStack::Pop(textCriteria1); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + textCriteria->SetAttributesToSearch(attr); + + err = composite->AddArgument(textCriteria); + if (err != KErrNone) User::Leave(667); + CleanupStack::Pop(textCriteria); + + TInt nr = composite->NumOfArguments(); + + if (self->iTestCase == KTestCaseCompositeSearch2) + { + // Should raise a USER-130 panic + /*CPosLmSearchCriteria& comp3 = */composite->Argument(nr); + } + else + { + // Should raise a USER-130 panic + /*CPosLmSearchCriteria& comp3 = */composite->Argument(nr+1); + } + CleanupStack::PopAndDestroy(search); + } + else if (self->iTestCase == KTestCaseCompositeSearch4) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Panic test 1, invalid position, should raise USER-130 panic, unfortunately raises a compiler warning + // about signed/unsigned + + TInt dummy = -1; + composite->Argument(dummy); + } + else if (self->iTestCase == KTestCaseCompositeSearch5) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Removing invalid position, should raise USER-130 panic, unfortunately raises a compiler warning + // about signed/unsigned + + TInt dummy = -1; + composite->RemoveArgument(dummy); + } + else if (self->iTestCase == KTestCaseCompositeSearch6) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Removing invalid position, should raise USER-130 panic, unfortunately raises a compiler warning + // about signed/unsigned + + TInt dummy = 0; + composite->RemoveArgument(dummy); + } + else if (self->iTestCase == KTestCaseCompositeSearch7) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Removing invalid position, should raise USER-130 panic, unfortunately raises a compiler warning + // about signed/unsigned + + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + composite->AddArgument(textCriteria); + CleanupStack::Pop(textCriteria); + + TInt dummy = 1; + composite->RemoveArgument(dummy); + } + else if (self->iTestCase == KTestCaseCompositeSearch8) + { + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + // Removing invalid position, should raise USER-130 panic, unfortunately raises a compiler warning + // about signed/unsigned + + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + composite->AddArgument(textCriteria); + CleanupStack::Pop(textCriteria); + + TInt dummy = 2; + composite->RemoveArgument(dummy); + } + } + else if (self->iTestCase == KTestCaseDuplicateNotifyDatabaseEvent) + { + self->iExpectedPanicCode = static_cast(2); + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + TRequestStatus status1; + TPosLmEvent event1; + TRequestStatus status2; + TPosLmEvent event2; + lmd->NotifyDatabaseEvent(event1, status1); + // Just in case + User::After(1000000); + // Should raise a EPosEventNotifierAlreadyHasOutstandingRequest Panic + lmd->NotifyDatabaseEvent(event2, status2); + // Just in case + User::After(1000000); + CleanupStack::PopAndDestroy(lmd); + } + else if (self->iExpectedPanicCode == EPosInvalidEnumValue) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + if (self->iTestCase == KTestCaseIncorrectCompositeType1) + { + composite->SetCompositionType((CPosLmCompositeCriteria::TCompositionType)10); + } + else if (self->iTestCase == KTestCaseIncorrectCompositeType2) + { + composite->SetCompositionType((CPosLmCompositeCriteria::TCompositionType)-1); + } + else if (self->iTestCase == KTestCaseIncorrectCompositeType3) + { + CPosLmCompositeCriteria* composite2 = CPosLmCompositeCriteria::NewLC((CPosLmCompositeCriteria::TCompositionType)5); + CleanupStack::PopAndDestroy(composite2); + } + else if (self->iTestCase == KTestCaseIncorrectCompositeType4) + { + CPosLmCompositeCriteria* composite2 = CPosLmCompositeCriteria::NewLC((CPosLmCompositeCriteria::TCompositionType)-5); + CleanupStack::PopAndDestroy(composite2); + } + CleanupStack::PopAndDestroy(composite); + + // Test that using invalid sortpref panics + if (self->iTestCase == KTestCaseCategoryIteratorSortPref) + { + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL((CPosLmCategoryManager::TCategorySortPref)3); + CleanupStack::PushL(catIter); + CleanupStack::PopAndDestroy(catIter); + } + // Test that using invalid sortpref panics + else if (self->iTestCase == KTestCaseReferencedCategoryIteratorSortPref) + { + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CPosLmItemIterator* catIter = categoryManager->ReferencedCategoryIteratorL((CPosLmCategoryManager::TCategorySortPref)4); + CleanupStack::PushL(catIter); + CleanupStack::PopAndDestroy(catIter); + } + //Test that using invalid sortpref panics + else if (self->iTestCase == KTestCaseCategorySearchSortPref) + { + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(landmarkSearch); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + // Use wildcard * as search pattern + nameCriteria->SetSearchPatternL(_L("Pub")); + ExecuteAndDeleteLD(landmarkSearch->StartCategorySearchL(*nameCriteria, (CPosLmCategoryManager::TCategorySortPref)5)); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + } + //Test that it is not possible to create a TPosLmSortPref with invalid value + else if (self->iTestCase == KTestCaseLandmarkSortPref) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, + (TPosLmSortPref::TSortOrder)4321); + } + //Test that it is not possible to set a TPosLmSortPref to invalid values + else if (self->iTestCase == KTestCaseLandmarkSortPref2) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, (TPosLmSortPref::TSortOrder)25); + } + CleanupStack::PopAndDestroy(lmd); + } + else if (self->iExpectedPanicCode == EPosInvalidOperationMode) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(landmarkSearch); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Library*")); + CPosLmOperation* operation = landmarkSearch->StartLandmarkSearchL(*textCriteria); + CleanupStack::PushL(operation); + + if (self->iTestCase == KTestCaseInvalidOperationMode1) + { + // Two subsequent ExecuteL calls should Panic + operation->ExecuteL(); + operation->ExecuteL(); + } + else if (self->iTestCase == KTestCaseInvalidOperationMode2) + { + operation->ExecuteL(); + TRequestStatus status; + TReal32 progress; + operation->NextStep(status, progress); + } + else if (self->iTestCase == KTestCaseInvalidOperationMode3) + { + TRequestStatus status; + TReal32 progress; + operation->NextStep(status, progress); + operation->ExecuteL(); + } + else if (self->iTestCase == KTestCaseInvalidOperationMode4) + { + TRequestStatus status; + TReal32 progress; + operation->NextStep(status, progress); + operation->NextStep(status, progress); + } + CleanupStack::PopAndDestroy(operation); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + CleanupStack::PopAndDestroy(lmd); + } + else if (self->iExpectedPanicCode == EPosLmInvalidArgument) + { + if (self->iTestCase == KTestCaseNegativeMatches) + { + CPosLandmarkSearch* search = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(search); + search->SetMaxNumOfMatches(-10); + CleanupStack::PopAndDestroy(search); + } + else if (self->iTestCase == KTestCaseZeroMatches) + { + CPosLandmarkSearch* search = CPosLandmarkSearch::NewL(*lmd); + CleanupStack::PushL(search); + search->SetMaxNumOfMatches(0); + CleanupStack::PopAndDestroy(search); + } + else if (self->iTestCase == KTestLandmarkSetIconTest1) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + // Panics here + lm->SetIconL(_L("IconFileName"), -2, KPosLmIconMaskNotUsed); + CleanupStack::PopAndDestroy(lm); + } + else if (self->iTestCase == KTestLandmarkSetIconTest2) + { + CPosLandmark* lm = CPosLandmark::NewLC(); + // Panics here + lm->SetIconL(_L("IconFileName"), 1, -2); + CleanupStack::PopAndDestroy(lm); + } + else if (self->iTestCase == KTestCategorySetIconTest1) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("NewCategory1")); + // Panics here + category->SetIconL(_L("IconFileName"), -5, KPosLmIconMaskNotUsed); + CleanupStack::PopAndDestroy(category); + } + else if (self->iTestCase == KTestCategorySetIconTest2) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("NewCategory2")); + // Panics here + category->SetIconL(_L("IconFileName"), 5, -2); + CleanupStack::PopAndDestroy(category); + } + } + + CleanupStack::PopAndDestroy(4,&ids); + } + +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp12::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp12::CreateThreadL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp12::CreateThreadL() + { + _LIT(KThreadName, "TP12testthread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + TBuf<100> buf; + buf.Format(KThreadName, iTreadCounter++); + TInt err=0; + err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + } + +// --------------------------------------------------------- +// CPosTp12::ResourceFilePanicTestLL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp12::ResourceFilePanicTestL() + { + RemoveDefaultDbL(); + CPosLandmarkDatabase* lmd=UseInvalidResourceFileL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(categoryManager); + + RArray ids; + CleanupClosePushL(ids); + + ids.Append(1); + ExecuteAndDeleteLD(categoryManager->RemoveCategoriesL(ids)); + + CleanupStack::PopAndDestroy(3, lmd); + } + +// --------------------------------------------------------- +// CPosTp12::UseInvalidGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +CPosLandmarkDatabase* CPosTp12::UseInvalidResourceFileL() + { + _LIT(KInvalidResourceFile, "c:\\system\\test\\testdata\\EPOSLMASYNCOPS.RSC"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TInt err = fileMan->Rename(KResourceFile, KTempResourceFile, CFileMan::EOverWrite); + if (err != KErrNone && err != KErrNotFound) + { + iLog->Log(_L("Unexpected error when trying to rename EPOSLMASYNCOPS.RSC")); + User::Leave(err); + } + + User::LeaveIfError(fileMan->Copy(KInvalidResourceFile, KResourceFilePath, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp12::RestoreResourceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp12::RestoreResourceFileL() + { + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Delete(KResourceFile)); + + TInt err = fileMan->Rename(KTempResourceFile, KResourceFile, CFileMan::EOverWrite); + if (err != KErrNone && err != KErrNotFound) + { + iLog->Log(_L("Unexpected error when trying to rename TEMP_EPOSLMASYNCOPS.RSC")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(fileMan); + + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp120.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp120.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1225 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp120.h" +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KNrOfDbs = 5; +const TInt KLmPerDb = 20; +const TInt KTotLms = 105; + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp120::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + delete iDbArray; + + delete iLmMultiSearch; + iLmMultiSearch = NULL; + + iAreaSearchResults.ResetAndDestroy(); + + REComSession::FinalClose(); + } + +// --------------------------------------------------------- +// CPosTp120::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::StartL() + { + // Split databases, NrOfDBs db, LmPerDb lm in each, TotLms is last lm id from original db. + // Last param is to enable/disable debug + iDbArray = CreateDatabasesL(KNrOfDbs, KLmPerDb, KTotLms); //, ETrue); + + // Constructing a lm multi search + iLmMultiSearch = CPosLmMultiDbSearch::NewL(*iDbArray); + + AppendAreaSearchResultsL(); + + iLog->Log(_L("Testing search with criterias read from LmDbAreaSearchResult.txt syncronously")); + SearchL(iAreaSearchResults, ESynchronous); + + iLog->Log(_L("Testing search with criterias read from LmDbAreaSearchResult.txt asyncronously")); + SearchL(iAreaSearchResults, EAsynchronous); + + + iLog->Log(_L("Testing search with a defined sortorder")); + SearchWithSortOrderL(iAreaSearchResults); + + iLog->Log(_L("Testing search and cancel")); + SearchAndCancelL(); + + + iLog->Log(_L("Testing maximum number of matches")); + SearchWithMaximumL(); + + iLog->Log(_L("Testing searching on the fly")); + OnTheFlySearchL(); + + iLog->Log(_L("Testing a redefined search after landmarks have been renamed")); + SearchAndRenameL(); + + iLog->Log(_L("Testing a redefined search after a landmark has been removed")); + SearchAndDeleteL(); + + } + +// --------------------------------------------------------- +// CPosTp120::AreaCriteriaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLmAreaCriteria* CPosTp120::AreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong) + { + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(aSouthLat, + aNorthLat, + aWestLong, + aEastLong); + CleanupStack::Pop(); + return areaCriteria; + } + +// --------------------------------------------------------- +// CPosTp120::CheckDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::CheckDatabasesL( + CDesCArray* aExpectedLmUris, + TUint aExpectedMaxMatches) + { + CDesCArray* dbToSearch = iLmMultiSearch->DatabasesToSearchL(); + CleanupStack::PushL(dbToSearch); + + _LIT(KWrongNrDatabases, "Wrong number of databases to search!"); + AssertTrueSecL(aExpectedLmUris != dbToSearch, KWrongNrDatabases); + AssertTrueSecL(aExpectedLmUris->Count() == dbToSearch->Count(), KWrongNrDatabases); + CleanupStack::PopAndDestroy(dbToSearch); + + AssertTrueSecL(aExpectedLmUris->Count() == iLmMultiSearch->NumOfDatabasesToSearch(), + KWrongNrDatabases); + for (TInt i=0; iCount(); i++) + { + AssertTrueSecL(aExpectedLmUris->MdcaPoint(i) == iLmMultiSearch->DatabaseUriPtr(i), + KWrongNrDatabases); + } + + _LIT(KWrongNrMatches, "Wrong number of max matches!"); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == aExpectedMaxMatches, + KWrongNrMatches); + } + +// --------------------------------------------------------- +// CPosTp120::GetLmIdsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::GetLmIdsL( + TInt aDbId, + RArray aSearchResults, + RArray& aLmIdForADb) + { + TInt startId = aDbId * KLmPerDb + 1; + TInt stopId = 0; + + if (aDbId == KNrOfDbs - 1) + { + stopId = KTotLms; + } + else + { + stopId = (aDbId+1) * KLmPerDb; + } + + for (TInt i=0; i= startId && aSearchResults[i] <= stopId) + { + User::LeaveIfError(aLmIdForADb.Append(aSearchResults[i])); + } + } + } + +// --------------------------------------------------------- +// CPosTp120::CheckEqualsLmsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::CheckEqualsLmsL( + TPosLmItemId aSource, + TPosLmItemId aTarget) + { + _LIT(KSortorderErr, "The sortorder is incorrect"); + + if (aSource != aTarget) + { + // Check if same name then don't Leave + CPosLandmark* source = iDatabase->ReadLandmarkLC(aSource); + CPosLandmark* target = iDatabase->ReadLandmarkLC(aTarget); + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + if (EFalse) + { + // For debugging purposes + TBuf<100> buf; + buf.Append(_L("Name:")); + buf.Append(sourceName); + buf.Append(targetName); + iLog->Log(buf); + } + + AssertTrueSecL(!sourceName.CompareC(targetName), KSortorderErr, aSource); + CleanupStack::PopAndDestroy(2, source); // target, source + } + } + +// --------------------------------------------------------- +// CPosTp120::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + TBuf<255> info; + + for(TInt i=0; iSouthLat(), + aSearchResults[i]->NorthLat(), + aSearchResults[i]->WestLong(), + aSearchResults[i]->EastLong())); + CleanupStack::PushL(areaCriteria); + + if (err != aSearchResults[i]->ErrorCode()) + { + iLog->Log(_L("Unexpected error code returned")); + iLog->Log(_L("Area Search result read from file:")); + + aSearchResults[i]->Print(info); + iLog->Log(info); + + _LIT(KReturned, "Search returned errorCode = %d"); + info.Format(KReturned, err); + iLog->Log(info); + User::Leave(KErrGeneral); + } + + if (!err) + { + CPosLmOperation* operation = + iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, aSearchResults[i]->Redefined()); + CleanupStack::PushL(operation); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(operation); + CleanupStack::Pop(operation); + break; + case EAsynchronous: + RunAsyncOperationLD(operation); + CleanupStack::Pop(operation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(operation); + CleanupStack::PopAndDestroy(operation); + break; + } + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + // Check total number of matches + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != + iLmMultiSearch->TotalNumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLmMultiSearch->TotalNumOfMatches()); + iLog->Log(info); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + RArray lmids; + CleanupClosePushL(lmids); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr); + User::LeaveIfError(lmids.Append(id)); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + } + + AssertTrueSecL(aSearchResults[i]->SearchResult().Count() == lmids.Count(), + _L("Expected number of hits and found hits don't match")); + + for (TInt k=0; kFindSearchResult(lmids[k]), KNotFoundErr); + } + + CleanupStack::PopAndDestroy(&lmids); // lmids + } + + CleanupStack::PopAndDestroy(areaCriteria); + + _LIT(KSearchNr, "Multi search test index #%d executed ok."); + TBuf<100> buf; + buf.Format(KSearchNr, i); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp120::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchWithSortOrderL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed syncronously"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + for (TInt j=0; jSouthLat(), + iAreaSearchResults[j]->NorthLat(), + iAreaSearchResults[j]->WestLong(), + iAreaSearchResults[j]->EastLong())); + + CleanupStack::PushL(areaCriteria); + + if (err != KErrNone) + { + CleanupStack::PopAndDestroy(areaCriteria); + continue; + } + + + // 5 and 6 is using WaitForRequest + for (TInt i=0; i<4; i++) + { + switch (i) + { + //**** sync + case 0: + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 1: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 2: + //**** async + RunAsyncOperationLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 3: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + RunAsyncOperationLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + //**** asych with User::WaitForRequest() + case 4: + { + CPosLmOperation* op = iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + case 5: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmOperation* op = iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + } + } + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + // Check total number of matches + if ((TUint)(aSearchResults[j]->SearchResult()).Count() != + iLmMultiSearch->TotalNumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[j]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLmMultiSearch->TotalNumOfMatches()); + iLog->Log(info); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + RArray* searchResults = &aSearchResults[j]->SearchResult(); + for (TInt n=0; nNumOfDatabasesToSearch(); n++) + { + RArray lmids; + CleanupClosePushL(lmids); + GetLmIdsL(n, *searchResults, lmids); + + iDatabase = CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(n)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + LandmarksSortL(lmids, sortPref); + + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(n); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TInt lmid = 0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CheckEqualsLmsL(id, lmids[lmid]); + + id = iter->NextL(); + ++lmid; + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + + CleanupStack::PopAndDestroy(&lmids); + } + + CleanupStack::PopAndDestroy(areaCriteria); + + _LIT(KSearchNr, "Multi search test index #%d executed ok."); + TBuf<100> buf; + buf.Format(KSearchNr, j); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp120::OnTheFlySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::OnTheFlySearchL() + { + const TInt KTestIndex = 4; + + _LIT(KTestNr, "Multi search test, using test index %d."); + TBuf<100> buf; + buf.Format(KTestNr, KTestIndex); + iLog->Log(buf); + + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KTestIndex]->SouthLat(), + iAreaSearchResults[KTestIndex]->NorthLat(), + iAreaSearchResults[KTestIndex]->WestLong(), + iAreaSearchResults[KTestIndex]->EastLong()); + + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + onTheFlyTester->StartSearchCampaignL(iLmMultiSearch, + iAreaSearchResults[KTestIndex]->SearchResult(), + areaCriteria); + + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + iLog->Log(msg); + User::Leave(result); + } + + CleanupStack::PopAndDestroy(2, areaCriteria); + + iLmMultiSearch->UnsetDisplayData(); + } + +// --------------------------------------------------------- +// CPosTp120::SearchAndDeleteL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchAndDeleteL() + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + const TInt KTestIndex = 4; + + _LIT(KTestNr, "Multi search test, using test index %d."); + TBuf<100> buf; + buf.Format(KTestNr, KTestIndex); + iLog->Log(buf); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmAreaCriteria* areaCriteria=CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KTestIndex]->SouthLat(), + iAreaSearchResults[KTestIndex]->NorthLat(), + iAreaSearchResults[KTestIndex]->WestLong(), + iAreaSearchResults[KTestIndex]->EastLong()); + + // Search #1 + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref)); + + RArray* searchResults = &iAreaSearchResults[KTestIndex]->SearchResult(); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint)searchResults->Count() == iLmMultiSearch->TotalNumOfMatches(), + KNumOfMatchesErr); + + TPosLmItemId lmid = (*searchResults)[0]; + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iDatabase->RemoveLandmarkL(lmid); + searchResults->Remove(0); + searchResults->Compress(); + delete iDatabase; + iDatabase = NULL; + + // Search #2 + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref, ETrue)); + + // Check result + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint)searchResults->Count() == iLmMultiSearch->TotalNumOfMatches(), + KNumOfMatchesErr); + + RArray lmids; + CleanupClosePushL(lmids); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(iAreaSearchResults[KTestIndex]->FindSearchResult(id), KNotFoundErr); + User::LeaveIfError(lmids.Append(id)); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + } + + AssertTrueSecL(iAreaSearchResults[KTestIndex]->SearchResult().Count() == lmids.Count(), + _L("Expected number of hits and found hits don't match")); + + for (TInt k=0; kFindSearchResult(lmids[k]), KNotFoundErr); + } + + CleanupStack::PopAndDestroy(&lmids); // lmids + + CleanupStack::PopAndDestroy(areaCriteria); + + // Prepare for another search with different criteria + TInt otherTestIndex = KTestIndex + 1; + + buf.Format(KTestNr, otherTestIndex); + iLog->Log(buf); + + areaCriteria = CPosLmAreaCriteria::NewLC( + iAreaSearchResults[otherTestIndex]->SouthLat(), + iAreaSearchResults[otherTestIndex]->NorthLat(), + iAreaSearchResults[otherTestIndex]->WestLong(), + iAreaSearchResults[otherTestIndex]->EastLong()); + + // Search #3 + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref, ETrue)); + + // Check result + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL(iLmMultiSearch->TotalNumOfMatches() != searchResults->Count(), + KNumOfMatchesErr); + + AssertTrueSecL(iLmMultiSearch->TotalNumOfMatches() == 0, KNumOfMatchesErr); + + CleanupStack::PopAndDestroy(areaCriteria); + } + +// --------------------------------------------------------- +// CPosTp120::SearchAndRenameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchAndRenameL() + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + const TInt KTestIndex = 4; + + _LIT(KTestNr, "Multi search test, using test index %d."); + TBuf<100> buf; + buf.Format(KTestNr, KTestIndex); + iLog->Log(buf); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KTestIndex]->SouthLat(), + iAreaSearchResults[KTestIndex]->NorthLat(), + iAreaSearchResults[KTestIndex]->WestLong(), + iAreaSearchResults[KTestIndex]->EastLong()); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref)); + + RArray* searchResults = &iAreaSearchResults[KTestIndex]->SearchResult(); + + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + _LIT(KLmName, "LmTP120"); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + iDatabase = + CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(j)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(iAreaSearchResults[KTestIndex]->FindSearchResult(id), + KNotFoundErr); + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + + TBuf<30> lmName; + lmName = KLmName; + lm->SetLandmarkNameL(lmName); + iDatabase->UpdateLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + } + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref, ETrue)); + + // Check database array + CheckDatabasesL(iDbArray); + + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + + AssertTrueSecL((TUint) searchResults->Count() == + iLmMultiSearch->TotalNumOfMatches(), KNumOfMatchesErr); + + for (TInt j=0; jNumOfDatabasesToSearch(); j++) + { + iDatabase = + CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(j)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(j); + + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Check that found id is expected + AssertTrueSecL(iAreaSearchResults[KTestIndex]->FindSearchResult(id), + KNotFoundErr); + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + + TPtrC16 lmName; + lm->GetLandmarkName(lmName); + AssertTrueSecL(!lmName.CompareC(KLmName), _L("Wrong landmark name")); + + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + } + + CleanupStack::PopAndDestroy(areaCriteria); + } + +// --------------------------------------------------------- +// CPosTp120::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchAndCancelL(const TBool& aInCallback) + { + // Test search with one criteria + const TInt KTestIndex = 0; + + _LIT(KTestNr, "Multi search test, using test index %d."); + TBuf<100> buf; + buf.Format(KTestNr, KTestIndex); + iLog->Log(buf); + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KTestIndex]->SouthLat(), + iAreaSearchResults[KTestIndex]->NorthLat(), + iAreaSearchResults[KTestIndex]->WestLong(), + iAreaSearchResults[KTestIndex]->EastLong()); + + if (aInCallback) + { + TReal threshold = 3; + for (TReal i=0; i<100; i+=10) + { + threshold = i/100; + RunAsyncOperationAndCancelInCallbackLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, iAreaSearchResults[KTestIndex]->Redefined()), threshold); + + _LIT(KCancelNr, "Multi search test, cancel after progress %f, canceled ok."); + TBuf<100> buf; + buf.Format(KCancelNr, threshold); + iLog->Log(buf); + } + } + else + { + RunAsyncOperationAndCancelLD(iLmMultiSearch->StartLandmarkSearchL( + *areaCriteria, iAreaSearchResults[KTestIndex]->Redefined())); + } + + CleanupStack::PopAndDestroy(areaCriteria); + } + +// --------------------------------------------------------- +// CPosTp120::SearchWithMaximumL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp120::SearchWithMaximumL() + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchWithMaximumL is performed"); + + // Test search with one criteria + const TInt KTestIndex = 8; + + _LIT(KTestNr, "Multi search test, using test index %d."); + TBuf<100> buf; + buf.Format(KTestNr, KTestIndex); + iLog->Log(buf); + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KTestIndex]->SouthLat(), + iAreaSearchResults[KTestIndex]->NorthLat(), + iAreaSearchResults[KTestIndex]->WestLong(), + iAreaSearchResults[KTestIndex]->EastLong()); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + + // First get the maximum number of matches + TInt maxMatches = KNrOfDbs; + iLmMultiSearch->SetMaxNumOfMatches(maxMatches); + _LIT(KErrNrOfMatches, "Number of matches is incorrect"); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria, sortPref)); + + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + RArray* searchResults = &iAreaSearchResults[KTestIndex]->SearchResult(); + TInt totalMatches = iLmMultiSearch->TotalNumOfMatches(); + + // Check database array + CheckDatabasesL(iDbArray, maxMatches); + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + // Check that nr is not expected number of results + AssertTrueSecL((TUint) searchResults->Count() != + totalMatches, KNumOfMatchesErr); + + for (TInt n=0; nNumOfDatabasesToSearch(); n++) + { + RArray lmids; + CleanupClosePushL(lmids); + GetLmIdsL(n, *searchResults, lmids); + + iDatabase = CPosLandmarkDatabase::OpenL(iLmMultiSearch->DatabaseUriPtr(n)); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + LandmarksSortL(lmids, sortPref); + + CPosLmItemIterator* iter = iLmMultiSearch->MatchIteratorL(n); + // Check if there are any matches = iteration exists. + if (iter) + { + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == iLmMultiSearch->NumOfMatches(n), + KNumOfMatchesErr); + + TInt lmid = 0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CheckEqualsLmsL(id, lmids[lmid]); + + id = iter->NextL(); + ++lmid; + } + CleanupStack::PopAndDestroy(iter); + } + else + { + _LIT(KIterNull, "MatchIterator returned null for a db"); + iLog->Log(KIterNull); + } + + delete iDatabase; + iDatabase = NULL; + + CleanupStack::PopAndDestroy(&lmids); + } + + // Test max matches again + TInt incMatches = 2; + maxMatches = maxMatches + incMatches; + iLmMultiSearch->SetMaxNumOfMatches(maxMatches); + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + + ExecuteAndDeleteLD(iLmMultiSearch->StartLandmarkSearchL(*areaCriteria)); + + AssertTrueSecL(iLmMultiSearch->MaxNumOfMatches() == maxMatches, KErrNrOfMatches); + TInt reTotalMatches = iLmMultiSearch->TotalNumOfMatches(); + + AssertTrueSecL(reTotalMatches != totalMatches, + _L("Total number of matches should not be that same.")); + + // Check database array + CheckDatabasesL(iDbArray, maxMatches); + // Check for errors + AssertTrueSecL(iLmMultiSearch->NumOfSearchErrors() == 0, + _L("Error(s) found during multi search.")); + // Check that nr is not expected number of results + AssertTrueSecL((TUint) searchResults->Count() != + reTotalMatches, KNumOfMatchesErr); + + CleanupStack::PopAndDestroy(areaCriteria); + + // Unset max number of matches to normal/unlimited again + iLmMultiSearch->SetMaxNumOfMatches(); + } + +// --------------------------------------------------------- +// CPosTp120::CreateDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CDesCArray* CPosTp120::CreateDatabasesL(TInt aNrOfLmDbs, TInt aLmPerDb, + TInt aLastId, TBool aDebug) + { + + CDesCArray* iDbArray = new (ELeave) CDesCArrayFlat(aNrOfLmDbs); + CleanupStack::PushL(iDbArray); + + RemoveDefaultDbL(); + + // Populate default db + iDatabase = UseGeneratedDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + delete iDatabase; + iDatabase = NULL; + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + // Create databases + TInt i=0; + for (i=1; i < aNrOfLmDbs; i++) + { + TBuf<100> db; + db.Format(KDbNamePath, i * aLmPerDb); + + iFileSession.Delete(db); + User::LeaveIfError(fileMan->Copy(KLmFullDefaultDbPath, db, CFileMan::EOverWrite)); + } + CleanupStack::PopAndDestroy(fileMan); + + for (TInt db=0; db < aNrOfLmDbs; db++) + { + TInt dbform = db; + if (db == aNrOfLmDbs) + { + dbform = aNrOfLmDbs - 1; + } + + CPosLandmarkDatabase* lmd = NULL; + TBuf<100> name; + if (db == 0) + { + _LIT(KDefLmDb, "eposlm.ldb"); + name = KDefLmDb; + lmd = CPosLandmarkDatabase::OpenL(); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + else + { + name.Format(KDbName, dbform * aLmPerDb); + lmd = CPosLandmarkDatabase::OpenL(name); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + CleanupStack::PushL(lmd); + // Append db name to array + iDbArray->AppendL(name); + + if (aDebug) + { + iLog->Log(name); + } + + TInt startItemid = dbform * aLmPerDb + 1; + TInt stopItemid = dbform * aLmPerDb + aLmPerDb; + if (dbform == aNrOfLmDbs - 1) + { + stopItemid = aLastId; + } + + for (TInt lmid=1; lmid <= aLastId; lmid++) + { + TBuf<100> lmidbuf; + + if (aDebug) + { + _LIT(KLmId, "Landmark with LmId: %d"); + lmidbuf.Format(KLmId, lmid); + iLog->Log(lmidbuf); + } + + if (lmid < startItemid || lmid > stopItemid) + { + if (aDebug) + { + _LIT(KDelLmId, "Removing LmId: %d"); + lmidbuf.Format(KDelLmId, lmid); + iLog->Log(lmidbuf); + } + + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, lmd->RemoveLandmarkL(lmid)); + } + } + } + + // Compact database + ExecuteAndDeleteLD(lmd->CompactL()); + CleanupStack::PopAndDestroy(lmd); + } + + // Log/print landmark databases. + if (aDebug) + { + // DEBUG + for (i=0; i < aNrOfLmDbs; i++) + { + TBuf<100> dbNo; + dbNo.Format(_L(" -------- Printing Db %d --------------"), i); + iLog->Log(dbNo); + + CPosLandmarkDatabase* lmd = NULL; + if (i == 0) + { + _LIT(KDbDefName, "Default Lm DB"); + iLog->Log(KDbDefName); + lmd = CPosLandmarkDatabase::OpenL(); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + else + { + TInt dbform = i; + if (i == 5) + { + dbform = 4; + } + + TBuf<100> db; + db.Format(KDbName, dbform * aLmPerDb); + iLog->Log(db); + + lmd = CPosLandmarkDatabase::OpenL(db); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + } + CleanupStack::PushL(lmd); + CPosLmCategoryManager* lmcat = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(lmcat); + + CPosLmItemIterator* iter = lmd->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + _LIT(KNrLms, "Nr of Lms: %d"); + TBuf<20> lms; + lms.Format(KNrLms, iter->NumOfItemsL()); + iLog->Log(lms); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = lmd->ReadLandmarkLC(id); + + TBuf<255> info; + PrintLandmark(*lm, info); + iLog->Log(info); + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(iter); + + CPosLmItemIterator* catiter = lmcat->CategoryIteratorL(); + CleanupStack::PushL(catiter); + + _LIT(KNrLmCats, "Nr of Lm Cats: %d"); + TBuf<20> lmcats; + lmcats.Format(KNrLmCats, catiter->NumOfItemsL()); + iLog->Log(lmcats); + + id = catiter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmarkCategory* cat = lmcat->ReadCategoryLC(id); + + TBuf<255> info; + // PrintLandmark(*lm, info); + _LIT(KCatId, "Category id: %d"); + _LIT(KCatGlobalId, "Global Category id: %d"); + _LIT(KCatName, "Category name: %S"); + + info.Format(KCatId, cat->CategoryId()); + iLog->Log(info); + + info.Format(KCatGlobalId, cat->GlobalCategory()); + iLog->Log(info); + + TPtrC catname; + TInt err = cat->GetCategoryName(catname); + info.Format(KCatName, &catname); + iLog->Log(info); + + CleanupStack::PopAndDestroy(cat); + + id = catiter->NextL(); + } + + + CleanupStack::PopAndDestroy(3, lmd); // catiter, lmcat + } + } + + CleanupStack::Pop(iDbArray); + return iDbArray; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp121.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp121.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1272 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include +#include +#include "FT_CPosTp121.h" +#include "FT_LandmarkConstants.h" +#include "FT_CCategoryLandmarkSearchResult.h" + +// CONSTANTS +// Used when searching for global categories (Global categories are dynamically appended in the test. +// There are originally 26 local categories in the databases) +//const TPosLmItemId KRestaurant = 27; +const TPosLmItemId KBar = 28; +//const TPosLmItemId KGas_Station = 29; +const TPosLmItemId KHotel = 30; +//const TPosLmItemId KShop = 31; +const TPosLmItemId KSports_Ground = 33; +const TPosLmItemId KGarage = 34; +const TPosLmItemId KBus_Stop = 36; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp121::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::CloseTest() + { + delete iDatabases; + delete iMultiDbSearch; + iCategoryLandmarkSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp121::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::InitTestL() + { + CLandmarkTestProcedureBase::InitTestL(); + + // PrepareDatabases + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + iNrOfDatabases = 5; + + iLog->Log(_L("Test Dbs Copied")); + + // Initialize data members + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDatabases->Sort(); + AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); + iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + CleanupStack::PopAndDestroy(dbManager); + + iLog->Log(_L("Members ready")); + + TInt err = KErrNone; + CPosLandmarkDatabase* database = NULL; + // Reset Global categories for all databases but EPOSLM_105.LDB and add the global category + // "Hotel" to the 5 first landmarks in the databases. + for (TInt i = 0; i < iNrOfDatabases - 1; i++) // Do not use global categories in the last db + { + database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); + CleanupStack::PushL(database); + if ( database->IsInitializingNeeded() ) + { + TRAP( err, ExecuteAndDeleteLD( database->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catMan); + TRAP( err, ExecuteAndDeleteLD( catMan->ResetGlobalCategoriesL() ) ); + AssertTrueSecL( err == KErrNone, _L("Reset cats failed")); + CleanupStack::PopAndDestroy(2, database); + } + + iLog->Log(_L("Cats reset")); + + // Initiallize iCategoryLandmarkSearchResults + AppendCategoryLandmarkSearchResultsL(); + + iLog->Log(_L("AppendCategoryLandmarkSearchResultsL done")); + } + +// --------------------------------------------------------- +// CPosTp121::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::StartL() + { +// 1. Search in various ways + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt synchronously, using CategoryName. Sort order: ascending")); + TestSearchL(iCategoryLandmarkSearchResults, ESynchronous, ESortAscending); + + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt synchronously, using CategoryName. Sort order: descending")); + TestSearchL(iCategoryLandmarkSearchResults, ESynchronous, ESortDescending); + + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt synchronously, using CategoryName. Sort order: none")); + TestSearchL(iCategoryLandmarkSearchResults, ESynchronous, ESortNone); + + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt asynchronously, using CategoryName. Sort order: ascending")); + TestSearchL(iCategoryLandmarkSearchResults, EAsynchronous, ESortAscending); + + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt asynchronously, using CategoryName. Sort order: descending")); + TestSearchL(iCategoryLandmarkSearchResults, EAsynchronous, ESortDescending); + + iLog->Log(_L("Testing search with criteria read from LmDbSearchResult.txt asynchronously, using CategoryName. Sort order: none")); + TestSearchL(iCategoryLandmarkSearchResults, EAsynchronous, ESortNone); + +// 2. Search non-existing category + iLog->Log(_L("Searching fon nonexisting entries synchronously")); + SearchNonExistingL(ESynchronous); + + iLog->Log(_L("Searching for nonexisting entries asynchronously")); + SearchNonExistingL(EAsynchronous); + +// 3. Test maximum number of matches + iLog->Log(_L("Searching with maximum number of results synchronously")); + TestMaximumNrOfMatchesL(iCategoryLandmarkSearchResults, ESynchronous); + + iLog->Log(_L("Searching with maximum number of results asynchronously")); + TestMaximumNrOfMatchesL(iCategoryLandmarkSearchResults, EAsynchronous); + +// 4. Test cancel + iLog->Log(_L("Search and cancel the search")); + SearchAndCancelL(); + +// 5. Search in global categories + // Add some more landmarks associated with global categories + AddLandmarksToGlobalCategoriesL(); + + iLog->Log(_L("SearchForLandmarksInGlobalCategoriesL asynchronously")); + SearchForLandmarksInGlobalCategoriesL(EAsynchronous); + + iLog->Log(_L("SearchForLandmarksInGlobalCategoriesL synchronously")); + SearchForLandmarksInGlobalCategoriesL(ESynchronous); + +// 6. Test some leave codes + iLog->Log(_L("Check that StartLandmarkSearchL leaves with correct codes")); + TestLeaveCodesL(); + +// 7. Test automatically reset of search attributes + iLog->Log(_L("Check that CPosLmCategoryCriteria resets other criteria when setting a new one")); + TestResetSearchAttributesL(); + +// 8. Test searching by name is case insensitive + iLog->Log(_L("Testing case insensitive")); + TestCaseInsensitiveL(); + +// 9. Test search for categories containing wildcards + iLog->Log(_L("Testing wild cards")); + TestWildCardsL(); + +// 10. Test various combinations of refined search + // Modify database2 + iLog->Log(_L("Testing refined search")); + RIdArray idArray; + CleanupClosePushL(idArray); + idArray.Append(51); + idArray.Append(52); + idArray.Append(53); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[2]); + CleanupStack::PushL(db); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(14, idArray)); // 14 = TietoEnator kontor + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(17, idArray)); // 17 = BurgerKing + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(catMan->GetGlobalCategoryL(15000), idArray)); // 15000 = Entertainment + CleanupStack::PopAndDestroy(3, &idArray); + + TestRefinedSearchL(ESynchronous); + TestRefinedSearchL(EAsynchronous); + +// 11. Test modify list of databases + iLog->Log(_L("Testing modifying list of databases")); + RIdArray expectedMatches; + CleanupClosePushL(expectedMatches); + expectedMatches.AppendL(iGasStationId1); + expectedMatches.AppendL(iGasStationId2); + expectedMatches.AppendL(51); + expectedMatches.AppendL(52); + expectedMatches.AppendL(53); + + TestDatabaseListL(expectedMatches); + +// 12. Test on-the-fly + iLog->Log(_L("Testing searching on the fly")); + TestOnTheFlySearchL(expectedMatches); + + CleanupStack::PopAndDestroy(&expectedMatches); + } + +// --------------------------------------------------------- +// CPosTp121::TestSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestSearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode, + TTp121SortOrder aSortOrder) + { + // Test SetMaxNumOfMatches, first set to one and then back to unlimited + iMultiDbSearch->SetMaxNumOfMatches(1); + iMultiDbSearch->SetMaxNumOfMatches(); + + for(TInt i = 0; i < aSearchResults.Count(); i++) + { + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Perform search by name + catSearchCriteria->SetCategoryNameL(aSearchResults[i]->CategoryName()); + iLog->Log(aSearchResults[i]->CategoryName()); + + SearchL(catSearchCriteria, aExecutionMode, aSearchResults[i]->Redefined(), aSortOrder); + + if (i != 28) + { + // Row 28 in xls-file contains an error. If fixed, TP21 starts to fail. + ValidateSearchResultsL(aSearchResults[i], iMultiDbSearch, aSortOrder); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + (TUint)(aSearchResults[i]->SearchResult()).Count(), + catSearchCriteria->CategoryName()); + } + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + } + +// --------------------------------------------------------- +// CPosTp121::SearchForLandmarksInGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::SearchForLandmarksInGlobalCategoriesL( + TExecutionMode aExecutionMode) + { + iLog->Log(_L("SearchForGlobalCategoriesL")); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + RIdArray expectedIds; + CleanupClosePushL(expectedIds); + + // Search for "Accommodation", should result in two matches + catSearchCriteria->SetGlobalCategory( KAccommodation ); + SearchL(catSearchCriteria, aExecutionMode); + expectedIds.AppendL(iRestaurantId1); + expectedIds.AppendL(iRestaurantId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + // Search for "Entertainment" id using the global category id should result in two matches + + catSearchCriteria->SetGlobalCategory(KBusiness); + SearchL(catSearchCriteria, aExecutionMode); + expectedIds.AppendL(iGasStationId1); + expectedIds.AppendL(iGasStationId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + // Search for "Accommodation" in the result from previous search + catSearchCriteria->SetGlobalCategory(KAccommodation); + SearchL(catSearchCriteria, aExecutionMode, ETrue); + expectedIds.AppendL(iGasStationId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + // Search for a non existing global category in the result from previous search + // Nothing should be found + catSearchCriteria->SetCategoryNameL(_L("NonExistingGLobalCategory")); + SearchL(catSearchCriteria, aExecutionMode, ETrue); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + // Search for "Accommodation" using the globalcategory id + catSearchCriteria->SetGlobalCategory(3000); + SearchL(catSearchCriteria, aExecutionMode); + expectedIds.AppendL(iRestaurantId1); + expectedIds.AppendL(iRestaurantId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + // Search for "Entertainment" using the globalcategory id from the result + // from previous search + catSearchCriteria->SetGlobalCategory(15000); + SearchL(catSearchCriteria, aExecutionMode, ETrue); + expectedIds.AppendL(iGasStationId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + expectedIds.Reset(); + + + CleanupStack::PopAndDestroy(2, catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp121::AddLandmarksToGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::AddLandmarksToGlobalCategoriesL() + { + iLog->Log(_L("AddLandmarksToGlobalCategoriesL")); + + // Add some new landmarks to the dbs, associate some with global categories + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[0]); + CleanupStack::PushL(db); + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("LandmarkName1")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription")); + + /*************************************************************/ + // Search for id maintained by database for the global category + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL( *db ); + CleanupStack::PushL(catMan); + TPosLmItemId globCatId1 = catMan->GetGlobalCategoryL( KAccommodation ); + TPosLmItemId globCatId2 = catMan->GetGlobalCategoryL( KEntertainment ); + + CPosLandmarkCategory* cat = catMan->ReadCategoryLC( globCatId1 ); + + CleanupStack::PopAndDestroy( 2 ); + /*************************************************************/ + lm->AddCategoryL( globCatId1 ); + TPosLmItemId id = db->AddLandmarkL(*lm); + iRestaurantId1 = id; + + CleanupStack::PopAndDestroy(2, db); + + db = CPosLandmarkDatabase::OpenL((*iDatabases)[1]); + CleanupStack::PushL(db); + lm = CPosLandmark::NewLC(); + db->AddLandmarkL(*lm); // Add one uncategorized to increase id in order to avoid equal ids between dbs. + lm->SetLandmarkNameL(_L("LandmarkName2")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription2")); + lm->AddCategoryL(KBus_Stop); + id = db->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(2, db); + + db = CPosLandmarkDatabase::OpenL((*iDatabases)[2]); + CleanupStack::PushL(db); + lm = CPosLandmark::NewLC(); + db->AddLandmarkL(*lm); // Add two uncategorized to increase id in order to avoid equal ids between dbs. + db->AddLandmarkL(*lm); + lm->SetLandmarkNameL(_L("LandmarkName3")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription3")); + lm->AddCategoryL( globCatId2 ); + lm->AddCategoryL(KHotel); + //lm->AddCategoryL(KShop); + lm->AddCategoryL(KBar); + lm->AddCategoryL(KSports_Ground); + lm->AddCategoryL(KGarage); + id = db->AddLandmarkL(*lm); + iGarageId1 = id; + iGasStationId1 = id; + CleanupStack::PopAndDestroy(2, db); + + db = CPosLandmarkDatabase::OpenL((*iDatabases)[3]); + CleanupStack::PushL(db); + lm = CPosLandmark::NewLC(); + db->AddLandmarkL(*lm); // Add three uncategorized to increase id in order to avoid equal ids between dbs. + db->AddLandmarkL(*lm); + db->AddLandmarkL(*lm); + lm->SetLandmarkNameL(_L("LandmarkName4")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription4")); + lm->AddCategoryL(KBar); + lm->AddCategoryL( globCatId1 ); + lm->AddCategoryL( globCatId2 ); + lm->AddCategoryL(KHotel); + // lm->AddCategoryL(KShop); + lm->AddCategoryL(KBar); + lm->AddCategoryL(1); + lm->AddCategoryL(2); + lm->AddCategoryL(3); + id = db->AddLandmarkL(*lm); + iRestaurantId2 = id; + iGasStationId2 = id; + CleanupStack::PopAndDestroy(lm); + + lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("LandmarkName5")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription5")); + lm->AddCategoryL(KBus_Stop); + db->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(2, db); + + } + +// --------------------------------------------------------- +// CPosTp121::SearchNonExistingL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::SearchNonExistingL(TExecutionMode aExecutionMode) + { + iLog->Log(_L("SearchNonExistingL")); + + _LIT(KCategoryName, "NonExistingLandmark"); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetCategoryNameL(KCategoryName); + + SearchL(catSearchCriteria, aExecutionMode); + ValidateTotalNrOfMatchesL(iMultiDbSearch->TotalNumOfMatches(), 0, KCategoryName); + ValidateSearchResultsL(NULL, iMultiDbSearch); + CleanupStack::PopAndDestroy(catSearchCriteria); + + catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + TPosLmGlobalCategory nonExistingId = 56789; + catSearchCriteria->SetGlobalCategory(nonExistingId); + + SearchL(catSearchCriteria, aExecutionMode); + ValidateTotalNrOfMatchesL(iMultiDbSearch->TotalNumOfMatches(), 0, KCategoryName); + ValidateSearchResultsL(NULL, iMultiDbSearch); + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp121::TestMaximumNrOfMatchesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestMaximumNrOfMatchesL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + TInt idFromXls = 25; // Use 25 "Läkarna" + catSearchCriteria->SetCategoryNameL(aSearchResults[idFromXls]->CategoryName()); + iLog->Log(aSearchResults[idFromXls]->CategoryName()); + + SearchL(catSearchCriteria, aExecutionMode, aSearchResults[idFromXls]->Redefined()); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + (TUint)(aSearchResults[idFromXls]->SearchResult()).Count(), + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Set maximum number, first set to more than should be found here 13 in each db must be enough + iLog->Log(_L("Set to 13 * iNrOfDatabases = 65 matches")); + TUint maxMatches = 13; + iMultiDbSearch->SetMaxNumOfMatches(13); + + SearchL(catSearchCriteria, aExecutionMode, ETrue); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + (TUint)(aSearchResults[idFromXls]->SearchResult()).Count(), + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Set maximum number here to 3 in each db + iLog->Log(_L("Set to 3 * iNrOfDatabases = 10 matches")); + maxMatches = 3; + const TInt KNrOfDbsWithMatches = 3; + iMultiDbSearch->SetMaxNumOfMatches(maxMatches); + + SearchL(catSearchCriteria, aExecutionMode, ETrue); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + maxMatches * KNrOfDbsWithMatches, // only three of the databases contain matches + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Set maximum number here to 1 in each db + maxMatches = 1; + iLog->Log(_L("Set to 1 * iNrOfDatabases = 5 matches")); + iMultiDbSearch->SetMaxNumOfMatches(maxMatches); + SearchL(catSearchCriteria, aExecutionMode, ETrue); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + maxMatches * KNrOfDbsWithMatches, + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Set maximum number here to 2 in each db, however since search is refined only 3 matches should be returned + maxMatches = 2; + iLog->Log(_L("Set to 2 * iNrOfDatabases = 10 matches")); + iMultiDbSearch->SetMaxNumOfMatches(maxMatches); + SearchL(catSearchCriteria, aExecutionMode, ETrue); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + 1 * KNrOfDbsWithMatches, + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Same as above but no refined search is made. Should get 2 * 3 matches + iLog->Log(_L("Set to 2 * iNrOfDatabases = 10 matches")); + iMultiDbSearch->SetMaxNumOfMatches(maxMatches); + SearchL(catSearchCriteria, aExecutionMode); + ValidateTotalNrOfMatchesL( + iMultiDbSearch->TotalNumOfMatches(), + maxMatches * KNrOfDbsWithMatches, + aSearchResults[idFromXls]->CategoryName()); + ValidateSearchResultsL(aSearchResults[idFromXls], iMultiDbSearch); + + // Set back to unlimited + iMultiDbSearch->SetMaxNumOfMatches(); + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp121::TestLeaveCodesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestLeaveCodesL() + { + iLog->Log(_L("TestLeaveCodesL")); + + TPosLmSortPref sortPref(CPosLandmark::ECategoryInfo, TPosLmSortPref::EAscending); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Only ECategoryName is supported,all other leave with KErrNotSupported + TRAPD(err, iMultiDbSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref)); + AssertTrueSecL(err == KErrNotSupported, _L("Should have left with KErrNotSupported")); + + // Only ECategoryName is supported,all other leave with KErrNotSupported + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EDescription, TPosLmSortPref::EDescending); + TRAP(err, iMultiDbSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref)); + AssertTrueSecL(err == KErrNotSupported, _L("Should have left with KErrNotSupported")); + + // Test search by local category id + catSearchCriteria->SetCategoryItemId(7); + TRAP(err, iMultiDbSearch->StartLandmarkSearchL(*catSearchCriteria)); + AssertTrueSecL(err == KErrArgument, _L("Should have left with KErrArgument")); + + // Test search by too long category name > 124 = KPosLmMaxCategoryNameLength + TBuf name = _L("12345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678"); + TRAP(err, catSearchCriteria->SetCategoryNameL(name)); + AssertTrueSecL(err == KErrArgument, _L("Should have left with KErrArgument")); + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp121::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::SearchAndCancelL() + { + // Test search with one criteria + const TInt KIndex=0; + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetCategoryNameL(iCategoryLandmarkSearchResults[KIndex]->CategoryName()); + + TReal32 progress(0); + while (progress < 1.0) + { + RunAsyncOperationAndCancelInCallbackLD( + iMultiDbSearch->StartLandmarkSearchL( + *catSearchCriteria, + iCategoryLandmarkSearchResults[KIndex]->Redefined()), + progress); + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + nrOfMatches += iter->NumOfItemsL(); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators when cancelling")); + + progress = progress + 0.09; + } + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + + +// --------------------------------------------------------- +// CPosTp121::ValidateIdL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::ValidateIdL(TPosLmItemId aId, TInt aDbIndex) + { + TBool condition = EFalse; + switch (aDbIndex) + { + case 0: + // Db 0 contains landmarks with id = 1-20 + condition = aId >= 1 && aId <= 20; + break; + case 1: + // Db 1 contains landmarks with id = 21-40 + condition = aId >= 21 && aId <= 40; + break; + case 2: + // Db 2 contains landmarks with id = 41-60 + condition = aId >= 41 && aId <= 60; + break; + case 3: + // Db 3 contains landmarks with id = 61-80 + condition = aId >= 61 && aId <= 80; + break; + case 4: + // Db 4 contains landmarks with id = 81-105 + condition = aId >= 81 && aId <= 105; + break; + } + + AssertTrueSecL(condition, _L("Invalid match from database reported")); + } + +// --------------------------------------------------------- +// CPosTp121::ValidateTotalNrOfMatchesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::ValidateTotalNrOfMatchesL( + TUint aRetrievedNrOfMatches, + TUint aExpectedNrOfMatches, + const TDesC& aCategoryName) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + + if (aRetrievedNrOfMatches != aExpectedNrOfMatches) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, aExpectedNrOfMatches); + iLog->Log(info); + info.Format(KReturned, aRetrievedNrOfMatches); + iLog->Log(info); + _LIT(KFormat, "Search criteria: %S"); + info.Format(KFormat, &aCategoryName); + iLog->Log(info); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp121::ValidateSearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::ValidateSearchResultsL( + CCategoryLandmarkSearchResult* aExpectedSearchResult, + CPosLmMultiDbSearch* aMultiDbSearcher, + TTp121SortOrder aSortOrder) + { + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[j]); + CleanupStack::PushL(db); + CPosLmItemIterator* iter = aMultiDbSearcher->MatchIteratorL(j); + CleanupStack::PushL(iter); + + nrOfMatches += iter->NumOfItemsL(); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + ValidateIdL(id, j); + AssertTrueSecL(aExpectedSearchResult->FindSearchResult(id), KNotFoundErr, id); + CPosLandmark* lm1 = db->ReadLandmarkLC(id); + id = iter->NextL(); + if (aSortOrder != ESortNone && id != KPosLmNullItemId) + { + CPosLandmark* lm2 = db->ReadLandmarkLC(id); + TPtrC name1, name2; + lm1->GetLandmarkName(name1); + lm2->GetLandmarkName(name2); + if (aSortOrder == ESortAscending) + { + AssertTrueSecL(name1.CompareC(name2) <= 0, _L("Not sorted ascending as expected")); + } + else // aSortOrder == ESortDescending + { + AssertTrueSecL(name1.CompareC(name2) >= 0, _L("Not sorted descending as expected")); + } + CleanupStack::PopAndDestroy(lm2); + } + CleanupStack::PopAndDestroy(lm1); + } + CleanupStack::PopAndDestroy(2, db); + } + AssertTrueSecL(nrOfMatches == aMultiDbSearcher->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators")); + AssertTrueSecL(NrOfSearchErrors(aMultiDbSearcher) == 0, _L("Found search errors!")); + } + +// --------------------------------------------------------- +// CPosTp121::ValidateSearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::ValidateSearchResultsL( + const RIdArray& aExpectedIds, + CPosLmMultiDbSearch* aMultiDbSearcher, + TInt aNrOfExpectedErrors) + { + _LIT(KNotFoundErr, "Id %d not found in expected Lm search results"); + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLmItemIterator* iter = aMultiDbSearcher->MatchIteratorL(j); + CleanupStack::PushL(iter); + nrOfMatches += iter->NumOfItemsL(); + + TUint nrOfSearchMatches = aMultiDbSearcher->NumOfMatches( j ); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(aExpectedIds.Find(id) != KErrNotFound, KNotFoundErr, id); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(nrOfMatches == aMultiDbSearcher->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators")); + AssertTrueSecL(nrOfMatches == aExpectedIds.Count(), _L("Total nr of matches doesn't match expected")); + AssertTrueSecL(NrOfSearchErrors(aMultiDbSearcher) == aNrOfExpectedErrors, _L("Found search errors!")); + } + +// --------------------------------------------------------- +// CPosTp121::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::SearchL( + CPosLmCategoryCriteria* aCatSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch, + TTp121SortOrder aSortOrder) + { + TPosLmSortPref ascending(CPosLandmark::ELandmarkName); + TPosLmSortPref descending(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + + switch (aSortOrder) + { + case ESortNone: + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCatSearchCriteria, aRefinedSearch); + break; + case ESortAscending: + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCatSearchCriteria, ascending, aRefinedSearch); + break; + case ESortDescending: + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCatSearchCriteria, descending, aRefinedSearch); + break; + default: + User::Leave(KErrArgument); + break; + } + + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + default: + User::Leave(KErrArgument); + break; + } + } + +// --------------------------------------------------------- +// CPosTp121::TestResetSearchAttributesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestResetSearchAttributesL() + { + CPosLmCategoryCriteria* crit = CPosLmCategoryCriteria::NewLC(); + + // Verify default values + TPosLmItemId id = crit->CategoryItemId(); + AssertTrueSecL(id == KPosLmNullItemId, _L("id != KPosLmNullItemId")); + TPosLmGlobalCategory globalId = crit->GlobalCategory(); + AssertTrueSecL(globalId == KPosLmNullItemId, _L("globalId != KPosLmNullItemId")); + TPtrC name = crit->CategoryName(); + AssertTrueSecL(name.Length() == 0, _L("name.Length() != 0")); + + // Set id - other values should be default + const TPosLmItemId KId = 10; + crit->SetCategoryItemId(KId); + AssertTrueSecL(crit->CategoryItemId() == KId, _L("id != KId")); + AssertTrueSecL(crit->GlobalCategory()== KPosLmNullItemId, _L("globalId != KPosLmNullItemId")); + AssertTrueSecL(crit->CategoryName().Length() == 0, _L("name.Length() != 0")); + + // Set name - other values should be default + _LIT(KName, "Category Name"); + crit->SetCategoryNameL(KName); + AssertTrueSecL(crit->CategoryItemId() == KPosLmNullItemId, _L("id != KPosLmNullItemId")); + AssertTrueSecL(crit->GlobalCategory()== KPosLmNullItemId, _L("globalId != KPosLmNullItemId")); + AssertTrueSecL(crit->CategoryName() == KName, _L("name != KName")); + + // Set global id - other values should be default + const TPosLmGlobalCategory KGlobalCategoryId = 20; + crit->SetGlobalCategory(KGlobalCategoryId); + AssertTrueSecL(crit->CategoryItemId() == KPosLmNullItemId, _L("id != KPosLmNullItemId")); + AssertTrueSecL(crit->GlobalCategory()== KGlobalCategoryId, _L("globalId != KGlobalCategoryId")); + AssertTrueSecL(crit->CategoryName().Length() == 0, _L("name.Length() != 0")); + + // Set id - other values should be default + crit->SetCategoryItemId(KId); + AssertTrueSecL(crit->CategoryItemId() == KId, _L("id != KId")); + AssertTrueSecL(crit->GlobalCategory()== KPosLmNullItemId, _L("globalId != KPosLmNullItemId")); + AssertTrueSecL(crit->CategoryName().Length() == 0, _L("name.Length() != 0")); + + CleanupStack::PopAndDestroy(crit); + } + +// --------------------------------------------------------- +// CPosTp121::TestCaseInsensitiveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestCaseInsensitiveL() + { + CPosLmCategoryCriteria* crit = CPosLmCategoryCriteria::NewLC(); + RIdArray expectedIds; + CleanupClosePushL(expectedIds); + + // Search for "rEStaUrANt", should result in no match + TBuf<25> rest = _L("rEStaUrANt"); + crit->SetCategoryNameL(rest); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + + // Search for "RESTAURANT", should result in no match + rest.UpperCase(); + crit->SetCategoryNameL(rest); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + + // Search for "Restaurant", should result in two matches + HBufC* restaurant = GetGlobalCategoryFromResourceLC( KAccommodation ); + crit->SetCategoryNameL(*restaurant); + SearchL(crit, ESynchronous); + expectedIds.AppendL(iRestaurantId1); + expectedIds.AppendL(iRestaurantId2); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + CleanupStack::PopAndDestroy( restaurant ); + + // Search for "mCDoNAldS", should result in no match + rest = _L("mCDoNAldS"); + crit->SetCategoryNameL(rest); + SearchL(crit, EAsynchronous); + expectedIds.Reset(); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + + // Search for "MCDONALDS", should result in no match + rest.UpperCase(); + crit->SetCategoryNameL(rest); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + + // Search for "McDonalds", should result in two matches + rest = _L("McDonalds"); + crit->SetCategoryNameL(rest); + SearchL(crit, EAsynchronous); + expectedIds.AppendL(7); + expectedIds.AppendL(27); + ValidateSearchResultsL(expectedIds, iMultiDbSearch); + CleanupStack::PopAndDestroy(2, crit); + } + +// --------------------------------------------------------- +// CPosTp121::TestWildCardsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestWildCardsL() + { + CPosLmCategoryCriteria* crit = CPosLmCategoryCriteria::NewLC(); + const TInt KNrOfArrays = 5; + RIdArray* idArrays[KNrOfArrays]; + for (TInt i = 0; i < KNrOfArrays; i++) + { + RIdArray* array = new (ELeave) RIdArray; + CleanupStack::PushL(array); + CleanupClosePushL(*array); + idArrays[i] = array; + } + RIdArray empty; + CleanupClosePushL(empty); + + // Search for "*", should result in no matches + crit->SetCategoryNameL(_L("*")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + + // Search for "?", should result in no matches + crit->SetCategoryNameL(_L("?")); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// -------------- Setup databases -------------- + +// Add a category to db0 + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[0]); + CleanupStack::PushL(db); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + + // Add category "*wild card" + _LIT(KCategory0, "*wild card"); + category->SetCategoryNameL(KCategory0); + TPosLmItemId id0 = catMan->AddCategoryL(*category); + idArrays[0]->AppendL(1); + idArrays[0]->AppendL(2); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(id0, *idArrays[0])); + CleanupStack::PopAndDestroy(3, db); + +// Add categories to db2 + db = CPosLandmarkDatabase::OpenL((*iDatabases)[2]); + CleanupStack::PushL(db); + catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + category = CPosLandmarkCategory::NewLC(); + + // Add category "wi?d c?rd" + _LIT(KCategory1, "wi?d c?rd"); + category->SetCategoryNameL(KCategory1); + TPosLmItemId id1 = catMan->AddCategoryL(*category); + idArrays[1]->AppendL(44); + idArrays[1]->AppendL(45); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(id1, *idArrays[1])); + + // Add category "***" + _LIT(KCategory2, "***"); + category->SetCategoryNameL(KCategory2); + TPosLmItemId id2 = catMan->AddCategoryL(*category); + idArrays[2]->AppendL(44); + idArrays[2]->AppendL(47); + idArrays[2]->AppendL(55); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(id2, *idArrays[2])); + CleanupStack::PopAndDestroy(3, db); + +// Add categories to db4 + db = CPosLandmarkDatabase::OpenL((*iDatabases)[4]); + CleanupStack::PushL(db); + catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + category = CPosLandmarkCategory::NewLC(); + + // Add category "?" + _LIT(KCategory3, "?"); + category->SetCategoryNameL(KCategory3); + TPosLmItemId id3 = catMan->AddCategoryL(*category); + idArrays[3]->AppendL(86); + idArrays[3]->AppendL(81); + idArrays[3]->AppendL(104); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(id3, *idArrays[3])); + + // Add category "wi?d ca*" + _LIT(KCategory4, "wi?d ca*"); + category->SetCategoryNameL(KCategory4); + TPosLmItemId id4 = catMan->AddCategoryL(*category); + idArrays[4]->AppendL(101); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(id4, *idArrays[4])); + CleanupStack::PopAndDestroy(3, db); + +// -------------- Search and verify -------------- + +// Search for "*" and verify results - no matches expected + crit->SetCategoryNameL(_L("*")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "*wild*" and verify results - no matches expected + crit->SetCategoryNameL(_L("*wild*")); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "w?ld ca?d" and verify results - no matches expected + crit->SetCategoryNameL(_L("w?ld ca?d")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "wi?d c?rd" and verify results - two matches expected + crit->SetCategoryNameL(KCategory1); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(*idArrays[1], iMultiDbSearch); + +// Search for "****" and verify results - no matches expected + crit->SetCategoryNameL(_L("****")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "***" and verify results - three matches expected + crit->SetCategoryNameL(KCategory2); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(*idArrays[2], iMultiDbSearch); + +// Search for "**" and verify results - no matches expected + crit->SetCategoryNameL(_L("**")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "?" and verify results - two matches expected + crit->SetCategoryNameL(KCategory3); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(*idArrays[3], iMultiDbSearch); + +// Search for "?*" and verify results - no matches expected + crit->SetCategoryNameL(_L("?*")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + +// Search for "wi?d ca*" and verify results - one match expected + crit->SetCategoryNameL(KCategory4); + SearchL(crit, EAsynchronous); + ValidateSearchResultsL(*idArrays[4], iMultiDbSearch); + +// Search for "wi?d card" and verify results - no matches expected + crit->SetCategoryNameL(_L("wi?d card")); + SearchL(crit, ESynchronous); + ValidateSearchResultsL(empty, iMultiDbSearch); + + CleanupStack::PopAndDestroy(&empty); + CleanupStack::PopAndDestroy(2 * KNrOfArrays); + CleanupStack::PopAndDestroy(crit); + } + +// --------------------------------------------------------- +// CPosTp121::TestRefinedSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestRefinedSearchL(TExecutionMode aExecutionMode) + { + CPosLmCategoryCriteria* crit = CPosLmCategoryCriteria::NewLC(); + RIdArray idArray; + CleanupClosePushL(idArray); + + // Make a search for local category name + crit->SetCategoryNameL(_L("TietoEnator kontor")); // lm 7,27,51-61 will be found according to xls-sheet and code above + idArray.AppendL(7); + idArray.AppendL(27); + for (TInt i = 51; i <= 61; i++) + { + idArray.AppendL(i); + } + SearchL(crit, aExecutionMode); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Refine the previous search by specifying another local category name + crit->SetCategoryNameL(_L("BurgerKing")); // lm 7,27,51-54 will be found according to xls-sheet and the code above + for (TInt i = idArray.Count() - 1; i >= 5; i--) + { + idArray.Remove(i); + } + SearchL(crit, aExecutionMode, ETrue); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Repeat previous step but set max nr of matches to 1 - only 7,27,51 will be found + iMultiDbSearch->SetMaxNumOfMatches(1); + for (TInt i = idArray.Count() - 1; i >= 3; i--) + { + idArray.Remove(i); + } + SearchL(crit, aExecutionMode, ETrue); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Increase max nr of matches to 10 => all qualified lms will be found + crit->SetCategoryNameL(_L("TietoEnator kontor")); + iMultiDbSearch->SetMaxNumOfMatches(10); + for (TInt i = 52; i <= 61; i++) + { + idArray.AppendL(i); + } + SearchL(crit, aExecutionMode); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Refine search with the global category gas station by searching by id + crit->SetGlobalCategory(15000); // Entertainment + idArray.Reset(); + for (TInt i = 51; i <= 53; i++) + { + idArray.AppendL(i); + } + SearchL(crit, aExecutionMode, ETrue); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Refine search with the local category Pizzeria by searching by name + crit->SetCategoryNameL(_L("Pizzeria")); // only lm 51 should be found + idArray.Remove(1); + idArray.Remove(1); + SearchL(crit, aExecutionMode, ETrue); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + // Refine search with a global id that does not exist + crit->SetGlobalCategory(10000); // no lms should be found + idArray.Remove(0); + SearchL(crit, aExecutionMode, ETrue); + ValidateSearchResultsL(idArray, iMultiDbSearch); + + iMultiDbSearch->SetMaxNumOfMatches(); + CleanupStack::PopAndDestroy(2, crit); + } + +// --------------------------------------------------------- +// CPosTp121::TestDatabaseListL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestDatabaseListL(const RIdArray& aExpectedMatches) + { + iLog->Log(_L("TestDatabaseListL")); + _LIT(KNonExistingDb, "Jimmi.ldb"); + // Append an invalid(missing extension) database and search + + iDatabases->AppendL(_L("Jimmi")); + iNrOfDatabases++; + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetGlobalCategory(15000); // Entertainment + SearchL(catSearchCriteria, ESynchronous); + + ValidateSearchResultsL(aExpectedMatches, iMultiDbSearch, 1); // one error expected + CPosLmMultiDbSearch::TSearchError searchError; + iMultiDbSearch->GetSearchError(0, searchError); + AssertTrueSecL(searchError.iDatabaseIndex == 5, _L("Error in wrong database")); + AssertTrueSecL(searchError.iErrorCode == KErrArgument, _L("Wrong error in database, %d"), searchError.iErrorCode); + + // Remove non-existing database + another one and search - no errors should occur + TPtrC dbName = (*iDatabases)[iDatabases->Count() - 2]; + iDatabases->Delete(iDatabases->Count() - 2, 2); + iNrOfDatabases = iNrOfDatabases - 2; + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + + SearchL(catSearchCriteria, EAsynchronous); + + ValidateSearchResultsL(aExpectedMatches, iMultiDbSearch); + + iDatabases->AppendL(KDb105); + iNrOfDatabases++; + CleanupStack::PopAndDestroy(catSearchCriteria); + + // Verify that NewL for CPosLmMultiDbSearch is correct + iDatabases->AppendL(KNonExistingDb); + iNrOfDatabases++; + CPosLmMultiDbSearch* multiDb = CPosLmMultiDbSearch::NewL(*iDatabases); + CleanupStack::PushL(multiDb); + + catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetGlobalCategory(15000); // Entertainment + + iOperation = multiDb->StartLandmarkSearchL(*catSearchCriteria, EFalse); + ExecuteAndDeleteLD(iOperation); + + ValidateSearchResultsL(aExpectedMatches, multiDb, 1); // one error expected + multiDb->GetSearchError(0, searchError); + AssertTrueSecL(searchError.iDatabaseIndex == 5, _L("Error in wrong database")); + AssertTrueSecL(searchError.iErrorCode == KErrNotFound, _L("Wrong error in database, %d"), searchError.iErrorCode); + + // Remove added db from list + TInt pos = 0; + + TInt res = iDatabases->Find(KNonExistingDb, pos); + if (res == KErrNone) iDatabases->Delete(pos); + iNrOfDatabases--; + CleanupStack::PopAndDestroy(catSearchCriteria); + CleanupStack::PopAndDestroy(multiDb); + } + +// --------------------------------------------------------- +// CPosTp121::TestOnTheFlySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp121::TestOnTheFlySearchL(const RIdArray& aExpectedMatches) + { + iMultiDbSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetGlobalCategory(15000); // Entertainment + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + onTheFlyTester->StartSearchCampaignL(iMultiDbSearch, aExpectedMatches, catSearchCriteria); + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + iLog->Log(msg); + User::Leave(result); + } + CleanupStack::PopAndDestroy(2, catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp121::NrOfSearchErrors +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp121::NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher) + { + TInt nrOfSearchErrors = aMultiDbSearcher->NumOfSearchErrors(); + if (nrOfSearchErrors != 0) + { + for (TInt i = 0; i < nrOfSearchErrors; i++) + { + CPosLmMultiDbSearch::TSearchError error; + aMultiDbSearcher->GetSearchError(i, error); + TBuf<100> msg; + msg.Format(_L("Found error %d in database %d"), error.iErrorCode, error.iDatabaseIndex); + iLog->Log(msg); + } + } + return nrOfSearchErrors; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp122.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp122.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1620 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include +#include +#include "FT_CPosTp122.h" +#include "FT_LandmarkConstants.h" +#include +#include + +#include + +// CONSTANTS +const TInt KMaxFieldLength = 80; +const TInt KDistanceFieldLength = 24; +const TInt KMaxNearestLineLength = 1024; + +//const TInt KNrOfDatabases = 5; + +_LIT(KLMDB1, "NEARESTLMDB_1.LDB"); +_LIT(KLMDB2, "NEARESTLMDB_2.LDB"); +_LIT(KLMDB3, "NEARESTLMDB_3.LDB"); +_LIT(KLMDB4, "NEARESTLMDB_4.LDB"); +_LIT(KLMDB5, "NEARESTLMDB_5.LDB"); + +_LIT(KNEARESTLMDB, "eposlmnearestsearch.ldb"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp122::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iDatabases; + + if (iMultiDbSearch) iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + + delete iMultiDbSearch; + iNearestSearchResults.ResetAndDestroy(); + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("Error when RemoveAllLmDatabasesL")); + } + +// --------------------------------------------------------- +// CPosTp122::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::InitTestL() + { + CLandmarkTestProcedureBase::InitTestL(); + + iLog->Log(_L("InitTestL")); + RemoveAllLmDatabasesL(); + + // PrepareDatabases + PrepareDatabasesL(); + + SetupLimits(); + + iNrOfDatabases = 5; + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDatabases->Sort(); // Not really necessary... + AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); + + iLog->Log( _L("List sorted")); + + iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + CleanupStack::PopAndDestroy(dbManager); + + iLog->Log( _L("multi search")); + + // Copy db file, used by CNearestSearchResult + CopyTestDbFileL(KNEARESTLMDB); + + iLog->Log( _L("copied")); + + // Initiallize iNearestSearchResults + AppendNearestSearchResultsL(); + } + +// --------------------------------------------------------- +// CPosTp122::SetupLimits() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp122::SetupLimits() + { + iIdDb1Min = 1; + iIdDb1Max = 50; + + iIdDb2Min = 51; + iIdDb2Max = 100; + + iIdDb3Min = 101; + iIdDb3Max = 150; + + iIdDb4Min = 151; + iIdDb4Max = 200; + + iIdDb5Min = 201; + iIdDb5Max = 254; + } + +// --------------------------------------------------------- +// CPosTp122::AppendNearestSearchResultsL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp122::AppendNearestSearchResultsL() + { + iNearestSearchResults.ResetAndDestroy(); + + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\lmDbNearestSearchResult.txt"); + + RFile file; + CleanupClosePushL(file); + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + + TInt row=0; + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + ++row; + + //iLog->Log(_L("Nearest search result in progress")); + CNearestSearchResult* searchResult = CNearestSearchResult::NewL(line, row, iFileSession); + CleanupStack::PushL(searchResult); + + User::LeaveIfError(iNearestSearchResults.Append(searchResult)); + CleanupStack::Pop(searchResult); + //iLog->Log(_L("Nearest search result added")); + } + } + CleanupStack::PopAndDestroy(&file); + } + +// --------------------------------------------------------- +// CPosTp122::PrepareDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::PrepareDatabasesL() + { + iLog->Log(_L("PrepareDatabasesL")); + // Copy eposlmnearestsearch.ldb into five dbs + _LIT(KDbFile, "c:\\system\\test\\testdata\\eposlmnearestsearch.ldb"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<100> path; + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB1); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB2); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB3); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB4); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB5); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + + // Now adjust dbs according to following: + // First db-> Keep landmarks 1-50 + // Second db-> Keep landmarks 51-100 + // Third db-> Keep landmarks 101-150 + // Fourth db-> Keep landmarks 151-200 + // Fifth db-> Keep landmarks 201-254 + + RArray array; + CleanupClosePushL(array); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KLMDB1); + CleanupStack::PushL(lmd); + + TBool debug = EFalse; + TInt index=0; + TInt max=254; + for (index=50;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB2); + CleanupStack::PushL(lmd); + + for (index=0;index<50;index++) array.Append(index+1); + for (index=100;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB3); + CleanupStack::PushL(lmd); + + for (index=0;index<100;index++) array.Append(index+1); + for (index=150;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB4); + CleanupStack::PushL(lmd); + + for (index=0;index<150;index++) array.Append(index+1); + for (index=200;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB5); + CleanupStack::PushL(lmd); + + for (index=0;index<200;index++) array.Append(index+1); + if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + array.Reset(); + if (debug) PrintLm(lmd); + + CleanupStack::PopAndDestroy(lmd); + + CleanupStack::PopAndDestroy(&array); + iLog->Log(_L("PrepareDatabasesL Done")); + } + +// --------------------------------------------------------- +// CPosTp122::PrintLm +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::PrintLm(CPosLandmarkDatabase* db) + { + CPosLmItemIterator* iter = db->LandmarkIteratorL(); + CleanupStack::PushL(iter); + iLog->Log(_L("PrintLm")); + //for (TInt i=0;i< iter->Count();i++) + TPosLmItemId id = iter->NextL(); + TBuf<100> buf; + + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = db->ReadLandmarkLC(id); + TPtrC name; + lm->GetLandmarkName(name); + iLog->Log(_L("Found LM '%S' "), &name); + TInt idde = lm->LandmarkId(); + + id = iter->NextL(); + CleanupStack::PopAndDestroy(lm); + } + + CleanupStack::PopAndDestroy(iter); + iLog->Log(_L("PrintLm Done")); + } + +// --------------------------------------------------------- +// CPosTp122::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::StartL() + { + TInt KNrOfSearch = 0; + iErrorsFound= KErrNone; + + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + iLog->Log(_L(">>>>>Search Synchronous with ascending sort order")); + StartSearchOperationL(iNearestSearchResults, ESynchronous, ESortAscending, KNrOfSearch); + + iLog->Log(_L(">>>>>Search Synchronous with descending sort order")); + StartSearchOperationL(iNearestSearchResults, ESynchronous, ESortDescending, KNrOfSearch); + + iLog->Log(_L(">>>>>Search Asynchronous with ascending sort order")); + StartSearchOperationL(iNearestSearchResults, EAsynchronous, ESortAscending, KNrOfSearch); + + iLog->Log(_L(">>>>>Search Asynchronous with descending sort order")); + StartSearchOperationL(iNearestSearchResults, EAsynchronous, ESortDescending, KNrOfSearch); + + iLog->Log(_L(">>>>>Search Synchronous with no sort order (therefore sorted by distance)")); + StartSearchOperationL(iNearestSearchResults, ESynchronous, ESortNone); + + iLog->Log(_L(">>>>>Search Asynchronous with no sort order (therefore sorted by distance)")); + StartSearchOperationL(iNearestSearchResults, EAsynchronous, ESortNone); + + iLog->Log(_L(">>>>>Search Synchronous with no sort order, partial (therefore sorted by distance)")); + iPartial = ETrue; + StartSearchOperationL(iNearestSearchResults, ESynchronous, ESortNone); + iPartial = EFalse; + iDisplayData->UnsetPartialReadParameters(); + + iLog->Log(_L("Test with maximum searches")); + TestMaximumNrOfMatchesL(iNearestSearchResults, EAsynchronous, ESortNone); + TestMaximumNrOfMatchesL(iNearestSearchResults, ESynchronous, ESortNone); + TestMaximumNrOfMatchesL(iNearestSearchResults, EAsynchronous, ESortDescending); + TestMaximumNrOfMatchesL(iNearestSearchResults, EAsynchronous, ESortAscending); + + iLog->Log(_L("TestOnTheFlySearchL")); + TestOnTheFlySearchL(iNearestSearchResults); + + // Since TestOnTheFlySearchL is changing displadata + iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + iLog->Log(_L("Test Leave codes for nearest search")); + TestLeaveCodesL(); + + // TC Step 6 "A new array of databases is set to be searched" + iLog->Log(_L("Test refined search, test different search dbs")); + DoLastTestPartL(iNearestSearchResults); + + iLog->Log(_L("Testing cancel immediately")); + CancelTestL(iNearestSearchResults, EFalse); + + // XXX Hangs client + iLog->Log(_L("Testing cancel in callback")); + CancelTestL(iNearestSearchResults, ETrue); + + if (iErrorsFound != KErrNone) + { + + iLog->Log(_L("Errors found in TP122")); + User::Leave(-1); + } + else iLog->Log(_L("TP122 successfully completed")); + } + +// --------------------------------------------------------- +// CPosTp122::StartSearchOperationL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::StartSearchOperationL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode, + TTp122SortOrder aSortOrder, + TInt aNrOfSearches) + { + + // Test SetMaxNumOfMatches, first set to one and then back to unlimited + iMultiDbSearch->SetMaxNumOfMatches(1); + iMultiDbSearch->SetMaxNumOfMatches(); + + TBuf<100> buf; + TInt maxSearches = 0; + if (aNrOfSearches == 0) maxSearches = aSearchResults.Count(); + else maxSearches = aNrOfSearches; + + for(TInt i=0; iiLatitude, aSearchResults[i]->iLongitude); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, aSearchResults[i]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(aSearchResults[i]->iMaxDistance); + buf.Format(_L("StartSearchOperationL: Searching for Lat %f Long %f"), aSearchResults[i]->iLatitude, aSearchResults[i]->iLongitude); + //iLog->Log(buf); + + if (aSearchResults[i]->iMaxSearchResult > 0) + { + // Does not work anymore + //iMultiDbSearch->SetMaxNumOfMatches(aSearchResults[i]->iMaxSearchResult); + } + else + { + iMultiDbSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + } + + if (iNearestSearchResults[i]->Redefined() && i > 0) + { + // Remove distances that are not present in the previous + + for (TInt j=0; jiDistances.Count(); j++) + { + TBool found = EFalse; + TInt id = 0; + TPosLmItemId idde; + + id = j; + idde = iNearestSearchResults[i]->iDistances[j].Id(); + + TBuf<100> debug; + debug.Format(_L("Looking for id %d or id: %d "), idde, id); + //iLog->Log(debug); + + for (TInt p=0;piDistances.Count();p++) + { + + if (iNearestSearchResults[i]->iDistances[j].Id() == iNearestSearchResults[i-1]->iDistances[p].Id()) + { + found = ETrue; + TBuf<100> buf; + buf.Format(_L("Found id %d or id: %d "), idde, id); + //iLog->Log(buf); + } + } + if (!found) + { + // Remove since not found, only keep ids that was found in previous search + TBuf<100> buf; + buf.Format(_L("Removing lm Id %d from index %d"), idde, id); + //iLog->Log(buf); + iNearestSearchResults[i]->iDistances.Remove(id); + //iLog->Log(_L("Removing Done")); + j--; + } + //iLog->Log(_L("***********")); + } + } + + TTime iStart; + TTime iStop; + + iStart.UniversalTime(); + SearchL(nearestCriteria, aExecutionMode, aSearchResults[i]->Redefined(), aSortOrder); + iStop.UniversalTime(); + + TInt64 msec = (iStop.Int64() - iStart.Int64())/1000; + buf.Format(_L("Search op nr %d took %d msec"), i, msec); + iLog->Log(buf); + + AssertTrueSecL(NrOfSearchErrors(iMultiDbSearch) == 0, _L("Found search errors!")); + + // Add check of result here + CheckSearchResultL(*aSearchResults[i], aSortOrder); + + CleanupStack::PopAndDestroy(nearestCriteria); + iDisplayData->Reset(); + + } + } + +// --------------------------------------------------------- +// CPosTp122::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::SearchL( + CPosLmNearestCriteria* aNearestSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch, + TTp122SortOrder aSortOrder) + { + if (iPartial) + { + RArray reqFields; + CleanupClosePushL(reqFields); + reqFields.Append(EPositionFieldStreet); + reqFields.Append(EPositionFieldBuildingFloor); + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + CleanupStack::PopAndDestroy(2); + } + + switch (aSortOrder) + { + case ESortNone: + { + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aNearestSearchCriteria, aRefinedSearch); + break; + } + case ESortAscending: + { + TPosLmSortPref ascending(CPosLandmark::ELandmarkName); + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aNearestSearchCriteria, ascending, aRefinedSearch); + break; + } + case ESortDescending: + { + TPosLmSortPref descending(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aNearestSearchCriteria, descending, aRefinedSearch); + break; + } + default: + User::Leave(KErrArgument); + break; + } + + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + default: + User::Leave(KErrArgument); + break; + } + } + +// --------------------------------------------------------- +// CPosTp122::TestMaximumNrOfMatchesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::TestMaximumNrOfMatchesL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode, TTp122SortOrder aSortOrder) + { + iLog->Log(_L("TestMaximumNrOfMatchesL")); + for (TInt j=0;jiLatitude, aSearchResults[KIndex]->iLongitude); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, aSearchResults[KIndex]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(aSearchResults[KIndex]->iMaxDistance); + + for (TInt i=1;i<10;i++) + { + // Test with different maximum nr of matches + iMultiDbSearch->SetMaxNumOfMatches(i*2); + + TBuf<100> buf; + SearchL(nearestCriteria, aExecutionMode, aSearchResults[KIndex]->Redefined(), aSortOrder); + + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + nrOfMatches += iter->NumOfItemsL(); + CleanupStack::PopAndDestroy(iter); + } + + AssertTrueSecL(nrOfMatches <= i*2 * iNrOfDatabases, _L("Total nr of matches are bigger than the set value of maximum nr of matches")); + AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators")); + AssertTrueSecL(nrOfMatches == iDisplayData->Count(), _L("Total nr of matches doesn't match sum of matches in displaydata")); + } + + CleanupStack::PopAndDestroy(nearestCriteria); + } + + } + +// --------------------------------------------------------- +// CPosTp122::TestLeaveCodesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::TestLeaveCodesL() + { + iLog->Log(_L("TestLeaveCodesL")); + + TPosLmSortPref sortPref(CPosLandmark::ECategoryInfo, TPosLmSortPref::EAscending); + TCoordinate coord(25, 45); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord); + + // Only ECategoryName is supported,all other leave with KErrNotSupported + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EDescription, TPosLmSortPref::EDescending); + TRAPD(err, iMultiDbSearch->StartLandmarkSearchL(*nearestCriteria, sortPref)); + AssertTrueSecL(err == KErrNotSupported, _L("Should have left with KErrNotSupported")); + + CleanupStack::PopAndDestroy(nearestCriteria); + } + +// --------------------------------------------------------- +// CPosTp122::CancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::CancelTestL(const RPointerArray& aSearchResults, TBool aCancelInCallback) + { + //Test search with one criteria + const TInt KIndex=0; + + TCoordinate coord(aSearchResults[KIndex]->iLatitude, aSearchResults[KIndex]->iLongitude); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, aSearchResults[KIndex]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(aSearchResults[KIndex]->iMaxDistance); + + // Cancel in callback, cancel in every progress step phase + // when progress has increased with 0.09 + if (aCancelInCallback) + { + TReal32 progress(0); + while (progress < 1.0) + { + RunAsyncOperationAndCancelInCallbackLD( + iMultiDbSearch->StartLandmarkSearchL( + *nearestCriteria, + aSearchResults[KIndex]->Redefined()), + progress); + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + nrOfMatches += iter->NumOfItemsL(); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators when cancelling")); + //AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); + + progress = progress + 0.09; + } + } + else + { + // Cancel immediately + RunAsyncOperationAndCancelLD( + iMultiDbSearch->StartLandmarkSearchL( + *nearestCriteria, + aSearchResults[KIndex]->Redefined())); + + AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); + } + + if (iMultiDbSearch->NumOfSearchErrors() != 0) iLog->Log(_L("Errors after search")); + for (TInt i=0;iNumOfSearchErrors(); i++) + { + CPosLmMultiDbSearch::TSearchError searchErr; + iMultiDbSearch->GetSearchError(i, searchErr); + TBuf<150> buf; + buf.Format(_L("ErrorCode %d returned from db nr %d"),searchErr.iErrorCode, searchErr.iDatabaseIndex); + iLog->Log(buf); + } + + CleanupStack::PopAndDestroy(nearestCriteria); + } + +// --------------------------------------------------------- +// CPosTp122::DoLastTestPartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::DoLastTestPartL(const RPointerArray& aSearchResults) + { + TInt KIndex = 0; + TCoordinate coord(aSearchResults[KIndex]->iLatitude, aSearchResults[KIndex]->iLongitude); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, aSearchResults[KIndex]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(aSearchResults[KIndex]->iMaxDistance); + + TBuf<100> buf; + iLog->Log(_L("Search in all dbs")); + SearchL(nearestCriteria, ESynchronous, aSearchResults[KIndex]->Redefined(), ESortNone); + + // Check displaydata/iterator here + CheckDbL(); + + HBufC16* db4 = (*iDatabases)[4].AllocL(); + HBufC16* db2 = (*iDatabases)[2].AllocL(); + + // Remove two dbs from uri list + iDatabases->Delete(4); + iDatabases->Delete(2); + iNrOfDatabases-=2; + + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + + iIdDb3Min = 151; + iIdDb3Max = 200; + + iLog->Log(_L("Search in all dbs but db2 and db4")); + SearchL(nearestCriteria, ESynchronous, aSearchResults[KIndex]->Redefined(), ESortNone); + CheckDbL(); + + // Now search in all dbs but db nr 2 + buf.Zero(); + buf.Format(_L("%S"), db4); + iDatabases->AppendL(buf); + iNrOfDatabases++; + iDatabases->Sort(); + + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + + // Add a new landmark to db nr 4, nr 2 in the list + buf.Zero(); + buf.Format(_L("Open Database: %S"), db4); + iLog->Log(buf); + + buf.Zero(); + buf.Format(_L("%S"), db4); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(buf); + if (db->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(db->InitializeL()); + } + + CleanupStack::PushL(db); + CPosLandmark* lm1 = CPosLandmark::NewLC(); + lm1->SetLandmarkNameL(_L("TP122_Landmark")); + lm1->SetLandmarkDescriptionL(_L("Some Description")); + TCoordinate newCoord(aSearchResults[KIndex]->iLatitude-5, aSearchResults[KIndex]->iLongitude+1); + + TLocality loc(newCoord, 0.5); + lm1->SetPositionL(loc); + iLog->Log(_L("Add new Landmark to db nr 4")); + TPosLmItemId newLmId = db->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + CleanupStack::PopAndDestroy(db); + + iLog->Log(_L("Search in all dbs but db2")); + //Refine search. new landmark should not be included + SearchL(nearestCriteria, ESynchronous, ETrue, ESortNone); + + SetupLimits(); + iIdDb3Min = 151; + iIdDb3Max = 200; + iIdDb4Min = 201; + iIdDb4Max = 254; + + CheckDbL(); + + TInt itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + + CPosLmDisplayItem& item = iDisplayData->DisplayItem(itemId); + TInt lmId = item.Landmark().LandmarkId(); + TPtrC name; + item.Landmark().GetLandmarkName(name); + // Verify that the landmark is not found + if (name.CompareC(_L("TP122_Landmark")) == 0) { + iLog->Log(_L("Added landmarks should not be found in refined search")); + User::Leave(-1); + + } + itemId = iDisplayData->NewItemIndex(); + } + + // Add all dbs to the search list + SetupLimits(); + + // Add the last db to the search list + buf.Zero(); + buf.Format(_L("%S"), db2); + iDatabases->AppendL(buf); + iNrOfDatabases++; + iDatabases->Sort(); + + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + iLog->Log(_L("Search in all dbs")); + //Refine search. new landmark should not be included + SearchL(nearestCriteria, ESynchronous, ETrue, ESortNone); + CheckDbL(); + itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + + CPosLmDisplayItem& item = iDisplayData->DisplayItem(itemId); + TInt lmId = item.Landmark().LandmarkId(); + TPtrC name; + item.Landmark().GetLandmarkName(name); + // Verify that the landmark is not found + if (name.CompareC(_L("TP122_Landmark")) == 0) { + + iLog->Log(_L("Added landmarks should not be found in refined search")); + User::Leave(-1); + + } + + itemId = iDisplayData->NewItemIndex(); + } + + CleanupStack::PopAndDestroy(nearestCriteria); + + // Correct limits if more testing after this part + SetupLimits(); + delete db4; + delete db2; + } + +// --------------------------------------------------------- +// CPosTp122::CheckDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::CheckDbL() + { + iLog->Log(_L("CheckDbL")); + CDesCArray* dbToSearch = iMultiDbSearch->DatabasesToSearchL(); + CleanupStack::PushL(dbToSearch); + TBuf<100> buf; + + for (TInt i=0;iCount();i++) + { + buf.Zero(); + buf.Format(_L("DB nr %d "), i); + + buf.Append((*dbToSearch)[i]); + iLog->Log(buf); + } + + if (iMultiDbSearch->NumOfDatabasesToSearch() != dbToSearch->Count()) iLog->Log(_L("Differ...")); + + CleanupStack::PopAndDestroy(dbToSearch); + + for (TInt j = 0; j NumOfDatabasesToSearch(); j++) + { + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + ValidateIdL(id, j); + id = iter->NextL(); + } + //GetSearchError + //NumOfSearchErrors + CleanupStack::PopAndDestroy(iter); + } + iLog->Log(_L("CheckDbL Done")); + } + +// --------------------------------------------------------- +// CPosTp122::CheckSearchResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::CheckSearchResultL(CNearestSearchResult& aSearchResult, TTp122SortOrder aSortOrder) + { + TBuf<150> buf; + TUint expectedNoMatches = aSearchResult.iDistances.Count(); + if (aSearchResult.iMaxSearchResult != 0 && aSearchResult.iMaxSearchResult < aSearchResult.iDistances.Count()) + { + + } + + ValidateTotalNrOfMatchesL(expectedNoMatches, iMultiDbSearch->TotalNumOfMatches()); + + //iLog->Log(_L("Adding...")); + + // First check that result comes from correct db + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[j]); + if (db->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(db->InitializeL()); + } + + CleanupStack::PushL(db); + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + + nrOfMatches += iter->NumOfItemsL(); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + ValidateIdL(id, j); + id = iter->NextL(); + } + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches from db nr %d"), iter->NumOfItemsL(), j); + //iLog->Log(buf); + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(db); + } + + //iLog->Log(_L("Done adding...")); + + if (nrOfMatches != iDisplayData->Count()) + { + iLog->Log(_L("Wrong number of items")); + User::Leave(-1); + + } + + // Sorted on distance + if (aSortOrder == ESortNone) + { + TInt index=0; + TInt itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + + CPosLmDisplayItem& item = iDisplayData->DisplayItem(itemId); + TInt lmId = item.Landmark().LandmarkId(); + + TReal32 distance =0; + TInt dist = item.GetDistance(distance); + if(dist == KErrNone) + { + //iLog->Log(_L("CPosLmDisplayItem::GetDistanced returns KErrNone")); + } + + else if(dist == KErrNotFound) + { + //iLog->Log(_L("CPosLmDisplayItem::GetDistanced returns KErrNotFound")); + } + + // Validate lm from correct db + TInt dbIndex = item.DatabaseIndex(); + + ValidateIdL(lmId, dbIndex); + + TBuf<100> buf; + buf.Format(_L("Found exp id %d returned id %d"),aSearchResult.iDistances[index].iId, lmId); + //iLog->Log(buf); + + if (aSearchResult.iDistances[index].iId != lmId) + { + // if the distance is equal to the distance to the landmark + // before or after then no error. + // This to be able to use a database with landmarks with the same position. + + TBool noError=EFalse; + if (index > 0) + { + noError = (aSearchResult.iDistances[index-1].iDistance == aSearchResult.iDistances[index].iDistance); + } + if (index < aSearchResult.iDistances.Count() && !noError) + { + noError = (aSearchResult.iDistances[index+1].iDistance == aSearchResult.iDistances[index].iDistance); + } + if (!noError) + { + _LIT(KUnexpectedItemId, "ERROR: Unexpected item id"); + + iErrorsFound++; + iLog->Log(KUnexpectedItemId); + } + } + itemId = iDisplayData->NewItemIndex(); + index++; + } + } + // Ascended and descended + else + { + /////////// + for (TInt i=0;iCount();i++) + { + // Check for all but first and last + if (i>0 && iCount()-1) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + TReal32 distance =0; + TInt dist = item.GetDistance(distance); + if(dist == KErrNone) + { + //iLog->Log(_L("CPosLmDisplayItem::GetDistanced returns KErrNone")); + } + + else if(dist == KErrNotFound) + { + //iLog->Log(_L("CPosLmDisplayItem::GetDistanced returns KErrNotFound")); + } + + CPosLmDisplayItem& nextItem = iDisplayData->DisplayItem(i+1); + TInt nextLmId = nextItem.Landmark().LandmarkId(); + + TPtrC name, nextLmName; + item.Landmark().GetLandmarkName(name); + nextItem.Landmark().GetLandmarkName(nextLmName); + + // Validate lm from correct db + TInt dbIndex = item.DatabaseIndex(); + ValidateIdL(lmId, dbIndex); + TInt nextDbIndex = nextItem.DatabaseIndex(); + // Validate next lm from correct db + ValidateIdL(nextLmId, nextDbIndex); + + //debugging purposes + + + TInt order = nextLmName.CompareC(name); + if (aSortOrder == ESortAscending) + { // sorted ascended + if (order < 0) + { + iLog->Log(_L("ERROR: Wrong sortorder when ascended")); + iErrorsFound++; + } + } + else // sorted descended + { + if (order > 0) + { + iLog->Log(_L("ERROR: Wrong sortorder when descended")); + iErrorsFound++; + } + + } + } + } + + } + iLog->Log(_L("CheckSearchResultL Done")); + } + +// --------------------------------------------------------- +// CPosTp122::ValidateTotalNrOfMatchesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::ValidateTotalNrOfMatchesL ( + TUint aRetrievedNrOfMatches, + TUint aExpectedNrOfMatches) + { + _LIT(KNumOfMatchesErr, "ERROR: No. of matches is incorrect when the search is performed"); + + if (aRetrievedNrOfMatches != aExpectedNrOfMatches) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, aExpectedNrOfMatches); + iLog->Log(info); + info.Format(KReturned, aRetrievedNrOfMatches); + iLog->Log(info); + + iLog->Log(KNumOfMatchesErr); + iErrorsFound++; + } + } + +// --------------------------------------------------------- +// CPosTp122::ValidateIdL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::ValidateIdL(TPosLmItemId aId, TInt aDbIndex) + { + TBool condition = EFalse; + switch (aDbIndex) + { + case 0: + // Db 1 contains landmarks with id = 1-50 + condition = aId >= iIdDb1Min && aId <= iIdDb1Max; + break; + case 1: + // Db 2 contains landmarks with id = 51-100 + condition = aId >= iIdDb2Min && aId <= iIdDb2Max; + break; + case 2: + // Db 3 contains landmarks with id = 101-150 + condition = aId >= iIdDb3Min && aId <= iIdDb3Max; + break; + case 3: + // Db 4 contains landmarks with id = 151-200 + condition = aId >= iIdDb4Min && aId <= iIdDb4Max; + break; + case 4: + // Db 5 contains landmarks with id = 201-254 + condition = aId >= iIdDb5Min && aId <= iIdDb5Max; + break; + } + + if (!condition) + { + iErrorsFound++; + TBuf<150> buf; + buf.Format(_L("ERROR: Invalid match from database reported, index %d in db %d"), aId, aDbIndex); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp122::TestOnTheFlySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp122::TestOnTheFlySearchL(const RPointerArray& aSearchResults) + { + iMultiDbSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + iMultiDbSearch->SetMaxNumOfMatches(); + + TInt KIndex = 0; + TCoordinate coord(aSearchResults[KIndex]->iLatitude, aSearchResults[KIndex]->iLongitude); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, aSearchResults[KIndex]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(aSearchResults[KIndex]->iMaxDistance); + + RIdArray expectedMatches; + CleanupClosePushL(expectedMatches); + + TBuf<150> buf; + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + + // Remove lm with index 48,49,50, they have no location (see lmDbNearestSearch in landmarksdb.xls) + TInt pos = aSearchResults[KIndex]->iSearchResult.Find(48); + aSearchResults[KIndex]->iSearchResult.Remove(pos); + pos = aSearchResults[KIndex]->iSearchResult.Find(49); + aSearchResults[KIndex]->iSearchResult.Remove(pos); + pos = aSearchResults[KIndex]->iSearchResult.Find(50); + aSearchResults[KIndex]->iSearchResult.Remove(pos); + + onTheFlyTester->StartSearchCampaignL(iMultiDbSearch, aSearchResults[KIndex]->iSearchResult, nearestCriteria); + + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + + iLog->Log(msg); + User::Leave(result); + } + CleanupStack::PopAndDestroy(onTheFlyTester); + CleanupStack::PopAndDestroy(&expectedMatches); + CleanupStack::PopAndDestroy(nearestCriteria); + iLog->Log(_L("TestOnTheFlySearchL Done")); + } + +// --------------------------------------------------------- +// CPosTp122::NrOfSearchErrors +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp122::NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher) + { + TInt nrOfSearchErrors = aMultiDbSearcher->NumOfSearchErrors(); + if (nrOfSearchErrors != 0) + { + for (TInt i = 0; i < nrOfSearchErrors; i++) + { + CPosLmMultiDbSearch::TSearchError error; + aMultiDbSearcher->GetSearchError(i, error); + TBuf<100> msg; + msg.Format(_L("Found error %d in database %d"), error.iErrorCode, error.iDatabaseIndex); + iLog->Log(msg); + } + } + return nrOfSearchErrors; + } + + +// --------------------------------------------------------- +// CNearestSearchResult::NewL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +CNearestSearchResult* CNearestSearchResult::NewL( + const TDesC& aDes, + const TInt& aIndex, + RFs& aFileSession) + { + CNearestSearchResult* self = new(ELeave) CNearestSearchResult(aFileSession); + CleanupStack::PushL(self); + self->ConstructL(aDes, aIndex); + CleanupStack::Pop(); + return self; + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CNearestSearchResult::CNearestSearchResult(RFs& aFileSession) +: iFileSession( aFileSession ) + { + TRealX nan; + nan.SetNaN(); + iMaxDistance = nan; + } + +// --------------------------------------------------------- +// CNearestSearchResult::CounstructL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResult::ConstructL(const TDesC& aDes, const TInt& aIndex) + { + // Use KNEARESTLMDB as correct template + iDatabase = CPosLandmarkDatabase::OpenL(KNEARESTLMDB); + + if ( iDatabase->IsInitializingNeeded() ) + { + TRAPD( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + } + + TLex line(aDes); + line.Mark(); + TInt redefined=0, useCoverageRadius; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ELatitude: + val.Val(iLatitude, TChar(',')); + break; + case ELongitude: + val.Val(iLongitude, TChar(',')); + break; + case EUseCoverageRadius: + val.Val(useCoverageRadius); + if (useCoverageRadius == 1) + { + iUseCoverageRadius = ETrue; + } + break; + case EMaxDistance: + val.Val(iMaxDistance); + break; + case EErrorCode: + val.Val(iErrorCode); + break; + case ESearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + case EMaxSearchResult: + val.Val(iMaxSearchResult); + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + AppendDistancesL(aIndex); + + } + } + + +// Destructor +CNearestSearchResult::~CNearestSearchResult() + { + iDistances.Close(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CNearestSearchResult::AppendDistancesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResult::AppendDistancesL(const TInt& aIndex) + { + iDistances.Reset(); + + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\lmDbNearestSearch.txt"); + + RFile file; + CleanupClosePushL(file); + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + + TInt row=0; + TBuf line; + while (CLandmarkTestProcedureBase::ReadLn(file, line) != KErrEof) + { + ParseDistanceL(line, aIndex, row); + ++row; + } + + SortDistances(); + + CleanupStack::PopAndDestroy(&file); + } + +// --------------------------------------------------------- +// CNearestSearchResult::ParseDistancesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResult::ParseDistanceL(const TDesC& aDes, + const TInt& aIndex, + const TPosLmItemId& aId) + { + + const TInt KStartIndex = 5; + + TLex line(aDes); + line.Mark(); + TInt index = 0; + TReal64 dist=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t' || line.Peek() == '\n' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + + if (index == (KStartIndex + aIndex)) + { + TLex val(token); + val.Val(dist, TChar(',')); + + if (iUseCoverageRadius) + { + CPosLandmark* lm = iDatabase->ReadLandmarkLC(aId); + + TReal32 aCoverageRadius; + if (lm->GetCoverageRadius(aCoverageRadius) == KErrNone) + { + dist -= aCoverageRadius; + if (dist < 0) + { + dist = 0; + } + } + CleanupStack::PopAndDestroy(lm); + } + + if (Math::IsNaN(iMaxDistance) || dist <= iMaxDistance) + { + if (dist != -1) + { + TSearchResult searchResult(aId, TReal32(dist)); + iDistances.Append(searchResult); + } + } + + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } +// --------------------------------------------------------- +// CNearestSearchResult::Latitude +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CNearestSearchResult::Latitude() const + { + return iLatitude; + } + +// --------------------------------------------------------- +// CNearestSearchResult::Latitude +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal64 CNearestSearchResult::Longitude() const + { + return iLongitude; + } + +// --------------------------------------------------------- +// CNearestSearchResult::UseCoverageRadius +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CNearestSearchResult::UseCoverageRadius() const + { + return iUseCoverageRadius; + } + +// --------------------------------------------------------- +// CNearestSearchResult::MaxDistance +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TReal32 CNearestSearchResult::MaxDistance() const + { + return iMaxDistance; + } + +// --------------------------------------------------------- +// CNearestSearchResult::ErrorCode +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CNearestSearchResult::ErrorCode() const + { + return iErrorCode; + } + +// --------------------------------------------------------- +// InternalLandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt InternalSort(const TSearchResult& aSource, const TSearchResult& aTarget) + { + // zero, if the two objects are equal + // a negative value, if the first object is less than the second. + // a positive value, if the first object is greater than the second. + + if ( aSource.Distance() == aTarget.Distance()) + { + return 0; + } + else if (aSource.Distance() < aTarget.Distance()) + { + return -1; + } + + return 1; + } + +// --------------------------------------------------------- +// CNearestSearchResult::ErrorCode +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResult::SortDistances() + { + TLinearOrder order(InternalSort); + iDistances.Sort(order); + } + +// --------------------------------------------------------- +// CNearestSearchResult::Print +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResult::Print(TDes& aPrint) + { + _LIT(KPosInfo, "Latitude=%g, Longitude=%g"); + TChar del(','); + + TBuf info; + info.Format(KPosInfo, iLatitude, iLongitude); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KUseCoverageRadius, "UseCoverageRadius=%d"); + info.Format(KUseCoverageRadius, iUseCoverageRadius); + aPrint.Append(info); + aPrint.Append(del); + + if (!Math::IsNaN(iMaxDistance)) + { + _LIT(KMaxDistance, "MaxDistance=%g"); + info.Format(KMaxDistance, iMaxDistance); + aPrint.Append(info); + aPrint.Append(del); + } + + _LIT(KErrorCode, "ErrorCode = %d"); + info.Format(KErrorCode, iErrorCode); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KRedefined, "Redefined=%d"); + info.Format(KRedefined, iRedefined); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KMaxSearchResult, "MaxSearchResult=%d"); + info.Format(KMaxSearchResult, iMaxSearchResult); + aPrint.Append(info); + aPrint.Append(del); + + + PrintDistances(aPrint); + } + +// --------------------------------------------------------- +// CNearestSearchResult::PrintDistances +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResult::PrintDistances(TDes& aPrint) + { + TBuf info2; + TChar del(':'); + aPrint.Append(_L("Distances: ")); + + for (TInt j=0; j +#include +#include +#include +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp123::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +/*void CPosTp123::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp123 - Uncategorized LM MultiDb Search"); + aName = KTestName; + } +*/ +// --------------------------------------------------------- +// CPosTp123::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::CloseTest() + { + delete iDatabases; + delete iLandmarkSearch; + for (TInt i = 0; i < iIdArrays.Count(); i++) + { + iIdArrays[i].Close(); + } + iIdArrays.Close(); + } + +// --------------------------------------------------------- +// CPosTp123::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::InitTestL() + { + CLandmarkTestProcedureBase::InitTestL(); + + // PrepareDatabases + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + iNrOfDatabases = 5; + + // Initialize data members + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDatabases->Sort(); + AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); + iLandmarkSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + CleanupStack::PopAndDestroy(dbManager); + + iLog->Log( _L("Multi db search created")); + + // Enable use of global categories + // CPosLandmarkDatabase* database = UseGlobalCategoriesL(); + // delete database; + CPosLandmarkDatabase* database = NULL; + // Reset Global categories for all databases but EPOSLM_105.LDB and add the global category + // "Hotel" to the 5 first landmarks in the databases. + for (TInt i = 0; i < iNrOfDatabases - 1; i++) // Do not use global categories in + { + database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); + CleanupStack::PushL(database); + if ( database->IsInitializingNeeded() ) + { + TRAPD( err, ExecuteAndDeleteLD( database->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catMan); + ExecuteAndDeleteLD(catMan->ResetGlobalCategoriesL()); + CPosLmItemIterator* lmIter = database->LandmarkIteratorL(); + CleanupStack::PushL(lmIter); + RIdArray idArray; + CleanupClosePushL(idArray); + lmIter->GetItemIdsL(idArray, 0, 5); + + // Remove all existing categories from the 5 first landmarks + for (TInt i = 0; i < idArray.Count(); i++) + { + CPosLandmark* lm = database->ReadLandmarkLC(idArray[i]); + lm->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); + TInt err = KErrLocked; + while (err==KErrLocked) + { + TRAP(err, database->UpdateLandmarkL(*lm)); + } + CleanupStack::PopAndDestroy(lm); + } + + // Add global category hotel to 5 first LMs + TPosLmGlobalCategory accommodation(3000); // 27 == Global category id for accommodation according to .the global ids added for BC testing + User::After(200000); + ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(catMan->GetGlobalCategoryL(accommodation), idArray)); + + CleanupStack::PopAndDestroy(4, database); + } + + // Initialize arrays that will contain expected search results + RIdArray array20; + User::LeaveIfError(iIdArrays.Append(array20)); + RIdArray array40; + User::LeaveIfError(iIdArrays.Append(array40)); + RIdArray array60; + User::LeaveIfError(iIdArrays.Append(array60)); + RIdArray array80; + User::LeaveIfError(iIdArrays.Append(array80)); + RIdArray array105; + User::LeaveIfError(iIdArrays.Append(array105)); + } + +// --------------------------------------------------------- +// CPosTp123::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::StartL() + { +// 1. Verify KErrArgument is returned from API + iLog->Log(_L("<<< 1. Verify KErrArgument is returned from API >>>")); + for (TBool runSynch = EFalse; runSynch <= ETrue; runSynch++) + { + iLog->Log(_L("Should leave with KErrArgument...")); + TRAPD(err, TestSearchCategoriesL(runSynch)); + AssertTrueSecL(err == KErrArgument, _L("Should have left with KErrArgument but failed with %d"), err); + iLog->Log(_L("Function left correctly with KErrArgument")); + } + +// 2. We should not find any uncategorized landmarks since every landmark in the db +// belongs to a category + iLog->Log(_L("<<< 2. Search uncategorized LMs (none exist) >>>")); + SearchForUncategorizedLMsL(0); + +// 3. Remove all categories from M landmarks in each database + iLog->Log(_L("<<< 3. Remove all categories from M landmarks in each database >>>")); + const TInt M = 2; + RemoveCategoriesFromLandmarksL(M); + // Check that correct number of uncategorized landmarks are found + SearchForUncategorizedLMsL(M * iNrOfDatabases); + +// 4. Remove a local category that Q LMs belong to and add an uncategorized lm + iLog->Log(_L("<<< 4. Remove a local category that Q LMs belong to and add an uncategorized lm >>>")); + const TInt Q = 6; + TInt dbIndex = 3; + TPosLmItemId localCatId = 26; // Läkare + RemoveCategoryFromDbL(localCatId, (*iDatabases)[dbIndex]); + // Landmark 72-77 should now be uncategorized. + for (TInt i = 72; i <= 77; i++) + { + iIdArrays[dbIndex].Append(i); + } + + // Add a lm + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("Guru")); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); + CleanupStack::PushL(database); + TPosLmItemId id = database->AddLandmarkL(*lm); + iIdArrays[dbIndex].Append(id); + CleanupStack::PopAndDestroy(2, lm); + + // Check that correct number of uncategorized landmarks are found + SearchForUncategorizedLMsL(Q + 1 + M*iNrOfDatabases); + +// 5. Associate an uncategorized landmark with a category, e.g. lm with id 76 + iLog->Log(_L("<<< 5. Associate an uncategorized landmark with a category >>>")); + id = 76; + database = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); + CleanupStack::PushL(database); + lm = database->ReadLandmarkLC(id); + lm->AddCategoryL(localCatId - 1); // Sjukhus + database->UpdateLandmarkL(*lm); + TInt index = iIdArrays[dbIndex].Find(id); + AssertTrueSecL(index > 0, _L("Unable to find landmark in array")); + iIdArrays[dbIndex].Remove(index); + CleanupStack::PopAndDestroy(2, database); + + // Check that correct number of uncategorized landmarks are found + SearchForUncategorizedLMsL(Q + M*iNrOfDatabases); + +// 6. Remove the global category Hotel, that K LMs belong to, from 2 databases + iLog->Log(_L("<<< 6. Remove the global category Hotel, that K LMs belong to, from 2 databases >>>")); + //const TPosLmGlobalCategory KHotel = 4; + const TPosLmGlobalCategory KAccommodation = 3000; + const TInt K = 2*3; // 2 dbs and three in each have hotel as category + for (TInt dbIndex = 0; dbIndex <= 1; dbIndex++) + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); + CleanupStack::PushL(db); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + TPosLmItemId itemId = catMan->GetGlobalCategoryL(KAccommodation); + RemoveCategoryFromDbL(itemId, (*iDatabases)[dbIndex]); + CleanupStack::PopAndDestroy(2, db); + } + + // Landmarks 3-5 and 23-25 should now be uncategorized. + dbIndex = 0; + for (TInt i = 3; i <= 5; i++) + { + iIdArrays[dbIndex].Append(i); + } + for (TInt i = 23; i <= 25; i++) + { + iIdArrays[dbIndex + 1].Append(i); + } + + // Check that correct number of uncategorized landmarks are found + SearchForUncategorizedLMsL(K + Q + M*iNrOfDatabases); + +// 7. Exclude one database (the last) + iLog->Log(_L("<<< 7. Exclude one database >>>")); + iDatabases->Delete(4); + iNrOfDatabases--; + iLandmarkSearch->SetDatabasesToSearchL(*iDatabases); + SearchForUncategorizedLMsL(K + Q + M*iNrOfDatabases); + +// 8. Test maximum nr of matches + iLog->Log(_L("<<< 8. Test maximum nr of matches >>>")); + const TInt P = 1; + iLandmarkSearch->SetMaxNumOfMatches(P); + SearchForUncategorizedLMsL(P * iNrOfDatabases); + +// 9. Test maximum nr of matches and sort + iLog->Log(_L("<<< 9. Test maximum nr of matches and sort >>>")); + iLandmarkSearch->SetMaxNumOfMatches(2); + SearchForUncategorizedLMsL(2 * iNrOfDatabases, ETrue); + +// 10. Test on-the-fly sorting + iLog->Log(_L("<<< 10. Test on-the-fly sorting >>>")); + iLandmarkSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + + // Create one big array with all expected matches + RIdArray expectedMatches; + CleanupClosePushL(expectedMatches); + for (TInt i = 0; i < iNrOfDatabases; i++) + { + for (TInt j = 0; j < iIdArrays[i].Count(); j++) + { + User::LeaveIfError(expectedMatches.Append(iIdArrays[i][j])); + } + } + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + onTheFlyTester->StartSearchCampaignL(iLandmarkSearch, expectedMatches, catSearchCriteria); + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + iLog->Log(msg); + User::Leave(result); + } + CleanupStack::PopAndDestroy(3, &expectedMatches); + } + +// --------------------------------------------------------- +// CPosTp123::TestSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::TestSearchL( + TBool aExecuteSync, + TSearchCriterion aCriterion, + TInt aNrOfHits, + TBool aSorted) + { + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Specified in header file EPos_CPosLmCategoryCriteria.h says that + // specifying no criteria should return uncategorized landmarks + // SetCategoryItemId(KPosLmNullItemId) should return uncategorized landmarks and that + // SetGlobalCategory(KPosLmNullGlobalCategory) should return uncategorized landmarks and that + // SetCategoryNameL(KNullDesC) should return uncategorized landmarks + switch (aCriterion) + { + case ENoCriterion: + // Do nothing. Default initialized CPosLmCategoryCriteria is fine. + break; + case ELocalCategoryId: + catSearchCriteria->SetCategoryItemId(KPosLmNullItemId); + break; + case EGlobalCategoryId: + catSearchCriteria->SetGlobalCategory(KPosLmNullGlobalCategory); + break; + case ECategoryName: + catSearchCriteria->SetCategoryNameL(KNullDesC); + break; + } + + if (aSorted) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref); + } + else + { + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); + } + + if (aExecuteSync) + { + ExecuteAndDeleteLD(iOperation); + } + else + { + RunAsyncOperationLD(iOperation); + } + + VerifySearchResultL(aNrOfHits, aSorted); + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp123::TestSearchCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::TestSearchCategoriesL(TBool aExecuteSync) + { + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // This method should leave according to EPos_CPosLmCategoryCriteria.h + iOperation = iLandmarkSearch->StartCategorySearchL( + *catSearchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + if (aExecuteSync) + { + ExecuteAndDeleteLD(iOperation); + } + else + { + RunAsyncOperationLD(iOperation); + } + + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp123::RemoveCategoriesFromLandmarksL +// Use this method to remove the category from a specified number of landmarks +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::RemoveCategoriesFromLandmarksL(TInt aNrOfLandmarks) + { + for (TInt i = 0; i < iNrOfDatabases; i++) + { + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); + CleanupStack::PushL(database); + ExecuteAndDeleteLD(database->CompactL()); + CPosLmItemIterator* iter = database->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + TInt counter=0; + + // Remove the categories from aNrOfLandmarks nr of landmarks + while ((id != KPosLmNullItemId) && (counter < aNrOfLandmarks)) + { + CPosLandmark* landmark = database->ReadLandmarkLC(id); + landmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, database->UpdateLandmarkL(*landmark)); + } + CleanupStack::PopAndDestroy(landmark); + User::LeaveIfError(iIdArrays[i].Append(id)); + + id = iter->NextL(); + if (id == KPosLmNullItemId) + { + iLog->Log(_L("KPosLmNullItemId")); + } + counter++; + } + + CleanupStack::PopAndDestroy(2, database); + } + } + +// --------------------------------------------------------- +// CPosTp123::SearchForUncategorizedLMsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::SearchForUncategorizedLMsL(TInt aNrOfHits, TBool aSorted) + { + for (TBool runSynch = EFalse; runSynch < 2; runSynch++) + { + for (TSearchCriterion searchCriterion = ENoCriterion; + searchCriterion <= ECategoryName; + searchCriterion = (TSearchCriterion)((TInt)searchCriterion + 1)) + { + TestSearchL(runSynch, searchCriterion, aNrOfHits, aSorted); + } + } + } + +// --------------------------------------------------------- +// CPosTp123::RemoveCategoryFromDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::RemoveCategoryFromDbL( + TPosLmItemId aCategoryId, + const TDesC& aDbUri) + { + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(aDbUri); + CleanupStack::PushL(database); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(catMan); + + ExecuteAndDeleteLD(catMan->RemoveCategoryL(aCategoryId)); + + CleanupStack::PopAndDestroy(2, database); + } + +// --------------------------------------------------------- +// CPosTp123::VerifySearchResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::VerifySearchResultL( + TInt aNrOfHits, + TBool aSorted) + { + AssertTrueSecL(iLandmarkSearch->NumOfSearchErrors() == 0, _L("Found search errors!")); + + // Verify total number of matches is correct + TInt totNrOfMatches = iLandmarkSearch->TotalNumOfMatches(); + if (totNrOfMatches != aNrOfHits) + { + iBuf.Format(_L("Wrong number of landmarks returned when searching for uncategorized landmarks, found: %d expected %d"), totNrOfMatches, aNrOfHits); + iLog->Log(iBuf); + User::Leave(-1); + } + + + for (TUint i = 0; i < iNrOfDatabases; i++) + { + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); + CleanupStack::PushL(database); + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(i); + CleanupStack::PushL(iter); + + // Verify number of matches in each database is correct + TInt nrInIter = iter->NumOfItemsL(); + AssertTrueSecL(nrInIter == iLandmarkSearch->NumOfMatches(i), _L("wrong number of items returned in a specific iterator!")); + + // Verify that correct landmarks were found + TPosLmItemId id = iter->NextL(); + TInt index = 0; + while (id != KPosLmNullItemId) + { + TInt found = iIdArrays[i].Find(id); + if (found == KErrNotFound) + { + iLog->Log(_L("Not found")); + User::Leave(KErrNotFound); + } + else + { + index++; + CPosLandmark* landmark = database->ReadLandmarkLC(id); + CPosLandmark* landmark2 = database->ReadLandmarkLC(iIdArrays[i][found]); + + CompareLandmarksL(*landmark, *landmark2); + + CleanupStack::PopAndDestroy(landmark2); + CleanupStack::PopAndDestroy(landmark); + } + id = iter->NextL(); + } + + if (index != nrInIter) + { + iLog->Log(_L("The correct landmark was never found")); + User::Leave(-1); + + } + if (aSorted) + { + VerifySortOrderL(iter, database); + } + CleanupStack::PopAndDestroy(2, database); + } + } + +// --------------------------------------------------------- +// CPosTp123::VerifySortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp123::VerifySortOrderL( + CPosLmItemIterator* aIter, + CPosLandmarkDatabase* aDb) + { + RIdArray idArray; + CleanupClosePushL(idArray); + TInt nrOfItems = aIter->NumOfItemsL(); + aIter->GetItemIdsL(idArray, 0, nrOfItems); + + for (TInt i = 0; i < nrOfItems; i++) + { + if (i < nrOfItems - 1) + { + CPosLandmark* lm1 = aDb->ReadLandmarkLC(idArray[i]); + CPosLandmark* lm2 = aDb->ReadLandmarkLC(idArray[i + 1]); + TPtrC name1, name2; + lm1->GetLandmarkName(name1); + lm2->GetLandmarkName(name2); + AssertTrueSecL(name1.CompareC(name2) <= 0, _L("lm1 is greater than lm2 - should not be the case since ascending order is used.")); + CleanupStack::PopAndDestroy(2, lm1); + } + } + CleanupStack::PopAndDestroy(&idArray); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp124.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp124.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1701 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp124.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +#include "FT_CCompositeSearchResult.h" + +#include +#include + +#include +#include +#include + +#include + +// CONSTANTS +_LIT(KLMDB1, "COMPOSITELMDB_1.LDB"); +_LIT(KLMDB2, "COMPOSITELMDB_2.LDB"); +_LIT(KLMDB3, "COMPOSITELMDB_3.LDB"); +_LIT(KLMDB4, "COMPOSITELMDB_4.LDB"); +_LIT(KLMDB5, "COMPOSITELMDB_5.LDB"); +_LIT(KLMDB1Path,"file://C:COMPOSITELMDB_1.LDB"); +_LIT(KLMDB2Path,"file://C:COMPOSITELMDB_2.LDB"); +_LIT(KLMDB3Path,"file://C:COMPOSITELMDB_3.LDB"); +_LIT(KLMDB4Path,"file://C:COMPOSITELMDB_4.LDB"); +_LIT(KLMDB5Path,"file://C:COMPOSITELMDB_5.LDB"); + +//_LIT(KCOMPOSITELMDB, "compositeeposlm.ldb"); + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp124::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase=NULL; + + delete iDatabases; + + if (iMultiDbSearch) iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + + delete iMultiDbSearch; + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("Error when RemoveAllLmDatabasesL")); + } + +// --------------------------------------------------------- +// CPosTp124::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::InitTestL() + { + CLandmarkTestProcedureBase::InitTestL(); + + iLog->Log(_L("InitTestL")); + RemoveAllLmDatabasesL(); + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + // check the count of databases that could not be delted since they were in use + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDbCount = iDatabases->Count(); + + + // PrepareDatabases + PrepareDatabasesL(); + + SetupLimits(); + + + + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDatabases->Sort(); // Not really necessary... + // database count is equal to ones added plus ones not been able to delte since they were in use + TInt dbCount = iDatabases->Count(); + iNrOfDatabases = iDbCount + 5; + + iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + CleanupStack::PopAndDestroy(dbManager); + + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + } + +// --------------------------------------------------------- +// CPosTp124::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::StartL() + { + TTime startTime; + TTime stopTime; + startTime.UniversalTime(); + + MakeSurePanicDebugFileExistsL(); + + iDatabase = UseCompositeLandmarksDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // TC_Part 1 + // ASynchronous, Sort ascending + StartLandmarksCompositeTestL(EAsynchronous, ESortAscending); + // Synchronous, Sort descending + StartLandmarksCompositeTestL(EAsynchronous, ESortDescending); + // ASynchronous, Sort ascending + TestWithSortOrderLandmarksL(EAsynchronous, ESortAscending); + + TestWithSortOrderNearestL(EAsynchronous, ESortAscending); + TestWithSortOrderNearestL(ESynchronous, ESortNone); + TestWithSortOrderNearestL(EAsynchronous, ESortDescending); + TestWithSortOrderNearestL(EAsynchronous, ESortDistance); + + // TC Part 2_3 Test with several text criterias + TestSeveralTextArgumentsL(); + + // TC Part 4-5 Test add and remove from composite object + TestAddAndRemoveL(); + + // TC Part 6 + // Cancel immediately + CancelTestL(EFalse); + + // Cancel in callback + CancelTestL(ETrue); + + // TC Part 7 + TestOnTheFlySearchL(); + + // Since TestOnTheFlySearchL is changing displadata + iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + // TC Part 8-11 + // TestLessDbsToSearchL(); + + // TC Part 12 + // It is not possible to use Composite in a composite object in multi search + TestCompositeInCompositeL(); + + // TC Part 13 + // It is not possible to use IdList in a composite object in multi search + TestWithIdListAndCompositeL(); + + // TC Part 14 + // It is not possible to use CPosLmCatNameCriteria in a composite object in multi search + TestCategoryCompositeSearchL(); + + // TC Part 15 + // Test with no previous result but try to refine search anyway + TestWithNoPreviousResultL(); + + TInt KNrOfObjectsInComposite = 100; + TInt KStartIndex = 90; + CompositeStressTestL(KStartIndex, KNrOfObjectsInComposite); + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + TBuf<100> buf; + buf.Format(_L("TP124 took %d seconds"), resse); + iLog->Log(buf); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP124")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp124::SetupLimits() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp124::SetupLimits() + { + // First db-> Keep landmarks 1-20 + // Second db-> Keep landmarks 21-40 + // Third db-> Keep landmarks 41-60 + // Fourth db-> Keep landmarks 61-80 + // Fifth db-> Keep landmarks 81-105 + + iIdDb1Min = 1; + iIdDb1Max = 20; + + iIdDb2Min = 21; + iIdDb2Max = 40; + + iIdDb3Min = 41; + iIdDb3Max = 60; + + iIdDb4Min = 61; + iIdDb4Max = 80; + + iIdDb5Min = 81; + iIdDb5Max = 105; + } + +// --------------------------------------------------------- +// CPosTp124::ValidateIdL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::ValidateIdL(TPosLmItemId aId, TInt aDbIndex) + { + TBool condition = EFalse; + switch (aDbIndex) + { + case 0: + // Db 1 contains landmarks with id = 1-20 + condition = aId >= iIdDb1Min && aId <= iIdDb1Max; + break; + case 1: + // Db 2 contains landmarks with id = 21-40 + condition = aId >= iIdDb2Min && aId <= iIdDb2Max; + break; + case 2: + // Db 3 contains landmarks with id = 41-60 + condition = aId >= iIdDb3Min && aId <= iIdDb3Max; + break; + case 3: + // Db 4 contains landmarks with id = 61-80 + condition = aId >= iIdDb4Min && aId <= iIdDb4Max; + break; + case 4: + // Db 5 contains landmarks with id = 81-105 + condition = aId >= iIdDb5Min && aId <= iIdDb5Max; + break; + } + + if (!condition) + { + iErrorsFound++; + TBuf<150> buf; + buf.Format(_L("ERROR: Invalid match from database reported, index %d in db %d"), aId, aDbIndex); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp124::PrepareDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::PrepareDatabasesL() + { + iLog->Log(_L("PrepareDatabasesL")); + // Copy eposlmnearestsearch.ldb into five dbs + _LIT(KDbFile, "c:\\system\\test\\testdata\\compositeeposlm.ldb"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + // Create five copies of testdata\\compositeeposlm.ldb + TBuf<100> path; + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB1); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB2); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB3); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB4); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + path.Zero(); + path.Append(KLmDbPath); + path.Append(KLMDB5); + User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(fileMan); + + // Now adjust dbs according to following: + // First db-> Keep landmarks 1-20 + // Second db-> Keep landmarks 21-40 + // Third db-> Keep landmarks 41-60 + // Fourth db-> Keep landmarks 61-80 + // Fifth db-> Keep landmarks 81-105 + + RArray array; + CleanupClosePushL(array); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KLMDB1); + CleanupStack::PushL(lmd); + + TBool debug = EFalse; + TInt index=0; + TInt max=105; + for (index=20;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + User::After(200000); + ExecuteAndDeleteLD(lmd->CompactL()); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB2); + CleanupStack::PushL(lmd); + + for (index=0;index<20;index++) array.Append(index+1); + for (index=40;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + User::After(200000); + ExecuteAndDeleteLD(lmd->CompactL()); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB3); + CleanupStack::PushL(lmd); + + for (index=0;index<40;index++) array.Append(index+1); + for (index=60;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + User::After(200000); + ExecuteAndDeleteLD(lmd->CompactL()); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB4); + CleanupStack::PushL(lmd); + + for (index=0;index<60;index++) array.Append(index+1); + for (index=80;indexIsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + User::After(200000); + ExecuteAndDeleteLD(lmd->CompactL()); + array.Reset(); + if (debug) PrintLm(lmd); + CleanupStack::PopAndDestroy(lmd); + + lmd = CPosLandmarkDatabase::OpenL(KLMDB5); + CleanupStack::PushL(lmd); + + for (index=0;index<80;index++) array.Append(index+1); + if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); + ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); + User::After(200000); + ExecuteAndDeleteLD(lmd->CompactL()); + array.Reset(); + if (debug) PrintLm(lmd); + + CleanupStack::PopAndDestroy(lmd); + + CleanupStack::PopAndDestroy(&array); + iLog->Log(_L("PrepareDatabasesL Done")); + } + +// --------------------------------------------------------- +// CPosTp124::PrintLm +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::PrintLm(CPosLandmarkDatabase* db) + { + CPosLmItemIterator* iter = db->LandmarkIteratorL(); + CleanupStack::PushL(iter); + iLog->Log(_L("PrintLm")); + + TPosLmItemId id = iter->NextL(); + TBuf<100> buf; + + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = db->ReadLandmarkLC(id); + TPtrC name; + lm->GetLandmarkName(name); + iLog->Log(_L("Found LM: ")); + iLog->Log(name); + TInt idde = lm->LandmarkId(); + + id = iter->NextL(); + CleanupStack::PopAndDestroy(lm); + } + + CleanupStack::PopAndDestroy(iter); + iLog->Log(_L("PrintLm Done")); + } + +// --------------------------------------------------------- +// CPosTp124::TestOnTheFlySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestOnTheFlySearchL() + { + iLog->Log(_L("TestOnTheFlySearchL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); + CleanupStack::PushL(res); + + while (!res->GetCompositeSearchResultsL(*composite)) + { + // Check if IdList is included in composite, if so dont + // use this search since IdList is not possible to use in multiple db seach + if (!CheckCompositeForIdListL(composite)) + { + PrintCompositeInfo(composite); + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + TBuf<150> buf; + COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); + onTheFlyTester->StartSearchCampaignL(iMultiDbSearch, res->iResultIds, composite); + + TInt result = onTheFlyTester->Err(); + if (result != KErrNone) + { + TPtrC msg; + onTheFlyTester->GetErrMsg(msg); + iLog->Log(msg); + User::Leave(result); + } + CleanupStack::PopAndDestroy(onTheFlyTester); + } + } + + CleanupStack::PopAndDestroy(res); + CleanupStack::PopAndDestroy(composite); + iLog->Log(_L("TestOnTheFlySearchL Done")); + + } + +// --------------------------------------------------------- +// CPosTp124::TestLessDbsToSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestLessDbsToSearchL() + { + iLog->Log(_L("TestLessDbsToSearchL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + TBuf<100> buf; + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("LO*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // Create search result + RArray searchResults; + CleanupClosePushL(searchResults); + + // Will find: + searchResults.Append(1); + searchResults.Append(2); + searchResults.Append(20); + searchResults.Append(21); + searchResults.Append(22); + searchResults.Append(23); + searchResults.Append(24); + searchResults.Append(26); + searchResults.Append(27); + searchResults.Append(28); + + iLog->Log(_L("Search in all dbs")); + + SearchL(composite, ESynchronous, EFalse, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + // delete the COMPOSITELMDB_1 & COMPOSITELMDB_3 + TInt count = iDatabases->Count(); + for(TInt i =0;iDelete(i); + } + } + // iDatabases->Delete(0); + // iDatabases->Delete(3); + + iNrOfDatabases-=2; + + iIdDb1Min = 21; + iIdDb1Max = 40; + + iIdDb2Min = 41; + iIdDb2Max = 60; + + iIdDb3Min = 81; + iIdDb3Max = 105; + + iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); + + iLog->Log(_L("Search in all dbs but db0 and db3")); + // Remove three first items, found in db0 + searchResults.Remove(0); // id 1 + searchResults.Remove(0); // id 2 + searchResults.Remove(0); // id 20 + SearchL(composite, ESynchronous, EFalse, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + // Open DB last in list and add a new landmark + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KLMDB3); + CleanupStack::PushL(db); + CPosLandmark* lm1 = CPosLandmark::NewLC(); + lm1->SetLandmarkNameL(_L("LOOOPIA Landmark")); + lm1->SetLandmarkDescriptionL(_L("Some Description")); + + iLog->Log(_L("Add new Landmark to db nr 0")); + TPosLmItemId newLmId = db->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + + iLog->Log(_L("Search in all dbs but db0 and db3")); + //Refine search. new landmark should not be included + SearchL(composite, ESynchronous, ETrue, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + CPosLmCategoryCriteria* catSearchCriteria1 = CPosLmCategoryCriteria::NewLC(); + CPosLmCategoryCriteria* catSearchCriteria2 = CPosLmCategoryCriteria::NewLC(); + + catSearchCriteria1->SetCategoryNameL(_L("Stadsbibliotek")); + catSearchCriteria2->SetCategoryNameL(_L("Systembolag")); + + User::LeaveIfError(composite->AddArgument(catSearchCriteria1)); + User::LeaveIfError(composite->AddArgument(catSearchCriteria2)); + CleanupStack::Pop(catSearchCriteria2); + CleanupStack::Pop(catSearchCriteria1); + + iLog->Log(_L("Search in all dbs but db0 and db3")); + //Refine search with more specific composite search object + // new landmark should not be included + + searchResults.Reset(); + searchResults.Append(27); + + SearchL(composite, ESynchronous, ETrue, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + // Remove some criterias from composite and do a new search, + iLog->Log(_L("Search in all dbs but db0 and db3, remove last argument from composite")); + // Remove last added argument + CPosLmSearchCriteria* obj1 = composite->RemoveArgument(composite->NumOfArguments()-1); + delete obj1; + obj1 = NULL; + + //Refine search. new landmark should not be included + SearchL(composite, ESynchronous, ETrue, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + // Remove last added argument + obj1 = composite->RemoveArgument(composite->NumOfArguments()-1); + delete obj1; + obj1 = NULL; + + //Do a new search (not more refined). new landmark should be included + searchResults.Append(newLmId); + iIdDb3Max = newLmId; + searchResults.Reset(); + searchResults.Append(21); + searchResults.Append(22); + searchResults.Append(23); + searchResults.Append(24); + searchResults.Append(26); + searchResults.Append(27); + searchResults.Append(28); + searchResults.Append(newLmId); + iLog->Log(_L("Search in all dbs but db0 and db3, without refined")); + SearchL(composite, ESynchronous, EFalse, ESortNone); + ValidateSearchResultsL(searchResults, ESortNone); + + // Remove the added landmark + db->RemoveLandmarkL(newLmId); + CleanupStack::PopAndDestroy(db); + + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + // Correct limits if more testing after this part + SetupLimits(); + + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + delete iDatabases; + iDatabases = NULL; + iDatabases = dbManager->ListDatabasesLC(); + CleanupStack::Pop(iDatabases); + iDatabases->Sort(); // Not really necessary... + // Remove compositeeposlm.ldb that should not be searched + iNrOfDatabases = iDbCount + 5; + iDatabases->Delete(0); + AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); + + iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + + delete iMultiDbSearch; + iMultiDbSearch = NULL; + + iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + CleanupStack::PopAndDestroy(dbManager); + + } + +// --------------------------------------------------------- +// CPosTp124::TestWithSortOrderNearestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestWithSortOrderNearestL(TExecutionMode aExecutionMode, + TTp124SortOrder aSortOrder) + { + iLog->Log(_L("TestWithSortOrderNearestL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // Then create a nearest criteria same coordinate as landmark itemid=31 Text1 + TCoordinate coord(45.5, 0.5); + iCoord = coord; + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, ETrue); + nearestCriteria->SetMaxDistance(80000); + + + User::LeaveIfError(composite->AddArgument(nearestCriteria)); + CleanupStack::Pop(nearestCriteria); + + // Create search result + RArray searchResults; + CleanupClosePushL(searchResults); + + // Will find Unique, Text'1 and Text1 + searchResults.Append(29); + searchResults.Append(31); + searchResults.Append(30); + + iLog->Log(_L("Innan search")); + SearchL(composite, aExecutionMode, EFalse, aSortOrder); + iLog->Log(_L("Innan validate")); + ValidateSearchResultsL(searchResults, aSortOrder); + + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + } + +// --------------------------------------------------------- +// CPosTp124::CheckCompositeForIdListL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp124::CheckCompositeForIdListL(CPosLmCompositeCriteria* aComposite) + { + iLog->Log(_L("CheckCompositeForIdListL")); + TBool res = EFalse; + for (TUint i=0;iNumOfArguments();i++) + { + CPosLmSearchCriteria& comp = aComposite->Argument(i); + TInt type = comp.CriteriaType(); + if (type == CPosLmSearchCriteria::ECriteriaIdList) + { + res = ETrue; + } + } + return res; + } + +// --------------------------------------------------------- +// CPosTp124::StartLandmarksCompositeTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::StartLandmarksCompositeTestL(TExecutionMode aExecutionMode, + TTp124SortOrder aSortOrder) + { + iLog->Log(_L("StartLandmarksCompositeTestL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); + CleanupStack::PushL(res); + + + + while (!res->GetCompositeSearchResultsL(*composite)) + { + // Check if IdList is included in composite, if so dont + // use this search since IdList is not possible to use in multiple db seach + if (!CheckCompositeForIdListL(composite)) + { + PrintCompositeInfo(composite); + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + SearchL(composite, aExecutionMode, res->Redefined(), aSortOrder); + ValidateSearchResultsL(res->iResultIds, aSortOrder); + } + } + + CleanupStack::PopAndDestroy(res); + CleanupStack::PopAndDestroy(composite); + iLog->Log(_L("StartLandmarksCompositeTestL Done")); + } + +// --------------------------------------------------------- +// CPosTp124::TestWithSortOrderLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestWithSortOrderLandmarksL(TExecutionMode aExecutionMode, + TTp124SortOrder aSortOrder) + { + iLog->Log(_L("TestWithSortOrderLandmarksL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + TInt i=0; + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // Then create a nearest criteria + TCoordinate coord(12.123, -20,123); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, EFalse); + User::LeaveIfError(composite->AddArgument(nearestCriteria)); + CleanupStack::Pop(nearestCriteria); + + // Create search result of all landmark ids: 1-105 + RArray searchResults; + CleanupClosePushL(searchResults); + for (i=1;i<106;i++) {searchResults.Append(i);} + + SearchL(composite, aExecutionMode, EFalse, aSortOrder); + ValidateSearchResultsL(searchResults, aSortOrder); + + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + + } + +// --------------------------------------------------------- +// CPosTp124::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::SearchL( + CPosLmCompositeCriteria* aCompositeSearchCriteria, + TExecutionMode aExecutionMode, + TBool aRefinedSearch, + TTp124SortOrder aSortOrder) + { + switch (aSortOrder) + { + case ESortNone: + { + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, aRefinedSearch); + break; + } + case ESortAscending: + { + TPosLmSortPref ascending(CPosLandmark::ELandmarkName); + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, ascending, aRefinedSearch); + break; + } + case ESortDescending: + { + TPosLmSortPref descending(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, descending, aRefinedSearch); + break; + } + case ESortDistance: + { + iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, aRefinedSearch); + break; + } + default: + { + User::Leave(KErrArgument); + break; + } + } + + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + default: + User::Leave(KErrArgument); + break; + } + } + +// --------------------------------------------------------- +// CPosTp124::TestSeveralTextArgumentsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestSeveralTextArgumentsL() + { + iLog->Log(_L("TestSeveralTextArgumentsL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // >>>>>>> Test different text criterias <<<<<<<<<< + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Nokia*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("*Stockholm")); + err = composite->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + + // Should find landmark id: 63 name: "Nokia, Stockholm" + iLog->Log(_L("iMultiDbSearch->StartLandmarkSearchL")); + RIdArray expectedIds; + CleanupClosePushL(expectedIds); + User::LeaveIfError(expectedIds.Append(63)); + + SearchL(composite, EAsynchronous, EFalse, ESortAscending); + ValidateSearchResultsL(expectedIds, ESortAscending); + composite->ClearArguments(); + + // >>>>>>> Test same text as criterias in composite <<<<<<< + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Text9")); + err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // First create a textcriteria + textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("Text9")); + err = composite->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + expectedIds.Reset(); + // Should find landmark id: 39 name: Text9 + iLog->Log(_L("iMultiDbSearch->StartLandmarkSearchL")); + User::LeaveIfError(expectedIds.Append(39)); + + SearchL(composite, EAsynchronous, EFalse, ESortDescending); + ValidateSearchResultsL(expectedIds, ESortDescending); + + CleanupStack::PopAndDestroy(&expectedIds); + CleanupStack::PopAndDestroy(composite); + iDisplayData->Reset(); + } + +// --------------------------------------------------------- +// CPosTp124::TestAddAndRemoveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestAddAndRemoveL() + { + iLog->Log(_L("TestAddAndRemoveL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // Add a text criteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("PELLE")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // Test that ClearArguments is correct + composite->ClearArguments(); + + if (composite->NumOfArguments() != 0) + { + iLog->Log(_L("Wrong number of arguments")); + User::Leave(-1); + } + + // 1) Add a text criteria + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // 2) Add a text criteria + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Natur*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // 3) Add an area criteria + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-12.23, 34.4, -2.05, 45.5); + User::LeaveIfError(composite->AddArgument(areaCriteria)); + CleanupStack::Pop(areaCriteria); + + // 4) Add a category criteria + CPosLmCategoryCriteria* catCriteria = CPosLmCategoryCriteria::NewLC(); + catCriteria->SetCategoryNameL(_L("Museum")); + User::LeaveIfError(composite->AddArgument(catCriteria)); + CleanupStack::Pop(catCriteria); + + // 5) Add a nearest criteria + TCoordinate cord(12.23, 12); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(cord, ETrue); + User::LeaveIfError(composite->AddArgument(nearestCriteria)); + CleanupStack::Pop(nearestCriteria); + + if (composite->NumOfArguments() != 5) + { + iLog->Log(_L("Wrong number of arguments")); + User::Leave(-1); + } + + // Remove (3) area criteria + CPosLmSearchCriteria* obj1 = composite->RemoveArgument(2); + delete obj1;obj1 = NULL; + + // Remove (5) nearest criteria (after 3 removed it has id 4) + CPosLmSearchCriteria* obj2 = composite->RemoveArgument(3); + delete obj2;obj2 = NULL; + + RIdArray expectedIds; + CleanupClosePushL(expectedIds); + + // Should find landmark with id: 87 name: "Naturhistoriska" + User::LeaveIfError(expectedIds.Append(87)); + SearchL(composite, EAsynchronous, EFalse, ESortAscending); + ValidateSearchResultsL(expectedIds, ESortAscending); + + // Remove (1) first text criteria + CPosLmSearchCriteria* obj4 = composite->RemoveArgument(0); + delete obj4; obj4 = NULL; + + // Remove (2) the second text criteria + CPosLmSearchCriteria* obj3 = composite->RemoveArgument(0); + delete obj3; obj3 = NULL; + + expectedIds.Reset(); + // Should find six landmarks belonging to category "museum", + User::LeaveIfError(expectedIds.Append(22)); + User::LeaveIfError(expectedIds.Append(84)); + User::LeaveIfError(expectedIds.Append(85)); + User::LeaveIfError(expectedIds.Append(86)); + User::LeaveIfError(expectedIds.Append(87)); + User::LeaveIfError(expectedIds.Append(89)); + + SearchL(composite, EAsynchronous, EFalse, ESortNone); + ValidateSearchResultsL(expectedIds, ESortNone); + + CleanupStack::PopAndDestroy(&expectedIds); + CleanupStack::PopAndDestroy(composite); + + iLog->Log(_L("TestAddAndRemoveL Done")); + } + +// --------------------------------------------------------- +// CPosTp124::ValidateSearchResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::ValidateSearchResultsL( + RIdArray& aExpectedIds, TTp124SortOrder aSortOrder, + TInt aNrOfExpectedErrors) + { + iLog->Log(_L("ValidateSearchResultsL")); + + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); + _LIT(KNotFoundErr2, "Id %d not found in search result from displaydata"); + _LIT(KNrOfMatchError, "Nr of matches from DisplayData is not correct"); + _LIT(KNrOfMatchError2, "Expected matches is not correct"); + + TBuf<100> buf; + + TInt nrOfMatches = 0; + // list of databases to search in + CDesCArray* dbList = new (ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(dbList); + dbList->AppendL(KLMDB1); + dbList->AppendL(KLMDB2); + dbList->AppendL(KLMDB3); + dbList->AppendL(KLMDB4); + dbList->AppendL(KLMDB5); + TInt dbListCount = dbList->Count(); + for (TInt j = 0; j < dbListCount; j++) + { + // CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[j]); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*dbList)[j]); + CleanupStack::PushL(db); + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + + nrOfMatches += iter->NumOfItemsL(); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + buf.Format(_L("Found idde %d in db %d"), id, j); + //iLog->Log(buf); + ValidateIdL(id, j); + AssertTrueSecL(aExpectedIds.Find(id) != KErrNotFound, KNotFoundErr, id); + + CPosLandmark* lm1 = db->ReadLandmarkLC(id); + id = iter->NextL(); + // Check sort order in every iterator + if (aSortOrder != ESortNone && aSortOrder != ESortDistance && id != KPosLmNullItemId) + { + CPosLandmark* lm2 = db->ReadLandmarkLC(id); + TPtrC name1, name2; + lm1->GetLandmarkName(name1); + lm2->GetLandmarkName(name2); + + if (aSortOrder == ESortAscending) + { + AssertTrueSecL(name1.CompareC(name2) <= 0, _L("Not sorted ascending as expected")); + } + else if (aSortOrder == ESortDescending) + { + AssertTrueSecL(name1.CompareC(name2) >= 0, _L("Not sorted descending as expected")); + } + CleanupStack::PopAndDestroy(lm2); + } + CleanupStack::PopAndDestroy(lm1); + } + + // Now check that iterator is sorted on distance + if (aSortOrder == ESortDistance) + { + iter->Reset(); + RArray result; + CleanupClosePushL(result); + + if (iter->NumOfItemsL() > 0) + { + iter->GetItemIdsL(result,0, iter->NumOfItemsL()); + LandmarksSortL(result, aSortOrder); + TPosLmItemId idde = iter->NextL(); + TInt index=0; + while (idde != KPosLmNullItemId) + { + iLog->Log(_L("##### Check iterator sorted on distance")); + AssertTrueSecL(idde == result[index], _L("Iterator is not sorted on distance")); + index++; + idde = iter->NextL(); + } + } + CleanupStack::PopAndDestroy(&result); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(db); + } + + AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators")); + AssertTrueSecL(NrOfSearchErrors(iMultiDbSearch) == aNrOfExpectedErrors, _L("Found search errors!")); + AssertTrueSecL(nrOfMatches == iDisplayData->Count(), KNrOfMatchError); + AssertTrueSecL(aExpectedIds.Count() == iDisplayData->Count(), KNrOfMatchError2); + + TInt itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item1 = iDisplayData->DisplayItem(itemId); + TInt lmId = item1.Landmark().LandmarkId(); + TPtrC name1; + item1.Landmark().GetLandmarkName(name1); + TInt dbIndex = item1.DatabaseIndex(); + // Validate lm from correct db + ValidateIdL(lmId, dbIndex); + + buf.Format(_L("LM id: %d"), lmId); + //iLog->Log(buf); + AssertTrueSecL(aExpectedIds.Find(lmId) != KErrNotFound, KNotFoundErr2, lmId); + itemId = iDisplayData->NewItemIndex(); + if (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item2 = iDisplayData->DisplayItem(itemId); + lmId = item2.Landmark().LandmarkId(); + TPtrC name2; + lmId = item2.Landmark().LandmarkId(); + dbIndex = item2.DatabaseIndex(); + // Validate lm from correct db + ValidateIdL(lmId, dbIndex); + + item2.Landmark().GetLandmarkName(name2); + AssertTrueSecL(aExpectedIds.Find(lmId) != KErrNotFound, KNotFoundErr2, lmId); + + // Check sort order for display data items + if (aSortOrder == ESortAscending) + { + AssertTrueSecL(name1.CompareC(name2) <= 0, _L("Not sorted ascending as expected")); + } + else if (aSortOrder == ESortDescending) + { + AssertTrueSecL(name1.CompareC(name2) >= 0, _L("Not sorted descending as expected")); + } + } + } + + if (aSortOrder == ESortDistance) + { + iLog->Log(_L("##### Check sorted on distance")); + LandmarksSortL(aExpectedIds, aSortOrder); + for (TInt i=0;iDisplayItem(i); + TInt lmId = item1.Landmark().LandmarkId(); + if (aExpectedIds[i] != lmId) + { + buf.Format(_L("Incorrect distance sorting Id1 %d Id2 %d"),aExpectedIds[i], lmId ); + //iLog->Log(buf); + iLog->Log(buf); + User::Leave(-1); + } + } + } + CleanupStack::PopAndDestroy(dbList); + } + +// --------------------------------------------------------- +// CPosTp124::NrOfSearchErrors +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp124::NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher) + { + TInt nrOfSearchErrors = aMultiDbSearcher->NumOfSearchErrors(); + if (nrOfSearchErrors != 0) + { + for (TInt i = 0; i < nrOfSearchErrors; i++) + { + CPosLmMultiDbSearch::TSearchError error; + aMultiDbSearcher->GetSearchError(i, error); + TBuf<100> msg; + msg.Format(_L("Found error %d in database %d"), error.iErrorCode, error.iDatabaseIndex); + iLog->Log(msg); + } + } + return nrOfSearchErrors; + } + +// --------------------------------------------------------- +// Tp124InternalLandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt Tp124InternalLandmarksSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) + { + // NOTE: Always sorted on distance to TCoordinate iCoord(45.5, 0.5); + TLocality loc1; + TLocality loc2; + + aSource.GetPosition(loc1); + aTarget.GetPosition(loc2); + TReal32 distance1, distance2; + // Not nice, ugly hardcoded + TCoordinate iCoord(45.5, 0.5); + loc1.Distance(iCoord, distance1); + loc2.Distance(iCoord, distance2); + + iCoord.Distance(loc1, distance1); + iCoord.Distance(loc2, distance2); + + TInt res = distance1-distance2; + + return res; + } + +// --------------------------------------------------------- +// CPosTp124::LandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::LandmarksSortL(RArray& aArray, TTp124SortOrder aSortOrder) + { + iLog->Log(_L("LandmarksSortL")); + + RPointerArray landmarks; + CleanupClosePushL(landmarks); + + for (TInt i=0; iReadLandmarkLC(aArray[i]); + landmarks.Append(lm); + CleanupStack::Pop(lm); + } + + // Sort on distance, possible to add a ascending and descending sort here as well + // if needed + TLinearOrder order(Tp124InternalLandmarksSortL); + landmarks.Sort(order); + aArray.Reset(); + if (aSortOrder == ESortDistance) + { + for (TInt j=0; jLandmarkId()); + } + } + + + landmarks.ResetAndDestroy(); + CleanupStack::PopAndDestroy(&landmarks); + } + +// --------------------------------------------------------- +// CPosTp124::CancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::CancelTestL(const TBool& aCancelInCallback) + { + iLog->Log(_L("CancelTestL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); + CleanupStack::PushL(res); + + // Get first composite search from lmDbCompositeSearchResult.txt + res->GetCompositeSearchResultsL(*composite); + + // Cancel in callback, cancel in every progress step phase + // when progress has increased with 0.09 + if (aCancelInCallback) + { + iLog->Log(_L("Cancel in Callback")); + TReal32 progress(0); + while (progress < 1.0) + { + RunAsyncOperationAndCancelInCallbackLD( + iMultiDbSearch->StartLandmarkSearchL( + *composite, + EFalse), + progress); + + TInt nrOfMatches = 0; + for (TInt j = 0; j < iNrOfDatabases; j++) + { + CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); + CleanupStack::PushL(iter); + nrOfMatches += iter->NumOfItemsL(); + CleanupStack::PopAndDestroy(iter); + } + AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators when cancelling")); + //AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); + + progress = progress + 0.09; + } + } + else + { + // Cancel immediately + iLog->Log(_L("Cancel immediately")); + RunAsyncOperationAndCancelLD( + iMultiDbSearch->StartLandmarkSearchL( + *composite, + EFalse)); + + AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); + } + + if (iMultiDbSearch->NumOfSearchErrors() != 0) iLog->Log(_L("Errors after search")); + for (TInt i=0;iNumOfSearchErrors(); i++) + { + CPosLmMultiDbSearch::TSearchError searchErr; + iMultiDbSearch->GetSearchError(i, searchErr); + TBuf<150> buf; + buf.Format(_L("ErrorCode %d returned from db nr %d"),searchErr.iErrorCode, searchErr.iDatabaseIndex); + iLog->Log(buf); + } + + CleanupStack::PopAndDestroy(res); + CleanupStack::PopAndDestroy(composite); + } + +// --------------------------------------------------------- +// CPosTp124::CompositeStressTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::CompositeStressTestL(TInt aStartNr, TInt aTotalNr) + { + iLog->Log(_L("CompositeStressTestL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + TInt i=0; + + for (i=0;iSetTextL(_L("*")); + + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + if (i>aStartNr) + { + SearchL(composite, EAsynchronous, EFalse, ESortAscending); + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches"), iDisplayData->Count()); + iLog->Log(buf); + } + } + + TInt antal = composite->NumOfArguments(); + if (antal != aTotalNr) iLog->Log(_L("nr of composite arguments is incorrect")); + + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches"), iDisplayData->Count()); + iLog->Log(buf); + + TInt itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item1 = iDisplayData->DisplayItem(itemId); + TInt lmId = item1.Landmark().LandmarkId(); + TPtrC name1; + item1.Landmark().GetLandmarkName(name1); + TInt dbIndex = item1.DatabaseIndex(); + // Validate lm from correct db + ValidateIdL(lmId, dbIndex); + buf.Format(_L("LM id: %d from DB %d"), lmId, dbIndex); + iLog->Log(buf); + itemId = iDisplayData->NewItemIndex(); + } + + // 105 is the total number of landmarks in the five dbs + if (iDisplayData->Count() != 105) + { + iLog->Log(_L("Wrong number of matches found")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(composite); + } + +// --------------------------------------------------------- +// CPosTp124::TestWithNoPreviousResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestWithNoPreviousResultL() + { + iLog->Log(_L("TestWithNoPreviousResultL")); + + if (iMultiDbSearch) iMultiDbSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + delete iMultiDbSearch; + iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); + + iDisplayData = CPosLmDisplayData::NewL(); + iMultiDbSearch->SetDisplayData(*iDisplayData); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // No previous result-> should leave with KErrArgument + TRAPD(err, SearchL(composite, EAsynchronous, ETrue, ESortAscending)); + if (err != KErrArgument) + { + iLog->Log(_L("It should not be possible to search when no previous result has been retrieved")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(composite); + } + +// --------------------------------------------------------- +// CPosTp124::TestWithIdListAndCompositeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestWithIdListAndCompositeL() + { + iLog->Log(_L("TestWithIdListAndCompositeL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Nokia*")); + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + // Then create an IdList + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + RIdArray ids; + CleanupClosePushL(ids); + User::LeaveIfError(ids.Append(63)); + User::LeaveIfError(ids.Append(33)); + idList->SetLandmarkIdsL(ids); + CleanupStack::PopAndDestroy(&ids); + + User::LeaveIfError(composite->AddArgument(idList)); + CleanupStack::Pop(idList); + + // It is not possible to use IdList in combination with composite in multiple db search + TRAPD(err, SearchL(composite, EAsynchronous, EFalse, ESortAscending)); + if (err != KErrArgument) + { + iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); + User::Leave(err); + + } + + CleanupStack::PopAndDestroy(composite); + iDisplayData->Reset(); + } + +// --------------------------------------------------------- +// CPosTp124::TestCategoryCompositeSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestCategoryCompositeSearchL() + { + iLog->Log(_L("TestCategoryCompositeSearchL")); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // It should not be possible to add a CPosLmCatNameCriteria to composite + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + TInt err = composite->AddArgument(nameCriteria); + if (err != KErrNotSupported) + { + iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(nameCriteria); + + // Test once more + CPosLmCatNameCriteria* nameCriteria2 = CPosLmCatNameCriteria::NewLC(); + nameCriteria2->SetSearchPatternL(_L("*kontor")); + err = composite->AddArgument(nameCriteria2); + if (err != KErrNotSupported) + { + iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(nameCriteria2); + + CleanupStack::PopAndDestroy(composite); + } + +// --------------------------------------------------------- +// CPosTp124::TestCompositeInCompositeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::TestCompositeInCompositeL() + { + iLog->Log(_L("TestCompositeInCompositeL")); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(_L("*")); + + User::LeaveIfError(composite->AddArgument(textCriteria)); + CleanupStack::Pop(textCriteria); + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-48, 5, -5, 20); + + User::LeaveIfError(composite->AddArgument(areaCriteria)); + CleanupStack::Pop(areaCriteria); + + //Create composite object that should be used as argument to the first composite object + CPosLmCompositeCriteria* composite2 = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("TE,*")); + + User::LeaveIfError(composite2->AddArgument(textCriteria2)); + CleanupStack::Pop(textCriteria2); + + //User::LeaveIfError(composite->AddArgument(composite2)); + TInt res = composite->AddArgument(composite2); + if (res != KErrNotSupported) + { + iLog->Log(_L("It should not be possible to add to a composite ")); + User::Leave(-1); + + } + + CleanupStack::PopAndDestroy(composite2); + + + CleanupStack::PopAndDestroy(composite); + + iLog->Log(_L("TestCompositeInCompositeL Done")); + + } + +// --------------------------------------------------------- +// CPosTp124::PrintCompositeInfo +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp124::PrintCompositeInfo(CPosLmCompositeCriteria* aComposite) + { + TBuf<100> buf; + buf.Format(_L("PrintCompositeInfo() NrOfArg %d"), aComposite->NumOfArguments()); + iLog->Log(buf); + + for (TUint i=0;iNumOfArguments();i++) + { + + CPosLmSearchCriteria& comp = aComposite->Argument(i); + TInt type = comp.CriteriaType(); + + if (type == CPosLmSearchCriteria::ECriteriaArea) + { + iLog->Log(_L("Arg Area found")); + + CPosLmAreaCriteria& tt = static_cast(comp); + + TReal64 southLat; + TReal64 northLat; + TReal64 westLong; + TReal64 eastLong; + + tt.GetSearchArea(southLat, northLat, westLong, eastLong); + + buf.Format(_L("SouthL %f NorthL: %f WestL :%f EastL: %f"), (TReal)southLat, (TReal)northLat, (TReal)westLong, (TReal)eastLong); + iLog->Log(buf); + + } + else if (type == CPosLmSearchCriteria::ECriteriaText) + { + iLog->Log(_L("Arg Text found:")); + CPosLmTextCriteria& tt = static_cast(comp); + iLog->Log(tt.Text()); + } + else if (type == CPosLmSearchCriteria::ECriteriaComposite) + { + iLog->Log(_L("Arg Composite found")); + } + else if (type == CPosLmSearchCriteria::ECriteriaCategory) + { + iLog->Log(_L("Arg Category found")); + + CPosLmCategoryCriteria& tt = static_cast(comp); + iLog->Log(tt.CategoryName()); + } + else if (type == CPosLmSearchCriteria::ECriteriaFindNearest) + { + CPosLmNearestCriteria& tt = static_cast(comp); + TCoordinate cord; + tt.GetCoordinate(cord); + iLog->Log(_L("Arg Nearest found")); + buf.Format(_L("Latitude %f Longitude: %f MaxDist:%f"), (TReal)cord.Latitude(), (TReal)cord.Longitude(), (TReal)tt.MaxDistance()); + iLog->Log(buf); + } + else if (type == CPosLmSearchCriteria::ECriteriaIdList) + { + iLog->Log(_L("Arg Idlist found")); + CPosLmIdListCriteria& tt = static_cast(comp); + + RArray result; + CleanupClosePushL(result); + tt.GetLandmarkIdsL(result); + + buf.Format(_L("Nr of Ids: %d"), result.Count()); + iLog->Log(buf); + + for (TInt i=0;iLog(_L("Arg Categorybyname found")); + } + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp125.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp125.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1453 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp125.h" +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS + + _LIT(KPizzeria, "Pizzeria"); // Db 1, id 1 + _LIT(KHambergerbar, "Hamburgerbar"); // Db 1, id 2 + _LIT(KKinarestaurang, "Kinarestaurang"); // Db 1, id 3 + _LIT(KGaraget, "Garaget"); // Db 1, id 4 + _LIT(KBilverkstad, "Bilverkstad"); // Db 1, id 5 + _LIT(KPastaRestaurang, "Pasta Restaurang"); // Db 2, id 6 + _LIT(KBilia, "Bilia"); // Db 2, id 7 + _LIT(KVolksWagen, "VolksWagen"); // Db 2, id 8 + _LIT(KTaxiGoteborg, "Taxi Göteborg"); // Db 2, id 9 + _LIT(KTaxi, "Taxi"); // Db 2, id 10 + _LIT(KStadsbibliotek, "Stadsbibliotek"); // Db 2, id 11 + _LIT(KSystembolag, "Systembolag"); // Db 2, id 12 + _LIT(KNokiKontor, "Nokia Kontor"); // Db 2, id 13 + _LIT(KTietoEnatorKontor, "TietoEnator kontor"); // Db 2, id 14 + _LIT(KThaiRestaurang, "Thai Restaurang"); // Db 3, id 15 + _LIT(KMcDonalds, "McDonalds"); // Db 3, id 16 + _LIT(KBurgerKing, "BurgerKing"); // Db 3, id 17 + _LIT(KFrisor, "Frisör"); // Db 3, id 18 + _LIT(KHunddagis, "Hunddagis"); // Db 3, id 19 + _LIT(KVeterinar, "Veterinär"); // Db 3, id 20 + _LIT(KKyrkogard, "Kyrkogård"); // Db 4, id 21 + _LIT(KMuseum, "Museum"); // Db 4, id 22 + _LIT(KDagis, "Dagis"); // Db 4, id 23 + _LIT(KStadspark, "StadsPark"); // Db 4, id 24 + _LIT(KSjukhus, "Sjukhus"); // Db 5, id 25 + _LIT(KLakare, "Läkare"); // Db 5, id 26 + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp125::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iLandmarksMultiDbSearch; + iLandmarksMultiDbSearch = NULL; + + delete iDatabase; + iDatabase=NULL; + + iCategorySearchResults.ResetAndDestroy(); + + TRAPD(err, RemoveGlobalCategoriesL()); + TBuf<50> buf; + if (err != KErrNone) + { + buf.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log(buf); + } + } + +// --------------------------------------------------------- +// CPosTp125::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::StartL() + { + + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + SetupDbArrayL(); + + _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); + CDesCArray* dbList = new (ELeave) CDesCArrayFlat(8); + + CleanupStack::PushL(dbList); + + dbList->AppendL(KDb20); + dbList->AppendL(KDb40); + dbList->AppendL(KDb60); + dbList->AppendL(KDb80); + dbList->AppendL(KDb105); + + RemoveExtraCategoriesL(); + + iLandmarksMultiDbSearch = CPosLmMultiDbSearch::NewL(*dbList); + + TInt err = KErrNone; + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + // Start by testing some error flows, returning KErrArgument + TRAP(err, iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + + // Test empty string + nameCriteria->SetSearchPatternL(_L("")); + TRAP(err, iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + CleanupStack::PopAndDestroy(nameCriteria); + + AppendCategorySearchResultsL(); + +// Search synchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt syncronously")); + SearchL(iCategorySearchResults, ESynchronous); + + iLog->Log(_L("Testing search with sort order")); + SearchWithSortOrderL(iCategorySearchResults, ESynchronous); + + + iLog->Log(_L("Testing search with maximum nr of matches")); + SearchWithMaximumL(iCategorySearchResults, ESynchronous); + + +// Search asynchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asyncronously")); + SearchL(iCategorySearchResults, EAsynchronous); + + iLog->Log(_L("Testing search with sort order asynchronously")); + SearchWithSortOrderL(iCategorySearchResults, EAsynchronous); + + iLog->Log(_L("Testing search with maximum nr of matches asynchronously")); + SearchWithMaximumL(iCategorySearchResults, EAsynchronous); + +// Search for added categories + iLog->Log(_L("Testing search after category has been added")); + SearchAfterAddedCategoryL(); + +// Cancel search test + iLog->Log(_L("Testing category search and cancel")); + SearchAndCancelL(); + + iLog->Log(_L("Testing category search and cancel in callback")); + SearchAndCancelL(ETrue); + + delete iDatabase; + iDatabase = NULL; + delete iLandmarksMultiDbSearch; + iLandmarksMultiDbSearch = NULL; + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + dbMan->SetDefaultDatabaseUriL(KDb20); + + iDatabase = CPosLandmarkDatabase::OpenL(); + iLandmarksMultiDbSearch = CPosLmMultiDbSearch::NewL(*dbList); + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->InitializeL()); + CleanupStack::PushL(categoryManager); + + CleanupStack::PopAndDestroy(categoryManager); + + iLog->Log(_L("Testing search with global categories included, sync")); + SearchGlobalL(iCategorySearchResults, ETrue); + + iLog->Log(_L("Testing search with global categories included, asyncronously")); + SearchGlobalL(iCategorySearchResults, EFalse); + + // Test to add the global categories to one more DB + delete iDatabase; + iDatabase = NULL; + delete iLandmarksMultiDbSearch; + iLandmarksMultiDbSearch = NULL; + dbMan->SetDefaultDatabaseUriL(KDb40); + CleanupStack::PopAndDestroy(dbMan); + + iDatabase = CPosLandmarkDatabase::OpenL(); + iLandmarksMultiDbSearch = CPosLmMultiDbSearch::NewL(*dbList); + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager2 = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->InitializeL()); + CleanupStack::PushL(categoryManager2); + CleanupStack::PopAndDestroy(categoryManager2); + + iLog->Log(_L("Testing search with duplicate global categories included, sync")); + TestDuplicateGlobalCategoriesL(iCategorySearchResults, ETrue); + + iLog->Log(_L("Testing search with duplicate global categories included, async")); + TestDuplicateGlobalCategoriesL(iCategorySearchResults, EFalse); + + RemoveGlobalCategoriesL(); + CleanupStack::PopAndDestroy(dbList); + + } + +// --------------------------------------------------------- +// CPosTp125::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + for(TInt i=0; iSetSearchPatternL(aSearchResults[i]->TextCriteria()); + + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + } + + + TInt matchesSum = 0; + for (TInt count = 0; count < 5; count++) + { + matchesSum += iLandmarksMultiDbSearch->NumOfMatches(count); + } + + + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + // Test the display data: + TInt displayCount = displayData->Count(); + + if (displayCount != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + + } + + TInt count = 0; + TInt dbIndex = 0; + TInt categoryId = 0; + TPtrC categoryName; + TBuf<100> categoryName2; + _LIT(KErrCatMismatch, "Category wrong in display data"); + _LIT(KErrorWrongType, "Display data doesn't indicate ECategoryItem when it should."); + + for (count = 0; count < displayCount; count++) + { + CPosLmDisplayItem& displayItem = displayData->DisplayItem(count); + + // Check that the item indicates that it contains a category + AssertTrueSecL(displayItem.DisplayItemType() == CPosLmDisplayItem::ECategoryItem, KErrorWrongType); + const CPosLandmarkCategory& displayCategory = displayItem.Category(); + dbIndex = displayItem.DatabaseIndex(); + categoryId = displayCategory.CategoryId(); + + // Check that the db index is correct + AssertThatIdIsInCorrectDbL(dbIndex, categoryId); + + // Check that this match is correct + AssertTrueSecL(aSearchResults[i]->FindSearchResult(categoryId), KNotFoundErr, categoryId); + displayCategory.GetCategoryName(categoryName); + categoryName2 = (*iDbArray)[categoryId - 1]; // Compensate for 0-index + + // Check that the category name is correct + AssertTrueSecL(categoryName == categoryName2, KErrCatMismatch); + } + + + CPosLmItemIterator* iter = NULL; + + for (count = 0; count < 5; count++) + { + iter = iLandmarksMultiDbSearch->MatchIteratorL(count); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + AssertThatIdIsInCorrectDbL(count, id); + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr, id); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + iter = NULL; + } + + CleanupStack::PopAndDestroy(nameCriteria); + } + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + +// --------------------------------------------------------- +// CPosTp125::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchWithSortOrderL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KErrorInSorting, "Error in sorting"); + + CPosLmCategoryManager::TCategorySortPref sortPref; + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + for (TInt j=0;j<2;j++) + { + for(TInt i=0; iSetSearchPatternL(aSearchResults[i]->TextCriteria()); + + if (j==0) + { + sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, sortPref); + } + else + { + sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, sortPref); + } + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + } + + TInt matchesSum = 0; + for (TInt count = 0; count < 5; count++) + { + matchesSum += iLandmarksMultiDbSearch->NumOfMatches(count); + } + + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt displayCount = displayData->Count(); + + if (displayCount != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + // Test the display data: + // Create a sorted list out of the search result + RArray searchResults = aSearchResults[i]->SearchResult(); + // To avoid User-44 create a copy of the aSearchResults[i] + RArray searchResultsSorted; + CleanupClosePushL(searchResultsSorted); + + for (TInt kk=0;kk categoryName2; + TBuf<100> categoryName3; + + for (count = 0; count < displayCount; count++) + { + CPosLmDisplayItem& displayItem = displayData->DisplayItem(count); + const CPosLandmarkCategory& displayCategory = displayItem.Category(); + categoryId = displayCategory.CategoryId(); + categoryName2 = (*iDbArray)[categoryId - 1]; // Compensate for 0-index + categoryName3 = (*sortedArray)[count]; + // Check that sort order is correct + AssertTrueSecL(categoryName3 == categoryName2, _L("Error in sorting")); + } + + CleanupStack::PopAndDestroy(sortedArray); + + typedef RArray myArrayType; + RArray resultArray; + myArrayType array1; + myArrayType array2; + myArrayType array3; + myArrayType array4; + myArrayType array5; + + CleanupClosePushL(resultArray); + CleanupClosePushL(array1); + CleanupClosePushL(array2); + CleanupClosePushL(array3); + CleanupClosePushL(array4); + CleanupClosePushL(array5); + + if (sortPref == CPosLmCategoryManager::ECategorySortOrderNameAscending) + { + array1.AppendL(5); + array1.AppendL(4); + array1.AppendL(2); + array1.AppendL(3); + array1.AppendL(1); + + array2.AppendL(7); + array2.AppendL(13); + array2.AppendL(6); + array2.AppendL(11); + array2.AppendL(12); + array2.AppendL(10); + array2.AppendL(9); + array2.AppendL(14); + array2.AppendL(8); + + array3.AppendL(17); + array3.AppendL(18); + array3.AppendL(19); + array3.AppendL(16); + array3.AppendL(15); + array3.AppendL(20); + + array4.AppendL(23); + array4.AppendL(21); + array4.AppendL(22); + array4.AppendL(24); + + array5.AppendL(26); + array5.AppendL(25); + } + else + { + array1.AppendL(1); + array1.AppendL(3); + array1.AppendL(2); + array1.AppendL(4); + array1.AppendL(5); + + array2.AppendL(8); + array2.AppendL(14); + array2.AppendL(9); + array2.AppendL(10); + array2.AppendL(12); + array2.AppendL(11); + array2.AppendL(6); + array2.AppendL(13); + array2.AppendL(7); + + array3.AppendL(20); + array3.AppendL(15); + array3.AppendL(16); + array3.AppendL(19); + array3.AppendL(18); + array3.AppendL(17); + + array4.AppendL(24); + array4.AppendL(22); + array4.AppendL(21); + array4.AppendL(23); + + array5.AppendL(25); + array5.AppendL(26); + } + + resultArray.Append(array1); + resultArray.Append(array2); + resultArray.Append(array3); + resultArray.Append(array4); + resultArray.Append(array5); + + CPosLmItemIterator* iter = NULL; + + for (TInt dbCount = 0; dbCount < 5; dbCount++) + { + iter = iLandmarksMultiDbSearch->MatchIteratorL(dbCount); + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + TInt itemCount = 0; + while (id != KPosLmNullItemId) + { + AssertThatIdIsInCorrectDbL(dbCount, id); + // Check that sort order is correct: + // Some elements will be missing after the search, so skip those. + while (itemCount < resultArray[dbCount].Count() + && resultArray[dbCount][itemCount] != id) + { + itemCount++; + } + // Check that a match was found in the loop above. + AssertTrueSecL(itemCount < resultArray[dbCount].Count(), KErrorInSorting); + id = iter->NextL(); + itemCount++; + } + CleanupStack::PopAndDestroy(iter); + iter = NULL; + } + + CleanupStack::PopAndDestroy(6); // Arrays + CleanupStack::PopAndDestroy(nameCriteria); + } + } + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + + +// --------------------------------------------------------- +// CPosTp125::SearchWithMaximumL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchWithMaximumL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchWithMaximumL is performed"); + _LIT(KNumOfDisplayMatchesErr, "No. of matches for the display data is incorrect when SearchWithMaximumL is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + // Set max nr of matches from 1 to 10 and check that correct nr of matches for each value + for (TInt j = 1; j <= 10; j++) + { + nameCriteria->SetSearchPatternL(_L("*")); + iLandmarksMultiDbSearch->SetMaxNumOfMatches(j); + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + } + + TInt displayCount = displayData->Count(); + + switch(j) + { + case 1: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 1, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 1, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 1, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 1, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 1, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 5, KNumOfDisplayMatchesErr); + break; + case 2: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 2, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 2, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 2, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 2, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 10, KNumOfDisplayMatchesErr); + break; + case 3: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 3, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 3, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 3, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 3, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 14, KNumOfDisplayMatchesErr); + break; + case 4: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 18, KNumOfDisplayMatchesErr); + break; + case 5: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 21, KNumOfDisplayMatchesErr); + break; + case 6: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 23, KNumOfDisplayMatchesErr); + break; + case 7: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 7, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 24, KNumOfDisplayMatchesErr); + break; + case 8: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 8, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 25, KNumOfDisplayMatchesErr); + break; + case 9: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 9, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 26, KNumOfDisplayMatchesErr); + break; + case 10: + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 5, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 9, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 6, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 4, KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 2, KNumOfMatchesErr); + AssertTrueSecL(displayCount == 26, KNumOfDisplayMatchesErr); + break; + default: + break; + } + + // Check that the DB:s actually contains correct data: + CPosLmItemIterator* iter = NULL; + + for (TInt count = 0; count < 5; count++) + { + iter = iLandmarksMultiDbSearch->MatchIteratorL(count); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + AssertThatIdIsInCorrectDbL(count, id); + // Use search result for position 0, should always be for * + AssertTrueSecL(aSearchResults[0]->FindSearchResult(id), KNotFoundErr, id); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + iter = NULL; + } + } + + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(nameCriteria); + } + + +// --------------------------------------------------------- +// CPosTp125::SearchAfterAddedCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchAfterAddedCategoryL() + { + // _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchAfterAddedCategoryL is performed"); + _LIT(KCategoryNotFound, "Added category could not be found"); + _LIT(KCategory, "StoraKoncernen"); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + //iDatabase = CP + iDatabase = CPosLandmarkDatabase::OpenL(KDb40); + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + CPosLandmarkCategory* cat1 = CPosLandmarkCategory::NewLC(); + + // First do a search with wildcard + nameCriteria->SetSearchPatternL(_L("S*")); + ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + // Then add a new category with a name starting with S + cat1->SetCategoryNameL(KCategory); + TPosLmItemId categoryId = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + // Then use do another search within the results of previous search + // should return Stadsbibliotek and Stadspark + nameCriteria->SetSearchPatternL(_L("St*")); + ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone, ETrue)); + + _LIT(KErrorNrOfMatchesRefined, "Wrong nr matches after refined search after adding a category."); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 1, KErrorNrOfMatchesRefined); // Stadsbibliotek + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 1, KErrorNrOfMatchesRefined); // Stadspark + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(displayData->Count() == 2, KErrorNrOfMatchesRefined); + // Set a maximum number of matches, should return only one of Stadsbibliotek and Stadspark + iLandmarksMultiDbSearch->SetMaxNumOfMatches(1); + + // Do another search just to see that it is possible to find the added category + nameCriteria->SetSearchPatternL(KCategory); + ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == 1, KErrorNrOfMatchesRefined); // StoraKoncernen + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == 0, KErrorNrOfMatchesRefined); + AssertTrueSecL(displayData->Count() == 1, KErrorNrOfMatchesRefined); + + CPosLmItemIterator* iter = iLandmarksMultiDbSearch->MatchIteratorL(1); + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + if (categoryId != id) + { + iLog->Log(KCategoryNotFound); + User::Leave(-1); + } + + // Remove added category + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(categoryId)); + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + delete iDatabase; + iDatabase = NULL; + + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + + +// --------------------------------------------------------- +// CPosTp125::SearchGlobalL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchGlobalL(const RPointerArray& aSearchResults, const TBool& aSync) + { + iLog->Log(_L("SearchGlobalL")); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchGlobalL is performed"); + + // Nr of global categories, defined in resource file + //const TInt KNrOfGlobalCategories = 8; + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + CPosLmCategoryManager::TCategorySortPref sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + for (TInt l=0;l<2;l++) + { + if (l==0) sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + else if (l==1) sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + + // i=0 the first entry in aSearchResults should be wildcard "*" + TInt i = 0; + // First do a search with wildcard + nameCriteria->SetSearchPatternL(aSearchResults[i]->TextCriteria()); + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, sortPref); + + // The asynchronous flow + if (aSync) + { + RunAsyncOperationLD(iOperation); + } + else + { + ExecuteAndDeleteLD(iOperation); + } + + + SetupDbArrayL(); + + iDbArray->Sort(); + + if (sortPref == CPosLmCategoryManager::ECategorySortOrderNameDescending) + { + InvertArrayL(iDbArray); + } + + //TUint expNr = (aSearchResults[i]->SearchResult()).Count() + KNrOfGlobalCategories; + TUint expNr = (aSearchResults[i]->SearchResult()).Count(); + + + TInt matchesSum = 0; + for (TInt count = 0; count < 5; count++) + { + matchesSum += iLandmarksMultiDbSearch->NumOfMatches(count); + } + + if (expNr != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt displayCount = displayData->Count(); + + if (displayCount != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt count = 0; + TBuf<100> categoryName2; + TPtrC categoryName; + RPointerArray searchResults; + + for (count = 0; count < displayCount; count++) + { + CPosLmDisplayItem& displayItem = displayData->DisplayItem(count); + const CPosLandmarkCategory& displayCategory = displayItem.Category(); + displayCategory.GetCategoryName(categoryName); + categoryName2 = (*iDbArray)[count]; + // Check that sort order is correct + AssertTrueSecL(categoryName == categoryName2, _L("Error in sorting")); + } + + } // end for (TInt l=0 ...) + + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + iLog->Log(_L("SearchGlobalL Done")); + } + +// --------------------------------------------------------- +// CPosTp24::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp125::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KCancelErr, "The search is canceled after progress has increased but no search result is found"); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + // Test search with one criteria + const TInt KIndex=0; + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(iCategorySearchResults[KIndex]->TextCriteria()); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarksMultiDbSearch->StartCategorySearchL( + *nameCriteria, + CPosLmCategoryManager::ECategorySortOrderNone, + iCategorySearchResults[KIndex]->Redefined())); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarksMultiDbSearch->StartCategorySearchL( + *nameCriteria, + CPosLmCategoryManager::ECategorySortOrderNone, + iCategorySearchResults[KIndex]->Redefined())); + } + + + + if (aInCallback) + { + CPosLmItemIterator* iter0 = iLandmarksMultiDbSearch->MatchIteratorL(0); + CleanupStack::PushL(iter0); + CPosLmItemIterator* iter1 = iLandmarksMultiDbSearch->MatchIteratorL(1); + CleanupStack::PushL(iter1); + CPosLmItemIterator* iter2 = iLandmarksMultiDbSearch->MatchIteratorL(2); + CleanupStack::PushL(iter2); + CPosLmItemIterator* iter3 = iLandmarksMultiDbSearch->MatchIteratorL(3); + CleanupStack::PushL(iter3); + CPosLmItemIterator* iter4 = iLandmarksMultiDbSearch->MatchIteratorL(4); + CleanupStack::PushL(iter4); + + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(0) == iter0->NumOfItemsL(), KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(1) == iter1->NumOfItemsL(), KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(2) == iter2->NumOfItemsL(), KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(3) == iter3->NumOfItemsL(), KNumOfMatchesErr); + AssertTrueSecL(iLandmarksMultiDbSearch->NumOfMatches(4) == iter4->NumOfItemsL(), KNumOfMatchesErr); + + AssertTrueSecL(displayData->Count() > 0, KNumOfMatchesErr); + + AssertTrueSecL((iter0->NumOfItemsL() + + iter0->NumOfItemsL() + + iter0->NumOfItemsL() + + iter0->NumOfItemsL() + + iter0->NumOfItemsL()) == displayData->Count(), KCancelErr); + + CleanupStack::PopAndDestroy(5); + } + + + + CleanupStack::PopAndDestroy(nameCriteria); + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + +void CPosTp125::TestDuplicateGlobalCategoriesL(const RPointerArray& aSearchResults, const TBool& aSync) + { + iLog->Log(_L("SearchGlobalL with duplicates")); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchGlobalL with duplicates is performed"); + + // Nr of global categories, defined in resource file + //const TInt KNrOfGlobalCategories = 15 * 2; + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + CPosLmCategoryManager::TCategorySortPref sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarksMultiDbSearch->SetDisplayData(*displayData); + + for (TInt l=0;l<2;l++) + { + if (l==0) sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + else if (l==1) sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + + // i=0 the first entry in aSearchResults should be wildcard "*" + TInt i = 0; + // First do a search with wildcard + nameCriteria->SetSearchPatternL(aSearchResults[i]->TextCriteria()); + iOperation = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria, sortPref); + + // The asynchronous flow + if (aSync) + { + RunAsyncOperationLD(iOperation); + } + else + { + ExecuteAndDeleteLD(iOperation); + } + + SetupDbArrayL(); + + iDbArray->Sort(); + + if (sortPref == CPosLmCategoryManager::ECategorySortOrderNameDescending) + { + InvertArrayL(iDbArray); + } + + TUint expNr = (aSearchResults[i]->SearchResult()).Count(); + + TInt matchesSum = 0; + for (TInt count = 0; count < 5; count++) + { + matchesSum += iLandmarksMultiDbSearch->NumOfMatches(count); + } + + if (expNr != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt displayCount = displayData->Count(); + + if (displayCount != matchesSum) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt count = 0; + + TBuf<100> categoryName2; + TPtrC categoryName; + + for (count = 0; count < displayCount; count++) + { + CPosLmDisplayItem& displayItem = displayData->DisplayItem(count); + const CPosLandmarkCategory& displayCategory = displayItem.Category(); + displayCategory.GetCategoryName(categoryName); + categoryName2 = (*iDbArray)[count]; + // Check that sort order is correct + AssertTrueSecL(categoryName == categoryName2, _L("Error in sorting")); + } + + } // end for (TInt l=0 ...) + + iLandmarksMultiDbSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + iLog->Log(_L("SearchGlobalL Done")); + } + +void CPosTp125::RemoveExtraCategoriesL() + { + TInt err = KErrNone; + iDatabase = CPosLandmarkDatabase::OpenL(KDb20); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L(" Default database opened and initialised ")); + + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + ExecuteAndDeleteLD(catMan->ResetGlobalCategoriesL()); + + RemoveCategoryL(catMan, 6); + RemoveCategoryL(catMan, 7); + RemoveCategoryL(catMan, 8); + RemoveCategoryL(catMan, 9); + RemoveCategoryL(catMan, 10); + RemoveCategoryL(catMan, 11); + RemoveCategoryL(catMan, 12); + RemoveCategoryL(catMan, 13); + RemoveCategoryL(catMan, 14); + RemoveCategoryL(catMan, 15); + RemoveCategoryL(catMan, 16); + RemoveCategoryL(catMan, 17); + RemoveCategoryL(catMan, 18); + RemoveCategoryL(catMan, 19); + RemoveCategoryL(catMan, 20); + RemoveCategoryL(catMan, 21); + RemoveCategoryL(catMan, 22); + RemoveCategoryL(catMan, 23); + RemoveCategoryL(catMan, 24); + RemoveCategoryL(catMan, 25); + RemoveCategoryL(catMan, 26); + + + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(3000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(6000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(9000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(12000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(15000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(18000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(21000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(24000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(27000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(30000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(33000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(36000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(39000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(42000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(45000)); + + CleanupStack::PopAndDestroy(catMan); + delete iDatabase; + iDatabase = NULL; + + + iDatabase = CPosLandmarkDatabase::OpenL(KDb40); + if ( iDatabase->IsInitializingNeeded() ) + { + TRAP( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + + RemoveCategoryL(catMan, 1); + RemoveCategoryL(catMan, 2); + RemoveCategoryL(catMan, 3); + RemoveCategoryL(catMan, 4); + RemoveCategoryL(catMan, 5); + // Existing categories here + RemoveCategoryL(catMan, 15); + RemoveCategoryL(catMan, 16); + RemoveCategoryL(catMan, 17); + RemoveCategoryL(catMan, 18); + RemoveCategoryL(catMan, 19); + RemoveCategoryL(catMan, 20); + RemoveCategoryL(catMan, 21); + RemoveCategoryL(catMan, 22); + RemoveCategoryL(catMan, 23); + RemoveCategoryL(catMan, 24); + RemoveCategoryL(catMan, 25); + RemoveCategoryL(catMan, 26); + + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(3000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(6000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(9000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(12000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(15000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(18000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(21000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(24000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(27000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(30000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(33000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(36000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(39000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(42000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(45000)); + + CleanupStack::PopAndDestroy(catMan); + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(KDb60); + if ( iDatabase->IsInitializingNeeded() ) + { + TRAP( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + RemoveCategoryL(catMan, 1); + RemoveCategoryL(catMan, 2); + RemoveCategoryL(catMan, 3); + RemoveCategoryL(catMan, 4); + RemoveCategoryL(catMan, 5); + RemoveCategoryL(catMan, 6); + RemoveCategoryL(catMan, 7); + RemoveCategoryL(catMan, 8); + RemoveCategoryL(catMan, 9); + RemoveCategoryL(catMan, 10); + RemoveCategoryL(catMan, 11); + RemoveCategoryL(catMan, 12); + RemoveCategoryL(catMan, 13); + RemoveCategoryL(catMan, 14); + // Existing categories here + RemoveCategoryL(catMan, 21); + RemoveCategoryL(catMan, 22); + RemoveCategoryL(catMan, 23); + RemoveCategoryL(catMan, 24); + RemoveCategoryL(catMan, 25); + RemoveCategoryL(catMan, 26); + + + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(3000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(6000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(9000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(12000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(15000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(18000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(21000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(24000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(27000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(30000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(33000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(36000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(39000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(42000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(45000)); + + CleanupStack::PopAndDestroy(catMan); + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(KDb80); + if ( iDatabase->IsInitializingNeeded() ) + { + TRAP( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + RemoveCategoryL(catMan, 1); + RemoveCategoryL(catMan, 2); + RemoveCategoryL(catMan, 3); + RemoveCategoryL(catMan, 4); + RemoveCategoryL(catMan, 5); + RemoveCategoryL(catMan, 6); + RemoveCategoryL(catMan, 7); + RemoveCategoryL(catMan, 8); + RemoveCategoryL(catMan, 9); + RemoveCategoryL(catMan, 10); + RemoveCategoryL(catMan, 11); + RemoveCategoryL(catMan, 12); + RemoveCategoryL(catMan, 13); + RemoveCategoryL(catMan, 14); + RemoveCategoryL(catMan, 15); + RemoveCategoryL(catMan, 16); + RemoveCategoryL(catMan, 17); + RemoveCategoryL(catMan, 18); + RemoveCategoryL(catMan, 19); + RemoveCategoryL(catMan, 20); + // Existing categories here + RemoveCategoryL(catMan, 25); + RemoveCategoryL(catMan, 26); + + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(3000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(6000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(9000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(12000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(15000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(18000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(21000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(24000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(27000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(30000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(33000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(36000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(39000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(42000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(45000)); + + CleanupStack::PopAndDestroy(catMan); + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(KDb105); + if ( iDatabase->IsInitializingNeeded() ) + { + TRAP( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL( err == KErrNone, _L("Init db failed")); + } + catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + RemoveCategoryL(catMan, 1); + RemoveCategoryL(catMan, 2); + RemoveCategoryL(catMan, 3); + RemoveCategoryL(catMan, 4); + RemoveCategoryL(catMan, 5); + RemoveCategoryL(catMan, 6); + RemoveCategoryL(catMan, 7); + RemoveCategoryL(catMan, 8); + RemoveCategoryL(catMan, 9); + RemoveCategoryL(catMan, 10); + RemoveCategoryL(catMan, 11); + RemoveCategoryL(catMan, 12); + RemoveCategoryL(catMan, 13); + RemoveCategoryL(catMan, 14); + RemoveCategoryL(catMan, 15); + RemoveCategoryL(catMan, 16); + RemoveCategoryL(catMan, 17); + RemoveCategoryL(catMan, 18); + RemoveCategoryL(catMan, 19); + RemoveCategoryL(catMan, 20); + RemoveCategoryL(catMan, 21); + RemoveCategoryL(catMan, 22); + RemoveCategoryL(catMan, 23); + RemoveCategoryL(catMan, 24); + + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(3000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(6000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(9000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(12000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(15000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(18000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(21000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(24000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(27000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(30000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(33000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(36000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(39000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(42000)); + RemoveCategoryL(catMan, catMan->GetGlobalCategoryL(45000)); + + CleanupStack::PopAndDestroy(catMan); + delete iDatabase; + iDatabase = NULL; + } + + + void CPosTp125::RemoveCategoryL(CPosLmCategoryManager* aCatMan, + const TPosLmItemId aCatId) + { + ExecuteAndDeleteLD(aCatMan->RemoveCategoryL(aCatId)); + } + +void CPosTp125::AssertThatIdIsInCorrectDbL(TInt aDbIndex, TInt aId) + { + _LIT(KErrorWrongDb, "Id returned from wrong db"); + _LIT(KIllegalIndex, "Illegal index sent to AssertThatIdIsInCorrectDbL()"); + switch(aDbIndex) + { + case 0: + AssertTrueSecL(aId >= 1 && aId <= 5, KErrorWrongDb); + break; + case 1: + AssertTrueSecL(aId >= 6 && aId <= 14, KErrorWrongDb); + break; + case 2: + AssertTrueSecL(aId >= 15 && aId <= 20, KErrorWrongDb); + break; + case 3: + AssertTrueSecL(aId >= 21 && aId <= 24, KErrorWrongDb); + break; + case 4: + AssertTrueSecL(aId >= 25 && aId <= 26, KErrorWrongDb); + break; + default: + iLog->Log(KIllegalIndex); + User::Leave(-1); + break; + + } + } + +void CPosTp125::SetupDbArrayL() + { + iDbArray = NULL; + // This array is used when testing display data. + iDbArray = new(ELeave) CDesCArrayFlat(8); + + // Build the array so that the array index is equivalent with the db index, except that this array is 0-based. + iDbArray->AppendL(KPizzeria); + iDbArray->AppendL(KHambergerbar); + iDbArray->AppendL(KKinarestaurang); + iDbArray->AppendL(KGaraget); + iDbArray->AppendL(KBilverkstad); + iDbArray->AppendL(KPastaRestaurang); + iDbArray->AppendL(KBilia); + iDbArray->AppendL(KVolksWagen); + iDbArray->AppendL(KTaxiGoteborg); + iDbArray->AppendL(KTaxi); + iDbArray->AppendL(KStadsbibliotek); + iDbArray->AppendL(KSystembolag); + iDbArray->AppendL(KNokiKontor); + iDbArray->AppendL(KTietoEnatorKontor); + iDbArray->AppendL(KThaiRestaurang); + iDbArray->AppendL(KMcDonalds); + iDbArray->AppendL(KBurgerKing); + iDbArray->AppendL(KFrisor); + iDbArray->AppendL(KHunddagis); + iDbArray->AppendL(KVeterinar); + iDbArray->AppendL(KKyrkogard); + iDbArray->AppendL(KMuseum); + iDbArray->AppendL(KDagis); + iDbArray->AppendL(KStadspark); + iDbArray->AppendL(KSjukhus); + iDbArray->AppendL(KLakare); + } + +void CPosTp125::SortResultsL(RArray& aArray, + CDesCArrayFlat*& aResultArray) + { + TInt count = 0; + aResultArray = new(ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(aResultArray); + for (count = 0 ; count < aArray.Count(); count++) + { + TInt id = aArray[count]; + aResultArray->AppendL((*iDbArray)[id - 1]); // compensate for 0-based array + } + + aResultArray->Sort(); + CleanupStack::Pop(aResultArray); + } + +void CPosTp125::InvertArrayL(CDesCArrayFlat*& aArray) + { + TInt maxCount = aArray->Count(); + TInt count = 0; + + CDesCArrayFlat* copyArray = new(ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(copyArray); + + for (count = 0; count < maxCount; count++) + { + copyArray->AppendL((*aArray)[count]); + } + + aArray->Reset(); + for (count = 0; count < maxCount; count++) + { + aArray->AppendL((*copyArray)[maxCount - count - 1]); + } + + CleanupStack::PopAndDestroy(copyArray); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp126.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp126.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,452 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp126.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" +#include +//#include + + +// CONSTANTS +_LIT(KWildcard, "*"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp126::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp126::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iLandmarksMultiDbSearch; + iLandmarksMultiDbSearch = NULL; + + iThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp126::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp126::StartL() + { + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + CDesCArray* dbList = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(dbList); + dbList->AppendL(KDb20); + dbList->AppendL(KDb40); + dbList->AppendL(KDb60); + dbList->AppendL(KDb80); + dbList->AppendL(KDb105); + + iLandmarksMultiDbSearch = CPosLmMultiDbSearch::NewL(*dbList); + TInt err = KErrNone; + + // Test that a 'use previous matches' search doesn't work in the first search. + CPosLmTextCriteria* lmtextCriteria = CPosLmTextCriteria::NewLC(); + lmtextCriteria->SetTextL(KWildcard); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartLandmarkSearchL(*lmtextCriteria, + sortPref, + ETrue))); + + _LIT(KErrorWrongCodePreviousMatches, "Wrong error code for searching in previous matches when there are no previous matches"); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodePreviousMatches, err); + + // Test that a 'use previous matches' search doesn't work in the first search. (category search) + CPosLmCategoryManager::TCategorySortPref sortPrefCat = CPosLmCategoryManager::ECategorySortOrderNameAscending; + CPosLmCatNameCriteria* nameCriteriaCat = CPosLmCatNameCriteria::NewLC(); + nameCriteriaCat->SetSearchPatternL(KWildcard); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteriaCat, + sortPrefCat, + ETrue))); + _LIT(KErrorWrongCodePreviousMatchesCat, "Wrong error code for searching in previous matches when there are no previous matches (categories)"); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodePreviousMatchesCat, err); + + CleanupStack::PopAndDestroy(nameCriteriaCat); + + // Check that only correct criteria works with category searches: + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(5,5,5,5); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + CPosLmCompositeCriteria* compCriteria = + CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + CPosLmIdListCriteria* idListCriteria = CPosLmIdListCriteria::NewLC(); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(TCoordinate(10,10)); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + CPosLmCategoryCriteria* catCriteria = CPosLmCategoryCriteria::NewLC(); + nameCriteria->SetSearchPatternL(KWildcard); + RArray idArray; + CleanupClosePushL(idArray); + idArray.Append(3); + idArray.Append(4); + idListCriteria->SetLandmarkIdsL(idArray); + textCriteria->SetTextL(KWildcard); + catCriteria->SetCategoryNameL(KWildcard); + textCriteria->SetTextL(KWildcard); + + _LIT(KErrorWrongCodeForUnsupportedCriteria,"Wrong error code for unsupported criteria in category search"); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*catCriteria,sortPrefCat))); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForUnsupportedCriteria, err); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*textCriteria,sortPrefCat))); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForUnsupportedCriteria, err); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*areaCriteria,sortPrefCat))); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForUnsupportedCriteria, err); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*compCriteria,sortPrefCat))); + // Composite is not supported in category search + AssertTrueSecL(err == KErrNotSupported, KErrorWrongCodeForUnsupportedCriteria, err); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*idListCriteria,sortPrefCat))); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForUnsupportedCriteria, err); + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nearestCriteria,sortPrefCat))); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForUnsupportedCriteria, err); + + // This should not leave: + ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria,sortPrefCat)); + + // Start a search and test that a new search cannot start until it is finished: + CPosLmOperation* op = iLandmarksMultiDbSearch->StartLandmarkSearchL(*lmtextCriteria,sortPref); + CleanupStack::PushL(op); + TRAP(err, iLandmarksMultiDbSearch->StartLandmarkSearchL(*lmtextCriteria,sortPref)); + _LIT(KErrorWrongCodeForInUse, "Wrong error code when testing 'in use' for multi db searches."); + AssertTrueSecL(err == KErrInUse, KErrorWrongCodeForInUse, err); + + // Check that a new db list cannot be set during a search. + TRAP(err,iLandmarksMultiDbSearch->SetDatabasesToSearchL(*dbList)); + _LIT(KErrorWrongCodeForInUseSetDB, "Wrong error code when testing 'in use' for SetDatabasesToSearchL."); + AssertTrueSecL(err == KErrInUse, KErrorWrongCodeForInUseSetDB, err); + TRAP(err, iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria,sortPrefCat)); + ExecuteAndDeleteLD(op); + CleanupStack::Pop(op); + AssertTrueSecL(err == KErrInUse, KErrorWrongCodeForInUse, err); + + // Start a category search and test that a new search cannot start until it is finished: + op = iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria,sortPrefCat); + CleanupStack::PushL(op); + TRAP(err, iLandmarksMultiDbSearch->StartCategorySearchL(*nameCriteria,sortPrefCat)); + AssertTrueSecL(err == KErrInUse, KErrorWrongCodeForInUse, err); + TRAP(err, iLandmarksMultiDbSearch->StartLandmarkSearchL(*lmtextCriteria,sortPref)); + ExecuteAndDeleteLD(op); + CleanupStack::Pop(op); + AssertTrueSecL(err == KErrInUse, KErrorWrongCodeForInUse, err); + + // Test that an id list criteria cannot be used. + TRAP(err, ExecuteAndDeleteLD(iLandmarksMultiDbSearch->StartLandmarkSearchL(*idListCriteria, + sortPref))); + _LIT(KErrorWrongCodeForIdListCriteria, "Wrong error code for id list criteria."); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForIdListCriteria, err); + + CleanupStack::PopAndDestroy(); // idArray + CleanupStack::PopAndDestroy(catCriteria); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(nearestCriteria); + CleanupStack::PopAndDestroy(idListCriteria); + CleanupStack::PopAndDestroy(compCriteria); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(areaCriteria); + + + /////////////////////////////////////////////////////////////////////////// + // Panic tests //////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + //Set max nr of matches to zero: + iStep = EStepZeroMaxMatches; + iExpectedPanicCode = EPosLmInvalidArgument; + ResumeThreadAndVerifyExitL(); + + // Set max nr of matches to a negative value: + iStep = EStepNegativeMaxMatches; + iExpectedPanicCode = EPosLmInvalidArgument; + ResumeThreadAndVerifyExitL(); + + //Set max nr of matches to constant KPosLmMaxNumOfMatchesUnlimited: + // This is allowed so we use our own panic code to verify that method + // was correctly returned + iStep = EStepUnlimitedMaxMatches; + iExpectedPanicCode = (TPositionLandmarksClientPanic)567; + ResumeThreadAndVerifyExitL(); + + // Invalid index to DatabaseUriPtr method: + iStep = EStepOutOfBoundsDatabaseUriPtr; + iExpectedPanicCode = EPosInvalidIndex; + ResumeThreadAndVerifyExitL(); + + // Invalid index for GetSearchError: + iStep = EStepOutOfBoundsGetSearchError; + iExpectedPanicCode = EPosInvalidIndex; + ResumeThreadAndVerifyExitL(); + + // Invalid TPosLmSortPref + iStep = EStepIllegalSortPrefLMa; + iExpectedPanicCode = EPosInvalidEnumValue; + ResumeThreadAndVerifyExitL(); + + // Invalid TPosLmSortPref + iStep = EStepIllegalSortPrefLMb; + iExpectedPanicCode = EPosInvalidEnumValue; + ResumeThreadAndVerifyExitL(); + + // Invalid TPosLmSortPref + iStep = EStepIllegalSortPrefLMc; + iExpectedPanicCode = EPosNoneOrMultipleLandmarkAttributeSet; + ResumeThreadAndVerifyExitL(); + + // Invalid TPosLmSortPref + iStep = EStepIllegalSortPrefLMd; + iExpectedPanicCode = EPosNoneOrMultipleLandmarkAttributeSet; + ResumeThreadAndVerifyExitL(); + + // Invalid TPosLmSortPref + iStep = EStepIllegalSortPrefCat; + iExpectedPanicCode = EPosInvalidEnumValue; + ResumeThreadAndVerifyExitL(); + + // Invalid index for MatchIteratorL: + iStep = EStepTooBigValueMatchIteratorL; + iExpectedPanicCode = EPosInvalidIndex; + ResumeThreadAndVerifyExitL(); + + // Invalid index for NumOfMatches: + iStep = EStepTooBigValueNumOfMatches; + iExpectedPanicCode = EPosInvalidIndex; + ResumeThreadAndVerifyExitL(); + + // Test LandmarkSearch with NULL search criteria + iStep = EStepNULLSearch1; + iExpectedPanicCode = (TPositionLandmarksClientPanic)3; // KernExec-3 + ResumeThreadAndVerifyExitL(); + + // Test LandmarkSearch with NULL search criteria + iStep = EStepNULLSearch2; + iExpectedPanicCode = (TPositionLandmarksClientPanic)3; // KernExec-3 + ResumeThreadAndVerifyExitL(); + + // Test CategorySearch with NULL search criteria + iStep = EStepNULLSearch3; + iExpectedPanicCode = (TPositionLandmarksClientPanic)3; // KernExec-3 + ResumeThreadAndVerifyExitL(); + + // Test LandmarkSearch with Databases to search with NULL value + iStep = EStepNULLSearch4; + iExpectedPanicCode = (TPositionLandmarksClientPanic)3; // KernExec-3 + ResumeThreadAndVerifyExitL(); + + CleanupStack::PopAndDestroy(lmtextCriteria); + CleanupStack::PopAndDestroy(dbList); + } + +// --------------------------------------------------------- +// CPosTp126::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp126::RunPanicTestL(TAny* aData) + { + CPosTp126* self = reinterpret_cast(aData); + + CDesCArray* dbList = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(dbList); + dbList->AppendL(KDb20); + dbList->AppendL(KDb40); + dbList->AppendL(KDb60); + dbList->AppendL(KDb80); + dbList->AppendL(KDb105); + + CPosLmTextCriteria* textCriteria = NULL; + CPosLmMultiDbSearch* multiSearch = CPosLmMultiDbSearch::NewL(*dbList); + switch(self->iStep) + { + case EStepZeroMaxMatches: + // Not allowed to set 0 number of matches + multiSearch->SetMaxNumOfMatches(0); + break; + case EStepUnlimitedMaxMatches: + multiSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + User::Panic(_L("567"), 567); + break; + case EStepNegativeMaxMatches: + multiSearch->SetMaxNumOfMatches(-10); + break; + case EStepOutOfBoundsDatabaseUriPtr: + multiSearch->DatabaseUriPtr(6); + break; + case EStepOutOfBoundsGetSearchError: + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(KWildcard); + multiSearch->SetMaxNumOfMatches(3); + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria)); + TInt errors = multiSearch->NumOfSearchErrors(); + CPosLmMultiDbSearch::TSearchError searchError; + multiSearch->GetSearchError(errors + 2, searchError); // too large, should panic + CleanupStack::PopAndDestroy(textCriteria); + break; + case EStepTooBigValueMatchIteratorL: + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(KWildcard); + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria)); + multiSearch->MatchIteratorL(6); // Panic here + CleanupStack::PopAndDestroy(textCriteria); + break; + case EStepTooBigValueNumOfMatches: + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(KWildcard); + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria)); + multiSearch->NumOfMatches(6); // Panic here + CleanupStack::PopAndDestroy(textCriteria); + break; + case EStepIllegalSortPrefLMa: + TPosLmSortPref sortPrefa(CPosLandmark::ELandmarkName, + (TPosLmSortPref::TSortOrder)4321); + break; + case EStepIllegalSortPrefLMb: + TPosLmSortPref sortPrefb(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + sortPrefb.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, + (TPosLmSortPref::TSortOrder)4321); // Panic here + break; + case EStepIllegalSortPrefLMc: + TPosLmSortPref sortPrefc(0, TPosLmSortPref::EAscending); + break; + case EStepIllegalSortPrefLMd: + TPosLmSortPref sortPrefd(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + sortPrefd.SetSortByLandmarkAttribute(0, TPosLmSortPref::EAscending); + case EStepIllegalSortPrefCat: + CPosLmCategoryManager::TCategorySortPref sortPrefCat = + (CPosLmCategoryManager::TCategorySortPref)12345; + CPosLmCatNameCriteria* nameCriteriaCat = CPosLmCatNameCriteria::NewLC(); + nameCriteriaCat->SetSearchPatternL(KWildcard); + ExecuteAndDeleteLD(multiSearch->StartCategorySearchL(*nameCriteriaCat, + sortPrefCat)); // Panic here + CleanupStack::PopAndDestroy(nameCriteriaCat); + break; + case EStepNULLSearch1: + textCriteria = NULL; + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria)); + break; + case EStepNULLSearch2: + textCriteria = NULL; + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + break; + case EStepNULLSearch3: + CPosLmCategoryManager::TCategorySortPref sortPrefCat2 = CPosLmCategoryManager::ECategorySortOrderNameAscending; + CPosLmCatNameCriteria* criteria = NULL; + ExecuteAndDeleteLD(multiSearch->StartCategorySearchL(*criteria, sortPrefCat2)); + break; + case EStepNULLSearch4: + CDesCArray* list = NULL; + CPosLmMultiDbSearch* multiSearch = CPosLmMultiDbSearch::NewL(*list); + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(KWildcard); + TPosLmSortPref sortPref4(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + ExecuteAndDeleteLD(multiSearch->StartLandmarkSearchL(*textCriteria, sortPref4)); + break; + default: + break; + + } + } + +// --------------------------------------------------------- +// CPosTp126::ResumeThreadAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp126::ResumeThreadAndVerifyExitL() + { + iLog->Log(_L("ResumeThreadAndVerifyExitL")); + _LIT(KPanicErr, "Method didn't Panic when expected"); + _LIT(KPanicCodeErr, "Panicked with unexpected panic code"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + + User::WaitForRequest(status); + + // Used for debugging + TBuf<100> buf; + buf.Format(_L("ExitType %d Exit reason %d"), iThread.ExitType(), iThread.ExitReason()); + iLog->Log(buf); + + AssertTrueSecL(iThread.ExitType() == EExitPanic, KPanicErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedPanicCode, KPanicCodeErr); + + iThread.Close(); + } + +// --------------------------------------------------------- +// ThreadFunction +// +// --------------------------------------------------------- + +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp126::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +void CPosTp126::CreateThreadL() + { + _LIT(KThreadName, "TP126testthread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + TBuf<100> buf; + buf.Format(KThreadName, (TInt)iStep); + + TInt err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp127.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp127.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1385 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp127.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KShortExecutionTimeInSeconds = 15; +const TInt KLongExecutionTimeInSeconds = 5 * 60; // Five minutes. The longer the more errors seem appear... +const TInt KNrOfDatabases = 5; +const TInt KLockedDbIndex = 2; +const TInt KMaxNrOfLms = 20; +const TInt KLockThreadStartupTime = 500000; +_LIT(KCreateThreadErr, "Creating thread failed with %d"); +_LIT(KLockThreadSearchPattern, "*TP127_LockThread*"); +_LIT(KTestDbUri, "TestDatabase.ldb"); +_LIT(KTestDbUriUC, "TESTDATABASE.LDB"); + +// ================= LOCAL FUNCTIONS ======================= + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TThreadParam* params = reinterpret_cast (aData); + TRAPD(err, (*params->iTestFunction)(params->iMessage)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// LOCAL_C AssertTrueL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C void AssertTrueL( + TBool aCondition, + const TDesC& aBuf, + TDes* aMessage, + TInt aError = KErrGeneral) + { + if (!aCondition) + { + _LIT(KFormat, "%S, error = %d"); + aMessage->Format(KFormat, &aBuf, aError); + + aError == KErrNone ? User::Leave(KErrGeneral) : User::Leave(aError); + } + } + +// --------------------------------------------------------- +// LOCAL_C ThreadExistsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TBool ThreadExistsL(const TDesC& aSearchPattern) + { + TFindThread threadSearcher; + threadSearcher.Find(aSearchPattern); + TFullName fullName; + return (threadSearcher.Next(fullName) == KErrNone); + } + +// --------------------------------------------------------- +// LOCAL_C VerifyResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C void VerifyResultL( + TBool aLockThreadExists, + CPosLmMultiDbSearch* aMultiDbSearcher, + TDes* aDes) + { + TInt nrOfErrors = aMultiDbSearcher->NumOfSearchErrors(); + if (aLockThreadExists) + { + // Reading locked db should result in KErrLocked + AssertTrueL(nrOfErrors == 1, _L("Not one error as expected"), aDes); + CPosLmMultiDbSearch::TSearchError error; + aMultiDbSearcher->GetSearchError(0, error); + AssertTrueL(error.iDatabaseIndex == KLockedDbIndex, _L("Error in wrong db"), aDes); + AssertTrueL(error.iErrorCode == KErrLocked, _L("Wrong error"), aDes, error.iErrorCode); + } + else + { + AssertTrueL(nrOfErrors == 0, _L("Search failed with errors"), aDes); + } + + aDes->Zero(); + } + +// ================= CThreadMonitor MEMBER FUNCTIONS ======================= + +// Constructor +CThreadMonitor::CThreadMonitor(RThread* aThread) +: CActive(CActive::EPriorityStandard), iThread(aThread) + { + CActiveScheduler::Add(this); + } + +// Destructor +CThreadMonitor::~CThreadMonitor() + { + Cancel(); + } + +// --------------------------------------------------------- +// CThreadMonitor::NewL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CThreadMonitor* CThreadMonitor::NewL(RThread* aThread) + { + CThreadMonitor* self = new (ELeave) CThreadMonitor(aThread); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// CThreadMonitor::ConstructL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::ConstructL() + { + iThread->Resume(); + iThread->Logon(iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CThreadMonitor::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::DoCancel() + { + iThread->LogonCancel(iStatus); + + // Kill thread + TRequestStatus status; + iThread->Logon(status); + iThread->Kill(KErrCancel); + User::WaitForRequest(status); + } + +// --------------------------------------------------------- +// CThreadMonitor::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::RunL() + { + CActiveScheduler::Stop(); + } + +// ================= CPosTp127 MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp127::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::GetName(TDes& aName) const + { + _LIT(KTestName, "TP127 - Multiple databases, multiple clients"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp127::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::InitTestL() + { + MakeSurePanicDebugFileExistsL(); + + // PrepareDatabases + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + // Initialize databases - is this really needed? + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + for (TInt i = 0; i < KNrOfDatabases; i++) + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(dbList->operator[](i)); + CleanupStack::PushL(db); + ExecuteAndDeleteLD(db->InitializeL()); + CleanupStack::PopAndDestroy(db); + } + + // Remove the last 5 lms of the the last db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDb105); + CleanupStack::PushL(db); + CPosLmItemIterator* iter = db->LandmarkIteratorL(); + CleanupStack::PushL(iter); + RIdArray idArray; + CleanupClosePushL(idArray); + iter->GetItemIdsL(idArray, 20, iter->NumOfItemsL() - 20); + ExecuteAndDeleteLD(db->RemoveLandmarksL(idArray)); + CleanupStack::PopAndDestroy(3, db); + + CleanupStack::PopAndDestroy(2, dbMan); + } + +// --------------------------------------------------------- +// CPosTp127::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::CloseTest() + { + } + +// --------------------------------------------------------- +// CPosTp127::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::StartL() + { + // 1. Create multiple db search threads + iLog->Put(_L("<<<< 1. Create multiple db search threads >>>>")); + TBool lockDb = ETrue; + TBool successful = MultipleDbSearchClientsL(!lockDb); + //TBool successful = MultipleDbSearchClientsL(lockDb); + + // Sometimes error ESLI-69LDJD DBMS - Error occurs + // 2. One of the databases is locked + iLog->Put(_L("<<<< 2. One of the databases is locked >>>>")); + User::After(KLockThreadStartupTime); // Let previous thread instances really die + if (!MultipleDbSearchClientsL(lockDb)) + { + successful = EFalse; + } + + // 3. Copy database in use + iLog->Put(_L("<<<< 3. Copy database in use >>>>")); + if (!VerifyInUseWhenCopyL()) + { + successful = EFalse; + } + + // 4. Copy databases continuously in parallel + iLog->Put(_L("<<<< 4. Copy databases continuously in parallel >>>>")); + if (!VerifyCopyStressL()) + { + successful = EFalse; + } + + // 5. Use all LM APIs + iLog->Put(_L("<<<< 5. Use all LM APIs simultaneously >>>>")); + if (!MultipleLmClientsL()) + { + successful = EFalse; + } + // Leave if error + if (!successful) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp127::MultipleDbSearchClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp127::MultipleDbSearchClientsL(TBool aLockDb) + { + RThread searchThread1, searchThread2, searchThread3, lockThread; + TThreadParam params1, params2, params3, params4; + TBuf<200> threadMsg1, threadMsg2, threadMsg3, threadMsg4; + RArray threadArray; + CleanupClosePushL(threadArray); + + // Create search thread 1 + _LIT(KSearchThread1, "TP127 - Search thread 1"); + TInt err = searchThread1.Create(KSearchThread1, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(searchThread1); + params1.iMessage = &threadMsg1; + params1.iTestFunction = MultipleDbCategorySearchL; + params1.iThread = &searchThread1; + threadArray.AppendL(params1); + + // Create search thread 2 + _LIT(KSearchThread2, "TP127 - Search thread 2"); + err = searchThread2.Create(KSearchThread2, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms2); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(searchThread2); + params2.iMessage = &threadMsg2; + params2.iTestFunction = MultipleDbLandmarkSearchL; + params2.iThread = &searchThread2; + threadArray.AppendL(params2); + + // Create search thread 3 + _LIT(KSearchThread3, "TP127 - Search thread 3"); + err = searchThread3.Create(KSearchThread3, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms3); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(searchThread3); + params3.iMessage = &threadMsg3; + params3.iTestFunction = MultipleDbLandmarkWithoutCategorySearchL; + params3.iThread = &searchThread3; + threadArray.AppendL(params3); + + if (aLockDb) + { + // Create db lock thread + _LIT(KLockThread, "TP127 - TP127_LockThread"); + err = lockThread.Create(KLockThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms4); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(lockThread); + params4.iMessage = &threadMsg4; + params4.iTestFunction = LockDatabaseL; + params4.iThread = &lockThread; + threadArray.AppendL(params4); + } + + TBool successful = ResumeThreadsAndVerifyExitL(threadArray); + + if (aLockDb) + { + CleanupStack::PopAndDestroy(&lockThread); + } + CleanupStack::PopAndDestroy(4, &threadArray); + return successful; + } + +// --------------------------------------------------------- +// CPosTp127::MultipleLmClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp127::MultipleLmClientsL() + { + // Set default db + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KTestDbUri); + dbMan->CreateDatabaseL(*dbInfo); + CleanupStack::PopAndDestroy(dbInfo); + dbMan->SetDefaultDatabaseUriL(KTestDbUri); + CleanupStack::PopAndDestroy(dbMan); + + RThread dbManThread, multiSearchThread, dbThread, singleSearchThread; + TThreadParam params1, params2, params3, params4; + TBuf<200> threadMsg1, threadMsg2, threadMsg3, threadMsg4; + RArray threadArray; + CleanupClosePushL(threadArray); + + // Create db management thread + _LIT(KDbManThread, "TP127 - Db manager thread"); + TInt err = dbManThread.Create(KDbManThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(dbManThread); + params1.iMessage = &threadMsg1; + params1.iTestFunction = DbManagementL; + params1.iThread = &dbManThread; + threadArray.AppendL(params1); + + // Create multi db search thread + _LIT(KMultiSearchThread, "TP127 - Multi search thread"); + err = multiSearchThread.Create(KMultiSearchThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms2); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(multiSearchThread); + params2.iMessage = &threadMsg2; + params2.iTestFunction = MultipleDbSearchL; + params2.iThread = &multiSearchThread; + threadArray.AppendL(params2); + + // Create LM API thread + _LIT(KDbThread, "TP127 - db thread"); + err = dbThread.Create(KDbThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms3); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(dbThread); + params3.iMessage = &threadMsg3; + params3.iTestFunction = DbAccessL; + params3.iThread = &dbThread; + threadArray.AppendL(params3); + + // Create single db search thread + _LIT(KSingleSearchThread, "TP127 - Single search thread"); + err = singleSearchThread.Create(KSingleSearchThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms4); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(singleSearchThread); + params4.iMessage = &threadMsg4; + params4.iTestFunction = SingleDbSearchL; + params4.iThread = &singleSearchThread; + threadArray.AppendL(params4); + + TBool successful = ResumeThreadsAndVerifyExitL(threadArray); + + CleanupStack::PopAndDestroy(5, &threadArray); + return successful; + } + +// --------------------------------------------------------- +// CPosTp127::VerifyInUseWhenCopyL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp127::VerifyInUseWhenCopyL() + { + RThread copyThread, lockThread; + TThreadParam params1, params2; + TBuf<200> threadMsg1, threadMsg2; + RArray threadArray; + CleanupClosePushL(threadArray); + + // Create copy thread + _LIT(KCopyThread, "TP127 - Copy thread"); + TInt err = copyThread.Create(KCopyThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread); + params1.iMessage = &threadMsg1; + params1.iTestFunction = CopyLockedDatabaseL; + params1.iThread = ©Thread; + threadArray.AppendL(params1); + + // Create db lock thread + _LIT(KLockThread, "TP127 - TP127_LockThread"); + err = KErrAlreadyExists; + while (err == KErrAlreadyExists) + { + err = lockThread.Create(KLockThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms2); + } + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(lockThread); + params2.iMessage = &threadMsg2; + params2.iTestFunction = LockDatabaseL; + params2.iThread = &lockThread; + threadArray.AppendL(params2); + + TBool successful = ResumeThreadsAndVerifyExitL(threadArray); + + CleanupStack::PopAndDestroy(3, &threadArray); + return successful; + } + +// --------------------------------------------------------- +// CPosTp127::VerifyCopyStressL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp127::VerifyCopyStressL() + { + RThread copyThread1, copyThread2, copyThread3, copyThread4, copyThread5; + TThreadParam params1, params2, params3, params4, params5; + TBuf<200> threadMsg1, threadMsg2, threadMsg3, threadMsg4, threadMsg5; + RArray threadArray; + CleanupClosePushL(threadArray); + + // Create copy thread1 + _LIT(KCopyThread1, "TP127 - Copy thread1"); + TInt err = copyThread1.Create(KCopyThread1, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread1); + params1.iMessage = &threadMsg1; + params1.iTestFunction = CopyDatabaseL; + params1.iThread = ©Thread1; + threadArray.AppendL(params1); + + // Create copy thread2 + _LIT(KCopyThread2, "TP127 - Copy thread2"); + err = copyThread2.Create(KCopyThread2, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms2); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread2); + params2.iMessage = &threadMsg2; + params2.iTestFunction = CopyDatabaseL; + params2.iThread = ©Thread2; + threadArray.AppendL(params2); + + // Create copy thread3 + _LIT(KCopyThread3, "TP127 - Copy thread3"); + err = copyThread3.Create(KCopyThread3, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms3); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread3); + params3.iMessage = &threadMsg3; + params3.iTestFunction = CopyDatabaseL; + params3.iThread = ©Thread3; + threadArray.AppendL(params3); + + // Create copy thread4 + _LIT(KCopyThread4, "TP127 - Copy thread4"); + err = copyThread4.Create(KCopyThread4, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms4); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread4); + params4.iMessage = &threadMsg4; + params4.iTestFunction = CopyDatabaseL; + params4.iThread = ©Thread4; + threadArray.AppendL(params4); + + // Create copy thread5 + _LIT(KCopyThread5, "TP127 - Copy thread5"); + err = copyThread5.Create(KCopyThread5, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, ¶ms5); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(copyThread5); + params5.iMessage = &threadMsg5; + params5.iTestFunction = CopyDatabaseL; + params5.iThread = ©Thread5; + threadArray.AppendL(params5); + + TBool successful = ResumeThreadsAndVerifyExitL(threadArray); + + CleanupStack::PopAndDestroy(6, &threadArray); + return successful; + } + +// --------------------------------------------------------- +// CPosTp127::ResumeThreadsAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp127::ResumeThreadsAndVerifyExitL(const RArray& aThreadParams) + { + // Start threads. + RPointerArray threadMonitors; + CleanupClosePushL(threadMonitors); + TInt nrOfThreads = aThreadParams.Count(); + for (TInt j = 0; j < nrOfThreads; j++) + { + threadMonitors.AppendL(CThreadMonitor::NewL(aThreadParams[j].iThread)); + } + +// <<<< Commented code below can be enabled for immediate interruption when any thread fails >>>> + + // Wait until any of the threads exits. + TInt error = KErrNone; + TBool allThreadsTerminated = EFalse; + while (!allThreadsTerminated +/* && error == KErrNone*/) + { + CActiveScheduler::Start(); + + // Assume all threads are terminated + allThreadsTerminated = ETrue; + for (TInt i = 0; i < nrOfThreads +/* && error == KErrNone*/; i++) + { + if (threadMonitors[i]->IsActive()) + { + // Thread is still alive + allThreadsTerminated = EFalse; + } + else + { +/* if (aThreadParams[i].iThread->ExitType() != EExitKill) + { + error = KErrGeneral; + } + else if (aThreadParams[i].iThread->ExitReason()) + { + error = aThreadParams[i].iThread->ExitReason(); + } +*/ } + } + } + +// <<<< Commented code above can be enabled for immediate interruption when any thread fails >>>> + + // Terminate all remaining threads (in case of errors) + threadMonitors.ResetAndDestroy(); + CleanupStack::PopAndDestroy(&threadMonitors); + + // Log summary + for (TInt i = 0; i < nrOfThreads; i++) + { + if (*aThreadParams[i].iMessage != KNullDesC) + { + iLog->Put(*aThreadParams[i].iMessage); + } + TName threadName = aThreadParams[i].iThread->Name(); + if (aThreadParams[i].iThread->ExitType() != EExitKill) + { + iBuf.Format(_L("%S was not killed!"), &threadName); + iLog->PutError(iBuf); + TExitCategoryName category = aThreadParams[i].iThread->ExitCategory(); + iBuf.Format(_L("Exit Category = %S %d"), &category, aThreadParams[i].iThread->ExitReason()); + iLog->Put(iBuf); + error = KErrGeneral; + } + else + { + TInt exitReason = aThreadParams[i].iThread->ExitReason(); + if (exitReason != 0) + { + iBuf.Format(_L("%S's exit reason wasn't 0 but %d."), &threadName, exitReason); + iLog->PutError(iBuf); + error = exitReason; + } + } + } + + return (error == KErrNone); + } + +// ================= STATIC THREAD FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp127::MultipleDbCategorySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::MultipleDbCategorySearchL(TDes* aMessage) + { + TBool lockThreadExists = ThreadExistsL(KLockThreadSearchPattern); + if (lockThreadExists) + { + // Let lock thread launch first + User::After(KLockThreadStartupTime); + } + + // Search multiple databases for some seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + while (executionTime.Int() < KShortExecutionTimeInSeconds) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + AssertTrueL(dbList->Count() == KNrOfDatabases, _L("MultipleDbCategorySearchL: Wrong number of databases"), aMessage); + CPosLmMultiDbSearch* dbSearcher = CPosLmMultiDbSearch::NewL(*dbList); + CleanupStack::PushL(dbSearcher); + + // Search for categories containing a specific string + CPosLmCatNameCriteria* criteria = CPosLmCatNameCriteria::NewLC(); + criteria->SetSearchPatternL(_L("*Log*")); + CPosLmOperation* operation = dbSearcher->StartCategorySearchL(*criteria, CPosLmCategoryManager::ECategorySortOrderNone); + ExecuteAndDeleteLD(operation); + + aMessage->Copy(_L("MultipleDbCategorySearchL: ")); + VerifyResultL(lockThreadExists, dbSearcher, aMessage); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + CleanupStack::PopAndDestroy(4, dbMan); + } + } + +// --------------------------------------------------------- +// CPosTp127::MultipleDbLandmarkSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::MultipleDbLandmarkSearchL(TDes* aMessage) + { + TBool lockThreadExists = ThreadExistsL(KLockThreadSearchPattern); + if (lockThreadExists) + { + // Let lock thread launch first + User::After(KLockThreadStartupTime); + } + + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + while (executionTime.Int() < KShortExecutionTimeInSeconds) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + CPosLmMultiDbSearch* dbSearcher = CPosLmMultiDbSearch::NewL(*dbList); + CleanupStack::PushL(dbSearcher); + + // Search for landmarks containing a specific string + CPosLmTextCriteria* criteria = CPosLmTextCriteria::NewLC(); + criteria->SetTextL(_L("*as*")); + CPosLmOperation* operation = dbSearcher->StartLandmarkSearchL(*criteria); + ExecuteAndDeleteLD(operation); + + aMessage->Copy(_L("MultipleDbLandmarkSearchL: ")); + VerifyResultL(lockThreadExists, dbSearcher, aMessage); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + CleanupStack::PopAndDestroy(4, dbMan); + } + } + +// --------------------------------------------------------- +// CPosTp127::MultipleDbLandmarkWithoutCategorySearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::MultipleDbLandmarkWithoutCategorySearchL(TDes* aMessage) + { + TBool lockThreadExists = ThreadExistsL(KLockThreadSearchPattern); + if (lockThreadExists) + { + // Let lock thread launch first + User::After(KLockThreadStartupTime); + } + + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + while (executionTime.Int() < KShortExecutionTimeInSeconds) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + AssertTrueL(dbList->Count() == KNrOfDatabases, _L("MultipleDbLandmarkWithoutCategorySearchL: Wrong number of databases"), aMessage); + CPosLmMultiDbSearch* dbSearcher = CPosLmMultiDbSearch::NewL(*dbList); + CleanupStack::PushL(dbSearcher); + + // Search for uncategorized landmarks + CPosLmCategoryCriteria* criteria = CPosLmCategoryCriteria::NewLC(); + CPosLmOperation* operation = dbSearcher->StartLandmarkSearchL(*criteria); + ExecuteAndDeleteLD(operation); + + aMessage->Copy(_L("MultipleDbLandmarkWithoutCategorySearchL: ")); + VerifyResultL(lockThreadExists, dbSearcher, aMessage); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + + CleanupStack::PopAndDestroy(4, dbMan); + } + } + +// --------------------------------------------------------- +// CPosTp127::LockDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::LockDatabaseL(TDes* aMessage) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + AssertTrueL(dbList->Count() == KNrOfDatabases, _L("MultipleDbLandmarkWithoutCategorySearchL: Wrong number of databases"), aMessage); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*dbList)[KLockedDbIndex]); + CleanupStack::PushL(db); + CPosLmOperation* operation = db->RemoveAllLandmarksL(); + User::After((KShortExecutionTimeInSeconds + 1) * 1000000); + delete operation; + + CleanupStack::PopAndDestroy(3, dbMan); + } + +// --------------------------------------------------------- +// CPosTp127::DbManagementL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::DbManagementL(TDes* aMessage) + { + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + TInt i(0); + TBool errorsFound = EFalse; + + while (executionTime.Int() < KLongExecutionTimeInSeconds) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + + // List dbs + CDesCArray* dbList = dbMan->ListDatabasesLC(); + + // Create db + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KTestDbUri); + TRAPD(err, dbMan->CreateDatabaseL(*dbInfo)); + CleanupStack::PopAndDestroy(dbInfo); + if (err != KErrAlreadyExists) + { + AssertTrueL(dbMan->DatabaseExistsL(KTestDbUri), _L("DbManagementL: Created database does not exist"), aMessage); + } + + // Try to read default URI + HBufC* defaultDb = dbMan->DefaultDatabaseUriLC(); + + // Set default db to the created one + dbMan->SetDefaultDatabaseUriL(KTestDbUri); + + // Remove default db + TRAP(err, dbMan->DeleteDatabaseL(KTestDbUri)); + AssertTrueL(err == KErrNone || err == KErrInUse, _L("DbManagementL: Wrong error code when removing created database"), aMessage, err); + if (err == KErrNone) + { + AssertTrueL(!dbMan->DatabaseExistsL(KTestDbUri), _L("DbManagementL: Removed database exists"), aMessage); + } + + // Create a copy of a db + if (dbList->Count() > 0) + { + TRAP(err, dbMan->CopyDatabaseL((*dbList)[0], KTestDbUri)); +// TBD: How can err == KErrLocked happen? Refer to ESLI-68HKE6 +// TBD: Sometimes KErrDied is returned from this function. Why? Write error report? + AssertTrueL(err == KErrNone || err == KErrAlreadyExists || err == KErrInUse || err == KErrLocked, _L("DbManagementL: Wrong error code when copying database"), aMessage, err); + if (err == KErrNone || err == KErrAlreadyExists) + { + AssertTrueL(dbMan->DatabaseExistsL(KTestDbUri), _L("DbManagementL: Copied database does not exist"), aMessage); + + // Remove copy + TRAP(err, dbMan->DeleteDatabaseL(KTestDbUri)); + AssertTrueL(err == KErrNone || err == KErrInUse, _L("DbManagementL: Wrong error code when removing copied database"), aMessage, err); + if (err == KErrNone) + { + AssertTrueL(!dbMan->DatabaseExistsL(KTestDbUri), _L("DbManagementL: Removed database exists"), aMessage); + } + } + else if (err == KErrLocked) // To be removed when ESLI-68HKE6 is solved + { + aMessage->Copy(_L("DbManagementL: CPosLmDatabaseManager::CopyDatabaseL() left with KErrLocked - check ESLI-68HKE6")); + errorsFound = ETrue; + } + } + + // Set default db to another uri + dbMan->SetDefaultDatabaseUriL((*dbList)[i]); + if (++i == 5) + { + i = 0; + } + + // Increase probability that (*dbList)[i] and not KTestDbUri is default db most of the time + User::After(10000); + + CleanupStack::PopAndDestroy(3, dbMan); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + } + + if (errorsFound) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp127::DbAccessL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::DbAccessL(TDes* aMessage) + { + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + TBool errorsFound = EFalse; + + while (executionTime.Int() < KLongExecutionTimeInSeconds) + { + CPosLandmarkDatabase* db = NULL; + TRAPD(err, db = CPosLandmarkDatabase::OpenL()); +// TBD: How can KErrNotFound happen? Refer to ESLI-68HE4P + if (err == KErrLocked || err == KErrInUse || err == KErrNotFound) + { + if (err == KErrNotFound) // To be removed when ESLI-68HE4P is solved + { + aMessage->Copy(_L("DbAccessL: CPosLandmarkDatabase::OpenL() left with KErrNotFound - check ESLI-68HE4P")); + errorsFound = ETrue; + } + // Some client is writing(KErrLocked)/deleting(KErrInUse) the db. Try again. + continue; + } + AssertTrueL(err == KErrNone, _L("DbAccessL: Wrong error code when opening db"), aMessage, err); + CleanupStack::PushL(db); + + // We don't want to use the empty test database + HBufC* dbUri = db->DatabaseUriLC(); +// TBD: Both UC and original case need to be checked here due to SDK bug! To be updated. (refer to INC053631 in teamtrack and ESLI-68HK3W in TSW) + if (dbUri->Find(KTestDbUriUC) != KErrNotFound || dbUri->Find(KTestDbUri) != KErrNotFound) + { + if (dbUri->Find(KTestDbUriUC) != KErrNotFound) // To be removed when ESLI-68HK3W is solved + { + aMessage->Copy(_L("DbAccessL: UPPER CASE of db URI found - check ESLI-68HK3W")); + errorsFound = ETrue; + } + CleanupStack::PopAndDestroy(2, db); + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + continue; + } + + // Fetch db iterator + CPosLmItemIterator* iterator = NULL; + TRAP(err, iterator = db->LandmarkIteratorL()); +// TBD: KErrPosLmNotInitialized should not be accepted. Refer to ESLI-68JAMD + if (err == KErrCorrupt || err == KErrPosLmNotInitialized) + { + if (err == KErrPosLmNotInitialized) // To be removed when ESLI-68JAMD is solved + { + aMessage->Copy(_L("DbAccessL: CPosLandmarkDatabase::LandmarkIteratorL() left with KErrPosLmNotInitialized - check ESLI-68JAMD")); + errorsFound = ETrue; + } +// TBD: Databases need to be re-initialized, because they haved been damaged. Why do they become damaged? + err = KErrLocked; + while (err == KErrLocked && db->IsInitializingNeeded()) + { + TRAP(err, ExecuteAndDeleteLD(db->InitializeL())); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("DbAccessL: Wrong error code when initializing"), aMessage, err); + } + TRAP(err, iterator = db->LandmarkIteratorL()); + } + TBuf<100> buf; + _LIT(KFormat, "DbAccessL: Wrong error code when creating iterator for db %S"); + buf.Format(KFormat, dbUri); + AssertTrueL(err == KErrNone, buf, aMessage, err); + CleanupStack::PopAndDestroy(dbUri); + CleanupStack::PushL(iterator); + + // Add, read and update a landmark + CPosLandmark* lm = CPosLandmark::NewLC(); + TPosLmItemId id = KPosLmNullItemId; + TRAP(err, id = db->AddLandmarkL(*lm)); + CleanupStack::PopAndDestroy(lm); + if (err == KErrNone) + { + TRAP(err, CleanupStack::Pop(lm = db->ReadLandmarkLC(id))); + CleanupStack::PushL(lm); + AssertTrueL(err == KErrNone, _L("DbAccessL: Wrong error code when reading created landmark"), aMessage, err); + lm->SetLandmarkNameL(_L("A landmark")); + TRAP(err, db->UpdateLandmarkL(*lm)); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("DbAccessL: Wrong error code when updating lm"), aMessage, err); + CleanupStack::PopAndDestroy(lm); + } + else + { + AssertTrueL(err == KErrLocked, _L("DbAccessL: Wrong error code when adding lm"), aMessage, err); + } + + // Remove possible added landmarks + TInt nrOfItems = iterator->NumOfItemsL(); + if (nrOfItems > KMaxNrOfLms) + { + RIdArray idArray; + CleanupClosePushL(idArray); + iterator->GetItemIdsL(idArray, KMaxNrOfLms, nrOfItems - KMaxNrOfLms); + err = KErrLocked; + while (err != KErrNone) + { + TRAP(err, ExecuteAndDeleteLD(db->RemoveLandmarksL(idArray))); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("DbAccessL: Wrong error code when removing lm"), aMessage, err); + } + CleanupStack::PopAndDestroy(&idArray); + } + + CleanupStack::PopAndDestroy(2, db); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + } + + if (errorsFound) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp127::SingleDbSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::SingleDbSearchL(TDes* aMessage) + { + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + TInt64 seed = startTime.Int64(); + TBool errorsFound = EFalse; + + while (executionTime.Int() < KLongExecutionTimeInSeconds) + { + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + + // Open one of the pre-defined databases + TInt index = (TInt) (Math::FRand(seed) * dbList->Count()); + TPtrC uri = (*dbList)[index]; +// TBD: Both UC and original case need to be checked here due to SDK bug! To be updated. (refer to INC053631 in teamtrack and ESLI-68HK3W in TSW) + if (uri.Find(KTestDbUriUC) != KErrNotFound || uri.Find(KTestDbUri) != KErrNotFound) + { + if (uri.Find(KTestDbUriUC) != KErrNotFound) // To be removed when ESLI-68HK3W is solved + { + aMessage->Copy(_L("SingleDbSearchL: UPPER CASE of db URI found - check ESLI-68HK3W")); + errorsFound = ETrue; + } + // We don't want to search the empty test database + CleanupStack::PopAndDestroy(2, dbMan); + continue; + } + CPosLandmarkDatabase* db = NULL; + TRAPD(err, db = CPosLandmarkDatabase::OpenL(uri)); + if (err == KErrLocked) + { + // Some client is writing to the db. Try again. + CleanupStack::PopAndDestroy(2, dbMan); + continue; + } + _LIT(KFormat, "SingleDbSearchL: Wrong error code when opening db %S"); + TBuf<100> buf; + buf.Format(KFormat, &uri); + AssertTrueL(err == KErrNone, buf, aMessage, err); + CleanupStack::PushL(db); + + CPosLandmarkSearch* dbSearcher = NULL; + TRAP(err, dbSearcher = CPosLandmarkSearch::NewL(*db)); + AssertTrueL(err == KErrNone, _L("SingleDbSearchL: Wrong error code when calling CPosLandmarkSearch::NewL"), aMessage, err); + CleanupStack::PushL(dbSearcher); + + // Search for landmarks containing a specific string + CPosLmTextCriteria* criteria = CPosLmTextCriteria::NewLC(); + criteria->SetTextL(_L("*as*")); + CPosLmOperation* operation = NULL; + TRAP(err, operation = dbSearcher->StartLandmarkSearchL(*criteria)); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("SingleDbSearchL: Wrong error code when creating search op"), aMessage, err); + if (operation) + { + CleanupStack::PushL(operation); + TRAP(err, operation->ExecuteL()); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("SingleDbSearchL: Wrong error code when executing search op"), aMessage, err); + CleanupStack::PopAndDestroy(operation); + } + + CleanupStack::PopAndDestroy(5, dbMan); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + } + + if (errorsFound) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp127::MultipleDbSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::MultipleDbSearchL(TDes* aMessage) + { + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); +/* + RArray expectedResult; // contains expected matches when search patern is *e* + CleanupClosePushL(expectedResult); + + RIdArray array1; + CleanupClosePushL(array1); + array1.AppendL(4); // vegetariskt + array1.AppendL(5); // Inte sa bra + array1.AppendL(8); // Medel + array1.AppendL(9); // Medel2 + array1.AppendL(12); // GatesB + array1.AppendL(13); // Text"'1 + array1.AppendL(14); // GatesF + array1.AppendL(15); // xStekt + array1.AppendL(18); // enat?r + array1.AppendL(19); // enator + expectedResult.AppendL(array1); + + RIdArray array2; + CleanupClosePushL(array2); + for (TInt i = 29; i <= 40; i++) + { + array2.AppendL(i); // Unique - Text10 + } + expectedResult.AppendL(array2); + + RIdArray array3; + CleanupClosePushL(array3); + array3.AppendL(45); // Several + array3.AppendL(51); // PellesPizza + array3.AppendL(52); // Kalles Hundgård + for (TInt i = 54; i <= 60; i++) + { + array3.AppendL(i); // TE, Gårda - TE, Oulu + } + expectedResult.AppendL(array3); + + RIdArray array4; + CleanupClosePushL(array4); + array4.AppendL(61); // TE, Tampere + array4.AppendL(62); // Nokia, Köpenhamn + array4.AppendL(65); // Tampere + array4.AppendL(66); // Helsinki + array4.AppendL(67); // Bengtfors + array4.AppendL(70); // Göteborg + array4.AppendL(71); // PallesPalör + array4.AppendL(72); // Läkare utan gränser + array4.AppendL(74); // Läkargruppen + array4.AppendL(75); // Läkarhuset + array4.AppendL(76); // Sahlgrenska + array4.AppendL(77); // östra sjukhuset + array4.AppendL(80); // GöteborgsTaxi + expectedResult.AppendL(array4); + + RIdArray array5; + CleanupClosePushL(array5); + array5.AppendL(81); // LandvetterTaxi + array5.AppendL(84); // Länsmuseumet + array5.AppendL(85); // Sjöfartsmuseumet + array5.AppendL(86); // KinaMuseumet + array5.AppendL(88); // Etnogfrafiska + array5.AppendL(89); // TekniskaMuseumet + array5.AppendL(91); // Centrum dagiset + array5.AppendL(93); // Lackarbäcks daghem + for (TInt i = 95; i <= 100; i++) + { + array5.AppendL(i); // TE dagis - krokslätts frisörerna + } + expectedResult.AppendL(array5); +*/ + RArray nrOfExpectedMatches; // contains the number of matches for each db when search pattern is *e* + CleanupClosePushL(nrOfExpectedMatches); + nrOfExpectedMatches.AppendL(10); + nrOfExpectedMatches.AppendL(12); + nrOfExpectedMatches.AppendL(10); + nrOfExpectedMatches.AppendL(13); + nrOfExpectedMatches.AppendL(14); + + while (executionTime.Int() < KLongExecutionTimeInSeconds) + { + CDesCArray* dbList = new (ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(dbList); + dbList->AppendL(KDb20); + dbList->AppendL(KDb40); + dbList->AppendL(KDb60); + dbList->AppendL(KDb80); + dbList->AppendL(KDb105); + CPosLmMultiDbSearch* dbSearcher = CPosLmMultiDbSearch::NewL(*dbList); + CleanupStack::PushL(dbSearcher); + + // Search for landmarks containing a specific string in name + CPosLmTextCriteria* criteria = CPosLmTextCriteria::NewLC(); + criteria->SetTextL(_L("*e*")); + criteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + CPosLmOperation* operation = NULL; + TRAPD(err, operation = dbSearcher->StartLandmarkSearchL(*criteria)) + AssertTrueL(err == KErrNone || err == KErrLocked, _L("MultipleDbSearchL: Wrong error code when creating search op"), aMessage, err); + if (operation) + { + CleanupStack::PushL(operation); + TRAP(err, operation->ExecuteL()); + AssertTrueL(err == KErrNone || err == KErrLocked, _L("MultipleDbSearchL: Wrong error code when executing search op"), aMessage, err); + CleanupStack::PopAndDestroy(operation); + } + + // Check errors + RArray dbsWithErrors; + CleanupClosePushL(dbsWithErrors); + TUint nrOfSearchErrors = dbSearcher->NumOfSearchErrors(); + for (TUint i = 0; i < nrOfSearchErrors; i++) + { + CPosLmMultiDbSearch::TSearchError error; + dbSearcher->GetSearchError(i, error); + AssertTrueL(error.iErrorCode == KErrLocked, _L("MultipleDbSearchL: Wrong error code when searching"), aMessage, error.iErrorCode); + dbsWithErrors.AppendL(error.iDatabaseIndex); + } + + // Check number of matches + for (TInt i = 0; i < dbList->Count(); i++) + { + if (dbsWithErrors.Find(i) == KErrNotFound) + { + TInt nrOfMatches = dbSearcher->NumOfMatches(i); + TInt expectedResult = nrOfExpectedMatches[i]; + AssertTrueL(nrOfMatches == expectedResult, _L("MultipleDbSearchL: Wrong number of matches"), aMessage); + } + } + + CleanupStack::PopAndDestroy(4, dbList); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + } + + CleanupStack::PopAndDestroy(&nrOfExpectedMatches); + } + +// --------------------------------------------------------- +// CPosTp127::CopyLockedDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::CopyLockedDatabaseL(TDes* aMessage) + { + TBool lockThreadExists = ThreadExistsL(KLockThreadSearchPattern); + if (lockThreadExists) + { + // Let lock thread launch first + User::After(KLockThreadStartupTime); + } + + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbList = dbMan->ListDatabasesLC(); + AssertTrueL(dbList->Count() == KNrOfDatabases, _L("CopyLockedDatabaseL: Wrong number of databases"), aMessage); + + // Try to copy database. Should result in KErrInUse + TRAPD(err, dbMan->CopyDatabaseL((*dbList)[KLockedDbIndex], KTestDbUri)); +// TBD: KErrLocked should not be accepted. Refer to ESLI-68HKE6 + AssertTrueL(err != KErrLocked, _L("CopyLockedDatabaseL: Wrong error code when copying database - check ESLI-68HKE6"), aMessage, err); + AssertTrueL(err == KErrInUse , _L("CopyLockedDatabaseL: Wrong error code when copying database"), aMessage, err); + + CleanupStack::PopAndDestroy(2, dbMan); + } + +// --------------------------------------------------------- +// CPosTp127::CopyDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp127::CopyDatabaseL(TDes* aMessage) + { + // Execute thread for a number of seconds + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalSeconds executionTime; + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + TInt64 seed = startTime.Int64(); + TBool errorsFound = EFalse; + + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + while (executionTime.Int() < KShortExecutionTimeInSeconds) + { + CDesCArray* dbList = dbMan->ListDatabasesLC(); + + // Create a source and a target URI + _LIT(KCopy, "_copy"); + TInt copyLength = KCopy().Length(); + TInt index = (TInt) (Math::FRand(seed) * dbList->Count()); + TPtrC sourceUri = (*dbList)[index]; + HBufC* targetUriBuffer = HBufC::NewLC(sourceUri.Length() + copyLength); + TPtr targetUri = targetUriBuffer->Des(); + targetUri.Copy(sourceUri); + targetUri.Insert(targetUri.Length() - 4, KCopy); // 4 == length of ".ldb" + + // Try to copy database. Should result in KErrInUse if locked, KErrNone otherwise + TRAPD(err, dbMan->CopyDatabaseL(sourceUri, targetUri)); + AssertTrueL(err == KErrNone || err == KErrAlreadyExists, _L("CopyDatabaseL: Wrong error code when copying database"), aMessage, err); + + // Set default database to the created one + TRAP(err, dbMan->SetDefaultDatabaseUriL(targetUri)); + AssertTrueL(err == KErrNone || err == KErrNotFound, _L("CopyDatabaseL: Wrong error code when setting default db to target"), aMessage, err); + + // Remove the created database + err = KErrLocked; + while (err != KErrNone && err != KErrNotFound) + { + TRAP(err, dbMan->DeleteDatabaseL(targetUri)); + } + + // Set default database to the source + TRAP(err, dbMan->SetDefaultDatabaseUriL(sourceUri)); + AssertTrueL(err == KErrNone, _L("CopyDatabaseL: Wrong error code when setting default db to source"), aMessage, err); + + CleanupStack::PopAndDestroy(2, dbList); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.SecondsFrom(startTime, executionTime)); + } + + if (errorsFound) + { + User::Leave(KErrGeneral); + } + CleanupStack::PopAndDestroy(dbMan); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp13.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp13.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,417 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include "FT_CPosTp13.h" +#include +#include +#include +#include +#include +#include +#include "EPos_Landmarks.h" + +// CONSTANTS +_LIT(KTP13Db, "eposlm_tp13.ldb"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp13::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp13::CloseTest() + { + iLog->Log(_L("CloseTest")); + } + +// --------------------------------------------------------- +// CPosTp13::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp13::StartL(CStifItemParser& /*aItem*/) + { + _LIT( KTransportName, "Teleport" ); + _LIT( KPeopleName, "People" ); + _LIT( KLmAName, "A" ); + _LIT( KLmBName, "B" ); + + const TInt KTransportGlobalId = 45000; + const TInt KPeopleGlobalId = 27000; + +#undef TP13_PREP + +#ifdef TP13_PREP + // Preparation code, should be executed in Finnish (non-English) locale + // Default database should be removed so that new database is created + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + + CPosLmItemIterator* iter = NULL; + if ( db->IsInitializingNeeded() ) + { + ExecuteAndDeleteLD( db->InitializeL() ); + } + + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL( *db ); + CleanupStack::PushL( catMan ); + + // Rename global category + TPosLmItemId id = catMan->GetGlobalCategoryL( KTransportGlobalId ); + CPosLandmarkCategory* cat = catMan->ReadCategoryLC( id ); + cat->SetCategoryNameL( KTransportName ); + catMan->UpdateCategoryL( *cat ); + CleanupStack::PopAndDestroy( cat ); + + // Create user category + cat = CPosLandmarkCategory::NewLC(); + cat->SetCategoryNameL( KPeopleName ); + TPosLmItemId idUserPeople = catMan->AddCategoryL( *cat ); + CleanupStack::PopAndDestroy( cat ); + + // Find matching global category + TPosLmItemId idPeople = catMan->GetGlobalCategoryL( KPeopleGlobalId ); + + // Create landmark for user's People category + CPosLandmark* lmA = CPosLandmark::NewLC(); + lmA->SetLandmarkNameL( KLmAName ); + lmA->AddCategoryL( idUserPeople ); + db->AddLandmarkL( *lmA ); + CleanupStack::PopAndDestroy( lmA ); + + // Create landmark for global People category + CPosLandmark* lmB = CPosLandmark::NewLC(); + lmA->SetLandmarkNameL( KLmBName ); + lmA->AddCategoryL( idPeople ); + db->AddLandmarkL( *lmB ); + CleanupStack::PopAndDestroy( lmB ); + + CleanupStack::PopAndDestroy( catMan ); + CleanupStack::PopAndDestroy( db ); + +#else + + // Test code, should be executed in English locale + + TInt lang = User::Language(); + iLog->Log(_L("Current language is %d"), lang); + + if ( lang != ELangEnglish ) + { + iLog->Log(_L("Wrong language, should be English (1)")); + User::Leave( KErrGeneral ); + } + + CopyTestDbFileL( KTP13Db ); + + // 1. Open database + iLog->Log(_L("1. Open database")); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL( KTP13Db ); + CleanupStack::PushL(db); + + // 2. Try to use it + iLog->Log(_L("2. Try use it")); + + CPosLmItemIterator* iter = NULL; + TRAPD( err, iter = db->LandmarkIteratorL() ); + if ( err != KErrPosLmNotInitialized ) + { + iLog->Log(_L("Unexpected error on uninitialized database")); + iErrorsFound++; + } + + // 3. Initialize database + iLog->Log(_L("3. Init database")); + + if ( db->IsInitializingNeeded() ) + { + ExecuteAndDeleteLD( db->InitializeL() ); + } + else + { + iLog->Log(_L("Intialization not requried")); + iErrorsFound++; + } + + // 4. Verify names of global categories + iLog->Log(_L("4. Verify globals")); + + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL( *db ); + CleanupStack::PushL( catMan ); + + iter = catMan->CategoryIteratorL(); + CleanupStack::PushL( iter ); + + TPosLmItemId id = iter->NextL(); + while ( id != KPosLmNullItemId ) + { + CPosLandmarkCategory* cat = catMan->ReadCategoryLC( id ); + TPosLmGlobalCategory globalId = cat->GlobalCategory(); + + TPtrC name; + cat->GetCategoryName( name ); + + if ( globalId != KTransportGlobalId ) + { + HBufC* globalName = catMan->GlobalCategoryNameL( globalId ); + if ( name.Compare( *globalName ) != 0 ) + { + iLog->Log( _L("Global category %d name mismatch: actual '%S', predefined '%S'"), + globalId, &name, globalName ); + iErrorsFound++; + } + delete globalName; + } + else // should retain user-defiend name + { + if ( name.Compare( KTransportName() ) != 0 ) + { + iLog->Log( _L("Global category %d name mismatch: actual '%S', user-defined '%S'"), + globalId, &name, &KTransportName() ); + iErrorsFound++; + } + } + + CleanupStack::PopAndDestroy( cat ); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy( iter ); + + // 5. Verify user-created category People, which now matches global category + iLog->Log(_L("5. Verify user's")); + TPosLmItemId idPeople = catMan->GetCategoryL( KPeopleName ); + CPosLandmarkCategory* cat = catMan->ReadCategoryLC( idPeople ); + TPosLmGlobalCategory idPeopleGlobal = cat->GlobalCategory(); + if ( idPeopleGlobal != KPeopleGlobalId ) + { + iLog->Log( _L("Global category People ID mismatch: actual '%d', predefined '%d'"), + idPeopleGlobal, KPeopleGlobalId ); + iErrorsFound++; + } + + RArray lmIds; + CleanupClosePushL( lmIds ); + FindLandmarksL( *db, idPeople, lmIds ); + if ( lmIds.Count() != 2 ) + { + iLog->Log( _L("Global category People landmark list count mismatch: actual '%d', expected '%d'"), + lmIds.Count(), 2 ); + iErrorsFound++; + } + CleanupStack::PopAndDestroy( &lmIds ); + + // verify that those landmarks belong only to People + RArray catIds; + + CPosLandmark* lmA = FindLandmarkLC( *db, KLmAName ); + lmA->GetCategoriesL( catIds ); + if ( catIds.Count() != 1 ) + { + iLog->Log( _L("LmA: wrong category list count, actual '%d', expected '%d'"), + catIds.Count(), 1 ); + iErrorsFound++; + } + if ( catIds.Count() && catIds[0] != idPeople ) + { + iLog->Log( _L("LmB: wrong category in list, actual '%d', expected '%d'"), + catIds[0], idPeople ); + iErrorsFound++; + } + catIds.Reset(); + CleanupStack::PopAndDestroy( lmA ); + + CPosLandmark* lmB = FindLandmarkLC( *db, KLmBName ); + lmA->GetCategoriesL( catIds ); + if ( catIds.Count() != 1 ) + { + iLog->Log( _L("LmB: wrong category list count, actual '%d', expected '%d'"), + catIds.Count(), 1 ); + iErrorsFound++; + } + if ( catIds.Count() && catIds[0] != idPeople ) + { + iLog->Log( _L("LmB: wrong category in list, actual '%d', expected '%d'"), + catIds[0], idPeople ); + iErrorsFound++; + } + catIds.Reset(); + CleanupStack::PopAndDestroy( lmB ); + CleanupStack::PopAndDestroy( cat ); + + // 6. Reset global categories and verify again + iLog->Log(_L("6. Reset and verify globals")); + ExecuteAndDeleteLD(catMan->ResetGlobalCategoriesL()); + + iter = catMan->CategoryIteratorL(); + CleanupStack::PushL( iter ); + + id = iter->NextL(); + while ( id != KPosLmNullItemId ) + { + CPosLandmarkCategory* cat = catMan->ReadCategoryLC( id ); + TPosLmGlobalCategory globalId = cat->GlobalCategory(); + + TPtrC name; + cat->GetCategoryName( name ); + + HBufC* globalName = catMan->GlobalCategoryNameL( globalId ); + if ( name.Compare( *globalName ) != 0 ) + { + iLog->Log( _L("Global category %d name mismatch: actual '%S', predefined '%S'"), + globalId, &name, globalName ); + iErrorsFound++; + } + delete globalName; + CleanupStack::PopAndDestroy( cat ); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy( iter ); + + CleanupStack::PopAndDestroy( catMan ); + CleanupStack::PopAndDestroy( db ); + + if ( iErrorsFound > 0 ) + { + iLog->Log(_L("Errors found in TP13 = %d"), iErrorsFound ); + User::Leave( KErrGeneral ); + } +#endif + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +CPosLandmark* CPosTp13::FindLandmarkLC( CPosLandmarkDatabase& aDb, const TDesC& aName ) + { + CPosLmTextCriteria* crit = CPosLmTextCriteria::NewLC(); + crit->SetTextL( aName ); + crit->SetAttributesToSearch( CPosLandmark::ELandmarkName ); + + CPosLandmarkSearch* search = CPosLandmarkSearch::NewL( aDb ); + CleanupStack::PushL( search ); + + CPosLmOperation* op = search->StartLandmarkSearchL( *crit ); + CleanupStack::PushL( op ); + op->ExecuteL(); + + CPosLmItemIterator* iter = search->MatchIteratorL(); + CleanupStack::PushL( iter ); + RArray lmIds; + iter->GetItemIdsL( lmIds, 0, iter->NumOfItemsL() ); + CleanupClosePushL( lmIds ); + + if ( lmIds.Count() < 1 ) + { + iLog->Log(_L("Couldn't find landmarks, which match name '%S'"), &aName ); + User::Leave( KErrNotFound ); + } + else + { + iLog->Log(_L("Found %d landmarks, which match name '%S'"), lmIds.Count(), &aName ); + } + + CPosLandmark* lm = aDb.ReadLandmarkLC( lmIds[0] ); + CleanupStack::Pop(); + + CleanupStack::PopAndDestroy( &lmIds ); + CleanupStack::PopAndDestroy( iter ); + CleanupStack::PopAndDestroy( op ); + CleanupStack::PopAndDestroy( search ); + CleanupStack::PopAndDestroy( crit ); + + CleanupStack::PushL( lm ); + return lm; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp13::FindLandmarksL( + CPosLandmarkDatabase& aDb, + TPosLmItemId aCategoryId, + RArray& aLmIds ) + { + CPosLmCategoryCriteria* crit = CPosLmCategoryCriteria::NewLC(); + crit->SetCategoryItemId( aCategoryId ); + + CPosLandmarkSearch* search = CPosLandmarkSearch::NewL( aDb ); + CleanupStack::PushL( search ); + + CPosLmOperation* op = search->StartLandmarkSearchL( *crit ); + CleanupStack::PushL( op ); + op->ExecuteL(); + + CPosLmItemIterator* iter = search->MatchIteratorL(); + CleanupStack::PushL( iter ); + + iter->GetItemIdsL( aLmIds, 0, iter->NumOfItemsL() ); + + CleanupStack::PopAndDestroy( iter ); + CleanupStack::PopAndDestroy( op ); + CleanupStack::PopAndDestroy( search ); + CleanupStack::PopAndDestroy( crit ); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp13::ListCategoriesL( CPosLmCategoryManager& aCatMan ) + { + iLog->Log(_L("--- Global Categories ---")); + + CPosLmItemIterator* iter = aCatMan.CategoryIteratorL(); + CleanupStack::PushL(iter); + TBuf<50> buffe; + + TPosLmItemId idde = iter->NextL(); + while (idde != KPosLmNullItemId) + { + CPosLandmarkCategory* cat = aCatMan.ReadCategoryLC(idde); + + TPtrC name; + cat->GetCategoryName(name); + + TPosLmGlobalCategory globalId = cat->GlobalCategory(); + + TPtrC iconName; + TInt iconNr; + TInt iconMaskIndex; + cat->GetIcon(iconName, iconNr, iconMaskIndex); + + iLog->Log(_L("Category %d, globalId %d, name '%S', icon {'%S',%d,%d}"), + cat->CategoryId(), cat->GlobalCategory(), &name, &iconName, iconNr, iconMaskIndex ); + + CleanupStack::PopAndDestroy(cat); + + idde = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + + iLog->Log(_L("------")); + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp130.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp130.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,716 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp130.h" +#include "FT_LandmarkConstants.h" +#include +#include +#include +#include +#include +#include +#include "badesca.h" + +// CONSTANTS +const TInt KNrOfDatabases = 5; +_LIT(KSearchPattern, "*e*"); + +class CNamedLmItem : public CBase + { + public: + ~CNamedLmItem() { delete iName; }; + TPosLmItemId iId; + HBufC* iName; + + static TInt CompareByName( const CNamedLmItem& aLeft, const CNamedLmItem& aRight ) + { + return aLeft.iName->CompareC( *aRight.iName ); + }; + }; + +// ================= LOCAL FUNCTIONS ======================= + +void ResetAndDestroy(TAny* aAny) + { + RPointerArray* pointerArray = + reinterpret_cast *> (aAny); + pointerArray->ResetAndDestroy(); + } + +void ResetAndDestroyNamedLmItem(TAny* aAny) + { + RPointerArray* pointerArray = + reinterpret_cast *> (aAny); + pointerArray->ResetAndDestroy(); + } + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp130::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::InitTestL() + { + CLandmarkTestProcedureBase::InitTestL(); + + // PrepareDatabases + const TInt KNrOfDatabases = 5; + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + // List databases + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + iDbUris = dbMan->ListDatabasesLC(); + CleanupStack::Pop(iDbUris); + AssertTrueSecL(iDbUris->Count() == KNrOfDatabases, _L("Wrong number of test databases!")); + CleanupStack::PopAndDestroy(dbMan); + + iDbSearcher = CPosLmMultiDbSearch::NewL(*iDbUris); + + // Initialize expected landmark search result + + for ( TInt i = 0; i < iDbUris->Count(); i++ ) + { + RIdArray* lmArray = new (ELeave) RIdArray; + InitExpectedResultsL( (*iDbUris)[i], *lmArray, ETrue ); + iExpectedLmResult.AppendL( lmArray ); + + RIdArray* catArray = new (ELeave) RIdArray; + InitExpectedResultsL( (*iDbUris)[i], *catArray, EFalse ); + iExpectedCatResult.AppendL( catArray ); + } + + } + +// --------------------------------------------------------- +// CPosTp130::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::CloseTest() + { + delete iDbUris; + delete iDbSearcher; + for (TInt i = 0; i < iExpectedLmResult.Count(); i++) + { + iExpectedLmResult[i]->Close(); + iExpectedCatResult[i]->Close(); + } + iExpectedLmResult.ResetAndDestroy(); + iExpectedCatResult.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp130::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::StartL() + { + // nrOfExpectedMatches contains the number of matches for each db when search pattern is *e* + RArray nrOfExpectedMatches; + CleanupClosePushL(nrOfExpectedMatches); + for (TInt i = 0; i < KNrOfDatabases; i++) + { + nrOfExpectedMatches.AppendL((*iExpectedLmResult[i]).Count()); + } + +// 1. Search for landmarks + iLog->Log(_L("1")); + SearchForLandmarksL(); + +// 2-9. Verify result + iLog->Log(_L("2-9")); + VerifyIteratorsL(nrOfExpectedMatches, ETrue); + + iLog->Log(_L("10.true")); +// 10. Test iterators dynamically + TestMatchIteratorL(ETrue); + iLog->Log(_L("10.false")); + TestMatchIteratorL(EFalse); + + iLog->Log(_L("11")); +// 11. Test error codes + TestErrorCodesL(); + + iLog->Log(_L("12")); +// 12. Check iterators from matching categories + nrOfExpectedMatches.Reset(); + for (TInt i = 0; i < KNrOfDatabases; i++) + { + nrOfExpectedMatches.AppendL((*iExpectedCatResult[i]).Count()); + } + SearchForCategoriesL(); + VerifyIteratorsL(nrOfExpectedMatches, EFalse); + CleanupStack::PopAndDestroy(&nrOfExpectedMatches); + } + +// --------------------------------------------------------- +// CPosTp130::SearchForLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::SearchForLandmarksL() + { + // Search for landmarks containing a specific string in name + CPosLmTextCriteria* criteria = CPosLmTextCriteria::NewLC(); + criteria->SetTextL(KSearchPattern); + criteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + + // Do the search + ExecuteAndDeleteLD(iDbSearcher->StartLandmarkSearchL(*criteria)); + + // Check errors + TUint nrOfSearchErrors = iDbSearcher->NumOfSearchErrors(); + AssertTrueSecL(nrOfSearchErrors == 0, _L("Found errors during search")); + + CleanupStack::PopAndDestroy(criteria); + } + +// --------------------------------------------------------- +// CPosTp130::SearchForCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::SearchForCategoriesL() + { + // Search for categories containing a specific string in name + CPosLmCatNameCriteria* criteria = CPosLmCatNameCriteria::NewLC(); + criteria->SetSearchPatternL(KSearchPattern); + + // Do the search + ExecuteAndDeleteLD(iDbSearcher->StartCategorySearchL(*criteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + // Check errors + TUint nrOfSearchErrors = iDbSearcher->NumOfSearchErrors(); + AssertTrueSecL(nrOfSearchErrors == 0, _L("Found errors during search")); + + CleanupStack::PopAndDestroy(criteria); + } + +// --------------------------------------------------------- +// CPosTp130::VerifyIteratorsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::VerifyIteratorsL(RArray& aNrOfExpectedItems, TBool aLm) + { + RPointerArray iterators; + CleanupClosePushL(iterators); + CleanupStack::PushL(TCleanupItem(ResetAndDestroy, &iterators)); + + TInt totalNrOfMatches(0), totalNrOfExpectedMatches(0); + for (TInt i = 0; i < KNrOfDatabases; i++) + { + // 2. Ask for the iterator for each database + iterators.AppendL(iDbSearcher->MatchIteratorL(i)); + + // 3. Verify that the number of each iterator equals to the expected result + AssertTrueSecL(aNrOfExpectedItems[i] == iterators[i]->NumOfItemsL(), _L("aNrOfExpectedItems[i] != iterators[i]->NumOfItemsL()")); + AssertTrueSecL(aNrOfExpectedItems[i] == iDbSearcher->NumOfMatches(i), _L("aNrOfExpectedItems[i] != iDbSearcher->NumOfMatches(i)")); + + totalNrOfExpectedMatches += aNrOfExpectedItems[i]; + totalNrOfMatches += iterators[i]->NumOfItemsL(); + } + + // 4. Verify that the total number of matches equals the sum of expected + AssertTrueSecL(totalNrOfMatches == totalNrOfExpectedMatches, _L("totalNrOfMatches != totalNrOfExpectedMatches")); + AssertTrueSecL(totalNrOfMatches == iDbSearcher->TotalNumOfMatches(), _L("totalNrOfMatches != iDbSearcher->TotalNumOfMatches()")); + + for (TInt dbIndex = 0; dbIndex < KNrOfDatabases; dbIndex++) + { + // 5. Ask for the first item in each iterator + TPosLmItemId id1 = iterators[dbIndex]->NextL(); + + // 6. Perform an operation on the first item, e.g. read it from db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDbUris)[dbIndex]); + CleanupStack::PushL(db); + if (aLm) + { + CPosLandmark* lm = db->ReadLandmarkLC(id1); + TPtrC name; + lm->GetLandmarkName(name); + AssertTrueSecL(name.MatchC(KSearchPattern) != KErrNotFound, _L("First lm in iterator does not contain \"e\"")); + CleanupStack::PopAndDestroy(lm); + } + else + { + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + CPosLandmarkCategory* cat = catMan->ReadCategoryLC(id1); + TPtrC name; + cat->GetCategoryName(name); + AssertTrueSecL(name.MatchC(KSearchPattern) != KErrNotFound, _L("First category in iterator does not contain \"e\"")); + CleanupStack::PopAndDestroy(2, catMan); + } + CleanupStack::PopAndDestroy(db); + + RIdArray allIds; + CleanupClosePushL(allIds); + + // 7. Reset iterator and ask for next item + iterators[dbIndex]->Reset(); + TPosLmItemId id2 = iterators[dbIndex]->NextL(); + AssertTrueSecL(id1 == id2, _L("id1 != id2")); + allIds.AppendL(id2); + + // 8. Iterate until there are no more items to iterate + while (id2 != KPosLmNullItemId) + { + id2 = iterators[dbIndex]->NextL(); + allIds.AppendL(id2); + } + AssertTrueSecL(id2 == KPosLmNullItemId, _L("id2 != KPosLmNullItemId")); + + // 9. Ask for sequences of iterator + RIdArray idArray; + CleanupClosePushL(idArray); + TInt nrOfItems = iterators[dbIndex]->NumOfItemsL(); + for (TInt iterIndex = 0; iterIndex < nrOfItems; iterIndex++) + { + // Get sequence of the tail of the iterator + iterators[dbIndex]->GetItemIdsL(idArray, iterIndex, nrOfItems - iterIndex); + AssertTrueSecL(idArray.Count() == nrOfItems - iterIndex, _L("A: Wrong number of items in id array")); + for (TInt i = iterIndex; i < nrOfItems - iterIndex; i++) + { + id1 = idArray[i - iterIndex]; + id2 = allIds[i]; + AssertTrueSecL(id1 == id2, _L("A: Unexpected id in part of all ids array")); + } + + // Get sequence of the nose of the iterator + iterators[dbIndex]->GetItemIdsL(idArray, 0, iterIndex); + AssertTrueSecL(idArray.Count() == iterIndex, _L("B: Wrong number of items in id array")); + for (TInt j = 0; j < iterIndex; j++) + { + id1 = idArray[j]; + id2 = allIds[j]; + AssertTrueSecL(id1 == id2, _L("B: Unexpected id in part of all ids array")); + } + } + CleanupStack::PopAndDestroy(2, &allIds); + } + + CleanupStack::PopAndDestroy(2, &iterators); + } + +// --------------------------------------------------------- +// CPosTp130::TestErrorCodesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::TestErrorCodesL() + { + // No error codes to test + } + +// --------------------------------------------------------- +// CPosTp130::TestMatchIteratorL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp130::TestMatchIteratorL(TBool aSearchLm) + { + CMatchIteratorTester* matchIterTester = CMatchIteratorTester::NewLC(iDbUris, iLog); + CPosLmOperation* operation = NULL; + + if (aSearchLm) + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(KSearchPattern); + textCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + operation = iDbSearcher->StartLandmarkSearchL(*textCriteria, sortPref); + CleanupStack::PopAndDestroy(textCriteria); + + CleanupStack::PushL(operation); + matchIterTester->RunTestL(iDbSearcher, operation, iExpectedLmResult); + CleanupStack::Pop(operation); // ownership transferred + } + else + { + CPosLmCatNameCriteria* criteria = CPosLmCatNameCriteria::NewLC(); + criteria->SetSearchPatternL(KSearchPattern); + operation = iDbSearcher->StartCategorySearchL(*criteria, CPosLmCategoryManager::ECategorySortOrderNameAscending); + CleanupStack::PopAndDestroy(criteria); + + CleanupStack::PushL(operation); + matchIterTester->RunTestL(iDbSearcher, operation, iExpectedCatResult); + CleanupStack::Pop(operation); // ownership transferred + } + + TInt error = matchIterTester->Result(); + if (error != KErrNone) + { + TPtrC msg; + matchIterTester->GetErrorMsg(msg); + + iLog->Log(msg); + User::Leave(error); + } + + CleanupStack::PopAndDestroy(matchIterTester); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp130::InitExpectedResultsL( const TDesC& aDbName, RIdArray& aArray, TBool aSearchLm ) + { + iLog->Log( aDbName ); + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL( aDbName ); + CleanupStack::PushL( db ); + + if ( db->IsInitializingNeeded() ) + { + ExecuteAndDeleteLD( db->InitializeL() ); + } + + CPosLmCategoryManager* catman = CPosLmCategoryManager::NewL( *db ); + CleanupStack::PushL( catman ); + + RPointerArray items; + CleanupStack::PushL( TCleanupItem( ResetAndDestroyNamedLmItem, &items ) ); + + CPosLmItemIterator* iter = NULL; + if ( aSearchLm ) + { + iter = db->LandmarkIteratorL(); + } + else + { + iter = catman->CategoryIteratorL(); + } + CleanupStack::PushL( iter ); + + TPosLmItemId id = iter->NextL(); + while ( id != KPosLmNullItemId ) + { + CNamedLmItem* item = new (ELeave) CNamedLmItem; + CleanupStack::PushL( item ); + + item->iId = id; + + TPtrC name; + if ( aSearchLm ) + { + CPosLandmark* lm = db->ReadLandmarkLC( id ); + lm->GetLandmarkName( name ); + item->iName = name.AllocL(); + CleanupStack::PopAndDestroy( lm ); + } + else + { + CPosLandmarkCategory* cat = catman->ReadCategoryLC( id ); + cat->GetCategoryName( name ); + item->iName = name.AllocL(); + CleanupStack::PopAndDestroy( cat ); + } + + if ( item->iName->MatchC( KSearchPattern ) != KErrNotFound ) + { + items.AppendL( item ); + CleanupStack::Pop( item ); + } + else + { + CleanupStack::PopAndDestroy( item ); + } + id = iter->NextL(); + } + CleanupStack::PopAndDestroy( iter ); + + TLinearOrder order( CNamedLmItem::CompareByName ); + items.Sort( order ); + + aArray.Reset(); + for( TInt i = 0; i < items.Count(); i++ ) + { + aArray.AppendL( items[i]->iId ); + iLog->Log( _L("id: %d, name = '%S'"), items[i]->iId, items[i]->iName ); + } + + CleanupStack::PopAndDestroy(); // items + CleanupStack::PopAndDestroy( catman ); + CleanupStack::PopAndDestroy( db ); + } + +// ================= CMatchIteratorTester MEMBER FUNCTIONS ======================= + +// Constructor +CMatchIteratorTester::CMatchIteratorTester( + CDesCArray* aDbUris, CStifLogger* aLog ) +: CActive(CActive::EPriorityStandard), +iDbUris(aDbUris), iLog( aLog ) + { + CActiveScheduler::Add(this); + } + +// Destructor +CMatchIteratorTester::~CMatchIteratorTester() + { + Cancel(); + delete iErrorMsg; + delete iOperation; + iIterators.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CMatchIteratorTester::NewLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CMatchIteratorTester* CMatchIteratorTester::NewLC( + CDesCArray* aDbUris, CStifLogger* aLog) + { + CMatchIteratorTester* self = + new (ELeave) CMatchIteratorTester(aDbUris, aLog); + CleanupStack::PushL(self); + return self; + } + +// --------------------------------------------------------- +// CMatchIteratorTester::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::RunL() + { + iResult = iStatus.Int(); + VerifyIteratorsL(iResult); + + if (iStatus.Int() == KPosLmOperationNotComplete) + { + iOperation->NextStep(iStatus, iProgress); + SetActive(); + } + else + { + CActiveScheduler::Stop(); + } + } + +// --------------------------------------------------------- +// CMatchIteratorTester::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::DoCancel() + { + delete iOperation; + iOperation = NULL; + } + +// --------------------------------------------------------- +// CMatchIteratorTester::RunError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CMatchIteratorTester::RunError(TInt aError) + { + iResult = aError; + CActiveScheduler::Stop(); + return KErrNone; + } + +// --------------------------------------------------------- +// CMatchIteratorTester::RunTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::RunTestL( + CPosLmMultiDbSearch* aMultiSearcher, + CPosLmOperation* aSearchOperation, + RPointerArray& aExpectedResult) + { + iMultiSearcher = aMultiSearcher; + iExpectedResult = &aExpectedResult; + iOperation = aSearchOperation; + + // Initialize iIterators + for (TInt i = 0; i < iMultiSearcher->NumOfDatabasesToSearch(); i++) + { + CPosLmItemIterator* iterator = iMultiSearcher->MatchIteratorL(i); + CleanupStack::PushL(iterator); + User::LeaveIfError(iIterators.Append(iterator)); + CleanupStack::Pop(iterator); + } + + iOperation->NextStep(iStatus, iProgress); + SetActive(); + CActiveScheduler::Start(); + } + +// --------------------------------------------------------- +// CMatchIteratorTester::Result +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CMatchIteratorTester::Result() const + { + return iResult; + } + +// --------------------------------------------------------- +// CMatchIteratorTester::GetErrorMsg +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::GetErrorMsg(TPtrC& aMsg) const + { + aMsg.Set(*iErrorMsg); + } + +// --------------------------------------------------------- +// CMatchIteratorTester::VerifyIteratorsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::VerifyIteratorsL(TInt aResult) + { + for (TInt dbIndex = 0; dbIndex < iMultiSearcher->NumOfDatabasesToSearch(); dbIndex++) + { + CPosLmItemIterator* iterator = iMultiSearcher->MatchIteratorL(dbIndex); + CleanupStack::PushL(iterator); + CompareIteratorsL(*iterator, *iIterators[dbIndex]); + delete iIterators[dbIndex]; + iIterators[dbIndex] = iterator; + CleanupStack::Pop(iterator); + + // Verify matches are correct + TBuf<50> buf; + iterator->Reset(); + TPosLmItemId id = iterator->NextL(); + while (id != KPosLmNullItemId) + { + if ((*(*iExpectedResult)[dbIndex]).Find(id) == KErrNotFound) + { + buf.Format(_L("Cannot find match %d in expected result"), id ); + SetErrorAndLeaveL(buf); + } + id = iterator->NextL(); + } + + if (aResult == KErrNone) // Search is completed - result should be sorted ascending + { + RIdArray idArray; + CleanupClosePushL(idArray); + TInt nrOfItems = iterator->NumOfItemsL(); + iterator->GetItemIdsL(idArray, 0, nrOfItems); + for (TInt i = 0; i < nrOfItems; i++) + { + TPosLmItemId id1 = idArray[i]; + TPosLmItemId id2 = (*(*iExpectedResult)[dbIndex])[i]; + if (id1 != id2) + { + buf.Format(_L("Sorted result differs, %d != %d"), id1, id2); + SetErrorAndLeaveL(buf); + } + } + + TInt expectedLength = (*(*iExpectedResult)[dbIndex]).Count(); + if (nrOfItems != expectedLength) + { + buf.Format(_L("Length of arrays doesnät match, %d != %d"), nrOfItems, expectedLength); + SetErrorAndLeaveL(buf); + } + CleanupStack::PopAndDestroy(&idArray); + } + } + } + +// --------------------------------------------------------- +// CMatchIteratorTester::CompareIteratorsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::CompareIteratorsL( + CPosLmItemIterator& aNewIter, + CPosLmItemIterator& aOldIter) + { + TInt oldIterLength = aOldIter.NumOfItemsL(); + TInt newIterLength = aNewIter.NumOfItemsL(); + + if (newIterLength < oldIterLength) + { + SetErrorAndLeaveL(_L("aNewIter is shorter than aOldIter")); + } + + // Verify that all the items in the old iterator can be found in the new one + if (newIterLength > 0) + { + RArray newItemIds; + CleanupClosePushL(newItemIds); + aNewIter.GetItemIdsL(newItemIds, 0, newIterLength); + + aOldIter.Reset(); + TPosLmItemId id = aOldIter.NextL(); + while (id != KPosLmNullItemId) + { + TInt err = newItemIds.Find(id); + if (err == KErrNotFound) + { + SetErrorAndLeaveL(_L("aNewIter doesn't match aOldIter")); + } + id = aOldIter.NextL(); + } + + CleanupStack::PopAndDestroy(&newItemIds); + } + } + +// --------------------------------------------------------- +// CMatchIteratorTester::SetErrorAndLeaveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CMatchIteratorTester::SetErrorAndLeaveL(const TDesC& aErrMsg) + { + delete iErrorMsg; + iErrorMsg = NULL; + iErrorMsg = aErrMsg.AllocL(); + User::Leave(KErrGeneral); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp131.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp131.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,979 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp131.h" +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp131::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::CloseTest() + { + iLog->Log(_L("CloseTest")); + iSearchResults.ResetAndDestroy(); + + //CHECK TR Delete of landmarks search - ESLI-5WNG9N + delete iDatabase; + iDatabase = NULL; + + iLandmarkSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + } + +// --------------------------------------------------------- +// CPosTp131::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::StartL() + { + iErrorsFound = KErrNone; + // copy test db to the private path + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp131TestDb); + + TInt er = fileMan->Copy(srcPath, KLmTp131DefaultDbPath, + CFileMan::EOverWrite); + if (er != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp131TestDb); + CleanupStack::PopAndDestroy(manager); + + iDatabase = CPosLandmarkDatabase::OpenL(KTp131TestDb); + if (iDatabase->IsInitializingNeeded()) + { + TRAPD( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL(err == KErrNone, _L("Init db failed")); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + AppendSearchResultsL(); + + iLog->Log(_L("Testing search with a defined sortorder")); + SearchWithSortOrderL(iSearchResults); + + // Test Partial landmarks + iLog->Log(_L("Testing search with a defined sortorder for partial landmarks")); + SearchPartialLandmarksL(iSearchResults); + + iLog->Log(_L("Testing reset of DisplayData")); + CheckResetL(iSearchResults); + + iLog->Log(_L("Testing cancel and displaydata")); + CancelTestL(iSearchResults); + + // Test DisplayDataItem, create Landmark type + TUint dbIndex = 0; + CPosLandmark* lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("Tp131Landmarkname")); + CPosLmDisplayItem* item = CPosLmDisplayItem::NewL(lm, dbIndex); + CleanupStack::PushL(item); + + CPosLmDisplayItem::TDisplayItemType type = item->DisplayItemType(); + AssertTrueSecL(type == CPosLmDisplayItem::ELandmarkItem, _L("Wrong TDisplayItemType")); + CleanupStack::PopAndDestroy(item); + CleanupStack::Pop(lm); // lm deleted when deleting displaydata + + // Test DisplayDataItem, create Category type + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("Tp131CategoryName")); + item = CPosLmDisplayItem::NewL(category, dbIndex); + CleanupStack::PushL(item); + type = item->DisplayItemType(); + + AssertTrueSecL(type == CPosLmDisplayItem::ECategoryItem, _L("Wrong TDisplayItemType")); + CleanupStack::PopAndDestroy(item); + CleanupStack::Pop(category); // category deleted when deleting displaydata + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors were found in TP131")); + User::Leave(-1); + } + + } + +// --------------------------------------------------------- +// CPosTp131::ChechPartialLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const CPosLandmark::TAttributes& aAttr, const RArray& aReqFields) + { + _LIT(KPartialIdErr, "Incorrect Id when reading from a Partial landmark"); + _LIT(KPartialCategoryInfoErr, "Incorrect Category info when reading from a Partial landmark"); + + TPosLmItemId id = aLandmark.LandmarkId(); + AssertTrueSecL(id != 0, KPartialIdErr); + + AssertTrueSecL(aLandmark.IsPartial(), _L("Landmark is not partial")); + + TInt err; + TPtrC name; + err = aLandmark.GetLandmarkName(name); + // Name is always included + CheckPartialErrorCodeL(aAttr & CPosLandmark::ELandmarkName, err); + + TReal32 coverageR; + err = aLandmark.GetCoverageRadius(coverageR); + CheckPartialErrorCodeL(aAttr & CPosLandmark::ECoverageRadius, err); + + TPtrC desc; + err = aLandmark.GetLandmarkDescription(desc); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EDescription, err); + + TPtrC iconName; + TInt iconIndex; + TInt iconMaskIndex; + err = aLandmark.GetIcon(iconName, iconIndex, iconMaskIndex); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EIcon, err); + + RArray categories; + CleanupClosePushL(categories); + + aLandmark.GetCategoriesL(categories); + if (aAttr & CPosLandmark::ECategoryInfo) + { + AssertTrueSecL(categories.Count() != 0, KPartialCategoryInfoErr); + } + else + { + AssertTrueSecL(categories.Count() == 0, KPartialCategoryInfoErr); + } + CleanupStack::PopAndDestroy(&categories); + + TLocality loc; + err = aLandmark.GetPosition(loc); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EPosition, err); + + // Check PositionFields + // Check fields from EPositionFieldCompassCapabilitiesBegin up to EPositionFieldMediaCapabilitiesBegin+100 + // should be enough to also cover URL + for (TInt i=EPositionFieldCompassCapabilitiesBegin; iLog(value); + } + else if (!avail && found != KErrNotFound || avail && found == KErrNotFound) + { + // Fields 405 and 802 are not always set + if (i!=405 && i!=802) + { + TBuf<100> buf; + buf.Format(_L("ERROR: Mismatch in positionfields, id %d were not found"), i); + iLog->Log(buf); + iErrorsFound++; + } + } + } + } + +// --------------------------------------------------------- +// CPosTp131::ChechPartialErrorCodeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr) + { + _LIT(KPartialLmErr, "Incorrect error code returned when reading from a Partial landmark"); + + if (aPartial) + { + AssertTrueSecL(aErr == KErrNone, KPartialLmErr); + } + else + { + AssertTrueSecL(aErr == KErrNotFound, KPartialLmErr); + } + } + +// --------------------------------------------------------- +// CPosTp131::SearchPartialLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::SearchPartialLandmarksL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect"); + _LIT(KNumOfMatchesErr2, "No. of display data matches is incorrect"); + _LIT(KSortorderErr, "The sortorder is incorrect"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + iDisplayData = CPosLmDisplayData::NewL(); + iLandmarkSearch->SetDisplayData(*iDisplayData); + + // Only do search for index KWhatToSearchFor in lmDbSearchResult.txt + // index 11 is MLFW + TInt KWhatToSearchFor = 11; + textCriteria->SetTextL(aSearchResults[KWhatToSearchFor]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[KWhatToSearchFor]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[KWhatToSearchFor]->PositionFields()); + + RArray reqFields; + CleanupClosePushL(reqFields); + + iLog->Log(aSearchResults[KWhatToSearchFor]->TextCriteria()); + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + CPosLmPartialReadParameters* fakePartialParam = CPosLmPartialReadParameters::NewLC(); + reqFields.Append(EPositionFieldStreet); + fakePartialParam->SetRequestedPositionFields(reqFields); + reqFields.Reset(); + + // Dont search for all search criteras + // takes just too long time on target (approx 1 hour for this test on target) + + // Search for all combinations from 0 - CPosLandmark::EDescription + // Ex attr=0, attr=1, attr=2, attr=3, .....attr=63, +#ifdef __WINS__ + TUint max = CPosLandmark::EDescription; + max <<= 1; + max -= 1; +#else + TUint max = CPosLandmark::ECategoryInfo; + max <<= 1; + max -= 1; +#endif + + TUint attr=0; + for (attr=0; attr<=max; attr++) + { + partialParam->SetRequestedAttributes(attr); + reqFields.Reset(); + + if (attr == 5) + { + // Add EPositionFieldCountry + iLog->Log(_L("Also cover EPositionFieldCountry")); + reqFields.Append(EPositionFieldCountry); + } + else if (attr == 12) + { + // Add EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry + iLog->Log(_L("Also cover EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry")); + reqFields.Append(EPositionFieldCity); + reqFields.Append(EPositionFieldStreet); + reqFields.Append(EPositionFieldCountry); + + } + else if (attr == 32) + { + // Add EPositionFieldMediaLinksStart, EPositionFieldDistrict + iLog->Log(_L("Also cover EPositionFieldMediaLinksStart, EPositionFieldDistrict")); + reqFields.Append(EPositionFieldMediaLinksStart); + reqFields.Append(EPositionFieldDistrict); + } + + iDisplayData->UnsetPartialReadParameters(); + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + + for (TInt i=0; i<2; i++) + { + switch (i) + { + case 0: + { + //**** async + //iLog->Log(_L("*****Async, EDescending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iAscendedSorted = EFalse; + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[KWhatToSearchFor]->Redefined()); + // Test that if SetPartialReadParametersL is called after search has started it has no affect + iDisplayData->SetPartialReadParametersL(*fakePartialParam); + ExecuteLmOpL(); + } + break; + case 1: + { + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + //iLog->Log(_L("*****Async EAscending")); + iAscendedSorted = ETrue; + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[KWhatToSearchFor]->Redefined()); + ExecuteLmOpL(); + } + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray* searchResults = &aSearchResults[KWhatToSearchFor]->SearchResult(); + if ((TUint)searchResults->Count() != iLandmarkSearch->NumOfMatches()) + { + TBuf<50> buf; + buf.Append(_L("KNumOfMatchesError when searching for ")); + buf.Append(aSearchResults[KWhatToSearchFor]->TextCriteria()); + iLog->Log(buf); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + + } + + // Check correct displayData + AssertTrueSecL(iter->NumOfItemsL() == iDisplayData->Count(), KNumOfMatchesErr2); + LandmarksSortL(*searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + + CPosLandmark* target = iDatabase->ReadLandmarkLC((*searchResults)[ii]); + TPtrC sourceName, targetName; + item.Landmark().GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + if (lmId != (*searchResults)[ii]) + { + // If found multiple match -> "Mölndal" etc + //Check if same name then don't Leave + AssertTrueSecL(sourceName.CompareC(targetName) == 0,KSortorderErr, lmId); + } + else + { + //CompareLandmarksL(item.Landmark(), *target); + // Add some check of partial landmarks here + AssertTrueSecL(sourceName.CompareC(targetName) == 0,KSortorderErr, lmId); + + // Landmarkname is always included when sorting + CheckPartialLandmarkL(item.Landmark() , attr | CPosLandmark::ELandmarkName, reqFields); + } + + CleanupStack::PopAndDestroy(target); + id = iter->NextL(); + + ++ii; + } + CleanupStack::PopAndDestroy(iter); + iDisplayData->Reset(); + } + } + + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(fakePartialParam); + CleanupStack::PopAndDestroy(partialParam); + CleanupStack::PopAndDestroy(&reqFields); + CleanupStack::PopAndDestroy(textCriteria); + delete iDisplayData; + iDisplayData = NULL; + } + +// --------------------------------------------------------- +// CPosTp131::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::SearchWithSortOrderL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect"); + _LIT(KNumOfMatchesErr2, "No. of display data matches is incorrect"); + _LIT(KSortorderErr, "The sortorder is incorrect"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + iDisplayData = CPosLmDisplayData::NewL(); + iLandmarkSearch->SetDisplayData(*iDisplayData); + + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + RArray reqFields; + CleanupClosePushL(reqFields); + + // Test that UnsetPartialReadParameters works + reqFields.Append(EPositionFieldCountry); + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + CleanupStack::PopAndDestroy(&reqFields); + CleanupStack::PopAndDestroy(partialParam); + iDisplayData->UnsetPartialReadParameters(); + + // Dont search for all search criteras (see excel file) + // takes just too long time on target (approx 1 hour for this test on target) + // therefore start at j=7 +#ifdef __WINS__ + for(TInt j=2; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + + iLog->Log(aSearchResults[j]->TextCriteria()); + + // Dont test sync search + for (TInt i=2; i<6; i++) + { + switch (i) + { + //**** sync + case 0: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + } + break; + case 1: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + } + break; + case 2: + { + //**** async + //iLog->Log(_L("*****Async, EDescending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iAscendedSorted = EFalse; + //iLog->Log(_L("Start")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); + ExecuteLmOpL(); + //iLog->Log(_L("Done")); + } + break; + case 3: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + //iLog->Log(_L("*****Async EAscending")); + iAscendedSorted = ETrue; + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); + ExecuteLmOpL(); + } + break; + //**** asych with User::WaitForRequest() + case 4: + { + //iLog->Log(_L("*****User::WaitForRequest() EDescending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + case 5: + { + //iLog->Log(_L("*****User::WaitForRequest() EAscending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray* searchResults = &aSearchResults[j]->SearchResult(); + if ((TUint)searchResults->Count() != iLandmarkSearch->NumOfMatches()) + { + TBuf<50> buf; + buf.Append(_L("KNumOfMatchesError when searching for ")); + buf.Append(aSearchResults[j]->TextCriteria()); + iLog->Log(buf); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + // Check correct displayData + AssertTrueSecL(iter->NumOfItemsL() == iDisplayData->Count(), KNumOfMatchesErr2); + LandmarksSortL(*searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + + CPosLandmark* target = iDatabase->ReadLandmarkLC((*searchResults)[ii]); + TPtrC sourceName, targetName; + item.Landmark().GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + if (lmId != (*searchResults)[ii]) + { + // If found multiple match -> "Mölndal" etc + //Check if same name then don't Leave + AssertTrueSecL(sourceName.CompareC(targetName) == 0,KSortorderErr, lmId); + } + else + { + CompareLandmarksL(item.Landmark(), *target); + } + + CleanupStack::PopAndDestroy(target); + id = iter->NextL(); + + ++ii; + } + CleanupStack::PopAndDestroy(iter); + iDisplayData->Reset(); + } + } + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(textCriteria); + delete iDisplayData; + iDisplayData = NULL; + } + +// --------------------------------------------------------- +// CPosTp131::CheckResetL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::CheckResetL(const RPointerArray& aSearchResults) + { + iLog->Log(_L("CheckResetL")); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + + // Sync + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[j]->Redefined())); + AssertTrueSecL(iLandmarkSearch->NumOfMatches() == displayData->Count(),_L("Wrong number of matches1"),j); + displayData->Reset(); + AssertTrueSecL(displayData->Count() == 0,_L("DisplayData should have been resetted")); + + // Async + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[j]->Redefined())); + AssertTrueSecL(iLandmarkSearch->NumOfMatches() == displayData->Count(),_L("Wrong number of matches2"),j); + + RArray* searchResults = &aSearchResults[j]->SearchResult(); + //AssertTrueSecL(iLandmarkSearch->NumOfMatches() == searchResults->Count(),_L("Wrong number of matches3"),j); + if (iLandmarkSearch->NumOfMatches() != searchResults->Count()) + { + TBuf<150> buf; + buf.Format(_L("Exp %d nr of matches, got %d, searching for: "), searchResults->Count(), iLandmarkSearch->NumOfMatches()); + buf.Append(aSearchResults[j]->TextCriteria()); + iLog->Log(buf); + } + + AssertTrueSecL(displayData->Count() == iLandmarkSearch->NumOfMatches(),_L("DisplayData matches is not correct")); + + } + + // Test unset of displaydata + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + + displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + iLandmarkSearch->UnsetDisplayData(); + + textCriteria->SetTextL(aSearchResults[0]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[0]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[0]->PositionFields()); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); + AssertTrueSecL(displayData->Count() == 0,_L("No matches should be found in DisplayData")); + + iLandmarkSearch->SetDisplayData(*displayData); + + textCriteria->SetTextL(aSearchResults[0]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[0]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[0]->PositionFields()); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); + RArray* searchResults = &aSearchResults[0]->SearchResult(); + AssertTrueSecL(iLandmarkSearch->NumOfMatches() == displayData->Count(),_L("Wrong number of matches4")); + AssertTrueSecL(iLandmarkSearch->NumOfMatches() == searchResults->Count(),_L("Wrong number of matches5")); + + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp131::CancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::CancelTestL(const RPointerArray& aSearchResults) + { + iLog->Log(_L("CancelTestL")); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Cancel search operation and verify that the displayData result is sorted correctly + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + for (TInt pp=0;pp<2;pp++) + { + if (pp == 0) + { + //iLog->Log(_L("Sorting Descending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + } + else { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + //iLog->Log(_L("Sorting Ascending")); + } + + // Set DisplayData + iLandmarkSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + + TBuf<150> buf; + buf.Append(aSearchResults[j]->TextCriteria()); + //iLog->Log(buf); + + // Cancel operation in callback + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, EFalse)); + AssertTrueSecL(iLandmarkSearch->NumOfMatches() == displayData->Count(),_L("Wrong number of matches after cancel"),j); + + buf.Zero(); + buf.Format(_L("Search returned %d nr of matches, displayData %d nr of matches"),iLandmarkSearch->NumOfMatches(), displayData->Count()); + //iLog->Log(buf); + + // Check sort order below + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (iter->NumOfItemsL()>0) + { + RArray arr; + CleanupClosePushL(arr); + iter->GetItemIdsL(arr, 0, iter->NumOfItemsL()); + + // Sort matchiterator + LandmarksSortL(arr, sortPref); + + TInt index=0; + TInt itemId = displayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item = displayData->DisplayItem(itemId); + + AssertTrueSecL(item.DisplayItemType() == CPosLmDisplayItem::ELandmarkItem, + _L("Wrong item returned, only ELandmarkItem should be returned")); + + AssertTrueSecL(item.DatabaseIndex() == 0, _L("Wrong DatabaseIndex, should be 0")); + + TInt lmId = item.Landmark().LandmarkId(); + + + // AssertTrueSecL(arr[index] == lmId , _L("Incorrect sortorder")); + CPosLandmark* lm = iDatabase->ReadLandmarkLC(arr[index]); + + if ( arr[index] != lmId ) + { + TPtrC sourceName; + item.Landmark().GetLandmarkName(sourceName); + TPtrC name2; + lm->GetLandmarkName(name2); + iLog->Log( _L("CancelTestL: #%02d, exp %d, act %d, '%S', '%S'"), + index, arr[index], lmId, &name2, &sourceName ); + + if ( sourceName.CompareC( name2 ) != 0 ) + { + AssertTrueSecL( arr[index] == lmId, _L("Incorrect sort order") ); + } + } + else + { + CompareLandmarksL(*lm, item.Landmark()); + } + + itemId = displayData->NewItemIndex(); + index++; + CleanupStack::PopAndDestroy(lm); + } + CleanupStack::PopAndDestroy(&arr); + } + CleanupStack::PopAndDestroy(iter); + } + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// Tp131InternalLandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt Tp131InternalLandmarksSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) + { + TPtrC sourceName, targetName; + + User::LeaveIfError(aSource.GetLandmarkName(sourceName)); + User::LeaveIfError(aTarget.GetLandmarkName(targetName)); + + return sourceName.CompareC(targetName); + } + +// --------------------------------------------------------- +// CPosTp131::LandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::LandmarksSortL(RArray& aArray, const TPosLmSortPref& aSortPref) + { + + RPointerArray landmarks; + CleanupClosePushL(landmarks); + + for (TInt i=0; iReadLandmarkLC(aArray[i]); + landmarks.Append(lm); + CleanupStack::Pop(lm); + } + + TLinearOrder order(Tp131InternalLandmarksSortL); + landmarks.Sort(order); + + aArray.Reset(); + + if (aSortPref.SortOrder() == TPosLmSortPref::EAscending) + { + for (TInt j=0; jLandmarkId()); + } + } + else + { + for (TInt k=landmarks.Count()-1; k>=0; k--) + { + aArray.Append(landmarks[k]->LandmarkId()); + } + } + landmarks.ResetAndDestroy(); + CleanupStack::PopAndDestroy(&landmarks); + + } + +// --------------------------------------------------------- +// CPosTp131::ExecuteLmOpL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::ExecuteLmOpL() + { + CActiveLmOperation* operationWrapper = new (ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(operationWrapper); + + operationWrapper->Start(iOperation, this); + CActiveScheduler::Start(); + + operationWrapper->CheckOperationL(); + operationWrapper->DeleteOperationD(); + + CleanupStack::PopAndDestroy(operationWrapper); + + } + +// --------------------------------------------------------- +// CPosTp131::NotifyProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp131::NotifyProgress(TReal aProgress) + { + + TBuf<100> buf; + + TInt progress = (TInt) (aProgress * 100); + buf.Format(_L("Progress: %d"), progress); + + + if (iDisplayData) + { + + + if (iDisplayData->Count()>0) + { + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray arr; + CleanupClosePushL(arr); + iter->GetItemIdsL(arr, 0, iter->NumOfItemsL()); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + if (iAscendedSorted) sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + else sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + // Sort matchiterator + LandmarksSortL(arr, sortPref); + + if (iter->NumOfItemsL() != iDisplayData->Count()) + { + iLog->Log(_L("Error: Wrong number of items")); + iErrorsFound++; + } + + TInt itemId = iDisplayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(itemId); + + if (item.DisplayItemType() != CPosLmDisplayItem::ELandmarkItem) + { + iLog->Log(_L("Error: TDisplayItemType should be ELandmarkItem")); + iErrorsFound++; + } + + if (item.DatabaseIndex() != 0) + { + // When single search, index should always be 0 + iLog->Log(_L("Error: Wrong DatabaseIndex, should be 0")); + iErrorsFound++; + } + + TPtrC lmName; + item.Landmark().GetLandmarkName(lmName); + TInt lmId = item.Landmark().LandmarkId(); + + // Compare all landmarks from CPosLmDisplayItem and landmarks from MatchIteratorL + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TPtrC sourceName; + item.Landmark().GetLandmarkName(sourceName); + + + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(arr[i]); + TPtrC name; + lm2->GetLandmarkName(name); + + + // Only compare names + if (name.Compare(sourceName) != 0) + { + iLog->Log(_L("ERROR: No match, name %S, sourceName %S"), &name, &sourceName); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(lm2); + } + + itemId = iDisplayData->NewItemIndex(); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(iter); + } + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp132.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp132.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,696 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp132.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +// CONSTANTS +//EPosLmServer +_LIT(KPosLandmarksServerName, "*eposlmserver*"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp132::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp132::StartL() + { + MakeSurePanicDebugFileExistsL(); + + iUseLogFromThreadIsDisabled = ETrue; + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + iErrorsFound = KErrNone; + + // Use multiple db + _LIT(KDb20, "EPOSLM_020.LDB"); + _LIT(KDb40, "EPOSLM_040.LDB"); + _LIT(KDb60, "EPOSLM_060.LDB"); + _LIT(KDb80, "EPOSLM_080.LDB"); + _LIT(KDb105, "EPOSLM_105.LDB"); + + // Copy to secure area + + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // <<<<<<<<<<<<<>>>>>>>>>>>>>>>>>> + iLog->Log(_L(">>>>>>>Start Panic test<<<<<<<<<")); + + // 1 Try to get item from DisplayData::DisplayItem outside accepted interval + // Should panic with EPosInvalidIndex + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 1")); + iTestCase = 1; + iExpectedErrorCode = EPosInvalidIndex; + ResumeThreadAndVerifyExit(); + + // 2 Try to get item from DisplayData::DisplayItem outside accepted interval + // Should panic with EPosInvalidIndex + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 2")); + iTestCase = 2; + iExpectedErrorCode = EPosInvalidIndex; + ResumeThreadAndVerifyExit(); + + // 3 Set displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 3")); + iTestCase = 3; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // 4 Unset displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 4")); + iTestCase = 4; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // 5 Unset displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 5")); + iTestCase = 5; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // Nothing seems to happen, no leave or no panic + // 6 NULL check, try to set DisplayData as NULL + iExpectedExitType = ExitNormal; + iLog->Log(_L("Panic test 6")); + iTestCase = 6; + iExpectedErrorCode = KErrNone; + ResumeThreadAndVerifyExit(); + + // 7 Delete displaydata during search -> "may lead to unexpected errors" + // For some reason it panics with Kern-Exec 3 + /* Excerpt from EPos_CPosLandmarkSearch.h + * The client owns the display data object. If the client deletes it + * during a search, this may lead to unexpected errors. The client must + * call @ref UnsetDisplayData before it deletes the display data object. + */ + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 7")); + iTestCase = 7; + //iExpectedErrorCode = KErrNone; + iExpectedErrorCode = 3; // Kern-Exec 3 + ResumeThreadAndVerifyExit(); + + // Test multi db search below + // 8) Set displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 8")); + iTestCase = 8; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // 9) Unset displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 9")); + iTestCase = 9; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // 10) Unset displaydata during search, should panic with EPosSearchOperationInUse + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 10")); + iTestCase = 10; + iExpectedErrorCode = EPosSearchOperationInUse; + ResumeThreadAndVerifyExit(); + + // 11 Delete displaydata during search -> "may lead to unexpected errors" + /* The client owns the display data object. If the client deletes it + * during a search, this may lead to unexpected errors. The client must + * call @ref UnsetDisplayData before it deletes the display data object. + */ + // For some reason it panics with Kern-Exec 3 + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 11")); + iTestCase = 11; + iExpectedErrorCode = 3; //3 Kern-Exec 3 + ResumeThreadAndVerifyExit(); + + // 12) Use the CPosLmDisplayItem::Category() function on a Landmark item + // Should panic with EPosInvalidItemType + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 12")); + iTestCase = 12; + iExpectedErrorCode = EPosInvalidItemType; + ResumeThreadAndVerifyExit(); + + // 13) Use the CPosLmDisplayItem::Landmark() function on a Category item + // Should panic with EPosInvalidItemType + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 13")); + iTestCase = 13; + iExpectedErrorCode = EPosInvalidItemType; + ResumeThreadAndVerifyExit(); + + // 14) Set DisplayData to NULL and do multipledb search + // Nothing seems to happen, everything is OK + iExpectedExitType = ExitNormal; + iLog->Log(_L("Panic test 14")); + iTestCase = 14; + iExpectedErrorCode = KErrNone; + ResumeThreadAndVerifyExit(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("TP132 Failed")); + User::Leave(-1); + } + iLog->Log(_L(">>>>>>>Panic test Done<<<<<<<<<")); + } + +// --------------------------------------------------------- +// CPosTp132::ResumeThreadAndVerifyExit +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp132::ResumeThreadAndVerifyExit() + { + iLog->Log(_L("ResumeThreadAndVerifyExit")); + _LIT(KPanicErr, "Err: Method didn't Panic when expected"); + _LIT(KPanicCodeErr, "Err: Paniced with unexpected panic code"); + _LIT(KLeaveErr, "Err: Method didn't end correctly"); + _LIT(KLeaveCodeErr, "Err: Unexpected leave error"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + + User::WaitForRequest(status); + + // Used for debugging + TBuf<100> buf; + buf.Format(_L("ExitType %d Exit reason %d "), iThread.ExitType(), iThread.ExitReason()); + iLog->Log(buf); + + TExitCategoryName buf1; + buf1=iThread.ExitCategory(); + iLog->Log(buf1); + + if (iExpectedExitType == ExitPanic) + { + + if (iThread.ExitType() != EExitPanic) + {iErrorsFound++;iLog->Log(KPanicErr);} + + if(iTestCase != 11) + { + if (iThread.ExitReason() != iExpectedErrorCode) + {iErrorsFound++;iLog->Log(KPanicCodeErr);} + } + + } + else if (iExpectedExitType == ExitLeave) + { + + if (iThread.ExitType() != EExitKill) + {iErrorsFound++;iLog->Log(KLeaveErr);} + + if (iThread.ExitReason() != iExpectedErrorCode) + {iErrorsFound++;iLog->Log(KLeaveCodeErr);} + } + else if (iExpectedExitType == ExitNormal) + { + + if (iThread.ExitType() != KErrNone) + {iErrorsFound++;iLog->Log(KLeaveErr);} + + if (iThread.ExitReason() != iExpectedErrorCode) + {iErrorsFound++;iLog->Log(KLeaveCodeErr);} + } + + iThread.Close(); + + TBool alive = ServerAlive(KPosLandmarksServerName); + if (!alive) + { + iLog->Log(_L("Landmarks Server is not alive")); + User::Leave(-1); + + } + } + +// --------------------------------------------------------- +// CPosTp132::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp132::CloseTest() + { + iLog->Log(_L("CloseTest")); + iThread.Close(); + + delete iDatabase; + iDatabase = NULL; + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp132::UnsetTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp132::UnsetTest(TAny* aSelf) + { + CPosLandmarkSearch* aLmSearch = static_cast(aSelf); + aLmSearch->UnsetDisplayData(); + return 0; + } + +// --------------------------------------------------------- +// CPosTp132::UnsetMultiSearch +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp132::UnsetMultiSearch(TAny* aSelf) + { + CPosLmMultiDbSearch* aLmSearch = static_cast(aSelf); + aLmSearch->UnsetDisplayData(); + return 0; + } + +// --------------------------------------------------------- +// CPosTp132::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp132::RunPanicTestL(TAny* aData) + { + CPosTp132* self = reinterpret_cast(aData); + + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkSearch* lmSearch = CPosLandmarkSearch::NewL(*database); + CleanupStack::PushL(lmSearch); + + CDesCArray* dbUris = new (ELeave) CDesC16ArrayFlat(2); + CleanupStack::PushL(dbUris); + + _LIT(KDb20, "c:EPOSLM_020.LDB"); + _LIT(KDb40, "c:EPOSLM_040.LDB"); + + dbUris->AppendL(KDb20); + dbUris->AppendL(KDb40); + + if (self->iTestCase == 1 || self->iTestCase == 2) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + lmSearch->SetDisplayData(*displayData); + + textCriteria->SetTextL(_L("*")); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(operation); + operation = NULL; + + // Outside accepted interval, should Panic with EPosInvalidIndex + if (self->iTestCase == 1) + { + CPosLmDisplayItem& item = displayData->DisplayItem(displayData->Count()); + } + else if (self->iTestCase == 2) + { + CPosLmDisplayItem& item = displayData->DisplayItem(-1); + } + + lmSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + + } + else if (self->iTestCase == 3) + { + // Set displaydata during search, should panic with EPosSearchOperationInUse + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + textCriteria->SetTextL(_L("*")); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + lmSearch->SetDisplayData(*displayData); + + ExecuteAndDeleteLD(operation); + operation = NULL; + + lmSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + } + else if (self->iTestCase == 4) + { + // Unset displaydata during search, should panic with EPosSearchOperationInUse + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + lmSearch->SetDisplayData(*displayData); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + lmSearch->UnsetDisplayData(); + ExecuteAndDeleteLD(operation); + operation = NULL; + + lmSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + + } + else if (self->iTestCase == 5) + { + // Unset displaydata during search, should panic with EPosSearchOperationInUse + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + lmSearch->SetDisplayData(*displayData); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + // Unset displaydata in callback method + TCallBack callback(UnsetTest, lmSearch); + CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); + CleanupStack::PushL(periodicTimer); + periodicTimer->Start(1, 1, callback); + + self->RunAsyncOperationLD(operation); + operation = NULL; + + CPosLmItemIterator* iter = lmSearch->MatchIteratorL(); + TInt size = iter->NumOfItemsL(); + + CleanupStack::PopAndDestroy(periodicTimer); + lmSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + + } + else if (self->iTestCase == 6) + { + // NULL check + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = NULL; + lmSearch->SetDisplayData(*displayData); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(operation); + operation = NULL; + + CPosLmItemIterator* iter = lmSearch->MatchIteratorL(); + TInt size = iter->NumOfItemsL(); + + lmSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(textCriteria); + } + else if (self->iTestCase == 7) + { + // Delete displaydata during search, "may lead to unexpected errors" + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Set DisplayData + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + lmSearch->SetDisplayData(*displayData); + + CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse); + + // Delete display data here + CleanupStack::PopAndDestroy(displayData); + ExecuteAndDeleteLD(operation); + operation = NULL; + + CleanupStack::PopAndDestroy(textCriteria); + } + else if (self->iTestCase == 8) + { + // Set displaydata during search, should panic with EPosSearchOperationInUse + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + multiSearcher->SetDisplayData(*displayData); + ExecuteAndDeleteLD(operation); + operation = NULL; + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(multiSearcher); + + } + else if (self->iTestCase == 9) + { + // Unset displaydata during search, should panic with EPosSearchOperationInUse + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + multiSearcher->UnsetDisplayData(); + ExecuteAndDeleteLD(operation); + operation = NULL; + + multiSearcher->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(multiSearcher); + } + else if (self->iTestCase == 10) + { + // Unset displaydata during search, should panic with EPosSearchOperationInUse + // Unset displaydata in callback method + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + + TCallBack callback(UnsetMultiSearch, lmSearch); + CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); + CleanupStack::PushL(periodicTimer); + periodicTimer->Start(1, 1, callback); + self->RunAsyncOperationLD(operation); + operation = NULL; + + ExecuteAndDeleteLD(operation); + multiSearcher->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(multiSearcher); + } + else if (self->iTestCase == 11) + { + // Delete displaydata during search, "may lead to unexpected errors" + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + // Delete displaydata here + delete displayData; + + ExecuteAndDeleteLD(operation); + operation = NULL; + + CleanupStack::PopAndDestroy(multiSearcher); + } + else if (self->iTestCase == 12) + { + // Use the CPosLmDisplayItem::Category() function on a Landmark item + // Should panic with EPosInvalidItemType + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(operation); + + // Verify that something was found + if (displayData->Count() < 2) User::Leave(-900); + + CPosLmDisplayItem& item = displayData->DisplayItem(0); + TInt lmId = item.Landmark().LandmarkId(); + + if (item.DisplayItemType() != CPosLmDisplayItem::ELandmarkItem) User::Leave(-901); + + // This call should panic + item.Category(); + + multiSearcher->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(multiSearcher); + } + else if (self->iTestCase == 13) + { + // Use the CPosLmDisplayItem::Landmark() function on a Category item + // Should panic with EPosInvalidItemType + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + ExecuteAndDeleteLD(operation); + + // Verify that something was found + if (displayData->Count() < 2) User::Leave(-900); + + CPosLmDisplayItem& item = displayData->DisplayItem(0); + TInt lmId = item.Landmark().LandmarkId(); + + if (item.DisplayItemType() != CPosLmDisplayItem::ECategoryItem) User::Leave(-901); + + // This call should panic + item.Landmark(); + + multiSearcher->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(multiSearcher); + } + else if (self->iTestCase == 14) + { + // NULL check, set DisplayData to NULL + CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris); + CleanupStack::PushL(multiSearcher); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + CPosLmDisplayData* displayData = NULL; + multiSearcher->SetDisplayData(*displayData); + + CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(operation); + + multiSearcher->UnsetDisplayData(); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(multiSearcher); + } + + CleanupStack::PopAndDestroy(dbUris); + CleanupStack::PopAndDestroy(lmSearch); + CleanupStack::PopAndDestroy(database); + } + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp132::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp132::CreateThreadL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp132::CreateThreadL() + { + _LIT(KCreateThreadErr, "Create thread failed with %d"); + TBuf<100> buf; + buf.Format(_L("Tp132 test thread %d"), iTestCase); + TInt err=0; + err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp133.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp133.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1063 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp133.h" +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include + +#include +#include + +// CONSTANTS +const TInt KNrOfDatabases = 5; +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp133::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::CloseTest() + { + iLog->Log(_L("CloseTest")); + iSearchResults.ResetAndDestroy(); + + delete iDatabase; + iDatabase = NULL; + + delete iDisplayData; + iDisplayData = NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("Problem when removing all lm databases")); + } + +// --------------------------------------------------------- +// CPosTp133::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::StartL() + { + _LIT(KDb20, "EPOSLM_020.LDB"); + _LIT(KDb40, "EPOSLM_040.LDB"); + _LIT(KDb60, "EPOSLM_060.LDB"); + _LIT(KDb80, "EPOSLM_080.LDB"); + _LIT(KDb105, "EPOSLM_105.LDB"); + + // PrepareDatabases + RemoveAllLmDatabasesL(); + CopyTestDbFileL(KDb20); + CopyTestDbFileL(KDb40); + CopyTestDbFileL(KDb60); + CopyTestDbFileL(KDb80); + CopyTestDbFileL(KDb105); + + iDisplayData = NULL; + iLandmarkSearch = NULL; + + CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbMan); + CDesCArray* dbUris = dbMan->ListDatabasesLC(); + CleanupStack::Pop(dbUris); + CleanupStack::PopAndDestroy(dbMan); + CleanupStack::PushL(dbUris); + + AssertTrueSecL(dbUris->Count() == KNrOfDatabases, _L("Wrong number of test databases!")); + + // Use this db as a template for how the result from multiple db search should be sorted + // used mostly in LandmarksSortL + iDatabase = UseGeneratedDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + AppendSearchResultsL(); + + DoSearchL(iSearchResults, dbUris, ESynchronous); + + DoSearchL(iSearchResults, dbUris, EAsynchronous); + + // Test Partial landmarks + iLog->Log(_L("Testing search with a defined sortorder for partial landmarks")); + + // Only do search for index KWhatToSearchFor in lmDbSearchResult.txt + // index 11 is MLFW + TInt KWhatToSearchFor = 11; + SearchPartialLandmarksL(KWhatToSearchFor, iSearchResults, dbUris); + + // index 20 is x + KWhatToSearchFor = 20; + SearchPartialLandmarksL(KWhatToSearchFor, iSearchResults, dbUris); + + iLog->Log(_L("Testing search for partial landmarks without name")); + SearchPartialWithoutNameL(iSearchResults, dbUris); + + iLog->Log(_L("Testing reset of DisplayData")); + CheckResetL(iSearchResults, dbUris); + + iLog->Log(_L("Testing cancel and displaydata, cancel immeditely")); + CancelTestL(iSearchResults, dbUris, EFalse); + + iLog->Log(_L("Testing cancel and displaydata, cancel in callback")); + CancelTestL(iSearchResults, dbUris, ETrue); + + CleanupStack::PopAndDestroy(dbUris); + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors were found in TP133")); + User::Leave(-1); + + } + } + +// --------------------------------------------------------- +// CPosTp133::DoSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::DoSearchL(const RPointerArray& aSearchResults, + CDesCArray* aDbUris, TExecutionMode aExecutionMode) + { + iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TBuf<150> buf; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Dont search for all search criteras (see excel file) + // takes just too long time on target (approx 1 hour for this test on target) + // therefore start at j=2 +#ifdef __WINS__ + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) + { + // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h + // they contain the 802 field (instead of 803) so append this id as well + RArray arr; + iLog->Log(_L("Found 803")); + arr = aSearchResults[j]->PositionFields(); + arr.Append(802); + textCriteria->SetPositionFieldsToSearchL(arr); + } + else + { + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + } + + iLog->Log(_L(">>>>>>Searching for: ")); + iLog->Log(aSearchResults[j]->TextCriteria()); + + // Sort ascended and descended + for (TInt sorted=0;sorted<2;sorted++) + { + iDisplayData = CPosLmDisplayData::NewL(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + + switch (sorted) + { + case 0: + iLog->Log(_L("******Sorting EAscending*******")); + iAscendedSorted = ETrue; + sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + break; + case 1: + iLog->Log(_L("**********Sorting EDescending**********")); + iAscendedSorted = EFalse; + sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + break; + } + + iJustNowSearchResults = &aSearchResults[j]->SearchResult(); + LandmarksSortL(*iJustNowSearchResults, sortPref); + iLastNrOfDisplayData = 0; + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); + switch (aExecutionMode) + { + case ESynchronous: + iLog->Log(_L("ESynchronous")); + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + iLog->Log(_L("EAsynchronous")); + // Also check progress here + ExecuteLmOpL(); + break; + } + + + // Check for any errors when multi searching + if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) + { + iLog->Log(_L("Errors after multi db search")); + User::Leave(-1); + } + + TInt number = iDisplayData->Count(); + buf.Zero(); + buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); + iLog->Log(buf); + + AssertTrueSecL(iDisplayData->Count() == iJustNowSearchResults->Count(),_L("Mismatch in number of matches")); + + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + CPosLandmark* target = iDatabase->ReadLandmarkLC((*iJustNowSearchResults)[i]); + TPtrC sourceName, targetName; + + item.Landmark().GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + buf.Zero(); + + if (sourceName.CompareC(targetName) != 0) + { + + iLog->Log(_L("Mismatch between landmarks")); + User::Leave(-1); + } + CleanupStack::PopAndDestroy(target); + } + + iMultiLandmarkSearch->UnsetDisplayData(); + delete iDisplayData;iDisplayData=NULL; + } + } + CleanupStack::PopAndDestroy(textCriteria); + + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp133::CheckPartialLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const CPosLandmark::TAttributes& aAttr, const RArray& aReqFields) + { + _LIT(KPartialIdErr, "Incorrect Id when reading from a Partial landmark"); + _LIT(KPartialCategoryInfoErr, "Incorrect Category info when reading from a Partial landmark"); + + TPosLmItemId id = aLandmark.LandmarkId(); + AssertTrueSecL(id != 0, KPartialIdErr); + + AssertTrueSecL(aLandmark.IsPartial(), _L("Landmark is not partial")); + + TInt err; + TPtrC name; + err = aLandmark.GetLandmarkName(name); + // Name is always included + CheckPartialErrorCodeL(aAttr & CPosLandmark::ELandmarkName, err); + + TBuf<100> buf; + buf.Format(_L("Checking LM: %S"), &name); + // iLog->Log(buf); + + TReal32 coverageR; + err = aLandmark.GetCoverageRadius(coverageR); + CheckPartialErrorCodeL(aAttr & CPosLandmark::ECoverageRadius, err); + + TPtrC desc; + err = aLandmark.GetLandmarkDescription(desc); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EDescription, err); + + TPtrC iconName; + TInt iconIndex; + TInt iconMaskIndex; + err = aLandmark.GetIcon(iconName, iconIndex, iconMaskIndex); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EIcon, err); + + RArray categories; + CleanupClosePushL(categories); + + aLandmark.GetCategoriesL(categories); + if (aAttr & CPosLandmark::ECategoryInfo) + { + AssertTrueSecL(categories.Count() != 0, KPartialCategoryInfoErr); + } + else + { + AssertTrueSecL(categories.Count() == 0, KPartialCategoryInfoErr); + } + CleanupStack::PopAndDestroy(&categories); + + TLocality loc; + err = aLandmark.GetPosition(loc); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EPosition, err); + + // Check PositionFields + // Check fields from EPositionFieldCompassCapabilitiesBegin up to EPositionFieldMediaCapabilitiesBegin+100 + // should be enough to also cover URL + for (TInt i=EPositionFieldCompassCapabilitiesBegin; iLog(value); + } + else if (!avail && found != KErrNotFound || avail && found == KErrNotFound) + { + // Fields 405 and 802 are not always set + if (i!=405 && i!=802) + { + TBuf<100> buf; + buf.Format(_L("ERROR: Mismatch in positionfields, id %d were not found"), i); + iLog->Log(buf); + iErrorsFound++; + } + } + } + } + +// --------------------------------------------------------- +// CPosTp133::ChechPartialErrorCodeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr) + { + _LIT(KPartialLmErr, "Incorrect error code returned when reading from a Partial landmark"); + _LIT(KPartialLmErr2, "Incorrect error code returned when reading from a non-Partial landmark"); + + if (aPartial) + { + + if (aErr != KErrNone) + { + iLog->Log(KPartialLmErr); + iErrorsFound++; + } + } + else + { + + if (aErr != KErrNotFound) + { + iLog->Log(KPartialLmErr2); + iErrorsFound++; + } + } + } + +// --------------------------------------------------------- +// CPosTp133::SearchPartialWithoutNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::SearchPartialWithoutNameL(const RPointerArray& aSearchResults, + CDesCArray* aDbUris) + { + iLog->Log(_L("SearchPartialWithoutNameL")); + // Search in all lm dbs + iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); + // Set DisplayData + iDisplayData = CPosLmDisplayData::NewL(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TBuf<150> buf; + + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + // Dont search for all search criteras (see excel file) + // takes just too long time on target + // therefore start at j=2 +#ifdef __WINS__ + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + + + if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) + { + // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h + // they contain the 802 field (instead of 803) so append this id as well + RArray arr; + iLog->Log(_L("Found 803")); + arr = aSearchResults[j]->PositionFields(); + arr.Append(802); + textCriteria->SetPositionFieldsToSearchL(arr); + } + else + { + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + } + + RArray reqFields; + CleanupClosePushL(reqFields); + + iLog->Log(aSearchResults[j]->TextCriteria()); + + // Set position and descriptiom + //partialParam->SetRequestedAttributes(CPosLandmark::EPosition); + partialParam->SetRequestedAttributes(CPosLandmark::EDescription| CPosLandmark::EPosition); + + iDisplayData->SetPartialReadParametersL(*partialParam); + iLastNrOfDisplayData=0; + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[j]->Redefined()); + ExecuteLmOpL(); + + iLog->Log(_L("Search Done, check sorting")); + // Check for any errors when multi searching + if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) + { + iLog->Log(_L("Errors after multi db search")); + User::Leave(-1); + } + + RArray* result = &aSearchResults[j]->SearchResult(); + + TInt number = iDisplayData->Count(); + buf.Zero(); + buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, result->Count()); + iLog->Log(buf); + TInt nrOfNoPos = 0; + AssertTrueSecL(iDisplayData->Count() == result->Count(),_L("Mismatch in number of matches")); + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + + TInt err; + TPtrC name; + err = item.Landmark().GetLandmarkName(name); + AssertTrueSecL(err == KErrNotFound,_L("GetLandmarkName returned name")); + TReal32 radius; + err = item.Landmark().GetCoverageRadius(radius); + AssertTrueSecL(err == KErrNotFound,_L("GetLandmarkName returned name")); + TPtrC desc; + err = item.Landmark().GetLandmarkDescription(desc); + AssertTrueSecL(err == KErrNone,_L("GetLandmarkDescription returned error")); + TLocality loc; + err = item.Landmark().GetPosition(loc); + + // Should only be three landmarks without position + if (err == KErrNotFound) nrOfNoPos++; + + } + + if (nrOfNoPos > 3) + { + iLog->Log(_L("ERROR: GetPosition returned error")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(&reqFields); + } + + + CleanupStack::PopAndDestroy(partialParam); + + CleanupStack::PopAndDestroy(textCriteria); + iMultiLandmarkSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + + } + +// --------------------------------------------------------- +// CPosTp133::SearchPartialLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::SearchPartialLandmarksL(TInt aWhatIndexToSerrachFor, const RPointerArray& aSearchResults, + CDesCArray* aDbUris) + { + // Search in all lm dbs + iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); + // Set DisplayData + iDisplayData = CPosLmDisplayData::NewL(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TBuf<150> buf; + + textCriteria->SetTextL(aSearchResults[aWhatIndexToSerrachFor]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[aWhatIndexToSerrachFor]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[aWhatIndexToSerrachFor]->PositionFields()); + + RArray reqFields; + CleanupClosePushL(reqFields); + + iLog->Log(aSearchResults[aWhatIndexToSerrachFor]->TextCriteria()); + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + CPosLmPartialReadParameters* fakePartialParam = CPosLmPartialReadParameters::NewLC(); + reqFields.Append(EPositionFieldStreet); + fakePartialParam->SetRequestedPositionFields(reqFields); + reqFields.Reset(); + + // Search for all combinations from 0 - CPosLandmark::EDescription + // Ex attr=0, attr=1, attr=2, attr=3, .....attr=63, + TUint max = CPosLandmark::EDescription; + max <<= 1; + max -= 1; + + TUint attr=0; + for (attr=0; attr<=max; attr++) + { + partialParam->SetRequestedAttributes(attr); + reqFields.Reset(); + + if (attr == 5) + { + // Add EPositionFieldCountry + iLog->Log(_L("Also cover EPositionFieldCountry")); + reqFields.Append(EPositionFieldCountry); + } + else if (attr == 12) + { + // Add EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry + iLog->Log(_L("Also cover EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry")); + reqFields.Append(EPositionFieldCity); + reqFields.Append(EPositionFieldStreet); + reqFields.Append(EPositionFieldCountry); + } + else if (attr == 32) + { + // Add EPositionFieldMediaLinksStart, EPositionFieldDistrict + iLog->Log(_L("Also cover EPositionFieldMediaLinksStart, EPositionFieldDistrict")); + reqFields.Append(EPositionFieldMediaLinksStart); + reqFields.Append(EPositionFieldDistrict); + } + + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + + for (TInt i=0; i<2; i++) + { + switch (i) + { + case 0: + { + //**** async + iLog->Log(_L("*****Async, EDescending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iAscendedSorted = EFalse; + iLastNrOfDisplayData=0; + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[aWhatIndexToSerrachFor]->Redefined()); + // Test that if SetPartialReadParametersL is called after search has started it has no affect + iDisplayData->SetPartialReadParametersL(*fakePartialParam); + ExecuteLmOpL(); + } + break; + case 1: + { + partialParam->SetRequestedPositionFields(reqFields); + iDisplayData->SetPartialReadParametersL(*partialParam); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + iLog->Log(_L("*****Async EAscending")); + iAscendedSorted = ETrue; + iLastNrOfDisplayData=0; + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[aWhatIndexToSerrachFor]->Redefined()); + ExecuteLmOpL(); + } + break; + } + + // Sort correct result + iJustNowSearchResults = &aSearchResults[aWhatIndexToSerrachFor]->SearchResult(); + LandmarksSortL(*iJustNowSearchResults, sortPref); + // + iLog->Log(_L("Search Done, check sorting")); + // Check for any errors when multi searching + if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) + { + iLog->Log(_L("Errors after multi db search")); + User::Leave(-1); + } + + TInt number = iDisplayData->Count(); + buf.Zero(); + buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); + iLog->Log(buf); + + AssertTrueSecL(iDisplayData->Count() == iJustNowSearchResults->Count(),_L("Mismatch in number of matches")); + + for (TInt i=0;iCount();i++) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + CPosLandmark* target = iDatabase->ReadLandmarkLC((*iJustNowSearchResults)[i]); + TPtrC sourceName, targetName; + + item.Landmark().GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + buf.Zero(); + + if (sourceName.CompareC(targetName) != 0) + { + + iLog->Log(_L("Mismatch between landmarks")); + User::Leave(-1); + } + CleanupStack::PopAndDestroy(target); + + // Landmarkname is always included when sorting + CheckPartialLandmarkL(item.Landmark() , attr | CPosLandmark::ELandmarkName, reqFields); + } + + } + } + + CleanupStack::PopAndDestroy(fakePartialParam); + CleanupStack::PopAndDestroy(partialParam); + CleanupStack::PopAndDestroy(&reqFields); + CleanupStack::PopAndDestroy(textCriteria); + iMultiLandmarkSearch->UnsetDisplayData(); + delete iDisplayData; + iDisplayData = NULL; + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + } + + +// --------------------------------------------------------- +// CPosTp133::CheckResetL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::CheckResetL(const RPointerArray& aSearchResults, CDesCArray* aDbUris) + { + iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TBuf<150> buf; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + iDisplayData = CPosLmDisplayData::NewL(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + iAscendedSorted = ETrue; + + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + + if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) + { + // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h + // they contain the 802 field (instead of 803) so append this id as well + RArray arr; + iLog->Log(_L("Found 803")); + arr = aSearchResults[j]->PositionFields(); + arr.Append(802); + textCriteria->SetPositionFieldsToSearchL(arr); + } + else + { + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + } + + iLog->Log(_L(">>>>>>Searching for: ")); + iLog->Log(aSearchResults[j]->TextCriteria()); + + RArray* result = &aSearchResults[j]->SearchResult(); + + LandmarksSortL(*result, sortPref); + iLastNrOfDisplayData = 0; + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); + ExecuteAndDeleteLD(iOperation); + + iLastNrOfDisplayData = 0; + iDisplayData->Reset(); + AssertTrueSecL(iDisplayData->Count() == 0,_L("DisplayData should have been resetted")); + + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); + // Also check progress here + ExecuteLmOpL(); + AssertTrueSecL(iDisplayData->Count() == result->Count(),_L("Mismatch in number of matches")); + } + + iMultiLandmarkSearch->UnsetDisplayData(); + iDisplayData->Reset(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + AssertTrueSecL(iDisplayData->Count() == 0,_L("DisplayData should have been resetted")); + + // Unset display data + iMultiLandmarkSearch->UnsetDisplayData(); + + textCriteria->SetTextL(aSearchResults[0]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[0]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[0]->PositionFields()); + + // Check that no result is found in displaydata + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[0]->Redefined()); + ExecuteAndDeleteLD(iOperation); + AssertTrueSecL(iDisplayData->Count() == 0,_L("No matches should be found in DisplayData1")); + + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[0]->Redefined()); + ExecuteAndDeleteLD(iOperation); + + // Check that result is found in displaydata + RArray* searchResults = &aSearchResults[0]->SearchResult(); + AssertTrueSecL(iMultiLandmarkSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches1")); + AssertTrueSecL(iMultiLandmarkSearch->TotalNumOfMatches() == searchResults->Count(),_L("Wrong number of matches2")); + + CleanupStack::PopAndDestroy(textCriteria); + + iMultiLandmarkSearch->UnsetDisplayData(); + delete iDisplayData;iDisplayData=NULL; + + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp133::CancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::CancelTestL(const RPointerArray& aSearchResults, CDesCArray* aDbUris, + TBool aCancelInCallback) + { + iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + TBuf<150> buf; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + // Search for wildcard, index 0 in lmdbsearchresult.txt + TInt KWhatToSearchForIndex = 0; + + textCriteria->SetTextL(aSearchResults[KWhatToSearchForIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[KWhatToSearchForIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[KWhatToSearchForIndex]->PositionFields()); + + iLog->Log(_L(">>>>>>Searching for: ")); + iLog->Log(aSearchResults[KWhatToSearchForIndex]->TextCriteria()); + + // Sort ascended and descended + for (TInt sorted=0;sorted<2;sorted++) + { + iDisplayData = CPosLmDisplayData::NewL(); + iMultiLandmarkSearch->SetDisplayData(*iDisplayData); + + switch (sorted) + { + case 0: + iLog->Log(_L("******Sorting EAscending*******")); + iAscendedSorted = ETrue; + sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + break; + case 1: + iLog->Log(_L("**********Sorting EDescending**********")); + iAscendedSorted = EFalse; + sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + break; + } + + iJustNowSearchResults = &aSearchResults[KWhatToSearchForIndex]->SearchResult(); + LandmarksSortL(*iJustNowSearchResults, sortPref); + iLastNrOfDisplayData = 0; + + iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[KWhatToSearchForIndex]->Redefined()); + + switch (aCancelInCallback) + { + case EFalse: + iLog->Log(_L("Cancel")); + RunAsyncOperationAndCancelLD(iOperation); + break; + case ETrue: + iLog->Log(_L("Cancel In Callback")); + RunAsyncOperationAndCancelInCallbackLD(iOperation); + break; + } + + + buf.Format(_L("TotalNumOfMatches returned %d matches and iDisplayData %d matches after cancel"), iMultiLandmarkSearch->TotalNumOfMatches(), iDisplayData->Count()); + iLog->Log(buf); + + iLog->Log(_L("After Cancel, check result")); + // Check for any errors when multi searching + // XXX Shouldnt error be KErrCancel + if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) iLog->Log(_L("Errors after cancel")); + for (TInt i=0;iNumOfSearchErrors(); i++) + { + CPosLmMultiDbSearch::TSearchError searchErr; + iMultiLandmarkSearch->GetSearchError(i, searchErr); + + buf.Format(_L("ErrorCode %d returned from db nr %d"),searchErr.iErrorCode, searchErr.iDatabaseIndex); + iLog->Log(buf); + + } + + TInt number = iDisplayData->Count(); + buf.Zero(); + buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); + iLog->Log(buf); + + if (!aCancelInCallback) + { + if (iDisplayData->Count() != 0) + { + iLog->Log(_L("No matches should be found when cancel before search started")); + User::Leave(-1); + } + } + else + { + // XXX maybe check result here + } + + iMultiLandmarkSearch->UnsetDisplayData(); + delete iDisplayData;iDisplayData=NULL; + } + CleanupStack::PopAndDestroy(textCriteria); + + delete iMultiLandmarkSearch; + iMultiLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// Tp133InternalLandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt Tp133InternalLandmarksSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) + { + TPtrC sourceName, targetName; + + User::LeaveIfError(aSource.GetLandmarkName(sourceName)); + User::LeaveIfError(aTarget.GetLandmarkName(targetName)); + + return sourceName.CompareC(targetName); + } + +// --------------------------------------------------------- +// CPosTp133::LandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::LandmarksSortL(RArray& aArray, const TPosLmSortPref& aSortPref) + { + iLog->Log(_L("LandmarksSortL")); + RPointerArray landmarks; + CleanupClosePushL(landmarks); + + for (TInt i=0; iReadLandmarkLC(aArray[i]); + landmarks.Append(lm); + CleanupStack::Pop(lm); + } + + TLinearOrder order(Tp133InternalLandmarksSortL); + landmarks.Sort(order); + + aArray.Reset(); + + if (aSortPref.SortOrder() == TPosLmSortPref::EAscending) + { + for (TInt j=0; jLandmarkId()); + } + } + else + { + for (TInt k=landmarks.Count()-1; k>=0; k--) + { + aArray.Append(landmarks[k]->LandmarkId()); + } + } + landmarks.ResetAndDestroy(); + CleanupStack::PopAndDestroy(&landmarks); + } + +// --------------------------------------------------------- +// CPosTp133::ExecuteLmOpL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::ExecuteLmOpL() + { + CActiveLmOperation* operationWrapper = new (ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(operationWrapper); + + // Start operation with this class as observer + operationWrapper->Start(iOperation, this); + CActiveScheduler::Start(); + + operationWrapper->CheckOperationL(); + operationWrapper->DeleteOperationD(); + + CleanupStack::PopAndDestroy(operationWrapper); + } + +// --------------------------------------------------------- +// CPosTp133::ExecuteLmOpInCallbackL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::ExecuteLmOpInCallbackL() + { + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog, iUseLogFromThreadIsDisabled); + CleanupStack::PushL(activeLmOperation); + + TCallBack callback(CLandmarkTestProcedureBase::CancelTest, activeLmOperation); + + CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); + CleanupStack::PushL(periodicTimer); + + periodicTimer->Start(1, 1, callback); + activeLmOperation->SetCancelTest(); + // Start operation with this class as observer + activeLmOperation->Start(iOperation, this); + + CActiveScheduler::Start(); + periodicTimer->Cancel(); + + CleanupStack::PopAndDestroy(2, activeLmOperation); + } + +// --------------------------------------------------------- +// CPosTp133::NotifyProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp133::NotifyProgress(TReal aProgress) + { + TBuf<100> buf; + TInt progress = (TInt) (aProgress * 100); + buf.Format(_L("Progress: %d"), progress); + TInt nrOfMatches = 0; + + if (iDisplayData) + { + buf.Zero(); + buf.Format(_L("Progress: %g DisplayData %d"), aProgress * 100, iDisplayData->Count()); + + // Check that nr of matches never decreases + if (iLastNrOfDisplayData>iDisplayData->Count()) + { + iLog->Log(_L("ERROR: Less nr of mathes than in last search")); + iErrorsFound++; + } + + if (iDisplayData->Count()>0) + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + // Check nr of hits for each db using the iterator + for (TInt i=0;iMatchIteratorL(i); + CleanupStack::PushL(iter); + if (iter->NumOfItemsL() > 0) + { + buf.Zero(); + buf.Format(_L("Found %d nr of lm in db %d"), iter->NumOfItemsL(), i); + + nrOfMatches+=iter->NumOfItemsL(); + } + CleanupStack::PopAndDestroy(iter); + } + + if (iAscendedSorted) sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + else sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + + for (TInt i=0;iCount();i++) + { + // Check for all but first and last + if (i>0 && iCount()-1) + { + CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); + TInt lmId = item.Landmark().LandmarkId(); + + CPosLmDisplayItem& nextItem = iDisplayData->DisplayItem(i+1); + TInt nextLmId = item.Landmark().LandmarkId(); + + TPtrC name, nextLmName; + item.Landmark().GetLandmarkName(name); + nextItem.Landmark().GetLandmarkName(nextLmName); + + TInt order = nextLmName.CompareC(name); + if (iAscendedSorted) + { // sorted ascended + if (order < 0) + { + iLog->Log(_L("ERROR: Wrong sortorder when ascended")); + iErrorsFound++; + } + } + else // sorted descended + { + if (order > 0) + { + iLog->Log(_L("ERROR: Wrong sortorder when descended")); + iErrorsFound++; + } + + } + } // if (i>0 && iCount()-1) + } // for (TInt i=0;iCount();i++) + } // if (iDisplayData->Count()>0) + iLastNrOfDisplayData = iDisplayData->Count(); + } //if (iDisplayData) + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp134.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp134.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,491 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp134.h" +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include +#include +#include +#include "FT_LandmarkConstants.h" +#include + +// CONSTANTS +_LIT(KUriDb01, "C:TP104DB01.LDB"); +_LIT(KUriDb01Full, "file://C:TP104DB01.LDB"); +_LIT(KUriDb02Full, "file://C:TP104DB02.LDB"); +_LIT(KUriDb02, "C:TP104DB02.LDB"); +_LIT(KUriDbNonExisting, "file://C:TP104DBBLABLA.LDB"); +_LIT(KUriDbCorrupt, ":jf785hjtr748.abc"); +_LIT(KUriNotSupported, "bike://test/tp104.wheel"); +_LIT(KProtocolFile, "file"); + +#ifdef __WINS__ + _LIT(KUriRemovableMediaDb, "file://D:REMOVABLEDB.LDB"); + _LIT(KUriRemovableMediaDbNonExisting, "file://D:REMOVABLEDBBLABLA.LDB"); + #else + _LIT(KUriRemovableMediaDb, "file://F:REMOVABLEDB.LDB"); + _LIT(KUriRemovableMediaDbNonExisting, "file://F:REMOVABLEDBBLABLA.LDB"); + #endif + +_LIT(KNewDbName, "TP134 Disp Name"); + +_LIT(KErrorWrongDrive, "Wrong drive returned from db info"); + +_LIT(KErrorWrongDefault, "Wrong default db returned from db info"); +_LIT(KErrorWrongDbUri, "Wrong db uri returned from db info"); +_LIT(KErrorWrongProtocol, "Wrong protocol returned from db info"); +_LIT(KErrorWrongDbName, "Wrong db name returned from db info"); +_LIT(KErrorWrongAttributeInfo, "Wrong attribute info from db info"); +_LIT(KErrorWrongNrOfDbs, "Wrong nr of db:s for ListDatasesL"); +_LIT(KErrorWrongCodeForNonExistingDb, "Wrong error code for non-existing db"); +_LIT(KErrorWrongCodeForNonExistingDbRem, "Wrong error code for non-existing db on removable media"); +_LIT(KErrorWrongCodeForCorruptUri, "Wrong error code for corrupt uri"); +_LIT(KErrorWrongCodeForNotSupportedUri, "Wrong error code for not supported uri"); + +// ================= MEMBER FUNCTIONS ======================= +// Cleanup for RPointerArray objects +void TP134CleanupTestPointerArray(TAny* aArray) + + { + (static_cast*>(aArray))->ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp134::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp134::CloseTest() + { + iLog->Log(_L("CloseTest")); + } + +// --------------------------------------------------------- +// CPosTp134::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp134::StartL() + { + iLog->Log(_L("Warning: this test case requires E: drive")); + + iErrorsFound = KErrNone; + RemoveAllLmDatabasesL(); + SetupExpectedResultsL(); + // Create the test DB:s + iDbMan = CPosLmDatabaseManager::NewL(); + HPosLmDatabaseInfo* dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01); + iDbMan->CreateDatabaseL(*dbInfo01); + CleanupStack::PopAndDestroy(dbInfo01); + HPosLmDatabaseInfo* dbInfo02 = HPosLmDatabaseInfo::NewLC(KUriDb02); + iDbMan->CreateDatabaseL(*dbInfo02); + CleanupStack::PopAndDestroy(dbInfo02); + HPosLmDatabaseInfo* dbInfoRemovableMedia = HPosLmDatabaseInfo::NewLC(KUriRemovableMediaDb); + iDbMan->CreateDatabaseL(*dbInfoRemovableMedia); + CleanupStack::PopAndDestroy(dbInfoRemovableMedia); + dbInfo02 = NULL; + dbInfo01 = NULL; + dbInfoRemovableMedia = NULL; + + // 1 Get info about the default DB + dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01Full); + iDbMan->SetDefaultDatabaseUriL(KUriDb01Full); + iDbMan->GetDatabaseInfoL(*dbInfo01); + CheckInfoL(dbInfo01, 1); + CleanupStack::PopAndDestroy(dbInfo01); + dbInfo01 = NULL; + + // 2 Get info about a non-default DB + dbInfo02 = HPosLmDatabaseInfo::NewLC(KUriDb02Full); + iDbMan->GetDatabaseInfoL(*dbInfo02); + CheckInfoL(dbInfo02, 2); + CleanupStack::PopAndDestroy(dbInfo02); + dbInfo02 = NULL; + + // 3a Change the default db + // Check error report "ESLI-6CXJP3 Default database not marked as default" + iDbMan->SetDefaultDatabaseUriL(KUriDb02); + dbInfo02 = HPosLmDatabaseInfo::NewLC(KUriDb02Full); + iDbMan->GetDatabaseInfoL(*dbInfo02); + CheckInfoL(dbInfo02, 3); + CleanupStack::PopAndDestroy(dbInfo02); + dbInfo02 = NULL; + + iDbMan->SetDefaultDatabaseUriL(KUriDb01Full); + + // 3b Change the default db + // Check error report "ESLI-6CXJP3 Default database not marked as default" + iDbMan->SetDefaultDatabaseUriL(KUriDb02Full); + iDbUri[3] = KUriDb02; + iProtocol[3] = KNullDesC; + dbInfo02 = HPosLmDatabaseInfo::NewLC(KUriDb02); + iDbMan->GetDatabaseInfoL(*dbInfo02); + CheckInfoL(dbInfo02, 3); + CleanupStack::PopAndDestroy(dbInfo02); + dbInfo02 = NULL; + + iDbMan->SetDefaultDatabaseUriL(KUriDb01Full); + // 3c Change the default db + // Check error report "ESLI-6CXJP3 Default database not marked as default" + iDbMan->SetDefaultDatabaseUriL(KUriDb02Full); + iDbUri[3] = KUriDb02Full; + iProtocol[3] = KProtocolFile; + dbInfo02 = HPosLmDatabaseInfo::NewLC(KUriDb02Full); + iDbMan->GetDatabaseInfoL(*dbInfo02); + CheckInfoL(dbInfo02, 3); + CleanupStack::PopAndDestroy(dbInfo02); + dbInfo02 = NULL; + + + // 4 DB on removable media + dbInfoRemovableMedia = HPosLmDatabaseInfo::NewLC(KUriRemovableMediaDb); + iDbMan->GetDatabaseInfoL(*dbInfoRemovableMedia); + CheckInfoL(dbInfoRemovableMedia, 4); + CleanupStack::PopAndDestroy(dbInfoRemovableMedia); + dbInfoRemovableMedia = NULL; + + // 5 Get info for all databases using ListDatabasesL + iDbMan->ListDatabasesL(iDbArray); + AssertTrueSecL(iDbArray.Count() == 3, KErrorWrongNrOfDbs); + + HPosLmDatabaseInfo* dbInfo = NULL; + for(TInt count = 0; count < 3; count++) + { + dbInfo = iDbArray[count]; + TBuf<50> testbuf = dbInfo->DatabaseUri(); + if (dbInfo->DatabaseUri() == KUriDb01Full) + { + CheckInfoL(dbInfo, 5); + } + else if (dbInfo->DatabaseUri() == KUriDb02Full) + { + CheckInfoL(dbInfo, 6); + } + else if (dbInfo->DatabaseUri() == KUriRemovableMediaDb) + { + CheckInfoL(dbInfo, 7); + } + } + + // According to header for ListDatabasesL in EPos_CPosLmDatabaseManager.h + // "Any objects which are in the array when it is passed to this function are not removed." + // Therefore add object and make sure that it is not removed + HPosLmDatabaseInfo* testDbInfo = HPosLmDatabaseInfo::NewLC(_L("VeryMuchDummyURI.ldb")); + iDbArray.ResetAndDestroy(); + iDbArray.Append(testDbInfo); + iDbMan->ListDatabasesL(iDbArray); + AssertTrueSecL(iDbArray.Count() == 4, _L("iDbArray count should be 4")); + + CleanupStack::Pop(testDbInfo); + iDbArray.ResetAndDestroy(); + + // 6 Get info from a non-existing db: + TPosLmDatabaseSettings dummySettings; + HPosLmDatabaseInfo* dbInfoNonExisting = HPosLmDatabaseInfo::NewLC(KUriDbNonExisting); + TInt err = KErrNone; + TRAP(err, iDbMan->GetDatabaseInfoL(*dbInfoNonExisting)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCodeForNonExistingDb); + + CleanupStack::PopAndDestroy(dbInfoNonExisting); + dbInfoNonExisting = NULL; + + // 7 Get info from a non-existing db on the removable media: + HPosLmDatabaseInfo* dbInfoNonExistingRem = HPosLmDatabaseInfo::NewLC(KUriRemovableMediaDbNonExisting); + TRAP(err, iDbMan->GetDatabaseInfoL(*dbInfoNonExistingRem)); + AssertTrueSecL(err == KErrNotFound, KErrorWrongCodeForNonExistingDbRem); + CleanupStack::PopAndDestroy(dbInfoNonExistingRem); + dbInfoNonExistingRem = NULL; + + // 8 Get info from a corrupt uri: + HPosLmDatabaseInfo* dbInfoCorrupt = HPosLmDatabaseInfo::NewLC(KUriDbCorrupt); + TRAP(err, iDbMan->GetDatabaseInfoL(*dbInfoCorrupt)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForCorruptUri); + TRAP(err, iDbMan->ModifyDatabaseSettingsL(KUriDbCorrupt, dummySettings)); + AssertTrueSecL(err == KErrArgument, KErrorWrongCodeForCorruptUri); + CleanupStack::PopAndDestroy(dbInfoCorrupt); + dbInfoCorrupt = NULL; + + // 9 Get info from a non-supported protocol in uri + HPosLmDatabaseInfo* dbInfoNotSupported = HPosLmDatabaseInfo::NewLC(KUriNotSupported); + TRAP(err, iDbMan->GetDatabaseInfoL(*dbInfoNotSupported)); + AssertTrueSecL(err == KErrNotSupported, KErrorWrongCodeForNotSupportedUri); + TRAP(err, iDbMan->ModifyDatabaseSettingsL(KUriNotSupported, dummySettings)); + AssertTrueSecL(err == KErrNotSupported, KErrorWrongCodeForNotSupportedUri); + CleanupStack::PopAndDestroy(dbInfoNotSupported); + dbInfoNotSupported = NULL; + + // 10 Get info from the non-default db + dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01); + iDbMan->GetDatabaseInfoL(*dbInfo01); + CheckInfoL(dbInfo01, 8); + + // 11 Change the display name for the non-default DB + TPosLmDatabaseSettings settings = dbInfo01->Settings(); + TPosLmDatabaseName bufName(KNewDbName); + settings.SetDatabaseName(bufName); + iDbMan->ModifyDatabaseSettingsL(KUriDb01, settings); + CleanupStack::PopAndDestroy(dbInfo01); + dbInfo01 = NULL; + + // 12 Get info after name change + dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01); + iDbMan->GetDatabaseInfoL(*dbInfo01); + CheckInfoL(dbInfo01, 9); + CleanupStack::PopAndDestroy(dbInfo01); + dbInfo01 = NULL; + + // 10b Get info from the removable media db + dbInfoRemovableMedia = HPosLmDatabaseInfo::NewLC(KUriRemovableMediaDb); + iDbMan->GetDatabaseInfoL(*dbInfoRemovableMedia); + CheckInfoL(dbInfoRemovableMedia, 11); + + // 11b Change the display name for the non-default DB + settings = dbInfoRemovableMedia->Settings(); + bufName = KNewDbName; + settings.SetDatabaseName(bufName); + iDbMan->ModifyDatabaseSettingsL(KUriRemovableMediaDb, settings); + CleanupStack::PopAndDestroy(dbInfoRemovableMedia); + dbInfoRemovableMedia = NULL; + + // 12b Get info after name change + dbInfoRemovableMedia = HPosLmDatabaseInfo::NewLC(KUriRemovableMediaDb); + iDbMan->GetDatabaseInfoL(*dbInfoRemovableMedia); + CheckInfoL(dbInfoRemovableMedia, 12); + CleanupStack::PopAndDestroy(dbInfoRemovableMedia); + dbInfoRemovableMedia = NULL; + + // 13 Get info after name change + dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01); + iDbMan->GetDatabaseInfoL(*dbInfo01); + CheckInfoL(dbInfo01, 9); + + // 14 Change display name, but use the unset attribute mechanism + settings = dbInfo01->Settings(); + settings.UnsetAttribute(TPosLmDatabaseSettings::EName); + iDbMan->ModifyDatabaseSettingsL(KUriDb01, settings); + CleanupStack::PopAndDestroy(dbInfo01); + dbInfo01 = NULL; + + // 15 Get info after "non-name-change" + dbInfo01 = HPosLmDatabaseInfo::NewLC(KUriDb01); + iDbMan->GetDatabaseInfoL(*dbInfo01); + CheckInfoL(dbInfo01, 10); + CleanupStack::PopAndDestroy(dbInfo01); + dbInfo01 = NULL; + + // 16 Check max length and KNullDesC + //_LIT(KErrorWrongCode, "Didn't receive correct error code"); + _LIT(KMaxLengthString64, "1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString64Bad, "x1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString66, "c:2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString66Bad, "c:x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString71, "file://3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString71Bad, "file://x3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString73, "file://c:4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + _LIT(KMaxLengthString73Bad, "file://c:x4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ldb"); + + CheckUriLengthL(KMaxLengthString64, KErrNotFound); + CheckUriLengthL(KMaxLengthString64Bad, KErrNotFound); // tbd shall it be like this? (Should be KErrArgument) + CheckUriLengthL(KMaxLengthString66, KErrNotFound); + CheckUriLengthL(KMaxLengthString66Bad, KErrNotFound); // tbd shall it be like this? + CheckUriLengthL(KMaxLengthString71, KErrNotFound); + CheckUriLengthL(KMaxLengthString71Bad, KErrNotFound); // tbd shall it be like this? + CheckUriLengthL(KMaxLengthString73, KErrNotFound); + CheckUriLengthL(KMaxLengthString73Bad, KErrNotFound); // tbd shall it be like this? + CheckUriLengthL(KNullDesC, KErrArgument); //tbd This crashes, should it be so? + + if (iErrorsFound != KErrNone) //LogErrorAndLeave(_L("Errors found in TP134")); + { + iLog->Log(_L("Errors found in TP134")); + User::Leave(-1); + } + else iLog->Log(_L("CPosTp134 Passed")); + + } + +void CPosTp134::CheckInfoL(HPosLmDatabaseInfo* aDbInfo, TInt aTestNr) + { + _LIT(KTestInfo, "Step nr %d"); + TBuf<20> testInfo; + testInfo.Format(KTestInfo, aTestNr); + iLog->Log(testInfo); + + AssertTrueSecL(iDbDrive[aTestNr] == (aDbInfo->DatabaseDrive()).GetUpperCase(), KErrorWrongDrive); + + + iLog->Log(aDbInfo->DatabaseUri()); + iLog->Log(iDbUri[aTestNr]); + AssertTrueSecL(iDefaultDb[aTestNr] == aDbInfo->IsDefault(), KErrorWrongDefault); + AssertTrueSecL(iDbUri[aTestNr] == aDbInfo->DatabaseUri(), KErrorWrongDbUri); + + AssertTrueSecL(iProtocol[aTestNr] == aDbInfo->Protocol(), KErrorWrongProtocol); + + TPosLmDatabaseSettings settings = aDbInfo->Settings(); + if ( iDbName[aTestNr] != settings.DatabaseName() ) + { + iLog->Log(_L("CheckInfo: dbNames do not match: exp '%S', act '%S'"), + &iDbName[aTestNr], &settings.DatabaseName() ); + User::Leave( KErrGeneral ); + } + + AssertTrueSecL(iAttrSet[aTestNr] == settings.IsAttributeSet(TPosLmDatabaseSettings::EName), + KErrorWrongAttributeInfo); + } + +void CPosTp134::SetupExpectedResultsL() + { + TChar cDrive = 'C'; + #ifdef __WINS__ + TChar removableDrive = 'D'; + TMediaType mediaTypeRemovable = EMediaHardDisk; + // DatabaseMedia() seems to return EMediaRam for WINS and EMediaFlash for target + TMediaType mediaType = EMediaRam; + #else + TMediaType mediaTypeRemovable = EMediaFlash; + TChar removableDrive = 'F'; + // DatabaseMedia() seems to return EMediaRam for WINS and EMediaFlash for target + TMediaType mediaType = EMediaNANDFlash; + #endif + + HBufC* dbName = ReadDefaultDatabaseNameFromResourceLC(); + iLog->Log(_L("Default database name: '%S'"), dbName ); + + iDbDrive[1] = cDrive; + iMediaType[1] = mediaType; + iDefaultDb[1] = ETrue; + iDbUri[1] = KUriDb01Full; + iProtocol[1] = KProtocolFile; + iDbName[1] = *dbName; + iAttrSet[1] = ETrue; // TBD Shall it actually be so? + + iDbDrive[2] = cDrive; + iMediaType[2] = mediaType; + iDefaultDb[2] = EFalse; + iDbUri[2] = KUriDb02Full; + iProtocol[2] = KProtocolFile; + iDbName[2] = KNullDesC; + iAttrSet[2] = EFalse; + + iDbDrive[3] = cDrive; + iMediaType[3] = mediaType; + iDefaultDb[3] = ETrue; + iDbUri[3] = KUriDb02Full; + iProtocol[3] = KProtocolFile; + iDbName[3] = *dbName; + iAttrSet[3] = ETrue; + + iDbDrive[4] = removableDrive; + iMediaType[4] = mediaTypeRemovable; + iDefaultDb[4] = EFalse; + iDbUri[4] = KUriRemovableMediaDb; + iProtocol[4] = KProtocolFile; + iDbName[4] = KNullDesC; + iAttrSet[4] = EFalse; + + iDbDrive[5] = cDrive; + iMediaType[5] = mediaType; + iDefaultDb[5] = EFalse; + iDbUri[5] = KUriDb01Full; + iProtocol[5] = KProtocolFile; + iDbName[5] = KNullDesC; + iAttrSet[5] = EFalse; + + iDbDrive[6] = cDrive; + iMediaType[6] = mediaType; + iDefaultDb[6] = ETrue; + iDbUri[6] = KUriDb02Full; + iProtocol[6] = KProtocolFile; + iDbName[6] = *dbName; + iAttrSet[6] = ETrue; + + iDbDrive[7] = removableDrive; + iMediaType[7] = mediaTypeRemovable; + iDefaultDb[7] = EFalse; + iDbUri[7] = KUriRemovableMediaDb; + iProtocol[7] = KProtocolFile; + iDbName[7] = KNullDesC; + iAttrSet[7] = EFalse; + + iDbDrive[8] = cDrive; + iMediaType[8] = mediaType; + iDefaultDb[8] = EFalse; + iDbUri[8] = KUriDb01; + iProtocol[8] = KNullDesC; + iDbName[8] = KNullDesC; + iAttrSet[8] = EFalse; + + iDbDrive[9] = cDrive; + iMediaType[9] = mediaType; + iDefaultDb[9] = EFalse; + iDbUri[9] = KUriDb01; + iProtocol[9] = KNullDesC; + iDbName[9] = KNewDbName; + iAttrSet[9] = ETrue; + + iDbDrive[10] = cDrive; + iMediaType[10] = mediaType; + iDefaultDb[10] = EFalse; + iDbUri[10] = KUriDb01; + iProtocol[10] = KNullDesC; + iDbName[10] = KNullDesC; + iAttrSet[10] = EFalse; + + iDbDrive[11] = removableDrive; + iMediaType[11] = mediaTypeRemovable; + iDefaultDb[11] = EFalse; + iDbUri[11] = KUriRemovableMediaDb; + iProtocol[11] = KProtocolFile; + iDbName[11] = KNullDesC; + iAttrSet[11] = EFalse; + + iDbDrive[12] = removableDrive; + iMediaType[12] = mediaTypeRemovable; + iDefaultDb[12] = EFalse; + iDbUri[12] = KUriRemovableMediaDb; + iProtocol[12] = KProtocolFile; + iDbName[12] = KNewDbName; + iAttrSet[12] = ETrue; + + CleanupStack::PopAndDestroy( dbName ); + } + +void CPosTp134::CheckUriLengthL(const TDesC& aUri, + TInt aExpectedErrorCode) + { + _LIT(KErrorWrongCode, "Wrong code when testing uri lengths"); + TPosLmDatabaseSettings dummySettings; + HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(aUri); + TInt err = KErrNone; + TRAP(err, iDbMan->GetDatabaseInfoL(*dbInfo)); + AssertTrueSecL(err == aExpectedErrorCode, KErrorWrongCode); + TRAP(err, iDbMan->ModifyDatabaseSettingsL(aUri, dummySettings)); + AssertTrueSecL(err == aExpectedErrorCode, KErrorWrongCode); + CleanupStack::PopAndDestroy(dbInfo); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp135.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp135.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,660 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp135.h" +#include +#include + + +// ================= CONSTANTS ======================= + +_LIT(KRemoteDb1, "test://RemoteDb1.ldb"); +_LIT(KRemoteDb2, "test://RemoteDb2.ldb"); +_LIT(KLocalDb1, "file://C:SOMEDB.LDB"); +_LIT(KLocalDbName1, "SOMEDB"); +_LIT(KRemoteDbName1, "RemoteDb1"); +_LIT(KRemoteDbName2, "RemoteDb2"); +_LIT(KRemoteDb3, "test://RemoteDb3.ldb"); +_LIT(KRemoteDb4, "test://RemoteDb4.ldb"); +_LIT(KRemoteDb5, "RemoteDb5.ldb"); +_LIT(KLocalDb2, "file://C:SOMELOCALDB.LDB"); +_LIT(KRemoteNonExistingDb, "test://NonExistingDb.ldb"); + +// ================= MEMBER FUNCTIONS ======================= + +// Cleanup for RPointerArray objects +void CleanupTestPointerArray(TAny* aArray) + + { + (static_cast*>(aArray))->ResetAndDestroy(); + } + +// Cleanup for RPointerArray objects +void CleanupTestPointerArray2(TAny* aArray) + + { + + (static_cast*>(aArray))->Reset(); + } + +// --------------------------------------------------------- +// CPosTp135::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp135::CloseTest() + { + iLog->Log(_L("CloseTest")); + + iDbArray->Reset(); + delete iDbArray; + iDbArray = NULL; + + TRAPD(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Log(_L("RemoveAllLmDatabasesL() leaved")); + + } + +// --------------------------------------------------------- +// CPosTp135::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp135::StartL() + { + _LIT(KEmptyProtocol, ""); + _LIT(KRemoteProtocol, "test"); + + TInt err=KErrNone; + iErrorsFound = KErrNone; + + RemoveAllLmDatabasesL(); + + iDbArray = NULL; + iDbArray = new (ELeave) CDesCArrayFlat(5); + + // Create defaultdb + CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(dbManager); + + // TC Step 1 Create a remote database (uses the test provider implementation, using test as identifier + // (compare with file) + HPosLmDatabaseInfo* db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); + dbManager->CreateDatabaseL(*db1); + + // TC Step 2 Register db + dbManager->RegisterDatabaseL(*db1); + TPosLmDatabaseSettings settings = db1->Settings(); + TPosLmDatabaseName bufName(KRemoteDbName1); + settings.SetDatabaseName(bufName); + dbManager->ModifyDatabaseSettingsL(KRemoteDb1, settings); + CleanupStack::PopAndDestroy(db1); + + // TC Step 3 Create local db and try to register it + HPosLmDatabaseInfo* localDb1 = HPosLmDatabaseInfo::NewLC(KLocalDb1); + dbManager->CreateDatabaseL(*localDb1); + + settings = db1->Settings(); + TPosLmDatabaseName bufName2(KLocalDbName1); + settings.SetDatabaseName(bufName2); + dbManager->ModifyDatabaseSettingsL(KLocalDb1, settings); + + TRAP(err, dbManager->RegisterDatabaseL(*localDb1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("Register a local db should leave with KErrNotSupported")) ; + User::Leave(err); + } + CleanupStack::PopAndDestroy(localDb1); + + // TC Step 4 Create another remote database and register it + db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb2); + dbManager->CreateDatabaseL(*db1); + // Register db, + dbManager->RegisterDatabaseL(*db1); + settings = db1->Settings(); + TPosLmDatabaseName bufName3(KRemoteDbName2); + settings.SetDatabaseName(bufName3); + dbManager->ModifyDatabaseSettingsL(KRemoteDb2, settings); + CleanupStack::PopAndDestroy(db1); + + // TC Step 5 List all dbs without specifying protocol + CDesCArray* list = dbManager->ListDatabasesLC(); + // Verify list should contain two remote and one local database + iDbArray->AppendL(KLocalDb1); + iDbArray->AppendL(KRemoteDb1); + iDbArray->AppendL(KRemoteDb2); + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 6 List all dbs but specify protocol (protocol "local") + list = dbManager->ListDatabasesLC(_L("file")); + iDbArray->Delete(0, iDbArray->Count()); + iDbArray->AppendL(KLocalDb1); + //Verify list should contain one local database + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 7 List all dbs but specify protocol (protocol "test") + list = dbManager->ListDatabasesLC(KRemoteProtocol); + //Verify list should contain two remote databases + iDbArray->Reset(); + iDbArray->AppendL(KRemoteDb1); + iDbArray->AppendL(KRemoteDb2); + //Verify list should contain one local database + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 8 Also test with empty protocol, All existing dbs will be returned + list = dbManager->ListDatabasesLC(_L("")); + iDbArray->Reset(); + iDbArray->AppendL(KLocalDb1); + iDbArray->AppendL(KRemoteDb1); + iDbArray->AppendL(KRemoteDb2); + //Verify list + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 9 Retrive info about all dbs without specifying protocol + HPosLmDatabaseInfo* dbInfo01 = HPosLmDatabaseInfo::NewLC(KLocalDb1); + HPosLmDatabaseInfo* dbInfo02 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); + HPosLmDatabaseInfo* dbInfo03 = HPosLmDatabaseInfo::NewLC(KRemoteDb2); + + RPointerArray myDbInfoList; + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray2, &myDbInfoList)); + + RPointerArray infoList; + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + + dbManager->ListDatabasesL(infoList); + // Verify list should contain all dbs + + myDbInfoList.Append(dbInfo01); + myDbInfoList.Append(dbInfo02); + myDbInfoList.Append(dbInfo03); + + VerifyDbInfoListL(infoList, myDbInfoList); + CleanupStack::PopAndDestroy(&infoList); + myDbInfoList.Reset(); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + + // TC Step 10 Retrive info about dbs specifying remote protocol + dbManager->ListDatabasesL(infoList, KRemoteProtocol); + // Verify list should contain two remote databases + myDbInfoList.Append(dbInfo03); myDbInfoList.Append(dbInfo02); + VerifyDbInfoListL(infoList, myDbInfoList); + CleanupStack::PopAndDestroy(&infoList); + myDbInfoList.Reset(); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + + // TC Step 11 Retrive info but specify empty protocol, + dbManager->ListDatabasesL(infoList, KEmptyProtocol); + // Verify list should contain all databases + myDbInfoList.Append(dbInfo01);myDbInfoList.Append(dbInfo02);myDbInfoList.Append(dbInfo03); + VerifyDbInfoListL(infoList, myDbInfoList); + CleanupStack::PopAndDestroy(&infoList); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + myDbInfoList.Reset(); + + // TC Step 12 Also test when specifying KNullDesC + dbManager->ListDatabasesL(infoList, KEmptyProtocol); + // Verify list should contain all databases + myDbInfoList.Append(dbInfo01);myDbInfoList.Append(dbInfo02);myDbInfoList.Append(dbInfo03); + VerifyDbInfoListL(infoList, myDbInfoList); + CleanupStack::PopAndDestroy(&infoList); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + myDbInfoList.Reset(); + + // TC Step 13 Unregister one remote db and list dbs + dbManager->UnregisterDatabaseL(KRemoteDb1); + + list = dbManager->ListDatabasesLC(KRemoteProtocol); + // Verify list should contain one remote databases + iDbArray->Delete(0, iDbArray->Count()); + iDbArray->AppendL(KRemoteDb2); + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 14 Retrieves info about dbs, specify remote protocol + dbManager->ListDatabasesL(infoList, KRemoteProtocol); + // Verify list, should contain one remote + myDbInfoList.Append(dbInfo03); + VerifyDbInfoListL(infoList, myDbInfoList); + CleanupStack::PopAndDestroy(&infoList); + myDbInfoList.Reset(); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + + // TC Step 15 Unregisters all remote dbs + dbManager->UnregisterAllDatabasesL(KRemoteProtocol); + // Retrieves info about all dbs without specifying protocol + CleanupStack::PopAndDestroy(&infoList); + CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); + dbManager->ListDatabasesL(infoList); + // Verify list should contain one local database + myDbInfoList.Append(dbInfo01); + VerifyDbInfoListL(infoList, myDbInfoList); + myDbInfoList.Reset(); + + CleanupStack::PopAndDestroy(&infoList); + CleanupStack::PopAndDestroy(&myDbInfoList); + CleanupStack::PopAndDestroy(dbInfo03); + CleanupStack::PopAndDestroy(dbInfo02); + CleanupStack::PopAndDestroy(dbInfo01); + + // TC Step 16 set the default database to a remote database + TRAP(err, dbManager->SetDefaultDatabaseUriL(KRemoteDb1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: SetDefaultDatabaseUriL to a remote db should leave with KErrNotSupported")) ; + User::Leave(err); + } + + // TC Step 17 Try to register a landmark database with an incorrect URI + db1 = HPosLmDatabaseInfo::NewLC(_L("test:/awd/C:Pelle.ldb")); + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (1)")) ; + User::Leave(err); + + } + CleanupStack::PopAndDestroy(db1); + + // TC Step 18 Try to register a landmark database with an incorrect URI + db1 = HPosLmDatabaseInfo::NewLC(_L("test:/\"/C:Pelle.ldb")); + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (2)")) ; + User::Leave(err); + + } + CleanupStack::PopAndDestroy(db1); + + // TC Step 19 Try to register a landmark database with an incorrect URI + db1 = HPosLmDatabaseInfo::NewLC(_L("file:/awd/C:C:Pelle.ldb")); + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (3)")) ; + User::Leave(err); + + } + CleanupStack::PopAndDestroy(db1); + + // TC Step 20 Try to register a landmark database with an incorrect URI + db1 = HPosLmDatabaseInfo::NewLC(_L("file:/ /C:C:Pelle.ldb")); + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (4)")) ; + User::Leave(err); + + } + CleanupStack::PopAndDestroy(db1); + + // TC Step 21 Try to un-register a landmark database with an incorrect URI + TRAP(err, dbManager->UnregisterDatabaseL(_L("test:/ /C:Pelle.ldb"))); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: UnregisterDatabaseL with incorrect URI should leave with KErrArgument (1)")) ; + User::Leave(err); + + } + + // TC Step 22 Try to un-register a landmark database with an incorrect URI + TRAP(err, dbManager->UnregisterDatabaseL(_L("file: //C:C:Pelle.ldb"))); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: UnregisterDatabaseL with incorrect URI should leave with KErrArgument (2)")) ; + User::Leave(err); + + } + + // TC Step 23 Try to register a local landmark database + db1 = HPosLmDatabaseInfo::NewLC(KLocalDb1); + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: RegisterDatabaseL a local db should leave with KErrNotSupported")) ; + User::Leave(err); + + } + CleanupStack::PopAndDestroy(db1); + + // TC Step 24 Try to unregister a local landmark database + TRAP(err, dbManager->UnregisterDatabaseL(KLocalDb1)); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR:UnRegisterDatabaseL a local db should leave with KErrNotSupported")) ; + User::Leave(err); + + } + + // TC Step 25 Unregisters all dbs using empty protocol + // make sure that one is registered + db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); + dbManager->RegisterDatabaseL(*db1); + TRAP(err, dbManager->UnregisterAllDatabasesL(_L(""))); + if (err != KErrArgument) + { + iLog->Log(_L("ERROR: UnregisterAllDatabasesL with empty protocol should leave with KErrArgument")) ; + User::Leave(err); + + } + + // TC Step 26 Unregisters all dbs using KNullDesC + // make sure that one is registered + + TRAP(err, dbManager->UnregisterAllDatabasesL(KNullDesC)); + if (err != KErrArgument) + { + iLog->Log(_L("ERROR: UnregisterAllDatabasesL with KNullDesc protocol should leave with KErrArgument")) ; + User::Leave(err); + + } + + // TC Step 27 Unregisters all dbs using local protocol + // make sure that one is registered + + TRAP(err, dbManager->UnregisterAllDatabasesL(_L("file"))); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: UnregisterAllDatabasesL with file protocol should leave with KErrArgument(1)")) ; + User::Leave(err); + + } + + // TC Step 28 Unregisters all dbs using local protocol + // make sure that one is registered + TRAP(err, dbManager->UnregisterAllDatabasesL(_L("file://"))); + if (err != KErrNotSupported) + { + iLog->Log(_L("ERROR: UnregisterAllDatabasesL with file protocol should leave with KErrNotSupported(2)")) ; + User::Leave(err); + + } + + // TC 29 try to register again, should leave with KErrAlreadyExists + + TRAP(err, dbManager->RegisterDatabaseL(*db1)); + if (err != KErrAlreadyExists) + { + iLog->Log(_L("ERROR: RegisterDatabaseL already registered db should leave with KErrAlreadyExists")) ; + User::Leave(err); + + } + + CleanupStack::PopAndDestroy(db1); + + // TC Step 30 Copy database and verify that it is registered + dbManager->UnregisterAllDatabasesL(_L("test")); + db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb3); + dbManager->CreateDatabaseL(*db1); + // Register db, + dbManager->RegisterDatabaseL(*db1); + CleanupStack::PopAndDestroy(db1); + dbManager->CopyDatabaseL(KRemoteDb3, KRemoteDb4); + // Only list "remote" dbs + list = dbManager->ListDatabasesLC(_L("test")); + iDbArray->Reset(); + iDbArray->AppendL(KRemoteDb3); + iDbArray->AppendL(KRemoteDb4); + + VerifyDbListL(list); + CleanupStack::PopAndDestroy(list); + + // TC Step 31) Check DatabaseExistsL method + TBool result = dbManager->DatabaseExistsL(KRemoteDb3); + if (!result) + { + iLog->Log(_L("DatabaseExistsL should return ETrue")) ; + User::Leave(-1); + + } + result = dbManager->DatabaseExistsL(KRemoteNonExistingDb); + if (result) + { + iLog->Log(_L("DatabaseExistsL should return EFalse")) ; + User::Leave(-1); + } + + // TC Step 32) Try to copy remote db to local + TRAP(err, dbManager->CopyDatabaseL(KRemoteDb3, KLocalDb2)); + if (err != KErrArgument) + { + iLog->Log(_L("Copy from remote to local should leave with KErrArgument")) ; + User::Leave(err); + } + + // TC Step 33) Try to copy remote db to local + TRAP(err, dbManager->CopyDatabaseL(KRemoteDb3, KRemoteDb5)); + if (err != KErrArgument) + { + iLog->Log(_L("Copy from remote to unspecified should leave with KErrArgument")) ; + User::Leave(err); + + } + + CleanupStack::PopAndDestroy(dbManager); + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP135")) ; + User::Leave(-1); + + } + else iLog->Log(_L("CPosTp135 Passed")); + } + +// --------------------------------------------------------- +// CPosTp135::VerifyDbListL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp135::VerifyDbListL(CDesCArray* aDbArray) + { + iLog->Log(_L("VerifyDbListL")); + if (aDbArray->Count() != iDbArray->Count()) + { + TBuf<100> buf; + buf.Format(_L("List was %d should be %d "), aDbArray->Count(), iDbArray->Count()); + + iLog->Log(buf); + User::Leave(KErrNone); + } + + TInt found = 0; + TInt count = aDbArray->Count(); + TInt i = 0; + + for (i = 0; iFind(iDbArray->MdcaPoint(i), pos) != KErrNone) + { + iLog->Log(_L("Did Not Found:")); + iLog->Log(iDbArray->MdcaPoint(i)); + iLog->Log(_L("------------------")); + } + else + { + iLog->Log(iDbArray->MdcaPoint(i)); + found++; + } + } + + if (found != count) + { + + iLog->Log(_L("List was not correct")); + User::Leave(-1); + + } + + } + +// --------------------------------------------------------- +// CPosTp135::VerifyDbInfoListL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp135::VerifyDbInfoListL(RPointerArray aDbInfoList, + RPointerArray aDbInfoList2) + { + iLog->Log(_L("VerifyDbInfoListL")); + + TBuf<100> debug; + + if (aDbInfoList.Count() != aDbInfoList2.Count()) + { + TBuf<100> buf; + buf.Format(_L("List was %d should be %d "), aDbInfoList.Count(), aDbInfoList2.Count()); + + iLog->Log(buf); + User::Leave(KErrNone); + + } + + TBool found = EFalse; + TInt count = aDbInfoList.Count(); + TInt j=0; + + for (j = 0; jLog(_L("Looking for: ")); + iLog->Log(aDbInfoList[j]->DatabaseUri()); + + for (i = 0; iDatabaseUri()).CompareC((aDbInfoList2[i])->DatabaseUri()) == KErrNone) + { + iLog->Log(_L("Found:")); + iLog->Log(aDbInfoList2[i]->DatabaseUri()); + found = ETrue; + TPosLmDatabaseSettings settings = aDbInfoList[j]->Settings(); + + if (aDbInfoList[j]->IsDefault()) + { + iLog->Log(_L("Db should never be default")); + User::Leave(KErrNone); + } + + if (aDbInfoList[j]->DatabaseUri() == KRemoteDb1) + { + if (settings.DatabaseName() != KRemoteDbName1) + { + iLog->Log(_L("Incorrect Databasename for remote db1")); + User::Leave(-1); + } + if (aDbInfoList[j]->Protocol() != _L("test")) + { + iLog->Log(_L("Incorrect protocol for remote db1")); + User::Leave(-1); + } + if (aDbInfoList[j]->DatabaseMedia() != EMediaRemote) + { + iLog->Log(_L("Incorrect media for remote db1")); + User::Leave(-1); + } + if (aDbInfoList[j]->DatabaseDrive() != 'U') + { + iLog->Log(_L("Incorrect drive for remote db1")); + User::Leave(-1); + } + } + else if (aDbInfoList[j]->DatabaseUri() == KRemoteDb2) + { + if (settings.DatabaseName() != KRemoteDbName2) + { + iLog->Log(_L("Incorrect Databasename for remote db2")); + User::Leave(-1); + } + if (aDbInfoList[j]->Protocol() != _L("test")) + { + iLog->Log(_L("Incorrect protocol for remote db2")); + User::Leave(-1); + } + if (aDbInfoList[j]->DatabaseMedia() != EMediaRemote) + { + iLog->Log(_L("Incorrect media for remote db2")); + User::Leave(-1); + } + if (aDbInfoList[j]->DatabaseDrive() != 'U') + { + iLog->Log(_L("Incorrect drive for remote db2")); + User::Leave(-1); + } + } + else + { + // Local db + if (aDbInfoList[j]->Protocol() != _L("file")) + { + iLog->Log(_L("Incorrect protocol for local db")); + User::Leave(-1); + } + if (settings.DatabaseName() != KLocalDbName1) + { + iLog->Log(_L("Incorrect Databasename for local db")); + User::Leave(-1); + } + + + + if (aDbInfoList[j]->DatabaseDrive() != 'C') + { + iLog->Log(_L("Incorrect drive for remote db1")); + User::Leave(-1); + } + + } + + if (aDbInfoList[j]->Size() <1) + { + iLog->Log(_L("Size should have a value")); + User::Leave(-1); + } + if (!settings.IsAttributeSet(TPosLmDatabaseSettings::EName)) + { + iLog->Log(_L("Name attribute should be set")); + User::Leave(-1); + } + + } + } + if (!found) + { + + iLog->Log(_L("List was not correct")); + User::Leave(-1); + } + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp136.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp136.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp136.h" +#include +#include +#include + +// ================= CONSTANTS ======================= + + _LIT(KLMXFile, "c:\\system\\test\\testdata\\Tp136.xml"); + _LIT(KGPXFile, "c:\\system\\test\\testdata\\Tp136.gpx"); + + _LIT(KEmpty, ""); + + _LIT(K1, "Category nr1 added in TP48"); + + _LIT(K2, "Läkare"); + _LIT(K3, "Sjukhus"); + _LIT(K4, "Restaurant"); + _LIT(K5, "Shop"); + + _LIT(K6, "Frisör"); + + _LIT(K7, "Dagis"); + _LIT(K8, "BurgerKing"); + _LIT(K9, "Hotel"); + _LIT(K10, "Car park"); + + _LIT(K11, "Garage"); + _LIT(K12, "Bus stop"); + _LIT(K13, "BurgerKing"); + + _LIT(K14, "Category nr2 added in TP48"); + _LIT(K15_1, "OutSight"); + const TInt KNrOfLandmarks = 8; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp136::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp136::CloseTest() + { + // Release ECOM stuff + ReleaseLandmarkResources(); + + delete iOperation;iOperation=NULL; + } + +// --------------------------------------------------------- +// CPosTp136::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp136::StartL() + { + iErrorsFound = 0; + + // LMX + TestParseL(KLMXFile, KLmxMimeType); + TestImportL(KLMXFile, KLmxMimeType); + + // GPX + TestParseL(KGPXFile, KGpxMimeType); + TestImportL(KGPXFile, KGpxMimeType); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP136")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp136::TestParseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp136::TestParseL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestParseL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + parser->SetInputFileHandleL(file); + iOperation = parser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress=0; + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TInt counter=0; + while (progress != 1) + { + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + CPosLandmark* lm = parser->LandmarkLC(); + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + RArray arr; + CleanupClosePushL(arr); + + lm->GetCategoriesL(arr); + for (TInt i=0;iLandmarkCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name when comparing")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + counter++; + } + + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + iLog->Log(_L("-------------------\n")); + delete iOperation;iOperation=NULL; + + CleanupStack::PopAndDestroy(&file); + + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + CleanupStack::PopAndDestroy(parser); + } + +// --------------------------------------------------------- +// CPosTp136::TestImportL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp136::TestImportL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkDatabase* database = OpenDatabaseLC(); + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(categoryManager); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + + parser->SetInputFileHandleL(file); + iOperation = database->ImportLandmarksL(*parser, CPosLandmarkDatabase::EIncludeCategories); + + ExecuteAndDeleteLD(iOperation); + iOperation=NULL; + + CPosLmItemIterator* iter = database->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TPosLmItemId id = iter->NextL(); + TInt counter = 0; + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = database->ReadLandmarkLC(id); + RArray arr; + CleanupClosePushL(arr); + + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + lm->GetCategoriesL(arr); + if (arr.Count() == 0) iLog->Log(_L("NOLL")); + else + { + TBuf<100> buf; + buf.Format(_L("nr of categories %d"), arr.Count()); + iLog->Log(buf); + } + + for (TInt i=0;iReadCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + counter++; + } + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(iter); + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + + iLog->Log(_L("-------------------\n")); + + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(database); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp137.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp137.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,295 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp137.h" +#include +#include +#include + +#include +#include +#include +#include + +// ================= CONSTANTS ======================= + + _LIT(KLmxFile, "c:\\system\\test\\testdata\\Tp137.xml"); + _LIT(KGpxFile, "c:\\system\\test\\testdata\\Tp137.gpx"); + +#define DEBUG ETrue + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp137::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp137::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp137::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp137::StartL() + { + iErrorsFound = 0; + + // LMX + TestImportEmptyDbL( KLmxFile, KLmxMimeType ); + TestImport1L( KLmxFile, KLmxMimeType ); + + // GPX + TestImportEmptyDbL( KGpxFile, KGpxMimeType ); + TestImport1L( KGpxFile, KGpxMimeType ); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP137")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp137::TestImportEmptyDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp137::TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportEmptyDbL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + // No categories should be imported, since ESupressCategoryCreation is used and the landmarks + // db is empty when starting + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: No categories should have been imported")); + iErrorsFound++; + } + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp137::TestImport1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp137::TestImport1L(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImport1L ------")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + // Create two local categories, "Dagis" and "BurgerKing" belongs to landmark "asdf" + CPosLandmarkCategory* category1 = CPosLandmarkCategory::NewLC(); + category1->SetCategoryNameL(_L("Dagis")); + TPosLmItemId id1 = categoryManager->AddCategoryL(*category1); + CleanupStack::PopAndDestroy(category1); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewLC(); + category2->SetCategoryNameL(_L("BurgerKing")); + TPosLmItemId id2 = categoryManager->AddCategoryL(*category2); + CleanupStack::PopAndDestroy(category2); + + // Create "Frisör" belongs to landmark "TE, Lund" + CPosLandmarkCategory* category3 = CPosLandmarkCategory::NewLC(); + category3->SetCategoryNameL(_L("Frisör")); + TPosLmItemId id3 = categoryManager->AddCategoryL(*category3); + CleanupStack::PopAndDestroy(category3); + + // Remove global category with global id 1 + // Belongs to "Kalles Hundgård" + TPosLmItemId globalId = categoryManager->GetGlobalCategoryL(3000); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(globalId)); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EIncludeGlobalCategoryNames | CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: Three categories should have been added")); + iErrorsFound++; + } + + // Check that landmark "TE, Lund" has "Frisör" and + // landmark "asdf" has "Dagis" and "BurgerKing" (and also already existing global categories + + TBuf<100> buf; + + RArray categories; + CleanupClosePushL(categories); + + TPosLmItemId idde1; + + // Check id=5 Te, Lund + idde1 = categoryManager->GetCategoryL(_L("Frisör")); + categories.Append(idde1); + CheckLandmarkL(5, categories); + categories.Reset(); + + // Check id=6 asdf + idde1 = categoryManager->GetCategoryL(_L("Dagis")); + TPosLmItemId idde2 = categoryManager->GetCategoryL(_L("BurgerKing")); + categories.Append(idde1); + if ( aMime != KGpxMimeType ) + { + categories.Append(idde2); + } + CheckLandmarkL(6, categories); + categories.Reset(); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp137::CheckLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp137::CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList) + { + iLog->Log(_L("CheckLandmarkL")); + + // Get landmark + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(aLandmarkId); + TPtrC name1; + lm1->GetLandmarkName(name1); + iLog->Log(name1); + + RArray categories; + CleanupClosePushL(categories); + // Get all categories attached to this landmark + lm1->GetCategoriesL(categories); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + if ( aCategoriesList.Count() != categories.Count() ) + { + iLog->Log(_L("ERROR: Wrong number of categories, actual %d, expected %d"), + categories.Count(), aCategoriesList.Count() ); + iErrorsFound++; + } + + for (TInt i=0;iLog(_L("Found")); + } + else + { + iLog->Log(_L("ERROR: Category '%S' was not found")); + iErrorsFound++; + } + } + + CleanupStack::PopAndDestroy(categoryManager); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(lm1); + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp139.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp139.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp139.h" +#include + + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp139::GetSortAttribute +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp139::GetSortAttribute() + { + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLandmark::TAttributes att; + + for (TInt i=0; i<6; i++) + { + if (i==0) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::ELandmarkName) + { + iLog->Log(_L("The landmark attribute to sort by is :ELandmarkName")); + } + } + else if (i==1) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EPosition, TPosLmSortPref::EDescending); + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::EPosition ) + { + iLog->Log(_L("The landmark attribute to sort by is :EPosition")); + } + } + else if (i==2) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ECoverageRadius, TPosLmSortPref::EAscending); + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::ECoverageRadius) + { + iLog->Log(_L("The landmark attribute to sort by is :ECoverageRadius")); + } + } + else if (i==3) + { + + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ECategoryInfo, TPosLmSortPref::EDescending); + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::ECategoryInfo) + { + iLog->Log(_L("The landmark attribute to sort by is :ECategoryInfo")); + } + } + else if (i==4) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EIcon, TPosLmSortPref::EAscending); + + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::EIcon) + { + iLog->Log(_L("The landmark attribute to sort by is :EIcon")); + } + } + + else if (i==5) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EDescription, TPosLmSortPref::EDescending); + + att = sortPref.LandmarkAttributeToSortBy(); + if(att == CPosLandmark::EDescription) + { + iLog->Log(_L("The landmark attribute to sort by is :EDescription")); + } + } + + } + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp141.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp141.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,183 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp141.h" +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp141::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp141::CloseTest() + { + + delete iDatabase; + iDatabase = NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp141::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp141::StartL() + { + _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); + _LIT(KLandMarkattrErr, "Landmark attribute set -> AttributesToSearch should return ELandmarkName |EDescription "); + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + TestInvalidPositionFieldsL(); + + // Check iterator before search has started (in multidb search all iterators are empty thus NOT NULL) + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + if (iter) + { + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == 0, _L("Iterator should be empty")); + CleanupStack::PopAndDestroy(iter); + } + else + { + + iLog->Log(_L("Iterator should NOT be NULL")); + User::Leave(-1); + } + + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetAttributesToSearch(attr); + AssertTrueSecL(textCriteria->AttributesToSearch() == CPosLandmark::EDescription | CPosLandmark::ELandmarkName, KLandMarkattrErr); + + textCriteria->SetTextL(_L("")); + + TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + + + CleanupStack::PopAndDestroy(textCriteria); + + } + + +// --------------------------------------------------------- +// CPosTp141::TestInvalidPositionFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp141::TestInvalidPositionFieldsL() + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + RArray arr; + CleanupClosePushL(arr); + textCriteria->GetPositionFieldsToSearchL(arr); + textCriteria->SetTextL(_L("*")); + textCriteria->SetPositionFieldsToSearchL(arr); + + // Search with empty positionfields list, should find all landmarks + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + ExecuteAndDeleteLD(iOperation); + TInt nr = iLandmarkSearch->NumOfMatches(); + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches when searching in empty position fields list"), nr); + iLog->Log(buf); + + + + User::LeaveIfError(arr.Append(1)); + User::LeaveIfError(arr.Append(2)); + User::LeaveIfError(arr.Append(3)); + + textCriteria->SetPositionFieldsToSearchL(arr); + textCriteria->GetPositionFieldsToSearchL(arr); + TBuf<100> buf1; + for(TInt i=0;i< arr.Count();i++) + { + buf1.Format(_L(" %d position fields--%d- "),i, arr[i]); + iLog->Log(buf1); + } + + + //Clears the position fields list used in a search + textCriteria->ClearPositionFieldsToSearch(); + textCriteria->GetPositionFieldsToSearchL(arr); + if(arr.Count()==0) + { + iLog->Log(_L("ClearPositionFieldsToSearch()-Cleared the position fields list used in a search.")); + } + + + + iLog->Log(_L("Sets the position fields list used in a search")); + User::LeaveIfError(arr.Append(0)); + User::LeaveIfError(arr.Append(50)); + User::LeaveIfError(arr.Append(500)); + + textCriteria->SetPositionFieldsToSearchL(arr); + textCriteria->GetPositionFieldsToSearchL(arr); + TBuf<100> buf2; + for(TInt i=0;i< arr.Count();i++) + { + buf2.Format(_L(" %d position fields--%d- "),i, arr[i]); + iLog->Log(buf2); + } + + + // Search with invalid positionfields list, should NOT find any landmarks + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + ExecuteAndDeleteLD(iOperation); + nr = iLandmarkSearch->NumOfMatches(); + + buf.Format(_L("Found %d nr of matches when searching in invalid position fields"), nr); + iLog->Log(buf); + + AssertTrueSecL(nr == 0, _L("We should not find any matches")); + textCriteria->ClearPositionFieldsToSearch(); + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(textCriteria); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp143.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp143.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +#include +#include +#include +#include // RDebug +#include "FT_CPosTp143.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp143::StartL() + { + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + ExecuteAndDeleteLD(iDatabase->CompactL()); + AddLandmarksL(); + + CheckCountersL(); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp143::CloseTest() + { + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp143::AddLandmarksL() + { + iLog->Log(_L("AddLandmarksL")); + _LIT(KLmName, "LmTP143 - %d"); + _LIT(KLmDescription, "LmTP143Description - %d"); + + const TInt KNoLandmarks = 1000; + for (TInt i=0; i< KNoLandmarks ; i++) + { + TBuf<100> lmName; + lmName.Format(KLmName,i); + TBuf<100> lmDesc; + lmDesc.Format(KLmDescription,i); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + landmark->SetLandmarkDescriptionL(lmDesc); + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iDatabase->AddLandmarkL(*landmark)); + } + + iLandmarks.Append(landmark); + + CleanupStack::Pop(landmark); + } + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp143::CheckCountersL() + { + iLog->Log(_L("CheckCountersL")); + + TTime start, end; + CPosLandmarkDatabaseExtended* dbExt = CPosLandmarkDatabaseExtended::OpenL(); + CleanupStack::PushL(dbExt); + + iLog->Log(_L("checking LandmarksCount")); + start.UniversalTime(); + TInt lmCount = dbExt->LandmarksCount(); + end.UniversalTime(); + TTimeIntervalMicroSeconds interval = end.MicroSecondsFrom( start ); + iLog->Log(_L("LandmarksCount done in %ld us"), interval.Int64()); + + if ( lmCount != iLandmarks.Count() ) + { + iLog->Log( _L("LandmarksCount wrong result, expected %d, actual %d"), + iLandmarks.Count(), lmCount ); + User::Leave( KErrGeneral ); + } + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + if ( lmCount != iter->NumOfItemsL() ) + { + iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"), + iter->NumOfItemsL(), lmCount ); + User::Leave( KErrGeneral ); + } + + CleanupStack::PopAndDestroy( iter ); + + iLog->Log(_L("checking CategoriesCount")); + start.UniversalTime(); + TInt catCount = dbExt->CategoriesCount(); + end.UniversalTime(); + interval = end.MicroSecondsFrom( start ); + iLog->Log(_L("CategoriesCount done in %ld us"), interval.Int64()); + + CPosLmCategoryManager& catman = dbExt->CategoryManager(); + + CPosLmItemIterator* catIter = catman.CategoryIteratorL(); + CleanupStack::PushL(catIter); + + if ( catCount != catIter->NumOfItemsL() ) + { + iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"), + catIter->NumOfItemsL(), catCount ); + User::Leave( KErrGeneral ); + } + + CleanupStack::PopAndDestroy( catIter ); + CleanupStack::PopAndDestroy( dbExt ); + } + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp144.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp144.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp144.h" +#include +#include + +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp144::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp144::StartL() + { + + CheckLmSerializationL(); + + } + +// --------------------------------------------------------- +// CPosTp144::DumpBuffer +// +// --------------------------------------------------------- + +void CPosTp144::DumpBuffer(const TDesC8& aBuffer) + { + DECLARE_ERROR_LOGGING; + LOG("=== Buffer Dump ==="); + message.Format(_L("Buffer size = %d units"), aBuffer.Length()); + LOG_DES(message); + for (TInt i = 0; i < aBuffer.Length(); i++) + { + _LIT(KByte, "Offset %4d = % 2d"); + _LIT(KChar, "Offset %4d = % 2c"); + TUint8 c = aBuffer[i]; + if (TChar(c).IsAlphaDigit()) + { + message.Format(KChar, i, c); + } + else + { + message.Format(KByte, i, TInt(c)); + } + LOG_DES(message); + } + LOG("==================="); + } +// --------------------------------------------------------- +// CPosTp144::CompareBuffers +// +// --------------------------------------------------------- + +void CPosTp144::CompareBuffers( + const TDesC8& aBuf1, + const TDesC8& aBuf2) + { + DECLARE_ERROR_LOGGING; + + CHECK_EQUAL(aBuf1.Length(), aBuf2.Length(), "Different buffer lengths"); + for (TInt i = 0; i < Min(aBuf1.Length(), aBuf2.Length()); i++) + { + TInt c1 = aBuf1[i], c2 = aBuf2[i]; + if (c1 != c2) + { + _LIT(KMessage, "Different at offset %d (actual = %d, expected %d)"); + message.Format(KMessage, i, c1, c2); + ERR_DES(message); + } + } + } + +// --------------------------------------------------------- +// CPosTp144::CreateDummyLandmarkLC +// +// --------------------------------------------------------- + +CPosLandmark* CPosTp144::CreateDummyLandmarkLC() + { + CPosLandmark* lm = CPosLandmark::NewLC(); + + _LIT(KName, "Name"); + _LIT(KDesc, "Description"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + + const TPosLmItemId KCat[] = { 3, 4, 5 }; + const TInt KCats = sizeof KCat / sizeof(TPosLmItemId); + + _LIT(KField1Val, "field1"); + _LIT(KField2Val, "field11"); + const TPositionFieldId KField[] = + { + EPositionFieldComment, + EPositionFieldCountry + }; + const TInt KFields = sizeof KField / sizeof(TPositionFieldId); + const TPtrC KFieldData[] = + { + KField1Val(), KField2Val() + }; + + const TReal32 KRadius = 0.12; + const TReal32 KHacc = 0.23, KVacc = 0.34; + const TReal KLat = 12, KLon = -23, KAlt = 34; + + lm->SetLandmarkNameL(KName); + lm->SetLandmarkDescriptionL(KDesc); + lm->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + + const TLocality KLoc(TCoordinate(KLat,KLon,KAlt), KHacc, KVacc); + lm->SetPositionL(KLoc); + lm->SetCoverageRadius(KRadius); + + for (TInt c = 0; c < KCats; c++) + { + lm->AddCategoryL(KCat[c]); + } + + for (TInt f = 0; f < KFields; f++) + { + lm->SetPositionFieldL(KField[f], KFieldData[f]); + } + + return lm; + } + +// --------------------------------------------------------- +// CPosTp144::CompareLandmarks +// +// --------------------------------------------------------- + +void CPosTp144::CompareLandmarks( + CPosLandmark& aLm1, + CPosLandmark& aLm2) + { + DECLARE_ERROR_LOGGING; + + TPtrC name1, name2; + + CHECK_EQUAL(aLm1.LandmarkId(), aLm2.LandmarkId(), "Diff id"); + CHECK_EQUAL(aLm1.IsPartial(), aLm2.IsPartial(), "Diff partial state"); + + aLm1.GetLandmarkName(name1); + aLm2.GetLandmarkName(name2); + ERROR(name1 != name2, "Diff name"); + + aLm1.GetLandmarkDescription(name1); + aLm2.GetLandmarkDescription(name2); + ERROR(name1 != name2, "Diff description"); + + TInt iconIndex1 = 0, iconMaskIndex1 = 0; + TInt iconIndex2 = 1, iconMaskIndex2 = 2; + + TInt found1 = aLm1.GetIcon(name1, iconIndex1, iconMaskIndex1); + TInt found2 = aLm2.GetIcon(name2, iconIndex2, iconMaskIndex2); + + if (found1 == found2) + { + if (found1 != KErrNotFound) + { + ERROR(name1 != name2, "Diff icon name"); + CHECK_EQUAL(iconIndex1, iconIndex2, "Diff icon index"); + CHECK_EQUAL(iconMaskIndex1, iconMaskIndex2, "Diff icon mask index"); + } + } + else + { + ERR("Diff icon") + } + + // location + TLocality loc1, loc2; + found1 = aLm1.GetPosition(loc1); + found2 = aLm2.GetPosition(loc2); + + if (found1 == found2) + { + if (found1 != KErrNotFound) + { + CHECK_EQUAL(loc1.Latitude(), loc2.Latitude(), "Diff latitude"); + CHECK_EQUAL(loc1.Longitude(), loc2.Longitude(), "Diff longitude"); + CHECK_EQUAL(loc1.Altitude(), loc2.Altitude(), "Diff altitude"); + CHECK_EQUAL(loc1.HorizontalAccuracy(), loc2.HorizontalAccuracy(), "Diff hacc"); + CHECK_EQUAL(loc1.VerticalAccuracy(), loc2.VerticalAccuracy(), "Diff vacc"); + CHECK_EQUAL(loc1.Datum(), loc2.Datum(), "Diff datum"); + } + } + else + { + ERR("Diff position"); + } + + // categories + RArray cats1, cats2; + aLm1.GetCategoriesL(cats1); + aLm2.GetCategoriesL(cats2); + CHECK_EQUAL(cats1.Count(), cats2.Count(), "Diff amount of categories"); + for (TInt c = 0; c < Min(cats1.Count(), cats2.Count()); c++) + { + CHECK_EQUAL(cats1[c], cats2[c], "Diff category"); + } + cats1.Close(); + cats2.Close(); + + // fields + TInt fields1 = aLm1.NumOfAvailablePositionFields(); + TInt fields2 = aLm2.NumOfAvailablePositionFields(); + CHECK_EQUAL(fields1, fields2, "Diff amount of fields"); + + TPositionFieldId fid1 = aLm1.FirstPositionFieldId(); + TPositionFieldId fid2 = aLm2.FirstPositionFieldId(); + for (TInt f = 0; + f < Min(fields1, fields2) && + (fid1 != EPositionFieldNone || fid2 != EPositionFieldNone); + f++) + { + CHECK_EQUAL(fid1, fid2, "Diff field"); + aLm1.GetPositionField(fid1, name1); + aLm2.GetPositionField(fid2, name2); + ERROR(name1 != name2, "Diff field data"); + + fid1 = aLm1.NextPositionFieldId(fid1); + fid2 = aLm1.NextPositionFieldId(fid2); + } + } + + +// --------------------------------------------------------- +// CPosTp144::CheckLmSerialization_SubL +// +// --------------------------------------------------------- + +void CPosTp144::CheckLmSerialization_SubL(CPosLandmark* lm) + { + DECLARE_ERROR_LOGGING; + + CPosLandmark* lm1 = lm; + CPosLandmark* lm2 = NULL; + + TInt err = KErrNone; + HBufC8* buf1 = NULL; + HBufC8* buf2 = NULL; + + TRAP(err, buf1 = PosLandmarkSerialization::PackL(*lm1)); + IF_ERROR(err, "Packing failed"); + User::LeaveIfError(err); + CleanupStack::PushL(buf1); + + TRAP(err, lm2 = PosLandmarkSerialization::UnpackL(*buf1)); + IF_ERROR(err, "Unpacking failed"); + User::LeaveIfError(err); + CleanupStack::PushL(lm2); + + // read and compare values + CompareLandmarks(*lm1, *lm2); + + // compare by buffer + TRAP(err, buf2 = PosLandmarkSerialization::PackL(*lm2)); + CleanupStack::PushL(buf2); + + CompareBuffers(*buf1, *buf2); + + // cleanup + CleanupStack::PopAndDestroy(buf2); + CleanupStack::PopAndDestroy(lm2); + CleanupStack::PopAndDestroy(buf1); + + } + +// --------------------------------------------------------- +// CPosTp144::CheckLmSerializationL +// +// --------------------------------------------------------- + + void CPosTp144::CheckLmSerializationL() + { + DECLARE_ERROR_LOGGING; + + + //LOG("1. Dummy landmark") + CPosLandmark* lm = CreateDummyLandmarkLC(); + CheckLmSerialization_SubL(lm); + CleanupStack::PopAndDestroy(lm); + + //LOG("2. Empty landmark") + lm = CPosLandmark::NewLC(); + CheckLmSerialization_SubL(lm); + CleanupStack::PopAndDestroy(lm); + + + LEAVE_IF_ERRORS() + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp145.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp145.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp145.h" +#include +#include + +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp145::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp145::StartL() + { + + CheckLmCatSerializationL(); + + } + +// --------------------------------------------------------- +// CPosTp145::CompareBuffers +// +// --------------------------------------------------------- + + + void CPosTp145::CompareBuffers( + const TDesC8& aBuf1, + const TDesC8& aBuf2) + { + DECLARE_ERROR_LOGGING + + CHECK_EQUAL(aBuf1.Length(), aBuf2.Length(), "Different buffer lengths"); + for (TInt i = 0; i < Min(aBuf1.Length(), aBuf2.Length()); i++) + { + TInt c1 = aBuf1[i], c2 = aBuf2[i]; + if (c1 != c2) + { + _LIT(KMessage, "Different at offset %d (actual = %d, expected %d)"); + message.Format(KMessage, i, c1, c2); + ERR_DES(message); + } + } + } + +// --------------------------------------------------------- +// CPosTp145::CreateDummyCategoryLC +// +// --------------------------------------------------------- + +CPosLandmarkCategory* CPosTp145::CreateDummyCategoryLC() + { + CPosLandmarkCategory* cat = CPosLandmarkCategory::NewLC(); + + TInt KCatId = cat->CategoryId(); + _LIT(KName, "Name"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + cat->SetCategoryNameL(KName); + cat->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + return cat; + } + +// --------------------------------------------------------- +// CPosTp145::CompareCategoriesL +// +// --------------------------------------------------------- + +void CPosTp145::CompareCategoriesL( + CPosLandmarkCategory& aCat1, + CPosLandmarkCategory& aCat2) + { + DECLARE_ERROR_LOGGING; + + CHECK_EQUAL(aCat1.CategoryId(), aCat2.CategoryId(), "Diff id"); + CHECK_EQUAL(aCat1.GlobalCategory(), aCat2.GlobalCategory(), "Diff global category"); + + TPtrC name1, name2; + aCat1.GetCategoryName(name1); + aCat2.GetCategoryName(name2); + ERROR(name1 != name2, "Diff name"); + + TInt iconIndex1 = 0, iconMaskIndex1 = 0; + TInt iconIndex2 = 1, iconMaskIndex2 = 2; + + TInt found1 = aCat1.GetIcon(name1, iconIndex1, iconMaskIndex1); + TInt found2 = aCat2.GetIcon(name2, iconIndex2, iconMaskIndex2); + + if (found1 == found2) + { + if (found1 != KErrNotFound) + { + ERROR(name1 != name2, "Diff icon name"); + CHECK_EQUAL(iconIndex1, iconIndex2, "Diff icon index"); + CHECK_EQUAL(iconMaskIndex1, iconMaskIndex2, "Diff icon mask index"); + } + } + else + { + ERR("Diff icon"); + } + } + +// --------------------------------------------------------- +// CPosTp145::CheckLmCatSerializationL +// +// --------------------------------------------------------- + +void CPosTp145::CheckLmCatSerializationL() + { + DECLARE_ERROR_LOGGING; + + + LOG("1. Dummy category") + CPosLandmarkCategory* cat = CreateDummyCategoryLC(); + CheckLmCatSerialization_SubL(cat); + CleanupStack::PopAndDestroy(cat); + + LOG("2. Empty category") + cat = CPosLandmarkCategory::NewLC(); + CheckLmCatSerialization_SubL(cat); + CleanupStack::PopAndDestroy(cat); + + + LEAVE_IF_ERRORS() + } + +// --------------------------------------------------------- +// CPosTp145::CheckLmCatSerialization_SubL +// +// --------------------------------------------------------- + +void CPosTp145::CheckLmCatSerialization_SubL(CPosLandmarkCategory* aTest) + { + DECLARE_ERROR_LOGGING; + + CPosLandmarkCategory* cat1 = aTest; + CPosLandmarkCategory* cat2 = NULL; + + TInt err = KErrNone; + HBufC8* buf1 = NULL; + HBufC8* buf2 = NULL; + + TRAP(err, buf1 = PosLmCategorySerialization::PackL(*cat1)); + IF_ERROR(err, "Packing failed"); + User::LeaveIfError(err); + CleanupStack::PushL(buf1); + + TRAP(err, cat2 = PosLmCategorySerialization::UnpackL(*buf1)); + IF_ERROR(err, "Unpacking failed"); + User::LeaveIfError(err); + CleanupStack::PushL(cat2); + + CompareCategoriesL(*cat1, *cat2); + + // compare by buffer + TRAP(err, buf2 = PosLmCategorySerialization::PackL(*cat2)); + CleanupStack::PushL(buf2); + + CompareBuffers(*buf1, *buf2); + + // cleanup + CleanupStack::PopAndDestroy(buf2); + CleanupStack::PopAndDestroy(cat2); + CleanupStack::PopAndDestroy(buf1); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp146.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp146.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp146.h" +#include +#include + +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp146::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp146::StartL() + { + + CheckLmCatSerializationInvalidL(); + + } + +// --------------------------------------------------------- +// CPosTp146::CreateDummyLandmarkLC +// +// --------------------------------------------------------- + +CPosLandmark* CPosTp146::CreateDummyLandmarkLC() + { + CPosLandmark* lm = CPosLandmark::NewLC(); + + _LIT(KName, "Name"); + _LIT(KDesc, "Description"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + + const TPosLmItemId KCat[] = { 3, 4, 5 }; + const TInt KCats = sizeof KCat / sizeof(TPosLmItemId); + + _LIT(KField1Val, "field1"); + _LIT(KField2Val, "field11"); + const TPositionFieldId KField[] = + { + EPositionFieldComment, + EPositionFieldCountry + }; + const TInt KFields = sizeof KField / sizeof(TPositionFieldId); + const TPtrC KFieldData[] = + { + KField1Val(), KField2Val() + }; + + const TReal32 KRadius = 0.12; + const TReal32 KHacc = 0.23, KVacc = 0.34; + const TReal KLat = 12, KLon = -23, KAlt = 34; + + lm->SetLandmarkNameL(KName); + lm->SetLandmarkDescriptionL(KDesc); + lm->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + + const TLocality KLoc(TCoordinate(KLat,KLon,KAlt), KHacc, KVacc); + lm->SetPositionL(KLoc); + lm->SetCoverageRadius(KRadius); + + for (TInt c = 0; c < KCats; c++) + { + lm->AddCategoryL(KCat[c]); + } + + for (TInt f = 0; f < KFields; f++) + { + lm->SetPositionFieldL(KField[f], KFieldData[f]); + } + + return lm; + } + +// --------------------------------------------------------- +// CPosTp146::CreateDummyCategoryLC +// +// --------------------------------------------------------- + + +CPosLandmarkCategory* CPosTp146::CreateDummyCategoryLC() + { + CPosLandmarkCategory* cat = CPosLandmarkCategory::NewLC(); + + TInt KCatId = cat->CategoryId(); + _LIT(KName, "Name"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + cat->SetCategoryNameL(KName); + cat->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + return cat; + } + +// --------------------------------------------------------- +// CPosTp146::CheckLmCatSerializationInvalidL +// +// --------------------------------------------------------- + +void CPosTp146::CheckLmCatSerializationInvalidL() + { + DECLARE_ERROR_LOGGING + + + TInt err = KErrNone; + HBufC8* buf1 = NULL; + HBufC8* buf2 = NULL; + + CPosLandmark* lm = CreateDummyLandmarkLC(); + TRAP(err, buf1 = PosLandmarkSerialization::PackL(*lm)); + CleanupStack::PopAndDestroy(lm); + lm = NULL; + + IF_ERROR(err, "Packing failed"); + User::LeaveIfError(err); + CleanupStack::PushL(buf1); + + CPosLandmarkCategory* cat = CreateDummyCategoryLC(); + TRAP(err, buf2 = PosLmCategorySerialization::PackL(*cat)); + CleanupStack::PopAndDestroy(cat); + cat = NULL; + + IF_ERROR(err, "Packing failed"); + User::LeaveIfError(err); + CleanupStack::PushL(buf2); + + TRAP(err, cat = PosLmCategorySerialization::UnpackL(*buf1)); + delete cat; + + ERROR(err == KErrNone, "Wrong error (lm->cat)"); + + TRAP(err, lm = PosLandmarkSerialization::UnpackL(*buf2)); + delete lm; + + ERROR(err == KErrNone, "Wrong error (cat->lm)"); + + CleanupStack::PopAndDestroy(buf2); + CleanupStack::PopAndDestroy(buf1); + + + LEAVE_IF_ERRORS() + } + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp147.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp147.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp147.h" +#include +#include + +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp147::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp147::StartL() + { + + CheckSerializationMemoryL(); + + } + +// --------------------------------------------------------- +// CPosTp147::CreateDummyLandmarkLC +// +// --------------------------------------------------------- + +CPosLandmark* CPosTp147::CreateDummyLandmarkLC() + { + CPosLandmark* lm = CPosLandmark::NewLC(); + + _LIT(KName, "Name"); + _LIT(KDesc, "Description"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + + const TPosLmItemId KCat[] = { 3, 4, 5 }; + const TInt KCats = sizeof KCat / sizeof(TPosLmItemId); + + _LIT(KField1Val, "field1"); + _LIT(KField2Val, "field11"); + const TPositionFieldId KField[] = + { + EPositionFieldComment, + EPositionFieldCountry + }; + const TInt KFields = sizeof KField / sizeof(TPositionFieldId); + const TPtrC KFieldData[] = + { + KField1Val(), KField2Val() + }; + + const TReal32 KRadius = 0.12; + const TReal32 KHacc = 0.23, KVacc = 0.34; + const TReal KLat = 12, KLon = -23, KAlt = 34; + + lm->SetLandmarkNameL(KName); + lm->SetLandmarkDescriptionL(KDesc); + lm->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + + const TLocality KLoc(TCoordinate(KLat,KLon,KAlt), KHacc, KVacc); + lm->SetPositionL(KLoc); + lm->SetCoverageRadius(KRadius); + + for (TInt c = 0; c < KCats; c++) + { + lm->AddCategoryL(KCat[c]); + } + + for (TInt f = 0; f < KFields; f++) + { + lm->SetPositionFieldL(KField[f], KFieldData[f]); + } + + return lm; + } + +// --------------------------------------------------------- +// CPosTp147::CreateDummyCategoryLC +// +// --------------------------------------------------------- + + +CPosLandmarkCategory* CPosTp147::CreateDummyCategoryLC() + { + CPosLandmarkCategory* cat = CPosLandmarkCategory::NewLC(); + + TInt KCatId = cat->CategoryId(); + _LIT(KName, "Name"); + _LIT(KIcon, "IconFile"); + const TInt KIconIndex = 1, KIconMaskIndex = 2; + cat->SetCategoryNameL(KName); + cat->SetIconL(KIcon, KIconIndex, KIconMaskIndex); + return cat; + } + +// --------------------------------------------------------- +// CPosTp147::CheckSerializationMemoryL +// +// --------------------------------------------------------- + +void CPosTp147::CheckSerializationMemoryL() + { + CheckLmSerialization_MemoryL(); + CheckLmCatSerialization_MemoryL(); + } + +// --------------------------------------------------------- +// CPosTp147::CheckLmSerialization_MemoryL +// +// --------------------------------------------------------- + +void CPosTp147::CheckLmSerialization_MemoryL() + { + DECLARE_ERROR_LOGGING; + + LOG("Packing and checking uheap"); + + CPosLandmark* lm = CreateDummyLandmarkLC(); + + __UHEAP_MARK; + HBufC8* buf = PosLandmarkSerialization::PackL(*lm); + delete buf; + __UHEAP_MARKEND; + + LOG("Unpacking and checking uheap"); + + buf = PosLandmarkSerialization::PackL(*lm); + CleanupStack::PopAndDestroy(lm); + CleanupStack::PushL(buf); + + __UHEAP_MARK; + lm = PosLandmarkSerialization::UnpackL(*buf); + delete lm; + __UHEAP_MARKEND; + + LOG("Done"); + CleanupStack::PopAndDestroy(buf); + } + +// --------------------------------------------------------- +// CPosTp147::CheckLmCatSerialization_MemoryL +// +// --------------------------------------------------------- + +void CPosTp147::CheckLmCatSerialization_MemoryL() + { + DECLARE_ERROR_LOGGING; + + LOG("Packing and checking uheap"); + + CPosLandmarkCategory* cat = CreateDummyCategoryLC(); + + __UHEAP_MARK; + HBufC8* buf = PosLmCategorySerialization::PackL(*cat); + delete buf; + __UHEAP_MARKEND; + + LOG("Unpacking and checking uheap"); + + buf = PosLmCategorySerialization::PackL(*cat); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PushL(buf); + + __UHEAP_MARK; + cat = PosLmCategorySerialization::UnpackL(*buf); + delete cat; + __UHEAP_MARKEND; + + LOG("Done"); + CleanupStack::PopAndDestroy(buf); + } + + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp148.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp148.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,632 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp148.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP148Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + + + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP148Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp148KMZFile.kmz"); + +// Maxmimum size for each line in trace file +static const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp148::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp148::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp148KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if ( correctLine.Compare( line ) != KErrNone ) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + + CleanupStack::PopAndDestroy( linebuffer ); + CleanupStack::PopAndDestroy( correctLinebuffer ); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP148")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp148::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp148::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + + buf.Append( catName ); + iLog->Log( buf ); + TraceL( buf ); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp148::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName( landmarkName ); + if ( err == KErrNone ) + { + + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L(" srcRadius %S" ), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Format( _L( "\tIdField Id: %d Value:" ), sourceFieldId ); + buf.Append( sourceValue ); + iLog->Log( buf ); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId( sourceFieldId ); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp148::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp148::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp149.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp149.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp149.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP149Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP149Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp149KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp149::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp149::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + +if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp149KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP149")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp149::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp149::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp149::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + + + } + + +// --------------------------------------------------------- +// CPosTp149::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp149::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp15.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp15.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp15.h" +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp15::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp15::GetName(TDes& aName) const + { + _LIT(KTestName, "TP15 - Database initialization - Created"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp13::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp15::StartL() + { + TestInitializeDatabaseL(ETrue); + + TestInitializeDatabaseL(); + + TestInitializeWithUserWaitForL(); + + TestInitializeDatabaseAndCancelL(); + + // Cancel proceeds even if the client cancels it so added User::After just to make sure it's done when the test case completes + User::After(2000000); + } + +// --------------------------------------------------------- +// CPosTp15::TestInitializeDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp15::TestInitializeDatabaseL(const TBool aSyncronously) + { + _LIT(KAccessErr, "Access method is not returning KErrPosLmNotInitialized when expected"); + _LIT(KInitializedErr, "Method InitializedNeeded is not returning ETrue when expected"); + _LIT(KAccessAfterInitErr, "Access method leaves with %d after initialized"); + + TRAPD(err, RemoveDefaultDbL()); + while (err == KErrInUse) + { + User::After(1000); + TRAP(err, RemoveDefaultDbL()); + } + User::LeaveIfError(err); + + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + TPosLmGlobalCategory globalCategory = 1; + TRAP(err, cm->GetGlobalCategoryL(globalCategory)); + AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessErr); + + AssertTrueSecL(lmd->IsInitializingNeeded(), KInitializedErr); + + if (aSyncronously) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + else + { + RunAsyncOperationLD(lmd->InitializeL()); + } + + + TRAP(err, cm->GetGlobalCategoryL(globalCategory)); + AssertTrueSecL(err == KErrNone, KAccessAfterInitErr, err); + + CleanupStack::PopAndDestroy(2, lmd); + + } + + +// --------------------------------------------------------- +// CPosTp15::TestInitializeDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp15::TestInitializeWithUserWaitForL() + { + // ESLI-64VGXW + _LIT(KInitializedErr, "Method InitializedNeeded is not returning ETrue when expected"); + + TRAPD(err, RemoveDefaultDbL()); + while (err == KErrInUse) + { + User::After(1000); + TRAP(err, RemoveDefaultDbL()); + } + User::LeaveIfError(err); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + AssertTrueSecL(lmd->IsInitializingNeeded(), KInitializedErr); + + CPosLmOperation* op = lmd->InitializeL(); + CleanupStack::PushL(op); + + RunAsyncOperationByWaitForReqL(op); + + CleanupStack::PopAndDestroy(2, lmd); + + } + +// --------------------------------------------------------- +// CPosTp15::TestInitializeDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp15::TestInitializeDatabaseAndCancelL() + { + iLog->Put(_L("TestInitializeDatabaseAndCancelL")); + _LIT(KAccessCancelErr, "Access method is not returning KErrPosLmNotInitialized after cancel"); + + CPosLandmarkDatabase* lmd = NULL; + TReal32 progress(0); + while (progress < 1.0) + { + RemoveDefaultDbL(); + lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + RunAsyncOperationAndCancelInCallbackLD(lmd->InitializeL(), progress); + progress = progress + 0.09; + + CleanupStack::PopAndDestroy(lmd); + } + + lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + TPosLmGlobalCategory globalCategory = 1; + TRAPD(err, cm->GetGlobalCategoryL(globalCategory)); + + // KErrNone means that the initialization already has completed which is OK + if (err == KErrNone) + { + iLog->Put(_L("Err. code returned is KErrNone->initialization has already completed")); + } + else + { + AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessCancelErr, err); + } + + CleanupStack::PopAndDestroy(2, lmd); + iLog->Put(_L("TestInitializeDatabaseAndCancelL Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp150.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp150.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,615 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp150.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP150Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP150Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp150KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp150::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp150::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp150KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP150")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp150::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp150::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + + buf.Append( catName ); + iLog->Log( buf ); + TraceL( buf ); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp150::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp150::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp150::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp151.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp151.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,611 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp151.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP151Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP151Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp151KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp151::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp151::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp151KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP151")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp151::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp151::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy(buffer); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp151::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp151::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp151::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp152.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp152.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp152.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP152Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP152Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp152KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp152::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp152::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp152KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP152")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp152::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp152::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy(buffer); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp152::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp152::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp152::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp153.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp153.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,613 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp153.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP153Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP153Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp153KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp153::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp153::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp153KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, -993, KKmzMimeType ); //EXmlTagMismatch = -993 + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP153")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp153::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + if(status == KErrNone) + { + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + iErrorsFound++; + } + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp153::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC(array[i]); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + + buf.Append( catName ); + iLog->Log( buf ); + TraceL( buf ); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp153::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp153::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp153::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp154.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp154.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp154.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP154Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP154Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp154KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp154::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp154::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp154KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, -993, KKmzMimeType ); //EXmlTagMismatch = -993 + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC * correctLinebuffer = HBufC::NewLC(KBufSize); + TPtr correctLine(correctLinebuffer->Des()); + HBufC * linebuffer = HBufC::NewLC(KBufSize); + TPtr line(linebuffer->Des()); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP154")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp154::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp154::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp154::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp154::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp154::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp155.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp155.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,609 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp155.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP155Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP155Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp155KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp155::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp155::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + +if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp155KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP155")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp155::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp155::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp155::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp155::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp155::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp156.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp156.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,616 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp156.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP156Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP156Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp156KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp156::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp156::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp156KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, -993, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP156")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp156::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + if(status == KErrNone) + { + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + iErrorsFound++; + } + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp156::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC(array[i]); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + + buf.Append( catName ); + iLog->Log( buf ); + TraceL( buf ); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp156::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp156::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp156::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp157.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp157.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp157.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP157Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP157Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp157KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp157::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp157::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp157::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp157::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + + iLog->Log(_L("Test with Tp157KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP157")); + User::Leave(-1); + } + + } + + + // --------------------------------------------------------- +// CPosTp157::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp157::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + TRAPD(err,iLandmarkParser->SetInputFileL(file)); + if(err != KErrNone) + { + TBuf<100> buffe; + buffe.Format(_L("\t SetInputFile leaves with error code : %d"), err); + iLog->Log(buffe); + + } + else + { + iErrorsFound++; + TBuf<100> buffe; + buffe.Format(_L("\tERROR: SetInputFile should leave with error code")); + iLog->Log(buffe); + + } + + + delete iLandmarkParser; + iLandmarkParser = NULL; + + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + + + +// --------------------------------------------------------- +// CPosTp157::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp157::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp158.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp158.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,607 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp158.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP158Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP158Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp158KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp158::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp158::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp158KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + DoCancelTestL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP158")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp158::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType); + iLandmarkParser->SetInputFileL(KKMZFile); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KKMZFile); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + + // --------------------------------------------------------- +// CPosTp158::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + iLandmarkParser->SetInputFileL(file); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + iLog->Log(_L("Parsing Complete")); + + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("Parsing element")); + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC( array[i] ); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy(category); + } + + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + // --------------------------------------------------------- +// CPosTp158::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + iLog->Log(_L("Parsing Description ... \n")); + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + +// --------------------------------------------------------- +// CPosTp158::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp158::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp159.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp159.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,284 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp159.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP159Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP159Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp159KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp159::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp159::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp159::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp159::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + +if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp159KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrPosLmUnknownFormat, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP159")); + User::Leave(-1); + } + } + + + + // --------------------------------------------------------- +// CPosTp159::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp159::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + TRAPD(err,iLandmarkParser->SetInputFileL(file)); + if(err != KErrPosLmUnknownFormat) + { + iErrorsFound++; + TBuf<100> buffe; + buffe.Format(_L("\tERROR: SetInputFile should leave with error code KErrPosLmUnknownFormat (-30352)")); + iLog->Log(buffe); + + } + else + { + + TBuf<100> buffe; + buffe.Format(_L("\tSetInputFile leaves with error code KErrPosLmUnknownFormat")); + iLog->Log(buffe); + + } + + + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + + +// --------------------------------------------------------- +// CPosTp159::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp159::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp16.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp16.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp16.h" +#include +#include +#include + +#include "FT_LandmarkConstants.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp16::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp16::GetName(TDes& aName) const + { + _LIT(KTestName, "TP16 - Initialize corrupt database"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp16::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp16::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + iGlobalCategoryIds.Close(); + iGlobalCategoryNames.Close(); + RemoveGlobalCategoriesL(); + } + +// --------------------------------------------------------- +// CPosTp16::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp16::StartL() + { + _LIT(KAccessErr, "Access method is not returning KErrPosLmNotInitialized when expected"); + _LIT(KInitializedErr, "Method InitializedNeeded is not returning ETrue when expected"); + + SetupGlobalCategoriesL(); + + iDatabase=UseCorruptDbL(); + delete iDatabase; + iDatabase = NULL; + + iDatabase = UseGlobalCategoriesL(); + + CPosLmItemIterator* iter = NULL; + TRAPD(err, iter = iDatabase->LandmarkIteratorL()); + delete iter; + AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessErr); + AssertTrueSecL(iDatabase->IsInitializingNeeded(), KInitializedErr); + + ExecuteAndDeleteLD(iDatabase->InitializeL()); + + iter = iDatabase->LandmarkIteratorL(); + delete iter; + iter=NULL; + + // check that global categories are automatically inserter into lm db + // when recovering database + CheckGlobalCategoriesL(); + + delete iDatabase; + iDatabase = NULL; + + iDatabase=UseCorruptDbL(); + TRAP(err, iter = iDatabase->LandmarkIteratorL()); + delete iter; + AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessErr); + AssertTrueSecL(iDatabase->IsInitializingNeeded(), KInitializedErr); + + RunAsyncOperationLD(iDatabase->InitializeL()); + + iter = iDatabase->LandmarkIteratorL(); + delete iter; + + // check that global categories are automatically inserter into lm db + // when recovering database + CheckGlobalCategoriesL(); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = UseTextDbL(); + + ExecuteAndDeleteLD(iDatabase->InitializeL()); + + iter = iDatabase->LandmarkIteratorL(); + delete iter; + iter=NULL; + + // check that global categories are automatically inserter into lm db + // when recovering database + CheckGlobalCategoriesL(); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = UseContactDbL(); + + ExecuteAndDeleteLD(iDatabase->InitializeL()); + + iter = iDatabase->LandmarkIteratorL(); + delete iter; + iter=NULL; + + // check that global categories are automatically inserter into lm db + // when recovering database + CheckGlobalCategoriesL(); + + delete iDatabase; + iDatabase = NULL; + } + + +// --------------------------------------------------------- +// CPosTp16::CheckGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp16::CheckGlobalCategoriesL() + { + iLog->Put(_L("CheckGlobalCategoriesL")); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(cm); + + iLog->Put(_L("using CategoryIteratorL")); + CPosLmItemIterator* catIter = cm->CategoryIteratorL(); + CleanupStack::PushL(catIter); + + AssertTrueSecL(catIter->NumOfItemsL() == (TUint)iGlobalCategoryIds.Count(), _L("Wrong number of global categories")); + + TPosLmItemId id = catIter->NextL(); + TInt i=0; + while (id != KPosLmNullItemId) + { +/* + // For debugging purposes + TBuf<100> buf; + buf.Format(_L("Id %d Exp Id %d"),id, iGlobalCategoryIds[i]); + iLog->Put(buf); + if (id != iGlobalCategoryIds[i]) LogErrorAndLeave(_L("Wrong id")); + else iLog->Put(_L("++")); +*/ + id = catIter->NextL(); + i++; + } + CleanupStack::PopAndDestroy(catIter); + CleanupStack::PopAndDestroy(cm); + + } + +// --------------------------------------------------------- +// CPosTp16::UseCorruptDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp16::UseCorruptDbL() + { + RemoveDefaultDbL(); + + #ifdef __WINS__ + _LIT(KCorruptDbFile, "z:\\system\\test\\testdata\\SRVeposdamaged.ldb"); + #else + _LIT(KCorruptDbFile, "c:\\system\\test\\testdata\\SRVeposdamaged.ldb"); + #endif + + _LIT(KCorruptDbFileOld, "c:\\system\\data\\SRVeposdamaged.ldb"); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Copy(KCorruptDbFile, KDefaultDbPath, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Rename(KCorruptDbFileOld, KDefaultDb, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp16::UseTextDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp16::UseTextDbL() + { + RemoveDefaultDbL(); + + #ifdef __WINS__ + _LIT(KCorruptDbFile, "z:\\system\\test\\testdata\\SRVepostext.ldb"); + #else + _LIT(KCorruptDbFile, "c:\\system\\test\\testdata\\SRVepostext.ldb"); + #endif + + _LIT(KCorruptDbFileOld, "c:\\system\\data\\SRVepostext.ldb"); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Copy(KCorruptDbFile, KDefaultDbPath, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Rename(KCorruptDbFileOld, KDefaultDb, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp16::UseContactDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp16::UseContactDbL() + { + RemoveDefaultDbL(); + + #ifdef __WINS__ + _LIT(KCorruptDbFile, "z:\\system\\test\\testdata\\SRVeposcontact.ldb"); + #else + _LIT(KCorruptDbFile, "c:\\system\\test\\testdata\\SRVeposcontact.ldb"); + #endif + + _LIT(KCorruptDbFileOld, "c:\\system\\data\\SRVeposcontact.ldb"); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Copy(KCorruptDbFile, KDefaultDbPath, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Rename(KCorruptDbFileOld, KDefaultDb, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp16::SetupGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp16::SetupGlobalCategoriesL() + { + iGlobalCategoryNames.Reset(); + iGlobalCategoryIds.Reset(); + + iGlobalCategoryNames.Append(_L("Restaurant")); + iGlobalCategoryIds.Append(1); + + iGlobalCategoryNames.Append(_L("Bar")); + iGlobalCategoryIds.Append(2); + + iGlobalCategoryNames.Append(_L("Gas station")); + iGlobalCategoryIds.Append(3); + + iGlobalCategoryNames.Append(_L("Hotel")); + iGlobalCategoryIds.Append(4); + + iGlobalCategoryNames.Append(_L("Shop")); + iGlobalCategoryIds.Append(5); + + iGlobalCategoryNames.Append(_L("Sight")); + iGlobalCategoryIds.Append(6); + + iGlobalCategoryNames.Append(_L("Car park")); + iGlobalCategoryIds.Append(7); + + iGlobalCategoryNames.Append(_L("Bus stop")); + iGlobalCategoryIds.Append(8); + + iGlobalCategoryNames.Append(_L("Pools")); + iGlobalCategoryIds.Append(9); + + iGlobalCategoryNames.Append(_L("Shopping streets")); + iGlobalCategoryIds.Append(10); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp160.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp160.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,281 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp160.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KFileTrace, "c:\\documents\\LandmarksTP160Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + + + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP160Trace.txt"); + +_LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp160KMZFile.kmz"); + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp160::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp160::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp160::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp160::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + iLog->Log(_L("Test with Tp160KMZFile.kmz")); + PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); + + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + + + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP160")); + User::Leave(-1); + } + } + + + + // --------------------------------------------------------- +// CPosTp160::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp160::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + + TFileName file( aFile ); + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + TraceL(file); + TRAPD(err,iLandmarkParser->SetInputFileL(file)); + if(err != KErrNone) + { + TBuf<100> buffe; + buffe.Format(_L("\t SetInputFile leaves with error code : %d"), err); + iLog->Log(buffe); + + } + else + { + iErrorsFound++; + TBuf<100> buffe; + buffe.Format(_L("\tERROR: SetInputFile should leave with error code")); + iLog->Log(buffe); + + } + + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + + + + + +// --------------------------------------------------------- +// CPosTp160::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp160::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp161.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp161.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,325 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp161.h" +#include +#include +#include + +// ================= CONSTANTS ======================= + + + _LIT(KKMLFile, "c:\\system\\test\\testdata\\Tp161KML.kml"); + + + _LIT(KEmpty, ""); + + _LIT(K1, "Category nr1 added in TP48"); + + _LIT(K2, "Läkare"); + _LIT(K3, "Sjukhus"); + _LIT(K4, "Restaurant"); + _LIT(K5, "Shop"); + + _LIT(K6, "Frisör"); + + _LIT(K7, "Dagis"); + _LIT(K8, "BurgerKing"); + _LIT(K9, "Hotel"); + _LIT(K10, "Car park"); + + _LIT(K11, "Garage"); + _LIT(K12, "Bus stop"); + _LIT(K13, "BurgerKing"); + + _LIT(K14, "Category nr2 added in TP48"); + _LIT(K15_1, "OutSight"); + const TInt KNrOfLandmarks = 8; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp161::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp161::CloseTest() + { + // Release ECOM stuff + ReleaseLandmarkResources(); + + delete iOperation;iOperation=NULL; + } + +// --------------------------------------------------------- +// CPosTp161::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp161::StartL() + { + iErrorsFound = 0; + + + // KML + TestParseL(KKMLFile, KKmlMimeType); + TestImportL(KKMLFile, KKmlMimeType); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP161")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp161::TestParseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp161::TestParseL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestParseL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + parser->SetInputFileHandleL(file); + iOperation = parser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress=0; + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TInt counter=0; + while (progress != 1) + { + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + CPosLandmark* lm = parser->LandmarkLC(); + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + RArray arr; + CleanupClosePushL(arr); + + lm->GetCategoriesL(arr); + for (TInt i=0;iLandmarkCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name when comparing")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + counter++; + } + + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + iLog->Log(_L("-------------------\n")); + delete iOperation;iOperation=NULL; + + CleanupStack::PopAndDestroy(&file); + + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + CleanupStack::PopAndDestroy(parser); + } + +// --------------------------------------------------------- +// CPosTp161::TestImportL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp161::TestImportL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkDatabase* database = OpenDatabaseLC(); + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(categoryManager); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + + parser->SetInputFileHandleL(file); + iOperation = database->ImportLandmarksL(*parser, CPosLandmarkDatabase::EIncludeCategories); + + ExecuteAndDeleteLD(iOperation); + iOperation=NULL; + + CPosLmItemIterator* iter = database->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TPosLmItemId id = iter->NextL(); + TInt counter = 0; + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = database->ReadLandmarkLC(id); + RArray arr; + CleanupClosePushL(arr); + + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + lm->GetCategoriesL(arr); + if (arr.Count() == 0) iLog->Log(_L("NOLL")); + else + { + TBuf<100> buf; + buf.Format(_L("nr of categories %d"), arr.Count()); + iLog->Log(buf); + } + + for (TInt i=0;iReadCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + counter++; + } + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(iter); + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + + iLog->Log(_L("-------------------\n")); + + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(database); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp162.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp162.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,290 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp162.h" +#include +#include +#include + +#include +#include +#include +#include + +// ================= CONSTANTS ======================= + + + _LIT(KKMLFile, "c:\\system\\test\\testdata\\Tp162KML.kml"); + + +#define DEBUG ETrue + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp162::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp162::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp162::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp162::StartL() + { + iErrorsFound = 0; + + + // KML + TestImportEmptyDbL( KKMLFile, KKmlMimeType ); + TestImport1L( KKMLFile, KKmlMimeType ); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP162")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp162::TestImportEmptyDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp162::TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportEmptyDbL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + // No categories should be imported, since ESupressCategoryCreation is used and the landmarks + // db is empty when starting + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: No categories should have been imported")); + iErrorsFound++; + } + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp162::TestImport1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp162::TestImport1L(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImport1L ------")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + // Create two local categories, "Dagis" and "BurgerKing" belongs to landmark "asdf" + CPosLandmarkCategory* category1 = CPosLandmarkCategory::NewLC(); + category1->SetCategoryNameL(_L("Dagis")); + TPosLmItemId id1 = categoryManager->AddCategoryL(*category1); + CleanupStack::PopAndDestroy(category1); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewLC(); + category2->SetCategoryNameL(_L("BurgerKing")); + TPosLmItemId id2 = categoryManager->AddCategoryL(*category2); + CleanupStack::PopAndDestroy(category2); + + // Create "Frisör" belongs to landmark "TE, Lund" + CPosLandmarkCategory* category3 = CPosLandmarkCategory::NewLC(); + category3->SetCategoryNameL(_L("Frisör")); + TPosLmItemId id3 = categoryManager->AddCategoryL(*category3); + CleanupStack::PopAndDestroy(category3); + + // Remove global category with global id 1 + // Belongs to "Kalles Hundgård" + TPosLmItemId globalId = categoryManager->GetGlobalCategoryL(3000); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(globalId)); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EIncludeGlobalCategoryNames | CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: Three categories should have been added")); + iErrorsFound++; + } + + // Check that landmark "TE, Lund" has "Frisör" and + // landmark "asdf" has "Dagis" and "BurgerKing" (and also already existing global categories + + TBuf<100> buf; + + RArray categories; + CleanupClosePushL(categories); + + TPosLmItemId idde1; + + // Check id=5 Te, Lund + idde1 = categoryManager->GetCategoryL(_L("Frisör")); + categories.Append(idde1); + CheckLandmarkL(5, categories); + categories.Reset(); + + // Check id=6 asdf + idde1 = categoryManager->GetCategoryL(_L("Dagis")); + + categories.Append(idde1); + + CheckLandmarkL(6, categories); + categories.Reset(); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp162::CheckLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp162::CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList) + { + iLog->Log(_L("CheckLandmarkL")); + + // Get landmark + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(aLandmarkId); + TPtrC name1; + lm1->GetLandmarkName(name1); + iLog->Log(name1); + + RArray categories; + CleanupClosePushL(categories); + // Get all categories attached to this landmark + lm1->GetCategoriesL(categories); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + if ( aCategoriesList.Count() != categories.Count() ) + { + iLog->Log(_L("ERROR: Wrong number of categories, actual %d, expected %d"), + categories.Count(), aCategoriesList.Count() ); + iErrorsFound++; + } + + for (TInt i=0;iLog(_L("Found")); + } + else + { + iLog->Log(_L("ERROR: Category '%S' was not found")); + iErrorsFound++; + } + } + + CleanupStack::PopAndDestroy(categoryManager); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(lm1); + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp163.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp163.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,325 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp163.h" +#include +#include +#include + +// ================= CONSTANTS ======================= + + + _LIT(KKMZFile, "c:\\system\\test\\testdata\\Tp163KMZ.kmz"); + + + _LIT(KEmpty, ""); + + _LIT(K1, "Category nr1 added in TP48"); + + _LIT(K2, "Läkare"); + _LIT(K3, "Sjukhus"); + _LIT(K4, "Restaurant"); + _LIT(K5, "Shop"); + + _LIT(K6, "Frisör"); + + _LIT(K7, "Dagis"); + _LIT(K8, "BurgerKing"); + _LIT(K9, "Hotel"); + _LIT(K10, "Car park"); + + _LIT(K11, "Garage"); + _LIT(K12, "Bus stop"); + _LIT(K13, "BurgerKing"); + + _LIT(K14, "Category nr2 added in TP48"); + _LIT(K15_1, "OutSight"); + const TInt KNrOfLandmarks = 8; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp163::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp163::CloseTest() + { + // Release ECOM stuff + ReleaseLandmarkResources(); + + delete iOperation;iOperation=NULL; + } + +// --------------------------------------------------------- +// CPosTp163::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp163::StartL() + { + iErrorsFound = 0; + + + // KML + TestParseL(KKMZFile, KKmzMimeType); + TestImportL(KKMZFile, KKmzMimeType); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in Tp163")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp163::TestParseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp163::TestParseL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestParseL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + parser->SetInputFileHandleL(file); + iOperation = parser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress=0; + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TInt counter=0; + while (progress != 1) + { + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + CPosLandmark* lm = parser->LandmarkLC(); + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + RArray arr; + CleanupClosePushL(arr); + + lm->GetCategoriesL(arr); + for (TInt i=0;iLandmarkCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name when comparing")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + counter++; + } + + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + iLog->Log(_L("-------------------\n")); + delete iOperation;iOperation=NULL; + + CleanupStack::PopAndDestroy(&file); + + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + CleanupStack::PopAndDestroy(parser); + } + +// --------------------------------------------------------- +// CPosTp163::TestImportL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp163::TestImportL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + + RemoveAllLmDatabasesL(); + + const TDesC* categoryNames[KNrOfLandmarks][4] = {{&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K1, &KEmpty, &KEmpty, &KEmpty}, + {&K2, &K3, &K4, &K5}, + {&KEmpty, &KEmpty, &KEmpty, &KEmpty}, + {&K6, &KEmpty, &KEmpty, &KEmpty}, + {&K7, &K8, &K9, &K10}, + {&K11, &K12, &K13, &KEmpty}, + {&K14, &K15_1, &KEmpty, &KEmpty}}; + + CPosLandmarkDatabase* database = OpenDatabaseLC(); + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(aMime); + CleanupStack::PushL(parser); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(categoryManager); + + RFile file; + TInt err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L("Error when opening file")); + User::Leave(err); + } + CleanupClosePushL(file); + + parser->SetInputFileHandleL(file); + iOperation = database->ImportLandmarksL(*parser, CPosLandmarkDatabase::EIncludeCategories); + + ExecuteAndDeleteLD(iOperation); + iOperation=NULL; + + CPosLmItemIterator* iter = database->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + CDesCArrayFlat* landmarkNames = new (ELeave) CDesCArrayFlat(KNrOfLandmarks); + landmarkNames->AppendL(_L("Billigt")); + landmarkNames->AppendL(_L("LOG9")); + landmarkNames->AppendL(_L("Kalles Hundgård")); + landmarkNames->AppendL(_L("MLFW")); + landmarkNames->AppendL(_L("TE, Lund")); + landmarkNames->AppendL(_L("asdf")); + landmarkNames->AppendL(_L("TP48LandmarkWithAllXMLFields")); + landmarkNames->AppendL(_L("TP48Landmark With Empty XML Fields")); + + TPosLmItemId id = iter->NextL(); + TInt counter = 0; + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = database->ReadLandmarkLC(id); + RArray arr; + CleanupClosePushL(arr); + + TPtrC name; + lm->GetLandmarkName(name); + TPtrC expName(landmarkNames->MdcaPoint(counter)); + iLog->Log(_L("Landmark %d, Actual name '%S', Expected '%S'"), counter, &name, &expName); + if (expName.CompareC(name) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Landmark Name")); + iErrorsFound++; + } + + lm->GetCategoriesL(arr); + if (arr.Count() == 0) iLog->Log(_L("NOLL")); + else + { + TBuf<100> buf; + buf.Format(_L("nr of categories %d"), arr.Count()); + iLog->Log(buf); + } + + for (TInt i=0;iReadCategoryLC(arr[i]); + TPtrC catName; + cat->GetCategoryName(catName); + iLog->Log(_L("Category %d, Actual '%S', Expected '%S'"), i, &catName, categoryNames[counter][i]); + if (catName.CompareC(*categoryNames[counter][i]) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong Category Name")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + counter++; + } + TUint32 nr = parser->NumOfParsedLandmarks(); + if (nr != KNrOfLandmarks) + { + iLog->Log(_L("ERROR: Wrong number of landmarks parsed")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(iter); + landmarkNames->Reset(); + delete landmarkNames; + landmarkNames = NULL; + + iLog->Log(_L("-------------------\n")); + + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(database); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp164.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp164.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,290 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp164.h" +#include +#include +#include + +#include +#include +#include +#include + +// ================= CONSTANTS ======================= + + + _LIT(KKMZFile, "c:\\system\\test\\testdata\\Tp164KMZ.kmz"); + + +#define DEBUG ETrue + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp164::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp164::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp164::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp164::StartL() + { + iErrorsFound = 0; + + + // KML + TestImportEmptyDbL( KKMZFile, KKmzMimeType ); + TestImport1L( KKMZFile, KKmzMimeType ); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP164")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp164::TestImportEmptyDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp164::TestImportEmptyDbL(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImportEmptyDbL -----")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + // No categories should be imported, since ESupressCategoryCreation is used and the landmarks + // db is empty when starting + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: No categories should have been imported")); + iErrorsFound++; + } + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp164::TestImport1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp164::TestImport1L(const TDesC& aFile, const TDesC8& aMime) + { + iLog->Log(_L("----- TestImport1L ------")); + iLog->Log(_L("FILE: %S"), &aFile); + RemoveAllLmDatabasesL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMime); + iLandmarkParser->SetInputFileL(aFile); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + // Create two local categories, "Dagis" and "BurgerKing" belongs to landmark "asdf" + CPosLandmarkCategory* category1 = CPosLandmarkCategory::NewLC(); + category1->SetCategoryNameL(_L("Dagis")); + TPosLmItemId id1 = categoryManager->AddCategoryL(*category1); + CleanupStack::PopAndDestroy(category1); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewLC(); + category2->SetCategoryNameL(_L("BurgerKing")); + TPosLmItemId id2 = categoryManager->AddCategoryL(*category2); + CleanupStack::PopAndDestroy(category2); + + // Create "Frisör" belongs to landmark "TE, Lund" + CPosLandmarkCategory* category3 = CPosLandmarkCategory::NewLC(); + category3->SetCategoryNameL(_L("Frisör")); + TPosLmItemId id3 = categoryManager->AddCategoryL(*category3); + CleanupStack::PopAndDestroy(category3); + + // Remove global category with global id 1 + // Belongs to "Kalles Hundgård" + TPosLmItemId globalId = categoryManager->GetGlobalCategoryL(3000); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(globalId)); + + CPosLmItemIterator* catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesBefore = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + + iLog->Log(_L("iDatabase->ImportLandmarksL")); + + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EIncludeGlobalCategoryNames | CPosLandmarkDatabase::ESupressCategoryCreation| CPosLandmarkDatabase::EIncludeCategories)); + + + catIter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(catIter); + TInt nrOfcategoriesAfter = catIter->NumOfItemsL(); + CleanupStack::PopAndDestroy(catIter); + if (nrOfcategoriesAfter != nrOfcategoriesBefore) + { + iLog->Log(_L("ERROR: Three categories should have been added")); + iErrorsFound++; + } + + // Check that landmark "TE, Lund" has "Frisör" and + // landmark "asdf" has "Dagis" and "BurgerKing" (and also already existing global categories + + TBuf<100> buf; + + RArray categories; + CleanupClosePushL(categories); + + TPosLmItemId idde1; + + // Check id=5 Te, Lund + idde1 = categoryManager->GetCategoryL(_L("Frisör")); + categories.Append(idde1); + CheckLandmarkL(5, categories); + categories.Reset(); + + // Check id=6 asdf + idde1 = categoryManager->GetCategoryL(_L("Dagis")); + + categories.Append(idde1); + + CheckLandmarkL(6, categories); + categories.Reset(); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase = NULL; + iLog->Log(_L("-------------------\n")); + } + +// --------------------------------------------------------- +// CPosTp164::CheckLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp164::CheckLandmarkL(TPosLmItemId aLandmarkId, RArray aCategoriesList) + { + iLog->Log(_L("CheckLandmarkL")); + + // Get landmark + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(aLandmarkId); + TPtrC name1; + lm1->GetLandmarkName(name1); + iLog->Log(name1); + + RArray categories; + CleanupClosePushL(categories); + // Get all categories attached to this landmark + lm1->GetCategoriesL(categories); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + if ( aCategoriesList.Count() != categories.Count() ) + { + iLog->Log(_L("ERROR: Wrong number of categories, actual %d, expected %d"), + categories.Count(), aCategoriesList.Count() ); + iErrorsFound++; + } + + for (TInt i=0;iLog(_L("Found")); + } + else + { + iLog->Log(_L("ERROR: Category '%S' was not found")); + iErrorsFound++; + } + } + + CleanupStack::PopAndDestroy(categoryManager); + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(lm1); + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp17.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp17.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,219 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp17.h" +#include +#include + +// CONSTANTS +const TInt KMaxDllFileNameLength = 100; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp17::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp17::GetName(TDes& aName) const + { + _LIT(KTestName, "TP17 - Memory footprint"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp17::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp17::CloseTest() + { + iFootprints.Close(); + iDllNames.Close(); + } + +// --------------------------------------------------------- +// CPosTp17::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp17::StartL() + { +#ifdef __WINS__ + _LIT(KNotSupported, "Test case is not supported on WINS, exucute it on target!"); + LogErrorAndLeave(KNotSupported); +#else + _LIT(KErrors, "One or several Dll's have an incorrect size"); + SetupTestDataL(); + + RFs session; + User::LeaveIfError(session.Connect()); + CleanupClosePushL(session); + + RFile file; + TBuf<1> drive= _L("c"); + TBuf name; + name.Copy(iDllNames[0]); + name.Replace(0,1,drive); + + if (file.Open(session, name, EFileRead) != KErrNone) + { + iLog->Put(_L("(Flashed) Use Drive Z:")); + drive.Copy(_L("z")); + } + else iLog->Put(_L("(Nonflashed) Use Drive C:")); + + file.Close(); + TBool errors=EFalse; + for (TInt i=0; i buffe; + buffe.Append(_L("Error when opening file ")); + buffe.Append(name); + LogErrorAndLeave(buffe, err); + } + + CleanupClosePushL(file); + TInt fileSize=0; + file.Size(fileSize); + + if (fileSize > iFootprints[i]) + { + errors = ETrue; + + _LIT(KDllSizeErr, "ERROR: %S is to big (%d), Max allowed ROM footprint is %d"); + TBuf<255> info; + HBufC* temp = name.Alloc(); + info.Format(KDllSizeErr, temp, fileSize, iFootprints[i]); + delete temp; + iLog->Put(info); + } + else + { + // Always log .dll size + _LIT(KDllSizeDebug, "%S is (%d), Max allowed ROM footprint is %d"); + TBuf<255> info; + HBufC* temp = name.Alloc(); + info.Format(KDllSizeDebug, temp, fileSize, iFootprints[i]); + delete temp; + iLog->Put(info); + } + + CleanupStack::PopAndDestroy(&file); + } + CleanupStack::PopAndDestroy(&session); + + if (errors) + { + LogErrorAndLeave(KErrors); + } +#endif + } + +// --------------------------------------------------------- +// CPosTp17::SetupTestDataL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp17::SetupTestDataL() + { + iLog->Put(_L("SetupTestDataL")); + + _LIT(KLANDMARK,"z:\\sys\\bin\\eposlandmarks.dll"); + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + //check if landmark is flashed + if (BaflUtils::FileExists(fs, KLANDMARK)) + { + //Landmark is flashed + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlandmarks.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmsearchlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmmultidbsearch.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalsearchprovider.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalaccessprovider.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalaccess.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmservlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmserver.exe"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbreg.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmintservices.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmconverter.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmrecognizer.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbmanlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbmanprov.dll"))); + User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocaldbmanprovider.dll"))); + } + else + { + //Landmark is not flashed + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlandmarks.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmsearchlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmmultidbsearch.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalsearchprovider.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalaccessprovider.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalaccess.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmservlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmserver.exe"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbreg.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmintservices.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmconverter.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmrecognizer.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbmanlib.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbmanprov.dll"))); + User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocaldbmanprovider.dll"))); + } + + User::LeaveIfError(iFootprints.Append(9000)); //eposlandmarks.dll (Landmarks Client Library) + // Note that eposlmmultidbsearch.dll + eposlmsearchlib.dll must not be bigger than 17000 + User::LeaveIfError(iFootprints.Append(8500)); //eposlmsearchlib.dll (Landmarks Search Client Library) + User::LeaveIfError(iFootprints.Append(8500)); //eposlmmultidbsearch.dll (Landmarks Search Client Library) + User::LeaveIfError(iFootprints.Append(19000)); //eposlmlocalsearchprovider.dll (Landmarks Local Search Provider) + // Note that eposlmlocalaccessprovider.dll + eposlmlocalaccess.dll must not be bigger than 23000 + User::LeaveIfError(iFootprints.Append(400)); //eposlmlocalaccessprovider.dll (Landmarks Local Access Provider) + User::LeaveIfError(iFootprints.Append(23000)); //eposlmlocalaccess.dll (Landmarks Local Access) + User::LeaveIfError(iFootprints.Append(2000)); //eposlmservlib.dll (Landmarks Server Client Library) + User::LeaveIfError(iFootprints.Append(26000)); //eposlmserver.exe (Landmarks Server) + User::LeaveIfError(iFootprints.Append(6000)); //eposlmdbreg.dll (Landmarks Database Registry) + User::LeaveIfError(iFootprints.Append(23000)); //eposlmintservices.dll (Landmarks Internal Services) + User::LeaveIfError(iFootprints.Append(22000)); //eposlmconverter,dll (Landmarks Content Format Converter) + User::LeaveIfError(iFootprints.Append(2000)); //eposlmrecognizer.mdl (Landmarks Content Format Recognizer) + User::LeaveIfError(iFootprints.Append(3000)); //eposlmdbmanlib.dll (Landmarks DB Management Client) + User::LeaveIfError(iFootprints.Append(6000)); //eposlmdbmanprov.dll (Landmarks Database Management Provider) + User::LeaveIfError(iFootprints.Append(5000)); //eposlmlocaldbmanprovider.dll (Landmarks Local Database Management Provider) + + CleanupStack::PopAndDestroy(2, &fs); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp18.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp18.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,851 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp18.h" +#include +#include +#include +#include + + +// CONSTANTS +const TInt KNoPreparePartial = 40; +_LIT(KTakePreparedPartialErr, "Method TakePreparedPartialLandmarksL doesn't leave with KErrNotFound"); +_LIT(KNoPreparedPartialErr, "Method TakePreparedPartialLandmarksL returns incorrect no. landmarks"); +_LIT(KNoPreparedPartialErr2, "Method TakePreparedPartialLandmarksL returns incorrect landmarks"); + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp10::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::CloseTest() + { + if (iArrayPtr) + { + iArrayPtr->ResetAndDestroy(); + } + delete iArrayPtr; + iArrayPtr = NULL; + + delete iDatabase; + iDatabase = NULL; + + delete iOperation; + iOperation = NULL; + } + +// --------------------------------------------------------- +// CPosTp18::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::StartL() + { + _LIT(KNotPartialErr, "Landmark is not a partial landmark"); + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Test some non-existing landmark ids + TPosLmItemId id = KPosLmNullItemId; + TRAPD(err, iDatabase->ReadPartialLandmarkLC(id)); + if (err != KErrNotFound) + { + iLog->Log(_L("ReadPartialLandmarkLC should leave with KErrnotFound")); + User::Leave(err); + } + id = 2000; + TRAP(err, iDatabase->ReadPartialLandmarkLC(id)); + if (err != KErrNotFound) + { + iLog->Log(_L("ReadPartialLandmarkLC should leave with KErrnotFouns")); + User::Leave(err); + } + + TestAllPartialAttributesL(); + + TestPartialPositionFieldsL(); + + PreparePartialLandmarksL(); + + PreparePartialLandmarksAsyncL(EAsynchronous); + + PreparePartialLandmarksAsyncL(EWaitForRequest); + + iLog->Log(_L("TESTS BELOW ARE TESTING CANCEL")); + PreparePartialLandmarksAsyncAndCancelL(); + + iLog->Log(_L("TEST BELOW IS TESTING CANCEL IN CALLBACK")); + PreparePartialLandmarksAsyncAndCancelL(ETrue); + + TUint attr=CPosLandmark::ELandmarkName; + CPosLmPartialReadParameters* partialParam = iDatabase->PartialReadParametersLC(); + partialParam->SetRequestedAttributes(attr); + CPosLandmark* lm = GetPartialLandmarkLC(1, *partialParam); + CheckPartialLandmarkL(*lm, attr); + + CPosLandmark* copy = CPosLandmark::NewLC(*lm); + + iDatabase->AddLandmarkL(*copy); + + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(copy->LandmarkId()); + + AssertTrueSecL(!lm2->IsPartial(), KNotPartialErr); + CleanupStack::PopAndDestroy(4,partialParam); + } + +// --------------------------------------------------------- +// CPosTp18::TestAllPartialAttributes +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::TestAllPartialAttributesL() + { + iLog->Log(_L("TestAllPartialAttributesL")); + iLog->Log(_L("Testing GetPartialLandmarks with all combination of attributes requested")); + _LIT(KNoAttrReqErr, "No attributes have been requested -> RequestedAttributes should return ENoAttribute"); + + CPosLmPartialReadParameters* partialParam = iDatabase->PartialReadParametersLC(); + + AssertTrueSecL(partialParam->RequestedAttributes() == CPosLandmark::ENoAttribute, KNoAttrReqErr); + + iDatabase->SetPartialReadParametersL(*partialParam); + + TPosLmItemId id=1; // landmarks Id with all attr set + + TUint max = CPosLandmark::EDescription; + max <<= 1; + max -= 1; + CPosLandmark* lm = NULL; + + TUint attr=0; + for (attr=0; attr<=max; attr++) + { + partialParam->SetRequestedAttributes(attr); + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, attr); + CleanupStack::PopAndDestroy(lm); + } + + id = 2; // attr coverage radius not availible + attr = 0x003F; // req all + partialParam->SetRequestedAttributes(attr); + lm = GetPartialLandmarkLC(id, *partialParam); + attr = attr & 0x00FB; // remove coverage radius + CheckPartialLandmarkL(*lm, attr); + CleanupStack::PopAndDestroy(lm); + + id = 3; // Description not available + attr = 0x003F; // req all + partialParam->SetRequestedAttributes(attr); + lm = GetPartialLandmarkLC(id, *partialParam); + + + // After error report "ESLI-5ZDH4N Landmarks - Empty descriptors" + // Even if name or description not has been set it will return empty string "" when reading + // it from landmarks db, thus GetLandmarkDescription will KErrNone (instead of KErrNotFound as earlier) + //attr = attr & 0x00DF; // remove description + CheckPartialLandmarkL(*lm, attr); + CleanupStack::PopAndDestroy(lm); + + id= 5; // IconName and IconIndex not availible + attr = 0x003F; // req all + partialParam->SetRequestedAttributes(attr); + lm = GetPartialLandmarkLC(id, *partialParam); + attr = attr & 0x00EF; // remove IconName and IconIndex + CheckPartialLandmarkL(*lm, attr); + CleanupStack::PopAndDestroy(lm); + + CleanupStack::PopAndDestroy(partialParam); + } + +// --------------------------------------------------------- +// CPosTp18::TestPartialPositionFields +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::TestPartialPositionFieldsL() + { + iLog->Log(_L("TestPartialPositionFieldsL")); + iLog->Log(_L("Testing GetPartialLandmarks with different combinations of positionfields requested")); + _LIT(KNoFieldsReqErr, "No fields have been requested -> GetRequestedPositionFields should return 0"); + + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + RArray reqFields; + partialParam->GetRequestedPositionFields(reqFields); + CleanupClosePushL(reqFields); + + AssertTrueSecL(partialParam->GetRequestedPositionFields(reqFields) == 0, KNoFieldsReqErr); + iDatabase->SetPartialReadParametersL(*partialParam); + + + // Landmark Id with Street, PostalCode, City, LocationName, + // Country, MediaLinks, MediaLink1, MediaLink2 fields + TPosLmItemId id=2; + + AppendFields(reqFields); + RArray availFields; + CleanupClosePushL(availFields); + for(TInt i=0; i<8; i++) + { + availFields.Append(ETrue); + } + + partialParam->SetRequestedPositionFields(reqFields); + + CPosLandmark* lm = NULL; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with PostalCode, City, LocationName, + // Country, MediaLinks, MediaLink1, MediaLink2 fields + id=3; + availFields[0] = EFalse; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street, City, LocationName, + // Country, MediaLinks, MediaLink1, MediaLink2 fields + id=4; + availFields[0] = ETrue; + availFields[1] = EFalse; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street, PostalCode, LocationName, + // Country, MediaLinks, MediaLink1, MediaLink2 fields + id=5; + availFields[1] = ETrue; + availFields[2] = EFalse; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street,PostalCode, City, + // Country, MediaLinks, MediaLink1, MediaLink2 fields + id=6; + availFields[2] = ETrue; + availFields[3] = EFalse; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street,PostalCode, City, + // MediaLinks, MediaLink1, MediaLink2 fields + id=7; + availFields[3] = ETrue; + availFields[4] = EFalse; + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street,PostalCode, City, + // Country fields + id=8; + availFields[4] = ETrue; + availFields[5] = EFalse; + availFields[6] = EFalse; + availFields[7] = EFalse; + + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + // Landmark Id with Street,PostalCode, City, + // Country, MediaLinks, MediaLink1 fields + id=9; + availFields[5] = ETrue; + availFields[6] = ETrue; + availFields[7] = EFalse; + + lm = GetPartialLandmarkLC(id, *partialParam); + CheckPartialLandmarkL(*lm, reqFields, availFields); + CleanupStack::PopAndDestroy(lm); + + availFields[0] = EFalse; + + reqFields[0] = EPositionFieldMagneticCourse; + + partialParam->SetRequestedPositionFields(reqFields); + lm = GetPartialLandmarkLC(id, *partialParam); + + reqFields[0] = EPositionFieldStreet; // To verify that street is not return when not requested + CheckPartialLandmarkL(*lm, reqFields, availFields); + + CleanupStack::PopAndDestroy(4, partialParam); + + } + +// --------------------------------------------------------- +// CPosTp18::PreparePartialLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::PreparePartialLandmarksL() + { + iLog->Log(_L("PreparePartialLandmarksL")); + iLog->Log(_L("Testing Prepare and TakePartialLandmarks syncronously")); + + CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); + + TUint attr = CPosLandmark::ELandmarkName; + partialParam->SetRequestedAttributes(attr); + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray ids; + CleanupClosePushL(ids); + + for (TInt i=0; iPreparePartialLandmarksL(ids); + iOperation->ExecuteL(); + + iArrayPtr = iDatabase->TakePreparedPartialLandmarksL(iOperation); + AssertTrueSecL(iArrayPtr->Count() == ids.Count(), KNoPreparedPartialErr); + + for (TInt j=0; jCount()-1; j++) + { + CheckPartialLandmarkL(*iArrayPtr->At(j), CPosLandmark::ELandmarkName); + } + AssertTrueSecL(iArrayPtr->At(iArrayPtr->Count()-1) == NULL, KNoPreparedPartialErr2); + + TRAPD(err, iArrayPtr=iDatabase->TakePreparedPartialLandmarksL(iOperation)); + AssertTrueSecL(err == KErrNotFound, KTakePreparedPartialErr); + + delete iOperation; + iOperation = NULL; + + // landmarks with Name, coverage radius, description and fields street and country set + const TInt idsStart = 8; + const TInt idsEnd = 28; + + attr = attr | CPosLandmark::ECoverageRadius | CPosLandmark::EDescription; + partialParam->SetRequestedAttributes(attr); + + RArray reqFields; + CleanupClosePushL(reqFields); + + reqFields.Append(EPositionFieldStreet); + reqFields.Append(EPositionFieldCountry); + partialParam->SetRequestedPositionFields(reqFields); + + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray availFields; + CleanupClosePushL(availFields); + for(TInt jj=0; jj<2; jj++) + { + availFields.Append(ETrue); + } + + ids.Reset(); + for (TInt k=idsStart; k<=idsEnd; k++) + { + ids.Append(k); + } + + iOperation = iDatabase->PreparePartialLandmarksL(ids); + iOperation->ExecuteL(); + + iArrayPtr->ResetAndDestroy(); + delete iArrayPtr; + iArrayPtr = NULL; + + iArrayPtr = iDatabase->TakePreparedPartialLandmarksL(iOperation); + delete iOperation; + iOperation = NULL; + + AssertTrueSecL(iArrayPtr->Count() == ids.Count(),KNoPreparedPartialErr); + for (TInt ii=0; iiCount()-1; ii++) + { + CheckPartialLandmarkL(*iArrayPtr->At(ii), attr); + CheckPartialLandmarkL(*iArrayPtr->At(ii), reqFields, availFields); + } + + CleanupStack::PopAndDestroy(4, partialParam); + + iArrayPtr->ResetAndDestroy(); + delete iArrayPtr; + iArrayPtr = NULL; + + // Test not setting any attributes with SetRequestedAttributes, + // should only return empty landmarks + delete iDatabase; + iDatabase = NULL; + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) ExecuteAndDeleteLD(iDatabase->InitializeL()); + + CleanupClosePushL(ids); + ids.Append(1); + ids.Append(2); + ids.Append(10); + ids.Append(20); + iOperation = iDatabase->PreparePartialLandmarksL(ids); + iOperation->ExecuteL(); + + iArrayPtr = iDatabase->TakePreparedPartialLandmarksL(iOperation); + AssertTrueSecL(iArrayPtr->Count() == ids.Count(), _L("Nr of Ids not correct")); + delete iOperation; + iOperation = NULL; + + // Check that returned landmarks are empty + for (TInt ii=0; iiCount()-1; ii++) + { + for (TInt j=0;jAt(ii)->IsPositionFieldAvailable(j), _L("Only empty landmarks should be returned")); + } + } + iArrayPtr->ResetAndDestroy(); + delete iArrayPtr; + iArrayPtr = NULL; + + CleanupStack::PopAndDestroy(&ids); + + // Test with empty list, should cause error + partialParam = CPosLmPartialReadParameters::NewLC(); + attr = CPosLandmark::ELandmarkName; + partialParam->SetRequestedAttributes(attr); + iDatabase->SetPartialReadParametersL(*partialParam); + + CleanupClosePushL(ids); + TRAP(err, iDatabase->PreparePartialLandmarksL(ids)); + + CleanupStack::PopAndDestroy(); + if (err != KErrArgument) + { + iLog->Log(_L("PreparePartialLandmarksL should leave with KErrArgument")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(partialParam); +// CleanupStack::PopAndDestroy(&ids); + + } + +// --------------------------------------------------------- +// CPosTp18::PreparePartialLandmarksAsyncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::PreparePartialLandmarksAsyncL(TExecutionMode aExecutionMode) + { + iLog->Log(_L("Testing Prepare and TakePartialLandmarks asyncronously")); + + CPosLmPartialReadParameters* partialParam = iDatabase->PartialReadParametersLC(); + + TUint attr = CPosLandmark::ELandmarkName; + partialParam->SetRequestedAttributes(attr); + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray ids; + CleanupClosePushL(ids); + for (TInt i=0; iPreparePartialLandmarksL(ids); + + TRAPD(err, iArrayPtr=iDatabase->TakePreparedPartialLandmarksL(iOperation)); + AssertTrueSecL(err == KErrNotFound, KTakePreparedPartialErr); + + switch (aExecutionMode) + { + case EAsynchronous: + RunAsyncOperationL(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + break; + default: + User::Leave(KErrArgument); + break; + } + + if (iArrayPtr != NULL) + { + iArrayPtr->ResetAndDestroy(); + delete iArrayPtr; + iArrayPtr=NULL; + } + + iArrayPtr = iDatabase->TakePreparedPartialLandmarksL(iOperation); + + AssertTrueSecL(iArrayPtr->Count() == ids.Count(),KNoPreparedPartialErr); + AssertTrueSecL(iArrayPtr->At(iArrayPtr->Count()-1) == NULL, KNoPreparedPartialErr2); + + for (TInt j=0; jCount()-1; j++) + { + CheckPartialLandmarkL(*iArrayPtr->At(j), CPosLandmark::ELandmarkName); + } + + iArrayPtr->ResetAndDestroy(); + delete iArrayPtr; + iArrayPtr = NULL; + + delete iOperation; + iOperation = NULL; + + // landmarks with Name, Icon, Position MediaLink1 set + const TInt idsStart = 10; + const TInt idsEnd = 35; + + attr = attr | CPosLandmark::EIcon | CPosLandmark::EPosition; + partialParam->SetRequestedAttributes(attr); + + RArray reqFields; + CleanupClosePushL(reqFields); + reqFields.Append(EPositionFieldMediaLinks); + reqFields.Append(EPositionFieldMediaLinksStart); + partialParam->SetRequestedPositionFields(reqFields); + + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray availFields; + CleanupClosePushL(availFields); + for(TInt jj=0; jj<2; jj++) + { + availFields.Append(ETrue); + } + + ids.Reset(); + for (TInt k=idsStart; k<=idsEnd; k++) + { + ids.Append(k); + } + + iOperation = iDatabase->PreparePartialLandmarksL(ids); + + switch (aExecutionMode) + { + case EAsynchronous: + RunAsyncOperationL(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + break; + default: + User::Leave(KErrArgument); + break; + } + + iArrayPtr = iDatabase->TakePreparedPartialLandmarksL(iOperation); + + AssertTrueSecL(iArrayPtr->Count() == ids.Count(),KNoPreparedPartialErr); + + for (TInt x=0; xCount()-1; x++) + { + CheckPartialLandmarkL(*iArrayPtr->At(x), attr); + CheckPartialLandmarkL(*iArrayPtr->At(x), reqFields, availFields); + } + + delete iOperation; + iOperation = NULL; + + CleanupStack::PopAndDestroy(4, partialParam); + } + +// --------------------------------------------------------- +// CPosTp18::PreparePartialLandmarksAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::PreparePartialLandmarksAsyncAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("Testing Prepare and TakePartialLandmarks asyncronously with cancel")); + + CPosLmPartialReadParameters* partialParam = iDatabase->PartialReadParametersLC(); + + TUint attr = CPosLandmark::ELandmarkName; + partialParam->SetRequestedAttributes(attr); + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray ids; + CleanupClosePushL(ids); + for (TInt i=0; iPreparePartialLandmarksL(ids); + + TRAPD(err, iArrayPtr=iDatabase->TakePreparedPartialLandmarksL(iOperation)); + AssertTrueSecL(err == KErrNotFound, KTakePreparedPartialErr); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iOperation); + iOperation = NULL; + } + else + { + RunAsyncOperationAndCancelLD(iOperation); + } + + // landmarks with Name, Icon, Position MediaLink1 set + const TInt idsStart = 10; + const TInt idsEnd = 35; + + attr = attr | CPosLandmark::EIcon | CPosLandmark::EPosition; + partialParam->SetRequestedAttributes(attr); + + RArray reqFields; + CleanupClosePushL(reqFields); + reqFields.Append(EPositionFieldMediaLinks); + reqFields.Append(EPositionFieldMediaLinksStart); + partialParam->SetRequestedPositionFields(reqFields); + + iDatabase->SetPartialReadParametersL(*partialParam); + + RArray availFields; + CleanupClosePushL(availFields); + for(TInt jj=0; jj<2; jj++) + { + availFields.Append(ETrue); + } + + ids.Reset(); + for (TInt k=idsStart; k<=idsEnd; k++) + { + ids.Append(k); + } + + iOperation = iDatabase->PreparePartialLandmarksL(ids); + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iOperation); + iOperation = NULL; + } + else + { + RunAsyncOperationAndCancelLD(iOperation); + } + + CleanupStack::PopAndDestroy(4, partialParam); + } + +// --------------------------------------------------------- +// CPosTp18::GetPartialLandmarkLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmark* CPosTp18::GetPartialLandmarkLC(const TPosLmItemId aId, + const CPosLmPartialReadParameters& aPartialParam) + { + _LIT(KIsPartialErr, "Method Landmark->IsPartial returns incorrect value"); + _LIT(KUpdateErr, "It should not be possible to update a partial landmark"); + + iDatabase->SetPartialReadParametersL(aPartialParam); + + CPosLandmark* lm = iDatabase->ReadPartialLandmarkLC(aId); + AssertTrueSecL(lm->IsPartial(), KIsPartialErr); + + TRAPD(err, iDatabase->UpdateLandmarkL(*lm)); + AssertTrueSecL(err == KErrArgument, KUpdateErr); + + return lm; + } + +// --------------------------------------------------------- +// CPosTp18::AppendFields +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::AppendFields(RArray& aArray) + { + // Appends fields availible to set with Landmarks db generator + aArray.Append(EPositionFieldStreet); + aArray.Append(EPositionFieldPostalCode); + aArray.Append(EPositionFieldCity); + aArray.Append(EPositionFieldLocationName); + aArray.Append(EPositionFieldCountry); + aArray.Append(EPositionFieldMediaLinks); + aArray.Append(EPositionFieldMediaLinksStart); + + TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; + aArray.Append(++tmp); + + } + +// --------------------------------------------------------- +// CPosTp18::ChechPartialLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::CheckPartialLandmarkL(const CPosLandmark& aLandmark, + const RArray& aReqFields, + const RArray& aAvailFields) + { + + _LIT(KPosFieldAvailableErr, "Method IsPositionFieldAvailable return incorrect value, should be availabe"); + _LIT(KPosFieldAvailableErr2, "Method IsPositionFieldAvailable return incorrect value, should not be available"); + + TInt err=0; + for (TInt i=0; i categories; + CleanupClosePushL(categories); + + aLandmark.GetCategoriesL(categories); + if (aAttr & CPosLandmark::ECategoryInfo) + { + AssertTrueSecL(categories.Count() != 0, KPartialCategoryInfoErr); + } + else + { + AssertTrueSecL(categories.Count() == 0, KPartialCategoryInfoErr); + } + CleanupStack::PopAndDestroy(&categories); + + TLocality loc; + err = aLandmark.GetPosition(loc); + CheckPartialErrorCodeL(aAttr & CPosLandmark::EPosition, err); + + } + +// --------------------------------------------------------- +// CPosTp18::ChechPartialErrorCodeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp18::CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr) + { + _LIT(KPartialLmErr, "Incorrect error code returned when reading from a Partial landmark"); + + if (aPartial) + { + AssertTrueSecL(aErr == KErrNone, KPartialLmErr); + } + else + { + AssertTrueSecL(aErr == KErrNotFound, KPartialLmErr); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp19.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp19.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,269 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp19.h" +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp19::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + delete iCategoryManager; + iCategoryManager = NULL; + + iCategoryIds.Close(); + iCategoryNames.ResetAndDestroy(); + + iGlobalCategoryNames.Close(); + iGlobalCategoryIds.Close(); + + iCategories.ResetAndDestroy(); + iCategories.Close(); + } + +// --------------------------------------------------------- +// CPosTp19::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::StartL() + { + iLog->Log(_L("**** Testing CPosCategoryManager():: GetCategoires methods ****")); + + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); // return default database + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L(" Default database opened and initialised ")); + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + + // Test with non-global categories + TestGetByNameL(); + + /* + * Test with global categories + */ + + // Added for testing + ExecuteAndDeleteLD(iCategoryManager->ResetGlobalCategoriesL()); + + iLog->Log(_L(" ******** Testing with global categories ******")); + + TestGetGlobalL(); + } + +// --------------------------------------------------------- +// CPosTp19::TestGetGlobal +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::TestGetGlobalL() + { + _LIT(KGetGlobalErr, "GetGlobalCategoryL should return KPosLmNullItemId for category Id = 0"); + _LIT(KGetGlobalErr2, "GetGlobalCategoryL should return KPosLmNullItemId for non existing categories"); // Rajesh : Commented + + SetupGlobalCategoriesL(); + TBuf<100> info; + info.Zero(); + TPosLmItemId id(0); + + /* + * Test with global categories + */ + iLog->Log(_L("Testing GetGlobalCategoryL() with non existing global category( catId 0 )")); + id = iCategoryManager->GetGlobalCategoryL(0); + AssertTrueSecL(id == KPosLmNullItemId, KGetGlobalErr); + + iLog->Log(_L("Testing GlobalCategoryNameL() with non existing global category (catid 0)")); + HBufC* name = iCategoryManager->GlobalCategoryNameL(0); + CleanupStack::PushL(name); + AssertTrueSecL(name == NULL, KGetGlobalErr); + CleanupStack::PopAndDestroy(name); + + // Test with non existing category id + iLog->Log(_L("Testing GetGlobalCategoryL() with non existing global category (CatId = 500)")); + id = iCategoryManager->GetGlobalCategoryL(500); + AssertTrueSecL(id == KPosLmNullItemId, KGetGlobalErr2); + + iLog->Log(_L("Testing GlobalCategoryNameL() with non existing global category (CatId = 500)")); + name = iCategoryManager->GlobalCategoryNameL(500); + CleanupStack::PushL(name); + AssertTrueSecL(name == NULL, KGetGlobalErr2); + CleanupStack::PopAndDestroy(name); + + iLog->Log(_L("Testing GetGlobalCategoryL() and GlobalCategoryNameL() with valid categories)")); + + for (TInt i=0; iGetGlobalCategoryL(iGlobalCategoryIds[i]); + CPosLandmarkCategory* category = iCategoryManager->ReadCategoryLC( catId ); + + // Compare the Ids of the global categories + if ( category->GlobalCategory() != iGlobalCategoryIds[i]) + { + iLog->Log(_L("Incorrect category id returned")); + _LIT(KIds, "Expected: %d, returned %d"); + info.Format(KIds, iGlobalCategoryIds[i], category->GlobalCategory()); + iLog->Log(info); + info.Zero(); + User::Leave(KErrGeneral); + } + CleanupStack::PopAndDestroy( category); + + HBufC* name = iCategoryManager->GlobalCategoryNameL(iGlobalCategoryIds[i]); + CleanupStack::PushL(name); + + if (name->CompareC(*iGlobalCategoryNames[i])) + { + iLog->Log(_L("Incorrect global category name")); + iLog->Log(_L("Expected: ")); + iLog->Log(*iGlobalCategoryNames[i]); + iLog->Log(_L("Returned: ")); + iLog->Log(*name); + User::Leave(KErrGeneral); + } + CleanupStack::PopAndDestroy(name); + } + } + +// --------------------------------------------------------- +// CLandmarkTestProcedureBase::SetupGlobalCategoriesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + + void CPosTp19::SetupGlobalCategoriesL() + { + ReadGlobalCategoriesFromResourceL( iGlobalCategoryIds, iGlobalCategoryNames ); + } + + +// --------------------------------------------------------- +// CPosTp19::TestGetByName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::TestGetByNameL() + { + _LIT(KEmptyStringErr, "GetCategoryL with an empty string should return KErrArgument, not %d"); + _LIT(KMaxStringErr, "GetCategoryL with an maximum length string should return KErrArgument, not %d"); + _LIT(KNotFoundErr, "GetCategoryL should return KPosLmNullItemId for a category that doesn't exist in the db, not %d"); + + iLog->Log(_L(" Testing CPosCategoryManager::GetCategoryL() with wrong arguement (Empty name string)")); + TRAPD(err, iCategoryManager->GetCategoryL(_L(""))); + AssertTrueSecL(err == KErrArgument, KEmptyStringErr, err); + + iLog->Log(_L(" Testing CPosCategoryManager::GetCategoryL() with wrong arguement (Name not existing)")); + TPosLmItemId categoryId = iCategoryManager->GetCategoryL(_L("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk")); + AssertTrueSecL(categoryId == KPosLmNullItemId, KNotFoundErr, categoryId); + + // Test with maximum lenght of name + iLog->Log(_L(" Testing CPosCategoryManager::GetCategoryL() with wrong arguement (With max length of Name not existing)")); + _LIT(KMaxName124, "Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12_ABC"); + categoryId = iCategoryManager->GetCategoryL(KMaxName124); + AssertTrueSecL(categoryId == KPosLmNullItemId, KNotFoundErr, categoryId); + + // Test with more than maximum lenght of name + iLog->Log(_L(" Testing CPosCategoryManager::GetCategoryL() with wrong arguement (With more than max length of Name not existing)")); + _LIT(KMaxName, "Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12Category12"); + TRAP(err, iCategoryManager->GetCategoryL(KMaxName)); + AssertTrueSecL(err == KErrArgument, KMaxStringErr, err); + + // Add some categories and verify the addition + iLog->Log(_L(" Testing with some valid categories in the database ( +ve testing )")); + AddCategoriesL (10); + VerifyAddedCategoriesL(); + } + +// --------------------------------------------------------- +// CPosTp19:AddCategoriesL +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::AddCategoriesL( TInt aNumofCats ) + { + _LIT(KName, "Category - %d"); + TInt err = KErrLocked; + for (TUint i = 0; i categoryName; + categoryName.Format( KName,i ); + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL( categoryName ); + err = KErrLocked; + while ( err == KErrLocked ) + { + TRAP(err, iCategoryManager->AddCategoryL( *lmc )); + } + iCategories.Append(lmc); + CleanupStack::Pop( lmc ); + } + } + +// --------------------------------------------------------- +// CPosTp19:VerifyAddedCategoriesL() +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp19::VerifyAddedCategoriesL() + { + TInt noOfCats = iCategoryNames.Count(); + // Verify the added categories + for ( TUint i = 0; i < noOfCats; i++ ) + { + CPosLandmarkCategory* cat = iCategories[i]; + TPtrC catName; + cat->GetCategoryName( catName ); + // Get the categories from the database using name + TPosLmItemId catId = iCategoryManager->GetCategoryL( catName); + + if ( catId != cat->CategoryId()) + { + TBuf<150> buf; + buf.Format(_L("Unable to verify the added non-global category Id %d "), cat->CategoryId() ); + iLog->Log(buf); + User::Leave(-1); + } + } + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp2.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp2.h" +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp2::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp2::StartL() + { + _LIT(KMoveDllErr, "Move of the Local Acces Provider dll failed with %d"); + _LIT(KMoveRscErr, "Move of the Local Acces Provider rsc failed with %d"); + _LIT(KLeaveErr, "CPosLandmarkDatabase::OpenL() doesn't leave with KErrNotSupported"); + _LIT(KOpenErr, "CPosLandmarkDatabase::OpenL() failed with %d"); + + _LIT(KMoveToPath, "c:\\system\\test\\"); + _LIT(KPluginMovedToPathDll, "c:\\system\\test\\eposlmlocalaccessprovider.dll"); + _LIT(KPluginMovedToPathRsc, "c:\\system\\test\\eposlmlocalaccessprovider.RSC"); + + /* + // Before + //_LIT(KPluginMovedToPathRsc, "c:\\system\\test\\101FDF89.RSC"); + + _LIT(KPluginsPath, "c:\\system\\libs\\plugins\\"); + _LIT(KDll, "c:\\system\\libs\\plugins\\eposlmlocalaccessprovider.dll"); + _LIT(KRsc,"c:\\system\\libs\\plugins\\101FDF89.RSC"); + */ + + _LIT(KPluginsPath, "c:\\sys\\bin\\"); + _LIT(KPluginsResourcePath, "c:\\resource\\plugins\\"); + _LIT(KDll, "c:\\sys\\bin\\eposlmlocalaccessprovider.dll"); + _LIT(KRsc,"c:\\resource\\plugins\\eposlmlocalaccessprovider.RSC"); + +//#ifdef __WINS__ +// _LIT(KCanceledErr, "Test canceled"); +// _LIT(KMoveDll, "Move Epoc32\\release\\winscw\\udeb\\eposlmlocalaccessprovider.dll to c:\\sys\\bin\\ \ +// and z:\\resource\\plugins\\eposlmlocalaccessprovider.rsc to c:\\resource\\plugins, press OK when done."); +// TUtfwUserAnswer answer; +// answer = iUserInfo->ShowDialog(KMoveDll, EUtfwDialogTypeOkCancel, EFalse); +// AssertTrueSecL(answer == EUtfwUserAnswerOk, KCanceledErr, KErrCancel); +//#endif + + CPosLandmarkDatabase* lmd=CPosLandmarkDatabase::OpenL(); + delete lmd; + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + REComSession ecom = REComSession::OpenL(); + CleanupClosePushL(ecom); + + TRequestStatus status; + + TInt err; + err = fileMan->Move(KDll, KMoveToPath, CFileMan::EOverWrite); + AssertTrueSecL(err == KErrNone, KMoveDllErr, err); + err = fileMan->Move(KRsc, KMoveToPath, CFileMan::EOverWrite); + AssertTrueSecL(err == KErrNone, KMoveRscErr, err); + + ecom.NotifyOnChange(status); + User::WaitForRequest(status); // Wait for Ecom + + CPosLandmarkDatabase* lmd2=NULL; + TRAP(err, lmd2=CPosLandmarkDatabase::OpenL()); + delete lmd2; + if (err) + { + AssertTrueSecL(err == KErrNotFound || err == KErrNotSupported, KLeaveErr, err); + } + else + { + AssertTrueSecL(err == KErrNotFound || err == KErrNotSupported, KLeaveErr); + } + + err = fileMan->Move(KPluginMovedToPathDll, KPluginsPath, CFileMan::EOverWrite); + AssertTrueSecL(err == KErrNone, KMoveDllErr, err); + err = fileMan->Move(KPluginMovedToPathRsc, KPluginsResourcePath, CFileMan::EOverWrite); + AssertTrueSecL(err == KErrNone, KMoveRscErr, err); + + ecom.NotifyOnChange(status); + User::WaitForRequest(status); // Wait for Ecom + + CPosLandmarkDatabase* lmd3=NULL; + TRAP(err, lmd3 = CPosLandmarkDatabase::OpenL()); + delete lmd3; + AssertTrueSecL(err == KErrNone, KOpenErr, err); + + CleanupStack::PopAndDestroy(3, &fs); + +// #ifdef __WINS__ +// _LIT(KRestoreTest, "Restore c:\\sys\\bin\\eposlmlocalaccessprovider.dll to Epoc32\\release\\winscw\\udeb\\ and \ +// c:\\resource\\plugins\\eposlmlocalaccessprovider.rsc to z:\\resource\\plugins "); +// answer = iUserInfo->ShowDialog(KRestoreTest, EUtfwDialogTypeOk, EFalse); +// #endif + + } + +// --------------------------------------------------------- +// CPosTp2::WaitForEcomL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp2::WaitForEcomL() + { + REComSession ecom = REComSession::OpenL(); + CleanupClosePushL(ecom); + TRequestStatus status; + ecom.NotifyOnChange(status); + User::WaitForRequest(status); + CleanupStack::PopAndDestroy(&ecom); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp20.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp20.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,358 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp20.h" +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS +// See file eposlmglobalcategories02.rss in testdata for category Bar +//_LIT(KICONFILE, "c:\\system\\data\\test2.mbm"); +//const TInt KTP20IconIndex = 2; +//const TInt KTP20IconMaskIndex = 2; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp20::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iDatabase; + iDatabase = NULL; + delete iCategoryManager; + iCategoryManager = NULL; + iGlobalCategoryIds.Close(); + iGlobalCategoryNames.Close(); + iGlobalCategoryTestNames.Close(); + } + +// --------------------------------------------------------- +// CPosTp20::RemoveAllCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::RemoveAllCategoriesL() + { + iLog->Log(_L("RemoveAllCategoriesL")); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(catMan); + + CPosLmItemIterator* iter = catMan->CategoryIteratorL(); + CleanupStack::PushL(iter); + + RArray ids; + CleanupClosePushL(ids); + if (iter->NumOfItemsL() > 0) + { + iter->GetItemIdsL(ids, 0, iter->NumOfItemsL()); + ExecuteAndDeleteLD(catMan->RemoveCategoriesL(ids)); + } + + CleanupStack::PopAndDestroy(&ids); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(catMan); + } + +// --------------------------------------------------------- +// CPosTp20::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::StartL() + { + iLog->Log(_L("**** Testing CPosCategoryManager::ResetGlobalCategories() ********")); + /* + * Open the default landmark database + * By default it is initialized with global categories (Assumption based on global categories API specification) + * Test the Reset global categories functionality + */ + + TBuf<150> info; + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L("Default database opened and initialised")); + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + // Setup global category info + SetupGlobalCategoriesL(); + + iLog->Log(_L("Execute ResetGlobalCategoriesL() synchronously)")); + + // Rename some global categories + UpdateGlobalCategoriesInDb(); + + iLog->Log(_L("Global category info updated in database (Renaming category done)")); + + // Execute synchronously + // Reset the global categories (the name and icon info of the global category will be reset) + ExecuteAndDeleteLD(iCategoryManager->ResetGlobalCategoriesL()); + + /* + * Verification of 'reset' feature of global categories + * Check for global category with name 'Hotel' and it should not exist + * Check for global category having name 'Accomodation' + */ + VerifyGlobalCategoriesL(); + + iLog->Log(_L("Verification of CPosCategoryManager::ResetGlobalCategories() done)")); + + + iLog->Log(_L("Execute ResetGlobalCategoriesL() asynchronously)")); + // Rename some global categories + UpdateGlobalCategoriesInDb(); + + iLog->Log(_L("Global category info updated in database (Renaming category done)")); + + // Execute asynchronously + RunAsyncOperationLD(iCategoryManager->ResetGlobalCategoriesL()); + VerifyGlobalCategoriesL(); + + iLog->Log(_L("Verification of CPosCategoryManager::ResetGlobalCategories() done)")); + + + iLog->Log(_L("Execute ResetGlobalCategoriesL() Asynchronously using User::WaitForRequest())")); + + // Rename some global categories + UpdateGlobalCategoriesInDb(); + + iLog->Log(_L("Global category info updated in database (Renaming category done)")); + + // Execute asynchronously using User::WaitForRequest() + CPosLmOperation* op = iCategoryManager->ResetGlobalCategoriesL(); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + VerifyGlobalCategoriesL(); + + iLog->Log(_L("Verification of CPosCategoryManager::ResetGlobalCategories() done)")); + + iLog->Log(_L("Execute ResetGlobalCategoriesL() using Cancel immediately, after a while etc...")); + // Rename some global categories + UpdateGlobalCategoriesInDb(); + + // Test cancel immediately + RunAsyncOperationAndCancelLD(iCategoryManager->ResetGlobalCategoriesL()); + + // Test cancel after a while + RunAsyncOperationAndCancelInCallbackLD(iCategoryManager->ResetGlobalCategoriesL()); + + ExecuteAndDeleteLD(iCategoryManager->ResetGlobalCategoriesL()); + VerifyGlobalCategoriesL(); + iLog->Log(_L("Verification of CPosCategoryManager::ResetGlobalCategories() done)")); + } + + +// --------------------------------------------------------- +// CPosTp20::UseGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::UpdateGlobalCategoriesInDb() + { + /* + * Change some properties of the existing global category (changing only the name here) + */ + + TBuf<150>info; + // Get sample global category info + TPosLmItemId catId(0); + TPosLmItemId catId1(0); + CPosLandmarkCategory* category = NULL; + + for (TUint i = 0; i< iGlobalCategoryNames.Count(); i++) + { + catId = iCategoryManager->GetGlobalCategoryL(iGlobalCategoryIds[i]); + category = iCategoryManager->ReadCategoryLC( catId ); + category->SetCategoryNameL( iGlobalCategoryTestNames[i] ); + iCategoryManager->UpdateCategoryL( *category ); + CleanupStack::PopAndDestroy( category ); + + // Verify whether the added category exists with same global category id or not + catId1 = iCategoryManager->GetCategoryL( iGlobalCategoryTestNames[i] ); + + //Read the landmark from the database + category = iCategoryManager->ReadCategoryLC( catId1 ); + + // verify whether this is a global category or not (Accomodation) + + if ( category->GlobalCategory() != iGlobalCategoryIds[i] ) + {// Error in category updation/verification + iLog->Log(_L("Error in global category verification")); + info.Zero(); + info.Format(_L("Expected global category id %d"), iGlobalCategoryIds[i] ); + info.Format(_L("Returned global category id %d"), category->GlobalCategory() ); + iLog->Log( info ); + info.Zero(); + User::Leave(-1); + } + CleanupStack::PopAndDestroy( category ); + } + } + +// --------------------------------------------------------- +// CPosTp20::SetupGlobalCategoriesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +void CPosTp20::SetupGlobalCategoriesL() + { + // Testing with only 3 global categories + ReadGlobalCategoriesFromResourceL( iGlobalCategoryIds, iGlobalCategoryNames, 3 ); + + iGlobalCategoryTestNames.Append(_L("Housing")); + iGlobalCategoryTestNames.Append(_L("Movies")); + iGlobalCategoryTestNames.Append(_L("Society")); + } + + + + +// --------------------------------------------------------- +// CPosTp20::VerifyGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::VerifyGlobalCategoriesL(TBool /*aCheck */) + { + // Search database based on the new names of the global categories + TBuf<100> info; + info.Zero(); + + TPosLmItemId catId( 0 ); + + for ( TUint i = 0; i < iGlobalCategoryNames.Count(); i++ ) + { + // Search based on the Test names (with which the global category was renamed!) + catId = iCategoryManager->GetCategoryL(iGlobalCategoryTestNames[i]); + + if ( catId != KPosLmNullItemId ) + { + iLog->Log(_L("Error in global category reset functionality verification")); + info.Zero(); + info.Format(_L("Expected global category id %d"), KPosLmNullItemId ); + info.Format(_L("Returned global category id %d"), catId ); + iLog->Log( info ); + info.Zero(); + User::Leave(-1); + } + + // Search for old names of the global category + catId = iCategoryManager->GetCategoryL( *iGlobalCategoryNames[i] ); + CPosLandmarkCategory* category = iCategoryManager->ReadCategoryLC( catId ); + + // Get the global category id + if ( category->GlobalCategory() ) + { + if ( category->GlobalCategory() != iGlobalCategoryIds[i] ) + { + iLog->Log(_L("Error in global category reset functionality verification")); + info.Zero(); + info.Format(_L("Expected global category id %d"), iGlobalCategoryIds[i] ); + info.Format(_L("Returned global category id %d"), catId ); + iLog->Log( info ); + info.Zero(); + User::Leave(-1); + } + } + CleanupStack::PopAndDestroy(category); + } + } + +// --------------------------------------------------------- +// CPosTp20::RenameAndDeleteGlobalL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp20::RenameAndDeleteGlobalL() + { + const TPosLmGlobalCategory KRemoveGlobalId1 = 1; + const TPosLmGlobalCategory KRemoveGlobalId2 = 11; + + const TPosLmGlobalCategory KRenameGlobalId1 = 3; + const TPosLmGlobalCategory KRenameGlobalId2 = 12; + + TBuf<150> buf; + ExecuteAndDeleteLD(iDatabase->CompactL()); + TPosLmItemId id = iCategoryManager->GetGlobalCategoryL(KRemoveGlobalId1); + HBufC* name = iCategoryManager->GlobalCategoryNameL(KRemoveGlobalId1); + CleanupStack::PushL(name); + buf.Format(_L("Removing global category %S"), name); + iLog->Log(buf); + CleanupStack::PopAndDestroy(name); + CPosLmOperation* op = iCategoryManager->RemoveCategoryL(id); + ExecuteAndDeleteLD(op); + + id = iCategoryManager->GetGlobalCategoryL(KRemoveGlobalId2); + name = iCategoryManager->GlobalCategoryNameL(KRemoveGlobalId2); + CleanupStack::PushL(name); + buf.Zero(); + buf.Format(_L("Removing global category %S"), name); + iLog->Log(buf); + CleanupStack::PopAndDestroy(name); + op = iCategoryManager->RemoveCategoryL(id); + ExecuteAndDeleteLD(op); + + id = iCategoryManager->GetGlobalCategoryL(KRenameGlobalId1); + + name = iCategoryManager->GlobalCategoryNameL(KRenameGlobalId1); + CleanupStack::PushL(name); + buf.Format(_L("Renaming global category %S to Jada jada"), name); + iLog->Log(buf); + CleanupStack::PopAndDestroy(name); + + CPosLandmarkCategory* cm = iCategoryManager->ReadCategoryLC(id); + cm->SetCategoryNameL(_L("Jada jada")); + iCategoryManager->UpdateCategoryL(*cm); + CleanupStack::PopAndDestroy(cm); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + id = iCategoryManager->GetGlobalCategoryL(KRenameGlobalId2); + name = iCategoryManager->GlobalCategoryNameL(KRenameGlobalId2); + CleanupStack::PushL(name); + buf.Format(_L("Renaming global category %S to asdfasdas"), name); + iLog->Log(buf); + CleanupStack::PopAndDestroy(name); + cm = iCategoryManager->ReadCategoryLC(id); + cm->SetCategoryNameL(_L("asdfasdas")); + iCategoryManager->UpdateCategoryL(*cm); + CleanupStack::PopAndDestroy(cm); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp21.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp21.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,780 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include + +#include "FT_CPosTp21.h" +#include "FT_CCategoryLandmarkSearchResult.h" +#include + +//CONSTANTS +const TInt KNoCategoriesTp21 = 40; +const TInt KNoLandmarksTp21 = 40; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp29::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::CloseTest() + { + iCategories.ResetAndDestroy(); + iCategories.Close(); + iReferencedCategories.Close(); + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iCategoryManager; + iCategoryManager = NULL; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp21::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::StartL() + { + + iLog->Log(_L("***Testing CPosLandmarkSearch:: ( LM Search Category Criteria) *** ")); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + iLog->Log(_L("Default database initialized")); + + + // Remove all the categories and landmarks from database to make it empty + MakeEmptyLmDatabaseL( *iDatabase, *iCategoryManager); + + // Add some landmarks to db + // Add some categories to db + // Add categories to lms in the database + AddCategoriesL(); + AddLandmarksL(); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + // Test some leave codes + iLog->Log(_L("Check that StartLandmarkSearchL leaves with correct codes ")); + SearchWithSortOrderL(); + + // Search synchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt syncronously, \ +using CategoryName")); + + SearchL(iCategoryLandmarkSearchResults, ETrue); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt syncronously, \ +using CategoryId")); + SearchL(iCategoryLandmarkSearchResults); + + iLog->Log(_L("Searching fon nonexisting entries synchronously")); + SearchNonExistingL(ESynchronous); + + // Search asynchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asynchronously, \ +using CategoryName")); + SearchL(iCategoryLandmarkSearchResults, ETrue, EAsynchronous); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asynchronously, \ +using Categoryid")); + SearchL(iCategoryLandmarkSearchResults, EFalse, EAsynchronous); + + iLog->Log(_L("Searching for nonexisting entries asynchronously")); + SearchNonExistingL(EAsynchronous); + + // Search asynchronously using User::WaitForRequest() + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asynchronously, \ +with User::WaitForRequest() using CategoryName")); + SearchL(iCategoryLandmarkSearchResults, ETrue, EWaitForRequest); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asynchronously, \ +with User::WaitForRequest() using Categoryid")); + SearchL(iCategoryLandmarkSearchResults, EFalse, EWaitForRequest); + + iLog->Log(_L("Searching for nonexisting entries asynchronously")); + SearchNonExistingL(EWaitForRequest); + + + // Test cancel + iLog->Log(_L("Search and cancels the search")); + SearchAndCancelL(); + + iLog->Log(_L("Search and cancels the search in a callback")); + SearchAndCancelL(ETrue); + + // Search in global categories + iLog->Log(_L("SearchForLandmarksInGlobalCategoriesL asynchronously")); + SearchForLandmarksInGlobalCategoriesL(EAsynchronous); + + iLog->Log(_L("SearchForLandmarksInGlobalCategoriesL synchronously")); + SearchForLandmarksInGlobalCategoriesL(ESynchronous); + + iLog->Log(_L("SearchForLandmarksInGlobalCategoriesL synchronously")); + SearchForLandmarksInGlobalCategoriesL(EWaitForRequest); + + iLog->Log(_L("Check maximum length of search pattern")); + TestSearchPatternLengthL(); + } + +// --------------------------------------------------------- +// CPosTp21::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::SearchL( + const RPointerArray& /* aSearchResults */, + TBool aNameOrId, + TExecutionMode aExecutionMode) + { + /* + * Positive test cases + * Test for referenced category search + */ + + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + + //Test SetMaxNumOfMatches, first set to one and then back to unlimited + iLandmarkSearch->SetMaxNumOfMatches(1); + iLandmarkSearch->SetMaxNumOfMatches(); + + TPtrC refCatName; + TPosLmItemId refCatId(0); + + for ( TInt i = 0; i < iReferencedCategories.Count(); i++ ) + { + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + // Perform search with either name or id + if (aNameOrId) + { + // Set cearch criteria based on category name + TInt retErr = iReferencedCategories[i]->GetCategoryName( refCatName ); + if ( retErr == KErrNone) + { + catSearchCriteria->SetCategoryNameL( refCatName ); + //iLog->Log( refCatName ); + } + } + else + { + refCatId = iReferencedCategories[i]->CategoryId(); + catSearchCriteria->SetCategoryItemId( refCatId ); + } + + //aSearchOnlyPreviousMatches is set to false by default + iOperation = iLandmarkSearch->StartLandmarkSearchL( *catSearchCriteria ); + + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + /* iter->NumOfItems() contains the number of items that are contained in this search + * iteration + */ + + TPosLmItemId id = iter->NextL(); // First item from the search results + + if ( iLandmarkSearch->NumOfMatches() != iter->NumOfItemsL() ) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format( KExpected, iter->NumOfItemsL() ); + iLog->Log( info ); + info.Format( KReturned, iLandmarkSearch->NumOfMatches() ); + iLog->Log(info); + iLog->Log(KNumOfMatchesErr); + CleanupStack::PopAndDestroy( 2 ); // Iter,catSearchCriteria + User::Leave(-1); + } + + CleanupStack::PopAndDestroy( iter ); + + // Test by setting Max num of matches and also set aSearchOnlyPreviousMatches to true + + iLandmarkSearch->SetMaxNumOfMatches(1); + + if ( aNameOrId ) + { + refCatId = iReferencedCategories[i]->CategoryId(); + catSearchCriteria->SetCategoryItemId( refCatId ); + } + else + { + // Set cearch criteria based on category name + TInt retErr = iReferencedCategories[i]->GetCategoryName( refCatName ); + if ( retErr == KErrNone) + { + catSearchCriteria->SetCategoryNameL( refCatName ); + //iLog->Log( refCatName ); + } + } + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, ETrue); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + id = iter->NextL(); + + if (iLandmarkSearch->NumOfMatches() != 1) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, 1); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Search criteria: ")); + iLog->Log(catSearchCriteria->CategoryName()); + iLog->Log(KNumOfMatchesErr); + CleanupStack::PopAndDestroy( 2 ); // Iter,catSearchCriteria + User::Leave(-1); + } + + // Set back to unlimited + iLandmarkSearch->SetMaxNumOfMatches(); + CleanupStack::PopAndDestroy( 2 ); // Iter,catSearchCriteria + } + } + +// --------------------------------------------------------- +// CPosTp21::SearchForLandmarksInGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::SearchForLandmarksInGlobalCategoriesL( + TExecutionMode aExecutionMode) + { + iLog->Log(_L("SearchForGlobalCategoriesL")); + TBuf<150> buf; // Buffer used for log messages + buf.Zero(); + + /* + *Default db is open in the beginning of the test procedure anyway + *Use it for global categories related testing + */ + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + // Using default database with global cateegories initialized + // Add some more landmarks + AddLandmarksToGlobalCategoriesL(); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Set the criteria for global category search + catSearchCriteria->SetGlobalCategory( KAccommodation ); + if ( catSearchCriteria->GlobalCategory() == KPosLmNullGlobalCategory ) // Error in setting category search criteria + { + iLog->Log(_L("Error in setting Search criteria for global category search")); + buf.Format(_L("What should be set : global cat id %d, "), KAccommodation); + buf.Format(_L("What is set now : global cat id %d, "), catSearchCriteria->GlobalCategory() ); + iLog->Log( buf ); + buf.Zero(); + CleanupStack::PopAndDestroy( catSearchCriteria ); + User::Leave(-1); + } + + iOperation = iLandmarkSearch->StartLandmarkSearchL( *catSearchCriteria ); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + /* + * Verify the search result + * iter->NumOfItems holds the total number of searched items in this iteration + */ + + if ( iLandmarkSearch->NumOfMatches() != iter->NumOfItemsL() ) + { + iLog->Log(_L("Wrong number of landmarks returned global category search (Accomodation)")); + buf.Format(_L("Expected : Num %d, "), iter->NumOfItemsL()); + buf.Format(_L("Found : Num %d, "), iLandmarkSearch->NumOfMatches() ); + buf.Zero(); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(catSearchCriteria); + User::Leave( -1 ); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp21::AddLandmarksToGlobalCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::AddLandmarksToGlobalCategoriesL() + { + iLog->Log(_L("AddLandmarksToGlobalCategoriesL")); + ExecuteAndDeleteLD(iDatabase->CompactL()); + CPosLandmark* lm = NULL; + + // Add some new landmarks to the db, associate some with global categories + + // lm1 + lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("LandmarkName1")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription")); + lm->AddCategoryL( KAccommodation ); + lm->AddCategoryL( KBusiness ); + + TPosLmItemId id = iDatabase->AddLandmarkL(*lm); + iRestaurantId1 = id; + CleanupStack::PopAndDestroy(lm); + + // lm2 + lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("LandmarkName2")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription2")); + lm->AddCategoryL(KAccommodation ); + lm->AddCategoryL( KBusiness ); + id = iDatabase->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + + // lm3 + lm = CPosLandmark::NewLC(); + lm->SetLandmarkNameL(_L("LandmarkName3")); + lm->SetLandmarkDescriptionL(_L("SomeLandmarkDescription3")); + lm->AddCategoryL( KAccommodation ); + lm->AddCategoryL( KBusiness ); + lm->AddCategoryL( KEducational ); + id = iDatabase->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + +// --------------------------------------------------------- +// CPosTp21::SearchNonExistingL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::SearchNonExistingL(TExecutionMode aExecutionMode) + { + iLog->Log(_L("SearchNonExistingL")); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + catSearchCriteria->SetCategoryNameL(_L("NonExistingLandmark")); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + if (id != KPosLmNullItemId) + { + //LogErrorAndLeave(_L("Should return KPosLmNullItemId")); + iLog->Log(_L("Should return KPosLmNullItemId")); + User::Leave(-1); + } + CleanupStack::PopAndDestroy(iter); + + TPosLmItemId nonExistingId = 56789; + catSearchCriteria->SetCategoryItemId(nonExistingId); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + id = iter->NextL(); + if (id != KPosLmNullItemId) + { + //LogErrorAndLeave(_L("Should return KPosLmNullItemId")); + iLog->Log(_L("Should return KPosLmNullItemId")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(iter); + + //Test with invalid id as global category id + catSearchCriteria->SetGlobalCategory((TPosLmGlobalCategory)nonExistingId); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); + ExecuteAndDeleteLD(iOperation); + + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + id = iter->NextL(); + if (id != KPosLmNullItemId) + { + //LogErrorAndLeave(_L("Should return KPosLmNullItemId")); + iLog->Log(_L("Should return KPosLmNullItemId")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(catSearchCriteria); + } + +// --------------------------------------------------------- +// CPosTp21::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::SearchWithSortOrderL() + { + iLog->Log(_L("SearchWithSortOrderL")); + + TPosLmSortPref sortPref(CPosLandmark::ECategoryInfo, TPosLmSortPref::EAscending); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Only ECategoryName is supported,all other leave with KErrNotSupported + TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref)); + if (err != KErrNotSupported) //LogErrorAndLeave(_L("Should leave with KErrNotSupported1")); + { + iLog->Log(_L("Should leave with KErrNotSupported1")); + User::Leave(err); + } + + // Only ECategoryName is supported,all other leave with KErrNotSupported + catSearchCriteria->SetCategoryNameL(_L("SomeCategory")); + TRAP(err, iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref)); + if (err != KErrNotSupported) //LogErrorAndLeave(_L("Should leave with KErrNotSupported2")); + { + iLog->Log(_L("Should leave with KErrNotSupported2")); + User::Leave(err); + } + + // Only ECategoryName is supported,all other leave with KErrNotSupported + sortPref.SetSortByLandmarkAttribute(CPosLandmark::EDescription, TPosLmSortPref::EDescending); + TRAP(err, iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref)); + if (err != KErrNotSupported)// LogErrorAndLeave(_L("Should leave with KErrNotSupported3")); + { + iLog->Log(_L("Should leave with KErrNotSupported3")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(catSearchCriteria); + + // Also test with a category criteria into a landmarksearch operation + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("SomeCategoryPattern")); + TRAP(err, iLandmarkSearch->StartLandmarkSearchL(*nameCriteria, sortPref)); + if (err != KErrArgument) //LogErrorAndLeave(_L("Should leave with KErrNotSupported4"), err); + { + iLog->Log(_L("Should leave with KErrNotSupported4")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(nameCriteria); + } + +//--------------------------------------------------------- +// CPosTp21::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KCancelErr, "The search is canceled after progress has increased but no search result is found"); + + // Test search with one criteria + + const TInt KIndex = 10; // Try testing with referenced category at index 10 + TPtrC refCatName; + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + TInt err = iReferencedCategories[KIndex]->GetCategoryName( refCatName ); + if (err == KErrNone) // Got the category name + { + catSearchCriteria->SetCategoryNameL( refCatName ); + } + else + { + iLog->Log(_L("Error in setting category search criteria")); + CleanupStack::PopAndDestroy(); // catSearchCriteria + User::Leave(-1); + } + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD( + iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria)); + } + else + { + RunAsyncOperationAndCancelLD( + iLandmarkSearch->StartLandmarkSearchL( + *catSearchCriteria)); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + if (iter->NumOfItemsL() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Iterators no. of items is not equal to LandmarksSearch no. matches")); + _LIT( KExpected, "Iter. of matches: %d" ); + _LIT( KReturned, "LandmarksSearch no. of matches: %d" ); + TBuf<100> info; + info.Format( KExpected, iter->NumOfItemsL() ); + info.Format( KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log( info ); + iLog->Log( KNumOfMatchesErr ); + CleanupStack::PopAndDestroy ( 2 ); + User::Leave(-1); + } + + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancel = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + AssertTrueSecL(iter->NumOfItemsL() != 0, KCancelErr); + } + + CleanupStack::PopAndDestroy( 2 );// Iter, catSearchCriteria + + + + } + +// --------------------------------------------------------- +// CPosTp21::TestSearchPatternLengthL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::TestSearchPatternLengthL() + { + iLog->Log(_L("TestSearchPatternLengthL")); + + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + //Test with maximum size of search pattern + //KPosLmMaxCategoryNameLength is 124 (from EPos_Landmarks.h) + HBufC* hbuf = HBufC::NewLC(KPosLmMaxCategoryNameLength+1); + while(hbuf->Des().Length() < KPosLmMaxCategoryNameLength) + { + hbuf->Des().Append(_L("*")); + } + catSearchCriteria->SetCategoryNameL(*hbuf); + + hbuf->Des().Append(_L("*")); + + TRAPD(err, catSearchCriteria->SetCategoryNameL(*hbuf)); + + AssertTrueSecL(err == KErrArgument, _L("It should not be possible to set search pattern")); + CleanupStack::PopAndDestroy(hbuf); + CleanupStack::PopAndDestroy(catSearchCriteria); + } + + +/* + * Added for BC testing + */ + + +// --------------------------------------------------------- +// CPosTp11::AddCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::AddCategoriesL() + { + _LIT(KName, "CategoryTP21 - %d"); + TInt err=KErrLocked; + for (TInt i=0; i categoryName; + categoryName.Format(KName,i); + + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(categoryName); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iCategoryManager->AddCategoryL(*lmc)); + } + + iCategories.Append(lmc); + //TPosLmItemId catId = iCategories [i]->CategoryId(); + CleanupStack::Pop(lmc); + } + } + +// --------------------------------------------------------- +// CPosTp11::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp21::AddLandmarksL() + { + _LIT(KLmName, "LmTP21 - %d"); + TInt err = KErrLocked; + TPosLmItemId catId(0); + for (TInt i=0; i lmName; + lmName.Format(KLmName,i); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + + if (i % 2) + { + catId = iCategories[i]->CategoryId(); + landmark->AddCategoryL( catId ); + iReferencedCategories.Append(iCategories[i]); + } + + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iDatabase->AddLandmarkL(*landmark)); + } + iLandmarks.Append(landmark); + CleanupStack::Pop(landmark); + } + } + +// --------------------------------------------------------- +// CPosTp21::MakeEmptyLmDatabaseL() +// --------------------------------------------------------- +// +void CPosTp21::MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ) + { + CPosLmOperation* operation1 = aLdb.RemoveAllLandmarksL(); + + //Remove all landmarks from default db : Sync call + ExecuteAndDeleteLD( operation1 ); + + RArray catArray; + CleanupClosePushL( catArray ); + + // Get all the categories from the database and delete them if necessary + CPosLmItemIterator* iter = aCatMgr.CategoryIteratorL(); + CleanupStack::PushL( iter ); + + TUint count = iter->NumOfItemsL(); + if ( count > 0 ) + { // can only be called if there are some items + iter->GetItemIdsL( catArray, 0, count ); + } + + // Remove all the categories here Sync call + ExecuteAndDeleteLD(aCatMgr.RemoveCategoriesL( catArray )); + + CleanupStack::PopAndDestroy( 2 ); // catArray, iter + } + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp23.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp23.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,778 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp23.h" +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp23::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::CloseTest() + { + //CHECK TR Delete of landmarks search - ESLI-5WNG9N + delete iDatabase; + iDatabase = NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp23::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::StartL() + { + _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + TestInvalidPositionFieldsL(); + + // Check iterator before search has started (in multidb search all iterators are empty thus NOT NULL) + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + if (iter) + { + CleanupStack::PushL(iter); + AssertTrueSecL(iter->NumOfItemsL() == 0, _L("Iterator should be empty")); + CleanupStack::PopAndDestroy(iter); + } + else + { + + iLog->Log(_L("Iterator should NOT be NULL")); + User::Leave(-1); + } + + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetAttributesToSearch(attr); + textCriteria->SetTextL(_L("")); + + TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + CleanupStack::PopAndDestroy(textCriteria); + + AppendSearchResultsL(); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt syncronously")); + SearchL(iSearchResults, ESynchronous); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asyncronously")); + SearchL(SearchResults(), EAsynchronous); + + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asyncronously using User::WaitForRequest")); + SearchL(SearchResults(), EWaitForRequest); + + iLog->Log(_L("Testing search with a defined sortorder")); + SearchWithSortOrderL(iSearchResults); + + iLog->Log(_L("Testing search anc cancel")); + SearchAndCancelL(); + + iLog->Log(_L("Testing search and cancel in callback")); + SearchAndCancelL(ETrue); + + iLog->Log(_L("Testing a redefined search after a landmark has been removed")); + SearchAndDeleteL(iSearchResults); + + iLog->Log(_L("Testing a redefined search after landmarks have been renamed")); + SearchAndRenameL(iSearchResults); + + iLog->Log(_L("Test max length for SetTextL")); + TestMaxLengthL(); + + // Verify error report "ESLI-62DBXR Landmarks - Sort order is not correctly implemented" + // Check that CPosLandmarkSearch::MatchIteratorL are CPosLandmarkDatabase::LandmarkIteratorL + // are sorted correctly (should be identically sorted) + VerifySortOrderL(); + } + +// --------------------------------------------------------- +// CPosTp23::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + + // Set DisplayData + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + for(TInt i=0; iSetTextL(aSearchResults[i]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[i]->Attributes()); + + textCriteria->SetPositionFieldsToSearchL(aSearchResults[i]->PositionFields()); + + CPosLmOperation* operation = + iLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[i]->Redefined()); + CleanupStack::PushL(operation); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(operation); + CleanupStack::Pop(operation); + break; + case EAsynchronous: + RunAsyncOperationLD(operation); + CleanupStack::Pop(operation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(operation); + CleanupStack::PopAndDestroy(operation); + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != iLandmarkSearch->NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + + } + + //Check displaydata + AssertTrueSecL(iter->NumOfItemsL() == displayData->Count(), _L("Wrong number of DisplayData matches")); + + TInt itemId = displayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item = displayData->DisplayItem(itemId); + + if (item.DisplayItemType() != CPosLmDisplayItem::ELandmarkItem) + { + iLog->Log(_L("ERROR :::::")); + iLog->Log(_L("Wrong item returned, only ELandmarkItem should be returned")); + User::Leave(-1); + } + + if (item.DatabaseIndex() != 0) + { + // When single search, index should always be 0 + iLog->Log(_L("Wrong DatabaseIndex, should be 0")); + User::Leave(-1); + + } + + + TInt lmId = item.Landmark().LandmarkId(); + + AssertTrueSecL(aSearchResults[i]->FindSearchResult(lmId), KNotFoundErr, lmId); + itemId = displayData->NewItemIndex(); + } + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr, id); + + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(textCriteria); + } + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + } + +// --------------------------------------------------------- +// CPosTp23::VerifySortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::VerifySortOrderL() + { + iLog->Log(_L("VerifySortOrderL")); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect"); + _LIT(KNumOfMatchesErr2, "No. of matches in DisplayData is incorrect"); + _LIT(KSortorderErr, "The sortorder is incorrect"); + _LIT(KNameMatchError, "The landmark names does not match"); + _LIT(KNameMatchError2, "The landmark name in DisplayData does not match"); + + // Just in case, add some landmarks + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("CategoryA")); + TPosLmItemId id1 = iDatabase->AddLandmarkL(*landmark); + + CleanupStack::PopAndDestroy(landmark); + + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("Categorya")); + TPosLmItemId id2 = iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("AA")); + TPosLmItemId id3 = iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("aa")); + TPosLmItemId id4 = iDatabase->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + TPosLmSortPref sortDesc(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + TPosLmSortPref sortAsc(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + // Search pattern "*" should match all existing landmarks -> it is possible to compare + // sort order of CPosLandmarkSearch::MatchIteratorL with CPosLandmarkDatabase::LandmarkIteratorL + textCriteria->SetTextL(_L("*")); + + // Set DisplayData + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + CPosLmItemIterator* lmDbIter = NULL; + + for (TInt i=0; i<6; i++) + { + if(i==0) + { + // Sorted ascending + lmDbIter = iDatabase->LandmarkIteratorL(sortAsc); + CleanupStack::PushL(lmDbIter); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortAsc, EFalse)); + } + else if (i==1) + { + // Sorted descending + lmDbIter = iDatabase->LandmarkIteratorL(sortDesc); + CleanupStack::PushL(lmDbIter); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortDesc, EFalse)); + } + else if (i==2) + { + //**** Async search, sorted ascending + lmDbIter = iDatabase->LandmarkIteratorL(sortAsc); + CleanupStack::PushL(lmDbIter); + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortAsc, EFalse)); + } + else if (i==3) + { + //**** Async search, sorted descending + lmDbIter = iDatabase->LandmarkIteratorL(sortDesc); + CleanupStack::PushL(lmDbIter); + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortDesc, EFalse)); + } + else if (i==4) + { + //**** Async search with User::WaitForRequest(), sorted ascending + lmDbIter = iDatabase->LandmarkIteratorL(sortAsc); + CleanupStack::PushL(lmDbIter); + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortAsc, EFalse); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + else if (i==5) + { + //**** Async search with User::WaitForRequest(), sorted descending + lmDbIter = iDatabase->LandmarkIteratorL(sortDesc); + CleanupStack::PushL(lmDbIter); + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, sortDesc, EFalse); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == lmDbIter->NumOfItemsL(), KNumOfMatchesErr); + // Check correct displayData + AssertTrueSecL(iter->NumOfItemsL() == displayData->Count(), KNumOfMatchesErr2); + + TInt itemId = displayData->NewItemIndex(); + + TPosLmItemId id = iter->NextL(); + TPosLmItemId lmDbId = lmDbIter->NextL(); + // check that the two iterators are sorted identically + while (id != KPosLmNullItemId) + { + CPosLandmark* source = iDatabase->ReadLandmarkLC(id); + CPosLandmark* target = iDatabase->ReadLandmarkLC(lmDbId); + + CPosLmDisplayItem& item = displayData->DisplayItem(itemId); + TPtrC lmName; + item.Landmark().GetLandmarkName(lmName); + + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + // For debugging purposes + TBuf<150> buf; + buf.Append(_L("Name:")); + buf.Append(sourceName); + buf.Append(_L("<->")); + buf.Append(targetName); + buf.Append(_L("<->")); + buf.Append(lmName); + //iLog->Log(buf); + + + if (id != lmDbId) iLog->Log(_L("ids are not identical, therefore check name")); + // Should always be the same + AssertTrueSecL(sourceName.Compare(targetName) == KErrNone, KNameMatchError); + AssertTrueSecL(sourceName.Compare(lmName) == KErrNone, KNameMatchError2); + + CleanupStack::PopAndDestroy(target); + CleanupStack::PopAndDestroy(source); + id = iter->NextL(); + lmDbId = lmDbIter->NextL(); + itemId = displayData->NewItemIndex(); + } + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(lmDbIter); + } + // Unset displayData before deleting + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(textCriteria); + + //Remove landmarks created in this part + iDatabase->RemoveLandmarkL(id1); + iDatabase->RemoveLandmarkL(id2); + iDatabase->RemoveLandmarkL(id3); + iDatabase->RemoveLandmarkL(id4); + + iLog->Log(_L("VerifySortOrderL Done")); + } + +// --------------------------------------------------------- +// CPosTp23::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::SearchWithSortOrderL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed syncronously"); + _LIT(KSortorderErr, "The sortorder is incorrect"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + for(TInt j=0; jSetTextL(aSearchResults[j]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); + + //iLog->Log(aSearchResults[j]->TextCriteria()); + + for (TInt i=0; i<6; i++) + { + switch (i) + { + //**** sync + case 0: + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 1: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 2: + //**** async + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + case 3: + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined())); + break; + //**** asych with User::WaitForRequest() + case 4: + { + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + case 5: + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + CPosLmOperation* op = iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortPref, + aSearchResults[j]->Redefined()); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray* searchResults = &aSearchResults[j]->SearchResult(); + if ((TUint)searchResults->Count() != iLandmarkSearch->NumOfMatches()) + { + TBuf<50> buf; + buf.Append(_L("KNumOfMatchesError when searching for ")); + buf.Append(aSearchResults[j]->TextCriteria()); + iLog->Log(buf); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + LandmarksSortL(*searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + if (id != (*searchResults)[ii]) + { + //Check if same name then don't Leave + CPosLandmark* source = iDatabase->ReadLandmarkLC(id); + CPosLandmark* target = iDatabase->ReadLandmarkLC((*searchResults)[ii]); + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + target->GetLandmarkName(targetName); + + AssertTrueSecL(!sourceName.CompareC(targetName),KSortorderErr, id); + CleanupStack::PopAndDestroy(2, source); + } + id = iter->NextL(); + ++ii; + } + CleanupStack::PopAndDestroy(iter); + } // for (TInt i=0; i<6; i++) + } // for(TInt j=0; j& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + _LIT(KSortorderErr, "The sortorder is incorrect after a delete when a redefined search is performed"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(aSearchResults[11]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[11]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[11]->PositionFields()); + + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + + RArray* searchResults = &aSearchResults[11]->SearchResult(); + + iDatabase->RemoveLandmarkL((*searchResults)[0]); + searchResults->Remove(0); + searchResults->Compress(); + + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, ETrue)); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + AssertTrueSecL((TUint)searchResults->Count() == iLandmarkSearch->NumOfMatches(), KNumOfMatchesErr); + + LandmarksSortL(*searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(id == (*searchResults)[ii], KSortorderErr, id); + + id = iter->NextL(); + ++ii; + } + + CleanupStack::PopAndDestroy(2, textCriteria); + } + +// --------------------------------------------------------- +// CPosTp23::SearchAndRenameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::SearchAndRenameL(const RPointerArray& aSearchResults) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when a redefined search is performed"); + const TInt KTestIndex=4; + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(aSearchResults[KTestIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(aSearchResults[KTestIndex]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(aSearchResults[KTestIndex]->PositionFields()); + + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref)); + + RArray* searchResults = &aSearchResults[KTestIndex]->SearchResult(); + + _LIT(KLmName, "LmTP23-%d"); + for (TInt i=0; iCount(); i++) + { + CPosLandmark* lm =iDatabase->ReadLandmarkLC((*searchResults)[i]); + + TBuf<100> lmName; + lmName.Format(KLmName,i); + + lm->SetLandmarkNameL(lmName); + iDatabase->UpdateLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, ETrue)); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + + + AssertTrueSecL(iLandmarkSearch->NumOfMatches()==0, KNumOfMatchesErr); + + CleanupStack::PopAndDestroy(2, textCriteria); + + } + +// --------------------------------------------------------- +// CPosTp23::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KCancelErr, "The search is canceled after progress has increased but no search result is found"); + + // Test search with one criteria + const TInt KIndex=0; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(iSearchResults[KIndex]->TextCriteria()); + textCriteria->SetAttributesToSearch(iSearchResults[KIndex]->Attributes()); + + textCriteria->SetPositionFieldsToSearchL(iSearchResults[KIndex]->PositionFields()); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, iSearchResults[KIndex]->Redefined())); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarkSearch->StartLandmarkSearchL( + *textCriteria, iSearchResults[KIndex]->Redefined())); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + if (iter->NumOfItemsL() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Iterators no. of items is not equal to LandmarksSearch no. matches")); + _LIT(KExpected, "Iter. of matches: %d"); + _LIT(KReturned, "LandmarksSearch no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, iter->NumOfItemsL()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Search criteria: ")); + iLog->Log(textCriteria->Text()); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancel = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + AssertTrueSecL(iter->NumOfItemsL() != 0, KCancelErr); + } + + CleanupStack::PopAndDestroy(2, textCriteria); + + } + +// --------------------------------------------------------- +// CPosTp23::TestMaxLengthL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::TestMaxLengthL() + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + _LIT(K255Error, "Exceeding limit should leave with KErrArgument"); + + _LIT(K255CHAR, "ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ12345"); + _LIT(K256CHAR, "ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ123456"); + + textCriteria->SetTextL(K255CHAR); + + TRAPD(err, textCriteria->SetTextL(K256CHAR);); + AssertTrueSecL(err == KErrArgument, K255Error); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + ExecuteAndDeleteLD(iOperation); + + TInt nr = iLandmarkSearch->NumOfMatches(); + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches"), nr); + iLog->Log(buf); + + AssertTrueSecL(nr == 0, _L("We should not find any matches")); + CleanupStack::PopAndDestroy(textCriteria); + } + +// --------------------------------------------------------- +// CPosTp23::TestInvalidPositionFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp23::TestInvalidPositionFieldsL() + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + RArray arr; + CleanupClosePushL(arr); + + textCriteria->SetTextL(_L("*")); + textCriteria->SetPositionFieldsToSearchL(arr); + + // Search with empty positionfields list, should find all landmarks + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + ExecuteAndDeleteLD(iOperation); + TInt nr = iLandmarkSearch->NumOfMatches(); + TBuf<100> buf; + buf.Format(_L("Found %d nr of matches when searching in empty position fields list"), nr); + iLog->Log(buf); + + + + User::LeaveIfError(arr.Append(0)); + User::LeaveIfError(arr.Append(50)); + User::LeaveIfError(arr.Append(500)); + textCriteria->SetPositionFieldsToSearchL(arr); + + // Search with invalid positionfields list, should NOT find any landmarks + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); + ExecuteAndDeleteLD(iOperation); + nr = iLandmarkSearch->NumOfMatches(); + + buf.Format(_L("Found %d nr of matches when searching in invalid position fields"), nr); + iLog->Log(buf); + + AssertTrueSecL(nr == 0, _L("We should not find any matches")); + + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(textCriteria); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp24.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp24.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,384 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp24.h" +#include +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp24::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp24::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase = NULL; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iAreaSearchResults.ResetAndDestroy(); + delete iOperation;iOperation=NULL; + } + +// --------------------------------------------------------- +// CPosTp24::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp24::StartL() + { + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + AppendAreaSearchResultsL(); + + // Invalid areas is tested (see LmDbAreaSearchResult.txt) + iLog->Log(_L("Testing area search with criterias read from LmDbAreaSearchResult.txt syncronously")); + SearchL(ESynchronous); + + iLog->Log(_L("Testing area search with criterias read from LmDbAreaSearchResult.txt asyncronously")); + SearchL(EAsynchronous); + + iLog->Log(_L("Testing area search with criterias read from LmDbAreaSearchResult.txt asyncronously with User::WaitForRequest()")); + SearchL(EWaitForRequest); + + iLog->Log(_L("Testing area search with a defined sortorder")); + SearchWithSortOrderL(); + + iLog->Log(_L("Testing area search and cancel")); + SearchAndCancelL(); + iLog->Log(_L("Testing area search and cancel in callback")); + SearchAndCancelL(ETrue); + } + +// --------------------------------------------------------- +// CPosTp24::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp24::SearchL(TExecutionMode aExecutionMode) + { + TBuf<255> info; + for (TInt i=0; iSouthLat(), + iAreaSearchResults[i]->NorthLat(), + iAreaSearchResults[i]->WestLong(), + iAreaSearchResults[i]->EastLong() + )); + CleanupStack::PushL(areaCriteria); + if (err != iAreaSearchResults[i]->ErrorCode()) + { + iLog->Log(_L("Unexpected error code returned")); + iLog->Log(_L("Area Search result read from file:")); + + iAreaSearchResults[i]->Print(info); + iLog->Log(info); + + _LIT(KReturned, "Search returned errorCode = %d"); + info.Format(KReturned, err); + iLog->Log(info); + User::Leave(KErrGeneral); + } + + if (!err) + { + iOperation = iLandmarkSearch->StartLandmarkSearchL( + *areaCriteria, iAreaSearchResults[i]->Redefined()); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + iOperation = NULL; + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + iOperation = NULL; + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation;iOperation=NULL; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if ((TUint)(iAreaSearchResults[i]->SearchResult()).Count() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Unexpected no. of matches returned")); + _LIT(KExpected, "Expected no. of matches: %d "); + _LIT(KReturned, "Returned no. of matches: %d "); + info.Format(KExpected, (iAreaSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Area Search result read from file:")); + info.Zero(); + iAreaSearchResults[i]->Print(info); + iLog->Log(info); + + iLog->Log(_L("Landmarks expected to find:")); + for (TInt j=0; jSearchResult().Count(); j++) + { + RArray* searchResults = &iAreaSearchResults[i]->SearchResult(); + CPosLandmark* lm = iDatabase->ReadLandmarkLC((*searchResults)[j]); + info.Zero(); + PrintLandmark(*lm, info); + iLog->Log(info); + CleanupStack::PopAndDestroy(lm); + } + + iLog->Log(_L("Landmarks returned by Area search:")); + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(id); + info.Zero(); + PrintLandmark(*lm2, info); + iLog->Log(info); + CleanupStack::PopAndDestroy(lm2); + id = iter->NextL(); + } + + User::Leave(KErrGeneral); + } + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + if (!iAreaSearchResults[i]->FindSearchResult(id)) + { + _LIT(KUnexpectedId, "Unexpected id, %d returned from search which is not in read area search result"); + info.Format(KUnexpectedId, id); + iLog->Log(_L("Area Search result read from file:")); + iAreaSearchResults[i]->Print(info); + iLog->Log(info); + User::Leave(KErrGeneral); + } + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + CleanupStack::PopAndDestroy(areaCriteria); + } + } + +// --------------------------------------------------------- +// CPosTp24::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp24::SearchWithSortOrderL() + { + const TInt KSortOrderIndex=4; + _LIT(KNumOfMatchesErr, "No. of matches is incorrect"); + _LIT(KSortorderErr, "The sortorder is incorrect"); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + CPosLmAreaCriteria* areaCriteria=CPosLmAreaCriteria::NewLC( + iAreaSearchResults[KSortOrderIndex]->SouthLat(), + iAreaSearchResults[KSortOrderIndex]->NorthLat(), + iAreaSearchResults[KSortOrderIndex]->WestLong(), + iAreaSearchResults[KSortOrderIndex]->EastLong() + ); + + // Test SetSearchArea + areaCriteria->SetSearchArea(iAreaSearchResults[KSortOrderIndex]->SouthLat(), + iAreaSearchResults[KSortOrderIndex]->NorthLat(), + iAreaSearchResults[KSortOrderIndex]->WestLong(), + iAreaSearchResults[KSortOrderIndex]->EastLong()); + + + TReal64 southLat; + TReal64 northLat; + TReal64 westLong; + TReal64 eastLong; + areaCriteria->GetSearchArea(southLat, northLat, westLong, eastLong); + AssertTrueSecL(southLat == iAreaSearchResults[KSortOrderIndex]->SouthLat(), _L("SouthLat is wrong")); + AssertTrueSecL(northLat == iAreaSearchResults[KSortOrderIndex]->NorthLat(), _L("NorthLat is wrong")); + AssertTrueSecL(westLong == iAreaSearchResults[KSortOrderIndex]->WestLong(), _L("WestLong is wrong")); + AssertTrueSecL(eastLong == iAreaSearchResults[KSortOrderIndex]->EastLong(), _L("EastLong is wrong")); + + + for (TInt i=0; i<6; i++) + { + if(i==0) + { + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + ExecuteAndDeleteLD(iOperation); + } + else if (i==1) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + ExecuteAndDeleteLD(iOperation); + } + else if (i==2) + { + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + RunAsyncOperationLD(iOperation); + } + else if (i==3) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + RunAsyncOperationLD(iOperation); + } + else if (i==4) + { + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation;iOperation=NULL; + } + else if (i==5) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*areaCriteria, sortPref); + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation;iOperation=NULL; + } + iOperation = NULL; + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray* searchResults = &iAreaSearchResults[KSortOrderIndex]->SearchResult(); + AssertTrueSecL((TUint)searchResults->Count() == iLandmarkSearch->NumOfMatches(), KNumOfMatchesErr); + + LandmarksSortL(*searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(id == (*searchResults)[ii], KSortorderErr, id); + + id = iter->NextL(); + ++ii; + } + CleanupStack::PopAndDestroy(iter); + } + + CleanupStack::PopAndDestroy(areaCriteria); + } + +// --------------------------------------------------------- +// CPosTp24::NewLmAreaCriteriaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLmAreaCriteria* CPosTp24::NewLmAreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong) + { + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(aSouthLat, + aNorthLat, + aWestLong, + aEastLong + ); + CleanupStack::Pop(); + return areaCriteria; + } + +// --------------------------------------------------------- +// CPosTp24::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp24::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KCancelErr, "The search is canceled after progress has increased but no search result is found"); + + // Test search with one criteria + const TInt KIndex=0; + + CPosLmAreaCriteria* areaCriteria=NULL; + areaCriteria = CPosLmAreaCriteria::NewLC(iAreaSearchResults[KIndex]->SouthLat(), + iAreaSearchResults[KIndex]->NorthLat(), + iAreaSearchResults[KIndex]->WestLong(), + iAreaSearchResults[KIndex]->EastLong() + ); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartLandmarkSearchL( + *areaCriteria, iAreaSearchResults[KIndex]->Redefined())); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarkSearch->StartLandmarkSearchL( + *areaCriteria, iAreaSearchResults[KIndex]->Redefined())); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + if (iter->NumOfItemsL() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Iterators no. of items is not equal to LandmarksSearch no. matches")); + _LIT(KExpected, "Iter. of matches: %d"); + _LIT(KReturned, "LandmarksSearch no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, iter->NumOfItemsL()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancel = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + AssertTrueSecL(iter->NumOfItemsL() != 0, KCancelErr); + } + + CleanupStack::PopAndDestroy(2, areaCriteria); + + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp25.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp25.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,958 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp25.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp25::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + delete iDatabase; + iDatabase=NULL; + + iCategorySearchResults.ResetAndDestroy(); + + } + +// --------------------------------------------------------- +// CPosTp25::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::StartL() + { + _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); + _LIT(KEmptyTextCriteriaErr1, "An empty text criteria should not be allowed"); + // copy test db to the private path + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp25TestDb); + + TInt er = fileMan->Copy(srcPath, KLmTp25DefaultDbPath, + CFileMan::EOverWrite); + if (er != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp25TestDb); + CleanupStack::PopAndDestroy(manager); + + iDatabase = CPosLandmarkDatabase::OpenL(KTp25TestDb); + if (iDatabase->IsInitializingNeeded()) + { + TRAPD( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) ); + AssertTrueSecL(err == KErrNone, _L("Init db failed")); + } + + + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + TInt err = KErrNone; + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + // Start by testing some error flows, returning KErrArgument + TRAP(err, iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr1); + + + // Test with a landmark search criteria into a category search operation + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TRAP(err, iLandmarkSearch->StartCategorySearchL(*textCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + CleanupStack::PopAndDestroy(textCriteria); + + // Test empty string + nameCriteria->SetSearchPatternL(_L("")); + TRAP(err, iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); + CleanupStack::PopAndDestroy(nameCriteria); + + // test with maximum nr of characters in search pattern + TestSearchPatternLengthL(); + + AppendCategorySearchResultsL(); + + // Search synchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt syncronously")); + SearchL(iCategorySearchResults, ESynchronous); + + iLog->Log(_L("Testing search with sort order")); + SearchWithSortOrderL(iCategorySearchResults, ESynchronous); + + iLog->Log(_L("Testing search with maximum nr of matches")); + SearchWithMaximumL(iCategorySearchResults, ESynchronous); + + // Search asynchronously + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asyncronously")); + SearchL(iCategorySearchResults, EAsynchronous); + + iLog->Log(_L("Testing search with sort order asynchronously")); + SearchWithSortOrderL(iCategorySearchResults, EAsynchronous); + + iLog->Log(_L("Testing search with maximum nr of matches asynchronously")); + SearchWithMaximumL(iCategorySearchResults, EAsynchronous); + + // Search asynchronously with User::WaitForRequest() + iLog->Log(_L("Testing search with criterias read from LmDbSearchResult.txt asyncronously using User::WaitForRequest()")); + SearchL(iCategorySearchResults, EWaitForRequest); + + iLog->Log(_L("Testing search with sort order asynchronously using User::WaitForRequest()")); + SearchWithSortOrderL(iCategorySearchResults, EWaitForRequest); + + iLog->Log(_L("Testing search with maximum nr of matches asynchronously using User::WaitForRequest()")); + SearchWithMaximumL(iCategorySearchResults, EWaitForRequest); + + // Search for added categories + iLog->Log(_L("Testing search after category has been added")); + SearchAfterAddedCategoryL(); + + // Cancel search test + iLog->Log(_L("Testing category search and cancel")); + SearchAndCancelL(); + + iLog->Log(_L("Testing category search and cancel in callback")); + SearchAndCancelL(ETrue); + + delete iDatabase; + iDatabase = NULL; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iDatabase = UseGlobalCategoriesL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + iLog->Log(_L("Testing search with global categories included, sync")); + SearchGlobalL(iCategorySearchResults, ETrue); + + iLog->Log(_L("Testing search with global categories included, asyncronously")); + SearchGlobalL(iCategorySearchResults, EFalse); + + // Verify error report "ESLI-62DBXR Landmarks - Sort order is not correctly implemented" + // Check that CPosLandmarkSearch::MatchIteratorL are CPosLandmarkDatabase::LandmarkIteratorL + // are sorted correctly (should be identically sorted) + VerifySortOrderL(); + + RemoveGlobalCategoriesL(); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + } + +// --------------------------------------------------------- +// CPosTp25::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + + for(TInt i=0; iSetSearchPatternL(aSearchResults[i]->TextCriteria()); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != iLandmarkSearch->NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Name criteria: ")); + iLog->Log(nameCriteria->SearchPattern()); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(aSearchResults[i]->FindSearchResult(id), KNotFoundErr, id); + + id = iter->NextL(); + } + + // Check DisplayData below + TInt nrr = displayData->Count(); + + if ((TUint)(aSearchResults[i]->SearchResult()).Count() != displayData->Count()) + { + _LIT(KExpected, "Expected no. of displaydata matches: %d"); + _LIT(KReturned, "Returned no. of displaydata matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, displayData->Count()); + iLog->Log(info); + iLog->Log(_L("Name criteria: ")); + iLog->Log(nameCriteria->SearchPattern()); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TInt itemId = displayData->NewItemIndex(); + while (itemId != KPosLmNoNewItems) + { + CPosLmDisplayItem& item = displayData->DisplayItem(itemId); + + if (item.DisplayItemType() != CPosLmDisplayItem::ECategoryItem) + { + iLog->Log(_L("ERROR :::::")); + iLog->Log(_L("Wrong item returned, only ECategoryItem should be returned")); + User::Leave(-1); + } + + if (item.DisplayItemType() == CPosLmDisplayItem::ELandmarkItem) + { + iLog->Log(_L("Is ELandmarkItem:::::")); + } + + if (item.DatabaseIndex() != 0) + { + // When single search, index should always be 0 + iLog->Log(_L("Wrong DatabaseIndex, should be 0")); + User::Leave(-1); + + } + + TInt categoryId = item.Category().CategoryId(); + + if (!aSearchResults[i]->FindSearchResult(categoryId)) + { + iLog->Log(_L("Not Found")); + TPtrC name; + item.Category().GetCategoryName(name); + iLog->Log(name); + iLog->Log(_L("Could not find LandmarkCategory")); + User::Leave(-1); + + } + itemId = displayData->NewItemIndex(); + } + + CleanupStack::PopAndDestroy(iter); + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + CleanupStack::PopAndDestroy(nameCriteria); + } + } + +// --------------------------------------------------------- +// CPosTp25::TestSearchPatternLengthL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::TestSearchPatternLengthL() + { + iLog->Log(_L("TestSearchPatternLengthL")); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + //Test with maximum size of search pattern + //KPosLmMaxCategoryNameLength is 124 (from EPos_Landmarks.h) + HBufC* hbuf = HBufC::NewLC(KPosLmMaxCategoryNameLength+1); + while(hbuf->Des().Length() < KPosLmMaxCategoryNameLength) + { + hbuf->Des().Append(_L("*")); + } + nameCriteria->SetSearchPatternL(*hbuf); + + hbuf->Des().Append(_L("*")); + TRAPD(err, nameCriteria->SetSearchPatternL(*hbuf)); + + AssertTrueSecL(err == KErrArgument, _L("It should not be possible to set search pattern")); + + CleanupStack::PopAndDestroy(hbuf); + CleanupStack::PopAndDestroy(nameCriteria); + } + +// --------------------------------------------------------- +// CPosTp25::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchWithSortOrderL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + + CPosLmCategoryManager::TCategorySortPref sortPref; + + for (TInt j=0;j<2;j++) + { + for(TInt i=0; iSetSearchPatternL(aSearchResults[i]->TextCriteria()); + + if (j==0) + { + sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPref); + } + else + { + sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPref); + } + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + // Create a sorted list out of the search result + RArray searchResults = aSearchResults[i]->SearchResult(); + // To avoid User-44 create a copy of the aSearchResults[i] + RArray searchResultsSorted; + CleanupClosePushL(searchResultsSorted); + + for (TInt kk=0;kkSearchResult()).Count() != iLandmarkSearch->NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResults[i]->SearchResult()).Count()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(_L("Name criteria: ")); + iLog->Log(nameCriteria->SearchPattern()); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + + } + + TPosLmItemId id = iter->NextL(); + TInt counter=0; + while (id != KPosLmNullItemId) + { + // Check that sort order is correct + AssertTrueSecL(searchResultsSorted[counter] == id, _L("Error in sorting")); + id = iter->NextL(); + counter++; + } + CleanupStack::PopAndDestroy(&searchResultsSorted); + CleanupStack::PopAndDestroy(2, nameCriteria); + } + } + } + +// --------------------------------------------------------- +// CPosTp25::SearchWithMaximumL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchWithMaximumL( + const RPointerArray& aSearchResults, + TExecutionMode aExecutionMode) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchWithMaximumL is performed"); + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + // First get the maximum number of matches + nameCriteria->SetSearchPatternL(_L("*")); + ExecuteAndDeleteLD(iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + TInt max = iLandmarkSearch->NumOfMatches(); + + for (TInt j=1;j<=max;j++) + { + nameCriteria->SetSearchPatternL(_L("*")); + iLandmarkSearch->SetMaxNumOfMatches(j); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + // The execution flow + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(iOperation); + break; + case EAsynchronous: + RunAsyncOperationLD(iOperation); + break; + case EWaitForRequest: + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + break; + } + + AssertTrueSecL((TUint)j == iLandmarkSearch->NumOfMatches(), KNumOfMatchesErr); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + // Use search result for position 0, should always be for * + AssertTrueSecL(aSearchResults[0]->FindSearchResult(id), KNotFoundErr, id); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + + CleanupStack::PopAndDestroy(nameCriteria); + } + +// --------------------------------------------------------- +// CPosTp25::SearchAfterAddedCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchAfterAddedCategoryL() + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchAfterAddedCategoryL is performed"); + _LIT(KCategoryNotFound, "Added category could not be found"); + _LIT(KCategory, "StoraKoncernen"); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + + CPosLandmarkCategory* cat1 = CPosLandmarkCategory::NewLC(); + + // First do a search with wildcard + nameCriteria->SetSearchPatternL(_L("S*")); + ExecuteAndDeleteLD(iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + // Then add a new category with a name starting with S + cat1->SetCategoryNameL(KCategory); + TPosLmItemId categoryId = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + // Then use do another search within the results of previous search + // should return Stadsbibliotek and Stadspark + nameCriteria->SetSearchPatternL(_L("St*")); + ExecuteAndDeleteLD(iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone, ETrue)); + TInt max = iLandmarkSearch->NumOfMatches(); + + if (max != 2) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + // Set a maximum number of matches, should return only one of Stadsbibliotek and Stadspark + iLandmarkSearch->SetMaxNumOfMatches(1); + + // Do another search just to see that it is possible to find the added category + nameCriteria->SetSearchPatternL(KCategory); + ExecuteAndDeleteLD(iLandmarkSearch->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + max = iLandmarkSearch->NumOfMatches(); + + if (max != 1) + { + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + if (categoryId != id) + { + iLog->Log(KCategoryNotFound); + User::Leave(-1); + } + + + // Remove added category + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(categoryId)); + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp25::SearchGlobalL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchGlobalL(const RPointerArray& aSearchResults, const TBool& aSync) + { + iLog->Log(_L("SearchGlobalL")); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when SearchGlobalL is performed"); + + // Nr of global categories, defined in resource file + const TInt KNrOfGlobalCategories = 15; + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + CPosLmCategoryManager::TCategorySortPref sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + + for (TInt l=0;l<2;l++) + { + if (l==0) sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + else if (l==1) sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + + // i=0 the first entry in aSearchResults should be wildcard "*" + TInt i = 0; + // First do a search with wildcard + nameCriteria->SetSearchPatternL(aSearchResults[i]->TextCriteria()); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPref); + + // The asynchronous flow + if (aSync) + { + RunAsyncOperationLD(iOperation); + } + else + { + ExecuteAndDeleteLD(iOperation); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + // Create a sorted list out of the search result + RArray searchResults = aSearchResults[i]->SearchResult(); + RArray searchResultsSorted; + + for (TInt kk=0;kkSearchResult()).Count() + KNrOfGlobalCategories; + TUint expNr2 = iLandmarkSearch->NumOfMatches(); + + if (expNr != expNr2) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, expNr); + iLog->Log(info); + info.Format(KReturned, expNr2); + iLog->Log(info); + iLog->Log(_L("Name criteria: ")); + iLog->Log(nameCriteria->SearchPattern()); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + TPosLmItemId id = iter->NextL(); + TInt counter=0; + while (id != KPosLmNullItemId) + { + // Check that sort order is correct + AssertTrueSecL(searchResultsSorted[counter] == id, _L("Error in sorting")); + id = iter->NextL(); + counter++; + } + + CleanupStack::PopAndDestroy(iter); + searchResultsSorted.Reset(); + searchResultsSorted.Close(); + + } // end for (TInt l=0 ...) + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + iLog->Log(_L("SearchGlobalL Done")); + } + +// --------------------------------------------------------- +// CPosTp24::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KCancelErr, "The search is canceled after progress has increased but no search result is found"); + + // Test search with one criteria + const TInt KIndex=0; + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(iCategorySearchResults[KIndex]->TextCriteria()); + iLandmarkSearch->SetMaxNumOfMatches(); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartCategorySearchL( + *nameCriteria, + CPosLmCategoryManager::ECategorySortOrderNone, + iCategorySearchResults[KIndex]->Redefined())); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarkSearch->StartCategorySearchL( + *nameCriteria, + CPosLmCategoryManager::ECategorySortOrderNone, + iCategorySearchResults[KIndex]->Redefined())); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + if (iter->NumOfItemsL() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Iterators no. of items is not equal to LandmarksSearch no. matches")); + _LIT(KExpected, "Iter. of matches: %d"); + _LIT(KReturned, "LandmarksSearch no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, iter->NumOfItemsL()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancel = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + AssertTrueSecL(iter->NumOfItemsL() != 0, KCancelErr); + } + + CleanupStack::PopAndDestroy(2, nameCriteria); + } + +// --------------------------------------------------------- +// CPosTp25::VerifySortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp25::VerifySortOrderL() + { + iLog->Log(_L("VerifySortOrderL")); + // Search pattern "*" should match all existing landmarks -> it is possible to compare + // sort order of CPosLandmarkSearch::MatchIteratorL with CPosLandmarkDatabase::LandmarkIteratorL + + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + _LIT(KNumOfMatchesErr2, "No. of matches in DisplayData is incorrect when the search is performed"); + + _LIT(KSortorderErr, "The sortorder is incorrect"); + _LIT(KNameMatchError, "The landmark category name does not match"); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + // Just in case, add some categories + CPosLandmarkCategory* cat1 = CPosLandmarkCategory::NewLC(); + cat1->SetCategoryNameL(_L("CategoryA")); + TPosLmItemId categoryId1 = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + cat1 = CPosLandmarkCategory::NewLC(); + cat1->SetCategoryNameL(_L("Categorya")); + TPosLmItemId categoryId2 = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + cat1 = CPosLandmarkCategory::NewLC(); + cat1->SetCategoryNameL(_L("AA")); + TPosLmItemId categoryId3 = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + cat1 = CPosLandmarkCategory::NewLC(); + cat1->SetCategoryNameL(_L("aa")); + TPosLmItemId categoryId4 = categoryManager->AddCategoryL(*cat1); + CleanupStack::PopAndDestroy(cat1); + + CleanupStack::PopAndDestroy(categoryManager); + + CPosLmCategoryManager::TCategorySortPref sortPrefAsc = CPosLmCategoryManager::ECategorySortOrderNameAscending;; + CPosLmCategoryManager::TCategorySortPref sortPrefDesc = CPosLmCategoryManager::ECategorySortOrderNameDescending;; + CPosLmItemIterator* categoryDbIter = NULL; + + for (TInt j=0;j<6;j++) + { + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + + CPosLmDisplayData* displayData = CPosLmDisplayData::NewL(); + CleanupStack::PushL(displayData); + iLandmarkSearch->SetDisplayData(*displayData); + + if (j==0) + { + // Sorted Ascending, sync + iLog->Log(_L("Sorted Ascending, Sync")); + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefAsc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefAsc); + ExecuteAndDeleteLD(iOperation); + } + else if (j==1) + { + // Sorted Descending, sync + iLog->Log(_L("Sorted Descending, Sync")); + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefDesc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefDesc); + ExecuteAndDeleteLD(iOperation); + } + else if (j==2) + { + // Sorted Ascending, async + iLog->Log(_L("Sorted Ascending, Async")); + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefAsc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefAsc); + RunAsyncOperationLD(iOperation); + } + else if (j==3) + { + // Sorted Descending, async + iLog->Log(_L("Sorted Descending, Async")); + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefDesc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefDesc); + RunAsyncOperationLD(iOperation); + } + else if (j==4) + { + iLog->Log(_L("Sorted Ascending, Async using User::WaitForRequest")); + // Sorted Ascending, async using User::WaitForRequest() + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefAsc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefAsc); + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + } + else if (j==5) + { + iLog->Log(_L("Sorted Descending, Async using User::WaitForRequest")); + // Sorted Descending, async using User::WaitForRequest() + categoryDbIter = categoryManager->CategoryIteratorL(sortPrefDesc); + CleanupStack::PushL(categoryDbIter); + iOperation = iLandmarkSearch->StartCategorySearchL(*nameCriteria, sortPrefDesc); + RunAsyncOperationByWaitForReqL(iOperation); + delete iOperation; + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == categoryDbIter->NumOfItemsL(), KNumOfMatchesErr); + + // Check correct displayData + AssertTrueSecL(iter->NumOfItemsL() == displayData->Count(), KNumOfMatchesErr2); + + TInt itemId = displayData->NewItemIndex(); + + TPosLmItemId id = iter->NextL(); + TPosLmItemId categoryDbId = categoryDbIter->NextL(); + // check that the two iterators are sorted identically + while (id != KPosLmNullItemId) + { + CPosLandmarkCategory* source = categoryManager->ReadCategoryLC(id); + CPosLandmarkCategory* target = categoryManager->ReadCategoryLC(categoryDbId); + + CPosLmDisplayItem& item = displayData->DisplayItem(itemId); + TInt categoryId = item.Category().CategoryId(); + + // For debugging purposes + TPtrC sourceName, targetName; + source->GetCategoryName(sourceName); + target->GetCategoryName(targetName); + TPtrC name; + item.Category().GetCategoryName(name); + + TBuf<150> buf; + buf.Append(_L("Name:")); + buf.Append(sourceName); + buf.Append(_L("<->")); + buf.Append(targetName); + buf.Append(_L("<->")); + buf.Append(name); + iLog->Log(buf); + + AssertTrueSecL(id == categoryDbId, KSortorderErr); + AssertTrueSecL(id == categoryId, _L("Wrong displaydata item when sorting")); + // Should always be the same, since we check that id are equal above + AssertTrueSecL(sourceName.Compare(targetName) == KErrNone, KNameMatchError); + AssertTrueSecL(sourceName.Compare(name) == KErrNone, _L("Wrong DisplayData item name when sorting")); + + CleanupStack::PopAndDestroy(target); + CleanupStack::PopAndDestroy(source); + + id = iter->NextL(); + categoryDbId = categoryDbIter->NextL(); + itemId = displayData->NewItemIndex(); + } + iLog->Log(_L("Done")); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(categoryDbIter); + + iLandmarkSearch->UnsetDisplayData(); + CleanupStack::PopAndDestroy(displayData); + + CleanupStack::PopAndDestroy(nameCriteria); + CleanupStack::PopAndDestroy(categoryManager); + } + + // Delete the categories added in the beginning + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + iOperation = categoryManager->RemoveCategoryL(categoryId1); + ExecuteAndDeleteLD(iOperation); + iOperation = categoryManager->RemoveCategoryL(categoryId2); + ExecuteAndDeleteLD(iOperation); + iOperation = categoryManager->RemoveCategoryL(categoryId3); + ExecuteAndDeleteLD(iOperation); + iOperation = categoryManager->RemoveCategoryL(categoryId4); + ExecuteAndDeleteLD(iOperation); + + CleanupStack::PopAndDestroy(categoryManager); + iLog->Log(_L("VerifySortOrderL Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp3.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp3.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp3.h" +#include + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp3::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp3::StartL() + { + + _LIT(KDbUri5, "http://c:\\system\\data\\eposlm.ldb"); + + _LIT(KHttpErr, "http is not a supported protocol"); + + RemoveDefaultDbL(); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + delete lmd; + + + TInt err=0; + TRAP(err, TestOpenDbL(KDbUri5)); + AssertTrueSecL(err == KErrNotSupported, KHttpErr); + + } + +// --------------------------------------------------------- +// CPosTp3::TestOPenDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp3::TestOpenDbL(const TDesC& aDbURI) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(aDbURI); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CleanupStack::PopAndDestroy(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp30.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp30.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,307 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_CSearchResult.h" +#include +#include +#include + +#include "FT_CPosTp30.h" + + +#include "FT_LandmarkConstants.h" +//#include "FT_CActiveSearch.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp30::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp30::GetName(TDes& aName) const + { + _LIT(KTestName, "TP30 - Multiple clients in search"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp30::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp30::CloseTest() + { + for (TInt i=0; i n*'request time for one request'"); + MakeSurePanicDebugFileExistsL(); + + iDatabase = UseGeneratedDbFileL(); + delete iDatabase; + iDatabase=NULL; + iUseLogFromThreadIsDisabled = ETrue; + AppendSearchResultsL(); + iAsyncSearch = ETrue; + TTime start, stop; + start.UniversalTime(); + StartMultipleClientsL(1); + stop.UniversalTime(); + + TInt64 msecOne = (stop.Int64() - start.Int64())/1000; + + _LIT8(KTrace, "%d simultaneously search request(s) = %d mseconds"); + TBuf8<100> msg; + msg.Format(KTrace, 1, msecOne); + iLog->Put(msg); + + start.UniversalTime(); + StartMultipleClientsL(KNoMultipleClients); + stop.UniversalTime(); + iAsyncSearch = EFalse; + + TInt64 msecSeveral = (stop.Int64() - start.Int64())/1000; + msg.Format(KTrace, KNoMultipleClients, msecSeveral); + iLog->Put(msg); + + AssertTrueSecL((msecOne*KNoMultipleClients) >= msecSeveral, KTimeErr); + + iLog->Put(_L("Testing simultaneously search syncronously and remove all syncronously")); + + iRemoveTest=ETrue; + StartMultipleClientsL(3); + iRemoveTest=EFalse; + + delete iDatabase; + iDatabase = NULL; + iDatabase = UseGeneratedDbFileL(); + + iLog->Put(_L("Testing simultaneously search asyncronously")); + iAsyncSearch = ETrue; + StartMultipleClientsL(KNoMultipleClients); + +//// + + iLog->Put(_L("Testing simultaneously search asyncronously and remove all syncronously")); + iRemoveTest=ETrue; + StartMultipleClientsL(3); + + } + +// --------------------------------------------------------- +// CPosTp30::StartMultipleClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp30::StartMultipleClientsL(const TUint aNoClients) + { + _LIT(KMultipleErr, "Error %d when multiple clients access the landmarks db"); + _LIT(KPanicErr, "Thread has panicked or is still alive when multiple clients searched the databse"); + + CreateThreadsL(aNoClients); + + RArray statuses; + CleanupClosePushL(statuses); + + for (TUint j=0; jIsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosTp30* self = reinterpret_cast(aData); + ++self->iThreadIndex; + + if (self->iRemoveTest && self->iThreadIndex == 3) + { + CPosLmOperation* lmo=NULL; + TRAPD(err,lmo = lmd->RemoveAllLandmarksL()); + + if (err != KErrNone && err != KErrLocked) + { + User::Leave(err); + } + else if(!err) + { + TRAP(err, ExecuteAndDeleteLD(lmo)); + if (err != KErrNone && err != KErrLocked) + { + User::Leave(err); + } + } + } + else + { + CPosLandmarkSearch* lms = CPosLandmarkSearch::NewL(*lmd); + + CleanupStack::PushL(lms); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(self->iSearchResults[0]->TextCriteria()); + textCriteria->SetAttributesToSearch(self->iSearchResults[0]->Attributes()); + textCriteria->SetPositionFieldsToSearchL(self->iSearchResults[0]->PositionFields()); + + if (!self->iAsyncSearch) + { + ExecuteAndDeleteLD(lms->StartLandmarkSearchL(*textCriteria)); + } + else + { + self->RunAsyncOperationLD(lms->StartLandmarkSearchL(*textCriteria)); + } + + CPosLmItemIterator* iter = lms->MatchIteratorL(); + CleanupStack::PushL(iter); + + self->AssertTrueSecL((TUint)(self->iSearchResults[0]->SearchResult()).Count() == lms->NumOfMatches(), KNumOfMatchesErr); + + CleanupStack::PopAndDestroy(3, lms); + + } + + CleanupStack::PopAndDestroy(lmd); + } + + +// --------------------------------------------------------- +// ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp30::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp30::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp30::CreateThreadsL(const TUint aNoThreads) + { + _LIT(KThreadName, "LM test thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TUint i=0; i name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp31.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp31.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,575 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp31.h" +#include +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KNoListeners=2; + +const TInt KNoLandmarks = 10; +const TInt KNoCategories = 10; + +const TInt KCancelledThreadIndex = 2; + +const TInt KNoEvents = 25; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp31::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::GetName(TDes& aName) const + { + _LIT(KTestName, "TP31 - Multiple event listeners"); + aName = KTestName; + + } + +// --------------------------------------------------------- +// CPosTp31::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::StartL() + { + _LIT(KMultipleErr, "Error %d when multiple clients listen for events"); + _LIT(KEventErr, "%d Error(s) when multiple clients listen for events"); + _LIT(KExitErr, "Thread was panicked or is still alive"); + iUseLogFromThreadIsDisabled = ETrue; + MakeSurePanicDebugFileExistsL(); + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + //We should use an empty database for this test case + CPosLandmarkDatabase* database = UseEmptyDbFileL(); + delete database; + + TFixedArray statuses; + + CreateThreadsL(); + + for (TInt i=0; i 0) + { + TBuf<100> info; + info.Format(KEventErr, iErrors); + LogErrorAndLeave(iErrorLog); + } + } + +// --------------------------------------------------------- +// CPosTp31::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::CloseTest() + { + for (TInt i=0; i(aData); + + RDebug::Print(_L(">>>>>>>>>RunReceiveEventsTestL<<<<<<<<<")); + + CEventObserver* eventObserver = CEventObserver::NewL(self, ++self->iThreadIndex); + CleanupStack::PushL(eventObserver); + eventObserver->Start(); + + eventObserver->StartTimer(); + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(eventObserver); + + } + +LOCAL_C TInt ReceiveEventsThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp31::RunReceiveEventsTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp31::CreateEventsTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::CreateEventsTestL(TAny* aData) + { + CPosTp31* self = reinterpret_cast(aData); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + ExecuteAndDeleteLD(lmd->CompactL()); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + RArray landmarksIds; + CleanupClosePushL(landmarksIds); + RDebug::Print(_L(">>>>>>>>>CreateEventsTestL<<<<<<<<<")); + for (TInt i=0; iSetLandmarkNameL(_L("TP31")); + TPosLmItemId idde; + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, idde = lmd->AddLandmarkL(*landmark)); + } + landmarksIds.Append(idde); + CleanupStack::PopAndDestroy(landmark); + } + + RArray catIds; + CleanupClosePushL(catIds); + + _LIT(KCategoryName, "TP31 Category %d"); + for (TInt j =0; j < KNoCategories; j++) + { + TBuf<100> name; + name.Format(KCategoryName, j); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(name); + TPosLmItemId idde; + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, idde = cm->AddCategoryL(*category)); + } + catIds.Append(idde); + CleanupStack::PopAndDestroy(category); + } + ExecuteAndDeleteLD(lmd->CompactL()); + + // Add categories to landmarks #21 + self->RunAsyncOperationLD(cm->AddCategoryToLandmarksL(catIds[0], landmarksIds)); + + // Remove category #22 + self->RunAsyncOperationLD(cm->RemoveCategoryL(catIds[0])); + + // Remove categories #23 + catIds.Remove(0); + self->RunAsyncOperationLD(cm->RemoveCategoriesL(catIds)); + + // Remove category from landmarks #24 + TRAPD(err, self->RunAsyncOperationLD(cm->RemoveCategoryFromLandmarksL(catIds[0], landmarksIds))); + User::After(200000); + + // Remove landmarks #25 + landmarksIds.Remove(0); + landmarksIds.Remove(1); + self->RunAsyncOperationLD(lmd->RemoveLandmarksL(landmarksIds)); + User::After(200000); + + // Remove all landmarks #26 + self->RunAsyncOperationLD(lmd->RemoveAllLandmarksL()); + User::After(200000); + + CleanupStack::PopAndDestroy(4, lmd); + } + +LOCAL_C TInt CreateEventsThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp31::CreateEventsTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp31::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::CreateThreadsL() + { + + _LIT(KThreadName, "TP31 test thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TInt i=0; i<=KNoListeners; i++) + { + RThread thread; + TBuf<32> name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + if (i==KNoListeners) + { + err = thread.Create(name, CreateEventsThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + } + else + { + err = thread.Create(name, ReceiveEventsThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + } + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// --------------------------------------------------------- +// CPosTp31::LogError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::LogError(const TDesC& aError) + { + iErrorLog.Append(aError); + iErrors++; + } + +// --------------------------------------------------------- +// CEventObserver::CheckEventL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp31::CheckEvent(const TInt aThreadIndex, + const TPosLmEventType aExpectedEventType, + const TPosLmEventType aEventType, + const TPosLmItemId aExpectedItemId, + const TPosLmItemId aItemId) + { + if (aExpectedEventType != aEventType) + { + _LIT(KError,"Thread %d received an unexpected eventtype. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aThreadIndex, aExpectedEventType, aEventType); + LogError(error); + } + if (aExpectedItemId != aItemId) + { + _LIT(KError,"Thread %d received an unexpected item id. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aThreadIndex, aExpectedItemId, aItemId); + LogError(error); + } + } + +// ----------------------------------------------------------------------------- +// CEventObserver::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CEventObserver* CEventObserver::NewL(CPosTp31* aTp31, TInt aThreadIndex) + { + CEventObserver* self = new(ELeave) CEventObserver(aTp31, aThreadIndex); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CEventObserver::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CEventObserver::ConstructL() + { + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iPeriodicTimer = CPeriodic::NewL(EPriorityNormal); + } + +// C++ Constructor +CEventObserver::CEventObserver(CPosTp31* aTp31, TInt aThreadIndex) : + CActive(EPriorityNormal), + iTp31(aTp31), + iThreadIndex(aThreadIndex), + iCallback(TimeoutCheck, this) + { + CActiveScheduler::Add(this); + } + +// C++ destructor +CEventObserver::~CEventObserver() + { + Cancel(); + delete iDatabase; + iDatabase = NULL; + if (iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + } + delete iPeriodicTimer; + iPeriodicTimer = NULL; + } + +// --------------------------------------------------------- +// CEventObserver::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserver::Start() + { + + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + + SetActive(); + } + +//--------------------------------------------------------- +// CEventObserver::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserver::DoCancel() + { + iDatabase->CancelNotifyDatabaseEvent(); + } + +//--------------------------------------------------------- +// CEventObserver::StartTimer +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserver::StartTimer() + { + iPeriodicTimer->Start(10000000, 10000000, TCallBack(TimeoutCheck, this)); + } + +//--------------------------------------------------------- +// CPosEventObserver::TimeoutCheck +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CEventObserver::TimeoutCheck(TAny* aSelf) + { + CEventObserver* self = reinterpret_cast(aSelf); + + + if ((self->iEventNumber == KNoEvents && self->iThreadIndex != KCancelledThreadIndex) || + (self->iEventNumber == KNoEvents && self->iThreadIndex == KCancelledThreadIndex)) + { + self->iPeriodicTimer->Cancel(); + self->Cancel(); + + CActiveScheduler::Stop(); + } + else if (self->iEventNumber != KNoEvents) + { + _LIT(KError,"Incorrect number of events received by Thread %d, events received %d \r\n"); + TBuf<200> error; + error.Format(KError, self->iThreadIndex, self->iEventNumber); + self->iTp31->LogError(error); + + self->iPeriodicTimer->Cancel(); + self->Cancel(); + CActiveScheduler::Stop(); + } + + return 0; + } + +// --------------------------------------------------------- +// CPosEventObserver::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserver::RunL() + { + iEventNumber++; + + if (!(iEventNumber == KNoEvents && iThreadIndex == KCancelledThreadIndex)) + { + if (iStatus != KErrNone) + { + iTp31->LogError(_L("Unexpected status in RunL")); + } + } + switch (iEventNumber) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + iTp31->CheckEvent(iThreadIndex, + EPosLmEventLandmarkCreated, + iEvent.iEventType, + iEventNumber, + iEvent.iLandmarkItemId); + break; + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + iTp31->CheckEvent(iThreadIndex, + EPosLmEventCategoryCreated, + iEvent.iEventType, + (iEventNumber-KNoLandmarks), + iEvent.iLandmarkItemId); + break; + case 21: + case 24: + case 25: + + iTp31->CheckEvent(iThreadIndex, + EPosLmEventLandmarkUnknownChanges, + iEvent.iEventType, + 0, + iEvent.iLandmarkItemId); + break; + case 22: + iTp31->CheckEvent(iThreadIndex, + EPosLmEventCategoryDeleted, + iEvent.iEventType, + 1, + iEvent.iLandmarkItemId); + break; + case 23: + iTp31->CheckEvent(iThreadIndex, + EPosLmEventCategoryUnknownChanges, + iEvent.iEventType, + 0, + iEvent.iLandmarkItemId); + break; + case 26: + if (iThreadIndex == KCancelledThreadIndex) + { + if (iStatus != KErrCancel) + { + iTp31->LogError(_L("Unexpected status when cancelled")); + } + } + else + { + iTp31->CheckEvent(iThreadIndex, + EPosLmEventLandmarkUnknownChanges, + iEvent.iEventType, + 0, + iEvent.iLandmarkItemId); + } + break; + default: + iTp31->LogError(_L("Unexpected event received")); + iPeriodicTimer->Cancel(); + Cancel(); + CActiveScheduler::Stop(); + break; + } + + + if (iEventNumber == KNoEvents-1 && iThreadIndex == KCancelledThreadIndex) + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + iDatabase->CancelNotifyDatabaseEvent(); + + SetActive(); + } + else if(!(iEventNumber == KNoEvents && iThreadIndex == KCancelledThreadIndex)) + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp33.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp33.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,564 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp33.h" +#include +#include + +//EPosLmServer +_LIT(KPosLandmarksServerName, "*eposlmserver*"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp33::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp33 - LM Server shutdown"); + aName = KTestName; + } + +void CPosTp33::CloseTest() + { + delete iLmd1; + iLmd1 = NULL; + delete iLmd2; + iLmd2 = NULL; + for (TInt i=0; iIsInitializingNeeded()) + { + iLog -> Put(_L("Doing InitializeL()")); + ExecuteAndDeleteLD(iLmd1->InitializeL()); + } + + MonitorHeapL(ETrue); + + alive = ServerAlive(KPosLandmarksServerName); + if(!alive) LogErrorAndLeave(_L("Server not alive")); + + iLmd2 = CPosLandmarkDatabase::OpenL(); + + alive = ServerAlive(KPosLandmarksServerName); + if(!alive) LogErrorAndLeave(_L("Server not alive")); + + delete iLmd1; + iLmd1 = NULL; + User::After(4000000); //just to make sure that timing does not matter + + alive = ServerAlive(KPosLandmarksServerName); + if(!alive) LogErrorAndLeave(_L("Server not alive")); + + delete iLmd2; + iLmd2 = NULL; + User::After(4000000); + + alive = ServerAlive(KPosLandmarksServerName); + if(alive) LogErrorAndLeave(_L("Server alive")); + + //stress test below + StressTestL(); + + //thread test to verify that heap does not grow when threads are killed. + ThreadTestL(); + } + +// --------------------------------------------------------- +// CPosTp33::StressTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::StressTestL() + { + iLog -> Put(_L("StressTestL() -->")); + for(TInt i = 0; i < 50; i++) + { + iLmd1 = CPosLandmarkDatabase::OpenL(); + iLmd2 = CPosLandmarkDatabase::OpenL(); + delete iLmd1; + iLmd1 = NULL; + delete iLmd2; + iLmd2 = NULL; + } + // MonitorHeapL(); + MonitorHeapL(ETrue); + TBool alive = ServerAlive(KPosLandmarksServerName); + if(!alive) LogErrorAndLeave(_L("Server not alive in StressTestL")); + + User::After(4000000); + + alive = ServerAlive(KPosLandmarksServerName); + if(alive) LogErrorAndLeave(_L("Server alive in StressTestL")); + iLog -> Put(_L("StressTestL() <--")); + } +// --------------------------------------------------------- +// CPosTp33::ListAllServers +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::ListAllServers(const TDesC& aServerName) + { + TFindServer find(aServerName); + TFullName name; + + //TraceL(_L("ListAllServers"), aTraceFile); + + iLog->Put(_L("ListAllServers")); + + while (find.Next(name) == KErrNone) + { + //iLog->Put(name); + //TraceL(name, aTraceFile); + iLog->Put(name); + + } + //TraceL(_L("--------------------"), aTraceFile); + iLog->Put(_L("--------------------")); + } + +// --------------------------------------------------------- +// CPosTp33::ListAllProcesses +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::ListAllProcesses(const TDesC& aProcessName) + { + TFindProcess find(aProcessName); + TFullName name; + + iLog->Put(_L("ListAllProcesses")); + //TraceL(_L("ListAllProcesses"), aTraceFile); + + while (find.Next(name) == KErrNone) + { + //iLog->Put(name); + //TraceL(name, aTraceFile); + iLog->Put(name); + } + //TraceL(_L("--------------------"), aTraceFile); + iLog->Put(_L("--------------------")); + } + +// --------------------------------------------------------- +// CPosTp33::ListAllThreads +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::ListAllThreads(const TDesC& aThreadName) + { + TFindThread find(aThreadName); + TFullName name; + + iLog->Put(_L("ListAllThreads")); + //TraceL(_L("ListAllThreads"), aTraceFile); + while (find.Next(name) == KErrNone) + { + //TraceL(name, aTraceFile); + iLog->Put(name); + } + //TraceL(_L("--------------------"), aTraceFile); + iLog->Put(_L("--------------------")); + } + +// --------------------------------------------------------- +// CPosTp33::KillTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::KillTestL() + { + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + TFullName targetName; + + #ifndef __WINS__ + TFindProcess finderLMSERV(KPosLandmarksServerName); + RProcess process_or_thread_lmserv; + #else + TFindThread finderLMSERV(KPosLandmarksServerName); + RThread process_or_thread_lmserv; + #endif + + if (finderLMSERV.Next(targetName) == KErrNone) + { + process_or_thread_lmserv.Open(finderLMSERV); + process_or_thread_lmserv.Kill(KErrGeneral); + process_or_thread_lmserv.Close(); + } + + if (ServerAlive(KPosLandmarksServerName)) + { + LogErrorAndLeave(_L("Server alive, error in TC!")); + } + + CPosLandmark* landmark = CPosLandmark::NewLC(); + + landmark->SetLandmarkNameL(_L("TP33")); + + TRAPD(err, lmd->AddLandmarkL(*landmark)); + if (err != KErrServerTerminated) + { + LogErrorAndLeave(_L("AddLanmdark does not Leave with -15 after the server has been killed")); + } + + TRAP(err, lmd->UpdateLandmarkL(*landmark)); + if (err != KErrServerTerminated) + { + LogErrorAndLeave(_L("UpdateLandmark does not Leave with -15 after the server has been killed")); + } + + CleanupStack::PopAndDestroy(2, lmd); + } + +// --------------------------------------------------------- +// CPosTp33::MonitorHeapL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::MonitorHeapL(TBool aMaxSet) + { + iLog->Put(_L("MonitorHeapL")); + TInt landmarkHeap=0, landmarkHeapUsed=0; + + TBuf<150> buf; + TInt err = GetHeapSizeL(KPosLandmarksServerName, landmarkHeap, landmarkHeapUsed); + if (err != KErrNone) + { + buf.Zero(); + buf.Format(_L("GetHeapSizeL for Landmark server returned error, err %d"), err); + iLog->Put(buf); + } + if (aMaxSet) + { + iMaxHeap = 2*landmarkHeapUsed; + } + else + { + if(landmarkHeapUsed > iMaxHeap) + { + LogErrorAndLeave(_L("Used heap to large")); + } + } + + buf.Zero(); + buf.Format(_L("Landmark Heap; %d Landmark Heap Used: %d"), landmarkHeap, landmarkHeapUsed); + iLog->Put(buf); + } + + +// --------------------------------------------------------- +// CPosTp33::GetHeapSizeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp33::GetHeapSizeL(const TDesC& aThreadName, TInt& aSize, TInt& aUsed) + { + RThread thread; + TFindThread findThread(aThreadName); + + TFullName fullName; + + if (findThread.Next(fullName) != KErrNone) + { + iLog->Put(_L("Thread not found")); + aSize=-1;aUsed=-1; + return KErrNotFound; + } + + TInt err = thread.Open(fullName); + + if (err != KErrNone) + { + iLog->Put(_L("Thread could not be opened")); + aSize=-1;aUsed=-1; + return err; + } + CleanupClosePushL(thread); + + //TInt tmp; + +#ifndef __WINS__ +// For some reason cannot access heap in target +// thread.GetRamSizes(aSize,tmp); +// aUsed = aSize; + + // FrBo Commented since not supported on ARMV5 (on SDK Series60_30_2005_wk02_incl_LBSpre4) + //thread.GetRamSizes(aSize, aUsed); + // Use below for now + aSize=-1;aUsed=-1; + + TThreadStackInfo stackInfo; + thread.StackInfo(stackInfo); + + aSize = stackInfo.iBase - stackInfo.iLimit; + aUsed = aSize; + +#else + + // FrBo Commented since not supported on WINSCW (on SDK Series60_30_2005_wk04_Mars) + // Use below for now + aSize=-1;aUsed=-1; + + TThreadStackInfo stackInfo; + thread.StackInfo(stackInfo); + + aSize = stackInfo.iBase - stackInfo.iLimit; + aUsed = aSize; + + /* + // In WINS we can get both the size of the heap, and amount + // of bytes actually used. This method Panics on ARMI + RHeap* heap = NULL; + heap = thread.Heap(); + if (heap == NULL) + { + iLog->Put(_L("Could not open heap.")); + aSize=-1;aUsed=-1; + return KErrGeneral; + LogErrorAndLeave(_L("Could not open heap.")); + } + TInt tmp; + aSize = heap->Size(); + aUsed = heap->Size() - (heap->Available(tmp)); + */ + +#endif + CleanupStack::PopAndDestroy(&thread); // thread + return KErrNone; + } + + +void CPosTp33::ThreadTestL() + { + iLog -> Put(_L("ThreadTestL() -->")); + StartMultipleClientsL(5); + MonitorHeapL(); + User::After(4000000); + TBool alive = ServerAlive(KPosLandmarksServerName); + if(alive) LogErrorAndLeave(_L("Server alive")); + iLog -> Put(_L("ThreadTestL() <--")); + } + +// --------------------------------------------------------- +// ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp33::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +void CPosTp33::StartMultipleClientsL(const TUint aNoClients) + { + _LIT(KMultipleErr, "Error %d from client %d when multiple clients access the landmarks db"); + _LIT(KPanicErr, "Thread exit with incorrect code"); + + CreateThreadsL(aNoClients); + + RArray statuses; + CleanupClosePushL(statuses); + + for (TUint j=0; j Put(_L("Checking Thread")); + TInt exitReason = iThreads[i].ExitReason(); + + //AssertTrueSecL(exitReason == KErrNone || exitReason == KErrNotFound, KMultipleErr, exitReason); + if (exitReason != KErrNone && exitReason != KErrNotFound) + { + TBuf<100> buf; + buf.Format(KMultipleErr, exitReason, i); + iLog->Put(buf); + errrorsFound++; + } + +#ifndef __WINS__ + AssertTrueSecL(iThreads[i].ExitType() == EExitPanic, KPanicErr); //does not currently work use exit on wins instead +#else + AssertTrueSecL(iThreads[i].ExitType() == EExitKill, KPanicErr); +#endif + } + for (i=0; i name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + + +// --------------------------------------------------------- +// CPosTp30::RunTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp33::RunTestL(TAny* /*aData*/) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + TRequestStatus status; + TPosLmEvent event; + lmd->NotifyDatabaseEvent(event, status); + + //XXX fix this when dialogs works again +#ifndef __WINS__ + User::Panic(_L("Panic before cleanup"),-1); //does not currently work use exit on wins instead +#else + User::Exit(-1); +#endif + + lmd->CancelNotifyDatabaseEvent(); + CleanupStack::PopAndDestroy(2, lmd); + + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp34.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp34.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp34.h" +#include + +//#include "FT_CSearchResult.h" +//#include "FT_CActiveSearch.h" +#include +#include +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp34::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp34::GetName(TDes& aName) const + { + _LIT(KTestName, "TP34 - Multiple async operations"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp34::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp34::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp34::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp34::StartL() + { + _LIT(KInUseErr, "search is already running, StartLandmarksSearch should leave with error code KErrInUse"); + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog);//1 + CleanupStack::PushL(activeLmOperation); + + AppendSearchResultsL(); + + const TInt KSearchResultIndex1=1; + const TInt KSearchResultIndex2=10; + + CPosLmTextCriteria* textCriteria1 = CPosLmTextCriteria::NewLC(); //2 + textCriteria1->SetTextL(iSearchResults[KSearchResultIndex1]->TextCriteria()); + textCriteria1->SetAttributesToSearch(iSearchResults[KSearchResultIndex1]->Attributes()); + + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); //3 + textCriteria2->SetTextL(iSearchResults[KSearchResultIndex2]->TextCriteria()); + textCriteria2->SetAttributesToSearch(iSearchResults[KSearchResultIndex2]->Attributes()); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria1); + activeLmOperation->Start(iOperation); + + TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*textCriteria2)); + AssertTrueSecL(err == KErrInUse, KInUseErr); + + CActiveLmOperation* activeLmOperation2 = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation2); //4 + + /// + CPosLandmarkSearch* landmarkSearch2 = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(landmarkSearch2); //5 + + CPosLmOperation* lmo = landmarkSearch2->StartLandmarkSearchL(*textCriteria2); + CleanupStack::PushL(lmo); //6 + + activeLmOperation2->Start(lmo); + + CActiveScheduler::Start(); + + CActiveScheduler::Start(); + + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + + activeLmOperation2->CheckOperationL(); + + CheckSearchResultL(*iSearchResults[KSearchResultIndex1], *iLandmarkSearch, *textCriteria1); + + CheckSearchResultL(*iSearchResults[KSearchResultIndex2], *landmarkSearch2, *textCriteria2); + + //CleanupStack::PopAndDestroy(5, activeSearch); + CleanupStack::PopAndDestroy(6, activeLmOperation); + + } + +// --------------------------------------------------------- +// CPosTp34::CheckSearchResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp34::CheckSearchResultL(CSearchResult& aSearchResult, + CPosLandmarkSearch& aLandmarkSearch, + CPosLmTextCriteria& aTextCriteria) + { + _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + if ((TUint)(aSearchResult.SearchResult()).Count() != aLandmarkSearch.NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, (aSearchResult.SearchResult()).Count()); + iLog->Put(info); + info.Format(KReturned, aLandmarkSearch.NumOfMatches()); + iLog->Put(info); + iLog->Put(_L("Search criteria: ")); + iLog->Put(aTextCriteria.Text()); + LogErrorAndLeave(KNumOfMatchesErr); + } + CPosLmItemIterator* iter = aLandmarkSearch.MatchIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + AssertTrueSecL(aSearchResult.FindSearchResult(id), KNotFoundErr, id); + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(iter); + + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp35.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp35.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,903 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp35.h" +#include +#include +#include + +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KMaxFieldLength = 80; +const TInt KDistanceFieldLength = 24; +const TInt KMaxNearestLineLength = 1024; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp35::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp35::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase = NULL; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iNearestSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp35::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp35::StartL() + { + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + iDatabase = UseNearestSearchGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + AppendNearestSearchResultsL(); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + iLog->Log(_L("Testing search with criterias read from LmDbNearestResult.txt syncronously")); + SearchL(); + + iLog->Log(_L("Testing search with criterias read from LmDbNearestResult.txt asyncronously")); + SearchL(ETrue); + + iLog->Log(_L("Testing search and cancel")); + SearchAndCancelL(); + + iLog->Log(_L("Testing search and cancel in callback")); + SearchAndCancelL(ETrue); + + iLog->Log(_L("Testing search with a sortorder")); + SearchWithSortOrderL(); + + iLog->Log(_L("Testing error codes")); + _LIT(KStartCatErr, "StartCategorySearch should leave with KErrArgument with nearest criteria"); + _LIT(KNaNErr, "Max distance should be NaN by default"); + + TCoordinate coord(12, 13); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord); + AssertTrueSecL(Math::IsNaN(nearestCriteria->MaxDistance()), KNaNErr); + + TRAPD(err, iLandmarkSearch->StartCategorySearchL(*nearestCriteria, CPosLmCategoryManager::ECategorySortOrderNone)); + AssertTrueSecL(err == KErrArgument, KStartCatErr); + + CleanupStack::PopAndDestroy(nearestCriteria); + + TCoordinate pos(55, 18); + nearestCriteria = CPosLmNearestCriteria::NewLC(pos, ETrue); + nearestCriteria->SetMaxDistance(1); + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL(*nearestCriteria, EFalse)); + + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + + CleanupStack::PopAndDestroy(nearestCriteria); + + nearestCriteria = CPosLmNearestCriteria::NewLC(pos, ETrue); + nearestCriteria->SetMaxDistance(300); + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL(*nearestCriteria, EFalse)); + + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + CleanupStack::PopAndDestroy(nearestCriteria); + + } + +// --------------------------------------------------------- +// CPosTp35::UseNearestSearchGeneratedDbFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp35::UseNearestSearchGeneratedDbFileL() + { + _LIT(KDbFile, "eposlmnearestsearch.ldb"); + CopyTestDbFileL(KDbFile); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + // This db must exist + manager->SetDefaultDatabaseUriL(KDbFile); + CleanupStack::PopAndDestroy(manager); + + return CPosLandmarkDatabase::OpenL(KDbFile); + } + +// --------------------------------------------------------- +// CPosTp35::SearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp35::SearchL(const TBool& aSync) + { + + for(TInt i=0; iiLatitude, iNearestSearchResults[i]->iLongitude); + iLog->Log(_L("SearchL")); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, iNearestSearchResults[i]->iUseCoverageRadius); + nearestCriteria->SetMaxDistance(iNearestSearchResults[i]->iMaxDistance); + + TBuf<100> pelle; + pelle.Format(_L("StartSearchOperationL: Searching for Lat %f Long %f"), iNearestSearchResults[i]->iLatitude, iNearestSearchResults[i]->iLongitude); + iLog->Log(pelle); + + if (iNearestSearchResults[i]->iMaxSearchResult > 0) + { + iLandmarkSearch->SetMaxNumOfMatches(iNearestSearchResults[i]->iMaxSearchResult); + } + else + { + iLandmarkSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + } + + if (aSync) + { + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL(*nearestCriteria, iNearestSearchResults[i]->Redefined())); + } + else + { + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*nearestCriteria, iNearestSearchResults[i]->Redefined())); + } + + if (iNearestSearchResults[i]->Redefined() && i > 0) + { + iLog->Log(_L("Redefined")); + + for (TInt j=0; jiDistances.Count(); j++) + { + TBool found = EFalse; + TInt id = 0; + TPosLmItemId idde; + + id = j; + idde = iNearestSearchResults[i]->iDistances[j].Id(); + + TBuf<100> debug; + debug.Format(_L("Looking for id %d or id: %d "), idde, id); + //iLog->Log(debug); + + for (TInt p=0;piDistances.Count();p++) + { + + if (iNearestSearchResults[i]->iDistances[j].Id() == iNearestSearchResults[i-1]->iDistances[p].Id()) + { + found = ETrue; + TBuf<100> buf; + buf.Format(_L("Found id %d or id: %d "), idde, id); + //iLog->Log(buf); + } + } + if (!found) + { + // Remove since not found, only keep ids that was found in previous search + TBuf<100> buf; + buf.Format(_L("Removing lm Id %d from index %d"), idde, id); + //iLog->Log(buf); + iNearestSearchResults[i]->iDistances.Remove(id); + //iLog->Log(_L("Removing Done")); + j--; + } + //iLog->Log(_L("***********")); + } + + + } + + CheckSearchResultL(*iNearestSearchResults[i]); + + CleanupStack::PopAndDestroy(nearestCriteria); + } + } + +// --------------------------------------------------------- +// CPosTp35::CheckSearchResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +//void CPosTp35::CheckSearchResultL(CNearestSearchResult& aSearchResult) +void CPosTp35::CheckSearchResultL(CNearestSearchResultTp35& aSearchResult) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + + TUint expectedNoMatches = aSearchResult.iDistances.Count(); + if (aSearchResult.iMaxSearchResult != 0 && aSearchResult.iMaxSearchResult < aSearchResult.iDistances.Count()) + { + expectedNoMatches = aSearchResult.iMaxSearchResult; + } + + if (expectedNoMatches != iLandmarkSearch->NumOfMatches()) + { + _LIT(KExpected, "Expected no. of matches: %d"); + _LIT(KReturned, "Returned no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, expectedNoMatches); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TInt index=0; + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + if (aSearchResult.iDistances[index].iId != id) + { + // if the distance is equal to the distance to the landmark + // before or after then no error. + // This to be able to use a databse with landmarks with the same position. + + TBool noError=EFalse; + if (index > 0) + { + noError = (aSearchResult.iDistances[index-1].iDistance == aSearchResult.iDistances[index].iDistance); + } + if (index < aSearchResult.iDistances.Count() && !noError) + { + noError = (aSearchResult.iDistances[index+1].iDistance == aSearchResult.iDistances[index].iDistance); + } + if (!noError) + { + _LIT(KUnexpectedItemId, "Unexpected item id"); + _LIT(KExpected, "Expected item id: %d"); + _LIT(KReturned, "Returned item id: %d"); + TBuf<100> info; + info.Format(KExpected, aSearchResult.iDistances[index].iId); + iLog->Log(info); + info.Format(KReturned, id); + iLog->Log(info); + + TBuf<800> info2; + aSearchResult.Print(info2); + iLog->Log(info2); + + + iLog->Log(KUnexpectedItemId); + User::Leave(-1); + + } + } + _LIT(KReturned, "Returned id: %d or id: %d"); + TBuf<100> info; + info.Format(KReturned, aSearchResult.iDistances[index].iId, id); + //iLog->Log(info); + + id = iter->NextL(); + index++; + } + + CleanupStack::PopAndDestroy(iter); + + } + +// --------------------------------------------------------- +// CPosTp35::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp35::SearchAndCancelL(const TBool& aInCallback) + { + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); + + // Test search with one criteria + const TInt KIndex=0; + + TCoordinate coord(iNearestSearchResults[KIndex]->iLatitude, iNearestSearchResults[KIndex]->iLongitude); + + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, iNearestSearchResults[KIndex]->iUseCoverageRadius); + + iLandmarkSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + iNearestSearchResults[KIndex]->Redefined())); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + iNearestSearchResults[KIndex]->Redefined())); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + if (iter->NumOfItemsL() != iLandmarkSearch->NumOfMatches()) + { + iLog->Log(_L("Iterators no. of items is not equal to LandmarksSearch no. matches")); + _LIT(KExpected, "Iter. of matches: %d"); + _LIT(KReturned, "LandmarksSearch no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, iter->NumOfItemsL()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + + iLog->Log(KNumOfMatchesErr); + User::Leave(-1); + + } + + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancelled the operation = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + // FrBo: No longer sure that result is returned when cancelling + //AssertTrueSecL(iter->NumOfItemsL() != 0, KCancelErr); + } + + CleanupStack::PopAndDestroy(2, nearestCriteria); + + } + +// --------------------------------------------------------- +// CPosTp35::SearchWithSortOrderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp35::SearchWithSortOrderL() + { + // Only verifies that search does not fail when only landmarks with no name in the db + + _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed with a sortorder"); + + // Test search with one criteria which return all landmarks in db + const TInt KIndex=0; + + TCoordinate coord(iNearestSearchResults[KIndex]->iLatitude, iNearestSearchResults[KIndex]->iLongitude); + + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, iNearestSearchResults[KIndex]->iUseCoverageRadius); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + iLandmarkSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); + + for (TInt i=0; i<4; i++) + { + if(i==0) + { + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + sortPref, + iNearestSearchResults[KIndex]->Redefined())); + } + else if (i==1) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + sortPref, + iNearestSearchResults[KIndex]->Redefined())); + } + //**** async + else if (i==2) + { + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + sortPref, + iNearestSearchResults[KIndex]->Redefined())); + } + else if (i==3) + { + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + RunAsyncOperationLD(iLandmarkSearch->StartLandmarkSearchL( + *nearestCriteria, + sortPref, + iNearestSearchResults[KIndex]->Redefined())); + } + AssertTrueSecL((TUint)iNearestSearchResults[KIndex]->iDistances.Count()== iLandmarkSearch->NumOfMatches(), KNumOfMatchesErr); + } + + CleanupStack::PopAndDestroy(nearestCriteria); + } + +// --------------------------------------------------------- +// CPosTp35::AppendAreaSearchResultsL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp35::AppendNearestSearchResultsL() + { + iNearestSearchResults.ResetAndDestroy(); + + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\lmDbNearestSearchResult.txt"); + + RFile file; + CleanupClosePushL(file); + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + + TInt row=0; + TBuf line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#' && lex.Peek() != '\t') + { + ++row; + //CNearestSearchResult* searchResult = CNearestSearchResult::NewL(line, row); + CNearestSearchResultTp35* searchResult = CNearestSearchResultTp35::NewL(line, row, iFileSession); + CleanupStack::PushL(searchResult); + + User::LeaveIfError(iNearestSearchResults.Append(searchResult)); + CleanupStack::Pop(searchResult); + + } + } + CleanupStack::PopAndDestroy(&file); + } + +// --------------------------------------------------------- +// CNearestSearchResult::NewL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +//CNearestSearchResult* CNearestSearchResult::NewL(const TDesC& aDes, const TInt& aIndex) +CNearestSearchResultTp35* CNearestSearchResultTp35::NewL( + const TDesC& aDes, + const TInt& aIndex, + RFs& aFileSession) + { + CNearestSearchResultTp35* self = new(ELeave) CNearestSearchResultTp35( aFileSession ); + CleanupStack::PushL(self); + self->ConstructL(aDes, aIndex); + CleanupStack::Pop(); + return self; + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// + +CNearestSearchResultTp35::CNearestSearchResultTp35(RFs& aFileSession) +: iFileSession( aFileSession ) + { + TRealX nan; + nan.SetNaN(); + iMaxDistance = nan; + } + +// --------------------------------------------------------- +// CNearestSearchResult::CounstructL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResultTp35::ConstructL(const TDesC& aDes, const TInt& aIndex) + { + iDatabase = CPosLandmarkDatabase::OpenL(); + + TLex line(aDes); + line.Mark(); + TInt redefined=0, useCoverageRadius; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ELatitude: + val.Val(iLatitude, TChar(',')); + break; + case ELongitude: + val.Val(iLongitude, TChar(',')); + break; + case EUseCoverageRadius: + val.Val(useCoverageRadius); + if (useCoverageRadius == 1) + { + iUseCoverageRadius = ETrue; + } + break; + case EMaxDistance: + val.Val(iMaxDistance); + break; + case EErrorCode: + val.Val(iErrorCode); + break; + case ESearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + case EMaxSearchResult: + val.Val(iMaxSearchResult); + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + AppendDistancesL(aIndex); + + } + } + + +// Destructor + +CNearestSearchResultTp35::~CNearestSearchResultTp35() + { + iDistances.Close(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CNearestSearchResult::AppendDistancesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResultTp35::AppendDistancesL(const TInt& aIndex) + { + iDistances.Reset(); + + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\lmDbNearestSearch.txt"); + + RFile file; + CleanupClosePushL(file); + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + + TInt row=0; + TBuf line; + while (CLandmarkTestProcedureBase::ReadLn(file, line) != KErrEof) + { + ParseDistanceL(line, aIndex, row); + ++row; + } + + SortDistances(); + + CleanupStack::PopAndDestroy(&file); + } + +// --------------------------------------------------------- +// CNearestSearchResult::ParseDistancesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CNearestSearchResultTp35::ParseDistanceL(const TDesC& aDes, + const TInt& aIndex, + const TPosLmItemId& aId) + { + + const TInt KStartIndex = 5; + + TLex line(aDes); + line.Mark(); + TInt index = 0; + TReal64 dist=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t' || line.Peek() == '\n' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + + if (index == (KStartIndex + aIndex)) + { + TLex val(token); + val.Val(dist, TChar(',')); + + if (iUseCoverageRadius) + { + CPosLandmark* lm = iDatabase->ReadLandmarkLC(aId); + + TReal32 aCoverageRadius; + if (lm->GetCoverageRadius(aCoverageRadius) == KErrNone) + { + dist -= aCoverageRadius; + if (dist < 0) + { + dist = 0; + } + } + CleanupStack::PopAndDestroy(lm); + } + + if (Math::IsNaN(iMaxDistance) || dist <= iMaxDistance) + { + if (dist != -1) + { + TSearchResultTp35 searchResult(aId, TReal32(dist)); + iDistances.Append(searchResult); + } + } + + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + } +// --------------------------------------------------------- +// CNearestSearchResult::Latitude +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +//TReal64 CNearestSearchResult::Latitude() const +TReal64 CNearestSearchResultTp35::Latitude() const + { + return iLatitude; + } + +// --------------------------------------------------------- +// CNearestSearchResult::Latitude +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +//TReal64 CNearestSearchResult::Longitude() const +TReal64 CNearestSearchResultTp35::Longitude() const + { + return iLongitude; + } + +// --------------------------------------------------------- +// CNearestSearchResult::UseCoverageRadius +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +//TBool CNearestSearchResult::UseCoverageRadius() const +TBool CNearestSearchResultTp35::UseCoverageRadius() const + { + return iUseCoverageRadius; + } + +// --------------------------------------------------------- +// CNearestSearchResult::MaxDistance +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + +TReal32 CNearestSearchResultTp35::MaxDistance() const + { + return iMaxDistance; + } + +// --------------------------------------------------------- +// CNearestSearchResult::ErrorCode +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +//TInt CNearestSearchResult::ErrorCode() const +TInt CNearestSearchResultTp35::ErrorCode() const + { + return iErrorCode; + } + +// --------------------------------------------------------- +// InternalLandmarksSortL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt InternalSort(const TSearchResultTp35& aSource, const TSearchResultTp35& aTarget) + { + // zero, if the two objects are equal + // a negative value, if the first object is less than the second. + // a positive value, if the first object is greater than the second. + + if ( aSource.Distance() == aTarget.Distance()) + { + return 0; + } + else if (aSource.Distance() < aTarget.Distance()) + { + return -1; + } + + return 1; + } + +// --------------------------------------------------------- +// CNearestSearchResult::ErrorCode +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResultTp35::SortDistances() + { + TLinearOrder order(InternalSort); + iDistances.Sort(order); + } + +// --------------------------------------------------------- +// CNearestSearchResult::Print +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResultTp35::Print(TDes& aPrint) + { + _LIT(KPosInfo, "Latitude=%g, Longitude=%g"); + TChar del(','); + + TBuf info; + info.Format(KPosInfo, iLatitude, iLongitude); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KUseCoverageRadius, "UseCoverageRadius=%d"); + info.Format(KUseCoverageRadius, iUseCoverageRadius); + aPrint.Append(info); + aPrint.Append(del); + + if (!Math::IsNaN(iMaxDistance)) + { + _LIT(KMaxDistance, "MaxDistance=%g"); + info.Format(KMaxDistance, iMaxDistance); + aPrint.Append(info); + aPrint.Append(del); + } + + _LIT(KErrorCode, "ErrorCode = %d"); + info.Format(KErrorCode, iErrorCode); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KRedefined, "Redefined=%d"); + info.Format(KRedefined, iRedefined); + aPrint.Append(info); + aPrint.Append(del); + + _LIT(KMaxSearchResult, "MaxSearchResult=%d"); + info.Format(KMaxSearchResult, iMaxSearchResult); + aPrint.Append(info); + aPrint.Append(del); + + PrintDistances(aPrint); + } + +// --------------------------------------------------------- +// CNearestSearchResult::PrintDistances +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CNearestSearchResultTp35::PrintDistances(TDes& aPrint) + { + TBuf info2; + TChar del(':'); + aPrint.Append(_L("Distances: ")); + + for (TInt j=0; j +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp36::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp36::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iArray.Close(); + } + +// --------------------------------------------------------- +// CPosTp36::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp36::StartL() + { + TTime startTime; + TTime stopTime; + + startTime.UniversalTime(); + + // Delete "c:\\system\\data\\eposlm.ldb" + RemoveDefaultDbL(); + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // we should not find any uncategorized landmarks since every landmark in the db + // belongs to a category + iLog->Log(_L("Searching async")); + DoTestL(ETrue, 0, 0); + DoTestL(ETrue, 1, 0); + DoTestL(ETrue, 2, 0); + DoTestL(ETrue, 3, 0); + + iLog->Log(_L("Searching sync")); + DoTestL(EFalse, 0, 0); + DoTestL(EFalse, 1, 0); + DoTestL(EFalse, 2, 0); + DoTestL(EFalse, 3, 0); + + iLog->Log(_L("Should leave with KErrArgument")); + TRAPD(err, DoSearchForCategoryL(ETrue)); + if (err != KErrArgument) + { + iLog->Log(_L("Should leave with KErrArgument")); + User::Leave(err); + } + else iLog->Log(_L("Function correctly leaved with KErrArgument")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("Should leave with KErrArgument")); + TRAP(err, DoSearchForCategoryL(EFalse)); + if (err != KErrArgument) + { + iLog->Log(_L("Should leave with KErrArgument")); + User::Leave(err); + + } + else iLog->Log(_L("Function correctly leaved with KErrArgument")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + TInt maxNr = GetNrOfLandmarksL(); + + TBuf<100> buf; + buf.Format(_L("Nr of landmarks: %d"), maxNr); + iLog->Log(buf); + + // Remove categories from some landmarks + RemoveCategoriesFromLandmarksL(5); + // Check that correct number of uncategorized landmarks are found + DoTestL(EFalse, 0, 5); + DoTestL(EFalse, 1, 5); + DoTestL(EFalse, 2, 5); + DoTestL(EFalse, 3, 5); + // Remove categories from some landmarks + RemoveCategoriesFromLandmarksL(6); + // Check that correct number of uncategorized landmarks are found + DoTestL(EFalse, 0, 11); + DoTestL(EFalse, 1, 11); + DoTestL(EFalse, 2, 11); + DoTestL(EFalse, 3, 11); + + // Remove categories from some landmarks + RemoveCategoriesFromLandmarksL(43); + // Check that correct number of uncategorized landmarks are found + DoTestL(EFalse, 0, 54); + DoTestL(EFalse, 1, 54); + DoTestL(EFalse, 2, 54); + DoTestL(EFalse, 3, 54); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + delete iDatabase; + iDatabase=NULL; + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + buf.Zero(); + buf.Format(_L("TP36 took %d seconds"), resse); + iLog->Log(buf); + } + +// --------------------------------------------------------- +// CPosTp36::DoTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp36::DoTestL(TBool aSync, TInt aTestNr, TInt aNrOfHits) + { + TBuf<150> buf; + buf.Format(_L("DoTestL part: %d"), aTestNr); + iLog->Log(buf); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // Specified in header file EPos_CPosLmCategoryCriteria.h says that + // SetCategoryItemId(KPosLmNullItemId) should return uncategorized landmarks and that + // SetGlobalCategory(KPosLmNullGlobalCategory) should return uncategorized landmarks and that + // SetCategoryNameL(KNullDesC) should return uncategorized landmarks + if (aTestNr == 0) + { + } + else if (aTestNr == 1) + { + catSearchCriteria->SetCategoryItemId(KPosLmNullItemId); + } + else if (aTestNr == 2) + { + catSearchCriteria->SetGlobalCategory(KPosLmNullGlobalCategory); + } + else if (aTestNr == 3) + { + catSearchCriteria->SetCategoryNameL(KNullDesC); + } + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); + + if (aSync) + { + RunAsyncOperationLD(iOperation); + } + else + { + ExecuteAndDeleteLD(iOperation); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TInt nr = iter->NumOfItemsL(); + if (nr != aNrOfHits) + { + buf.Format(_L("Wrong number of landmarks returned when searching for uncategorized landmarks, found: %d should found %d"), nr, aNrOfHits); + + iLog->Log(buf); + User::Leave(-1); + + } + + buf.Format(_L("Found %d nr of landmarks when searching GlobaCategories"), nr); + iLog->Log(buf); + TPosLmItemId id = iter->NextL(); + TInt res = 0; + if (nr != 0) + { + while (id != KPosLmNullItemId) + { + TInt found = iArray.Find(id); + if (found == KErrNotFound) + { + + iLog->Log(_L("Not found")); + } + else + { + res++; + CPosLandmark* landmark = iDatabase->ReadLandmarkLC(id); + CPosLandmark* landmark2 = iDatabase->ReadLandmarkLC(iArray[found]); + + CompareLandmarksL(*landmark, *landmark2); + + CleanupStack::PopAndDestroy(landmark2); + CleanupStack::PopAndDestroy(landmark); + } + id = iter->NextL(); + } + + if (res != nr) + { + + iLog->Log(_L("The correct landmark was never found")); + User::Leave(-1); + + } + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(catSearchCriteria); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp36::DoSearchForCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp36::DoSearchForCategoryL(TBool aSync) + { + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + + // This method should leave + iOperation = iLandmarkSearch->StartCategorySearchL(*catSearchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); + + if (aSync) + { + RunAsyncOperationLD(iOperation); + } + else + { + ExecuteAndDeleteLD(iOperation); + } + + CleanupStack::PopAndDestroy(catSearchCriteria); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp36::RemoveCategoriesFromLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp36::RemoveCategoriesFromLandmarksL(TInt aNrOfLandmarks) + { + // Use this method to remove the category from a specified number of landmarks + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(_L("*")); + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + textCriteria->SetAttributesToSearch(attr); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + TInt counter=0; + + // Remove the category from aNrOfLandmarks nr of landmarks + while ((id != KPosLmNullItemId) && (counter ReadLandmarkLC(id); + + RArray categories; + CleanupClosePushL(categories); + landmark->GetCategoriesL(categories); + TPtrC landmarkName; + landmark->GetLandmarkName(landmarkName); + TBuf<50> buf; + + TInt size = categories.Count(); + if (size != 0) + { + buf.Format(_L("Removing from landmark: ")); + buf.Append(landmarkName); + iLog->Log(buf); + iArray.Append(id); + + for (TInt j=0;jRemoveCategory(categories[j]); + } + iDatabase->UpdateLandmarkL(*landmark); + counter++; + } + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(landmark); + id = iter->NextL(); + if (id == KPosLmNullItemId) iLog->Log(_L("KPosLmNullItemId")); + } + iter->Reset(); + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(textCriteria); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp36::GetNrOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp36::GetNrOfLandmarksL() + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(_L("*")); + TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; + textCriteria->SetAttributesToSearch(attr); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria, EFalse); + ExecuteAndDeleteLD(iOperation); + + TInt nrOfMatches = iLandmarkSearch->NumOfMatches(); + + CleanupStack::PopAndDestroy(textCriteria); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + return nrOfMatches; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp37.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp37.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,541 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp37.h" +#include +#include +#include +#include +#include +#include +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp37::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp37::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::StartL() + { + TTime startTime; + TTime stopTime; + + startTime.UniversalTime(); + // Delete "c:\\system\\data\\eposlm.ldb" + RemoveDefaultDbL(); + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + TInt err = KErrNone; + + TRAP(err, DoErrorTestL(0)); + if (err != KErrArgument) {iLog->Log(_L("Wrong error1"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + TRAP(err, DoErrorTestL(1)); + if (err != KErrNotSupported) {iLog->Log(_L("Wrong error2")); iErrorsFound++;}; + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + TRAP(err, DoErrorTestL(2)); + if (err != KErrNotSupported) {iLog->Log(_L("Wrong error3"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + + TRAP(err, DoErrorTest3L(0)); + if (err != KErrArgument) {iLog->Log(_L("Wrong error5"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + TRAP(err, DoErrorTest3L(1)); + if (err != KErrNotSupported) {iLog->Log(_L("Wrong error6"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + TRAP(err, DoErrorTest3L(2)); + if (err != KErrArgument) {iLog->Log(_L("Wrong error7"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + TRAP(err, DoErrorTest3L(3)); + if (err != KErrNotSupported) {iLog->Log(_L("Wrong error8"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + + TRAP(err, DoErrorTest3L(4)); + if (err != KErrArgument) {iLog->Log(_L("Wrong error9"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + + TRAP(err, DoErrorTest4L(0)); + if (err != KErrArgument) {iLog->Log(_L("Wrong error10"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + + TRAP(err, DoErrorTest4L(1)); + if (err != KErrNotSupported) {iLog->Log(_L("Wrong error11"));iErrorsFound++;} + delete iLandmarkSearch; + iLandmarkSearch = NULL; + err = KErrNone; + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + TBuf<100> buf; + buf.Format(_L("TP37 took %d seconds"), resse); + iLog->Log(buf); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP37")); + User::Leave(-1); + } + + } + +// --------------------------------------------------------- +// CPosTp37::DoErrorTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::DoErrorTestL(TInt aTestNr) + { + TBuf<100> buf; + buf.Format(_L("DoErrorTestL %d"), aTestNr); + iLog->Log(buf); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CPosLmCompositeCriteria::TCompositionType type = composite->CompositionType(); + if (type != CPosLmCompositeCriteria::ECompositionAND) + { + iLog->Log( _L("Error1: Wrong type returned")); + User::Leave(-1); + } + + TInt nr = composite->NumOfArguments(); + if (nr != 0) + { + iLog->Log(_L("Wrong number of arguments returned")); + User::Leave(-1); + + } + + if (aTestNr == 0) + { + // Test that it is not possible to perform a composite search without any search arguments attached to + // the composite object + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + } + else if (aTestNr == 1) + { + // Test that it is not possible to perform a composite search without any search arguments attached to + // the composite object + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + } + else if (aTestNr == 2) + { + // Test that it is not possible to attach a category search attribute to + // a composite object + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + TInt err = composite->AddArgument(nameCriteria); + if (err != KErrNotSupported) + { + iLog->Log(_L("Wrong error when adding CPosLmCatNameCriteria to composite")); + User::Leave(err); + } + User::Leave(KErrNotSupported); + } + + + iLog->Log(_L("Did not leave!!!")); + User::Leave(-1); + + iLog->Log(_L("ClearArguments")); + composite->ClearArguments(); + iLog->Log(_L("PopAndDestroy")); + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp37::DoErrorTest3L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::DoErrorTest3L(TInt aTestNr) + { + TBuf<100> buf; + buf.Format(_L("DoErrorTest3L %d"), aTestNr); + iLog->Log(buf); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + TInt err = KErrNone; + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + if (aTestNr == 0) + { + // add empty ID List + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + err = composite->AddArgument(idList); + CleanupStack::Pop(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + } + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + } + else if (aTestNr == 1) + { + // add empty ID List + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + TInt err = composite->AddArgument(idList); + CleanupStack::Pop(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + + } + + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + + } + else if (aTestNr == 2) + { + // Test with list that contain items + RArray list; + CleanupClosePushL(list); + + list.Append(0); + list.Append(1); + list.Append(2); + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + idList->SetLandmarkIdsL(list); + err = composite->AddArgument(idList); + CleanupStack::Pop(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + } + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + + CleanupStack::PopAndDestroy(&list); + } + else if (aTestNr == 3) + { + // Test with list that contain items + RArray list; + CleanupClosePushL(list); + + list.Append(0); + list.Append(1); + list.Append(2); + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + idList->SetLandmarkIdsL(list); + err = composite->AddArgument(idList); + CleanupStack::Pop(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + } + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + + CleanupStack::PopAndDestroy(&list); + } + else if (aTestNr == 4) + { + // Test with list that contain valid and invalid items + RArray list; + CleanupClosePushL(list); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("")); + + err = composite->AddArgument(textCriteria); + CleanupStack::Pop(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + } + + list.Append(1); + list.Append(2); + list.Append(2000); + list.Append(2001); + + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + idList->SetLandmarkIdsL(list); + err = composite->AddArgument(idList); + CleanupStack::Pop(idList); + CleanupStack::PopAndDestroy(&list); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + } + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + + ExecuteAndDeleteLD(iOperation); + // We should never come here + iLog->Log(_L("Should leave here")); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + CleanupStack::PopAndDestroy(iter); + } + else + { + + iLog->Log(_L("Error in testcode, we should never come here")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp37::DoErrorTest4L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::DoErrorTest4L(TInt aTestNr) + { + TBuf<100> buf; + buf.Format(_L("DoErrorTest4L %d"), aTestNr); + iLog->Log(buf); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + if (aTestNr == 0) + { + // Test with several lists + RArray list1; + CleanupClosePushL(list1); + + list1.Append(0); + list1.Append(1); + list1.Append(2); + + RArray list2; + CleanupClosePushL(list2); + + list2.Append(3); + list2.Append(4); + list2.Append(5); + + CPosLmIdListCriteria* idList1 = CPosLmIdListCriteria::NewLC(); + CPosLmIdListCriteria* idList2 = CPosLmIdListCriteria::NewLC(); + + idList1->SetLandmarkIdsL(list1); + idList2->SetLandmarkIdsL(list2); + TInt err = composite->AddArgument(idList2); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList2);")); + User::Leave(err); + } + CleanupStack::Pop(idList2); + err = composite->AddArgument(idList1); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList2);")); + User::Leave(err); + + } + CleanupStack::Pop(idList1); + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + } + else if (aTestNr == 1) + { + // Test with several lists + RArray list1; + CleanupClosePushL(list1); + + list1.Append(0); + list1.Append(1); + list1.Append(2); + + RArray list2; + CleanupClosePushL(list2); + + list2.Append(3); + list2.Append(4); + list2.Append(5); + + CPosLmIdListCriteria* idList1 = CPosLmIdListCriteria::NewLC(); + CPosLmIdListCriteria* idList2 = CPosLmIdListCriteria::NewLC(); + + idList1->SetLandmarkIdsL(list1); + idList2->SetLandmarkIdsL(list2); + + TInt err = composite->AddArgument(idList2); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList2);")); + User::Leave(err); + } + CleanupStack::Pop(idList2); + err = composite->AddArgument(idList1); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList2);")); + User::Leave(err); + + } + CleanupStack::Pop(idList1); + + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + iLog->Log(_L("Should leave here")); + ExecuteAndDeleteLD(iOperation); + } + else + { + + iLog->Log(_L("Error in testcode, we should never come here")); + User::Leave(-1); + + } + + + iLog->Log(_L("Did not leave!!!")); + User::Leave(-1); + + + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp37::TestCompositeAndCategoryL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp37::TestCompositeAndCategoryL(TInt /*aTestNr*/) + { + iLog->Log(_L("TestCompositeAndCategoryL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // Test with list that contain items + RArray list; + CleanupClosePushL(list); + + list.Append(0); + list.Append(1); + list.Append(2); + + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + idList->SetLandmarkIdsL(list); + TInt err = composite->AddArgument(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(idList);")); + User::Leave(err); + + } + CleanupStack::Pop(idList); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + err = composite->AddArgument(nameCriteria); + if (err != KErrNotSupported) + { + iLog->Log(_L("Wrong error from AddArgument(nameCriteria); should be KErrNotSupported")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(nameCriteria); + User::Leave(KErrNotSupported); + + + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iLog->Log(_L("Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp38.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp38.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1452 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp38.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +#include "FT_CCompositeSearchResult.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp38::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::CloseTest() + { + iLog->Log(_L("CloseTest")); + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + } + +// --------------------------------------------------------- +// CPosTp38::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::StartL() + { + TTime startTime; + TTime stopTime; + startTime.UniversalTime(); + + iDatabase = UseCompositeLandmarksDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + StartLandmarksCompositeTestL(); + + TestCompositeInCompositeL(); + + TestSeveralTextArgumentsL(); + + TestSeveralTextArgumentsWithORL(); + + TestSortOrderWithORL(); + + TestWithSortOrderLandmarksL(); + + TestWithSortOrderNearestL(); + + TestTwoLmCategoryCriteriaL(); + + TestAddAndRemoveL(); + + TInt err = KErrNone; + TRAP(err, TestWithNoPreviousResultL(0)); + if (err != KErrArgument) + + { + iLog->Log(_L("Searching with no previous result should cause StartLandmarkL to leave with KErrArgument")); + User::Leave(err); + } + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + SearchAndCancelL(EFalse); + SearchAndCancelL(ETrue); + + // Since category and composite is no longer allowed, no need to test this + //TestWithSortOrderCategoriesL(); + //TestCategoryCompositeSearchL(); + + stopTime.UniversalTime(); + TTimeIntervalMicroSeconds executionTime = + stopTime.MicroSecondsFrom(startTime); + + TInt resse = executionTime.Int64()/1000000; + TBuf<100> buf; + buf.Format(_L("TP38 took %d seconds"), resse); + iLog->Log(buf); + } + +// --------------------------------------------------------- +// CPosTp38::TestWithSortOrderCategoriesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestWithSortOrderCategoriesL() + { + iLog->Log(_L("TestWithSortOrderCategoriesL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + TInt err = composite->AddArgument(nameCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(nameCriteria)")); + User::Leave(err); + } + CleanupStack::Pop(nameCriteria); + + CPosLmCategoryManager::TCategorySortPref sortPref; + sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + TInt i=0; + TInt j=0; + for (j=0;j<2;j++) + { + if (j==0) + { + iLog->Log(_L("Sorting Ascending")); + sortPref = CPosLmCategoryManager::ECategorySortOrderNameAscending; + } + else + { + iLog->Log(_L("Sorting Descending")); + sortPref = CPosLmCategoryManager::ECategorySortOrderNameDescending; + } + + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, sortPref); + + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + // Create a sorted list out of the search result + RArray searchResults; + CleanupClosePushL(searchResults); + + for (i=1;i<27;i++) {searchResults.Append(i);} + + CategoriesSortL(searchResults, sortPref); + + TPosLmItemId id = iter->NextL(); + TInt counter=0; + while (id != KPosLmNullItemId) + { + // Check that sort order is correct + AssertTrueSecL(searchResults[counter] == id, _L("Error in sorting")); + id = iter->NextL(); + counter++; + } + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(iter); + } + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp38::TestWithSortOrderNearestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestWithSortOrderNearestL() + { + + iLog->Log(_L("TestWithSortOrderNearestL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // Then create a nearest criteria same coordinate as landmark itemid=3 God + TCoordinate coord(45, 45); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, EFalse); + err = composite->AddArgument(nearestCriteria); + if (err != KErrNone) + + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + + } + CleanupStack::Pop(nearestCriteria); + + // Then add an IdList + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + RArray list; + CleanupClosePushL(list); + + // Use these four landmarks + list.Append(6); + list.Append(7); + list.Append(3); + list.Append(10); + + idList->SetLandmarkIdsL(list); + err = composite->AddArgument(idList); + if (err != KErrNone) + + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(&list); + CleanupStack::Pop(idList); + + // Create search result + RArray searchResults; + CleanupClosePushL(searchResults); + // This is the correct distance sorted array + searchResults.Append(3); + searchResults.Append(7); + searchResults.Append(6); + searchResults.Append(10); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + if (id != (searchResults)[ii]) + { + // Check if same name then don't leave, there are three landmarks with same name, Mölndal + CPosLandmark* source = iDatabase->ReadLandmarkLC(id); + CPosLandmark* target = iDatabase->ReadLandmarkLC((searchResults)[ii]); + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + TInt sourceId = source->LandmarkId(); + target->GetLandmarkName(targetName); + TInt targetId = target->LandmarkId(); + + + AssertTrueSecL(sourceName.CompareC(targetName) == KErrNone,_L("Wrong sortorder"), id); + CleanupStack::PopAndDestroy(2, source); + } + + id = iter->NextL(); + ++ii; + } + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestTwoLmCategoryCriteriaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestTwoLmCategoryCriteriaL() + { + iLog->Log(_L("TestTwoLmCategoryCriteriaL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // Create a cat search criteria + CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); + iLog->Log(_L("SetCategoryItemId")); + catSearchCriteria->SetCategoryItemId(14); + composite->AddArgument(catSearchCriteria); + CleanupStack::Pop(catSearchCriteria); + + // Create another cat search criteria + CPosLmCategoryCriteria* catSearchCriteria2 = CPosLmCategoryCriteria::NewLC(); + iLog->Log(_L("SetCategoryNameL")); + catSearchCriteria2->SetCategoryNameL(_L("McDonalds")); + composite->AddArgument(catSearchCriteria2); + CleanupStack::Pop(catSearchCriteria2); + + // Should find id7=Billigt and id27=LOG9 + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + ExecuteAndDeleteLD(iOperation); + + // Create search result + RArray searchResults; + CleanupClosePushL(searchResults); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + // This is the correct result list + searchResults.Append(27); + searchResults.Append(7); + + TInt size = iter->NumOfItemsL(); + if (size != searchResults.Count()) + + { + iLog->Log(_L("Wrong result returned from iterator")); + User::Leave(-1); + + } + + TInt found = 0; + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + for (ii=0;iiNextL(); + } + + if (found != searchResults.Count()) + + { + iLog->Log(_L("Wrong result returned from iterator1")); + User::Leave(-1); + + } + + // Now refine search with another CPosLmCategoryCriteria + // Create another cat search criteria + CPosLmCategoryCriteria* catSearchCriteria3 = CPosLmCategoryCriteria::NewLC(); + iLog->Log(_L("SetCategoryItemId")); + catSearchCriteria3->SetCategoryItemId(11); + composite->AddArgument(catSearchCriteria3); + CleanupStack::Pop(catSearchCriteria3); + + // Should find id27=LOG9 + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, ETrue); + ExecuteAndDeleteLD(iOperation); + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + searchResults.Reset(); + searchResults.Append(27); + found=0; + size = iter->NumOfItemsL(); + id = iter->NextL(); + if (size != searchResults.Count()) + + { + iLog->Log(_L("Wrong result returned from iterator")); + User::Leave(-1); + + } + + while (id != KPosLmNullItemId) + { + for (ii=0;iiNextL(); + } + + if (found != searchResults.Count()) + + { + iLog->Log(_L("Wrong items returned from iterator2")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestWithSortOrderLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestWithSortOrderLandmarksL() + { + iLog->Log(_L("TestWithSortOrderLandmarksL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + TInt i=0; + TInt j=0; + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // Then create a nearest criteria + TCoordinate coord(12.123, -20,123); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, EFalse); + err = composite->AddArgument(nearestCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(nearestCriteria); + + // Then add an IdList + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + RArray list; + CleanupClosePushL(list); + for (i=1;i<106;i++) {list.Append(i);} + idList->SetLandmarkIdsL(list); + err = composite->AddArgument(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(&list); + CleanupStack::Pop(idList); + + // Create search result of all landmark ids: 1-105 + RArray searchResults; + CleanupClosePushL(searchResults); + for (i=1;i<106;i++) {searchResults.Append(i);} + + for (j=0;j<2;j++) + { + if (j==0) + { + iLog->Log(_L("Sorting Ascending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + } + else + { + iLog->Log(_L("Sorting Descending")); + sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + } + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, sortPref, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TInt size = iter->NumOfItemsL(); + + LandmarksSortL(searchResults, sortPref); + + TInt ii=0; + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + if (id != (searchResults)[ii]) + { + // Check if same name then don't leave, there are three landmarks with same name, Mölndal + + CPosLandmark* source = iDatabase->ReadLandmarkLC(id); + CPosLandmark* target = iDatabase->ReadLandmarkLC((searchResults)[ii]); + TPtrC sourceName, targetName; + source->GetLandmarkName(sourceName); + TInt sourceId = source->LandmarkId(); + target->GetLandmarkName(targetName); + TInt targetId = target->LandmarkId(); + + AssertTrueSecL(sourceName.CompareC(targetName) == KErrNone,_L("Wrong sortorder"), id); + + CleanupStack::PopAndDestroy(2, source); + } + + id = iter->NextL(); + ++ii; + } + CleanupStack::PopAndDestroy(iter); + } + + CleanupStack::PopAndDestroy(&searchResults); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestCompositeInCompositeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestCompositeInCompositeL() + { + iLog->Log(_L("TestCompositeInCompositeL")); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + + textCriteria->SetTextL(_L("*")); + + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-48, 5, -5, 20); + + err = composite->AddArgument(areaCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(areaCriteria); + + //Create composite object that should be used as argument to the first composite object + CPosLmCompositeCriteria* composite2 = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + + textCriteria2->SetTextL(_L("TE,*")); + + err = composite2->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + + // Add a IdList + RArray list; + CleanupClosePushL(list); + + CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); + + for (TInt i=0;i<100;i++) + { + list.Append(i); + } + idList->SetLandmarkIdsL(list); + + err = composite2->AddArgument(idList); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument4")); + User::Leave(err); + } + CleanupStack::Pop(idList); + CleanupStack::PopAndDestroy(&list); + + // Nested composite is not allowed + err = composite->AddArgument(composite2); + if (err != KErrNotSupported) + { + iLog->Log(_L("Wrong error code when adding composite to a composite")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(composite2); + + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp38::StartLandmarksCompositeTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::StartLandmarksCompositeTestL() + { + iLog->Log(_L("StartTestL")); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); + CleanupStack::PushL(res); + + TInt index=0; + TInt errorsFound = KErrNone; + + TBuf<100> buf; + buf.Format(_L(">>>>>>>Test round %d <<<<<<<"), index); + + while (!res->GetCompositeSearchResultsL(*composite)) + { + PrintCompositeInfo(composite); + + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, res->Redefined()); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + + TInt matches = iLandmarkSearch->NumOfMatches(); + TInt expMatches = res->iResultIds.Count(); + + buf.Format(_L("nr of matches: %d nr of exp matches: %d"), matches, expMatches); + iLog->Log(buf); + + while (id != KPosLmNullItemId) + { + buf.Format(_L("Result from iterator id: %d"), id); + iLog->Log(buf); + TInt idde = res->iResultIds.Find(id); + if (idde == KErrNotFound) + { + iLog->Log(_L("MyError: Could not find id!!!")); + errorsFound++; + } + else + { + // Remove so that we dont find the same id again + res->iResultIds.Remove(idde); + } + id = iter->NextL(); + } + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + + if (expMatches != matches) + { + iLog->Log(_L("MyError: Wrong number of matches")); + errorsFound++; + } + } + + if (errorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP38")); + User::Leave(-1); + + } + iLog->Log(_L("----Done---")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + CleanupStack::PopAndDestroy(res); + CleanupStack::PopAndDestroy(composite); + } + + +// --------------------------------------------------------- +// CPosTp38::TestSeveralTextArgumentsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestSeveralTextArgumentsL() + { + iLog->Log(_L("TestSeveralTextArgumentsL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Nokia*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("*Stockholm")); + err = composite->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + + // Should find landmark id: 63 name: "Nokia, Stockholm" + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + TPosLmItemId id = iter->NextL(); + + TInt matches = iLandmarkSearch->NumOfMatches(); + if (matches != 1) + { + iLog->Log(_L("Wrong number of matches")); + User::Leave(-1); + } + + if (id != 63) + { + + iLog->Log(_L("Wrong landmark found, should find landmark with id 63")); + User::Leave(-1); + } + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestSeveralTextArgumentsWithORL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestSeveralTextArgumentsWithORL() + { + iLog->Log(_L("TestSeveralTextArgumentsWithORL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionOR); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Nokia*")); + textCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("*Eriksberg")); + textCriteria2->SetAttributesToSearch(CPosLandmark::ELandmarkName); + err = composite->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + + //Create nearest criteria instance and try adding it to composite criteria,should leave with KErrNotSupported since ORcomposition + // is supported only for text criteria + TCoordinate coord(45, 45); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, EFalse); + err = composite->AddArgument(nearestCriteria); + if (err != KErrNotSupported) + + { + iLog->Log(_L("Error,should not support any other criteria except Text criteria")); + User::Leave(err); + + } + CleanupStack::Pop(nearestCriteria); + + + + + + // Should find landmark ids 48,55,62 & 63 with name:"Nokia","TE Eriksberg","Nokia Copenhagen" "Nokia, Stockholm" + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray idArray; + iter->GetItemIdsL(idArray, 0, iter->NumOfItemsL()); + + + TInt matches = iLandmarkSearch->NumOfMatches(); + if (matches != 4) + { + iLog->Log(_L("Wrong number of matches")); + User::Leave(-1); + } + + for(int i=0; iLog(_L("Wrong landmark found, should find landmark with id 48, 55, 62 & 63")); + User::Leave(-1); + } + } + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + + +// --------------------------------------------------------- +// CPosTp38::TestSortOrderWithORL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestSortOrderWithORL() + { + + + + iLog->Log(_L("TestSeveralTextArgumentsWithORL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionOR); + + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Nokia*")); + textCriteria->SetAttributesToSearch(CPosLandmark::ELandmarkName); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + // First create a textcriteria + CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); + textCriteria2->SetTextL(_L("*Eriksberg")); + textCriteria2->SetAttributesToSearch(CPosLandmark::ELandmarkName); + err = composite->AddArgument(textCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria2); + + // Should find landmark ids 48,55,62 & 63 with name:"Nokia","TE Eriksberg","Nokia Copenhagen" "Nokia, Stockholm" + iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite,sortPref, EFalse); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + RArray idArray; + iter->GetItemIdsL(idArray, 0, iter->NumOfItemsL()); + + + TInt matches = iLandmarkSearch->NumOfMatches(); + if (matches != 4) + { + iLog->Log(_L("Wrong number of matches")); + User::Leave(-1); + } + +//Check if the landmarks are in ascending order i.e "Nokia","Nokia Copenhagen","Nokia Stockholm","TE Eriksberg" + + + if(idArray[0] != 48 || idArray[1] != 62 || idArray[2] != 63 || idArray[3] != 55) + { + iLog->Log(_L("Wrong landmark found, should find landmark with id 48, 55, 62 & 63")); + User::Leave(-1); + } + + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(composite); + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestCategoryCompositeSearchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestCategoryCompositeSearchL() + { + iLog->Log(_L("TestCategoryCompositeSearchL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // Use differen text pattern + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*")); + TInt err = composite->AddArgument(nameCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(nameCriteria);")); + User::Leave(err); + } + CleanupStack::Pop(nameCriteria); + + CPosLmCatNameCriteria* nameCriteria2 = CPosLmCatNameCriteria::NewLC(); + nameCriteria2->SetSearchPatternL(_L("*kontor")); + err = composite->AddArgument(nameCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(nameCriteria);")); + User::Leave(err); + } + CleanupStack::Pop(nameCriteria2); + + // Should find category id: 13 name "Nokia Kontor" and id: 14 name: "TietoEnator kontor" + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TInt matches = iLandmarkSearch->NumOfMatches(); + if (matches != 2) + { + iLog->Log(_L("Wrong number of matches")); + User::Leave(-1); + } + else iLog->Log(_L("Found 2 nr of matches")); + + TPosLmItemId id1 = iter->NextL(); + TPosLmItemId id2 = iter->NextL(); + + if ((id1 == 13 && id2 != 14) || (id1 == 14 && id2 != 13) + || (id2 == 13 && id1 != 14) || (id2 == 14 && id1 != 13)) + { + iLog->Log(_L("Wrong landmark found")); + User::Leave(-1); + } + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + + // Use same text pattern + nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("TietoEnator*")); + err = composite->AddArgument(nameCriteria); + if (err != KErrNone) + { + + iLog->Log(_L("Error from AddArgument(nameCriteria);")); + User::Leave(err); + } + CleanupStack::Pop(nameCriteria); + + nameCriteria2 = CPosLmCatNameCriteria::NewLC(); + nameCriteria2->SetSearchPatternL(_L("TietoEnator*")); + err = composite->AddArgument(nameCriteria2); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(nameCriteria);")); + User::Leave(err); + + } + CleanupStack::Pop(nameCriteria2); + + // Should find category id: 14 name "TietoEnator Kontor" + iLog->Log(_L("iLandmarkSearch->StartCategorySearchL")); + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone); + + ExecuteAndDeleteLD(iOperation); + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + matches = iLandmarkSearch->NumOfMatches(); + if (matches != 1) + { + iLog->Log(_L("Wrong number of matches")); + User::Leave(-1); + + } + else iLog->Log(_L("Found 1 nr of matches")); + + id1 = iter->NextL(); + + if (id1 != 14) + { + iLog->Log(_L("Wrong landmark found")); + User::Leave(-1); + } + + iter->Reset(); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp38::TestAddAndRemoveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestAddAndRemoveL() + { + iLog->Log(_L("TestAddAndRemoveL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + // 1) Add a text criteria + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(err); + + } + CleanupStack::Pop(textCriteria); + + // 2) Add a text criteria + textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Natur*")); + err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument2")); + User::Leave(err); + + } + CleanupStack::Pop(textCriteria); + + // 3) Add an area criteria + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-12.23, 34.4, -2.05, 45.5); + err = composite->AddArgument(areaCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + + } + CleanupStack::Pop(areaCriteria); + + // 4) Add a category criteria + CPosLmCategoryCriteria* catCriteria = CPosLmCategoryCriteria::NewLC(); + catCriteria->SetCategoryNameL(_L("Museum")); + err = composite->AddArgument(catCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + + } + CleanupStack::Pop(catCriteria); + + // 5) Add a nearest criteria + TCoordinate cord(12.23, 12); + CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(cord, ETrue); + err = composite->AddArgument(nearestCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + + } + CleanupStack::Pop(nearestCriteria); + + if (composite->NumOfArguments() != 5) + { + iLog->Log(_L("Error when adding argument1")); + User::Leave(-1); + + } + + // Remove (3) area criteria + CPosLmSearchCriteria* obj1 = composite->RemoveArgument(2); + delete obj1; + obj1 = NULL; + + // Remove (5) nearest criteria (after 3 removed it has id 4) + CPosLmSearchCriteria* obj2 = composite->RemoveArgument(3); + delete obj2; + obj2 = NULL; + + // Should find landmark with id: 87 name: "Naturhistoriska" + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite); + ExecuteAndDeleteLD(iOperation); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TInt nr = iter->NumOfItemsL(); + TBuf<100> buf; + buf.Format(_L("Found %d nr of landmarks after removing two arguments "), nr); + iLog->Log(buf); + + TPosLmItemId id = iter->NextL(); + if (id != 87) + { + iLog->Log(_L("Wrong landmark found")); + User::Leave(-1); + + } + iter->Reset(); + + // Remove (1) first text criteria + CPosLmSearchCriteria* obj4 = composite->RemoveArgument(0); + delete obj4; + obj4 = NULL; + + // Remove (2) the second text criteria + CPosLmSearchCriteria* obj3 = composite->RemoveArgument(0); + delete obj3; + obj3 = NULL; + + CleanupStack::PopAndDestroy(iter); + + // Should find six landmarks belonging to category "museum", + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite); + ExecuteAndDeleteLD(iOperation); + + iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + nr = iter->NumOfItemsL(); + if (nr != 6) + { + iLog->Log(_L("Wrong number of landmarks returned")); + User::Leave(-1); + } + buf.Format(_L("Found %d nr of landmarks after removing two more arguments"), nr); + iLog->Log(buf); + + iter->Reset(); + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLog->Log(_L("Done")); + } + +// --------------------------------------------------------- +// CPosTp38::SearchAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::SearchAndCancelL(const TBool& aInCallback) + { + iLog->Log(_L("SearchAndCancelL")); + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error when adding argument3")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iLandmarkSearch->StartLandmarkSearchL( + *composite, EFalse)); + } + else + { + RunAsyncOperationAndCancelLD(iLandmarkSearch->StartLandmarkSearchL( + *composite, EFalse)); + } + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + if (aInCallback) + { + _LIT(KExpected, "Iter. of matches: %d"); + _LIT(KReturned, "LandmarksSearch no. of matches: %d"); + TBuf<100> info; + info.Format(KExpected, iter->NumOfItemsL()); + iLog->Log(info); + info.Format(KReturned, iLandmarkSearch->NumOfMatches()); + iLog->Log(info); + + TBuf<100> info2; + _LIT(KNof, "No. of matches found before cancel = %d"); + info2.Format(KNof, iter->NumOfItemsL()); + iLog->Log(info2); + + + } + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(composite); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp38::TestWithNoPreviousResultL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::TestWithNoPreviousResultL(TInt aTestNr) + { + iLog->Log(_L("TestWithNoPreviousResultL")); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); + + if (aTestNr == 0) + { + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("*")); + + TInt err = composite->AddArgument(textCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(textCriteria);")); + User::Leave(err); + } + CleanupStack::Pop(textCriteria); + + iOperation = iLandmarkSearch->StartLandmarkSearchL(*composite, ETrue); + ExecuteAndDeleteLD(iOperation); + iLog->Log(_L("ERROR: Should leave here")); + + iLog->Log(_L("Should never come here in the code")); + User::Leave(-1); + + } + else if (aTestNr == 1) + { + + CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); + nameCriteria->SetSearchPatternL(_L("*kontor")); + TInt err = composite->AddArgument(nameCriteria); + if (err != KErrNone) + { + iLog->Log(_L("Error from AddArgument(nameCriteria);")); + User::Leave(err); + } + CleanupStack::Pop(nameCriteria); + + iOperation = iLandmarkSearch->StartCategorySearchL(*composite, CPosLmCategoryManager::ECategorySortOrderNone, ETrue); + ExecuteAndDeleteLD(iOperation); + iLog->Log(_L("ERROR: Should leave here")); + + iLog->Log(_L("Should never come here in the code")); + User::Leave(-1); + + } + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + } + +// --------------------------------------------------------- +// CPosTp38::PrintCompositeInfo +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp38::PrintCompositeInfo(CPosLmCompositeCriteria* aComposite) + { + TBuf<100> buf; + buf.Format(_L("PrintCompositeInfo() NrOfArg %d"), aComposite->NumOfArguments()); + iLog->Log(buf); + + for (TUint i=0;iNumOfArguments();i++) + { + + CPosLmSearchCriteria& comp = aComposite->Argument(i); + TInt type = comp.CriteriaType(); + + if (type == CPosLmSearchCriteria::ECriteriaArea) + { + iLog->Log(_L("Arg Area found")); + + CPosLmAreaCriteria& tt = static_cast(comp); + + TReal64 southLat; + TReal64 northLat; + TReal64 westLong; + TReal64 eastLong; + + tt.GetSearchArea(southLat, northLat, westLong, eastLong); + + buf.Format(_L("SouthL %f NorthL: %f WestL :%f EastL: %f"), (TReal)southLat, (TReal)northLat, (TReal)westLong, (TReal)eastLong); + iLog->Log(buf); + + } + else if (type == CPosLmSearchCriteria::ECriteriaText) + { + iLog->Log(_L("Arg Text found:")); + CPosLmTextCriteria& tt = static_cast(comp); + iLog->Log(tt.Text()); + } + else if (type == CPosLmSearchCriteria::ECriteriaComposite) + { + iLog->Log(_L("Arg Composite found")); + } + else if (type == CPosLmSearchCriteria::ECriteriaCategory) + { + iLog->Log(_L("Arg Category found")); + + CPosLmCategoryCriteria& tt = static_cast(comp); + iLog->Log(tt.CategoryName()); + } + else if (type == CPosLmSearchCriteria::ECriteriaFindNearest) + { + CPosLmNearestCriteria& tt = static_cast(comp); + TCoordinate cord; + tt.GetCoordinate(cord); + iLog->Log(_L("Arg Nearest found")); + buf.Format(_L("Latitude %f Longitude: %f MaxDist:%f"), (TReal)cord.Latitude(), (TReal)cord.Longitude(), (TReal)tt.MaxDistance()); + iLog->Log(buf); + } + else if (type == CPosLmSearchCriteria::ECriteriaIdList) + { + iLog->Log(_L("Arg Idlist found")); + CPosLmIdListCriteria& tt = static_cast(comp); + + RArray result; + CleanupClosePushL(result); + tt.GetLandmarkIdsL(result); + + buf.Format(_L("Nr of Ids: %d"), result.Count()); + iLog->Log(buf); + + for (TInt i=0;iLog(_L("Arg Categorybyname found")); + } + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp39.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp39.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,579 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp39.h" +#include +#include +#include +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KNoListeners=5; +const TInt KMaxQueueSize = 5; +const TInt KLmServerMaxHeapSize = 40000; + +_LIT(KLandmarkServerName, "eposlmserver*"); + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp39::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::GetName(TDes& aName) const + { + _LIT(KTestName, "TP39 - Heap Usage (Goofy)"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp39::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::StartL() + { + _LIT(KMultipleErr, "Error %d when multiple clients listen for events"); + _LIT(KEventErr, "%d Error(s) when multiple clients listen for events"); + MakeSurePanicDebugFileExistsL(); + iUseLogFromThreadIsDisabled = ETrue; + + _LIT(KCanceledErr, "Test canceled"); + _LIT(KStartGoofy, "Start up Goofy and start a test (Options->Test->Start)."); + + RemoveDefaultDbL(); + +#ifndef __WINS__ + TUtfwUserAnswer answer; + answer = iUserInfo->ShowDialog(KStartGoofy, EUtfwDialogTypeOkCancel, EFalse); + AssertTrueSecL(answer == EUtfwUserAnswerOk, KCanceledErr, KErrCancel); +#endif + + RemoveDefaultDbL(); + + SetupGlobalCategoriesL(); + + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + delete database; + + TFixedArray statuses; + + CreateThreadsL(); + + for (TInt i=0; i 0) + { + TBuf<100> info; + info.Format(KEventErr, iErrors); + LogErrorAndLeave(iErrorLog); + } + + +#ifndef __WINS__ + + TInt heapSize, stackSize=0; + + TBuf<127> info; + TInt err = GetHeapSizeL(KLandmarkServerName, heapSize, stackSize); + if (err) + { + info.Format(_L("GetHeapSizeL error, %d"), err); + LogErrorAndLeave(info); + } + + info.Format(_L("LandmarkServer Heap: %d LandmarkServer Stack:"), heapSize, stackSize); + iLog->Put(info); + + if (heapSize > KLmServerMaxHeapSize) + { + LogErrorAndLeave(_L("The memory consumption for the LandmarkServer is too high!")); + } +#endif + +/* + _LIT(KCatId, "category_id = %d;"); + _LIT(KCatName, "category_name = \"%S\";"); + + // 201-300 + _LIT(KName, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901%d"); + + for (TInt i=201; i<=300; i++) + { + iLog->Put(_L("POS_LM_CATEGORY_INFO")); + iLog->Put(_L("{")); + + TBuf<150> info; + + info.Format(KCatId, (i+1)); + + iLog->Put(info); + + info.Format(KName, i); + + HBufC* name = info.Alloc(); + + info.Format(KCatName, name); + iLog->Put(info); + iLog->Put(_L("},")); + } +*/ + } + +// --------------------------------------------------------- +// CPosTp39::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::CloseTest() + { + for (TInt i=0; iPut(_L("Landmark is NOT flashed, rename global categories")); + //Landmark is not flashed rename the file before copy a own defiend file. + //since landmark is not flashed the file should exist hence leaving if it is not found! + User::LeaveIfError(fileMan->Rename(KGlobalCategoryResFileWINS, KGlobalCategoryResFileCOPY, CFileMan::EOverWrite)); + } + else + { + iLog->Put(_L("Landmark is flashed, copy global categories")); + } + + User::LeaveIfError(fileMan->Copy(KGlobalCategoryResFile, KGlobalCategoryResPath, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Rename(KGlobalCategoryResFileOld, KGlobalCategoryResFileNew, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + + } + +// --------------------------------------------------------- +// CPosTp39::RunReceiveEventTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::RunEventsListenerL(TAny* aData) + { + CPosTp39* self = reinterpret_cast(aData); + + CEventObserverTp39* eventObserver = CEventObserverTp39::NewL(self, ++self->iThreadIndex); + CleanupStack::PushL(eventObserver); + eventObserver->Start(); + + eventObserver->StartTimer(); + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(eventObserver); + } + +LOCAL_C TInt ReceiveEventsThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp39::RunEventsListenerL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp39::CreateEventsTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::RunEventsGeneratorL(TAny* /*aData*/) + { + //CPosTp39* self = reinterpret_cast(aData); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + ///////////////////////////////////////////// + // Add one landmark #1 + ////////////////////////////////////////////// + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("TP39")); + lmd->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + ///////////////////////////////////////////// + // Add 5 categories #2 + ///////////////////////////////////////////// + + _LIT(KCategoryName, "TP39 Category %d"); + for (TInt j =0; j < KMaxQueueSize; j++) + { + TBuf<100> name; + name.Format(KCategoryName, j); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(name); + cm->AddCategoryL(*category); + CleanupStack::PopAndDestroy(category); + } + + CleanupStack::PopAndDestroy(2, lmd); + } + +LOCAL_C TInt CreateEventsThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp39::RunEventsGeneratorL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp39::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::CreateThreadsL() + { + _LIT(KThreadName, "TP39 thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TInt i=0; i<=KNoListeners; i++) + { + RThread thread; + TBuf<32> name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + if (i==KNoListeners) + { + err = thread.Create(name, CreateEventsThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + } + else + { + err = thread.Create(name, ReceiveEventsThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + } + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// --------------------------------------------------------- +// CPosTp39::LogError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::LogError(const TDesC& aError) + { + iErrorLog.Append(aError); + iErrors++; + } + +// --------------------------------------------------------- +// CEventObserverTp39::CheckEventL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp39::CheckEvent(const TInt aThreadIndex, + const TPosLmEventType aExpectedEventType, + const TPosLmEventType aEventType, + const TPosLmItemId aExpectedItemId, + const TPosLmItemId aItemId) + { + if (aExpectedEventType != aEventType) + { + _LIT(KError,"Thread %d received an unexpected eventtype. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aThreadIndex, aExpectedEventType, aEventType); + LogError(error); + } + if (aExpectedItemId != aItemId) + { + _LIT(KError,"Thread %d received an unexpected item id. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aThreadIndex, aExpectedItemId, aItemId); + LogError(error); + } + } + +// --------------------------------------------------------- +// CPosTp39::GetHeapSizeL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp39::GetHeapSizeL(const TDesC& aThreadName, TInt& aHeapSize, TInt& aStackSize) + { + RThread thread; + TFindThread findThread(aThreadName); + + TFullName fullName; + + TInt err = findThread.Next(fullName); + + if (err) + { + iLog->Put(_L("Thread not found")); + return err; + } + err = thread.Open(fullName); + if (err) + { + iLog->Put(_L("Thread could not be opened")); + return err; + } + + // FrBo Commented since not supported on ARMV5 (on SDK Series60_30_2005_wk02_incl_LBSpre4) + //err = thread.GetRamSizes(aHeapSize, aStackSize); + // Use below for now + err =KErrNone;aHeapSize=-1;aStackSize=-1; + + if (err) + { + iLog->Put(_L("GetRameSize fails")); + thread.Close(); + return err; + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CEventObserverTp39::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CEventObserverTp39* CEventObserverTp39::NewL(CPosTp39* aTp39, TInt aThreadIndex) + { + CEventObserverTp39* self = new(ELeave) CEventObserverTp39(aTp39, aThreadIndex); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CEventObserverTp39::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CEventObserverTp39::ConstructL() + { + iDatabase = CPosLandmarkDatabase::OpenL(); + iPeriodicTimer = CPeriodic::NewL(EPriorityNormal); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + } + +// C++ Constructor +CEventObserverTp39::CEventObserverTp39(CPosTp39* aTp39, TInt aThreadIndex) : + CActive(EPriorityNormal), + iTp39(aTp39), + iThreadIndex(aThreadIndex), + iCallback(StopEventNotification, this) + { + CActiveScheduler::Add(this); + } + +// C++ destructor +CEventObserverTp39::~CEventObserverTp39() + { + Cancel(); + delete iDatabase; + iDatabase = NULL; + if (iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + } + delete iPeriodicTimer; + iPeriodicTimer = NULL; + } + +// --------------------------------------------------------- +// CEventObserverTp39::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserverTp39::Start() + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + +//--------------------------------------------------------- +// CEventObserverTp39::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserverTp39::DoCancel() + { + iDatabase->CancelNotifyDatabaseEvent(); + } + +//--------------------------------------------------------- +// CEventObserverTp39::StartTimer +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserverTp39::StartTimer() + { + iPeriodicTimer->Start(10000000, 10000000, TCallBack(StopEventNotification, this)); + } + +//--------------------------------------------------------- +// CPosEventObserverTp39::TimeoutCheck +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CEventObserverTp39::StopEventNotification(TAny* aSelf) + { + CEventObserverTp39* self = reinterpret_cast(aSelf); + + self->Cancel(); + self->iPeriodicTimer->Cancel(); + CActiveScheduler::Stop(); + + return 0; + } + +// --------------------------------------------------------- +// CPosEventObserver::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CEventObserverTp39::RunL() + { + iEventNumber++; + + switch (iEventNumber) + { + case 1: + iTp39->CheckEvent(iThreadIndex, + EPosLmEventLandmarkCreated, + iEvent.iEventType, + iEventNumber, + iEvent.iLandmarkItemId); + // Don't renew the event notification so the server will have to start queueing the events + break; + default: + iTp39->LogError(_L("Test logic error, no more events should be received since the queue on the server should be filled")); + iPeriodicTimer->Cancel(); + Cancel(); + CActiveScheduler::Stop(); + break; + } + //iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + //SetActive(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp4.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp4.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp4.h" +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp4::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp4::StartL() + { + TestCompactL(ESynchronous); + + TestCompactL(EAsynchronous); + + TestCompactL(EWaitForRequest); + } + +// --------------------------------------------------------- +// CPosTp4::TestCompactL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp4::TestCompactL(TExecutionMode aExecutionMode) + { + _LIT(KFileSizeErr, "Returned file size is incorrect"); + _LIT(KUsageErr, "Returned usage is incorrect"); + _LIT(KFileSizeAfterCompactErr, "The file size after compact is not less than the file size before compact"); + _LIT(KUsageAfterCompactErr, "The usage is equal or less than before compact"); + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // Create new test db + HPosLmDatabaseInfo* dbInfoDefault = HPosLmDatabaseInfo::NewLC(KTp4TestDb); + manager->CreateDatabaseL(*dbInfoDefault); + CleanupStack::PopAndDestroy(dbInfoDefault); + // This db must exist + manager->SetDefaultDatabaseUriL(KTp4TestDb); + CleanupStack::PopAndDestroy(manager); + + CPosLandmarkDatabase* tmp = CPosLandmarkDatabase::OpenL(); // Make sure default database is created + CleanupStack::PushL(tmp); + if (tmp->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(tmp->InitializeL()); + } + CleanupStack::PopAndDestroy(tmp); + + RFile file; + User::LeaveIfError(file.Open(iFileSession, KLmTp4DefaultDbPath, EFileRead)); + TInt fileSize=0; + file.Size(fileSize); + file.Close(); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + CPosLandmarkDatabase::TSize size = lmd->SizeL(); + + AssertTrueSecL(size.iFileSize == fileSize, KFileSizeErr); + AssertTrueSecL(size.iUsage >= 0.0 && size.iUsage <= 1.0, KUsageErr); // For now, when compact is supported should usage be 100% + + CPosLmOperation* op = lmd->CompactL(); + switch (aExecutionMode) + { + case ESynchronous: + ExecuteAndDeleteLD(op); + break; + case EAsynchronous: + RunAsyncOperationLD(op); //*** async + break; + case EWaitForRequest: + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + break; + default: + + break; + } + + CPosLandmarkDatabase::TSize sizeAfterCompact = lmd->SizeL(); + + AssertTrueSecL(sizeAfterCompact.iFileSize < size.iFileSize, KFileSizeAfterCompactErr); + + AssertTrueSecL(sizeAfterCompact.iUsage >= size.iUsage, KUsageAfterCompactErr); + + CleanupStack::PopAndDestroy(lmd); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp40.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp40.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp40.h" +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp40::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp40::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp40 - Verify KErrLocked not returned, etc"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp40::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp40::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + } +// --------------------------------------------------------- +// CPosTp40::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp40::StartL() + { + RemoveDefaultDbL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); // Synchronous since no argument + } + + ExecuteAndDeleteLD(iDatabase->CompactL()); + + // Test error report ESLI-5ZYMPM + TestPart1L(); + ExecuteAndDeleteLD(iDatabase->CompactL()); + // Test error report ESLI-62FGEV, (debug panic, only raised on WINS (not on target)) + TestPart2L(); + + delete iDatabase; + iDatabase = NULL; + } +// --------------------------------------------------------- +// CPosTp40::TestPart1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp40::TestPart1L() + { + // + // Testing error report ESLI-5ZYMPM + // Landmarks - KErrLocked returned on write operations even if no operations are outstanding. + // + iLog->Put(_L("TestPart1L")); + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(landmarkSearch); + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Library*")); + + CPosLmOperation* operation = landmarkSearch->StartLandmarkSearchL(*textCriteria); + RArray arr1; + CleanupClosePushL(arr1); + TPosLmItemId id1(1); + TPosLmItemId id2(2); + arr1.Append(id1); + arr1.Append(id2); + operation -> ExecuteL(); + + CPosLmOperation* operationPartial = iDatabase -> PreparePartialLandmarksL(arr1); + CleanupStack::PushL(operationPartial); + delete operation; //if this is moved to before PreparePartial... everything works + operation = NULL; + operationPartial->ExecuteL(); + + iDatabase -> RemoveLandmarkL(1); //Before leaved with -22 here -> ERROR + CleanupStack::PopAndDestroy(operationPartial); + CleanupStack::PopAndDestroy(&arr1); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + iLog->Put(_L("TestPart1L completed successfully")); + } + +// --------------------------------------------------------- +// CPosTp40::TestPart2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp40::TestPart2L() + { + // + // Testing error report ESLI-62FGEV + // Landmarks - TPosLmItemId array with 0 value and PreparePartialLandmarksL + // + iLog->Put(_L("TestPart2L")); + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(landmarkSearch); + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("Library*")); + + CPosLmOperation* operation = landmarkSearch->StartLandmarkSearchL(*textCriteria); + RArray arr1; + CleanupClosePushL(arr1); + TPosLmItemId id1(0); // Is actually not allowed to have a 0 value + TPosLmItemId id2(1); + arr1.Append(id1); + arr1.Append(id2); + operation -> ExecuteL(); + + // When passing an array with 0 value method should leave with error, + // instead the operationPartial->ExecuteL() method panics with -2 + CPosLmOperation* operationPartial = iDatabase -> PreparePartialLandmarksL(arr1); + CleanupStack::PushL(operationPartial); + delete operation; + operation = NULL; + // This method Panics (debug panic only on WINS) with -2 + operationPartial->ExecuteL(); + + CleanupStack::PopAndDestroy(operationPartial); + CleanupStack::PopAndDestroy(&arr1); + CleanupStack::PopAndDestroy(textCriteria); + CleanupStack::PopAndDestroy(landmarkSearch); + iLog->Put(_L("TestPart2L completed successfully")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp41.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp41.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,263 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp41.h" +#include +#include +#include +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp41::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp41::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp41 - Empty Landmark Name and Descriptor"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp41::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp41::StartL() + { + RemoveDefaultDbL(); + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + ExecuteAndDeleteLD(iDatabase->CompactL()); + + VerifyEmptyLandmarksL(); + } + +// --------------------------------------------------------- +// CPosTp41::CloseTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp41::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp41::VerifyEmptyLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp41::VerifyEmptyLandmarksL() + { + _LIT(KLmName, "LmTp41 - %d"); + _LIT(KLmDescription, "LmTp41Description - %d"); + + _LIT(KCompareNameErr, "Landmark names are not equal"); + _LIT(KCompareDescErr, "Landmark descriptions are not equal"); + + _LIT(KNameErr, "GetLandmarkName returned wrong"); + _LIT(KDescErr, "GetLandmarkDescription returned wrong"); + + // 1) Create landmark with name and descriptor + TBuf<100> lmName; + lmName.Format(KLmName,1); + TBuf<100> lmDesc; + lmDesc.Format(KLmDescription,1); + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + landmark->SetLandmarkDescriptionL(lmDesc); + TPosLmItemId id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + // Read landmark from local landmark + TPtrC sourceDesc; + TPtrC sourceName; + TInt sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNone, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNone, KDescErr); + + AssertTrueSecL(sourceName.Compare(lmName) == KErrNone, KCompareNameErr); + AssertTrueSecL(sourceDesc.Compare(lmDesc) == KErrNone, KCompareDescErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + + // 2) Create landmark with name and and empty descriptor + lmName.Format(KLmName,2); + lmDesc.Append(_L("")); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + landmark->SetLandmarkDescriptionL(lmDesc); + id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + // Read landmark from local landmark + sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNone, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNone, KDescErr); + + AssertTrueSecL(sourceName.Compare(lmName) == KErrNone, KCompareNameErr); + AssertTrueSecL(sourceDesc.Compare(lmDesc) == KErrNone, KCompareDescErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + + // 3) Create landmark with name and and no descriptor set + lmName.Format(KLmName, 2); + lmDesc.Append(_L("")); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + // Read landmark from local landmark, GetLandmarkDescription should return KErrNotFound since it is not set + sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNone, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNotFound, KDescErr); + + AssertTrueSecL(sourceName.Compare(lmName) == KErrNone, KCompareNameErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + + // 4) Create landmark with empty name and no description set + lmName.Append(_L("")); + lmDesc.Append(_L("")); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + // Read landmark from local landmark, GetLandmarkDescription + // should return KErrNotFound since it is not set + sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNone, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNotFound, KDescErr); + + AssertTrueSecL(sourceName.Compare(lmName) == KErrNone, KCompareNameErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + + // 5) Create landmark with no name set but with description + lmName.Append(_L("")); + lmDesc.Format(KLmDescription,2); + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkDescriptionL(lmDesc); + id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + // Read landmark from local landmark, GetLandmarkName + // should return KErrNotFound since it is not set + sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNotFound, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNone, KDescErr); + AssertTrueSecL(sourceDesc.Compare(lmDesc) == KErrNone, KCompareDescErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + + // 6) Create empty landmark + landmark = CPosLandmark::NewLC(); + id = iDatabase->AddLandmarkL(*landmark); + User::After(200000); + lmName.Append(_L("")); + lmDesc.Append(_L("")); + + // Read landmark from local landmark, GetLandmarkName and GetLandmarkDescription + // should return KErrNotFound since it is not set + sourceErr = landmark->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNotFound, KNameErr); + sourceErr = landmark->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNotFound, KDescErr); + + CleanupStack::PopAndDestroy(landmark); + // Read landmark from landmark db + CheckLandmarkL(id, lmName, lmDesc); + lmName.Zero(); + lmDesc.Zero(); + } + +// --------------------------------------------------------- +// CPosTp41::InternalGet +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp41::CheckLandmarkL(TPosLmItemId aId, TDesC& aName, TDesC& aDesc) + { + iLog->Put(_L("CheckLandmarkL")); + _LIT(KNameErr2, "lm->GetLandmarkName returned wrong"); + _LIT(KDescErr2, "lm->GetLandmarkDescription returned wrong"); + + _LIT(KCompareNameErr, "Landmark names are not equal"); + _LIT(KCompareDescErr, "Landmark descriptions are not equal"); + + TPtrC sourceDesc; + TPtrC sourceName; + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(aId); + + TInt sourceErr = lm->GetLandmarkName(sourceName); + AssertTrueSecL(sourceErr == KErrNone, KNameErr2); + + AssertTrueSecL(sourceName.Compare(aName) == KErrNone, KCompareNameErr); + sourceErr = lm->GetLandmarkDescription(sourceDesc); + AssertTrueSecL(sourceErr == KErrNone, KDescErr2); + AssertTrueSecL(sourceDesc.Compare(aDesc) == KErrNone, KCompareDescErr); + + CleanupStack::PopAndDestroy(lm); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp42.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp42.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,613 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp42.h" +#include +#include + +// CONSTANTS +_LIT(KTraceDir, "c:\\documents\\"); +_LIT(KFileTrace, "c:\\documents\\TP42_File%d.xml"); +_LIT(KFileTraceWild, "c:\\documents\\TP42_File*.xml"); + +_LIT( KDump, "%02d: '%S'" ); + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp42::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::CloseTest() + { + iDataToRecognize.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp42::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KFileTrace ); + + iErrorsFound = 0; + // Test reading from buffer + iLog->Log(_L("**************BUFFER***************")); + TestWithBufferL(); + + iLog->Log(_L("**************FILE***************")); + //Test reading from file and filehandle + TestWithFileL(); + + iLog->Log(_L("**************EMPTY FILE***************")); + //Test reading from empty file + TestWithEmptyFileL(); + + iLog->Log(_L("**************LARGE FILE***************")); + + //Test reading from large file + TestWithLargeFilesL(_L(" < *:lmx*>"), CApaDataRecognizerType::EProbable); + + iDataToRecognize.ResetAndDestroy(); + + if (iErrorsFound != KErrNone) + { + TBuf<64> buf; + buf.Format(_L("%d Errors were found in TP42"), iErrorsFound ); + iLog->Log(buf); + User::Leave(-1); + } + } + + +// ---------++++++++++++++------------------------------------------------ +// CPosTp42::TestWithBufferL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::TestWithEmptyFileL() + { + // Create empty file + RFile file; + TBuf<100> buf; + _LIT(KFileName, "c:\\documents\\DummyFile.txt"); + + TInt err = file.Open(iFileSession, KFileName , EFileWrite); + if (err != KErrNone && err != KErrAlreadyExists) + { + if (err == KErrNotFound) + { + User::LeaveIfError(file.Create(iFileSession, KFileName, EFileWrite)); + } + else + { + buf.Format(_L("Error %d when creating empty file"), err); + iLog->Log(buf); + } + } + + file.Close(); + TBuf8<1> kalle; + + RApaLsSession lsSession; + CleanupClosePushL(lsSession); + User::LeaveIfError(lsSession.Connect()); + TDataRecognitionResult recognizerResultFromFile; + TDataRecognitionResult recognizerResultFromFileHandle; + + // Check file + err = lsSession.RecognizeData(KFileName, kalle , recognizerResultFromFile); + if (err != KErrNone) + { + iLog->Log(_L("Error from lsSession.RecognizeData")); + User::Leave(err); + } + iLog->Log(recognizerResultFromFile.iDataType.Des()); + TInt expCode = CApaDataRecognizerType::EProbable; + + if (recognizerResultFromFile.iDataType.Des() != _L("text/plain")) + { + + iLog->Log(_L("datatype from recognizer")); + } + + if (recognizerResultFromFile.iConfidence != expCode) + { + + iLog->Log(_L(" confidence from recognizer")); + } + + // Check filehandle + User::LeaveIfError(iFileSession.ShareProtected()); + + RFile fileHandle; + CleanupClosePushL(fileHandle); + err = fileHandle.Open(iFileSession, KFileName, EFileRead | EFileShareAny); + if (err != KErrNone) + { + iLog->Log(_L("Error from file.Open")); + User::Leave(err); + + } + err = lsSession.RecognizeData(fileHandle, recognizerResultFromFileHandle); + if (err != KErrNone) + { + iLog->Log(_L("Error from lsSession.RecognizeData")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(&fileHandle); + iLog->Log(recognizerResultFromFileHandle.iDataType.Des()); + + if (recognizerResultFromFileHandle.iDataType.Des() != _L("text/plain")) + { + iLog->Log(_L(" datatype from recognizer")); + } + + if (recognizerResultFromFileHandle.iConfidence != expCode) + { + iLog->Log(_L("confidence from recognizer")); + } + + CleanupStack::PopAndDestroy(&lsSession); + + } + +// --------------------------------------------------------- +// CPosTp42::TestWithBufferL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::TestWithBufferL() + { + //start reading the file line by line and create objects. + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmRecognizerData.txt"); + + RFile file; + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + CleanupClosePushL(file); + + TBuf<500> line; //declarera som en konstant tack + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if ( lex.Peek() != '#' ) + { + CRecognizerData* recognizerData = CRecognizerData::NewL(line); + CleanupStack::PushL(recognizerData); + + User::LeaveIfError(iDataToRecognize.Append(recognizerData)); + CleanupStack::Pop(recognizerData); + } + } + + CleanupStack::PopAndDestroy(&file); + + RApaLsSession lsSession; + CleanupClosePushL(lsSession); + User::LeaveIfError(lsSession.Connect()); + TDataRecognitionResult recognizerResult; + TBuf<10> dummy; //dummy + + TInt numberOfResults = iDataToRecognize.Count(); + for (TInt i = 0; i < numberOfResults; i++) + { + CRecognizerData* data = iDataToRecognize[i]; + TBuf8<200> kalle; + kalle.Copy((data -> RecognizerData())); + + // Check buffer + User::LeaveIfError(lsSession.RecognizeData(dummy, kalle , recognizerResult)); + + const TDataRecognitionResult expected = data->ExpectedResult(); + + TBuf<512> buf; + TPtrC content( data->RecognizerData() ); + buf.Format( KDump, i+1, &content ); + iLog->Log( buf ); + + CheckResultL(expected, recognizerResult); + } + + CleanupStack::PopAndDestroy(&lsSession); + iDataToRecognize.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp42::TestWithFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::TestWithFileL() + { + //start reading the file line by line and create objects. + _LIT(KFileTestValues, "c:\\system\\test\\testdata\\LmRecognizerDataFile.txt"); + + RFile file; + + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + // Delete all old files + TInt err = fileMan->Delete(KFileTraceWild); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Error from CFileMan::Delete")); + CleanupStack::PopAndDestroy(fileMan); + + CleanupClosePushL(file); + User::LeaveIfError(file.Open(iFileSession, KFileTestValues, EFileRead)); + + TBuf<500> line; + while (ReadLn(file, line) != KErrEof) + { + TLex lex(line); + if (lex.Peek() != '#') + { + CRecognizerData* recognizerData = CRecognizerData::NewL(line); + CleanupStack::PushL(recognizerData); + + User::LeaveIfError(iDataToRecognize.Append(recognizerData)); + CleanupStack::Pop(recognizerData); + } + } + + CleanupStack::PopAndDestroy(&file); + + //start comparing + RApaLsSession lsSession; + CleanupClosePushL(lsSession); + User::LeaveIfError(lsSession.Connect()); + TDataRecognitionResult recognizerResultFromFile; + TDataRecognitionResult recognizerResultFromFileHandle; + TBuf<40> fileName; //dummy + + TInt numberOfResults = iDataToRecognize.Count(); + for (TInt i = 0; i < numberOfResults; i++) + { + CRecognizerData* data = iDataToRecognize[i]; + + TBuf8<512> buf8; + buf8.Copy( data->RecognizerData() ); + + RFile file; + TFileName fileName; + TInt err = file.Temp( iFileSession, KTraceDir, fileName, EFileWrite ); + if ( err ) + { + iLog->Log(_L("Failed to create temp file, %d"), err); + User::Leave( err ); + } + file.Write( buf8 ); + _LIT8( KCrLf, "\n" ); + file.Write( KCrLf ); + file.Close(); + + const TDataRecognitionResult expected = data->ExpectedResult(); + + TBuf<512> buf; + TPtrC content( data->RecognizerData() ); + buf.Format( KDump, i+1, &content ); + iLog->Log( buf ); + + // Check file + recognizerResultFromFile.Reset(); + buf8.Zero(); + lsSession.RecognizeData( fileName, buf8, recognizerResultFromFile ); + CheckResultL(expected, recognizerResultFromFile); + + // Check FileHandle + + RFs fileSessionNew; + User::LeaveIfError(fileSessionNew.Connect()); + CleanupClosePushL(fileSessionNew); + + //iLog->Log(_L("Check filehandle")); + err = fileSessionNew.ShareProtected(); + if (err != KErrNone) + { + iLog->Log(_L("Error from file.ShareProtected")); + User::Leave(err); + } + + RFile fileHandle; + CleanupClosePushL(fileHandle); + err = fileHandle.Open(fileSessionNew, fileName, EFileRead | EFileShareAny); + if (err != KErrNone) + { + iLog->Log(_L("Error from file.open")); + User::Leave(err); + } + err = lsSession.RecognizeData(fileHandle, recognizerResultFromFileHandle); + if (err != KErrNone) + { + iLog->Log(_L("Error from lsSession.RecognizeData")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(&fileHandle); + CleanupStack::PopAndDestroy(&fileSessionNew); + CheckResultL(expected, recognizerResultFromFileHandle); + + iFileSession.Delete( fileName ); + } + + CleanupStack::PopAndDestroy(&lsSession); + + iDataToRecognize.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp42::TestWithLargeFilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp42::TestWithLargeFilesL(const TDesC& msg, TInt aExpCode) + { + RApaLsSession lsSession; + CleanupClosePushL(lsSession); + User::LeaveIfError(lsSession.Connect()); + + TDataRecognitionResult recognizerResultFromFile; + TDataRecognitionResult recognizerResultFromFileHandle; + + const TInt KBufSize = 400; + TBuf8 tmp1; + TBuf8 tmp; + TBuf8<1> kalle; + + _LIT(KEnd,"\n"); + + RFile file; + TFileName fileName; + file.Temp( iFileSession, KTraceDir, fileName, EFileWrite ); + CleanupClosePushL(file); + + for (TInt i=0;i<10;i++) + { + tmp1.Append(_L(" \n\t ")); + } + + tmp.Append(tmp1); + tmp.Append(msg); + tmp.Append(KEnd); + tmp.Append(tmp1); + tmp.Append(KEnd); + file.Write(tmp); + + CleanupStack::PopAndDestroy(&file); + + lsSession.RecognizeData(fileName, kalle , recognizerResultFromFile); + iLog->Log(recognizerResultFromFile.iDataType.Des()); + + if (recognizerResultFromFile.iDataType.Des() != _L("application/vnd.nokia.landmarkcollection+xml")) + { + iLog->Log(_L("datatype from recognizer")); + } + + if (recognizerResultFromFile.iConfidence != aExpCode) + { + iLog->Log(_L(" confidence from recognizer")); + } + + // Check FileHandle + iLog->Log(_L("Check filehandle")); + + RFs fs; + CleanupClosePushL(fs); + User::LeaveIfError(fs.Connect()); + User::LeaveIfError(fs.ShareProtected()); + + RFile fileHandle; + CleanupClosePushL(fileHandle); + TInt err = fileHandle.Open(fs, fileName, EFileRead | EFileShareAny); + if (err != KErrNone) + { + iLog->Log(_L("Error from file.Open")); + User::Leave(err); + } + err = lsSession.RecognizeData(fileHandle, recognizerResultFromFileHandle); + if (err != KErrNone) + { + iLog->Log(_L("Error from lsSession.RecognizeData")); + User::Leave(err); + } + CleanupStack::PopAndDestroy(&fileHandle); + + if (recognizerResultFromFileHandle.iDataType.Des() != _L("application/vnd.nokia.landmarkcollection+xml")) + { + iLog->Log(_L("datatype from recognizer")); + } + + if (recognizerResultFromFileHandle.iConfidence != aExpCode) + { + iLog->Log(_L("confidence from recognizer")); + } + + iFileSession.Delete( fileName ); + CleanupStack::PopAndDestroy(&fs); + CleanupStack::PopAndDestroy(&lsSession); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CPosTp42::CheckResultL(TDataRecognitionResult aExpectedResult, TDataRecognitionResult aResult) + { + _LIT(KExpected, "Expect: '%S' (%d)"); + _LIT(KActual, "Actual: '%S' (%d)"); + + TBuf<256> exp, act; + TPtrC expMime( aExpectedResult.iDataType.Des() ); + TPtrC actMime( aResult.iDataType.Des() ); + + exp.Format(KExpected, &expMime, aExpectedResult.iConfidence ); + act.Format(KActual, &actMime, aResult.iConfidence ); + + if ( aExpectedResult.iConfidence == NOLANDMARKNUMBER ) // Magic number for not any landmark + { + _LIT8(KLmxType, "application/vnd.nokia.landmarkcollection+xml"); + _LIT8(KGpxType, "application/gps+xml"); + + if ( aResult.iDataType.Des8().Compare( KLmxType ) == 0 || + aResult.iDataType.Des8().Compare( KGpxType ) == 0 ) + { + iLog->Log(_L( "ERR: landmark detected when it shouldn't be" )); + iLog->Log(exp); + iLog->Log(act); + iErrorsFound++; + } + } + else //if (aExpectedResult.iConfidence == CApaDataRecognizerType::ECertain) //a landmark buffer is expected + { + if ( aExpectedResult.iDataType != aResult.iDataType ) + { + iLog->Log(_L( "ERR: datatype mismatch" )); + iLog->Log(exp); + iLog->Log(act); + iErrorsFound++; + } + if ( aExpectedResult.iConfidence != aResult.iConfidence ) + { + iLog->Log(_L("ERR: confidence mismatch")); + iLog->Log(exp); + iLog->Log(act); + iErrorsFound++; + } + } + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +// Implementation of the supporter class +CRecognizerData* CRecognizerData::NewL(const TDesC& aDes) + { + CRecognizerData* self = new(ELeave) CRecognizerData; + CleanupStack::PushL(self); + self->ConstructL(aDes); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +CRecognizerData::CRecognizerData() + { + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +CRecognizerData::~CRecognizerData() + { + delete iRecognizerData; + iRecognizerData = NULL; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +TPtrC CRecognizerData::RecognizerData() const + { + return *iRecognizerData; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +const TDataRecognitionResult& CRecognizerData::ExpectedResult() const + { + return iExpectedResult; + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CRecognizerData::ConstructL(const TDesC& aDes) + { + _LIT( KDelim, "#" ); + TInt delim = aDes.Find( KDelim ); + iRecognizerData = aDes.Left( delim ).AllocL(); + iRecognizerData->Des().TrimRight(); + + TLex line( aDes.Mid( delim + 1 ) ); + + ParseResult( line.NextToken() ); + ParseType( line.NextToken() ); + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CRecognizerData::ParseResult(const TDesC& aDes) + { + _LIT(KECertain, "ECertain"); + _LIT(KEProbable, "EProbable"); + if (aDes.CompareF(KECertain) == 0) + { + iExpectedResult.iConfidence = CApaDataRecognizerType::ECertain; + } + else if (aDes.CompareF(KEProbable) == 0) + { + iExpectedResult.iConfidence = CApaDataRecognizerType::EProbable; + } + else + { + iExpectedResult.iConfidence = NOLANDMARKNUMBER; + } + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// +void CRecognizerData::ParseType(const TDesC& aDes) + { + _LIT8(KLmxType, "application/vnd.nokia.landmarkcollection+xml"); + _LIT8(KGpxType, "application/gps+xml"); + _LIT(KGpx, "gpx"); + _LIT(KLmx, "lmx"); + + TDataType dataLmx(KLmxType); + TDataType dataGpx(KGpxType); + + if (aDes.CompareF(KGpx) == 0) + { + iExpectedResult.iDataType = dataGpx; + } + else if (aDes.CompareF(KLmx) == 0) + { + iExpectedResult.iDataType = dataLmx; + } + else + { + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp43.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp43.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1665 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp43.h" + +#include +#include +#include +#include +#include +#include + +// CONST +_LIT(KFileName, "c:\\documents\\Tp43EncodeOutput.xml"); +_LIT(KFileName2, "c:\\documents\\Tp43EncodeOutputIncMode.xml"); +_LIT(KFileName3, "c:\\documents\\Tp43EncodeOutputCollectionData1.xml"); +_LIT(KFileName4, "c:\\documents\\Tp43EncodeOutputCollectionData2.xml"); +_LIT(KFileEmptyCollectionData, "c:\\documents\\Tp43EncodeOutputEmptyCollectionData.xml"); +_LIT(KFileEmptyCollectionData2, "c:\\documents\\Tp43EncodeOutputEmptyCollectionData2.xml"); +_LIT(KFileLongCollectionFieldName, "c:\\documents\\Tp43EncodeOutputLongCollectionField.xml"); + +// Filename with 260 characters +_LIT(KLongFileName, "c:\\File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); +_LIT(KEmptyFileName, ""); +_LIT8(KLongMimeType, "application/vnd.nokia.landmarkcollection+xmlFile123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); + +_LIT(KFileNameCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutput_Correct.xml"); +_LIT(KFileName2Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputIncMode_Correct.xml"); +_LIT(KFileName3Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputCollectionData1_Correct.xml"); +_LIT(KFileName4Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputCollectionData2_Correct.xml"); +_LIT(KFileEmptyCollectionDataCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputEmptyCollectionData_Correct.xml"); +_LIT(KFileEmptyCollectionData2Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputEmptyCollectionData2_Correct.xml"); +_LIT(KFileLongCollectionFieldNameCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputLongCollectionField_Correct.xml"); +_LIT(KErrorScenario4FileCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputErrorScenario4_Correct.xml"); +_LIT(KErrorScenario5FileCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputErrorScenario5_Correct.xml"); + +_LIT(KErrorTestFileName, "c:\\documents\\Tp43EncodeOutputErrorTest.xml"); +_LIT(KErrorScenario4File, "c:\\documents\\Tp43EncodeOutputErrorScenario4.xml"); +_LIT(KErrorScenario5File, "c:\\documents\\Tp43EncodeOutputErrorScenario5.xml"); + +// This number must be updated if any more landmarks are added +const TInt KNrOfAddedLandmarks = 7; + +const TInt KBufSize = 1024; + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp43::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::CloseTest() + { + iLog->Log(_L("CloseTest")); + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + } + +// --------------------------------------------------------- +// CPosTp43::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KFileName ); + + DeleteFileL(KFileName); + DeleteFileL(KFileName2); + DeleteFileL(KFileName3); + DeleteFileL(KFileName4); + DeleteFileL(KFileEmptyCollectionData); + DeleteFileL(KFileEmptyCollectionData2); + + + RemoveAllLmDatabasesL(); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + + // 2) Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KFileName); + CreateEncoderPartsL(); + + // 13 Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + // Check data + HBufC8* emptyBuffer=NULL; + ParseAndCheckDataFromEncoderL(KFileName, _L(""), _L(""), *emptyBuffer); + + // Repeate step 2-12, finalize with incremental mode and monitor progress + iLandmarkEncoder->SetOutputFileL(KFileName2); + CreateEncoderPartsL(); + + // 15 Finalize encoding with incremental mode and monitor progress + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + + ParseAndCheckDataFromEncoderL(KFileName2, _L(""), _L(""), *emptyBuffer); + + CleanupStack::PopAndDestroy(activeLmOperation); + + // 16 Repeat step 3-15, use buffer + CBufBase* myEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer); + + // 17a Repeat step 3-15, use buffer + iLog->Log(_L("Part 17a Repeat step 3-15 use buffer")); + CreateEncoderPartsL(); + + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + HBufC8* filecontent = HBufC8::NewLC(myEncoderBuffer->Size()); + TPtr8 ptr = filecontent->Des(); + myEncoderBuffer->Read(0, ptr, myEncoderBuffer->Size()); + ParseAndCheckDataFromEncoderL(KNullDesC, _L(""), _L(""), *filecontent); + myEncoderBuffer->Reset(); + CleanupStack::PopAndDestroy(filecontent); + CleanupStack::PopAndDestroy(myEncoderBuffer); + + // 17b Repeat step 3-15 use buffer, finalize with incremental mode and monitor progress + iLog->Log(_L("Part 17b Repeat step 3-15 use buffer")); + CBufBase* myEncoderBuffer2 = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer2); + + CreateEncoderPartsL(); + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + + HBufC8* filecontent2 = HBufC8::NewLC(myEncoderBuffer2->Size()); + TPtr8 ptr2 = filecontent2->Des(); + myEncoderBuffer2->Read(0, ptr2, myEncoderBuffer2->Size()); + + ParseAndCheckDataFromEncoderL(KNullDesC, _L(""), _L(""), *filecontent2); + + myEncoderBuffer2->Reset(); + CleanupStack::PopAndDestroy(filecontent2); + CleanupStack::PopAndDestroy(activeLmOperation); + CleanupStack::PopAndDestroy(myEncoderBuffer2); + + // 18 Use file when encoding, set output file + iLog->Log(_L("Part 18 Use file when encoding, set output file")); + iLandmarkEncoder->SetOutputFileL(KFileName3); + + // 19 Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameFile1")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionFile1")); + + CreateEncoderPartsL(); + + // Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + // Check data + ParseAndCheckDataFromEncoderL(KFileName3, _L("TP43CollectionDataNameFile1"), _L("TP43CollectionDataDescriptionFile1"), *emptyBuffer); + + // 20a Repeat step 3-17 Use file when encoding, set output file, finalize with incremental mode and monitor progress + iLog->Log(_L("Part 20a ")); + iLandmarkEncoder->SetOutputFileL(KFileName4); + + // Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameFile2")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionFile2")); + + CreateEncoderPartsL(); + + // finalize with incremental mode and monitor progress + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + CleanupStack::PopAndDestroy(activeLmOperation); + + // Check data + ParseAndCheckDataFromEncoderL(KFileName4, _L("TP43CollectionDataNameFile2"), _L("TP43CollectionDataDescriptionFile2"), *emptyBuffer); + + // 20b Use buffer when encoding + iLog->Log(_L("Part 20b ")); + CBufBase* myEncoderBuffer3 = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer3); + + // Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer1")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer1")); + CreateEncoderPartsL(); + + // Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + HBufC8* filecontent3 = HBufC8::NewLC(myEncoderBuffer3->Size()); + TPtr8 ptr3 = filecontent3->Des(); + myEncoderBuffer3->Read(0, ptr3, myEncoderBuffer3->Size()); + ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer1"), _L("TP43CollectionDataDescriptionBuffer1"), *filecontent3); + myEncoderBuffer3->Reset(); + CleanupStack::PopAndDestroy(filecontent3); + CleanupStack::PopAndDestroy(myEncoderBuffer3); + + + // 20c Repeat step 3-17 Use buffer when encoding, set output file, finalize with incremental mode and monitor progress + iLog->Log(_L("Part 20c ")); + CBufBase* myEncoderBuffer4 = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer4); + + // Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer2")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer2")); + + CreateEncoderPartsL(); + + // finalize with incremental mode and monitor progress + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + + HBufC8* filecontent4 = HBufC8::NewLC(myEncoderBuffer4->Size()); + TPtr8 ptr4 = filecontent4->Des(); + myEncoderBuffer4->Read(0, ptr4, myEncoderBuffer4->Size()); + ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer2"), _L("TP43CollectionDataDescriptionBuffer2"), *filecontent4); + myEncoderBuffer4->Reset(); + CleanupStack::PopAndDestroy(filecontent4); + + CleanupStack::PopAndDestroy(activeLmOperation); + CleanupStack::PopAndDestroy(myEncoderBuffer4); + + // 21 Use file when encoding, set output file + iLog->Log(_L("Part 21 ")); + iLandmarkEncoder->SetOutputFileL(KFileEmptyCollectionData); + // 22 Add collection data to the encoder, but without specifying name and description + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("")); + + CreateEncoderPartsL(); + + // Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + // Check data + ParseAndCheckDataFromEncoderL(KFileEmptyCollectionData, _L(""), _L(""), *emptyBuffer); + + // 23a Repeat step 3-17 Use file when encoding, set output file, finalize with incr. mode + iLog->Log(_L("Part 23a ")); + iLandmarkEncoder->SetOutputFileL(KFileEmptyCollectionData2); + // Add collection data to the encoder, but without specifying name and description + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("")); + + CreateEncoderPartsL(); + + // finalize with incremental mode and monitor progress + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + CleanupStack::PopAndDestroy(activeLmOperation); + + // Check data + ParseAndCheckDataFromEncoderL(KFileEmptyCollectionData, _L(""), _L(""), *emptyBuffer); + + // 23b Repeat step 3-17 Use buffer when encoding + iLog->Log(_L("Part 23b ")); + CBufBase* myEncoderBuffer5 = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer5); + + // Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer3")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer3")); + CreateEncoderPartsL(); + + // Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + // Check data here + HBufC8* filecontent5 = HBufC8::NewLC(myEncoderBuffer5->Size()); + TPtr8 ptr5 = filecontent5->Des(); + myEncoderBuffer5->Read(0, ptr5, myEncoderBuffer5->Size()); + ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer3"), _L("TP43CollectionDataDescriptionBuffer3"), *filecontent5); + myEncoderBuffer5->Reset(); + CleanupStack::PopAndDestroy(filecontent5); + CleanupStack::PopAndDestroy(myEncoderBuffer5); + + // 23c Repeat step 3-17 Use buffer when encoding, finalize with incremental mode and monitor progress + iLog->Log(_L("Part 23c ")); + CBufBase* myEncoderBuffer6 = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer6); + + // Add collection data to the encoder, name and description set + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer4")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer4")); + CreateEncoderPartsL(); + + // finalize with incremental mode and monitor progress + iOperation = iLandmarkEncoder->FinalizeEncodingL(); + + activeLmOperation = new(ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(activeLmOperation); + + // Progress is monitored in CLandmarkTestProcedureBase class + activeLmOperation->Start(iOperation); + CActiveScheduler::Start(); + + // Check for no errors + iLog->Log(_L("CheckOperationL")); + activeLmOperation->CheckOperationL(); + delete iOperation; + iOperation = NULL; + CleanupStack::PopAndDestroy(activeLmOperation); + + // Check data here + HBufC8* filecontent6 = HBufC8::NewLC(myEncoderBuffer6->Size()); + TPtr8 ptr6 = filecontent6->Des(); + myEncoderBuffer6->Read(0, ptr6, myEncoderBuffer6->Size()); + ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer4"), _L("TP43CollectionDataDescriptionBuffer4"), *filecontent6); + myEncoderBuffer6->Reset(); + CleanupStack::PopAndDestroy(filecontent6); + CleanupStack::PopAndDestroy(myEncoderBuffer6); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + DeleteFileL(KFileLongCollectionFieldName); + // Test with file + TestLongCollectionFieldsL(ETrue); + // Test with buffer + TestLongCollectionFieldsL(EFalse); + + // Check that all created XML files are correct by comparing to saved files + iLog->Log(_L("Comparing files...")); + + TFileName filename; + CreateCorrectXmlFileL( KFileNameCorrect, filename ); + CompareTwoFilesL(filename, KFileName); + + CreateCorrectXmlFileL( KFileName2Correct, filename ); + CompareTwoFilesL(filename, KFileName2); + + CreateCorrectXmlFileL( KFileName3Correct, filename ); + CompareTwoFilesL(filename, KFileName3); + + CreateCorrectXmlFileL( KFileName4Correct, filename ); + CompareTwoFilesL(filename, KFileName4); + + CreateCorrectXmlFileL( KFileEmptyCollectionDataCorrect, filename ); + CompareTwoFilesL(filename, KFileEmptyCollectionData); + + CreateCorrectXmlFileL( KFileEmptyCollectionData2Correct, filename ); + CompareTwoFilesL(filename, KFileEmptyCollectionData2); + + CreateCorrectXmlFileL( KFileLongCollectionFieldNameCorrect, filename ); + CompareTwoFilesL(filename, KFileLongCollectionFieldName); + + // Test for correct leave codes + TestErrorScenariosL(); + + // check for correct output + CreateCorrectXmlFileL( KErrorScenario4FileCorrect, filename ); + CompareTwoFilesL(filename, KErrorScenario4File); + + CreateCorrectXmlFileL( KErrorScenario5FileCorrect, filename ); + CompareTwoFilesL(filename, KErrorScenario5File); + + // Test to encode to file with long filename (more than 255 characters) + TestWithLongFileNameL(); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP43")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp43::CreateEncoderPartsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::CreateEncoderPartsL() + { + iLog->Log(_L("CreateEncoderPartsL")); + // 3 Add one landmark to be encoded (id7 name "Billigt" in categories 1-3,14-17) + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); + iLandmarkEncoder->AddLandmarkL(*lm1); + // Remove field 408 which is not exported + lm1->RemovePositionField(408); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + // 4 Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 5 Add one category to the latest added landmark + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + + // 6 Add one more landmark to be encoded (id52 "Kalles Hundgård" in category 19) + lm2 = iDatabase->ReadLandmarkLC(52); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 7 Add several global and local categories to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + landmarkCategory = categoryManager->ReadCategoryLC(26); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + landmarkCategory = categoryManager->ReadCategoryLC(25); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + TPosLmItemId globalCategoryId = categoryManager->GetGlobalCategoryL(3000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found1")); + User::Leave(-1); + } + + //globalCategoryId = categoryManager->GetGlobalCategoryL(6000); + globalCategoryId = categoryManager->GetGlobalCategoryL(15000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found2")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(categoryManager); + + // 8 Add one landmark (not containing any categories), id=11 "MLFW" + lm2 = iDatabase->ReadLandmarkLC(11); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 9 Add one more landmark (not containing any categories), id=56 "TE, Lund" + lm2 = iDatabase->ReadLandmarkLC(56); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 10 Add one category to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + landmarkCategory = categoryManager->ReadCategoryLC(18); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + + // 11 Add one landmark (not containing any categories), id=43 "asdf" + lm2 = iDatabase->ReadLandmarkLC(43); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 12 Add several local and global categories to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + landmarkCategory = categoryManager->ReadCategoryLC(23); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + landmarkCategory = categoryManager->ReadCategoryLC(17); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + + globalCategoryId = categoryManager->GetGlobalCategoryL(24000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found3")); + User::Leave(-1); + } + + + globalCategoryId = categoryManager->GetGlobalCategoryL(27000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + // 13) Add a landmark with fields that are encoded to XML set + lm1 = CreateXMLLandmarkLC(_L("TP43LandmarkWithAllXMLFields")); + AddAllXMLFieldsL(lm1); + iLandmarkEncoder->AddLandmarkL(*lm1); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 13) Add one global category (Garage) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(36000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found3")); + User::Leave(-1); + } + + // 14) Add one global category (Bus stop) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(39000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + // 15) Add one category (BurgerKing) to the latest added landmark + landmarkCategory = categoryManager->ReadCategoryLC(17); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + CleanupStack::PopAndDestroy(categoryManager); + iLog->Log(_L("CreateEncoderParts Done")); + } + +// --------------------------------------------------------- +// CPosTp43::PrintLandmarkIdFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::PrintLandmarkIdFieldsL(const CPosLandmark& aLandmark) + { + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + TBuf<150> buf; + TInt err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + TReal vertAcc(loc.VerticalAccuracy()); + TReal horAcc(loc.HorizontalAccuracy()); + TReal alt(loc.Altitude()); + TReal lon = loc.Longitude(); + TReal lat = loc.Latitude(); + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f srcRadius %f"), lon, lat, vertAcc, horAcc, alt, sourceR); + } + else + { + buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f "), lon, lat, vertAcc, horAcc, alt); + } + //iLog->Log(buf); + } + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + buf.Format(_L("IdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + //iLog->Log(buf); + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + } + } + +// --------------------------------------------------------- +// CPosTp43::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::PrintParsedDataFromEncoderL(const TDesC& aFile, const TDesC8& aBuffer) + { + iLog->Log(_L("PrintParsedDataFromEncoderL")); + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile != KNullDesC) + { + iLog->Log(_L("----->Using FILE<-------")); + iLandmarkParser->SetInputFileL(aFile); + } + else + { + iLog->Log(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + while (status == KPosLmOperationNotComplete) + { + //iLog->Log(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;i buf; + CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[i]); + + if (category->GlobalCategory()) buf.Append(_L("Global category: ")); + else buf.Append(_L("Local category: ")); + category->GetCategoryName(catName); + buf.Append(catName); + //iLog->Log(buf); + CleanupStack::PopAndDestroy(category); + } + PrintLandmarkIdFieldsL(*lm); + //iLog->Log(_L("---------->")); + PrintLandmarkIdFieldsL(*iLandmarks[number]); + //iLog->Log(_L("<----------")); + number++; + // CPosLmOperation::NextStep call will parse a new landmark. + CleanupStack::PopAndDestroy(lm); + } + + //iLog->Log(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + //iLog->Log(_L("----->CollectionData")); + + TBuf<100> buf; + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + buf.Format(_L("Collectiond Id: %d CollectionData: "), lmId); + buf.Append(first); + //iLog->Log(buf); + } + //else iLog->Log(_L("No collection data found 1")); + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + buf.Format(_L("Collectiond Id: %d CollectionData: "), lmId); + buf.Append(first); + //iLog->Log(buf); + } + //else iLog->Log(_L("No collection data found 2")); + } + + //iLog->Log(_L("<-----CollectionData")); + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("PrintParsedDataFromEncoderL Done")); + } + +// --------------------------------------------------------- +// CPosTp43::ParseAndCheckDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ParseAndCheckDataFromEncoderL(const TDesC& aFile , const TDesC& aCollectionName, + const TDesC& aCollectiondDescription, const TDesC8& aBuffer) + { + iLog->Log(_L("ParseAndCheckDataFromEncoderL")); + + PrintParsedDataFromEncoderL(aFile, aBuffer); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile != KNullDesC) + { + //iLog->Log(_L("----->Using FILE<-------")); + iLandmarkParser->SetInputFileL(aFile); + } + else + { + //iLog->Log(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iLog->Log(_L("ParseContentL")); + iOperation = iLandmarkParser->ParseContentL(); + iLog->Log(_L("ParseContentL Done")); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + // 1) Get the first landmark, "Billigt", no categories + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CleanupStack::PopAndDestroy(lm); + + // 2) Get LOG9, included category Pizzeria + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 1, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[0]); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(1); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(lm); + + // 3) Get Kalles Hundgård, included categories sjukhus, läkare, global Restaurant, Shop + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + if (array.Count()!=4) + { + iLog->Log(_L("ERROR: Wrong number of landmark categories")); + iErrorsFound++; + } + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + cat = categoryManager->ReadCategoryLC(26); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + category = iLandmarkParser->LandmarkCategoryLC(array[1]); + cat = categoryManager->ReadCategoryLC(25); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=1 Restaurant" here + category = iLandmarkParser->LandmarkCategoryLC(array[2]); + cat = categoryManager->ReadCategoryLC(27); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=5 Shop" here + if (array.Count()== 4) + { + category = iLandmarkParser->LandmarkCategoryLC(array[3]); + cat = categoryManager->ReadCategoryLC(31);//28 + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + } + + CleanupStack::PopAndDestroy(lm); + + // 4) Get MLFW, no categories + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CleanupStack::PopAndDestroy(lm); + + // 5) Get Te, Lund category Frisör + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 1, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + cat = categoryManager->ReadCategoryLC(18); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(lm); + + // 6) Get asdf, category Dagis, Burger King and global hotel, car park + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 4, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + cat = categoryManager->ReadCategoryLC(23); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + category = iLandmarkParser->LandmarkCategoryLC(array[1]); + cat = categoryManager->ReadCategoryLC(17); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=4 Hotel" here + category = iLandmarkParser->LandmarkCategoryLC(array[2]); + cat = categoryManager->ReadCategoryLC(34);//39 + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=9 Car Park" here + category = iLandmarkParser->LandmarkCategoryLC(array[3]); + cat = categoryManager->ReadCategoryLC(35);//30 + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(lm); + + // 7) Get TP43LandmarkWithAllXMLFields, category Burger King and global Garage, Bus stop + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 3, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + //Check global category "id=4 Garage" here + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + cat = categoryManager->ReadCategoryLC(38);//31 + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=10 Bus Stop" here + category = iLandmarkParser->LandmarkCategoryLC(array[1]); + cat = categoryManager->ReadCategoryLC(39);//34 + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + // Check local category here, burger king + category = iLandmarkParser->LandmarkCategoryLC(array[2]); + cat = categoryManager->ReadCategoryLC(17); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + CleanupStack::PopAndDestroy(lm); + + // Check that correct number of landmarks has been parsed + if (number != KNrOfAddedLandmarks) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != KNrOfAddedLandmarks) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(&array); + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + // Check that collection data and name is correct + if (lmId == EPosLmCollDataCollectionName) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + if (aCollectionName != first) + { + + iLog->Log(_L("CollectionName does not match")); + User::Leave(-1); + } + } + else if (lmId == EPosLmCollDataNone) + { + if (aCollectionName != KNullDesC) + { + iLog->Log(_L("ERROR: CollectionName should be defined")); + iErrorsFound++; + } + } + else + { + iLog->Log(_L("Wrong order of collection data1")); + User::Leave(-1); + } + + lmId = iLandmarkParser->NextCollectionDataId(lmId); + + if (lmId == EPosLmCollDataCollectionDescription) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + if (aCollectiondDescription != first) + { + + iLog->Log(_L("CollectionDescription does not match")); + User::Leave(-1); + } + } + else if (lmId == EPosLmCollDataNone) + { + if (aCollectiondDescription != KNullDesC) + { + + iLog->Log(_L(" CollectionDescription should be defined")); + User::Leave(KErrNone); + } + } + else + { + iLog->Log(_L("Wrong order of collection data2 ")); + User::Leave(-1); + } + + // Test with some non existing ids + lmId = iLandmarkParser->NextCollectionDataId((TPosLmCollectionDataId)66700); + if (lmId != EPosLmCollDataNone) + { + iLog->Log(_L("ERROR: No collection data should be found")); + iErrorsFound++; + } + + TPtrC empty = iLandmarkParser->CollectionData((TPosLmCollectionDataId)66700); + if (empty != KNullDesC) + { + iLog->Log(_L("ERROR: CollectionData should be emtpy")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + + CleanupStack::PopAndDestroy(categoryManager); + iLandmarks.ResetAndDestroy(); + + iLog->Log(_L("ParseAndCheckDataFromEncoderL Done")); + } + +// --------------------------------------------------------- +// CPosTp43::CompareTwoFilesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::CompareTwoFilesL(const TDesC16& aCorrectFile, const TDesC16& aFile) +{ + iLog->Log(_L("ComparingTwoFilesL")); + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + TBuf<150> buf; + buf.Append(_L("Comparing files ")); + buf.Append(aCorrectFile); + buf.Append(_L(" and ")); + buf.Append(aFile); + iLog->Log(buf); + + CleanupClosePushL(correctFile); + CleanupClosePushL(file); + TInt err = KErrNone; + err = correctFile.Open(iFileSession, aCorrectFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L(" Problem with correct file")); + User::Leave(err); + } + err = file.Open(iFileSession, aFile, EFileRead); + if (err != KErrNone) + { + iLog->Log(_L(" Problem with encoded XML file")); + User::Leave(err); + } + + TBuf correctLine; + TBuf line; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if (err == KErrEof) done = ETrue; + + if (correctLine.CompareC(line) != KErrNone) + { + TBuf<50> buffe; + buffe.Format(_L("ERROR in XML file on line %d: "), lineNr); + iLog->Log(buffe); + iLog->Log(correctLine); + iLog->Log(line); + iErrorsFound++; + } + } + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + } + +// --------------------------------------------------------- +// CPosTp43::TestLongCollectionFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::TestLongCollectionFieldsL(TBool aUseFile) + { + iLog->Log(_L("TestLongCollectionFieldsL")); + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + CBufBase* myEncoderBuffer = NULL; + HBufC8* filecontent = NULL; + + if (aUseFile) + { + // 2) Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KFileLongCollectionFieldName); + } + else + { + // 2) Use buffer for encoding + myEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + CleanupStack::PushL(myEncoderBuffer); + } + + // 300 characters + _LIT(KLongFieldName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + _LIT(KLongFieldDescription, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, KLongFieldName); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, KLongFieldDescription); + + iLog->Log(_L("Create Data...")); + // 3) Add one landmark to be encoded (id7 name "Billigt" in categories 1-3,14-17) + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); + iLandmarkEncoder->AddLandmarkL(*lm1); + // Remove field 408 which is not exported + lm1->RemovePositionField(408); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + // 4) Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 5) Add one category (pizzeria) to the latest added landmark + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + + // 6) Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + // Check data + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + if (aUseFile) + { + iLog->Log(_L("----->Using FILE<-------")); + iLandmarkParser->SetInputFileL(KFileLongCollectionFieldName); + } + else + { + iLog->Log(_L("----->Using BUFFER<-------")); + filecontent = HBufC8::NewLC(myEncoderBuffer->Size()); + TPtr8 ptr = filecontent->Des(); + myEncoderBuffer->Read(0, ptr, myEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*filecontent); + ptr.Zero(); + } + + iLog->Log(_L("ParseContentL")); + iOperation = iLandmarkParser->ParseContentL(); + iLog->Log(_L("ParseContentL Done")); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + + // 1) Get the first landmark, "Billigt", no categories + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CleanupStack::PopAndDestroy(lm); + + iLog->Log(_L("----->CollectionData")); + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + // First should be name + TPtrC first = iLandmarkParser->CollectionData(lmId); + if (first.Compare(KLongFieldName) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong name!!")); + iErrorsFound++; + } + + lmId = iLandmarkParser->NextCollectionDataId(lmId); + TPtrC next = iLandmarkParser->CollectionData(lmId); + if (next.Compare(KLongFieldDescription) != KErrNone) + { + iLog->Log(_L("ERROR: Wrong description!!")); + iErrorsFound++; + } + + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + iLog->Log(_L("ERROR: Wrong description!!")); + iErrorsFound++; + } + + + iLog->Log(_L("<-----CollectionData")); + CleanupStack::PopAndDestroy(&array); + if (!aUseFile) + { + CleanupStack::PopAndDestroy(filecontent); + myEncoderBuffer->Reset(); + CleanupStack::PopAndDestroy(myEncoderBuffer); + } + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + iLandmarks.ResetAndDestroy(); + iLog->Log(_L("TestLongCollectionFieldsL Done")); + } + +// --------------------------------------------------------- +// CPosTp43::TestErrorScenariosL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::TestErrorScenariosL() + { + iLog->Log(_L("TestErrorScenariosL")); + + TInt err = KErrNone; + TRAP(err, ErrorScenario1L()); + if (err != KErrAlreadyExists) //LogErrorAndLeave(_L("ErrorScenario1L did not leave with error KErrAlreadyExists")); + { + iLog->Log(_L(" ErrorScenario1L did not leave with error KErrAlreadyExists")); + User::Leave(err); + } + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + DeleteFileL(KErrorTestFileName); + + ErrorScenario2L(); + DeleteFileL(KErrorTestFileName); + + TRAP(err, ErrorScenario3L()); + if (err != KErrAlreadyExists)// LogErrorAndLeave(_L("ErrorScenario3L did not leave with error KErrAlreadyExists")); + { + iLog->Log(_L(" ErrorScenario3L did not leave with error KErrAlreadyExists")); + User::Leave(err); + } + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + DeleteFileL(KErrorTestFileName); + + TRAP(err, ErrorScenario4L()); + if (err != KErrNone) + { + iLog->Log(_L("ERROR: Adding meta data \"out-of-range\" should be silently ignored, instead leave error")); + iErrorsFound++; + } + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + DeleteFileL(KErrorTestFileName); + + ErrorScenario5L(); + + } + +// --------------------------------------------------------- +// CPosTp43::ErrorScenario1L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ErrorScenario1L() + { + iLog->Log(_L("ErrorScenario1L")); + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + + RFile file; + CleanupClosePushL(file); + + // Make sure that file exist + TInt err = file.Replace(iFileSession, KErrorTestFileName, EFileShareAny); + if (err != KErrNone) + { + iLog->Log(_L("Error when replacing file ")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(&file); + + // 2) Use file for encoding, set output file should leave + iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; +} + +// --------------------------------------------------------- +// CPosTp43::ErrorScenario2L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ErrorScenario2L() + { + iLog->Log(_L("ErrorScenario2L")); + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // 2) Use file for encoding, set output file + DeleteFileL(KErrorTestFileName); + iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); + + RFile file; + CleanupClosePushL(file); + + // Make sure that file exist + TInt err = file.Open(iFileSession, KErrorTestFileName, EFileShareAny); + if (err != KErrInUse) //LogErrorAndLeave(_L("File should not be able to open")); + { + iLog->Log(_L("File should not be able to open")); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(&file); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; +} + +// --------------------------------------------------------- +// CPosTp43::ErrorScenario3L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ErrorScenario3L() + { + iLog->Log(_L("ErrorScenario3L")); + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // 2) Use file for encoding, set output file + DeleteFileL(KErrorTestFileName); + iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); + + // AddCollectionDataL(id) with same id twice should leave + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("A yada yada collextion of landmarks")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("Another yada yada collextion of landmarks")); + + // We should never get here + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; +} + +// --------------------------------------------------------- +// CPosTp43::ErrorScenario4L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ErrorScenario4L() + { + iLog->Log(_L("ErrorScenario4L")); + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // 2) Use file for encoding, set output file + DeleteFileL(KErrorScenario4File); + iLandmarkEncoder->SetOutputFileL(KErrorScenario4File); + + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("A yada yada name for landmarks")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("A yada yada description for landmarks")); + + // Will be silently ignored + iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)5, _L("A dummy string")); + + TInt pos = EPosLmCollDataContentSpecificDataBegin; + _LIT(KFormatString, "Dummmmmmmmmmmy string: %d"); + TBuf<100> buf; + + for (TInt i=0;i<10;i++) + { + buf.Format(KFormatString, pos); + iLog->Log(buf); + // Will be silently ignored + iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)pos, buf); + pos++; + } + + // Will be silently ignored + iLog->Log(_L("Adding the last meta data collection allowed")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataLast, _L("The last dummy string")); + iLog->Log(_L("After adding the last meta data collection allowed")); + + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); + iLandmarkEncoder->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; +} + +// --------------------------------------------------------- +// CPosTp43::ErrorScenario5L +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::ErrorScenario5L() + { + iLog->Log(_L("ErrorScenario5L")); + + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // 2) Use file for encoding, set output file + DeleteFileL(KErrorScenario5File); + iLandmarkEncoder->SetOutputFileL(KErrorScenario5File); + + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("A yada yada name for landmarks")); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("")); + + CPosLandmark* lm1 = CreateXMLLandmarkLC(_L("")); + iLandmarkEncoder->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + + lm1 = CreateXMLLandmarkLC(_L("")); + iLandmarkEncoder->AddLandmarkL(*lm1); + CleanupStack::PopAndDestroy(lm1); + + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; +} + +// --------------------------------------------------------- +// CPosTp43::TestWithLongFileNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp43::TestWithLongFileNameL() + { + iLog->Log(_L("TestWithLongFileNameL")); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + TInt errorsFound = KErrNone; + + // 2) Set file with long filename (more than 255 characters) + TRAPD(err, iLandmarkEncoder->SetOutputFileL(KLongFileName)); + + + + if ( err != KErrBadName ) + { + TBuf<100> buf; + buf.Format(_L("ERROR: SetInputFileL should leave with KErrBadName, instead err: %d"), err); + iLog->Log(buf); + iErrorsFound++; + } + + + // 3) Set file to 0 characters + TRAP(err, iLandmarkEncoder->SetOutputFileL(KEmptyFileName)); + if (err != KErrBadName) + { + TBuf<100> buf; + buf.Format(_L("ERROR: SetOutputFileL(KEmptyFileName) should leave with KErrBadName, instead err: %d"), err); + iLog->Log(buf); + errorsFound++; + } + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + // Try to create an encoder with the long file name, should leave with KErrNotSupported + TRAP(err, CPosLandmarkEncoder::NewL(KLongMimeType)); + if (err != KErrNotSupported) + { + iLog->Log(_L("CPosLandmarkEncoder::NewL should leave with KErrNotSupported")); + User::Leave(err); + } + + if (errorsFound != KErrNone) + { + iLog->Log(_L("SetOutputFileL leaved with wrong error code")); + User::Leave(-1); + + } + + + + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp44.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp44.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,730 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp44.h" +#include +#include +#include +#include +#include + +_LIT8(KNonExistingMimeType1, "Application/vnd.nokia.landmarkcollection+xml"); +_LIT8(KNonExistingMimeType2, "application/vnd.nokia.kokoibollen"); +_LIT8(KEmptyMimeType, ""); +_LIT(KFileName, "c:\\documents\\SomeDummyFile.xml"); +_LIT(KFileName2, "c:\\documents\\SomeDummyFile2.xml"); +_LIT(KFileName3, "c:\\documents\\SomeDummyFile3.xml"); +_LIT(KFileName4, "c:\\documents\\SomeDummyFile4.xml"); +_LIT(KFileName5, "c:\\documents\\SomeDummyFile5.xml"); +_LIT(KFileName6, "c:\\documents\\SomeDummyFile6.xml"); +_LIT(KFileName7, "c:\\documents\\SomeDummyFile7.xml"); +_LIT(KFileName8, "c:\\documents\\SomeDummyFile8.xml"); +_LIT(KFileName9, "c:\\documents\\SomeDummyFile9.xml"); +_LIT(KFileName9a, "c:\\documents\\SomeDummyFile9a.xml"); +_LIT(KFileName10, "c:\\documents\\SomeDummyFile10.xml"); +_LIT(KFileName11, "c:\\documents\\SomeDummyFile11.xml"); +_LIT(KFileName12, "c:\\documents\\SomeDummyFile12.xml"); +_LIT(KFileName13, "c:\\documents\\SomeDummyFile13.xml"); +_LIT(KFileName14, "c:\\documents\\SomeDummyFile14.xml"); +_LIT(KFileName15, "c:\\documents\\SomeDummyFile15.xml"); +_LIT(KFileName16, "c:\\documents\\SomeDummyFile16.xml"); +_LIT(KFileName17, "c:\\documents\\SomeDummyFile17.xml"); +_LIT(KFileName18, "c:\\documents\\SomeDummyFile18.xml"); + + + +// More than 255 characters +_LIT(KLongFileName, "c:\\SomeDummeFilewithVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongVeryLongFileName.xml"); + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp44::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp44::StartL() + { + + BaflUtils::EnsurePathExistsL( iFileSession, KFileName ); + + MakeSurePanicDebugFileExistsL(); + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + delete iDatabase; + iDatabase = NULL; + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + // <<<<<<<<<<<<<>>>>>>>>>>>>>>>>>> + iLog->Log(_L(">>>>>>>Start Panic test<<<<<<<<<")); + + iExpectedExitType = ExitPanic; + // Add collection data after landmarks has been added to encoder + iLog->Log(_L("Panic test 1")); +// DeleteFileL(KFileName); + iTestCase = 1; + iExpectedErrorCode = EPosLmProtocolBreak; + ResumeThreadAndVerifyExit(); + + // Add collection data after landmarks has been added to encoder + iLog->Log(_L("Panic test 2")); + //DeleteFileL(KFileName); + iTestCase = 2; + iExpectedErrorCode = EPosLmProtocolBreak; + ResumeThreadAndVerifyExit(); + + // Try to use encoder after finalization + iLog->Log(_L("Panic test 3")); + //DeleteFileL(KFileName); + iTestCase = 3; + iExpectedErrorCode = EPosLmProtocolBreak; + ResumeThreadAndVerifyExit(); + + // 4 The client deletes the operation object before the encoding has been + // finalized and then tries to use the encoder object.Should cause Panic and FileLock should have been released + iLog->Log(_L("Panic test 4")); + //DeleteFileL(KFileName); + iTestCase = 4; + iExpectedErrorCode = EPosLmProtocolBreak; + ResumeThreadAndVerifyExit(); + // Check that fileLock has been released + RFile file; + CleanupClosePushL(file); + // Make sure that file exist + TInt err = file.Open(iFileSession, KFileName, EFileShareAny); + if (err != KErrNone) //LogErrorAndLeave(_L("File should be able to open")); + { + iLog->Log(_L("File should be able to open")); + User::Leave(err); + + } + CleanupStack::PopAndDestroy(&file); + iLog->Log(_L("FileLock has been released")); + + // 5 The client tries to specify a collection id already added. Should cause a leave with -11 + iLog->Log(_L("Leave test 5")); +// DeleteFileL(KFileName); + iTestCase = 5; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrAlreadyExists; + ResumeThreadAndVerifyExit(); + + // 6 The client tries to specify a mime type that does not exist. Should cause a leave with KErrNotSupported + iLog->Log(_L("Leave test 6")); +// DeleteFileL(KFileName); + iTestCase = 6; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNotSupported; + ResumeThreadAndVerifyExit(); + + // 7 The client tries to specify a output file that already exists. Shoule leave with KErrAlreadyExists + iLog->Log(_L("Leave test 7")); + iTestCase = 7; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrAlreadyExists; + ResumeThreadAndVerifyExit(); + + // 8 The client only specifies a collection and then finalize the encoding. + iLog->Log(_L("Panic test 8")); +// DeleteFileL(KFileName); + iTestCase = 8; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosLmProtocolBreak; + ResumeThreadAndVerifyExit(); + + // 9a Export landmark with nonexisting id (positive id), should leave with KErrNotFound + iLog->Log(_L("Panic test 9a")); +// DeleteFileL(KFileName); + iTestCase = 9; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNotFound; + ResumeThreadAndVerifyExit(); + + // 9b Export landmark with nonexisting id (negative id), should leave with KErrNotFound + iLog->Log(_L("Leave test 9b")); +// DeleteFileL(KFileName); + iTestCase = 10; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNotFound; + ResumeThreadAndVerifyExit(); + + // 10 Delete export object before completion and then finalize + iLog->Log(_L("Leave test 10")); +// DeleteFileL(KFileName); + iTestCase = 11; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosLmProtocolBreak; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNone; + ResumeThreadAndVerifyExit(); + + // 11 The client creates an encoder and by using the Landmark API + // tries to export landmarks with invalid transfer option. Should cause Panic + iLog->Log(_L("Panic test 11")); +// DeleteFileL(KFileName); + iTestCase = 12; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosLmInvalidArgument; + ResumeThreadAndVerifyExit(); + + // 12 The client creates an encoder by using the file option and + // adds some landmarks but instead of finalizing the encoding a new file is set. + iLog->Log(_L("Leave test 12")); +// DeleteFileL(KFileName); +// DeleteFileL(KFileName2); + iTestCase = 13; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNone; + ResumeThreadAndVerifyExit(); + + // 13 The client creates an encoder by using the file option and + // adds a collection data with EPosLmCollDataNone, should Panic with EPosLmInvalidArgument + iLog->Log(_L("Leave test 13")); +// DeleteFileL(KFileName); +// DeleteFileL(KFileName2); + iTestCase = 14; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosLmInvalidArgument; + ResumeThreadAndVerifyExit(); + + // 14 The client tries to specify a mime type that does not exist. Should cause a leave with KErrNotSupported + // the mime type name is similar to KLmxMimeType but contains capital letters + iLog->Log(_L("Leave test 14")); +// DeleteFileL(KFileName); + iTestCase = 15; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrNotSupported; + ResumeThreadAndVerifyExit(); + + // 15 The client creates an encoder and by using the Landmark API + // tries to export landmarks with invalid transfer option. Should cause Panic + iLog->Log(_L("Panic test 15")); +// DeleteFileL(KFileName); + iTestCase = 16; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosLmInvalidArgument; + ResumeThreadAndVerifyExit(); + + // 16 Export landmark with empty subset of ids, should leave with KErrArgument + iLog->Log(_L("Leave test 16")); +// DeleteFileL(KFileName); + iTestCase = 17; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrArgument; + ResumeThreadAndVerifyExit(); + +#if 0 + // 17 Try to create encoder with empty mime type + // TE: the REComSession::CreateImplementationL( leaves with KErrArgument which I think is acceptable + // Nokia: This is not part of API definition, case removed + iLog->Log(_L("Leave test 17")); +// DeleteFileL(KFileName); + iTestCase = 18; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrArgument; + ResumeThreadAndVerifyExit(); +#endif + +#ifdef __WINS__ + // 18 Try to create encoder with a very long file name and export one landmark + iLog->Log(_L("Leave test 18")); + iTestCase = 19; + + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrBadName; + + ResumeThreadAndVerifyExit(); +#endif + iLog->Log(_L(">>>>>>>Panic test Done<<<<<<<<<")); + } + +// --------------------------------------------------------- +// CPosTp44::ResumeThreadAndVerifyExit +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp44::ResumeThreadAndVerifyExit() + { + iLog->Log(_L("ResumeThreadAndVerifyExit")); + _LIT(KPanicErr, "Method didn't Panic when expected"); + _LIT(KPanicCodeErr, "Paniced with unexpected panic code"); + _LIT(KLeaveErr, "Method didn't end correctly"); + _LIT(KLeaveCodeErr, "Unexpected leave error"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + User::WaitForRequest(status); + + + // Used for debugging + TBuf<100> buf; + buf.Format(_L("ExitType %d Exit reason %d"), iThread.ExitType(), iThread.ExitReason()); + iLog->Log(buf); + + if (iExpectedExitType == ExitPanic) + { + AssertTrueSecL(iThread.ExitType() == EExitPanic, KPanicErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KPanicCodeErr); + } + else if (iExpectedExitType == ExitLeave) + { + AssertTrueSecL(iThread.ExitType() == EExitKill, KLeaveErr); + AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KLeaveCodeErr); + } + + iThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp44::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp44::CloseTest() + { + iLog->Log(_L("CloseTest")); + iThread.Close(); + + delete iDatabase; + iDatabase = NULL; + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp44::DeleteEncoderCallback +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp44::DeleteEncoderCallback(TAny* aSelf) + { + CPosLandmarkEncoder* encoder = static_cast(aSelf); + delete encoder; + return 0; + } + +// --------------------------------------------------------- +// CPosTp44::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp44::RunPanicTestL(TAny* aData) + { + CPosTp44* self = reinterpret_cast(aData); + + if (self->iTestCase == 1) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder *landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName); + // Add landmark to be encoded + CPosLandmark* lm = database->ReadLandmarkLC(1); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Add one more landmark to be encoded + lm = database->ReadLandmarkLC(2); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Add collection data after that landmarks has been added, should cause Panic + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 2) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName3); + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*database); + CleanupStack::PushL(categoryManager); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); + // Add one category when no landmark has been addded , should cause Panic + landmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + } + else if (self->iTestCase == 3) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName4); + // Add landmark to be encoded + CPosLandmark* lm = database->ReadLandmarkLC(1); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Finalize + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + // Try to use encoder after finalization, should cause Panic + lm = database->ReadLandmarkLC(2); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + else if (self->iTestCase == 4) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName5); + // Add landmark to be encoded + CPosLandmark* lm = database->ReadLandmarkLC(1); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Finalize + CPosLmOperation* op = landmarkEncoder->FinalizeEncodingL(); + delete op; + op = NULL; + // Try to use encoder after deletion of object, should cause Panic + lm = database->ReadLandmarkLC(2); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + } + else if (self->iTestCase == 5) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName6); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + // Add same collection data again, should cause leave + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName2")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 6) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create encoder with invalid MIME type, should leave with KErrNotSupported + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KNonExistingMimeType2); + landmarkEncoder->SetOutputFileL(KFileName7); + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 7) + { + RFs fs; + RFile file; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CleanupClosePushL(file); + + // Make sure that file exist + TInt err = file.Create(fs, KFileName8, EFileShareAny); + // Should never happen + if (err != KErrNone) User::Leave(666); + + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&fs); + + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use same file for encoding, set output file should leave + landmarkEncoder->SetOutputFileL(KFileName8); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 8) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName9); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + // Finalize without adding any landmarks, should cause panic + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 9 || self->iTestCase == 10) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + if(self->iTestCase == 9) + landmarkEncoder->SetOutputFileL(KFileName9a); + if(self->iTestCase == 10) + landmarkEncoder->SetOutputFileL(KFileName10); + + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + + RArray arr; + CleanupClosePushL(arr); + arr.Append(1); + arr.Append(15); + arr.Append(21); + arr.Append(38); + arr.Append(32); + arr.Append(12); + + if (self->iTestCase == 9) + { + // 9a + // Should never exist + arr.Append(666); + } + else if (self->iTestCase == 10) + { + // 9b + // Should never exist, + TInt dummy = -666; + arr.Append(dummy); + } + // Should leave with KErrNotFound + ExecuteAndDeleteLD(database->ExportLandmarksL(*landmarkEncoder, arr, CPosLandmarkDatabase::EDefaultOptions)); + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 11) + { + // Delete export object before completion and then finalize + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName11); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + + RArray arr; + CleanupClosePushL(arr); + arr.Append(1); + arr.Append(15); + arr.Append(21); + arr.Append(38); + arr.Append(32); + arr.Append(12); + + // Delete encoder from callback + TCallBack callback(DeleteEncoderCallback, landmarkEncoder); + CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); + CleanupStack::PushL(periodicTimer); + periodicTimer->Start(1, 1, callback); + + ExecuteAndDeleteLD(database->ExportLandmarksL(*landmarkEncoder, arr, CPosLandmarkDatabase::EDefaultOptions)); + // Try to FinalizeEncodingL + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + + CleanupStack::PopAndDestroy(periodicTimer); + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 12) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName12); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + + RArray arr; + CleanupClosePushL(arr); + arr.Append(1); + arr.Append(15); + arr.Append(21); + arr.Append(38); + arr.Append(32); + arr.Append(12); + + // Export with invalid transfer options, should panic + ExecuteAndDeleteLD(database->ExportLandmarksL(*landmarkEncoder, arr, 666)); + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 13) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + CleanupStack::PushL(landmarkEncoder); + landmarkEncoder->SetOutputFileL(KFileName13); + // Add landmark to be encoded + CPosLandmark* lm = database->ReadLandmarkLC(1); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Set new output file instead of finalization + landmarkEncoder->SetOutputFileL(KFileName2); + + // Check that filelock has been released + RFs fs; + RFile file; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CleanupClosePushL(file); + // Make sure that file exist + TInt err = file.Open(fs, KFileName13, EFileShareAny); + if (err != KErrNone) User::Leave(667); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&fs); + + // Add landmark to be encoded + lm = database->ReadLandmarkLC(11); + landmarkEncoder->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + // Finalize + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 14) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + CleanupStack::PushL(landmarkEncoder); + landmarkEncoder->SetOutputFileL(KFileName14); + // Add collection data of type EPosLmCollDataNone, should panic + landmarkEncoder->AddCollectionDataL(EPosLmCollDataNone, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 15) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create encoder with invalid MIME type, should leave with KErrNotSupported + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KNonExistingMimeType1); + landmarkEncoder->SetOutputFileL(KFileName15); + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 16) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName16); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + + RArray arr; + CleanupClosePushL(arr); + arr.Append(1); + arr.Append(15); + arr.Append(21); + arr.Append(38); + arr.Append(32); + arr.Append(12); + + // Export with invalid transfer options, should panic + ExecuteAndDeleteLD(database->ExportLandmarksL(*landmarkEncoder, arr, 0x04)); + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 17) + { + // Export with empty landmark array + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + landmarkEncoder->SetOutputFileL(KFileName17); + // Add collection data + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + + RArray arr; + CleanupClosePushL(arr); + + ExecuteAndDeleteLD(database->ExportLandmarksL(*landmarkEncoder, arr, CPosLandmarkDatabase::EDefaultOptions)); + ExecuteAndDeleteLD(landmarkEncoder->FinalizeEncodingL()); + CleanupStack::PopAndDestroy(&arr); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 18) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create encoder with empty MIME type, should leave with KErrArgument + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KEmptyMimeType); + landmarkEncoder->SetOutputFileL(KFileName18); + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 19) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create encoder with long file name, should leave with KErrBadName + CPosLandmarkEncoder* landmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Should leave here + landmarkEncoder->SetOutputFileL(KLongFileName); + landmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP44CollectionDataName")); + CleanupStack::PopAndDestroy(landmarkEncoder); + CleanupStack::PopAndDestroy(database); + } + } + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp44::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp44::CreateThreadL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp44::CreateThreadL() + { + _LIT(KThreadName, "Tp44testthread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + TBuf<100> buf; + buf.Format(KThreadName, iTestCase); + + TInt err=0; + err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp45.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp45.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,805 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp45.h" +#include +#include +#include +#include + + +// CONSTANTS +const TInt KNoCategoriesTp45 = 100; +// Filename with 260 characters +_LIT(KLongFileName, "c:\\File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); +// Filename with 264 characters +_LIT(KLongFileName2, "c:\\File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12.txt"); + +_LIT(KDefaultOptions, "c:\\system\\test\\testdata\\TP45-DefOptions.xml"); +_LIT(KInclCategories, "c:\\system\\test\\testdata\\TP45-IncCategories.xml"); +_LIT(KExclCategories, "c:\\system\\test\\testdata\\TP45-ExcCategories.xml"); +_LIT(KOneLandmark, "c:\\system\\test\\testdata\\TP45-OneLandmark.xml"); +_LIT(KTwoLandmarks, "c:\\system\\test\\testdata\\TP45-TwoLandmarks.xml"); +_LIT(KTwoLandmarksWithColData, "c:\\system\\test\\testdata\\TP45-TwoLandmarksWithCollData.xml"); + +_LIT(KFileSync, "c:\\documents\\TP45-DefOptions.xml"); +_LIT(KFileInc, "c:\\documents\\TP45-DefOptionsInc.xml"); +_LIT(KFileWait4Req, "c:\\documents\\TP45-DefOptionsWait4Req.xml"); +_LIT(KBufferSync, "c:\\documents\\TP45-DefOptionsBuffer.xml"); +_LIT(KBufferInc, "c:\\documents\\TP45-DefOptionsBufferInc.xml"); +_LIT(KBufferWait4Req, "c:\\documents\\TP45-DefOptionsBufferWait4Req.xml"); + +_LIT(KFileSync2, "c:\\documents\\TP45-IncCategories.xml"); +_LIT(KFileInc2, "c:\\documents\\TP45-IncCategoriesInc.xml"); +_LIT(KFileWait4Req2, "c:\\documents\\TP45-IncCategoriesWait4Req.xml"); +_LIT(KBufferSync2, "c:\\documents\\TP45-IncCategoriesBuffer.xml"); +_LIT(KBufferInc2, "c:\\documents\\TP45-IncCategoriesBufferInc.xml"); +_LIT(KBufferWait4Req2, "c:\\documents\\TP45-IncCategoriesBufferWait4Req.xml"); + +_LIT(KFileSync3, "c:\\documents\\TP45-ExcCategories.xml"); +_LIT(KFileInc3, "c:\\documents\\TP45-ExcCategoriesInc.xml"); +_LIT(KFileWait4Req3, "c:\\documents\\TP45-ExcCategoriesWait4Req.xml"); +_LIT(KBufferSync3, "c:\\documents\\TP45-ExcCategoriesBuffer.xml"); +_LIT(KBufferInc3, "c:\\documents\\TP45-ExcCategoriesBufferInc.xml"); +_LIT(KBufferWait4Req3, "c:\\documents\\TP45-ExcCategoriesBufferWait4Req.xml"); + +_LIT(KFileSync4, "c:\\documents\\TP45-OneLandmark.xml"); +_LIT(KFileInc4, "c:\\documents\\TP45-OneLandmarkInc.xml"); +_LIT(KFileWait4Req4, "c:\\documents\\TP45-OneLandmarkWait4Req.xml"); + +_LIT(KFileSync5, "c:\\documents\\TP45-TwoLandmarks.xml"); +_LIT(KFileInc5, "c:\\documents\\TP45-TwoLandmarksInc.xml"); +_LIT(KFileWait4Req5, "c:\\documents\\TP45-TwoLandmarksWait4Req.xml"); + +_LIT(KFileSync6, "c:\\documents\\TP45-TwoLandmarksWithCollData.xml"); + +_LIT(KFileCancelled, "c:\\documents\\TP45-Cancelled.xml"); + +_LIT(KFileCancelledInCallback, "c:\\documents\\TP45-CancelledInCallback.xml"); + +_LIT(KTmpFile, "c:\\documents\\TMP.xml"); + +//const TPosLmItemId KGlobalCategoryId = 2; +//const TPosLmItemId KGlobalCategoryId2 = 4; +const TPosLmItemId KGlobalCategoryId = 5; +const TPosLmItemId KGlobalCategoryId2 = 9; + +const TPosLmItemId KLandmarkId = 3; +const TPosLmItemId KLandmarkId2 = 1; + +const TInt KMaxCancelled = 10; + +const TInt KMaxCancelledInCallback = 50; + +_LIT(KCollectionName, "TP45-CollectionName"); +_LIT(KCollectionDes, "TP45-Description"); + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp45::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iDatabase; + delete iLandmarkEncoder; + delete iBuffer; + + // Added for BC testing + delete iCategoryManager; + iGlobalCategoryIds.Close(); + iGlobalCategoryNames.Close(); + iGlobalCategoryTestNames.Close(); + + iCategories.ResetAndDestroy(); + iCategories.Close(); + RemoveGlobalCategoriesL(); + } +// --------------------------------------------------------- +// CPosTp45::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KTmpFile ); + + RemoveDefaultDbL(); + RemoveGlobalCategoriesL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + + iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); + ExecuteAndDeleteLD(iDatabase->CompactL()); + + // Setup global category info + SetupGlobalCategoriesL(); + + AddLandmarksL(); + AddCategoriesL(); + + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + + TestErrorCodesL(); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + iLogToFile = ETrue; + TBool useWaitForRequest = ETrue; + +// Exporting all landmarks to file + iLog->Log(_L("Exporting all landmarks syncronously to file")); + ExportLandmarksL(KFileSync, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Exporting all landmarks incrementally to file")); + ExportLandmarksIncL(KFileInc, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks incrementally using User::WaitForRequest() to file")); + ExportLandmarksIncL(KFileWait4Req, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, useWaitForRequest); + + RenameGlobalCategoryL(); + +// Exporting with global cateogries to file + iLog->Log(_L("Exporting all landmarks with global categories names syncronously to file")); + ExportLandmarksL(KFileSync2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames); + + iLog->Log(_L("Exporting all landmarks with global categories names incrementally to file")); + ExportLandmarksIncL(KFileInc2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames, + !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks with global categories names incrementally using User::WaitForRequest() to file")); + ExportLandmarksIncL(KFileWait4Req2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames, + useWaitForRequest); + +// Exporting without global cateogries to file + iLog->Log(_L("Exporting all landmarks with categories exc. global categories syncronously to file")); + ExportLandmarksL(KFileSync3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories); + + iLog->Log(_L("Exporting all landmarks with categories exc. global categories incrementally to file")); + ExportLandmarksIncL(KFileInc3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories, !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks with categories exc. global categories incrementally using User::WaitForRequest() to file")); + ExportLandmarksIncL(KFileWait4Req3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories, useWaitForRequest); + + iLogToFile = EFalse; + +// Exporting all landmarks to buffer + iLog->Log(_L("Exporting all landmarks syncronously to buffer")); + ExportLandmarksL(KBufferSync, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Exporting all landmarks incrementally to buffer")); + ExportLandmarksIncL(KBufferInc, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks incrementally using User::WaitForRequest() to buffer")); + ExportLandmarksIncL(KBufferWait4Req, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, useWaitForRequest); + +// Exporting all landmarks with global categories to buffer + iLog->Log(_L("Exporting all landmarks with global categories names syncronously to buffer")); + ExportLandmarksL(KBufferSync2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames); + + iLog->Log(_L("Exporting all landmarks with global categories names incrementally to buffer")); + ExportLandmarksIncL(KBufferInc2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames, + !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks with global categories names incrementally using User::WaitForRequest() to buffer")); + ExportLandmarksIncL(KBufferWait4Req2, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories | + CPosLandmarkDatabase::EIncludeGlobalCategoryNames, + useWaitForRequest); + +// Exporting all landmarks with global categories to buffer + iLog->Log(_L("Exporting all landmarks with categories exc. global categories syncronously to buffer")); + ExportLandmarksL(KBufferSync3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories); + + iLog->Log(_L("Exporting all landmarks with categories exc. global categories incrementally to buffer")); + ExportLandmarksIncL(KBufferInc3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories, !useWaitForRequest); + + iLog->Log(_L("Exporting all landmarks with categories exc. global categories incrementally using User::WaitForRequest() to buffer")); + ExportLandmarksIncL(KBufferWait4Req3, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories, useWaitForRequest); + + iLogToFile = ETrue; + CleanupStack::PopAndDestroy(iter); + arrayOfIds.Reset(); + +// Exporting one landmark to file + arrayOfIds.Append(KLandmarkId); + iLog->Log(_L("Exporting one landmark syncronously to file")); + ExportLandmarksL(KFileSync4, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Exporting one landmark syncronously to file incrementally")); + ExportLandmarksIncL(KFileInc4, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, !useWaitForRequest); + + iLog->Log(_L("Exporting one landmark syncronously to file incrementally using User::WaitForRequest()")); + ExportLandmarksIncL(KFileWait4Req4, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, useWaitForRequest); + +// Exporting two landmarks to file + arrayOfIds.Append(KLandmarkId2); + iLog->Log(_L("Exporting two landmark syncronously to file")); + ExportLandmarksL(KFileSync5, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Exporting two landmark syncronously to file incrementally")); + ExportLandmarksIncL(KFileInc5, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, !useWaitForRequest); + + iLog->Log(_L("Exporting two landmark syncronously to file incrementally using User::WaitForRequest()")); + ExportLandmarksIncL(KFileWait4Req5, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions, useWaitForRequest); + +// Exporting landmarks with collection data + iLog->Log(_L("Exporting landmarks with collection data added to the encoder")); + ExportWithCollectionDataL(arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Compares the created XML files with saved correct ones")); + + TInt errors = 0; + + errors += CompareL(KDefaultOptions, KFileSync); + errors += CompareL(KDefaultOptions, KFileInc); + errors += CompareL(KDefaultOptions, KFileWait4Req); + errors += CompareL(KDefaultOptions, KBufferSync); + errors += CompareL(KDefaultOptions, KBufferInc); + errors += CompareL(KDefaultOptions, KBufferWait4Req); + + TFileName filename; + CreateCorrectXmlFileL( KInclCategories, filename ); + errors += CompareL(filename, KFileSync2); + errors += CompareL(filename, KFileInc2); + errors += CompareL(filename, KFileWait4Req2); + errors += CompareL(filename, KFileInc2); + errors += CompareL(filename, KBufferSync2); + errors += CompareL(filename, KBufferInc2); + errors += CompareL(filename, KBufferWait4Req2); + + CreateCorrectXmlFileL( KExclCategories, filename ); + errors += CompareL(filename, KFileSync3); + errors += CompareL(filename, KFileInc3); + errors += CompareL(filename, KFileWait4Req3); + errors += CompareL(filename, KBufferSync3); + errors += CompareL(filename, KBufferInc3); + errors += CompareL(filename, KBufferWait4Req3); + + errors += CompareL(KOneLandmark, KFileSync4); + errors += CompareL(KOneLandmark, KFileInc4); + errors += CompareL(KOneLandmark, KFileWait4Req4); + + errors += CompareL(KTwoLandmarks, KFileSync5); + errors += CompareL(KTwoLandmarks, KFileInc5); + errors += CompareL(KTwoLandmarks, KFileWait4Req5); + + errors += CompareL(KTwoLandmarksWithColData, KFileSync6); + + if (errors > 0) + { + errors = errors / KErrGeneral; + } + + AssertTrueSecL(errors == 0, _L("%d file(s) are not equal"), errors); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L("Exports landmarks and cancels the operation")); + ExportAndCancelL(KFileCancelled, EFalse, CPosLandmarkDatabase::EDefaultOptions); + + iLog->Log(_L("Exports landmarks and cancels the operation in a callback")); + ExportAndCancelL(KFileCancelledInCallback, ETrue, CPosLandmarkDatabase::EDefaultOptions); + + VerifyCancelL(KFileCancelled, KMaxCancelled); + + VerifyCancelL(KFileCancelledInCallback, KMaxCancelledInCallback); + + CleanupStack::PopAndDestroy(&arrayOfIds); + + } + +// --------------------------------------------------------- +// CPosTp45::ExportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::ExportLandmarksL(const TDesC& aFileName, + RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions) + { + iLog->Log(_L("ExportLandmarksL")); + TBuf<100> file; + file.Append(aFileName); + + if (iLogToFile) + { + DeleteFile(file); + iLandmarkEncoder->SetOutputFileL(file); + } + else + { + iBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + } + + CPosLmOperation* op = iDatabase->ExportLandmarksL(*iLandmarkEncoder, aArrayOfIds, aTransferOptions); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + + op = iLandmarkEncoder->FinalizeEncodingL(); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + + if (!iLogToFile) + { + WriteBufferToFileL(iBuffer, file); + delete iBuffer; + iBuffer = NULL; + } + } + +// --------------------------------------------------------- +// CPosTp45::ExportLandmarksIncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::ExportLandmarksIncL(const TDesC& aFileName, + RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions, + TBool aUseWaitForRequest) + { + iLog->Log(_L("ExportLandmarksIncL")); + TBuf<100> file; + file.Append(aFileName); + + if (iLogToFile) + { + DeleteFile(file); + iLandmarkEncoder->SetOutputFileL(file); + } + else + { + iBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + } + + CPosLmOperation* op = iDatabase->ExportLandmarksL(*iLandmarkEncoder, aArrayOfIds, aTransferOptions); + if (aUseWaitForRequest) + { + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + else + { + RunAsyncOperationLD(op); + } + + op = iLandmarkEncoder->FinalizeEncodingL(); + if (aUseWaitForRequest) + { + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + } + else + { + RunAsyncOperationLD(op); + } + + if (!iLogToFile) + { + WriteBufferToFileL(iBuffer, file); + delete iBuffer; + iBuffer = NULL; + } + } + +// --------------------------------------------------------- +// CPosTp45::ExportWithCollectionDataL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::ExportWithCollectionDataL(RArray& aArrayOfIds, + CPosLandmarkDatabase::TTransferOptions aTransferOptions) + { + iLog->Log(_L("ExportWithCollectionDataL")); + TBuf<100> file; + //file.Append(KTargetPath); + file.Append(KFileSync6); + + DeleteFile(file); + iLandmarkEncoder->SetOutputFileL(file); + + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, KCollectionName); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, KCollectionDes); + + CPosLmOperation* op = iDatabase->ExportLandmarksL(*iLandmarkEncoder, aArrayOfIds, aTransferOptions); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + + op = iLandmarkEncoder->FinalizeEncodingL(); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + iLog->Log(_L("ExportWithCollectionDataL Done")); + } + +// --------------------------------------------------------- +// CPosTp45::ExportAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::ExportAndCancelL(const TDesC& aFileName, + const TBool& aInCallback, + CPosLandmarkDatabase::TTransferOptions aTransferOptions) + { + iLog->Log(_L("ExportAndCancelL")); + TBuf<100> file; + //file.Append(KTargetPath); + file.Append(aFileName); + + DeleteFile(file); + iLandmarkEncoder->SetOutputFileL(file); + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + if (aInCallback) + { + RunAsyncOperationAndCancelInCallbackLD(iDatabase->ExportLandmarksL(*iLandmarkEncoder, arrayOfIds, aTransferOptions)); + } + else + { + RunAsyncOperationAndCancelLD(iDatabase->ExportLandmarksL(*iLandmarkEncoder, arrayOfIds, aTransferOptions)); + } + + CPosLmOperation* op = iLandmarkEncoder->FinalizeEncodingL(); + CleanupStack::PushL(op); + op->ExecuteL(); + + CleanupStack::PopAndDestroy(3, iter); + iLog->Log(_L("ExportAndCancelL Done")); + } + +// --------------------------------------------------------- +// CPosTp45::VerifyCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::VerifyCancelL(const TDesC& aFileName, const TInt aMaxExported) + { + iLog->Log(_L("VerifyCancelL")); + TBuf<100> file; + file.Append(aFileName); + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(KLmxMimeType); + CleanupStack::PushL(parser); + + parser->SetInputFileL(file); + + CPosLmOperation* op = parser->ParseContentL(); + CleanupStack::PushL(op); + + op->ExecuteL(); + + TInt parsed = parser->NumOfParsedLandmarks(); + AssertTrueSecL(aMaxExported > parsed , _L("More than %d landmarks have been exported when cancelled"), aMaxExported); + + CleanupStack::PopAndDestroy(2, parser); + iLog->Log(_L("VerifyCancelL Done")); + } + +// --------------------------------------------------------- +// CPosTp45::TestErrorCodesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::TestErrorCodesL() + { + iLog->Log(_L("TestErrorCodesL")); + _LIT(KNotFoundErr, "Incorrect error code %d returned from ExecuteL when executed with Lm id not in db"); + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + arrayOfIds.Append(666); + + DeleteFile( KTmpFile ); + + iLog->Log(_L("SetOutputFileL")); + iLandmarkEncoder->SetOutputFileL( KTmpFile ); + iLog->Log(_L("After SetOutputFileL")); + + CPosLmOperation* op = iDatabase->ExportLandmarksL(*iLandmarkEncoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + + TRAPD(err, op->ExecuteL()); + delete op; + + CleanupStack::PopAndDestroy(2, iter); + + AssertTrueSecL(err == KErrNotFound, KNotFoundErr, err); + + iLog->Log(_L("TestErrorCodesL Done")); + } + + +// --------------------------------------------------------- +// CPosTp45::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::AddLandmarksL() + { + iLog->Log(_L("AddLandmarksL")); + CPosLandmark* lm = CreateXMLLandmarkLC(_L("TP45 - LM with all fields set")); + AddAllXMLFieldsL(lm); + iDatabase->AddLandmarkL(*lm); + + CPosLandmark* lm2 = CPosLandmark::NewLC(); + lm2->SetLandmarkNameL(_L("TP45 - LM, only name set")); + iDatabase->AddLandmarkL(*lm2); + + CPosLandmark* lm3 = CreateLandmarkLC(_L("TP45 - LM with categories")); + iDatabase->AddLandmarkL(*lm3); + + CPosLandmark* lm4 = CPosLandmark::NewLC(); + lm4->SetLandmarkNameL(_L("TP45 - LM with Global categories")); + lm4->AddCategoryL(KGlobalCategoryId); + lm4->AddCategoryL(KGlobalCategoryId2); + iDatabase->AddLandmarkL(*lm4); + + CleanupStack::PopAndDestroy(4, lm); + } + +// --------------------------------------------------------- +// CPosTp45::RenameGlobalCategoryL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::RenameGlobalCategoryL() + { + /* + * Rename a global category + */ + + TBuf<150>info; + // Get sample global category info + TPosLmItemId catId(0); + + CPosLandmarkCategory* category = NULL; + catId = iCategoryManager->GetGlobalCategoryL( KAccommodation ); + category = iCategoryManager->ReadCategoryLC( catId ); + category->SetCategoryNameL(_L("TP45 - Renamed global")); + iCategoryManager->UpdateCategoryL( *category ); + + CleanupStack::PopAndDestroy( category ); + } + +// --------------------------------------------------------- +// CPosTp45::ExportToFileWithLongFileNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::ExportToFileWithLongFileNameL() + { + iLog->Log(_L("ExportToFileWithLongFileNameL")); + +#ifndef __WINS__ + DeleteFileL(KLongFileName); + DeleteFileL(KLongFileName2); +#endif + + // 1) Create an encoder object + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + + TInt errorsFound=KErrNone; + + // 2) Set file with long filename (more than 255 characters) + TRAPD(err, iLandmarkEncoder->SetOutputFileL(KLongFileName)); + TInt expErr; + +#ifdef __WINS__ + expErr = KErrBadName; + if (err != KErrBadName) +#else + expErr = KErrNone; + if (err != KErrNone) +#endif + { + TBuf<100> buf; + buf.Format(_L("SetOutputFileL should leave with %d, instead err:%d"),expErr, err); + errorsFound++; + iLog->Log(buf); + } + + // 3) Set file with long filename (more than 255 characters) + TRAP(err, iLandmarkEncoder->SetOutputFileL(KLongFileName2)); +#ifdef __WINS__ + expErr = KErrBadName; + if (err != KErrBadName) +#else + expErr = KErrAlreadyExists; + if (err != KErrAlreadyExists) +#endif + { + TBuf<100> buf; + buf.Format(_L("SetOutputFileL(2) should leave with %d, instead err:%d"), expErr, err); + //LogErrorAndLeave(buf); + errorsFound++; + iLog->Log(buf); + } + + if (errorsFound != KErrNone) + { + iLog->Log(_L("Wrong error code from SetOutputFileL")); + User::Leave(-1); + } + + iLog->Log(_L("ExportToFileWithLongFileNameL Done")); + } + +// --------------------------------------------------------- +// CPosTp45::DeleteFile +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::DeleteFile(const TDesC& aFile) + { + TInt err = iFileSession.Delete(aFile); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("Delete of file %S failed with error %d"), &aFile, err); + iLog->Log(buf); + } + } + + +void CPosTp45::MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ) + { + + CPosLmOperation* operation1 = aLdb.RemoveAllLandmarksL(); + //Remove all landmarks from default db : Sync call + ExecuteAndDeleteLD( operation1 ); + + RArray catArray; + CleanupClosePushL( catArray ); + + // Get all the categories from the database and delete them if necessary + CPosLmItemIterator* iter = aCatMgr.CategoryIteratorL(); + CleanupStack::PushL( iter ); + + TUint count = iter->NumOfItemsL(); + if ( count > 0 ) + { // can only be called if there are some items + iter->GetItemIdsL( catArray, 0, count ); + } + + // Remove all the categories here Sync call + ExecuteAndDeleteLD(aCatMgr.RemoveCategoriesL( catArray )); + CleanupStack::PopAndDestroy( 2 ); // catArray, iter + } + +void CPosTp45::AddCategoriesL() + { + _LIT(KName, "CategoryTP45 - %d"); + TInt err=KErrLocked; + for (TInt i=0; i categoryName; + categoryName.Format(KName,i); + + CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC(); + lmc->SetCategoryNameL(categoryName); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iCategoryManager->AddCategoryL(*lmc)); + } + + iCategories.Append(lmc); + CleanupStack::Pop(lmc); + } + iLog->Log(_L("Adding categories to database done ")); + } + +// --------------------------------------------------------- +// CPosTp45::SetupGlobalCategoriesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp45::SetupGlobalCategoriesL() + { + // Testing with only 3 global categories + iGlobalCategoryNames.Append(_L("Accommodation")); + iGlobalCategoryIds.Append(3000); + + /*iGlobalCategoryNames.Append(_L("Business")); + iGlobalCategoryIds.Append(6000); + + iGlobalCategoryNames.Append(_L("Communication")); + iGlobalCategoryIds.Append(9000);*/ + + iGlobalCategoryNames.Append(_L("Entertainment")); + iGlobalCategoryIds.Append(15000); + + iGlobalCategoryNames.Append(_L("People")); + iGlobalCategoryIds.Append(27000); + + iGlobalCategoryTestNames.Append(_L("Housing")); + iGlobalCategoryTestNames.Append(_L("Movie")); + iGlobalCategoryTestNames.Append(_L("Society")); + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp46.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp46.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,378 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp46.h" + +#include +#include +#include +#include + + + +#include +#include +#include + +const TInt KNoMultipleClients = 10; +_LIT(KExportFileIndex, "c:\\TP46-ExportedFileFromThread%d.xml"); + +#ifdef __WINS__ + _LIT(KImportFile, "z:\\system\\test\\testdata\\TP45-DefOptions.xml"); +#else + _LIT(KImportFile, "c:\\system\\test\\testdata\\TP45-DefOptions.xml"); +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp46::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp46::GetName(TDes& aName) const + { + _LIT(KTestName, "TP46 - Multiple export operations"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp46::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp46::CloseTest() + { + for (TInt i=0; iIsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + RemoveFilesL(); + + iLog->Put(_L("Export landmarks syncronously simultaneously")); + iTestStep=0; + StartMultipleClientsL(KNoMultipleClients); + + iLog->Put(_L("Export landmarks incrementally simultaneously")); + ++iTestStep; + RemoveFilesL(); + StartMultipleClientsL(KNoMultipleClients); + + iLog->Put(_L("Export landmarks after import operation has taken write lock")); + ++iTestStep; + RemoveFilesL(); + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(KMimeType); + CleanupStack::PushL(parser); + parser->SetInputFileL(KImportFile); + // Take write lock + CPosLmOperation* op = iDatabase->ImportLandmarksL(*parser, CPosLandmarkDatabase::EDefaultOptions); + CleanupStack::PushL(op); + // Try to export + StartMultipleClientsL(KNoMultipleClients); + CleanupStack::PopAndDestroy(2, parser); + + // ESLI-64LLU3 - read/write lock only affects the same database instance. + parser = CPosLandmarkParser::NewL(KMimeType); + CleanupStack::PushL(parser); + parser->SetInputFileL(KImportFile); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + op = iDatabase->ImportLandmarksL(*parser, CPosLandmarkDatabase::EDefaultOptions); + CleanupStack::PushL(op); + + TRAPD(err, CleanupStack::PopAndDestroy(lmd->ReadLandmarkLC(1))); + AssertTrueSecL(err == KErrLocked, _L("Didn't get KErrLocked but %d"), err); + + TRAP(err, CleanupStack::PopAndDestroy(iDatabase->ReadLandmarkLC(1))); + AssertTrueSecL(err == KErrLocked, _L("Didn't get KErrLocked but %d"), err); + + // Lock should prevent export threads to complete successfully + StartMultipleClientsL(KNoMultipleClients); + + // Release lock - export threads should complete successfully + CleanupStack::PopAndDestroy(op); + iTestStep = ESync; + StartMultipleClientsL(KNoMultipleClients); + + CleanupStack::PopAndDestroy(lmd); + CleanupStack::PopAndDestroy(parser); + } + +// --------------------------------------------------------- +// CPosTp46::RemoveFiles +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp46::RemoveFilesL() + { + RFs fs; + User::LeaveIfError(fs.Connect()); + for (TInt i=1; i <= KNoMultipleClients; i++) + { + TBuf<100> fileName; + fileName.Format(KExportFileIndex, i); + fs.Delete(fileName); + } + fs.Close(); + } + +// --------------------------------------------------------- +// CPosTp46::StartMultipleClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp46::StartMultipleClientsL(const TUint aNoClients) + { + _LIT(KMultipleErr, "Error %d from thread %d"); + _LIT(KPanicErr, "Thread %d has panicked or is alive"); + + _LIT(KSuccess, "Threads %d is successful"); + + CreateThreadsL(aNoClients); + + RArray statuses; + CleanupClosePushL(statuses); + + for (TUint j=0; j info; + + if (exitReason != KErrNone) + { + errors++; + info.Format(KMultipleErr, exitReason, i+1); + } + else + { + info.Format(KSuccess, i+1); + } + iLog->Put(info); + + AssertTrueSecL(iThreads[i].ExitType() == EExitKill, KPanicErr, i+1); + AssertTrueSecL(exitReason == KErrNone || exitReason == KErrLocked, info); + } + + if (iTestStep != EImportStarted) + { + AssertTrueSecL(errors == 0, _L("No thread should leave with error, all should be able to read from the db")); + } + else + { + AssertTrueSecL(errors == aNoClients, _L("All threads should leave with error, none should be able to read from the db")); + } + + + for (i=0; i(aData); + TInt index = ++self->iThreadIndex; + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + /* + _LIT(KInfo, "Thread %d"); + TBuf<100> info; + info.Format(KInfo, index); + RDebug::Print(info); + */ + + CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KMimeType); + CleanupStack::PushL(encoder); + + CPosLmItemIterator* iter = lmd->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + TBuf<100> fileName; + fileName.Format(KExportFileIndex, index); + encoder->SetOutputFileL(fileName); + + switch (self->iTestStep) + { + //case self->ESync: + case 0: + //case self->EImportStarted: + case 2: + { + CPosLmOperation* op = lmd->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories); + + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + + op = encoder->FinalizeEncodingL(); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + break; + } + //case self->EInc: + case 1: + { + CPosLmOperation* op2 = lmd->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories); + self->RunAsyncOperationLD(op2); + + op2 = encoder->FinalizeEncodingL(); + self->RunAsyncOperationLD(op2); + break; + } + } + /* + _LIT(KInfo3, "Thread %d after execute"); + info.Format(KInfo3, index); + RDebug::Print(info); + */ + CleanupStack::PopAndDestroy(4, lmd); + } + + +// --------------------------------------------------------- +// ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp46::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp46::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp46::CreateThreadsL(const TUint aNoThreads) + { + _LIT(KThreadName, "TP46 test thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TUint i=0; i name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp47.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp47.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1876 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + +// INCLUDES +#include "FT_CPosTp47.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS +_LIT(KFileName, "c:\\documents\\Tp47Data.xml"); +_LIT(KFileTrace, "c:\\documents\\LandmarksTP47Trace.txt"); + +// See \epoc32\include\xml\XmlParserErrors.h for error codes + + +_LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP47Trace.txt"); + +_LIT(KMimeWithNameAndTimeStampFile, "c:\\system\\test\\TestData\\Tp47Data_With_MIME_Name.xml"); +_LIT(KErronousXMLFile, "c:\\system\\test\\TestData\\Tp47ErrounousXMLData.xml"); + +_LIT(KErronousXMLFileDataMissing1, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields1.xml"); +_LIT(KErronousXMLFileDataMissing2, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields2.xml"); +_LIT(KErronousXMLFileDataMissing3, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields3.xml"); + +_LIT(KErronousXMLFileWrongOrder1, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataWrongOrder1.xml"); +_LIT(KErronousXMLFileWrongOrder2, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataWrongOrder2.xml"); +_LIT(KErronousXMLFileWrongOrder3, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataWrongOrder3.xml"); + +_LIT(KErronousXMLFileRepeatedTag, "c:\\system\\test\\TestData\\Tp47ErronousXMLDataRepeatedTag.xml"); +_LIT(KErronousXMLFileUnclosedTag1, "c:\\system\\test\\TestData\\Tp47ErronousXMLDataUnclosedTag1.xml"); +//_LIT(KErronousXMLFileUnclosedTag2, "c:\\system\\test\\TestData\\Tp47ErronousXMLDataUnclosedTag2.xml"); + +_LIT(KUnknownTags, "c:\\system\\test\\TestData\\Tp47UnknownTags.xml"); +_LIT(KUnknownTrees, "c:\\system\\test\\TestData\\Tp47UnknownTrees.xml"); + +_LIT(KNoEndTag1, "c:\\system\\test\\TestData\\Tp47ErrounousXMLNoEndTag1.xml"); +_LIT(KNoEndTag2, "c:\\system\\test\\TestData\\Tp47ErrounousXMLNoEndTag2.xml"); + +_LIT(KNoXMLFile1, "c:\\system\\test\\TestData\\Tp47ErronousFileNoXML1.xml"); +_LIT(KNoXMLFile2, "c:\\system\\test\\TestData\\Tp47ErronousFileNoXML2.xml"); + +_LIT(KTestXMLInput1, "c:\\system\\test\\TestData\\Tp47XMLDataTestInput1.xml"); + +_LIT(KXMLFileWithLongCategoryName, "c:\\system\\test\\TestData\\Tp47XMLWithLongCategoryName.xml"); +_LIT(KXMLFileWithLongLandmarkName, "c:\\system\\test\\TestData\\Tp47XMLWithLongName.xml"); +_LIT(KXMLFileWithLongLatitudeField, "c:\\system\\test\\TestData\\Tp47XMLWithLongLatitudeField.xml"); + +_LIT(KXMLFileWithEmptyCollection, "c:\\system\\test\\TestData\\Tp47ErronousXMLFileEmptyCollection.xml"); + +_LIT(KXMLFileWithXMLTagAsDataField1, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField1.xml"); +_LIT(KXMLFileWithXMLTagAsDataField2, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField2.xml"); +_LIT(KXMLFileWithXMLTagAsDataField3, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField3.xml"); + +_LIT(KErronousXMLFileTagInTag, "c:\\system\\test\\TestData\\Tp47ErronousXMLDataTagInTag1.xml"); +//_LIT(KErronousXMLFileMissingLMPrefix, "c:\\system\\test\\TestData\\Tp47ErronousXMLDataMissingLMPrefix.xml"); + +_LIT(KXMLFileUTF8, "c:\\system\\test\\TestData\\Tp47DataUTF8.xml"); +_LIT(KXMLFileUTF16, "c:\\system\\test\\TestData\\Tp47DataUTF16.xml"); + +_LIT(KXML_UTF_16_BE, "c:\\system\\test\\TestData\\TP47_UTF-16-bigEndian.xml"); +_LIT(KXML_UTF_16_LE, "c:\\system\\test\\TestData\\TP47_UTF-16-littleEndian.xml"); +_LIT(KXML_UTF_8, "c:\\system\\test\\TestData\\TP47_UTF-8.xml"); +_LIT(KXML_UTF_CHINESE, "c:\\system\\test\\TestData\\TP47_UTF-Chinese.xml"); + +_LIT(KXMLFileWithEmptyMedialink, "c:\\system\\test\\TestData\\Tp47EmptyMediaLink.xml"); +_LIT(KXMLFileWithEmptyCoordinates, "c:\\system\\test\\TestData\\Tp47EmptyCoordinates.xml"); +_LIT(KXMLFileWithEmptyAdresseInfo, "c:\\system\\test\\TestData\\Tp47EmptyAdresseInfo.xml"); + +_LIT(KXMLFileWithErronousTextInTag1, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag1.xml"); +_LIT(KXMLFileWithErronousTextInTag2, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag2.xml"); +_LIT(KXMLFileWithErronousTextInTag3, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag3.xml"); +_LIT(KXMLFileWithErronousTextInTag4, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag4.xml"); +_LIT(KXMLFileWithErronousTextInTag5, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag5.xml"); +_LIT(KXMLFileWithErronousTextInTag6, "c:\\system\\test\\TestData\\Tp47ErronousTextInTag6.xml"); + +//KML test files +_LIT(KKMLFile, "c:\\system\\test\\TestData\\Tp47KML.kml"); +_LIT(KKMLFile1, "c:\\system\\test\\TestData\\Tp47KMLfile1.kml"); +_LIT(KKMLFile2, "c:\\system\\test\\TestData\\Tp47KMLfile2.kml"); +_LIT(KKMLFile3, "c:\\system\\test\\TestData\\Tp47KMLfile3.kml"); + +_LIT(KKMLLongName, "c:\\system\\test\\TestData\\Tp47KMLlongName.kml"); +_LIT(KKMLNameCaps, "c:\\system\\test\\TestData\\Tp47KMLNameCaps.kml"); +_LIT(KKMLErroneousNameTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousNameTag.kml"); +_LIT(KKMLErroneousNameTagPosition1, "c:\\system\\test\\TestData\\Tp47KMLErroneousNameTagPosition1.kml"); +_LIT(KKMLErroneousNameTagPosition2, "c:\\system\\test\\TestData\\Tp47KMLErroneousNameTagPosition2.kml"); +_LIT(KKMLEmptyName, "c:\\system\\test\\TestData\\Tp47KMLEmptyName.kml"); +_LIT(KKMLMissingNameTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingNameTag1.kml"); +_LIT(KKMLMissingNameTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingNameTag2.kml"); +_LIT(KKMLNameWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLNameWithSpecialCharacters1.kml"); +_LIT(KKMLNameWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLNameWithSpecialCharacters2.kml"); + +_LIT(KKMLEmptyPhoneNumber, "c:\\system\\test\\TestData\\Tp47KMLEmptyPhoneNumber.kml"); +_LIT(KKMLErroneousPhoneNumberTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousPhoneNumberTag.kml"); +_LIT(KKMLErroneousPhoneNumberTagPosition, "c:\\system\\test\\TestData\\Tp47KMLErroneousPhoneNumberTagPosition.kml"); +_LIT(KKMLLongPhoneNumer, "c:\\system\\test\\TestData\\Tp47KMLLongPhoneNumer.kml"); +_LIT(KKMLMissingPhoneTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingPhoneTag1.kml"); +_LIT(KKMLMissingPhoneTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingPhoneTag2.kml"); +_LIT(KKMLPhoneNumberCaps, "c:\\system\\test\\TestData\\Tp47KMLPhoneNumberCaps.kml"); +_LIT(KKMLPhoneNumberWithText, "c:\\system\\test\\TestData\\Tp47KMLPhoneNumberWithText.kml"); +_LIT(KKMLPhoneNumberWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLPhoneNumberWithSpecialCharacters1.kml"); +_LIT(KKMLPhoneNumberWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLPhoneNumberWithSpecialCharacters2.kml"); + +_LIT(KKMLEmptyPoint, "c:\\system\\test\\TestData\\Tp47KMLEmptyPoint.kml"); +_LIT(KKMLErroneousPointTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousPointTag.kml"); +_LIT(KKMLErroneousPointTagPosition, "c:\\system\\test\\TestData\\Tp47KMLErroneousPointTagPosition.kml"); +_LIT(KKMLMissingPointTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingPointTag1.kml"); +_LIT(KKMLMissingPointTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingPointTag2.kml"); +_LIT(KKMLPointCaps, "c:\\system\\test\\TestData\\Tp47KMLPointCaps.kml"); +_LIT(KKMLPointTag1, "c:\\system\\test\\TestData\\Tp47KMLPointTag1.kml"); +_LIT(KKMLPointTag2, "c:\\system\\test\\TestData\\Tp47KMLPointTag2.kml"); +_LIT(KKMLPointTag3, "c:\\system\\test\\TestData\\Tp47KMLPointTag3.kml"); + +_LIT(KKMLEmptyDescription, "c:\\system\\test\\TestData\\Tp47KMLEmptyDescription.kml"); +_LIT(KKMLDescriptionWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLDescriptionWithSpecialCharacters1.kml"); +_LIT(KKMLDescriptionWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLDescriptionWithSpecialCharacters2.kml"); +_LIT(KKMLDescriptionCaps, "c:\\system\\test\\TestData\\Tp47KMLDescriptionCaps.kml"); +_LIT(KKMLLongDescription, "c:\\system\\test\\TestData\\Tp47KMLLongDescription.kml"); +_LIT(KKMLErroneousDescriptionTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousDescriptionTag.kml"); +_LIT(KKMLErroneousDescriptionTagposition, "c:\\system\\test\\TestData\\Tp47KMLErroneousDescriptionTagposition.kml"); +_LIT(KKMLMissingDescriptionTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingDescriptionTag1.kml"); +_LIT(KKMLMissingDescriptionTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingDescriptionTag2.kml"); +_LIT(KKMLDescriptionWithCDATA, "c:\\system\\test\\TestData\\Tp47KMLDescriptionWithCDATA.kml"); + +_LIT(KKMLErroneousFolderTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousFolderTag.kml"); +_LIT(KKMLFolderCaps, "c:\\system\\test\\TestData\\Tp47KMLFolderCaps.kml"); +_LIT(KKMLMissingFolderTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingFolderTag1.kml"); +_LIT(KKMLMissingFolderTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingFolderTag2.kml"); +_LIT(KKMLEmptyFolderName, "c:\\system\\test\\TestData\\Tp47KMLEmptyFolderName.kml"); +_LIT(KKMLLongFolderName, "c:\\system\\test\\TestData\\Tp47KMLLongFolderName.kml"); +_LIT(KKMLFolderNameWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLFolderNameWithSpecialCharacters1.kml"); +_LIT(KKMLFolderNameWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLFolderNameWithSpecialCharacters2.kml"); + +_LIT(KKMLDocumentNameWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLDocumentNameWithSpecialCharacters1.kml"); +_LIT(KKMLDocumentNameWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLDocumentNameWithSpecialCharacters2.kml"); +_LIT(KKMLEmptyDocumentName, "c:\\system\\test\\TestData\\Tp47KMLEmptyDocumentName.kml"); +_LIT(KKMLLongDocumentName, "c:\\system\\test\\TestData\\Tp47KMLLongDocumentName.kml"); +_LIT(KKMLDocumentCaps, "c:\\system\\test\\TestData\\Tp47KMLDocumentCaps.kml"); +_LIT(KKMLErroneousDocumentTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousDocumentTag.kml"); +_LIT(KKMLMissingDocumentTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingDocumentTag1.kml"); +_LIT(KKMLMissingDocumentTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingDocumentTag2.kml"); + +_LIT(KKMLAddressCaps, "c:\\system\\test\\TestData\\Tp47KMLAddressCaps.kml"); +_LIT(KKMLAddressWithSpecialCharacters1, "c:\\system\\test\\TestData\\Tp47KMLAddressWithSpecialCharacters1.kml"); +_LIT(KKMLAddressWithSpecialCharacters2, "c:\\system\\test\\TestData\\Tp47KMLAddressWithSpecialCharacters2.kml"); +_LIT(KKMLEmptyAddress1, "c:\\system\\test\\TestData\\Tp47KMLEmptyAddress1.kml"); +_LIT(KKMLEmptyAddress2, "c:\\system\\test\\TestData\\Tp47KMLEmptyAddress2.kml"); +_LIT(KKMLLongAddress1, "c:\\system\\test\\TestData\\Tp47KMLLongAddress1.kml"); +_LIT(KKMLLongAddress2, "c:\\system\\test\\TestData\\Tp47KMLLongAddress2.kml"); +_LIT(KKMLLongAddress3, "c:\\system\\test\\TestData\\Tp47KMLLongAddress3.kml"); +_LIT(KKMLErroneousAddressTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousAddressTag.kml"); +_LIT(KKMLErroneousAddressTagPosition, "c:\\system\\test\\TestData\\Tp47KMLErroneousAddressTagPosition.kml"); +_LIT(KKMLMissingAddressTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingAddressTag1.kml"); +_LIT(KKMLMissingAddressTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingAddressTag2.kml"); + +_LIT(KKMLCoordinateCaps, "c:\\system\\test\\TestData\\Tp47KMLCoordinateCaps.kml"); +_LIT(KKMLMoreCoordinates, "c:\\system\\test\\TestData\\Tp47KMLMoreCoordinates.kml"); +_LIT(KKMLErroneousCoordinateTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinateTag.kml"); +_LIT(KKMLErroneousCoordinateTagPosition, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinateTagPosition.kml"); +_LIT(KKMLCoordinates1, "c:\\system\\test\\TestData\\Tp47KMLCoordinates1.kml"); +_LIT(KKMLCoordinates2, "c:\\system\\test\\TestData\\Tp47KMLCoordinates2.kml"); +_LIT(KKMLCoordinates3, "c:\\system\\test\\TestData\\Tp47KMLCoordinates3.kml"); +_LIT(KKMLCoordinates4, "c:\\system\\test\\TestData\\Tp47KMLCoordinates4.kml"); +_LIT(KKMLCoordinates5, "c:\\system\\test\\TestData\\Tp47KMLCoordinates5.kml"); +_LIT(KKMLCoordinates6, "c:\\system\\test\\TestData\\Tp47KMLCoordinates6.kml"); +_LIT(KKMLLongCoordinates1, "c:\\system\\test\\TestData\\Tp47KMLLongCoordinates1.kml"); +_LIT(KKMLLongCoordinates2, "c:\\system\\test\\TestData\\Tp47KMLLongCoordinates2.kml"); +_LIT(KKMLMissingCoordinateTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingCoordinateTag1.kml"); +_LIT(KKMLMissingCoordinateTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingCoordinateTag2.kml"); +_LIT(KKMLEmptyCoordinates1, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates1.kml"); +_LIT(KKMLEmptyCoordinates2, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates2.kml"); +_LIT(KKMLEmptyCoordinates3, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates3.kml"); +_LIT(KKMLEmptyCoordinates4, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates4.kml"); +_LIT(KKMLEmptyCoordinates5, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates5.kml"); +_LIT(KKMLEmptyCoordinates6, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates6.kml"); +_LIT(KKMLEmptyCoordinates7, "c:\\system\\test\\TestData\\Tp47KMLEmptyCoordinates7.kml"); +_LIT(KKMLErroneousCoordinates1, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinates1.kml"); +_LIT(KKMLErroneousCoordinates2, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinates2.kml"); +_LIT(KKMLErroneousCoordinates3, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinates3.kml"); +_LIT(KKMLErroneousCoordinates4, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinates4.kml"); +_LIT(KKMLErroneousCoordinates5, "c:\\system\\test\\TestData\\Tp47KMLErroneousCoordinates5.kml"); +_LIT(KKMLNegativeCoordinates, "c:\\system\\test\\TestData\\Tp47KMLNegativeCoordinates.kml"); + +_LIT(KKMLErroneousTextWithinPlacemark, "c:\\system\\test\\TestData\\Tp47KMLErroneousTextWithinPlacemark.kml"); +_LIT(KKMLEmptyfile1, "c:\\system\\test\\TestData\\Tp47KMLEmptyfile1.kml"); +_LIT(KKMLEmptyfile2, "c:\\system\\test\\TestData\\Tp47KMLEmptyfile2.kml"); +_LIT(KKMLInvalidfile, "c:\\system\\test\\TestData\\Tp47KMLInvalidfile.kml"); + +_LIT(KKMLPlacemarkCaps, "c:\\system\\test\\TestData\\Tp47KMLPlacemarkCaps.kml"); +_LIT(KKMLErroneousPlacemarkTag, "c:\\system\\test\\TestData\\Tp47KMLErroneousPlacemarkTag.kml"); +_LIT(KKMLMissingPlacemarkTag1, "c:\\system\\test\\TestData\\Tp47KMLMissingPlacemarkTag1.kml"); +_LIT(KKMLMissingPlacemarkTag2, "c:\\system\\test\\TestData\\Tp47KMLMissingPlacemarkTag2.kml"); +_LIT(KKMLEmptyPlacemarkTag, "c:\\system\\test\\TestData\\Tp47KMLEmptyPlacemarkTag.kml"); + +_LIT(KKMLGandhiMuseum, "c:\\system\\test\\TestData\\Tp47KMLGandhi Museum.kml"); +_LIT(KKMLIndusHeritageCentreIndia, "c:\\system\\test\\TestData\\Tp47KMLIndus Heritage Centre, India.kml"); +_LIT(KKMLHiltonHotels, "c:\\system\\test\\TestData\\Tp47KMLhilton hotels near new york (1 - 10).kml"); + +_LIT(KKMLFile4, "c:\\system\\test\\TestData\\Tp47KMLfile4.kml"); +_LIT(KKMLFile5, "c:\\system\\test\\TestData\\Tp47KMLfile5.kml"); +_LIT(KKMLFile6, "c:\\system\\test\\TestData\\Tp47KMLfile6.kml"); +_LIT(KKMLFile7, "c:\\system\\test\\TestData\\Tp47KMLfile7.kml"); +_LIT(KKMLFile8, "c:\\system\\test\\TestData\\Tp47KMLfile8.kml"); +_LIT(KKMLFile9, "c:\\system\\test\\TestData\\Tp47KMLfile9.kml"); + + + + + + + +// Maxmimum size for each line in trace file +const TInt KBufSize = 5000; + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp47::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iDatabase; + iDatabase=NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + TRAPD(err, RemoveGlobalCategoriesL()); + if (err != KErrNone && err != KErrNotFound) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err); + iLog->Log( buffer ); + + CleanupStack::PopAndDestroy( buf ); + } + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp47::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KFileName ); + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Delete the trace file + DeleteFileL(KFileTrace); + + delete iDatabase; + iDatabase = NULL; + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + HBufC8* emptyBuffer=NULL; + + CreateXMLData(ETrue); + + PrintParsedDataFromEncoderL(KFileName, *emptyBuffer, KErrNone, KLmxMimeType ); + + CheckXMLData(ETrue); + + // Use buffer instead of file + CreateXMLData(EFalse); + CheckXMLData(EFalse); + + iLandmarks.ResetAndDestroy(); + + + + iLog->Log(_L("Mime With Name and Stamp")); + PrintParsedDataFromEncoderL(KMimeWithNameAndTimeStampFile, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KMimeWithNameAndTimeStampFile, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Several Landmark File")); + // XXX PrintParsedDataFromEncoderL(KSeveralLandmarkFile, *emptyBuffer, KErrPosLmUnknownFormat); + + iLog->Log(_L("Erronous XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFile, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFile, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Several LandmarkCollection File")); + // XXX PrintParsedDataFromEncoderL(KSeveralLandmarkCollectionFile, *emptyBuffer, KErrPosLmUnknownFormat); + + iLog->Log(_L("1) Wrong Order in XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileWrongOrder1, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileWrongOrder1, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("2) Wrong Order in XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileWrongOrder2, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileWrongOrder2, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("3) Wrong Order in XML File")); + // AdresseInfo can be sorted randomly without any error + PrintParsedDataFromEncoderL(KErronousXMLFileWrongOrder3, *emptyBuffer, KErrNone, KLmxMimeType ); + // N/A for GPX + + iLog->Log(_L("1) Data missing in XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing1, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing1, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("2) Data missing in XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing2, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing2, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("3) Data missing in XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing3, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileDataMissing3, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Unknown tags in XML File")); + PrintParsedDataFromEncoderL(KUnknownTags, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KUnknownTags, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Unknown trees in XML File")); + PrintParsedDataFromEncoderL(KUnknownTrees, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KUnknownTrees, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("No End landmarkCollection tag in XML File")); + PrintParsedDataFromEncoderL(KNoEndTag1, *emptyBuffer, -993, KLmxMimeType ); + PrintParsedDataFromEncoderL(KNoEndTag1, *emptyBuffer, -993, KGpxMimeType ); + + iLog->Log(_L("No End landmark tag in XML File")); + PrintParsedDataFromEncoderL(KNoEndTag2, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KNoEndTag2, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with different input formats in XML File")); + PrintParsedDataFromEncoderL(KTestXMLInput1, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KTestXMLInput1, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with repeated tag XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileRepeatedTag, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileRepeatedTag, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with unclosed tag XML File")); + PrintParsedDataFromEncoderL(KErronousXMLFileUnclosedTag1, *emptyBuffer, -993, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileUnclosedTag1, *emptyBuffer, -993, KGpxMimeType ); + +// Incorrect test +// iLog->Log(_L("Test with unclosed tag XML File")); +// PrintParsedDataFromEncoderL(KErronousXMLFileUnclosedTag2, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); +// PrintParsedDataFromEncoderL(KErronousXMLFileUnclosedTag2, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with a non XML File 1")); + PrintParsedDataFromEncoderL(KNoXMLFile1, *emptyBuffer, -982, KLmxMimeType ); + PrintParsedDataFromEncoderL(KNoXMLFile1, *emptyBuffer, -982, KGpxMimeType ); + + iLog->Log(_L("Test with a non XML File 2")); + PrintParsedDataFromEncoderL(KNoXMLFile2, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); //temporarily changed KErrPosLmUnknownFormat to KErrNone + PrintParsedDataFromEncoderL(KNoXMLFile2, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); //temporarily KErrPosLmUnknownFormat to KErrNone + + iLog->Log(_L("Test with a XML UTFW8 File")); + PrintParsedDataFromEncoderL(KXMLFileUTF8, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileUTF8, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with a XML UTFW16 File")); + PrintParsedDataFromEncoderL(KXMLFileUTF16, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileUTF16, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with long category names")); + PrintParsedDataFromEncoderL(KXMLFileWithLongCategoryName, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithLongCategoryName, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with long landmark name")); + PrintParsedDataFromEncoderL(KXMLFileWithLongLandmarkName, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithLongLandmarkName, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with long latitude field")); + PrintParsedDataFromEncoderL(KXMLFileWithLongLatitudeField, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithLongLatitudeField, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with empty collection")); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyCollection, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + // N/A for GPX + + iLog->Log(_L("Test with a XML File with Landmark Tag in Landmark Tag")); + PrintParsedDataFromEncoderL(KErronousXMLFileTagInTag, *emptyBuffer, EXmlRecursiveEntity, KLmxMimeType ); + PrintParsedDataFromEncoderL(KErronousXMLFileTagInTag, *emptyBuffer, EXmlRecursiveEntity, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with XML Tag as data field 1")); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField1, *emptyBuffer, -993, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField1, *emptyBuffer, -993, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with XML Tag as data field 2")); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField2, *emptyBuffer, -993, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField2, *emptyBuffer, -993, KGpxMimeType ); + + iLog->Log(_L("Test with a XML File with XML Tag as data field 3")); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField3, *emptyBuffer, -993, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithXMLTagAsDataField3, *emptyBuffer, -993, KGpxMimeType ); + +// Incorrect test +// iLog->Log(_L("Test with a XML File with missing LM prefix")); +// PrintParsedDataFromEncoderL(KErronousXMLFileMissingLMPrefix, *emptyBuffer, EXmlRecursiveEntity, KLmxMimeType ); +// PrintParsedDataFromEncoderL(KErronousXMLFileMissingLMPrefix, *emptyBuffer, EXmlRecursiveEntity, KGpxMimeType ); +// + iLog->Log(_L("Test with UTF-16-bigEndian.xml")); + PrintParsedDataFromEncoderL(KXML_UTF_16_BE, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXML_UTF_16_BE, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with UTF-16-littleEndian.xml")); + PrintParsedDataFromEncoderL(KXML_UTF_16_LE, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXML_UTF_16_LE, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with UTF-8.xml")); + PrintParsedDataFromEncoderL(KXML_UTF_8, *emptyBuffer, KErrNone, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXML_UTF_8, *emptyBuffer, KErrNone, KGpxMimeType ); + + iLog->Log(_L("Test with UTF-Chinese.xml")); + PrintParsedDataFromEncoderL(KXML_UTF_CHINESE, *emptyBuffer, -982, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXML_UTF_CHINESE, *emptyBuffer, -982, KGpxMimeType ); + + + + //testing kml files + iLog->Log(_L("Test with Tp47KML.kml")); + PrintParsedDataFromEncoderL(KKMLFile, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLfile1.kml")); + PrintParsedDataFromEncoderL(KKMLFile1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLfile2.kml")); + PrintParsedDataFromEncoderL(KKMLFile2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLfile3.kml")); + PrintParsedDataFromEncoderL(KKMLFile3, *emptyBuffer, KErrNone, KKmlMimeType ); + + //testing the name tag related cases + iLog->Log(_L("Test with Tp47KMLlongName.kml")); + PrintParsedDataFromEncoderL(KKMLLongName, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLNameCaps.kml")); + PrintParsedDataFromEncoderL(KKMLNameCaps, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousNameTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousNameTag, *emptyBuffer, -993, KKmlMimeType ); //EXmlTagMismatch = -993 + + iLog->Log(_L("Test with Tp47KMLErroneousNameTagPosition1.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousNameTagPosition1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousNameTagPosition2.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousNameTagPosition2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyName.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyName, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingNameTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingNameTag1, *emptyBuffer, -993, KKmlMimeType ); //EXmlTagMismatch = -993 + + iLog->Log(_L("Test with Tp47KMLMissingNameTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingNameTag2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLNameWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLNameWithSpecialCharacters1, *emptyBuffer, -996, KKmlMimeType ); // EXmlInvalidToken = -996 + + iLog->Log(_L("Test with Tp47KMLNameWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLNameWithSpecialCharacters2, *emptyBuffer, KErrNone, KKmlMimeType ); + + //testing the PhoneNumber tag related cases + iLog->Log(_L("Test with Tp47KMLEmptyPhoneNumber.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyPhoneNumber, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousPhoneNumberTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousPhoneNumberTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousPhoneNumberTagPosition.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousPhoneNumberTagPosition, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongPhoneNumer.kml")); + PrintParsedDataFromEncoderL(KKMLLongPhoneNumer, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPhoneTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPhoneTag1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPhoneTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPhoneTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPhoneNumberCaps.kml")); + PrintParsedDataFromEncoderL(KKMLPhoneNumberCaps, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPhoneNumberWithText.kml")); + PrintParsedDataFromEncoderL(KKMLPhoneNumberWithText, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPhoneNumberWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLPhoneNumberWithSpecialCharacters1, *emptyBuffer, -996, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPhoneNumberWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLPhoneNumberWithSpecialCharacters2, *emptyBuffer, KErrNone, KKmlMimeType ); + + //testing the point tag related test cases + iLog->Log(_L("Test with Tp47KMLEmptyPoint.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyPoint, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousPointTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousPointTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousPointTagPosition.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousPointTagPosition, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPointTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPointTag1, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPointTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPointTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPointCaps.kml")); + PrintParsedDataFromEncoderL(KKMLPointCaps, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPointTag1.kml")); + PrintParsedDataFromEncoderL(KKMLPointTag1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPointTag2.kml")); + PrintParsedDataFromEncoderL(KKMLPointTag2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLPointTag3.kml")); + PrintParsedDataFromEncoderL(KKMLPointTag3, *emptyBuffer, KErrNone, KKmlMimeType ); + + + //testing the description tag related cases + iLog->Log(_L("Test with Tp47KMLEmptyDescription.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyDescription, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDescriptionWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLDescriptionWithSpecialCharacters1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDescriptionWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLDescriptionWithSpecialCharacters2, *emptyBuffer, -996, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDescriptionCaps.kml")); + PrintParsedDataFromEncoderL(KKMLDescriptionCaps, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongDescription.kml")); + PrintParsedDataFromEncoderL(KKMLLongDescription, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousDescriptionTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousDescriptionTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousDescriptionTagposition.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousDescriptionTagposition, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingDescriptionTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingDescriptionTag1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingDescriptionTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingDescriptionTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDescriptionWithCDATA.kml")); + PrintParsedDataFromEncoderL(KKMLDescriptionWithCDATA, *emptyBuffer, KErrNone, KKmlMimeType ); + + //testing the folder tag related cases + iLog->Log(_L("Test with Tp47KMLErroneousFolderTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousFolderTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFolderCaps.kml")); + PrintParsedDataFromEncoderL(KKMLFolderCaps, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingFolderTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingFolderTag1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingFolderTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingFolderTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyFolderName.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyFolderName, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongFolderName.kml")); + PrintParsedDataFromEncoderL(KKMLLongFolderName, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFolderNameWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLFolderNameWithSpecialCharacters1, *emptyBuffer, -996, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFolderNameWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLFolderNameWithSpecialCharacters2, *emptyBuffer, KErrNone, KKmlMimeType ); + + + //testing the document tag related cases + iLog->Log(_L("Test with Tp47KMLDocumentNameWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLDocumentNameWithSpecialCharacters1, *emptyBuffer, -996, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDocumentNameWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLDocumentNameWithSpecialCharacters2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyDocumentName.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyDocumentName, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongDocumentName.kml")); + PrintParsedDataFromEncoderL(KKMLLongDocumentName, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLDocumentCaps.kml")); + PrintParsedDataFromEncoderL(KKMLDocumentCaps, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousDocumentTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousDocumentTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingDocumentTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingDocumentTag1, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingDocumentTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingDocumentTag2, *emptyBuffer, -993, KKmlMimeType ); + + + //testing the address tag related cases + iLog->Log(_L("Test with Tp47KMLAddressCaps.kml")); + PrintParsedDataFromEncoderL(KKMLAddressCaps, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLAddressWithSpecialCharacters1.kml")); + PrintParsedDataFromEncoderL(KKMLAddressWithSpecialCharacters1, *emptyBuffer, -996, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLAddressWithSpecialCharacters2.kml")); + PrintParsedDataFromEncoderL(KKMLAddressWithSpecialCharacters2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyAddress1.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyAddress1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyAddress2.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyAddress2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongAddress1.kml")); + PrintParsedDataFromEncoderL(KKMLLongAddress1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongAddress2.kml")); + PrintParsedDataFromEncoderL(KKMLLongAddress2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongAddress3.kml")); + PrintParsedDataFromEncoderL(KKMLLongAddress3, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousAddressTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousAddressTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousAddressTagPosition.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousAddressTagPosition, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingAddressTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingAddressTag1, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingAddressTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingAddressTag2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + //testing the coordinate tag related cases + iLog->Log(_L("Test with Tp47KMLCoordinateCaps.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinateCaps, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMoreCoordinates.kml")); + PrintParsedDataFromEncoderL(KKMLMoreCoordinates, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinateTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinateTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinateTagPosition.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinateTagPosition, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates1.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates2.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates3.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates3, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates4.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates4, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates5.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates5, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLCoordinates6.kml")); + PrintParsedDataFromEncoderL(KKMLCoordinates6, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongCoordinates1.kml")); + PrintParsedDataFromEncoderL(KKMLLongCoordinates1, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLLongCoordinates2.kml")); + PrintParsedDataFromEncoderL(KKMLLongCoordinates2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingCoordinateTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingCoordinateTag1, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingCoordinateTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingCoordinateTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates1.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates2.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates2, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates3.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates3, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates4.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates4, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates5.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates5, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates6.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates6, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyCoordinates7.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyCoordinates7, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinates1.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinates1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinates2.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinates2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinates3.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinates3, *emptyBuffer, KErrOverflow, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinates4.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinates4, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousCoordinates5.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousCoordinates5, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLNegativeCoordinates.kml")); + PrintParsedDataFromEncoderL(KKMLNegativeCoordinates, *emptyBuffer, KErrNone, KKmlMimeType ); + + //testing some invalid cases + iLog->Log(_L("Test with Tp47KMLErroneousTextWithinPlacemark.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousTextWithinPlacemark, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyfile1.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyfile1, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyfile2.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyfile2, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLInvalidfile.kml")); + PrintParsedDataFromEncoderL(KKMLInvalidfile, *emptyBuffer, -983, KKmlMimeType ); //EXmlMisplacedPi = -983 + + //testing the Placemark tag related cases + iLog->Log(_L("Test with Tp47KMLPlacemarkCaps.kml")); + PrintParsedDataFromEncoderL(KKMLPlacemarkCaps, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLErroneousPlacemarkTag.kml")); + PrintParsedDataFromEncoderL(KKMLErroneousPlacemarkTag, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPlacemarkTag1.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPlacemarkTag1, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLMissingPlacemarkTag2.kml")); + PrintParsedDataFromEncoderL(KKMLMissingPlacemarkTag2, *emptyBuffer, -993, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLEmptyPlacemarkTag.kml")); + PrintParsedDataFromEncoderL(KKMLEmptyPlacemarkTag, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + //testing with kml files downloaded from google earth + iLog->Log(_L("Test with Tp47KMLGandhi Museum.kml")); + PrintParsedDataFromEncoderL(KKMLGandhiMuseum, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLIndus Heritage Centre, India.kml")); + PrintParsedDataFromEncoderL(KKMLIndusHeritageCentreIndia, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLhilton hotels near new york (1 - 10).kml")); + PrintParsedDataFromEncoderL(KKMLHiltonHotels, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile4.kml")); + PrintParsedDataFromEncoderL(KKMLFile4, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile5.kml")); + PrintParsedDataFromEncoderL(KKMLFile5, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile6.kml")); + PrintParsedDataFromEncoderL(KKMLFile6, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile7.kml")); + PrintParsedDataFromEncoderL(KKMLFile7, *emptyBuffer, KErrNone, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile8.kml")); + PrintParsedDataFromEncoderL(KKMLFile8, *emptyBuffer, KErrPosLmUnknownFormat, KKmlMimeType ); + + iLog->Log(_L("Test with Tp47KMLFile9.kml")); + PrintParsedDataFromEncoderL(KKMLFile9, *emptyBuffer, -993, KKmlMimeType ); + + // Now compare tha trace file against the correct one + RFile correctFile; + RFile file; + + iLog->Log(_L(">>>>>>>Comparing files<<<<<")); + + TFileName filename; + CreateCorrectXmlFileL( KCorrectFile, filename ); + + User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); + CleanupClosePushL(correctFile); + User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); + CleanupClosePushL(file); + + HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); + TPtr correctLine = correctLinebuffer->Des(); + HBufC* linebuffer = HBufC::NewLC( KBufSize ); + TPtr line = linebuffer->Des(); + + TInt err = KErrNone; + TBool done = EFalse; + TInt lineNr = 0; + + while (ReadLn(correctFile, correctLine) != KErrEof && !done) + { + lineNr++; + err = ReadLn(file, line); + if ( err == KErrEof ) + { + done = ETrue; + } + correctLine.Trim(); + line.Trim(); + if (correctLine.Compare(line) != KErrNone) + { + HBufC* buf = HBufC::NewLC( 128 ); + TPtr buffer = buf->Des(); + + buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); + + iLog->Log( buffer ); + iLog->Log( correctLine ); + iLog->Log( line ); + iErrorsFound++; + CleanupStack::PopAndDestroy( buf ); + } + } + CleanupStack::PopAndDestroy(linebuffer); + CleanupStack::PopAndDestroy(correctLinebuffer); + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&correctFile); + + // EOF for trace file was reach before EOF in the correct file + if (done) + { + iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); + iErrorsFound++; + } + + iLog->Log(_L("Test with Empty MediaLink")); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyMedialink, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyMedialink, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Empty Coordinates")); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyCoordinates, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyCoordinates, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Empty AdresseInfo")); + PrintParsedDataFromEncoderL(KXMLFileWithEmptyAdresseInfo, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + // N/A for GPX + + iLog->Log(_L("Test with Erronous Text in Tag1")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag1, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag1, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Erronous Text in Tag2")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag2, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag2, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Erronous Text in Tag3")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag3, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag3, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Erronous Text in Tag4")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag4, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag4, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Erronous Text in Tag5")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag5, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag5, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + iLog->Log(_L("Test with Erronous Text in Tag6")); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag6, *emptyBuffer, KErrPosLmUnknownFormat, KLmxMimeType ); + PrintParsedDataFromEncoderL(KXMLFileWithErronousTextInTag6, *emptyBuffer, KErrPosLmUnknownFormat, KGpxMimeType ); + + CheckIndexNotSupportedL(); + + DoCancelTestL(); + + if (iErrorsFound != KErrNone)// LogErrorAndLeave(_L("Errors found in TP47")); + { + iLog->Log(_L("Errors found in TP47")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp47::CheckIndexNotSupportedL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::CheckIndexNotSupportedL() + { + iLog->Log(_L("CheckIndexNotSupportedL")); + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + iLandmarkParser->SetInputFileL(KFileName); + + // This function should leave with KErrNotSupported + TRAPD(err, iOperation = iLandmarkParser->ParseContentL(ETrue)); + + delete iOperation; + iOperation = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + if (err != KErrNotSupported) + { + iLog->Log(_L("ParseContentL(ETrue) did not leave with KErrNotSupported")); + User::Leave(err); + } + + iLandmarkParser = CPosLandmarkParser::NewL(KGpxMimeType); + iLandmarkParser->SetInputFileL(KFileName); + + // This function should leave with KErrNotSupported + TRAP(err, iOperation = iLandmarkParser->ParseContentL(ETrue)); + + delete iOperation; + iOperation = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + if (err != KErrNotSupported) + { + iLog->Log(_L("ParseContentL(ETrue) (GPX) did not leave with KErrNotSupported")); + User::Leave(err); + } + + iLog->Log(_L("CheckIndexNotSupportedL Done")); + } + +// --------------------------------------------------------- +// CPosTp47::DoCancelTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::DoCancelTestL() + { + iLog->Log(_L("DoCancelTestL")); + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + iLandmarkParser->SetInputFileL(KFileName); + + iOperation = iLandmarkParser->ParseContentL(); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // 1 ) Cancel parse function by deleting iOperation + delete iOperation; + iOperation = NULL; + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAPD(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + // 1 ) Cancel parse function by changing input + iOperation = iLandmarkParser->ParseContentL(); + + // Get the first landmark + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 1) + { + iLog->Log(_L("One landmark should be found")); + User::Leave(KErrNone); + } + + // Change input + iLandmarkParser->SetInputFileL(KFileName); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != 0) + { + iLog->Log(_L("No landmarks should be found")); + User::Leave(KErrNone); + } + + // No landmark should be found + TRAP(err, iLandmarkParser->LandmarkLC()); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: No Landmark should be found")); + iErrorsFound++; + } + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("DoCancelTestL Done")); + } + +// --------------------------------------------------------- +// CPosTp47::CreateXMLData +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::CreateXMLData(TBool aUseFile) + { + iLog->Log(_L("CreateXMLData")); + // 1) Create an encoder object + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + if (aUseFile) + { + DeleteFileL(KFileName); + // 2) Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KFileName); + } + else + { + // 2) Use buffer for encoding + iEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + } + + // 300 characters + _LIT(KLongFieldName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + _LIT(KLongFieldDescription, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + _LIT(KLongFieldDescriptionExtra, "A________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________BA________B"); + _LIT(KLongFieldDescriptionExtra2, "Extra Extra Extra Extra Extra Extra Extra Extra Extra Extra Extra Extra"); + + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, KLongFieldName); + iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, KLongFieldDescription); + iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)(EPosLmCollDataContentSpecificDataBegin), KLongFieldDescriptionExtra); + iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)(EPosLmCollDataContentSpecificDataBegin + 1), KLongFieldDescriptionExtra2); + + iLog->Log(_L("Create Data...")); + + // 3) Add one landmark with all fields set to be encoded + CPosLandmark* lm1 = CreateXMLLandmarkLC(_L("TP47Landmark1")); + AddAllXMLFieldsL(lm1); + + iLandmarkEncoder->AddLandmarkL(*lm1); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 4) Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 5) Add one category (pizzeria) to the latest added landmark + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + // 6) Add one landmark to be encoded (id=18 "enat?r" in category 18) + lm1 = iDatabase->ReadLandmarkLC(18); + iLandmarkEncoder->AddLandmarkL(*lm1); + // Remove field 408 which is not exported + lm1->RemovePositionField(408); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 7) Add one category (Frisör) to the latest added landmark + landmarkCategory = categoryManager->ReadCategoryLC(18); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + // 8 ) Add one global category (Entertainment) to the latest added landmark + + TPosLmItemId globalCategoryId = categoryManager->GetGlobalCategoryL(15000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found1")); + User::Leave(-1); + } + + // 9 ) Add one global category (People) to the latest added landmark + + globalCategoryId = categoryManager->GetGlobalCategoryL(27000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found2")); + User::Leave(-1); + } + // 11) Add one landmark with all fields set to empty (_L("")) + lm1 = CreateXMLLandmarkLC(_L("TP47LandmarkEmpty")); + AddAllEmptyXMLFieldsL(lm1); + iLandmarkEncoder->AddLandmarkL(*lm1); + // Remove field 402 (EPositionFieldCountryCode) which is not exported when empty + lm1->RemovePositionField(402); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 12) Add one landmark with all fields set to be encoded + lm1 = CreateXMLLandmarkLC(_L("TP47Landmark2")); + AddAllXMLFieldsL(lm1); + iLandmarkEncoder->AddLandmarkL(*lm1); + + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 13) Add one global category (Shopping) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(36000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found3")); + User::Leave(-1); + } + + // 14) Add one global category (Sports) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(42000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + // ) Finalize encoding + iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + iLog->Log(_L("FinalizeEncodingL Done")); + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp47::CheckXMLData +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::CheckXMLData(TBool aUseFile) + { + iLog->Log(_L("CheckXMLData")); + + // This number must be updated if any more landmarks are added + const TInt KNrOfAddedLandmarks = 5; + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + RArray array; + CleanupClosePushL(array); + + HBufC8* bufferContent = NULL; + + if (aUseFile) + { + iLog->Log(_L("----->Using FILE<-------")); + iLandmarkParser->SetInputFileL(KFileName); + } + else + { + iLog->Log(_L("----->Using BUFFER<-------")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + // 1) Get the first landmark, "TP47Landmark1", no categories + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 0, _L("1) Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CleanupStack::PopAndDestroy(lm); + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != number) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + // 2) Get landmark, "LOG9", local category Pizzeria + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 1, _L("2) Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[0]); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(1); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(lm); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != number) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + // 3) Get landmark, "enato?r", local categories Frisör, Hunddagis and global categories Sports Ground, Gas Station + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 3, _L("3) Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + // check local category Frisör here + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + cat = categoryManager->ReadCategoryLC(18); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + // check global category Sports Ground globalid=7 (id=33) here + category = iLandmarkParser->LandmarkCategoryLC(array[1]); + // cat = categoryManager->ReadCategoryLC(33); + cat = categoryManager->ReadCategoryLC(31); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=3 Gas station" here + category = iLandmarkParser->LandmarkCategoryLC(array[2]); + //cat = categoryManager->ReadCategoryLC(29); + cat = categoryManager->ReadCategoryLC(35); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + CleanupStack::PopAndDestroy(lm); + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != number)// LogErrorAndLeave(_L("Wrong number of landmarks parsed")); + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + // 4) Get landmark, TP47LandmarkEmpty, no categories + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 0, _L("4) Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + CleanupStack::PopAndDestroy(lm); + + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != number) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + // 5) Get landmark, TP47Landmark2, local categories Burger King and global categories Garage, Bus Stop + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + // Get last parsed landmark + lm = iLandmarkParser->LandmarkLC(); + lm->GetCategoriesL(array); + AssertTrueSecL(array.Count() == 2, _L("5) Wrong number of landmark categories")); + iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); + + // check global category Garage globalid=8 (id=34) here + category = iLandmarkParser->LandmarkCategoryLC(array[0]); + //cat = categoryManager->ReadCategoryLC(34); + cat = categoryManager->ReadCategoryLC(38); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + + //Check global category "id=10 Bus Stop" here + category = iLandmarkParser->LandmarkCategoryLC(array[1]); + // cat = categoryManager->ReadCategoryLC(36); + cat = categoryManager->ReadCategoryLC(40); + iErrorsFound += CompareXMLCategoriesL(*cat, *category); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(lm); + + // Check that correct number of landmarks has been parsed + if (number != KNrOfAddedLandmarks) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + nr = iLandmarkParser->NumOfParsedLandmarks(); + if ((TInt)nr != KNrOfAddedLandmarks) + { + iLog->Log(_L("Wrong number of landmarks parsed")); + User::Leave(-1); + } + + if (!aUseFile) CleanupStack::PopAndDestroy(bufferContent); + + CleanupStack::PopAndDestroy(&array); + CleanupStack::PopAndDestroy(categoryManager); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iOperation; + iOperation = NULL; + + // iEncoderBuffer was allocated in CreateXMLData + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLog->Log(_L("CheckXMLData Done")); + } + +// --------------------------------------------------------- +// CPosTp47::PrintParsedDataFromEncoderL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::PrintParsedDataFromEncoderL( + const TDesC& aFile, + const TDesC8& aBuffer, + TInt aExpectedStatusCode, + const TDesC8& aMimeType) + { + iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); + + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + + if (aFile != KNullDesC) + { + TFileName file( aFile ); + if ( aMimeType == KGpxMimeType ) + { + TInt pos = file.Find( KXmlFileExt ); + file.Replace( pos, KXmlFileExt().Length(), KGpxFileExt ); + } + iLog->Log(_L("FILE (%S)"), &file ); + TraceL(_L("----->Using FILE<-------")); + iLog->Log(_L("Calling TraceL")); + TraceL(file); + iLog->Log(_L("Input file to be set")); + iLandmarkParser->SetInputFileL(file); + iLog->Log(_L("Input file set")); + } + else + { + iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); + TraceL(_L("----->Using BUFFER<-------")); + iLandmarkParser->SetInputBuffer(aBuffer); + } + + iOperation = iLandmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + TInt number = 0; + + RArray array; + CleanupClosePushL(array); + iLog->Log(_L("Parse begin")); + while (status == KPosLmOperationNotComplete) + { + iLog->Log(_L("--- Parsing ---------------------------")); + TraceL(_L("------------------------------")); + iOperation->NextStep(status, progress); + + // Wait for NextStep to complete + User::WaitForRequest(status); + if (status != KPosLmOperationNotComplete && status != KErrNone) + { + HBufC* buffer = HBufC::NewLC( 128); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tStatus %d"), status.Int()); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + if ( iLandmarkParser->NumOfParsedLandmarks() ) + { + // Get last parsed landmark + CPosLandmark* lm = iLandmarkParser->LandmarkLC(); + TPtrC lmName; + TPtrC catName; + lm->GetLandmarkName(lmName); + lm->GetCategoriesL(array); + //iLog->Log(lmName); + for (TInt i=0;iLandmarkCategoryLC(array[i]); + category->GetCategoryName( catName ); + + HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); + TPtr buf = buffer->Des(); + + if ( category->GlobalCategory()) + { + buf.Append(_L("\tGlobal category: ")); + } + else + { + buf.Append(_L("\tLocal category: ")); + } + buf.Append(catName); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy(buffer); + buffer = NULL; + CleanupStack::PopAndDestroy(category); + } + + if ( aMimeType == KKmlMimeType ) + { + PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); + } + else + { + PrintLandmarkFieldsL(*lm, ETrue); + } + + number++; + CleanupStack::PopAndDestroy(lm); + } + } + } + + iLog->Log(_L("--- Parsing end ---------------------------")); + TraceL(_L("------------------------------")); + CleanupStack::PopAndDestroy(&array); + + if (status.Int() != aExpectedStatusCode) + { + HBufC* buffer = HBufC::NewLC( 128 ); + TPtr buf = buffer->Des(); + + buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); + iLog->Log( buf ); + iErrorsFound++; + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); + HBufC* buffer = HBufC::NewLC( 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + if (nr != (TUint32)number) + { + iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); + iErrorsFound++; + } + + TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 1")); + } + + while (lmId != EPosLmCollDataNone) + { + lmId = iLandmarkParser->NextCollectionDataId(lmId); + if (lmId != EPosLmCollDataNone) + { + TPtrC first = iLandmarkParser->CollectionData(lmId); + + HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Zero(); + buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); + buf.Append(first); + iLog->Log(buf); + TraceL(buf); + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + else + { + iLog->Log(_L("\tNo collection data found 2")); + } + } + + iLog->Log(_L("--- CollectionData ---")); + TraceL(_L("--- CollectionData ---")); + + + delete iOperation; + iOperation = NULL; + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); + } + +// --------------------------------------------------------- +// CPosTp47::PrintLandmarkFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::PrintLandmarkFieldsL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + TInt err; + TPtrC landmarkName; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + + buf.Append( _L(" \tLandmark Name: ")); + buf.Append( landmarkName ); + iLog->Log( buf ); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy(buffer); + } + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy( buffer ); + } + } + + + // --------------------------------------------------------- +// CPosTp47::PrintLandmarkFieldsWithDescriptionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) + { + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + + + TInt err; + TPtrC landmarkName; + TPtrC landmarkDescription; + err = aLandmark.GetLandmarkName(landmarkName); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Append(_L("\tLandmark Name: ")); + buf.Append(landmarkName); + iLog->Log(buf); + if( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( 1024 ); + TPtr buf = buffer->Des(); + TRealFormat format( 12, KRealFormatFixed ); + format.iPoint = TChar('.'); + format.iTriLen = KDoNotUseTriads; + format.iPlaces = 6; + + TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; + sLon.Num( loc.Longitude(), format ); + sLat.Num( loc.Latitude(), format ); + sAlt.Num( loc.Altitude(), format ); + sVacc.Num( loc.VerticalAccuracy(), format ); + sHacc.Num( loc.HorizontalAccuracy(), format ); + buf.Format( + _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), + &sLon, &sLat, &sVacc, &sHacc, &sAlt); + + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + sRad.Num( sourceR, format ); + buf.AppendFormat(_L("srcRadius %S"), &sRad); + } + iLog->Log(buf); + if (aTraceFlag) TraceL(buf); + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + //Get landmark description + err = aLandmark.GetLandmarkDescription(landmarkDescription); + if (err == KErrNone) + { + HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tLandmark Description: ")); + buf.Append(landmarkDescription); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + + CleanupStack::PopAndDestroy( buffer ); + buffer = NULL; + } + + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + + HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); + TPtr buf = buffer->Des(); + buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + if ( aTraceFlag ) + { + TraceL( buf ); + } + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + + CleanupStack::PopAndDestroy(buffer); + } +} +// --------------------------------------------------------- +// CPosTp47::TraceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp47::TraceL(const TDesC& msg) + { + _LIT8( KEnd, "\r\n" ); + + RFile file; + TInt err = file.Open(iFileSession, KFileTrace, EFileWrite); + if (err == KErrNotFound) + { + file.Create(iFileSession, KFileTrace, EFileWrite); + } + + HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg ); + + TInt pos( 0 ); + file.Seek( ESeekEnd, pos ); + file.Write( *line8 ); + file.Write( KEnd ); + file.Close(); + + delete line8; + } + +void CPosTp47::MakeEmptyLmDatabaseL( CPosLandmarkDatabase& aLdb, + CPosLmCategoryManager& aCatMgr ) + { + + CPosLmOperation* operation1 = aLdb.RemoveAllLandmarksL(); + //Remove all landmarks from default db : Sync call + ExecuteAndDeleteLD( operation1 ); + + RArray catArray; + CleanupClosePushL( catArray ); + + // Get all the categories from the database and delete them if necessary + CPosLmItemIterator* iter = aCatMgr.CategoryIteratorL(); + CleanupStack::PushL( iter ); + + TUint count = iter->NumOfItemsL(); + if ( count > 0 ) + { // can only be called if there are some items + iter->GetItemIdsL( catArray, 0, count ); + } + + // Remove all the categories here Sync call + ExecuteAndDeleteLD(aCatMgr.RemoveCategoriesL( catArray )); + CleanupStack::PopAndDestroy( 2 ); // catArray, iter + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp48.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp48.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1442 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp48.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS +_LIT(KXMLFile, "c:\\documents\\Tp48.xml"); +// Filename with 260 characters +_LIT(KLongFileName, "c:\\File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); +_LIT(KEmptyFileName1, "c:\\"); +_LIT(KEmptyFileName2, ""); +_LIT(KNonExistingFileName, "c:\\NonExistingFile.xml"); + +_LIT(KNewGlobalCategory, "OutSight"); + +const TInt KOrigGlobalCategoryId = 45000;// "Transport" + +//#define DEBUG EFalse +#define DEBUG ETrue +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp48::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iOperation; + iOperation = NULL; + + delete iDatabase; + iDatabase=NULL; + + delete iEncoderBuffer; + iEncoderBuffer = NULL; + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp48::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::StartL() + { + BaflUtils::EnsurePathExistsL( iFileSession, KXMLFile ); + + TInt lang = User::Language(); + iLog->Log(_L("StartL")); + + // Use file + DoTestL(ETrue, EFalse); + + // Use buffer + DoTestL(EFalse, EFalse); + + // Use file, parse XML content before import + DoTestL(ETrue, ETrue); + + // Use buffer, parse XML content before import + DoTestL(EFalse, ETrue); + + // Use file, cancel before complete + iLog->Log(_L("Use file, cancel before complete")); + DoTestL(ETrue, EFalse, EFalse, ETrue); + + iLog->Log(_L("Use buffer, cancel before complete")); + // Use buffer, cancel before complete + DoTestL(EFalse, EFalse, EFalse, ETrue); + + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + // Remove one global category + iLog->Log(_L("TC_Step10 Delete one global category")); + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + // Remove global category "Hotel global id=4" + + TPosLmItemId id = categoryManager->GetGlobalCategoryL(39000); + ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(id)); + + //Verify removed + + id = categoryManager->GetGlobalCategoryL(39000); + if (id != KPosLmNullItemId) + { + iLog->Log(_L("Global category has not been removed")); + User::Leave(-1); + } + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + iLandmarkParser->SetInputFileL(KXMLFile); + + iLog->Log(_L("TC_Step11 Import all landmarks")); + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EIncludeCategories)); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + //Verify that global category has been added again, since it is predefined it should be + // imported as a global category (otherwise it should be a local category) + + id = categoryManager->GetGlobalCategoryL(39000); + if (id == KPosLmNullItemId) iLog->Log(_L("Global category has not been added")); + + CPosLandmarkCategory* catte = categoryManager->ReadCategoryLC(id); + + if (catte->GlobalCategory() == KPosLmNullGlobalCategory) iLog->Log(_L(" Not global category")); + + CleanupStack::PopAndDestroy(catte); + + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + + CleanupStack::PopAndDestroy(categoryManager); + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + // Rename one global category + // Rename global category "Shop global id=5" to Nisses BilAffär + iLog->Log(_L("TC_Step12 Rename one global category")); + id = categoryManager->GetGlobalCategoryL(15000); + catte = categoryManager->ReadCategoryLC(id); + catte->SetCategoryNameL(_L("Nisses BilAffär")); + categoryManager->UpdateCategoryL(*catte); + CleanupStack::PopAndDestroy(catte); + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + iLandmarkParser->SetInputFileL(KXMLFile); + + iLog->Log(_L("TC_Step13 Import all landmarks")); + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EIncludeCategories)); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + //Verify that global category has been added again, since it is predefined it should be + // imported as a global category (otherwise it should be a local category) + + TPosLmItemId id1 = categoryManager->GetGlobalCategoryL(15000); + if (id1 == KPosLmNullItemId) iLog->Log(_L("Global category has not been added")); + + TPosLmItemId id2 = categoryManager->GetCategoryL(_L("Nisses BilAffär")); + if (id2 == KPosLmNullItemId) iLog->Log(_L("Global category has not been added 2")); + + if (id1 != id2) + { + iLog->Log(_L("Categories should have the same id")); + User::Leave(-1); + } + + catte = categoryManager->ReadCategoryLC(id1); + if (catte->GlobalCategory() == KPosLmNullGlobalCategory) iLog->Log(_L("Nisses Bilaffär is no global category")); + + id = categoryManager->GetCategoryL(_L("Shop")); + if (id != KPosLmNullItemId) iLog->Log(_L("Shop should not exist")); + + CleanupStack::PopAndDestroy(catte); + CleanupStack::PopAndDestroy(categoryManager); + + iLog->Log(_L("TC_Step14 Test import with long file name")); + ImportFromFileWithLongFileNameL(); + + iLog->Log(_L("TC_Step15 Change ")); + DoTestChangeInputMethodL(); + + if (iErrorsFound != KErrNone) + { + + iLog->Log(_L("Errors were found in TP48")); + User::Leave(-1); + } + + } + +// --------------------------------------------------------- +// CPosTp48::DoTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::DoTestL(TBool aFile, TBool aFullParse, TBool aDoParse, TBool aCancel) + { + iLog->Log(_L("DoTestL")); + + // find localized name of needed category + HBufC* origGlobalCategory = GetGlobalCategoryFromResourceLC( KOrigGlobalCategoryId ); + + RArray subset; + CleanupClosePushL(subset); + + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + + HBufC8* bufferContent = NULL; + + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + if (aFile) + { + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + } + else + { + // Use buffer for encoding + iEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + } + + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step2 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step2 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + iLog->Log(_L("TC_Step3 Import all landmarks Synchronously")); + ImportLandmarksL(ETrue, aFullParse, CPosLandmarkDatabase::EDefaultOptions, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step3 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step3 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + iLog->Log(_L("TC_Step3 Import all landmarks Asynchronously")); + ImportLandmarksL(EFalse, aFullParse, CPosLandmarkDatabase::EDefaultOptions, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step3 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step3 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + iLog->Log(_L("TC_Step3 Import all landmarks Synchronously")); + ImportLandmarksL(ETrue, aFullParse, CPosLandmarkDatabase::EDefaultOptions, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + + // Only import a subset of landmarks + iLog->Log(_L("TC_Step4 Only import a subset of landmarks, Sync")); + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step4 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step4 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + subset.Append(0); + subset.Append(1); + subset.Append(2); + subset.Append(3); + + delete iLandmarks[7]; + delete iLandmarks[6]; + delete iLandmarks[5]; + delete iLandmarks[4]; + + iLandmarks.Remove(7); + iLandmarks.Remove(6); + iLandmarks.Remove(5); + iLandmarks.Remove(4); + + ImportLandmarksL(ETrue, aFullParse, CPosLandmarkDatabase::EDefaultOptions, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + subset.Reset(); + + // Only import a subset of landmarks + iLog->Log(_L("TC_Step4 Only import a subset of landmarks, Async")); + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step4 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step4 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + subset.Append(0); + subset.Append(1); + subset.Append(2); + subset.Append(3); + + delete iLandmarks[7]; + delete iLandmarks[6]; + delete iLandmarks[5]; + delete iLandmarks[4]; + + iLandmarks.Remove(7); + iLandmarks.Remove(6); + iLandmarks.Remove(5); + iLandmarks.Remove(4); + + ImportLandmarksL(EFalse, aFullParse, CPosLandmarkDatabase::EDefaultOptions, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + subset.Reset(); + + iLog->Log(_L("TC_Step5 Only import a subset of landmarks, use EIncludeCategories, ASync")); + ResetLandmarksDbL(); + subset.Reset(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step5 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step5 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + subset.Append(0); + subset.Append(1); + subset.Append(2); + subset.Append(3); + subset.Append(7); + + delete iLandmarks[6]; + delete iLandmarks[5]; + delete iLandmarks[4]; + + iLandmarks.Remove(6); + iLandmarks.Remove(5); + iLandmarks.Remove(4); + + ImportLandmarksL(EFalse, aFullParse, CPosLandmarkDatabase::EIncludeCategories, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + + iLog->Log(_L("TC_Step5 Only import a subset of landmarks, use EIncludeCategories, Sync")); + ResetLandmarksDbL(); + subset.Reset(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step5 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step5 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + subset.Append(0); + subset.Append(1); + subset.Append(2); + subset.Append(3); + subset.Append(7); + + delete iLandmarks[6]; + delete iLandmarks[5]; + delete iLandmarks[4]; + + iLandmarks.Remove(6); + iLandmarks.Remove(5); + iLandmarks.Remove(4); + + ImportLandmarksL(ETrue, aFullParse, CPosLandmarkDatabase::EIncludeCategories, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + // Since only EIncludeCategories was used, the global category should not have been overwritten + CheckGlobalCategoryExistL(*origGlobalCategory, KNewGlobalCategory); + + // Now use EIncludeCategories | EIncludeGlobalCategoryNames which should cause the global cateory name to + // be overwritten + iLog->Log(_L("TC_Step5 Only import a subset of landmarks, use EIncludeCategories | EIncludeGlobalCategoryNames, Sync")); + subset.Reset(); + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step5 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step5 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + subset.Append(0); + subset.Append(1); + subset.Append(2); + subset.Append(3); + subset.Append(4); + subset.Append(5); + subset.Append(6); + subset.Append(7); + + ImportLandmarksL(ETrue, aFullParse, CPosLandmarkDatabase::EIncludeCategories | CPosLandmarkDatabase::EIncludeGlobalCategoryNames, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + // Since EIncludeCategories| EIncludeGlobalCategoryNames was used, the global category should have been overwritten + // Dont do check if cancel was performed + if (!aCancel) CheckGlobalCategoryExistL(KNewGlobalCategory, *origGlobalCategory); + + iLog->Log(_L("TC_Step5 Only import a subset of landmarks, use EIncludeCategories | EIncludeGlobalCategoryNames, Async")); + ResetLandmarksDbL(); + DeleteFileL(KXMLFile); + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + // Use file for encoding, set output file + iLandmarkEncoder->SetOutputFileL(KXMLFile); + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + if (aFile) + { + iLog->Log(_L("TC_Step5 Set input to be parsed from XML File")); + iLandmarkParser->SetInputFileL(KXMLFile); + } + else + { + iLog->Log(_L("TC_Step5 Set input to be parsed from buffer")); + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + } + + ImportLandmarksL(EFalse, aFullParse, CPosLandmarkDatabase::EIncludeCategories | CPosLandmarkDatabase::EIncludeGlobalCategoryNames, subset, aDoParse, aCancel); + delete iLandmarkParser; + iLandmarkParser = NULL; + if (!aFile) CleanupStack::PopAndDestroy(bufferContent); + // Since EIncludeCategories| EIncludeGlobalCategoryNames was used, the global category should have been overwritten + // Dont do check if cancel was performed + if (!aCancel) CheckGlobalCategoryExistL(KNewGlobalCategory, *origGlobalCategory); + + CleanupStack::PopAndDestroy(&subset); + delete iEncoderBuffer; + iEncoderBuffer = NULL; + CleanupStack::PopAndDestroy( origGlobalCategory ); + } + +// --------------------------------------------------------- +// CPosTp48::ImportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::ImportLandmarksL(TBool aSync, TBool aFullParse, TUint aTransferOption, const RArray& aLandmarkSubSet, TBool aDoParse, TBool aCancel) + { + iLog->Log(_L("ImportLandmarksL")); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress = 0; + + if (aFullParse) + { + // ParseContent before importing + ExecuteAndDeleteLD(iLandmarkParser->ParseContentL()); + iLog->Log(_L("After ExecuteAndDeleteLD(iLandmarkParser->ParseContentL());")); + } + + if (aDoParse) + { + // Do an "almost full" parsecontent before import + iOperation = iLandmarkParser->ParseContentL(); + + + while (progress <0.7) + { + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + } + iLog->Log(_L("After aDoParse")); + delete iOperation; + iOperation = NULL; + } + + if (aLandmarkSubSet.Count() == 0) + { + iOperation = iDatabase->ImportLandmarksL(*iLandmarkParser, aTransferOption); + } + else + { + // Import only a subset of the landmarks in parser + iOperation = iDatabase->ImportLandmarksL(*iLandmarkParser, aLandmarkSubSet, aTransferOption); + } + + if (aSync) + { + // Synchronous + ExecuteAndDeleteLD(iOperation); + iOperation = NULL; + iLog->Log(_L("After aSync")); + } + else + { + // Asynchronous + // Progress us checked in test procedure base + if (aCancel) + { + + // It is no more possible to do WaitForRequest after ImportLandmarksL + RunAsyncOperationAndCancelInCallbackLD(iOperation); + iOperation = NULL; + iLog->Log(_L("After aCancel")); + } + else + { + RunAsyncOperationLD(iOperation); + iOperation = NULL; + iLog->Log(_L("After RunAsyncOperationLD(iOperation);")); + } + } + + if (!aCancel) CheckLandmarksDatabaseL(aTransferOption); + + } + +// --------------------------------------------------------- +// CPosTp48::ResetLandmarksDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::ListLandmarksDbL() + { + iLog->Log(_L("ListLandmarksDbL")); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + RArray categories; + CleanupClosePushL(categories); + + iLog->Log(_L("Landmarks:")); + TPosLmItemId id = iter->NextL(); + TBuf<255> buffe; + while (id != KPosLmNullItemId) + { + TPtrC name; + + CPosLandmark* lm = iDatabase->ReadLandmarkLC(id); + lm->GetLandmarkName(name); + + buffe.Zero(); + buffe.Append(name); + lm->GetCategoriesL(categories); + + buffe.Append(_L(" With Categories: ")); + iLog->Log(buffe); + for (TInt i=0;iReadCategoryLC(categories[i]); + cat->GetCategoryName(name); + buffe.Zero(); + buffe.Append(name); + iLog->Log(buffe); + CleanupStack::PopAndDestroy(cat); + } + CleanupStack::PopAndDestroy(lm); + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(&categories); + CleanupStack::PopAndDestroy(iter); + + iter = categoryManager->CategoryIteratorL(); + CleanupStack::PushL(iter); + + iLog->Log(_L("Categories:")); + id = iter->NextL(); + while (id != KPosLmNullItemId) + { + TPtrC name; + TBuf<255> buffe; + + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(id); + cat->GetCategoryName(name); + buffe.Zero(); + buffe.Append(name); + iLog->Log(buffe); + CleanupStack::PopAndDestroy(cat); + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp48::ResetLandmarksDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::ResetLandmarksDbL() + { + iLog->Log(_L("ResetLandmarksDbL")); + + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + + delete iDatabase; + iDatabase=NULL; + + // Use same lm db as in composite search test + iDatabase = UseCompositeLandmarksDbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + delete iDatabase; + iDatabase = NULL; + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + iLog->Log(_L("ResetLandmarksDbL Done")); + } + +// --------------------------------------------------------- +// CPosTp48::DoTestChangeInputMethodL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::DoTestChangeInputMethodL() + { + iLog->Log(_L("DoTestChangeInputMethodL")); + ResetLandmarksDbL(); + + HBufC8* bufferContent = NULL; + + iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); + iEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); + + CreateXMLDataL(); + delete iLandmarkEncoder; + iLandmarkEncoder = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + + bufferContent = HBufC8::NewLC(iEncoderBuffer->Size()); + TPtr8 ptr = bufferContent->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + iLandmarkParser->SetInputBuffer(*bufferContent); + + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress = 0; + + // Do an "almost full" parsecontent + iOperation = iLandmarkParser->ParseContentL(); + while (progress <0.5) + { + iOperation->NextStep(status, progress); + // Wait for NextStep to complete + User::WaitForRequest(status); + } + + delete iOperation; + iOperation = NULL; + + // Change input method + iLandmarkParser->SetInputFileL(KXMLFile); + + // Now import all XML data from file + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iLandmarkParser, CPosLandmarkDatabase::EDefaultOptions)); + CheckLandmarksDatabaseL(CPosLandmarkDatabase::EDefaultOptions); + + CleanupStack::PopAndDestroy(bufferContent); + + delete iLandmarkParser; + iLandmarkParser = NULL; + } + +// --------------------------------------------------------- +// CPosTp48::ImportFromFileWithLongFileNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::ImportFromFileWithLongFileNameL() + { + iLog->Log(_L("ImportFromFileWithLongFileNameL")); + delete iLandmarkParser; + iLandmarkParser = NULL; + + iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); + TRAPD(err, iLandmarkParser->SetInputFileL(KLongFileName)); + + // Error differs between winscw and target + + if ( err != KErrBadName ) + { + TBuf<100> buf; + buf.Format(_L("ERROR: SetInputFileL should leave with KErrBadName, instead err: %d"), err); + iLog->Log(buf); + iErrorsFound++; + } + + // Also test empty filename here + TRAP(err, iLandmarkParser->SetInputFileL(KEmptyFileName1)); + if (err != KErrBadName) + { + iLog->Log(_L("ERROR: SetInputFileL(KEmptyFileName1) should leave with KErrBadName")); + iErrorsFound++; + } + + // Also test empty filename here + TRAP(err, iLandmarkParser->SetInputFileL(KEmptyFileName2)); + if (err != KErrBadName) + { + TBuf<100> buf; + buf.Format(_L("ERROR: SetInputFileL(KEmptyFileName2) should leave with KErrBadName, instead err: %d"), err); + iLog->Log(buf); + iErrorsFound++; + } + + // Also test non existing filen here + TRAP(err, iLandmarkParser->SetInputFileL(KNonExistingFileName)); + if (err != KErrNotFound) + { + iLog->Log(_L("ERROR: SetInputFileL(KNonExistingFileName) should leave with KErrNotFound")); + iErrorsFound++; + } + + delete iLandmarkParser; + iLandmarkParser = NULL; + iLog->Log(_L("ImportFromFileWithLongFileNameL Done")); + } + +// --------------------------------------------------------- +// CPosTp48::CheckLandmarksDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::CheckLandmarksDatabaseL(TUint aTransferOption) + { + iLog->Log(_L("CheckLandmarksDatabaseL")); + iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + TUint attr = CPosLandmark::ELandmarkName; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + RArray sourceArray; + CleanupClosePushL(sourceArray); + + RArray array; + CleanupClosePushL(array); + + TInt nrOfLandmarks = iLandmarks.Count(); + TPtrC lmName; + + for (TInt i=0;iGetLandmarkName(lmName); + + textCriteria->SetAttributesToSearch(attr); + textCriteria->SetTextL(lmName); + + ExecuteAndDeleteLD(iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); + + CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + TUint nr = iLandmarkSearch->NumOfMatches(); + iLog->Log(_L("****** Found %d nr of landmarks when looking for '%S'"),nr, &lmName); + TPosLmItemId id = iter->NextL(); + + if (nr > 1) + { + // The first landmark is the one existing in db before import, + // no need to check that one, only the one added from import (the second one) + id = iter->NextL(); + } + + while (id != KPosLmNullItemId) + { + CPosLandmark* source = iDatabase->ReadLandmarkLC(id); + TPtrC sourceName; + source->GetLandmarkName(sourceName); + + iLog->Log(_L("Found landmark '%S'"), &sourceName); + + TInt err = CompareXMLLandmarksL(*iLandmarks[i], *source, DEBUG); + if (err != KErrNone) + { + PrintLandmarkIdFieldsL(*iLandmarks[i]); + PrintLandmarkIdFieldsL(*source); + iLog->Log(_L("ERROR: CompareXMLLandmarksL returned error")); + iErrorsFound+=err; + } + + source->GetCategoriesL(sourceArray); + iLandmarks[i]->GetCategoriesL(array); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + if (aTransferOption == CPosLandmarkDatabase::EDefaultOptions) + { + // No categories imported + if (sourceArray.Count() != 0) + { + iLog->Log(_L("ERROR: No categories should have been imported, found %d "), sourceArray.Count()); + iErrorsFound++; + } + } + else + { + if (sourceArray.Count() != array.Count()) + { + for (TInt j=0;jReadCategoryLC(sourceArray[j]); + TPtrC sourceName; + sourceCat->GetCategoryName( sourceName ); + iLog->Log(_L("Found category '%S'"), &sourceName); + } + iLog->Log(_L("ERROR: Nr of categories differ, was %d should be %d"), sourceArray.Count(), array.Count()); + User::Leave(KErrNone); + } + + for (TInt j=0;jLog(_L("Src Id: %d Id: %d"), sourceArray[j], array[j]); + + CPosLandmarkCategory* sourceCat = categoryManager->ReadCategoryLC(sourceArray[j]); + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(array[j]); + TPtrC sourceName, name; + cat->GetCategoryName(name); + sourceCat->GetCategoryName(sourceName); + iLog->Log(_L("Found category, source cat '%S', cat '%S'"), &sourceName, &name); + iErrorsFound += CompareXMLCategoriesL(*cat, *sourceCat, DEBUG); + CleanupStack::PopAndDestroy(cat); + CleanupStack::PopAndDestroy(sourceCat); + } + } + CleanupStack::PopAndDestroy(categoryManager); + + CleanupStack::PopAndDestroy(source); + id = iter->NextL(); + } + CleanupStack::PopAndDestroy(iter); + } + + CleanupStack::PopAndDestroy(&array); + CleanupStack::PopAndDestroy(&sourceArray); + CleanupStack::PopAndDestroy(textCriteria); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + } + +// --------------------------------------------------------- +// CPosTp48::RemoveCategoriesFromLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::RemoveCategoriesFromLandmarkL(CPosLandmark& aLandmark) + { + RArray array; + CleanupClosePushL(array); + + aLandmark.GetCategoriesL(array); + + for (TInt i=0;iLog(_L("CreateXMLDataL")); + + // 3 Add one landmark to be encoded (id7 name "Billigt" in categories 1-3,14-17) + CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); + iLandmarkEncoder->AddLandmarkL(*lm1); + // Remove field 408 which is not exported + lm1->RemovePositionField(408); + RemoveCategoriesFromLandmarkL(*lm1); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + // 4 Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) + CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + + // 5 Create a new category and add to the latest added landmark + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(37); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + + RemoveCategoriesFromLandmarkL(*lm2); + lm2->AddCategoryL(37); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 6 Add one more landmark to be encoded (id52 "Kalles Hundgård" in category 19) + lm2 = iDatabase->ReadLandmarkLC(52); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + + // 7 Add several global and local categories to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + landmarkCategory = categoryManager->ReadCategoryLC(26); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + landmarkCategory = categoryManager->ReadCategoryLC(25); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + + TPosLmItemId globalCategoryId = categoryManager->GetGlobalCategoryL(3000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found1")); + User::Leave(-1); + } + + + globalCategoryId = categoryManager->GetGlobalCategoryL(15000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found2")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(categoryManager); + + RemoveCategoriesFromLandmarkL(*lm2); + lm2->AddCategoryL(26); + lm2->AddCategoryL(25); + lm2->AddCategoryL(27); + lm2->AddCategoryL(31); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 8 Add one landmark (not containing any categories), id=11 "MLFW" + lm2 = iDatabase->ReadLandmarkLC(11); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + RemoveCategoriesFromLandmarkL(*lm2); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 9 Add one more landmark (not containing any categories), id=56 "TE, Lund" + lm2 = iDatabase->ReadLandmarkLC(56); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + + // 10 Add one category to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + landmarkCategory = categoryManager->ReadCategoryLC(18); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + + RemoveCategoriesFromLandmarkL(*lm2); + lm2->AddCategoryL(18); + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 11 Add one landmark (not containing any categories), id=43 "asdf" + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + lm2 = iDatabase->ReadLandmarkLC(43); + iLandmarkEncoder->AddLandmarkL(*lm2); + // Remove field 408 which is not exported + lm2->RemovePositionField(408); + + // 12 Add several local and global categories to the latest added landmark + landmarkCategory = categoryManager->ReadCategoryLC(23); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + landmarkCategory = categoryManager->ReadCategoryLC(17); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + + globalCategoryId = categoryManager->GetGlobalCategoryL(39000); + + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found3")); + User::Leave(-1); + } + + + globalCategoryId = categoryManager->GetGlobalCategoryL(27000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + RemoveCategoriesFromLandmarkL(*lm2); + lm2->AddCategoryL(23); + lm2->AddCategoryL(17); + lm2->AddCategoryL(39); + lm2->AddCategoryL(35); + + iLandmarks.Append(lm2); + CleanupStack::Pop(lm2); + + // 13) Add a landmark with fields that are encoded to XML set + lm1 = CreateXMLLandmarkLC(_L("TP48LandmarkWithAllXMLFields")); + AddAllXMLFieldsL(lm1); + iLandmarkEncoder->AddLandmarkL(*lm1); + + // 13) Add one global category (Garage) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(24000); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + // 14) Add one global category (Bus stop) to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(42000);//30000 + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + // 15) Add one category (BurgerKing) to the latest added landmark + landmarkCategory = categoryManager->ReadCategoryLC(17); + + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + RemoveCategoriesFromLandmarkL(*lm1); + lm1->AddCategoryL(34); + lm1->AddCategoryL(40); + lm1->AddCategoryL(17); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + CleanupStack::PopAndDestroy(categoryManager); + + // 16 Create new landmark with empty fields + lm1 = CreateXMLLandmarkLC(_L("TP48Landmark With Empty XML Fields")); + AddAllEmptyXMLFieldsL(lm1); + iLandmarkEncoder->AddLandmarkL(*lm1); + + // 17 Create a new category and add to the latest added landmark + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + //landmarkCategory = CPosLandmarkCategory::NewLC(); + landmarkCategory = categoryManager->ReadCategoryLC(38); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + // 18 Add global category "Outsight" which is "Sight" id=6 with changed name + // and add to the latest added landmark + globalCategoryId = categoryManager->GetGlobalCategoryL(KOrigGlobalCategoryId); + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + landmarkCategory->SetCategoryNameL(KNewGlobalCategory); + categoryManager->UpdateCategoryL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + + + globalCategoryId = categoryManager->GetGlobalCategoryL(KOrigGlobalCategoryId); + if (globalCategoryId != KPosLmNullItemId) + { + landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); + iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); + CleanupStack::PopAndDestroy(landmarkCategory); + } + else + { + iLog->Log(_L("Global category was not found4")); + User::Leave(-1); + } + + CleanupStack::PopAndDestroy(categoryManager); + + RemoveCategoriesFromLandmarkL(*lm1); + // The new category will have id=38 + lm1->AddCategoryL(38); + lm1->AddCategoryL(globalCategoryId); + // Remove field 402 which is not included + lm1->RemovePositionField(402); + iLandmarks.Append(lm1); + CleanupStack::Pop(lm1); + + // 13 Finalize encoding + //iLog->Log(_L("FinalizeEncodingL")); + ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); + //iLog->Log(_L("FinalizeEncodingL Done")); + + categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + //Change back name for this global category, needed to test use of TTransferOptions::EIncludeGlobalCategoryNames + // by resetting global categories + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + + iLog->Log(_L("CreateXMLDataL Done")); + } + + +// --------------------------------------------------------- +// CPosTp48::CheckGlobalCategoryExistL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::CheckGlobalCategoryExistL(const TDesC& aShouldExistName, const TDesC& aShouldNotExistName) + { + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + // Should be found + TPosLmItemId id1 = categoryManager->GetCategoryL(aShouldExistName); + // Should not be found + TPosLmItemId id2 = categoryManager->GetCategoryL(aShouldNotExistName); + + if (id1 == KPosLmNullItemId) + { + iLog->Log(_L("ERROR: CheckGlobalCategoryExistL Global Category '%S' should be found"), + &aShouldExistName); + iErrorsFound++; + } + + if (id2 != KPosLmNullItemId) + { + iLog->Log(_L("ERROR: CheckGlobalCategoryExistL Global Category '%S' should NOT be found"), + &aShouldNotExistName); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp48::PrintLandmarkIdFieldsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp48::PrintLandmarkIdFieldsL(const CPosLandmark& aLandmark) + { + TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); + TLocality loc; + TBuf<150> buf; + TInt err = aLandmark.GetPosition(loc); + if (err == KErrNone) + { + TReal vertAcc(loc.VerticalAccuracy()); + TReal horAcc(loc.HorizontalAccuracy()); + TReal alt(loc.Altitude()); + TReal lon = loc.Longitude(); + TReal lat = loc.Latitude(); + TReal32 sourceR; + err = aLandmark.GetCoverageRadius(sourceR); + if (err == KErrNone ) + { + buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f srcRadius %f"), lon, lat, vertAcc, horAcc, alt, sourceR); + } + else + { + buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f "), lon, lat, vertAcc, horAcc, alt); + } + iLog->Log(buf); + } + + while (sourceFieldId != EPositionFieldNone) + { + TPtrC sourceValue; + aLandmark.GetPositionField(sourceFieldId, sourceValue); + buf.Format(_L("IdField Id: %d Value:"), sourceFieldId); + buf.Append(sourceValue); + iLog->Log(buf); + sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); + } + } + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp49.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp49.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,472 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp49.h" +#include +#include +#include + +// CONSTANTS +#ifdef __WINS__ +_LIT(KFileWithCorrectSyntax, "z:\\system\\test\\testdata\\Tp49ImportInput.xml"); +_LIT(KFileWithSyntaxError, "z:\\system\\test\\testdata\\Tp49ImportInputSyntaxError.xml"); +#else +_LIT(KFileWithCorrectSyntax, "c:\\system\\test\\testdata\\Tp49ImportInput.xml"); +_LIT(KFileWithSyntaxError, "c:\\system\\test\\testdata\\Tp49ImportInputSyntaxError.xml"); +#endif +const TInt KNrOfImportedLandmarks = 7; + +#ifdef __WINS__ +const TInt KNrOfCorrectLandmarks = 3; +#else +const TInt KNrOfCorrectLandmarks = 4; +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp49::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::GetName(TDes& aName) const + { + _LIT(KTestName, "TP49 - Iterate imported landmarks"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp49::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::InitTestL() + { + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + SetupPreConditionsL(); + } + +// --------------------------------------------------------- +// CPosTp49::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::CloseTest() + { + // Delete and set base class members to NULL + delete iOperation; + iOperation = NULL; + delete iIterator; + iIterator = NULL; + delete iDatabase; + iDatabase = NULL; + + delete iLandmarkParser; + iImportedLandmarkIds.Close(); + iRemovedLandmarkIds.Close(); + + delete iLandmarkNames; + iLandmarkNames = NULL; + + } + +// --------------------------------------------------------- +// CPosTp49::NotifyProgress +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::NotifyProgress(TReal aProgress) + { + if (aProgress > iProgressInterruptLevel) + { + CActiveScheduler::Stop(); + } + } + +// --------------------------------------------------------- +// CPosTp49::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::StartL() + { + // <<<<<<<<<<<<<< 1-2 Import unparsed landmarks >>>>>>>>>>>>>>>>>>> + RecreateParserL(KFileWithCorrectSyntax); + ImportAllLandmarksL(); + FetchIteratorL(); + VerifyImportedLandmarksL(KNrOfImportedLandmarks); + + // <<<<<<<<<<<<<< 3-5 Import parsed landmarks >>>>>>>>>>>>>>>>>>> + RecreateParserL(KFileWithCorrectSyntax); + ParseLandmarksContentL(); + ImportAllLandmarksL(); + FetchIteratorL(); + VerifyImportedLandmarksL(KNrOfImportedLandmarks); + + // <<<<<<<<<<<<<< 6-8 Remove some imported landmarks >>>>>>>>>>>>>>>>>>> + RecreateParserL(KFileWithCorrectSyntax); + ImportAllLandmarksL(); + FetchIteratorL(); + RemoveThreeLandmarksL(); + FetchIteratorL(); + VerifyImportedLandmarksL(KNrOfImportedLandmarks); + + // <<<<<<<<<<<<<< 9-10 Fetch iterator before import is ready >>>>>>>>>>>>>>>>>>> + iProgressInterruptLevel = 0.5; // Cancel the import operation when half ready. + TInt nrOfLandmarks = ImportSomeLandmarksL(); + // Cancel import operation, otherwise db will be locked when verifying + delete iOperation; iOperation = NULL; + VerifyImportedLandmarksL(nrOfLandmarks); + + // <<<<<<<<<<<<<< 11-12 Fetch iterator before import is started >>>>>>>>>>>>>>>>>>> + iProgressInterruptLevel = 0; // Cancel the import operation as fast as possible. + nrOfLandmarks = ImportSomeLandmarksL(); + // Cancel import operation, otherwise db will be locked when verifying + delete iOperation; iOperation = NULL; + VerifyImportedLandmarksL(nrOfLandmarks); + + // <<<<<<<<<<<<<< 13-14 Fetch iterator if import fails >>>>>>>>>>>>>>>>>>> + RecreateParserL(KFileWithSyntaxError); + StartImportLandmarksL(); + ExecuteLmOpL(EXmlTagMismatch); + FetchIteratorL(); + CreateNameArrayL(KNrOfCorrectLandmarks); + // We don't need to cancel operation since import operation failed. Hence + // it should release the database lock itself. + // delete iOperation; iOperation = NULL; + // Note: It seems that there is a difference between target and emulator in the number of imported + // landmarks in each next step, thus it differs in the number of imported lms before the incorrect xml-landmark + // is found + VerifyImportedLandmarksL(KNrOfCorrectLandmarks); + + // <<<<<<<<<<<<<< 15 Test leave codes - nothing to do >>>>>>>>>>>>>>>>>>> + iLog->Put(_L("TP49 Done")); + } + +// --------------------------------------------------------- +// CPosTp49::ImportAllLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::ImportAllLandmarksL() + { + // Fetch nr of existing items before import + CPosLmItemIterator* iterator = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iterator); + TInt nrOfItems = iterator->NumOfItemsL(); + CleanupStack::PopAndDestroy(iterator); + + StartImportLandmarksL(); + ExecuteLmOpL(KErrNone); + CreateNameArrayL(KNrOfImportedLandmarks); + + // Check nr of landmarks in db after import + iterator = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iterator); + _LIT(KErrMsg, "Not all landmarks were imported to database!"); + TInt nrOfImportedItems = iterator->NumOfItemsL() - nrOfItems; + AssertTrueSecL( + nrOfImportedItems == KNrOfImportedLandmarks, KErrMsg, KErrGeneral); + CleanupStack::PopAndDestroy(iterator); + } + +// --------------------------------------------------------- +// CPosTp49::ImportSomeLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp49::ImportSomeLandmarksL() + { + RecreateParserL(KFileWithCorrectSyntax); + StartImportLandmarksL(); + ExecuteLmOpL(KPosLmOperationNotComplete, ETrue); + FetchIteratorL(); + CreateNameArrayL(iIterator->NumOfItemsL()); + return iIterator->NumOfItemsL(); + } + +// --------------------------------------------------------- +// CPosTp49::ParseLandmarksContentL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::ParseLandmarksContentL() + { + delete iOperation; + iOperation = NULL; + iOperation = iLandmarkParser->ParseContentL(); + ExecuteLmOpL(KErrNone); + } + +// --------------------------------------------------------- +// CPosTp49::RemoveThreeLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::RemoveThreeLandmarksL() + { + // It is important that the highest index is removed first. + TInt indexToRemove[] = {6, 5, 2}; + + const TInt KNrOfItemsToRemove = 3; + _LIT(KErrMsg, "Removed landmark exists in database!"); + + for (TInt i = 0; i < KNrOfItemsToRemove; i++) + { + User::LeaveIfError( + iRemovedLandmarkIds.Append(iImportedLandmarkIds[indexToRemove[i]])); + iLandmarkNames->Delete(indexToRemove[i]); + iDatabase->RemoveLandmarkL(iImportedLandmarkIds[indexToRemove[i]]); + + // Verify landmark is removed + CPosLandmark* lm = NULL; + TRAPD(err, lm = iDatabase->ReadLandmarkLC(iImportedLandmarkIds[indexToRemove[i]])); + delete lm; + lm = NULL; + AssertTrueSecL(err == KErrNotFound, KErrMsg, KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp49::VerifyImportedLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::VerifyImportedLandmarksL(TInt aNrOfExpectedItems) + { + iLog->Put(_L("VerifyImportedLandmarksL")); + // Iterate through all imported landmarks + TInt i = 0; + TPosLmItemId id = iIterator->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = NULL; + if (iRemovedLandmarkIds.Find(id) == KErrNotFound) + { + // The landmark has not been removed from database. + // Try to read the imported landmark. + lm = iDatabase->ReadLandmarkLC(id); + + // Verify that the landmark name exists in the name array. + _LIT(KErrMsg, "Unexpected landmark name"); + _LIT(KErrMsg1, "GetLandmarkName returned KErrNotFound"); + TPtrC name; + TInt res = lm->GetLandmarkName(name); + if (res == KErrNotFound) + { + // No name found at all + LogErrorAndLeave(KErrMsg1, KErrGeneral); + } + else + { + TInt index; + iLog->Put(name); + res = iLandmarkNames->Find(name, index); + if (res != KErrNone) + { + // Found name does not match any name in the array. + LogErrorAndLeave(KErrMsg, KErrGeneral); + } + } + CleanupStack::PopAndDestroy(lm); + } + else + { + // The landmark has been removed from db. + // Verify that landmark does not exist in database. + _LIT(KErrMsg, "Removed landmark exists in database!"); + TRAPD(err, lm = iDatabase->ReadLandmarkLC(id)); + delete lm; + lm = NULL; + AssertTrueSecL(err == KErrNotFound, KErrMsg, KErrGeneral); + } + + i++; + id = iIterator->NextL(); + } + + // Verify that length of iterator is equal to the nr of imported landmarks. + _LIT(KErrMsg, "Nr of iterated landmarks did not match the nr of imported."); + AssertTrueSecL(i == aNrOfExpectedItems, KErrMsg, KErrGeneral); + } + +// --------------------------------------------------------- +// CPosTp49::SetupPreConditionsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::SetupPreConditionsL() + { + // Precondition: A non-empty database exists + CPosLandmarkDatabase* db = OpenDatabaseLC(); + CleanupStack::Pop(db); + iDatabase = db; + + ExecuteAndDeleteLD(iDatabase->CompactL()); + + // Add one item to make it non-empty + CPosLandmark* dummy = CPosLandmark::NewLC(); + iDatabase->AddLandmarkL(*dummy); + CleanupStack::PopAndDestroy(dummy); + } + +// --------------------------------------------------------- +// CPosTp49::ExecuteLmOpL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::ExecuteLmOpL(TInt aExpectedResult, TBool aObserveProgress) + { + CActiveLmOperation* operationWrapper = + new (ELeave) CActiveLmOperation(iLog); + CleanupStack::PushL(operationWrapper); + + if (aObserveProgress) + { + operationWrapper->Start(iOperation, this); + } + else + { + operationWrapper->Start(iOperation); + } + + CActiveScheduler::Start(); + if (aExpectedResult == KErrNone) + { + operationWrapper->CheckOperationL(); + } + else + { + if (aExpectedResult != operationWrapper->Status()) + { + _LIT(KErrMsg, "Expected result %d but got %d"); + TBuf<50> msg; + msg.Format(KErrMsg, aExpectedResult, operationWrapper->Status()); + LogErrorAndLeave(msg, KErrGeneral); + } + } + + CleanupStack::PopAndDestroy(operationWrapper); + } + +// --------------------------------------------------------- +// CPosTp49::FetchIteratorL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::FetchIteratorL() + { + delete iIterator; + iIterator = NULL; + iIterator = iDatabase->ImportedLandmarksIteratorL(iOperation); + TBuf<100> buf; + iImportedLandmarkIds.Close(); + TInt nrOfItems = (TInt) iIterator->NumOfItemsL(); + buf.Format(_L("Retreving %d nr of ids from iterator"), nrOfItems); + iLog->Put(buf); + if (nrOfItems > 0) + { + iIterator->GetItemIdsL(iImportedLandmarkIds, 0, nrOfItems); + } + buf.Zero(); + for (TInt i=0;i idde; + idde.Format(_L(" Id:%d "), iImportedLandmarkIds[i]); + buf.Append(idde); + } + iLog->Put(buf); + } + +// --------------------------------------------------------- +// CPosTp49::RecreateParserL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::RecreateParserL(const TDesC& aFileName) + { + delete iLandmarkParser; + iLandmarkParser = NULL; + iLandmarkParser = CPosLandmarkParser::NewL(KMimeType); + iLandmarkParser->SetInputFileL(aFileName); + } + +// --------------------------------------------------------- +// CPosTp49::StartImportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::StartImportLandmarksL() + { + delete iOperation; + iOperation = NULL; + iLog->Put(_L("Innan ImportLandmarksL")); + iOperation = iDatabase->ImportLandmarksL( + *iLandmarkParser, CPosLandmarkDatabase::EDefaultOptions); + iLog->Put(_L("EfterImportLandmarksL")); + } + +// --------------------------------------------------------- +// CPosTp49::CreateNameArrayL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp49::CreateNameArrayL(TInt aNrOfItems) + { + _LIT(KName0, "Landmark 0"); + _LIT(KName1, "Landmark 1"); + _LIT(KName2, "Landmark 2"); + _LIT(KName3, "Landmark 3"); + _LIT(KName4, "Landmark 4"); + _LIT(KName5, "Landmark 5"); + _LIT(KName6, "Landmark 6"); + + const TDesC* names[] = {&KName0, &KName1, &KName2, &KName3, &KName4, + &KName5, &KName6}; + + // Create array of landmark names. Names match those specified in the + // import file. + delete iLandmarkNames; + iLandmarkNames = new (ELeave) CDesCArrayFlat(8); + for (TInt i = 0; i < aNrOfItems; i++) + { + iLandmarkNames->AppendL(*names[i]); + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp5.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp5.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,614 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp5.h" +#include +#include +#include +#include +#include + + +#include "FT_LandmarkConstants.h" + +// CONSTANTS +// _LIT(KGetNameErr, "GetLandmarks name returns incorrect error code"); +_LIT(KNameErr, "Landmark name is incorrect"); +_LIT(KIdErr, "Landmark Id is incorrect"); +_LIT(KLongitudeErr, "Longitude is incorrect"); + +_LIT(KLatitudeErr, "Latitude is incorrect"); +_LIT(KHorizontalAccErr, "Horizontal accuracy is incorrect"); +_LIT(KVerticalAccErr, "Vertical accuracy is incorrect"); +_LIT(KAltitudeErr, "Altitude is incorrect"); +_LIT(KNumOfAvailablePositionFieldsErr, "NumOfAvailablePositionFields is incorrect"); +_LIT(KNumOfategoriesErr, "Number of categories is incorrect"); +_LIT(KCoverageRadiusErr, "CoverageRadius is incorrect"); +_LIT(KIconIndexErr, "Icon index is incorrect"); +_LIT(KIconMaskIndexErr, "Icon MaskIndex is incorrect"); +_LIT(KMbmFileNameErr, "MbmFileName is incorrect"); +_LIT(KDescriptionErr, "Description is incorrect"); +_LIT(KPositionFieldErr, "Error in positions fields"); + +_LIT(KNameTp5, "Lm-Tp5"); + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp5::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::StartL() + { + _LIT(KNameTp5, "Lm-Tp5"); + RemoveDefaultDbL(); + CPosLandmark* landmark = CreateLandmarkLC(KNameTp5); + + CheckGetMethodsL(landmark); + + CheckRemoveMethodsL(landmark); + + CheckFieldsMaxLengthL(); + + CleanupStack::PopAndDestroy(); // landmark + + CheckNaNErrorL(); + } + +// --------------------------------------------------------- +// CPosTp5::CheckGetMethods +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckGetMethodsL(CPosLandmark* aLandmark) + { + + TPtrC landmarkName; + aLandmark->GetLandmarkName(landmarkName); + AssertTrueSecL(landmarkName.Compare(KNameTp5) == KErrNone, KNameErr); + AssertTrueSecL(aLandmark->LandmarkId() == 0, KIdErr); + + CPosLandmarkDatabase* lmd = OpenDatabaseLC(); + TPosLmItemId id=lmd->AddLandmarkL(*aLandmark); + AssertTrueSecL(aLandmark->LandmarkId() == id, KIdErr); + + TLocality loc2; + aLandmark->GetPosition(loc2); + AssertTrueSecL(loc2.Longitude() == KLongitude, KLongitudeErr); + AssertTrueSecL(loc2.Latitude() == KLatitude, KLatitudeErr); + AssertTrueSecL(loc2.HorizontalAccuracy() == KHorizontalAcc, KHorizontalAccErr); + AssertTrueSecL(loc2.VerticalAccuracy() == KVerticalAcc, KVerticalAccErr); + AssertTrueSecL(loc2.Altitude() == KAltitude, KAltitudeErr); + + TReal32 r; + aLandmark->GetCoverageRadius(r); + AssertTrueSecL(r == KCoverageRadius, KCoverageRadiusErr); + + TPtrC mbmFileName; + TInt index; + TInt indexMask; + aLandmark->GetIcon(mbmFileName, index, indexMask); + AssertTrueSecL(mbmFileName.Compare(KMbmFileName) == KErrNone, KMbmFileNameErr); + AssertTrueSecL(index == KIconIndex, KIconIndexErr); + AssertTrueSecL(indexMask == KIconMaskIndex, KIconMaskIndexErr); + + TPtrC desc; + aLandmark->GetLandmarkDescription(desc); + AssertTrueSecL(desc.Compare(KDescription) == KErrNone, KDescriptionErr); + AssertTrueSecL(KNoPosFields == aLandmark->NumOfAvailablePositionFields(), KNumOfAvailablePositionFieldsErr); + + TPositionFieldId posFieldId = aLandmark->FirstPositionFieldId(); + for (TUint i=0; iNextPositionFieldId(posFieldId); + } + + RArray categories; + CleanupClosePushL(categories); + aLandmark->GetCategoriesL(categories); + AssertTrueSecL(categories.Count() == KNoCategories, KNumOfategoriesErr); + CleanupStack::PopAndDestroy(2,lmd); + + } + +// --------------------------------------------------------- +// CPosTp5::CheckRemoveMethodsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckRemoveMethodsL(CPosLandmark* aLandmark) + { + aLandmark->RemoveLandmarkAttributes(CPosLandmark::ENoAttribute); + aLandmark->RemoveLandmarkAttributes(CPosLandmark::EPosition); + aLandmark->RemoveLandmarkAttributes(CPosLandmark::ECoverageRadius); + aLandmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); + aLandmark->RemoveLandmarkAttributes(CPosLandmark::EIcon); + aLandmark->RemoveLandmarkAttributes(CPosLandmark::EDescription); + + CheckRemovedL(aLandmark); + _LIT(KLandmarkName, "Nisse"); + CPosLandmark* landmark = CreateLandmarkLC(KLandmarkName); + landmark->RemoveLandmarkAttributes(CPosLandmark::EAllAttributes); + CheckRemovedL(landmark); + + + TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; + landmark->RemovePositionField(EPositionFieldMediaLinksStart); + landmark->RemovePositionField(EPositionFieldCountry); + landmark->RemovePositionField(EPositionFieldHorizontalSpeed); + // FrBo Below has been removed + + landmark->RemovePositionField(EPositionFieldMediaLinks); + landmark->RemovePositionField(EPositionFieldMediaLinksStart); + landmark->RemovePositionField(++tmp); + landmark->RemovePositionField(++tmp); + landmark->RemovePositionField(EPositionFieldIdLast); + + TPtrC ptr; + AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinksStart, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(EPositionFieldCountry, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(EPositionFieldHorizontalSpeed, ptr) == KErrNotFound, KPositionFieldErr); + // FrBo Below has been removed + + AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinks, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinksStart, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(++tmp, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(++tmp, ptr) == KErrNotFound, KPositionFieldErr); + AssertTrueSecL(landmark->GetPositionField(EPositionFieldIdLast, ptr) == KErrNotFound, KPositionFieldErr); + + // Remove some non-existing fields, nothing should happen + landmark->RemovePositionField(6000); + AssertTrueSecL(landmark->GetPositionField(6000, ptr) == KErrNotFound, KPositionFieldErr); + landmark->RemovePositionField(6001); + AssertTrueSecL(landmark->GetPositionField(6001, ptr) == KErrNotFound, KPositionFieldErr); + + CleanupStack::PopAndDestroy(); // landmark + + } + +// --------------------------------------------------------- +// CPosTp5::CheckRemovedL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckRemovedL(CPosLandmark* aLandmark) + { + _LIT(KPositionRemovedErr, "GetPosition is not returning an error code when position is not set"); + TLocality loc; + AssertTrueSecL(aLandmark->GetPosition(loc) == KErrNotFound, KPositionRemovedErr); + + RArray categories; + CleanupClosePushL(categories); + aLandmark->GetCategoriesL(categories); + AssertTrueSecL(categories.Count() == 0, KNumOfategoriesErr); + CleanupStack::PopAndDestroy(&categories); + + TReal32 r; + AssertTrueSecL(aLandmark->GetCoverageRadius(r) == KErrNotFound, KCoverageRadiusErr); + + TPtrC mbmFileName; + TInt index; + TInt indexMask; + AssertTrueSecL(aLandmark->GetIcon(mbmFileName, index, indexMask) == KErrNotFound, KMbmFileNameErr); + + TPtrC desc; + AssertTrueSecL(aLandmark->GetLandmarkDescription(desc) == KErrNotFound, KDescriptionErr); + } + +//--------------------------------------------------------- +// CPosTp5::CheckPositionFieldIdL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckPositionFieldL(const CPosLandmark& aLandmark, const TUint16 aId) + { + + _LIT(KPositionFieldIdErr, "PositionFieldId is incorrect"); + _LIT(KComparePositionFieldValueErr, "PositionField value is different from set value"); + + TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; + TBuf<100> buf; + buf.Format(_L("Looking for id:%d "),aId); + iLog->Log(buf); + + TPtrC value; + if (aId == EPositionFieldCountry) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KCountry) == KErrNone, KComparePositionFieldValueErr); + } + else if (aId == EPositionFieldHorizontalSpeed) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KHorizontalSpeed) == KErrNone, KComparePositionFieldValueErr); + } + + else if (aId == EPositionFieldMediaLinks) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KMediaLinks) == KErrNone, KComparePositionFieldValueErr); + } + else if (aId == EPositionFieldMediaLinksStart) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KMediaLink1) == KErrNone, KComparePositionFieldValueErr); + iLog->Log(_L("EPositionFieldMediaLinksStart")); + } + else if (aId == EPositionFieldIdLast) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KLast) == KErrNone, KComparePositionFieldValueErr); + } + else if (aId == (tmp+1)) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KMediaLink2) == KErrNone, KComparePositionFieldValueErr); + } + else if(aId == (tmp+2)) + { + aLandmark.GetPositionField(aId, value); + AssertTrueSecL(value.Compare(KMediaLink3) == KErrNone, KComparePositionFieldValueErr); + } + else + { + buf.Format(_L("Looking for id: %d %d %d"), aId, (tmp+1), (tmp+2)); + iLog->Log(buf); + iLog->Log(KPositionFieldIdErr); + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp5::CheckFieldsMaxLength +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckFieldsMaxLengthL() + { + + _LIT(K255Error, "Text field is not limited to 255 characters"); + _LIT(K4095Error, "Description field is not limited to 4095 characters"); + _LIT(KIconError, "Icon File Name field is not limited to correct nr of characters"); + + HBufC* hbuf = HBufC::NewLC(4096); + while(hbuf->Des().Length() < 255) + { + hbuf->Des().Append(_L("X")); + } + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(*hbuf); + landmark->SetLandmarkDescriptionL(*hbuf); + landmark->SetPositionFieldL(EPositionFieldCountry, *hbuf); + hbuf->Des().Append(_L("X")); + + TRAPD(err, landmark->SetLandmarkNameL(*hbuf)); + AssertTrueSecL(err == KErrArgument, K255Error); + + landmark->SetLandmarkDescriptionL(*hbuf); + + TRAP(err, landmark->SetPositionFieldL(EPositionFieldCountry, *hbuf)); + AssertTrueSecL(err == KErrArgument, K255Error); + + while(hbuf->Des().Length() < 4095) + { + hbuf->Des().Append(_L("X")); + } + landmark->SetLandmarkDescriptionL(*hbuf); + hbuf->Des().Append(_L("X")); + TRAP(err, landmark->SetLandmarkDescriptionL(*hbuf)); + AssertTrueSecL(err == KErrArgument, K4095Error); + + CleanupStack::PopAndDestroy(2, hbuf); + + // Test setIconL + // KMaxFileName is defined in e32const.h + HBufC* icon = HBufC::NewLC(KMaxFileName+1); + while(icon->Des().Length() < KMaxFileName) + { + icon->Des().Append(_L("X")); + } + + landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(_L("SomeLandmarkName")); + landmark->SetLandmarkDescriptionL(_L("SomeLandmarkDescription")); + landmark->SetIconL(*icon, 1, KPosLmIconMaskNotUsed); + + icon->Des().Append(_L("X")); + + TRAP(err, landmark->SetIconL(*icon, 1, KPosLmIconMaskNotUsed)); + AssertTrueSecL(err == KErrArgument, KIconError); + CleanupStack::PopAndDestroy(landmark); + CleanupStack::PopAndDestroy(icon); + + + } + +// --------------------------------------------------------- +// CPosTp5::CheckNaNErrorL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp5::CheckNaNErrorL() + { + iLog->Log(_L("CheckErrorL")); + CPosLandmarkDatabase* lmdb = OpenDatabaseLC(); + CPosLandmark* landmark = CPosLandmark::NewLC(); + + ExecuteAndDeleteLD(lmdb->CompactL()); + TInt errorsFound = KErrNone; + TRealX NaN; + NaN.SetNaN(); + + // Used for testing SDK: + // This part should result in log: + // Not Equal1 + // Not Equal2 + TRealX pos1; + TRealX pos2; + + iLog->Log(_L("Testing with NaN and 45")); + pos1.SetNaN(); + pos2 = 45; + + if (pos2 == pos1) + iLog->Log(_L("Equal1")); + else + iLog->Log(_L("Not Equal1")); + + if (pos2 != pos1) + iLog->Log(_L("Not Equal2")); + else + iLog->Log(_L("Equal2")); + + + iLog->Log(_L("Testing with NaN and 0")); + pos1.SetNaN(); + pos2 = 0; + + if (pos2 == pos1) + iLog->Log(_L("Equal1")); + else + iLog->Log(_L("Not Equal1")); + + if (pos2 != pos1) + iLog->Log(_L("Not Equal2")); + else + iLog->Log(_L("Equal2")); + + iLog->Log(_L("Testing with NaN and NaN")); + pos1.SetNaN(); + pos2.SetNaN(); + + if (pos2 == pos1) + iLog->Log(_L("Equal1")); + else + iLog->Log(_L("Not Equal1")); + + if (pos2 != pos1) + iLog->Log(_L("Not Equal2")); + else + iLog->Log(_L("Equal2")); + + landmark->SetLandmarkNameL(_L("TestingLandmarkError")); + + // Only set position with Latitude and Longitude (thus Altitude and Accuracy is NaN) + TLocality loc; + loc.SetCoordinate(1,2); + landmark->SetPositionL(loc); + + TPosLmItemId myId = lmdb->AddLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test Altitude + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc); + + loc.SetCoordinate(1,2, 123); + landmark->SetPositionL(loc); + + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + TLocality loc3; + landmark->GetPosition(loc3); + + if (TRealX(loc3.Altitude()).IsNaN()) + { + iLog->Log(_L("Error: Altitude is Nan")); + errorsFound++; + } + else if (loc3.Altitude() != 123) + { + iLog->Log(_L("Error: Incorrect altitude returned")); + errorsFound++; + } + + // Reset landmark + loc.SetCoordinate(1,2, NaN); + landmark->SetPositionL(loc); + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test Horizontal accuracy + landmark = lmdb->ReadLandmarkLC(myId); + loc.SetCoordinate(1,2, NaN); + loc.SetHorizontalAccuracy(12); + landmark->SetPositionL(loc); + + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc3); + + if (TRealX(loc3.HorizontalAccuracy()).IsNaN()) + { + iLog->Log(_L("Error: Horizontal accuracy is Nan")); + errorsFound++; + } + else if (loc3.HorizontalAccuracy() != 12) + { + iLog->Log(_L("Error: Incorrect horizontal accuracy returned")); + errorsFound++; + } + + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test with NaN for hor acc + landmark = lmdb->ReadLandmarkLC(myId); + loc.SetCoordinate(1,2, NaN); + loc.SetHorizontalAccuracy(NaN); + landmark->SetPositionL(loc); + + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc3); + + if (TRealX(loc3.HorizontalAccuracy()).IsNaN()) + { + iLog->Log(_L("Horizontal accuracy is correctly set to Nan")); + } + else + { + iLog->Log(_L("Error: Incorrect horizontal accuracy returned")); + errorsFound++; + } + + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test Vertical accuracy + landmark = lmdb->ReadLandmarkLC(myId); + loc.SetCoordinate(1,2, NaN); + loc.SetVerticalAccuracy(21); + landmark->SetPositionL(loc); + + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc3); + + if (TRealX(loc3.VerticalAccuracy()).IsNaN()) + { + iLog->Log(_L("Error: Vertical accuracy is Nan")); + errorsFound++; + } + else if (loc3.VerticalAccuracy() != 21) + { + iLog->Log(_L("Error: Incorrect vertical accuracy returned")); + errorsFound++; + } + + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test landmark description + landmark = lmdb->ReadLandmarkLC(myId); + landmark->SetLandmarkDescriptionL(_L("TestingLandmarkErrorDescription")); + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + TPtrC des; + landmark->GetLandmarkDescription(des); + TInt res = des.CompareC(_L("TestingLandmarkErrorDescription")); + + if (res != KErrNone) + { + iLog->Log(_L("Error: Incorrect description returned")); + errorsFound++; + } + + CleanupStack::PopAndDestroy(landmark); + + ////////////////////////////////////// + // Test coverage radius + landmark = lmdb->ReadLandmarkLC(myId); + landmark->SetCoverageRadius(15); + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc3); + TReal32 radius; + landmark->GetCoverageRadius(radius); + if (TRealX(radius).IsNaN()) + { + iLog->Log(_L("Error: Radius is Nan")); + errorsFound++; + } + else if (radius != 15) + { + iLog->Log(_L("Error: Incorrect radius returned")); + errorsFound++; + } + ////////////////////////////////////// + CleanupStack::PopAndDestroy(landmark); + ////////////////////////////////////// + // Test coverage radius, part2 + // Set coverage radius to NaN + landmark = lmdb->ReadLandmarkLC(myId); + TRealX nan; + nan.SetNaN(); + landmark->SetCoverageRadius(nan); + lmdb->UpdateLandmarkL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + landmark = lmdb->ReadLandmarkLC(myId); + landmark->GetPosition(loc3); + + res = landmark->GetCoverageRadius(radius); + if (res != KErrNotFound) + { + iLog->Log(_L("Error: GetCoverageRadius should return KErrNotFound when set to NaN")); + errorsFound++; + } + ////////////////////////////////////// + CleanupStack::PopAndDestroy(landmark); + + CleanupStack::PopAndDestroy(lmdb); + + if (errorsFound != KErrNone) + { + + iLog->Log(_L("Errors found in part CheckNaNErrorL()")); + User::Leave(-1); + } + + } diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp50.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp50.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,449 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp50.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +const TInt KNoMultipleClients = 5; +_LIT(KExportFile, "c:\\TP50-ExportedFile.xml"); + +_LIT(KAllLandmarks, "c:\\TP50-AllLandmarks.xml"); + +_LIT(KAllLandmarksIndex, "c:\\TP50-AllLandmarks%d.xml"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp50::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::GetName(TDes& aName) const + { + _LIT(KTestName, "TP50 - Multiple import operations"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp50::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::CloseTest() + { + for (TInt i=0; iIsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + ExportLandmarksL(); + + delete iDatabase; + iDatabase=NULL; + + // We want an empty database + RemoveDefaultDbL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iUseLogFromThreadIsDisabled = ETrue; + + iLog->Put(_L("Imports landmarks syncronously simultaneously")); + iTestStep=0; + StartMultipleClientsL(KNoMultipleClients); + + iLog->Put(_L("Imports landmarks incrementally simultaneously")); + ++iTestStep; + StartMultipleClientsL(KNoMultipleClients); + + iLog->Put(_L("A search is started but no step is executed")); + ++iTestStep; + + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + textCriteria->SetTextL(_L("kalle")); + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(landmarkSearch); + + CPosLmOperation* op = landmarkSearch->StartLandmarkSearchL(*textCriteria); + CleanupStack::PushL(op); + + iLog->Put(_L("Imports landmarks syncronously simultaneously (all should fail)")); + StartMultipleClientsL(KNoMultipleClients); + + iLog->Put(_L("The search is cancelled")); + CleanupStack::PopAndDestroy(op); + + iLog->Put(_L("Imports landmarks syncronously simultaneously (at least one should succed)")); + ++iTestStep; + StartMultipleClientsL(KNoMultipleClients); + + CleanupStack::PopAndDestroy(2, textCriteria); + + TestESLI_64LLU3L(); + } + +// --------------------------------------------------------- +// CPosTp50::StartMultipleClientsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::StartMultipleClientsL(const TUint aNoClients) + { + _LIT(KMultipleErr, "Error %d from thread %d"); + _LIT(KPanicErr, "Thread %d has panicked or is alive"); + _LIT(KAllErr, "Wrong number of threads left with error"); + _LIT(KSuccess, "Threads %d is successful"); + _LIT(KAllNotFailedErr, "All imports haven't failed"); + + CreateThreadsL(aNoClients); + + RArray statuses; + CleanupClosePushL(statuses); + + for (TUint j=0; j info; + + if (exitReason != KErrNone) + { + errors++; + info.Format(KMultipleErr, exitReason, i+1); + } + else + { + info.Format(KSuccess, i+1); + } + iLog->Put(info); + + AssertTrueSecL(iThreads[i].ExitType() == EExitKill, KPanicErr, i+1); + AssertTrueSecL(exitReason == KErrNone || exitReason == KErrLocked, info); + } + + if (iTestStep != EReadLockTaken) + { + AssertTrueSecL(errors == KNoMultipleClients - 1, KAllErr); + } + else + { + // All imports should have failed since the started search should have taken a read lock + AssertTrueSecL(errors == KNoMultipleClients, KAllNotFailedErr); + } + + for (i=0; i(aData); + TInt index = ++self->iThreadIndex; + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(KMimeType); + CleanupStack::PushL(parser); + + + TBuf<100> fileName; + fileName.Format(KAllLandmarksIndex, index); + + parser->SetInputFileL(fileName); + + _LIT(KInfo, "Thread %d"); + TBuf<100> info; + info.Format(KInfo, index); + RDebug::Print(info); + + CPosLmOperation* op = lmd->ImportLandmarksL(*parser, CPosLandmarkDatabase::EDefaultOptions); + + _LIT(KInfo2, "Thread %d before execute"); + info.Format(KInfo2, index); + RDebug::Print(info); + + switch (self->iTestStep) + { + //case self->ESync: + case ESync: + //case self->EReadLockTaken: + case EReadLockTaken: + //case self->ESearchCancelled: + case ESearchCancelled: + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + break; + //case self->EInc: + case EInc: + self->RunAsyncOperationLD(op); + break; + } + + _LIT(KInfo3, "Thread %d after execute"); + info.Format(KInfo3, index); + RDebug::Print(info); + + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(lmd); + } + + +// --------------------------------------------------------- +// ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp50::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp50::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::CreateThreadsL(const TUint aNoThreads) + { + _LIT(KThreadName, "TP50 test thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TUint i=0; i name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + +// --------------------------------------------------------- +// CPosTp50::ExportAllLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::ExportLandmarksL() + { + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + fs.Delete(KAllLandmarks); + + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KMimeType); + CleanupStack::PushL(encoder); + + encoder->SetOutputFileL(KAllLandmarks); + + CPosLmOperation* op = iDatabase->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + CleanupStack::PushL(op); + op->ExecuteL(); + CleanupStack::PopAndDestroy(op); + + op = encoder->FinalizeEncodingL(); + CleanupStack::PushL(op); + op->ExecuteL(); + + // Create a file to be used from each thread + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + for (TInt i=0; i fileName; + fileName.Format(KAllLandmarksIndex, i+1); + fs.Delete(fileName); + + User::LeaveIfError(fileMan->Copy(KAllLandmarks, fileName, CFileMan::EOverWrite)); + } + + CleanupStack::PopAndDestroy(6, &fs); + } + +// --------------------------------------------------------- +// CPosTp50::TestESLI_64LLU3L +// ESLI-64LLU3 - read/write lock only affects the same database instance. +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp50::TestESLI_64LLU3L() + { + RFs fs; + User::LeaveIfError(fs.Connect()); + fs.Delete(KExportFile); + fs.Close(); + + // Create encoder that will take read lock + CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KMimeType); + CleanupStack::PushL(encoder); + encoder->SetOutputFileL(KExportFile); + + // Create another db handle + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + // Create array of ids to export + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + User::LeaveIfError(arrayOfIds.Append(1)); + User::LeaveIfError(arrayOfIds.Append(2)); + User::LeaveIfError(arrayOfIds.Append(3)); + + // Take read lock by starting exporting + CPosLmOperation* op = lmd->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions); + CleanupStack::PushL(op); + + // Verify take write lock fails on db instance 2 + TRAPD(err, lmd->RemoveLandmarkL(1)); + AssertTrueSecL(err == KErrLocked, _L("Didn't get KErrLocked but %d"), err); + + // Verify take write lock fails on db instance 1 + TRAP(err, iDatabase->RemoveLandmarkL(1)); + AssertTrueSecL(err == KErrLocked, _L("Didn't get KErrLocked but %d"), err); + + // Lock should prevent import threads to complete successfully + iTestStep = EReadLockTaken; + StartMultipleClientsL(KNoMultipleClients); + + // Release lock - import threads should complete successfully + CleanupStack::PopAndDestroy(op); + iTestStep = ESync; + StartMultipleClientsL(KNoMultipleClients); + + CleanupStack::PopAndDestroy(&arrayOfIds); + CleanupStack::PopAndDestroy(lmd); + CleanupStack::PopAndDestroy(encoder); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp51.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp51.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,654 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp51.h" +#include +#include +#include +#include +#include +//#include + +// CONSTANTS +_LIT8(KNonExistingMimeType1, "APPLICATION/VND.NOKIA.LANDMARKCOLLECTION+XML"); +_LIT8(KNonExistingMimeType2, "application/vnd.nokia.kokoibollen"); +//_LIT8(KNonExistingMimeType3, "application/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollen"); +_LIT8(KEmptyMimeType, ""); +_LIT(KPosLandmarksServerName, "*eposlmserver*"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp51::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp51::StartL() + { + iErrorsFound = 0; + MakeSurePanicDebugFileExistsL(); + + RemoveDefaultDbL(); + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + // <<<<<<<<<<<<<>>>>>>>>>>>>>>>>>> + iLog->Log(_L(">>>>>>>Start Panic test<<<<<<<<<")); + + // 1 The client asks the API to parse XML content both synchronously + // and incrementally without specifying the input method. + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 1")); + iTestCase = 1; + iExpectedErrorCode = EPosLmProtocolBreak; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 2")); + iTestCase = 2; + iExpectedErrorCode = EPosLmProtocolBreak; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Import landmarks with an invalid transfer option + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 3")); + iTestCase = 3; + iExpectedErrorCode = EPosLmInvalidArgument; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Import landmarks with an invalid transfer option + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 9")); + iTestCase = 9; + iExpectedErrorCode = EPosLmInvalidArgument; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Import landmarks with an invalid transfer option + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 10")); + iTestCase = 10; + iExpectedErrorCode = EPosLmInvalidArgument; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Create a parser with incorrect MIME type, should leave + iExpectedExitType = ExitLeave; + iLog->Log(_L("Leave test 4")); + iTestCase = 4; + iExpectedErrorCode = KErrNotSupported; + ResumeThreadAndVerifyExitL(); + + // Create a parser with incorrect MIME (correct MIME type but with capital letters) type, should leave + iExpectedExitType = ExitLeave; + iLog->Log(_L("Leave test 5")); + iTestCase = 5; + iExpectedErrorCode = KErrNotSupported; + ResumeThreadAndVerifyExitL(); + + // Create a parser with incorrect MIME type, should leave + iExpectedExitType = ExitLeave; + iLog->Log(_L("Leave test 18")); + iTestCase = 18; + iExpectedErrorCode = KErrNotSupported; + ResumeThreadAndVerifyExitL(); + +#if 0 + // Create a parser with incorrect MIME type, should leave + // TE: the REComSession::CreateImplementationL( leaves with KErrArgument which I think is acceptable + // Nokia: This is not part of API definition, case removed + iExpectedExitType = ExitLeave; + iLog->Log(_L("Leave test 19")); + iTestCase = 19; + iExpectedErrorCode = KErrArgument; + ResumeThreadAndVerifyExitL(); +#endif + + // Create a parser, parse inc. but change input method after one step + iExpectedExitType = ExitPanic; + iLog->Log(_L("Leave test 6")); + iTestCase = 6; + iExpectedErrorCode = EPosLmProtocolBreak; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + +#ifndef __WINS__ + // Fetch Import Iterator with NULL argument + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 7")); + iTestCase = 7; + iExpectedErrorCode = 3; // Kern-Exec 3 + ResumeThreadAndVerifyExitL(); + ListAllServers(); + if (!ServerAlive(KPosLandmarksServerName)) + { + iLog->Log(_L("Server not alive as expected(1)!")); + User::Leave(-1); + + } + + // Use a CPosLmOperation object from a compact operation as input to an + // ImportedLandmarksIteratorL function call + iExpectedExitType = ExitPanic; + iLog->Log(_L("Panic test 8")); + iTestCase = 8; + iExpectedErrorCode = 3; // Kern-Exec 3 + ResumeThreadAndVerifyExitL(); + ListAllServers(); + if (!ServerAlive(KPosLandmarksServerName)) + { + iLog->Log(_L("Server not alive as expected(2)!")); + User::Leave(-1); + + } +#endif + + // Import subset of landmarks with non existing ids + iLog->Log(_L("Panic test 11")); + iTestCase = 11; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosInvalidIndex; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Import subset of landmarks with empty subset of ids + // should leave with KErrArgument + iLog->Log(_L("Panic test 12")); + iTestCase = 12; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrArgument; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Try to receive parsed landmark with invalid index + iLog->Log(_L("Panic test 13")); + iTestCase = 13; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = EPosInvalidIndex; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Try to ParseContentL from empty buffer + iLog->Log(_L("Panic test 14")); + iTestCase = 14; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrPosLmUnknownFormat; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Try toParseContentL from NULL input buffer + iLog->Log(_L("Panic test 15")); + iTestCase = 15; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = 3; // Kern-Exec 3 + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Try to ImportLandmarks from empty buffer + iLog->Log(_L("Panic test 16")); + iTestCase = 16; + iExpectedExitType = ExitLeave; + iExpectedErrorCode = KErrPosLmUnknownFormat; + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + // Try to ImportLandmarks from NULL buffer + iLog->Log(_L("Panic test 17")); + iTestCase = 17; + iExpectedExitType = ExitPanic; + iExpectedErrorCode = 3; // Kern-Exec 3 + iMimeType.Set( KLmxMimeType ); + ResumeThreadAndVerifyExitL(); + iMimeType.Set( KGpxMimeType ); + ResumeThreadAndVerifyExitL(); + + iLog->Log(_L(">>>>>>>Panic test Done<<<<<<<<<")); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors found in TP51")); + User::Leave(-2); + } + } + +// --------------------------------------------------------- +// CPosTp51::ResumeThreadAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp51::ResumeThreadAndVerifyExitL() + { + iLog->Log(_L("ResumeThreadAndVerifyExitL")); + _LIT(KPanicErr, "ERROR: Method didn't panic, exit type %d"); + _LIT(KPanicCodeErr, "ERROR: Unexpected panic code, actual %d, expected %d"); + _LIT(KLeaveErr, "ERROR: Method didn't leave, exit type %d"); + _LIT(KLeaveCodeErr, "ERROR: Unexpected leave error, actual %d, expected %d"); + + CreateThreadL(); + TRequestStatus status; + iThread.Logon(status); + iThread.Resume(); + + User::WaitForRequest(status); + + if (iExpectedExitType == ExitPanic) + { + if (iThread.ExitType() != EExitPanic ) + { + iLog->Log( KPanicErr, iThread.ExitType() ); + iErrorsFound++; + } + if ( iThread.ExitReason() != iExpectedErrorCode ) + { + iLog->Log( KPanicCodeErr, iThread.ExitReason(), iExpectedErrorCode ); + iErrorsFound++; + } + } + else if (iExpectedExitType == ExitLeave) + { + if (iThread.ExitType() != EExitKill ) + { + iLog->Log( KLeaveErr, iThread.ExitType() ); + iErrorsFound++; + } + if ( iThread.ExitReason() != iExpectedErrorCode ) + { + iLog->Log( KLeaveCodeErr, iThread.ExitReason(), iExpectedErrorCode ); + iErrorsFound++; + } + } + iThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp51::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp51::CloseTest() + { + iLog->Log(_L("CloseTest")); + iThread.Close(); + + delete iDatabase; + iDatabase = NULL; + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp51::RunPanicTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +void CPosTp51::RunPanicTestL(TAny* aData) + { + CPosTp51* self = reinterpret_cast(aData); + + _LIT(KXML1, "c:\\system\\test\\TestData\\TP47_UTF-16-bigEndian.xml"); + _LIT(KXML2, "c:\\system\\test\\TestData\\TP47_UTF-16-littleEndian.xml"); + _LIT(KXML3, "c:\\system\\test\\TestData\\TP47_UTF-16-bigEndian.gpx"); + _LIT(KXML4, "c:\\system\\test\\TestData\\TP47_UTF-16-littleEndian.gpx"); + + if (self->iTestCase == 1) + { + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + + //Should Panic when no input is set, parse sync + ExecuteAndDeleteLD(landmarkParser->ParseContentL()); + } + else if (self->iTestCase == 2) + { + // Create parser, + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + // Parse content, should panic when no input set, parse incrementally + CPosLmOperation* operation = landmarkParser->ParseContentL(); + self->RunAsyncOperationLD(operation); + } + else if (self->iTestCase == 3) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + // Importlandmarks with invalid transfer option, should panic + ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, 666)); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 4) + { + // Create parser with incorrect MIME type, should leave with KErrNotSupported + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType2); + CleanupStack::PushL(landmarkParser); + CleanupStack::PopAndDestroy(landmarkParser); + } + else if (self->iTestCase == 5) + { + // Create parser with incorrect MIME (including capital letters) type, should leave with KErrNotSupported + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType1); + CleanupStack::PushL(landmarkParser); + CleanupStack::PopAndDestroy(landmarkParser); + } + else if (self->iTestCase == 18) + { + // Create parser with incorrect MIME type (long string), should leave with KErrNotSupported + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType2); + CleanupStack::PushL(landmarkParser); + CleanupStack::PopAndDestroy(landmarkParser); + } + else if (self->iTestCase == 19) + { + // Create parser with incorrect MIME (empty string) type, should leave with KErrNotSupported (or KErrArgument) + // however the REComSession::CreateImplementationL( leaves with KErrArgument which I think is acceptable + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KEmptyMimeType); + CleanupStack::PushL(landmarkParser); + CleanupStack::PopAndDestroy(landmarkParser); + } + else if (self->iTestCase == 6) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + landmarkParser->SetInputFileL(KXML1); + // Call ParseContentL + CPosLmOperation* operation = landmarkParser->ParseContentL(); + TRequestStatus status = KPosLmOperationNotComplete; + TReal32 progress; + + // Set new input method before first operation has completed + landmarkParser->SetInputFileL(KXML2); + + // Use first operation object->should panic + operation->NextStep(status, progress); + User::WaitForRequest(status); + + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 7) + { + // <<<<<<<<<<<<<< Fetch iterator with CPosLmOperation == NULL >>>>>>>>>>>>>>>>>>> + CPosLandmarkDatabase* databasen = self->OpenDatabaseLC(); + CPosLmItemIterator* iterator = databasen->ImportedLandmarksIteratorL(NULL); + delete iterator; + CleanupStack::PopAndDestroy(databasen); + } + else if (self->iTestCase == 8) + { + // <<<<<<<<<<<<<< Fetch iterator with CPosLmOperation != ImportLandmarksL() >>>>>>>>>>>>>>>>>>> + CPosLandmarkDatabase* databasen = self->OpenDatabaseLC(); + CPosLmOperation* operation = databasen->CompactL(); + CleanupStack::PushL(operation); + CPosLmItemIterator* iterator = databasen->ImportedLandmarksIteratorL(operation); + delete iterator; + CleanupStack::PopAndDestroy(2, databasen); + } + else if (self->iTestCase == 9) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + // Importlandmarks with invalid transfer option, should panic + ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, 0x17)); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 10) + { + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + RArray subset; + CleanupClosePushL(subset); + subset.Append(12);subset.Append(13); + // Importlandmarks with invalid transfer option, should panic + ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, 0x17)); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 11) + { + // Importlandmarks with non existing subset of ids, should panic + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + if ( self->iMimeType != KGpxMimeType ) + { + landmarkParser->SetInputFileL(KXML1); + } + else + { + landmarkParser->SetInputFileL(KXML3); + } + RArray subset; + CleanupClosePushL(subset); + subset.Append(1);subset.Append(2);subset.Append(1200);subset.Append(1300); + // Importlandmarks with non existing subset of ids, should panic + // Should it Panic with EPosInvalidIndex + ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, CPosLandmarkDatabase::EIncludeCategories)); + CleanupStack::PopAndDestroy(&subset); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 12) + { + // Importlandmarks with empty subset of id, leaves with KErrArgument + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + landmarkParser->SetInputFileL(KXML1); + RArray subset; + CleanupClosePushL(subset); + // Importlandmarks with empty subset of ids, should leave with KErrArgument + ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, CPosLandmarkDatabase::EIncludeCategories)); + CleanupStack::PopAndDestroy(&subset); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 13) + { + // Retreive parsed landmark with index outside interval of parsed landmarks + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + if ( self->iMimeType != KGpxMimeType ) + { + landmarkParser->SetInputFileL(KXML1); + } + else + { + landmarkParser->SetInputFileL(KXML3); + } + + ExecuteAndDeleteLD(landmarkParser->ParseContentL()); + + // Should panic with EPosInvalidIndex + landmarkParser->LandmarkLC(2000); + + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 14) + { + // ParseContentL from empty buffer + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + HBufC8* bufferContent = HBufC8::NewLC(0); + landmarkParser->SetInputBuffer(*bufferContent); + + CPosLmOperation* operation = landmarkParser->ParseContentL(); + ExecuteAndDeleteLD(operation); + + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 15) + { + // ParseContentL from NULL input buffer + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + HBufC8* bufferContent = NULL; + landmarkParser->SetInputBuffer(*bufferContent); + + ExecuteAndDeleteLD(landmarkParser->ParseContentL()); + + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 16) + { + // ImportLandmarks from empty buffer + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + HBufC8* bufferContent = HBufC8::NewLC(0); + landmarkParser->SetInputBuffer(*bufferContent); + + CPosLmOperation* operation = database->ImportLandmarksL(*landmarkParser, CPosLandmarkDatabase::EIncludeCategories); + ExecuteAndDeleteLD(operation); + + CleanupStack::PopAndDestroy(bufferContent); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + else if (self->iTestCase == 17) + { + // ImportLandmarks from NULL input buffer + CPosLandmarkDatabase* database = self->OpenDatabaseLC(); + // Create parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); + CleanupStack::PushL(landmarkParser); + HBufC8* bufferContent = NULL; + landmarkParser->SetInputBuffer(*bufferContent); + + CPosLmOperation* operation = database->ImportLandmarksL(*landmarkParser, CPosLandmarkDatabase::EIncludeCategories); + ExecuteAndDeleteLD(operation); + CleanupStack::PopAndDestroy(landmarkParser); + CleanupStack::PopAndDestroy(database); + } + } + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp51::RunPanicTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp51::ListAllServers +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp51::ListAllServers() + { + TFindServer find(_L("*")); + TFullName name; + + iLog->Log(_L("ListAllServers")); + + while (find.Next(name) == KErrNone) + { + iLog->Log(name); + + + } + iLog->Log(_L("--------------------")); + } + +// --------------------------------------------------------- +// CPosTp51::CreateThreadL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp51::CreateThreadL() + { + _LIT(KThreadName, "Tp51test%dthread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + TBuf<100> buf; + buf.Format(KThreadName, iTestCase, ++iThreadCounter); + + TInt err=0; + err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp52.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp52.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,451 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp52.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// CONSTANTS + +_LIT(KErronousXMLFile, "c:\\system\\test\\TestData\\Tp47ErrounousXMLData.xml"); +_LIT(KErronousXMLFileDataMissing1, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields1.xml"); +_LIT(KErronousXMLFileDataMissing2, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields2.xml"); +_LIT(KErronousXMLFileDataMissing3, "c:\\system\\test\\TestData\\Tp47ErrounousXMLDataMissingFields3.xml"); +_LIT(KUnknownTags, "c:\\system\\test\\TestData\\Tp47UnknownTags.xml"); +_LIT(KUnknownTrees, "c:\\system\\test\\TestData\\Tp47UnknownTrees.xml"); +_LIT(KNoEndTag1, "c:\\system\\test\\TestData\\Tp47ErrounousXMLNoEndTag1.xml"); +_LIT(KNoEndTag2, "c:\\system\\test\\TestData\\Tp47ErrounousXMLNoEndTag2.xml"); +_LIT(KXMLFileWithLongCategoryName, "c:\\system\\test\\TestData\\Tp47XMLWithLongCategoryName.xml"); +_LIT(KXMLFileWithLongLandmarkName, "c:\\system\\test\\TestData\\Tp47XMLWithLongName.xml"); +_LIT(KXMLFileWithLongLatitudeField, "c:\\system\\test\\TestData\\Tp47XMLWithLongLatitudeField.xml"); +_LIT(KXMLFileWithEmptyCollection, "c:\\system\\test\\TestData\\Tp47ErronousXMLFileEmptyCollection.xml"); +_LIT(KXMLFileWithXMLTagAsDataField1, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField1.xml"); +_LIT(KXMLFileWithXMLTagAsDataField2, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField2.xml"); +_LIT(KXMLFileWithXMLTagAsDataField3, "c:\\system\\test\\TestData\\Tp47UsingXMLTagAsDataField3.xml"); +_LIT(KXMLFileWithQuotedXMLTagAsDataField1, "c:\\system\\test\\TestData\\Tp52QuotedXMLTag1.xml"); + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CPosTp52::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::CloseTest() + { + iLog->Log(_L("CloseTest")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + + delete iLandmarkParser; + iLandmarkParser = NULL; + + + delete iDatabase; + iDatabase=NULL; + + + iLog->Log(_L("CloseTest Done")); + } + +// --------------------------------------------------------- +// CPosTp52::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::StartL() + { + iLog->Log(_L("1)) *********************")); + DoTestL(KErronousXMLFile, KLmxMimeType, KErrPosLmUnknownFormat); + DoTestL(KErronousXMLFile, KGpxMimeType, KErrPosLmUnknownFormat); + + iLog->Log(_L("2)) *********************")); + DoTestL(KUnknownTags, KLmxMimeType, KErrNone, 1); + DoTestL(KUnknownTags, KGpxMimeType, KErrNone, 1); + + DoTestL(KUnknownTrees, KLmxMimeType, KErrNone, 1); + DoTestL(KUnknownTrees, KGpxMimeType, KErrNone, 1); + + iLog->Log(_L("3)) *********************")); + DoTestL(KNoEndTag1, KLmxMimeType, EXmlTagMismatch, 0); + DoTestL(KNoEndTag1, KGpxMimeType, EXmlTagMismatch, 0); + + iLog->Log(_L("4)) *********************")); + DoTestL(KNoEndTag2, KLmxMimeType, KErrPosLmUnknownFormat, 0); + DoTestL(KNoEndTag2, KGpxMimeType, KErrPosLmUnknownFormat, 0); + + // Containing XML tags as data field + iLog->Log(_L("5)) *********************")); + DoTestL(KXMLFileWithXMLTagAsDataField1, KLmxMimeType, EXmlTagMismatch, 0); + DoTestL(KXMLFileWithXMLTagAsDataField1, KGpxMimeType, EXmlTagMismatch, 0); + + // Containing XML tags as data field + iLog->Log(_L("6)) *********************")); + DoTestL(KXMLFileWithXMLTagAsDataField2, KLmxMimeType, EXmlTagMismatch, 0); + DoTestL(KXMLFileWithXMLTagAsDataField2, KGpxMimeType, EXmlTagMismatch, 0); + + // Containing XML tags as data field + iLog->Log(_L("7)) *********************")); + DoTestL(KXMLFileWithXMLTagAsDataField3, KLmxMimeType, EXmlTagMismatch, 0); + DoTestL(KXMLFileWithXMLTagAsDataField3, KGpxMimeType, EXmlTagMismatch, 0); + + iLog->Log(_L("8)) *********************")); + DoTestL(KXMLFileWithEmptyCollection, KLmxMimeType, KErrPosLmUnknownFormat, 0); + // N/A for GPX + + iLog->Log(_L("9)) *********************")); + DoTestL(KXMLFileWithLongCategoryName, KLmxMimeType, KErrNone, 1); + CheckLongCategoryNameL(4); + DoTestL(KXMLFileWithLongCategoryName, KGpxMimeType, KErrNone, 1); + CheckLongCategoryNameL(1); + + iLog->Log(_L("10)) *********************")); + DoTestL(KXMLFileWithLongLandmarkName, KLmxMimeType, KErrNone, 1); + CheckLongLandmarkNameL(); + DoTestL(KXMLFileWithLongLandmarkName, KGpxMimeType, KErrNone, 1); + CheckLongLandmarkNameL(); + + iLog->Log(_L("11)) *********************")); + DoTestL(KXMLFileWithLongLatitudeField, KLmxMimeType, KErrNone, 1); + DoTestL(KXMLFileWithLongLatitudeField, KGpxMimeType, KErrNone, 1); + + iLog->Log(_L("12)) *********************")); + DoTestL(KErronousXMLFileDataMissing1, KLmxMimeType, KErrPosLmUnknownFormat, 0); + DoTestL(KErronousXMLFileDataMissing1, KGpxMimeType, KErrPosLmUnknownFormat, 0); + + iLog->Log(_L("13)) *********************")); + DoTestL(KErronousXMLFileDataMissing2, KLmxMimeType, KErrNone, 1); + DoTestL(KErronousXMLFileDataMissing2, KGpxMimeType, KErrNone, 1); + + iLog->Log(_L("14)) *********************")); + DoTestL(KErronousXMLFileDataMissing3, KLmxMimeType, KErrNone, 1); + DoTestL(KErronousXMLFileDataMissing3, KGpxMimeType, KErrNone, 1); + + iLog->Log(_L("15)) *********************")); + DoTestL(KXMLFileWithQuotedXMLTagAsDataField1, KLmxMimeType, KErrNone, 2); + DoTestL(KXMLFileWithQuotedXMLTagAsDataField1, KGpxMimeType, KErrNone, 2); + + if (iErrorsFound != KErrNone) + { + iLog->Log(_L("Errors were found in Tp52")); + User::Leave(-1); + } + } + +// --------------------------------------------------------- +// CPosTp52::DoTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::DoTestL( + const TDesC& aTestFile, + const TDesC8& aMimeType, + TInt aExpectedErrorCode, + TInt aExpNrImportedLandmarks ) + { + TBuf<150> buf; + TInt nr=0; + ResetLandmarksDbL(); + + TFileName file( aTestFile ); + if ( aMimeType == KGpxMimeType ) + { + TInt pos = file.Find( KXmlFileExt ); + file.Replace( pos, KXmlFileExt().Length(), KGpxFileExt ); + } + + iLog->Log(_L("FILE (%S)"), &file ); + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + iLandmarkParser->SetInputFileL(file); + + TInt errorCode = 0; + // Test sync + errorCode = ImportLandmarksL(ETrue, CPosLandmarkDatabase::EIncludeCategories); + + if (errorCode != aExpectedErrorCode) + { + buf.Format(_L("ERROR: Errorcode %d , should be %d when importing from "), errorCode, aExpectedErrorCode); + buf.Append(file); + iLog->Log(buf); + iErrorsFound++; + } + else + { + buf.Format(_L("Correct errorcode %d returned when from "), errorCode); + buf.Append(file); + iLog->Log(buf); + } + + delete iLandmarkParser; + iLandmarkParser = NULL; + + nr = GetNrOfLandmarksL(); + if (nr != aExpNrImportedLandmarks) + { + buf.Format(_L("ERROR: Found %d landmarks should found %d"), nr, aExpNrImportedLandmarks); + iLog->Log(buf); + iErrorsFound++; + } + + ResetLandmarksDbL(); + + iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); + iLandmarkParser->SetInputFileL(file); + + // Test async + errorCode = ImportLandmarksL(ETrue, CPosLandmarkDatabase::EIncludeCategories); + + if (errorCode != aExpectedErrorCode) + { + buf.Format(_L("ERROR: Errorcode %d , should be %d when importing from "), errorCode, aExpectedErrorCode); + buf.Append(file); + iLog->Log(buf); + iErrorsFound++; + } + else + { + buf.Format(_L("Correct errorcode %d returned when importing landmarks from file "), errorCode); + buf.Append(file); + iLog->Log(buf); + } + + delete iLandmarkParser; + iLandmarkParser = NULL; + + nr = GetNrOfLandmarksL(); + if (nr != aExpNrImportedLandmarks) + { + buf.Format(_L("ERROR: Found %d landmarks should found %d"), nr, aExpNrImportedLandmarks); + iLog->Log(buf); + iErrorsFound++; + } + } + +// --------------------------------------------------------- +// CPosTp52::ImportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp52::ImportLandmarksL(TBool aSync, TUint aTransferOption) + { + iLog->Log(_L("ImportLandmarksL")); + + //TRequestStatus status = KPosLmOperationNotComplete; + //TReal32 progress = 0; + TInt err = KErrNone; + + CPosLmOperation* op; + op = iDatabase->ImportLandmarksL(*iLandmarkParser, aTransferOption); + + CleanupStack::PushL(op); + // Import only a subset of the landmarks in parser + // iOperation = iDatabase->ImportLandmarksL(*iLandmarkParser, aLandmarkSubSet, aTransferOption); + if (aSync) + { + // Synchronous + TRAP(err, op->ExecuteL()); + iOperation = NULL; + } + else + { + // Asynchronous + // Progress us checked in test procedure base + RunAsyncOperationLD(iDatabase->ImportLandmarksL(*iLandmarkParser, aTransferOption)); + iOperation = NULL; + } + CleanupStack::PopAndDestroy(op); + return err; + } + +// --------------------------------------------------------- +// CPosTp52::ResetLandmarksDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::ResetLandmarksDbL() + { + iLog->Log(_L("ResetLandmarksDbL()")); + + delete iLandmarkSearch; + iLandmarkSearch = NULL; + + delete iLandmarkParser; + iLandmarkParser = NULL; + + delete iDatabase; + iDatabase=NULL; + + + // Use an empty landmarks db in this test + RemoveDefaultDbL(); + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + delete iDatabase; + iDatabase = NULL; + iDatabase = CPosLandmarkDatabase::OpenL(); + // Do reset so that global categories are included + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); + CleanupStack::PopAndDestroy(categoryManager); + } + +// --------------------------------------------------------- +// CPosTp52::CheckLongLandmarkNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::CheckLongLandmarkNameL() + { + iLog->Log(_L("CheckLandmarkL")); + // Should only exist one landmark in db + CPosLandmark* lm = iDatabase->ReadLandmarkLC(1); + + TPtrC lmname; + TInt res = lm->GetLandmarkName(lmname); + + if (res != KErrNone) //LogErrorAndLeave(_L("Problem getting Landmark")); + { + iLog->Log(_L("Problem getting Landmark")); + User::Leave(-1); + + } + + _LIT(KLONGNAME, "Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landmark10Landm"); + if (lmname.Compare(KLONGNAME) != 0) + { + iLog->Log(_L("Long landmark name does not match")); + iErrorsFound++; + } + + CleanupStack::PopAndDestroy(lm); + } + +// --------------------------------------------------------- +// CPosTp52::CheckLongCategoryNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp52::CheckLongCategoryNameL(TInt aNumExpectedCategories ) + { + iLog->Log(_L("CheckLongCategoryNameL")); + // Should only exist one landmark in db + CPosLandmark* lm = iDatabase->ReadLandmarkLC(1); + + RArray array; + CleanupClosePushL(array); + lm->GetCategoriesL(array); + TInt nr = array.Count(); + TPtrC name; + + _LIT(KLONGNAME1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234"); + _LIT(KLONGNAME2, "Pizzeria10Pizzeria20Pizzeria30Pizzeria40Pizzeria50Pizzeria60Pizzeria70Pizzeria80Pizzeria90Pizzeria10Pizzeria10Pizzeria20Pizz"); + _LIT(KLONGNAME3, "Gizzeria10Gizzeria20Gizzeria30Gizzeria40Gizzeria50Gizzeria60Gizzeria70Gizzeria80Gizzeria90Gizzeria10Gizzeria10Gizzeria20_ABC"); + _LIT(KLONGNAME4, "Dizzeria10Dizzeria20Dizzeria30Dizzeria40Dizzeria50Dizzeria60Dizzeria70Dizzeria80Dizzeria90Dizzeria10Dizzeria10Dizzeria20_ABC"); + + const TInt numNames = 4; + const TPtrC names[] = { KLONGNAME1(), KLONGNAME2(), KLONGNAME3(), KLONGNAME4() }; + + if (nr != aNumExpectedCategories) //LogErrorAndLeave(_L("Wrong number of categories for landmark")); + { + iLog->Log(_L("Wrong number of categories for landmark")); + User::Leave(-1); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + + for ( TInt i = 0; i < aNumExpectedCategories; i++ ) + { + CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(array[i]); + + cat->GetCategoryName(name); + // Maximum size for category name is 124 characters + if (name.Length() != 124) + { + iLog->Log(_L("Category name has wrong size, should be 124")); + User::Leave(-1); + + } + if (name.Compare(names[i]) != 0) + { + iLog->Log(_L("Long category name does not match")); + iErrorsFound++; + } + CleanupStack::PopAndDestroy(cat); + } + + CleanupStack::PopAndDestroy(categoryManager); + + CleanupStack::PopAndDestroy(&array); + CleanupStack::PopAndDestroy(lm); + } + +// --------------------------------------------------------- +// CPosTp52::GetNrOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosTp52::GetNrOfLandmarksL() + { + TInt nrOfLandmarks = 0; + CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); + // Search pattern "*" should match all existing landmarks + textCriteria->SetTextL(_L("*")); + + CPosLandmarkSearch* landmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); + CleanupStack::PushL(landmarkSearch); + + TPosLmSortPref sortAsc(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + ExecuteAndDeleteLD(landmarkSearch->StartLandmarkSearchL( + *textCriteria, + sortAsc, + EFalse)); + + CPosLmItemIterator* iter = landmarkSearch->MatchIteratorL(); + CleanupStack::PushL(iter); + + nrOfLandmarks = iter->NumOfItemsL(); + CleanupStack::PopAndDestroy(iter); + CleanupStack::PopAndDestroy(landmarkSearch); + CleanupStack::PopAndDestroy(textCriteria); + return nrOfLandmarks; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp53.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp53.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,452 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp53.h" + +#include + +// CONSTANTS +// const TInt KMaxQueueSize = 5; +const TReal32 KCompactDbLevel = 0.75; // From ...landmarks\inernalServeices\resources\eposlmcompactdblevel.rss + +#ifdef __WINS__ + _LIT(KImportFile, "z:\\system\\test\\testdata\\TP53-CategoriesNotInDb.xml"); + _LIT(KImportFile2, "z:\\system\\test\\testdata\\TP53-OneLandmark.xml"); + _LIT(KImportFile3, "z:\\system\\test\\testdata\\TP53-Categories.xml"); + _LIT(KImportFile4, "z:\\system\\test\\testdata\\TP53-Category.xml"); + _LIT(KImportFile5, "z:\\system\\test\\testdata\\TP53-GlobalCategory.xml"); + _LIT(KImportFile6, "z:\\system\\test\\testdata\\TP53-LandmarksOneCategory.xml"); + _LIT(KImportFile7, "z:\\system\\test\\testdata\\TP53-LandmarkCategories.xml"); + _LIT(KImportFile8, "z:\\system\\test\\testdata\\TP53-LandmarksCategories.xml"); + + _LIT(KCompactImportFile, "z:\\system\\test\\testdata\\TP53-Compact.xml"); +#else + _LIT(KImportFile, "c:\\system\\test\\testdata\\TP53-CategoriesNotInDb.xml"); + _LIT(KImportFile2, "c:\\system\\test\\testdata\\TP53-OneLandmark.xml"); + _LIT(KImportFile3, "c:\\system\\test\\testdata\\TP53-Categories.xml"); + _LIT(KImportFile4, "c:\\system\\test\\testdata\\TP53-Category.xml"); + _LIT(KImportFile5, "c:\\system\\test\\testdata\\TP53-GlobalCategory.xml"); + _LIT(KImportFile6, "c:\\system\\test\\testdata\\TP53-LandmarksOneCategory.xml"); + _LIT(KImportFile7, "c:\\system\\test\\testdata\\TP53-LandmarkCategories.xml"); + _LIT(KImportFile8, "c:\\system\\test\\testdata\\TP53-LandmarksCategories.xml"); + + _LIT(KCompactImportFile, "c:\\system\\test\\testdata\\TP53-Compact.xml"); +#endif + +_LIT(KCategoryName, "TP53Category1"); +_LIT(KCategoryName2, "TP53Category2"); +_LIT(KCategoryName3, "TP53Category3"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp53::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp53 - Events and compact during import"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp53::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::CloseTest() + { + delete iDatabase; + iDatabase = NULL; + + delete iActiveLmEvent; + iActiveLmEvent = NULL; + + delete iParser; + iParser = NULL; + + RemoveGlobalCategoriesL(); + } + +// --------------------------------------------------------- +// CPosTp53::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::StartL() + { + RemoveDefaultDbL(); + RemoveGlobalCategoriesL(); + + iDatabase = UseGlobalCategoriesL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + ExecuteAndDeleteLD(iDatabase->CompactL()); + + AddCategoriesL(); + + iActiveLmEvent = CActiveLmImportEvent::NewL(iLog); + + iLog->Put(_L("Test events during import")); + ExecuteAndDeleteLD(iDatabase->CompactL()); + LandmarkImportEventTestL(); + + iLog->Put(_L("Test compact during import")); + ExecuteAndDeleteLD(iDatabase->CompactL()); + LandmarkImportCompactTestL(); + } + +// --------------------------------------------------------- +// CPosTp53::LandmarkImportEventTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::LandmarkImportEventTestL() + { + iActiveLmEvent->Start(); + + iParser = CPosLandmarkParser::NewL(KMimeType); + + ///////////////////////////////////////////// + // Landmark created event #1 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile, CPosLandmarkDatabase::EDefaultOptions); + + ///////////////////////////////////////////// + // Landmark created event #2 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile2, CPosLandmarkDatabase::EIncludeCategories); + + ///////////////////////////////////////////// + // Landmark created event #3 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile3, CPosLandmarkDatabase::EIncludeCategories); + + ///////////////////////////////////////////// + // Landmark created event #4 and category created event #5 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile4, CPosLandmarkDatabase::EIncludeCategories); + + ///////////////////////////////////////////// + // Landmark created event #6 and category updated event #7 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile5, CPosLandmarkDatabase::EIncludeCategories | CPosLandmarkDatabase::EIncludeGlobalCategoryNames); + + ///////////////////////////////////////////// + // Unknown landmark changes event #8 and category created event #9 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile6, CPosLandmarkDatabase::EIncludeCategories); + + ///////////////////////////////////////////// + // Landmark created event #10 and Unknown category changes event #11 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile7, CPosLandmarkDatabase::EIncludeCategories); + + ///////////////////////////////////////////// + // Unknown changes event #12 + ///////////////////////////////////////////// + ImportLandmarksL(KImportFile8, CPosLandmarkDatabase::EIncludeCategories); + + + if (iActiveLmEvent->iGlobalErr != 0) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp53::ImportLandmarksL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::ImportLandmarksL(const TDesC& aFileName, CPosLandmarkDatabase::TTransferOptions aTransferOptions) + { + iParser->SetInputFileL(aFileName); + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*iParser, aTransferOptions)); + CActiveScheduler::Start(); + } + +// --------------------------------------------------------- +// CPosTp53::AddCategoriesL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::AddCategoriesL() + { + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(cm); + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(KCategoryName); + + CPosLandmarkCategory* category2 = CPosLandmarkCategory::NewLC(); + category2->SetCategoryNameL(KCategoryName2); + + CPosLandmarkCategory* category3 = CPosLandmarkCategory::NewLC(); + category3->SetCategoryNameL(KCategoryName3); + + cm->AddCategoryL(*category); + cm->AddCategoryL(*category2); + cm->AddCategoryL(*category3); + + CleanupStack::PopAndDestroy(4, cm); + } + +// --------------------------------------------------------- +// CPosTp53::LandmarkImportCompactTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp53::LandmarkImportCompactTestL() + { + CPosLandmarkParser* parser = CPosLandmarkParser::NewL(KMimeType); + CleanupStack::PushL(parser); + + User::After(200000); + TReal32 usage = iDatabase->SizeL().iUsage; + TInt count=0; + + while (usage > KCompactDbLevel) + { + TBuf<100> name; + name.Format(_L("LMTP53%d"), ++count); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(name); + iDatabase->AddLandmarkL(*landmark); + User::After(200000); + + CleanupStack::PopAndDestroy(landmark); + + usage = iDatabase->SizeL().iUsage; + } + + parser->SetInputFileL(KCompactImportFile); + + iLog->Put(_L("importing...")); + ExecuteAndDeleteLD(iDatabase->ImportLandmarksL(*parser, CPosLandmarkDatabase::EDefaultOptions)); + iLog->Put(_L("importing...Done")); + User::After(200000); + + usage = iDatabase->SizeL().iUsage; + + AssertTrueSecL(usage >= KCompactDbLevel, _L("Import operation haven't done compact on the database")); + + CleanupStack::PopAndDestroy(parser); + } + +// ----------------------------------------------------------------------------- +// CActiveLmImportEvent::NewL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CActiveLmImportEvent* CActiveLmImportEvent::NewL(MUtfwLog* aLog) + { + CActiveLmImportEvent* self = new(ELeave) CActiveLmImportEvent(aLog); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CActiveLmImportEvent::ConstructL +// +//(other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CActiveLmImportEvent::ConstructL() + { + iDatabase = CPosLandmarkDatabase::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CActiveLmImportEvent::CActiveLmImportEvent +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// + +CActiveLmImportEvent::CActiveLmImportEvent(MUtfwLog* aLog) : + CActive(EPriorityNormal), + iLog(aLog) + { + CActiveScheduler::Add(this); + } + +// Destructor +CActiveLmImportEvent::~CActiveLmImportEvent() + { + Cancel(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CActiveLmImportEvent::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmImportEvent::Start() + { + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + + SetActive(); + } + +// --------------------------------------------------------- +// CActiveLmImportEvent::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmImportEvent::RunL() + { + VerifyEvent(); + + iDatabase->NotifyDatabaseEvent(iEvent, iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CActiveLmOperation::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmImportEvent::DoCancel() + { + iDatabase->CancelNotifyDatabaseEvent(); + } + +// --------------------------------------------------------- +// CActiveLmImportEvent::VerifyEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmImportEvent::VerifyEvent() + { + iEventNumber++; + switch (iEventNumber) + { + case 1: + case 2: + case 3: + AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iEventNumber, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + case 4: + AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iEventNumber, iEvent.iLandmarkItemId); + break; + case 5: + AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, 14, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + case 6: + AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, 5, iEvent.iLandmarkItemId); + break; + case 7: + AssertCorrectEvent(EPosLmEventCategoryUpdated, iEvent.iEventType, 2, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + case 8: + AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, 15, iEvent.iLandmarkItemId); + break; + case 9: + // Two landmarks added + AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + case 10: + AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, 8, iEvent.iLandmarkItemId); + break; + case 11: + AssertCorrectEvent(EPosLmEventCategoryUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + case 12: + AssertCorrectEvent(EPosLmEventUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); + CActiveScheduler::Stop(); + break; + default: + iLog->Put(_L("Unexpected event received")); + ++iGlobalErr; + CActiveScheduler::Stop(); + break; + } + } +// --------------------------------------------------------- +// CActiveLmImportEvent::AssertCorrectEvent +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CActiveLmImportEvent::AssertCorrectEvent( + TPosLmEventType aExpectedEventType, + TPosLmEventType aEventType, + TPosLmItemId aExpectedLandMarkItemId, + TPosLmItemId aLandMarkItemId) + { + if (aExpectedEventType != aEventType) + { + _LIT(KError,"Unexpected eventtype. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aExpectedEventType, aEventType); + iLog->Put(error); + iGlobalErr++; + } + else + { + TBuf<50> debug; + debug.Format(_L("Received event %d"), aEventType); + iLog->Put(debug); + } + + if (aExpectedLandMarkItemId != aLandMarkItemId) + { + _LIT(KError,"Unexpected item id. Excpected %d got %d\r\n"); + TBuf<200> error; + error.Format(KError, aExpectedLandMarkItemId, aLandMarkItemId); + iLog->Put(error); + iGlobalErr++; + } + else + { + TBuf<50> debug; + debug.Format(_L("Received item id %d"), aLandMarkItemId); + iLog->Put(debug); + } + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp56.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp56.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,373 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp56.h" +#include +#include + +// CONSTANTS + +_LIT(KDbUri1, "file://c:eposlm.ldb"); +_LIT(KDbUri2, "c:eposlm.ldb"); +_LIT(KDbUri3, "eposlm.ldb"); +_LIT(KDbUri4, "file://eposlm.ldb"); +_LIT(KDbUri5, "testlm.ldb"); + +// Will need to be changed to the secure dbms path when security is implemented +_LIT(KDbUri6, "c:\\system\\data\\eposlm.ldb"); +// Will need to be changed to the secure dbms path when security is implemented +_LIT(KDbUri7, "file://c:\\system\\data\\eposlm.ldb"); + +_LIT(KDbUri8, "eposlm"); +_LIT(KDbUri9, "c:eposlm"); +_LIT(KDbUri10, "file://c:eposlm"); + +_LIT(KDbUri11, "file://c:XXXX.ldb"); +_LIT(KDbUri12, "http://c:eposlm.ldb"); +_LIT(KDbUri13, ""); + +_LIT(KDbUri14, "file://\\eposlm.ldb"); // UNC +_LIT(KDbUri15, "\\eposlm.ldb"); + + +#ifdef __WINS__ + _LIT(KTestDb, "z:\\system\\test\\TestData\\testlm.ldb"); +#else + _LIT(KTestDb, "c:\\system\\test\\TestData\\testlm.ldb"); +#endif + + // Will need to be changed to the secure dbms path when security is implemented + _LIT(KLocalDbLocation, "c:\\system\\data\\"); + +_LIT(KExportFileFullPath, "c:\\TP56-LandmarksFromThreeDatabases.xml"); +_LIT(KExportFile, "TP56-LandmarksFromThreeDatabases.xml"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp56::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::GetName(TDes& aName) const + { + _LIT(KTestName, "TP56 - Open specific db and multiple db export"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp56::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::StartL() + { + RemoveDefaultDbL(); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + delete lmd; + + TestOpenSpecificDbL(); + + TestMultipleExportL(); + + TestLockedDatabaseL(); + } + +// --------------------------------------------------------- +// CPosTp56::TestMultipleExportL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::TestMultipleExportL() + { + _LIT(KDb1, "eposlm1.ldb"); + _LIT(KDb2, "eposlm2.ldb"); + _LIT(KDb3, "eposlm3.ldb"); + + CreateDatabasesL(); + + CPosLandmarkDatabase* lmd1 = CPosLandmarkDatabase::OpenL(KDb1); + CleanupStack::PushL(lmd1); + + CPosLandmarkDatabase* lmd2 = CPosLandmarkDatabase::OpenL(KDb2); + CleanupStack::PushL(lmd2); + + CPosLandmarkDatabase* lmd3 = CPosLandmarkDatabase::OpenL(KDb3); + CleanupStack::PushL(lmd3); + + CPosLandmark* lm = CreateXMLLandmarkLC(_L("TP56 - LM with all fields set")); + AddAllXMLFieldsL(lm); + + lmd1->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(lm); + + CPosLandmark* lm2 = CreateXMLLandmarkLC(_L("TP56 - LM2")); + lmd2->AddLandmarkL(*lm2); + CleanupStack::PopAndDestroy(lm2); + + + CPosLandmark* lm3 = CreateXMLLandmarkLC(_L("TP56 - LM3")); + + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd3); + CleanupStack::PushL(cm); + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(_L("category")); + TPosLmItemId id = cm->AddCategoryL(*category); + CleanupStack::PopAndDestroy(2, cm); + + lm3->AddCategoryL(id); + lmd3->AddLandmarkL(*lm3); + CleanupStack::PopAndDestroy(lm3); + + CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KMimeType); + CleanupStack::PushL(encoder); + + encoder->SetOutputFileL(KExportFileFullPath); + + CPosLmItemIterator* iter = lmd1->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + RArray arrayOfIds; + CleanupClosePushL(arrayOfIds); + + TInt numberOfElements = iter->NumOfItemsL(); + iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements)); + + ExecuteAndDeleteLD(lmd1->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions)); + + RunAsyncOperationLD(lmd2->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EDefaultOptions)); + + ExecuteAndDeleteLD(lmd3->ExportLandmarksL(*encoder, arrayOfIds, CPosLandmarkDatabase::EIncludeCategories)); + + ExecuteAndDeleteLD(encoder->FinalizeEncodingL()); + + CleanupStack::PopAndDestroy(6, lmd1); + + TInt err = CompareL(KExportFile); + AssertTrueSecL(err == KErrNone, _L("The exported file is not equal to file exported prevoius release")); + } + +// --------------------------------------------------------- +// CPosTp56::CreateDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::CreateDatabasesL() + { + // Paths will need to be changed to the secure dbms path when security is implemented + + _LIT(KDefaultDbPath, "c:\\system\\data\\eposlm.ldb"); + + _LIT(KDb1Path, "c:\\system\\data\\eposlm1.ldb"); + _LIT(KDb2Path, "c:\\system\\data\\eposlm2.ldb"); + _LIT(KDb3Path, "c:\\system\\data\\eposlm3.ldb"); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CleanupStack::PopAndDestroy(lmd); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + fs.Delete(KExportFile); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb1Path, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb2Path, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb3Path, CFileMan::EOverWrite)); + + + CleanupStack::PopAndDestroy(2, &fs); + } + +// --------------------------------------------------------- +// CPosTp56::TestOpenSpecificDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::TestOpenSpecificDbL() + { + _LIT(KHttpErr, "http is not a supported protocol"); + _LIT(KURIErr, "Not a valid URI"); + _LIT(KArgumentErr, "An empty descr is not a valid URI"); + + TestOpenDbL(KDbUri1); + TestOpenDbL(KDbUri2); + TestOpenDbL(KDbUri3); + TestOpenDbL(KDbUri4); + + CopyTestDbL(); + TestOpenDbL(KDbUri5); + + TRAPD(err, TestOpenDbL(KDbUri6)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri7)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri8)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri9)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri10)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri11)); + AssertTrueSecL(err == KErrNotFound, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri12)); + AssertTrueSecL(err == KErrNotSupported, KHttpErr); + + TRAP(err, TestOpenDbL(KDbUri13)) + AssertTrueSecL(err == KErrArgument, KArgumentErr); + + TRAP(err, TestOpenDbL(KDbUri14)); + AssertTrueSecL(err == KErrArgument, KURIErr); + + TRAP(err, TestOpenDbL(KDbUri15)); + AssertTrueSecL(err == KErrArgument, KURIErr); + } + +// --------------------------------------------------------- +// CPosTp56::TestOpenDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::TestOpenDbL(const TDesC& aDbURI) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(aDbURI); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + + CleanupStack::PopAndDestroy(lmd); + } + +//--------------------------------------------------------- +// CPosTp56::CopTestDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::CopyTestDbL() + { + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + User::LeaveIfError(fileMan->Copy(KTestDb, KLocalDbLocation, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + + } + +// --------------------------------------------------------- +// CPosTp56::TestLockedDatabaseL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp56::TestLockedDatabaseL() + { + CPosLandmarkDatabase* db1 = UseGeneratedDbFileL(); + CleanupStack::PushL(db1); + + // Take read lock + RArray ids; + CleanupClosePushL(ids); + User::LeaveIfError(ids.Append(1)); + User::LeaveIfError(ids.Append(3)); + User::LeaveIfError(ids.Append(4)); + User::LeaveIfError(ids.Append(6)); + User::LeaveIfError(ids.Append(7)); + User::LeaveIfError(ids.Append(9)); + User::LeaveIfError(ids.Append(24)); + User::LeaveIfError(ids.Append(14)); + User::LeaveIfError(ids.Append(66)); + User::LeaveIfError(ids.Append(61)); + User::LeaveIfError(ids.Append(14)); + CPosLmOperation* operation = db1->PreparePartialLandmarksL(ids); + CleanupStack::PushL(operation); + TReal32 progress(0); + TRequestStatus status; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle + operation->NextStep(status, progress); + CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(KDbUri1); + delete db2; + User::WaitForRequest(status); + + // Release read lock + CleanupStack::PopAndDestroy(operation); + + // Take write lock + operation = db1->RemoveAllLandmarksL(); + CleanupStack::PushL(operation); + progress = 0; + while (progress < 0.4) + { + operation->NextStep(status, progress); + User::WaitForRequest(status); + } + + // Try to instantiate a new db handle - should result in KErrLocked + operation->NextStep(status, progress); + db2 = NULL; + TRAPD(err, db2 = CPosLandmarkDatabase::OpenL(KDbUri1)); + delete db2; + User::WaitForRequest(status); + AssertTrueSecL(err == KErrLocked, _L("OpenL() didn't result in KErrLocked but in %d"), err); + + CleanupStack::PopAndDestroy(3, db1); + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp57.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp57.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,310 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp57.h" +#include +#include +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp57::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::GetName(TDes& aName) const + { + _LIT(KTestName, "TP57 - Multiple db search"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp57::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::CloseTest() + { + iSearchResults.ResetAndDestroy(); + } + +// --------------------------------------------------------- +// CPosTp57::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::StartL() + { + + iDatabase = UseGeneratedDbFileL(); + + CPosLandmark* lm = NULL; + TRAPD(err, + { + lm = iDatabase->ReadLandmarkLC(1); + CleanupStack::PopAndDestroy(lm); + } + ); + +/* if (!err) + { + delete lm; + } + */ + + + /* + CreateDatabasesL(); + + SearchWithTextCriteriaL(); + + SearchWithAreaCriteriaL(); + */ + } + + + +// --------------------------------------------------------- +// CPosTp57::SearchWithTextCriteria +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::SearchWithTextCriteriaL() + { + AppendSearchResultsL(); + + for(TInt i=0; iSetTextL(iSearchResults[i]->TextCriteria()); + textCriteria->SetAttributesToSearch(iSearchResults[i]->Attributes()); + + textCriteria->SetPositionFieldsToSearchL(iSearchResults[i]->PositionFields()); + + + + } + + } + +// --------------------------------------------------------- +// CPosTp57::SearchWithAreaCriteriaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::SearchWithAreaCriteriaL() + { + AppendAreaSearchResultsL(); + + + TBuf<255> info; + for (TInt i=0; iSouthLat(), + iAreaSearchResults[i]->NorthLat(), + iAreaSearchResults[i]->WestLong(), + iAreaSearchResults[i]->EastLong() + )); + CleanupStack::PushL(areaCriteria); + + if (err != iAreaSearchResults[i]->ErrorCode()) + { + iLog->Put(_L("Unexpected error code returned")); + iLog->Put(_L("Area Search result read from file:")); + + iAreaSearchResults[i]->Print(info); + iLog->Put(info); + + _LIT(KReturned, "NewLmAreaCriteriaL error = %d"); + info.Format(KReturned, err); + iLog->Put(info); + User::Leave(KErrGeneral); + } + + if (!err) + { + + + + } + } + + } + +// --------------------------------------------------------- +// CPosTp57::NewLmAreaCriteriaL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLmAreaCriteria* CPosTp57::NewLmAreaCriteriaL(const TReal64 &aSouthLat, + const TReal64 &aNorthLat, + const TReal64 &aWestLong, + const TReal64 &aEastLong) + { + CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(aSouthLat, + aNorthLat, + aWestLong, + aEastLong + ); + CleanupStack::Pop(); + + return areaCriteria; + } +// --------------------------------------------------------- +// CPosTp57::CreateDatabasesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp57::CreateDatabasesL() + { + /* + Very inefficient and time consuming method, maybe better to execute once and store the + created databases as testdata + + Db name: Landmarks id: + eposlm1.ldb 1-10 + eposlm2.ldb 11-20 + eposlm3.ldb 21-30 + eposlm4.ldb 31-40 + eposlm5.ldb 41-50 + eposlm6.ldb 51-60 + eposlm7.ldb 61-70 + eposlm8.ldb 71-80 + eposlm9.ldb 81-90 + eposlm10.ldb 91-100 + eposlm11.ldb 101-105 + */ + + // Paths will need to be changed to the secure dbms path when security is implemented + _LIT(KDefaultDbPath, "c:\\system\\data\\eposlm.ldb"); // Contains now no landmarks but the global categories + _LIT(KDbNamePath, "c:\\system\\data\\eposlm%d.ldb"); + + const TInt KLastId=105; + const TInt KNoDatabases=11; + + RemoveDefaultDbL(); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + CleanupStack::PopAndDestroy(lmd); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + // Create 11 databases + TInt i=0; + for (i=1; i <= KNoDatabases; i++) + { + TBuf<100> db; + db.Format(KDbNamePath, i); + + fs.Delete(db); + User::LeaveIfError(fileMan->Copy(KDefaultDbPath, db, CFileMan::EOverWrite)); + } + CleanupStack::PopAndDestroy(2, &fs); + + iDatabase = UseGeneratedDbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + _LIT(KDbName, "eposlm%d.ldb"); + + TInt databaseNumber=1; + for (i=1; i <= KLastId; i++) + { + CPosLandmark* lm = iDatabase->ReadLandmarkLC(i); + + TBuf<100> name; + name.Format(KDbName, databaseNumber); + + iLog->Put(name); + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(name); + CleanupStack::PushL(lmd); + + lmd->AddLandmarkL(*lm); + CleanupStack::PopAndDestroy(2, lm); + + if (i % 10 == 0) + { + ++databaseNumber; + } + } + + // DEBUG + for (i=1; i <= KNoDatabases; i++) + { + TBuf<100> dbNo; + dbNo.Format(_L(" -------- Printing Db %d --------------"), i); + iLog->Put(dbNo); + + TBuf<100> db; + db.Format(KDbName, i); + iLog->Put(db); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(db); + CleanupStack::PushL(lmd); + + CPosLmItemIterator* iter = lmd->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + + while (id != KPosLmNullItemId) + { + CPosLandmark* lm = lmd->ReadLandmarkLC(id); + + TBuf<255> info; + PrintLandmark(*lm, info); + iLog->Put(info); + CleanupStack::PopAndDestroy(lm); + + id = iter->NextL(); + } + + CleanupStack::PopAndDestroy(2, lmd); + } + } + +// End of File \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp58.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp58.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,379 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp58.h" +#include +#include + +// CONSTANTS +#ifdef __WINS__ +_LIT(KXMLFile, "z:\\system\\test\\testdata\\Tp49ImportInput.xml"); // re-use +#else +_LIT(KXMLFile, "c:\\system\\test\\testdata\\Tp49ImportInput.xml"); // re-use +#endif +_LIT(KTp58Panic, "Timeout Panic"); +const TInt KTp58PanicNumber = 58; + +// ================= LOCAL FUNCTIONS ======================= + +// --------------------------------------------------------- +// LOCAL_C ImportThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ImportThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp58::RunImportTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// LOCAL_C KillerThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt KillerThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp58::RunThreadKillerL(reinterpret_cast (aData))); + + delete actSch; + delete cleanup; + return err; + } + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp58::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::GetName(TDes& aName) const + { + _LIT(KTestName, "TP58 - Import landmarks using User::WaitForRequest()"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp58::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::InitTestL() + { + MakeSurePanicDebugFileExistsL(); + } + +// --------------------------------------------------------- +// CPosTp58::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::CloseTest() + { + } + +// --------------------------------------------------------- +// CPosTp58::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::StartL() + { +// Test Import all landmarks + iLog->Put(_L("Importing all landmarks")); + iTestCase = ETestImportAllLandmarks; + iExpectedErrorCode = KErrGeneral; + ResumeThreadsAndVerifyExitL(); + +// Test Import subset of landmarks + iLog->Put(_L("Importing subset of all landmarks")); + iTestCase = ETestImportSubsetOfLandmarks; + iExpectedErrorCode = KErrGeneral; + ResumeThreadsAndVerifyExitL(); + } + +// --------------------------------------------------------- +// CPosTp58::InitDbLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp58::InitDbLC() + { + RemoveDefaultDbL(); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + + if (database->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(database->InitializeL()); + } + + return database; + } + +// --------------------------------------------------------- +// CPosTp58::RunImportTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::RunImportTestL(TAny* aData) + { + CPosTp58* tp58 = reinterpret_cast (aData); + + switch (tp58->iTestCase) + { + case ETestImportAllLandmarks: + tp58->ImportLandmarksL(NULL); + break; + case ETestImportSubsetOfLandmarks: + { + RArray subset; + CleanupClosePushL(subset); + subset.Append(5); + subset.Append(1); + subset.Append(9); + subset.Append(3); + + tp58->ImportLandmarksL(&subset); + + CleanupStack::PopAndDestroy(&subset); + } + break; + }; + } + +// --------------------------------------------------------- +// CPosTp58::RunThreadKillerL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::RunThreadKillerL(RThread* aThread) + { + TTimeIntervalMicroSeconds32 oneMinute = 60 * 1000000; + + // Enter a infinite loop. This reason to this is that I want to be sure + // that it is killed by the TP58-thread. + TBool forever = ETrue; + while (forever) + { + User::After(oneMinute); + + // Panic importThread if it is still alive + if (aThread->ExitType() == EExitPending) + { + TRequestStatus status; + aThread->Logon(status); + aThread->Panic(KTp58Panic, KTp58PanicNumber); + User::WaitForRequest(status); + } + } + } + +// --------------------------------------------------------- +// CPosTp58::ImportLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::ImportLandmarksL(const RArray* aLandmarkSubSet) + { + CPosLandmarkDatabase* db = InitDbLC(); + + // Recreate parser + CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KMimeType); + CleanupStack::PushL(landmarkParser); + landmarkParser->SetInputFileL(KXMLFile); + + CPosLmOperation* operation = NULL; + if (aLandmarkSubSet) + { + // Import only a subset of the landmarks in parser + operation = db->ImportLandmarksL( + *landmarkParser, + *aLandmarkSubSet, + CPosLandmarkDatabase::EDefaultOptions); + } + else + { + operation = db->ImportLandmarksL( + *landmarkParser, + CPosLandmarkDatabase::EDefaultOptions); + } + TRequestStatus status(KPosLmOperationNotComplete); + TReal32 progress(0); + operation->NextStep(status, progress); + + // Wait for NextStep to complete - should hang + User::WaitForRequest(status); + + // Cancel the import operation + delete operation; + + CleanupStack::PopAndDestroy(2, db); + } + +// --------------------------------------------------------- +// CPosTp58::ResumeThreadsAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp58::ResumeThreadsAndVerifyExitL() + { + iLog->Put(_L("ResumeThreadAndVerifyExitL")); + _LIT(KCreateThreadErr, "Creating thread failed with %d"); + + TBuf<100> threadName; + // Create import thread + RThread importThread; + CleanupClosePushL(importThread); + _LIT(KImportThreadName, "TP58 - Import thread, part %d"); + threadName.Format(KImportThreadName, iTestCase); + iLog->Put(_L("Creating Import thread")); + //TInt err = importThread.Create(KImportThreadName, ImportThreadFunction, + TInt err = importThread.Create(threadName, ImportThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + // Create killer thread + RThread killerThread; + CleanupClosePushL(killerThread); + _LIT(KKillerThreadName, "TP58 - Killer thread, part %d"); + threadName.Format(KKillerThreadName, iTestCase); + iLog->Put(_L("Creating Killer thread")); + err = killerThread.Create(threadName, KillerThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, &importThread); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + // Start threads and wait until either of them exits. + TRequestStatus importThreadStatus, killerThreadStatus; + importThread.Logon(importThreadStatus); + importThread.Resume(); + killerThread.Logon(killerThreadStatus); + killerThread.Resume(); + User::WaitForRequest(importThreadStatus, killerThreadStatus); + + // Kill the thread that might still be alive + TExitType importThreadExitType = importThread.ExitType(); + TExitCategoryName importThreadExitCategory = importThread.ExitCategory(); + TInt importThreadExitReason = importThread.ExitReason(); + if (importThreadExitType == EExitPending) + { + importThread.Kill(KErrCancel); + User::WaitForRequest(importThreadStatus); + } + TExitType killerThreadExitType = killerThread.ExitType(); + TExitCategoryName killerThreadExitCategory = killerThread.ExitCategory(); + TInt killerThreadExitReason = killerThread.ExitReason(); + if (killerThreadExitType == EExitPending) + { + killerThread.Kill(KErrCancel); + User::WaitForRequest(killerThreadStatus); + } + + // Log threads' exit results + TBuf<100> buf; + buf.Format( + _L("ImportThread ended with exit type: %d, exit reason: %d, exit category: %S"), + importThreadExitType, importThreadExitReason, &importThreadExitCategory); + iLog->Put(buf); + buf.Format( + _L("KillerThread ended with exit type: %d, exit reason: %d, exit category: %S"), + killerThreadExitType, killerThreadExitReason, &killerThreadExitCategory); + iLog->Put(buf); + + // Verify thread exit results + TBool error = VerifyThreadExitResults(killerThreadExitType, importThreadExitType, + importThreadExitCategory, importThreadExitReason); + if (error) + { + User::Leave(KErrGeneral); + } + + CleanupStack::PopAndDestroy(2, &importThread); + } + +// --------------------------------------------------------- +// CPosTp58::VerifyThreadExitResults +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp58::VerifyThreadExitResults( + TExitType aKillerThreadExitType, + TExitType aImportThreadExitType, + const TExitCategoryName& aImportThreadExitCategory, + TInt aImportThreadExitReason) + { + TBool error = EFalse; + + if (aImportThreadExitType != EExitPanic) + { + _LIT(KExitTypeErr, "Import thread was not panicked as expected."); + iLog->PutError(KExitTypeErr); + error = ETrue; + } + if (aImportThreadExitCategory != KTp58Panic) + { + _LIT(KPanicErr, "Import thread had unexpected panic category"); + iLog->PutError(KPanicErr); + error = ETrue; + } + if (aImportThreadExitReason != KTp58PanicNumber) + { + _LIT(KPanicCodeErr, "Import thread had unexpected panic number"); + iLog->PutError(KPanicCodeErr); + error = ETrue; + } + if (aKillerThreadExitType != EExitPending) + { + _LIT(KExitTypeErr, "Killer thread was not alive as expected."); + iLog->PutError(KExitTypeErr); + error = ETrue; + } + + return error; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp6.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp6.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,266 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp6.h" + +#include +#include +#include + +#include "FT_LandmarkConstants.h" + +// CONSTANTS +// _LIT(KGetCategoryNameErr, "GetCategoryName returns incorrect error code"); +_LIT(KCategoryNameErr, "Category name is incorrect"); +_LIT(KCategoryIdErr, "Category Id is incorrect"); +_LIT(KGlobalCategoryIdErr, "Global Category Id is incorrect"); +_LIT(KCategoryIconIndexErr, "Category Icon index is incorrect"); +_LIT(KCategoryIconMaskIndexErr, "Category Icon Mask Index is incorrect"); +_LIT(KCategoryMbmFileNameErr, "Category MbmFileName is incorrect"); +_LIT(KAddCategoryErr, "AddCategory should return an error"); + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp6::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::StartL() + { + iLog->Log(_L("In the StartL of FT_CPosTp6.h")); + RemoveDefaultDbL(); + + CPosLandmarkCategory* category = CreateCategoryLC(KCategoryName); + CPosLandmarkCategory* copy = CPosLandmarkCategory::NewLC(*category); + + CheckGetMethodsL(category, KCategoryName); + + copy->SetCategoryNameL(KCategoryName2); + CheckGetMethodsL(copy, KCategoryName2); + + CheckRemoveMethodsL(category); + CheckRemoveMethodsL(copy); + + CPosLandmarkDatabase* lmd = OpenDatabaseLC(); + ExecuteAndDeleteLD(lmd->CompactL()); + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + User::After(1000000); + TRAPD(err, cm->AddCategoryL(*copy)); + AssertTrueSecL(err == KErrArgument, KAddCategoryErr); + + CheckFieldsMaxLengthL(); + + CheckEmptyCategoryNameL(); + + CheckSetIconL(); + + CleanupStack::PopAndDestroy(4); // category, copy, lmd, cm + } + +// --------------------------------------------------------- +// CPosTp6::CheckGetmethods +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckGetMethodsL(CPosLandmarkCategory* aCategory, const TDesC& aName) + { + TPtrC categoryName; + + aCategory->GetCategoryName(categoryName); + + AssertTrueSecL(categoryName.Compare(aName) == KErrNone, KCategoryNameErr); + AssertTrueSecL(aCategory->CategoryId() == 0, KCategoryIdErr); + AssertTrueSecL(aCategory->GlobalCategory() == 0, KGlobalCategoryIdErr); + + TPtrC mbmFileName; + TInt index; + TInt indexMask; + aCategory->GetIcon(mbmFileName, index, indexMask); + AssertTrueSecL(mbmFileName.Compare(KMbmFileName) == KErrNone, KCategoryMbmFileNameErr); + AssertTrueSecL(index == KIconIndex, KCategoryIconIndexErr); + AssertTrueSecL(indexMask == KIconMaskIndex, KCategoryIconMaskIndexErr); + + CPosLandmarkDatabase* lmd = OpenDatabaseLC(); + CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(cm); + + TPosLmItemId id1 = cm->AddCategoryL(*aCategory); + User::After(1000000); + TRAPD(err, cm->AddCategoryL(*aCategory)); + AssertTrueSecL(err == KErrAlreadyExists, KAddCategoryErr); + AssertTrueSecL(id1 == aCategory->CategoryId(), KCategoryIdErr); + + CleanupStack::PopAndDestroy(2); // lmd, cm + } + +// --------------------------------------------------------- +// CPosTp6::CheckRemoveMethodsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckRemoveMethodsL(CPosLandmarkCategory* aCategory) + { + aCategory->RemoveCategoryAttributes(CPosLandmarkCategory::ENoAttribute); + aCategory->RemoveCategoryAttributes(CPosLandmarkCategory::ECategoryName); + aCategory->RemoveCategoryAttributes(CPosLandmarkCategory::EIcon); + + CheckRemovedL(aCategory); + + CPosLandmarkCategory* category = CreateCategoryLC(KCategoryName); + category->RemoveCategoryAttributes(CPosLandmarkCategory::EAllAttributes); + CheckRemovedL(category); + CleanupStack::PopAndDestroy(category); + + // Check with attributes outside defined interval + // since TAttributes is a TUint32 -1 is casted to EAllAttributes = 0xFFFF + category = CreateCategoryLC(_L("NewCategory")); + category->RemoveCategoryAttributes((CPosLandmarkCategory::TAttributes)-1); + + TPtrC categoryName; + if (category->GetCategoryName(categoryName) == KErrNotFound) iLog->Log(_L("Category Name has been removed")); + TPtrC mbmFileName; + TInt index; + TInt indexMask; + if (aCategory->GetIcon(mbmFileName, index, indexMask) == KErrNotFound) iLog->Log(_L("Catgory Icon has been removed")); + + CleanupStack::PopAndDestroy(category); + + // Check with attributes outside defined interval + category = CreateCategoryLC(_L("NewCategory2")); + category->RemoveCategoryAttributes(0); + category->GetCategoryName(categoryName); + AssertTrueSecL(categoryName.CompareC(_L("NewCategory2")) == KErrNone, _L("Wrong category name returned after remove invalid attribute")); + + CleanupStack::PopAndDestroy(category); + } + +// --------------------------------------------------------- +// CPosTp6::CheckRemovedL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckRemovedL(CPosLandmarkCategory* aCategory) + { + TPtrC name; + AssertTrueSecL(aCategory->GetCategoryName(name) == KErrNotFound, KCategoryNameErr); + + TPtrC mbmFileName; + TInt index; + TInt indexMask; + AssertTrueSecL(aCategory->GetIcon(mbmFileName, index, indexMask) == KErrNotFound, KCategoryMbmFileNameErr); + + } + +//--------------------------------------------------------- +// CPosTp6::CheckEmptyCategoryNameL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckEmptyCategoryNameL() + { + + iLog->Log(_L("CheckEmptyCategoryNameL")); + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + + // Set empty string as category name + // should not be accepted + TRAPD(err, category->SetCategoryNameL(_L(""))); + + if (err != KErrArgument) + { + iLog->Log(_L("Empty category name should not be accepted")); + User::Leave(err); + } + + + CleanupStack::PopAndDestroy(category); + } + +//--------------------------------------------------------- +// CPosTp6::CheckSetIconL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckSetIconL() + { + iLog->Log(_L("CheckSetIconL")); + + _LIT(K124Error, "Icon name is not limited to 255 characters"); + + + // Defined in KMaxFileName e32const.h + HBufC* hbuf = HBufC::NewLC(KMaxFileName+1); + while(hbuf->Des().Length() < KMaxFileName) + { + hbuf->Des().Append(_L("X")); + } + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetIconL(*hbuf, 0, KPosLmIconMaskNotUsed); + + hbuf->Des().Append(_L("X")); + + TRAPD(err, category->SetIconL(*hbuf, 0, KPosLmIconMaskNotUsed)); + AssertTrueSecL(err == KErrArgument, K124Error); + + CleanupStack::PopAndDestroy(2, hbuf); + } + +//--------------------------------------------------------- +// CPosTp6::CheckFieldsMaxLength +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp6::CheckFieldsMaxLengthL() + { + _LIT(K124Error, "Category name is not limited to 255 characters"); + + const TInt KMaxFileName = 124; + HBufC* hbuf = HBufC::NewLC(KMaxFileName+1); + + while(hbuf->Des().Length() < KMaxFileName) + { + hbuf->Des().Append(_L("X")); + } + + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + category->SetCategoryNameL(*hbuf); + + hbuf->Des().Append(_L("X")); + + TRAPD(err, category->SetCategoryNameL(*hbuf)); + AssertTrueSecL(err == KErrArgument, K124Error); + + CleanupStack::PopAndDestroy(2, hbuf); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp7.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp7.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,223 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp7.h" +#include +#include +#include +#include +#include +#include +#include +//#include +#include "FT_LandmarkConstants.h" + +const TInt KShortDelayMicroSeconds = 10000; // 0.01 sec + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CPosTp7::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp7::StartL() + { + _LIT(KMultipleErr, "Error %d when multiple clients access the landmarks db"); + _LIT(KMultipleAddErr, "All Add request from multiple clients returns KErrLocked"); + _LIT(KExitErr, "Thread was panicked or is still alive"); + + MakeSurePanicDebugFileExistsL(); + + RemoveDefaultDbL(); + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + if (lmd->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(lmd->InitializeL()); + } + CleanupStack::PopAndDestroy(lmd); + + iOneSucces=EFalse; + TFixedArray statuses; + + CreateThreadsL(); + + iLog->Log(_L("Logon")); + for (TInt i=0; iLog(_L("WaitForRequest")); + for (TInt j=0; jLog(_L("Checking Threads")); + for (TInt t=0; t(aData); + TInt threadIndex = ++self->iThreadIndex; + + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + TInt err = KErrLocked; + while ( ETrue ) + { + TRAP( err, ExecuteAndDeleteLD(lmd->InitializeL()) ); + if ( !err ) + { + break; + } + else if ( err != KErrLocked ) + { + RDebug::Print( _L("TP7: thread %d, db init failed with %d"), + threadIndex, err ); + User::Leave( err ); + } + else + { + RDebug::Print( _L("TP7: thread %d, db locked, can't init"), + threadIndex); + } + User::After( TTimeIntervalMicroSeconds32( KShortDelayMicroSeconds ) ); + } + } + + for ( TInt i = 0; i < KNoAddRequests; i++ ) + { + CPosLandmark* landmark = CPosLandmark::NewLC(); + + _LIT(KLmName, "Thread%d Lm %d"); + TBuf<100> lmName; + lmName.Format(KLmName, threadIndex, i); + landmark->SetLandmarkNameL(lmName); + + RDebug::Print( _L("TP7: thread %d, adding lm %d"), threadIndex, i ); + TRAPD( err, lmd->AddLandmarkL( *landmark ) ); + if ( err != KErrLocked && err != KErrNone && err != KErrInUse ) + { + RDebug::Print( _L("TP7: thread %d, add lm %d failed with %d"), threadIndex, i, err ); + User::Leave( err ); + } + else if( err == KErrNone ) + { + self->iOneSucces = ETrue; // At lest one add request should return KErrNone + } + else + { + RDebug::Print( _L("TP7: thread %d, db locked, can't add lm %d"), threadIndex, i ); + } + + CleanupStack::PopAndDestroy(landmark); + User::After( TTimeIntervalMicroSeconds32( KShortDelayMicroSeconds ) ); + } + CleanupStack::PopAndDestroy(lmd); + } + + +LOCAL_C TInt ThreadFunction(TAny* aData) + { + + CTrapCleanup* cleanup=CTrapCleanup::New(); + + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp7::RunTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// CPosTp7::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp7::CreateThreadsL() + { + iLog->Log(_L("CreateThreadsL")); + _LIT(KThreadName, "TP7thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TInt i=0; i name; + name.Format(KThreadName, i + 1); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(this)); + + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + + iLog->Log(_L("CreateThreadsL Done")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp76.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp76.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp76.h" +#include +#include "FT_LandmarkConstants.h" + +//_LIT(KCopyFilePath, "c:\\system\\data\\EPOSLMGLOBALCATEGORIES.R01"); +_LIT(KCopyFilePath, "c:\\resource\\EPOSLMGLOBALCATEGORIES.R01"); +#ifdef __WINS__ +_LIT(KCORRUPTFILE, "z:\\system\\test\\testdata\\corrupt_EPOSLMGLOBALCATEGORIES.R06"); +#else +_LIT(KCORRUPTFILE, "c:\\system\\test\\testdata\\corrupt_EPOSLMGLOBALCATEGORIES.R06"); +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp76::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp76::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp76 - Corrupt Global Categories resource file"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp76::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp76::StartL() + { + + // Test error report ESLI-65WADU + TestCorruptGlobalCategoriesFileL(); + + } + +// --------------------------------------------------------- +// CPosTp76::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp76::CloseTest() + { + iLog->Put(_L("CloseTest")); + // Delete "corrupt" global categories file + DeleteFileL(KCopyFilePath); + + delete iOperation; + iOperation = NULL; + + } + +// --------------------------------------------------------- +// CPosTp76::TestCorruptGlobalCategoriesFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp76::TestCorruptGlobalCategoriesFileL() + { + iLog->Put(_L("TestCorruptGlobalCategoriesFileL")); + RemoveDefaultDbL(); + + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + // use emtpy landmarks db as corrupt global categories file + //User::LeaveIfError(fileMan->Copy(KLandmarksEmptyDb, KCopyFilePath, CFileMan::EOverWrite)); + User::LeaveIfError(fileMan->Copy(KCORRUPTFILE, KCopyFilePath, CFileMan::EOverWrite)); + + CleanupStack::PopAndDestroy(2, &fs); + iLog->Put(_L("Open Landmarksdb")); + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(lmd); + + if (lmd->IsInitializingNeeded()) + { + iLog->Put(_L("IsInitializingNeeded()")); + ExecuteAndDeleteLD(lmd->InitializeL()); + iLog->Put(_L("After InitializeL()")); + } + + // FrBo TBD below, what will happen below when error above is fixed + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd); + CleanupStack::PushL(categoryManager); + // Make sure that global categories are included in lm db, use default global categories + iLog->Put(_L("categoryManager->ResetGlobalCategoriesL()")); + + TRAPD(err, iOperation = categoryManager->ResetGlobalCategoriesL()); + + if (err == KErrNone) LogErrorAndLeave(_L("ResetGlobalCategoriesL should leave with errorcode")); + TBuf<100> buf; + buf.Format(_L("ResetGlobalCategoriesL leaved with code: %d"), err); + iLog->Put(buf); + + delete iOperation; + iOperation = NULL; + + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(lmd); + + DeleteFileL(KCopyFilePath); + iLog->Put(_L("TestCorruptGlobalCategoriesFileL")); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp77.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp77.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,604 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp77.h" +#include + +// CONSTANTS +// _LIT(KTp77Panic, "Timeout Panic"); +const TInt KTp77PanicNumber = 77; + +// ================= LOCAL FUNCTIONS ======================= + +// --------------------------------------------------------- +// LOCAL_C BadThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt BadClientThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp77::RunBadClientTestL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// --------------------------------------------------------- +// LOCAL_C KillerThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt KillerThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TRAPD(err, CPosTp77::RunThreadKillerL(aData)); + + delete actSch; + delete cleanup; + return err; + } + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp77::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::GetName(TDes& aName) const + { + _LIT(KTestName, "TP77 - Bad server usage"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp77::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::InitTestL() + { + MakeSurePanicDebugFileExistsL(); + } + +// --------------------------------------------------------- +// CPosTp77::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::CloseTest() + { + iBadThread.Close(); + } + +// --------------------------------------------------------- +// CPosTp77::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::StartL() + { +// Test multiple Notify Db events + iLog->Put(_L("1st part, testing multiple notify Db event")); + iTestCase = ETestNotifyDbEvent; + CPosLandmarkDatabase* db = InitDbLC(); + iTimeToWait = 3000000; + ResumeThreadsAndVerifyExitL(); + TBool errors = VerifyThreadExitResultsL(KTp77PanicNumber); + (errors) ? + VerifyLmServerIsAliveL(db) : + errors = VerifyLmServerIsAliveL(db); + CleanupStack::PopAndDestroy(db); + +// Test non terminated single Notify Db event + iLog->Put(_L("2nd part, testing non terminated sinlge notify Db event")); + iTestCase = ETestNotifyDbEvent2; + db = InitDbLC(); + ResumeThreadsAndVerifyExitL(); + (errors) ? + VerifyThreadExitResultsL(0) : + errors = VerifyThreadExitResultsL(0); + (errors) ? + VerifyLmServerIsAliveL(db) : + errors = VerifyLmServerIsAliveL(db); + CleanupStack::PopAndDestroy(db); + +// Test non terminated single InitializeL() + iLog->Put(_L("3rd part, testing non terminated single Initialize db operations")); + iTestCase = ETestInitialize; + RemoveDefaultDbL(); + db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + ResumeThreadsAndVerifyExitL(); + (errors) ? + VerifyThreadExitResultsL(0) : + errors = VerifyThreadExitResultsL(0); + CPosLmOperation* initOp = db->InitializeL(); + CleanupStack::PushL(initOp); + TRAPD(err, initOp->ExecuteL()); + if (err != KErrNone) + { + _LIT(KError, "Trying to initialize after badThread failed with %d"); + iBuf.Format(KError, err); + iLog->PutError(iBuf); + errors = ETrue; + } + CleanupStack::PopAndDestroy(initOp); + (errors) ? + VerifyLmServerIsAliveL(db) : + errors = VerifyLmServerIsAliveL(db); + CleanupStack::PopAndDestroy(db); + +// Test non terminated multiple InitializeL() + iLog->Put(_L("4th part, testing non terminated multiple Initialize db operations")); + iTestCase = ETestInitialize2; + RemoveDefaultDbL(); + db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + ResumeThreadsAndVerifyExitL(); + (errors) ? + VerifyThreadExitResultsL(0) : + errors = VerifyThreadExitResultsL(0); + initOp = db->InitializeL(); + CleanupStack::PushL(initOp); + TRAP(err, initOp->ExecuteL()); + if (err != KErrNone) + { + _LIT(KError, "Trying to initialize after badThread failed with %d"); + iBuf.Format(KError, err); + iLog->PutError(iBuf); + errors = ETrue; + } + CleanupStack::PopAndDestroy(initOp); + (errors) ? + VerifyLmServerIsAliveL(db) : + errors = VerifyLmServerIsAliveL(db); + CleanupStack::PopAndDestroy(db); + +// Test write lock on non terminated import operation + iLog->Put(_L("5th part, testing write lock on non terminated import operation")); + iTestCase = ETestWriteLock; + db = UseGeneratedDbFileL(); + CleanupStack::PushL(db); + ResumeThreadsAndVerifyExitL(); + (errors) ? + VerifyThreadExitResultsL(0) : + errors = VerifyThreadExitResultsL(0); + (errors) ? + VerifyLmServerIsAliveL(db) : + errors = VerifyLmServerIsAliveL(db); + CleanupStack::PopAndDestroy(db); + +// The test below should be successful. This is the case on WINS but not in THUMB. On +// THUMB it runs for a while and then fails with KErrNoMemory. A duration test is needed! +/* +// Test RegisterUri (executed during OpenL()) + iLog->Put(_L("2nd part, testing registering URI...")); + iTestCase = ETestRegisterUri; + db = InitDbLC(); + + TBool ready = EFalse; + TInt diff; + iTimeToWait = 3000000; + while (!ready) + { + diff = iTimeToWait.Int() - iLastTimeToWait.Int(); + iLastTimeToWait = iTimeToWait; + ResumeThreadsAndVerifyExitL(); + VerifyLmServerIsAliveL(db); + if (iBadThreadExitReason == KTp77PanicNumber && + iBadThreadExitType == EExitKill) + { + // Increase iTimeToWait + iTimeToWait = iTimeToWait.Int() + Abs(diff / 2); + } + else if (iBadThreadExitReason == 0 && + iBadThreadExitType == EExitKill) + { + // Decrease iTimeToWait + iTimeToWait = iTimeToWait.Int() - Abs(diff / 2); + } + else + { + LogErrorAndLeave(_L("Got unexpected exit code from badThread")); + } + ready = iTimeToWait == iLastTimeToWait; + } + iBuf.Format(_L("Estimated critical code after %d microseconds"), iTimeToWait.Int()); + iLog->Put(buf); + + // Execute vulnarable code + iTimeToWait = iTimeToWait.Int() - 3000; + diff = 20; + ready = EFalse; + TInt i = 0; + while (!ready) + { + iTimeToWait = iTimeToWait.Int() + diff; + ResumeThreadsAndVerifyExitL(); + VerifyLmServerIsAliveL(db); + ready = iBadThreadExitReason != KTp77PanicNumber; + i++; + } + + buf.Format(_L("Tested %d loops"), i); + iLog->Put(buf); + + CleanupStack::PopAndDestroy(db);*/ + + if (errors) + { + User::Leave(KErrGeneral); + } + } + +// --------------------------------------------------------- +// CPosTp77::InitDbLC +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp77::InitDbLC() + { + RemoveDefaultDbL(); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + + if (database->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(database->InitializeL()); + } + + return database; + } + +// --------------------------------------------------------- +// CPosTp77::RunBadClientTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::RunBadClientTestL(TAny* aData) + { + CPosTp77* tp77 = reinterpret_cast (aData); + switch (tp77->iTestCase) + { + case ETestNotifyDbEvent: + { + TPosLmEvent event1, event2, event3, event4, event5; + TRequestStatus status1 = KErrNone; + TRequestStatus status2 = KErrNone; + TRequestStatus status3 = KErrNone; + TRequestStatus status4 = KErrNone; + TRequestStatus status5 = KErrNone; + TRequestStatus status[5] = {status1, status2, status3, status4, status5}; + + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db1); + CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db2); + CPosLandmarkDatabase* db3 = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db3); + CPosLandmarkDatabase* db4 = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db4); + CPosLandmarkDatabase* db5 = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db5); + + db1->NotifyDatabaseEvent(event1, status[0]); + db2->NotifyDatabaseEvent(event2, status[1]); + db3->NotifyDatabaseEvent(event3, status[2]); + db4->NotifyDatabaseEvent(event4, status[3]); + db5->NotifyDatabaseEvent(event5, status[4]); + + for (TInt i = 0; i < 5; i++) + { + User::WaitForRequest(status[i]); + } + + CleanupStack::PopAndDestroy(5, db1); + } + break; + + case ETestNotifyDbEvent2: + { + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(); + + // Observe events + TPosLmEvent event1; + TRequestStatus status1; + db1->NotifyDatabaseEvent(event1, status1); + } + break; + + case ETestInitialize: + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + + // Start to initialize db + CPosLmOperation* op = db->InitializeL(); + TRequestStatus status; + TReal32 progress; + op->NextStep(status, progress); + } + break; + + case ETestInitialize2: + { + TRequestStatus status1, status2, status3, status4, status5; + TReal32 progress1, progress2, progress3, progress4, progress5; + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(); + CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(); + CPosLandmarkDatabase* db3 = CPosLandmarkDatabase::OpenL(); + CPosLandmarkDatabase* db4 = CPosLandmarkDatabase::OpenL(); + CPosLandmarkDatabase* db5 = CPosLandmarkDatabase::OpenL(); + + // Start to initialize db + CPosLmOperation* op1 = db1->InitializeL(); + CPosLmOperation* op2 = db2->InitializeL(); + CPosLmOperation* op3 = db3->InitializeL(); + CPosLmOperation* op4 = db4->InitializeL(); + CPosLmOperation* op5 = db5->InitializeL(); + op1->NextStep(status1, progress1); + op2->NextStep(status2, progress2); + op3->NextStep(status3, progress3); + op4->NextStep(status4, progress4); + op5->NextStep(status5, progress5); + } + break; + + case ETestWriteLock: + { + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + CPosLmOperation* removeOp = db->RemoveAllLandmarksL(); + TReal32 progress(0); + TRequestStatus status; + while (progress < 0.4) + { + removeOp->NextStep(status, progress); + User::WaitForRequest(status); + } + CleanupStack::Pop(db); + } + break; + + case ETestRegisterUri: + { + CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(); + delete db1; + } + break; + + }; + } + +// --------------------------------------------------------- +// CPosTp77::RunThreadKillerL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::RunThreadKillerL(TAny* aData) + { + CPosTp77* tp77 = reinterpret_cast (aData); + + // Enter a infinite loop. This reason to this is that I want to be sure + // that it is killed by the TP77-thread. + TBool forever = ETrue; + while (forever) + { + // Panic badThread if it is still alive + if (tp77->iBadThread.ExitType() == EExitPending) + { + TRequestStatus status; + tp77->iBadThread.Logon(status); + + switch (tp77->iTestCase) + { + case ETestNotifyDbEvent: + { + // Make sure that the badThread has started 5 observers of db events + User::After(tp77->iTimeToWait); + + // Generate db event + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + CPosLandmark* lm = CPosLandmark::NewLC(); + db->AddLandmarkL(*lm); + + // Kill Event observing thread + tp77->iBadThread.Kill(KTp77PanicNumber); + User::WaitForRequest(status); + + CleanupStack::PopAndDestroy(2, db); + } + break; + + case ETestNotifyDbEvent2: + case ETestInitialize: + case ETestInitialize2: + case ETestWriteLock: + { + // Do nothing + User::LeaveIfError(tp77->iBadThread.LogonCancel(status)); + forever = EFalse; + } + break; + + case ETestRegisterUri: + { + User::After(tp77->iTimeToWait); + + // Kill Event observing thread + tp77->iBadThread.Kill(KTp77PanicNumber); + User::WaitForRequest(status); + } + break; + + }; + } + else + { + forever = EFalse; + } + } + } + +// --------------------------------------------------------- +// CPosTp77::ResumeThreadsAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp77::ResumeThreadsAndVerifyExitL() + { + _LIT(KCreateThreadErr, "Creating thread failed with %d"); + + // Create bad thread + _LIT(KBadThreadName, "TP77 - Bad thread"); + iBadThread.Close(); + TInt err = iBadThread.Create(KBadThreadName, BadClientThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + // Create killer thread + RThread killerThread; + CleanupClosePushL(killerThread); + _LIT(KKillerThreadName, "TP77 - Killer thread"); + err = killerThread.Create(KKillerThreadName, KillerThreadFunction, + KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + + // Start threads and wait until either of them exits. + TRequestStatus badThreadStatus, killerThreadStatus; + iBadThread.Logon(badThreadStatus); + iBadThread.Resume(); + killerThread.Logon(killerThreadStatus); + killerThread.Resume(); + User::WaitForRequest(badThreadStatus); + User::WaitForRequest(killerThreadStatus); + + // Fetch exit data + iBadThreadExitType = iBadThread.ExitType(); + iBadThreadExitCategory = iBadThread.ExitCategory(); + iBadThreadExitReason = iBadThread.ExitReason(); + iKillerThreadExitType = killerThread.ExitType(); + iKillerThreadExitCategory = killerThread.ExitCategory(); + iKillerThreadExitReason = killerThread.ExitReason(); + + // Log threads' exit results + iBuf.Format( + _L("BadThread ended with exit type: %d, exit reason: %d, exit category: %S"), + iBadThreadExitType, iBadThreadExitReason, &iBadThreadExitCategory); +// iLog->Put(buf); + iBuf.Format( + _L("KillerThread ended with exit type: %d, exit reason: %d, exit category: %S"), + iKillerThreadExitType, iKillerThreadExitReason, &iKillerThreadExitCategory); +// iLog->Put(buf); + + CleanupStack::PopAndDestroy(&killerThread); + } + +// --------------------------------------------------------- +// CPosTp77::VerifyThreadExitResultsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp77::VerifyThreadExitResultsL(TInt aBadThreadExitReason) + { + TBool error = EFalse; + _LIT(KKillCategory, "Kill"); + + if (iBadThreadExitType != EExitKill) + { + _LIT(KExitTypeErr, "BadThread was not killed as expected."); + iLog->PutError(KExitTypeErr); + error = ETrue; + } + if (iBadThreadExitCategory != KKillCategory) + { + _LIT(KPanicErr, "BadThread had unexpected exit category"); + iLog->PutError(KPanicErr); + error = ETrue; + } + if (iBadThreadExitReason != aBadThreadExitReason) + { + _LIT(KPanicCodeErr, "BadThread had unexpected exit reason"); + iLog->PutError(KPanicCodeErr); + error = ETrue; + } + if (iKillerThreadExitType != EExitKill) + { + _LIT(KExitTypeErr, "KillerThread was not killed as expected."); + iLog->PutError(KExitTypeErr); + error = ETrue; + } + if (iKillerThreadExitCategory != KKillCategory) + { + _LIT(KPanicErr, "KillerThread had unexpected exit category"); + iLog->PutError(KPanicErr); + error = ETrue; + } + if (iKillerThreadExitReason != 0) + { + _LIT(KPanicCodeErr, "KillerThread had unexpected exit reason"); + iLog->PutError(KPanicCodeErr); + error = ETrue; + } + + return error; + } + +// --------------------------------------------------------- +// CPosTp77::VerifyLmServerIsAliveL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CPosTp77::VerifyLmServerIsAliveL(CPosLandmarkDatabase* aDb) + { + TRAPD(err, aDb->RemoveLandmarkL(1)); + TBool errorExists = err != KErrNone && err != KErrNotFound; + if (errorExists) + { + _LIT(KError, "Unable to use db instance. Using db failed with %d."); + iBuf.Format(KError, err); + iLog->PutError(iBuf); + } + + return errorExists; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp78.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp78.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,815 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp78.h" +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KExectionTimeInMinutes = 60 * 10; // 10 hours + +// ================= LOCAL FUNCTIONS ======================= + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TThreadParam* params = reinterpret_cast (aData); + TRAPD(err, (*params->iTestFunction)(params->iMessage)); + + delete actSch; + delete cleanup; + return err; + } + +LOCAL_C void AddLandmarksL( + TInt aNrOfLmsToAdd, + const TDesC& aName, + CPosLandmarkDatabase* aDb, + RArray& aIdArray) + { + for (TInt i = 0; i < aNrOfLmsToAdd; i++) + { + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(aName); + landmark->SetPositionL(TLocality(TCoordinate(64, 85, 20), 25, 53)); + landmark->SetCoverageRadius(18); + landmark->AddCategoryL(1); + landmark->SetIconL(_L("Icon"), 23, KPosLmIconMaskNotUsed); + landmark->SetLandmarkDescriptionL(_L("Desc")); + User::LeaveIfError(aIdArray.Append(aDb->AddLandmarkL(*landmark))); + CleanupStack::PopAndDestroy(landmark); + } + } + +LOCAL_C void VerifyErrorL(const TDesC& aFormat, TInt aErr, TDes* aMessage) + { + if (aErr != KErrNone && aErr != KErrLocked) + { + aMessage->Format(aFormat, aErr); + + // Append time + _LIT(KTimeFormat, " %F%Y-%M-%D at %H.%T:%S"); + TTime now; + now.HomeTime(); + TBuf<50> time; + now.FormatL(time, KTimeFormat); + aMessage->Append(time); + + User::Leave(aErr); + } + } + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp78::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::GetName(TDes& aName) const + { + _LIT(KTestName, "TP78 - CPosLandmarkDatabase duration tests"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp78::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::InitTestL() + { + MakeSurePanicDebugFileExistsL(); + InitDbL(); + } + +// --------------------------------------------------------- +// CPosTp78::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::CloseTest() + { + } + +// --------------------------------------------------------- +// CPosTp78::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::StartL() + { +// Test Open database duration test + ResumeThreadsAndVerifyExitL(); + } + +// --------------------------------------------------------- +// CPosTp78::InitDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::InitDbL() + { + RemoveDefaultDbL(); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + + if (database->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(database->InitializeL()); + } + + CleanupStack::PopAndDestroy(database); + + // Wait for LM server to die + User::After(2000000); + } + +// --------------------------------------------------------- +// CPosTp78::ResumeThreadsAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::ResumeThreadsAndVerifyExitL() + { + _LIT(KCreateThreadErr, "Creating thread failed with %d"); + TInt nrOfThreads = 0; + RThread openDbThread, addRemoveLmThread, impExpLmThread, dbEventThread, readAndUpdateThread; + TThreadParam params1, params2, params3, params4, params5; + TBuf<200> threadMsg1, threadMsg2, threadMsg3, threadMsg4, threadMsg5; + + // Create open database thread + _LIT(KOpenDatabase, "TP78 - Open database duration thread"); + params1.iMessage = &threadMsg1; + params1.iTestFunction = RunOpenDbTestL; + TInt err = openDbThread.Create(KOpenDatabase, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(openDbThread); + nrOfThreads++; + + // Create add remove LMs thread + _LIT(KAddRemoveLandmarks, "TP78 - Add remove landmarks duration thread"); + params2.iMessage = &threadMsg2; + params2.iTestFunction = RunAddRemoveLmTestL; + err = addRemoveLmThread.Create(KAddRemoveLandmarks, ThreadFunction, + KDefaultStackSize, KMinHeapSize, 5 * KDefaultHeapSize, ¶ms2); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(addRemoveLmThread); + nrOfThreads++; + + // Create import/export LMs thread + _LIT(KImpExpLandmarks, "TP78 - Import/Export landmarks duration thread"); + params3.iMessage = &threadMsg3; + params3.iTestFunction = RunImportExportLmTestL; + err = impExpLmThread.Create(KImpExpLandmarks, ThreadFunction, + KDefaultStackSize, KMinHeapSize, 5 * KDefaultHeapSize, ¶ms3); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(impExpLmThread); + nrOfThreads++; + + // Create db event thread + _LIT(KDbEventThread, "TP78 - Database events duration thread"); + params4.iMessage = &threadMsg4; + params4.iTestFunction = RunDbEventTestL; + err = dbEventThread.Create(KDbEventThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, ¶ms4); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(dbEventThread); + nrOfThreads++; + + // Create read and update thread + _LIT(KReadAndUpdateThread, "TP78 - Read and update landmarks duration thread"); + params5.iMessage = &threadMsg5; + params5.iTestFunction = RunReadAndUpdateTestL; + err = readAndUpdateThread.Create(KReadAndUpdateThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, 5 * KDefaultHeapSize, ¶ms5); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(readAndUpdateThread); + nrOfThreads++; + + // Start threads. + RThread* threads[] = {&openDbThread, &addRemoveLmThread, &impExpLmThread, &dbEventThread, &readAndUpdateThread}; + RPointerArray threadMonitors; + for (TInt j = 0; j < nrOfThreads; j++) + { + threadMonitors.Append(CThreadMonitor::NewL(threads[j])); + } + + // Log time stamp + _LIT(KTimeFormat, "Threads started on %F%Y-%M-%D at %H.%T:%S"); + TTime now; + now.HomeTime(); + now.FormatL(iBuf, KTimeFormat); + iLog->Put(iBuf); + + // Wait until any of the threads exits. + TDes* messages[] = {&threadMsg1, &threadMsg2, &threadMsg3, &threadMsg4, &threadMsg5}; + TInt errors = KErrNone; + TBool allThreadsTerminated = EFalse; + while (!allThreadsTerminated && errors == KErrNone) + { + CActiveScheduler::Start(); + + // Assume all threads are terminated + allThreadsTerminated = ETrue; + for (TInt i = 0; i < nrOfThreads && errors == KErrNone; i++) + { + if (threadMonitors[i]->IsActive()) + { + // Thread is still alive + allThreadsTerminated = EFalse; + } + else + { + // Thread is terminated, check exit codes + if (*messages[i] != KNullDesC) + { + iLog->Put(*(messages[i])); + } + if (threads[i]->ExitType() != EExitKill) + { + iBuf.Format(_L("Thread %i was not killed!"), i); + iLog->PutError(iBuf); + TExitCategoryName category = threads[i]->ExitCategory(); + iBuf.Format(_L("Exit Category = %S %d"), &category, threads[i]->ExitReason()); + iLog->Put(iBuf); + errors = KErrGeneral; + } + else + { + TInt exitReason = threads[i]->ExitReason(); + if (exitReason != 0) + { + iBuf.Format(_L("Thread's exit reason wasn't 0 but %d."), exitReason); + iLog->PutError(iBuf); + errors = exitReason; + } + } + } + } + } + + // Terminate all remaining threads + threadMonitors.ResetAndDestroy(); + + // Log time stamp + _LIT(KTimeFormat2, "Threads terminated on %F%Y-%M-%D at %H.%T:%S"); + now.HomeTime(); + now.FormatL(iBuf, KTimeFormat2); + iLog->Put(iBuf); + + + User::LeaveIfError(errors); + + CleanupStack::PopAndDestroy(nrOfThreads, &openDbThread); + } + +// --------------------------------------------------------- +// CPosTp78::RunOpenDbTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::RunOpenDbTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + while (executionTime.Int() < KExectionTimeInMinutes) + { + CPosLandmarkDatabase* db = NULL; + TRAPD(err, db = CPosLandmarkDatabase::OpenL()); + CleanupStack::PushL(db); + VerifyErrorL(_L("<-- OpenDbThread: CPosLandmarkDatabase::OpenL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + // Try to initialize the db + db->IsInitializingNeeded(); // don't care about the result. Init anyway + CPosLmOperation* operation = NULL; + TRAP(err, operation = db->InitializeL()); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- OpenDbThread: InitializeL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- OpenDbThread: ExecuteAndDeleteLD(InitializeL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + } + CleanupStack::PopAndDestroy(db); + + // Let other threads get access to the database + User::After(10000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + } + +// --------------------------------------------------------- +// CPosTp78::RunAddRemoveLmTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::RunAddRemoveLmTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + while (executionTime.Int() < KExectionTimeInMinutes) + { + RArray dbItems; + CleanupClosePushL(dbItems); + + // Remove all landmarks + CPosLmOperation* operation = NULL; + TRAPD(err, operation = db->RemoveAllLandmarksL()); + VerifyErrorL(_L("<-- AddRemoveThread: RemoveAllLandmarksL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, ExecuteAndDeleteLD(operation)); + VerifyErrorL(_L("<-- AddRemoveThread: ExecuteAndDeleteLD(RemoveAllLandmarksL()) left with %d -->"), err, aMessage); + } + + // Add some landmarks + const TInt KNrOfLms = 10; + TRAP(err, AddLandmarksL(KNrOfLms, _L("AddRemoveThread"), db, dbItems)); + VerifyErrorL(_L("<-- AddRemoveThread: AddLandmarksL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + // Remove some items one by one + for (TInt i = 0; i < KNrOfLms / 2; i++) + { + dbItems.Remove(0); + TRAP(err, db->RemoveLandmarkL(dbItems[0])); + VerifyErrorL(_L("<-- AddRemoveThread: RemoveLandmarkL(TPosLmItemId) left with %d -->"), err, aMessage); + } + + // Remove 5 items in one step + operation = NULL; + TRAPD(err, operation = db->RemoveLandmarksL(dbItems)); + VerifyErrorL(_L("<-- AddRemoveThread: RemoveLandmarksL(RArray) left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, ExecuteAndDeleteLD(operation)); + VerifyErrorL(_L("<-- AddRemoveThread: ExecuteAndDeleteLD(RemoveLandmarksL(dbItems)) left with %d -->"), err, aMessage); + } + dbItems.Reset(); + + CPosLandmarkDatabase::TSize dbSize; dbSize.iUsage = 0; + TRAP(err, dbSize = db->SizeL()); + VerifyErrorL(_L("<-- AddRemoveThread: SizeL() left with %d -->"), err, aMessage); + if (dbSize.iUsage < 0.9) + { + operation = NULL; + TRAP(err, operation = db->CompactL()); + VerifyErrorL(_L("<-- AddRemoveThread: CompactL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + CleanupStack::PushL(operation); + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- AddRemoveThread: ExecuteAndDeleteLD(CompactL()) left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(operation); + } + } + + HBufC* dbUri = NULL; + TRAP(err, CleanupStack::Pop(dbUri = db->DatabaseUriLC())); + CleanupStack::PushL(dbUri); + VerifyErrorL(_L("<-- AddRemoveThread: DatabaseUriLC() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(dbUri); + } + + dbItems.Reset(); + CleanupStack::PopAndDestroy(&dbItems); + + // Let other threads get access to the database + User::After(300000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// CPosTp78::RunImportExportLmTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::RunImportExportLmTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + while (executionTime.Int() < KExectionTimeInMinutes) + { +// Export landmarks + TBool exportSuccessful = EFalse; + CPosLmOperation* operation = NULL; + CPosLandmarkEncoder* encoder = NULL; + TRAPD(err, encoder = CPosLandmarkEncoder::NewL(KMimeType)); + VerifyErrorL(_L("<-- ImportExportThread: CPosLandmarkEncoder::NewL left with %d -->"), err, aMessage); + CleanupStack::PushL(encoder); + + // Use buffer as output + CBufBase* outputBuffer = NULL; + TRAP(err, outputBuffer = encoder->SetUseOutputBufferL()); + VerifyErrorL(_L("<-- ImportExportThread: SetUseOutputBufferL left with %d -->"), err, aMessage); + CleanupStack::PushL(outputBuffer); + + // Add collection data + TRAP(err, encoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("collection Name"))); + VerifyErrorL(_L("<-- ImportExportThread: AddCollectionDataL(Name) left with %d -->"), err, aMessage); + TRAP(err, encoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("collection Desc"))); + VerifyErrorL(_L("<-- ImportExportThread: AddCollectionDataL(Desc) left with %d -->"), err, aMessage); + + // Export landmarks + RArray lmIdArray; + CleanupClosePushL(lmIdArray); + TRAP(err, AddLandmarksL(5, _L("ImportExportThread"), db, lmIdArray)); + VerifyErrorL(_L("<-- ImportExportThread: AddLandmarksL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, operation = db->ExportLandmarksL(*encoder, lmIdArray, + CPosLandmarkDatabase::EIncludeCategories | CPosLandmarkDatabase::EIncludeGlobalCategoryNames)); + VerifyErrorL(_L("<-- ImportExportThread: ExportLandmarksL left with %d -->"), err, aMessage); + if (err == KErrNone) + { + CleanupStack::PushL(operation); + TRAP(err, ExecuteAndDeleteLD(operation)); + CleanupStack::Pop(operation); + VerifyErrorL(_L("<-- ImportExportThread: ExecuteAndDeleteLD(ExportLandmarksL) left with %d -->"), err, aMessage); + + // finalize encoding + operation = NULL; + TRAP(err, operation = encoder->FinalizeEncodingL()); + VerifyErrorL(_L("<-- ImportExportThread: FinalizeEncodingL left with %d -->"), err, aMessage); + if (err == KErrNone) + { + CleanupStack::PushL(operation); + TRAP(err, ExecuteAndDeleteLD(operation)); + CleanupStack::Pop(operation); + VerifyErrorL(_L("<-- ImportExportThread: ExecuteAndDeleteLD(FinalizeEncodingL) left with %d -->"), err, aMessage); + exportSuccessful = ETrue; + } + } + } + CleanupStack::PopAndDestroy(&lmIdArray); + +// Import landmarks + if (exportSuccessful) + { + CPosLandmarkParser* parser = NULL; + TRAP(err, parser = CPosLandmarkParser::NewL(KMimeType)); + CleanupStack::PushL(parser); + VerifyErrorL(_L("<-- ImportExportThread: CPosLandmarkParser::NewL left with %d -->"), err, aMessage); + + // Use buffer as input + TInt size = outputBuffer->Size(); + HBufC8* inputBuffer = HBufC8::New(size); + if (!inputBuffer) + { + aMessage->Copy(_L8("Unable to allocate inputBuffer. Error: KErrNoMemory")); + } + CleanupStack::PushL(inputBuffer); + TPtr8 inputBufferPtr = inputBuffer->Des(); + outputBuffer->Read(0, inputBufferPtr, size); + parser->SetInputBuffer(inputBufferPtr); + + // Import landmarks + operation = NULL; + TRAP(err, operation = db->ImportLandmarksL(*parser, + CPosLandmarkDatabase::EDefaultOptions)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- ImportExportThread: ImportLandmarksL left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- ImportExportThread: ExecuteAndDeleteLD(ImportLandmarksL) left with %d -->"), err, aMessage); + + CPosLmItemIterator* iterator = NULL; + TRAP(err, iterator = db->ImportedLandmarksIteratorL(operation)); + CleanupStack::PushL(iterator); + VerifyErrorL(_L("<-- ImportExportThread: ImportedLandmarksIteratorL() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(iterator); + } + CleanupStack::PopAndDestroy(operation); + CleanupStack::PopAndDestroy(inputBuffer); + CleanupStack::PopAndDestroy(parser); + } + CleanupStack::PopAndDestroy(outputBuffer); + CleanupStack::PopAndDestroy(encoder); + + // Let other threads get access to the database + User::After(100000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// CPosTp78::RunDbEventTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::RunDbEventTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + // Open db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + + while (executionTime.Int() < KExectionTimeInMinutes - 1) + { + TRequestStatus status; + TPosLmEvent event; + + // Listen for events for some time + db->NotifyDatabaseEvent(event, status); + User::After(100000); + + // Cancel listening + TInt err = db->CancelNotifyDatabaseEvent(); + VerifyErrorL(_L("<-- DbEventThread: CancelNotifyDatabaseEvent returned %d -->"), err, aMessage); + + // Start listening again + db->NotifyDatabaseEvent(event, status); + User::WaitForRequest(status); + VerifyErrorL(_L("<-- DbEventThread: NotifyDatabaseEvent returned %d -->"), status.Int(), aMessage); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// CPosTp78::UpdateLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::UpdateLandmarksL(CPosLandmarkDatabase* aDb, TPosLmItemId aId, TDes* aMessage) + { + //CPosLandmark* landmark = NULL; + CPosLandmark* landmark = aDb->ReadLandmarkLC(aId); + //VerifyErrorL(_L("<-- ReadAndUpdateThread: ReadLandmarkLC() left with %d -->"), err, aMessage); + + TRAPD(err, landmark->SetLandmarkNameL(_L("UpdatedName"))); + VerifyErrorL(_L("<-- ReadAndUpdateThread: SetLandmarkNameL() left with %d -->"), err, aMessage); + TRAP(err, aDb->UpdateLandmarkL(*landmark)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: UpdateLandmarkL() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(landmark); + } + +// --------------------------------------------------------- +// CPosTp78::RunReadAndUpdateTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp78::RunReadAndUpdateTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + // Open db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + + while (executionTime.Int() < KExectionTimeInMinutes) + { + RArray dbItems; + CleanupClosePushL(dbItems); + + const TInt KNrOfLms = 3; + TRAPD(err, AddLandmarksL(KNrOfLms, _L("ReadAndUpdateThread"), db, dbItems)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: AddLandmarksL() left with %d -->"), err, aMessage); + + if (err == KErrNone) + { + // Read and update + for (TInt i = 0; i < KNrOfLms; i++) + { + /* + CPosLandmark* landmark = NULL; + TRAP(err, landmark = db->ReadLandmarkLC(dbItems[i])); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ReadLandmarkLC() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + TRAP(err, landmark->SetLandmarkNameL(_L("UpdatedName"))); + VerifyErrorL(_L("<-- ReadAndUpdateThread: SetLandmarkNameL() left with %d -->"), err, aMessage); + TRAP(err, db->UpdateLandmarkL(*landmark)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: UpdateLandmarkL() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(landmark); + } + */ + + TRAPD(err, UpdateLandmarksL(db,dbItems[i], aMessage)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ReadLandmarkLC() left with %d -->"), err, aMessage); + } + + // Set partial read parameters + CPosLmPartialReadParameters* params = NULL; + TRAP(err, CleanupStack::Pop(params = db->PartialReadParametersLC())); + CleanupStack::PushL(params); + VerifyErrorL(_L("<-- ReadAndUpdateThread: PartialReadParametersLC() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + params->SetRequestedAttributes(CPosLandmark::EIcon | CPosLandmark::ECoverageRadius); + RArray posFields; + err = posFields.Append(EPositionFieldStreet); + params->SetRequestedPositionFields(posFields); + posFields.Close(); + VerifyErrorL(_L("<-- ReadAndUpdateThread: Append() returned %d -->"), err, aMessage); + TRAP(err, db->SetPartialReadParametersL(*params)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: SetPartialReadParametersL() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(params); + } + + // Read partial landmarks one by one + for (TInt j = 0; j < KNrOfLms; j++) + { + CPosLandmark* lm = NULL; + TRAP(err, CleanupStack::Pop(lm = db->ReadPartialLandmarkLC(dbItems[j]))); + CleanupStack::PushL(lm); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ReadPartialLandmarkLC() left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(lm); + } + + // Read several partial landmarks in one chunk + CPosLmOperation* operation = NULL; + TRAP(err, operation = db->PreparePartialLandmarksL(dbItems)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- ReadAndUpdateThread: PreparePartialLandmarksL() left with %d -->"), err, aMessage); + + if (err == KErrNone) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ExecuteAndDeleteLD(PreparePartialLandmarksL()) left with %d -->"), err, aMessage); + if (err == KErrNone) + { + CArrayPtr* landmarks = NULL; + TRAP(err, landmarks = db->TakePreparedPartialLandmarksL(operation)); + if (landmarks) + { + landmarks->ResetAndDestroy(); + delete landmarks; + } + VerifyErrorL(_L("<-- ReadAndUpdateThread: PreparePartialLandmarksL() left with %d -->"), err, aMessage); + } + } + CleanupStack::PopAndDestroy(operation); + } + CleanupStack::PopAndDestroy(&dbItems); + + // Let other threads get access to the database + User::After(110000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// CThreadMonitor::NewL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CThreadMonitor* CThreadMonitor::NewL(RThread* aThread) + { + CThreadMonitor* self = new (ELeave) CThreadMonitor(aThread); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// CThreadMonitor::ConstructL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::ConstructL() + { + iThread->Resume(); + iThread->Logon(iStatus); + SetActive(); + } + +// Constructor +CThreadMonitor::CThreadMonitor(RThread* aThread) +: CActive(CActive::EPriorityStandard), iThread(aThread) + { + CActiveScheduler::Add(this); + } + +// Destructor +CThreadMonitor::~CThreadMonitor() + { + Cancel(); + } + +// --------------------------------------------------------- +// CThreadMonitor::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::DoCancel() + { + iThread->LogonCancel(iStatus); + + // Kill thread + TRequestStatus status; + iThread->Logon(status); + iThread->Kill(KErrCancel); + User::WaitForRequest(status); + } + +// --------------------------------------------------------- +// CThreadMonitor::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CThreadMonitor::RunL() + { + CActiveScheduler::Stop(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp79.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp79.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp79.h" +#include "FT_CPosTp78.h" +#include +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KExectionTimeInMinutes = 60 * 10; // 10 hours + +// ================= LOCAL FUNCTIONS ======================= + +// --------------------------------------------------------- +// LOCAL_C ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + CActiveScheduler* actSch = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(actSch); + + TThreadParam* params = reinterpret_cast (aData); + TRAPD(err, (*params->iTestFunction)(params->iMessage)); + + delete actSch; + delete cleanup; + return err; + } + +LOCAL_C void AddCategoriesL( + TInt aNrOfLmsToAdd, + const TDesC& aName, + CPosLmCategoryManager* aCatMan, + RArray& aIdArray) + { + for (TInt i = 0; i < aNrOfLmsToAdd; i++) + { + CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); + HBufC* name = HBufC::NewLC(aName.Length() + 5); + TPtr namePtr = name->Des(); + namePtr.Format(aName, i); + category->SetCategoryNameL(namePtr); + category->SetIconL(_L("Icon"), 23, KPosLmIconMaskNotUsed); + TPosLmItemId id; + TRAPD(err, id = aCatMan->AddCategoryL(*category)); + if (err != KErrNone && err != KErrAlreadyExists) + { + User::Leave(err); + } + else + { + if (err == KErrAlreadyExists) + { + id = aCatMan->GetCategoryL(namePtr); + } + User::LeaveIfError(aIdArray.Append(id)); + } + CleanupStack::PopAndDestroy(2, category); + } + } + +LOCAL_C void VerifyErrorL(const TDesC& aFormat, TInt aErr, TDes* aMessage) + { + if (aErr != KErrNone && aErr != KErrLocked) + { + aMessage->Format(aFormat, aErr); + + // Append time + _LIT(KTimeFormat, " %F%Y-%M-%D at %H.%T:%S"); + TTime now; + now.HomeTime(); + TBuf<50> time; + now.FormatL(time, KTimeFormat); + aMessage->Append(time); + + User::Leave(aErr); + } + } + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp79::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::GetName(TDes& aName) const + { + _LIT(KTestName, "TP79 - Category and search duration tests"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp79::InitTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::InitTestL() + { + MakeSurePanicDebugFileExistsL(); + InitDbL(); + } + +// --------------------------------------------------------- +// CPosTp79::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::CloseTest() + { + } + +// --------------------------------------------------------- +// CPosTp79::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::StartL() + { +// Test Open database duration test + ResumeThreadsAndVerifyExitL(); + } + +// --------------------------------------------------------- +// CPosTp79::InitDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::InitDbL() + { + RemoveDefaultDbL(); + CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(database); + + if (database->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(database->InitializeL()); + } + + CleanupStack::PopAndDestroy(database); + + // Wait for LM server to die + User::After(2000000); + } + +// --------------------------------------------------------- +// CPosTp79::ResumeThreadsAndVerifyExitL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::ResumeThreadsAndVerifyExitL() + { + _LIT(KCreateThreadErr, "Creating thread failed with %d"); + TInt nrOfThreads = 0; + RThread searchThread, readAndUpdateThread, addRemoveCatsThread; + TThreadParam params1, params2, params3; + TBuf<200> threadMsg1, threadMsg2, threadMsg3; + + // Create search thread + _LIT(KSearch, "TP79 - Search duration thread"); + params1.iMessage = &threadMsg1; + params1.iTestFunction = RunSearchTestL; + TInt err = searchThread.Create(KSearch, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, ¶ms1); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(searchThread); + nrOfThreads++; + + // Create read and update thread + _LIT(KReadAndUpdateThread, "TP79 - Read and update categories duration thread"); + params2.iMessage = &threadMsg2; + params2.iTestFunction = RunReadAndUpdateTestL; + err = readAndUpdateThread.Create(KReadAndUpdateThread, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, ¶ms2); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(readAndUpdateThread); + nrOfThreads++; + + // Create add remove categories thread + _LIT(KAddRemoveCategories, "TP79 - Add remove categories duration thread"); + params3.iMessage = &threadMsg3; + params3.iTestFunction = RunAddRemoveCatsTestL; + err = addRemoveCatsThread.Create(KAddRemoveCategories, ThreadFunction, + KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, ¶ms3); + AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); + CleanupClosePushL(addRemoveCatsThread); + nrOfThreads++; + + // Start threads. + RThread* threads[] = {&searchThread, &readAndUpdateThread, &addRemoveCatsThread}; + RPointerArray threadMonitors; + for (TInt j = 0; j < nrOfThreads; j++) + { + threadMonitors.Append(CThreadMonitor::NewL(threads[j])); + } + + // Log time stamp + _LIT(KTimeFormat, "Threads started on %F%Y-%M-%D at %H.%T:%S"); + TTime now; + now.HomeTime(); + now.FormatL(iBuf, KTimeFormat); + iLog->Put(iBuf); + + // Wait until any of the threads exits. + TDes* messages[] = {&threadMsg1, &threadMsg2, &threadMsg3}; + TInt errors = KErrNone; + TBool allThreadsTerminated = EFalse; + while (!allThreadsTerminated && errors == KErrNone) + { + CActiveScheduler::Start(); + + // Assume all threads are terminated + allThreadsTerminated = ETrue; + for (TInt i = 0; i < nrOfThreads && errors == KErrNone; i++) + { + if (threadMonitors[i]->IsActive()) + { + // Thread is still alive + allThreadsTerminated = EFalse; + } + else + { + // Thread is terminated, check exit codes + if (*messages[i] != KNullDesC) + { + iLog->Put(*(messages[i])); + } + if (threads[i]->ExitType() != EExitKill) + { + iBuf.Format(_L("Thread %i was not killed!"), i); + iLog->PutError(iBuf); + TExitCategoryName category = threads[i]->ExitCategory(); + iBuf.Format(_L("Exit Category = %S %d"), &category, threads[i]->ExitReason()); + iLog->Put(iBuf); + errors = KErrGeneral; + } + else + { + TInt exitReason = threads[i]->ExitReason(); + if (exitReason != 0) + { + iBuf.Format(_L("Thread's exit reason wasn't 0 but %d."), exitReason); + iLog->PutError(iBuf); + errors = exitReason; + } + } + } + } + } + + // Terminate all remaining threads + threadMonitors.ResetAndDestroy(); + + // Log time stamp + _LIT(KTimeFormat2, "Threads terminated on %F%Y-%M-%D at %H.%T:%S"); + now.HomeTime(); + now.FormatL(iBuf, KTimeFormat2); + iLog->Put(iBuf); + + + User::LeaveIfError(errors); + + CleanupStack::PopAndDestroy(nrOfThreads, &searchThread); + } + +// --------------------------------------------------------- +// CPosTp79::RunSearchTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::RunSearchTestL(TDes* aMessage) + { + _LIT(KName, "SearchThread %d"); + + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + + while (executionTime.Int() < KExectionTimeInMinutes) + { + CPosLandmarkSearch* searcher = NULL; + TRAPD(err, searcher = CPosLandmarkSearch::NewL(*db)); + CleanupStack::PushL(searcher); + VerifyErrorL(_L("<-- SearchThread: CPosLandmarkSearch::NewL() left with %d -->"), err, aMessage); + + RArray dbItems; + CleanupClosePushL(dbItems); + + const TInt KNrOfCats = 3; + TRAP(err, AddCategoriesL(KNrOfCats, KName, catMan, dbItems)); + VerifyErrorL(_L("<-- SearchThread: AddCategoriesL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + // StartLandmarkSearchL + CPosLmTextCriteria* textCriteria = NULL; + TRAP(err, CleanupStack::Pop(textCriteria = CPosLmTextCriteria::NewLC())); + CleanupStack::PushL(textCriteria); + VerifyErrorL(_L("<-- SearchThread: CPosLmTextCriteria::NewLC() left with %d -->"), err, aMessage); + TRAP(err, textCriteria->SetTextL(KName().Left(5))); + VerifyErrorL(_L("<-- SearchThread: SetTextL() left with %d -->"), err, aMessage); + textCriteria->SetAttributesToSearch(CPosLandmark::EDescription & CPosLandmark::ELandmarkName); + TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + + CPosLmOperation* operation = NULL; + TRAPD(err, operation = searcher->StartLandmarkSearchL(*textCriteria, sortPref)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- SearchThread: StartLandmarkSearchL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- SearchThread: ExecuteLD(StartLandmarkSearchL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + + // StartCategorySearchL + CPosLmCatNameCriteria* nameCriteria = NULL; + TRAP(err, CleanupStack::Pop(nameCriteria = CPosLmCatNameCriteria::NewLC())); + CleanupStack::PushL(nameCriteria); + VerifyErrorL(_L("<-- SearchThread: CPosLmCatNameCriteria::NewLC() left with %d -->"), err, aMessage); + TRAP(err, nameCriteria->SetSearchPatternL(KName().Left(5))); + VerifyErrorL(_L("<-- SearchThread: SetSearchPatternL() left with %d -->"), err, aMessage); + operation = NULL; + TRAP(err, operation = searcher->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNameAscending)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- SearchThread: StartCategorySearchL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- SearchThread: ExecuteLD(StartCategorySearchL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(3, textCriteria); + } + + // Let other threads get access to the database + User::After(300000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + CleanupStack::PopAndDestroy(2, searcher); + } + + CleanupStack::PopAndDestroy(2, db); + } + +// --------------------------------------------------------- +// CPosTp79::RunAddRemoveCatsTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::RunAddRemoveCatsTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + // Open db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + + while (executionTime.Int() < KExectionTimeInMinutes) + { + CPosLmOperation* operation = NULL; + CPosLmCategoryManager* catMan = NULL; + TRAPD(err, catMan = CPosLmCategoryManager::NewL(*db)); + CleanupStack::PushL(catMan); + VerifyErrorL(_L("<-- AddRemoveCatsThread: CPosLmCategoryManager::NewL() left with %d -->"), err, aMessage); + + RArray dbItems; + CleanupClosePushL(dbItems); + + // RemoveCategoriesL / remove all categories + CPosLmItemIterator* iterator = NULL; + TRAP(err, iterator = catMan->CategoryIteratorL()); + CleanupStack::PushL(iterator); + VerifyErrorL(_L("<-- AddRemoveCatsThread: CategoryIteratorL() left with %d -->"), err, aMessage); + if (iterator) + { + TRAP(err, iterator->GetItemIdsL(dbItems, 0, iterator->NumOfItemsL())); + VerifyErrorL(_L("<-- AddRemoveCatsThread: GetItemIdsL() left with %d -->"), err, aMessage); + + if (err == KErrNone) + { + operation = NULL; + TRAP(err, operation = catMan->RemoveCategoriesL(dbItems)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- AddRemoveCatsThread: RemoveCategoriesL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- AddRemoveCatsThread: ExecuteLD(RemoveCategoriesL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + } + dbItems.Reset(); + } + CleanupStack::PopAndDestroy(iterator); + + // ResetGlobalCategoriesL + operation = NULL; + TRAP(err, operation = catMan->ResetGlobalCategoriesL()); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ResetGlobalCategoriesL() left with %d -->"), err, aMessage); + if (operation) + { + CleanupStack::PushL(operation); + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ExecuteLD(ResetGlobalCategoriesL()) left with %d -->"), err, aMessage); + CleanupStack::PopAndDestroy(operation); + } + + const TInt KNrOfCats = 3; + TRAP(err, AddCategoriesL(KNrOfCats, _L("AddRemoveCatsThread %d"), catMan, dbItems)); + VerifyErrorL(_L("<-- AddRemoveCatsThread: AddCategoriesL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + // AddCategoryToLandmarksL + operation = NULL; + TRAP(err, operation = catMan->AddCategoryToLandmarksL(dbItems[0], dbItems)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- AddRemoveCatsThread: AddCategoryToLandmarksL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- AddRemoveCatsThread: ExecuteLD(AddCategoryToLandmarksL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + + // RemoveCategoryFromLandmarksL + operation = NULL; + TRAP(err, operation = catMan->RemoveCategoryFromLandmarksL(dbItems[0], dbItems)); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- AddRemoveCatsThread: RemoveCategoryFromLandmarksL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- AddRemoveCatsThread: ExecuteLD(RemoveCategoryFromLandmarksL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + + // RemoveCategoryL + operation = NULL; + TRAP(err, operation = catMan->RemoveCategoryL(dbItems[0])); + CleanupStack::PushL(operation); + VerifyErrorL(_L("<-- AddRemoveCatsThread: RemoveCategoryL() left with %d -->"), err, aMessage); + if (operation) + { + TRAP(err, operation->ExecuteL()); + VerifyErrorL(_L("<-- AddRemoveCatsThread: ExecuteLD(RemoveCategoryL()) left with %d -->"), err, aMessage); + } + CleanupStack::PopAndDestroy(operation); + dbItems.Remove(0); + } + + // Let other threads get access to the database + User::After(300000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + CleanupStack::PopAndDestroy(2, catMan); + } + + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// CPosTp79::RunReadAndUpdateTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp79::RunReadAndUpdateTestL(TDes* aMessage) + { + // Execute thread for a number of hours + TTime startTime, stopTime; + startTime.HomeTime(); + stopTime.HomeTime(); + TTimeIntervalMinutes executionTime; + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + + // Open db + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(catMan); + + while (executionTime.Int() < KExectionTimeInMinutes) + { + RArray dbItems; + CleanupClosePushL(dbItems); + + const TInt KNrOfCats = 3; + TRAPD(err, AddCategoriesL(KNrOfCats, _L("ReadAndUpdateThread %d"), catMan, dbItems)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: AddCategoriesL() left with %d -->"), err, aMessage); + if (err == KErrNone) + { + // Read and update + for (TInt i = 0; i < KNrOfCats; i++) + { + CPosLandmarkCategory* category = NULL; + TRAP(err, CleanupStack::Pop(category = catMan->ReadCategoryLC(dbItems[i]))); + CleanupStack::PushL(category); + VerifyErrorL(_L("<-- ReadAndUpdateThread: ReadCategoryLC() left with %d -->"), err, aMessage); + if (category) + { + TPtrC namePtr; + err = category->GetCategoryName(namePtr); + VerifyErrorL(_L("<-- ReadAndUpdateThread: GetCategoryName() returned %d -->"), err, aMessage); + if (err == KErrNone) + { + TBuf name(namePtr); + name.Insert(0, name.Left(1)); + TRAP(err, category->SetCategoryNameL(name)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: SetCategoryNameL() left with %d -->"), err, aMessage); + TRAP(err, catMan->UpdateCategoryL(*category)); + if (err != KErrAlreadyExists) + { + VerifyErrorL(_L("<-- ReadAndUpdateThread: UpdateCategoryL() left with %d -->"), err, aMessage); + } + } + } + CleanupStack::PopAndDestroy(category); + } + + // GetCategoryL + if (err != KErrInUse) + { + TRAP(err, catMan->GetCategoryL(_L("RReadAndUpdateThread 3"))); + VerifyErrorL(_L("<-- ReadAndUpdateThread: GetCategoryL() left with %d -->"), err, aMessage); + } + } + CleanupStack::PopAndDestroy(&dbItems); + + // CategoryIteratorL + CPosLmItemIterator* iterator = NULL; + TRAP(err, iterator = catMan->CategoryIteratorL(CPosLmCategoryManager::ECategorySortOrderNameAscending)); + delete iterator; + VerifyErrorL(_L("<-- ReadAndUpdateThread: CategoryIteratorL() left with %d -->"), err, aMessage); + + // ReferencedCategoryIteratorL + iterator = NULL; + TRAP(err, iterator = catMan->ReferencedCategoryIteratorL(CPosLmCategoryManager::ECategorySortOrderNameDescending)); + delete iterator; + VerifyErrorL(_L("<-- ReadAndUpdateThread: ReferencedCategoryIteratorL() left with %d -->"), err, aMessage); + + // GetGlobalCategoryL + TRAP(err, catMan->GetGlobalCategoryL(3000)); + VerifyErrorL(_L("<-- ReadAndUpdateThread: GetGlobalCategoryL() left with %d -->"), err, aMessage); + + // GlobalCategoryNameL + HBufC* name = NULL; + TRAP(err, name = catMan->GlobalCategoryNameL(3000)); + delete name; + VerifyErrorL(_L("<-- ReadAndUpdateThread: GlobalCategoryNameL() left with %d -->"), err, aMessage); + + // Let other threads get access to the database + User::After(110000); + + stopTime.HomeTime(); + User::LeaveIfError(stopTime.MinutesFrom(startTime, executionTime)); + } + + CleanupStack::PopAndDestroy(2, db); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp8.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp8.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,897 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include "FT_CPosTp8.h" +#include +#include +#include +#include +#include "FT_LandmarkConstants.h" + +// CONSTANTS +const TInt KNoLandmarks = 100; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp8::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::CloseTest() + { + iLog->Log(_L("CloseTest")); + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + delete iDatabase; + iDatabase=NULL; + } + +// --------------------------------------------------------- +// CPosTp8::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::StartL() + { + _LIT(KLogFileName, "c:\\documents\\TP8TimeMeasurements.txt"); + + TTime start, stop, totalStart, totalStop; + totalStart.UniversalTime(); + start.UniversalTime(); + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + _LIT(KTestPath, "c:\\system\\test\\testdata\\"); + // copy the test db to the private path + CFileMan* fileMan = CFileMan::NewL(iFileSession); + CleanupStack::PushL(fileMan); + + TBuf<150> srcPath; + + srcPath.Append(KTestPath); + srcPath.Append(KTp8TestDb); + + TInt err = fileMan->Copy(srcPath, KLmTp8DefaultDbPath, + CFileMan::EOverWrite); + if (err != KErrNone) + iLog->Log(_L("Error when copying file")); + + CleanupStack::PopAndDestroy(fileMan); + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + + // This db must exist + manager->SetDefaultDatabaseUriL(KTp8TestDb); + CleanupStack::PopAndDestroy(manager); + + start.UniversalTime(); + iDatabase= CPosLandmarkDatabase::OpenL(KTp8TestDb); + stop.UniversalTime(); + + TInt64 msec = (stop.Int64() - start.Int64())/1000; + TBuf8 msg; + _LIT8(KTrace, "Opening (creating) an empty database = %d msec"); + msg.Format(KTrace, msec); + LogToFileL(KLogFileName, msg); + + if (iDatabase->IsInitializingNeeded()) + { + start.UniversalTime(); + ExecuteAndDeleteLD(iDatabase->InitializeL()); + + stop.UniversalTime(); + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace2, "Initializing an empty database = %d msec"); + msg.Format(KTrace2, msec); + LogToFileL(KLogFileName, msg); + } + +// Add landmarks + start.UniversalTime(); + AddLandmarksL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace3, "AddLandmarksL = %d msec"); + msg.Format(KTrace3, msec); + LogToFileL(KLogFileName, msg); + + delete iDatabase; + iDatabase=NULL; + iDatabase = BackupTp8DbFileL(); + +if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + +// Read landmarks + start.UniversalTime(); + ReadLandmarksL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace4, "ReadLandmarksL = %d msec"); + msg.Format(KTrace4, msec); + LogToFileL(KLogFileName, msg); + +// Update landmarks + start.UniversalTime(); + UpdateLandmarksL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace5, "UpdateLandmarksL = %d msec"); + msg.Format(KTrace5, msec); + LogToFileL(KLogFileName, msg); + + ReadLandmarksL(iDatabase); + +// Remove landmarks one by one + start.UniversalTime(); + RemoveLandmarksL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace6, "RemoveLandmarksL = %d msec"); + msg.Format(KTrace6, msec); + LogToFileL(KLogFileName, msg); + + // Restore database + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + +// Remove set of landmarks synchronously + start.UniversalTime(); + RemoveSetOfLandmarksL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace7, "RemoveSetOfLandmarksL = %d msec"); + msg.Format(KTrace7, msec); + LogToFileL(KLogFileName, msg); + + // Restore database + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + +// Remove set of landmarks and remove all landmarks asynchronously + start.UniversalTime(); + RemoveLandmarksAsyncL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace8, "RemoveLandmarksAsyncL = %d msec"); + msg.Format(KTrace8, msec); + LogToFileL(KLogFileName, msg); + + // Restore database + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + +// Remove set of landmarks and remove all landmarks with User::WaitForRequest() + start.UniversalTime(); + RemoveLandmarksAsyncWithWaitForReqL(iDatabase); + stop.UniversalTime(); + + msec = (stop.Int64() - start.Int64())/1000; + _LIT8(KTrace9, "RemoveLandmarksAsyncWithWaitForReqL = %d msec"); + msg.Format(KTrace9, msec); + LogToFileL(KLogFileName, msg); + + // Restore database + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + +// Remove set of landmarks asynchronously and cancel + iLog->Log(_L("TESTS BELOW ARE TESTING CANCEL")); + RemoveLandmarksAsyncAndCancelL(); + + // Check maximum length of Landmarkname + CheckLandmarkNameMaxLengthL(); + + totalStop.UniversalTime(); + msec = (totalStop.Int64() - totalStart.Int64())/1000; + _LIT8(KTrace10, "Complete test case = %d msec"); + msg.Format(KTrace10, msec); + LogToFileL(KLogFileName, msg); + } + +// --------------------------------------------------------- +// CPosTp8::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::AddLandmarksL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Adding and copying landmarks")); + + _LIT(KCategoryAddedErr, "A category that doesn't exist in the database should not be added to the landmark"); + _LIT(KLmName, "LmTP8 - %d"); + _LIT(KLmDescription, "LmTP8Description - %d"); + + iLandmarks.ResetAndDestroy(); + for (TInt i=0; i<(KNoLandmarks/4); i++) + { + TBuf<100> lmName; + TBuf<100> lmDesc; + lmName.Format(KLmName,i); + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + lmDesc.Format(KLmDescription,i); + landmark->SetLandmarkDescriptionL(lmDesc); + + CPosLandmark* copy = CPosLandmark::NewLC(*landmark); + + CPosLandmark* landmark2 = CPosLandmark::NewL(); + CleanupStack::PushL(landmark2); + landmark2->SetLandmarkNameL(lmName); + landmark2->SetLandmarkDescriptionL(lmDesc); + + CPosLandmark* copy2 = CPosLandmark::NewL(*landmark2); + CleanupStack::PushL(copy2); + TInt err = KErrLocked; + + ExecuteAndDeleteLD(aDatabase->CompactL()); + + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*landmark)); + } + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*copy)); + } + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*landmark2)); + } + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*copy2)); + } + + TPosLmItemId id2 = 5123321; + CPosLandmark* landmark3 = CPosLandmark::NewLC(); + landmark3->AddCategoryL(id2); + landmark3->AddCategoryL(id2); + + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*landmark3)); // CR115 this should not fail any more + } + + CPosLandmark* readLm3 = aDatabase->ReadLandmarkLC(landmark3->LandmarkId()); + + RArray catIds; + CleanupClosePushL(catIds); + readLm3->GetCategoriesL(catIds); + AssertTrueSecL(catIds.Count() == 0, KCategoryAddedErr); + CleanupStack::PopAndDestroy(3, landmark3); + + iLandmarks.Append(landmark); + iLandmarks.Append(copy); + iLandmarks.Append(landmark2); + iLandmarks.Append(copy2); + + CleanupStack::Pop(4, landmark); + } + } + +// --------------------------------------------------------- +// CPosTp8::ReadLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::ReadLandmarksL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Reading landmarks")); + + _LIT(KReadNotFoundErr, "The landmark id doesn't exist so ReadLandmark should return not found"); + TBuf<100> buf; + buf.Format(_L("Reading %d nr of landmarks from id %d to id %d"), iLandmarks.Count(), + iLandmarks[0]->LandmarkId(), iLandmarks[iLandmarks.Count()-1]->LandmarkId()); + iLog->Log(buf); + for (TInt i = 0; iReadLandmarkLC(iLandmarks[i]->LandmarkId()); + CompareLandmarksL(*iLandmarks[i], *lm); + CleanupStack::PopAndDestroy(); // lm + } + + TPosLmItemId id = 5123321; + CPosLandmark* lm=NULL; + TRAPD(err, lm=aDatabase->ReadLandmarkLC(id)); + delete lm; + lm = NULL; + AssertTrueSecL(err == KErrNotFound, KReadNotFoundErr); + + id = 13434; + lm=NULL; + TRAP(err, lm=aDatabase->ReadLandmarkLC(id)); + delete lm; + AssertTrueSecL(err == KErrNotFound, KReadNotFoundErr); + + id = 0; + lm=NULL; + TRAP(err, lm=aDatabase->ReadLandmarkLC(id)); + delete lm; + AssertTrueSecL(err == KErrNotFound, KReadNotFoundErr); + + } + + +// --------------------------------------------------------- +// CPosTp8::UpdateLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::UpdateLandmarksL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Updating landmarks")); + _LIT(KCategoryName, "UpdatedCategory %d"); + _LIT(KCategoryName2, "UpdatedCategory2:%d:%d"); + _LIT(KCategoryAddedErr, "A category that doesn't exist in the database should not be added to the landmark"); + + for (TInt i = 0; iSetLandmarkNameL(KName2); + break; + case 1: + iLandmarks[i]->SetPositionL(loc); + break; + case 2: + iLandmarks[i]->SetIconL(KMbmFileName2, KIconIndex2, KPosLmIconMaskNotUsed); + break; + case 3: + iLandmarks[i]->SetLandmarkDescriptionL(KDescription2); + break; + case 4: + iLandmarks[i]->SetCoverageRadius(KCoverageRadius); + break; + case 5: + AddFields2L(iLandmarks[i]); + break; + case 6: + for(j=0; j name; + name.Format(KCategoryName, j); + iLandmarks[i]->AddCategoryL(CreateCategoryL(name)); + } + break; + case 8: + AddFields3L(iLandmarks[i]); + break; + case 9: + break; + default: + iLandmarks[i]->SetLandmarkNameL(KName2); + iLandmarks[i]->SetPositionL(loc); + iLandmarks[i]->SetIconL(KMbmFileName2, KIconIndex2, KPosLmIconMaskNotUsed); + iLandmarks[i]->SetLandmarkDescriptionL(KDescription2); + iLandmarks[i]->SetCoverageRadius(KCoverageRadius); + AddFields2L(iLandmarks[i]); + + for(j=0; j name; + name.Format(KCategoryName2, j, i); + iLandmarks[i]->AddCategoryL(CreateCategoryL(name)); + } + break; + } + } + TInt err = KErrLocked; + for (TInt k = 0; kUpdateLandmarkL(*iLandmarks[k])); + } + } + + ExecuteAndDeleteLD(aDatabase->CompactL()); + + _LIT(KTemp, "temp"); + TPosLmItemId id2 = 8787876; + CPosLandmark* landmark = CreateLandmarkLC(KTemp); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->AddLandmarkL(*landmark)); + } + + landmark->AddCategoryL(id2); + + // 0 is equal to KPosLmNullItemId, should leave + id2 = 0; + TRAP(err, landmark->AddCategoryL(id2)); + AssertTrueSecL(err == KErrArgument, _L("AddCategory(0) should leave with KErrArgument")); + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->UpdateLandmarkL(*landmark)); // CR115 this should not fail any more + } + + // Make sure category not added to lm (TR ESLI-5X7FTZ) + CPosLandmark* readLm = aDatabase->ReadLandmarkLC(landmark->LandmarkId()); + RArray catIds; + CleanupClosePushL(catIds); + readLm->GetCategoriesL(catIds); + AssertTrueSecL(catIds.Count() == 3, KCategoryAddedErr); + + aDatabase->RemoveLandmarkL(landmark->LandmarkId()); + + CleanupStack::PopAndDestroy(3, landmark); + } + +// --------------------------------------------------------- +// CPosTp8::RemoveLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::RemoveLandmarksL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Removing landmarks")); + ExecuteAndDeleteLD(aDatabase->CompactL()); + const TInt start=9; + const TInt end=55; + + // First check invalid landmark ids, nothing should happen + CheckRemovedL(iLandmarks.Count(), iLandmarks.Count()); + TPosLmItemId id = 5123321; + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->RemoveLandmarkL(id)); + } + + id = 11233; + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->RemoveLandmarkL(id)); + } + id = 0; + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->RemoveLandmarkL(id)); + } + + CheckRemovedL(iLandmarks.Count(), iLandmarks.Count()); + + for (TInt i = start; i<=end; i++) + { + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->RemoveLandmarkL(iLandmarks[i]->LandmarkId())); + } + } + CheckRemovedL(start, end); + for (TInt j = start; j<=end; j++) + { + err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, aDatabase->RemoveLandmarkL(iLandmarks[j]->LandmarkId())); // nothing should happen + } + } + + CheckRemovedL(start, end); + + iLog->Log(_L("Removing all landmarks")); + ExecuteAndDeleteLD(aDatabase->CompactL()); + ExecuteAndDeleteLD(aDatabase->RemoveAllLandmarksL()); + + CheckRemovedL(0, iLandmarks.Count()-1); + + ExecuteAndDeleteLD(aDatabase->RemoveAllLandmarksL()); + + CheckRemovedL(0, iLandmarks.Count()-1); + + } + +// --------------------------------------------------------- +// CPosTp8::RemoveLandmarksAsyncL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::RemoveLandmarksAsyncL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Removing landmarks asynchronously")); + + // Remove a set of landmarks async + const TInt start=3; + const TInt end=47; + + RArray ids; + CleanupClosePushL(ids); + + for(TInt i=start; i<=end; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + + RunAsyncOperationLD(aDatabase->RemoveLandmarksL(ids)); + CleanupStack::PopAndDestroy(&ids); + + CheckRemovedL(start, end); + + // Remove all async + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L("Removing all landmarks asynchronously")); + + RunAsyncOperationLD(iDatabase->RemoveAllLandmarksL()); + + CheckRemovedL(0, iLandmarks.Count()-1); + } + +// --------------------------------------------------------- +// CPosTp8::RemoveLandmarksAsyncWithWaitForReqL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::RemoveLandmarksAsyncWithWaitForReqL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Removing landmarks asynchronously with User::WaitForRequest")); + + // Remove a set of landmarks async with WaitForReq + const TInt start=3; + const TInt end=47; + + RArray ids; + CleanupClosePushL(ids); + + for(TInt i=start; i<=end; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + + CPosLmOperation* op = aDatabase->RemoveLandmarksL(ids); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(op); + + CheckRemovedL(start, end); + + // Remove all async with WaitForReq + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + + + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + iLog->Log(_L("Removing all landmarks asynchronously with User::WaitForRequest")); + TRAPD(error,op = iDatabase->RemoveAllLandmarksL()); + iLog->Log(_L("error while RemoveAllLandmarksL = %d"),error); + CleanupStack::PushL(op); + RunAsyncOperationByWaitForReqL(op); + CleanupStack::PopAndDestroy(2, &ids); + + CheckRemovedL(0, iLandmarks.Count()-1); + } + +// --------------------------------------------------------- +// CPosTp8::RemoveLandmarksAsyncAndCancelL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::RemoveLandmarksAsyncAndCancelL() + { + iLog->Log(_L("Removing landmarks asynchronously and cancel")); + + // Remove a set of landmarks async + const TInt start=3; + const TInt end=47; + + RArray ids; + CleanupClosePushL(ids); + + for(TInt i=start; i<=end; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + } + + TReal32 progress(0); + while (progress < 1.0) + { + RunAsyncOperationAndCancelInCallbackLD(iDatabase->RemoveLandmarksL(ids), progress); + + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + progress = progress + 0.09; + } + CleanupStack::PopAndDestroy(&ids); + + iLog->Log(_L("Removing all landmarks asynchronously and cancel")); + + progress = 0; + while (progress < 1.0) + { + RunAsyncOperationAndCancelInCallbackLD(iDatabase->RemoveAllLandmarksL(), progress); + + delete iDatabase; + iDatabase=NULL; + iDatabase=RestoreTp8DbFileL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + progress = progress + 0.09; + } + } + +// --------------------------------------------------------- +// CPosTp8::RemoveSetOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::RemoveSetOfLandmarksL(CPosLandmarkDatabase* aDatabase) + { + iLog->Log(_L("Removing set of landmarks")); + + const TInt start=3; + const TInt end=57; + + RArray ids; + CleanupClosePushL(ids); + + // Test with empty list, should leave with KErrArgument + TRAPD(err, iOperation = aDatabase->RemoveLandmarksL(ids)); + if (err != KErrArgument) + { + iLog->Log(_L("Removing empty iterator should leave with KErrArgument")); + User::Leave(err); + + } + + #if 0 + // Added for testing -- Start + iOperation->ExecuteL(); + // Added for testing -- End + + delete iOperation; + iOperation = NULL; + #endif + + // Test with invalid sets of lm id arrays + ids.Append(11234); + ids.Append(556); + ids.Append(908); + + ExecuteAndDeleteLD(aDatabase->RemoveLandmarksL(ids)); + + // Check that no landmark has been removed + CheckRemovedL(iLandmarks.Count(), iLandmarks.Count()); + + for(TInt i=start; i<=end; i++) + { + ids.Append(iLandmarks[i]->LandmarkId()); + // Also add invalid ids + ids.Append(i+5000); + } + + ExecuteAndDeleteLD(aDatabase->RemoveLandmarksL(ids)); + + CheckRemovedL(start, end); + + ExecuteAndDeleteLD(aDatabase->RemoveLandmarksL(ids)); + + CleanupStack::PopAndDestroy(&ids); + + CheckRemovedL(start, end); + } + +// --------------------------------------------------------- +// CPosTp8::CheckRemoved +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::CheckRemovedL(const TInt startIndex, const TInt stopIndex) + { + _LIT(KRemoveNotFoundErr, "Landmark has not been removed"); + _LIT(KRemoveFoundErr, "Landmark should not been removed"); + + for (TInt i = 0; iLandmarkId())); + if (i >= startIndex && i <= stopIndex) + { + AssertTrueSecL(err == KErrNotFound, KRemoveNotFoundErr); + } + else + { + AssertTrueSecL(err == KErrNone, KRemoveFoundErr); + } + } + } + +// --------------------------------------------------------- +// CPosTp8::ReadLandmarkL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::ReadLandmarkL(TPosLmItemId aCategoryId) + { + CPosLandmark* lm = iDatabase->ReadLandmarkLC(aCategoryId); + CleanupStack::PopAndDestroy(lm); + } + +//--------------------------------------------------------- +// CPosTp8::CheckLandmarkNameMaxLengthL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp8::CheckLandmarkNameMaxLengthL() + { + _LIT(K255Error, "Landmark name is not limited to 255 characters"); + + iLog->Log(_L("CheckLandmarkNameMaxLengthL")); + + const TInt KPosLmMaxTextFieldLength = 255; + + HBufC* hbuf = HBufC::NewLC(KPosLmMaxTextFieldLength+1); + + CPosLandmark* lm = CPosLandmark::NewLC(); + // Test empty name, is OK + lm->SetLandmarkNameL(*hbuf); + + while(hbuf->Des().Length() < KPosLmMaxTextFieldLength) + { + hbuf->Des().Append(_L("X")); + } + + lm->SetLandmarkNameL(*hbuf); + + hbuf->Des().Append(_L("X")); + + TRAPD(err, lm->SetLandmarkNameL(*hbuf)); + AssertTrueSecL(err == KErrArgument, K255Error); + + CleanupStack::PopAndDestroy(2, hbuf); + } + +// --------------------------------------------------------- +// CPosTp8::BackupTp8DbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp8::BackupTp8DbFileL() + { + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + manager->SetDefaultDatabaseUriL(KTp8TestDb); + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(buf)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(*defaultDbUri, buf); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// --------------------------------------------------------- +// CPosTp8::RestoreTp8DbFileL() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmarkDatabase* CPosTp8::RestoreTp8DbFileL() + { + + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + manager->SetDefaultDatabaseUriL(KTp8TestDb); + HBufC* defaultDbUri = manager->DefaultDatabaseUriLC(); + TBuf<255> buf; + // Extract URI except characters ".ldb" + buf.Append(defaultDbUri->Left(defaultDbUri->Length()-4)); + buf.Append(_L("COPY.LDB")); + // Delete in case it already exist + TRAPD(err, manager->DeleteDatabaseL(*defaultDbUri)); + if (err != KErrNone && err != KErrNotFound) iLog->Log(_L("Could not delete file")); + manager->CopyDatabaseL(buf, *defaultDbUri); + + CleanupStack::PopAndDestroy(defaultDbUri); + CleanupStack::PopAndDestroy(manager); + return CPosLandmarkDatabase::OpenL(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp80.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp80.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp80.h" +#include "FT_LandmarkConstants.h" +#include +#include + +// ================= CONSTANTS======================= +_LIT(KLongFileName, "01234567890123456789012345678901234567890123456789012345678901234567890123456789_COMPOSITEEPOSLM.LDB"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp80::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp80::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp80 - Landmarks DB Long File Name"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp80::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp80::CloseTest() + { + iLog->Put(_L("CloseTest")); + + TRAPD(err, DeleteTestDbL()); + if (err != KErrNone) iLog->Put(_L("Error when DeleteTestDbL")); + + TRAP(err, RemoveAllLmDatabasesL()); + if (err != KErrNone) iLog->Put(_L("Error when RemoveAllLmDatabasesL")); + } + +// --------------------------------------------------------- +// CPosTp80::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp80::StartL() + { + // Init test part + iLog->Put(_L("DeleteTestDbL")); + DeleteTestDbL(); + iLog->Put(_L("RemoveAllLmDatabasesL")); + RemoveAllLmDatabasesL(); + + iLog->Put(_L("CopyTestDbFileL(KLongFileName)")); + CopyTestDbFileL(KLongFileName); + iLog->Put(_L("After CopyTestDbFileL(KLongFileName)")); + + CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); + CleanupStack::PushL(manager); + // Hangs here + iLog->Put(_L("Before DatabaseExistsL")); + TBool exist = manager->DatabaseExistsL(KLongFileName); + iLog->Put(_L("After DatabaseExistsL")); + + // if it exists, try to open it + if (exist) + { + CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KLongFileName); + CleanupStack::PushL(lmd); + CleanupStack::PopAndDestroy(lmd); + } + else iLog->Put(_L("DatabaseExistsL correctly returns EFalse")); + + CleanupStack::PopAndDestroy(manager); + } + +// --------------------------------------------------------- +// CPosTp80::DeleteTestDbL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp80::DeleteTestDbL() + { + iLog->Put(_L("DeleteTestDbL")); + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + CFileMan* fileMan = CFileMan::NewL(fs); + CleanupStack::PushL(fileMan); + + TBuf<150> path; + + path.Append(KLmDbPath); + path.Append(KLongFileName); + + TInt err = fileMan->Delete(path); + if (err != KErrNone) + { + TBuf<100> buf; + buf.Format(_L("Error %d when deleting file"), err); + iLog->Put(buf); + } + + CleanupStack::PopAndDestroy(2, &fs); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp81.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp81.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,220 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp81.h" +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp81::GetName +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp81::GetName(TDes& aName) const + { + _LIT(KTestName, "Tp81 - category with apostrophe in name (SBUY-6A9A5B)"); + aName = KTestName; + } + +// --------------------------------------------------------- +// CPosTp81::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp81::StartL() + { + _LIT(KCategoryName, "Category with apostrophe'"); + _LIT(KCategoryName2, "Category with apostrophe(')"); + + RemoveAllLmDatabasesL(); + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + if (db->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(db->InitializeL()); // Synchronous since no argument + } + + CPosLmCategoryManager* manager = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(manager); + + // Test with only apostrophe + CPosLandmarkCategory* cat = CPosLandmarkCategory::NewL(); + CleanupStack::PushL(cat); + iLog->Put(_L("Set name with apostrophe")); + cat->SetCategoryNameL(KCategoryName); + iLog->Put(_L("AddCategory with apostrophe in name")); + TPosLmItemId id = manager->AddCategoryL(*cat); + User::After(200000); + iLog->Put(_L("AddCategory was succesful")); + CleanupStack::PopAndDestroy(cat); + + CPosLandmarkCategory* category = manager->ReadCategoryLC(id); + TPtrC catName; + category->GetCategoryName(catName); + iLog->Put(catName); + if (catName.CompareC(KCategoryName) != KErrNone) iLog->Put(_L("ERROR: Names are not equal")); + CleanupStack::PopAndDestroy(category); + CleanupStack::PopAndDestroy(manager); + + // Test with apostrophe and paranthesis + manager = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(manager); + + cat = CPosLandmarkCategory::NewL(); + CleanupStack::PushL(cat); + iLog->Put(_L("Set name with apostrophe")); + cat->SetCategoryNameL(KCategoryName2); + iLog->Put(_L("AddCategory with apostrophe and paranthesis in name")); + id = manager->AddCategoryL(*cat); + User::After(200000); + iLog->Put(_L("AddCategory was succesful")); + CleanupStack::PopAndDestroy(cat); + + category = manager->ReadCategoryLC(id); + category->GetCategoryName(catName); + iLog->Put(catName); + if (catName.CompareC(KCategoryName2) != KErrNone) iLog->Put(_L("ERROR: Names are not equal (2)")); + CleanupStack::PopAndDestroy(category); + + ExecuteAndDeleteLD(db->CompactL()); + + CleanupStack::PopAndDestroy(manager); + CleanupStack::PopAndDestroy(db); + + TestDifferentNamesL(); + + } +// --------------------------------------------------------- +// CPosTp81::TestDifferentNamesL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp81::TestDifferentNamesL() + { + iLog->Put(_L("TestDifferentNamesL")); + //////////////////////////////////////////////////////////// + _LIT(KCategory1, "file://:://c:::en helt \" sjuk .ldb databas\".ldb.ldb.ldb"); + _LIT(KCategory2, "file://c:en helt sjuk databas.ldb"); + _LIT(KCategory3, "le:///c:en helt sjuk databas.ldb"); + _LIT(KCategory4, "/c::en helt sjuk databas.ldb"); + _LIT(KCategory5, "en helt sjuk .ldb databas.ldb"); + _LIT(KCategory6, "en helt sjuk databas.ldb.ldb.ldb"); + _LIT(KCategory7, "en helt \" sjuk databas.ldb"); + _LIT(KCategory8, "en helt < sjuk databas.ldb"); + _LIT(KCategory9, "en helt > sjuk databas.ldb"); + _LIT(KCategory10, "en helt | sjuk databas.ldb"); + _LIT(KCategory11, "en helt / sjuk databas.ldb"); + _LIT(KCategory12, "en helt ? sjuk databas.ldb"); + _LIT(KCategory13, "en helt \\ sjuk databas.ldb"); + _LIT(KCategory14, "en helt : sjuk databas.ldb"); + _LIT(KCategory15, ":!#¤%&()=+`´^¨~'§½-_,;.{}[]$£@0123456789åäöÅÄÖ.ldb"); + _LIT(KCategory16, "file://c:qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM.ldb"); + _LIT(KCategory17, "file://en otroligt helt sjuk databas.ldb"); + _LIT(KCategory18, "c:en helsjuk databas.ldb"); + _LIT(KCategory19, "file://c:\\system\\data\\en helt sjuk databas.ldb"); + _LIT(KCategory20, "file://c:.ldb"); + _LIT(KCategory21, "file://c:filename"); + _LIT(KCategory22, "file://c:filename.dip"); + _LIT(KCategory23, "file://c:filename. ldb"); + _LIT(KCategory24, "file://c:*.ldb"); + _LIT(KCategory25, "file://allan:en helt sjuk databas.ldb"); + _LIT(KCategory26, "file://g:en helt sjuk databas.ldb"); + _LIT(KCategory27, "file://c:filename.ldb"); + _LIT(KCategory28, "file://c:012345678901234567890123456789012345678901234567890123456789.ldb"); + + const TInt KNrOfUris = 28; + const TDesC* listOfCategories[] = {&KCategory1, &KCategory2, &KCategory3 ,&KCategory4, &KCategory5, &KCategory6, + &KCategory7, &KCategory8, &KCategory9 + , &KCategory10, &KCategory11, &KCategory12, &KCategory13, &KCategory14, &KCategory15 + , &KCategory16, &KCategory17, &KCategory18, &KCategory19, &KCategory20, &KCategory21 + , &KCategory22, &KCategory23, &KCategory24, &KCategory25, &KCategory26, &KCategory27, &KCategory28}; + +/* + const TInt KNrOfNonWorkingUris = 19; + const TDesC* listOfUrisNonWorking[] = {&KCategory1, &KCategory3 ,&KCategory4, &KCategory7, &KCategory8, &KCategory9 + , &KCategory10, &KCategory11, &KCategory12, &KCategory13, &KCategory14, &KCategory19, &KCategory20, &KCategory21 + , &KCategory22, &KCategory23, &KCategory24, &KCategory25, &KCategory26}; + + TInt errorList[] = {KErrBadName, KErrBadName, KErrBadName, KErrBadName, KErrBadName ,KErrBadName,KErrBadName, + KErrBadName, KErrBadName, KErrArgument, KErrBadName, KErrArgument, KErrArgument, + KErrArgument, KErrArgument,KErrArgument, KErrBadName, KErrBadName, KErrNotReady}; + */ + ////////////////////////////////////////////////// + + CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); + CleanupStack::PushL(db); + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*db); + CleanupStack::PushL(categoryManager); + + TBuf<100> buf; + + for (TInt i=0;iPut(_L("Set name to:")); + iLog->Put(*listOfCategories[i]); + TRAPD(err, cat->SetCategoryNameL(*listOfCategories[i])); + if (err == KErrNone) + { + iLog->Put(_L("AddCategory")); + TPosLmItemId id = -1; + TRAPD(err2, id = categoryManager->AddCategoryL(*cat)); + User::After(200000); + if (err2 != KErrNone) + { + buf.Format(_L("Error %d from AddCategoryL"), err2); + LogErrorAndLeave(buf); + } + else + { + buf.Format(_L("Checking landmark with id %d"), id); + iLog->Put(buf); + + CPosLandmarkCategory* category = categoryManager->ReadCategoryLC(id); + User::After(200000); + TPtrC catName; + category->GetCategoryName(catName); + iLog->Put(catName); + if (catName.CompareC(*listOfCategories[i]) != KErrNone) iLog->Put(_L("ERROR: Names are not equal")); + CleanupStack::PopAndDestroy(category); + } + } + else + { + buf.Format(_L("Error %d from SetCategoryNameL"), err); + LogErrorAndLeave(buf); + } + CleanupStack::PopAndDestroy(cat); + ExecuteAndDeleteLD(db->CompactL()); + } + + CleanupStack::PopAndDestroy(categoryManager); + CleanupStack::PopAndDestroy(db); + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp9.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp9.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,291 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES + +#include "FT_CPosTp9.h" +#include +#include +#include +#include +#include // RDebug + +// CONSTANTS +const TInt KNoLandmarks = 50; +_LIT(KIteratorNumOfItemsErr, "The iterator returns incorrect number of items"); +_LIT(KIteratorIdErr, "A landmarks id not in the database returned from the iterator"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosTp9::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::StartL() + { + + RemoveDefaultDbL(); + RemoveAllLmDatabasesL(); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + ExecuteAndDeleteLD(iDatabase->CompactL()); + AddLandmarksL(); + IterateLandmarksL(); + IterateSetOfLandmarksL(); + IterateSortedLandmarksL(); + } + +// --------------------------------------------------------- +// CPosTp9::CloseTestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::CloseTest() + { + iLandmarks.ResetAndDestroy(); + iLandmarks.Close(); + delete iDatabase; + iDatabase = NULL; + } + +// --------------------------------------------------------- +// CPosTp9::AddLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::AddLandmarksL() + { + iLog->Log(_L("AddLandmarksL")); + _LIT(KLmName, "LmTP9 - %d"); + _LIT(KLmDescription, "LmTP9Description - %d"); + + for (TInt i=0; i<(KNoLandmarks); i++) + { + TBuf<100> lmName; + lmName.Format(KLmName,i); + TBuf<100> lmDesc; + lmDesc.Format(KLmDescription,i); + + CPosLandmark* landmark = CPosLandmark::NewLC(); + landmark->SetLandmarkNameL(lmName); + landmark->SetLandmarkDescriptionL(lmDesc); + TInt err = KErrLocked; + while (err == KErrLocked) + { + TRAP(err, iDatabase->AddLandmarkL(*landmark)); + } + + iLandmarks.Append(landmark); + + CleanupStack::Pop(landmark); + } + } + +// --------------------------------------------------------- +// CPosTp9::IterateLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::IterateLandmarksL() + { + iLog->Log(_L("IterateLandmarksL")); + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + TPosLmItemId id = iter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* source = InternalGet(id); + AssertTrueSecL(source != NULL, KIteratorIdErr); + + CPosLandmark* target = iDatabase->ReadLandmarkLC(id); + CompareLandmarksL(*source, *target); + CleanupStack::PopAndDestroy(); // target + + id = iter->NextL(); + } + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)iLandmarks.Count(), KIteratorNumOfItemsErr); + + iter->Reset(); + id = iter->NextL(); + while (id != KPosLmNullItemId) + { + CPosLandmark* source = InternalGet(id); + AssertTrueSecL(source != NULL, KIteratorIdErr); + + CPosLandmark* target = iDatabase->ReadLandmarkLC(id); + CompareLandmarksL(*source, *target); + CleanupStack::PopAndDestroy(); // target + + id = iter->NextL(); + } + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)iLandmarks.Count(), KIteratorNumOfItemsErr); + + CleanupStack::PopAndDestroy(iter); + } + +// --------------------------------------------------------- +// CPosTp9::IterateSetOfLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::IterateSetOfLandmarksL() + { + iLog->Log(_L("IterateSetOfLandmarksL")); + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); + CleanupStack::PushL(iter); + + const TInt startIndex=5; + const TInt numOfItems=20; + + RArray ids; + CleanupClosePushL(ids); + + iter->GetItemIdsL(ids, startIndex, numOfItems); + + AssertTrueSecL(ids.Count() == numOfItems, KIteratorNumOfItemsErr); + + for (TInt i=0; iReadLandmarkLC(ids[i]); + CompareLandmarksL(*source, *target); + CleanupStack::PopAndDestroy(); // target + } + + CleanupStack::PopAndDestroy(2, iter); + } + +// --------------------------------------------------------- +// CPosTp9::InternalSort +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt InternalSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) + { + TPtrC sourceName, targetName; + + User::LeaveIfError(aSource.GetLandmarkName(sourceName)); + User::LeaveIfError(aTarget.GetLandmarkName(targetName)); + + return sourceName.Compare(targetName); + } + +// --------------------------------------------------------- +// CPosTp9::IterateLandmarksL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::IterateSortedLandmarksL() + { + iLog->Log(_L("IterateSortedLandmarksL")); + CheckIteratorArgL(CPosLandmark::EPosition); + CheckIteratorArgL(CPosLandmark::ECoverageRadius); + CheckIteratorArgL(CPosLandmark::ECategoryInfo); + CheckIteratorArgL(CPosLandmark::EIcon); + CheckIteratorArgL(CPosLandmark::EDescription); + + TLinearOrder order(InternalSortL); + iLandmarks.Sort(order); + + TPosLmSortPref sortDesc(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); + CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(sortDesc); + CleanupStack::PushL(iter); + + AssertTrueSecL(iter->NumOfItemsL() == (TUint)iLandmarks.Count(), KIteratorNumOfItemsErr); + + TInt lastIndex=iLandmarks.Count()-1; + for (TInt i=lastIndex; i>=0; i--) + { + CPosLandmark* target = iDatabase->ReadLandmarkLC(iter->NextL()); + + CompareLandmarksL(*iLandmarks[i], *target); + CleanupStack::PopAndDestroy(); // target + } + CleanupStack::PopAndDestroy(iter); + + TPosLmSortPref sortAsc(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); + iter = iDatabase->LandmarkIteratorL(sortAsc); + CleanupStack::PushL(iter); + + for (TInt j=0; j < iLandmarks.Count(); j++) + { + CPosLandmark* target = iDatabase->ReadLandmarkLC(iter->NextL()); + + CompareLandmarksL(*iLandmarks[j], *target); + CleanupStack::PopAndDestroy(); // target + } + + CleanupStack::PopAndDestroy(iter); + iLog->Log(_L("IterateSortedLandmarksL completed")); + } + +// --------------------------------------------------------- +// CPosTp9:: +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosTp9::CheckIteratorArgL(const CPosLandmark::TAttributes& aAttr) + { + _LIT(KSortByNameErr, "Only sorting by landmark name should be supported"); + iLog->Log(_L("CheckIteratorArgL")); + TPosLmSortPref sortPref(aAttr); + CPosLmItemIterator* iter = NULL; + TRAPD(err, iter = iDatabase->LandmarkIteratorL(sortPref)); + delete iter; + AssertTrueSecL(err==KErrNotSupported, KSortByNameErr); + } + +// --------------------------------------------------------- +// CPosTp9::InternalGet +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CPosLandmark* CPosTp9::InternalGet(TPosLmItemId id) + { + for (TInt i=0; iLandmarkId() == id) + { + return iLandmarks[i]; + } + } + + return NULL; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CSearchResult.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CSearchResult.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include "FT_CSearchResult.h" + +//CONSTANTS +const TInt KMaxFieldLength = 80; +const TInt KMaxLineLength=255; + + + +// C++ Constructor +CSearchResult::CSearchResult() + { + } + +CSearchResult* CSearchResult::NewL(const TDesC& aDes) + { + CSearchResult* self = new(ELeave) CSearchResult; + CleanupStack::PushL(self); + self->ConstructL(aDes); + CleanupStack::Pop(); + return self; + } + +// C++ destructor +CSearchResult::~CSearchResult() + { + delete iTextCriteria; + iTextCriteria = NULL; + + iPositionFields.Close(); + } + +void CSearchResult::ConstructL(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt redefined=0; + + if (line.Peek() != '#' && line.Peek() != '\t') + { + TInt index=0; + while (line.Peek() != '\n' && !(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == '\t') + { + TPtrC token = line.MarkedToken(); + TLex val(token); + switch(index) + { + case ETextCriteria: + iTextCriteria = token.AllocL(); + break; + case EAttributes: + ParseAttributesL(token); + break; + case EPositionFields: + ParsePositionFields(token); + break; + case ELmSearchResult: + ParseSearchResult(token); + break; + case ERedefined: + val.Val(redefined); + if (redefined == 1) + { + iRedefined = ETrue; + } + break; + } + line.Inc(); + while (line.Peek() == '\t') // Empty value + { + line.Inc(); + ++index; + } + line.Mark(); + ++index; + } + } + } + //Print(); + } + + +// --------------------------------------------------------- +// CSearchResult::ParsePositionFields() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSearchResult::ParsePositionFields(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt value=0; + + while (!(line.Peek()).Eos()) + { + line.Inc(); + if (line.Peek() == ',' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + TLex val(token); + val.Val(value); + iPositionFields.Append(value); + + if (line.Peek() == ',') + { + line.Inc(); + line.Mark(); + } + } + } + } + +// --------------------------------------------------------- +// CSearchResult::Print() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSearchResult::Print() + { + TBuf print; + + TChar del(','); + + print.Append(*iTextCriteria); + print.Append(del); + + TBuf info; + _LIT(KAttrInfo, "%x"); + info.Format(KAttrInfo, iAttributes); + print.Append(info); + print.Append(del); + + _LIT(KIntInfo, "%d"); + TInt i=0; + for (i=0; i& CSearchResult::PositionFields() const + { + return iPositionFields; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CSearchResultBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CSearchResultBase.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* ?description_line +* +*/ + + +// INCLUDES +#include +#include +#include +#include "FT_CSearchResultBase.h" + +//CONSTANTS + +// C++ Constructor +CSearchResultBase::CSearchResultBase() : + iRedefined(EFalse) + { + + } + +// C++ destructor +CSearchResultBase::~CSearchResultBase() + { + iSearchResult.Close(); + } + + +// --------------------------------------------------------- +// CSearchResultBase::ParseSearchResult() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSearchResultBase::ParseSearchResult(const TDesC& aDes) + { + TLex line(aDes); + line.Mark(); + TInt startValue=0; + TInt endValue=0; + + while (!(line.Peek()).Eos()) + { + line.Inc(); + + if (line.Peek() == ',' || line.Peek() == '-' || (line.Peek()).Eos()) + { + TPtrC token = line.MarkedToken(); + TLex val(token); + val.Val(startValue); + iSearchResult.Append(startValue); + if (line.Peek() == '-') + { + line.Inc(); + line.Mark(); + while (line.Peek() != ',' && !(line.Peek()).Eos()) + { + line.Inc(); + } + TPtrC endToken = line.MarkedToken(); + TLex endVal(endToken); + endVal.Val(endValue); + for (TInt i=startValue+1; i<=endValue; i++) + { + iSearchResult.Append(i); + } + } + if (line.Peek() == ',') + { + line.Inc(); + line.Mark(); + } + } + } + } + +// --------------------------------------------------------- +// CSearchResultBase::ParseAttribute() +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSearchResultBase::ParseAttributesL(const TDesC& aDes) + { + TLex line(aDes); + line.Inc(); + line.Inc(); + User::LeaveIfError(line.Val(iAttributes, EHex)); + } + +// --------------------------------------------------------- +// CSearchResultBase::Attributes +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TUint CSearchResultBase::Attributes() const + { + return iAttributes; + } + +// --------------------------------------------------------- +// CSearchResultBase::SearchResult +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +RArray& CSearchResultBase::SearchResult() + { + return iSearchResult; + } + +// --------------------------------------------------------- +// CSearchResultBase::Redefined +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CSearchResultBase::Redefined() const + { + return iRedefined; + } + +// --------------------------------------------------------- +// CSearchResultBase::FindSearchResult +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CSearchResultBase::FindSearchResult(const TPosLmItemId aId) + { + for (TInt i=0; i +#include "FT_DatabaseUtility.h" + +#include + +#include +// CONSTANTS + +// ============================ MEMBER FUNCTIONS =============================== + +// Code below taken from EPos_PosLmDatabaseManager.cpp +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateDatabaseL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateDatabaseL(const TDesC& aDbPath, TBool aReplaceDatabase, TBool aWrongId, TBool aCreateInvalidIndex) + { + RDbs dbSession; + CleanupClosePushL(dbSession); + + User::LeaveIfError(dbSession.Connect()); + + TPtrC dbPath(aDbPath); + + + RDbNamedDatabase db; + CleanupClosePushL(db); + + + TUid KPosSecureUidWrongId = { 0x10204058 }; + _LIT(KWrongIdString, "secure[10204058]"); + + if (aReplaceDatabase) + { + TInt err =KErrNone; + + if (!aWrongId) err = dbSession.DeleteDatabase(dbPath, KPosLmDbSecureUid); + else err = dbSession.DeleteDatabase(dbPath, KPosSecureUidWrongId); + + if (err == KErrNone || err == KErrNotFound) + { + if (!aWrongId) User::LeaveIfError(db.Create(dbSession, dbPath, KPosLmDbSecureFormat)); + else User::LeaveIfError(db.Create(dbSession, dbPath, KWrongIdString)); + } + else + { + User::Leave(err); + } + } + else + { + if (!aWrongId) + { + User::LeaveIfError(db.Create(dbSession, dbPath, KPosLmDbSecureFormat)); + + } + else User::LeaveIfError(db.Create(dbSession, dbPath, KWrongIdString)); + } + + CreateTablesL(db, aCreateInvalidIndex); + + CreateIndexesL(db); + + SetCounterToOneL(db, KPosLmLandmarkTable); + SetCounterToOneL(db, KPosLmCategoryTable); + + // The settings table is created last so that a database can be validated + // when opening it (there will be a check for language there which is a + // part of the settings table). + CreateSettingsTableL(db); + + CleanupStack::PopAndDestroy(2, &dbSession); // &db + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateTablesL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateTablesL( + RDbNamedDatabase& aDb, TBool aCreateInvalidIndex) + { + CreateLandmarkTableL(aDb, aCreateInvalidIndex); + CreateLandmarkFieldTableL(aDb); + CreateCategoryTableL(aDb, aCreateInvalidIndex); + CreateLmCategoryTableL(aDb); + CreateIconTableL(aDb); + + // Do not create settings table here. This is created in the end so that the + // database can be validated when opening it. + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateLandmarkTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateLandmarkTableL( + RDbNamedDatabase& aDb, TBool aCreateInvalidIndex) + { + CDbColSet* columns = CDbColSet::NewLC(); + + TDbCol col(KPosLmLandmarkIdCol, EDbColUint32); + col.iAttributes = col.EAutoIncrement; + columns->AddL(col); + + columns->AddL(TDbCol(KPosLmLatitudeCol, EDbColReal64)); + columns->AddL(TDbCol(KPosLmLongitudeCol, EDbColReal64)); + columns->AddL(TDbCol(KPosLmAltitudeCol, EDbColReal32)); + + // Dont create the following tables when creating invalid table + if (!aCreateInvalidIndex) + { + columns->AddL(TDbCol(KPosLmHorizAccCol, EDbColReal32)); + columns->AddL(TDbCol(KPosLmVertAccCol, EDbColReal32)); + columns->AddL(TDbCol(KPosLmCoverageRadiusCol, EDbColReal32)); + columns->AddL(TDbCol(KPosLmIconIdCol, EDbColUint32)); + columns->AddL(TDbCol(KPosLmIconPicNrCol, EDbColInt32)); + columns->AddL(TDbCol(KPosLmMaskPicNrCol, EDbColInt32)); + columns->AddL(TDbCol(KPosLmNameCol, EDbColLongText, + KPosLmMaxTextFieldLength)); + } + + columns->AddL(TDbCol(KPosLmNDescCol, EDbColLongText, + KPosLmMaxDescriptionLength)); + + User::LeaveIfError(aDb.CreateTable(KPosLmLandmarkTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateLandmarkFieldTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateLandmarkFieldTableL( + RDbNamedDatabase& aDb) + { + CDbColSet* columns = CDbColSet::NewLC(); + + TDbCol col(KPosLmLandmarkIdCol, EDbColUint32); + col.iAttributes = col.ENotNull; + columns->AddL(TDbCol(col)); + + TDbCol col2(KPosLmFieldTypeCol, EDbColUint16); + col2.iAttributes = col2.ENotNull; + columns->AddL(col2); + + columns->AddL(TDbCol(KPosLmFieldStringCol, EDbColLongText, + KPosLmMaxTextFieldLength)); + + User::LeaveIfError(aDb.CreateTable(KPosLmLandmarkFieldTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateCategoryTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateCategoryTableL( + RDbNamedDatabase& aDb, TBool aCreateInvalidIndex) + { + CDbColSet* columns = CDbColSet::NewLC(); + + TDbCol col(KPosLmCategoryIdCol, EDbColUint32); + col.iAttributes = col.EAutoIncrement; + columns->AddL(col); + + columns->AddL(TDbCol(KPosLmGlobalCategoryIdCol, EDbColUint16)); + columns->AddL(TDbCol(KPosLmIconIdCol, EDbColUint32)); + columns->AddL(TDbCol(KPosLmIconPicNrCol, EDbColInt32)); + columns->AddL(TDbCol(KPosLmMaskPicNrCol, EDbColInt32)); + columns->AddL(TDbCol(KPosLmCategoryNameCol, EDbColText, + KPosLmMaxCategoryNameLength)); + + // Dont create the following tables when creating invalid table + if (!aCreateInvalidIndex) + { + columns->AddL(TDbCol(KPosLmCategoryNameModifiedCol, EDbColBit)); + } + + User::LeaveIfError(aDb.CreateTable(KPosLmCategoryTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateLmCategoryTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateLmCategoryTableL( + RDbNamedDatabase& aDb) + { + CDbColSet* columns = CDbColSet::NewLC(); + + TDbCol col(KPosLmLandmarkIdCol, EDbColUint32); + col.iAttributes = col.ENotNull; + columns->AddL(col); + + TDbCol col2(KPosLmCategoryIdCol, EDbColUint32); + col2.iAttributes = col2.ENotNull; + columns->AddL(col2); + + User::LeaveIfError(aDb.CreateTable(KPosLmLandmarkCategoryTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateIconTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateIconTableL( + RDbNamedDatabase& aDb) + { + CDbColSet* columns = CDbColSet::NewLC(); + + TDbCol col(KPosLmIconIdCol, EDbColUint32); + col.iAttributes = col.EAutoIncrement; + columns->AddL(col); + + columns->AddL(TDbCol(KPosLmIconPathCol, EDbColLongText, KMaxFileName)); + + User::LeaveIfError(aDb.CreateTable(KPosLmIconTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateSettingsTableL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateSettingsTableL( + RDbNamedDatabase& aDb) + { + CDbColSet* columns = CDbColSet::NewLC(); + + columns->AddL(TDbCol(KPosLmLanguageCol, EDbColInt32)); + columns->AddL(TDbCol(KPosLmInitFlagCol, EDbColInt32)); + + User::LeaveIfError(aDb.CreateTable(KPosLmSettingsTable, *columns)); + CleanupStack::PopAndDestroy(columns); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateIndexesL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateIndexesL( + RDbNamedDatabase& aDb) + { + CreateIndexL(aDb, KPosLmLandmarkIdIndex, KPosLmLandmarkTable, + KPosLmLandmarkIdCol, ETrue); + CreateIndexL(aDb, KPosLmCategoryIdIndex, KPosLmCategoryTable, + KPosLmCategoryIdCol, ETrue); + CreateIndexL(aDb, KPosLmGlobalCategoryIdIndex, KPosLmCategoryTable, + KPosLmGlobalCategoryIdCol, EFalse); + CreateIndexL(aDb, KPosLmCategoryNameIndex, KPosLmCategoryTable, + KPosLmCategoryNameCol, ETrue); + CreateIndexL(aDb, KPosLmIconIdIndex, KPosLmIconTable, + KPosLmIconIdCol, ETrue); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::CreateIndexL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::CreateIndexL( + RDbNamedDatabase& aDb, + const TDesC& aIndex, + const TDesC& aTable, + const TDesC& aColumn, + TBool aUnique) + { + CDbKey* keys = CDbKey::NewLC(); + keys->AddL(TDbKeyCol(aColumn)); + + if (aUnique) + { + keys->MakeUnique(); + } + + User::LeaveIfError(aDb.CreateIndex(aIndex, aTable, *keys)); + CleanupStack::PopAndDestroy(keys); + } + +// ----------------------------------------------------------------------------- +// FTDatabaseUtility::SetCounterToOneL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void FTDatabaseUtility::SetCounterToOneL( + RDbNamedDatabase& aDb, + const TDesC& aTable) + { + HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); + sql->Des().Format(KPosLmSqlSelect, &KPosLmSqlAll, &aTable); + + RDbView view; + CleanupClosePushL(view); + User::LeaveIfError(view.Prepare(aDb, TDbQuery(*sql), + TDbWindow::EUnlimited)); + + view.InsertL(); + view.PutL(); + + if (!view.FirstL()) + { + User::Leave(KErrGeneral); + } + + view.DeleteL(); + + CleanupStack::PopAndDestroy(2, sql); //&view + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/LandMarksTestModule.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/LandMarksTestModule.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include "LandMarksTestModule.h" + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::CLandMarksTestModule +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLandMarksTestModule::CLandMarksTestModule( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CLandMarksTestModule::ConstructL() + { + iLog = CStifLogger::NewL( KLandMarksTestModuleLogPath, + KLandMarksTestModuleLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + } + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLandMarksTestModule* CLandMarksTestModule::NewL( + CTestModuleIf& aTestModuleIf ) + { + CLandMarksTestModule* self = new (ELeave) CLandMarksTestModule( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CLandMarksTestModule::~CLandMarksTestModule() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +// ========================== 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* ) CLandMarksTestModule::NewL( aTestModuleIf ); + + } + +// ----------------------------------------------------------------------------- +// E32Dll is a DLL entry point function. +// Returns: KErrNone +// ----------------------------------------------------------------------------- +// +#ifndef EKA2 // Hide Dll entry point to EKA2 +GLDEF_C TInt E32Dll( + TDllReason ) // Reason code + { + return(KErrNone); + + } +#endif // EKA2 + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/LandMarksTestModuleBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/LandMarksTestModuleBlocks.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,399 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include "LandMarksTestModule.h" + +#include "FT_CPosTp1.h" +#include "FT_CPosTp2.h" +#include "FT_CPosTp3.h" +#include "FT_CPosTp4.h" +#include "FT_CPosTp5.h" +#include "FT_CPosTp6.h" +#include "FT_CPosTp7.h" +#include "FT_CPosTp8.h" +#include "FT_CPosTp9.h" + +#include "FT_CPosTp10.h" +#include "FT_CPosTp11.h" +#include "FT_CPosTp12.h" +#include "FT_CPosTp13.h" +#include "FT_CPosTp18.h" +#include "FT_CPosTp19.h" + +#include "FT_CPosTp20.h" +#include "FT_CPosTp21.h" +#include "FT_CPosTp23.h" +#include "FT_CPosTp24.h" +#include "FT_CPosTp25.h" +#include "FT_CPosTp26.h" +#include "FT_CPosTp28.h" + +#include "FT_CPosTp35.h" +#include "FT_CPosTp36.h" +#include "FT_CPosTp37.h" +#include "FT_CPosTp38.h" + +#include "FT_CPosTp42.h" +#include "FT_CPosTp43.h" +#include "FT_CPosTp44.h" +#include "FT_CPosTp45.h" +#include "FT_CPosTp47.h" +#include "FT_CPosTp48.h" + +#include "FT_CPosTp51.h" +#include "FT_CPosTp52.h" + +#include "FT_CPosTp100.h" +#include "FT_CPosTp101.h" +#include "FT_CPosTp102.h" +#include "FT_CPosTp103.h" +#include "FT_CPosTp104.h" +#include "FT_CPosTp106.h" + +#include "FT_CPosTp116.h" +#include "FT_CPosTp117.h" +#include "FT_CPosTp118.h" +#include "FT_CPosTp119.h" + +#include "FT_CPosTp120.h" +#include "FT_CPosTp121.h" +#include "FT_CPosTp122.h" +#include "FT_CPosTp123.h" +#include "FT_CPosTp124.h" +#include "FT_CPosTp125.h" +#include "FT_CPosTp126.h" + +#include "FT_CPosTp130.h" +#include "FT_CPosTp131.h" +#include "FT_CPosTp132.h" +#include "FT_CPosTp134.h" +#include "FT_CPosTp133.h" +#include "FT_CPosTp135.h" +#include "FT_CPosTp136.h" +#include "FT_CPosTp137.h" +#include "FT_CPosTp139.h" + +#include "FT_CPosTp141.h" +#include "FT_CPosTp143.h" + +#include "FT_CPosTp144.h" +#include "FT_CPosTp145.h" +#include "FT_CPosTp146.h" +#include "FT_CPosTp147.h" + +#include "FT_CPosTp148.h" +#include "FT_CPosTp149.h" +#include "FT_CPosTp150.h" +#include "FT_CPosTp151.h" +#include "FT_CPosTp152.h" +#include "FT_CPosTp153.h" +#include "FT_CPosTp154.h" +#include "FT_CPosTp155.h" +#include "FT_CPosTp156.h" +#include "FT_CPosTp157.h" +#include "FT_CPosTp158.h" +#include "FT_CPosTp159.h" +#include "FT_CPosTp160.h" + +#include "FT_CPosTp161.h" +#include "FT_CPosTp162.h" +#include "FT_CPosTp163.h" +#include "FT_CPosTp164.h" + + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CLandMarksTestModule::Delete() + { + } + +// ----------------------------------------------------------------------------- +// CLandMarksTestModule::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CLandMarksTestModule::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( "FT_CPosTp1", CLandMarksTestModule::FT_CPosTp1 ), + ENTRY( "FT_CPosTp2", CLandMarksTestModule::FT_CPosTp2 ), + ENTRY( "FT_CPosTp3", CLandMarksTestModule::FT_CPosTp3 ), + ENTRY( "FT_CPosTp4", CLandMarksTestModule::FT_CPosTp4 ), + ENTRY( "FT_CPosTp5", CLandMarksTestModule::FT_CPosTp5 ), + ENTRY( "FT_CPosTp6", CLandMarksTestModule::FT_CPosTp6 ), + ENTRY( "FT_CPosTp7", CLandMarksTestModule::FT_CPosTp7 ), + ENTRY( "FT_CPosTp8", CLandMarksTestModule::FT_CPosTp8 ), + ENTRY( "FT_CPosTp9", CLandMarksTestModule::FT_CPosTp9 ), + + ENTRY( "FT_CPosTp10", CLandMarksTestModule::FT_CPosTp10 ), + ENTRY( "FT_CPosTp11", CLandMarksTestModule::FT_CPosTp11 ), + ENTRY( "FT_CPosTp12", CLandMarksTestModule::FT_CPosTp12 ), + ENTRY( "FT_CPosTp13", CLandMarksTestModule::FT_CPosTp13 ), + ENTRY( "FT_CPosTp18", CLandMarksTestModule::FT_CPosTp18 ), + ENTRY( "FT_CPosTp19", CLandMarksTestModule::FT_CPosTp19 ), + + ENTRY( "FT_CPosTp20", CLandMarksTestModule::FT_CPosTp20 ), + ENTRY( "FT_CPosTp21", CLandMarksTestModule::FT_CPosTp21 ), + ENTRY( "FT_CPosTp23", CLandMarksTestModule::FT_CPosTp23 ), + ENTRY( "FT_CPosTp24", CLandMarksTestModule::FT_CPosTp24 ), + ENTRY( "FT_CPosTp25", CLandMarksTestModule::FT_CPosTp25 ), + ENTRY( "FT_CPosTp26", CLandMarksTestModule::FT_CPosTp26 ), + ENTRY( "FT_CPosTp28", CLandMarksTestModule::FT_CPosTp28 ), + + ENTRY( "FT_CPosTp35", CLandMarksTestModule::FT_CPosTp35 ), + ENTRY( "FT_CPosTp36", CLandMarksTestModule::FT_CPosTp36 ), + ENTRY( "FT_CPosTp37", CLandMarksTestModule::FT_CPosTp37 ), + ENTRY( "FT_CPosTp38", CLandMarksTestModule::FT_CPosTp38 ), + + ENTRY( "FT_CPosTp42", CLandMarksTestModule::FT_CPosTp42 ), + ENTRY( "FT_CPosTp43", CLandMarksTestModule::FT_CPosTp43 ), + ENTRY( "FT_CPosTp44", CLandMarksTestModule::FT_CPosTp44 ), + ENTRY( "FT_CPosTp45", CLandMarksTestModule::FT_CPosTp45 ), + ENTRY( "FT_CPosTp47", CLandMarksTestModule::FT_CPosTp47 ), + ENTRY( "FT_CPosTp48", CLandMarksTestModule::FT_CPosTp48 ), + + ENTRY( "FT_CPosTp51", CLandMarksTestModule::FT_CPosTp51 ), + ENTRY( "FT_CPosTp52", CLandMarksTestModule::FT_CPosTp52 ), + + ENTRY( "FT_CPosTp100", CLandMarksTestModule::FT_CPosTp100 ), + ENTRY( "FT_CPosTp101", CLandMarksTestModule::FT_CPosTp101 ), + ENTRY( "FT_CPosTp102", CLandMarksTestModule::FT_CPosTp102 ), + ENTRY( "FT_CPosTp103", CLandMarksTestModule::FT_CPosTp103 ), + ENTRY( "FT_CPosTp104", CLandMarksTestModule::FT_CPosTp104 ), + ENTRY( "FT_CPosTp106", CLandMarksTestModule::FT_CPosTp106 ), + + ENTRY( "FT_CPosTp116", CLandMarksTestModule::FT_CPosTp116 ), + ENTRY( "FT_CPosTp117", CLandMarksTestModule::FT_CPosTp117 ), + ENTRY( "FT_CPosTp118", CLandMarksTestModule::FT_CPosTp118 ), + ENTRY( "FT_CPosTp119", CLandMarksTestModule::FT_CPosTp119 ), + + ENTRY( "FT_CPosTp120", CLandMarksTestModule::FT_CPosTp120 ), + ENTRY( "FT_CPosTp121", CLandMarksTestModule::FT_CPosTp121 ), + ENTRY( "FT_CPosTp122", CLandMarksTestModule::FT_CPosTp122 ), + ENTRY( "FT_CPosTp123", CLandMarksTestModule::FT_CPosTp123 ), + ENTRY( "FT_CPosTp124", CLandMarksTestModule::FT_CPosTp124 ), + ENTRY( "FT_CPosTp125", CLandMarksTestModule::FT_CPosTp125 ), + ENTRY( "FT_CPosTp126", CLandMarksTestModule::FT_CPosTp126 ), + + ENTRY( "FT_CPosTp130", CLandMarksTestModule::FT_CPosTp130 ), + ENTRY( "FT_CPosTp131", CLandMarksTestModule::FT_CPosTp131 ), + ENTRY( "FT_CPosTp132", CLandMarksTestModule::FT_CPosTp132 ), + ENTRY( "FT_CPosTp133", CLandMarksTestModule::FT_CPosTp133 ), + ENTRY( "FT_CPosTp134", CLandMarksTestModule::FT_CPosTp134 ), + ENTRY( "FT_CPosTp135", CLandMarksTestModule::FT_CPosTp135 ), + ENTRY( "FT_CPosTp136", CLandMarksTestModule::FT_CPosTp136 ), + ENTRY( "FT_CPosTp137", CLandMarksTestModule::FT_CPosTp137 ), + ENTRY( "FT_CPosTp139", CLandMarksTestModule::FT_CPosTp139 ), + + ENTRY( "FT_CPosTp141", CLandMarksTestModule::FT_CPosTp141 ), + ENTRY( "FT_CPosTp143", CLandMarksTestModule::FT_CPosTp143 ), + ENTRY( "FT_CPosTp144", CLandMarksTestModule::FT_CPosTp144 ), + ENTRY( "FT_CPosTp145", CLandMarksTestModule::FT_CPosTp145 ), + ENTRY( "FT_CPosTp146", CLandMarksTestModule::FT_CPosTp146 ), + ENTRY( "FT_CPosTp147", CLandMarksTestModule::FT_CPosTp147 ), + + ENTRY( "FT_CPosTp148", CLandMarksTestModule::FT_CPosTp148 ), + ENTRY( "FT_CPosTp149", CLandMarksTestModule::FT_CPosTp149 ), + ENTRY( "FT_CPosTp150", CLandMarksTestModule::FT_CPosTp150 ), + ENTRY( "FT_CPosTp151", CLandMarksTestModule::FT_CPosTp151 ), + ENTRY( "FT_CPosTp152", CLandMarksTestModule::FT_CPosTp152 ), + ENTRY( "FT_CPosTp153", CLandMarksTestModule::FT_CPosTp153 ), + ENTRY( "FT_CPosTp154", CLandMarksTestModule::FT_CPosTp154 ), + ENTRY( "FT_CPosTp155", CLandMarksTestModule::FT_CPosTp155 ), + ENTRY( "FT_CPosTp156", CLandMarksTestModule::FT_CPosTp156 ), + ENTRY( "FT_CPosTp157", CLandMarksTestModule::FT_CPosTp157 ), + ENTRY( "FT_CPosTp158", CLandMarksTestModule::FT_CPosTp158 ), + ENTRY( "FT_CPosTp159", CLandMarksTestModule::FT_CPosTp159 ), + ENTRY( "FT_CPosTp160", CLandMarksTestModule::FT_CPosTp160 ), + + ENTRY( "FT_CPosTp161", CLandMarksTestModule::FT_CPosTp161 ), + ENTRY( "FT_CPosTp162", CLandMarksTestModule::FT_CPosTp162 ), + ENTRY( "FT_CPosTp163", CLandMarksTestModule::FT_CPosTp163 ), + ENTRY( "FT_CPosTp164", CLandMarksTestModule::FT_CPosTp164 ), + + }; + + const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CLandMarksTestModule::RunTestProcedureL( + CLandmarkTestProcedureBase* tp, + CStifItemParser* aItem ) + { + TBuf<128> buf; + TInt tpId = tp->iModuleId; + + CleanupStack::PushL( tp ); + + _LIT(KTestInit, "---- Initializing TP %d ------"); + buf.Format( KTestInit, tpId ); + iLog->Log( buf ); + tp->InitTestL(); + + _LIT(KTestStart, "---- Starting TP %d ------"); + buf.Format( KTestStart, tpId ); + iLog->Log( buf ); + if ( aItem ) + tp->StartL( *aItem ); + else + tp->StartL(); + + _LIT(KTestClose, "---- Closing TP %d ------"); + buf.Format( KTestClose, tpId ); + iLog->Log( buf ); + tp->CloseTest(); + + CleanupStack::PopAndDestroy( tp ); + _LIT(KTestDestroy, "---- Destroyed TP %d ------"); + buf.Format( KTestDestroy, tpId ); + iLog->Log( buf ); + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +template +TInt CLandMarksTestModule::TestProcedure( TInt aId, CStifItemParser& ) + { + iLog->Log(_L("---- Creating TP %d ------"), aId); + T* tp = new (ELeave) T( aId, iLog ); + TRAPD( err, RunTestProcedureL( tp ) ); + return err; + } + +#define DEF_TP(_id) \ +TInt CLandMarksTestModule::FT_CPosTp##_id( CStifItemParser& aItem ) \ + { return TestProcedure( _id, aItem ); } + +DEF_TP(1) +DEF_TP(2) +DEF_TP(3) +DEF_TP(4) +DEF_TP(5) +DEF_TP(6) +DEF_TP(7) +DEF_TP(8) +DEF_TP(9) + +DEF_TP(10) +DEF_TP(11) +DEF_TP(12) +DEF_TP(13) +DEF_TP(18) +DEF_TP(19) + +DEF_TP(20) +DEF_TP(21) +DEF_TP(23) +DEF_TP(24) +DEF_TP(25) +DEF_TP(26) +DEF_TP(28) + +DEF_TP(35) +DEF_TP(36) +DEF_TP(37) +DEF_TP(38) + +DEF_TP(42) +DEF_TP(43) +DEF_TP(44) +DEF_TP(45) +DEF_TP(47) +DEF_TP(48) + +DEF_TP(51) +DEF_TP(52) + +DEF_TP(100) +DEF_TP(101) +DEF_TP(102) +DEF_TP(103) +DEF_TP(104) +DEF_TP(106) + +DEF_TP(116) +DEF_TP(117) +DEF_TP(118) +DEF_TP(119) + +DEF_TP(120) +DEF_TP(121) +DEF_TP(122) +DEF_TP(123) +DEF_TP(124) +DEF_TP(125) +DEF_TP(126) + +DEF_TP(130) +DEF_TP(131) +DEF_TP(132) +DEF_TP(133) +DEF_TP(134) +DEF_TP(135) +DEF_TP(136) +DEF_TP(137) +DEF_TP(139) + +DEF_TP(141) +DEF_TP(143) +DEF_TP(144) +DEF_TP(145) +DEF_TP(146) +DEF_TP(147) + +DEF_TP(148) +DEF_TP(149) +DEF_TP(150) +DEF_TP(151) +DEF_TP(152) +DEF_TP(153) +DEF_TP(154) +DEF_TP(155) +DEF_TP(156) +DEF_TP(157) +DEF_TP(158) +DEF_TP(159) +DEF_TP(160) + +DEF_TP(161) +DEF_TP(162) +DEF_TP(163) +DEF_TP(164) diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/Bmarm/CUTLandmarkURLu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/Bmarm/CUTLandmarkURLu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/Bwins/CUTLandmarkURLu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/Bwins/CUTLandmarkURLu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,209 @@ +// Definitions +[Define] +Parser 0 +Encoder 1 +TenEncoder 2 +Buffer 0 +File 1 +EmptyFile 2 +EmptyBuffer 3 +TestPanic 1 +Accommodation 3000 +Businesses 6000 +TeleCommunication 9000 +Educational 12000 +Entertainment 15000 +Food_Beverage 18000 +GeographicalArea 21000 +Outdoor 24000 +People 27000 +PublicService 30000 +Religious 33000 +Shopping 36000 +Sightseeing 39000 +Sports 42000 +Transport 45000 +TEST_NULL_NAME 1 +TEST_NULL_STREET 2 +TEST_NULL_HNO 3 +TEST_NULL_POSTALCODE 4 +TEST_NULL_CITY 5 +TEST_NULL_STATE 6 +TEST_NULL_COUNTRY 7 +TEST_NULL_TELEPHONE 8 +TEST_NULL_WEB 9 +TEST_NULL_DESCRIPTION 10 +TEST_MAXLENGTH_NAME 11 +TEST_MAXLENGTH1_NAME 12 +TEST_MAXLENGTH2_NAME 13 +TEST_MAXLENGTH_STREET 14 +TEST_MAXLENGTH1_STREET 15 +TEST_MAXLENGTH2_STREET 16 +TEST_MAXLENGTH_HNO 17 +TEST_MAXLENGTH1_HNO 18 +TEST_MAXLENGTH2_HNO 19 +TEST_MAXLENGTH_POSTALCODE 20 +TEST_MAXLENGTH1_POSTALCODE 21 +TEST_MAXLENGTH2_POSTALCODE 22 +TEST_MAXLENGTH_CITY 23 +TEST_MAXLENGTH1_CITY 24 +TEST_MAXLENGTH2_CITY 25 +TEST_MAXLENGTH_STATE 26 +TEST_MAXLENGTH1_STATE 27 +TEST_MAXLENGTH2_STATE 28 +TEST_MAXLENGTH_COUNTRY 29 +TEST_MAXLENGTH1_COUNTRY 30 +TEST_MAXLENGTH2_COUNTRY 31 +TEST_MAXLENGTH_TELEPHONE 32 +TEST_MAXLENGTH1_TELEPHONE 33 +TEST_MAXLENGTH2_TELEPHONE 34 +TEST_MAXLENGTH_WEB 35 +TEST_MAXLENGTH1_WEB 36 +TEST_MAXLENGTH2_WEB 37 +TEST_MAXLENGTH_DESCRIPTION 38 +TEST_MAXLENGTH1_DESCRIPTION 39 +TEST_MAXLENGTH2_DESCRIPTION 40 +[Enddefine] + +[Test] +title Create_Encoder +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Create_MULTIPLE_Encoder +create CUTLandmarkURL foobar +foobar CreateInstanceL TenEncoder +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title EncodeToBuffer +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.1234567 HACCURACY= 12.000009 LATITUDE= 85.10 LONGITUDE= 101.102 ALTITUDE= 100 SPEED= 5.12 HEADING= 90 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Businesses WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar SetOutputBuffer +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding Buffer 20 NAME= " Nokia%20India " LMDESCRIPTION= " This%20is%20an%20Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100.00 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer%20Ring%20Road " POSTALCODE= " 560%20103 " HOUSENO.= " 2A%20Jupiter%20Block " TELEPHONE= " %2b91%2d9902019801 " CATEGORY= " Business " WEB= " www%2enokia%2ecom " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title EncodeToFile +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.1234567 HACCURACY= 12.000009 LATITUDE= 85.10 LONGITUDE= 101.102 ALTITUDE= 100 SPEED= 5.12 HEADING= 90 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Businesses WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 20 NAME= " Nokia%20India " LMDESCRIPTION= " This%20is%20an%20Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100.00 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer%20Ring%20Road " POSTALCODE= " 560%20103 " HOUSENO.= " 2A%20Jupiter%20Block " TELEPHONE= " %2b91%2d9902019801 " CATEGORY= " Business " WEB= " www%2enokia%2ecom " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAddCategory +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.1234567 HACCURACY= 12.000009 LATITUDE= 85.10 LONGITUDE= 101.102 ALTITUDE= 100 SPEED= 5.12 HEADING= 90 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Businesses WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar AddCategoryForLatestLandmark TeleCommunication +foobar FinalizeEncoding +foobar VerifyEncoding File 21 NAME= " Nokia%20India " LMDESCRIPTION= " This%20is%20an%20Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100.00 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer%20Ring%20Road " POSTALCODE= " 560%20103 " HOUSENO.= " 2A%20Jupiter%20Block " TELEPHONE= " %2b91%2d9902019801 " CATEGORY= " Business " WEB= " www%2enokia%2ecom " CATEGORYTWO= " Communication " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar CleanUp +delete foobar +[Endtest] +//----------------------------------------------------------Test Latitude and Longitude Values--------------------------- +[Test] +title TestLatLongNormalization1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 90.1110 LONGITUDE= 180 +foobar SetOutputFileHandle +foobar SetOutputBuffer +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding Buffer 2 LATITUDE= 89.889000 LONGITUDE= 0.000000 +foobar CleanUp +delete foobar +[Endtest] + + +[Test] +title TestLatLongNormalization2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -89.999 LONGITUDE= -180.001 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 2 LATITUDE= -89.999000 LONGITUDE= 179.999000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestLatLongNormalization3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 270.000001 LONGITUDE= -359.999 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 2 LATITUDE= -89.999999 LONGITUDE= 0.001000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestLatLongNormalization4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 269.0001 LONGITUDE= -360.001 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 2 LATITUDE= -89.000100 LONGITUDE= 179.999000 +foobar CleanUp +delete foobar +[Endtest] +//------------------------------------------------------------------------------------------------------------------------ + +[Test] +title TestSetOutfileError +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 269.0001 LONGITUDE= -360.001 +foobar SetOutputFileHandle 1 +foobar CleanUp +delete foobar +[Endtest] +//------------------------------------------------------------------------------------------------------------------------ +[Test] +title TestAddAddLmkPanic +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 269.0001 LONGITUDE= -360.001 +foobar AddLandmark TestPanic +pause 3000 +bringtoforeground +foobar CleanUp +delete foobar +[Endtest] +//------------------------------------------------------------------------------------------------------------------------ +[Test] +title TestAddAddCategoryPanic +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar AddCategoryForLatestLandmark TeleCommunication TestPanic +foobar CleanUp +delete foobar +[Endtest] + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL1.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL1.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,734 @@ +// Definitions +[Define] +Parser 0 +Encoder 1 +Buffer 0 +File 1 +EmptyFile 2 +EmptyBuffer 3 +Accommodation 3000 +Business 6000 +Communication 9000 +Educational 12000 +Entertainment 15000 +Food_Beverage 18000 +GeographicalArea 21000 +Outdoor 24000 +People 27000 +PublicService 30000 +Religious 33000 +Shopping 36000 +Sightseeing 39000 +Sports 42000 +Transport 45000 +TEST_NULL_NAME 1 +TEST_NULL_STREET 2 +TEST_NULL_HNO 3 +TEST_NULL_POSTALCODE 4 +TEST_NULL_CITY 5 +TEST_NULL_STATE 6 +TEST_NULL_COUNTRY 7 +TEST_NULL_TELEPHONE 8 +TEST_NULL_WEB 9 +TEST_NULL_DESCRIPTION 10 +TEST_MAXLENGTH_NAME 11 +TEST_MAXLENGTH1_NAME 12 +TEST_MAXLENGTH2_NAME 13 +TEST_MAXLENGTH_STREET 14 +TEST_MAXLENGTH1_STREET 15 +TEST_MAXLENGTH2_STREET 16 +TEST_MAXLENGTH_HNO 17 +TEST_MAXLENGTH1_HNO 18 +TEST_MAXLENGTH2_HNO 19 +TEST_MAXLENGTH_POSTALCODE 20 +TEST_MAXLENGTH1_POSTALCODE 21 +TEST_MAXLENGTH2_POSTALCODE 22 +TEST_MAXLENGTH_CITY 23 +TEST_MAXLENGTH1_CITY 24 +TEST_MAXLENGTH2_CITY 25 +TEST_MAXLENGTH_STATE 26 +TEST_MAXLENGTH1_STATE 27 +TEST_MAXLENGTH2_STATE 28 +TEST_MAXLENGTH_COUNTRY 29 +TEST_MAXLENGTH1_COUNTRY 30 +TEST_MAXLENGTH2_COUNTRY 31 +TEST_MAXLENGTH_TELEPHONE 32 +TEST_MAXLENGTH1_TELEPHONE 33 +TEST_MAXLENGTH2_TELEPHONE 34 +TEST_MAXLENGTH_WEB 35 +TEST_MAXLENGTH1_WEB 36 +TEST_MAXLENGTH2_WEB 37 +TEST_MAXLENGTH_DESCRIPTION 38 +TEST_MAXLENGTH1_DESCRIPTION 39 +TEST_MAXLENGTH2_DESCRIPTION 40 +TEST_MAXLENGTH_PID 44 +TEST_MAXLENGTH1_PID 45 +TEST_MAXLENGTH2_PID 46 +TEST_NULL_PID 43 +[Enddefine] +//-----------------------------------------------------PID Param------------------------------------------------------------ +[Test] +title NullPID +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_PID LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 PID= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericPID +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 23 LONGITUDE= 100 PID= " PlaceBangNokLoc " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 PID= " PlaceBangNokLoc " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharPID +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 23 LONGITUDE= 100 PID= " Place:*[Bang,{Nok}]; " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 PID= " Place%3a%2a%5bBang%2c%7bNok%7d%3cLoc%3e%5d%3b " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title PID_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_PID LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title PID_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_PID LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title PID_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_PID LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] +//----------------------------------------------End of PId-------------------------------------------------------------- +//------------------------------------------Name Param--------------------------------------------------------------- +[Test] +title NullName +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_NAME LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 NAME= " " LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericName +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " John1 " LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 NAME= " John1 " LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharName +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " Amar_Akbar`Anthony~ " LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 NAME= " Amar%5fAkbar%60Anthony%7e " LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NameWithPercentage +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL NAME= " Aditya%20Singh " LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 NAME= " Aditya%2520Singh " LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] +//255 chars +[Test] +title Name_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_NAME LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title Name_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_NAME LATITUDE= 23 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title Name_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_NAME LATITUDE= 23.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//--------------------------------------------------- End of Name---------------------------------------------------------------------------------------------- + +//----------------------------------------------------Street Param--------------------------------------------------------------------------------------------- + +[Test] +title NullStreet +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_STREET LATITUDE= 79 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 STREET= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericStreet +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 79 LONGITUDE= 100 STREET= " 2AJupiterBlk " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 STREET= " 2AJupiterBlk " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharStreet +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 79 LONGITUDE= 100 STREET= " #2AJupiter-Block! " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 STREET= " %232AJupiter%2dBlock%21 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StreetWithPercentage +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 79 LONGITUDE= 100 STREET= " %2A " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 STREET= " %252A " +foobar CleanUp +delete foobar +[Endtest] +//255 chars +[Test] +title Street_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_STREET LATITUDE= 79 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title Street_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_STREET LATITUDE= 79 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 79.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title Street_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_STREET LATITUDE= 79.00000 LONGITUDE= 100.00000 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Street--------------------------------------------------------------------------------------------------- +//----------------------------------------------------HouseNumber Param--------------------------------------------------------------------------------------------- + +[Test] +title NullHouseNo +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_HNO LATITUDE= -56 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -56.000000 LONGITUDE= 100.000000 HOUSENO.= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericHouseNo +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -56 LONGITUDE= 100 HOUSENO.= " 10Janpath " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -56.000000 LONGITUDE= 100.000000 HOUSENO.= " 10Janpath " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharHouseNo +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -56 LONGITUDE= 100 HOUSENO.= " (10.Janpath)' " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -56.000000 LONGITUDE= 100.000000 HOUSENO.= " %2810%2eJanpath%29%27 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title HouseNo_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_HNO LATITUDE= -56 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -56.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title HouseNo_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_HNO LATITUDE= -56 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -56.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title HouseNo_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_HNO LATITUDE= -9.00 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of HouseNumber--------------------------------------------------------------------------------------------------- +//----------------------------------------------------Postal Code Param--------------------------------------------------------------------------------------------- + +[Test] +title NullPostalCode +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_POSTALCODE LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 POSTALCODE= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericPostalCode +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 POSTALCODE= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 POSTALCODE= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharPostalCode +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 POSTALCODE= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 POSTALCODE= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title PostalCode_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_POSTALCODE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title PostalCode_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_POSTALCODE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title PostalCode_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_POSTALCODE LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Postal Code--------------------------------------------------------------------------------------------------- + +//----------------------------------------------------City Param--------------------------------------------------------------------------------------------- + +[Test] +title NullCity +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_CITY LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 CITY= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericCity +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 CITY= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 CITY= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharCity +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9.00000 LONGITUDE= 100.00000 CITY= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 CITY= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title City_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_CITY LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title City_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_CITY LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title City_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_CITY LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of City-------------------------------------------------------------------------------------------------- + +//----------------------------------------------------State Param--------------------------------------------------------------------------------------------- + +[Test] +title NullState +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_STATE LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 STATE= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericState +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 STATE= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 STATE= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharState +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 STATE= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 STATE= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title State_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_STATE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title State_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_STATE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title State_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_STATE LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of State-------------------------------------------------------------------------------------------------- + + +//----------------------------------------------------Country Param--------------------------------------------------------------------------------------------- + +[Test] +title NullCountry +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_COUNTRY LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 COUNTRY= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericCountry +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 COUNTRY= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 COUNTRY= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharCountry +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 COUNTRY= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 COUNTRY= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title Country_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_COUNTRY LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title Country_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_COUNTRY LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title Country_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_COUNTRY LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Country-------------------------------------------------------------------------------------------------- diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL2.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLandmarkURL2.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,715 @@ +// Definitions +[Define] +Parser 0 +Encoder 1 +Buffer 0 +File 1 +EmptyFile 2 +EmptyBuffer 3 +Accommodation 3000 +Business 6000 +Communication 9000 +Educational 12000 +Entertainment 15000 +Food_Beverage 18000 +GeographicalArea 21000 +Outdoor 24000 +People 27000 +PublicService 30000 +Religious 33000 +Shopping 36000 +Sightseeing 39000 +Sports 42000 +Transport 45000 +TEST_NULL_NAME 1 +TEST_NULL_STREET 2 +TEST_NULL_HNO 3 +TEST_NULL_POSTALCODE 4 +TEST_NULL_CITY 5 +TEST_NULL_STATE 6 +TEST_NULL_COUNTRY 7 +TEST_NULL_TELEPHONE 8 +TEST_NULL_WEB 9 +TEST_NULL_DESCRIPTION 10 +TEST_MAXLENGTH_NAME 11 +TEST_MAXLENGTH1_NAME 12 +TEST_MAXLENGTH2_NAME 13 +TEST_MAXLENGTH_STREET 14 +TEST_MAXLENGTH1_STREET 15 +TEST_MAXLENGTH2_STREET 16 +TEST_MAXLENGTH_HNO 17 +TEST_MAXLENGTH1_HNO 18 +TEST_MAXLENGTH2_HNO 19 +TEST_MAXLENGTH_POSTALCODE 20 +TEST_MAXLENGTH1_POSTALCODE 21 +TEST_MAXLENGTH2_POSTALCODE 22 +TEST_MAXLENGTH_CITY 23 +TEST_MAXLENGTH1_CITY 24 +TEST_MAXLENGTH2_CITY 25 +TEST_MAXLENGTH_STATE 26 +TEST_MAXLENGTH1_STATE 27 +TEST_MAXLENGTH2_STATE 28 +TEST_MAXLENGTH_COUNTRY 29 +TEST_MAXLENGTH1_COUNTRY 30 +TEST_MAXLENGTH2_COUNTRY 31 +TEST_MAXLENGTH_TELEPHONE 32 +TEST_MAXLENGTH1_TELEPHONE 33 +TEST_MAXLENGTH2_TELEPHONE 34 +TEST_MAXLENGTH_WEB 35 +TEST_MAXLENGTH1_WEB 36 +TEST_MAXLENGTH2_WEB 37 +TEST_MAXLENGTH_DESCRIPTION 38 +TEST_MAXLENGTH1_DESCRIPTION 39 +TEST_MAXLENGTH2_DESCRIPTION 40 +TEST_NULL_SPEED 41 +TEST_NULL_HEADING 42 +TEST_MAX_HA 47 +TEST_MAX_VA 48 +[Enddefine] + +//----------------------------------------------------Telephone Param--------------------------------------------------------------------------------------------- + +[Test] +title NullTelephone +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_TELEPHONE LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 TELEPHONE= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericTelephone +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 TELEPHONE= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 TELEPHONE= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharTelephone +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 TELEPHONE= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 TELEPHONE= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title Telephone_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_TELEPHONE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title Telephone_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_TELEPHONE LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title Telephone_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_TELEPHONE LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Telephone-------------------------------------------------------------------------------------------------- + +//----------------------------------------------------Web Param--------------------------------------------------------------------------------------------- + +[Test] +title NullWeb +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_WEB LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 WEB= " " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericWeb +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 WEB= " K1A 0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 WEB= " K1A%200B1 " +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharWeb +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= -9 LONGITUDE= 100 WEB= " @$^&*=|0B1 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -9.000000 LONGITUDE= 100.000000 WEB= " %40%24%5e%26%2a%3d%7c0B1 " +foobar CleanUp +delete foobar +[Endtest] + +//255 chars +[Test] +title Web_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_WEB LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//254 chars +[Test] +title Web_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_WEB LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title Web_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_WEB LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Web-------------------------------------------------------------------------------------------------- +//----------------------------------------------------Description Param--------------------------------------------------------------------------------------------- + +[Test] +title NullDescription +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_NULL_DESCRIPTION LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LMDESCRIPTION= " " LATITUDE= -9.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AlphanumericDescription +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LMDESCRIPTION= " K1A 0B1 " LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LMDESCRIPTION= " K1A%200B1 " LATITUDE= -9.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title SpecialCharDescription +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LMDESCRIPTION= " @$^&*=|0B1 " LATITUDE= -9 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LMDESCRIPTION= " %40%24%5e%26%2a%3d%7c0B1 " LATITUDE= -9.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//4095 chars +[Test] +title Description_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH_DESCRIPTION LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//4094 chars +[Test] +title Description_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH1_DESCRIPTION LATITUDE= -45 LONGITUDE= 100 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= -45.000000 LONGITUDE= 100.000000 +foobar CleanUp +delete foobar +[Endtest] + +//4096 chars +[Test] +title Description_BV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAXLENGTH2_DESCRIPTION LATITUDE= -45 LONGITUDE= 100 +foobar CleanUp +delete foobar +[Endtest] + +//-------------------------------------------------------End of Description-------------------------------------------------------------------------------------------------- + + +//------------------------------------------PositionalAccuracy Param--------------------------------------------------------------- +[Test] +title PA_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAX_HA LATITUDE= 9 LONGITUDE= 18 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 340282346638529000000000000000000000000.00 LATITUDE= 9.000000 LONGITUDE= 18.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PA_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL HACCURACY= 1 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 1.00 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestPAFoatingNumber1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL HACCURACY= 1345.001 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 1345.00 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestPAFoatingNumber2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL HACCURACY= 1345.01 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 1345.01 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestPAFoatingNumber3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL HACCURACY= 1345.12 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 1345.12 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestPAFoatingNumber4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL HACCURACY= 1345.98 LATITUDE= 9.00000 LONGITUDE= 108.00000 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 HACCURACY= 1345.98 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +//--------------------------------------------------- End of PositionalAccuracy---------------------------------------------------------------------------------------------- + +//------------------------------------------Altitude Accuracy Param--------------------------------------------------------------- +[Test] +title AA_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL TEST_MAX_VA LATITUDE= 9 LONGITUDE= 18 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 340282346638529000000000000000000000000.00 LATITUDE= 9.000000 LONGITUDE= 18.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title AA_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL VERT_ACC= 1 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 1.00 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAAFoatingNumber1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL VERT_ACC= 1345.001 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 1345.00 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAAFoatingNumber2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL VERT_ACC= 1345.01 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 1345.01 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAAFoatingNumber3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL VERT_ACC= 1345.123456789 LATITUDE= 9 LONGITUDE= 108 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 1345.12 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAAFoatingNumber4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL VERT_ACC= 1345.987654321 LATITUDE= 9.00000 LONGITUDE= 108.00000 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 VERT_ACC= 1345.99 LATITUDE= 9.000000 LONGITUDE= 108.000000 +foobar CleanUp +delete foobar +[Endtest] + +//--------------------------------------------------- End of Altitude Accuracy---------------------------------------------------------------------------------------------- + +//--------------------------------------------------- Altitude Param ---------------------------------------------------------------------------------------------- + +[Test] +title Alt_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 18 ALTITUDE= 4294967296 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 18.000000 ALTITUDE= 4294967296.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Alt_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 ALTITUDE= 1 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 ALTITUDE= 1.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAltFoatingNumber1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 ALTITUDE= 1345.001 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 ALTITUDE= 1345.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAltFoatingNumber2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 ALTITUDE= 1345.01 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 ALTITUDE= 1345.01 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAltFoatingNumber3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 ALTITUDE= 1345.124 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 ALTITUDE= 1345.12 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestAltFoatingNumber4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 ALTITUDE= 1345.986 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 ALTITUDE= 1345.99 +foobar CleanUp +delete foobar +[Endtest] +//--------------------------------------------------- End of Altitude---------------------------------------------------------------------------------------------- + +//--------------------------------------------------- Speed Param ---------------------------------------------------------------------------------------------- + +[Test] +title Speed_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 18 SPEED= 340282346638529000000000000000000000000.00 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 18.000000 SPEED= 340282346638529000000000000000000000000.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Speed_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 SPEED= 1 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 SPEED= 1.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestSpeedFoatingNumber1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 SPEED= 1345.001 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 SPEED= 1345.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestSpeedFoatingNumber2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 SPEED= 1345.01 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 SPEED= 1345.01 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestSpeedFoatingNumber3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 SPEED= 1345.1234 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 SPEED= 1345.12 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestSpeedFoatingNumber4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 SPEED= 1345.9876 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 SPEED= 1345.99 +foobar CleanUp +delete foobar +[Endtest] +//--------------------------------------------------- End of Speed---------------------------------------------------------------------------------------------- +//--------------------------------------------------- Heading Param ---------------------------------------------------------------------------------------------- + +[Test] +title Heading_BV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 18 HEADING= 340282346638529000000000000000000000000.00 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 18.000000 HEADING= 340282346638529000000000000000000000000.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Heading_BV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 HEADING= 1 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 HEADING= 1.00 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestHeadingFoatingNumber1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 HEADING= 1345.00999 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 HEADING= 1345.01 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestHeadingFoatingNumber2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 HEADING= 1345.01 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 HEADING= 1345.01 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestHeadingFoatingNumber3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 HEADING= 1345.123456 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 HEADING= 1345.12 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestHeadingFoatingNumber4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Encoder +foobar CreateLandmarkL LATITUDE= 9 LONGITUDE= 108 HEADING= 1345.987654 +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar VerifyEncoding File 3 LATITUDE= 9.000000 LONGITUDE= 108.000000 HEADING= 1345.99 +foobar CleanUp +delete foobar +[Endtest] +//--------------------------------------------------- End of Heading---------------------------------------------------------------------------------------------- \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLmkURLParser.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLmkURLParser.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1122 @@ +// Definitions +[Define] +default 0 +Parser 0 +Encoder 1 +NoProtocol 1 +https 2 +InvalidProtocol 3 +NoHostName 4 +InvalidHostName 5 +InvalidHostName1 6 +InvalidHostName2 7 +UnknownFormat 2 +[Enddefine] + +//----------------------------------------------------BAT Cases--------------------------------------------------------------------------------------------- + +[Test] +title Create_Parser +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Parse_Buffer +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default la=85.100000&lo=101.102000&a=100.00&pa=12.00&aa=3.12&pid=1234&n=Nokia%20India&d=This%20is%20an%20Example&sn=2A%20Jupiter%20Block&s=Outer%20Ring%20Road&c=Bangalore&sp=Karnataka&cr=India&pz=560%20103&t=%2b91%2d9902019801&v=5.12&h=90.00&cat=Businesses&w=www%2enokia%2ecom&ts=20090430:120000.100000 +foobar ParseContent +foobar Landmark NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Business WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Parse_File +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar CreateInstanceL Encoder +foobar SetInputFile +foobar ParseContent +foobar Landmark NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Business WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar SetOutputFileHandle +foobar AddLandmark +foobar FinalizeEncoding +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Parse_FileHandle +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=85.100000&lo=101.102000&a=100.00&pa=12.00&aa=3.12&pid=1234&n=Nokia%20India&d=This%20is%20an%20Example&sn=2A%20Jupiter%20Block&s=Outer%20Ring%20Road&c=Bangalore&sp=Karnataka&cr=India&pz=560%20103&t=%2b91%2d9902019801&v=5.12&h=90.00&cat=Businesses&w=www%2enokia%2ecom&ts=20090430:120000.100000 +foobar ParseContent +foobar Landmark NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Business WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title GetLmkCat +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFile +foobar ParseContent +foobar Landmark NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Business WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar LandmarkCategory CATEGORY= " dummy " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------End of BAT cases----------------------------------------------------------- + +//--------------------------------------------Testing Protocol------------------------------------------------------------ +[Test] +title NoProtocol +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle NoProtocol la=-90.000000&lo=-180.000000 +foobar ParseContent +foobar Landmark LATITUDE= -90.000000 LONGITUDE= -180.000000 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HTTPSProtocol +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle https la=90.000000&lo=180.000000 +foobar ParseContent +foobar Landmark LATITUDE= 90.000000 LONGITUDE= -180.000000 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title InvalidProtocol +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle InvalidProtocol la=85.100000&lo=101.102000 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +//--------------------------------------- End of testing protocol------------------------------------------------------- + +//---------------------------------------- TestingHostName-------------------------------------------------------------- + +[Test] +title NoHostName +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer NoHostName la=85.100000&lo=101.102000 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title InvalidHostName +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer InvalidHostName la=85.100000&lo=101.102000 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title InvalidHostName1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer InvalidHostName1 la=85.100000&lo=101.102000 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title InvalidHostName2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer InvalidHostName1 la=85.100000&lo=101.102000 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +//---------------------------------------End of Testing Hostname ----------------------------------------------------------- +//-----------------------------------------Testing Lat and Long------------------------------------------------------------- +[Test] +title ValidLatLong +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=-179.99999&la=-89.99999 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NoLongitude +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=-89.010& +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NoLatitude +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=-102.001& +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title WithoutParam +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullPosition +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=&lo= +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title BVLatLong1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=90.000001&lo=100.1234 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title BVLatLong2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=9&lo=180.000001 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title BVLatLong3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=-90.000001&lo=100.1234 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title BVLatLong4 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default la=9&lo=-180.000001 +foobar ParseContent UnknownFormat +foobar NumOfParsedLandmarks 0 +foobar CleanUp +delete foobar +[Endtest] + +//------------------------------------------------End of Testing Lat and Long--------------------------------------------------------- +//--------------------------------------------------Testing PID----------------------------------------------------------------------- +[Test] +title ValidPID +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=1a +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 PID= " 1a " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PID_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=%235%2C%201st%20Cross%2E +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 PID= " #5, 1st Cross. " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullPID +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PIDBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 + +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PIDBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +//256 chars +[Test] +title PIDBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PIDRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&pid=123$abc +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 PID= " 123 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + + +//----------------------------------------------------------------------End of Testing PID------------------------------------------------------------------------------- + +//-----------------------------------------------------------------------Testing Name------------------------------------------------------------------------------------ + +[Test] +title ValidName +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=Aurthur3 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 NAME= " Aurthur3 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Name_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&n=Jim%2bCarrey +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 NAME= " Jim+Carrey " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullName +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&n= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NameBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&n=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NameBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&n=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NameBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&n=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NameRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&n=Jim+Carrey +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------End of Name--------------------------------------------------------------------------- +//----------------------------------------------------------Testing Street----------------------------------------------------------------------- +[Test] +title ValidStreet +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pid=CemeteryRidge +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 STREET= " CemeteryRidge " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Street_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&s=112%20½%20Beacon%20Street%2c%20Boston +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 STREET= " 112 ½ Beacon Street, Boston " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullStreet +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&s= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StreetBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&s=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StreetBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&s=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StreetBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&s=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StreetRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&s=112 ½ Beacon Street, Boston +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 STREET= " 112 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Street-------------------------------------------------------- +//----------------------------------------------------------Testing HouseNumber----------------------------------------------------------------------- +[Test] +title ValidHNo +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn=Apt56B +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 HOUSENO.= " Apt56B " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HNo_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn=221B%2520Baker%20Street +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 HOUSENO.= " 221B%20Baker Street " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullHNo +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HNoBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HNoBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HNoBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sn=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title HNoRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&s=Ottumwa, Iowa +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 HOUSENO.= " Ottumwa " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing House Number-------------------------------------------------------- +//----------------------------------------------------------Testing PostalCode----------------------------------------------------------------------- +[Test] +title ValidPostalCode +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz=DK-1448 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 POSTALCODE= " DK%2D1448 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PostalCode_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz=4455%2d111%25%252520 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 POSTALCODE= " 4455-111%%2520 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullPostalCode +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PostalCodeBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PostalCodeBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PostalCodeBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&pz=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title PostalCodeRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&pz=560%20103 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 POSTALCODE= " 560 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Postal Code-------------------------------------------------------- +//----------------------------------------------------------Testing City---------------------------------------------------------------------- +[Test] +title ValidCity +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c=Idaho +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 CITY= " Idaho " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title City_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c=Krung%2dthep%2dmaha%2dnakorn%2dboworn%2dratana +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 CITY= " Krung-thep-maha-nakorn-boworn-ratana " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullCity +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CityBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CityBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CityBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&c=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CityRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&c=New York +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 CITY= " New " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing City-------------------------------------------------------- +//----------------------------------------------------------Testing State---------------------------------------------------------------------- +[Test] +title ValidState +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=Helsinki +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 STATE= " Helsinki " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title State_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=Jammu%20%26%20Kashmir +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 STATE= " Jammu & Kashmir " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullState +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StateBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StateBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StateBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title StateRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&sp=Jammu & Kashmir +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 STATE= " Jammu " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing State-------------------------------------------------------- +//----------------------------------------------------------Testing Country---------------------------------------------------------------------- +[Test] +title ValidCountry +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&cr=India +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 COUNTRY= " India " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Country_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&cr=The%20Separate%20Customs%20Territory%20of%20Taiwan%2C%20Penghu%2C%20Kinmen%2C%20and%20Matsu%20%28Chinese%20Taipei%29 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 COUNTRY= " The Separate Customs Territory of Taiwan, Penghu, Kinmen, and Matsu (Chinese Taipei) " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullCountry +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CountryBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CountryBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CountryBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&sp=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CountryRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&sp=Jammu & Kashmir +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 COUNTRY= " Jammu " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Country-------------------------------------------------------- +//----------------------------------------------------------Testing Telephone---------------------------------------------------------------------- +[Test] +title ValidTelephone +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t=08040159999 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 TELEPHONE= " 08040159999 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Telephone_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t=%2b44%20%280%291248%20717171 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 TELEPHONE= " +44 (0) 1248 717171 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullTelephone +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TelephoneBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TelephoneBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TelephoneBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&t=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TelephoneRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&t=%2b91%20080%204015 99999 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TELEPHONE= " +91 080 4015 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Telephone-------------------------------------------------------- +//----------------------------------------------------------Testing Web---------------------------------------------------------------------- +[Test] +title ValidWeb +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w=www%2Enokia%2ecom +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 WEB= " www.nokia.com " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Web_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w=www%2ellanfairpwllgwyngyllgogerychwyrndrobwyll%2Dllantysiliogogogoch%2ecom%2F +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 WEB= " www.llanfairpwllgwyngyllgogerychwyrndrobwyll-llantysiliogogogoch.com/ " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullWeb +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title WebBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title WebBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title WebBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&w=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title webRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&w=http:// +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 WEB= " http " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Web-------------------------------------------------------- \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLmkURLParser1.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/conf/CUTLmkURLParser1.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,565 @@ +// Definitions +[Define] +Parser 0 +default 0 +Encoder 1 +NoProtocol 1 +NullCat 1 +https 2 +InvalidProtocol 3 +NoHostName 4 +InvalidHostName 5 +InvalidHostName1 6 +InvalidHostName2 7 +BV_Description1 8 +BV_Description2 9 +BV_Description3 10 +UnknownFormat 2 +deletefile 1 +TestPanic 1 +[Enddefine] + +//----------------------------------------------------------Testing Category---------------------------------------------------------------------- + +[Test] +title MultipleCat_Unique +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=179.99999&la=89.99999&cat=dummy1&cat=dummy2 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory default CATEGORY= " dummy1 " CATEGORYTWO= " dummy2 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title MultipleCat_Duplicate +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=179.99999&la=89.99999&cat=dummy&cat=dummy +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory default CATEGORY= " dummy " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullCat +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=179.99999&la=89.99999&cat= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory NullCat +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CategoryBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&cat=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory default +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CategoryBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&cat=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory default +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CategoryBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&cat=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar LandmarkCategory LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title CategoryRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&cat=cate_gory +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar LandmarkCategory default CATEGORY= " cate " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Category-------------------------------------------------------- +//----------------------------------------------------------Testing Description---------------------------------------------------------------------- +[Test] +title ValidDescription +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&d=Example +foobar ParseContent +foobar Landmark LMDESCRIPTION= " Example " LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Description_EncodedChars +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&d=This%20is%20Example +foobar ParseContent +foobar Landmark LMDESCRIPTION= " This is Example " LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullDescription +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=179.99999&la=89.99999&d= +foobar ParseContent +foobar Landmark LATITUDE= 89.99999 LONGITUDE= 179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DescriptionBV1 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle BV_Description1 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DescriptionBV2 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle BV_Description2 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DescriptionBV3 +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle BV_Description3 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DescriptionRecovery +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&d=This is Invalid +foobar ParseContent +foobar Landmark LMDESCRIPTION= " This " LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//---------------------------------------------------------------End of Testing Description-------------------------------------------------------- +//-----------------------------------------------------------------Testing Position accuracy------------------------------------------------------- +[Test] +title ValidPA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&pa=4.05 +foobar ParseContent +foobar Landmark HACCURACY= 4.05 LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullPA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&pa= +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NonDigitPA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&pa=123# +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +//-----------------------------------------------------End of Position accuracy----------------------------------------------- + +//-----------------------------------------------------------------Testing Vertical accuracy------------------------------------------------------- +[Test] +title ValidVA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&aa=12313.016 +foobar ParseContent +foobar Landmark VERT_ACC= 12313.02 LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullVA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&aa= +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NonDigitVA +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&aa=rsen +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//-----------------------------------------------------End of Vertical accuracy----------------------------------------------- + + +//-----------------------------------------------------------------Testing Altitude------------------------------------------------------- +[Test] +title ValidAlt +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&a=50000 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 ALTITUDE= 50000.00 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullAlt +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&a= +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NonDigitAlt +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&a=inf +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NegativeAltitude +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&a=-0.124 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 ALTITUDE= -0.124 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//-----------------------------------------------------End of Altitude----------------------------------------------- + + +//-----------------------------------------------------------------Testing Speed------------------------------------------------------- +[Test] +title ValidSpeed +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&v=9.125 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 SPEED= " 9.12 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullSpeed +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&v= +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NonDigitSpeed +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&v=NaN +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +//-----------------------------------------------------End of speed----------------------------------------------- +//-----------------------------------------------------------------Testing Heading------------------------------------------------------- +[Test] +title ValidHeading +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&h=90.126 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 HEADING= " 90.13 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NullHeading +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&h= +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title NonDigitHeading +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&h=-inf +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +//-----------------------------------------------------End of Heading----------------------------------------------- +//-----------------------------------------------------------------Testing TimeStamp------------------------------------------------------- +[Test] +title ValidTimeStamp +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090516:124800.000000 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TS= " 20090516:124800.000000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TSWithoutTime +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090516 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TS= " 20090516:000000.000000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TSWithoutDate +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=:124800.000000 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title InvalidMonth +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20091216 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestLeapYear +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20080229 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TS= " 20080229:000000.000000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestInvalidDay +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090229 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] +//-----------------------------------------------------End of TestingTimeStamp----------------------------------------------- +//--------------------------------------------------------Misc Error Handling Test Cases-------------------------------------- +[Test] +title DiscardingofFileHandle +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFileHandle default lo=1&la=4 +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090616:123605.000000 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TS= " 20090616:123605.000000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DiscardingofBuffer +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=1&la=4 +foobar SetInputFile +foobar ParseContent +foobar Landmark NAME= " Nokia India " LMDESCRIPTION= " This is an Example " VERT_ACC= 3.12 HACCURACY= 12.00 LATITUDE= 85.100000 LONGITUDE= 101.102000 ALTITUDE= 100 SPEED= 5.12 HEADING= 90.00 COUNTRY= " India " STATE= " Karnataka " CITY= " Bangalore " STREET= " Outer Ring Road " POSTALCODE= " 560 103 " HOUSENO.= " 2A Jupiter Block " TELEPHONE= " +91-9902019801 " CATEGORY= Business WEB= " www.nokia.com " PID= " 1234 " TS= " 20090430:120000.100000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DiscardingofFile +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFile +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090616 +foobar ParseContent +foobar Landmark LATITUDE= -89.99999 LONGITUDE= -179.99999 TS= " 20090616:000000.000000 " +foobar NumOfParsedLandmarks 1 +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title DeleteInputFile +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputFile deletefile +foobar CleanUp +delete foobar +[Endtest] + +//[Test] +//title WriteModeFileHandle +//create CUTLandmarkURL foobar +//foobar CreateInstanceL Parser +//foobar SetInputFileHandle default TESTMODE= 1 +//foobar CleanUp +//delete foobar +//[Endtest] + +[Test] +title TestPanic_Parsing +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar ParseContent TestPanic +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title TestPanic_Landmark +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar SetInputBuffer default lo=-179.99999&la=-89.99999&ts=20090516:124800.000000 +foobar ParseContent +foobar Landmark TestPanic +foobar CleanUp +delete foobar +[Endtest] + +[Test] +title Misc +create CUTLandmarkURL foobar +foobar CreateInstanceL Parser +foobar CreateInstanceL Encoder +foobar TestMisc +foobar CleanUp +delete foobar +[Endtest] +//-----------------------------------------------End of Testing------------------------------------------------------------------ \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/data/URLParser.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/data/URLParser.txt Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,1 @@ +http://www.maps.ovi.com/?la=85.100000&lo=101.102000&a=100.00&pa=12.00&aa=3.12&pid=1234&n=Nokia%20India&d=This%20is%20an%20Example&sn=2A%20Jupiter%20Block&s=Outer%20Ring%20Road&c=Bangalore&sp=Karnataka&cr=India&pz=560%20103&t=%2b91%2d9902019801&v=5.12&h=90.00&cat=dummy&w=www%2enokia%2ecom&ts=20090430:120000.100000 \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/eabi/CUTLandmarkURLu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/eabi/CUTLandmarkURLu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/group/ABLD.BAT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/group/ABLD.BAT Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,15 @@ +@ECHO OFF + +REM Bldmake-generated batch file - ABLD.BAT +REM ** DO NOT EDIT ** + +perl -S ABLD.PL "\Requirements\LandmarksURL\testcases\CUTLandmarkURL\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9 +if errorlevel==1 goto CheckPerl +goto End + +:CheckPerl +perl -v >NUL +if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed? +goto End + +:End diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/group/CUTLandmarkURL.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/group/CUTLandmarkURL.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,102 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: mmp file for test component +* +*/ + +/*TYPE TESTCLASS*//* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's TestScripter +* testclass test module. +* +*/ + + +#include + +TARGET CUTLandmarkURL.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 CUTLandmarkURL.def + +USERINCLUDE ../inc + +APP_LAYER_SYSTEMINCLUDE +MW_LAYER_SYSTEMINCLUDE +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE CUTLandmarkURL.cpp +SOURCE CUTLandmarkURLBlocks.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY eposlandmarks.lib +LIBRARY bafl.lib +LIBRARY Lbs.lib +LIBRARY efsrv.lib +LIBRARY egul.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename +EPOCALLOWDLLDATA + +SMPSAFE + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/group/CUTLandmarkURL.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/group/CUTLandmarkURL.pkg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,69 @@ +; +; 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 the License "Symbian Foundation License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: package file for device installation +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 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 + +; Files to install +"\epoc32\release\armv5\urel\CUTLandmarkURL.dll"-"!:\sys\bin\CUTLandmarkURL.dll" + +;data file +"..\data\URLParser.txt"-"C:\testframework\URLParser.txt" + +"..\conf\CUTLandmarkURL.cfg"-"C:\testframework\CUTLandmarkURL.cfg" +"..\conf\CUTLandmarkURL1.cfg"-"C:\testframework\CUTLandmarkURL1.cfg" +"..\conf\CUTLandmarkURL2.cfg"-"C:\testframework\CUTLandmarkURL2.cfg" +"..\conf\CUTLmkURLParser.cfg"-"C:\testframework\CUTLmkURLParser.cfg" +"..\conf\CUTLmkURLParser1.cfg"-"C:\testframework\CUTLmkURLParser1.cfg" + +"..\init\testframework.ini"-"C:\testframework\testframework.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,70 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is build file for urlparser test component +* +*/ + + + + +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' +../data/URLParser.txt /epoc32/winscw/c/TestFramework/URLParser.txt +../conf/CUTLandmarkURL1.cfg /epoc32/winscw/c/TestFramework/CUTLandmarkURL1.cfg +../conf/CUTLandmarkURL2.cfg /epoc32/winscw/c/TestFramework/CUTLandmarkURL2.cfg +../conf/CUTLandmarkURL.cfg /epoc32/winscw/c/TestFramework/CUTLandmarkURL.cfg +../conf/CUTLmkURLParser.cfg /epoc32/winscw/c/TestFramework/CUTLmkURLParser.cfg +../conf/CUTLmkURLParser1.cfg /epoc32/winscw/c/TestFramework/CUTLmkURLParser1.cfg + +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 + + CUTLandmarkURL.mmp + +PRJ_MMPFILES + + +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#if defined(MARM) +/agnmodel/group/agsvexe.mmp +#endif +*/ + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/inc/CUTLandmarkURL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/inc/CUTLandmarkURL.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,348 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF testclass declaration +* +*/ + +#ifndef CUTLANDMARKURL_H +#define CUTLANDMARKURL_H + +// INCLUDES +#include +#include +#include +#include + +#include +#include +#include +#include + + +// CONSTANTS +//const ?type ?constant_var = ?constant; +const TInt KMaxTestBuf= 10240; +const TInt KMaxTagName= 24; +const TInt CREATE_PARSER = 0; +const TInt CREATE_ENCODER =1; +const TInt MULTIPLE_ENCODER =2; +const TInt MULTIPLE_PARSER =3; +const TInt BUFFER_OUTPUT =0; +const TInt FILE_OUTPUT =1; +const TInt NO_ENCODING_FILE =2; +const TInt NO_ENCODING_BUFFER =3; +const TInt ERROR_VERIFICATION_OPFILE =1; +const TInt PANIC_CODE_VERIIFCATION =1; +const TInt TEST_NULL_NAME = 1; +const TInt TEST_NULL_STREET = 2; +const TInt TEST_NULL_HNO = 3; +const TInt TEST_NULL_POSTALCODE = 4; +const TInt TEST_NULL_CITY = 5; +const TInt TEST_NULL_STATE = 6; +const TInt TEST_NULL_COUNTRY = 7; +const TInt TEST_NULL_TELEPHONE = 8; +const TInt TEST_NULL_WEB = 9; +const TInt TEST_NULL_DESCRIPTION = 10; +const TInt TEST_NULL_SPEED = 41; +const TInt TEST_NULL_HEADING = 42; +const TInt TEST_NULL_PID = 43; +const TInt TEST_MAXLENGTH_NAME = 11; +const TInt TEST_MAXLENGTH1_NAME = 12; +const TInt TEST_MAXLENGTH2_NAME = 13; +const TInt TEST_MAXLENGTH_STREET = 14; +const TInt TEST_MAXLENGTH1_STREET = 15; +const TInt TEST_MAXLENGTH2_STREET = 16; +const TInt TEST_MAXLENGTH_HNO = 17; +const TInt TEST_MAXLENGTH1_HNO = 18; +const TInt TEST_MAXLENGTH2_HNO = 19; +const TInt TEST_MAXLENGTH_POSTALCODE = 20; +const TInt TEST_MAXLENGTH1_POSTALCODE = 21; +const TInt TEST_MAXLENGTH2_POSTALCODE = 22; +const TInt TEST_MAXLENGTH_CITY = 23; +const TInt TEST_MAXLENGTH1_CITY = 24; +const TInt TEST_MAXLENGTH2_CITY = 25; +const TInt TEST_MAXLENGTH_STATE = 26; +const TInt TEST_MAXLENGTH1_STATE = 27; +const TInt TEST_MAXLENGTH2_STATE = 28; +const TInt TEST_MAXLENGTH_COUNTRY = 29; +const TInt TEST_MAXLENGTH1_COUNTRY = 30; +const TInt TEST_MAXLENGTH2_COUNTRY = 31; +const TInt TEST_MAXLENGTH_TELEPHONE = 32; +const TInt TEST_MAXLENGTH1_TELEPHONE = 33; +const TInt TEST_MAXLENGTH2_TELEPHONE = 34; +const TInt TEST_MAXLENGTH_WEB = 35; +const TInt TEST_MAXLENGTH1_WEB = 36; +const TInt TEST_MAXLENGTH2_WEB = 37; +const TInt TEST_MAXLENGTH_DESCRIPTION = 38; +const TInt TEST_MAXLENGTH1_DESCRIPTION = 39; +const TInt TEST_MAXLENGTH2_DESCRIPTION = 40; +const TInt TEST_MAXLENGTH_PID = 44; +const TInt TEST_MAXLENGTH1_PID = 45; +const TInt TEST_MAXLENGTH2_PID = 46; +const TInt TEST_MAX_HA = 47; +const TInt TEST_MAX_VA = 48; + +//constants for testing the Parser +const TInt NOPROTOCOL= 1; +const TInt HTTPS= 2; +const TInt INVALIDPROTOCOL= 3; +const TInt NOHOSTNAME= 4; +const TInt INVALIDHOSTNAME= 5; +const TInt INVALIDHOSTNAME1= 6; +const TInt INVALIDHOSTNAME2= 7; +const TInt DESC_BV1= 8; +const TInt DESC_BV2= 9; +const TInt DESC_BV3= 10; +const TInt UNKNOWNFORMAT= 2; +const TInt NOLANDMARK= 2; +const TInt NULLCAT= 1; +const TInt DELETEFILE= 1; +const TInt KRead= 0; +const TInt KReadWrite= 1; +const TUint KColumnSeperator='&'; + + + + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +_LIT( KCUTLandmarkURLLogPath, "\\logs\\testframework\\CUTLandmarkURL\\" ); +// Log file +_LIT( KCUTLandmarkURLLogFile, "CUTLandmarkURL.txt" ); +_LIT( KCUTLandmarkURLLogFileWithTitle, "CUTLandmarkURL_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CCUTLandmarkURL; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CCUTLandmarkURL test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CCUTLandmarkURL) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCUTLandmarkURL* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CCUTLandmarkURL(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + 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 ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CCUTLandmarkURL( 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(); + + /** + * Test methods are listed below. + */ + + /** + * Example test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + + TInt CreateInstanceL(CStifItemParser& aItem); + TInt CleanUp (CStifItemParser& aItem); + TInt CreateLandmarkL (CStifItemParser& aItem); + + //Test methods for parser + TInt SetInputBufferL(CStifItemParser& aItem); + TInt SetInputFile(CStifItemParser& aItem); + TInt SetInputFileHandleL(CStifItemParser& aItem); + TInt ParseContent(CStifItemParser& aItem); + TInt NumOfParsedLandmarksL(CStifItemParser& aItem); + TInt LandmarkL(CStifItemParser& aItem); + TInt LandmarkCategoryL(CStifItemParser& aItem); + void MiscL(CStifItemParser& aItem); + + + //Test methods for encoder + TInt SetOutputFileHandle (CStifItemParser& aItem); + TInt SetOutputBuffer (CStifItemParser& aItem); + TInt AddLandmark (CStifItemParser& aItem); + TInt AddCategoryForLatestLandmarkL (CStifItemParser& aItem); + TInt FinalizeEncoding (CStifItemParser& aItem); + TInt VerifyEncodingL (CStifItemParser& aItem); + + //Helper methods + void VerifyParsingL(CStifItemParser& aItem, CPosLandmark* aPosLandmark); + TInt ParseURL(const TDesC8 & aDelimiter, TPtr8 aBufferedURL, CStifItemParser& aItem); + TInt ParseValueL(TPtr8 aBufferedURL, CStifItemParser& aItem); + TInt CompareParamValueL(TBuf8 aTagName , TPtrC8 aValue, CStifItemParser& aItem); + TInt GetStringTillQuote(CStifItemParser& aItem, TName& aName); + TInt GetStringAfterTag(CStifItemParser& aItem, const TDesC& aTag, TName& aString); + + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + CPosLandmarkParser *iPosLandmarkParser; + CPosLandmarkEncoder *iPosLandmarkEncoder; + CPosLandmark *iPosLandmark; + CPosLmOperation* iOperation; + CBufBase* iEncoderBuffer; + HBufC8 * iParsedURL ; + HBufC8 * iRemainingURL ; + CPosLandmarkDatabase* iDatabase; + RFs iFileSession; + RFile iFile; + + // These data types stores the values from the cfg files + TPtrC iVerticalAccuracy; + TPtrC iHorizontalAccuracy; + TName iName; + TName iDescription; + TPtrC iLatitude; + TPtrC iLongitude; + TPtrC iAltitude; + TPtrC iCategory; + TName iMatchCategory; + TName iMatchCategory2; + TName iTS; + TName iPID; + TPtrC iYear; + TPtrC iMonth; + TPtrC iDay; + TPtrC iHour; + TPtrC iMinutes; + TPtrC iSeconds; + TPtrC iMSeconds; + TPtrC iSpeed; + TName iTelephone; + TName iWeb; + TPtrC iHeading; + TName iCountry; + TName iState; + TName iCity; + TName iStreet; + TName iHouseNumber; + TName iPostalCode; + + TInt iCount; + + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // CUTLANDMARKURL_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/inc/EPos_LandmarksErrors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/inc/EPos_LandmarksErrors.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Defines landmarks panic codes +* +*/ + + + + + +#ifndef LANDMARKSERRORS_H +#define LANDMARKSERRORS_H + +// INCLUDES +#include +#include + +// CONSTANTS +_LIT(KPosLandmarksClientPanic,"Landmarks Client"); + +/** + * Landmarks panic codes + * + */ +enum TPositionLandmarksClientPanic + { + EPosInvalidPositionFieldId = 0 + /** A client has specified a position field ID that is invalid for + the landmark. */, + EPosNoneOrMultipleLandmarkAttributeSet = 1 + /** A client has specified none or multiple landmark attributes. */, + EPosSpecifiedIntervalLiesOutsideIteratedSet = 2 + /** A client has specified an interval that lies partially outside the + iterated set. */, + EPosNaNCoordinate = 3 + /** A client has specified a coordinate with latitude and/or longitude set + to NaN. */, + EPosInvalidLandmarkAttribute = 4 + /** A client has specified a landmark attribute that is invalid. */, + EPosInvalidValueSpecifiedInResourceFile = 5 + /** An invalid value has been detected in a resource file. */, + EPosInvalidPartialReadParameters = 6 + /** Invalid partial read parameters have been detected. */, + EPosInvalidRequestedPositionFields = 7 + /** Invalid requested position fields have been detected. */, + EPosNegativeValue = 8 + /** A negative value has been detected. */, + EPosInvalidOperationMode = 9 + /** Invalid operation mode. Caused by mixed calls to NextStep and ExecuteL + for an CPosLmOperation object or subsequent calls to NextStep. */, + EPosInvalidEnumValue = 10 + /** Invalid enum value. */, + EPosLmProtocolBreak = 11 + /** The protocol of CPosLandmarkEncoder/CPosLandmarkParser is not + followed. */, + EPosLmInvalidArgument = 12 + /** A client has passed an invalid argument. */, + EPosInvalidIndex = 14 + /** A client has specified an invalid index. */, + EPosInvalidItemType = 15 + /** A client has specified an invalid item type. */, + EPosSearchOperationInUse = 16 + /** A client has tried to set/unset display data during an ongoing search. + */ + }; + +// FUNCTION PROTOTYPES +IMPORT_C GLDEF_C void Panic(const TDesC& aCategory, TInt aReason); + +#endif // LANDMARKSERRORS_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/init/testframework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/init/testframework.ini Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,176 @@ +# +# This is STIFTestFramework 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. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +[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= YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= NormalCases.txt +# TestCaseFile= SmokeCases.txt +# TestCaseFile= 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= c:\testframework\CUTLandmarkURL.cfg +TestCaseFile= c:\testframework\CUTLandmarkURL1.cfg +TestCaseFile= c:\testframework\CUTLandmarkURL2.cfg +TestCaseFile= c:\testframework\CUTLmkURLParser.cfg +TestCaseFile= c:\testframework\CUTLmkURLParser1.cfg +[End_Module] + +#Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= testcases1.cfg +#TestCaseFile= testcases2.cfg +#TestCaseFile= manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework 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. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +EmulatorBasePath= C:\ +EmulatorFormat= TXT # Possible values: TXT or HTML +EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +HardwareBasePath= C:\ +HardwareFormat= TXT # Possible values: TXT or HTML +HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # 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 + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/src/CUTLandmarkURL.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/src/CUTLandmarkURL.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,188 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains testclass implementation. +* This file defines the test class for testing the encoder functionality. +* +*/ + + + + +// INCLUDE FILES +#include +#include +#include "CUTLandmarkURL.h" + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CCUTLandmarkURL +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CCUTLandmarkURL::CCUTLandmarkURL( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ), + iCount(0), + iVerticalAccuracy(_L("")), + iHorizontalAccuracy(_L("")), + iName(_L("")), + iDescription(_L("")), + iLatitude(_L("")), + iLongitude(_L("")), + iAltitude(_L("")), + iCategory(_L("")), + iMatchCategory(_L("")), + iMatchCategory2(_L("")), + iTS(_L("")), + iPID(_L("")), + iYear(_L("")), + iMonth(_L("")), + iDay(_L("")), + iHour(_L("")), + iMinutes(_L("")), + iSeconds(_L("")), + iMSeconds(_L("")), + iSpeed(_L("")), + iTelephone(_L("")), + iWeb(_L("")), + iHeading(_L("")), + iCountry(_L("")), + iState(_L("")), + iCity(_L("")), + iStreet(_L("")), + iHouseNumber(_L("")), + iPostalCode(_L("")) + { + + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCUTLandmarkURL::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KCUTLandmarkURLLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KCUTLandmarkURLLogFile); + } + + iLog = CStifLogger::NewL( KCUTLandmarkURLLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + //Connects the file session + User::LeaveIfError(iFileSession.Connect()); + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCUTLandmarkURL* CCUTLandmarkURL::NewL( + CTestModuleIf& aTestModuleIf ) + { + CCUTLandmarkURL* self = new (ELeave) CCUTLandmarkURL( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CCUTLandmarkURL::~CCUTLandmarkURL() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CCUTLandmarkURL::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CCUTLandmarkURL::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("CUTLandmarkURL.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== 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* ) CCUTLandmarkURL::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 landmarks/locationlandmarks/tsrc/LandmarkURL/src/CUTLandmarkURLBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/landmarks/locationlandmarks/tsrc/LandmarkURL/src/CUTLandmarkURLBlocks.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,2051 @@ +/* +* 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 the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains testclass implementation. +* This file containts the test blocks that tests the encoder functionality. +* +*/ + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CUTLandmarkURL.h" +#include "EPos_LandmarksErrors.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; + +//Tags used in cfg file + _LIT(KName, "NAME= "); + _LIT(KLandmarkDescription, "LMDESCRIPTION= "); + _LIT(KVerticalAccuracy, "VERT_ACC= "); + _LIT(KHorizontalAccuracy, "HACCURACY= "); + _LIT(KLatitude, "LATITUDE= "); + _LIT(KLongitude, "LONGITUDE= "); + _LIT(KCountry, "COUNTRY= "); + _LIT(KState, "STATE= "); + _LIT(KStreet, "STREET= "); + _LIT(KHouseNumber, "HOUSENO.= "); + _LIT(KPostalCode, "POSTALCODE= "); + _LIT(KCity, "CITY= "); + _LIT(KTelephone, "TELEPHONE= "); + _LIT(KWeb, "WEB= "); + _LIT(KAltitude, "ALTITUDE= "); + _LIT(KSpeed, "SPEED= "); + _LIT(KHeading, "HEADING= "); + _LIT(KCategory, "CATEGORY= "); + _LIT(K2ndCategory, "CATEGORYTWO= "); + _LIT(KPID, "PID= "); + _LIT(KTS, "TS= "); + + _LIT(KOutputFilePath, "c:\\testframework\\EncodedLandmarks.txt"); + _LIT(KInputFile, "c:\\testframework\\URLParser.txt"); + _LIT(KInputFileHandle, "c:\\testframework\\InputFilehandle.txt"); + + //255 + _LIT(KMAXSTRING, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"); + //254 + _LIT(KMAXSTRING1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"); + //256 + _LIT(KMAXSTRING2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"); + + //4095 + _LIT(KMAXDESSTRING, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"); + //4094 + _LIT(KMAXDESSTRING1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"); + //4096 + _LIT(KMAXDESSTRING2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"); + + //124 + _LIT(KMAXCAT, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234"); + //123 + _LIT(KMAXCAT1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"); + //125 + _LIT(KMAXCAT2, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CCUTLandmarkURL::Delete() + { + + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::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( "CreateInstanceL", CCUTLandmarkURL::CreateInstanceL ), + ENTRY( "CleanUp", CCUTLandmarkURL::CleanUp ), + ENTRY( "CreateLandmarkL", CCUTLandmarkURL::CreateLandmarkL ), + + //Test Methods for parsing + ENTRY( "SetInputBuffer", CCUTLandmarkURL::SetInputBufferL ), + ENTRY( "SetInputFile", CCUTLandmarkURL::SetInputFile ), + ENTRY( "SetInputFileHandle", CCUTLandmarkURL::SetInputFileHandleL ), + ENTRY( "ParseContent", CCUTLandmarkURL::ParseContent ), + ENTRY( "NumOfParsedLandmarks", CCUTLandmarkURL::NumOfParsedLandmarksL ), + ENTRY( "Landmark", CCUTLandmarkURL::LandmarkL ), + ENTRY( "LandmarkCategory", CCUTLandmarkURL::LandmarkCategoryL ), + ENTRY( "TestMisc", CCUTLandmarkURL::MiscL ), + + + //Test methods for encoder + ENTRY( "SetOutputFileHandle", CCUTLandmarkURL::SetOutputFileHandle ), + ENTRY( "SetOutputBuffer", CCUTLandmarkURL::SetOutputBuffer ), + ENTRY( "AddLandmark", CCUTLandmarkURL::AddLandmark ), + ENTRY( "AddCategoryForLatestLandmark", CCUTLandmarkURL::AddCategoryForLatestLandmarkL), + ENTRY( "FinalizeEncoding", CCUTLandmarkURL::FinalizeEncoding ), + ENTRY( "VerifyEncoding", CCUTLandmarkURL::VerifyEncodingL ), + + + + + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CreateInstanceL +// This function creates instances for URL parser and encoder +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::CreateInstanceL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt Case; + RArray ArrayOfEncoders; + RArray ArrayOfParsers; + + aItem.GetNextInt(Case); + _LIT8( KUrlMIMEType, "maps.ovi.com" ); + + switch(Case) + { + case CREATE_PARSER: + iLog->Log(_L("Creating Instance of parser.....")); + TRAP(result, iPosLandmarkParser = CPosLandmarkParser::NewL(KUrlMIMEType)); + if(result != KErrNone || !(iPosLandmarkParser)) + { + iLog->Log(_L("FAILED: Creating instance for Parser fails, error = %d"),result); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Creating instance for Parser passes")); + + break; + + case CREATE_ENCODER: + iLog->Log(_L("Creating Instance of encoder.....")); + TRAP(result, iPosLandmarkEncoder = CPosLandmarkEncoder::NewL(KUrlMIMEType)); + if(result != KErrNone || !(iPosLandmarkEncoder)) + { + iLog->Log(_L("FAILED: Creating instance for encoder fails, error = %d"),result); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Creating instance for Encoder passes ")); + break; + + + case MULTIPLE_ENCODER: + TRAPD(err, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err1, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err2, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err3, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err4, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err5, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err6, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err7, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err8, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + TRAPD(err9, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); + if((ArrayOfEncoders.Count() != 10)||(err||err1||err2||err3||err4||err5||err6||err7||err8||err9 != KErrNone)) + result = KErrNone; + break; + + case MULTIPLE_PARSER: + TRAPD(parseerr, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr1, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr2, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr3, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr4, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr5, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr6, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr7, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr8, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + TRAPD(parseerr9, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); + if((ArrayOfParsers.Count() != 10)||(parseerr||parseerr1||parseerr2||parseerr3||parseerr4||parseerr5||parseerr6||parseerr7||parseerr8||parseerr9 != KErrNone)) + result = KErrNone; + break; + + + default: + break; + } + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CleanUp +// Releases memory and other resources +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::CleanUp( CStifItemParser& /*aItem*/ ) + { + ReleaseLandmarkResources(); + if(iPosLandmark) + { + delete iPosLandmark; + iPosLandmark = NULL; + } + + if(iEncoderBuffer) + { + delete iEncoderBuffer; + iEncoderBuffer = NULL; + } + + if(iDatabase) + { + delete iDatabase; + iDatabase = NULL; + } + + if(iOperation) + { + delete iOperation; + iOperation = NULL; + } + + if(iPosLandmarkParser) + { + delete iPosLandmarkParser; + iPosLandmarkParser = NULL; + } + + if(iPosLandmarkEncoder) + { + delete iPosLandmarkEncoder; + iPosLandmarkEncoder = NULL; + } + + iFile.Close(); + iFileSession.Close(); + TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); + User::After( 20000 ); + iLog->Log(_L("PASSED: Cleanup Succesful")); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CreateLandmark +// This functions creates landmarks +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::CreateLandmarkL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt Case = 0; + TRAP(result, iPosLandmark = CPosLandmark::NewL()); + User::LeaveIfError(result); + aItem.GetNextInt(Case); + + //Reading location values from the cfg files + GetStringAfterTag(aItem, KName, iName); + GetStringAfterTag(aItem, KLandmarkDescription, iDescription); + aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); + aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); + aItem.GetNextString(KLatitude,iLatitude); + aItem.GetNextString(KLongitude,iLongitude); + aItem.GetNextString(KAltitude,iAltitude); + + + //Reading postion fields from cfg fields + aItem.GetNextString(KSpeed,iSpeed); + aItem.GetNextString(KHeading,iHeading); + GetStringAfterTag(aItem, KCountry,iCountry); + GetStringAfterTag(aItem, KState,iState); + GetStringAfterTag(aItem, KCity,iCity); + GetStringAfterTag(aItem, KStreet ,iStreet); + GetStringAfterTag(aItem, KPostalCode,iPostalCode); + GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); + GetStringAfterTag(aItem, KTelephone,iTelephone); + aItem.GetNextString(KCategory,iCategory); + GetStringAfterTag(aItem, KWeb,iWeb); + GetStringAfterTag(aItem, KPID,iPID); + GetStringAfterTag(aItem, KTS,iTS); + + + //Converting string to TReal + TReal32 VA = 0; + TLex16 VerticalAcc(iVerticalAccuracy); + VerticalAcc.Val(VA); + + TReal32 HA= 0; + TLex16 HorizontalAcc(iHorizontalAccuracy); + HorizontalAcc.Val(HA); + + TReal64 RLat = 0; + TLex16 Lat(iLatitude); + Lat.Val(RLat); + + TReal64 RLong = 0; + TLex16 Long(iLongitude); + Long.Val(RLong); + + TReal64 RAlt = 0; + TLex16 Alt(iAltitude); + Alt.Val(RAlt); + + //This part of the code sets the position params to the landmark + TLocality Locality; + if (!iAltitude.Compare(_L(""))) + Locality.SetCoordinate(RLat, RLong); + else + Locality.SetCoordinate(RLat,RLong, RAlt); + + if (iHorizontalAccuracy.Compare(_L(""))) + Locality.SetHorizontalAccuracy(HA); + + if (iVerticalAccuracy.Compare(_L(""))) + Locality.SetVerticalAccuracy(VA); + + TUint Cat; + TLex16 Categ(iCategory); + Categ.Val(Cat, EDecimal); + + //Sets the time stamp to the landmark + TTime TS; + TS.Set(iTS); + + if (iTS.Compare(_L(""))) + { + TRAP(result ,iPosLandmark->SetTimeStampL(TS)); + User::LeaveIfError(result); + } + + switch(Case) + { + //This case tests the normal condition for all the landmark param fields + default: + //fall through + case 0: + + if (iDescription.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetLandmarkDescriptionL(iDescription)); + User::LeaveIfError(result); + } + if (iName.Compare(_L(""))) + { + TRAP(result ,iPosLandmark->SetLandmarkNameL(iName)); + User::LeaveIfError(result); + } + + //Setting positions fields + if (iSpeed.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, iSpeed)); + User::LeaveIfError(result); + } + if (iHeading.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHeading, iHeading)); + User::LeaveIfError(result); + } + if (iCountry.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, iCountry)); + User::LeaveIfError(result); + } + if (iState.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, iState)); + User::LeaveIfError(result); + } + if (iCity.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, iCity)); + User::LeaveIfError(result); + } + if (iStreet.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, iStreet)); + User::LeaveIfError(result); + } + if (iPostalCode.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, iPostalCode)); + User::LeaveIfError(result); + } + if (iHouseNumber.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, iHouseNumber)); + User::LeaveIfError(result); + } + if (iTelephone.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, iTelephone)); + User::LeaveIfError(result); + } + if (iWeb.Compare(_L(""))) + { + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, iWeb)); + User::LeaveIfError(result); + } + if (iPID.Compare(_L(""))) + { + TRAP(result ,iPosLandmark->SetPlaceIdL(iPID)); + User::LeaveIfError(result); + } + break; + + //The following cases sets the location params to test the boundry and error cases + case TEST_NULL_NAME: + TRAP(result ,iPosLandmark->SetLandmarkNameL(iName)); + User::LeaveIfError(result); + break; + + case TEST_NULL_STREET: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, iStreet)); + User::LeaveIfError(result); + break; + + case TEST_NULL_HNO: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, iHouseNumber)); + User::LeaveIfError(result); + break; + + case TEST_NULL_POSTALCODE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, iPostalCode)); + User::LeaveIfError(result); + break; + + case TEST_NULL_CITY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, iCity)); + User::LeaveIfError(result); + break; + + case TEST_NULL_STATE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, iState)); + User::LeaveIfError(result); + break; + + case TEST_NULL_COUNTRY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, iCountry)); + User::LeaveIfError(result); + break; + + case TEST_NULL_TELEPHONE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, iTelephone)); + User::LeaveIfError(result); + break; + + case TEST_NULL_WEB: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, iWeb)); + User::LeaveIfError(result); + break; + + case TEST_NULL_DESCRIPTION: + TRAP(result, iPosLandmark->SetLandmarkDescriptionL(iDescription)); + User::LeaveIfError(result); + break; + + case TEST_NULL_SPEED: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, iSpeed)); + User::LeaveIfError(result); + break; + + case TEST_NULL_HEADING: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHeading, iHeading)); + User::LeaveIfError(result); + break; + + case TEST_NULL_PID: + TRAP(result ,iPosLandmark->SetPlaceIdL(iPID)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH_NAME: + TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_NAME: + TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_NAME: + TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_STREET: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_STREET: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_STREET: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_HNO: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_HNO: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_HNO: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_POSTALCODE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_POSTALCODE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_POSTALCODE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_CITY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_CITY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_CITY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_STATE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_STATE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_STATE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_COUNTRY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_COUNTRY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_COUNTRY: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_TELEPHONE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_TELEPHONE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_TELEPHONE: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_WEB: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_WEB: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_WEB: + TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_DESCRIPTION: + TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_DESCRIPTION: + TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_DESCRIPTION: + TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAXLENGTH_PID: + TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH1_PID: + TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING1)); + User::LeaveIfError(result); + break; + + case TEST_MAXLENGTH2_PID: + TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING2)); + if(result != KErrArgument) + User::Leave(result); + else + result = KErrNone; + break; + + case TEST_MAX_HA: + Locality.SetHorizontalAccuracy(KMaxTReal32); + break; + + case TEST_MAX_VA: + Locality.SetVerticalAccuracy(KMaxTReal32-1); + break; + } + + //Adding Global Category + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + if (iCategory.Compare(_L(""))) + { + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + TUint16 id = categoryManager->GetGlobalCategoryL(Cat); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(id); + TRAP(result, iPosLandmark->AddCategoryL(id)); + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + User::LeaveIfError(result); + } + + TRAP(result, iPosLandmark->SetPositionL(Locality)); + if(result!= KErrNone) + { + result = KErrGeneral; + iLog->Log(_L("FAILED: Creating Landmark fails!!")); + } + else + iLog->Log(_L("PASSED: Creating Landmark Success!!")); + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::SetOutputFileHandle +// This function sets the output file to which the encoded URLs will be written +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::SetOutputFileHandle( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + aItem.GetNextInt(result); + + switch(caseno) + { + default: + //fall through + case 0: + if ( BaflUtils::FileExists(iFileSession, KOutputFilePath)) + { + BaflUtils :: DeleteFile( iFileSession, KOutputFilePath ); + } + TRAP(result,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); + if(result != KErrNone) + { + iLog->Log(_L("FAILED: Setting output file fails with error %d"), result); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Setting output file passes")); + break; + + case ERROR_VERIFICATION_OPFILE: + if ( BaflUtils::FileExists(iFileSession, KOutputFilePath)) + { + BaflUtils ::DeleteFile( iFileSession, KOutputFilePath ); + } + TRAP(result,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); + TRAPD(err,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); + + if(err != KErrAlreadyExists) + { + iLog->Log(_L("FAILED: Error verification for setting output file fails with %d"), err); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Error Verification for setting output file passed!!")); + + break; + } + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::SetOutputFileHandle +// This function sets the output buffer to which the encoded URLs will be written +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::SetOutputBuffer( CStifItemParser& /*aItem*/ ) + { + TInt result = KErrNone; + + TRAP(result, iEncoderBuffer = iPosLandmarkEncoder->SetUseOutputBufferL()); + if(result != KErrNone) + iLog->Log(_L("FAILED: Setting Output buffer fails with error %d"), result); + + else + iLog->Log(_L("PASSED: Setting Output buffer passed")); + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::AddLandmark +// This function adds the landmark to be encoded +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::AddLandmark( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + aItem.GetNextInt(caseno); + + switch(caseno) + { + default: + //fall through + case 0: + TRAP(result, iPosLandmarkEncoder->AddLandmarkL(* iPosLandmark)); + if(result != KErrNone) + iLog->Log(_L("FAILED: Adding Landmark for encoding fails with error %d"), result); + + else + iLog->Log(_L("PASSED: Adding Landmark for encoding passed")); + break; + + case PANIC_CODE_VERIIFCATION: + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); + TRAP(result, iPosLandmarkEncoder->AddLandmarkL(* iPosLandmark)); + break; + } + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::AddCategoryForLatestLandmark +// This function adds category to the latest landmark +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::AddCategoryForLatestLandmarkL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt Category; + TInt caseno = 0; + + aItem.GetNextInt(Category); + aItem.GetNextInt(caseno); + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); + CleanupStack::PushL(categoryManager); + TUint16 id = categoryManager->GetGlobalCategoryL(Category); + CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(id); + + switch(caseno) + { + default: + //fall through + case 0: + TRAP(result, iPosLandmarkEncoder->AddCategoryForLatestLandmarkL(* landmarkCategory)); + if(result != KErrNone) + iLog->Log(_L("FAILED: Adding Category for latest landmark fails with error %d"), result); + + else + iLog->Log(_L("PASSED: Adding Category for latest landmark passed")); + break; + + case PANIC_CODE_VERIIFCATION: + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); + TRAP(result, iPosLandmarkEncoder->AddCategoryForLatestLandmarkL(* landmarkCategory)); + break; + } + CleanupStack::PopAndDestroy(landmarkCategory); + CleanupStack::PopAndDestroy(categoryManager); + return result; + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::FinalizeEncoding +// This function finalizes the encoding +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::FinalizeEncoding( CStifItemParser& /*aItem*/ ) + { + TInt result = KErrNone; + TRAP(result, iOperation = iPosLandmarkEncoder->FinalizeEncodingL()); + TRAPD(result1, iOperation->ExecuteL()); + if(result != KErrNone||result1 != KErrNone) + iLog->Log(_L("FAILED: Finalize Encoding fails with error %d"), result); + + else + iLog->Log(_L("PASSED: Encoding Completed Successfully")); + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::SetInputBuffer +// This function sets the input buffer containing the URL to be parsed +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::SetInputBufferL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + TPtrC inputBuffer = _L(""); + aItem.GetNextInt(caseno); + aItem.GetNextString(inputBuffer); + + HBufC *buffer = HBufC::NewLC(inputBuffer.Size()); + *buffer = inputBuffer; + + HBufC8 *urlBuffer = HBufC8::NewL((inputBuffer.Size() + 25)); + + switch(caseno) + { + default: + //fall through + case 0: + urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com/?")); + break; + + case NOPROTOCOL: + urlBuffer->Des().Copy(_L8("maps.ovi.com/?")); + break; + + case HTTPS: + urlBuffer->Des().Copy(_L8("https://maps.ovi.com/?")); + break; + + case INVALIDPROTOCOL: + urlBuffer->Des().Copy(_L8("ftp://maps.ovi.com/?")); + break; + + case NOHOSTNAME: + urlBuffer->Des().Copy(_L8("/?")); + break; + + case INVALIDHOSTNAME: + urlBuffer->Des().Copy(_L8("http://www.maps.google.com/?")); + break; + + case INVALIDHOSTNAME1: + urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com?/")); + break; + + case INVALIDHOSTNAME2: + urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com/")); + break; + } + + urlBuffer->Des().Append(*buffer); + iPosLandmarkParser->SetInputBuffer(* urlBuffer); + + CleanupStack::PopAndDestroy(buffer); + return result; + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::SetInputFile +// This function sets the input file containing the URL to be parsed +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::SetInputFile( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + aItem.GetNextInt(caseno); + + if(BaflUtils::FileExists(iFileSession, KInputFile)) + { + TRAP(result,iPosLandmarkParser->SetInputFileL(KInputFile)); + if(result != KErrNone) + iLog->Log(_L("FAILED: Setting Input File Fails with error, %d"), result); + + else + iLog->Log(_L("PASSED: Setting Input File passes")); + } + else + result = KErrNotFound; + + if(caseno == DELETEFILE) + { + result = BaflUtils::DeleteFile(iFileSession, KInputFile); + if (result != KErrInUse) + iLog->Log(_L("FAILED: Input File Deleted after Setting")); + else + { + iLog->Log(_L("PASSED: Input File cannot be deleted after Setting")); + result = KErrNone; + } + } + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::SetInputFileHandle +// This function sets the handle of file containing the URL to be parsed +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::SetInputFileHandleL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + _LIT(KTestMode, "TESTMODE= " ); + if(BaflUtils::FileExists(iFileSession, KInputFileHandle)) + { + BaflUtils::DeleteFile(iFileSession, KInputFileHandle); + } + TInt caseno = 0; + aItem.GetNextInt(caseno); + + TPtrC inputURL; + aItem.GetNextString(inputURL); + + TInt testmode = 0; + aItem.GetInt(KTestMode, testmode); + + + HBufC *url = HBufC::NewLC(inputURL.Size()); + *url = inputURL; + + HBufC8 *urlfile = HBufC8::NewLC(inputURL.Size()); + urlfile->Des().Copy(*url); + + User::LeaveIfError(iFile.Create(iFileSession,KInputFileHandle, EFileWrite)); + switch(caseno) + { + default: + //fall through + case 0: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?"))); + break; + + case NOPROTOCOL: + User::LeaveIfError(iFile.Write(0, _L8("maps.ovi.com/?"))); + break; + + case HTTPS: + User::LeaveIfError(iFile.Write(0, _L8("https://maps.ovi.com/?"))); + break; + + case INVALIDPROTOCOL: + User::LeaveIfError(iFile.Write(0, _L8("ftp://maps.ovi.com/?"))); + break; + + case NOHOSTNAME: + User::LeaveIfError(iFile.Write(0, _L8("/?"))); + break; + + case INVALIDHOSTNAME: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.google.com/?"))); + break; + + case INVALIDHOSTNAME1: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com?/"))); + break; + + case INVALIDHOSTNAME2: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/"))); + break; + + case DESC_BV1: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"))); + break; + + case DESC_BV2: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"))); + break; + + case DESC_BV3: + User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"))); + break; + + } + + User::LeaveIfError(iFile.Write(25, *urlfile)); + + CleanupStack::PopAndDestroy(urlfile); + CleanupStack::PopAndDestroy(url); + + //Closing the file and opening in ReadMode + TInt expectedResult = KErrNone; + if(testmode == KRead) + { + iFile.Close(); + User::LeaveIfError(iFile.Open(iFileSession, KInputFileHandle, EFileRead)); + expectedResult = KErrNone; + } + if(testmode == KReadWrite) + expectedResult = KErrAccessDenied; + + + TRAP(result,iPosLandmarkParser->SetInputFileHandleL(iFile)); + { + if(result != expectedResult) + { + iLog->Log(_L("FAILED: Setting Input File Handle Fails with error, %d"), result); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Setting Input File Handle passes")); + } + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::ParseContent +// This function calls the parser method to parse the URL set either in buffer or file +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::ParseContent( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + aItem.GetNextInt(caseno); + TReal32 progress; + TRequestStatus status; + + switch(caseno) + { + default: + //fall through + case 0: + TRAP(result, iOperation = iPosLandmarkParser->ParseContentL(EFalse)); + TRAPD(error, iOperation->NextStep(status, progress)); + User::WaitForRequest(status); + if(result != KErrNone || error != KErrNone && status != KPosLmOperationNotComplete) + { + iLog->Log(_L("FAILED: ParseContent Fails with Error: %d and %d"), result, error); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: ParseContent passes")); + break; + + case UNKNOWNFORMAT: + TRAP(result, iOperation = iPosLandmarkParser->ParseContentL(EFalse)); + TRAP(result, iOperation->ExecuteL()); + if(result != KErrPosLmUnknownFormat && status == KErrNone) + { + iLog->Log(_L("FAILED:Parse Content fails for unknown format with error, %d"), result); + result = KErrGeneral; + } + else + { + iLog->Log(_L("PASSED: Parse Content passes for unknown format")); + result = KErrNone; + } + break; + + case PANIC_CODE_VERIIFCATION: + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); + TRAP(result, iPosLandmarkParser->ParseContentL(EFalse)); + break; + } + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::NumOfParsedLandmarks +// This function gives the number of parsed landmarks +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::NumOfParsedLandmarksL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt value = 0; + User::LeaveIfError(aItem.GetNextInt(value)); + + if(iPosLandmarkParser->NumOfParsedLandmarks() != value) + { + iLog->Log(_L("FAILED: Number of parsed Landmark does not matches")); + result = KErrGeneral; + } + + else + iLog->Log(_L("PASSED: NumOfParsedLandmarks returns the correct value")); + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::Landmark +// This function returns the landmark that is parsed from the URL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::LandmarkL( CStifItemParser& aItem ) + { + TInt result = KErrNone; + TInt caseno = 0; + + aItem.GetNextInt(caseno); + + CPosLandmark* landmark = NULL; + + switch(caseno) + { + default: + //fall through + case 0: + landmark = iPosLandmarkParser->LandmarkLC(); + TRAP(result, VerifyParsingL(aItem, landmark)); + if(result != KErrNone) + { + iLog->Log(_L("FAILED: Verification of Parsing Failed with error %d"), result); + result = KErrGeneral; + } + else + iLog->Log(_L("PASSED: Verification of parsing passed")); + + + iDatabase = CPosLandmarkDatabase::OpenL(); + if (iDatabase->IsInitializingNeeded()) + { + ExecuteAndDeleteLD(iDatabase->InitializeL()); + } + iPosLandmark = CPosLandmark::NewL(*landmark); + CleanupStack::PopAndDestroy(landmark); + + break; + + case NOLANDMARK: + TRAP(result, landmark = iPosLandmarkParser->LandmarkLC(); CleanupStack::PopAndDestroy(landmark)); + if(result != KErrNotFound) + { + iLog->Log(_L("FAILED:LandmarkLC fails for no landmark parsed, %d"), result); + result = KErrGeneral; + } + else + { + iLog->Log(_L("PASSED: LandmarkLC passes no landmark parsed")); + result = KErrNone; + } + break; + + case PANIC_CODE_VERIIFCATION: + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosInvalidIndex ); + TRAP(result, iPosLandmarkParser->LandmarkLC(4); CleanupStack::PopAndDestroy(landmark)); + break; + } + + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::LandmarkCategory +// This function returns the category of the landmark that was most recently parsed +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::LandmarkCategoryL( CStifItemParser& aItem ) + { + TInt result = KErrGeneral; + TInt caseno = 0; + + aItem.GetNextInt(caseno); + + GetStringAfterTag(aItem, KCategory,iMatchCategory); + GetStringAfterTag(aItem, K2ndCategory,iMatchCategory2); + + RArray array; + CPosLandmark* landmark = NULL; + landmark = iPosLandmarkParser->LandmarkLC(); + TRAP(result, landmark->GetCategoriesL(array)); + switch(caseno) + { + default: + //fall through + case 0: + for (TInt i=0;i buf; + CPosLandmarkCategory* category = iPosLandmarkParser->LandmarkCategoryLC(array[i]); + + if (category->GlobalCategory()) buf.Append(_L("Global category: ")); + else buf.Append(_L("Local category: ")); + TPtrC catName; + User::LeaveIfError(category->GetCategoryName(catName)); + result = (catName.Compare(iMatchCategory)); + if (result == KErrNone) + goto CONTINUE; + result = (catName.Compare(iMatchCategory2)); + if (result == KErrNone) + goto CONTINUE; + result = (catName.Compare(KMAXCAT)); + if (result == KErrNone) + goto CONTINUE; + result = (catName.Compare(KMAXCAT1)); + if (result == KErrNone) + goto CONTINUE; + result = (catName.Compare(KMAXCAT2)); + if (result == KErrNone) + goto CONTINUE; + CONTINUE: + { + buf.Append(catName); + iLog->Log(buf); + CleanupStack::PopAndDestroy(category); + if (result != KErrNone) + break; + } + } + break; + + case NULLCAT: + if(array.Count()== 0) + result = KErrNone; + + } + if(result == KErrNone) + iLog->Log(_L("PASSED: LandmarkLC Passed!!")); + else + iLog->Log(_L("FAILED: LandmarkLC fails!!")); + CleanupStack::PopAndDestroy(landmark); + return result; + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::Misc +// This method verifies the encoded url as follows: +// 1. Complies with the URL grammer +// 2. Compares the parameters are same as they were set +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CCUTLandmarkURL::MiscL( CStifItemParser& /*aItem*/) + { + TInt result = KErrNone; + TPosLmCollectionDataId collectionDataId; + + //Testing CPosLandmarkParser::CollectionData() + if( iPosLandmarkParser->CollectionData(EPosLmCollDataNone)!= KNullDesC) + { + iLog->Log(_L("FAILED: CollectionData fails")); + User::Leave(KErrGeneral); + } + else + iLog->Log(_L("PASSED: Collection Data passed")); + + //Testing CPosLandmarkParser::FirstCollectionDataId() + collectionDataId= iPosLandmarkParser->FirstCollectionDataId(); + if(collectionDataId != EPosLmCollDataNone) + { + iLog->Log(_L("FAILED: FirstCollectionDataId fails")); + User::Leave(KErrGeneral); + } + else + iLog->Log(_L("PASSED: FirstCollectionDataId Data passed")); + + //Testing CPosLandmarkParser::NextCollectionDataId() + collectionDataId = iPosLandmarkParser->NextCollectionDataId(EPosLmCollDataNone); + if(collectionDataId != EPosLmCollDataNone) + { + iLog->Log(_L("FAILED: NextCollectionDataId fails")); + User::Leave(KErrGeneral); + } + else + iLog->Log(_L("PASSED: NextCollectionDataId Data passed")); + TBuf<16> collectionData; + TRAP(result,iPosLandmarkEncoder->AddCollectionDataL(EPosLmCollDataNone,collectionData)); + User::Leave(result); + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::VerifyEncoding +// This method verifies the encoded url as follows: +// 1. Complies with the URL grammer +// 2. Compares the parameters are same as they were set +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::VerifyEncodingL( CStifItemParser& aItem) + { + TInt result = KErrNone; + TInt caseno = 0; + TInt NumberofParams = 0; + aItem.GetNextInt(caseno); + aItem.GetNextInt(NumberofParams); + + HBufC8* aDes = NULL; + HBufC8 *BufferedURL = HBufC8::NewLC(KMaxTestBuf); + TInt size = 0; + + switch(caseno) + { + default: + case BUFFER_OUTPUT: + TRAP(result, aDes = HBufC8::NewL(iEncoderBuffer->Size())); + CleanupStack::PushL(aDes); + TPtr8 ptr = aDes->Des(); + iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); + result = ParseURL(_L8("?"),ptr ,aItem); + iEncoderBuffer->Reset(); + CleanupStack::PopAndDestroy(aDes); + break; + + case FILE_OUTPUT: + User::LeaveIfError(iFile.Open(iFileSession, KOutputFilePath,EFileRead)); + TPtr8 fileptr = BufferedURL->Des(); + User::LeaveIfError(iFile.Read(fileptr)); + result = ParseURL(_L8("?"),fileptr,aItem); + break; + + case NO_ENCODING_FILE: + User::LeaveIfError(iFile.Open(iFileSession, KOutputFilePath,EFileRead)); + User::LeaveIfError(iFile.Size(size)); + iLog->Log(_L("Size of the file is %d"), size); + if (size != -1) + User::Leave(KErrGeneral); + else + User::Leave(KErrNone); + break; + + case NO_ENCODING_BUFFER: + size = iEncoderBuffer->Size(); + if (size != -1) + User::Leave(KErrGeneral); + else + User::Leave(KErrNone); + break; + } + iLog->Log(_L("PASSED: All the location params values matches!!")); + if(iCount != (NumberofParams)) + { + result = KErrGeneral; + iLog->Log(_L("FAILED: number of location params encoded does not match with the cfg file!!")); + } + CleanupStack::PopAndDestroy(BufferedURL); + return result; + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::ParseURL +// This method parses the URL obtained after encoding the landmark +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::ParseURL(const TDesC8 & aDelimiter, TPtr8 aBufferedURL, CStifItemParser& aItem) + { + TInt result = KErrNone; + TInt ParamStart = 0; + TInt column = 0; + TPtrC parsedURL; + HBufC * bufferedURL = HBufC::NewLC(KMaxTestBuf); + HBufC * remainingURL = HBufC::NewLC(KMaxTestBuf); + ParamStart = aBufferedURL.Find(aDelimiter); + if(ParamStart != -1) + { + remainingURL->Des().Copy(aBufferedURL.Mid((ParamStart+1),aBufferedURL.Length() -(ParamStart+1) )); + bufferedURL->Des().Copy(remainingURL->Des()); + while(result != KErrNotFound) + { + result = TextUtils::ColumnText(parsedURL, column, bufferedURL, KColumnSeperator); + HBufC8 *parsedURL8 = HBufC8::NewLC(parsedURL.Length()); + parsedURL8->Des().Copy(parsedURL); + ParseValueL(parsedURL8->Des(), aItem); + column++; + CleanupStack::PopAndDestroy(parsedURL8); + } + } + CleanupStack::PopAndDestroy(2); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::ParseValue +// This method obtains the value of the location parameters in the URL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// + +TInt CCUTLandmarkURL::ParseValueL(TPtr8 aBufferedURL, CStifItemParser& aItem) + { + TInt result = KErrNone; + TInt paramStart = 0; + paramStart = aBufferedURL.Find(_L8("=")); + TBuf8 tagName; + HBufC8* temp = HBufC8::NewLC(KMaxTestBuf); + TPtr8 temp8 = temp->Des(); + if(paramStart != -1) + { + tagName .Copy(aBufferedURL.Mid(0,paramStart )) ; + temp8.Copy(aBufferedURL .Mid((paramStart+1),aBufferedURL .Length() -(paramStart+1) )); + temp8.TrimAll(); + TPtrC8 Value(temp8); + result = CompareParamValueL(tagName, Value, aItem); + } + CleanupStack::PopAndDestroy(temp); + return result; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CompareParamValue +// This method compares the values of the parameters in the URL and in the cfg file +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::CompareParamValueL(TBuf8 aTagName , TPtrC8 aValue, CStifItemParser& aItem) + { + TInt result = KErrGeneral; + TInt tagCompare = -1; + + HBufC *value = HBufC::NewLC(aValue.Length()); + value->Des().Copy(aValue); + aTagName.TrimAll(); + + //Reading location values from the cfg files + GetStringAfterTag(aItem, KName, iName); + GetStringAfterTag(aItem, KLandmarkDescription, iDescription); + aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); + aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); + aItem.GetNextString(KLatitude,iLatitude); + aItem.GetNextString(KLongitude,iLongitude); + aItem.GetNextString(KAltitude,iAltitude); + + + //Reading postion fields from cfg fields + aItem.GetNextString(KSpeed,iSpeed); + aItem.GetNextString(KHeading,iHeading); + GetStringAfterTag(aItem, KCountry,iCountry); + GetStringAfterTag(aItem, KState,iState); + GetStringAfterTag(aItem, KCity,iCity); + GetStringAfterTag(aItem, KStreet ,iStreet); + GetStringAfterTag(aItem, KPostalCode,iPostalCode); + GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); + GetStringAfterTag(aItem, KTelephone,iTelephone); + GetStringAfterTag(aItem, KCategory,iMatchCategory); + GetStringAfterTag(aItem, KWeb,iWeb); + GetStringAfterTag(aItem, K2ndCategory,iMatchCategory2); + GetStringAfterTag(aItem, KPID,iPID); + GetStringAfterTag(aItem, KTS,iTS); + + + + tagCompare = aTagName.Compare(_L8("la")); + if(tagCompare == 0) + result = value->Compare(iLatitude); + + tagCompare = aTagName.Compare(_L8("lo")); + if(tagCompare == 0) + result = value->Compare(iLongitude); + + tagCompare = aTagName.Compare(_L8("n")); + if(tagCompare == 0) + result = value->Compare(iName); + + tagCompare = aTagName.Compare(_L8("s")); + if(tagCompare == 0) + result = value->Compare(iStreet); + + tagCompare = aTagName.Compare(_L8("sn")); + if(tagCompare == 0) + result = value->Compare(iHouseNumber); + + tagCompare = aTagName.Compare(_L8("pz")); + if(tagCompare == 0) + result = value->Compare(iPostalCode); + + tagCompare = aTagName.Compare(_L8("c")); + if(tagCompare == 0) + result = value->Compare(iCity); + + tagCompare = aTagName.Compare(_L8("sp")); + if(tagCompare == 0) + result = value->Compare(iState); + + tagCompare = aTagName.Compare(_L8("cr")); + if(tagCompare == 0) + result = value->Compare(iCountry); + + tagCompare = aTagName.Compare(_L8("t")); + if(tagCompare == 0) + result = value->Compare(iTelephone); + + tagCompare = aTagName.Compare(_L8("w")); + if(tagCompare == 0) + result = value->Compare(iWeb); + + tagCompare = aTagName.Compare(_L8("cat")); + if(tagCompare == 0) + result = value->Compare(iMatchCategory); + if (result != KErrNone) + result = value->Compare(iMatchCategory2); + + tagCompare = aTagName.Compare(_L8("d")); + if(tagCompare == 0) + result = value->Compare(iDescription); + + tagCompare = aTagName.Compare(_L8("pa")); + if(tagCompare == 0) + result = value->Compare(iHorizontalAccuracy); + + tagCompare = aTagName.Compare(_L8("a")); + if(tagCompare == 0) + result = value->Compare(iAltitude); + + tagCompare = aTagName.Compare(_L8("aa")); + if(tagCompare == 0) + result = value->Compare(iVerticalAccuracy); + + tagCompare = aTagName.Compare(_L8("v")); + if(tagCompare == 0) + result = value->Compare(iSpeed); + + tagCompare = aTagName.Compare(_L8("h")); + if(tagCompare == 0) + result = value->Compare(iHeading); + + tagCompare = aTagName.Compare(_L8("pid")); + if(tagCompare == 0) + result = value->Compare(iPID); + + tagCompare = aTagName.Compare(_L8("ts")); + if(tagCompare == 0) + result = value->Compare(iTS); + + if (result != 0) + { + result = value->Compare(KMAXSTRING); + } + if (result != 0) + { + result = value->Compare(KMAXSTRING1); + } + if (result != 0) + { + result = value->Compare(KMAXSTRING2); + } + if (result != 0) + { + result = value->Compare(KMAXDESSTRING); + } + if (result != 0) + { + result = value->Compare(KMAXDESSTRING1); + } + if (result != 0) + { + result = value->Compare(KMAXDESSTRING2); + } + + + iCount++; + if(result != KErrNone) + { + iLog->Log(_L("FAILED: Params Values in the URL and cfg file does not match, Param: %S"),&aTagName); + User::Leave(KErrGeneral); + } + CleanupStack::PopAndDestroy(value); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CompareParamValue +// This method compares the values of the parameters in the URL and in the cfg file +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CCUTLandmarkURL::GetStringTillQuote(CStifItemParser& aItem, TName& aName) + { + TPtrC temp; + + + //Assuming that a " has already been seen. + if(aItem.GetNextString(temp) != KErrNone) + { + return KErrArgument; + } + + //The name should have atleast one word. + if(temp == _L("\"")) + { + return KErrArgument; + } + + + //Append the first word. + aName.Append(temp); + + if(aItem.GetNextString(temp) != KErrNone) + { + return KErrArgument; + } + + + while(temp!=_L("\"")) + { + //Append a space at the beginning + aName.Append(_L(" ")); + aName.Append(temp); + + //Keep on appending the next words. + if(aItem.GetNextString(temp) != KErrNone) + { + return KErrArgument; + } + } + + return KErrNone; + } + + +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::CompareParamValue +// This method compares the values of the parameters in the URL and in the cfg file +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// + +TInt CCUTLandmarkURL::GetStringAfterTag(CStifItemParser& aItem, const TDesC& aTag, TName& aString) + { + TPtrC temp; + aString.Delete(0,aString.Length()); + + if(aItem.GetString(aTag, temp) != KErrNone) + { + return KErrArgument; + } + + //Now temp should contain a " + if(temp != _L("\"")) + { + return KErrArgument; + } + + //Get the Country name till a " is found. + if(GetStringTillQuote(aItem, aString) != KErrNone) + { + return KErrArgument; + } + + return KErrNone; + } +// ----------------------------------------------------------------------------- +// CCUTLandmarkURL::VerifyParsing +// This method verifies the parsed url as follows: +// 1. Compares with the URL grammer +// 2. Compares the parameters are set properly in the landmark object +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CCUTLandmarkURL::VerifyParsingL( CStifItemParser& aItem,CPosLandmark* aPosLandmark ) + { + TInt result = KErrGeneral; + + //Reading location values from the cfg files + GetStringAfterTag(aItem, KName, iName); + GetStringAfterTag(aItem, KLandmarkDescription, iDescription); + aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); + aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); + aItem.GetNextString(KLatitude,iLatitude); + aItem.GetNextString(KLongitude,iLongitude); + aItem.GetNextString(KAltitude,iAltitude); + + + //Reading postion fields from cfg fields + aItem.GetNextString(KSpeed,iSpeed); + aItem.GetNextString(KHeading,iHeading); + + GetStringAfterTag(aItem, KCountry,iCountry); + GetStringAfterTag(aItem, KState,iState); + GetStringAfterTag(aItem, KCity,iCity); + GetStringAfterTag(aItem, KStreet ,iStreet); + GetStringAfterTag(aItem, KPostalCode,iPostalCode); + GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); + GetStringAfterTag(aItem, KTelephone,iTelephone); + GetStringAfterTag(aItem, KWeb,iWeb); + GetStringAfterTag(aItem, KPID,iPID); + GetStringAfterTag(aItem, KTS,iTS); + + + + //Converting string to TReal + TRealX floatX; + floatX.SetNaN(); + + TReal32 VA = 0; + if(iVerticalAccuracy != _L("")) + { + TLex16 VerticalAcc(iVerticalAccuracy); + VerticalAcc.Val(VA); + } + else + VA = floatX; + + TReal32 HA= 0; + if(iHorizontalAccuracy != _L("")) + { + TLex16 HorizontalAcc(iHorizontalAccuracy); + HorizontalAcc.Val(HA); + } + else + HA = floatX; + + TReal64 RLat = 0; + TLex16 Lat(iLatitude); + Lat.Val(RLat); + + TReal64 RLong = 0; + TLex16 Long(iLongitude); + Long.Val(RLong); + + TReal64 RAlt = 0; + if(iAltitude != _L("")) + { + TLex16 Alt(iAltitude); + Alt.Val(RAlt); + } + else + RAlt = floatX; + + + TPtrC landmarkDescription; + aPosLandmark->GetLandmarkDescription(landmarkDescription); + result = landmarkDescription.Compare(iDescription); + if(result != KErrNone) + result = landmarkDescription.Compare(KMAXDESSTRING); + if(result != KErrNone) + result = landmarkDescription.Compare(KMAXDESSTRING1); + if(result != KErrNone) + result = landmarkDescription.Compare(KMAXDESSTRING2); + + TPtrC name; + aPosLandmark->GetLandmarkName(name); + result = name.Compare(iName); + if(result != KErrNone) + result = name.Compare(KMAXSTRING); + if(result != KErrNone) + result = name.Compare(KMAXSTRING1); + if(result != KErrNone) + result = name.Compare(KMAXSTRING2); + + TPtrC pid; + aPosLandmark->GetPlaceId(pid); + result = pid.Compare(iPID); + if(result != KErrNone) + result = pid.Compare(KMAXSTRING); + if(result != KErrNone) + result = pid.Compare(KMAXSTRING1); + if(result != KErrNone) + result = pid.Compare(KMAXSTRING2); + + TLocality position; + TReal64 latitude, longitude = 0; + TReal32 altitude, pa, aa = 0; + aPosLandmark->GetPosition(position); + latitude = position.Latitude(); + if(latitude != RLat) + User::Leave(KErrGeneral); + longitude = position.Longitude(); + if(longitude != RLong) + User::Leave(KErrGeneral); + altitude = position.Altitude(); + if(Math::IsNaN(altitude)!= Math::IsNaN(RAlt) ) + { + if(altitude != RAlt) + User::Leave(KErrGeneral); + } + + pa = position.HorizontalAccuracy(); + if(Math::IsNaN(pa)!= Math::IsNaN(HA) ) + { + if(pa != HA) + User::Leave(KErrGeneral); + } + + aa = position.VerticalAccuracy(); + if(Math::IsNaN(aa)!= Math::IsNaN(VA) ) + { + if(aa != VA) + User::Leave(KErrGeneral); + } + + TPtrC speed; + aPosLandmark->GetPositionField(EPositionFieldHorizontalSpeed, speed); + result = speed.Compare(iSpeed); + if(result != KErrNone) + result = speed.Compare(KMAXSTRING); + if(result != KErrNone) + result = speed.Compare(KMAXSTRING1); + if(result != KErrNone) + result = speed.Compare(KMAXSTRING2); + + + + TPtrC heading; + aPosLandmark->GetPositionField(EPositionFieldHeading, heading); + result = heading.Compare(iHeading); + if(result != KErrNone) + result = heading.Compare(KMAXSTRING); + if(result != KErrNone) + result = heading.Compare(KMAXSTRING1); + if(result != KErrNone) + result = heading.Compare(KMAXSTRING2); + + TPtrC country; + aPosLandmark->GetPositionField(EPositionFieldCountry, country); + result = country.Compare(iCountry); + if(result != KErrNone) + result = country.Compare(KMAXSTRING); + if(result != KErrNone) + result = country.Compare(KMAXSTRING1); + if(result != KErrNone) + result = country.Compare(KMAXSTRING2); + + TPtrC state; + aPosLandmark->GetPositionField(EPositionFieldState, state); + result = state.Compare(iState); + if(result != KErrNone) + result = state.Compare(KMAXSTRING); + if(result != KErrNone) + result = state.Compare(KMAXSTRING1); + if(result != KErrNone) + result = state.Compare(KMAXSTRING2); + + TPtrC city; + aPosLandmark->GetPositionField(EPositionFieldCity, city); + result = city.Compare(iCity); + if(result != KErrNone) + result = city.Compare(KMAXSTRING); + if(result != KErrNone) + result = city.Compare(KMAXSTRING1); + if(result != KErrNone) + result = city.Compare(KMAXSTRING2); + + + TPtrC street; + aPosLandmark->GetPositionField(EPositionFieldStreet, street); + result = street.Compare(iStreet); + if(result != KErrNone) + result = street.Compare(KMAXSTRING); + if(result != KErrNone) + result = street.Compare(KMAXSTRING1); + if(result != KErrNone) + result = street.Compare(KMAXSTRING2); + + TPtrC postalCode; + aPosLandmark->GetPositionField(EPositionFieldPostalCode, postalCode); + result = postalCode.Compare(iPostalCode); + if(result != KErrNone) + result = postalCode.Compare(KMAXSTRING); + if(result != KErrNone) + result = postalCode.Compare(KMAXSTRING1); + if(result != KErrNone) + result = postalCode.Compare(KMAXSTRING2); + + TPtrC houseNumber; + aPosLandmark->GetPositionField(EPositionFieldStreetExtension, houseNumber); + result = houseNumber.Compare(iHouseNumber); + if(result != KErrNone) + result = houseNumber.Compare(KMAXSTRING); + if(result != KErrNone) + result = houseNumber.Compare(KMAXSTRING1); + if(result != KErrNone) + result = houseNumber.Compare(KMAXSTRING2); + + TPtrC telephone; + aPosLandmark->GetPositionField(EPositionFieldBuildingTelephone, telephone); + result = telephone.Compare(iTelephone); + if(result != KErrNone) + result = telephone.Compare(KMAXSTRING); + if(result != KErrNone) + result = telephone.Compare(KMAXSTRING1); + if(result != KErrNone) + result = telephone.Compare(KMAXSTRING2); + + TPtrC web; + aPosLandmark->GetPositionField(EPositionFieldMediaLinksStart, web); + result = web.Compare(iWeb); + if(result != KErrNone) + result = web.Compare(KMAXSTRING); + if(result != KErrNone) + result = web.Compare(KMAXSTRING1); + if(result != KErrNone) + result = web.Compare(KMAXSTRING2); + + User::LeaveIfError(result); + + // This part of the code Tests the timestamp + TTime timeStamp; + result = aPosLandmark->GetTimeStamp(timeStamp); + TTime ts; + if(iTS != _L("")) + ts.Set(iTS); + if(result != KErrNotFound && iTS != _L("")) + { + if(timeStamp != ts) + User::Leave(KErrGeneral); + } + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 6f8759468fd4 -r 7409e6184c90 layers.sysdef.xml --- a/layers.sysdef.xml Tue Jun 15 11:38:32 2010 +0100 +++ b/layers.sysdef.xml Thu Jul 22 16:37:56 2010 +0100 @@ -1,9 +1,9 @@ - ]> - + @@ -12,13 +12,21 @@ + filter="dfs_build" name="lodo_locationsrv_supl_asnpluginimplementation" /> + + + + filter="dfs_build" name="lodo_locationsrv_supl_asnpluginimplementationver2" /> + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/group/bld.inf --- a/locationsystemui/locationsysui/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/locationsystemui/locationsysui/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -23,13 +23,14 @@ PRJ_PLATFORMS DEFAULT +PRJ_EXPORTS // Export Configuration Markup language and Central Repository Mark up language files ../conf/loclocalvariation.confml MW_LAYER_CONFML(loclocalvariation.confml) ../conf/loclocalvariation_20022D83.crml MW_LAYER_CRML(loclocalvariation_20022D83.crml) -PRJ_EXPORTS + // Query and Notification #include "../queryandnotification/group/bld.inf" diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/locsysui.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/locsysui.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,27 @@ +# +# 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: project file for Locsysui +# + + +TEMPLATE = subdirs + +SYMBIAN_PLATFORMS = WINSCW ARMV5 + +SUBDIRS += possettings/possettings.pro +SUBDIRS += privacyverifiernotifierui/privacyverifiernotifierui.pro +SUBDIRS += posindicator/posindicator.pro + +BLD_INF_RULES.prj_exports += "conf/loclocalvariation.confml MW_LAYER_CONFML(loclocalvariation.confml)" \ + "conf/loclocalvariation_20022D83.crml MW_LAYER_CRML(loclocalvariation_20022D83.crml)" + \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posgeoaddress.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posgeoaddress.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,86 @@ +/* +* 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: Data structure containing positioning and address info +* +*/ + +#ifndef POSGEOADDRESS_H +#define POSGEOADDRESS_H + +#include + +#include "posindicatorglobal.h" + +class PosGeoAddressPrivate; + +/** +* PosGeoAddress represents a Location information. +*/ +class POSINDICATOR_EXPORT PosGeoAddress : public QObject + { + Q_OBJECT + + Q_PROPERTY(double latitude READ latitude WRITE setLatitude) + Q_PROPERTY(double longitude READ longitude WRITE setLongitude) + Q_PROPERTY(float hAccuracy READ hAccuracy WRITE sethAccuracy) + Q_PROPERTY(float vAccuracy READ vAccuracy WRITE setvAccuracy) + Q_PROPERTY(float altitude READ altitude WRITE setAltitude) + + Q_PROPERTY(QString country READ country WRITE setCountry) + Q_PROPERTY(QString state READ state WRITE setState) + Q_PROPERTY(QString city READ district WRITE setDistrict) + Q_PROPERTY(QString city READ city WRITE setCity) + Q_PROPERTY(QString zip READ zip WRITE setZip) + Q_PROPERTY(QString street READ street WRITE setStreet) + Q_PROPERTY(QString number READ number WRITE setNumber) + +public: + PosGeoAddress(); + ~PosGeoAddress(); + void setLatitude( double value ); + double latitude() const; + void setLongitude(double value); + double longitude() const; + void sethAccuracy(float value); + float hAccuracy() const; + void setvAccuracy(float value); + float vAccuracy() const; + void setAltitude(float value); + float altitude() const ; + void setCountry(QString value); + QString country() const; + void setState(QString value); + QString state() const; + void setDistrict(QString value); + QString district() const ; + void setCity(QString value); + QString city() const; + void setZip(QString value); + QString zip() const; + void setStreet(QString value); + QString street() const; + void setNumber(QString value); + QString number() const; + +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosGeoAddress) + +private: + /** + * Pointer to private implementation. + * Owns + */ + PosGeoAddressPrivate* d_ptr; + }; +#endif /* POSGEOADDRESS_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posindicatorglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posindicatorglobal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,34 @@ +/* +* 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: Positioning Indicators export/import declarations +* +*/ + + +#ifndef POSINDICATOR_GLOBAL_H +#define POSINDICATOR_GLOBAL_H + +#ifdef BUILD_POSINDICATOR + #define POSINDICATOR_EXPORT Q_DECL_EXPORT +#else + #define POSINDICATOR_EXPORT Q_DECL_IMPORT +#endif + + +#endif // POSINDICATOR_GLOBAL_H + +// End of file + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posindicatorinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posindicatorinfo.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2010 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: Positioning Indicators Info - QT Wrapper +* +*/ + +#ifndef POSITIONINDICATORINFO_H +#define POSITIONINDICATORINFO_H + +#include + +#include "posgeoaddress.h" +#include "posindicatorglobal.h" + +class PosIndicatorInfoPrivate; + +class POSINDICATOR_EXPORT PosIndicatorInfo : public QObject + { + Q_OBJECT + +public : + /* + * Constructor + */ + PosIndicatorInfo(); + + /* + * Destructor + */ + ~PosIndicatorInfo(); + + /** + * Requests for positioning information from Positioning Indicator + * Helper Server.PosInfoUpdated() will be emitted when + * position information is available. + * + */ + void requestPosInfo(); + + /** + * Cancels position info request. + */ + void cancelPosInfo(); + +private: + signals: + /* + * Signal emitted when new position updates available + * When coordinates are available, this object is + * populated with only Position attribute. + * When reverse geo-code address has been resolved, + * the only address fields will be populated. + * + * @param[in] posGeoAddress - Object containing position information + * @param[in] error - Any error code while retrieving position information + * - KTimeOut - if time out during retrieval of position information + */ + void posInfoUpdated(PosGeoAddress& posGeoAddress, int error); + +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosIndicatorInfo) + +private: + /** + * Pointer to private implementation. + * Owns + */ + PosIndicatorInfoPrivate* d_ptr; + }; + +#endif /* POSITIONINDICATORINFO_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posindicatorlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posindicatorlogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,38 @@ +/* +* 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: Implementation of logger. +* +*/ + + +#ifndef POSINDICATORLOGGER_H +#define POSINDICATORLOGGER_H + +#include +#include + +#define FUNC( x ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + RFileLogger::Write( _L("lbs"),_L("PosIndicatorLog.log"),EFileLoggingModeAppend,buffer); } + +#define LOG( x, y ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + buffer.AppendNum(y); \ + RFileLogger::Write( _L("lbs"),_L("PosIndicatorLog.log"),EFileLoggingModeAppend,buffer); } + +#endif /* POSINDICATORLOGGER_H*/ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posindicatorserverconst.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posindicatorserverconst.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2010 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: Declaration of server core class. +* +*/ + +#ifndef POSINDICATORSERVERCONSTS_H +#define POSINDICATORSERVERCONSTS_H + +/** + * Server core name. + */ +_LIT( KPosIndHelperSrvName,"posindicatorhelperserver" ); + + +/** + * Current server version number + * + */ +const TInt8 KMajorVersionNumber = 1; +const TInt8 KMinorVersionNumber = 0; +const TInt16 KBuildVersionNumber = 0; + + +/** + * Service Ids for client service requests. These + * service numbers should be used by the client library + * in all IPC messages to indicate the type of service + * required + */ +enum TServiceIds + { + /* Subsession Open */ + ESubSessionOpen, + /* Subsession Close */ + ESubSessionClose, + /* Get current position */ + EGetCurrentPosition, + /* Get current address info size */ + EGetCurrentAddressInfoSize, + /* Get current address info */ + EGetCurrentAddressInfo, + /* Cancel outstanding request*/ + ECancelCurrentOperation + }; + + +// This position in the IPC message should hold the sub-session handle +const TInt KParamSubsessionHandle = 3; + +// This position in the IPC message should hold last known position. +const TInt KParamLastKnownPosition = 0; + +// This position in the IPC message should hold current position. +const TInt KParamCurrentPosition = 0; + +// This position in the IPC message should hold current address size. +const TInt KParamCurrentAddressSize = 0; + +// This position in the IPC message should hold current address size. +const TInt KParamCurrentAddress = 0; + +#endif // POSINDICATORSERVERCONSTS_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posreversegeocodeinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posreversegeocodeinterface.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2010 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: Declaration of Geo coding interface class. +* +*/ + +#ifndef POSREVERSEGEOCODEINTERFACE_H +#define POSREVERSEGEOCODEINTERFACE_H + +#include +#include + +/* + * Observer class which exposes callbacks to notify the completion of reversegeocoding event. + * + **/ +class MPosReverseGeocodeObserver + { +public: + /* + * Callback function which notifys the completion of reverse geocode event. This signals the completion + * of the asynchronous function CReverseGeoCode::GetAddressByCoordinate. + * + * @param aErrorcode Error status KErrNone in case of success or other system specific errorcodes + * in case of failures. + */ + + virtual void ReverseGeocodeComplete( TInt aErrorcode ) =0; + }; + +/* + * CReverseGeocode + * Concrete class which exposes interfaces to convert the geo-coordinates information + * in to the address information. + * + **/ +class CPosReverseGeocodeInterface : public CBase + { +public: + /* + * Factory function to create the instance of CReverseGeocode Class. This also registers + * observer for getting the reverse geocode completion notifications. + * + * @param[in] aObserver refrence to the instance MReverseGeocodeObserver's + * implementation class. + * @return pointer to the instance of CReverseGeocode. + */ + IMPORT_C static CPosReverseGeocodeInterface* NewL( MPosReverseGeocodeObserver& aObserver ); + + /** + * Unloads the plugin. + */ + IMPORT_C virtual ~CPosReverseGeocodeInterface(); + + /* + * + * Gets the address information for the given geo coordinates. The geo-coordinates should be + * encapsulated inside a landmark object which is passed as argument to this method. This is an + * asyncronous function whose completion will be notified by + * MReverseGeocodeObserver::ReverseGeocodeComplete call back.Address information corresponding to + * coordinates can be retrieved from the same landmarks object. + * + * @param aLandmark[in/out] Landmarks object in which address information is expected. + * + */ + IMPORT_C virtual void GetAddressByCoordinateL( CPosLandmark& aLandmark ) = 0; + + + /** + * Cancels the current operation. + */ + IMPORT_C virtual void Cancel() = 0; +private: + /** + * Instance identifier key + */ + TUid iDtor_ID_Key; + }; + +#endif //POSREVERSEGEOCODEINTERFACE_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/inc/posreversegeocodeinterface.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/inc/posreversegeocodeinterface.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010 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: Resource headers for project +* +*/ + +#ifndef POSREVERSEGEOCODEINTERFACE_HRH +#define POSREVERSEGEOCODEINTERFACE_HRH + +// ECom interface ID for reverse geo-code interface +#define KPosReverseGeoCodeInterfaceId 0x2002E692 + + +#endif // POSREVERSEGEOCODEINTERFACE_HRH diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/bwins/posindicatorhelperu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/bwins/posindicatorhelperu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,57 @@ +EXPORTS + ??0PosIndicatorInfo@@QAE@XZ @ 1 NONAME ; PosIndicatorInfo::PosIndicatorInfo(void) + ?requestPosInfo@PosIndicatorInfo@@QAEXXZ @ 2 NONAME ; void PosIndicatorInfo::requestPosInfo(void) + ?zip@PosGeoAddress@@QBE?AVQString@@XZ @ 3 NONAME ; class QString PosGeoAddress::zip(void) const + ?city@PosGeoAddress@@QBE?AVQString@@XZ @ 4 NONAME ; class QString PosGeoAddress::city(void) const + ??_EPosGeoAddress@@UAE@I@Z @ 5 NONAME ; PosGeoAddress::~PosGeoAddress(unsigned int) + ?trUtf8@PosIndicatorInfo@@SA?AVQString@@PBD0@Z @ 6 NONAME ; class QString PosIndicatorInfo::trUtf8(char const *, char const *) + ?district@PosGeoAddress@@QBE?AVQString@@XZ @ 7 NONAME ; class QString PosGeoAddress::district(void) const + ?country@PosGeoAddress@@QBE?AVQString@@XZ @ 8 NONAME ; class QString PosGeoAddress::country(void) const + ?setState@PosGeoAddress@@QAEXVQString@@@Z @ 9 NONAME ; void PosGeoAddress::setState(class QString) + ?d_func@PosGeoAddress@@ABEPBVPosGeoAddressPrivate@@XZ @ 10 NONAME ; class PosGeoAddressPrivate const * PosGeoAddress::d_func(void) const + ?staticMetaObject@PosIndicatorInfo@@2UQMetaObject@@B @ 11 NONAME ; struct QMetaObject const PosIndicatorInfo::staticMetaObject + ?staticMetaObject@PosGeoAddress@@2UQMetaObject@@B @ 12 NONAME ; struct QMetaObject const PosGeoAddress::staticMetaObject + ?trUtf8@PosGeoAddress@@SA?AVQString@@PBD0@Z @ 13 NONAME ; class QString PosGeoAddress::trUtf8(char const *, char const *) + ?metaObject@PosGeoAddress@@UBEPBUQMetaObject@@XZ @ 14 NONAME ; struct QMetaObject const * PosGeoAddress::metaObject(void) const + ?altitude@PosGeoAddress@@QBEMXZ @ 15 NONAME ; float PosGeoAddress::altitude(void) const + ?tr@PosIndicatorInfo@@SA?AVQString@@PBD0H@Z @ 16 NONAME ; class QString PosIndicatorInfo::tr(char const *, char const *, int) + ?setCountry@PosGeoAddress@@QAEXVQString@@@Z @ 17 NONAME ; void PosGeoAddress::setCountry(class QString) + ?qt_metacast@PosGeoAddress@@UAEPAXPBD@Z @ 18 NONAME ; void * PosGeoAddress::qt_metacast(char const *) + ??_EPosIndicatorInfo@@UAE@I@Z @ 19 NONAME ; PosIndicatorInfo::~PosIndicatorInfo(unsigned int) + ??0PosGeoAddress@@QAE@XZ @ 20 NONAME ; PosGeoAddress::PosGeoAddress(void) + ?qt_metacall@PosGeoAddress@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 21 NONAME ; int PosGeoAddress::qt_metacall(enum QMetaObject::Call, int, void * *) + ?longitude@PosGeoAddress@@QBENXZ @ 22 NONAME ; double PosGeoAddress::longitude(void) const + ?d_func@PosIndicatorInfo@@ABEPBVPosIndicatorInfoPrivate@@XZ @ 23 NONAME ; class PosIndicatorInfoPrivate const * PosIndicatorInfo::d_func(void) const + ?qt_metacall@PosIndicatorInfo@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 24 NONAME ; int PosIndicatorInfo::qt_metacall(enum QMetaObject::Call, int, void * *) + ?latitude@PosGeoAddress@@QBENXZ @ 25 NONAME ; double PosGeoAddress::latitude(void) const + ?d_func@PosIndicatorInfo@@AAEPAVPosIndicatorInfoPrivate@@XZ @ 26 NONAME ; class PosIndicatorInfoPrivate * PosIndicatorInfo::d_func(void) + ?trUtf8@PosGeoAddress@@SA?AVQString@@PBD0H@Z @ 27 NONAME ; class QString PosGeoAddress::trUtf8(char const *, char const *, int) + ?tr@PosIndicatorInfo@@SA?AVQString@@PBD0@Z @ 28 NONAME ; class QString PosIndicatorInfo::tr(char const *, char const *) + ?getStaticMetaObject@PosGeoAddress@@SAABUQMetaObject@@XZ @ 29 NONAME ; struct QMetaObject const & PosGeoAddress::getStaticMetaObject(void) + ?getStaticMetaObject@PosIndicatorInfo@@SAABUQMetaObject@@XZ @ 30 NONAME ; struct QMetaObject const & PosIndicatorInfo::getStaticMetaObject(void) + ?metaObject@PosIndicatorInfo@@UBEPBUQMetaObject@@XZ @ 31 NONAME ; struct QMetaObject const * PosIndicatorInfo::metaObject(void) const + ?setLatitude@PosGeoAddress@@QAEXN@Z @ 32 NONAME ; void PosGeoAddress::setLatitude(double) + ?number@PosGeoAddress@@QBE?AVQString@@XZ @ 33 NONAME ; class QString PosGeoAddress::number(void) const + ?state@PosGeoAddress@@QBE?AVQString@@XZ @ 34 NONAME ; class QString PosGeoAddress::state(void) const + ??1PosGeoAddress@@UAE@XZ @ 35 NONAME ; PosGeoAddress::~PosGeoAddress(void) + ?setStreet@PosGeoAddress@@QAEXVQString@@@Z @ 36 NONAME ; void PosGeoAddress::setStreet(class QString) + ?setCity@PosGeoAddress@@QAEXVQString@@@Z @ 37 NONAME ; void PosGeoAddress::setCity(class QString) + ?street@PosGeoAddress@@QBE?AVQString@@XZ @ 38 NONAME ; class QString PosGeoAddress::street(void) const + ?setDistrict@PosGeoAddress@@QAEXVQString@@@Z @ 39 NONAME ; void PosGeoAddress::setDistrict(class QString) + ?tr@PosGeoAddress@@SA?AVQString@@PBD0H@Z @ 40 NONAME ; class QString PosGeoAddress::tr(char const *, char const *, int) + ?vAccuracy@PosGeoAddress@@QBEMXZ @ 41 NONAME ; float PosGeoAddress::vAccuracy(void) const + ?setNumber@PosGeoAddress@@QAEXVQString@@@Z @ 42 NONAME ; void PosGeoAddress::setNumber(class QString) + ??1PosIndicatorInfo@@UAE@XZ @ 43 NONAME ; PosIndicatorInfo::~PosIndicatorInfo(void) + ?posInfoUpdated@PosIndicatorInfo@@IAEXAAVPosGeoAddress@@H@Z @ 44 NONAME ; void PosIndicatorInfo::posInfoUpdated(class PosGeoAddress &, int) + ?setAltitude@PosGeoAddress@@QAEXM@Z @ 45 NONAME ; void PosGeoAddress::setAltitude(float) + ?d_func@PosGeoAddress@@AAEPAVPosGeoAddressPrivate@@XZ @ 46 NONAME ; class PosGeoAddressPrivate * PosGeoAddress::d_func(void) + ?hAccuracy@PosGeoAddress@@QBEMXZ @ 47 NONAME ; float PosGeoAddress::hAccuracy(void) const + ?setLongitude@PosGeoAddress@@QAEXN@Z @ 48 NONAME ; void PosGeoAddress::setLongitude(double) + ?qt_metacast@PosIndicatorInfo@@UAEPAXPBD@Z @ 49 NONAME ; void * PosIndicatorInfo::qt_metacast(char const *) + ?cancelPosInfo@PosIndicatorInfo@@QAEXXZ @ 50 NONAME ; void PosIndicatorInfo::cancelPosInfo(void) + ?trUtf8@PosIndicatorInfo@@SA?AVQString@@PBD0H@Z @ 51 NONAME ; class QString PosIndicatorInfo::trUtf8(char const *, char const *, int) + ?setZip@PosGeoAddress@@QAEXVQString@@@Z @ 52 NONAME ; void PosGeoAddress::setZip(class QString) + ?tr@PosGeoAddress@@SA?AVQString@@PBD0@Z @ 53 NONAME ; class QString PosGeoAddress::tr(char const *, char const *) + ?setvAccuracy@PosGeoAddress@@QAEXM@Z @ 54 NONAME ; void PosGeoAddress::setvAccuracy(float) + ?sethAccuracy@PosGeoAddress@@QAEXM@Z @ 55 NONAME ; void PosGeoAddress::sethAccuracy(float) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/eabi/posindicatorhelperu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/eabi/posindicatorhelperu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,53 @@ +EXPORTS + _ZN13PosGeoAddress10setCountryE7QString @ 1 NONAME + _ZN13PosGeoAddress11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME + _ZN13PosGeoAddress11qt_metacastEPKc @ 3 NONAME + _ZN13PosGeoAddress11setAltitudeEf @ 4 NONAME + _ZN13PosGeoAddress11setDistrictE7QString @ 5 NONAME + _ZN13PosGeoAddress11setLatitudeEd @ 6 NONAME + _ZN13PosGeoAddress12setLongitudeEd @ 7 NONAME + _ZN13PosGeoAddress12sethAccuracyEf @ 8 NONAME + _ZN13PosGeoAddress12setvAccuracyEf @ 9 NONAME + _ZN13PosGeoAddress16staticMetaObjectE @ 10 NONAME DATA 16 + _ZN13PosGeoAddress19getStaticMetaObjectEv @ 11 NONAME + _ZN13PosGeoAddress6setZipE7QString @ 12 NONAME + _ZN13PosGeoAddress7setCityE7QString @ 13 NONAME + _ZN13PosGeoAddress8setStateE7QString @ 14 NONAME + _ZN13PosGeoAddress9setNumberE7QString @ 15 NONAME + _ZN13PosGeoAddress9setStreetE7QString @ 16 NONAME + _ZN13PosGeoAddressC1Ev @ 17 NONAME + _ZN13PosGeoAddressC2Ev @ 18 NONAME + _ZN13PosGeoAddressD0Ev @ 19 NONAME + _ZN13PosGeoAddressD1Ev @ 20 NONAME + _ZN13PosGeoAddressD2Ev @ 21 NONAME + _ZN16PosIndicatorInfo11qt_metacallEN11QMetaObject4CallEiPPv @ 22 NONAME + _ZN16PosIndicatorInfo11qt_metacastEPKc @ 23 NONAME + _ZN16PosIndicatorInfo14posInfoUpdatedER13PosGeoAddressi @ 24 NONAME + _ZN16PosIndicatorInfo14requestPosInfoEv @ 25 NONAME + _ZN16PosIndicatorInfo16staticMetaObjectE @ 26 NONAME DATA 16 + _ZN16PosIndicatorInfo19getStaticMetaObjectEv @ 27 NONAME + _ZN16PosIndicatorInfoC1Ev @ 28 NONAME + _ZN16PosIndicatorInfoC2Ev @ 29 NONAME + _ZN16PosIndicatorInfoD0Ev @ 30 NONAME + _ZN16PosIndicatorInfoD1Ev @ 31 NONAME + _ZN16PosIndicatorInfoD2Ev @ 32 NONAME + _ZNK13PosGeoAddress10metaObjectEv @ 33 NONAME + _ZNK13PosGeoAddress3zipEv @ 34 NONAME + _ZNK13PosGeoAddress4cityEv @ 35 NONAME + _ZNK13PosGeoAddress5stateEv @ 36 NONAME + _ZNK13PosGeoAddress6numberEv @ 37 NONAME + _ZNK13PosGeoAddress6streetEv @ 38 NONAME + _ZNK13PosGeoAddress7countryEv @ 39 NONAME + _ZNK13PosGeoAddress8altitudeEv @ 40 NONAME + _ZNK13PosGeoAddress8districtEv @ 41 NONAME + _ZNK13PosGeoAddress8latitudeEv @ 42 NONAME + _ZNK13PosGeoAddress9hAccuracyEv @ 43 NONAME + _ZNK13PosGeoAddress9longitudeEv @ 44 NONAME + _ZNK13PosGeoAddress9vAccuracyEv @ 45 NONAME + _ZNK16PosIndicatorInfo10metaObjectEv @ 46 NONAME + _ZTI13PosGeoAddress @ 47 NONAME + _ZTI16PosIndicatorInfo @ 48 NONAME + _ZTV13PosGeoAddress @ 49 NONAME + _ZTV16PosIndicatorInfo @ 50 NONAME + _ZN16PosIndicatorInfo13cancelPosInfoEv @ 51 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posgeoaddress.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posgeoaddress.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,86 @@ +/* +* 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: Data structure containing positioning and address info +* +*/ + +#ifndef POSGEOADDRESS_H +#define POSGEOADDRESS_H + +#include + +#include "posindicatorglobal.h" + +class PosGeoAddressPrivate; + +/** +* PosGeoAddress represents a Location information. +*/ +class POSINDICATOR_EXPORT PosGeoAddress : public QObject + { + Q_OBJECT + + Q_PROPERTY(double latitude READ latitude WRITE setLatitude) + Q_PROPERTY(double longitude READ longitude WRITE setLongitude) + Q_PROPERTY(float hAccuracy READ hAccuracy WRITE sethAccuracy) + Q_PROPERTY(float vAccuracy READ vAccuracy WRITE setvAccuracy) + Q_PROPERTY(float altitude READ altitude WRITE setAltitude) + + Q_PROPERTY(QString country READ country WRITE setCountry) + Q_PROPERTY(QString state READ state WRITE setState) + Q_PROPERTY(QString city READ district WRITE setDistrict) + Q_PROPERTY(QString city READ city WRITE setCity) + Q_PROPERTY(QString zip READ zip WRITE setZip) + Q_PROPERTY(QString street READ street WRITE setStreet) + Q_PROPERTY(QString number READ number WRITE setNumber) + +public: + PosGeoAddress(); + ~PosGeoAddress(); + void setLatitude( double value ); + double latitude() const; + void setLongitude(double value); + double longitude() const; + void sethAccuracy(float value); + float hAccuracy() const; + void setvAccuracy(float value); + float vAccuracy() const; + void setAltitude(float value); + float altitude() const ; + void setCountry(QString value); + QString country() const; + void setState(QString value); + QString state() const; + void setDistrict(QString value); + QString district() const ; + void setCity(QString value); + QString city() const; + void setZip(QString value); + QString zip() const; + void setStreet(QString value); + QString street() const; + void setNumber(QString value); + QString number() const; + +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosGeoAddress) + +private: + /** + * Pointer to private implementation. + * Owns + */ + PosGeoAddressPrivate* d_ptr; + }; +#endif /* POSGEOADDRESS_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posgeoaddress_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posgeoaddress_p.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,52 @@ +/* +* 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: Private implementation of PosGeoAddress class +* +*/ + +#ifndef POSGEOADDRESSPRIVATE_H +#define POSGEOADDRESSPRIVATE_H + +#include "posgeoaddress.h" + +#include + +/** +* Private implementation of PosGeoAddress +*/ +class PosGeoAddressPrivate + { + +public : + + double mLatitude; + double mLongitude; + float mHAccuracy; + float mVAccuracy; + float mAltitude; + + QString mCountry; + QString mState; + QString mDistrict; + QString mCity; + QString mZip; + QString mStreet; + QString mNumber; + + PosGeoAddress* q_ptr; + + Q_DECLARE_PUBLIC(PosGeoAddress); + + }; +#endif /* POSGEOADDRESSPRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindhelperclientrequester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindhelperclientrequester.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Helper Client Requestor +* +*/ + + + +#ifndef POS_IND_HELPER_CLIENTREQUESTER_H +#define POS_IND_HELPER_CLIENTREQUESTER_H + +#include "posindicatorserverconst.h" + +// Forward declaration +class MServerRequestCompletetionObserver; +/** + * Client requestor class. + * + * This is a helper class used by RPosIndicatorHelper class to serve the asynchronous operations + * requested to the server. + */ +class CPosIndHelperClientRequester : public CActive + { +public: + + /** + * Construct a CPosIndHelperClientRequester object. + */ + static CPosIndHelperClientRequester* NewL( MServerRequestCompletetionObserver& aServerRequestCompletetionObserver ); + + /** + * Destructor. + */ + ~CPosIndHelperClientRequester(); + + /** + * Starts the asynchronous operation by setting the iStatus to active + * + * @param[in] aServiceId - Service id of the operation requested + */ + void Start(TServiceIds aServiceId); + +private://Derived from CActive + void RunL(); + TInt RunError( TInt aError ); + void DoCancel(); + +private: + /** + * C++ default constructor + */ + CPosIndHelperClientRequester( MServerRequestCompletetionObserver& aServerRequestCompletetionObserver ); + + /** + *Second phase constructor + */ + void ConstructL(); + +private:// data + + /* + * Handler to the observer which notifies operation completion to the client + */ + MServerRequestCompletetionObserver& iServerRequestCompletetionObserver; + + /* + * Service id of the operation requested. + */ + TServiceIds iServiceId; + }; + +#endif // POS_IND_HELPER_CLIENTREQUESTER_H + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorglobal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,34 @@ +/* +* 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: Positioning Indicators export/import declarations +* +*/ + + +#ifndef POSINDICATOR_GLOBAL_H +#define POSINDICATOR_GLOBAL_H + +#ifdef BUILD_POSINDICATOR + #define POSINDICATOR_EXPORT Q_DECL_EXPORT +#else + #define POSINDICATOR_EXPORT Q_DECL_IMPORT +#endif + + +#endif // POSINDICATOR_GLOBAL_H + +// End of file + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelper.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Helper Client Interface +* +*/ + + + +#ifndef POS_INDICATOR_HELPER_H +#define POS_INDICATOR_HELPER_H + +#include +#include +#include +#include + +#include "posindicatorserverconst.h" +#include "posindicatorlogger.h" + +class CPosIndHelperClientRequester; +class RPosIndicatorHelperServer; +class MPosIndInfoChangeObserver; +class CPosLandmark; + +/** + * A handle to Positioning Indicator Helper Server subsession. This class provides + * methods to use Positioning Indicator Helper service from Positioning Indicator Helper + * Server. + * + * RPosIndicatorHelper is used to create subsession with Positioning Indicator Helper Server. + * This class provides mechanisms for retrieving location + * [coordinate or reverse geo-code info], actively requesting location. + * Before using any of these services, a connection to Positioning Indicator Helper + * Server must first be made. + * + * A client can have multiple sessions connected to the Positioning Indicator Helper + * Server. There can be multiple subsessions opened from one session. + * + * + * @see RPosIndicatorHelperServer + * + * @lib posindicatorhelper.lib + * + */ + +class MServerRequestCompletetionObserver + { +public: + /* + * It will be used to notify RPosIndicatorHelper client that server has completed + * the requested operation. + * + * @param[out] aServiceId - Id of the operation which is requested + * @param[out] aErrCode - Error code if operation is failed + * KErrNone if operation is successful. + */ + virtual void NotifyServerRequestCompletion(TServiceIds aServiceId, TInt aErrCode) = 0; + }; + +class RPosIndicatorHelper : public RSubSessionBase, + public MServerRequestCompletetionObserver + { +public: + + public: + /** + * default constructior. + */ + RPosIndicatorHelper(); + + /** + * destructior. + */ + ~RPosIndicatorHelper(); + + /** + * Opens a subsession with Positioning Indicator Helper Server. + * + * A subsession must be opened before any other service can be used. + * + * @panic PosIndicatorHelper EPosIndicatorHelperServerBadHandle If a session to + * Positioning Indicator Helper Server has not been connected. + * + * @param[in] aServer Reference to the Positioning Indicator Helper Server + * session. + * @param[in] aPosIndInfoChangeObserver Reference to the Positioning + * Indicator Info Change observer. Any change in position information + * is notified by this observer. + * + * @return KErrNone if successful. Otherwise, Symbian standard + * error code is returned, such as KErrNoMemory, KErrServerBusy, etc. + */ + TInt Open( RPosIndicatorHelperServer& aServer, + MPosIndInfoChangeObserver* aPosIndInfoChangeObserver ); + + /** + * Closes the subsession with Positioning Indicator Helper Server. + * + * Close() must be called when RPosIndicatorHelper subsession is no longer required. + * + * Before a subsession is closed, the client application must ensure + * that all outstanding notification requests have been cancelled. In + * particular, the application must issue all the appropriate Cancel + * requests and then wait for a confirmation that the notification has + * been terminated. A failure to do so results in a panic. + * + * @panic PosIndicatorHelper EPosIndicatorHelperRequestsNotCancelled If client application + * has requests outstanding with Positioning Indicator Helper Server. + */ + void Close(); + + /* + * Requests current position information. + * + * It will first request for current location. if it is already available + * it will request for reverse geo-code address. + * + * The result of the request is notified to the client through observer. + */ + void RequestPosInfo(); + + /** + * Cancels the current request + */ + void CancelCurrentRequest(); + + /** + * Symbian 2nd phase construction. + */ + void ConstructL(); + + /* + * from MServerRequestCompletetionObserver + */ + void NotifyServerRequestCompletion(TServiceIds aServiceId, TInt aErrCode); + + private: + /* + * Requests size of landmark object containing current position with + * reverse geo-coded address. + * + * It will request for the reverse geo-coded location giving the + * position coordinates as input. + * + * The size of the landmark object returned from reverse geo-coded + * plugin is notified to the client through observer. + * + */ + void GetAddressInfoSize(); + + /* + * Requests landmark object containing current position with + * reverse geo-coded address. + * + * It will request for the reverse geo-coded location + * + * The landmark object returned from reverse geo-coded + * plugin is notified to the client through observer. + * + */ + void GetAddressL(); + + /* + * Check Hide Coordinates feature flag. + * Uses KLocHideCoordinates CenRep key + */ + void CheckHideCoordinateL(); + + private:// data + + /** + * Pointer to client requestor. + * Own. + */ + CPosIndHelperClientRequester* iClientRequester; + + /** + * It is used to request position details from server + */ + TPositionSatelliteInfo iPositionInfo; + + /** + * It is used to request size of the landmark object from server + */ + TInt iSize; + + /** + * It is used to request the landmark object from the server + * Owns + */ + HBufC8* iLmkBuf; + + /** + * It is used to sent the landmark object to the observer + * Owns + */ + CPosLandmark * iLandmark; + + /** + * It is used to notify PosIndicatorInfoPrivate that new position information + * new position information is available. + * + * Array of observers are not stored here as multiple client requests are actually + * handled by signal-slot mechanism in PosIndicatorInfoPrivate + * Does not own + */ + MPosIndInfoChangeObserver* iPosIndInfoChangeObserver; + + /* + * Holds value of Hide Coordinates CenRep key + */ + TInt iCoordinateSettingValue; + }; +#endif // POS_INDICATOR_HELPER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelpererrors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelpererrors.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2010 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: Position Indicator Helper Client panic category and panic code +* +*/ + + +#ifndef POS_IND_HELPER_ERRORS_H +#define POS_IND_HELPER_ERRORS_H + +#include +#include + +/** + *Position Indicator Helper Client API panic categories + */ +_LIT( KPosIndHelperClientPanicCategory, "PosIndicator" ); + +/** + * Position Indicator Helper Client API panic codes + */ +enum TPosIndicatorHelperClientPanic + { + /** + * An attempt has been made to connect using an already opened handle. + */ + EPosIndicatorHelperServerHandleNotClosed = 1, + /** + * An attempt to communicate using an unconnected handle. + */ + EPosIndicatorHelperServerBadHandle = 2, + /** + * A subsession was closed with requests still outstanding. + */ + EPosIndicatorHelperRequestsNotCancelled = 3, + /** + * A client has called an asynchronous request while it is still outstanding. + */ + EPosIndicatorHelperDuplicateRequest = 5, + /** + * Wrong value is given as parameter. + */ + EPosIndicatorHelperErrArgument = 6 + }; +#endif //POS_IND_HELPER_ERRORS_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelperserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorhelperserver.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Helper Client Library +* +*/ + + + +#ifndef POS_IND_HELPER_SERVER_H +#define POS_IND_HELPER_SERVER_H + + +#include + +#include "posindicatorlogger.h" + +/** + * A handle to Positioning Indicator Helper Server session. + * + * This is generally the first interface class used by all client applications. + * It is used to make the primary connection to the Positioning Indicator Helper Server. + * After the primary connection has been established, its handle is passed as a + * parameter of the Open methods of @p RPosIndicatorHelper to create a subsession. + * + * @lib posindicatorhelper.lib + * + */ +class RPosIndicatorHelperServer : public RSessionBase + { +public: + /** + * Constructor for RPosIndicatorHelperServer + */ + RPosIndicatorHelperServer(); + + /** + * Creates a session with the Positioning Indicator Helper Server. + * This method must be called before any subsession can be opened. + * @see RPosIndicatorHelper. + * + * @panic EPosIndicatorHelperServerHandleNotClosed Try to connect using an already opened handle. + * + * @return KErrNone, if successful. KErrNotSupported if Positioning Indicator Helper + * Server is not present in the system. Otherwise one of the other standard + * Symbian error code (for example KErrNoMemory, KErrServerBusy, etc. ) + * is returned. + */ + TInt Connect(); + + /** + * Closes a session with the Positioning Indicator Helper Server. + * Before the connection to Positioning Indicator Helper Server is closed, the + * client application must ensure that all subsessions is closed. + */ + void Close(); + + /** + * Obtains the client side version number of Positioning Indicator Helper Server. + * + * @return The client side version number. + */ + TVersion Version() const; + +#if defined(__WINSCW__) + TInt StartLbsRootProcess(); +#endif + +private: // data + /** + * Unused variable for future expansion. + */ + TAny* iReserved; + }; + + +#endif //POS_IND_HELPER_SERVER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorinfo.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2010 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: Positioning Indicators Info - QT Wrapper +* +*/ + +#ifndef POSITIONINDICATORINFO_H +#define POSITIONINDICATORINFO_H + +#include + +#include "posgeoaddress.h" +#include "posindicatorglobal.h" + +class PosIndicatorInfoPrivate; + +class POSINDICATOR_EXPORT PosIndicatorInfo : public QObject + { + Q_OBJECT + +public : + /* + * Constructor + */ + PosIndicatorInfo(); + + /* + * Destructor + */ + ~PosIndicatorInfo(); + + /** + * Requests for positioning information from Positioning Indicator + * Helper Server.PosInfoUpdated() will be emitted when + * position information is available. + * + */ + void requestPosInfo(); + + /** + * Cancels position info request. + */ + void cancelPosInfo(); + +private: + signals: + /* + * Signal emitted when new position updates available + * When coordinates are available, this object is + * populated with only Position attribute. + * When reverse geo-code address has been resolved, + * the only address fields will be populated. + * + * @param[in] posGeoAddress - Object containing position information + * @param[in] error - Any error code while retrieving position information + * - KTimeOut - if time out during retrieval of position information + */ + void posInfoUpdated(PosGeoAddress& posGeoAddress, int error); + +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosIndicatorInfo) + +private: + /** + * Pointer to private implementation. + * Owns + */ + PosIndicatorInfoPrivate* d_ptr; + }; + +#endif /* POSITIONINDICATORINFO_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorinfo_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindicatorinfo_p.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2010 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: Positioning Indicators Info private implementation +* +*/ + +#ifndef POSITIONINDICATORINFOPRIVATE_H +#define POSITIONINDICATORINFOPRIVATE_H + +#include "posindicatorinfo.h" +#include "posindinfochangeobserver.h" +#include "posindicatorhelperserver.h" +#include "posindicatorhelper.h" + +class PosGeoAddress; + +class PosIndicatorInfoPrivate : public MPosIndInfoChangeObserver + { +public : + /** + * Constructor + */ + PosIndicatorInfoPrivate(PosIndicatorInfo *aPositionIndicator); + + /** + * Destructor + */ + ~PosIndicatorInfoPrivate(); + + /** + * Requests for positioning information from Positioning Indicator + * Helper Server.NotifyPosInfoChange() will be called when + * position information is available. + * + */ + void RequestPosInfo(); + + /** + * Cancels positon info request. + */ + void CancelPosInfo(); + + /** + * Derived from MPosIndInfoChangeObserver + */ + void NotifyPosInfoChange(CPosLandmark* aLandmark, TInt aErrCode); + +private: + void AddToAddress(TPositionFieldId aFieldId, TPtrC aValue); + +private: + + // Handle to current server session + RPosIndicatorHelperServer mPosIndicatorHelperServer; + + // Handle to current subsession + RPosIndicatorHelper mPosIndicatorHelper; + + /** + * It contains the latest position information + * Owns + */ + PosGeoAddress* mPosGeoAddress; + + /* + * Handler to PosIndicatorInfo. + * It is required to emit PosInfoUpdated() signal + * + * + */ + PosIndicatorInfo* q_ptr; + + Q_DECLARE_PUBLIC(PosIndicatorInfo); + }; + + +#endif /* POSITIONINDICATORINFOPRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindinfochangeobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/inc/posindinfochangeobserver.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Info Change Observer +* +*/ + +#ifndef POSIND_INFOCHANGEOBSERVER_H +#define POSIND_INFOCHANGEOBSERVER_H + +#include + +class MPosIndInfoChangeObserver + { +public: + /* + * It will be used to notify client that position information is changed + * and new information is available. + * + * Landmark object contains coordinate information when location fix is available + * When reverse geo-code information is available, it contains address info. + * + * @param[out] aLandmark - landmark object containing new position information + * Ownership is NOT transferred to the observer. + * @param[out] aErrCode - Error code if operation is failed + * KErrNone if operation is successful. + */ + virtual void NotifyPosInfoChange(CPosLandmark* aLandmark, TInt aErrCode) = 0; + }; + +#endif /* POSIND_INFOCHANGEOBSERVER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/posindicatorhelperclientlib.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/posindicatorhelperclientlib.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,59 @@ +# +# Copyright (c) 2010 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: posindicator plugin project file +# + +TEMPLATE = lib +TARGET = posindicatorhelper +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +QT += core +QT -= gui +MOC_DIR = moc +OBJECTS_DIR = obj + + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 + +LIBS += -llbs \ + -leposlandmarks \ + -lflogger \ + -lCentralRepository + +HEADERS += inc/posindhelperclientrequester.h \ + inc/posindicatorhelper.h \ + inc/posindicatorhelperserver.h \ + inc/posindicatorhelpererrors.h \ + inc/posindicatorinfo_p.h \ + inc/posindicatorglobal.h \ + inc/posindicatorinfo.h \ + inc/posgeoaddress.h + +SOURCES += src/posindicatorhelper.cpp \ + src/posindicatorhelperserver.cpp \ + src/posindhelperclientrequester.cpp \ + src/posindicatorinfo_p.cpp \ + src/posindicatorinfo.cpp \ + src/posgeoaddress.cpp + +symbian: + { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += BUILD_POSINDICATOR + TARGET.UID3 = 0x2002E688 + TARGET.CAPABILITY = CAP_GENERAL_DLL + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posgeoaddress.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posgeoaddress.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,264 @@ +/* +* Copyright (c) 2010 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: Data structure containing positioning and address info +* +*/ + +#include "posgeoaddress.h" +#include "posgeoaddress_p.h" +#include "posindicatorlogger.h" + + +// --------------------------------------------------------------------------- +// PosGeoAddress::PosGeoAddress() +// --------------------------------------------------------------------------- +PosGeoAddress::PosGeoAddress() + { + d_ptr = new PosGeoAddressPrivate; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::~PosGeoAddress() +// --------------------------------------------------------------------------- +PosGeoAddress::~PosGeoAddress() + { + delete d_ptr; + } +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setLatitude( double value ) + { + FUNC("+ PosGeoAddress::setLatitude"); + d_ptr->mLatitude = value; + FUNC("- PosGeoAddress::setLatitude"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +double PosGeoAddress::latitude() const + { + FUNC("+ PosGeoAddress::latitude"); + return d_ptr->mLatitude; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setLongitude(double value) + { + FUNC("+ PosGeoAddress::setLongitude"); + d_ptr->mLongitude = value; + FUNC("- PosGeoAddress::setLongitude"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +double PosGeoAddress::longitude() const + { + FUNC("+ PosGeoAddress::longitude"); + return d_ptr->mLongitude; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::sethAccuracy(float value) + { + FUNC("+ PosGeoAddress::sethAccuracy"); + d_ptr->mHAccuracy = value; + FUNC("- PosGeoAddress::sethAccuracy"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +float PosGeoAddress::hAccuracy() const + { + FUNC("+ PosGeoAddress::hAccuracy"); + return d_ptr->mHAccuracy; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setvAccuracy(float value) + { + FUNC("+ PosGeoAddress::setvAccuracy"); + d_ptr->mVAccuracy = value; + FUNC("- PosGeoAddress::setvAccuracy"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +float PosGeoAddress::vAccuracy() const + { + FUNC("+ PosGeoAddress::vAccuracy"); + return d_ptr->mVAccuracy; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setAltitude(float value) + { + FUNC("+ PosGeoAddress::setAltitude"); + d_ptr->mAltitude = value; + FUNC("- PosGeoAddress::setAltitude"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +float PosGeoAddress::altitude() const + { + FUNC("+ PosGeoAddress::altitude"); + return d_ptr->mAltitude; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setCountry(QString value) + { + FUNC("+ PosGeoAddress::setCountry"); + d_ptr->mCountry = value; + FUNC("- PosGeoAddress::setCountry"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::country() const + { + FUNC("+ PosGeoAddress::country"); + return d_ptr->mCountry; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setState(QString value) + { + FUNC("+ PosGeoAddress::setState"); + d_ptr->mState = value; + FUNC("- PosGeoAddress::setState"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::state() const + { + FUNC("+ PosGeoAddress::state"); + return d_ptr->mState; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setDistrict(QString value) + { + FUNC("+ PosGeoAddress::setDistrict"); + d_ptr->mDistrict = value; + FUNC("- PosGeoAddress::setDistrict"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::district() const + { + FUNC("+ PosGeoAddress::district"); + return d_ptr->mDistrict; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setCity(QString value) + { + FUNC("+ PosGeoAddress::setCity"); + d_ptr->mCity = value; + FUNC("- PosGeoAddress::setCity"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::city() const + { + FUNC("+ PosGeoAddress::city"); + return d_ptr->mCity; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setZip(QString value) + { + FUNC("+ PosGeoAddress::setZip"); + d_ptr->mZip = value; + FUNC("- PosGeoAddress::setZip"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::zip() const + { + FUNC("+ PosGeoAddress::zip"); + return d_ptr->mZip; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setStreet(QString value) + { + FUNC("+ PosGeoAddress::setStreet"); + d_ptr->mStreet = value; + FUNC("- PosGeoAddress::setStreet"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::street() const + { + FUNC("+ PosGeoAddress::street"); + return d_ptr->mStreet; + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +void PosGeoAddress::setNumber(QString value) + { + FUNC("+ PosGeoAddress::setNumber"); + d_ptr->mNumber = value; + FUNC("- PosGeoAddress::setNumber"); + } + +// --------------------------------------------------------------------------- +// PosGeoAddress::setLatitude() +// --------------------------------------------------------------------------- +QString PosGeoAddress::number() const + { + FUNC("+ PosGeoAddress::number"); + return d_ptr->mNumber; + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindhelperclientrequester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindhelperclientrequester.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Helper Client Requestor +* +*/ + + +// INCLUDE FILES + +#include +#include +#include + +#include "posindhelperclientrequester.h" +#include "posindicatorhelper.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CPosIndHelperClientRequester::CPosIndHelperClientRequester +// +// Default constructor +// --------------------------------------------------------- +// +CPosIndHelperClientRequester::CPosIndHelperClientRequester( + MServerRequestCompletetionObserver& aServerRequestCompletetionObserver ): + CActive(EPriorityStandard),iServerRequestCompletetionObserver(aServerRequestCompletetionObserver) + { + FUNC("+ CPosIndHelperClientRequester::CPosIndHelperClientRequester"); + CActiveScheduler::Add(this); + FUNC("- CPosIndHelperClientRequester::CPosIndHelperClientRequester"); + } + +// --------------------------------------------------------------------------- +// CPosIndHelperClientRequester::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CPosIndHelperClientRequester::ConstructL() + { + FUNC("+ CPosIndHelperClientRequester::ConstructL"); + FUNC("- CPosIndHelperClientRequester::ConstructL"); + } + +// --------------------------------------------------------------------------- +// CPosIndHelperClientRequester::NewL() +// +// (other items were commented in a header). +// --------------------------------------------------------------------------- +// +CPosIndHelperClientRequester* CPosIndHelperClientRequester::NewL( + MServerRequestCompletetionObserver& aServerRequestCompletetionObserver ) + { + FUNC("+ CPosIndHelperClientRequester::NewL"); + CPosIndHelperClientRequester* self = new (ELeave) CPosIndHelperClientRequester( + aServerRequestCompletetionObserver ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + +// --------------------------------------------------------------------------- +// CPosIndHelperClientRequester::~CPosIndHelperClientRequester() +// Destructor +// --------------------------------------------------------------------------- +// +CPosIndHelperClientRequester::~CPosIndHelperClientRequester() + { + FUNC("+ CPosIndHelperClientRequester::~CPosIndHelperClientRequester"); + Cancel(); + FUNC("- CPosIndHelperClientRequester::~CPosIndHelperClientRequester"); + } + + +// --------------------------------------------------------- +// CPosIndHelperClientRequester::Start +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosIndHelperClientRequester::Start(TServiceIds aServiceId ) + { + FUNC("+ CPosIndHelperClientRequester::Start"); + iServiceId = aServiceId; + SetActive(); + FUNC("- CPosIndHelperClientRequester::Start"); + } + +// --------------------------------------------------------- +// CPosIndHelperClientRequester::RunL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosIndHelperClientRequester::RunL() + { + FUNC("+ CPosIndHelperClientRequester::RunL"); + LOG("Error code : %d", iStatus.Int()); + iServerRequestCompletetionObserver.NotifyServerRequestCompletion( iServiceId, iStatus.Int() ); + FUNC("- CPosIndHelperClientRequester::RunL"); + } + + +// --------------------------------------------------------- +// CPosIndHelperClientRequester::RunError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CPosIndHelperClientRequester::RunError(TInt /*aError*/) + { + FUNC("+ CPosIndHelperClientRequester::RunError"); + return KErrNone; + } + +// --------------------------------------------------------- +// CPosIndHelperClientRequester::DoCancel +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CPosIndHelperClientRequester::DoCancel() + { + FUNC("+ CPosIndHelperClientRequester::DoCancel"); + // iServerRequestCompletetionObserver.NotifyServerRequestCompletion( iServiceId, iStatus.Int() ); + FUNC("- CPosIndHelperClientRequester::DoCancel"); + } +// End of File + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorhelper.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,338 @@ +/* +* Copyright (c) 2010 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: Client-Server communication +* +*/ + +#include "posindicatorhelper.h" +#include "posindicatorhelperserver.h" +#include "posindhelperclientrequester.h" +#include "posindicatorhelpererrors.h" +#include "posindinfochangeobserver.h" + +#include +#include +#include + +#include + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::RPosIndicatorHelper() +// +// Default constructor. +// --------------------------------------------------------------------------- +// + RPosIndicatorHelper::RPosIndicatorHelper() + : iClientRequester(NULL), + iLmkBuf(NULL), + iLandmark(NULL), + iCoordinateSettingValue( ELocCoordinatesNotHidden ) + { + FUNC("+ RPosIndicatorHelper::RPosIndicatorHelper"); + FUNC("- RPosIndicatorHelper::RPosIndicatorHelper"); + } + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::~RPosIndicatorHelper +// +// Destructor. +// --------------------------------------------------------------------------- +// + RPosIndicatorHelper::~RPosIndicatorHelper() + { + FUNC("+ RPosIndicatorHelper::~RPosIndicatorHelper"); + + if(iClientRequester) + { + delete iClientRequester; + iClientRequester = NULL; + } + if(iLmkBuf) + { + delete iLmkBuf; + iLmkBuf = NULL; + } + if(iLandmark) + { + delete iLandmark; + iLandmark = NULL; + } + FUNC("- RPosIndicatorHelper::~RPosIndicatorHelper"); + } + + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::ConstructL +//Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void RPosIndicatorHelper::ConstructL() + { + FUNC("+ RPosIndicatorHelper::ConstructL"); + iClientRequester = CPosIndHelperClientRequester::NewL(*this); + iLandmark = NULL; + CheckHideCoordinateL(); + FUNC("- RPosIndicatorHelper::ConstructL"); + } + + +// --------------------------------------------------------- +// RPosIndicatorHelper::Open +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + TInt RPosIndicatorHelper::Open( RPosIndicatorHelperServer& aServer, + MPosIndInfoChangeObserver* aPosIndInfoChangeObserver ) + { + FUNC("+ RPosIndicatorHelper::Open"); + + __ASSERT_ALWAYS( aPosIndInfoChangeObserver , User::Panic (KPosIndHelperClientPanicCategory, EPosIndicatorHelperServerBadHandle)); + iPosIndInfoChangeObserver = aPosIndInfoChangeObserver; + + __ASSERT_ALWAYS(aServer.Handle() != 0, + User::Panic(KPosIndHelperClientPanicCategory, EPosIndicatorHelperServerBadHandle)); + + __ASSERT_ALWAYS(! SubSessionHandle() , User::Panic (KPosIndHelperClientPanicCategory, EPosIndicatorHelperServerBadHandle)); + TRAPD(ret, ConstructL()); + if (ret == KErrNone) + { + ret = CreateSubSession(aServer, ESubSessionOpen, TIpcArgs()); + } + return ret; + } + +// --------------------------------------------------------- +// RPosIndicatorHelper::Close +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + void RPosIndicatorHelper:: Close() + { + FUNC("+ RPosIndicatorHelper::Close"); + + TBool isActive = iClientRequester->IsActive(); + TInt status = iClientRequester->iStatus.Int(); + + if( isActive && status == KRequestPending ) + { + User::Panic(KPosIndHelperClientPanicCategory, EPosIndicatorHelperRequestsNotCancelled ); + } + + if(SubSessionHandle()) + { + CloseSubSession(ESubSessionClose); + } + + FUNC("- RPosIndicatorHelper::Close"); + } + + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::RequestPosInfo() +// --------------------------------------------------------------------------- +void RPosIndicatorHelper::RequestPosInfo() + { + FUNC("+ RPosIndicatorHelper::RequestPosInfo"); + + __ASSERT_ALWAYS(SubSessionHandle() , User::Panic (KPosIndHelperClientPanicCategory, EPosIndicatorHelperServerBadHandle)); + + if(iClientRequester->IsActive()) + return; // If a previous request for position is alive, ignore this call + + TPckg posSatPckg( iPositionInfo ); + TIpcArgs args; + args.Set(KParamCurrentPosition, &posSatPckg); + + iClientRequester->iStatus = KRequestPending; + SendReceive(EGetCurrentPosition, args , iClientRequester->iStatus); + iClientRequester->Start(EGetCurrentPosition); + FUNC("- RPosIndicatorHelper::RequestPosInfo"); + } + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::GetAddressInfoSizePrivate() +// --------------------------------------------------------------------------- +void RPosIndicatorHelper::GetAddressInfoSize() + { + FUNC("+ RPosIndicatorHelper::RPosIndicatorHelper"); + + // Create buffer and send message to resolve address + TPckg posSatPckg( iSize ); + TIpcArgs args; + args.Set(KParamCurrentAddressSize ,&posSatPckg); + + iClientRequester->iStatus = KRequestPending; + SendReceive(EGetCurrentAddressInfoSize, args, iClientRequester->iStatus); + iClientRequester->Start(EGetCurrentAddressInfoSize); + + FUNC("- RPosIndicatorHelper::GetAddressInfoSize"); + } + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::GetAddressL() +// --------------------------------------------------------------------------- +void RPosIndicatorHelper::GetAddressL() + { + FUNC("+ RPosIndicatorHelper::RPosIndicatorHelper"); + TIpcArgs args; + FUNC(" TIpcArgs args"); + iLmkBuf = HBufC8::NewL(iSize); // Need to check iStatus + FUNC(" HBufC8::NewLC"); + + TPtr8 bufferPtr = iLmkBuf->Des(); + FUNC(" iLmkBuf->Des()"); + + args.Set( KParamCurrentAddress , &bufferPtr); + FUNC(" args.Set"); + + iClientRequester->iStatus = KRequestPending; + SendReceive(EGetCurrentAddressInfo, args, iClientRequester->iStatus); + iClientRequester->Start(EGetCurrentAddressInfo); + + FUNC("- RPosIndicatorHelper::GetAddressL"); + + } + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::CancelCurrentRequest() +// --------------------------------------------------------------------------- +void RPosIndicatorHelper::CancelCurrentRequest() + { + FUNC("+ RPosIndicatorHelper::CancelCurrentRequest"); + if (iClientRequester->IsActive()) + { + SendReceive(ECancelCurrentOperation); + iClientRequester->Cancel(); + } + FUNC("- RPosIndicatorHelper::CancelCurrentRequest"); + } + +// --------------------------------------------------------------------------- +// RPosIndicatorHelper::NotifyServerRequestCompletion() +// --------------------------------------------------------------------------- +void RPosIndicatorHelper::NotifyServerRequestCompletion(TServiceIds aServiceId, TInt aErrCode ) + { + FUNC("+ RPosIndicatorHelper::NotifyServerRequestCompletion"); + TInt err = aErrCode; + switch( aServiceId ) + { + case EGetCurrentPosition: + { + FUNC("case EGetCurrentPosition"); + + //delete old landmark + if(iLandmark) + { + delete iLandmark; + iLandmark = NULL; + } + //if error in retrieval of coordinate info, notify client + if( err!=KErrNone ) + { + LOG("Error in NotifyServerRequestCompletion : %d",err); + //notify client about change in position information + iPosIndInfoChangeObserver->NotifyPosInfoChange( iLandmark, err ); + return; + } + if( iCoordinateSettingValue == ELocCoordinatesNotHidden ) + { + //add coordinate info to landmark object + TRAP(err, + iLandmark = CPosLandmark::NewL(); + TPosition position; + iPositionInfo.GetPosition( position ); + iLandmark->SetPositionL( position ); + ); + + if(err == KErrNone) + { + LOG("No error in NotifyServerRequestCompletion : %d",err); + //notify client about change in position information + iPosIndInfoChangeObserver->NotifyPosInfoChange( iLandmark, err ); + } + } + GetAddressInfoSize(); + break; + } + case EGetCurrentAddressInfoSize: + { + FUNC("case EGetCurrentAddressInfoSize"); + + //delete old landmark + if(iLandmark) + { + delete iLandmark; + iLandmark = NULL; + } + //if error in retrieval of coordinate info, notify client + if( err!=KErrNone ) + { + //notify client about change in position information + iPosIndInfoChangeObserver->NotifyPosInfoChange( iLandmark, err ); + break; + } + GetAddressL(); + break; + } + case EGetCurrentAddressInfo: + { + FUNC("case EGetCurrentAddressInfo"); + + //delete old landmark + if(iLandmark) + { + delete iLandmark; + iLandmark = NULL; + } + //if error in retrieval of coordinate info, notify client + if( err!=KErrNone ) + { + //notify client about change in position information + iPosIndInfoChangeObserver->NotifyPosInfoChange( iLandmark, err ); + } + + //add coordinate info to landmark object + TRAPD(err, + iLandmark = CPosLandmark::NewL(); + iLandmark = PosLandmarkSerialization::UnpackL(*iLmkBuf) + ); + + if(err == KErrNone) + { + //notify client about change in position information + iPosIndInfoChangeObserver->NotifyPosInfoChange( iLandmark, err ); + } + break; + } + default: + { + break; + } + } + FUNC("- RPosIndicatorHelper::NotifyServerRequestCompletion"); + } + +void RPosIndicatorHelper::CheckHideCoordinateL() + { + FUNC("+ RPosIndicatorHelper::CheckHideCoordinateL"); + CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocLocalVariation) ); + CleanupStack::PushL( repository ); + User::LeaveIfError( repository->Get( KLocHideCoordinates, + iCoordinateSettingValue )); + CleanupStack::PopAndDestroy( repository ); + FUNC("+ RPosIndicatorHelper::CheckHideCoordinateL"); + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorhelperserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorhelperserver.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2010 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: Positioning Indicator Helper Client-Server communication +* +*/ + +#include "posindicatorhelperserver.h" +#include "posindicatorhelpererrors.h" +#include "posindicatorserverconst.h" + +#include +#include + +const TInt KDefaultMessageSlots = 255; //max + +// --------------------------------------------------------------------------- +// RPosIndicatorHelperServer::RPosIndicatorHelperServer() +// Default constructor +// --------------------------------------------------------------------------- +// + RPosIndicatorHelperServer :: RPosIndicatorHelperServer():RSessionBase(),iReserved(NULL) + { + FUNC("+ RPosIndicatorHelperServer::RPosIndicatorHelperServer"); + FUNC("- RPosIndicatorHelperServer::RPosIndicatorHelperServer"); + } + +// --------------------------------------------------------- +// RPosIndicatorHelperServer::Connect +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + TInt RPosIndicatorHelperServer::Connect() + { + FUNC("+ RPosIndicatorHelperServer::Connect"); + __ASSERT_ALWAYS(Handle() == 0, User::Panic(KPosIndHelperClientPanicCategory, EPosIndicatorHelperServerHandleNotClosed)); + + TInt ret = CreateSession(KPosIndHelperSrvName, Version(), KDefaultMessageSlots); + + if( ret == KErrNotFound ) + { +#if defined(__WINSCW__) + StartLbsRootProcess(); +#endif + RProcess posIndHelperServerProcess; + ret = posIndHelperServerProcess.Create(KPosIndHelperSrvName, KNullDesC); + + if( ret != KErrNone ) + { + posIndHelperServerProcess.Close(); + return KErrNotFound; + } + + TRequestStatus status; + posIndHelperServerProcess.Rendezvous(status); + + if( status != KRequestPending ) + { + User::WaitForRequest(status); + posIndHelperServerProcess.Kill(KErrNone); + posIndHelperServerProcess.Close(); + return status.Int(); + } + else + { + posIndHelperServerProcess.Resume(); + } + + User::WaitForRequest(status); + posIndHelperServerProcess.Close(); + + if( status != KErrNone ) + { + return (status.Int()); + } + ret = CreateSession(KPosIndHelperSrvName, Version(), KDefaultMessageSlots); + } + + return ret; + } + +// --------------------------------------------------------- +// RPosIndicatorHelperServer::Close +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + void RPosIndicatorHelperServer::Close() + { + FUNC("+ RPosIndicatorHelperServer::Close"); + RSessionBase::Close(); + FUNC("- RPosIndicatorHelperServer::Close"); + } + +// --------------------------------------------------------- +// RPosIndicatorHelperServer::Version +// +// (other items were commented in a header). +// --------------------------------------------------------- +// + TVersion RPosIndicatorHelperServer::Version() const + { + FUNC("+ RPosIndicatorHelperServer::Version"); + return TVersion(KMajorVersionNumber, + KMinorVersionNumber, + KBuildVersionNumber); + } + +#if defined(__WINSCW__) +// --------------------------------------------------------- +// RPosIndicatorHelperServer::Version +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt RPosIndicatorHelperServer::StartLbsRootProcess() + { + FUNC("+ RPosIndicatorHelperServer::StartLbsRootProcess"); + + RProcess lbsrootProcess; + TInt ret = lbsrootProcess.Create(_L("lbsroot"), KNullDesC); + + if( ret != KErrNone ) + { + lbsrootProcess.Close(); + return KErrNotFound; + } + + TRequestStatus status; + lbsrootProcess.Rendezvous(status); + + if( status != KRequestPending ) + { + User::WaitForRequest(status); + lbsrootProcess.Kill(KErrNone); + lbsrootProcess.Close(); + return KErrNotFound; + } + else + { + lbsrootProcess.Resume(); + } + + User::WaitForRequest(status); + lbsrootProcess.Close(); + + if( status != KErrNone ) + { + return (status.Int()); + } + return ret; + } +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorinfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorinfo.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 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: Positioning Indicators Info - QT Wrapper +* +*/ + +#include "posindicatorinfo.h" +#include "posindicatorinfo_p.h" + +// --------------------------------------------------------------------------- +// PositionIndicatorInfo::PositionIndicatorInfo() +// --------------------------------------------------------------------------- + PosIndicatorInfo::PosIndicatorInfo() + { + FUNC("+ PosIndicatorInfo::PosIndicatorInfo"); + d_ptr = new PosIndicatorInfoPrivate(this); + FUNC("- PosIndicatorInfo::PosIndicatorInfo"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfo::~PosIndicatorInfo() +// --------------------------------------------------------------------------- + PosIndicatorInfo::~PosIndicatorInfo() + { + FUNC("+ PosIndicatorInfo::~PosIndicatorInfo"); + delete d_ptr; + d_ptr = NULL; + FUNC("- PosIndicatorInfo::~PosIndicatorInfo"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfo::requestPosInfo() +// --------------------------------------------------------------------------- + void PosIndicatorInfo::requestPosInfo() + { + FUNC("+ PosIndicatorInfo::requestPosInfo"); + d_ptr->RequestPosInfo(); + FUNC("- PosIndicatorInfo::requestPosInfo"); + } + + // --------------------------------------------------------------------------- + // PosIndicatorInfo::cancelPosInfo() + // --------------------------------------------------------------------------- + void PosIndicatorInfo::cancelPosInfo() + { + FUNC("+ PosIndicatorInfo::cancelPosInfo"); + d_ptr->CancelPosInfo(); + FUNC("- PosIndicatorInfo::cancelPosInfo"); + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorinfo_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindhelperclientlib/src/posindicatorinfo_p.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2010 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: Implementation of position indicator private class. +* +*/ + +#include "posindicatorinfo_p.h" +#include "posgeoaddress.h" +#include "posindicatorlogger.h" + +// --------------------------------------------------------------------------- +// PosIndicatorInfoPrivate::PosIndicatorInfoPrivate() +// --------------------------------------------------------------------------- +PosIndicatorInfoPrivate::PosIndicatorInfoPrivate( PosIndicatorInfo *aPositionIndicator ) + : q_ptr(aPositionIndicator) + { + FUNC("+ PosIndicatorInfoPrivate::PosIndicatorInfoPrivate"); + QT_TRAP_THROWING ( + qt_symbian_throwIfError(mPosIndicatorHelperServer.Connect()); + qt_symbian_throwIfError(mPosIndicatorHelper.Open(mPosIndicatorHelperServer, this)); + mPosGeoAddress = NULL; + ) + FUNC("- PosIndicatorInfoPrivate::PosIndicatorInfoPrivate"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfoPrivate::~PosIndicatorInfoPrivate() +// --------------------------------------------------------------------------- +PosIndicatorInfoPrivate::~PosIndicatorInfoPrivate() + { + FUNC("+ PosIndicatorInfoPrivate::~PosIndicatorInfoPrivate"); + if(mPosGeoAddress) + { + delete mPosGeoAddress; + mPosGeoAddress = NULL; + } + mPosIndicatorHelper.CancelCurrentRequest(); + mPosIndicatorHelper.Close(); + mPosIndicatorHelperServer.Close(); + FUNC("- PosIndicatorInfoPrivate::~PosIndicatorInfoPrivate"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfoPrivate::RequestPosInfo() +// --------------------------------------------------------------------------- +void PosIndicatorInfoPrivate::RequestPosInfo() + { + FUNC("+ PosIndicatorInfoPrivate::RequestPosInfo"); + mPosIndicatorHelper.RequestPosInfo(); + FUNC("- PosIndicatorInfoPrivate::RequestPosInfo"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfoPrivate::CancelPosInfo() +// --------------------------------------------------------------------------- +void PosIndicatorInfoPrivate::CancelPosInfo() + { + FUNC("+ PosIndicatorInfoPrivate::CancelPosInfo"); + mPosIndicatorHelper.CancelCurrentRequest(); + FUNC("- PosIndicatorInfoPrivate::CancelPosInfo"); + } + +// --------------------------------------------------------------------------- +// PosIndicatorInfoPrivate::NotifyPosInfoChange() +// --------------------------------------------------------------------------- +void PosIndicatorInfoPrivate::NotifyPosInfoChange(CPosLandmark* aLandmark, TInt aErrCode) + { + FUNC("+ PosIndicatorInfoPrivate::NotifyPosInfoChange"); + + if(mPosGeoAddress) + { + delete mPosGeoAddress; + mPosGeoAddress = NULL; + } + mPosGeoAddress = new PosGeoAddress(); + + if ( aErrCode != KErrNone ) + { + LOG("Error in NotifyPosInfoChange = ",aErrCode); + emit q_ptr->posInfoUpdated(*mPosGeoAddress , aErrCode ); + return; + } + + // Coordinate info + TLocality locality; + TInt err = aLandmark->GetPosition(locality); + + if (err != KErrNone) + { + emit q_ptr->posInfoUpdated( *mPosGeoAddress, err ); + FUNC("Unable to get position, exitting with error"); + return; + } + else + { + mPosGeoAddress->setLatitude(locality.Latitude()); + mPosGeoAddress->setLongitude(locality.Longitude()); + mPosGeoAddress->sethAccuracy(locality.HorizontalAccuracy()); + mPosGeoAddress->setvAccuracy(locality.VerticalAccuracy()); + } + + //reverse geo-code info + TUint numOfPositionFields = aLandmark->NumOfAvailablePositionFields(); + if (numOfPositionFields>0) + { + FUNC("Retrieving Address"); + + TPositionFieldId fieldId; + TPtrC value; + + // Read fields input by reverse geocoding and add to address + FUNC("Reading First Field"); + + fieldId = aLandmark->FirstPositionFieldId(); + aLandmark->GetPositionField( fieldId, value ); + AddToAddress(fieldId, value); + FUNC("Reading Fields"); + + for( int i = 0; iNextPositionFieldId(fieldId); + aLandmark->GetPositionField( fieldId, value ); + AddToAddress(fieldId, value); + } + } + + emit q_ptr->posInfoUpdated(*mPosGeoAddress , aErrCode ); + FUNC("- PosIndicatorInfoPrivate::NotifyPosInfoChange"); + } + +void PosIndicatorInfoPrivate::AddToAddress(TPositionFieldId aFieldId, TPtrC aValue) + { + FUNC("+ PosIndicatorInfoPrivate::AddToAddress"); + switch(aFieldId) + { + case EPositionFieldCountry: + { + mPosGeoAddress->setCountry(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + case EPositionFieldState: + { + mPosGeoAddress->setState(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + case EPositionFieldDistrict: + { + mPosGeoAddress->setDistrict(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + + case EPositionFieldCity: + { + mPosGeoAddress->setCity(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + + case EPositionFieldPostalCode: + { + mPosGeoAddress->setZip(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + + case EPositionFieldStreet: + { + mPosGeoAddress->setStreet(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + + case EPositionFieldStreetExtension: + { + mPosGeoAddress->setNumber(QString::fromUtf16(aValue.Ptr(), + aValue.Length())); + break; + } + + } + FUNC("- PosIndicatorInfoPrivate::AddToAddress"); + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicator.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicator.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,36 @@ +# 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: project file for positioning settings in control panel + + +TEMPLATE = subdirs +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 + +# Build.inf rules +BLD_INF_RULES.prj_mmpfiles += "posindicatorhelperserver/group/posindicatorhelperserver.mmp" +BLD_INF_RULES.prj_mmpfiles += "posreversegeocodeinterface/group/posreversegeocodeinterface.mmp" +BLD_INF_RULES.prj_mmpfiles += "posreversegeocodeplugin/group/posreversegeocodeplugin.mmp" + +SUBDIRS += posindhelperclientlib/posindicatorhelperclientlib.pro +SUBDIRS += posindicatorplugin/posindicator.pro + +DEFINES += BUILD_POSINDICATOR + +BLD_INF_RULES.prj_exports += "rom/posindicator.iby CORE_MW_LAYER_IBY_EXPORT_PATH(posindicator.iby)" \ + "posindhelperclientlib/inc/posgeoaddress.h ./inc/posgeoaddress.h" \ + "posindhelperclientlib/inc/posindicatorglobal.h ./inc/posindicatorglobal.h" \ + "posindhelperclientlib/inc/posindicatorinfo.h ./inc/posindicatorinfo.h" \ + "posindicatorhelperserver/inc/posindicatorserverconst.h ./inc/posindicatorserverconst.h" \ + "posreversegeocodeinterface/inc/posreversegeocodeinterface.h ./inc/posreversegeocodeinterface.h" \ + "posreversegeocodeinterface/inc/posreversegeocodeinterface.hrh ./inc/posreversegeocodeinterface.hrh" \ + +# TODO:This is temporary solution. Once there is support to include bld.inf directly, this needs to be +# removed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2010 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 file provides the information required for building the +* whole of a posindicatorhelperserver. +* +*/ + + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +posindicatorhelperserver.mmp + +PRJ_EXPORTS +../inc/posindicatorserverconst.h |../../inc/posindicatorserverconst.h \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/group/posindicatorhelperserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/group/posindicatorhelperserver.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2010 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 the project specification file for posindicatorhelperserver. +* +*/ + +TARGET posindicatorhelperserver.exe +TARGETTYPE exe +UID 0 0x2002E689 + +CAPABILITY CAP_SERVER -ProtServ + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + +SOURCEPATH ../src +SOURCE posindicatorhelperserverstartup.cpp +SOURCE posindicatorserversession.cpp +SOURCE posindicatorserversubsession.cpp +SOURCE posindicatorservercore.cpp +SOURCE posindicatorsubsessionregistry.cpp +SOURCE posindicatorlocationrequestor.cpp + +LIBRARY euser.lib +LIBRARY lbs.lib +LIBRARY posreversegeocodeinterface.lib +LIBRARY eposlandmarks.lib +LIBRARY flogger.lib +LIBRARY ecom.lib + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorlocationrequestor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorlocationrequestor.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2010 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: Declaration of location requestor class. +* +*/ + +#ifndef POSINDICATORLOCATIONREQUESTOR_H +#define POSINDICATORLOCATIONREQUESTOR_H + +#include +#include +#include +#include "posreversegeocodeinterface.h" + +class CPosIndicatorLocationRequestor : public CActive, + public MPosReverseGeocodeObserver + { + /** + * This defines the different states of location requestor + */ + enum TOperation + { + /** + * Idle state + */ + ENone, + + /** + * Acquiring last known position + */ + ELastKnownPosition, + + /** + * During acquiring location + */ + ECurrentPosition, + + /** + * During acquiring address. + */ + ECurrentAddress + }; +public: + /** + * Factory function that instantiates an object + * of CPosIndicatorLocationRequestor + */ + static CPosIndicatorLocationRequestor* NewL(); + + /** + * Destructor + */ + ~CPosIndicatorLocationRequestor(); + + /** + * Gets current position + */ + void GetCurrentPosition( const RMessage2& aMessage ); + + /** + * Gets current address info size. + */ + void GetCurrentAddressInfoSizeL( const RMessage2& aMessage ); + + /** + * Gets current address info. + */ + void GetCurrentAddressInfoL( const RMessage2& aMessage ); + + /** + * Cancels outstanding request + */ + void CancelRequest( const RMessage2& aMessage ); + + +public: // From MPosReverseGeocodeObserver + virtual void ReverseGeocodeComplete( TInt aErrorcode ); + +protected: // From CActive + void RunL(); + + void DoCancel(); + +private: + /** + * Default constructor. + */ + CPosIndicatorLocationRequestor(); + + /** + * 2nd phase constructor for instantiating member variables + */ + void ConstructL(); + + +private: // Data members + /** + * Queue of position request + */ + RArray iPositionRequestQueue; + + /** + * Queue of address request + */ + RArray iAddressRequestQueue; + /** + * Handle to the location server interface + */ + RPositionServer iPosServer; + + /** + * Handle to create a subsession with the location sever + */ + RPositioner iPositioner; + + /** + * Pointer to reverse geo-coding plugin object + * Own + */ + CPosReverseGeocodeInterface* iReverseGeoCodeInterface; + + /** + * Pointer to landmark object + * Own + */ + CPosLandmark* iLandmark; + + /** + * Pointer to landmarks package. + * Own + */ + HBufC8* iLandmarkPackage; + + /** + * Last known position + */ + TPositionInfo iLastKnownInfo; + + /** + * Requested satellite info. + */ + TPositionSatelliteInfo iPositionInfo; + + /** + * Current operation that is progress. + */ + TOperation iOperation; + }; + +#endif /* POSINDICATORLOCATIONREQUESTOR_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorlogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2010 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: Implementation of logger. +* +*/ + + +#ifndef POSINDICATORLOGGER_H +#define POSINDICATORLOGGER_H + +#include +#include + +#define FUNC( x ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + RFileLogger::Write( _L("lbs"),_L("PosIndicatorLog.log"),EFileLoggingModeAppend,buffer); } + +#define LOG( x, y ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + buffer.AppendNum(y); \ + RFileLogger::Write( _L("lbs"),_L("PosIndicatorLog.log"),EFileLoggingModeAppend,buffer); } + +#endif /* POSINDICATORLOGGER_H*/ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserverconst.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserverconst.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2010 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: Declaration of server core class. +* +*/ + +#ifndef POSINDICATORSERVERCONSTS_H +#define POSINDICATORSERVERCONSTS_H + +/** + * Server core name. + */ +_LIT( KPosIndHelperSrvName,"posindicatorhelperserver" ); + + +/** + * Current server version number + * + */ +const TInt8 KMajorVersionNumber = 1; +const TInt8 KMinorVersionNumber = 0; +const TInt16 KBuildVersionNumber = 0; + + +/** + * Service Ids for client service requests. These + * service numbers should be used by the client library + * in all IPC messages to indicate the type of service + * required + */ +enum TServiceIds + { + /* Subsession Open */ + ESubSessionOpen, + /* Subsession Close */ + ESubSessionClose, + /* Get current position */ + EGetCurrentPosition, + /* Get current address info size */ + EGetCurrentAddressInfoSize, + /* Get current address info */ + EGetCurrentAddressInfo, + /* Cancel outstanding request*/ + ECancelCurrentOperation + }; + + +// This position in the IPC message should hold the sub-session handle +const TInt KParamSubsessionHandle = 3; + +// This position in the IPC message should hold last known position. +const TInt KParamLastKnownPosition = 0; + +// This position in the IPC message should hold current position. +const TInt KParamCurrentPosition = 0; + +// This position in the IPC message should hold current address size. +const TInt KParamCurrentAddressSize = 0; + +// This position in the IPC message should hold current address size. +const TInt KParamCurrentAddress = 0; + +#endif // POSINDICATORSERVERCONSTS_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorservercore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorservercore.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2010 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: Declaration of server core class. +* +*/ + +#ifndef POSINDICATORSERVERCORE_H +#define POSINDICATORSERVERCORE_H + +#include +#include "posindicatorlocationrequestor.h" + +class CPosIndicatorServerCore : public CServer2 + { +public: + /** + * Destructor + * + */ + ~CPosIndicatorServerCore(); + + /** + * Instantiates a new object of + * CPosIndicatorServerCore + * + */ + static CPosIndicatorServerCore* NewLC(); + + /** + * Starts the position indicator server to listen + * to incoming requests + * + * @param[in] aName the name of the server which the + * client will use to connect + */ + void StartL(const TDesC &aName); + + /** + * Returns the handle of location requestor + */ + CPosIndicatorLocationRequestor* GetLocationRequestorHandle() const; + + /** + * Handle session closure. + */ + void HandleSessionClosure() const; + +private: + /** + * C++ constructor. + * + * @param aServerType Sharable or non-sharable sessions. + * + */ + CPosIndicatorServerCore( TServerType aServerType = ESharableSessions ); + + /** + * 2nd phase constructor for instantiating member variables + * + */ + void ConstructL(); + + /** + * From CServer2. Creates a server-side session object. + * + * @param aVersion The version information supplied by the client. + * @param aMessage Represents the details of the client request that + * is requesting the creation of the session. + * + * @return A pointer to the newly created server-side session object + */ + CSession2* NewSessionL(const TVersion& aVersion, + const RMessage2& aMessage) const; + + +private: // Private Data + /** + * Pointer to location requestor object. + * Own + */ + CPosIndicatorLocationRequestor* iLocationRequestor; + + /** + * Session counter + */ + mutable TInt iSessionCount; + }; + + +#endif /* POSINDICATORSERVERCORE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserversession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserversession.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2010 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: Declaration of server session class. +* +*/ + +#ifndef POSINDICATORSERVERSESSION_H +#define POSINDICATORSERVERSESSION_H + +#include + +// Forward declaration +class CPosIndicatorServerCore; +class CPosIndicatorSubSessionRegistry; + +class CPosIndicatorServerSession : public CSession2 + { +public: + /** + * Instantiates a new object of CPosIndicatorServerSession + * + */ + static CPosIndicatorServerSession* NewL( const + CPosIndicatorServerCore& aServerCore ); + +public: // From CSession2 + /** + * Handles the servicing of a client request that + * has been passed to the server via this session. + * + * @param[in] aMessage The message containing the details of + * the client request + * + */ + virtual void ServiceL(const RMessage2 &aMessage); + + /** + * Handles error cases when the ServiceL method leaves. + * + * @param[in] aMessage The message containing the details of + * the client request + * @param[in] aError The error code that the serviceL method + * leaves with + */ + virtual void ServiceError(const RMessage2& aMessage,TInt aError); + + /** + * Handles session closure when the client panics. + * + * @param[in] aMessage The message containing the details of + * the client request + * @param[in] aError The error code that the serviceL method + * leaves with + */ + virtual void Disconnect(const RMessage2& aMessage); + +private: + /** + * Default C++ Constructor + * + * @param[in] aSecureId the secure Id of the client application + * which has created this session object. + * + */ + CPosIndicatorServerSession( const CPosIndicatorServerCore& aServerCore ); + + /** + * Destructor + * + */ + ~CPosIndicatorServerSession(); + + /** + * 2nd phase constructor for instantiating + * member variables + * + * @param[in] aSecureId the secure Id of the client application + * which has created this session object. + */ + void ConstructL(); + + /** + * Create a sub-session object + * + */ + void CreateSubSessionL(const RMessage2 &aMessage); + + /** + * Forwards client request to sub-session + * + * @aMessage[in] The message containing the details of + * the client request + * + */ + void ForwardToSubSessionL(const RMessage2& aMessage); + + +private: //Data + + /** + * Reference to the server object + */ + const CPosIndicatorServerCore& iServerCore; + + /** + * Pointer to the sub-session registry + * Own + */ + CPosIndicatorSubSessionRegistry* iSubSessionRegistry; + }; + +#endif /* POSINDICATORSERVERSESSION_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserversubsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorserversubsession.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2010 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: Declaration of server session class. +* +*/ + +#ifndef POSINDICATORSERVERSUBSESSION_H +#define POSINDICATORSERVERSUBSESSION_H + +#include + +class CPosIndicatorLocationRequestor; + +class CPosIndicatorServerSubsession : public CObject + { +public: + /** + * Instantiates a new object of + * CPosIndicatorServerSubsession + * + * @return a pointer to instance of CLbtSubSession + */ + static CPosIndicatorServerSubsession* NewL( CPosIndicatorLocationRequestor& + aLocationRequestor ); + + /** + * C++ destructor + * + */ + ~CPosIndicatorServerSubsession(); + + /** + * Handles the servicing of a client request that + * has been passed from the session + * + * @aMessage The message containing the details of + * the client request + * + */ + void ServiceL(const RMessage2 &aMessage); + +private: + /** + * C++ Default constructor + * + */ + CPosIndicatorServerSubsession( CPosIndicatorLocationRequestor& + aLocationRequestor ); + + /** + * 2nd phase constructor for instantiating + * member variables + * + */ + void ConstructL(); + +private: // Data member + /** + * Pointer to location requestor object. + * Not own + */ + CPosIndicatorLocationRequestor& iLocationRequestor; + }; +#endif /* POSINDICATORSERVERSUBSESSION_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorsubsessionregistry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/inc/posindicatorsubsessionregistry.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2010 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: Declaration of subsession registry class. +* +*/ +#ifndef POSINDICATORSUBSESSIONREGISTRY_H +#define POSINDICATORSUBSESSIONREGISTRY_H + +#include + +// FORWARD DECLARATIONS +class CObjectCon; +class CObjectConIx; +class CPosIndicatorServerSubsession; + +class CPosIndicatorSubSessionRegistry : public CBase + { +public: + /** + * Instantiates a new object of + * CPosIndicatorSubSessionRegistry + * + * @return pointer to an instance of + * CPosIndicatorSubSessionRegistry + */ + static CPosIndicatorSubSessionRegistry* NewL(); + + /** + * C++ destructor + * + */ + ~CPosIndicatorSubSessionRegistry(); + + /** + * Adds an object instance to the registry and + * takes ownership of the object + * + * @param aSubSession an sub-session object instance + * @return a registry handle to the object instance. + */ + TInt AddSubSessionL( CPosIndicatorServerSubsession* aSubSession ); + + /** + * Removes the subsession from the registry and + * also closes the sub-session handle + * + * @param aHandle a handle to the subsession + * @return KErrNone if handle close successfully, + * ELbtServerBadHandle if handle not found + * + */ + TInt CloseSubSession( TUint aHandle ); + + /** + * Retrieves the appropriate subsession handle + * with the specified index + * + * @param aHandle index to the subsession handle + * @return pointer the subsession + * + */ + CPosIndicatorServerSubsession* SubSessionFromHandle( + TUint aHandle ); + +private: + /** + * Default C++ Constructor + * + */ + CPosIndicatorSubSessionRegistry(); + + /** + * 2nd phase constructor for instantiating + * member variables + * + */ + void ConstructL(); + +private:// Data + /** + * CObject to create the object container + * Own + */ + CObjectIx* iRegistryIndex; + + /** + * Object index container + * Own + */ + CObjectCon* iRegistryContainer; + + /** + * Object index + * Own + */ + CObjectConIx* iRegistryContainerIndex; + }; + +#endif /* POSINDICATORSUBSESSIONREGISTRY_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorhelperserverstartup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorhelperserverstartup.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 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: Position indicator server start up +* +*/ + +#include +#include +#include "posindicatorservercore.h" +#include "posindicatorserverconst.h" +#include "posindicatorlogger.h" + +// --------------------------------------------------------------------------- +// Starts the server core +// --------------------------------------------------------------------------- +// +void StartServerCoreL() + { + FUNC("StartServerCoreL"); + User::LeaveIfError(RThread().RenameMe(KPosIndHelperSrvName)); + + // Install the scheduler and start the LBT server + CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler; + CleanupStack::PushL( scheduler ); + CActiveScheduler::Install( scheduler ); + + CPosIndicatorServerCore* server = CPosIndicatorServerCore::NewLC(); + + // This starts the position indicator server + server->StartL(KPosIndHelperSrvName); + + // Finish rendezvous with launching process + RProcess::Rendezvous( KErrNone ); + + CActiveScheduler::Start(); + CleanupStack::PopAndDestroy( 2, scheduler ); + } + + +GLDEF_C TInt E32Main() + { + FUNC("E32Main"); + __UHEAP_MARK; + + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + + // The ret is initialized to KErrNoMemory so that the function returns + // KErrNoMemory if the cleanupstack allocation fails. + TInt ret = KErrNoMemory; + if (cleanupStack) + { + TRAP(ret, StartServerCoreL()); + delete cleanupStack; + } + + __UHEAP_MARKEND; + return ret; + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorlocationrequestor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorlocationrequestor.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,366 @@ +/* +* Copyright (c) 2010 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: Implementation of location requestor class. +* +*/ + +#include "posindicatorlocationrequestor.h" +#include "posindicatorserverconst.h" +#include "posindicatorlogger.h" + +#include +#include + +_LIT( KServer,"PositionIndicatorServer" ); +static const TInt KMaxUpdateAge = 10; +static const TInt KUpdateTimeOut = 5000000; + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::NewL +// ----------------------------------------------------------------------------- +CPosIndicatorLocationRequestor* CPosIndicatorLocationRequestor::NewL() + { + FUNC("CPosIndicatorLocationRequestor::NewL"); + CPosIndicatorLocationRequestor* self = new ( ELeave ) + CPosIndicatorLocationRequestor; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::~CPosIndicatorLocationRequestor +// ----------------------------------------------------------------------------- +CPosIndicatorLocationRequestor::~CPosIndicatorLocationRequestor() + { + FUNC("CPosIndicatorLocationRequestor::~CPosIndicatorLocationRequestor"); + + // Cancel the current operation. + Cancel(); + + iPositionRequestQueue.Close(); + iAddressRequestQueue.Close(); + iPositioner.Close(); + iPosServer.Close(); + delete iReverseGeoCodeInterface; + iReverseGeoCodeInterface = NULL; + delete iLandmark; + iLandmark = NULL; + delete iLandmarkPackage; + iLandmarkPackage = NULL; + // Release all landmark resources + ReleaseLandmarkResources(); + + // Release all ECOM resources + REComSession::FinalClose(); + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::CPosIndicatorLocationRequestor +// ----------------------------------------------------------------------------- +CPosIndicatorLocationRequestor::CPosIndicatorLocationRequestor():CActive( + EPriorityStandard ) + { + FUNC("CPosIndicatorLocationRequestor::CPosIndicatorLocationRequestor"); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::ConstructL +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::ConstructL() + { + FUNC("CPosIndicatorLocationRequestor::ConstructL"); + iOperation = ENone; + + User::LeaveIfError( iPosServer.Connect() ); + + TInt error = iPositioner.Open( iPosServer ); + + User::LeaveIfError( iPositioner.SetRequestor( + CRequestor::ERequestorService, + CRequestor::EFormatApplication, + KServer ) ); + + TPositionUpdateOptions updateops; + updateops.SetUpdateTimeOut(TTimeIntervalMicroSeconds(KUpdateTimeOut)); + User::LeaveIfError( iPositioner.SetUpdateOptions( updateops )); + + iReverseGeoCodeInterface = CPosReverseGeocodeInterface::NewL( *this ); + + iLandmark = CPosLandmark::NewL(); + + iLandmarkPackage = NULL; + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::GetCurrentPosition +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::GetCurrentPosition( const RMessage2& + aMessage ) + { + FUNC("CPosIndicatorLocationRequestor::GetCurrentPosition"); + // If location fix is already available and this is waiting for address info, + // reply the message with the fix available + if( iOperation == ECurrentAddress ) + { + FUNC("iOperation == ECurrentAddress"); + TPckg posSatPckg( iPositionInfo ); + TInt error = aMessage.Write( KParamCurrentPosition,posSatPckg ); + aMessage.Complete( error ); + } + else + { + FUNC("iOperation != ECurrentAddress"); + // Store client's message + iPositionRequestQueue.Append( aMessage ); + // If the requestor is idle without doing any operation, request + // current location. + if( iOperation == ENone ) + { + FUNC("iOperation == ENone"); + iOperation = ELastKnownPosition; + + // Last known position. + iPositioner.GetLastKnownPosition( iLastKnownInfo,iStatus ); + SetActive(); + } + } + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::GetCurrentAddressInfoSizeL +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::GetCurrentAddressInfoSizeL( const RMessage2& + aMessage ) + { + FUNC("CPosIndicatorLocationRequestor::GetCurrentAddressInfoSizeL"); + // Store client's message + iAddressRequestQueue.Append( aMessage ); + + // If the requestor is idle without doing any operation, request + // address information. + if( iOperation == ENone ) + { + iOperation = ECurrentAddress; + // Clear previous landmark information. + iLandmark->RemoveLandmarkAttributes( CPosLandmark::EAllAttributes ); + TPosition position; + iPositionInfo.GetPosition( position ); + iLandmark->SetPositionL( position ); + iReverseGeoCodeInterface->GetAddressByCoordinateL( *iLandmark ); + } + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::GetCurrentAddressInfoL +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::GetCurrentAddressInfoL( const RMessage2& + aMessage ) + { + FUNC("CPosIndicatorLocationRequestor::GetCurrentAddressInfoL"); + TInt error = aMessage.Write( KParamCurrentAddress,*iLandmarkPackage ); + aMessage.Complete( error ); + } + + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::RunL +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::RunL() + { + FUNC("CPosIndicatorLocationRequestor::RunL"); + LOG("Error Status : ", iStatus.Int()); + switch( iOperation ) + { + case ELastKnownPosition: + { + // Check the time stamp of the last fix, if the fix is 10 sec + // old, request for the new fix. + TPosition position; + iLastKnownInfo.GetPosition( position ); + TTime timeOfFix = position.Time(); + TTime currentTime; + currentTime.HomeTime(); + timeOfFix += TTimeIntervalSeconds( KMaxUpdateAge ); + if( iStatus.Int() == KErrNone && timeOfFix < currentTime && + !(Math::IsNaN( position.Latitude() ) || Math::IsNaN( position.Longitude() ) ) ) + { + // Set the last knowm position to position info to send it to + // client. + iPositionInfo.SetPosition( position ); + } + else + { + iOperation = ECurrentPosition; + + // Request current position. + iPositioner.NotifyPositionUpdate( iPositionInfo,iStatus ); + SetActive(); + return; + } + } + case ECurrentPosition: + { + // Reset operation id + iOperation = ENone; + // Pack the satellite position information + TPckg posSatPckg( iPositionInfo ); + TInt count = iPositionRequestQueue.Count(); + for( TInt i=0;i size( iLandmarkPackage->Size() ); + error = iAddressRequestQueue[i].Write( KParamCurrentAddressSize,size ); + } + iAddressRequestQueue[i].Complete( error ); + } + // All the messages in the address request queue are completed. Hence reset the list. + iAddressRequestQueue.Reset(); + break; + } + + default: + { + FUNC("- CPosIndicatorLocationRequestor::RunL default case"); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::CancelRequest +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::CancelRequest( const RMessage2& aMessage ) + { + // Iterate through the outstanding request and check whether there are + // outstanding request from the subsession from which cancel call is + // received. + RMessage2 outStandingMessage; + TBool outStandingFlag = EFalse; + TInt count = iPositionRequestQueue.Count(); + for( TInt i=0;iCancel(); + break; + } + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CPosIndicatorLocationRequestor::ReverseGeocodeComplete +// ----------------------------------------------------------------------------- +void CPosIndicatorLocationRequestor::ReverseGeocodeComplete( TInt aErrorcode ) + { + FUNC("CPosIndicatorLocationRequestor::ReverseGeocodeComplete"); + // Here we self complete our active to release the control from this + // call back method. + iStatus = KRequestPending; + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr,aErrorcode ); + } + +// End of file. diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorservercore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorservercore.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2010 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: Implementation of server core class. +* +*/ + +#include "posindicatorservercore.h" +#include "posindicatorserversession.h" +#include "posindicatorserverconst.h" +#include "posindicatorlogger.h" + +// Priorty of server +// This number has its origin in Symbian development. +// The priority of a server active object should be 950. +enum + { + EPriority=950 + }; + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::NewLC +//--------------------------------------------------------------- +CPosIndicatorServerCore* CPosIndicatorServerCore::NewLC() + { + FUNC("CPosIndicatorServerCore::NewLC"); + CPosIndicatorServerCore* self = new( ELeave ) + CPosIndicatorServerCore; + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::CPosIndicatorServerCore +//--------------------------------------------------------------- +CPosIndicatorServerCore::CPosIndicatorServerCore( + TServerType aServerType ): + CServer2( EPriority,aServerType ), + iSessionCount( 0 ) + { + FUNC("CPosIndicatorServerCore::CPosIndicatorServerCore"); + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::~CPosIndicatorServerCore +//--------------------------------------------------------------- +CPosIndicatorServerCore::~CPosIndicatorServerCore() + { + FUNC("CPosIndicatorServerCore::~CPosIndicatorServerCore"); + delete iLocationRequestor; + iLocationRequestor = NULL; + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::StartL +//--------------------------------------------------------------- +void CPosIndicatorServerCore::StartL(const TDesC &aName) + { + FUNC("CPosIndicatorServerCore::StartL"); + CServer2::StartL(aName); + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::ConstructL +//--------------------------------------------------------------- +void CPosIndicatorServerCore::ConstructL() + { + FUNC("CPosIndicatorServerCore::ConstructL"); + iLocationRequestor = CPosIndicatorLocationRequestor::NewL(); + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::NewSessionL +//--------------------------------------------------------------- +CSession2* CPosIndicatorServerCore::NewSessionL( const TVersion& aVersion, + const RMessage2& /*aMessage*/ ) const + { + FUNC("CPosIndicatorServerCore::NewSessionL"); + // Check if we're the right version + TVersion version( KMajorVersionNumber, + KMinorVersionNumber, + KBuildVersionNumber ); + if (!User::QueryVersionSupported(version, aVersion)) + { + User::Leave(KErrNotSupported); + } + CPosIndicatorServerSession* session = CPosIndicatorServerSession::NewL( *this ); + iSessionCount++; + return session; + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::GetLocationRequestorHandle +//--------------------------------------------------------------- +CPosIndicatorLocationRequestor* CPosIndicatorServerCore:: + GetLocationRequestorHandle() const + { + FUNC("CPosIndicatorServerCore::GetLocationRequestorHandle"); + return iLocationRequestor; + } + +//--------------------------------------------------------------- +// CPosIndicatorServerCore::HandleSessionClosure +//--------------------------------------------------------------- +void CPosIndicatorServerCore::HandleSessionClosure() const + { + FUNC("CPosIndicatorServerCore::HandleSessionClosure"); + // If all the sessions are closed, server should exit. + // This can be achieved by stop the active scheduler. + iSessionCount--; + + // Check the count of session iterator + if( !iSessionCount ) + { + CActiveScheduler::Stop(); + } + } + + +// End of file. diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorserversession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorserversession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2010 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: Implementation of server session class. +* +*/ + +#include "posindicatorserversession.h" +#include "posindicatorservercore.h" +#include "posindicatorserversubsession.h" +#include "posindicatorserverconst.h" +#include "posindicatorsubsessionregistry.h" +#include "posindicatorlogger.h" + +//--------------------------------------------------------------- +// CPosIndicatorServerSession::NewL +//--------------------------------------------------------------- +CPosIndicatorServerSession* CPosIndicatorServerSession::NewL( + const CPosIndicatorServerCore& aServerCore ) + { + FUNC("CPosIndicatorServerSession::NewL"); + CPosIndicatorServerSession* self = new( ELeave ) + CPosIndicatorServerSession( aServerCore ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +//--------------------------------------------------------------- +// CPosIndicatorServerSession::CPosIndicatorServerSession +//--------------------------------------------------------------- +CPosIndicatorServerSession::CPosIndicatorServerSession( + const CPosIndicatorServerCore& aServerCore ): + iServerCore( aServerCore ) + { + FUNC("CPosIndicatorServerSession::CPosIndicatorServerSession"); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSession::~CPosIndicatorServerSession +// Destructor +// --------------------------------------------------------------------------- +// +CPosIndicatorServerSession::~CPosIndicatorServerSession() + { + FUNC("CPosIndicatorServerSession::~CPosIndicatorServerSession"); + delete iSubSessionRegistry; + iServerCore.HandleSessionClosure(); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSession::ConstructL() +// 2nd phase constructor for instantiating member variables +// --------------------------------------------------------------------------- +void CPosIndicatorServerSession::ConstructL() + { + FUNC("CPosIndicatorServerSession::ConstructL"); + iSubSessionRegistry = CPosIndicatorSubSessionRegistry::NewL(); + } + +//--------------------------------------------------------------- +// CPosIndicatorServerSession::SecureId +//--------------------------------------------------------------- +void CPosIndicatorServerSession::ServiceL( const RMessage2 &aMessage ) + { + FUNC("CPosIndicatorServerSession::ServiceL"); + switch( aMessage.Function() ) + { + case ESubSessionOpen: + { + FUNC("ESubSessionOpen"); + CreateSubSessionL( aMessage ); + break; + } + case ESubSessionClose: + { + FUNC("ESubSessionClose"); + // Close the sub-session and free the sub-session object + TInt retVal = iSubSessionRegistry->CloseSubSession( aMessage.Int3() ); + aMessage.Complete( retVal ); + break; + } + default: // Forward other messages to the sub-session + { + ForwardToSubSessionL( aMessage ); + break; + } + } + } + +//--------------------------------------------------------------- +// CPosIndicatorServerSession::SecureId +//--------------------------------------------------------------- +void CPosIndicatorServerSession::ServiceError( const RMessage2& aMessage, + TInt aError ) + { + FUNC("CPosIndicatorServerSession::ServiceError"); + aMessage.Complete( aError ); + } + +//--------------------------------------------------------------- +// CPosIndicatorServerSession::Disconnect +//--------------------------------------------------------------- +void CPosIndicatorServerSession::Disconnect( const RMessage2& aMessage ) + { + FUNC("CPosIndicatorServerSession::Disconnect"); + CSession2::Disconnect( aMessage ); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSession::CreateSubSessionL +// --------------------------------------------------------------------------- +// +void CPosIndicatorServerSession::CreateSubSessionL( const RMessage2& aMessage ) + { + FUNC("CPosIndicatorServerSession::CreateSubSessionL"); + CPosIndicatorServerSubsession* subSession = + CPosIndicatorServerSubsession::NewL( + *iServerCore.GetLocationRequestorHandle()); + CleanupStack::PushL( subSession ); + // If the NewL cannot allocate then it leaves with KErrMemory. In such a + // scenario the ServiceError is invoked which responds to the IPC message + // with the error code. Hence no special handling is required for + // KErrNoMemory here. + + TInt subSessionHandle = iSubSessionRegistry->AddSubSessionL( subSession ); + CleanupStack::Pop(subSession); // subSession ownership taken by registry + + // Set the client subsession identifier. + TPckg handlePackage( subSessionHandle ); + TInt retVal = aMessage.Write( KParamSubsessionHandle,handlePackage ); + + // The error code from Write has to be handled as below, + // If the retVal is an error code then + // close the open subsession first. + // If error is KErrBadDescriptor then panic the client + // else complete the message with the error code. + // else complete the message with KErrNone. + if ( retVal != KErrNone ) + { + // close the open subsession first. + iSubSessionRegistry->CloseSubSession( subSessionHandle ); + } + aMessage.Complete( retVal ); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSession::ForwardToSubSessionL +// --------------------------------------------------------------------------- +void CPosIndicatorServerSession::ForwardToSubSessionL(const RMessage2& aMessage) + { + FUNC("CPosIndicatorServerSession::ForwardToSubSessionL"); + CPosIndicatorServerSubsession* subSession = + iSubSessionRegistry->SubSessionFromHandle(aMessage.Int3()); + + if (!subSession) + { + // Complete client's request if the sub-session handle is not + // present in the registry + aMessage.Complete( KErrNotFound ); + } + else + { + subSession->ServiceL(aMessage); + } + } +// End of file. diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorserversubsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorserversubsession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2010 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: Implementation of subsession class. +* +*/ + +// INCLUDES +#include "posindicatorserversubsession.h" +#include "posindicatorserversession.h" +#include "posindicatorservercore.h" +#include "posindicatorlocationrequestor.h" +#include "posindicatorserverconst.h" +#include "posindicatorlogger.h" + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSubsession::NewL +// --------------------------------------------------------------------------- +CPosIndicatorServerSubsession* CPosIndicatorServerSubsession::NewL( + CPosIndicatorLocationRequestor& + aLocationRequestor ) + { + FUNC("CPosIndicatorServerSubsession::NewL"); + CPosIndicatorServerSubsession* self = new ( ELeave ) + CPosIndicatorServerSubsession( aLocationRequestor ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSubsession::CPosIndicatorServerSubsession +// --------------------------------------------------------------------------- +CPosIndicatorServerSubsession::CPosIndicatorServerSubsession( + CPosIndicatorLocationRequestor& + aLocationRequestor ): + iLocationRequestor( aLocationRequestor ) + { + FUNC("CPosIndicatorServerSubsession::CPosIndicatorServerSubsession"); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSubsession::~CPosIndicatorServerSubsession +// --------------------------------------------------------------------------- +CPosIndicatorServerSubsession::~CPosIndicatorServerSubsession() + { + FUNC("CPosIndicatorServerSubsession::~CPosIndicatorServerSubsession"); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSubsession::ConstructL +// --------------------------------------------------------------------------- +void CPosIndicatorServerSubsession::ConstructL() + { + FUNC("CPosIndicatorServerSubsession::ConstructL"); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorServerSubsession::ServiceL +// --------------------------------------------------------------------------- +void CPosIndicatorServerSubsession::ServiceL( const RMessage2 &aMessage ) + { + FUNC("+ CPosIndicatorServerSubsession::ServiceL"); + switch( aMessage.Function() ) + { + case EGetCurrentPosition: + { + iLocationRequestor.GetCurrentPosition( aMessage ); + break; + } + case EGetCurrentAddressInfoSize: + { + iLocationRequestor.GetCurrentAddressInfoSizeL( aMessage ); + break; + } + case EGetCurrentAddressInfo: + { + iLocationRequestor.GetCurrentAddressInfoL( aMessage ); + break; + } + case ECancelCurrentOperation: + { + iLocationRequestor.CancelRequest( aMessage ); + break; + } + default: + aMessage.Complete( KErrNotFound ); + } + } + +// end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorsubsessionregistry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorhelperserver/src/posindicatorsubsessionregistry.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 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: Implementation of subsession registry class. +* +*/ + + +// INCLUDE FILES + +#include "posindicatorsubsessionregistry.h" +#include "posindicatorserversubsession.h" +#include "posindicatorlogger.h" +#include + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::NewL +// --------------------------------------------------------------------------- +CPosIndicatorSubSessionRegistry* CPosIndicatorSubSessionRegistry::NewL() + { + FUNC("CPosIndicatorSubSessionRegistry::NewL"); + CPosIndicatorSubSessionRegistry* self = new ( ELeave ) CPosIndicatorSubSessionRegistry; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::CPosIndicatorSubSessionRegistry +// --------------------------------------------------------------------------- +CPosIndicatorSubSessionRegistry::CPosIndicatorSubSessionRegistry() + { + FUNC("CPosIndicatorSubSessionRegistry::CPosIndicatorSubSessionRegistry"); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::~CPosIndicatorSubSessionRegistry +// --------------------------------------------------------------------------- +CPosIndicatorSubSessionRegistry::~CPosIndicatorSubSessionRegistry() + { + FUNC("CPosIndicatorSubSessionRegistry::~CPosIndicatorSubSessionRegistry"); + delete iRegistryIndex; + delete iRegistryContainerIndex; + } + + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::ConstructL +// --------------------------------------------------------------------------- +void CPosIndicatorSubSessionRegistry::ConstructL() + { + FUNC("CPosIndicatorSubSessionRegistry::ConstructL"); + iRegistryIndex = CObjectIx::NewL(); + iRegistryContainerIndex = CObjectConIx::NewL(); + iRegistryContainer = iRegistryContainerIndex->CreateL(); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::AddSubSessionL +// --------------------------------------------------------------------------- +TInt CPosIndicatorSubSessionRegistry::AddSubSessionL( + CPosIndicatorServerSubsession* aSubSession) + { + FUNC("CPosIndicatorSubSessionRegistry::AddSubSessionL"); + iRegistryContainer->AddL( aSubSession ); + return iRegistryIndex->AddL( aSubSession ); + } + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::CloseSubSession +// --------------------------------------------------------------------------- +TInt CPosIndicatorSubSessionRegistry::CloseSubSession( TUint aHandle ) + { + FUNC("CPosIndicatorSubSessionRegistry::CloseSubSession"); + if ( iRegistryIndex->At( aHandle ) ) + { + // Removes the sub-session object and closes + // the handle i,e. destroys the object + iRegistryIndex->Remove( aHandle ); + return KErrNone; + } + return KErrBadHandle; + } + +// --------------------------------------------------------------------------- +// CPosIndicatorSubSessionRegistry::SubSessionFromHandle +// --------------------------------------------------------------------------- +CPosIndicatorServerSubsession* CPosIndicatorSubSessionRegistry:: + SubSessionFromHandle( TUint aHandle ) + { + FUNC("CPosIndicatorSubSessionRegistry::SubSessionFromHandle"); + return static_cast (iRegistryIndex->At(aHandle)); + } + +// end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/inc/apilogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/inc/apilogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,37 @@ +/* +* 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + +#include +#include +#include +#include +#include + +using namespace std; + +// Flag to enable NFT logging +//#define POSINDICATOR_NFT + +class ApiLogger + { + public: + static void OpenLogFile(); + static void CloseLogFile(); + static void MyOutputHandler(QtMsgType type, const char *msg); + static void NftLogger( const QString msg ); + }; + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/inc/posindicator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/inc/posindicator.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2003-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: Implementation for positioning indicator plugin class +* +*/ + +#ifndef POS_INDICATOR_PLUGIN_H +#define POS_INDICATOR_PLUGIN_H + +#include +#include +#include + +#include +#include + + +class PosIndicatorInfo; +class PosGeoAddress; +class QTranslator; + +// Indicator Plugin class +class PosIndicatorPlugin : public QObject, public HbIndicatorPluginInterface +{ + Q_OBJECT + Q_INTERFACES(HbIndicatorPluginInterface) + +public: + /** + * Constructor + */ + PosIndicatorPlugin(); + /** + * Destructor + */ + ~PosIndicatorPlugin(); + + /** + * Returns indicator types implemented by this plugin + * @return List of strings that denote indicator types implemented + */ + QStringList indicatorTypes() const; + + /** + * creates an indicator of type indicatorType + * @param[in] String representing indicator type + * @return Pointer to HbIndicatorInterface + */ + HbIndicatorInterface* createIndicator(const QString &indicatorType); + + /** + * Virtual function to check for capabilities for calling client + * @return true if client has Location capability + false if client does not have Location capability + */ + bool accessAllowed(const QString &indicatorType, const QVariantMap &securityInfo) const; + + /** + * Returns the last error code + * @return error code integer + */ + int error() const; + +private: + Q_DISABLE_COPY(PosIndicatorPlugin) + int mError; + QStringList mIndicatorTypes; + /** + * Holds localization translator handle + * OWns + */ + QTranslator* mTranslator; +}; + +// Indicator class that the indicator plugin implements +class PosIndicator : public HbIndicatorInterface +{ + Q_OBJECT +public: + /** + * Constructor + */ + PosIndicator(const QString &indicatorType); + + /** + * Destructor + */ + ~PosIndicator(); + + /** + * Returns the data element store based on role + * @param[in] role + * @return Data stored for the role. + */ + QVariant indicatorData(int role) const; + + /* + * Called when Indicator menu is about to be shown + */ + bool refreshData(); + +private slots: + /* + * Refreshes indicator pane when new position information is available + */ + void refreshPosIndicatorPane(PosGeoAddress& posGeoAddress, int error); + +private : + /* + * Converts decimal coordinate information to Degrees, Minutes, + * Seconds value + */ + void ConvertToDMSFormat(QString &dDisplayString, double decimal); + +private : + + /** + * String containing information to be displayed + */ + QString mDisplayString; + + /** + * Owns + **/ + PosIndicatorInfo* mPosIndicatorInfo; + + /* + * Toggle flag to check whether current signal is returns address or co-ordinates + */ + bool processedAddess; +}; + +#endif // POS_INDICATOR_PLUGIN_H + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/posindicator.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/posindicator.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,59 @@ +# +# Copyright (c) 2010 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: posindicator plugin project file +# + + +TEMPLATE = lib +TARGET = posindicator +CONFIG += hb \ + plugin +MOC_DIR = moc +OBJECTS_DIR = obj +RESOURCES += posindicatorplugin.qrc + +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + +#Uncomment following line to disable logging +#DEFINES += QT_NO_DEBUG_OUTPUT +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 + +HEADERS += inc/posindicator.h \ + inc/apilogger.h +SOURCES += src/posindicator.cpp \ + src/apilogger.cpp + +LIBS += -lposindicatorhelper +symbian { + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = CAP_GENERAL_DLL + TARGET.UID3 = 0x2002E686 + + hblib.sources = Hb.dll + hblib.path = \sys\bin + hblib.depends = "(0xEEF9EA38), 1, 0, 0, {\"Hb\"}" + + pluginstub.sources = posindicator.dll + pluginstub.path = /resource/plugins/indicators + DEPLOYMENT += pluginstub + + # Add translation files + addFiles.sources = translations/lilocationmw.qm + addFiles.path = . + DEPLOYMENT += addFiles +} + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/posindicatorplugin.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/posindicatorplugin.qrc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ + + + translations/lilocationmw.qm + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/src/apilogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/src/apilogger.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,84 @@ +/* +* 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + + +#include "apilogger.h" +#include + +#ifdef POSINDICATOR_NFT +const char* debugFileName("c://logs//lbs//posindicatornftlog.txt"); +#else +const char* debugFileName("c://logs//lbs//posindicatorlog.txt"); +#endif + +ofstream logfile; +QFile file( debugFileName ); + +void ApiLogger::OpenLogFile() +{ +#ifdef POSINDICATOR_NFT + file.open( QIODevice::ReadWrite | QIODevice::Text ) ; +#else + logfile.open(debugFileName, ios::app); +#endif +} + +void ApiLogger::CloseLogFile() +{ +#ifdef POSINDICATOR_NFT + file.close(); +#else + logfile.flush(); + logfile.close(); +#endif + +} + +void ApiLogger::MyOutputHandler(QtMsgType type, const char *msg) +{ + switch (type) { + case QtDebugMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; + break; + case QtCriticalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n"; + break; + case QtWarningMsg: + // logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n"; + break; + case QtFatalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << "\n"; + default: + break; + } + logfile.flush(); +} + + + +void ApiLogger::NftLogger( const QString msg ) + { + QString displayString( msg ); + #ifdef POSINDICATOR_NFT + QTextStream stream( &file ); + QString display( QTime::currentTime().toString("h:m:s:z") ); + display.append( displayString ); + stream << display; + stream.flush(); + #endif + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/src/posindicator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/src/posindicator.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,383 @@ +/* +* Copyright (c) 2010 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: Implementation for positioning indicator plugin class +* +*/ + +#include "posindicator.h" +#include "posindicatorinfo.h" +#include "posgeoaddress.h" +#include "apilogger.h" + +#include +#include +#include +#include +#include + + +Q_EXPORT_PLUGIN(PosIndicatorPlugin) + +// This plugin implements just one indicator type +const QString typeOfIndicator ="com.nokia.positioning.indicatorplugin/1.0"; + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::PosIndicatorPlugin +// --------------------------------------------------------------------------- +// +PosIndicatorPlugin::PosIndicatorPlugin() : mError(0), mTranslator(0) +{ + #ifndef QT_NO_DEBUG_OUTPUT + ApiLogger::OpenLogFile(); + #ifndef POSINDICATOR_NFT + qInstallMsgHandler(ApiLogger::MyOutputHandler); + #endif + #endif + + qDebug() << "+ PosIndicatorPlugin::PosIndicatorPlugin()"; + + mTranslator = new QTranslator(); + + QString locale = QLocale::system().name(); + QString path = "z:/resource/qt/translations/"; + bool loaded = false; + loaded = mTranslator->load(path + QString("lilocationmw_") + locale); + if (loaded == false) + { + loaded = mTranslator->load("lilocationmw", ":/translations"); + } + if (loaded) + { + qApp->installTranslator(mTranslator); + } + + mIndicatorTypes.append(typeOfIndicator); + qDebug() << "- PosIndicatorPlugin::PosIndicatorPlugin()"; + +} + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::~PosIndicatorPlugin +// --------------------------------------------------------------------------- +// +PosIndicatorPlugin::~PosIndicatorPlugin() +{ + qDebug() << "+ PosIndicatorPlugin::~PosIndicatorPlugin()"; + if (mTranslator) + { + if (mTranslator->isEmpty() == false) + qApp->removeTranslator(mTranslator); + delete mTranslator; + } + qInstallMsgHandler(0); + ApiLogger::CloseLogFile(); +} + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::indicatorTypes +// --------------------------------------------------------------------------- +// +QStringList PosIndicatorPlugin::indicatorTypes() const +{ + qDebug() << "+ PosIndicatorPlugin::indicatorTypes()"; + // Return indicator types this plugin implements + return mIndicatorTypes; +} + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::createIndicator +// --------------------------------------------------------------------------- +// +HbIndicatorInterface* PosIndicatorPlugin::createIndicator( + const QString &indicatorType) +{ + qDebug() << "+ PosIndicatorPlugin::createIndicator()"; + ApiLogger::NftLogger("Before launching indicator"); + PosIndicator* ind = new PosIndicator( indicatorType ); + ApiLogger::NftLogger("After launching indicator"); + return ind; +} + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::accessAllowed +// --------------------------------------------------------------------------- +// +bool PosIndicatorPlugin::accessAllowed(const QString &/*indicatorType*/, const QVariantMap &securityInfo) const +{ + qDebug() << "+ PosIndicatorPlugin::accessAllowed()"; + QVariant value = securityInfo.value("sym-caps"); + if ((value.toInt() && ECapabilityLocation) == true ) + { + qDebug() << "Location capability present, pass"; + return true; + } + else + { + qDebug() << "Location capability absent, fail"; + return false; + } +} + +// --------------------------------------------------------------------------- +// PosIndicatorPlugin::error +// --------------------------------------------------------------------------- +// +int PosIndicatorPlugin::error() const +{ + qDebug() << "+ PosIndicatorPlugin::error()"; + return mError; +} + +// --------------------------------------------------------------------------- +// PosIndicator::PosIndicator +// --------------------------------------------------------------------------- +// +PosIndicator::PosIndicator(const QString &indicatorType) : + HbIndicatorInterface(indicatorType, SettingCategory, NoInteraction), + mDisplayString(QString(hbTrId("txt_loe_dblist_positioning_val_acquiring_position"))), + mPosIndicatorInfo(0), + processedAddess(false) +{ + qDebug() << "+ PosIndicator::PosIndicator()"; + qDebug() << "- PosIndicator::PosIndicator()"; +} + +// --------------------------------------------------------------------------- +// PosIndicator::RefreshPosIndicatorPane +// --------------------------------------------------------------------------- +// +void PosIndicator::refreshPosIndicatorPane(PosGeoAddress& posGeoAddress, int error) + { + qDebug() << "+ PosIndicator::refreshPosIndicatorPane()"; + if(error!=KErrNone) + { + qDebug() << "- PosIndicator::refreshPosIndicatorPane(),error code : "<cancelPosInfo(); + delete mPosIndicatorInfo; + mPosIndicatorInfo = 0; + } + qDebug() << "- PosIndicator::~PosIndicator()"; +} + +// --------------------------------------------------------------------------- +// PosIndicator::indicatorData +// --------------------------------------------------------------------------- +// +QVariant PosIndicator::indicatorData(int role) const +{ + qDebug() << "+ PosIndicator::indicatorData(), role = "<< role; +// Q_UNUSED(role) + + if (role == PrimaryTextRole) { + return QString(hbTrId("txt_loe_dblist_positioning")); + } else if (role == SecondaryTextRole) { + return mDisplayString; + } else if (role == DecorationNameRole) { + return QString("qtg_mono_gps"); + } else if (role == MonoDecorationNameRole ) { + return QString("qtg_mono_gps"); + } + else + return QVariant(); +} + +// --------------------------------------------------------------------------- +// PosIndicator::refreshData +// --------------------------------------------------------------------------- +// +bool PosIndicator::refreshData() + { + qDebug() << "+ PosIndicator::refreshData()"; + if(!mPosIndicatorInfo) + { + qDebug() << "First Call"; + mPosIndicatorInfo = new PosIndicatorInfo(); + if(!mPosIndicatorInfo) + { + qDebug() << "Error in constructing PosIndicatorInfo class"; + throw; + } + + QObject::connect(mPosIndicatorInfo, SIGNAL(posInfoUpdated(PosGeoAddress&, int)), this, SLOT(refreshPosIndicatorPane(PosGeoAddress&, int))); + } + ApiLogger::NftLogger("Before requesting position information"); + qDebug() << "Call requestPosInfo()"; + mPosIndicatorInfo->requestPosInfo(); + return true; + } + +// --------------------------------------------------------------------------- +// PosIndicator::ConvertToDMSFormat +// --------------------------------------------------------------------------- +// +void PosIndicator::ConvertToDMSFormat(QString &displayString, double decimal) +{ + qDebug() << "+ PosIndicator::ConvertToDMSFormat()"; + + int tempNum; + QString temp; + float tempDec; + + int degrees = (int)decimal; + + tempDec = decimal - degrees; + tempDec = tempDec * 60; + int minutes = (int)tempDec; + + tempDec = tempDec - minutes; + tempDec = tempDec * 60; + int seconds = (int)tempDec; + + tempDec = tempDec - seconds; + tempNum = tempDec * 100; + + QVariant varDegrees(degrees); + QVariant varMinutes(minutes); + QVariant varSeconds(seconds); + QVariant varTemp(tempNum); + + if (QString::compare(displayString, "latitude") == KErrNone) + { + displayString.clear(); + + if (decimal>=0) + { + displayString = QString(hbTrId("txt_loe_list_l1l2l3l4n")) + .arg(varDegrees.toString()) + .arg(varMinutes.toString()) + .arg(varSeconds.toString()) + .arg(varTemp.toString()); + } + else + { + displayString = QString(hbTrId("txt_loe_list_l1l2l3l4s")) + .arg(varDegrees.toString()) + .arg(varMinutes.toString()) + .arg(varSeconds.toString()) + .arg(varTemp.toString()); + } + } + else + { + displayString.clear(); + { + if (decimal>=0) + { + displayString = QString(hbTrId("txt_loe_list_l1l2l3l4e")) + .arg(varDegrees.toString()) + .arg(varMinutes.toString()) + .arg(varSeconds.toString()) + .arg(varTemp.toString()); + } + else + { + displayString = QString(hbTrId("txt_loe_list_l1l2l3l4w")) + .arg(varDegrees.toString()) + .arg(varMinutes.toString()) + .arg(varSeconds.toString()) + .arg(varTemp.toString()); + } + } + } + qDebug() << "- PosIndicator::ConvertToDMSFormat()"; +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/translations/lilocationmw.qm Binary file locationsystemui/locationsysui/posindicator/posindicatorplugin/translations/lilocationmw.qm has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posindicatorplugin/translations/lilocationmw.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posindicatorplugin/translations/lilocationmw.ts Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,826 @@ + + + + + + %1 is the name of the positioning server + Use %1 + + qtl_checkbox_sec + loe_008 + list + lo + False + + + Button for accessing settings in control palel + Settings + + txt_lint_button_settings + loe_002 + button + lo + False + + + Update interval value when update happens in seconds (59s or less) + Updates every %L1 seconds + + qtl_list_sec + loe_008 + list + lo + False + + + Coordinate value + %L1Ëš%L2'%L3.%L4"E + + txt_loe_list_l1l2l3l4e + loe_002 + list + lo + False + + + Location request query dialog - Softkey button. Allows the user to reject the suggested operation. + Reject + + qtl_dialog_softkey + common + button + co + False + + + Update interval. + Updates every %L1 day and %L2 hour + + qtl_list_sec + loe_008 + list + lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. Allows the user to cancel the action or process. + Cancel + + qtl_dialog_softkey_2 + common + button + co + False + + + Update interval. + Updates every %L1 hour and %L2 minute + + qtl_list_sec + loe_008 + list + lo + False + + + Wi-FI - enable/disable wifi usage in positioning context + Wi-Fi + + qtl_checkbox_sec + loe_008 + list + lo + False + + + Update interval. + Updates every %L1 minute and %L2 second + + qtl_list_sec + loe_008 + list + lo + False + + + Description text for GPS under the checkbox item + Enable for most accurate positioning + + qtl_dataform_description_sec + loe_007 + info + lo + False + + + %L1 = Accuracy information in kilometers. Displayed when over 999 meters + Accuracy: %Ln kilometers + + txt_lint_list_accuracy_1_kilometers + loe_002 + list + lo + False + + + Assisted GPS - enabling or disabling + Assisted GPS + + qtl_checkbox_sec + loe_008 + list + lo + False + + + subtitle for positioning settings main view + Positioning settings + + qtl_groupbox_simple_sec + loe_007 + subtitle + lo + False + + + Requestor info text in Location request query dialog + Location was requested by : + + qtl_dialog_pri5 + loe_013 + info + lo + False + + + %1 is the date value until the service is active/available + Valid until %1 + + qtl_list_sec + loe_008 + list + lo + False + + + Multiline secondary text in a list item. %1 is the name of the service + Your location not sent to: %1 + + qtl_list_sec + loe_018 + list + lo + False + + + Update interval. + Updates every %L1 hour and %L2 minutes + + qtl_list_sec + loe_008 + list + lo + False + + + Checkbox item for enabling/disabling Background positioning + Background positioning + + qtl_checkbox_sec + loe_007 + list + lo + False + + + Update interval. + Updates every %L1 hours and %L2 minute + + qtl_list_sec + loe_008 + list + lo + False + + + update interval value + Updates every %Ln months + + qtl_list_sec + loe_008 + list + lo + False + + + Update interval. + Updates every %L1 minutes and %L2 second + + qtl_list_sec + loe_008 + list + lo + False + + + Coordinate value + %L1Ëš%L2'%L3.%L4"N + + txt_loe_list_l1l2l3l4n + loe_002 + list + lo + False + + + Update interval. + Updates every %L1 months and %L2 days + + qtl_list_sec + loe_008 + list + lo + False + + + Multiline secondary text in a list item. %1 is the name of the service + Your location sent to : %1 + + qtl_list_sec + loe_018 + list + lo + False + + + Multiline secondary text in a list item for periodic location notifiers. %1 is the name of the service. %Ln indicates how many times the location has been sent to %1. Example text : Your location sent to Nokia , Friends finder 6 times + Your location sent to %1 %Ln times + + qtl_list_sec + loe_018 + list + lo + False + + + Update interval. + Updates every %L1 month and %L2 days + + qtl_list_sec + loe_008 + list + lo + False + + + If the requestor is unknown, this text string should be shown to the user. + Unknown requestor + + qtl_dialog_pri5 + loe_013 + info + lo + False + + + Update interval. + Updates every %L1 hours and %L2 minutes + + qtl_list_sec + loe_008 + list + lo + False + + + Info text for periodic location request query - No default policy + You location will be shared periodically with : + + qtl_dialog_pri5 + loe_014 + info + lo + False + + + UniversalIndicatorMenu item text. + Positioning + + qtl_indimenu_pri_medium_graphic + loe_001 + dblist_1 + lo + False + + + Button in dialog for closing the Positioning info dialog + Done + + qtl_dialog_softkey_1 + loe_002 + button + lo + False + + + If there are more than one unknown requestor, this text string should be shown to the user. + %Ln Unknown requestors + + qtl_dialog_pri5 + loe_013 + info + lo + False + + + Confirmation about stopping service. %1 is the name of the service + Stop service %1 + + qtl_dialog_pri3_large_graphic + loe_010 + info + lo + False + + + Location notification heading text + Your location not sent to : + + qtl_notifdialog_pri + loe_016 + dpophead + lo + False + + + Update interval. + Updates every %L1 days and %L2 hour + + qtl_list_sec + loe_008 + list + lo + False + + + Location request query dialog - Softkey button. Allows the user to accept the location request + Accept + + qtl_dialog_softkey + loe_013 + button + lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. When this button is pressed, the focused item or operation will be selected or accepted. + OK + + qtl_dialog_softkey_2 + common + button + co + False + + + 2G/3G/etc network settings for positionin use + Cellular network + + qtl_checkbox_sec + loe_008 + list + lo + False + + + Option menu item + Delete server + + qtl_menu_pri + loe_008 + opt + lo + False + + + Sub heading text for Location notification logs view + Logs + + qtl_groupbox_simple_sec + loe_018 + subhead + lo + False + + + Button - takes to advanced positioning settings + Advanced + + qtl_dataform_button_sec + loe_007 + button + lo + False + + + Update interval. + Updates every %L1 days and %L2 hours + + qtl_list_sec + loe_008 + list + lo + False + + + Control panel item in CP main view + Change positioning settings + + qtl_list_sec_large_graphic + cp_001 + dblist_1_val + cp + False + + + %L1 = Accuracy information in meters. Displayed when value is 999 meters or less + Accuracy: %Ln meters + + txt_lint_accuracy_1_meters + loe_002 + list + lo + False + + + Location notification heading text + Your location sent to : + + qtl_notifdialog_pri + loe_016 + dpophead + lo + False + + + Group heading for positioning methods + Positioning methods + + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + update interval value + Updates every %Ln hours + + qtl_list_sec + loe_008 + list + lo + False + + + Internal GPS chipset - enabling or disabling that + Internal GPS + + qtl_checkbox_sec + loe_008 + list + lo + False + + + Single toolbar item to clear logs in Location notification log view + Clear logs + + qtl_toolbar_tiny1 + loe_018 + button + lo + False + + + Description text for wireless networks under the checkbox item + Use only WI-FI and mobile networks to get position information + + qtl_dataform_description_sec + loe_007 + info + lo + False + + + Group heading positioning servers + Positioning servers + + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + Save button for saving current position + Save + + txt_loe_button_save + loe_002 + button + lo + False + + + Dialog text for server deletion + Select server to delete + + qtl_dialog_pri3 + loe_011 + info + lo + False + + + Info text for periodic location request query (Default policy - Accept) + Your location will be shared periodically by default if you don’t respond. + + qtl_dialog_pri5 + loe_015 + info + lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. Allows the user to delete an item. Note that deleting removes the item permanently from memory. + Delete + + qtl_dialog_softkey_2 + common + button + co + False + + + Heading for the positioning info dialog + Positioning + + qtl_dialog_pri_heading + loe_001 + title + lo + False + + + Title text for Location notifications log view + Location notifications + + qtl_titlebar + loe_018 + title + lo + False + + + Info text for periodic location request query (Default policy - Reject) + Your location will not be shared periodically by default if you don't respond + + qtl_dialog_pri5 + loe_015 + info + lo + False + + + Group heading for location based services + Background positioning + + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + Button - takes to advanced positioning settings + Advanced positioning settings + + qtl_groupbox_simple_sec + loe_008 + subtitle + lo + False + + + Info text for location request query - No default policy + Your location will be shared with : + + qtl_dialog_pri5 + loe_014 + info + lo + False + + + Location notification primarry text in Universal Indicator Menu + %Ln Location notifications + + qtl_indimenu_pri_medium_graphic + loe_017 + dblist_1 + lo + False + + + Info text in Location request query dialog (Default policy - Accept) + Your location will be shared by default if you don’t respond + + qtl_dialog_pri5 + loe_013 + info + lo + False + + + Checkbox item for enabling/disabling GPS + GPS + + qtl_checkbox_sec + loe_007 + list + lo + False + + + Info text in Location request query dialog (Default policy - Reject) + Your location will not be shared by default if you don’t respond + + qtl_dialog_pri5 + loe_013 + info + lo + False + + + Update interval. + Updates every %L1 day and %L2 hours + + qtl_list_sec + loe_008 + list + lo + False + + + Coordinate value + %L1Ëš%L2'%L3.%L4"W + + txt_loe_list_l1l2l3l4w + loe_002 + list + lo + False + + + Query header for save dialog + Save as + + qtl_dialog_pri_heading + loe_005 + title + lo + False + + + Bluetooth GPS - enabling/disabling external BT GPS device usage + Bluetooth GPS + + qtl_checkbox_sec + loe_008 + list + lo + False + + + Title text in Location request query dialog + Location request + + qtl_dialog_pri_heading + loe_013 + title + lo + False + + + Checkbox item for enabling/disabling Wireless positioning + Wireless networks + + qtl_checkbox_sec + loe_007 + list + lo + False + + + Control panel item in CP main view + Positioning + + qtl_list_pri_large_graphic + cp_001 + dblist_1 + cp + False + + + Update interval. + Updates every %L1 month and %L2 day + + qtl_list_sec + loe_008 + list + lo + False + + + Coordinate value + %L1Ëš%L2'%L3.%L4"S + + txt_loe_list_l1l2l3l4s + loe_002 + list + lo + False + + + update interval value + Updates every %Ln days + + qtl_list_sec + loe_008 + list + lo + False + + + Update interval. + Updates every %L1 minutes and %L2 seconds + + qtl_list_sec + loe_008 + list + lo + False + + + update interval value + Updates every %Ln minutes + + qtl_list_sec + loe_008 + list + lo + False + + + Description text for Location based services & background applications + Enable applications and services update and retrieve location information on the background + + qtl_dataform_description_sec + loe_007 + info + lo + False + + + Update interval. + Updates every %L1 months and %L2 day + + qtl_list_sec + loe_008 + list + lo + False + + + Update interval. + Updates every %L1 minute and %L2 seconds + + qtl_list_sec + loe_008 + list + lo + False + + + Universaln indicator menu. Secondary text when positioning is being acquired + Acquiring position + + qtl_indimenu_sec_medium_graphic + loe_001 + dblist_1_val + lo + False + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/bwins/posreversegeocodeinterfaceu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/bwins/posreversegeocodeinterfaceu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,4 @@ +EXPORTS + ?NewL@CPosReverseGeocodeInterface@@SAPAV1@AAVMPosReverseGeocodeObserver@@@Z @ 1 NONAME ; class CPosReverseGeocodeInterface * CPosReverseGeocodeInterface::NewL(class MPosReverseGeocodeObserver &) + ??1CPosReverseGeocodeInterface@@UAE@XZ @ 2 NONAME ; CPosReverseGeocodeInterface::~CPosReverseGeocodeInterface(void) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/eabi/posreversegeocodeinterfaceu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/eabi/posreversegeocodeinterfaceu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,8 @@ +EXPORTS + _ZN27CPosReverseGeocodeInterface4NewLER26MPosReverseGeocodeObserver @ 1 NONAME + _ZN27CPosReverseGeocodeInterfaceD0Ev @ 2 NONAME + _ZN27CPosReverseGeocodeInterfaceD1Ev @ 3 NONAME + _ZN27CPosReverseGeocodeInterfaceD2Ev @ 4 NONAME + _ZTI27CPosReverseGeocodeInterface @ 5 NONAME + _ZTV27CPosReverseGeocodeInterface @ 6 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,26 @@ +// Copyright (c) 2010 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: +// + + + +PRJ_MMPFILES +posreversegeocodeinterface.mmp + + +PRJ_EXPORTS +../inc/posreversegeocodeinterface.h |../../inc/posreversegeocodeinterface.h +../inc/posreversegeocodeinterface.hrh |../../inc/posreversegeocodeinterface.hrh + +// End of file. \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/group/posreversegeocodeinterface.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/group/posreversegeocodeinterface.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,40 @@ +// Copyright (c) 2010 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: +// + +#include + +TARGET posreversegeocodeinterface.dll +TARGETTYPE dll +UID 0x1000008d 0x2002E691 + +VENDORID VID_DEFAULT +CAPABILITY CAP_GENERAL_DLL + + +SOURCEPATH ../src +SOURCE posreversegeocodeinterface.cpp + + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + + +LIBRARY euser.lib +LIBRARY ecom.lib + + +// End of file \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/inc/posreversegeocodeinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/inc/posreversegeocodeinterface.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2010 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: Declaration of Geo coding interface class. +* +*/ + +#ifndef POSREVERSEGEOCODEINTERFACE_H +#define POSREVERSEGEOCODEINTERFACE_H + +#include +#include + +/* + * Observer class which exposes callbacks to notify the completion of reversegeocoding event. + * + **/ +class MPosReverseGeocodeObserver + { +public: + /* + * Callback function which notifys the completion of reverse geocode event. This signals the completion + * of the asynchronous function CReverseGeoCode::GetAddressByCoordinate. + * + * @param aErrorcode Error status KErrNone in case of success or other system specific errorcodes + * in case of failures. + */ + + virtual void ReverseGeocodeComplete( TInt aErrorcode ) =0; + }; + +/* + * CReverseGeocode + * Concrete class which exposes interfaces to convert the geo-coordinates information + * in to the address information. + * + **/ +class CPosReverseGeocodeInterface : public CBase + { +public: + /* + * Factory function to create the instance of CReverseGeocode Class. This also registers + * observer for getting the reverse geocode completion notifications. + * + * @param[in] aObserver refrence to the instance MReverseGeocodeObserver's + * implementation class. + * @return pointer to the instance of CReverseGeocode. + */ + IMPORT_C static CPosReverseGeocodeInterface* NewL( MPosReverseGeocodeObserver& aObserver ); + + /** + * Unloads the plugin. + */ + IMPORT_C virtual ~CPosReverseGeocodeInterface(); + + /* + * Gets the address information for the given geo coordinates. This is an asynchronous function + * Whose completion will be notified by the MReverseGeocodeObserver::ReverseGeocodeComplete callback. + * + * @param aLandmark[in] Landmarks object in which address information is expected. + * + */ + IMPORT_C virtual void GetAddressByCoordinateL( CPosLandmark& aLandmark ) = 0; + + + /** + * Cancels the current operation. + */ + IMPORT_C virtual void Cancel() = 0; +private: + /** + * Instance identifier key + */ + TUid iDtor_ID_Key; + }; + +#endif //POSREVERSEGEOCODEINTERFACE_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/inc/posreversegeocodeinterface.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/inc/posreversegeocodeinterface.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010 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: Resource headers for project +* +*/ + +#ifndef POSREVERSEGEOCODEINTERFACE_HRH +#define POSREVERSEGEOCODEINTERFACE_HRH + +// ECom interface ID for reverse geo-code interface +#define KPosReverseGeoCodeInterfaceId 0x2002E692 + + +#endif // POSREVERSEGEOCODEINTERFACE_HRH diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/src/posreversegeocodeinterface.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeinterface/src/posreversegeocodeinterface.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2010 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: Implementation of Geo coding interface class. +* +*/ + +#include "posreversegeocodeinterface.h" +#include "posreversegeocodeinterface.hrh" + +#include + +// static cleanup function +static void RImpleInfoPtrArrayCleanup( TAny* aArray ) + { + static_cast( aArray )->ResetAndDestroy(); + } + + +//------------------------------------------------------------------------------ +// CPosReverseGeocodeInterface::NewL +//------------------------------------------------------------------------------ +EXPORT_C CPosReverseGeocodeInterface* CPosReverseGeocodeInterface::NewL( + MPosReverseGeocodeObserver& aObserver ) + { + RImplInfoPtrArray implInfoPtrArray; + TCleanupItem arrayCleanup( RImpleInfoPtrArrayCleanup, &implInfoPtrArray ); + CleanupStack::PushL(arrayCleanup); + + TUid implementationUID; + + REComSession::ListImplementationsL( TUid::Uid(KPosReverseGeoCodeInterfaceId), + implInfoPtrArray ); + + if( implInfoPtrArray.Count() == 0 ) + { + implInfoPtrArray.ResetAndDestroy(); + User::Leave( KErrNotFound ); + } + + const CImplementationInformation* pluginInformation = implInfoPtrArray[0]; + implementationUID = pluginInformation->ImplementationUid(); + + TAny* ptr = REComSession::CreateImplementationL( implementationUID, + _FOFF(CPosReverseGeocodeInterface,iDtor_ID_Key), + reinterpret_cast( &aObserver )); + REComSession::FinalClose(); + CleanupStack::PopAndDestroy(); // arrayCleanup + return reinterpret_cast(ptr); + } + +//---------------------------------------------------------------------------------- +// CPosReverseGeocodeInterface::~CPosReverseGeocodeInterface +//---------------------------------------------------------------------------------- +EXPORT_C CPosReverseGeocodeInterface::~CPosReverseGeocodeInterface() + { + REComSession::DestroyedImplementation(iDtor_ID_Key); + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/data/2002E68A.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/data/2002E68A.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2010 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: Resource file for reverse geo code plugin +* +*/ +#include +#include "posreversegeocodeinterface.hrh" +#include "posreversegeocodeplugin.hrh" + +RESOURCE REGISTRY_INFO theInfo +{ +dll_uid = KPosReverseGeoCodePluginUid; +interfaces = + { + INTERFACE_INFO + { + interface_uid = KPosReverseGeoCodeInterfaceId; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = KPosReverseGeoCodeImplementationUid; + version_no = 1; + display_name = "Geocode plugin"; + default_data = "text/ascii"; + opaque_data = ""; + } + }; + } + }; +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/data/posreversegeocodeplugin.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/data/posreversegeocodeplugin.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010 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: Resource headers for project +* +*/ + + +#ifndef POSREVERSEGEOCODEPLUGIN_HRH +#define POSREVERSEGEOCODEPLUGIN_HRH + +#define KPosReverseGeoCodePluginUid 0x2002E68A +#define KPosReverseGeoCodeImplementationUid 0x2002E693 + + +#endif // POSREVERSEGEOCODEPLUGIN_HRH diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010 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: +* +*/ + + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +posreversegeocodeplugin.mmp + +// END OF FILE diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/group/posreversegeocodeplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/group/posreversegeocodeplugin.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2010 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: Project definition file for project reverse geo-code plugin +* +*/ + + + +#include +#include + + +TARGET posrevgeocodeplugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2002E68A + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../data + +SOURCEPATH ../src + +SOURCE posrevgeocodeplugin.cpp +SOURCE posrevgeocodeconnectiontimer.cpp +SOURCE posrevgeocodexmlparser.cpp +SOURCE posrevgeocodehttpclientengine.cpp + + +START RESOURCE ../data/2002E68A.rss +TARGET posrevgeocodeplugin.rsc +END + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY posreversegeocodeinterface.lib +LIBRARY insock.lib +LIBRARY inetprotutil.lib +LIBRARY http.lib +LIBRARY bafl.lib +LIBRARY commdb.lib +LIBRARY cmmanager.lib +LIBRARY xmlframework.lib +LIBRARY esock.lib +LIBRARY lbs.lib +LIBRARY libc.lib +LIBRARY charconv.lib +LIBRARY extendedconnpref.lib +LIBRARY eposlandmarks.lib +LIBRARY extendedconnpref.lib +LIBRARY netmeta.lib +LIBRARY flogger.lib +PAGED +// END OF FILE diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodeconnectiontimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodeconnectiontimer.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2010 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: Declaration of connection timer class. +* +*/ + +#ifndef POSREVGEOCODECONNECTIONTIMER_H +#define POSREVGEOCODECONNECTIONTIMER_H + +// INCLUDES +#include +#include + +class MPosRevGeoCodeTimeoutObserver + { +public: + virtual void HandleTimedoutEvent( TInt aErrorCode ) = 0; + }; + + +/** + * This is the timer class responsible for notifying client's on + * time out specified by the client. + */ +class CPosRevGeoCodeConnectionTimer : public CTimer + { +public: + /** + * Factory function to create the instance of CPosRevGeoCodeConnectionTimer object. + */ + static CPosRevGeoCodeConnectionTimer* NewL( MPosRevGeoCodeTimeoutObserver& + aConnectionTimeoutHandlerInterface); + + /** + * Destructor + */ + ~CPosRevGeoCodeConnectionTimer(); + + /** + * Starts the timer with specified time out. + * @return KErrInUse If timer is already running. + */ + TInt StartTimer( const TInt aTimeoutVal ); + + +protected: // From CTimer + void RunL(); + +private: + /** + * Symbian 2nd phase constructor + */ + void ConstructL(); + + /** + * Constructor + */ + CPosRevGeoCodeConnectionTimer( MPosRevGeoCodeTimeoutObserver& aConnectionTimeoutHandler ); + +private: // Data member + /** + * Reference to connection time out observer + */ + MPosRevGeoCodeTimeoutObserver& iConnectionTimeoutObserver; + }; + + +#endif /* POSREVGEOCODECONNECTIONTIMER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodehttpclientengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodehttpclientengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2010 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: Declaration of HTTP client engine class. +* +*/ + +#ifndef POSREVGEOCODEHTTPCLIENTENGINE_H +#define POSREVGEOCODEHTTPCLIENTENGINE_H + +#include +#include +#include +#include +#include + + + +class RHTTPSession; +class RHTTPTransaction; + +const TInt KDefaultBufferSize = 256; + +/* + * Enumration for the different states of HTTP GET request. + */ +enum THttpStatus + { + EHttpSessionError =0, + EHttpExitingApp, + EHttpConnecting, + EHttpTxCancelled, + EHttpHdrReceived, + EHttpBytesReceieved, + EHttpBodyReceieved, + EHttpTxCompleted, + EHttpTxSuccess, + EHttpTxFailed, + EHttpConnectionFailure, + EHttpUnknownEvent, + EHttpMhfRunError, + EHttpAuthNote, + EHttpAuthFailed, + EHttpAuthRequired, + }; + +enum TMobileRoamingStatus + { + EMobileNotRegistered = 0x00, + EMobileRegHomeNetwork, // home network + EMobileNationalRoaming, + EMobileInternationalRoaming + }; + +/** + * MClientObserver + * CPosRevGeoCodeHTTPClientEngine passes events and responses body data with this interface. + * An instance of this class must be provided for construction of CPosRevGeoCodeHTTPClientEngine. + */ +class MPosRevGeoCodeHTTPClientObserver + { + public: + /* + * ClientEvent() + * + * Called when event occurs in CClientEngine. + * + * @params aEvent Status of the event. + */ + virtual void ClientEvent( const THttpStatus& aEvent ) = 0; + + /* + * ClientBodyReceived() + * + * Called when a part of the HTTP body is received. + * + * @param aBodyData Part of the body data received. (e.g. part of + * the received HTML page) + */ + virtual void ClientBodyReceived( const TDesC8& aBodyData ) = 0; + }; + + +/* + * This class provides interface to HTTP client APIs + */ +class CPosRevGeoCodeHTTPClientEngine: public CActive, + public MHTTPTransactionCallback, + public MMobilityProtocolResp + { + /** + * Internal Engine state + */ + enum TEngineState + { + EIdle = 0, + EGet + }; +public: + /** + * Factory method which creates instance of CPosRevGeoCodeHTTPClientEngine object. + */ + static CPosRevGeoCodeHTTPClientEngine* NewL( MPosRevGeoCodeHTTPClientObserver& iObserver ); + + /** + * Destructor + */ + ~CPosRevGeoCodeHTTPClientEngine(); + + /** + * Starts a new HTTP GET transaction. + * + * @param aUri URI to get request. (e.g. http://host.org") + */ + void IssueHTTPGetL( const TDesC8& aUri ); + + /** + * Closes currently running transaction and frees resources related to it. + */ + void CancelTransaction(); + + /** + * Closes the connection + */ + void CloseConnection(); + +private: + /* + * Symbian 2nd phase constructor + */ + void ConstructL(); + + /* + * Constructor + */ + CPosRevGeoCodeHTTPClientEngine( MPosRevGeoCodeHTTPClientObserver& iObserver ); + + /** + * Sets header value of an HTTP request. + */ + void SetHeaderL( RHTTPHeaders aHeaders, TInt aHdrField, + const TDesC8& aHdrValue ); + + /** + * Sets up the connection + */ + void SetupConnectionL(); + +private: //From MHTTPSessionEventCallback + + void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent ); + + TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent ); + +private:// From MMobilityProtocolResp + void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, + TAccessPointInfo aNewAPInfo, + TBool aIsUpgrade, + TBool aIsSeamless ); + + void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ); + + void Error( TInt aError ); + +private: // from CActive + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + +private: + void DoHTTPGetL(); + +private: // Data members + RSocketServ iSocketServ; + RConnection iConnection; + TUint32 iSelectedIap; + + RHTTPSession iSession; + RHTTPTransaction iTransaction; + + MPosRevGeoCodeHTTPClientObserver& iObserver; // Used for passing body data and events to UI + TBool iRunning; // ETrue, if transaction running + TBool iConnectionSetupDone; + + TInt iPrevProfileId; + + CActiveCommsMobilityApiExt* iMobility; + TBool iTransactionOpen; + TEngineState iEngineState; + HBufC8* iUri; + RCmManager iCmManager; + }; +#endif /* POSREVGEOCODEHTTPCLIENTENGINE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodelogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodelogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 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: Implementation of logger. +* +*/ + +#ifndef POSREVGEOCODELOGGER_H +#define POSREVGEOCODELOGGER_H + +#include +#include + +//#ifdef _DEBUG +#define FUNC( x ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + RFileLogger::Write( _L("lbs"),_L("PosRevGeocode.log"),EFileLoggingModeAppend,buffer); } + +#define LOG ( x,y ) { TBuf8<150> buffer; \ + const unsigned char* string = (unsigned char*)(x); \ + buffer.Zero(); \ + buffer.Copy(string); \ + buffer.format(y); \ + RFileLogger::Write( _L("lbs"),_L("PosRevGeocode.log"),EFileLoggingModeAppend,buffer); } + +/*#else +#define FUNC( x ) +#define LOG ( x,y ) +#endif*/ + +#endif /* POSREVGEOCODELOGGER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodeplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodeplugin.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2010 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: Declaration of CPosRevGeoCodePlugin class. +* +*/ + +#ifndef POSREVGEOCODEPLUGIN_H +#define POSREVGEOCODEPLUGIN_H + +#include "posreversegeocodeinterface.h" +#include "posrevgeocodehttpclientengine.h" +#include "posrevgeocodeconnectiontimer.h" +#include "posrevgeocodexmlparser.h" + + +class CPosRevGeoCodePlugin : public CPosReverseGeocodeInterface, + public MPosRevGeoCodeXmlObserver, + public MPosRevGeoCodeHTTPClientObserver, + public MPosRevGeoCodeTimeoutObserver + { +public: + /** + * Factory function to create the instance of CPosRevGeoCodePlugin object. + */ + static CPosRevGeoCodePlugin* NewL( MPosReverseGeocodeObserver& aObserver ); + + /** + * Destructor + */ + ~CPosRevGeoCodePlugin(); + + /** + * Gets the address information for the given geo coordinates + */ + virtual void GetAddressByCoordinateL( CPosLandmark& aLandmark ); + + /** + * Cancels the current operation. + */ + virtual void Cancel(); + + /** + * Function to get the appropriate language for the request. + */ + void GetLanguageForTheRequest( TDes8& aLanguage ); + +public: // From MPosRevGeoCodeXmlObserver + virtual void OnParseCompletedL( TInt aError ); + +public: // From MPosRevGeoCodeHTTPClientObserver + virtual void ClientEvent( const THttpStatus& aEvent ); + + virtual void ClientBodyReceived( const TDesC8& aBodyData ); + +public: // From MPosRevGeoCodeTimeoutObserver + virtual void HandleTimedoutEvent( TInt aErrorCode ); + +private: + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + /** + * Constructor + */ + CPosRevGeoCodePlugin( MPosReverseGeocodeObserver& aObserver ); + + /** + * Starts the timer + */ + void StartTimer(); + + /** + * Closes connection + */ + void CloseConnection(); + +private: // Data members + + /** + * Reference to reverse geocode observer. + */ + MPosReverseGeocodeObserver& iObserver; + + /** + * Pointer to HTTP client engine + * Own + */ + CPosRevGeoCodeHTTPClientEngine* iHTTPClientEngine; + + /** + * Pointer to XML parser + * Own + */ + CPosRevGeoCodeXmlParser* iXmlParser; + + /** + * Pointer to connection timer + * Own + */ + CPosRevGeoCodeConnectionTimer* iConnectionTimer; + + /** + * Pointer to client's landmarks object. + * Not own. + */ + CPosLandmark* iClientLandmark; + + HBufC8* iXMLBuf; + + TBuf8 iQueryString; + + TBuf8 iAuthCode; + + TBuf8 iRefURL; + + TBuf8 iLang; + + }; + +#endif /* POSREVGEOCODEPLUGIN_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodexmlparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/inc/posrevgeocodexmlparser.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 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: Declaration of XML parser class. +* +*/ + +#ifndef POSREVGEOCODEXMLPARSER_H +#define POSREVGEOCODEXMLPARSER_H + +#include +#include +#include +using namespace Xml; + +// Forward declarations +class CPosLandmark; + +/** + * MPosRevGeoCodeXmlObserver, an observer to CXmlHandler class. + */ +class MPosRevGeoCodeXmlObserver + { +public: + /* + * Signyfys the completion of parsing of the output data. + * + * @param aError error status of parsing part. + */ + virtual void OnParseCompletedL( TInt aError ) = 0; + }; + +/** + * This class parses XML script and fills the information into landmarks structure. + */ +class CPosRevGeoCodeXmlParser : public CBase, + public MContentHandler + { + /* + * Category of the address information. This is used for + * internal parsing procedure. + */ + enum TLocationInfoType + { + ENone = 0, + ECountryName, + EState, + ECity, + EDistrict, + EPostalCode, + EThoroughfareName, + EThoroughfareNumber + }; +public: + /** + * Factory function to create the instance of CPosRevGeoCodeXmlParser object. + */ + static CPosRevGeoCodeXmlParser* NewL( MPosRevGeoCodeXmlObserver& aObserver ); + + /** + * Destructor + */ + virtual ~CPosRevGeoCodeXmlParser(); + +public: + /** + * Starts parsing XML provided through buffer. + */ + void StartParsingL( HBufC8* aXmlInfo,CPosLandmark* aLandmarkInfo ); + +private: + /** + * Constructor + */ + CPosRevGeoCodeXmlParser( MPosRevGeoCodeXmlObserver& aObserver ); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + +private: // from MContentHandler + void OnStartDocumentL( const RDocumentParameters &aDocParam, TInt aErrorCode ); + void OnEndDocumentL( TInt aErrorCode ); + void OnStartElementL( const RTagInfo &aElement, const RAttributeArray &aAttributes, TInt aErrorCode ); + void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode ); + void OnContentL( const TDesC8 &aBytes, TInt aErrorCode ); + void OnStartPrefixMappingL( const RString &aPrefix, const RString &aUri, TInt aErrorCode ); + void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode ); + void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode ); + void OnSkippedEntityL( const RString &aName, TInt aErrorCode ); + void OnProcessingInstructionL( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode); + void OnError( TInt aErrorCode ); + + TAny *GetExtendedInterface( const TInt32 aUid ); + +private://Data members + /** + * Reference to XML observer + */ + MPosRevGeoCodeXmlObserver& iObserver; + + /** + * Pointer to parser + * Own + */ + CParser* iParser; + + /** + * Buffer the contain XML to parsed + */ + HBufC8* iBuffer; + + /** + * Pointer to client's landmarks object. + */ + CPosLandmark* iClientLandmark; + + /** + * Current parsing element + */ + TLocationInfoType iCurrentElement; + + /** + * Boolean to represent thoroughfare. + */ + TBool iThoroughfare; + }; + +#endif /* POSREVGEOCODEXMLPARSER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodeconnectiontimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodeconnectiontimer.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2010 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: Implementation of connection timer class. +* +*/ + +#include "posrevgeocodeconnectiontimer.h" +#include "posrevgeocodelogger.h" + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::NewL +//------------------------------------------------------------------------------ +CPosRevGeoCodeConnectionTimer* CPosRevGeoCodeConnectionTimer::NewL( + MPosRevGeoCodeTimeoutObserver& aConnectionTimeoutObserver ) + { + FUNC("CPosRevGeoCodeConnectionTimer::NewL"); + CPosRevGeoCodeConnectionTimer* self = new ( ELeave ) + CPosRevGeoCodeConnectionTimer( aConnectionTimeoutObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::CPosRevGeoCodeConnectionTimer +//------------------------------------------------------------------------------ +CPosRevGeoCodeConnectionTimer::CPosRevGeoCodeConnectionTimer( + MPosRevGeoCodeTimeoutObserver& aConnectionTimeoutObserver ): + CTimer( EPriorityStandard ), + iConnectionTimeoutObserver ( aConnectionTimeoutObserver ) + { + FUNC("CPosRevGeoCodeConnectionTimer::CPosRevGeoCodeConnectionTimer"); + CActiveScheduler::Add(this); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::~CPosRevGeoCodeConnectionTimer +//------------------------------------------------------------------------------ +CPosRevGeoCodeConnectionTimer::~CPosRevGeoCodeConnectionTimer() + { + FUNC("CPosRevGeoCodeConnectionTimer::~CPosRevGeoCodeConnectionTimer"); + Cancel(); + } + + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::ConstructL +//------------------------------------------------------------------------------ + +void CPosRevGeoCodeConnectionTimer::ConstructL() + { + FUNC("CPosRevGeoCodeConnectionTimer::ConstructL"); + CTimer::ConstructL(); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::StartTimer +//------------------------------------------------------------------------------ +TInt CPosRevGeoCodeConnectionTimer::StartTimer(const TInt aTimeoutVal) + { + FUNC("CPosRevGeoCodeConnectionTimer::StartTimer"); + if( IsActive() ) + { + // If the timer is already running, return error code. + return KErrInUse; + } + After(aTimeoutVal); + return KErrNone; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeConnectionTimer::NewL +//------------------------------------------------------------------------------ + +void CPosRevGeoCodeConnectionTimer::RunL( ) + { + FUNC("CPosRevGeoCodeConnectionTimer::RunL"); + iConnectionTimeoutObserver.HandleTimedoutEvent( iStatus.Int() ); + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodehttpclientengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodehttpclientengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,491 @@ +/* +* Copyright (c) 2010 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: Implementation of HTTP client engine class. +* +*/ + +//Symbian headers +#include "posrevgeocodehttpclientengine.h" +#include "posrevgeocodelogger.h" + +#include +#include +#include +#include +#include + +// Used user agent for requests +_LIT8(KUserAgent, "ReverseGeoCode 1.0"); + +// This client accepts all content types. +_LIT8(KAccept, "*/*"); + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::NewL() +// ---------------------------------------------------------------------------- +CPosRevGeoCodeHTTPClientEngine* CPosRevGeoCodeHTTPClientEngine::NewL( + MPosRevGeoCodeHTTPClientObserver& aObserver ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::NewL"); + CPosRevGeoCodeHTTPClientEngine* self = new ( ELeave ) + CPosRevGeoCodeHTTPClientEngine( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::CPosRevGeoCodeHTTPClientEngine() +// ---------------------------------------------------------------------------- +CPosRevGeoCodeHTTPClientEngine::CPosRevGeoCodeHTTPClientEngine( + MPosRevGeoCodeHTTPClientObserver& aObserver ): + CActive( CActive::EPriorityStandard ), + iObserver( aObserver ), + iConnectionSetupDone( EFalse ), + iPrevProfileId( -1 ), + iMobility(NULL), + iTransactionOpen( EFalse ), + iUri(NULL) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::CPosRevGeoCodeHTTPClientEngine"); + CActiveScheduler::Add(this); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::~CPosRevGeoCodeHTTPClientEngine() +// ---------------------------------------------------------------------------- +CPosRevGeoCodeHTTPClientEngine::~CPosRevGeoCodeHTTPClientEngine() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::~CPosRevGeoCodeHTTPClientEngine"); + Cancel(); + + if( iMobility ) + { + iMobility->Cancel(); + delete iMobility; + } + + if ( iTransactionOpen ) + { + iTransaction.Close(); + } + + + iSession.Close(); + iConnection.Close(); + iSocketServ.Close(); + + delete iUri; + + iCmManager.Close(); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::ConstructL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::ConstructL() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::ConstructL"); + iCmManager.OpenL(); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::CloseConnection() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::CloseConnection() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::CloseConnection"); + if ( iTransactionOpen ) + { + iTransaction.Close(); + iTransactionOpen = EFalse; + } + + if ( iMobility ) + { + iMobility->Cancel(); + delete iMobility; + iMobility = NULL; + } + + iSession.Close(); + iConnection.Close(); + iSocketServ.Close(); + iConnectionSetupDone = EFalse; + } + + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::SetupConnectionL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::SetupConnectionL() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::SetupConnectionL"); + if ( iConnectionSetupDone ) + { + // Connection setup is done + User::Leave(KErrAlreadyExists); + } + + + // Open HTTP Session + iSession.OpenL(); + + User::LeaveIfError(iSocketServ.Connect()); + User::LeaveIfError(iConnection.Open(iSocketServ)); + + TConnPrefList prefList; + TExtendedConnPref prefs; + prefs.SetSnapPurpose( CMManager::ESnapPurposeInternet ); + prefs.SetForcedRoaming( EFalse ); + prefs.SetBearerSet( TExtendedConnPref::EExtendedConnBearerCellular | + TExtendedConnPref::EExtendedConnBearerWLAN ); + prefList.AppendL( &prefs ); + + iConnection.Start( prefList,iStatus ); + SetActive(); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::SetHeaderL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::SetHeaderL( RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::SetHeaderL"); + RStringF valStr = iSession.StringPool().OpenFStringL( aHdrValue ); + CleanupClosePushL( valStr ); + THTTPHdrVal val(valStr); + aHeaders.SetFieldL( iSession.StringPool().StringF( aHdrField, RHTTPSession::GetTable()), val); + CleanupStack::PopAndDestroy(); // valStr + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::IssueHTTPGetL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::IssueHTTPGetL( const TDesC8& aUri ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::IssueHTTPGetL"); + if ( IsActive() ) + { + return; + } + + iEngineState = EGet; + + delete iUri; + iUri = NULL; + iUri = aUri.AllocL(); + // Create HTTP connection + TRAPD( err, SetupConnectionL() ); + //If the Err is KErrNone, It will lead to RunL and + //hence jump to the DoHTTPGetL() from there. + + if( err == KErrAlreadyExists ) + { + DoHTTPGetL(); + } + else if( err != KErrNone ) + { + //If Setup Connection fails + iObserver.ClientEvent( EHttpConnectionFailure ); + User::Leave(err); + } + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::DoHTTPGetL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::DoHTTPGetL() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::DoHTTPGetL"); + // Parse string to URI (as defined in RFC2396) + TUriParser8 uri; + uri.Parse( *iUri ); + + // Get request method string for HTTP GET + RStringF method = iSession.StringPool().StringF( HTTP::EGET,RHTTPSession::GetTable() ); + CleanupClosePushL( method ); + // Open transaction with previous method and parsed uri. This class will + // receive transaction events in MHFRunL and MHFRunError. + iTransaction = iSession.OpenTransactionL( uri, *this, method ); + iTransactionOpen = ETrue; + + // Set headers for request; user agent and accepted content type + RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); + SetHeaderL( hdr, HTTP::EUserAgent, KUserAgent ); + SetHeaderL( hdr, HTTP::EAccept, KAccept ); + + // Submit the transaction. After this the framework will give transaction + // events via MHFRunL and MHFRunError. + iTransaction.SubmitL(); + CleanupStack::PopAndDestroy( 1 ); // method + iObserver.ClientEvent( EHttpConnecting ); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::CancelTransaction() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::CancelTransaction() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::CancelTransaction"); + iEngineState = EIdle; + delete iUri; + iUri = NULL; + + // Close() also cancels transaction (Cancel() can also be used but + // resources allocated by transaction must be still freed with Close()) + if( iTransactionOpen ) + { + iTransaction.Close(); + iTransactionOpen = EFalse; + + iObserver.ClientEvent( EHttpTxCancelled ); + } + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::MHFRunL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::MHFRunL"); + switch ( aEvent.iStatus ) + { + case THTTPEvent::EGotResponseHeaders: + { + // HTTP response headers have been received. Use + // aTransaction.Response() to get the response. However, it's not + // necessary to do anything with the response when this event occurs. + iObserver.ClientEvent( EHttpHdrReceived ); + break; + } + case THTTPEvent::EGotResponseBodyData: + { + // Part (or all) of response's body data received. Use + // aTransaction.Response().Body()->GetNextDataPart() to get the actual + // body data. + + // Get the body data supplier + MHTTPDataSupplier* body = aTransaction.Response().Body(); + TPtrC8 dataChunk; + + // GetNextDataPart() returns ETrue, if the received part is the last + // one. + TBool isLast = body->GetNextDataPart(dataChunk); + iObserver.ClientBodyReceived(dataChunk); + + iObserver.ClientEvent( EHttpBytesReceieved ); + + // NOTE: isLast may not be ETrue even if last data part received. + // (e.g. multipart response without content length field) + // Use EResponseComplete to reliably determine when body is completely + // received. + if( isLast ) + { + iObserver.ClientEvent( EHttpBodyReceieved ); + } + // Always remember to release the body data. + body->ReleaseData(); + break; + } + case THTTPEvent::EResponseComplete: + { + // Indicates that header & body of response is completely received. + // No further action here needed. + + iObserver.ClientEvent( EHttpTxCompleted ); + break; + } + case THTTPEvent::ESucceeded: + { + // Indicates that transaction succeeded. + iObserver.ClientEvent( EHttpTxSuccess ); + // Transaction can be closed now. It's not needed anymore. + aTransaction.Close(); + iTransactionOpen = EFalse; + break; + } + case THTTPEvent::EFailed: + { + // Transaction completed with failure. + iObserver.ClientEvent( EHttpTxFailed ); + aTransaction.Close(); + iTransactionOpen = EFalse; + break; + } + default: + // There are more events in THTTPEvent, but they are not usually + // needed. However, event status smaller than zero should be handled + // correctly since it's error. + { + if ( aEvent.iStatus < 0 ) + { + iObserver.ClientEvent( EHttpConnectionFailure ); + // Close the transaction on errors + aTransaction.Close(); + iTransactionOpen = EFalse; + } + break; + } + } + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::MHFRunError() +// ---------------------------------------------------------------------------- +TInt CPosRevGeoCodeHTTPClientEngine::MHFRunError( TInt /*aError*/, + RHTTPTransaction /*aTransaction*/, + const THTTPEvent& /*aEvent*/ ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::MHFRunError"); + // Just notify about the error and return KErrNone. + CloseConnection(); + iObserver.ClientEvent(EHttpMhfRunError); + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::PreferredCarrierAvailable() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::PreferredCarrierAvailable( + TAccessPointInfo /*aOldAPInfo*/, + TAccessPointInfo /*aNewAPInfo*/, + TBool /*aIsUpgrade*/, + TBool aIsSeamless ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::PreferredCarrierAvailable"); + if( !aIsSeamless && iMobility) + { + iMobility->MigrateToPreferredCarrier(); + } + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::NewCarrierActive() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, + TBool aIsSeamless ) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::NewCarrierActive"); + if( !aIsSeamless && iMobility) + { + iMobility->NewCarrierAccepted(); + } + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::Error() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::Error(TInt /*aError*/) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::Error"); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::DoCancel() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::DoCancel() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::DoCancel"); + iConnection.Stop(); + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::DoCancel() +// ---------------------------------------------------------------------------- +TInt CPosRevGeoCodeHTTPClientEngine::RunError(TInt /*aError*/) + { + FUNC("CPosRevGeoCodeHTTPClientEngine::RunError"); + // Just notify about the error and return KErrNone. + CloseConnection(); + iObserver.ClientEvent( EHttpTxFailed ); + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// CPosRevGeoCodeHTTPClientEngine::RunL() +// ---------------------------------------------------------------------------- +void CPosRevGeoCodeHTTPClientEngine::RunL() + { + FUNC("CPosRevGeoCodeHTTPClientEngine::RunL"); + TInt statusCode = iStatus.Int(); + + if ( statusCode == KErrNone ) + { + // Connection done ok + iConnectionSetupDone = ETrue; + + RStringPool strPool = iSession.StringPool(); + CleanupClosePushL( strPool ); + // Remove first session properties just in case. + RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); + + // Clear RConnection and Socket Server instances + connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable())); + connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable())); + + // Clear the proxy settings + connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable())); + connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable())); + + // RConnection and Socket Server + connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, + RHTTPSession::GetTable()), + THTTPHdrVal (iSocketServ.Handle()) ); + + TInt connPtr1 = REINTERPRET_CAST(TInt, &iConnection); + connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, + RHTTPSession::GetTable() ), THTTPHdrVal (connPtr1) ); + + // Register for mobility API + delete iMobility; + iMobility = NULL; + iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ); + CleanupStack::Pop( &strPool ); // strPool + + // Start selected HTTP action + switch( iEngineState ) + { + case EIdle: + { + // + CancelTransaction(); + break; + } + case EGet: + { + DoHTTPGetL(); + break; + } + }; + } + else + { + //handle error + if ( statusCode == KErrPermissionDenied ) + { + iObserver.ClientEvent( EHttpAuthFailed ); + } + else + { + //Throw some general Transaction falure error! + iObserver.ClientEvent( EHttpTxFailed ); + } + CloseConnection(); + } + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodeplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodeplugin.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,389 @@ +/* +* Copyright (c) 2010 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: Implementation of CPosRevGeoCodePlugin class. +* +*/ + +#include "posrevgeocodeplugin.h" +#include "posrevgeocodelogger.h" + +#include + +//Maximum length for the response buffer size +const int KMaxResponseLength = 2048; +//Authentication token for the Maps server +//This authentication in specific to our photo-tagging feature +_LIT8( KAuthenticationToken, "88dedc61fb43c924aa39a873dadd41f4" ); +//Static RefererURL which shows that request has been made from this app +_LIT8( KRefererURL, "nokia_positioningIndicator" ); + +//Language option for the REST request +_LIT8( KDefaultLanguage, "eng" ); + + +//Format of the HTTP request for the reverse geocode +_LIT8( KRequestFormat, "http://loc.mobile.maps.svc.ovi.com/geocoder/rgc/1.0?token=%S&referer=%S&n=10&lat=%f&long=%f&lg=%S&output=xml" ); + + +// http://www.loc.gov/marc/languages/ +// These are the nokia language id converted to MARC language strings. + static const char Marc_Table[ 104 ][ 4 ] = { + " ", // dummy + "ENG", // 1 English + "FRE", // 2 French + "GER", // 3 German + "SPA", // 4 Spanish + "ITA", // 5 Italian + "SWE", // 6 Swedish + "DAN", // 7 Danish + "NOR", // 8 Norwegian + "FIN", // 9 Finnish + "010", // 10 American + "011", // 11 Swiss French + "GSW", // 12 Swiss German + "POR", // 13 Portuguese + "TUR", // 14 Turkish + "ICE", // 15 Icelandic + "RUS", // 16 Russian + "HUN", // 17 Hungarian + "DUT", // 18 Dutch + "019", // 19 Flemish + "020", // 20 Australian English + "021", // 21 Belgian French + "022", // 22 Austrian German + "023", // 23 New Zealand English + "FRE", // 24 International French + "CZE", // 25 Czech + "SLO", // 26 Slovak + "POL", // 27 Polish + "SLV", // 28 Slovenian + "029", // 29 TaiwanChinese + "CHT", // 30 HongKongChinese + "CHI", // 31 PeoplesRepublicOfChina Chinese + "JPN", // 32 Japanese + "THA", // 33 Thai + "AFR", // 34 Afrikaans + "ALB", // 35 Albanian + "AMH", // 36 Amharic + "ARA", // 37 Arabic + "ARM", // 38 Armenian + "TGL", // 39 Tagalog + "BEL", // 40 Belarusian + "BEN", // 41 Bengali + "BUL", // 42 Bulgarian + "BUR", // 43 Burmese + "CAT", // 44 Catalan + "SCR", // 45 Croatian + "046", // 46 Canadian English + "ENG", // 47 International English + "048", // 48 SouthAfrican English + "EST", // 49 Estonian + "PER", // 50 Persian (Farsi) + "051", // 51 Canadian French + "GAE", // 52 Scots Gaelic + "GEO", // 53 Georgian + "GRE", // 54 Greek + "055", // 55 Cyprus Greek + "GUJ", // 56 Gujarati + "HEB", // 57 Hebrew + "HIN", // 58 Hindi + "IND", // 59 Bahasa indonesia + "GLE", // 60 Irish + "061", // 61 Swiss Italian + "KAN", // 62 Kannada + "KAZ", // 63 Kazakh + "KHM", // 64 Khmer + "KOR", // 65 Korean + "LAO", // 66 Lao + "LAV", // 67 Latvian + "LIT", // 68 Lithuanian + "MAC", // 69 Macedonian + "070", // 70 Bahasa Malaysia + "MAL", // 71 Malayalam + "MAR", // 72 Marathi + "MOL", // 73 Moldavian + "MON", // 74 Mongolian + "NNO", // 75 Norwegian Nynorsk + "076", // 76 Brazilian Portuguese + "PAN", // 77 Punjabi + "RUM", // 78 Romanian + "SCC", // 79 Serbian + "SNH", // 80 Sinhalese + "SOM", // 81 Somali + "082", // 82 International Spanish + "083", // 83 LatinAmerican Spanish + "SWA", // 84 Swahili + "085", // 85 Finland Swedish + "TAJ", // 86 Tajik + "TAM", // 87 Tamil + "TEL", // 88 Telugu + "TIB", // 89 Tibetan + "TIR", // 90 Tigrinya + "091", // 91 Cyprus Turkish + "TUK", // 92 Turkmen + "UKR", // 93 Ukrainian + "URD", // 94 Urdu + "UZB", // 95 Uzbek + "VIE", // 96 Vietnamese + "WEL", // 97 Welsh + "ZUL", // 98 Zulu + "UND", // 99 Other + "UND", // 100 Undef + "UND", // 101 Undef + "BAQ", // 102 Basque + "103", // 103 Galician + }; + +// Timer interval +const TInt KTimeOutInterval = 60000000; // 60 seconds + + +// ECOM implementation specifics +static const TImplementationProxy implTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( 0x2002E693, CPosRevGeoCodePlugin::NewL ) + }; + + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(implTable) / sizeof(TImplementationProxy); + + return implTable; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::NewL +//------------------------------------------------------------------------------ +CPosRevGeoCodePlugin* CPosRevGeoCodePlugin::NewL( MPosReverseGeocodeObserver& aObserver ) + { + FUNC("CPosRevGeoCodePlugin::NewL"); + CPosRevGeoCodePlugin *self = new (ELeave) CPosRevGeoCodePlugin( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::CPosRevGeoCodePlugin +//------------------------------------------------------------------------------ +CPosRevGeoCodePlugin::CPosRevGeoCodePlugin( MPosReverseGeocodeObserver& aObserver ): + iObserver( aObserver ), + iHTTPClientEngine ( NULL ), + iXmlParser ( NULL ), + iConnectionTimer( NULL ), + iXMLBuf ( NULL ) + { + FUNC("CPosRevGeoCodePlugin::CPosRevGeoCodePlugin"); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::~CPosRevGeoCodePlugin +//------------------------------------------------------------------------------ +CPosRevGeoCodePlugin::~CPosRevGeoCodePlugin() + { + FUNC("CPosRevGeoCodePlugin::~CPosRevGeoCodePlugin"); + + delete iConnectionTimer; + iConnectionTimer = NULL; + + delete iXMLBuf; + iXMLBuf = NULL; + + delete iXmlParser; + iXmlParser = NULL; + + delete iHTTPClientEngine; + iHTTPClientEngine = NULL; + FUNC("out>>CPosRevGeoCodePlugin"); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::GetAddressByCoordinateL +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::GetAddressByCoordinateL( CPosLandmark& aLandmark ) + { + FUNC("CPosRevGeoCodePlugin::GetAddressByCoordinateL"); + // Store the landmark object. + iClientLandmark = &aLandmark; + + TLocality locality; + User::LeaveIfError( aLandmark.GetPosition( locality ) ); + TReal64 latitude = locality.Latitude(); + TReal64 longitude = locality.Longitude(); + + iAuthCode.Copy( KAuthenticationToken ); + iRefURL.Copy( KRefererURL ); + + GetLanguageForTheRequest( iLang ); + + //Form the request URI + iQueryString.Format( KRequestFormat, &iAuthCode, &iRefURL, latitude, longitude, &iLang ); + + iHTTPClientEngine->IssueHTTPGetL( iQueryString ); + + if ( iConnectionTimer && iConnectionTimer->IsActive() ) + { + iConnectionTimer->Cancel(); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::Cancel() +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::Cancel() + { + if( iHTTPClientEngine->IsActive() ) + { + iHTTPClientEngine->CancelTransaction(); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::ConstructL +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::ConstructL() + { + FUNC("CPosRevGeoCodePlugin::ConstructL"); + iXMLBuf = HBufC8::NewL( KMaxResponseLength ); + + iXmlParser = CPosRevGeoCodeXmlParser::NewL( *this ); + + iHTTPClientEngine = CPosRevGeoCodeHTTPClientEngine::NewL( *this ); + + iConnectionTimer = CPosRevGeoCodeConnectionTimer::NewL(*this); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::OnParseCompletedL +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::OnParseCompletedL( TInt aError ) + { + FUNC("CPosRevGeoCodePlugin::OnParseCompletedL"); + StartTimer(); + iObserver.ReverseGeocodeComplete( aError ); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::ClientEvent +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::ClientEvent( const THttpStatus& aEvent ) + { + FUNC("CPosRevGeoCodePlugin::ClientEvent"); + TInt error; + switch( aEvent ) + { + case EHttpTxCompleted: + //Reading is done + //Parse the String and get the restults + if( iXmlParser ) + { + TRAP_IGNORE( iXmlParser->StartParsingL( iXMLBuf,iClientLandmark ) ); + } + break; + //All these cases will in turn lead to + //generic failure due to connection/Tx related problems + case EHttpConnectionFailure: + // May happen if Socket connection fails + error = KErrCouldNotConnect; + iObserver.ReverseGeocodeComplete( error ); + break; + case EHttpTxFailed: + case EHttpMhfRunError: + // May happen if Socket connection fails + // Complete the RGC with generic error. + error = KErrGeneral; + iObserver.ReverseGeocodeComplete( error ); + break; + case EHttpTxCancelled: + //On Cancellation of request. + error = KErrCancel; + iObserver.ReverseGeocodeComplete( error ); + break; + case EHttpAuthFailed: + //On authentication failed. + error = KErrPermissionDenied; + iObserver.ReverseGeocodeComplete( error ); + break; + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::ClientBodyReceived +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::ClientBodyReceived( const TDesC8& aBodyData ) + { + FUNC("CPosRevGeoCodePlugin::ClientBodyReceived"); + //Dump the contents here + TPtr8 ptr = iXMLBuf->Des(); + ptr.Zero(); + ptr.Append( aBodyData ); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::GetLanguageForTheRequest +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::GetLanguageForTheRequest( TDes8& aLanguage ) + { + FUNC("CPosRevGeoCodePlugin::GetLanguageForTheRequest"); + // Get the current phone langauge + TInt phoneLangIndex = User::Language(); + + // Get the converted language + if ( phoneLangIndex < sizeof( Marc_Table ) / sizeof( Marc_Table[ 0 ] ) ) + { + aLanguage = (const TUint8*) Marc_Table[ phoneLangIndex ]; + } + else + { + //By default language will be Eng + aLanguage.Copy( KDefaultLanguage ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::CloseConnection +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::CloseConnection() + { + FUNC("CPosRevGeoCodePlugin::CloseConnection"); + if( iHTTPClientEngine ) + { + iHTTPClientEngine->CloseConnection(); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::StartTimer +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::StartTimer() + { + FUNC("CPosRevGeoCodePlugin::StartTimer"); + if( iConnectionTimer ) + { + iConnectionTimer->StartTimer( KTimeOutInterval ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodePlugin::HandleTimedoutEvent +//------------------------------------------------------------------------------ +void CPosRevGeoCodePlugin::HandleTimedoutEvent(TInt /*aErrorCode*/) + { + FUNC("CPosRevGeoCodePlugin::HandleTimedoutEvent"); + CloseConnection(); + } + +//end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodexmlparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/posreversegeocodeplugin/src/posrevgeocodexmlparser.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,355 @@ +/* +* Copyright (c) 2010 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: Implementation of XML parser class. +* +*/ + +#include "posrevgeocodexmlparser.h" +#include "posrevgeocodelogger.h" + + +#include +#include + +// CONSTANTS +_LIT8( KXmlMimeType, "text/xml" ); +_LIT8( KCountry, "country" ); +_LIT8( KState, "state" ); +_LIT8( KDistrict, "district" ); +_LIT8( KCity, "city" ); +_LIT8( KPostalCode, "postCode" ); +_LIT8( KThoroughfare, "thoroughfare" ); +_LIT8( KNameTag, "name" ); +_LIT8( KNumberTag, "number" ); + + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::NewL +//------------------------------------------------------------------------------ +CPosRevGeoCodeXmlParser* CPosRevGeoCodeXmlParser::NewL( MPosRevGeoCodeXmlObserver& aObserver ) + { + FUNC("CPosRevGeoCodeXmlParser::NewL"); + CPosRevGeoCodeXmlParser* self = new ( ELeave ) CPosRevGeoCodeXmlParser( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::~CPosRevGeoCodeXmlParser +//------------------------------------------------------------------------------ +CPosRevGeoCodeXmlParser::~CPosRevGeoCodeXmlParser() + { + FUNC("CPosRevGeoCodeXmlParser::~CPosRevGeoCodeXmlParser"); + delete iParser; + delete iBuffer; + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::CPosRevGeoCodeXmlParser +//------------------------------------------------------------------------------ +CPosRevGeoCodeXmlParser::CPosRevGeoCodeXmlParser( MPosRevGeoCodeXmlObserver& aObserver ): + iObserver( aObserver ), + iParser( NULL ), + iBuffer( NULL ), + iThoroughfare( EFalse ) + { + FUNC("CPosRevGeoCodeXmlParser::CPosRevGeoCodeXmlParser"); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::ConstructL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::ConstructL() + { + FUNC("CPosRevGeoCodeXmlParser::ConstructL"); + iParser = CParser::NewL( KXmlMimeType,*this ); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::StartParsingL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::StartParsingL( HBufC8 *aXmlInfo, + CPosLandmark* aLandmarkInfo ) + { + FUNC("CPosRevGeoCodeXmlParser::StartParsingL"); + // Store client's landmark + iClientLandmark = aLandmarkInfo; + + if( iBuffer ) + { + delete iBuffer; + iBuffer = NULL; + } + + iBuffer = HBufC8::NewL( aXmlInfo->Size() ); + TPtr8 ptr = iBuffer->Des(); + ptr.Copy( aXmlInfo->Ptr(),aXmlInfo->Size() ); + + // Now, we have the whole file content in iBuffer. + // We are ready to parse the XML content. + iParser->ParseBeginL(); + iParser->ParseL( *iBuffer ); + + // Since we read the whole file contents within one-shot, + // we can call ParseEndL() right after calling ParseL(). + iParser->ParseEndL(); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnStartDocumentL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnStartDocumentL( const RDocumentParameters& /*aDocParam*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnStartDocumentL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnEndDocumentL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnEndDocumentL( TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnEndDocumentL"); + iObserver.OnParseCompletedL( aErrorCode ); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnStartElementL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnStartElementL( const RTagInfo& aElement, + const RAttributeArray& /*aAttributes*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnStartElementL"); + if ( aErrorCode == KErrNone ) + { + // If we find the start of an element, we write to the screen, + // for example: "" + + if( !aElement.LocalName().DesC().Compare( KCountry ) ) + { + iCurrentElement = ECountryName; + } + else if( !aElement.LocalName().DesC().Compare( KState ) ) + { + iCurrentElement = EState; + } + else if( !aElement.LocalName().DesC().Compare( KCity ) ) + { + iCurrentElement = ECity; + } + else if( !aElement.LocalName().DesC().Compare( KDistrict ) ) + { + iCurrentElement = EDistrict; + } + else if( !aElement.LocalName().DesC().Compare( KPostalCode ) ) + { + iCurrentElement = EPostalCode; + } + else if( !aElement.LocalName().DesC().Compare( KThoroughfare ) ) + { + iThoroughfare = ETrue; + } + else if( !aElement.LocalName().DesC().Compare( KNameTag ) && iThoroughfare ) + { + iCurrentElement = EThoroughfareName; + } + else if( !aElement.LocalName().DesC().Compare( KNumberTag ) && iThoroughfare ) + { + iCurrentElement = EThoroughfareNumber; + } + else + { + // Nothing to be done here. + } + } + else + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnEndElementL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnEndElementL( const RTagInfo& /*aElement*/, TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnEndElementL"); + if( aErrorCode == KErrNone ) + { + // at the end of the tag + //Set it to ENone + iCurrentElement = ENone; + iThoroughfare = EFalse; + } + else + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnContentL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnContentL( const TDesC8 &aBytes, TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnContentL"); + if( aErrorCode == KErrNone ) + { + + if( iCurrentElement == ENone ) + { + //ignore if the current element is not there + return; + } + + // convert the content to UCS-2 + // from UTF-8 + RBuf buffer; + CleanupClosePushL(buffer); + buffer.CreateL( aBytes.Length() ); + CnvUtfConverter::ConvertToUnicodeFromUtf8( buffer,aBytes ); + + if( iCurrentElement == ECountryName ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldCountry,buffer ); + } + else if( iCurrentElement == EState ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldState,buffer ); + } + else if( iCurrentElement == EDistrict ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldDistrict,buffer ); + } + else if( iCurrentElement == ECity ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldCity,buffer ); + } + else if( iCurrentElement == EPostalCode ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldPostalCode,buffer ); + } + else if( iCurrentElement == EThoroughfareName ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldStreet,buffer ); + } + else if( iCurrentElement == EThoroughfareNumber ) + { + iClientLandmark->SetPositionFieldL( EPositionFieldStreetExtension,buffer ); + } + else + { + // Nothing to be done here. + } + CleanupStack::PopAndDestroy( &buffer ); + } + else + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnStartPrefixMappingL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, + const RString& /*aUri*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnStartPrefixMappingL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnEndPrefixMappingL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnEndPrefixMappingL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnIgnorableWhiteSpaceL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnIgnorableWhiteSpaceL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnSkippedEntityL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnSkippedEntityL( const RString& /*aName*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnSkippedEntityL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnProcessingInstructionL +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, + const TDesC8& /*aData*/, + TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnProcessingInstructionL"); + if( aErrorCode != KErrNone ) + { + iObserver.OnParseCompletedL( aErrorCode ); + } + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::OnError +//------------------------------------------------------------------------------ +void CPosRevGeoCodeXmlParser::OnError( TInt aErrorCode ) + { + FUNC("CPosRevGeoCodeXmlParser::OnError"); + TRAP_IGNORE( iObserver.OnParseCompletedL( aErrorCode ) ); + } + +//------------------------------------------------------------------------------ +// CPosRevGeoCodeXmlParser::GetExtendedInterface +//------------------------------------------------------------------------------ +TAny* CPosRevGeoCodeXmlParser::GetExtendedInterface( const TInt32 /*aUid*/ ) + { + FUNC("CPosRevGeoCodeXmlParser::GetExtendedInterface"); + return NULL; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/posindicator/rom/posindicator.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/posindicator/rom/posindicator.iby Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 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 position indicator +* +*/ + + +#ifndef POSITIONINDICATOR_IBY +#define POSITIONINDICATOR_IBY + +#include +#include + +// Position indicator +file=ABI_DIR\BUILD_DIR\posindicator.dll SHARED_LIB_DIR\posindicator.dll + +// Position indicator helper client library +file=ABI_DIR\BUILD_DIR\posindicatorhelper.dll SHARED_LIB_DIR\posindicatorhelper.dll + +// Position indicator helper server +file=ABI_DIR\BUILD_DIR\posindicatorhelperserver.exe SHARED_LIB_DIR\posindicatorhelperserver.exe + +// Position reverse geo-code interface +file=ABI_DIR\BUILD_DIR\posreversegeocodeinterface.dll SHARED_LIB_DIR\posreversegeocodeinterface.dll + +// Position reverse geo-code plugin +ECOM_PLUGIN( posrevgeocodeplugin.dll,posrevgeocodeplugin.rsc ) + +// Position indicator plugin +data=\epoc32\data\z\resource\plugins\indicators\posindicator.qtplugin \resource\plugins\indicators\posindicator.qtplugin + +// stub sis +data=DATAZ_\system\install\posindicator_stub.sis system\install\posindicator_stub.sis + +#endif // POSITIONINDICATOR_IBY diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/conf/positioningsettings.confml Binary file locationsystemui/locationsysui/possettings/conf/positioningsettings.confml has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/conf/positioningsettings_2002E685.crml Binary file locationsystemui/locationsysui/possettings/conf/positioningsettings_2002E685.crml has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/inc/possettingsadvinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/inc/possettingsadvinterface.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2010 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: Positioning settings advanced interface class. +* +*/ + +#ifndef POSSETTINGSENGADVANCEDINTERFACE_H +#define POSSETTINGSENGADVANCEDINTERFACE_H + +#include "possettingsadvop.h" +#include + + + +//Provider id and version +static const char* KAdvancedInterfaceId = + "com.nokia.PosSettingsAdvInterface/1.0"; + + +/** + * Settings UI ECom plug-in interface + * + * PosSettingsAdvInterface class tdefines interface for Advanced + * positioning settings UI. Any Settings UI component should derive from this + * class and implement the abstract functions. + * + */ +class PosSettingsAdvInterface + { + +public: + /** + * Destructor + */ + virtual ~PosSettingsAdvInterface(){} + + + /** + * This method performs operations required to display advanced settings UI + * The operations would involve the following : + * - add data model items + * - add connections for the data model items + * - add actions for menu items ( if any ) + * - add connection to the view using the slot updateAdvancedView + * to update the view when the form is updated. + */ + virtual int initialise( PosSettingsAdvOp* operation ) = 0; + + }; + + +// MACROS +Q_DECLARE_INTERFACE( PosSettingsAdvInterface,KAdvancedInterfaceId ); + +#endif /* POSSETTINGSENGADVANCEDINTERFACE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/inc/possettingsadvop.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/inc/possettingsadvop.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,114 @@ +/* +* 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: Positioning settings advanced operation class. +* +*/ + +#ifndef POSSETTINGSENGADVANCEDOPERATION_H +#define POSSETTINGSENGADVANCEDOPERATION_H + + +#include "possettingsglobal.h" +#include +#include +#include +#include +#include + +class POSSETTINGS_EXPORT PosSettingsAdvOp : public QObject + { + Q_OBJECT + +public: + /** + * Constructor + */ + PosSettingsAdvOp(HbView* view); + + /** + * Destructor + */ + ~PosSettingsAdvOp(); + + /** + * Appends dataform model item to the dataform model. + */ + void appendDataFormItem( HbDataFormModelItem *data, + HbDataFormModelItem *parent = 0 ); + + /*** + * Makes connections for the data form model items + */ + void addConnection( HbDataFormModelItem *item, const char* signal, + QObject *receiver, const char* slot ); + + /** + * Used to add menue items & actions + */ + void addAction( HbAction *action, HbView::ActionContainer + preferedActionContainer ); + /** + * Gets the index of a particular data form model item + * @param[in] item - data form model item whose index is required + * @return - index of the data form model item within the data form model + */ + QModelIndex indexFromItem(const HbDataFormModelItem * item ); + /** + * Removes connection that were already made + */ + void removeConnection(HbDataFormModelItem *item, const char *signal, QObject *receiver, const char *slot); + /** + * Sets the model item to be expanded/collapsed + */ + void setExpanded(const QModelIndex &index, bool expanded); + /** + * Checks if a particualr data model item is expanded + */ + bool isExpanded (const QModelIndex &index) const; + /** + * Removes a particualr data form model item from the model + */ + bool removeItem(HbDataFormModelItem* item); + /** + * set prototype for data form + */ + void setItemPrototypes(QList &protoTypeList); + + /** + * gets prototype list for the data form + */ + void itemPrototypes(QList &protoTypeList); +private: + + /** + * Pointer to view. + * Not own. + */ + HbView* mView; + + /** + * Pointer to data form + * Not own. + */ + HbDataForm* mDataForm; + + /** + * Pointer to data form model. + * Not own. + */ + HbDataFormModel* mDataFormModel; + }; + + +#endif /* POSSETTINGSENGADVANCEDOPERATION_H_ */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/inc/possettingscrkey.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/inc/possettingscrkey.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,59 @@ +/* +* 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: Central Repository Key definition for ordering of the +* positioning settings plugins displayed in the advaced +* settings view +* +*/ + +#ifndef POSSETTINGSCRKEY_H +#define POSSETTINGSCRKEY_H + +#include + +/* + * UID of the Positioning Settings Central Repository Key. + * This key defines the position of the positioning settings plugins that are shown + * in the advanced settings view of Positioning. + */ +const TUid KCRUidPositioningSettings = {0x2002E685}; + +/* + * Key for listing the positioning settings plugins in the advacned view of Positioning. + * This key is a Read only key and the default values for the Keys is configured by the device + * manufacturer while flashing the device. They cannot be dynamically configured. + * The keys contains a string which contains a list of Unique Identifers for the Positioning settings + * plugins in the order in which the device manufacturer wants these plugins to be displayed. + * The maximum length of this string is 1024 characters + * The format of this Key is defined as + * | Count | Length(1) | Dllname(1) | Length(2) | Dllname(2) | ... | Length( Count ) | Dllname( Count ) | + * where, + * Count ( 4 digits ) - The number of positioning Settings plugins which are predefined to be displayed in + * the Advanced Settings view, in the Decimal format. + * Length(n) ( 4 digits ) - Length of the plugin's dll name in the string format. This field contains the length + * in the in the Decimal format. + * String(n) - Dll name of the positioning settings plugins encoded as a string. + */ +const TUint32 KPositioningSettingsPlugins = 0x00000001; + +/* + * Key for storing old state of background positioning in main view. + * This key is a Read/Write key and the default value for the key is one [i.e. enabled] + * The key contains integer which can be either 0 [disabled] or 1 [enabled] + * The key value is modified only when user marks/unmarks background positioning checkbox in the main view + * The key value is NOT modified when background positioning checkbox is removed/inserted + */ +const TUint32 KPositioningSettingsBackgroundServicesStatus = 0x00000002; + +#endif //POSSETTINGSCRKEY_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/inc/possettingsglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/inc/possettingsglobal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2010 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 POSSETTINGS_GLOBAL_H +#define POSSETTINGS_GLOBAL_H + +#ifdef BUILD_POSSETTINGS + #define POSSETTINGS_EXPORT Q_DECL_EXPORT +#else + #define POSSETTINGS_EXPORT Q_DECL_IMPORT +#endif + +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/inc/possettingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/inc/possettingsview.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2010 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 the first view for Positioning Settings plugin +* +*/ + +#ifndef POSSETTINGSVIEW_H +#define POSSETTINGSVIEW_H + +#include "possettingsglobal.h" + +#include +#include + +// Forward declaration +class PosSettingsEngine; +class PosSettingsForm; +class HbGroupBox; +class QGraphicsLinearLayout; + +class POSSETTINGS_EXPORT PosSettingsView: public CpBaseSettingView + { +public: + /** + * Constructor + */ + explicit PosSettingsView( QGraphicsItem *parent = 0 ); + + /** + * Destructor + */ + ~PosSettingsView(); + +private: // Data members + /** + * Pointer to settings engine object + * Own + */ + PosSettingsEngine* mSettingsEngine; + + /** + * Pointer to settings form object. + */ + PosSettingsForm* mSettingsForm; + }; + +#endif // POSSETTINGSVIEW_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/locationservicescustomviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/locationservicescustomviewitem.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2010 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 class to be used to create group items for location services + * + */ +#ifndef LOCATIONSERVICES_CUSTOMVIEWITEM_H +#define LOCATIONSERVICES_CUSTOMVIEWITEM_H + +#include +#include +#include + + +//dataItemType for Location services custom widget +const int LocationServicesCustomItem = HbDataFormModelItem::CustomItemBase + + 15; + +class LocationServicesCustomViewItem : public HbDataFormViewItem + { +Q_OBJECT +public: + /** + * Constructor + */ + explicit LocationServicesCustomViewItem(QGraphicsItem *parent = 0); + + /** + * Destructor + */ + ~LocationServicesCustomViewItem(); + +protected: + + /** + * This method is used to create the Custom widget for location services + * @returns - HbAbstractButton, instance of the custom widget + */ + virtual HbWidget* createCustomWidget(); + + /** + * + */ + virtual HbAbstractViewItem* createItem(); + + /** + * + */ + virtual bool canSetModelIndex(const QModelIndex &index) const; +public slots: + virtual void restore(); + //virtual void save(); +private: + /** + * instance of HbAbstractButton + */ + HbWidget *mPushWidget; + }; +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/locationserviceswidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/locationserviceswidget.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2010 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 header file is for creating the custom widget for location services + * for Advanced view of Positioning settings + * + */ + +#ifndef LOCATIONSERVICESWIDGET_H +#define LOCATIONSERVICESWIDGET_H + +#include +#include + +class HbTextItem; + +class LocationServicesWidget : public HbAbstractButton + { +Q_OBJECT + +// It is possible to set initial value to properties from the application designer. +Q_PROPERTY(QString primarytext READ primaryText WRITE setPrimaryText) +Q_PROPERTY(QString sectext READ secText WRITE setSecText) +Q_PROPERTY(QString sec2text READ sec2Text WRITE setSec2Text) + +public: + /** + * Constructor + */ + LocationServicesWidget(QGraphicsItem *parent = 0); + + /** + * Destructor + */ + ~LocationServicesWidget(); + +public: + + /** + * Sets the primary text for the widget + * @param [in] - primaryText, primary text for the widget + */ + void setPrimaryText(const QString &primaryText); + + /** + * Gets the primary text for the widget + * @returns - QString containing the primary text + */ + QString primaryText() const; + + /** + * Sets the primary text for the widget + * @param [in] - secText, secondry(second line) text for the widget + */ + void setSecText(const QString &secText); + + /** + * Gets the primary text for the widget + * @returns - QString containing the secondry text + */ + QString secText() const; + + /** + * Sets the primary text for the widget + * @param [in] - secText, secondry(third line) text for the widget + */ + void setSec2Text(const QString &secText); + + /** + * Gets the primary text for the widget + * @returns - QString containing the secondry2 text + */ + QString sec2Text() const; + +private: + + /** + * Primary Text item + * Does not own + */ + HbTextItem* mPrimaryTextItem; + + /** + * Secondry Text item + * Does not own + */ + HbTextItem* mSecondryTextItem; + + /** + * Secondry (third item) Text item + * Does not own + */ + HbTextItem* mSecondry2TextItem; + }; + +#endif // LOCATIONSERVICESWIDGET_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservices.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservices.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2010 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 for Location Based Servies Settings plugin + * for Advanced View + * + */ + +#ifndef POSLOCATIONSERVICES_PLUGIN_H +#define POSLOCATIONSERVICES_PLUGIN_H + +#include "poslocationservicesengine.h" + +#include +#include +#include +#include +#include + + +//Forward Declaration +class PosSettingsAdvOp; +class PosSettingsSignalMapper; +class HbMessageBox; +class HbAction; + +class PosLocationServices : public QObject, public PosSettingsAdvInterface + { +Q_OBJECT + Q_INTERFACES( PosSettingsAdvInterface) +public: + /** + * Constructor + */ + PosLocationServices(); + + /** + * Destructor + */ + ~PosLocationServices(); +public: + /* + * Derived from PosSettingsAdvInterface + */ + virtual int initialise(PosSettingsAdvOp* operation); + +private: + /** + * This method is used to list all the location services that are running + */ + void listServices(); + + /** + * This method constructs the string for update interval to be displayed in + * the second line of the widget. + * @param [in]- updateInterval, update interval is seconds, gets from the engine + * @param [out]- updateIntervalString, string to be displayed, depending on the update + * interval is in day, hour, minute or second + */ + void getUpdateIntervalString(int updateInterval, QString& updateIntervalString); + +private slots: + /** + * This is slot, which is called when the user selects the + * service to be deleted + */ + void stopService(int serviceId); + + /** + * This is slot, which is called whenever there is a new location service added or + * a server in the list is stopped. This refreshes the view. + */ + void updateList(); + + /** + * This slot is used to stop sessions. + * @param[in] action - Button which is pressed on messagebox dialog + */ + void stopSession(HbAction* action); + +private: + + /** + * an object if the location services setting engine class + */ + PosLocationServicesEngine* mLocationServiceEngine; + + /** + * an object of data form model item class + */ + HbDataFormModelItem * mGroup; + + /** + * Holds the params of the list of location services + */ + QList mServiceList; + + /** + * Handle to PosSettingsAdvOp object + */ + PosSettingsAdvOp * mOperation; + + /** + * an object of QSignalMapper + */ + QSignalMapper * mSignalMapper; + + /** + * hold the signal mapper objects of PosPsySettingsSignalMapper + */ + QList mSignalMapperList; + + + + /** + * holds the stop service query dialog + * Owns + */ + HbMessageBox * mStopQuery; + + /** + * holds service id to be stop + */ + int mServiceId; + }; +#endif // POSLOCATIONSERVICES_PLUGIN_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicescommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicescommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2010 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 header defines set of data structures used in +* locaion services plugin. +* +*/ + +#ifndef POSLOCATIONSERVICESCOMMON_H +#define POSLOCATIONSERVICESCOMMON_H + +#include +#include + +struct PosLocationServiceInfo + { + /** + * Location service Id. + */ + int mServiceId; + /** + * Location service name. + */ + QString mServiceName; + + /** + * Update interval. + */ + int mUpdateInterval; + + /** + * Date and time on which service ends. + */ + QDateTime mEndDateTime; + }; + +#endif //POSLOCATIONSERVICESCOMMON_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicesengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicesengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2010 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: Class declaration of PosLocationServicesEngine. +* +*/ +#ifndef POSLOCATIONSERVICESENGINE_H +#define POSLOCATIONSERVICESENGINE_H + +#include "poslocationservicesengineprivate.h" +#include + + + +/** + * PosLocationServicesEngine class provides interface to location services. + * Using this interface. This interface provides services like list, delete + * etc.. + */ +class PosLocationServicesEngine : public QObject, + public PosLocationServiceUpdateObserver + { + Q_OBJECT +public: + /** + * Constructor + */ + PosLocationServicesEngine(); + + /** + * Destructor + */ + virtual ~PosLocationServicesEngine(); + + /** + * Retrieves all location services info. + * + * @param[out] locationServiceList List of location + * services info. + * @return - KErrNone if location services information retrieved successfully. + * - KErrNotFound if there are no location services. + * otherwise system wide error codes. + */ + int getLocationServices( QList& + locationServiceList ); + + /** + * Removes location service based on the service Id. + * + * @param [in] serviceId Location service Id. + * + * @return following error codes + * - KErrNone if successful + * - KErrNotFound if service is not found + * otherwise system wide error codes. + */ + int removeLocationService( int serviceId ); + +public:// From PosLocationServiceUpdateObserver + void handleLocationServiceUpdate(); + +signals: + /** + * This signal is emitted when there is update in the + * location services. + */ + void locationServiceUpdate(); + +private:// Data members + /** + * Pointer to PosLocationServicesEnginePrivate object. + * Own + */ + PosLocationServicesEnginePrivate* d_ptr; + }; + +#endif /* POSLOCATIONSERVICESENGINE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicesengineprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/poslocationservicesengineprivate.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2010 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: Class declaration of PosLocationServicesEnginePrivate. +* +*/ +#ifndef POSLOCATIONSERVICESENGINEPRIVATE_H +#define POSLOCATIONSERVICESENGINEPRIVATE_H + +#include "poslocationservicescommon.h" +#include + +// Forward declaration +class CSuplSettings; + +/** + * The class defines the interface to get notification on location + * service update.The class interested in location service update + * should inherit from this class. + */ +class PosLocationServiceUpdateObserver + { +public: + virtual void handleLocationServiceUpdate() = 0; + }; + + +/** + * PosLocationServicesEnginePrivate class implements the engine logic.This + * provides wrapper over SUPL settings API + */ +class PosLocationServicesEnginePrivate : public MSuplSessionObserver + { +public: + /** + * Constructor + */ + PosLocationServicesEnginePrivate( PosLocationServiceUpdateObserver& + aObserver ); + + /** + * Destructor + */ + virtual ~PosLocationServicesEnginePrivate(); + + /** + * Retrieves all location services info. + * + * @param[out] locationServiceList List of location + * services info. + * @return - KErrNone if location services information retrieved successfully. + * - KErrNotFound if there are no location services. + * otherwise system wide error codes. + */ + int GetLocationServices( QList& + aLocationServiceList ); + + /** + * Retrieves all location services info. + * + * @param[out] locationServiceList List of location + * services info. + * @leaves - KErrNone if location services information retrieved successfully. + * - KErrNotFound if there are no location services. + * otherwise system wide error codes. + */ + void GetLocationServicesL( QList& + aLocationServiceList ); + /** + * Removes location service based on the service Id. + * + * @param [in] serviceId Location service Id. + * + * @return following error codes + * - KErrNone if successful + * - KErrNotFound if service is not found + * otherwise system wide error codes. + */ + int RemoveLocationService( int aServiceId ); + +public: // From MSuplSessionObserver + virtual void HandleSuplSessionChangeL( + TSuplSessionEventType aEvent,TInt64 aSessionId ); + +private:// Data members + + /** + * Reference to location service update observer. + */ + PosLocationServiceUpdateObserver& mObserver; + + /** + * Pointer to SUPL settings object. + * Own + */ + CSuplSettings* mSuplSettings; + }; + +#endif /* POSLOCATIONSERVICESENGINEPRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/inc/possettingssignalmapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/inc/possettingssignalmapper.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Settings signal mapper + * used to map the signals of each check box item to the index + * + */ + +#ifndef POSSETTINGSSIGNALMAPPER_H +#define POSSETTINGSSIGNALMAPPER_H + +#include + +class PosSettingsSignalMapper : public QObject + { + Q_OBJECT +public: + /* + * constructor + */ + PosSettingsSignalMapper(); + /** + * destructor + */ + ~PosSettingsSignalMapper(); +public: +signals: + /** + * signal emitted by the slot of this class + */ + void signalmapped(); +public slots: + /** + * slot to be called on a change in state of checkbox. + * this in turn calls the signal signalmapped() + */ + void signalmap(); + }; + +#endif //POSSETTINGSSIGNALMAPPER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/poslocationservices.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/poslocationservices.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,71 @@ +# +# Copyright (c) 2010 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: Location Based Services Plugin pro file +# + +TEMPLATE = lib +TARGET = poslocationservices +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += ../possettingsengine/inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb \ + plugin +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc +RESOURCES = poslocationservices.qrc + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +LIBS += -lcpframework \ + -lpossettingsengine \ + -lepos_suplsettings \ + -lflogger + +# Input +SOURCES += src/poslocationservices.cpp +SOURCES += src/poslocationservicesengine.cpp +SOURCES += src/poslocationservicesengineprivate.cpp +SOURCES += src/locationservicescustomviewitem.cpp +SOURCES += src/locationserviceswidget.cpp +SOURCES += src/possettingssignalmapper.cpp + +HEADERS += inc/poslocationservices.h +HEADERS += inc/poslocationservicescommon.h +HEADERS += inc/poslocationservicesengine.h +HEADERS += inc/poslocationservicesengineprivate.h +HEADERS += inc/locationservicescustomviewitem.h +HEADERS += inc/locationserviceswidget.h +HEADERS += inc/possettingssignalmapper.h + +symbian: { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += PLUGINUID3=0x2002DCEB + TARGET.UID3 = 0x2002DCEB +} +symbian { + deploy.path = C: + qtplugins.path = /resource/qt/plugins/positioningsettings + qtplugins.sources += qmakepluginstubs/poslocationservices.qtplugin + + # This is for new exporting system coming in garden + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" +} +TARGET.CAPABILITY = All \ + -TCB +plugin.sources = poslocationservices.dll +plugin.path = \resource\qt\plugins\positioningsettings +DEPLOYMENT += plugin diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/poslocationservices.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/poslocationservices.qrc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,10 @@ + + + resources/locationserviceswidget.widgetml + resources/locationserviceswidget.css + resources/locationservicesviewitemwidget.css + + + resources/qgn_note_warning.svg + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/resources/locationservicesviewitemwidget.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/resources/locationservicesviewitemwidget.css Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +LocationServicesCustomViewItem::dataItem_ContentWidget +{ + left: -var(hb-param-margin-gene-left); + right: var(hb-param-margin-gene-right); +} \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/resources/locationserviceswidget.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/resources/locationserviceswidget.css Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,36 @@ +LocationServicesWidget { + layout: default +} + +LocationServicesWidget::text_box1 { + left: -var(hb-param-margin-gene-left); + right: var(hb-param-margin-gene-right); + top: -var(hb-param-margin-gene-top); + bottom: var(hb-param-margin-gene-bottom); + pref-width: 36un; + pref-height: var(hb-param-text-height-secondary); + font-variant: primary; + text-height: var(hb-param-text-height-secondary); +} + +LocationServicesWidget::text_box2 { + left: -var(hb-param-margin-gene-left); + right: var(hb-param-margin-gene-right); + top: -var(hb-param-margin-gene-top); + bottom: var(hb-param-margin-gene-bottom); + pref-width: 36un; + pref-height: var(hb-param-text-height-secondary); + font-variant: secondary; + text-height: var(hb-param-text-height-secondary); +} + +LocationServicesWidget::text_box3 { + left: -var(hb-param-margin-gene-left); + right: var(hb-param-margin-gene-right); + top: -var(hb-param-margin-gene-top); + bottom: var(hb-param-margin-gene-bottom); + pref-width: 36un; + pref-height: var(hb-param-text-height-secondary); + font-variant: secondary; + text-height: var(hb-param-text-height-secondary); +} \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/resources/locationserviceswidget.widgetml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/resources/locationserviceswidget.widgetml Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/resources/qgn_note_warning.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/resources/qgn_note_warning.svg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/locationservicescustomviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/locationservicescustomviewitem.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2010 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 extended as HbDataFormViewItem to be used to create + * group items for location services + * + */ + + +#include "locationservicescustomviewitem.h" +#include "locationserviceswidget.h" +#include +#include +#include + + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::LocationServicesCustomViewItem +// --------------------------------------------------------------------------- +// +LocationServicesCustomViewItem::LocationServicesCustomViewItem( + QGraphicsItem *parent) : + HbDataFormViewItem(parent) + { + } + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::~LocationServicesCustomViewItem +// --------------------------------------------------------------------------- +// +LocationServicesCustomViewItem::~LocationServicesCustomViewItem() + { + } + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::createItem +// --------------------------------------------------------------------------- +// +HbAbstractViewItem* LocationServicesCustomViewItem::createItem() +{ + return new LocationServicesCustomViewItem(*this); +} + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::canSetModelIndex +// --------------------------------------------------------------------------- +// +bool LocationServicesCustomViewItem::canSetModelIndex(const QModelIndex &index) const +{ + int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt(); + if (type == LocationServicesCustomItem) { + return true; + } + else { + return false; + } +} + + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::createCustomWidget +// --------------------------------------------------------------------------- +// +HbWidget * LocationServicesCustomViewItem::createCustomWidget() + { + //get the type of the model + int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt(); + if (type == LocationServicesCustomItem) + { + //create the instance of location widget + LocationServicesWidget* locationservicesWidget = + new LocationServicesWidget(); + mPushWidget = locationservicesWidget; + return mPushWidget; + } + else + { + //else return 0 + return 0; + } + } + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::restore +// --------------------------------------------------------------------------- +// +void LocationServicesCustomViewItem::restore() +{ + HbDataFormViewItem::restore(); + if (mPushWidget) { + HbDataFormModelItem::DataItemType itemType = static_cast( + modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); + + if(itemType == LocationServicesCustomItem) { + + QModelIndex itemIndex = modelIndex(); + HbDataFormModel *model = static_cast(itemView()->model());; + HbDataFormModelItem *modelItem = static_cast( + model->itemFromIndex(itemIndex)); + + const QMetaObject *metaObj = mPushWidget->metaObject(); + int count = metaObj->propertyCount(); + for (int i = 0; i < count; ++i) { + QMetaProperty metaProperty = metaObj->property(i); + if (metaProperty.isValid() && metaProperty.isWritable()) { + metaProperty.write(mPushWidget,modelItem->contentWidgetData(metaProperty.name())); + } + + } + } + } +} + +// --------------------------------------------------------------------------- +// LocationServicesCustomViewItem::save +// --------------------------------------------------------------------------- +// +/*void LocationServicesCustomViewItem::save() +{ + HbDataFormViewItem::save(); + if (mPushWidget) { + HbDataFormModelItem::DataItemType itemType = static_cast( + modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); + + if(itemType == LocationServicesCustomItem) { + + QModelIndex itemIndex = modelIndex(); + HbDataFormModel *model = static_cast(itemView()->model());; + HbDataFormModelItem *modelItem = static_cast( + model->itemFromIndex(itemIndex)); + if (LocationServicesWidget *locationservicesWidget = qobject_cast(mPushWidget)) { + modelItem->setContentWidgetData("primarytext",locationservicesWidget->primaryText()); + modelItem->setContentWidgetData("sectext",locationservicesWidget->secText()); + modelItem->setContentWidgetData("sec2text",locationservicesWidget->sec2Text()); + } + } + } +}*/ + +//-------------End of File-------------------------- diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/locationserviceswidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/locationserviceswidget.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2010 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 file is for creating the custom widget for location services + * for Advanced view of Positioning settings + * + */ + +#include "locationserviceswidget.h" + +#include +#include +#include +#include +#include + + +static const QString FILE_PATH_WIDGETML = + ":/data/locationserviceswidget.widgetml"; +static const QString FILE_PATH_CSS = ":/data/locationserviceswidget.css"; + +// --------------------------------------------------------------------------- +// LocationServicesWidget::LocationServicesWidget +// --------------------------------------------------------------------------- +// +LocationServicesWidget::LocationServicesWidget(QGraphicsItem *parent) : + HbAbstractButton(parent) + { + // Path for widgetml and css files. + HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML); + HbStyleLoader::registerFilePath(FILE_PATH_CSS); + + //Create the primary and secondry text items + mPrimaryTextItem = new HbTextItem(QString("New"), this); + HbStyle::setItemName(mPrimaryTextItem, "text_box1"); + mPrimaryTextItem->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + + mSecondryTextItem = new HbTextItem(QString("New"), this); + HbStyle::setItemName(mSecondryTextItem, "text_box2"); + mSecondryTextItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); + + mSecondry2TextItem = new HbTextItem(QString("New"), this); + HbStyle::setItemName(mSecondry2TextItem, "text_box3"); + mSecondry2TextItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::LocationServicesWidget +// --------------------------------------------------------------------------- +// +LocationServicesWidget::~LocationServicesWidget() + { + HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML); + HbStyleLoader::unregisterFilePath(FILE_PATH_CSS); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::setPrimaryText +// --------------------------------------------------------------------------- +// +void LocationServicesWidget::setPrimaryText(const QString &primaryText) + { + mPrimaryTextItem->setText(primaryText); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::primaryText +// --------------------------------------------------------------------------- +// +QString LocationServicesWidget::primaryText() const + { + return mPrimaryTextItem->text(); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::setSecText +// --------------------------------------------------------------------------- +// +void LocationServicesWidget::setSecText(const QString& secText) + { + mSecondryTextItem->setText(secText); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::secText +// --------------------------------------------------------------------------- +// +QString LocationServicesWidget::secText() const + { + return mSecondryTextItem->text(); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::setSec2Text +// --------------------------------------------------------------------------- +// +void LocationServicesWidget::setSec2Text(const QString& secText) + { + mSecondry2TextItem->setText(secText); + } +// --------------------------------------------------------------------------- +// LocationServicesWidget::sec2Text +// --------------------------------------------------------------------------- +// +QString LocationServicesWidget::sec2Text() const + { + return mSecondry2TextItem->text(); + } + +// end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservices.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservices.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,478 @@ +/* + * Copyright (c) 2010 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 for Location Services Settings plugin + * for Positioning Settings's Advanced view + * + */ + +#include "poslocationservices.h" +#include "possettingsadvop.h" +#include "locationservicescustomviewitem.h" +#include "possettingssignalmapper.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +// constants +const int KMinToSecs = 60; +const int KHourToSecs = 3600; +const int KOneDay = 24; + +// --------------------------------------------------------------------------- +// PosLocationServices::PosLocationServices +// --------------------------------------------------------------------------- +// +PosLocationServices::PosLocationServices() : + mLocationServiceEngine(0), mGroup(0), mOperation(0), mSignalMapper(0), + mStopQuery(0), mServiceId(0) + { + mLocationServiceEngine = new PosLocationServicesEngine(); + } + +// --------------------------------------------------------------------------- +// PosLocationServices::~PosLocationServices +// --------------------------------------------------------------------------- +// +PosLocationServices::~PosLocationServices() + { + qDebug() << "+PosLocationServices::~PosLocationServices()"; + + if (mLocationServiceEngine) + { + delete mLocationServiceEngine; + mLocationServiceEngine = 0; + } + + if (mGroup) + { + if (mOperation) + { + mOperation->removeItem(mGroup); + } + } + + if (mSignalMapper) + { + delete mSignalMapper; + mSignalMapper = 0; + } + + if (mStopQuery) + { + delete mStopQuery; + mStopQuery = 0; + } + + //Clear the list + mServiceList.clear(); + + //clear the signal mapper list + int count = mSignalMapperList.count(); + qDebug() << "mSignalMapperList.count() = " << count; + + for (int i = 0; i < count; ++i) + { + delete mSignalMapperList[i]; + mSignalMapperList[i] = 0; + } + mSignalMapperList.clear(); + + qDebug() << "-PosLocationServices::~PosLocationServices()"; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::initialise +// --------------------------------------------------------------------------- +// +int PosLocationServices::initialise(PosSettingsAdvOp* operation) + { + qDebug() << "+PosLocationServices::initialise()"; + + int result = 0; + + // Assign to the member variable + mOperation = operation; + + //get the prototype list from the data form and append the custom control to the list + QList protoTypeList; + mOperation->itemPrototypes(protoTypeList); + + LocationServicesCustomViewItem* item = + new LocationServicesCustomViewItem(); + + protoTypeList.append(item); + + mOperation->setItemPrototypes(protoTypeList); + + // create the signal mapper + mSignalMapper = new QSignalMapper(); + + //get the list of location services + mServiceList.clear(); + if (mLocationServiceEngine) + { + result = mLocationServiceEngine->getLocationServices(mServiceList); + } + + qDebug() << "PosLocationServices::initialise(): result" << result; + + // if no error while getting the services list then add the group + // for Location based services + if (result == 0) + { + mGroup = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, + hbTrId("txt_loe_subtitle_background_positioning"), 0); + + //Add the group to the data form + mOperation->appendDataFormItem(mGroup); + + //list all the location services inside the group + listServices(); + } + QObject::connect(mLocationServiceEngine, SIGNAL(locationServiceUpdate()), + this, SLOT(updateList())); + + qDebug() << "-PosLocationServices::initialise()"; + return result; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::listServices +// --------------------------------------------------------------------------- +// +void PosLocationServices::listServices() + { + qDebug() << "+PosLocationServices::listServices()"; + qDebug() << "No of Location Services = " << mServiceList.count(); + + QList::const_iterator serviceIterator; + + qDebug() << "Appending the services in group "; + + // Get the location services names and display + for (serviceIterator = mServiceList.begin(); serviceIterator + != mServiceList.end(); ++serviceIterator) + { + qDebug() << "serviceIterator->mServiceId = " + << serviceIterator->mServiceId; + + qDebug() << "serviceIterator->mServiceName = " + << serviceIterator->mServiceName; + + qDebug() << "serviceIterator->mEndDateTime = " + << serviceIterator->mEndDateTime.date().toString(); + + qDebug() << "serviceIterator->mEndDateTime.isValid() = " + << serviceIterator->mEndDateTime.date().isValid(); + + qDebug() << "serviceIterator->mUpdateInterval = " + << serviceIterator->mUpdateInterval; + + // if any of the fields are invalid then skip listing + if (serviceIterator->mUpdateInterval > 0) + { + qDebug() << "creating services"; + + //for each services create new custom item + HbDataFormModelItem + * service = + new HbDataFormModelItem( + static_cast (LocationServicesCustomItem)); + + if(!serviceIterator->mServiceName.isEmpty()) + //set the widget data to the server name + service->setContentWidgetData("primarytext", + serviceIterator->mServiceName); + else + service->setContentWidgetData("primarytext", + QString(hbTrId("txt_loe_info_unknown_requestor"))); + + QString updateIntervalString; + //get the update interval String + getUpdateIntervalString(serviceIterator->mUpdateInterval, + updateIntervalString); + service->setContentWidgetData("sectext", updateIntervalString); + + //get the validity end date from the engine and convert to string + QString validity(serviceIterator->mEndDateTime.date().toString( + Qt::ISODate)); + + service->setContentWidgetData("sec2text", QString(hbTrId( + "txt_loe_list_valid_until_2")).arg(validity)); + + qDebug() << "Adding service into the group"; + mOperation->appendDataFormItem(service, mGroup); + + //create an object of dummy signal mapper class + //this is done to send the index info to the slots + //since checkbox is not of QObject type and dummy class is + // created. + PosSettingsSignalMapper* signalMapper = + new PosSettingsSignalMapper(); + + qDebug() << "Adding the signalMapper into mSignalMapperList"; + mSignalMapperList.append(signalMapper); + + //add connection for clicked for the custom item, depending on which the + //add connections to launch the dialog for the stopping the service + mOperation->addConnection( + service, + SIGNAL(clicked(bool)), + mSignalMapperList[serviceIterator - mServiceList.begin()], + SLOT(signalmap())); + + QObject::connect(mSignalMapperList[serviceIterator + - mServiceList.begin()], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + + // set mapping of each check box item to its index + if (mSignalMapper) + { + qDebug() << "mSignalMapper->setMapping "; + mSignalMapper->setMapping(mSignalMapperList[serviceIterator + - mServiceList.begin()], (serviceIterator + - mServiceList.begin())); + } + } + } + + qDebug() << "mGroup->childCount() = " << mGroup->childCount(); + + if (mGroup->childCount() == 0) + { + qDebug() << "mOperation->removeItem mGroup"; + mOperation->removeItem(mGroup); + mGroup = NULL; + } + else + { + //use signal mapper to connect + qDebug() << "use signal mapper to use stop service"; + QObject::connect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(stopService(int))); + } + qDebug() << "-PosLocationServices::listServices()"; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::updateList +// --------------------------------------------------------------------------- +// +void PosLocationServices::updateList() + { + qDebug() << "+PosLocationServices::updateList()"; + int result = 0; + int oldChildCount = 0; + + //store the current state (expanded) of the group + if (mGroup) + { + qDebug() << "Store the group info"; + + oldChildCount = mGroup->childCount(); + + // remove all connections + int count = mSignalMapperList.count(); + qDebug() << "mSignalMapperList.count() = " << count; + + if (count > 0) + { + for (TInt i = 0; i < count; ++i) + { + QObject::disconnect(mSignalMapperList[i], + SIGNAL(signalmapped()), mSignalMapper, SLOT(map())); + } + QObject::disconnect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(stopService(int))); + } + mSignalMapperList.clear(); + + qDebug() << " oldChildCount" << oldChildCount; + if (oldChildCount > 0) + { + qDebug() << "Removing the old children"; + //mGroup->removeChildren(0, oldChildCount); + //ToDo: Hack from HbDataForm team + for (int i = 0; i < oldChildCount; ++i) + { + qDebug() << "remove chile index " << i; + mGroup->removeChild(0); + } + } + + } + else + { + // this part of code is called when the services are added and + // Advanced view is in the background. Since there is no group + // a new group has to be created to add the services. + qDebug() << "Creating new group"; + mGroup = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, + hbTrId("txt_loe_subtitle_background_positioning"), 0); + mOperation->appendDataFormItem(mGroup); + } + + qDebug() << "oldChildCount = " << oldChildCount; + qDebug() << "mServiceList.count() before update = " + << mServiceList.count(); + + //clear the list and get the list of server present for positioning + mServiceList.clear(); + if (mLocationServiceEngine) + { + result = mLocationServiceEngine->getLocationServices(mServiceList); + } + + qDebug() << "PosLocationServices::listServices(): result" << result; + + //update the new list to the group + if (result == 0) + { + listServices(); + } + if (result == -1) + { + //remove the group + mOperation->removeItem(mGroup); + mGroup = NULL; + } + + qDebug() << "-PosLocationServices::updateList()"; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::stopService +// --------------------------------------------------------------------------- +// +void PosLocationServices::stopService(int serviceId) + { + qDebug() << "+PosLocationServices::stopService() service Id" << serviceId; + + mServiceId = serviceId; + + //Construct the display string + QString displayString; + displayString.append(QString(hbTrId("txt_loe_info_stop_service_1")).arg( + mServiceList[serviceId].mServiceName)); + + //create the message mStopQuery dialog + //HbMessageBox * mStopQuery = new HbMessageBox(); + + if (mStopQuery == 0) + { + mStopQuery = new HbMessageBox(); + mStopQuery->setTimeout(HbDialog::NoTimeout); + + //the secondry action that will come in the SK2 of the Dialog box + mStopQuery->addAction(new HbAction(QString(hbTrId( + "txt_common_button_cancel")))); + + //To-Do: set the actual stop service icon after released in sdk + QIcon stopServiceIcon(":/resources/qgn_note_warning.svg"); + mStopQuery->setIcon(HbIcon(stopServiceIcon)); + } + + //set the mStopQuery text + mStopQuery->setText(displayString); + mStopQuery->open(this,SLOT(stopSession(HbAction*))); + + qDebug() << "-PosLocationServices::stopService()"; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::stopSession +// --------------------------------------------------------------------------- +// +void PosLocationServices::stopSession(HbAction* action) + { + qDebug() << " + PosLocationServices::stopSession()"; + + //if LSK is pressed + if ((action == mStopQuery->actions().at(0)) && mLocationServiceEngine) + { + //stop the session + mLocationServiceEngine->removeLocationService( + mServiceList[mServiceId].mServiceId); + } + qDebug() << " - PosLocationServices::stopSession()"; + } + +// --------------------------------------------------------------------------- +// PosLocationServices::getUpdateIntervalString +// --------------------------------------------------------------------------- +// +void PosLocationServices::getUpdateIntervalString(int updateInterval, + QString& updateIntervalString) + { + qDebug() + << "+PosLocationServices::getUpdateIntervalString(): updateInterval" + << updateInterval; + + //To-Do: clarification needed from chelli + if (updateInterval / KMinToSecs < 1) + { + //seconds + QVariant var(updateInterval); + updateIntervalString = QString(hbTrId( + "txt_loe_list_updates_every_l1_seconds")).arg(var.toString()); + } + else if (updateInterval / KHourToSecs < 1) + { + //minutes + int minutes = (updateInterval / KMinToSecs); + int seconds = (updateInterval % KMinToSecs); + QVariant varMinutes(minutes); + QVariant varSeconds(seconds); + updateIntervalString = QString(hbTrId( + "txt_loe_list_updates_every_l1_minutes_and_l2_sec")).arg( + varMinutes.toString()).arg(varSeconds.toString()); + } + else if (updateInterval / (KHourToSecs * KOneDay) < 1) + { + //hour + int hours = (updateInterval / KHourToSecs); + int minutes = (updateInterval % KHourToSecs) / KMinToSecs; + QVariant varhour(hours); + QVariant varMinutes(minutes); + + updateIntervalString = QString(hbTrId( + "txt_loe_list_updates_every_l1_hours_and_l2_minut")).arg( + varhour.toString()).arg(varMinutes.toString()); + } + else + { + //days + int days = (updateInterval / (KHourToSecs * KOneDay)); + int hours = (updateInterval % (KHourToSecs * KOneDay)) / KMinToSecs; + QVariant varDays(days); + QVariant varHours(hours); + updateIntervalString = QString(hbTrId( + "txt_loe_list_updates_every_l1_days_and_l2_hours")).arg( + varDays.toString()).arg(varHours.toString()); + } + + qDebug() << "-PosLocationServices::updateInterval()"; + + } + +Q_EXPORT_PLUGIN2(poslocationservices, PosLocationServices) +; + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservicesengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservicesengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2010 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: Implementation of PosLocationServicesEngine class. +* +*/ +#include "poslocationservicesengine.h" + + +//---------------------------------------------------------------------- +// PosLocationServicesEngine::PosLocationServicesEngine +//---------------------------------------------------------------------- +PosLocationServicesEngine::PosLocationServicesEngine() + { + d_ptr = new PosLocationServicesEnginePrivate( *this ); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEngine::~PosLocationServicesEngine +//---------------------------------------------------------------------- +PosLocationServicesEngine::~PosLocationServicesEngine() + { + delete d_ptr; + d_ptr = NULL; + } + +//---------------------------------------------------------------------- +// PosLocationServicesEngine::getLocationServices +//---------------------------------------------------------------------- +int PosLocationServicesEngine::getLocationServices( + QList& + locationServiceList ) + { + return d_ptr->GetLocationServices( locationServiceList ); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEngine::removeLocationService +//---------------------------------------------------------------------- +int PosLocationServicesEngine::removeLocationService( int serviceId ) + { + return d_ptr->RemoveLocationService( serviceId ); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEngine::handleLocationServiceUpdate +//---------------------------------------------------------------------- +void PosLocationServicesEngine::handleLocationServiceUpdate() + { + emit locationServiceUpdate(); + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservicesengineprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/poslocationservicesengineprivate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2010 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: Implementation of PosLocationServicesEnginePrivate class. + * + */ +#include "poslocationservicesengineprivate.h" + +#include +#include +#include + +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::PosLocationServicesEnginePrivate +//---------------------------------------------------------------------- +PosLocationServicesEnginePrivate::PosLocationServicesEnginePrivate( + PosLocationServiceUpdateObserver& aObserver) : + mObserver(aObserver) + { + QT_TRAP_THROWING( mSuplSettings = CSuplSettings::NewL(); + mSuplSettings->SetSessionObserverL( *this ) ); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::~PosLocationServicesEnginePrivate +//---------------------------------------------------------------------- +PosLocationServicesEnginePrivate::~PosLocationServicesEnginePrivate() + { + mSuplSettings->RemoveSessionObserver(); + delete mSuplSettings; + mSuplSettings = NULL; + } + +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::GetLocationServices +//---------------------------------------------------------------------- +int PosLocationServicesEnginePrivate::GetLocationServices(QList< + PosLocationServiceInfo>& aLocationServiceList) + { + int err = 0; + TRAP(err, GetLocationServicesL(aLocationServiceList)); + return err; + } +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::GetLocationServicesL +//---------------------------------------------------------------------- +void PosLocationServicesEnginePrivate::GetLocationServicesL(QList< + PosLocationServiceInfo>& aLocationServiceList) + { + RPointerArray triggerParams; + CleanupClosePushL(triggerParams); + int error = mSuplSettings->GetTriggerParams(triggerParams); + + int count = triggerParams.Count(); + + //if there are no trigger params then leave with KErrNotFound + if (count <= 0) + { + User::Leave(KErrNotFound); + } + + //for each entry in the paramlist populate the locationservice list + for (int i = 0; i < count; ++i) + { + + TInt64 sessionId; + TUint64 outstandingTrigger; + TUint64 interval; + TTime endTime; + TBool notificationPresent; + TBool triggerNotificationStatus; + CTriggerParams::TTriggerType triggerType; + CTriggerParams::TRequestType requestType; + HBufC* sessionName = HBufC::NewLC( + KMaxTriggerSessionNameLen); + + error = triggerParams[i]->Get(sessionId, sessionName->Des(), + notificationPresent, triggerNotificationStatus, triggerType, + requestType, outstandingTrigger, interval); + triggerParams[i]->GetTriggerEndTime(endTime); + + if (error == KErrNone) + { + PosLocationServiceInfo serviceInfo; + serviceInfo.mServiceId = sessionId; + QString sName((QChar*) (sessionName->Ptr()), + sessionName->Length()); + + serviceInfo.mServiceName.append(sName); + serviceInfo.mUpdateInterval = interval; + serviceInfo.mEndDateTime.setDate(QDate(endTime.DateTime().Year(), + endTime.DateTime().Month() + 1, endTime.DateTime().Day() + + 1)); + serviceInfo.mEndDateTime.setTime(QTime(endTime.DateTime().Hour(), + endTime.DateTime().Minute(), endTime.DateTime().Second(), + endTime.DateTime().MicroSecond())); + + aLocationServiceList.append(serviceInfo); + } + CleanupStack::PopAndDestroy(sessionName); + } + CleanupStack::Pop(&triggerParams); + triggerParams.ResetAndDestroy(); + + //leave if there is an error + User::LeaveIfError(error); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::RemoveLocationService +//---------------------------------------------------------------------- +int PosLocationServicesEnginePrivate::RemoveLocationService(int aServiceId) + { + return mSuplSettings->CancelTriggerSession(aServiceId); + } + +//---------------------------------------------------------------------- +// PosLocationServicesEnginePrivate::HandleSuplSessionChangeL +//---------------------------------------------------------------------- +void PosLocationServicesEnginePrivate::HandleSuplSessionChangeL( + TSuplSessionEventType /*aEvent*/, TInt64 /*aSessionId*/) + { + mObserver.handleLocationServiceUpdate(); + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/poslocationservices/src/possettingssignalmapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/poslocationservices/src/possettingssignalmapper.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 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: Implementation of Positioning settings signal mapper class + * + */ + + +#include "possettingssignalmapper.h" + + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// Constructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// destructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::~PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// +//--------------------------------------------------------------------- +void PosSettingsSignalMapper::signalmap() + { + emit signalmapped(); + } + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingscommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingscommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 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: Contains the common data structures & Enum + * + */ + +#ifndef POSPSYSETTINGSCOMMON_H +#define POSPSYSETTINGSCOMMON_H + +#include +#include + +/** + * Enumeration to indicate the state of the Psy + */ +enum PosPsyState + { + PsyEnable, + + PsyDisable + }; +/** + * Struct that contains all the info related to each Psy + * - uid of Psy + * - name + * - state of the Psy whether enabled/disabled + */ +struct PosPsyInfo + { + TUid mPsyModuelId; + + QString mPsyName; + + PosPsyState mPsyState; + }; + +#endif /* POSPSYSETTINGSCOMMON_H */ + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Methods engine class + * used to get the list of available Psy & to manipulate + * the state of the Psy. + * + * + */ + +#ifndef POSPSYSETTINGSENGINE_H +#define POSPSYSETTINGSENGINE_H + +#include "pospsysettingsengineprivate.h" + +#include +#include + +class PosPsySettingsEngine : public QObject, + public PositionTechnologyChangeObserver + { +Q_OBJECT + +public: + /** + * Constructor + */ + PosPsySettingsEngine(); + + /** + * Destructor + */ + + ~PosPsySettingsEngine(); + + /** + * This method lists all the PSY that are available + * @param[out] psyList - Contains the list of psys that are available + * @return - KErrNone - if successfully finds any Psy + * KErrNotFound - if no Psy available. + */ + int listPsys(QList& psyList); + + /** + * This method is used to change the state of the Psy based on the user's + * action of either enabling/disabling the Psy. + * @param[in] psyModuleId - the uid of the Psy whose state is to be changed. + * @param[in] psyState - The value of state to which the Psy has to be changed. + */ + + int changePsyState(TUid psyModuleId, PosPsyState psyState); + +public: // from PositionTechnologyChangeObserver + void handlePositionTechnologyChange(); + +private: +signals: + /** + * This signal is emitted when there is change in PSY wrt to + * its availabilty, state etc.. + */ + void PSYChange(); +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosPsySettingsEngine) +private: + /** + * POinter to the PosPsySettingsEnginePrivate + * Owns + */ + PosPsySettingsEnginePrivate* d_ptr; + }; + +#endif /* POSPSYSETTINGSENGINE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsengineprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsengineprivate.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Methods private engine class + * used to get the list of available Psy & to manipulate + * the state of the Psy by using the location framework apis. + * + * + */ + +#ifndef POSPSYSETTINGSENGINEPRIVATE_H +#define POSPSYSETTINGSENGINEPRIVATE_H + +#include "pospsysettingscommon.h" + +#include +#include +#include + +/** + * The class defines the interface for receiving position + * technology change event.The class interested in position + * technology change should inherit from this class. + */ +class PositionTechnologyChangeObserver + { +public: + virtual void handlePositionTechnologyChange() = 0; + }; + + +// Forward declarations +class CPosModules; +class PosPsySettingsEngine; + +class PosPsySettingsEnginePrivate : public MPosModulesObserver + { +public: + /** + * Constructor + */ + PosPsySettingsEnginePrivate( PositionTechnologyChangeObserver& + posTechChangeObserver); + + /** + * Destructor + */ + + ~PosPsySettingsEnginePrivate(); + + /** + * This method lists all the PSY that are available + * @param[out] psyList - Contains the list of psys that are available + * @return - KErrNone - if successfully finds any Psy + * KErrNotFound - if no Psy available. + */ + int listPsys( QList& psyList ); + + /** + * This method is used to change the state of the Psy based on the user's + * action of either enabling/disabling the Psy. + * @param[in] psyModuleId - the uid of the Psy whose state is to be changed. + * @param[in] psyState - The value of state to which the Psy has to be changed. + */ + + int changePsyState( TUid psyModuleId, PosPsyState psyState ); + +public: // from MPosModulesObserver + virtual void HandleSettingsChangeL( TPosModulesEvent aEvent ); + +private: + /** + * This method uses the location framework apis to get the list of available psy + */ + void listPsysL(); + /** + * This method uses the location framework apis to manipulate the state of the Psy + */ + void changePsyStateL( TUid psyModuleId, PosPsyState psyState ); +private : + /** + * Pointer to CPosModules + * Owns + */ + CPosModules* mPosModules; + + /** + * Contains list of PSY info + * Own + */ + RArray mPsyInfoList; + /** + * Reference to position technology change observer. + */ + PositionTechnologyChangeObserver& mPosTechChangeObserver; + /* + * POinter to the name of the psy + * ToDo: Should be removed + */ + QList mNameList; + + friend class PosPsySettingsEngine; + }; + +#endif /* POSPSYSETTINGSENGINEPRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/inc/pospsysettingsplugin.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Methods plugin to the + * Avanced settings view + * + */ + +#ifndef POSPSYSETTINGSPLUGIN_H +#define POSPSYSETTINGSPLUGIN_H + + +#include "possettingsadvinterface.h" +#include "pospsysettingscommon.h" +#include "possettingssignalmapper.h" + +#include +#include +#include + +// Forward Declaration +class PosPsySettingsEngine; +class PosSettingsAdvOp; +class PosSettingsSignalMapper; + +class PosPsySettingsPlugin : public QObject, public PosSettingsAdvInterface +{ +Q_OBJECT + Q_INTERFACES( PosSettingsAdvInterface ) +public: + /** + * Constructor + */ + PosPsySettingsPlugin(); + /** + * Destructor + */ + ~PosPsySettingsPlugin(); +public: + /** + * Derived from PosSettingsAdvInterface + */ + int initialise( PosSettingsAdvOp* operation ); + +private slots: + /** + * This will be called when any of the positioning methods checkbox is clicked. + * @param[in] state - indicates the state of the checkbox,whether enabled/disabled + * @param[in] psyUid - indicates the Uid of the Psy that has been clciked. + */ + void onPsyPressed(int index); + /** + * This method will be called on a change in any of the psy info. + * It willbe used to update the positioning methods group to reflect + * the latest available info of psys. + */ + void updateGroup(); + +private: + /** + * adds items to the group & make connections + */ + void addItems(); + + +private: + /** + * Pointer to the PosPsySettingsEngine + * Owns + */ + PosPsySettingsEngine* mEngine; + /** + * List of available Positioning methods + */ + QList mPsyList; + /** + * pointer to the HbDataFormModelItem + * Does not own + */ + HbDataFormModelItem* mGroup; + /** + * Signal mapper used to map the signal emitted from + * each of the psy check box to the slot + * Owns + */ + QSignalMapper *mSignalMapper; + /** + * List of psy signal mapper class + */ + QList mPsySignalMapperList; + /** + * reference to PosSettingsAdvOp + */ + PosSettingsAdvOp* mOperation; + +}; +#endif // POSPSYSETTINGSPLUGIN_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/inc/possettingssignalmapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/inc/possettingssignalmapper.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Methods plugin signal mapper + * used to map the signals of each check box item to the index + * + */ + +#ifndef PosSettingsSignalMapper_H +#define PosSettingsSignalMapper_H + +#include + +class PosSettingsSignalMapper : public QObject + { + Q_OBJECT +public: + /* + * constructor + */ + PosSettingsSignalMapper(); + /** + * destructor + */ + ~PosSettingsSignalMapper(); +private: +signals: + /** + * signal emitted by the slot of this class + */ + void signalmapped(); +public slots: + /** + * slot to be called on a change in state of checkbox. + * this in turn calls the signal signalmapped() + */ + void signalmap(); + }; + +#endif //PosSettingsSignalMapper_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/pospsysettings.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/pospsysettings.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,65 @@ +# +# Copyright (c) 2010 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: PosPsySetting pro file +# + +TEMPLATE = lib +TARGET = pospsysettings +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb \ + plugin + +#Uncomment following line to disable logging +#DEFINES += QT_NO_DEBUG_OUTPUT +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +LIBS += -lcpframework \ + -llbs \ + -leposmodset \ + -lpossettingsengine + +# Input +SOURCES += src/possettingssignalmapper.cpp \ + src/pospsysettingsplugin.cpp \ + src/pospsysettingsengine.cpp \ + src/pospsysettingsengineprivate.cpp +HEADERS += inc/possettingssignalmapper.h \ + inc/pospsysettingsplugin.h \ + inc/pospsysettingsengine.h \ + inc/pospsysettingsengineprivate.h \ + inc/pospsysettingscommon.h +symbian: { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += PLUGINUID3=0x2002C31A + TARGET.UID3 = 0x2002C31A +} +symbian { + deploy.path = C: + qtplugins.path = /resource/qt/plugins/positioningsettings + qtplugins.sources += qmakepluginstubs/pospsysettings.qtplugin + + # This is for new exporting system coming in garden + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" +} +TARGET.CAPABILITY = All -TCB +plugin.sources = pospsysettings.dll +plugin.path = \resource\qt\plugins\positioningsettings +DEPLOYMENT += plugin diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2010 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: Implementation of psy settings engine class. + * + */ + +#include "pospsysettingsengine.h" +#include + +//--------------------------------------------------------------------- +// PosPsySettingsEngine::PosPsySettingsEngine() +// Constructor +//--------------------------------------------------------------------- +PosPsySettingsEngine::PosPsySettingsEngine() + { + qDebug() << "+ PosSettingsEngine::PosPsySettingsEngine()"; + d_ptr = new PosPsySettingsEnginePrivate(*this); + qDebug() << "- PosSettingsEngine::PosPsySettingsEngine()"; + } + +//--------------------------------------------------------------------- +// PosPsySettingsEngine::~PosPsySettingsEngine() +// Destructor +//--------------------------------------------------------------------- +PosPsySettingsEngine::~PosPsySettingsEngine() + { + qDebug() << "+ PosSettingsEngine::~PosPsySettingsEngine()"; + delete d_ptr; + d_ptr = NULL; + qDebug() << "- PosSettingsEngine::~PosPsySettingsEngine()"; + } + +//--------------------------------------------------------------------- +// PosPsySettingsEngine::listPsys( QList& psyList ) +// +//--------------------------------------------------------------------- +int PosPsySettingsEngine::listPsys(QList& psyList) + { + qDebug() << "+ PosSettingsEngine::listPsys()"; + int ret = d_ptr->listPsys(psyList); + qDebug() << "- PosSettingsEngine::listPsys()" << ret; + return ret; + } + +//--------------------------------------------------------------------- +// PosPsySettingsEngine::changePsyState( TUid psyModuleId, PosPsyState psyState ) +// +//--------------------------------------------------------------------- +int PosPsySettingsEngine::changePsyState(TUid psyModuleId, + PosPsyState psyState) + { + qDebug() << "+ PosSettingsEngine::changePsyState()"; + qDebug() << "psystate = " << psyState; + int ret = d_ptr->changePsyState(psyModuleId, psyState); + qDebug() << "- PosSettingsEngine::changePsyState()" << ret; + return ret; + } + +//--------------------------------------------------------------------- +// PosPsySettingsEngine::handlePositionTechnologyChange +// +//--------------------------------------------------------------------- +void PosPsySettingsEngine::handlePositionTechnologyChange() + { + qDebug() << "+ PosSettingsEngine::handlePositionTechnologyChange()"; + // emit the signal when there is a change in the list of available psys + emit PSYChange(); + qDebug() << "- PosSettingsEngine::handlePositionTechnologyChange()"; + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsengineprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsengineprivate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2010 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: Implementation of psy settings engine private class. + * + */ + + +#include "pospsysettingsengineprivate.h" +#include "pospsysettingsengine.h" + +#include +#include +#include +#include + +// constants +const TInt KNameLength = 50; + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::PosPsySettingsEnginePrivate() +// Constructor +//--------------------------------------------------------------------- +PosPsySettingsEnginePrivate::PosPsySettingsEnginePrivate( + PositionTechnologyChangeObserver& posTechChangeObserver) : + mPosTechChangeObserver(posTechChangeObserver) + { + + // initialize the CPosModules pointer + QT_TRAP_THROWING ( mPosModules = CPosModules::OpenL(); + // Register for settings change. + mPosModules->SetObserverL( *this )); + } + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::~PosPsySettingsEnginePrivate() +// Destructor +//--------------------------------------------------------------------- +PosPsySettingsEnginePrivate::~PosPsySettingsEnginePrivate() + { + // delete mPosModules + if (mPosModules) + { + // remove the observer + mPosModules->RemoveObserver(); + delete mPosModules; + mPosModules = NULL; + } + // delete the psyname + TInt cnt = mNameList.count(); + for(TInt i=0;i& psyList ) +// +//--------------------------------------------------------------------- +int PosPsySettingsEnginePrivate::listPsys(QList& psyList) + { + // Get the list of available psy + TRAPD( error, listPsysL() ); + + if (error == KErrNone) + { + // copy the psy from RArray to the Qlist + TInt cnt = mPsyInfoList.Count(); + for (TInt i = 0; i < cnt; ++i) + { + psyList.append(mPsyInfoList[i]); + } + return KErrNone; + } + else + { + return error; + } + + } + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::changePsyState( TUid psyModuleId, PosPsyState psyState ) +// +//--------------------------------------------------------------------- +int PosPsySettingsEnginePrivate::changePsyState(TUid psyModuleId, + PosPsyState psyState) + { + // update the psy state + TRAPD( error, changePsyStateL( psyModuleId, psyState ) ); + return error; + } + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::listPsysL( ) +// +//--------------------------------------------------------------------- +void PosPsySettingsEnginePrivate::listPsysL() + { + // reset the list of psyinfo + mPsyInfoList.Reset(); + + // get the list of psy module ids + CPosModuleIdList* idList = mPosModules->ModuleIdListLC(); + // for each psy in the list,do the following : + // - get module info + // - check visibility of psy,if true then do the following : + // -> store the uid,name, state of psy in the PosPsyInfo structure + // -> append to the list of psys. + TInt cnt = idList->Count(); + for (TInt i = 0; i < cnt; ++i) + { + TPositionModuleInfo moduleInfo; + mPosModules->GetModuleInfoL((*idList)[i], moduleInfo); + + // check visibility + if (mPosModules->IsModuleVisibleL((*idList)[i])) + { + + PosPsyInfo psyInfo; + // Set the module Id. + psyInfo.mPsyModuelId = moduleInfo.ModuleId(); + + // Set module name + TBuf moduleName; + moduleInfo.GetModuleName(moduleName); + // converting Tbuf to qstring + QString* name = new QString((QChar*) moduleName.Ptr(), + moduleName.Length()); + mNameList.append( name ); + psyInfo.mPsyName = *name; + + // Set the state of the psy + if (moduleInfo.IsAvailable()) + { + psyInfo.mPsyState = PsyEnable; + } + else + { + psyInfo.mPsyState = PsyDisable; + } + + // append the psyinfo to the list + mPsyInfoList.AppendL(psyInfo); + } + } + + CleanupStack::PopAndDestroy(idList); + } + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::changePsyStateL( TUid psyModuleId, PosPsyState psyState ) +// +//--------------------------------------------------------------------- +void PosPsySettingsEnginePrivate::changePsyStateL(TUid psyModuleId, + PosPsyState psyState) + { + // create an instance of CPosModuleUpdate to help in updating the attributes + // of Psy + CPosModuleUpdate* updateParams = CPosModuleUpdate::NewLC(); + // Depending on the changed state update the availability of the psy + // i.e enable/disable + if (psyState == PsyEnable) + { + updateParams->SetUpdateAvailability(ETrue); + } + else + { + updateParams->SetUpdateAvailability(EFalse); + } + // update the state of the psy whose id is mentioned + mPosModules->UpdateModuleL(psyModuleId, *updateParams); + + CleanupStack::PopAndDestroy(updateParams); + + } + +//--------------------------------------------------------------------- +// PosPsySettingsEnginePrivate::changePsyStateL( TUid psyModuleId, PosPsyState psyState ) +// +//--------------------------------------------------------------------- +void PosPsySettingsEnginePrivate::HandleSettingsChangeL( + TPosModulesEvent aEvent) + { + // Check the event type,only for installation,removal, + // change in visibility, + // get the newly available list of psy + if (aEvent.iType == EPosModulesEventModuleInstalled || + aEvent.iType == EPosModulesEventModuleRemoved || + aEvent.iType == EPosModulesEventVisibilityChanged) + { + listPsysL(); + // call the engine's handlePositionTechnologyChange + mPosTechChangeObserver.handlePositionTechnologyChange(); + } + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/src/pospsysettingsplugin.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2010 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: Implementation of psy settings plugin class. + * + */ +#include "pospsysettingsplugin.h" +#include "pospsysettingsengine.h" + +#include + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::PosPsySettingsPlugin() +// Constructor +//--------------------------------------------------------------------- +PosPsySettingsPlugin::PosPsySettingsPlugin(): +mGroup(NULL), +mSignalMapper(NULL), +mOperation(NULL) + { + qDebug() << "================ PSY Plug-in loaded =============================="; + qDebug() << "+ PosPsySettingsPlugin::PosPsySettingsPlugin()"; + mEngine = new PosPsySettingsEngine(); + qDebug() << "- PosPsySettingsPlugin::PosPsySettingsPlugin()"; + } + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::~PosPsySettingsPlugin() +// Destructor +//--------------------------------------------------------------------- +PosPsySettingsPlugin::~PosPsySettingsPlugin() + { + qDebug() << "- PosPsySettingsPlugin::~PosPsySettingsPlugin()"; + //Note: no need to call mOperation->removeConnection() as it is already handled in advview's destructor + if (mEngine) + { + delete mEngine; + mEngine = NULL; + } + + // delete the group + if(mGroup) + { + mOperation->removeItem( mGroup ); + } + + // clear the list of available psys + mPsyList.clear(); + + QObject::disconnect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(onPsyPressed(int))); + // delete the QSignalMapper instance + if (mSignalMapper) + { + delete mSignalMapper; + mSignalMapper = NULL; + } + + // delete the signal mapper instances + int cnt = mPsySignalMapperList.count(); + for (int i = 0; i < cnt ; ++i) + { + QObject::disconnect(mPsySignalMapperList[i], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + delete mPsySignalMapperList[i]; + mPsySignalMapperList[i] = NULL; + } + // clear the list of signal mapper + mPsySignalMapperList.clear(); + + qDebug() << "- PosPsySettingsPlugin::~PosPsySettingsPlugin()"; + qDebug() << "================ PSY Plug-in unloaded =============================="; + } + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::initialise( PosSettingsAdvOp* operation ) +// +//--------------------------------------------------------------------- +int PosPsySettingsPlugin::initialise(PosSettingsAdvOp* operation) + { + qDebug() << "+ PosPsySettingsPlugin::initialise()"; + mOperation = operation; + mPsyList.clear(); + // get the list of psys + int error = mEngine->listPsys(mPsyList); + // if the list is not available return error + if (error == KErrNone) + { + // create group + mGroup = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, tr( + "Positioning methods"), 0); + // append the group to data form using operation + operation->appendDataFormItem(mGroup); + + // add group items + addItems(); + + // make connection to update the group inase of change in availbale list of psy + QObject::connect(mEngine, SIGNAL(PSYChange()), this, + SLOT(updateGroup())); + qDebug() << "- PosPsySettingsPlugin::initialise()"; + return KErrNone; + } + qDebug() << "- PosPsySettingsPlugin::initialise()"; + return error; + } + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::onPsyPressed( int state, int psyUid ) +// +//--------------------------------------------------------------------- +void PosPsySettingsPlugin::onPsyPressed(int index) + { + qDebug() << "+ PosPsySettingsPlugin::onPsyPressed()"; + // get the check box item using the index + HbDataFormModelItem *checkBox = mGroup->childAt(index); + // get the psy name for the check box + QVariant name(checkBox->contentWidgetData("text")); + QString psyName = name.toString(); + qDebug() << "Psy to be changed:" << psyName; + + // get the psyuid for the psy + TUid psyUid = mPsyList.at(index).mPsyModuelId; + + // get the state of the check box + QVariant state(checkBox->contentWidgetData(("checkState"))); + int psyState = state.toInt(); + + // change the psy state based on check box state + if (psyState == Qt::Checked) + { + qDebug() << "Psy value:true"; + int error = mEngine->changePsyState(psyUid, PsyEnable); + } + else + { + qDebug() << "Psy value:false"; + int error = mEngine->changePsyState(psyUid, PsyDisable); + } + qDebug() << "- PosPsySettingsPlugin::onPsyPressed()"; + } + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::updateGroup +// +//--------------------------------------------------------------------- +void PosPsySettingsPlugin::updateGroup() + { + qDebug() << "+ PosPsySettingsPlugin::updateGroup()"; + // remove all connections + int cnt= mGroup->childCount(); + for (int i = 0; i < cnt; ++i) + { + mOperation->removeConnection(mGroup->childAt(i), + SIGNAL(stateChanged(int)), mPsySignalMapperList[i], + SLOT(signalmap())); + } + cnt = mPsySignalMapperList.count(); + for (int i = 0; i < cnt; ++i) + { + QObject::disconnect(mPsySignalMapperList[i], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + delete mPsySignalMapperList[i]; + mPsySignalMapperList[i] = NULL; + } + mPsySignalMapperList.clear(); + + QObject::disconnect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(onPsyPressed(int))); + + // delete the QSignalMapper instance + if (mSignalMapper) + { + delete mSignalMapper; + mSignalMapper = NULL; + } + + // clear list of psys + mPsyList.clear(); + // get the list of psys + int error = mEngine->listPsys(mPsyList); + // if the list is not available return error + if (error == KErrNone ) + { + // remove all group's children + //mGroup->removeChildren(0, oldChildCount); + //ToDo: Hack from HbDataForm team + int cnt = mGroup->childCount(); + for(int i=0;iremoveChild(0); + } + // add the group items + addItems(); + if (mOperation->isExpanded(mOperation->indexFromItem(mGroup))) + { + // set as expanded since group was already expanded + mOperation->setExpanded(mOperation->indexFromItem(mGroup), true); + } + } + qDebug() << "- PosPsySettingsPlugin::updateGroup()"; + } + +//--------------------------------------------------------------------- +// PosPsySettingsPlugin::addItems +// +//--------------------------------------------------------------------- +void PosPsySettingsPlugin::addItems() + { + qDebug() << "+ PosPsySettingsPlugin::addItems()"; + // create the signal mapper + if(mSignalMapper) + { + delete mSignalMapper; + mSignalMapper = NULL; + } + mSignalMapper = new QSignalMapper(); + + // for each of the psys in the list + // - add a check box item with name + // - set the checkbox state according to the psy's current state + // - make connections + // foreach( PosPsyInfo psy, mPsyList ) + int cnt = mPsyList.count(); + qDebug() << "No of Psys: " << cnt; + for (int i = 0; i < cnt; ++i) + { + // create the check box item + HbDataFormModelItem* checkBox = new HbDataFormModelItem( + HbDataFormModelItem::CheckBoxItem, QString()); + QString psyName = mPsyList.at(i).mPsyName; + qDebug() << "Psy Name: " << psyName; + checkBox->setContentWidgetData("text", psyName); + + // set the state of checkbox + if (mPsyList.at(i).mPsyState == PsyEnable) + { + checkBox->setContentWidgetData("checkState", Qt::Checked); + } + else + { + checkBox->setContentWidgetData("checkState", Qt::Unchecked); + } + // append the check box item to the group + mGroup->appendChild(checkBox); + + // create a new psySignalMapper for each checkbox created + PosSettingsSignalMapper* psySignalMapper = + new PosSettingsSignalMapper(); + mPsySignalMapperList.append(psySignalMapper); + + // add connections on change of check box state + mOperation->addConnection(checkBox, SIGNAL(stateChanged(int)), + mPsySignalMapperList[i], SLOT(signalmap())); + QObject::connect(mPsySignalMapperList[i], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + // set mapping of each check box item to its index + mSignalMapper->setMapping(mPsySignalMapperList[i], i); + + } + QObject::connect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(onPsyPressed(int))); + qDebug() << "- PosPsySettingsPlugin::addItems()"; + } + +Q_EXPORT_PLUGIN2(pospsysettings, PosPsySettingsPlugin) +; diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/posmethodsplugin/src/possettingssignalmapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/posmethodsplugin/src/possettingssignalmapper.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 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: Implementation of psy settings signal mapper class + * + */ + + +#include "possettingssignalmapper.h" + + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// Constructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// destructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::~PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// +//--------------------------------------------------------------------- +void PosSettingsSignalMapper::signalmap() + { + emit signalmapped(); + } + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettings.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettings.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,37 @@ +# +# Copyright (c) 2010 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: project file for positioing settings in control panel +# + + +TEMPLATE = subdirs + +SYMBIAN_PLATFORMS = WINSCW ARMV5 + +SUBDIRS += possettingsengine/possettingsengine.pro +SUBDIRS += possettingsplugin/possettingsplugin.pro +SUBDIRS += posmethodsplugin/pospsysettings.pro +SUBDIRS += possuplsettingsplugin/possuplsettings.pro +SUBDIRS += poslocationservices/poslocationservices.pro + +DEFINES += BUILD_POSSETTINGS + +# Build.inf rules +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \ + "possettings_stub.sis /epoc32/data/z/system/install/possettings_stub.sis" \ + "rom/possettings.iby CORE_MW_LAYER_IBY_EXPORT_PATH(possettings.iby)" \ + "rom/possettings_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(possettings_resources.iby)" \ + "conf/positioningsettings.confml MW_LAYER_CONFML(positioningsettings.confml)" \ + "conf/positioningsettings_2002E685.crml MW_LAYER_CRML(positioningsettings_2002E685.crml)" + + \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettings_stub.sis Binary file locationsystemui/locationsysui/possettings/possettings_stub.sis has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/bwins/possettingsengineu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/bwins/possettingsengineu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,26 @@ +EXPORTS ?trUtf8@PosSettingsAdvOp@@SA?AVQString@@PBD0@Z @ 1 NONAME ; class QString PosSettingsAdvOp::trUtf8(char const *, char const *) + ?staticMetaObject@PosSettingsAdvOp@@2UQMetaObject@@B @ 2 NONAME ; struct QMetaObject const PosSettingsAdvOp::staticMetaObject + ?setExpanded@PosSettingsAdvOp@@QAEXABVQModelIndex@@_N@Z @ 3 NONAME ; void PosSettingsAdvOp::setExpanded(class QModelIndex const &, bool) + ?addAction@PosSettingsAdvOp@@QAEXPAVHbAction@@W4ActionContainer@HbView@@@Z @ 4 NONAME ; void PosSettingsAdvOp::addAction(class HbAction *, enum HbView::ActionContainer) + ?qt_metacast@PosSettingsAdvOp@@UAEPAXPBD@Z @ 5 NONAME ; void * PosSettingsAdvOp::qt_metacast(char const *) + ??_EPosSettingsView@@UAE@I@Z @ 6 NONAME ; PosSettingsView::~PosSettingsView(unsigned int) + ?isExpanded@PosSettingsAdvOp@@QBE_NABVQModelIndex@@@Z @ 7 NONAME ; bool PosSettingsAdvOp::isExpanded(class QModelIndex const &) const + ?addConnection@PosSettingsAdvOp@@QAEXPAVHbDataFormModelItem@@PBDPAVQObject@@1@Z @ 8 NONAME ; void PosSettingsAdvOp::addConnection(class HbDataFormModelItem *, char const *, class QObject *, char const *) + ?tr@PosSettingsAdvOp@@SA?AVQString@@PBD0H@Z @ 9 NONAME ; class QString PosSettingsAdvOp::tr(char const *, char const *, int) + ?appendDataFormItem@PosSettingsAdvOp@@QAEXPAVHbDataFormModelItem@@0@Z @ 10 NONAME ; void PosSettingsAdvOp::appendDataFormItem(class HbDataFormModelItem *, class HbDataFormModelItem *) + ??1PosSettingsAdvOp@@UAE@XZ @ 11 NONAME ; PosSettingsAdvOp::~PosSettingsAdvOp(void) + ?qt_metacall@PosSettingsAdvOp@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 12 NONAME ; int PosSettingsAdvOp::qt_metacall(enum QMetaObject::Call, int, void * *) + ??0PosSettingsAdvOp@@QAE@PAVHbView@@@Z @ 13 NONAME ; PosSettingsAdvOp::PosSettingsAdvOp(class HbView *) + ??_EPosSettingsAdvOp@@UAE@I@Z @ 14 NONAME ; PosSettingsAdvOp::~PosSettingsAdvOp(unsigned int) + ??1PosSettingsView@@UAE@XZ @ 15 NONAME ; PosSettingsView::~PosSettingsView(void) + ?itemPrototypes@PosSettingsAdvOp@@QAEXAAV?$QList@PAVHbAbstractViewItem@@@@@Z @ 16 NONAME ; void PosSettingsAdvOp::itemPrototypes(class QList &) + ?removeConnection@PosSettingsAdvOp@@QAEXPAVHbDataFormModelItem@@PBDPAVQObject@@1@Z @ 17 NONAME ; void PosSettingsAdvOp::removeConnection(class HbDataFormModelItem *, char const *, class QObject *, char const *) + ?indexFromItem@PosSettingsAdvOp@@QAE?AVQModelIndex@@PBVHbDataFormModelItem@@@Z @ 18 NONAME ; class QModelIndex PosSettingsAdvOp::indexFromItem(class HbDataFormModelItem const *) + ?setItemPrototypes@PosSettingsAdvOp@@QAEXAAV?$QList@PAVHbAbstractViewItem@@@@@Z @ 19 NONAME ; void PosSettingsAdvOp::setItemPrototypes(class QList &) + ??0PosSettingsView@@QAE@PAVQGraphicsItem@@@Z @ 20 NONAME ; PosSettingsView::PosSettingsView(class QGraphicsItem *) + ?removeItem@PosSettingsAdvOp@@QAE_NPAVHbDataFormModelItem@@@Z @ 21 NONAME ; bool PosSettingsAdvOp::removeItem(class HbDataFormModelItem *) + ?trUtf8@PosSettingsAdvOp@@SA?AVQString@@PBD0H@Z @ 22 NONAME ; class QString PosSettingsAdvOp::trUtf8(char const *, char const *, int) + ?tr@PosSettingsAdvOp@@SA?AVQString@@PBD0@Z @ 23 NONAME ; class QString PosSettingsAdvOp::tr(char const *, char const *) + ?getStaticMetaObject@PosSettingsAdvOp@@SAABUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const & PosSettingsAdvOp::getStaticMetaObject(void) + ?metaObject@PosSettingsAdvOp@@UBEPBUQMetaObject@@XZ @ 25 NONAME ; struct QMetaObject const * PosSettingsAdvOp::metaObject(void) const + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/eabi/possettingsengineu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/eabi/possettingsengineu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,35 @@ +EXPORTS + _ZN15PosSettingsViewC1EP13QGraphicsItem @ 1 NONAME + _ZN15PosSettingsViewC2EP13QGraphicsItem @ 2 NONAME + _ZN15PosSettingsViewD0Ev @ 3 NONAME + _ZN15PosSettingsViewD1Ev @ 4 NONAME + _ZN15PosSettingsViewD2Ev @ 5 NONAME + _ZN16PosSettingsAdvOp10removeItemEP19HbDataFormModelItem @ 6 NONAME + _ZN16PosSettingsAdvOp11qt_metacallEN11QMetaObject4CallEiPPv @ 7 NONAME + _ZN16PosSettingsAdvOp11qt_metacastEPKc @ 8 NONAME + _ZN16PosSettingsAdvOp11setExpandedERK11QModelIndexb @ 9 NONAME + _ZN16PosSettingsAdvOp13addConnectionEP19HbDataFormModelItemPKcP7QObjectS3_ @ 10 NONAME + _ZN16PosSettingsAdvOp13indexFromItemEPK19HbDataFormModelItem @ 11 NONAME + _ZN16PosSettingsAdvOp14itemPrototypesER5QListIP18HbAbstractViewItemE @ 12 NONAME + _ZN16PosSettingsAdvOp16removeConnectionEP19HbDataFormModelItemPKcP7QObjectS3_ @ 13 NONAME + _ZN16PosSettingsAdvOp16staticMetaObjectE @ 14 NONAME DATA 16 + _ZN16PosSettingsAdvOp17setItemPrototypesER5QListIP18HbAbstractViewItemE @ 15 NONAME + _ZN16PosSettingsAdvOp18appendDataFormItemEP19HbDataFormModelItemS1_ @ 16 NONAME + _ZN16PosSettingsAdvOp19getStaticMetaObjectEv @ 17 NONAME + _ZN16PosSettingsAdvOp9addActionEP8HbActionN6HbView15ActionContainerE @ 18 NONAME + _ZN16PosSettingsAdvOpC1EP6HbView @ 19 NONAME + _ZN16PosSettingsAdvOpC2EP6HbView @ 20 NONAME + _ZN16PosSettingsAdvOpD0Ev @ 21 NONAME + _ZN16PosSettingsAdvOpD1Ev @ 22 NONAME + _ZN16PosSettingsAdvOpD2Ev @ 23 NONAME + _ZNK16PosSettingsAdvOp10isExpandedERK11QModelIndex @ 24 NONAME + _ZNK16PosSettingsAdvOp10metaObjectEv @ 25 NONAME + _ZTI15PosSettingsView @ 26 NONAME + _ZTI16PosSettingsAdvOp @ 27 NONAME + _ZTV15PosSettingsView @ 28 NONAME + _ZTV16PosSettingsAdvOp @ 29 NONAME + _ZThn16_N15PosSettingsViewD0Ev @ 30 NONAME + _ZThn16_N15PosSettingsViewD1Ev @ 31 NONAME + _ZThn8_N15PosSettingsViewD0Ev @ 32 NONAME + _ZThn8_N15PosSettingsViewD1Ev @ 33 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/checkcustomviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/checkcustomviewitem.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010 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 CHECK_CUSTOMVIEWITEM_H +#define CHECK_CUSTOMVIEWITEM_H + +#include +#include + +class HbWidget; + +class CheckCustomViewItem: public HbDataFormViewItem +{ + Q_OBJECT + +public: + explicit CheckCustomViewItem(QGraphicsItem *parent = 0); + ~CheckCustomViewItem(); + virtual HbAbstractViewItem* createItem(); + virtual bool canSetModelIndex(const QModelIndex &index) const; +}; +#endif // CHECK_CUSTOMVIEWITEM_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsadvview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsadvview.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2010 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:Declaration of the Positioning Settings Advanced View class + * + */ + +#ifndef POSSETTINGSENG_ADVANCEDVIEW_H +#define POSSETTINGSENG_ADVANCEDVIEW_H + +#include "possettingsadvop.h" + +#include +#include + +//class PosSettingsAdvancedDataForm; +class HbDataForm; +class HbDataFormModel; +class HbDataFormModelItem; +class PosSettingsAdvOp; +class PosSettingsAdvInterface; +class PosSettingsPluginsLoader; +class QFileSystemWatcher; + +class PosSettingsAdvView : public CpBaseSettingView + { +Q_OBJECT + +public: + /* + * Constructor + */ + PosSettingsAdvView(QGraphicsItem *parent = 0); + /* + * Destructor + */ + ~PosSettingsAdvView(); + +private slots: + /** + * Updates the advanced view in case of change in any of the plugins, + * this slot needs to be called + */ + void updateAdvView(); + +private: + + /** + * Handle to Heading groupbox + * Not Own + */ + HbDataFormModelItem *mHeading; + + + /* + * Pointer to the HbDataForm + * Owns + */ + HbDataForm* mAdvancedDataForm; + /* + * Pointer to the PosSettingsAdvOp + * owns + */ + PosSettingsAdvOp* mAdvancedOperation; + /** + * List containing the plugins + */ + QList mPluginsList; + /** + * Pointer to the PosSettingsPluginsLoader + */ + PosSettingsPluginsLoader* mPluginsLoader; + /** + * Pointer to the QFileSystemWatcher + * Owns + */ + QFileSystemWatcher* mWatcher; + + }; + +#endif //POSSETTINGSENG_ADVANCEDVIEW_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingscommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingscommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2010 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 header exposes common data structues and enums. +* +*/ + +#ifndef POSSETTINGSCOMMON_H +#define POSSETTINGSCOMMON_H + +#include + +/** + * This enum defines type of position technology. + */ +enum PositionTechnology + { + /** + * Bit mask used to specify GPS technology. + */ + PositionTechnologyGps = 0x01, + + /** + * Bit mask used to specify network technology. + */ + PositionTechnologyNetwork = 0x02, + + }; + +/** + * This enum defines different state. + */ +enum State + { + StateEnable, + + StateDisable + }; + +/** + * PSY module information + */ +struct PsyModuleInfo + { + /** + * Module id of Psy + */ + TUid mPsyModuleId; + + /** + * Position technology. + */ + PositionTechnology mPosTech; + + /** + * State of Psy + */ + State mState; + }; + + +#endif /* PosSettingsCOMMON_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings engine class. +* +*/ + +#ifndef POSITIONINGSETTINGS_ENGINE_H +#define POSITIONINGSETTINGS_ENGINE_H + + +#include "possettingscommon.h" +#include "possettingsengineprivate.h" +#include +#include + +/** + * PositioningSettingsEngine class provides an interface that abstracts client + * from different GPS and wireless positioning techniques. This exposes methods + * to perform operations on the positioning techniques. + */ + +class PosSettingsEngine : public QObject, + public PositionTechnologyChangeObserver + { + Q_OBJECT +public: + /** + * Default constructor + * This throws an error if construction fails. + */ + PosSettingsEngine(); + + /** + * Destructor + */ + ~PosSettingsEngine(); + + /** + * Returns whether specified position technology is available. + * @param[in] posTechnology Position technology of interest. + * @return true if specified position technology is available, + * false if it is not available. + */ + bool isPositionTechnologyAvailable( PositionTechnology posTechnology ); + + /** + * Sets the state of position technology. + * @param[in] posTechnologyState Resultant state of the position technology + * after this operation. + * @param[in] posTechnology State of position technology to be changed. + * @return KErrNone if successful, + * KErrNotFound if specified position technology is not available + * Otherwise, standard error code is returned, + * KErrServerBusy, etc.. + */ + int setPositionTechnologyState( State posTechnologyState, + PositionTechnology posTechnology ); + + /** + * Returns whether specified position technology is enabled. It is recemonded + * to use this method after checking the availability of the position technology + * using isPositionTechnologyAvailable method. + * @param[in] posTechnology Position technology of interest. + * @return true if specified position technology is enabled, + * false if it is disabled. + */ + bool isPositionTechnologyEnabled( PositionTechnology posTechnology ); + + /** + * Sets the state of back ground positioning. + * @param[in] backGroundPosState Resultant state of back ground positioning. + * @return KErrNone if successful, + * KErrNotSupported if none of the position type are available, + * KErrArgument if none of the position type are enabled + * otherwise, standard error code is returned, + * KErrServerBusy, etc.. + */ + int setBackGroundPositioningState( State backGroundPosState ); + + /** + * Returns whether back ground positioning is enabled. It is recemonded + * to use this method after checking the availability of the position type + * using isPositionTypeAvailable method. + * @return true if back ground positioning is enabled, + * false if it is disabled. + */ + bool isBackGroundPositioningEnabled(); + + /** + * It will set status of background positioning in CR key + * It is required to retain old status when checkbox is inserted/removed + * + * status [in] - The status of the background positioning in CR key + */ + void setCRBackgroundPositioningStatus(State backGroundPosState); + + /** + * It will return status of background positioning in CR key + * It is required to retain old status when checkbox is inserted/removed. + * + * returns true if enabled or false if disabled + */ + bool cRBackgroundPositioningStatus(); + +public: // from PositionTechnologyChangeObserver + void handlePositionTechnologyChange(); + +private: + signals: + /** + * This signal is emitted when there is change in any of position + * technology wrt to its availabilty, state etc.. + */ + void positionTechnologyChange(); + +private: + Q_DECLARE_PRIVATE_D(d_ptr, PosSettingsEngine) +private: // data member + /** + * Pointer to private implementation. + * Own + */ + PosSettingsEnginePrivate* d_ptr; + }; + +#endif /* POSITIONINGSETTINGS_ENGINE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsengineprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsengineprivate.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2010 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: Positioning settings engine private class. +* +*/ + +#ifndef POSITIONINGSETTINGSENGINE_PRIVATE_H +#define POSITIONINGSETTINGSENGINE_PRIVATE_H + +#include "possettingscommon.h" + +#include +#include +#include + +// Forward declarations + +class PosSettingsEngine; +class CPosModules; +class CSuplSettings; +struct TPosModulesEvent; + +/** + * The class defines the interface for receiving position + * technology change event.The class interested in position + * technology change should inherit from this class. + */ +class PositionTechnologyChangeObserver + { +public: + virtual void handlePositionTechnologyChange() = 0; + }; + +/** + * PositioningSettingsEnginePrivate is a class that provides implementation + * for PositionSettingsEngine class. + */ +class PosSettingsEnginePrivate : public MPosModulesObserver + { +public: + /** + * Default constructor + */ + PosSettingsEnginePrivate( PositionTechnologyChangeObserver& + posTechChangeObserver ); + + /** + * Destructor + */ + ~PosSettingsEnginePrivate(); + + /** + * Returns whether specified position technology is available. + * @param[in] posTechnology Position technology of interest. + * @return true if specified position technology is available, + * false if it is not available. + */ + bool isPositionTechnologyAvailable( PositionTechnology posTechnology ); + + /** + * Sets the state of position technology. + * @param[in] posTechnologyState Resultant state of the position technology + * after this operation. + * @param[in] posTechnology State of position technology to be changed. + * @return KErrNone if successful, + * KErrNotFound if specified position technology is not available + * Otherwise, standard error code is returned, + * KErrServerBusy, etc.. + */ + int setPositionTechnologyState( State posTechnologyState, + PositionTechnology posTechnology ); + + /** + * Returns whether specified position technology is enabled. It is recemonded + * to use this method after checking the availability of the position technology + * using isPositionTechnologyAvailable method. + * @param[in] posTechnology Position technology of interest. + * @return true if specified position technology is enabled, + * false if it is disabled. + */ + bool isPositionTechnologyEnabled( PositionTechnology posTechnology ); + + + /** + * Sets the state of back ground positioning. + * @param[in] backGroundPosState Resultant state of back ground positioning. + * @return KErrNone if successful, + * KErrNotSupported if none of the position type are available, + * KErrArgument if none of the position type are enabled + * otherwise, standard error code is returned, + * KErrServerBusy, etc.. + */ + int setBackGroundPositioningState( State backGroundPosState ); + + /** + * Returns whether back ground positioning is enabled. It is recemonded + * to use this method after checking the availability of the position type + * using isPositionTypeAvailable method. + * @return true if back ground positioning is enabled, + * false if it is disabled. + */ + bool isBackGroundPositioningEnabled(); + +public: // from MPosModulesObserver + virtual void HandleSettingsChangeL( TPosModulesEvent aEvent ); + +private: + /** + * Sets the state of given positioning technology. + * @param[in] posTechnologyState Resultant State of Positioning Technology + * StateEnable/StateDisable. + * @param[in] posTechnology Positioning Technology Name + * PositionTechnologyGps/PositionTechnologyNetwork. + */ + void setPositionTechnologyStateL( State posTechnologyState, + PositionTechnology posTechnology ); + /** + * Sets the state of back ground positioning. + * @param[in] backGroundPosState Resultant state of back ground positioning. + */ + void setBackGroundPositioningStateL( State backGroundPosState ); + + /** + * Populates the PSY module information list. + */ + void populatePsyModuleInfoListL(); + + /** + * Gets the state of back ground positioning. + */ + void GetBackGroundPositioingStateL(); + +private: //Data members + + /** + * Reference to position technology change observer. + */ + PositionTechnologyChangeObserver& mPosTechChangeObserver; + + /** + * Pointer to Supl settings object + * Own + */ + CSuplSettings* mSuplSettings; + + /** + * Pointer to lbt server + * Own + */ + RLbtServer mLbtServer; + + /** + * Pointer to lbt manager + * Own + */ + RLbtManager mLbtManager; + + /** + * Pointer to Pos module; + * Own + */ + CPosModules* mPosModules; + + /** + * List of PSY module info + * Own + */ + RArray mPsyModuleInfoList; + + /** + * State of back ground positioning + */ + State mBackGroundPositioningState; + + friend class PosSettingsEngine; + }; + + +#endif /* POSITIONINGSETTINGSENGINE_PRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsform.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2010 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: Positioning settings view class. +* +*/ + +#ifndef POSSETTINGSFORM_H +#define POSSETTINGSFORM_H + +#include + +class HbDataFormModelItem; +class PosSettingsEngine; +class PosSettingsAdvView; +class HbAction; + +class PosSettingsForm : public HbDataForm + { + Q_OBJECT +private: + /* + * Enumarator for the positioning category type + */ + enum PosTypeIndex + { + /* + * The position of GPS in HbDataForm + */ + PosTypeIndexGps = 1, + + /* + * The position of Wireless in HbDataForm + */ + PosTypeIndexWireless = 2 , + + /* + * The position of Background in HbDataForm + */ + PosTypeIndexBackground = 3 + }; +public: + /** + * Constructor. + */ + explicit PosSettingsForm( PosSettingsEngine& settingsEngine, + QGraphicsItem *parent = 0 ); + + /** + * Destructor + */ + ~PosSettingsForm(); + +private: + /** + * It will initiate the basic setting view + */ + void initSettingModel(); + + /** + * It will validate visibility of Positioning type + * + * posTypeModelItemIndex[in] - The position at which control should be placed + */ + void validatePosTypeVisibility(PosTypeIndex posTypeModelItemIndex); + + /** + * It will insert/remove Positioning type control in HbDataForm + * + * insert[in] - if true insert control else remove it + * posTypeModelItem[in] - HbDataFormModelItem handle for position type + * posTypeModelItemIndex[in] - The position at which control should be placed + * posIndex[in] - The absolute poisition index at which control should be placed. + * It will different from posTypeModelItemIndex for Wireless and Background + * depending on GPS, Wireless are visible. + */ + void insertOrRemovePosTypeModelItem(bool insert, HbDataFormModelItem* posTypeModelItem, + PosTypeIndex posTypeModelItemIndex, int posIndex); + /* + * It will create HbDataFormModelItem based on the position specified + * + * posTypeModelItemIndex [in] - The position at which control should be placed + */ + void createPosTypeModelItem(PosTypeIndex posTypeModelItemIndex); + + /** + * It will mark/unmark positioning category checkbox + * + * posTypeModelItemIndex [in] - The position at which control should be placed + */ + void setPosTypeState(PosTypeIndex posTypeModelItemIndex); + + /** + * It will add connection for the given model item + * + * posTypeModelItem [in] - HbDataFormModelItem handle for position type + */ + void addPosTypeConnection(HbDataFormModelItem* posTypeModelItem); + +private slots: + /** + * It will be called when 'Advanced' push button is pressed + */ + void onPressedAdvanced(); + + /** + * It will be called when 'GPS' checkbox is clicked + */ + void onPressedGps(); + + /** + * It will be called when 'Wirelss' checkbox is clicked + */ + void onPressedWireless(); + + /* + * It will be called when 'Background' checkbox is clicked + */ + void onPressedBackground(); + /* + * It will be called when the Back Button is pressed to dismiss the + * advanced view + */ + void closeAdvancedView(); + + /** + * It will validate visibility of all positioning type controls + * It will also be called when new positioning technology is + * added at runtime + */ + void validateVisibility(); + +private: // Data memebers + /** + * Handle to engine + * Not Own + */ + PosSettingsEngine& mSettingsEngine; + + /** + * Handle to 'GPS' checkbox + * Not Own + */ + HbDataFormModelItem *mGpsPosType; + + /** + * Handle to 'Wireless' checkbox + * Not Own + */ + HbDataFormModelItem *mWirelessPosType; + + /** + * Handle to 'Background' checkbox + * Not Own + */ + HbDataFormModelItem *mBgPosType; + + /** + * Handle to 'Advanced' push button + * Not Own + */ + HbDataFormModelItem *mAdvancedSettings; + + /** + * Handle to Heading groupbox + * Not Own + */ + HbDataFormModelItem *mHeading; + + /** + * Pointer to Advanced view class + * Owns this pointer. + */ + PosSettingsAdvView* mAdvancedView; + + /** + * handle to the Back Action + */ + HbAction* mBackAction; + + }; +#endif // POSSETTINGSFORM_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsgroupboxitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingsgroupboxitem.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 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 class provides custom list item +* for the groupbox on the DataForm +*/ + +#ifndef POSSETTINGS_GROUPBOXITEM_H +#define POSSETTINGS_GROUPBOXITEM_H + +#include + +#include +#include + +const int GroupboxItem = HbDataFormModelItem::CustomItemBase+12; + +class PosSettingsGroupboxItem : public HbDataFormViewItem +{ +Q_OBJECT + +public: //constructor and destructor + PosSettingsGroupboxItem(QGraphicsItem *parent); + ~PosSettingsGroupboxItem(); +public: //from HbDataFormViewItem + /* + * It will return custom control item + */ + virtual HbAbstractViewItem* createItem(); + virtual bool canSetModelIndex(const QModelIndex &index) const; + virtual void restore(); +protected: + /* + * It will define the custom control item + */ + virtual HbWidget* createCustomWidget(); + +private: + /* + * Does not own + */ + HbWidget* mWidget; +}; + +#endif // POSSETTINGS_GROUPBOXITEM_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingspluginsloader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingspluginsloader.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2010 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:Declaration of the Positioning Settings PLugins loader + * + */ + +#ifndef PosSettingsPluginsLoader_H +#define PosSettingsPluginsLoader_H + +#include "possettingsadvinterface.h" + +#include +#include + +class PosSettingsPluginsLoader + { + +public: + /** + * Constructor + */ + PosSettingsPluginsLoader(); + /** + * Destructor + */ + ~PosSettingsPluginsLoader(); + /* + * Detects & loads the plugins that implement the + * PosSettingsAdvInterface class + */ + QList loadPlugins(); +private: + /** + * Reads the cenrep key value to obtain the default order in which + * the positioning settings plugins need to be loaded. + */ + void ParseCenRepKey(); + +private: + /** + * Contains list of plugin's dll name in the order in which it + * is supposed to be displayed in the advanced view + */ + QList mDllNameList; + + + }; + +#endif //PosSettingsPluginsLoader_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingspushbuttonitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/inc/possettingspushbuttonitem.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 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 class provides custom list item +* for the push button on the DataForm +*/ + +#ifndef POSSETTINGS_PUSHBUTTONITEM_H +#define POSSETTINGS_PUSHBUTTONITEM_H + +#include + +#include +#include + +const int PushButtonItem = HbDataFormModelItem::CustomItemBase+11; + +class PosSettingsPushButtonItem : public HbDataFormViewItem +{ +Q_OBJECT + +public: //constructor and destructor + PosSettingsPushButtonItem(QGraphicsItem *parent); + ~PosSettingsPushButtonItem(); +public: //from HbDataFormViewItem + /* + * It will return custom control item + */ + virtual HbAbstractViewItem* createItem(); + virtual bool canSetModelIndex(const QModelIndex &index) const; + virtual void restore(); +protected: + /* + * It will define the custom control item + */ + virtual HbWidget* createCustomWidget(); + +private: + /* + * Does not own + */ + HbWidget* mWidget; +}; + +#endif // POSSETTINGS_PUSHBUTTONITEM_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/possettings.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/possettings.qrc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ + + + resources/pushbuttoncustomviewitem.css + resources/groupboxcustomviewitem.css + resources/checkcustomviewitem.css + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/possettingsengine.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/possettingsengine.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,74 @@ +# +# Copyright (c) 2010 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: PosSettingsEngine pro file +# + +TEMPLATE = lib +TARGET = possettingsengine +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb + + + +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc +RESOURCES = possettings.qrc + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +LIBS += -lcpframework \ + -llbt \ + -llbs \ + -llbtmanager \ + -leposmodset \ + -lepos_suplsettings \ + -lxqsettingsmanager + +# Input +SOURCES += src/possettingspluginsloader.cpp \ + src/possettingspushbuttonitem.cpp \ + src/possettingsgroupboxitem.cpp \ + src/possettingsform.cpp \ + src/possettingsview.cpp \ + src/possettingsengineprivate.cpp \ + src/possettingsengine.cpp \ + src/possettingsadvview.cpp \ + src/possettingsadvop.cpp \ + src/checkcustomviewitem.cpp +HEADERS += inc/possettingspluginsloader.h \ + inc/possettingspushbuttonitem.h \ + inc/possettingsgroupboxitem.h \ + inc/possettingsform.h \ + inc/possettingsengineprivate.h \ + inc/possettingsengine.h \ + inc/possettingscommon.h \ + inc/possettingsadvview.h \ + ../inc/possettingsadvop.h \ + inc/checkcustomviewitem.h +symbian: { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += BUILD_POSSETTINGS + DEFINES += PLUGINUID3=0x2002C319 + TARGET.UID3 = 0x2002C319 +} + +# Build.inf rules +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " + +TARGET.CAPABILITY = All -TCB + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/resources/checkcustomviewitem.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/resources/checkcustomviewitem.css Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +CheckCustomViewItem::dataItem_ContentWidget +{ + left: 0.0un; + right: var(hb-param-margin-gene-right); +} \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/resources/groupboxcustomviewitem.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/resources/groupboxcustomviewitem.css Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,6 @@ +PosSettingsGroupboxItem::dataItem_ContentWidget +{ + left: 0.0un; + right: var(hb-param-margin-gene-right); + top: 0.0un; +} \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/resources/pushbuttoncustomviewitem.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/resources/pushbuttoncustomviewitem.css Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +PosSettingsPushButtonItem::dataItem_ContentWidget +{ + left: -var(hb-param-margin-gene-left); + right: var(hb-param-margin-gene-right); +} \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/checkcustomviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/checkcustomviewitem.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010 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: + * + */ + +#include "checkcustomviewitem.h" +#include +#include +#include +#include + + +CheckCustomViewItem::CheckCustomViewItem(QGraphicsItem *parent ) + : HbDataFormViewItem(parent) + +{ +} +CheckCustomViewItem::~CheckCustomViewItem() +{ +} +HbAbstractViewItem* CheckCustomViewItem::createItem() +{ + return new CheckCustomViewItem(*this); +} +bool CheckCustomViewItem::canSetModelIndex(const QModelIndex &index) const +{ + int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt(); + if ( type == HbDataFormModelItem::CheckBoxItem ) { + return true; + } + else { + return false; + } +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsadvop.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsadvop.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2010 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: Implementation of Positioning settings advanced + * operation class. + * + */ + +#include "possettingsadvop.h" +#include "possettingsadvview.h" +#include +#include + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::PosSettingsAdvOp() +// Constructor +//--------------------------------------------------------------------- +PosSettingsAdvOp::PosSettingsAdvOp(HbView* view) : mView(view) + { + qDebug() << "+ PosSettingsAdvOp::PosSettingsAdvOp()"; + mDataForm = qobject_cast(mView->widget()); + mDataFormModel = static_cast(mDataForm->model()); + qDebug() << "- PosSettingsAdvOp::PosSettingsAdvOp()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::~PosSettingsAdvOp() +// Destructor +//--------------------------------------------------------------------- +PosSettingsAdvOp::~PosSettingsAdvOp() + { + qDebug() << "+ PosSettingsAdvOp::~PosSettingsAdvOp()"; + qDebug() << "- PosSettingsAdvOp::~PosSettingsAdvOp()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::appendDataFormItem +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::appendDataFormItem(HbDataFormModelItem *data, + HbDataFormModelItem *parent) + { + qDebug() << "+ PosSettingsAdvOp::appendDataFormItem()"; + mDataFormModel->appendDataFormItem(data, parent); + qDebug() << "- PosSettingsAdvOp::appendDataFormItem()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::addConnection +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::addConnection(HbDataFormModelItem *item, + const char* signal, QObject *receiver, const char* slot) + { + qDebug() << "+ PosSettingsAdvOp::addConnection()"; + mDataForm->addConnection(item, signal, receiver, slot); + qDebug() << "- PosSettingsAdvOp::addConnection()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::addAction +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::addAction(HbAction *action, + HbView::ActionContainer preferedActionContainer) + { + qDebug() << "+ PosSettingsAdvOp::addAction()"; + mView->addAction(action, preferedActionContainer); + qDebug() << "- PosSettingsAdvOp::addAction()"; + } + + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::indexFromItem +// +//--------------------------------------------------------------------- +QModelIndex PosSettingsAdvOp::indexFromItem(const HbDataFormModelItem * item) + { + qDebug() << "+ PosSettingsAdvOp::indexFromItem()"; + qDebug() << "- PosSettingsAdvOp::indexFromItem()"; + return mDataFormModel->indexFromItem(item); + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::removeConnection +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::removeConnection(HbDataFormModelItem *item, + const char* signal, QObject *receiver, const char* slot) + { + qDebug() << "+ PosSettingsAdvOp::removeConnection()"; + mDataForm->removeConnection(item, signal, receiver, slot); + qDebug() << "- PosSettingsAdvOp::removeConnection()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::setExpanded +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::setExpanded(const QModelIndex &index, bool expanded) + { + qDebug() << "+ PosSettingsAdvOp::setExpanded()"; + mDataForm->setExpanded( index,expanded); + qDebug() << "- PosSettingsAdvOp::setExpanded()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::isExpanded +// +//--------------------------------------------------------------------- +bool PosSettingsAdvOp::isExpanded(const QModelIndex &index)const + { + qDebug() << "+ PosSettingsAdvOp::isExpanded()"; + qDebug() << "- PosSettingsAdvOp::isExpanded()"; + return mDataForm->isExpanded(index); + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::removeItem +// +//--------------------------------------------------------------------- +bool PosSettingsAdvOp::removeItem(HbDataFormModelItem* item) + { + qDebug() << "+ PosSettingsAdvOp::removeItem()"; + qDebug() << "- PosSettingsAdvOp::removeItem()"; + return mDataFormModel->removeItem(item); + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::removeItem +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::setItemPrototypes( + QList &protoTypeList) + { + qDebug() << "+ PosSettingsAdvOp::setItemPrototypes()"; + QList oldProtoTypeList = mDataForm->itemPrototypes(); + oldProtoTypeList.append(protoTypeList); + mDataForm->setItemPrototypes(oldProtoTypeList); + qDebug() << "- PosSettingsAdvOp::setItemPrototypes()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvOp::itemPrototypes +// +//--------------------------------------------------------------------- +void PosSettingsAdvOp::itemPrototypes( + QList &protoTypeList) + { + qDebug() << "+ PosSettingsAdvOp::itemPrototypes()"; + protoTypeList = mDataForm->itemPrototypes(); + qDebug() << "- PosSettingsAdvOp::itemPrototypes()"; + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsadvview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsadvview.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2010 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:Implementation of the Positioning Settings Advanced View class + * + */ + +#include "possettingsadvview.h" +#include "possettingspluginsloader.h" +#include "possettingsgroupboxitem.h" +#include +#include + +#ifdef Q_OS_SYMBIAN +#define PLUGIN_PATH QString("\\resource\\qt\\plugins\\positioningsettings") + +#else +#define PLUGIN_PATH QString("C:\\qt\\plugins\\positioningsettings") +#endif + +//--------------------------------------------------------------------- +// PosSettingsAdvView::PosSettingsAdvView() +// Constructor +//--------------------------------------------------------------------- +PosSettingsAdvView::PosSettingsAdvView( QGraphicsItem *parent ): +CpBaseSettingView(0,parent) + { + qDebug() << "+ PosSettingsAdvView::PosSettingsAdvView()"; + // create instance of HbDataForm + mAdvancedDataForm = new HbDataForm(); + + // Create an instance of HbDataFormModel + HbDataFormModel* advancedDataFormModel = new HbDataFormModel(); + + // set the model + mAdvancedDataForm->setModel( advancedDataFormModel ); + + // set the Advanced settings form for this view + this->setWidget( mAdvancedDataForm ); + + //set prototype for custom controls + QList protoTypeList = mAdvancedDataForm->itemPrototypes(); + protoTypeList.append(new PosSettingsGroupboxItem(this)); + mAdvancedDataForm->setItemPrototypes(protoTypeList); + + //Heading + mHeading = advancedDataFormModel->appendDataFormItem(static_cast(GroupboxItem), + QString(), + advancedDataFormModel->invisibleRootItem()); + mHeading->setContentWidgetData("heading", + hbTrId("txt_loe_subtitle_advanced_positioning_settings")); + + + + // Create an instance of PosSettingsAdvancedOperation + mAdvancedOperation = new PosSettingsAdvOp(this); + + + mPluginsLoader = new PosSettingsPluginsLoader(); + // load the plugins + mPluginsList = mPluginsLoader->loadPlugins(); + + // for each plugin detected call the plugin's initialize method + + int cnt = mPluginsList.count(); + int error = 0; + for(int i=0;iinitialise(mAdvancedOperation ); + //pluging is unloaded if the there is an error, with exception for not found. + if (error != 0 && error != -1) + { + delete mPluginsList[i]; + mPluginsList[i] = 0; + mPluginsList.removeAt(i); + --cnt; + --i; + } + } + // create a QFileSystemWatcher instance + mWatcher = new QFileSystemWatcher(); + mWatcher->addPath(PLUGIN_PATH); + + // make connection to update the advanced view on change in the plugins + QObject::connect(mWatcher,SIGNAL(fileChanged ( const QString & path )), + this,SLOT(updateAdvView())); + qDebug() << "- PosSettingsAdvView::PosSettingsAdvView()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvView::~PosSettingsAdvView() +// Destructor +//--------------------------------------------------------------------- +PosSettingsAdvView::~PosSettingsAdvView() + { + qDebug() << "+ PosSettingsAdvView::~PosSettingsAdvView()"; + // mAdvancedDataForm->removeAllConnection(); + delete mAdvancedDataForm; + mAdvancedDataForm = NULL; + + + delete mAdvancedOperation; + mAdvancedOperation = NULL; + + delete mPluginsLoader; + mPluginsLoader = NULL; + + // delete the list of plugins + foreach( PosSettingsAdvInterface *plugin, mPluginsList ) + { + delete plugin; + plugin = 0; + } + mPluginsList.clear(); + + //ToDo: disconnect mWatcher'signal + delete mWatcher; + mWatcher = NULL; + qDebug() << "- PosSettingsAdvView::~PosSettingsAdvView()"; + } + +//--------------------------------------------------------------------- +// PosSettingsAdvView::updateAdvView() +// +//--------------------------------------------------------------------- +void PosSettingsAdvView::updateAdvView() + { + qDebug() << "+ PosSettingsAdvView::updateAdvView()"; + // clear the plugins list + foreach( PosSettingsAdvInterface *plugin, mPluginsList ) + { + delete plugin; + plugin= NULL; + } + mPluginsList.clear(); + + // reload the plugins again + mPluginsList = mPluginsLoader->loadPlugins(); + + int count = mPluginsList.count(); + + // for each plugin detected call the plugin's initialize method + for( int i=0;iinitialise( mAdvancedOperation ); + if( error != KErrNone ) + { + delete mPluginsList[i]; + mPluginsList[i] =NULL; + } + } + qDebug() << "- PosSettingsAdvView::updateAdvView()"; + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,174 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings engine class. +* +*/ + + +#include "possettingsengine.h" +#include "possettingscrkey.h" +#include +#include +#include + + +//--------------------------------------------------------------------- +// PosSettingsEngine::PosSettingsEngine() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSettingsEngine::PosSettingsEngine() + { + qDebug() << "+ PosSettingsEngine::PosSettingsEngine()"; + d_ptr = new PosSettingsEnginePrivate( *this ); + qDebug() << "- PosSettingsEngine::PosSettingsEngine()"; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::~PosSettingsEngine() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSettingsEngine::~PosSettingsEngine() + { + qDebug() << "+ PosSettingsEngine::~PosSettingsEngine()"; + delete d_ptr; + d_ptr = NULL; + qDebug() << "- PosSettingsEngine::~PosSettingsEngine()"; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::isPositionTechnologyAvailable() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsEngine::isPositionTechnologyAvailable( + PositionTechnology posTechnology ) + { + qDebug() << "+ PosSettingsEngine::isPositionTechnologyAvailable()"; + bool err = d_ptr->isPositionTechnologyAvailable( posTechnology ); + qDebug() << "- PosSettingsEngine::isPositionTechnologyAvailable() retvat: " << err; + return err; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::setPositionTechnologyState() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSettingsEngine::setPositionTechnologyState( + State posTechnologyState, + PositionTechnology posTechnology ) + { + qDebug() << "+ PosSettingsEngine::setPositionTechnologyState()"; + qDebug() << "posTechnologyState: " << posTechnologyState; + int ret = d_ptr->setPositionTechnologyState( posTechnologyState, + posTechnology ); + qDebug() << "- PosSettingsEngine::setPositionTechnologyState()" << ret; + return ret; + } + + +//--------------------------------------------------------------------- +// PosSettingsEngine::isPositionTechnologyEnabled() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsEngine::isPositionTechnologyEnabled( + PositionTechnology posTechnology ) + { + qDebug() << "+ PosSettingsEngine::isPositionTechnologyEnabled()"; + bool ret = d_ptr->isPositionTechnologyEnabled( posTechnology ); + qDebug() << "- PosSettingsEngine::isPositionTechnologyEnabled() retval= " << ret; + return ret; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::setBackGroundPositioningState() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSettingsEngine::setBackGroundPositioningState( + State backGroundPosState ) + { + qDebug() << "+ PosSettingsEngine::setBackGroundPositioningState()"; + qDebug() << "backGroundPosState: " << backGroundPosState; + int ret = d_ptr->setBackGroundPositioningState( backGroundPosState ); + qDebug() << "- PosSettingsEngine::setBackGroundPositioningState() retval= " << ret; + return ret; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::isPositionTechnologyEnabled() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsEngine::isBackGroundPositioningEnabled() + { + qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()"; + bool ret = d_ptr->isBackGroundPositioningEnabled(); + qDebug() << "- PosSettingsEngine::isBackGroundPositioningEnabled() retval= " << ret; + return ret; + } + +// --------------------------------------------------------------------------- +// PosSettingsEngine::backgroundPositioningStatus +// --------------------------------------------------------------------------- +bool PosSettingsEngine::cRBackgroundPositioningStatus() + { + qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()"; + // create a XQSettingsManager instance + XQSettingsManager* manager = new XQSettingsManager(); + // create a XQSettingsKey object to read the cenrep key value + XQSettingsKey cenrepKey(XQSettingsKey::TargetCentralRepository, + KCRUidPositioningSettings.iUid, KPositioningSettingsBackgroundServicesStatus); + // read the cenrep key value + QVariant key(manager->readItemValue(cenrepKey,XQSettingsManager::TypeInt)); + // convert the key value to string + int keyIntValue = key.toInt(); + + delete manager; + manager = 0; + + qDebug() << "- PosSettingsEngine::cRBackgroundPositioningStatus()"; + return keyIntValue; + } + +// --------------------------------------------------------------------------- +// PosSettingsEngine::setCRBackgroundPositioningStatus +// --------------------------------------------------------------------------- +void PosSettingsEngine::setCRBackgroundPositioningStatus(State backGroundPosState) + { + qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()"; + // create a XQSettingsManager instance + XQSettingsManager* manager = new XQSettingsManager(); + // create a XQSettingsKey object to read the cenrep key value + XQSettingsKey cenrepKey(XQSettingsKey::TargetCentralRepository, + KCRUidPositioningSettings.iUid, KPositioningSettingsBackgroundServicesStatus); + + // write the cenrep key value + if(backGroundPosState == StateEnable) + QVariant key(manager->writeItemValue(cenrepKey,QVariant(1))); + else + QVariant key(manager->writeItemValue(cenrepKey,QVariant(0))); + + delete manager; + manager = 0; + qDebug() << "- PosSettingsEngine::setCRBackgroundPositioningStatus()"; + } + +//--------------------------------------------------------------------- +// PosSettingsEngine::handlePositionTechnologyChange() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSettingsEngine::handlePositionTechnologyChange() + { + qDebug() << "+ PosSettingsEngine::handlePositionTechnologyChange()"; + emit positionTechnologyChange(); + qDebug() << "- PosSettingsEngine::handlePositionTechnologyChange()"; + } +// End of file. diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsengineprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsengineprivate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,329 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings engine private class. +* +*/ + +#include "possettingsengineprivate.h" +#include "possettingsengine.h" +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::PosSettingsEnginePrivate() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSettingsEnginePrivate::PosSettingsEnginePrivate( + PositionTechnologyChangeObserver& + posTechChangeObserver): + mPosTechChangeObserver( + posTechChangeObserver ) + { + // Open session to LBT server. + int error = mLbtServer.Connect(); + if( error != KErrNone ) + { + throw( error ); + } + //Open subsession to LBT server. + error = mLbtManager.Open( mLbtServer ); + if( error != KErrNone ) + { + throw( error ); + } + QT_TRAP_THROWING( mSuplSettings = CSuplSettings::NewL(); + mPosModules = CPosModules::OpenL(); + + populatePsyModuleInfoListL(); + // Get back ground position status + GetBackGroundPositioingStateL(); + // Register for settings change. + mPosModules->SetObserverL( *this ) + ); + } + + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::~PosSettingsEnginePrivate() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSettingsEnginePrivate::~PosSettingsEnginePrivate() + { + mLbtManager.Close(); + mLbtServer.Close(); + delete mSuplSettings; + mSuplSettings = NULL; + // remove observer + mPosModules->RemoveObserver(); + delete mPosModules; + mPosModules = NULL; + + mPsyModuleInfoList.Close(); + } + + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::isPositionTechnologyAvailable() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsEnginePrivate::isPositionTechnologyAvailable( + PositionTechnology posTechnology ) + { + // Iterate through the PSY list to find the specified position + // technology. + TInt cnt = mPsyModuleInfoList.Count(); + for( TInt i=0;iSetUpdateAvailability( ETrue ); + } + else + { + updateParams->SetUpdateAvailability( EFalse ); + } + TInt cnt = mPsyModuleInfoList.Count(); + for( TInt i=0;iUpdateModuleL( mPsyModuleInfoList[i].mPsyModuleId, + *updateParams ); + mPsyModuleInfoList[i].mState = posTechnologyState; + } + } + CleanupStack::PopAndDestroy( updateParams ); + } + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::setBackGroundPositioningStateL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSettingsEnginePrivate::setBackGroundPositioningStateL( + State backGroundPosState ) + { + if( backGroundPosState == StateEnable ) + { + mLbtManager.SetTriggeringMechanismStateL( + ETriggeringMechanismOn ); + User::LeaveIfError( mSuplSettings->SetSuplTriggeredServiceStatus( + CSuplSettings::ESuplTriggerOn ) ); + mBackGroundPositioningState = StateEnable; + } + else + { + mLbtManager.SetTriggeringMechanismStateL( + ETriggeringMechanismOff ); + User::LeaveIfError( mSuplSettings->SetSuplTriggeredServiceStatus( + CSuplSettings::ESuplTriggerOff ) ); + mBackGroundPositioningState = StateDisable; + } + } + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::populatePsyModuleInfoListL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSettingsEnginePrivate::populatePsyModuleInfoListL() + { + CPosModuleIdList* idList = mPosModules->ModuleIdListLC(); + TInt cnt = idList->Count(); + for ( TInt i = 0; i < cnt; ++i ) + { + TPositionModuleInfo moduleInfo; + mPosModules->GetModuleInfoL( (*idList)[i], moduleInfo ); + + // Psy module info hold the information regarding PSY that are + // essential for our operation. + PsyModuleInfo psyModuleInfo; + + // Set the module Id. + psyModuleInfo.mPsyModuleId = moduleInfo.ModuleId(); + + // Set position technology type. + if( moduleInfo.TechnologyType() == TPositionModuleInfo::ETechnologyTerminal || + moduleInfo.TechnologyType() == TPositionModuleInfo::ETechnologyAssisted ) + { + psyModuleInfo.mPosTech = PositionTechnologyGps; + } + else if ( moduleInfo.TechnologyType() == TPositionModuleInfo::ETechnologyNetwork ) + { + psyModuleInfo.mPosTech = PositionTechnologyNetwork; + } + + // Set state of Psy. + if( moduleInfo.IsAvailable() ) + { + psyModuleInfo.mState = StateEnable; + } + else + { + psyModuleInfo.mState = StateDisable; + } + + mPsyModuleInfoList.Append( psyModuleInfo ); + } + CleanupStack::PopAndDestroy( idList ); + } + + +//--------------------------------------------------------------------- +// PosSettingsEnginePrivate::GetBackGroundPositioingStateL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSettingsEnginePrivate::GetBackGroundPositioingStateL() + { + // Get the SUPL service status. + CSuplSettings::TSuplTriggerStatus suplTriggerStatus; + User::LeaveIfError( mSuplSettings->GetSuplTriggeredServiceStatus( + suplTriggerStatus ) ); + + // Get LBT service status. + TLbtTriggeringSystemManagementSettings triggeringSystemSettings; + mLbtManager.GetTriggeringSystemSettingsL( triggeringSystemSettings ); + + // Back ground positioning state is considered to be enabled only + // if both LBT and SUPL services are enabled. + if( suplTriggerStatus == CSuplSettings::ESuplTriggerOn && + triggeringSystemSettings.TriggeringMechanismState() == + ETriggeringMechanismOn ) + { + mBackGroundPositioningState = StateEnable; + } + else + { + mBackGroundPositioningState = StateDisable; + } + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsform.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsform.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,464 @@ +/* +* Copyright (c) 2010 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 class is for first basic view for positioning settings +* +*/ + + +#include "possettingsform.h" +#include "possettingspushbuttonitem.h" +#include "possettingsgroupboxitem.h" +#include "checkcustomviewitem.h" +#include "possettingsengine.h" +#include "possettingsadvview.h" +#include +#include +#include +#include +#include +#include + +static const QString FILE_PATH_CSS = ":/data"; + +// --------------------------------------------------------------------------- +// PosSettingsForm::PosSettingsForm +// Constructor +// --------------------------------------------------------------------------- +PosSettingsForm::PosSettingsForm( + PosSettingsEngine& settingsEngine, + QGraphicsItem *parent ): + HbDataForm( parent ),mSettingsEngine( settingsEngine ) + { + qDebug() << "+ PosSettingsForm::PosSettingsForm()"; + //initialize the form model + initSettingModel(); + + // slots for required signals on required controls + addConnection( mGpsPosType, SIGNAL(released()), + this, SLOT(onPressedGps()) ); + addConnection( mWirelessPosType, SIGNAL(released()), + this, SLOT(onPressedWireless()) ); + addConnection( mBgPosType, SIGNAL(released()), + this, SLOT(onPressedBackground()) ); + addConnection( mAdvancedSettings, SIGNAL(clicked()), + this, SLOT(onPressedAdvanced()) ); + + //to check runtime if any positioning technology installed/removed or if its visibility is changed. + connect(&mSettingsEngine, SIGNAL(positionTechnologyChange()),this, SLOT(validateVisibility()) ); + + //validate visibility of controls based on visibility of positioning technology + validateVisibility(); + qDebug() << "- PosSettingsForm::PosSettingsForm()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::~PosSettingsForm +// Destructor +// --------------------------------------------------------------------------- +PosSettingsForm::~PosSettingsForm() + { + qDebug() << "+ PosSettingsForm::PosSettingsForm()"; + // Remove custom layouts + HbStyleLoader::unregisterFilePath(FILE_PATH_CSS); + + //TODO Disconnect of mSettingsEngine positionTechnologyChange + + removeConnection( mAdvancedSettings, SIGNAL(clicked()), + this, SLOT(onPressedAdvanced()) ); + removeConnection( mGpsPosType, SIGNAL(released), + this, SLOT(onPressedGps()) ); + removeConnection( mWirelessPosType, SIGNAL(released), + this, SLOT(onPressedWireless()) ); + removeConnection( mBgPosType, SIGNAL(released), + this, SLOT(onPressedBackground()) ); + + //ToDo: removeAllConnection crashes with Kern-Exec3 error + //removeAllConnection(); + qDebug() << "- PosSettingsForm::PosSettingsForm()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::initSettingModel +// --------------------------------------------------------------------------- +void PosSettingsForm::initSettingModel() + { + qDebug() << "+ PosSettingsForm::initSettingModel()"; + HbDataFormModel *model = new HbDataFormModel(0); + this->setModel(model); + + //set prototype for custom controls + QList protoTypeList = this->itemPrototypes(); + protoTypeList.append(new PosSettingsPushButtonItem(this) ); + protoTypeList.append(new CheckCustomViewItem()); + protoTypeList.append(new PosSettingsGroupboxItem(this)); + this->setItemPrototypes(protoTypeList); + + // Set custom layouts + HbStyleLoader::registerFilePath(FILE_PATH_CSS); + + //Heading + mHeading = model->appendDataFormItem(static_cast(GroupboxItem), + QString(), + model->invisibleRootItem()); + mHeading->setContentWidgetData("heading", + hbTrId("txt_loe_subtitle_positioning_settings")); + + + + //GPS + createPosTypeModelItem(PosTypeIndexGps); + model->appendDataFormItem(mGpsPosType, model->invisibleRootItem()); + //Wireless + createPosTypeModelItem(PosTypeIndexWireless); + model->appendDataFormItem(mWirelessPosType, model->invisibleRootItem()); + //Background + createPosTypeModelItem(PosTypeIndexBackground); + model->appendDataFormItem(mBgPosType, model->invisibleRootItem()); + + //Advance + mAdvancedSettings = model->appendDataFormItem(static_cast(PushButtonItem), + QString(), + model->invisibleRootItem()); + mAdvancedSettings->setContentWidgetData("text", + hbTrId("txt_loe_button_advanced")); + + + setPosTypeState(PosTypeIndexGps); + setPosTypeState(PosTypeIndexWireless); + setPosTypeState(PosTypeIndexBackground); + qDebug() << "- PosSettingsForm::initSettingModel()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::onPressedAdvanced +// --------------------------------------------------------------------------- +void PosSettingsForm::onPressedAdvanced() +{ + qDebug() << "+ PosSettingsForm::onPressedAdvanced()"; + mAdvancedView = new PosSettingsAdvView(); + HbMainWindow* mainWindow = hbInstance->allMainWindows().at(0); + + mainWindow->addView(mAdvancedView); + mainWindow->setCurrentView(mAdvancedView); + + //take back action from controlpanel main window. + mBackAction = new HbAction(Hb::BackNaviAction ,mAdvancedView); + mAdvancedView->setNavigationAction(mBackAction); + + connect(mBackAction, SIGNAL(triggered()), this, SLOT(closeAdvancedView())); + mAdvancedView->show(); + qDebug() << "- PosSettingsForm::onPressedAdvanced()"; +} +// --------------------------------------------------------------------------- +// PosSettingsForm::closeAdvancedView +// --------------------------------------------------------------------------- +// +void PosSettingsForm::closeAdvancedView() + { + qDebug() << "+ PosSettingsForm::closeAdvancedView()"; + disconnect(mBackAction, SIGNAL(triggered()), this, SLOT(closeAdvancedView())); + + HbMainWindow* mainWindow = hbInstance->allMainWindows().at(0); + mainWindow->removeView(mAdvancedView); + + mAdvancedView->setParent(NULL); + + delete mAdvancedView; + mAdvancedView = NULL; + + // refresh first view + setPosTypeState( PosTypeIndexGps); + setPosTypeState( PosTypeIndexWireless); + setPosTypeState( PosTypeIndexBackground); + validatePosTypeVisibility(PosTypeIndexBackground); + qDebug() << "- PosSettingsForm::closeAdvancedView()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::onPressedGps +// --------------------------------------------------------------------------- +void PosSettingsForm::onPressedGps() + { + qDebug() << "+ PosSettingsForm::onPressedGps()"; + validatePosTypeVisibility(PosTypeIndexBackground); + + int state = mGpsPosType->contentWidgetData("checkState").toInt(); + if(state == Qt::Checked) + { //if Gps enable + mSettingsEngine.setPositionTechnologyState(StateEnable, PositionTechnologyGps); + } + else + { //if Gps disable + mSettingsEngine.setPositionTechnologyState(StateDisable, PositionTechnologyGps); + } + qDebug() << "- PosSettingsForm::onPressedGps()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::onPressedWireless +// --------------------------------------------------------------------------- +void PosSettingsForm::onPressedWireless() + { + qDebug() << "+ PosSettingsForm::onPressedWireless()"; + validatePosTypeVisibility(PosTypeIndexBackground); + int state = mWirelessPosType->contentWidgetData("checkState").toInt(); + if(state == Qt::Checked) + { + //if Wireless enable + mSettingsEngine.setPositionTechnologyState(StateEnable, PositionTechnologyNetwork); + } + else + { //if Wireless disable + mSettingsEngine.setPositionTechnologyState(StateDisable, PositionTechnologyNetwork); + } + qDebug() << "- PosSettingsForm::onPressedWireless()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::onPressedBackground +// --------------------------------------------------------------------------- +void PosSettingsForm::onPressedBackground() + { + qDebug() << "+ PosSettingsForm::onPressedBackground()"; + int state = mBgPosType->contentWidgetData("checkState").toInt(); + if(state == Qt::Checked) + { + //if Bg enable + mSettingsEngine.setBackGroundPositioningState(StateEnable); + mSettingsEngine.setCRBackgroundPositioningStatus(StateEnable); + } + else + { //if Bg disable; + mSettingsEngine.setBackGroundPositioningState(StateDisable); + mSettingsEngine.setCRBackgroundPositioningStatus(StateDisable); + } + qDebug() << "- PosSettingsForm::onPressedBackground()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::validatePosTypeVisibility +// --------------------------------------------------------------------------- +// +void PosSettingsForm::validatePosTypeVisibility(PosTypeIndex posTypeModelItemIndex) + { + qDebug() << "+ PosSettingsForm::validatePosTypeVisibility()"; + bool valid = false; + HbDataFormModelItem* posTypeModelItem = NULL; //does not own + int posIndex = posTypeModelItemIndex; + switch(posTypeModelItemIndex) { + case PosTypeIndexGps: { + valid = mSettingsEngine.isPositionTechnologyAvailable(PositionTechnologyGps); + posTypeModelItem = mGpsPosType; + break; + } + case PosTypeIndexWireless: { + valid = mSettingsEngine.isPositionTechnologyAvailable(PositionTechnologyNetwork); + posTypeModelItem = mWirelessPosType; + HbDataFormModel* model = static_cast(this->model()); + //if GPS is not there, it will be at position 1 + if(!model->indexFromItem(mGpsPosType).isValid()) { + --posIndex ; + } + break; + } + case PosTypeIndexBackground: { + //if Gps and Wireless are not marked, then make Background invisible + valid = (mGpsPosType->contentWidgetData("checkState").toInt() == Qt::Checked || + mWirelessPosType->contentWidgetData("checkState").toInt() == Qt::Checked); + posTypeModelItem = mBgPosType; + HbDataFormModel* model = static_cast(this->model()); + + //if GPS is not there, decremenet position + if(!model->indexFromItem(mGpsPosType).isValid()) { + --posIndex; + } + //if Wireless is not there, decremenet position + if(!model->indexFromItem(mWirelessPosType).isValid()) { + --posIndex; + } + //if no gps no wireless, quit control-panel application + if(posIndex == PosTypeIndexGps-1) { + qApp->quit(); + } + break; + } + default:{ + break; + } + + } + qDebug() << "valid =" << valid; + insertOrRemovePosTypeModelItem(valid, posTypeModelItem, posTypeModelItemIndex, posIndex); + qDebug() << "- PosSettingsForm::validatePosTypeVisibility()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::InsertOrRemovePosTypeModelItem +// --------------------------------------------------------------------------- +// +void PosSettingsForm::insertOrRemovePosTypeModelItem(bool insert, HbDataFormModelItem* posTypeModelItem, + PosTypeIndex posTypeModelItemIndex, int posIndex) + { + qDebug() << "+ PosSettingsForm::insertOrRemovePosTypeModelItem()"; + HbDataFormModel* model = static_cast(this->model()); + if(!insert) { + if(model->indexFromItem(posTypeModelItem).isValid()) { + if(model->removeItem(posTypeModelItem)) { + //Note: In removeItem, modelitem is removed and then deleted too. + // So next time when we want to check if it is present, we have to create dummy modelitem + // else with existing handle, we will get kern exec 3 error + createPosTypeModelItem(posTypeModelItemIndex); + if(posTypeModelItem == mBgPosType) { + mSettingsEngine.setBackGroundPositioningState(StateDisable); + } + } + } + } + else { + if(!model->indexFromItem(posTypeModelItem).isValid()) { + model->insertDataFormItem(posIndex,posTypeModelItem,model->invisibleRootItem()); + addPosTypeConnection(posTypeModelItem); + + if(posTypeModelItem == mBgPosType) { + //Restore to old state in case of background positioning. + if(mSettingsEngine.cRBackgroundPositioningStatus()) { + mSettingsEngine.setBackGroundPositioningState(StateEnable); + } + else { + mSettingsEngine.setBackGroundPositioningState(StateDisable); + } + setPosTypeState(PosTypeIndexBackground); + } + else //Restore old state of GPS/Wireless + setPosTypeState(posTypeModelItemIndex); + } + } + qDebug() << "- PosSettingsForm::insertOrRemovePosTypeModelItem()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::createPosTypeModelItem +// --------------------------------------------------------------------------- +// +void PosSettingsForm::createPosTypeModelItem(PosTypeIndex posTypeModelItemIndex) + { + qDebug() << "+ PosSettingsForm::createPosTypeModelItem()"; + HbDataFormModel* model = static_cast(this->model()); + switch(posTypeModelItemIndex) { + case PosTypeIndexGps: { + + mGpsPosType = new HbDataFormModelItem(HbDataFormModelItem::CheckBoxItem, + QString()); + mGpsPosType->setData(HbDataFormModelItem::DescriptionRole, hbTrId("txt_loe_info_enable_for_most_accurate_positioning")); + mGpsPosType->setContentWidgetData("text", hbTrId("txt_loe_list_gps")); + break; + } + case PosTypeIndexWireless: { + + mWirelessPosType = new HbDataFormModelItem(HbDataFormModelItem::CheckBoxItem, + QString()); + mWirelessPosType->setData(HbDataFormModelItem::DescriptionRole, hbTrId("txt_loe_info_use_wifi_and_mobile_networks_to_get")); + mWirelessPosType->setContentWidgetData("text", hbTrId("txt_loe_list_wireless_networks")); + break; + } + case PosTypeIndexBackground:{ + mBgPosType = new HbDataFormModelItem(HbDataFormModelItem::CheckBoxItem, + QString()); + mBgPosType->setData(HbDataFormModelItem::DescriptionRole, hbTrId("txt_loe_info_enable_applications_and_services_upda")); + mBgPosType->setContentWidgetData("text", hbTrId("txt_loe_list_background_positioning")); + break; + } + default: { + break; + } + } + qDebug() << "- PosSettingsForm::createPosTypeModelItem()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::validateVisibility +// --------------------------------------------------------------------------- +// +void PosSettingsForm::validateVisibility() + { + qDebug() << "+ PosSettingsForm::validateVisibility()"; + validatePosTypeVisibility(PosTypeIndexGps); + validatePosTypeVisibility(PosTypeIndexWireless); + validatePosTypeVisibility(PosTypeIndexBackground); + qDebug() << "- PosSettingsForm::validateVisibility()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::setPosTypeState +// --------------------------------------------------------------------------- +void PosSettingsForm::setPosTypeState(PosTypeIndex posTypeModelItemIndex) + { + qDebug() << "+ PosSettingsForm::setPosTypeState()"; + int state = Qt::Unchecked; + switch(posTypeModelItemIndex){ + case PosTypeIndexGps: { + if(mSettingsEngine.isPositionTechnologyEnabled(PositionTechnologyGps)) + state = Qt::Checked; + mGpsPosType->setContentWidgetData("checkState", state); + break; + } + case PosTypeIndexWireless: { + if(mSettingsEngine.isPositionTechnologyEnabled(PositionTechnologyNetwork)) + state = Qt::Checked; + mWirelessPosType->setContentWidgetData("checkState",state); + break; + } + case PosTypeIndexBackground: { + if(mSettingsEngine.isBackGroundPositioningEnabled()) + state = Qt::Checked; + mBgPosType->setContentWidgetData("checkState",state); + break; + } + default : { + break; + } + } + qDebug() << "- PosSettingsForm::setPosTypeState()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsForm::addPosTypeConnection +// --------------------------------------------------------------------------- +void PosSettingsForm::addPosTypeConnection(HbDataFormModelItem* posTypeModelItem) + { + qDebug() << "+ PosSettingsForm::addPosTypeConnection()"; + if(posTypeModelItem == mGpsPosType) + { + addConnection( mGpsPosType, SIGNAL(released()), + this, SLOT(onPressedGps()) ); + qDebug() << "- PosSettingsForm::addPosTypeConnection()"; + return; + } + + if(posTypeModelItem == mWirelessPosType) + { + addConnection( mWirelessPosType, SIGNAL(released()), + this, SLOT(onPressedWireless()) ); + qDebug() << "- PosSettingsForm::addPosTypeConnection()"; + return; + } + if(posTypeModelItem == mBgPosType) + { + addConnection( mBgPosType, SIGNAL(released()), + this, SLOT(onPressedBackground()) ); + qDebug() << "- PosSettingsForm::addPosTypeConnection()"; + return; + } + } +//EOF diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsgroupboxitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsgroupboxitem.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2010 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 class provides custom list item for the +* DataForm +* +*/ + +#include +#include +#include +#include +#include +#include + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::PosSettingsGroupboxItem +// --------------------------------------------------------------------------- +// +PosSettingsGroupboxItem::PosSettingsGroupboxItem(QGraphicsItem *parent) : +HbDataFormViewItem(parent) +{ +} + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::~PosSettingsGroupboxItem +// --------------------------------------------------------------------------- +// +PosSettingsGroupboxItem::~PosSettingsGroupboxItem() +{ +} + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::createItem +// --------------------------------------------------------------------------- +// +HbAbstractViewItem* PosSettingsGroupboxItem::createItem() +{ + return new PosSettingsGroupboxItem(*this); +} + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::canSetModelIndex +// --------------------------------------------------------------------------- + +bool PosSettingsGroupboxItem::canSetModelIndex(const QModelIndex &index) const +{ + int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt(); + if (type == GroupboxItem ) { + return true; + } + else { + return false; + } +} + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::createCustomWidget +// --------------------------------------------------------------------------- +// +HbWidget* PosSettingsGroupboxItem::createCustomWidget() +{ + HbDataFormModelItem::DataItemType itemType = + static_cast + ( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt() ); + + switch (itemType) { + case GroupboxItem: + { + //custom button + QString str = + modelIndex().data(HbDataFormModelItem::PropertyRole).toString(); + HbGroupBox* groupbox = new HbGroupBox(this); + // Use the Groupbox widget for heading + groupbox->setHeading(str); + mWidget = groupbox; + return mWidget; + } + default: + return 0; + } +} + +// --------------------------------------------------------------------------- +// PosSettingsGroupboxItem:::restore +// --------------------------------------------------------------------------- +// +void PosSettingsGroupboxItem::restore() +{ + HbDataFormViewItem::restore(); + if (mWidget) { + HbDataFormModelItem::DataItemType itemType = static_cast( + modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); + + if(itemType == GroupboxItem) { + + QModelIndex itemIndex = modelIndex(); + HbDataFormModel *model = static_cast(itemView()->model());; + HbDataFormModelItem *modelItem = static_cast( + model->itemFromIndex(itemIndex)); + + const QMetaObject *metaObj = mWidget->metaObject(); + int count = metaObj->propertyCount(); + for (int i = 0; i < count; ++i) { + QMetaProperty metaProperty = metaObj->property(i); + if (metaProperty.isValid() && metaProperty.isWritable()) { + metaProperty.write(mWidget,modelItem->contentWidgetData(metaProperty.name())); + } + } + } + } +} + +//EOF diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingspluginsloader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingspluginsloader.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2010 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: Implementation of the Positioning Settings Plugins Loader class + * + */ + + +#include "possettingspluginsloader.h" +#include "possettingscrkey.h" +#include +#include +#include +#include +#include +#include +#include + + +#ifdef Q_OS_SYMBIAN +#define PLUGIN_PATH QString("\\resource\\qt\\plugins\\positioningsettings") + +#else +#define PLUGIN_PATH QString("C:\\qt\\plugins\\positioningsettings") +#endif + +// constants +const int KNoOfDigits = 4; + +//--------------------------------------------------------------------- +// PosSettingsPluginsLoader::PosSettingsPluginsLoader +// +//--------------------------------------------------------------------- +PosSettingsPluginsLoader::PosSettingsPluginsLoader() + { + qDebug() << "+ PosSettingsPluginsLoader::PosSettingsPluginsLoader()"; + qDebug() << "- PosSettingsPluginsLoader::PosSettingsPluginsLoader()"; + } + +//--------------------------------------------------------------------- +// PosSettingsPluginsLoader::~PosSettingsPluginsLoader +// +//--------------------------------------------------------------------- +PosSettingsPluginsLoader::~PosSettingsPluginsLoader() + { + qDebug() << "+ PosSettingsPluginsLoader::~PosSettingsPluginsLoader()"; + mDllNameList.clear(); + qDebug() << "- PosSettingsPluginsLoader::~PosSettingsPluginsLoader()"; + } +//--------------------------------------------------------------------- +// PosSettingsPluginsLoader::loadPlugins +// +//--------------------------------------------------------------------- +QList PosSettingsPluginsLoader::loadPlugins() + { + qDebug() << "+ PosSettingsPluginsLoader::loadPlugins()"; + // parse the default cen rep key value which is used to determine + // the order of loading the default positioning settings plugins + ParseCenRepKey(); + // List containing the plugins implementing the PositioningSettingsAdvancedInterface + QList pluginsList; + // Check for the files under the positioningsettings directory + QDir pluginsDir(PLUGIN_PATH + QDir::separator()); + QFileInfoList fileInfoList = pluginsDir.entryInfoList(); + // check each file in this directory,only if its a dll give it to the + // plugin loader + foreach ( const QFileInfo &fileInfo, fileInfoList ) + { + QString fileName = fileInfo.absoluteFilePath(); + qDebug() << "Filename: " << fileName; + + if (!QLibrary::isLibrary(fileName)) + { + continue; + } + // load the dlls using QPluginLoader + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); + qDebug() << "Plugin Filename: " << pluginsDir.absoluteFilePath(fileName); + QObject *plugin = pluginLoader.instance(); + // Check if the plugin found is an implementation of the + // PosSettingsAdvInterface,if yes add it to the plugins list + + if (plugin) + { + PosSettingsAdvInterface* advancedInterface = qobject_cast< + PosSettingsAdvInterface *> (plugin); + + if (advancedInterface) + { + + QString dllName = fileInfo.baseName(); + // check the position into which the plugin needs to be + // inserted if it is one of the default plugins + for (int i = 0; i < mDllNameList.count(); i++) + { + if (dllName.compare(mDllNameList[i],Qt::CaseInsensitive) == KErrNone) + { + pluginsList.insert(i, advancedInterface); + break; + } + } + } + } + } + qDebug() << "- PosSettingsPluginsLoader::loadPlugins()"; + return pluginsList; + } + +//--------------------------------------------------------------------- +// PosSettingsPluginsLoader::ParseCenRepKey +// +//--------------------------------------------------------------------- +void PosSettingsPluginsLoader::ParseCenRepKey() + { + qDebug() << "+ PosSettingsPluginsLoader::ParseCenRepKey()"; + // create a XQSettingsManager instance + XQSettingsManager* manager = new XQSettingsManager(); + // create a XQSettingsKey object to read the cenrep key value + XQSettingsKey cenrepKey(XQSettingsKey::TargetCentralRepository, + KCRUidPositioningSettings.iUid, KPositioningSettingsPlugins); + // read the cenrep key value + QVariant key(manager->readItemValue(cenrepKey,XQSettingsManager::TypeString)); + // convert the key value to string + QString keyStringValue = key.toString(); + // if the length of default value is less than 4 digits then return + if (keyStringValue.size() < KNoOfDigits) + { + qDebug() << "- PosSettingsPluginsLoader::ParseCenRepKey()"; + return; + } + // get the count of the number of plugin dlls + int dllCount = keyStringValue.left(KNoOfDigits).toInt(); + // initialise current index to 4 + int currentIndex = KNoOfDigits; + // extract the name of each of the dll from the cenrep key value + for (int i = 0; i < dllCount; i++) + { + // extract length of dll name + int length = keyStringValue.mid(currentIndex, KNoOfDigits).toInt(); + // increment the current index value + currentIndex += KNoOfDigits; + // get the dll name + QString dllName = keyStringValue.mid(currentIndex, length); + // append to list of dll names + mDllNameList.append(dllName); + // increment the value of currentIndex by length of name + currentIndex += length; + } + qDebug() << "- PosSettingsPluginsLoader::ParseCenRepKey()"; + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingspushbuttonitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingspushbuttonitem.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2010 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 class provides custom list item for the +* DataForm +* +*/ + +#include +#include +#include +#include +#include +#include + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::PosSettingsPushButtonItem +// --------------------------------------------------------------------------- +// +PosSettingsPushButtonItem::PosSettingsPushButtonItem(QGraphicsItem *parent) : +HbDataFormViewItem(parent) +{ +} + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::~PosSettingsPushButtonItem +// --------------------------------------------------------------------------- +// +PosSettingsPushButtonItem::~PosSettingsPushButtonItem() +{ +} + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::createItem +// --------------------------------------------------------------------------- +// +HbAbstractViewItem* PosSettingsPushButtonItem::createItem() +{ + return new PosSettingsPushButtonItem(*this); +} + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::canSetModelIndex +// --------------------------------------------------------------------------- + +bool PosSettingsPushButtonItem::canSetModelIndex(const QModelIndex &index) const +{ + int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt(); + if (type == PushButtonItem ) { + return true; + } + else { + return false; + } +} + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::createCustomWidget +// --------------------------------------------------------------------------- +// +HbWidget* PosSettingsPushButtonItem::createCustomWidget() +{ + HbDataFormModelItem::DataItemType itemType = + static_cast + ( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt() ); + + switch (itemType) { + case PushButtonItem: + { + //custom button + QString str = + modelIndex().data(HbDataFormModelItem::PropertyRole).toString(); + HbPushButton *button = new HbPushButton(str); + mWidget = button; + return mWidget; + } + default: + return 0; + } +} + +// --------------------------------------------------------------------------- +// PosSettingsPushButtonItem:::restore +// --------------------------------------------------------------------------- +// +void PosSettingsPushButtonItem::restore() +{ + HbDataFormViewItem::restore(); + if (mWidget) { + HbDataFormModelItem::DataItemType itemType = static_cast( + modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); + + if(itemType == PushButtonItem) { + + QModelIndex itemIndex = modelIndex(); + HbDataFormModel *model = static_cast(itemView()->model());; + HbDataFormModelItem *modelItem = static_cast( + model->itemFromIndex(itemIndex)); + + const QMetaObject *metaObj = mWidget->metaObject(); + int count = metaObj->propertyCount(); + for (int i = 0; i < count; i++) { + QMetaProperty metaProperty = metaObj->property(i); + if (metaProperty.isValid() && metaProperty.isWritable()) { + metaProperty.write(mWidget,modelItem->contentWidgetData(metaProperty.name())); + } + } + } + } +} + +//EOF diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsview.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2010 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 the first view for Positioning Settings plugin +* +*/ + +#include "possettingsview.h" +#include "possettingsengine.h" +#include "possettingsform.h" +#include "possettingspushbuttonitem.h" +#include + +// --------------------------------------------------------------------------- +// PosSettingsView::PosSettingsView +// --------------------------------------------------------------------------- +// +PosSettingsView::PosSettingsView(QGraphicsItem + *parent):CpBaseSettingView(0,parent) + { + qDebug() << "================ Positiong settings is launched =============================="; + qDebug() << "+ PosSettingsView::PosSettingsView()"; + mSettingsEngine = new PosSettingsEngine; + if(!mSettingsEngine){ + qDebug() << "- PosSettingsView::PosSettingsView()"; + return; + } + + mSettingsForm = new PosSettingsForm( *mSettingsEngine, this ); + if(mSettingsForm) + this->setWidget( mSettingsForm ); + qDebug() << "- PosSettingsView::PosSettingsView()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsView::~PosSettingsViewl +// --------------------------------------------------------------------------- +// +PosSettingsView::~PosSettingsView() + { + qDebug() << "+ PosSettingsView::~PosSettingsView()"; + delete mSettingsEngine; + mSettingsEngine = NULL; + + delete mSettingsForm; + mSettingsForm = NULL; + + qDebug() << "- PosSettingsView::~PosSettingsView()"; + qDebug() << "================ Positiong settings is closed =============================="; + } + +//EOF + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/inc/apilogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/inc/apilogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2010 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + +#ifndef APILOGGER_H +#define APILOGGER_H + +#include +#include +#include +#include +#include + +using namespace std; + + +class ApiLogger + { + public: + static void OpenLogFile(); + static void CloseLogFile(); + static void MyOutputHandler(QtMsgType type, const char *msg); + }; + +#endif // APILOGGER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingsplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingsplugin.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2010 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 for Positioning Settings plugin in ControlPanel +* +*/ + +#ifndef POSSETTINGS_PLUGIN_H +#define POSSETTINGS_PLUGIN_H + +class QTranslator; +#include + +class PosSettingsPlugin : public QObject, public CpPluginInterface +{ +Q_OBJECT + Q_INTERFACES(CpPluginInterface) +public: //constructor and destructor + PosSettingsPlugin(); + virtual ~PosSettingsPlugin(); +public: + /* + * Derived from CpPluginPlatInterface + */ + virtual QList createSettingFormItemData(CpItemDataHelper &itemDataHelper) const; +private: + /** + * Holds localization translator handle + */ + QTranslator* mTranslator; +}; +#endif // POSSETTINGS_PLUGIN_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingspluginhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingspluginhelper.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2010 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: Positioning settings plugin helper class. +* +*/ + +#ifndef POSITIONINGSETTINGSPLUGIN_HELPER_H +#define POSITIONINGSETTINGSPLUGIN_HELPER_H + +#include + +class PosSettingsPluginHelperPrivate; +/** + * PosSettingsPluginHelper is a class that provides helper functions: + * To check if feature flag is On/Of + * To check if any positioning PSY is visible + */ +class PosSettingsPluginHelper + { +public: + + + /** + * Constructor + */ + PosSettingsPluginHelper(); + + /** + * Destructor + */ + ~PosSettingsPluginHelper(); + + /** + * Returns whether any position psy is available. + * @return true if any position psy is available, + * false if it is not available. + */ + bool isPositionPsyAvailable(); + + /** + * Returns whether feature flag is enabled. + * @return true if feature flag is enabled, + * false if it is not enabled. + */ + bool isFeatureFlagEnabled(); + +private: + Q_DECLARE_PRIVATE(PosSettingsPluginHelper) +protected: + PosSettingsPluginHelperPrivate* const d_ptr; + }; + + +#endif /* POSITIONINGSETTINGSPLUGIN_HELPER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingspluginhelper_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/inc/possettingspluginhelper_p.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 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: Positioning settings plugin helper private class. +* +*/ + +#ifndef POSITIONINGSETTINGSPLUGIN_HELPERPRIVATE_H +#define POSITIONINGSETTINGSPLUGIN_HELPERPRIVATE_H + +class PosSettingsPluginHelper; +/** + * PosSettingsPluginHelperPrivate is a class that provides helper functions: + * To check if feature flag is On/Of + * To check if any positioning PSY is visible + */ +class PosSettingsPluginHelperPrivate + { +private: + + /** + * Returns whether any position psy is available. + * @return true if any position psy is available, + * false if it is not available. + */ + bool isPositionPsyAvailable(); + + /** + * Returns whether feature flag is enabled. + * @return true if feature flag is enabled, + * false if it is not enabled. + */ + bool isFeatureFlagEnabled(); + + friend class PosSettingsPluginHelper; + }; + + +#endif /* POSITIONINGSETTINGSPLUGIN_HELPERPRIVATE_H_ */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/possettingsplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/possettingsplugin.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,77 @@ +# +# Copyright (c) 2010 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: project file for positioing settings plugin +# + +TEMPLATE = lib +TARGET = possettingsplugin +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + +CONFIG += hb\ + plugin + +#Uncomment following line to disable logging +#DEFINES += QT_NO_DEBUG_OUTPUT + +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc +RESOURCES += possettingsplugin.qrc +TRANSLATIONS = lilocationmw.ts + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 + +LIBS += -lcpframework \ + -lpossettingsengine \ + -leposmodset \ + -lfeatmgr + +# Input +SOURCES += src/possettingsplugin.cpp \ + src/possettingspluginhelper.cpp \ + src/possettingspluginhelper_p.cpp \ + src/apilogger.cpp + +HEADERS += inc/possettingsplugin.h \ + inc/possettingspluginhelper.h \ + inc/possettingspluginhelper_p.h \ + inc/apilogger.h + +symbian { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += PLUGINUID3=0x2002C318 + TARGET.UID3 = 0x2002C318 + + # Add translation files + addFiles.sources = translations/possettings.qm + addFiles.path = . + #DEPLOYMENT += addFiles + + deploy.path = C: + qtplugins.path = /resource/qt/plugins/controlpanel + qtplugins.sources += qmakepluginstubs/possettingsplugin.qtplugin + # This is for new exporting system coming in garden + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" +} + +TARGET.CAPABILITY = All -TCB +plugin.sources = possettingsplugin.dll +plugin.path = \resource\qt\plugins\controlpanel +DEPLOYMENT += plugin + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/possettingsplugin.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/possettingsplugin.qrc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ + + + translations/possettings.qm + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/src/apilogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/src/apilogger.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2010 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + + +#include "apilogger.h" +#include + +const char* debugFileName("c://logs//lbs//posSettingsEngineLog.txt"); +ofstream logfile; + +void ApiLogger::OpenLogFile() +{ + logfile.open(debugFileName, ios::app); +} + +void ApiLogger::CloseLogFile() +{ + logfile.flush(); + logfile.close(); +} + +void ApiLogger::MyOutputHandler(QtMsgType type, const char *msg) +{ + switch (type) { + case QtDebugMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; + break; + case QtCriticalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n"; + break; + case QtWarningMsg: + // logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n"; + break; + case QtFatalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << "\n"; + default: + break; + } + logfile.flush(); +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingsplugin.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2010 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 for Positioning Settings plugin in ControlPanel + * + */ + +#include "possettingsplugin.h" +#include "possettingsview.h" +#include "possettingspluginhelper.h" +#include "apilogger.h" + +#include +#include +#include +#include + + + +// --------------------------------------------------------------------------- +// PosSettingsPlugin::PosSettingsPlugin +// --------------------------------------------------------------------------- +// +PosSettingsPlugin::PosSettingsPlugin():mTranslator(0) + { +#ifndef QT_NO_DEBUG_OUTPUT + ApiLogger::OpenLogFile(); + qInstallMsgHandler(ApiLogger::MyOutputHandler); +#endif + + qDebug() << "+ PosSettingsPluginHelper::PosSettingsPlugin()"; + mTranslator = new QTranslator(); + + QString lang = QLocale::system().name(); + QString path = "z:/resource/qt/translations/"; + bool loaded = false; + loaded = mTranslator->load(path + QString("lilocationmw_") + lang); + if (loaded == false) + { + loaded = mTranslator->load("possettings", ":/translations"); + } + if (loaded) + { + qApp->installTranslator(mTranslator); + } + qDebug() << "- PosSettingsPluginHelper::PosSettingsPlugin()"; + } + +// --------------------------------------------------------------------------- +// PosSettingsPlugin::~PosSettingsPlugin +// --------------------------------------------------------------------------- +// +PosSettingsPlugin::~PosSettingsPlugin() + { + qDebug() << "+ PosSettingsPluginHelper::~PosSettingsPlugin()"; + if (mTranslator) + { + if (mTranslator->isEmpty() == false) + qApp->removeTranslator(mTranslator); + delete mTranslator; + } + qDebug() << "- PosSettingsPluginHelper::~PosSettingsPlugin()"; + #ifndef QT_NO_DEBUG_OUTPUT + qInstallMsgHandler(0); + ApiLogger::CloseLogFile(); + #endif + } + +// --------------------------------------------------------------------------- +// PosSettingsPlugin::createSettingFormItemData +// --------------------------------------------------------------------------- +// +QList PosSettingsPlugin::createSettingFormItemData( + CpItemDataHelper &itemDataHelper) const + { + qDebug() << "+ PosSettingsPluginHelper::createSettingFormItemData()"; + PosSettingsPluginHelper helper; + QList formItemDataList; + if (!helper.isFeatureFlagEnabled() && helper.isPositionPsyAvailable()) + { + CpSettingFormItemData *itemData = new CpSettingFormEntryItemDataImpl< + PosSettingsView> (itemDataHelper, hbTrId( + "txt_cp_dblist_positioning"), hbTrId( + "txt_cp_dblist_positioning_val_change_positioning_s")); + formItemDataList.append(itemData); + } + qDebug() << "- PosSettingsPluginHelper::createSettingFormItemData()"; + return formItemDataList; + } + +Q_EXPORT_PLUGIN2(possettingsplugin, PosSettingsPlugin) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingspluginhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingspluginhelper.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings plugin helper class. +* +*/ + +#include "possettingspluginhelper.h" +#include "possettingspluginhelper_p.h" +#include + +//----------------------------------------------------------------- +//PosSettingsPluginHelper::PosSettingsPluginHelper() +//----------------------------------------------------------------- +PosSettingsPluginHelper::PosSettingsPluginHelper() : + d_ptr(new PosSettingsPluginHelperPrivate()) + { + qDebug() << "+ PosSettingsPluginHelper::PosSettingsPluginHelper()"; + qDebug() << "- PosSettingsPluginHelper::PosSettingsPluginHelper()"; + } + +//----------------------------------------------------------------- +//PosSettingsPluginHelper::~PosSettingsPluginHelper() +//----------------------------------------------------------------- +PosSettingsPluginHelper::~PosSettingsPluginHelper() + { + qDebug() << "+ PosSettingsPluginHelper::~PosSettingsPluginHelper()"; + if (d_ptr) + { + delete d_ptr; + } + qDebug() << "- PosSettingsPluginHelper::~PosSettingsPluginHelper()"; + } + +//--------------------------------------------------------------------- +// PosSettingsPluginHelper::populatePsyModuleInfoListL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsPluginHelper::isPositionPsyAvailable() + { + qDebug() << "+ PosSettingsPluginHelper::isPositionPsyAvailable()"; + bool ret = d_ptr->isPositionPsyAvailable(); + qDebug() << "- PosSettingsPluginHelper::isPositionPsyAvailable() ret =" << ret; + return ret; + } + +//--------------------------------------------------------------------- +// PosSettingsPluginHelperPrivate::isFeatureFlagEnabledL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsPluginHelper::isFeatureFlagEnabled() + { + qDebug() << "+ PosSettingsPluginHelper::isFeatureFlagEnabled()"; + bool ret = d_ptr->isFeatureFlagEnabled(); + qDebug() << "- PosSettingsPluginHelper::isFeatureFlagEnabled() ret =" << ret; + return ret; + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingspluginhelper_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/src/possettingspluginhelper_p.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings plugin helper private class. +* +*/ + + +#include "possettingspluginhelper_p.h" +#include "possettingspluginhelper.h" +#include +#include +#include + +//--------------------------------------------------------------------- +// PosSettingsPluginHelperPrivate::isPositionPsyAvailable() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsPluginHelperPrivate::isPositionPsyAvailable() + { + TInt cnt = 0; + TInt err2 = KErrGeneral; + CPosModules* posModules; + TRAPD(err1, posModules = CPosModules::OpenL();); + if(!posModules) + { + User::Leave( KErrGeneral ); + } + else + { + TRAP(err2, + CPosModuleIdList* idList = posModules->ModuleIdListLC(); + cnt = idList->Count(); + CleanupStack::PopAndDestroy( idList );); + } + if(err1==KErrNone && err2 ==KErrNone && cnt) //if no error and there + return true; + else + return false; + } + +//--------------------------------------------------------------------- +// PosSettingsPluginHelperPrivate::isFeatureFlagEnabled() +// (other items were commented in a header). +//--------------------------------------------------------------------- +bool PosSettingsPluginHelperPrivate::isFeatureFlagEnabled() + { + TBool flag = EFalse; + TRAPD(err, + FeatureManager::InitializeLibL(); + if ( FeatureManager::FeatureSupported( KFeatureIdFfLocationsysuiHidePositioningMenu ) ) + { + flag = ETrue; + } + FeatureManager::UnInitializeLib(); + ); + if(err==KErrNone && flag) + return true; + else + return false; + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/translations/possettings.qm Binary file locationsystemui/locationsysui/possettings/possettingsplugin/translations/possettings.qm has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possettingsplugin/translations/possettings.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possettingsplugin/translations/possettings.ts Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,599 @@ + + + + + + Info text for periodic location request query (Default policy - Reject) + Your location will not be shared periodically by default if you don't respond + Your location will not be shared periodically by default if you don't respond + qtl_dialog_pri5 + Location notifications_03 + info + Lo + False + + + Name of the positioning server + Use %1 + Use %1 + qtl_checkbox_sec + loe_008 + list + lo + False + + + 2G/3G/etc network settings for positionin use + Cellular network + Cellular network + qtl_checkbox_sec + loe_008 + list + lo + False + + + Option menu item + Delete server + Delete server + qtl_menu_pri + loe_008 + opt + lo + False + + + Button - takes to advanced positioning settings + Advanced + Advanced + qtl_dataform_button_sec + loe_007 + button + lo + False + + + Button for accessing settings in control palel + Settings + Settings + txt_lint_button_settings + loe_002 + button + lo + False + + + Update interval value when update happens in seconds (59s or less) + Updates every %L1 seconds + Updates every %L1 seconds + qtl_list_sec + loe_008 + list + lo + False + + + Coordinates + L1%?L2%'L3%.L4%"E + L1%?L2%'L3%.L4%"E + txt_loe_list_l1l2l3l4e + loe_002 + list + lo + False + + + Location request query dialog - Softkey button. Allows the user to reject the suggested operation. + Reject + Reject + qtl_dialog_softkey + common + button + co + False + + + Control panel item in CP main view + Change positioning settings + Change positioning settings + qtl_list_sec_large_graphic + cp_001 + dblist_1_val + cp + False + + + Update interval value when interval is in days + Updates every %L1 days and %L2 hours + Updates every %L1 days and %L2 hours + qtl_list_sec + loe_008 + list + lo + False + + + Accuracy information in meters. Displayed when value is 999 meters or less + Accuracy: %L1 meters + Accuracy: %L1 meters + txt_lint_accuracy_1_meters + loe_002 + list + lo + False + + + Group heading for positioning methods + Positioning methods + Positioning methods + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. Allows the user to cancel the action or process. + Cancel + Cancel + None + common + button + co + False + + + Accuracy information in kilometers. Displayed when over 999 meters + Accuracy: %L1 kilometers + Accuracy: %L1 kilometers + txt_lint_list_accuracy_1_kilometers + loe_002 + list + lo + False + + + Primary text in list widget. Notification recieved time + <Time> + <Time> + qtl_list_pri + Location notifications_06 + list + Lo + False + + + Internal GPS chipset - enabling or disabling that + Internal GPS + Internal GPS + qtl_checkbox_sec + loe_008 + list + lo + False + + + Wi-FI - enable/disable wifi usage in positioning context + Wi-Fi + Wi-Fi + qtl_checkbox_sec + loe_008 + list + lo + False + + + Location notification heading text + Your location not sent to : + Your location not sent to : + qtl_notifdialog_pri + Location notifications_04 + dpophead + Lo + False + + + Description text for GPS under the checkbox item + Enable for most accurate positioning + Enable for most accurate positioning + qtl_dataform_description_sec + loe_007 + info + lo + False + + + Group heading positioning servers + Positioning servers + Positioning servers + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + Description text for wireless networks under the checkbox item + Use WI-FI and mobile networks to get position information + Use WI-FI and mobile networks to get position information + qtl_dataform_description_sec + loe_007 + info + lo + False + + + Single toolbar item to clear logs in Location notification log view + Clear logs + Clear logs + qtl_toolbar_tiny1_1 + Location notifications_06 + button + Lo + False + + + Sub heading text for Location notification logs view + Logs + Logs + qtl_groupbox_simple_sec + Location notifications_06 + subhead + Lo + False + + + Save button for saving current position + Save + Save + txt_loe_button_save + loe_002 + button + lo + False + + + Dialog text for server deletion + Select server to delete + Select server to delete + qtl_dialog_pri3 + loe_011 + info + lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. Allows the user to delete an item. Note that deleting removes the item permanently from memory. + Delete + Delete + None + common + button + co + False + + + value that tells the date until service will be active + Valid until %2 + Valid until %2 + qtl_list_sec + loe_008 + list + lo + False + + + Heading for the positioning info dialog + Positioning + Positioning + qtl_dialog_pri_heading + loe_001 + title + lo + False + + + Location notification primarry text in Universal Indicator Menu + %Ln Location notifications + + (s)%Ln Location notifications + (p)%Ln Location notifications + + qtl_indimenu_pri_medium_graphic + Location notifications_05 + dblist_1 + Lo + False + + + Assisted GPS - enabling or disabling + Assisted GPS + Assisted GPS + qtl_checkbox_sec + loe_008 + list + lo + False + + + Group heading for location based services + Background positioning + Background positioning + qtl_groupbox_expand_pri + loe_008 + subtitle + lo + False + + + subtitle for positioning settings main view + Positioning settings + Positioning settings + qtl_groupbox_simple_sec + loe_007 + subtitle + lo + False + + + Requestor info text in Location request query dialog + Location was requested by : + Location was requested by : + qtl_dialog_pri5 + Location notifications_01 + info + Lo + False + + + Button - takes to advanced positioning settings + Advanced positioning settings + Advanced positioning settings + qtl_groupbox_simple_sec + loe_008 + subtitle + lo + False + + + Title text in Location request query dialog + Location request + Location request + qtl_dialog_pri_heading + Location notifications_01 + title + Lo + False + + + Checkbox item for enabling/disabling Background positioning + Background positioning + Background positioning + qtl_checkbox_sec + loe_007 + list + lo + False + + + Update interval value when interval is hours (not days or months etc) + Updates every %L1 hours and %L2 minutes + Updates every %L1 hours and %L2 minutes + qtl_list_sec + loe_008 + list + lo + False + + + Update interval value when interval is in minutes + Updates every %L1 minutes and %L2 seconds + Updates every %L1 minutes and %L2 seconds + qtl_list_sec + loe_008 + list + lo + False + + + Checkbox item for enabling/disabling GPS + GPS + GPS + qtl_checkbox_sec + loe_007 + list + lo + False + + + Info text for periodic location request query - No default policy + You location will be shared periodically with : + You location will be shared periodically with : + qtl_dialog_pri5 + Location notifications_02 + info + Lo + False + + + Coordinates + L1%?L2%'L3%.L4%"W + L1%?L2%'L3%.L4%"W + txt_loe_list_l1l2l3l4w + loe_002 + list + lo + False + + + Coordinates + L1%?L2%'L3%.L4%"N + L1%?L2%'L3%.L4%"N + txt_loe_list_l1l2l3l4n + loe_002 + list + lo + False + + + Query header for save dialog + Save as + Save as + qtl_dialog_pri_heading + loe_005 + title + lo + False + + + Update interval value when interval is months + Updates every %L1 months and %L2 days + Updates every %L1 months and %L2 days + qtl_list_sec + loe_008 + list + lo + False + + + Bluetooth GPS - enabling/disabling external BT GPS device usage + Bluetooth GPS + Bluetooth GPS + qtl_checkbox_sec + loe_008 + list + lo + False + + + Checkbox item for enabling/disabling Wireless positioning + Wireless networks + Wireless networks + qtl_checkbox_sec + loe_007 + list + lo + False + + + Primary text in list widget. Notification received time and ate + <Time><Date> + <Time><Date> + qtl_list_pri + Location notifications_06 + list + Lo + False + + + Control panel item in CP main view + Positioning + Positioning + qtl_list_pri_large_graphic + cp_001 + dblist_1 + cp + False + + + Multiline secondary text in a list item + Your location sent to : + Your location sent to : + qtl_list_sec + Location notifications_06 + list + Lo + False + + + Location request query dialog - Softkey button. Allows the user to accept the location request + Accept + Accept + qtl_dialog_softkey + Location notifications_01 + button + Lo + False + + + Coordinates + L1%?L2%'L3%.L4%"S + L1%?L2%'L3%.L4%"S + txt_loe_list_l1l2l3l4s + loe_002 + list + lo + False + + + UniversalIndicatorMenu item text. + Positioning + Positioning + qtl_indimenu_pri_medium_graphic + loe_001 + dblist_1 + lo + False + + + Button in dialog for closing the Positioning info dialog + Done + Done + qtl_dialog_softkey_1 + loe_002 + button + lo + False + + + Confirmation about stopping service + Stop service %1 + Stop service %1 + qtl_dialog_pri3_large_graphic + loe_010 + info + lo + False + + + Description text for Location based services & background applications + Enable applications and services update and retrieve location information + Enable applications and services update and retrieve location information + qtl_dataform_description_sec + loe_007 + info + lo + False + + + Multiline secondary text in a list item + Your location not sent to: + Your location not sent to: + qtl_list_sec + Location notifications_06 + list + Lo + False + + + Title text for Location notifications log view + Location notifications + Location notifications + qtl_chrome_title + Location notifications_06 + title + Lo + False + + + Button. Note! Use this text ID only if there are max. two buttons in the dialog. When this button is pressed, the focused item or operation will be selected or accepted. + OK + OK + qtl_dialog_softkey_2 + common + button + co + False + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possettingssignalmapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possettingssignalmapper.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010 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: Declaration of the Positioning Settings signal mapper + * used to map the signals of each check box item to the index + * + */ + +#ifndef POSSETTINGSSIGNALMAPPER_H +#define POSSETTINGSSIGNALMAPPER_H + +#include + +class PosSettingsSignalMapper : public QObject + { + Q_OBJECT +public: + /* + * constructor + */ + PosSettingsSignalMapper(); + /** + * destructor + */ + ~PosSettingsSignalMapper(); +public: +signals: + /** + * signal emitted by the slot of this class + */ + void signalmapped(); +public slots: + /** + * slot to be called on a change in state of checkbox. + * this in turn calls the signal signalmapped() + */ + void signalmap(); + }; + +#endif //POSSETTINGSSIGNALMAPPER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettings.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2010 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 for SUPL Positioning Settings plugin + * for Advanced View + * + */ + +#ifndef POSSUPLSETTINGS_PLUGIN_H +#define POSSUPLSETTINGS_PLUGIN_H + +//User Includes +#include "possuplsettingscommon.h" +#include "possettingssignalmapper.h" + +#include +#include +#include +#include +#include + +//Forward Declaration +class PosSettingsAdvOp; +class PosSuplSettingsEngine; +class QModelIndex; +class HbRadioButtonList; +class HbDialog; + +class PosSuplSettingsPlugin : public QObject, public PosSettingsAdvInterface + + { +Q_OBJECT + Q_INTERFACES( PosSettingsAdvInterface ) +public: + /** + * Constructor + */ + PosSuplSettingsPlugin(); + + /** + * Destructor + */ + ~PosSuplSettingsPlugin(); +public: + /* + * Derived from PosSettingsAdvInterface + */ + virtual int initialise(PosSettingsAdvOp* operation); + +private: + /** + * This method is used to list all the server that are present for + * positioing. Depending on whether the server is enabled/disabled for positioning + * the corresponding checkboxes are marked. + */ + void listServers(); + + /** + * This method creates menu to delete the servers + */ + void createMenu(); + +private slots: + /** + * This is used as a slot whenever the checkbox is marked/unmarked. + * On changing the state of the checkbox the corresponding positioning + * server is enabled/disabled + * @param [in] - slpid for the server to be enababled/disabled + */ + void changeServerUsage(int slpid); + + /** + * This is slot, which is called whenever there is a new server added or + * a server in the list is deleted. This refreshes the view. + */ + void updateList(); + + /** + * This is slot, which is called when the user selects the + * server to be deleted + */ + void onDeleteServer(); + + /** + * This slot is used to enable the primary Action wheneven + * a server is selected from the list of servers to be deleted + * @param [in] - index of the server to be deleted + */ + void setPrimaryAction(int itemSelected); + + /** + * This slot is used to delete the server whenever + * a server is selected from the list of servers to be deleted + */ + void deleteServer(); + +private: + + /** + * an object if the supl setting engine class + * Owns + */ + PosSuplSettingsEngine* mSuplSettingsEngine; + + /** + * an object of data form model item class + * Owns + */ + HbDataFormModelItem * mGroup; + + /** + * Holds the params of the list of servers + * Owns + */ + QList mServerList; + + /** + * hold the signal mapper objects of PosPsySettingsSignalMapper + * Owns + */ + QList mSignalMapperList; + + /** + * Handle to PosSettingsAdvOp object + * Does not own + */ + PosSettingsAdvOp * mOperation; + + /** + * an object of QSignalMapper + * Owns + */ + QSignalMapper * mSignalMapper; + + /** + * an object on HbMenu + * Owns + */ + HbMenu* mMainMenu; + + /** + * list of servers that can be deleted + * Owns + */ + QList mDeleteableServerList; + + /** + * an instance of HBAction, used for SK1 in + * the delete server Dialog box + * Owns + */ + HbAction* mPrimaryAction; + + /** + * an instance of HbRadioButtonList, used to add server + * in the delete server selection Dialog box + * Owns + */ + HbRadioButtonList *mRadioButtonList; + + /** + * holds the server delete query dialog + * Owns + */ + HbDialog *mDeleteQuery; + }; +#endif // POSSUPLSETTINGS_PLUGIN_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingscommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingscommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010 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 a common header for SUPL Positioning Settings plugin + * for Advanced View + * + */ + +#ifndef POSSUPLSETTINGS_COMMON_H +#define POSSUPLSETTINGS_COMMON_H + +#include + +/** + * Contains info related to each SUPL Servers + * - SLP id + * - Server Address + * - Access Point + * - Server Usage State(enabled/disabled) + * - Sim Change Remove (Yes/No) + * - Usage is Home Network(Yes/No) + * - editable (Yes/No) + */ +class PosServerParams + { +public: + long slpId; + QString serverAdd; + QString iap; + bool serverEnabled; + }; + +#endif //POSSUPLSETTINGS_COMMON_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingsengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingsengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2010 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 the engine header for SUPL Positioning Settings plugin + * + */ + +#ifndef POSSUPLSETTINGS_ENGINE_H +#define POSSUPLSETTINGS_ENGINE_H + + +//User Includes +#include "possuplsettingsengineprivate.h" +#include "possuplsettingscommon.h" + +#include +#include +#include +#include + +//Forward Declarations +class PosSuplSettingsEnginePrivate; +class MSuplSettingsObserver; + +class PosSuplSettingsEngine : public QObject, public PosSuplSettingsChangeObserver + { +Q_OBJECT + +public: + + /** + * Constructor + */ + PosSuplSettingsEngine(); + + /** + * Destructor + */ + ~PosSuplSettingsEngine(); + + /** + * This method Lists all the Server that are present for Positioning. + * @param [out] - aServerList. Contains the servers that are present. + * @returns - KErrNone if successful + * - KErrNotfound is no servers are present + */ + + int suplServerList(QList& serverList); + + /** + * This method Lists all the Server that are present for Positioning. + * @param [out] - aServerList. Contains the servers that are present. + * @returns - KErrNone if successful + * - KErrNotfound is no servers are present + */ + + int deletableServerList(QList& serverList); + + + /** + * This method enables/disables the server in use for postioning. + * If the server is disabled, it will not be used for positioning unless enabled. + * @param [in] - aServerIndex. The server index which has to be enabled/disabled. + * @param [in] - aValue. true/false. + * @returns - KErrNone if enabling/disabling is successful + * - KErrArgument if the SLP ID passed is not valid/out of bounds + * - KErrGeneral if changing SUPL settings has failed + */ + int enableServer(int aServerIndex, bool aValue); + + /** + * This method is used to delete the server. + * @param [in] - aServerIndex. The server index which has to be deleted. + * @returns - KErrNone if the deletion is successful + * - KErrNotFound if the server at the index in missing/out of bounds. + * - KErrPermissionDenied if the sever cannot be deleted + * - KErrGeneral is other cases + */ + int deleteServer(int aServerIndex); + + +public: + + /** + * Inherited from PosSuplSettingsChangeObserver + */ + void handleSuplSettingsChange( MSuplSettingsObserver::TSuplSettingsEventType event,int slpId); +signals: + /** + * This signal is emitted when the server is deleted/added. + */ + void serverListUpdated(); + +private: + /** + * pointer to private implementation class + */ + Q_DECLARE_PRIVATE_D(d_ptr, PosSuplSettingsEngine) + PosSuplSettingsEnginePrivate * d_ptr; + }; +#endif // POSSUPLSETTINGS_ENGINE_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingsengineprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/inc/possuplsettingsengineprivate.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2010 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: Positioning settings engine private class header. +* +*/ + +#ifndef POSSUPLSETTINGSENGINEPRIVATE_H +#define POSSUPLSETTINGSENGINEPRIVATE_H + +#include "possuplsettingscommon.h" +#include +#include + +class CServerParams; +class CSuplSettings; + +//Constants +const int KMaxHSLPAddrLen = 256; +const int KMaxIAPLen = 256; +/** + * The class defines the interface for receiving SUPL settings + * change event. + */ +class PosSuplSettingsChangeObserver + { +public: + virtual void handleSuplSettingsChange( MSuplSettingsObserver::TSuplSettingsEventType aEvent,int aSlpId) = 0; + }; + + +/** + * The class defines the interface for listing,enabling\disabling and deleting + * SLP servers. + */ +class PosSuplSettingsEnginePrivate : public MSuplSettingsObserver + { +public: + /** + * Default constructor + */ + PosSuplSettingsEnginePrivate(); + + /** + * Destructor + */ + ~PosSuplSettingsEnginePrivate(); + + /** + * Returns properties of all servers from SUPL settings storage.. + * @[OUT] paramValues Array of retrieved server entries + * - KErrNone if SUPL settings are retrieved successfully. + * - KErrNotFound if the settings does not have any server entry + */ + int GetServerList( QList& aParamValues ); + + /** + * This method is used to change parameter which indicates whether server + * can be used for SUPL session or not. + * + * @param [IN] slpId SLP ID for which the parameter needs to be changed + * @param [IN] enableFlag Flag to indicate whether server can be enabled or not + * @return one of the following error codes: + * - KErrNone if SUPL settings are changed successfully. + * - KErrArgument if the SLP ID passed is not valid + * - KErrGeneral if changing SUPL settings has failed + */ + int SetServerStatus( int aSlpId, + bool aEnableFlg + ); + + + /** + * This method is deletes server entry from SUPL settings storage. + * + * @param [IN] slpId Server identity for which the entery needs to be deleted from the SUPL settings storage + * + * @return one of the following error codes: + * - KErrNone if entry is deleted successfully + * - KErrNotFound if the specified server identity does not exists in settings storage + * - KErrGeneral if changing SUPL settings has failed + * + */ + int RemoveServer( int aSlpId); + + /** + * Returns list all servers from SUPL settings storage that can be deleted.Operator configured servers will be omitted from + * this list. + * @[OUT] paramValues Array of retrieved server entries + * - KErrNone if SUPL settings are retrieved successfully. + * - KErrNotFound if the list does not have any server entry + */ + int GetRemovableServerList( QList& aParamValues ); + + /* @param [IN] observer The observing object. + * @return one of the following values + * - KErrNone if setting observer is successful + * - KErrAlreadyExists if observer is already set + * + */ + int SetObserver( PosSuplSettingsChangeObserver* aObserver ); + + +public: + void HandleSuplSettingsChangeL( TSuplSettingsEventType aEvent,TInt aSlpId ); + void HandleSuplTriggerStatusChangeL( CSuplSettings::TSuplTriggerStatus aSuplTriggerStatus ); + + +private: //Data members + + /** + * Reference to position technology change observer. + * Does not own + */ + PosSuplSettingsChangeObserver* mPosSuplSettingsObserver; + + /** + * Pointer to Supl settings object + * Owns + */ + CSuplSettings* mSuplSettings; + + /** + * Pointer to Supl Server List + * Owns + */ + RPointerArray mServerList; + }; + + + +#endif /* POSSUPLSETTINGSENGINEPRIVATE_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/possuplsettings.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/possuplsettings.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,63 @@ +# +# Copyright (c) 2010 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: Positioning Servers Plugin pro file +# +TEMPLATE = lib +TARGET = possuplsettings +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += ../possettingsengine/inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb \ + plugin +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +LIBS += -lcpframework \ + -lpossettingsengine \ + -lepos_suplsettings + +# Input +SOURCES += src/possuplsettings.cpp +SOURCES += src/possuplsettingsengine.cpp +SOURCES += src/possuplsettingsengineprivate.cpp +SOURCES += src/possettingssignalmapper.cpp + +HEADERS += inc/possuplsettingscommon.h \ + inc/possuplsettings.h +HEADERS += inc/possuplsettingsengine.h +HEADERS += inc/possuplsettingsengineprivate.h +HEADERS += inc/possettingssignalmapper.h +symbian: { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += PLUGINUID3=0x2002C31B + TARGET.UID3 = 0x2002C31B +} +symbian { + deploy.path = C: + qtplugins.path = /resource/qt/plugins/positioningsettings + qtplugins.sources += qmakepluginstubs/possuplsettings.qtplugin + + # This is for new exporting system coming in garden + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" +} +TARGET.CAPABILITY = All \ + -TCB +plugin.sources = possuplsettings.dll +plugin.path = \resource\qt\plugins\positioningsettings +DEPLOYMENT += plugin diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possettingssignalmapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possettingssignalmapper.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 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: Implementation of positioning settings signal mapper class + * + */ + + +#include "possettingssignalmapper.h" + + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// Constructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// destructor +//--------------------------------------------------------------------- +PosSettingsSignalMapper::~PosSettingsSignalMapper() + { + + } + +//--------------------------------------------------------------------- +// PosSettingsSignalMapper::PosSettingsSignalMapper() +// +//--------------------------------------------------------------------- +void PosSettingsSignalMapper::signalmap() + { + emit signalmapped(); + } + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettings.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,516 @@ +/* + * Copyright (c) 2010 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 for Positioning Supl Settings plugin + * for Positioning Settings's Advanced view + * + */ +#include "possuplsettings.h" +#include "possuplsettingsengine.h" +#include "possettingsadvop.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::PosSuplSettingsPlugin +// --------------------------------------------------------------------------- +// +PosSuplSettingsPlugin::PosSuplSettingsPlugin() : + mSuplSettingsEngine(0), mGroup(0), mOperation(0), mSignalMapper(0), + mMainMenu(0), mPrimaryAction(0), mRadioButtonList(0), + mDeleteQuery(0) + { + qDebug() << "+ PosSuplSettingsPlugin::PosSuplSettingsPlugin()"; + mSuplSettingsEngine = new PosSuplSettingsEngine(); + qDebug() << "- PosSuplSettingsPlugin::PosSuplSettingsPlugin()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::~PosSuplSettingsPlugin +// --------------------------------------------------------------------------- +// +PosSuplSettingsPlugin::~PosSuplSettingsPlugin() + { + qDebug() << "+ PosSuplSettingsPlugin::~PosSuplSettingsPlugin()"; + + if (mSuplSettingsEngine) + { + delete mSuplSettingsEngine; + mSuplSettingsEngine = 0; + } + + if (mGroup && mOperation) + { + mOperation->removeItem(mGroup); + mGroup = 0; + } + + if (mMainMenu) + { + delete mMainMenu; + mMainMenu = 0; + } + ///// + QObject::disconnect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(changeServerUsage(int))); + + if (mSignalMapper) + { + delete mSignalMapper; + mSignalMapper = NULL; + } + + if (mPrimaryAction) + { + delete mPrimaryAction; + mPrimaryAction = 0; + } + + if (mRadioButtonList) + { + mRadioButtonList->reset(); + delete mRadioButtonList; + } + + if (mDeleteQuery) + { + delete mDeleteQuery; + } + /// + + // delete the signal mapper instances + int cnt = mSignalMapperList.count(); + for (int i = 0; i < cnt ; ++i) + { + QObject::disconnect(mSignalMapperList[i], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + delete mSignalMapperList[i]; + mSignalMapperList[i] = NULL; + } + + /// + + mServerList.clear(); + mSignalMapperList.clear(); + mDeleteableServerList.clear(); + qDebug() << "- PosSuplSettingsPlugin::~PosSuplSettingsPlugin()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::initialise +// --------------------------------------------------------------------------- +// +int PosSuplSettingsPlugin::initialise(PosSettingsAdvOp* operation) + { + qDebug() << "+ PosSuplSettingsPlugin::initialise()"; + + int result = 0; + // Assign to the member variable + mOperation = operation; + + // create the signal mapper + mSignalMapper = new QSignalMapper(); + + //get the list of server present for positioning + if (mSuplSettingsEngine) + { + result = mSuplSettingsEngine->suplServerList(mServerList); + } + + // if no error while getting the server list then add the group + // for Positioning servers + if (result == 0) + { + mGroup = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, + hbTrId("txt_loe_subtitle_positioning_servers"), 0); + //Add the group to the data form + operation->appendDataFormItem(mGroup); + //list all the server inside the group + listServers(); + } + QObject::connect(mSuplSettingsEngine, SIGNAL(serverListUpdated()), this, + SLOT(updateList())); + + qDebug() << "- PosSuplSettingsPlugin::initialise()" << "result = " + << result; + + return result; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::ChangeServerUsage +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::changeServerUsage(int value) + { + qDebug() << "+ PosSuplSettingsPlugin::changeServerUsage()"; + //toggle the value based on the slpid + if (!mServerList[value].serverEnabled) + { + mSuplSettingsEngine->enableServer(mServerList[value].slpId, true); + } + else + { + mSuplSettingsEngine->enableServer(mServerList[value].slpId, false); + } + qDebug() << "- PosSuplSettingsPlugin::changeServerUsage()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::listServers +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::listServers() + { + qDebug() << "+ PosSuplSettingsPlugin::listServers()"; + + qDebug() << "mServerList.count = " << mServerList.count(); + + //create a serverlist iterator + QList::const_iterator serveriterator; + + // Get the server names and display + for (serveriterator = mServerList.begin(); serveriterator + != mServerList.end(); ++serveriterator) + { + qDebug() << "server name = " << serveriterator->serverAdd; + if (serveriterator->serverAdd.length() > 0) + { + //for each server create new checkbox item + HbDataFormModelItem* checkBox = new HbDataFormModelItem( + HbDataFormModelItem::CheckBoxItem, QString(), 0); + + //set the widget data to the server name + checkBox->setContentWidgetData("text", QString(hbTrId( + "txt_loe_list_use_1")).arg(serveriterator->serverAdd)); + + //if the server is enabled set the initial state of the checkbox + if (serveriterator->serverEnabled) + { + checkBox->setContentWidgetData("checkState", Qt::Checked); + } + else + { + checkBox->setContentWidgetData("checkState", Qt::Unchecked); + } + + qDebug() << "Adding checkbox in the group"; + + //this part of code is called when the servers are added and + //Advanced view is in the background. Since there is no group + // a new group has to be created to add the servers + mOperation->appendDataFormItem(checkBox, mGroup); + + //create an object of dummy signal mapper class + //this is done to send the index info to the slots + //since checkbox is not of QObject type and dummy class is + // created. + PosSettingsSignalMapper* signalMapper = + new PosSettingsSignalMapper(); + mSignalMapperList.append(signalMapper); + + //add connection for statechanged of the checkbox, depending on which the + // add connections on change of check box state + mOperation->addConnection(checkBox, SIGNAL(stateChanged(int)), + mSignalMapperList[serveriterator - mServerList.begin()], + SLOT(signalmap())); + + QObject::connect(mSignalMapperList[serveriterator + - mServerList.begin()], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + + // set mapping of each check box item to its index + if (mSignalMapper) + { + mSignalMapper->setMapping(mSignalMapperList[serveriterator + - mServerList.begin()], (serveriterator + - mServerList.begin())); + } + } + } + + //use signal mapper to connect + QObject::connect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(changeServerUsage(int))); + + qDebug() << "mDeleteableServerList.count before reset = " + << mDeleteableServerList.count(); + + //refresh the list of deleteable servers in case any deleteable server is added + mDeleteableServerList.clear(); + + if (mSuplSettingsEngine) + { + mSuplSettingsEngine->deletableServerList(mDeleteableServerList); + } + + qDebug() << "mDeleteableServerList.count after fetch = " + << mDeleteableServerList.count(); + + //if the server list is <=1 while updating the list the menu is destroyed + if (mDeleteableServerList.count() == 0) + { + if (mMainMenu) + { + delete mMainMenu; + mMainMenu = 0; + } + } + else + { + delete mMainMenu; + mMainMenu = 0; + createMenu(); + } + qDebug() << "- PosSuplSettingsPlugin::listServers()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::updateList +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::updateList() + { + qDebug() << "+ PosSuplSettingsPlugin::updateList()"; + int result = 0; + int oldChildCount = 0; + + if (mGroup) + { + qDebug() << "Store the group info"; + + oldChildCount = mGroup->childCount(); + + // remove all connections + int count = mSignalMapperList.count(); + qDebug() << "mSignalMapperList.count() = " << count; + + for (int i = 0; i < count; ++i) + { + QObject::disconnect(mSignalMapperList[i], SIGNAL(signalmapped()), + mSignalMapper, SLOT(map())); + } + QObject::disconnect(mSignalMapper, SIGNAL(mapped(int)), this, + SLOT(changeServerUsage(int))); + + qDebug() << "oldChildCount = " << oldChildCount; + + //remove the children in the group + if (oldChildCount > 0) + { + qDebug() << "removing the children"; + //mGroup->removeChildren(0, oldChildCount); + //ToDo: Hack from HbDataForm team + for (int i = 0; i < oldChildCount; ++i) + { + mGroup->removeChild(0); + } + } + } + else + { + qDebug() << "Creating new group "; + + mGroup = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, + hbTrId("txt_loe_subtitle_positioning_servers"), 0); + mOperation->appendDataFormItem(mGroup); + } + + qDebug() << "mServerList.count() before clean = " << mServerList.count(); + + //clear the list and get the list of server present for positioning + mServerList.clear(); + if (mSuplSettingsEngine) + { + result = mSuplSettingsEngine->suplServerList(mServerList); + } + qDebug() << "result = " << result; + + //update the new list to the group + if (result == 0) + { + listServers(); + } + if (result == -1) + { + qDebug() << "Removing the group from form"; + //remove the group + mOperation->removeItem(mGroup); + mGroup = 0; + // delete the menu + if (mMainMenu) + { + delete mMainMenu; + mMainMenu = 0; + } + } + qDebug() << "- PosSuplSettingsPlugin::updateList()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::onDeleteServer +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::onDeleteServer() + { + qDebug() << "+ PosSuplSettingsPlugin::onDeleteServer()"; + //list that will contain the deleteable servers names + QStringList contentList; + + //get the deleteable server list from the engine + QList::const_iterator iterator; + + qDebug() << "mDeleteableServerList.count = " + << mDeleteableServerList.count(); + + //add the server names to the string list + for (iterator = mDeleteableServerList.constBegin(); iterator + != mDeleteableServerList.constEnd(); ++iterator) + { + //Copy the address to Qstring object + qDebug() << "deletable server = " << iterator->serverAdd; + contentList << iterator->serverAdd; + } + + // delete the mRadioButtonList before creating it,each time the delete + // query needs to be popped up + if (mRadioButtonList != 0) + { + delete mRadioButtonList; + mRadioButtonList = 0; + } + //create a radion button list of the deletable servers + mRadioButtonList = new HbRadioButtonList(); + mRadioButtonList->setItems(contentList); + QObject::connect(mRadioButtonList, SIGNAL(itemSelected(int)), this, + SLOT(setPrimaryAction(int))); + + // delete the mDeleteQuery before creating it,each time the delete + // query needs to be popped up + + if (mDeleteQuery != 0) + { + delete mDeleteQuery; + mDeleteQuery = 0; + } + //create the query dialog and attach the radio button to the dialog + mDeleteQuery = new HbDialog(); + + mDeleteQuery->setTimeout(HbDialog::NoTimeout); + + //set the proper layout for the mDeleteQuery dialog + qreal lMargin = 0; + qreal rMargin = 0; + qreal tMargin = 0; + + if (mDeleteQuery->style()->parameter("hb-param-margin-gene-left", + lMargin) && mDeleteQuery->style()->parameter( + "hb-param-margin-gene-right", rMargin) + && mDeleteQuery->style()->parameter( + "hb-param-margin-gene-top", tMargin)) + { + HbLabel * heading = new HbLabel(QString(hbTrId( + "txt_loe_info_select_server_to_delete"))); + heading->setContentsMargins(lMargin, tMargin, rMargin, 0); + mDeleteQuery->setHeadingWidget(heading); + } + + // delete the mPrimaryAction before creating it,each time the delete + // query needs to be popped up + if (mPrimaryAction != 0) + { + delete mPrimaryAction; + mPrimaryAction = 0; + } + //the primary action that will come in the SK1 of the Dialog box + mPrimaryAction + = new HbAction(QString(hbTrId("txt_common_button_delete"))); + + mDeleteQuery->addAction(mPrimaryAction); + mDeleteQuery->addAction(new HbAction(QString(hbTrId( + "txt_common_button_cancel")))); + QObject::connect(mPrimaryAction, SIGNAL(triggered()), this, + SLOT(deleteServer())); + + //set the content Widget + mDeleteQuery->setContentWidget(mRadioButtonList); + + //the Primary action is disabled since no server from the list is selected + mPrimaryAction->setDisabled(true); + + mDeleteQuery->show(); + + qDebug() << "- PosSuplSettingsPlugin::onDeleteServer()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::createMenu +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::createMenu() + { + qDebug() << "+ PosSuplSettingsPlugin::createMenu()"; + mMainMenu = new HbMenu(); + HbAction* action = mMainMenu->addAction(hbTrId( + "txt_loe_opt_delete_server")); + + QObject::connect(action, SIGNAL(triggered()), this, + SLOT(onDeleteServer())); + + mOperation->addAction(action, HbView::OptionsMenu); + qDebug() << "- PosSuplSettingsPlugin::createMenu()"; + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::setPrimaryAction +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::setPrimaryAction(int /*itemSelected*/) + { + //enable the primary Action + if (mPrimaryAction) + { + mPrimaryAction->setEnabled(true); + } + } + +// --------------------------------------------------------------------------- +// PosSuplSettingsPlugin::deleteServer +// --------------------------------------------------------------------------- +// +void PosSuplSettingsPlugin::deleteServer() + { + //get the index of the selected servers + int serverIndex = mRadioButtonList->selected(); + + if( serverIndex != -1 ) + { + if (mSuplSettingsEngine) + { + //delete the server + mSuplSettingsEngine->deleteServer( + mDeleteableServerList[serverIndex].slpId); + } + } + } +Q_EXPORT_PLUGIN2(possuplsettings, PosSuplSettingsPlugin) +; + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettingsengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettingsengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2010 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 the engine for Positioning Supl Settings plugin + * for Positioning Settings's Advanced view + * + */ +#include "possuplsettingsengine.h" +#include "possuplsettingsengineprivate.h" + +#include + +//----------------------------------------------------------------- +//PosSuplSettingsEngine::PosSuplSettingsEngine() +//----------------------------------------------------------------- +PosSuplSettingsEngine::PosSuplSettingsEngine() : + d_ptr(0) + { + qDebug() << "+ PosSuplSettingsEngine::PosSuplSettingsEngine()"; + d_ptr = new PosSuplSettingsEnginePrivate(); + //Set the PosSuplSettingsChangeObserver + if (d_ptr) + { + d_ptr->SetObserver(this); + } + qDebug() << "- PosSuplSettingsEngine::PosSuplSettingsEngine()"; + } + +//----------------------------------------------------------------- +//PosSuplSettingsEngine::~PosSuplSettingsEngine() +//----------------------------------------------------------------- +PosSuplSettingsEngine::~PosSuplSettingsEngine() + { + qDebug() << "+ PosSuplSettingsEngine::~PosSuplSettingsEngine()"; + if (d_ptr) + { + delete d_ptr; + d_ptr = 0; + } + qDebug() << "- PosSuplSettingsEngine::~PosSuplSettingsEngine()"; + } +//----------------------------------------------------------------- +//PosSuplSettingsEngine::suplServerList +//----------------------------------------------------------------- +int PosSuplSettingsEngine::suplServerList(QList& serverList) + { + qDebug() << "+ PosSuplSettingsEngine::suplServerList()"; + int result = 0; + //Clear the server list to remove any junk + //serverList.clear(); + if (d_ptr) + { + result = d_ptr->GetServerList(serverList); + } + qDebug() << "- PosSuplSettingsEngine::suplServerList() result = %d" << result; + return result; + } + +//----------------------------------------------------------------- +//PosSuplSettingsEngine::deletableServerList +//----------------------------------------------------------------- +int PosSuplSettingsEngine::deletableServerList( + QList& serverList) + { + qDebug() << "+ PosSuplSettingsEngine::deletableServerList()"; + int result = 0; + //Clear the server list to remove any junk + serverList.clear(); + if (d_ptr) + { + result = d_ptr->GetRemovableServerList(serverList); + } + qDebug() << "- PosSuplSettingsEngine::deletableServerList() result =%d" << result; + return result; + } +//----------------------------------------------------------------- +//PosSuplSettingsEngine::enableServer +//----------------------------------------------------------------- +int PosSuplSettingsEngine::enableServer(int serverIndex, bool value) + { + qDebug() << "+ PosSuplSettingsEngine::enableServer()"; + int result = 0; + if (d_ptr) + { + result = d_ptr->SetServerStatus(serverIndex, value); + } + qDebug() << "- PosSuplSettingsEngine::enableServer() result =%d" << result; + return result; + } +//----------------------------------------------------------------- +//PosSuplSettingsEngine::deleteServer +//----------------------------------------------------------------- +int PosSuplSettingsEngine::deleteServer(int serverIndex) + { + qDebug() << "+ PosSuplSettingsEngine::deleteServer()"; + int result = 0; + if (d_ptr) + { + result = d_ptr->RemoveServer(serverIndex); + } + qDebug() << "- PosSuplSettingsEngine::deleteServer() result =%d" << result; + //Check where to return KErrPermissionDenied + return result; + } +//----------------------------------------------------------------- +//PosSuplSettingsEngine::handleSuplSettingsChange +//----------------------------------------------------------------- +void PosSuplSettingsEngine::handleSuplSettingsChange( + MSuplSettingsObserver::TSuplSettingsEventType /*event*/, int /**slpId*/) + { + qDebug() << "+ PosSuplSettingsEngine::handleSuplSettingsChange()"; + emit serverListUpdated(); + qDebug() << "- PosSuplSettingsEngine::handleSuplSettingsChange()"; + } + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettingsengineprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/possuplsettingsplugin/src/possuplsettingsengineprivate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2010 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: Implementation of positioning settings engine private class. + * + */ +#include "possuplsettingsengineprivate.h" + +#include +#include +#include + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::PosSuplSettingsEnginePrivate() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSuplSettingsEnginePrivate::PosSuplSettingsEnginePrivate() : + mPosSuplSettingsObserver(NULL), mSuplSettings(NULL) + { + QT_TRAP_THROWING( mSuplSettings = CSuplSettings::NewL(); + mSuplSettings->SetObserverL(*this); + ); + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::~PosSuplSettingsEnginePrivate() +// (other items were commented in a header). +//--------------------------------------------------------------------- +PosSuplSettingsEnginePrivate::~PosSuplSettingsEnginePrivate() + { + + + mServerList.ResetAndDestroy(); + + if (mSuplSettings) + { + mSuplSettings->RemoveObserver(); + delete mSuplSettings; + mSuplSettings = NULL; + } + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::GetServerList() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSuplSettingsEnginePrivate::GetServerList( + QList & aParamValues) + { + TInt64 slpId; + HBufC* serverAddress = HBufC::New(KMaxHSLPAddrLen); + HBufC* iapName = HBufC::New(KMaxIAPLen); + TBool serverEnabled; + TBool simChangeRemove; + TBool usageInHomeNw; + TBool editable; + + if (!serverAddress || !iapName) + { + delete serverAddress; + delete iapName; + return KErrNoMemory; + } + + mServerList.ResetAndDestroy(); + + TInt error = mSuplSettings->GetAllSlp(mServerList); //handle return value... + if (error!=KErrNone) + { + delete serverAddress; + delete iapName; + mServerList.Close(); + mServerList.ResetAndDestroy(); + return error; + } + + TInt count = mServerList.Count(); + for(TInt i = 0; i < count; ++i ) + { + PosServerParams params; + error = mServerList[i]->Get( + slpId, + serverAddress->Des(), + iapName->Des(), + serverEnabled, + simChangeRemove, + usageInHomeNw, + editable); + + if (error == 0) + { +// QString sName((QChar*) (serverAddress->Ptr()), +// serverAddress->Length()); + + QString sName = QString::fromUtf16(serverAddress->Ptr(), serverAddress->Length()); + + params.slpId = slpId; + params.serverAdd = sName; + params.serverEnabled = serverEnabled; + + aParamValues.append(params); + } + } + + delete serverAddress; + delete iapName; + + return KErrNone; + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::SetServerStatus() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSuplSettingsEnginePrivate::SetServerStatus(int aSlpId, bool aEnableFlg) + { + return (mSuplSettings->SetServerEnabledFlag(aSlpId, aEnableFlg)); + } + + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::RemoveServer() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSuplSettingsEnginePrivate::RemoveServer(int aSlpId) + { + return (mSuplSettings->RemoveServer(aSlpId)); + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::GetRemovableServerList() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSuplSettingsEnginePrivate::GetRemovableServerList(QList< + PosServerParams>& aParamValues) + { + qDebug() << "+ PosSuplSettingsEnginePrivate::getRemovableServerList()"; + TInt64 slpId; + HBufC* serverAddress = HBufC::New(KMaxHSLPAddrLen); + HBufC* iapName = HBufC::New(KMaxIAPLen); + TBool serverEnabled; + TBool simChangeRemove; + TBool usageInHomeNw; + TBool editable; + TBool productConfigured; + + if (!serverAddress || !iapName) + { + delete serverAddress; + delete iapName; + return KErrNoMemory; + } + + mServerList.ResetAndDestroy(); + + TInt error = mSuplSettings->GetAllSlp(mServerList); //handle return value... + if (error!=KErrNone) + { + delete serverAddress; + delete iapName; + mServerList.Close(); + mServerList.ResetAndDestroy(); + return error; + } + + TInt count = mServerList.Count(); + qDebug() << "Deleteable server list count = " << count; + for(TInt i = 0; i < count; ++i ) + { + + PosServerParams params; + error = mServerList[i]->Get(slpId, + serverAddress->Des(), + iapName->Des(), + serverEnabled, + simChangeRemove, + usageInHomeNw, + editable); + TInt err = mServerList[i]->GetServerConfigurationType(productConfigured); + qDebug()<< "GetServerConfigurationType returns error = "<< err; + if (error == 0) + { + QString sName = QString::fromUtf16(serverAddress->Ptr(), serverAddress->Length()); + + params.slpId = slpId; + params.serverAdd = sName; + params.serverEnabled = serverEnabled; + + if (!productConfigured) + { + aParamValues.append(params); + } + } + } + + delete serverAddress; + delete iapName; + qDebug() << "- PosSuplSettingsEnginePrivate::getRemovableServerList()"; + return KErrNone; + + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::SetObserver() +// (other items were commented in a header). +//--------------------------------------------------------------------- +int PosSuplSettingsEnginePrivate::SetObserver( + PosSuplSettingsChangeObserver* aObserver) + { + TInt ret; + if (!mPosSuplSettingsObserver) + { + mPosSuplSettingsObserver = aObserver; + ret = KErrNone; + } + else + { + ret = KErrAlreadyExists; + } + return ret; + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::HandleSuplSettingsChangeL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSuplSettingsEnginePrivate::HandleSuplSettingsChangeL( + MSuplSettingsObserver::TSuplSettingsEventType aEvent, TInt aSlpId) + { + if (aEvent == MSuplSettingsObserver::ESuplSettingsDBAddEvent || aEvent + == MSuplSettingsObserver::ESuplSettingsDBDeleteEvent) + { + if (mPosSuplSettingsObserver) + { + mPosSuplSettingsObserver->handleSuplSettingsChange(aEvent, aSlpId); + } + } + } + +//--------------------------------------------------------------------- +// PosSuplSettingsEnginePrivate::HandleSuplTriggerStatusChangeL() +// (other items were commented in a header). +//--------------------------------------------------------------------- +void PosSuplSettingsEnginePrivate::HandleSuplTriggerStatusChangeL( + CSuplSettings::TSuplTriggerStatus /*aSuplTriggerStatus*/) + { + } + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/rom/possettings.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/rom/possettings.iby Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2010 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 __POSSETTINGS_IBY__ +#define __POSSETTINGS_IBY__ + +#ifdef __LOCATIONSYSUI + +#include +file=ABI_DIR\BUILD_DIR\possettingsengine.dll SHARED_LIB_DIR\possettingsengine.dll +file=ABI_DIR\BUILD_DIR\possettingsplugin.dll SHARED_LIB_DIR\possettingsplugin.dll +file=ABI_DIR\BUILD_DIR\pospsysettings.dll SHARED_LIB_DIR\pospsysettings.dll +file=ABI_DIR\BUILD_DIR\possuplsettings.dll SHARED_LIB_DIR\possuplsettings.dll +file=ABI_DIR\BUILD_DIR\poslocationservices.dll SHARED_LIB_DIR\poslocationservices.dll +data=DATAZ_\system\install\possettings_stub.sis system\install\possettings_stub.sis +data=\epoc32\data\c\resource\qt\plugins\controlpanel\possettingsplugin.qtplugin resource\qt\plugins\controlpanel\possettingsplugin.qtplugin +data=\epoc32\data\c\resource\qt\plugins\positioningsettings\pospsysettings.qtplugin resource\qt\plugins\positioningsettings\pospsysettings.qtplugin +data=\epoc32\data\c\resource\qt\plugins\positioningsettings\possuplsettings.qtplugin resource\qt\plugins\positioningsettings\possuplsettings.qtplugin +data=\epoc32\data\c\resource\qt\plugins\positioningsettings\poslocationservices.qtplugin resource\qt\plugins\positioningsettings\poslocationservices.qtplugin + +#endif // (__LOCATIONSYSUI) + +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/possettings/rom/possettings_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/possettings/rom/possettings_resources.iby Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 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: Positioning Settings Resources iby file +* +*/ + + +#ifndef __POSSETTINGSPLUGIN_RESOURCES_IBY__ +#define __POSSETTINGSPLUGIN_RESOURCES_IBY__ + +#ifdef __LOCATIONSYSUI + +#include + +// <-- QT POSSETTINGS START --> +data=DATAZ_\QT_TRANSLATIONS_DIR\lilocationmw.qm QT_TRANSLATIONS_DIR\lilocationmw.qm +// <-- QT POSSETTINGS END --> + +#endif // (__LOCATIONSYSUI) + +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/bwins/locnotificationclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/bwins/locnotificationclientu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,6 @@ +EXPORTS + ?Close@RContactResolverSession@@QAEXXZ @ 1 NONAME ; void RContactResolverSession::Close(void) + ?Connect@RContactResolverSession@@QAEHXZ @ 2 NONAME ; int RContactResolverSession::Connect(void) + ??0RContactResolverSession@@QAE@XZ @ 3 NONAME ; RContactResolverSession::RContactResolverSession(void) + ?ResolveRequestorsL@RContactResolverSession@@QAEXAAV?$RPointerArray@VCPosRequestor@@@@@Z @ 4 NONAME ; void RContactResolverSession::ResolveRequestorsL(class RPointerArray &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/eabi/locnotificationclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/eabi/locnotificationclientu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _ZN23RContactResolverSession18ResolveRequestorsLER13RPointerArrayI13CPosRequestorE @ 1 NONAME + _ZN23RContactResolverSession5CloseEv @ 2 NONAME + _ZN23RContactResolverSession7ConnectEv @ 3 NONAME + _ZN23RContactResolverSessionC1Ev @ 4 NONAME + _ZN23RContactResolverSessionC2Ev @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/group/contactresolversession.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/group/contactresolversession.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 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: Project definition file for Contact Resolver clientlib +* +*/ + + +// INCLUDES +#include +#include // For the MW_LAYER_SYSTEMINCLUDE + +TARGET locnotificationclient.dll +TARGETTYPE DLL +UID 0x1000008d 0xEF2227BD + +CAPABILITY All -Tcb + +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE contactresolversession.cpp + + + +// System Include +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE . +USERINCLUDE ../inc +USERINCLUDE ../../inc + +LIBRARY euser.lib +LIBRARY eiksrv.lib +LIBRARY eposprvtyp.lib +LIBRARY estor.lib bafl.lib +LIBRARY flogger.lib + +EPOCALLOWDLLDATA diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/inc/contactresolversession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/inc/contactresolversession.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2010 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: RContactResolverSession + * This class provides the client-side interface to the server session + */ +#ifndef CONTACTRESOLVERSESSION_H +#define CONTACTRESOLVERSESSION_H + +#include + +class CPosRequestor; + +class RContactResolverSession : public RSessionBase + { +public: + // Constructors and destructors + + /** + * Default constructor. + * Constructs the object. + */ + IMPORT_C RContactResolverSession(); + +public: + // New functions + + /** + * Connect. + * Connects to the server and create a session. + * @return Error code. + */ + IMPORT_C TInt Connect(); + + /** + * Resolve the requestors. + * @param[IN,OUT] aRequestors Array of Requestors + */ + IMPORT_C void ResolveRequestorsL( + RPointerArray& aRequestors); + + /** + * closes the session. + */ + IMPORT_C void Close(); + + /** + * Starts the server process if not already started. + */ + static TInt StartServer(); + + /** + * creates the server process. + */ + static TInt CreateServerProcess(); + +private: + /** + * Version. + * Gets the version number. + * @return The version. + */ + TVersion Version() const; + + }; + +#endif //CONTACTRESOLVERSESSION_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/src/contactresolversession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/contactresolversession/src/contactresolversession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2010 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: client-side interface implementation for server session. + * + */ + +#include "contactresolversession.h" +#include "locprivacyinternal.h" +#include "locprivacycommon.h" + +#include +#include +#include +#include +#include + + +TInt KDefaultMessageSlots = 255; +const TUid KServerUid3 = + { + 0x101f7a86 + }; +_LIT(KServerFilename, "locnotificationserver.exe"); + +// ----------------------------------------------------------------------------- +// RContactResolverSession::RContactResolverSession() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C RContactResolverSession::RContactResolverSession() : + RSessionBase() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// RContactResolverSession::ResolveRequestorsL() +// Issues a request for the time to the server. +// ----------------------------------------------------------------------------- +// +EXPORT_C void RContactResolverSession::ResolveRequestorsL(RPointerArray< + CPosRequestor>& aRequestors) + { + + RPosRequestorStack* requestors = new (ELeave) RPosRequestorStack; + CleanupStack::PushL(requestors); + + //------------------------------------------------------------- + // getting size from the server in first IPC + CBufFlat* buffer = CBufFlat::NewL(512); + CleanupStack::PushL(buffer); + RBufWriteStream writeStream; + writeStream.Open(*buffer); + CleanupClosePushL(writeStream); + + TInt count = aRequestors.Count(); + for (TInt i = 0; i < count; ++i) + { + requestors->Append(aRequestors[i]); + } + requestors->ExternalizeL(writeStream); + writeStream.CommitL(); + + TPtr8 ptr = buffer->Ptr(0); + + TIpcArgs args; + TInt size = 0; + TPckg sizePkg(size); + args.Set(0, &sizePkg); + args.Set(1, &ptr); + + TInt in = SendReceive(ELocPrivacyGetSize, args); + + CleanupStack::PopAndDestroy(&writeStream); + CleanupStack::PopAndDestroy(buffer); + CleanupStack::PopAndDestroy(requestors); + //------------------------------------------------------------- + //------------------------------------------------------------- + // allocating the buffer of the size obtained in the first IPC + // and getting the data from the server in the 2nd IPC + + // This call waits for the server to complete the request before + // proceeding. When it returns, the new time will be in aTime. + + + CBufFlat* buffer1 = CBufFlat::NewL(512); + CleanupStack::PushL(buffer1); + buffer1->ResizeL(size); + + TPtr8 bufPtr = buffer1->Ptr(0); + TIpcArgs ipcArgs; + ipcArgs.Set(0, &bufPtr); + in = SendReceive(ELocPrivacyResolve, ipcArgs); + + //------------------------------------------------------------- + + RBufReadStream readStream; + readStream.Open(*buffer1); + CleanupClosePushL(readStream); + RPosRequestorStack* requestors2 = new (ELeave) RPosRequestorStack; + CleanupStack::PushL(requestors2); + requestors2->InternalizeL(readStream); + TInt cnt = requestors2->Count(); + aRequestors.Reset(); + for (TInt i = 0; i < cnt; ++i) + { + CPosRequestor * entry = requestors2->operator [](i); + aRequestors.Append(entry); + } + CleanupStack::PopAndDestroy(requestors2); + CleanupStack::PopAndDestroy(&readStream); + CleanupStack::PopAndDestroy(buffer1); + + } + +// ----------------------------------------------------------------------------- +// RContactResolverSession::Connect() +// Connects to the server and create a session. +// ----------------------------------------------------------------------------- + +EXPORT_C TInt RContactResolverSession::Connect() + { + TInt error = StartServer(); + + if (KErrNone == error) + { + error = CreateSession(KLocPrivacyServerName, Version(), + KDefaultMessageSlots); + } + return error; + } + +// ----------------------------------------------------------------------------- +// StartServer() +// Starts the server if it is not already running +// ----------------------------------------------------------------------------- +// +TInt RContactResolverSession::StartServer() + { + TInt result; + + TFindServer findServer(KLocPrivacyServerName); + TFullName name; + + result = findServer.Next(name); + if (result == KErrNone) + { + // Server already running + return KErrNone; + } + + result = CreateServerProcess(); + if (result != KErrNone) + { + return result; + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CreateServerProcess() +// Creates a server process +// ----------------------------------------------------------------------------- +// +TInt RContactResolverSession::CreateServerProcess() + { + TInt result; + + const TUidType serverUid(KNullUid, KNullUid, KServerUid3); + + RProcess server; + TRequestStatus status; + result = server.Create(KServerFilename, KNullDesC, serverUid); + + if (result != KErrNone) + { + server.Close(); + return KErrNotFound; + } + + server.Rendezvous(status); + + if (status != KRequestPending) + { + User::WaitForRequest(status); + server.Kill(KErrNone); + server.Close(); + return (status.Int()); + } + else + { + server.Resume(); + } + + User::WaitForRequest(status); + server.Close(); + + if (status != KErrNone) + { + return (status.Int()); + } + + return KErrNone; + } + +TVersion RContactResolverSession::Version() const + { + return TVersion(KLocPrivacyServerMajorVersionNumber, + KLocPrivacyServerMinorVersionNumber, + KLocPrivacyServerBuildVersionNumber); + } + +EXPORT_C void RContactResolverSession::Close() + { + RSessionBase::Close(); + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/inc/contactresolversession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/inc/contactresolversession.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2010 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: RContactResolverSession + * This class provides the client-side interface to the server session + */ +#ifndef CONTACTRESOLVERSESSION_H +#define CONTACTRESOLVERSESSION_H + +#include + +class CPosRequestor; + +class RContactResolverSession : public RSessionBase + { +public: + // Constructors and destructors + + /** + * Default constructor. + * Constructs the object. + */ + IMPORT_C RContactResolverSession(); + +public: + // New functions + + /** + * Connect. + * Connects to the server and create a session. + * @return Error code. + */ + IMPORT_C TInt Connect(); + + /** + * Resolve the requestors. + * @param[IN,OUT] aRequestors Array of Requestors + */ + IMPORT_C void ResolveRequestorsL( + RPointerArray& aRequestors); + + /** + * closes the session. + */ + IMPORT_C void Close(); + + /** + * Starts the server process if not already started. + */ + static TInt StartServer(); + + /** + * creates the server process. + */ + static TInt CreateServerProcess(); + +private: + /** + * Version. + * Gets the version number. + * @return The version. + */ + TVersion Version() const; + + }; + +#endif //CONTACTRESOLVERSESSION_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/inc/locprivacycommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/inc/locprivacycommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 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: Server name and version definition. +* +*/ + +#ifndef PRIVACYCOMMON_H +#define PRIVACYCOMMON_H + +#include + +// CONSTANTS +_LIT(KLocPrivacyServerName, "!locnotificationserver"); + +const TUint KLocPrivacyServerMajorVersionNumber = 0; +const TUint KLocPrivacyServerMinorVersionNumber = 0; +const TUint KLocPrivacyServerBuildVersionNumber = 0; + +#endif // PRIVACYCOMMON_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/inc/locprivacyinternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/inc/locprivacyinternal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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: IPC enumerations and constant definition for server. +* +*/ + +#ifndef PRIVACYINTERNAL_H +#define PRIVACYINTERNAL_H + + + +//CONSTANTS + +// IPC enumerations +enum TPosPrivacyClientServer + { + // To get the size of modified buffer containing resolved requestors. + ELocPrivacyGetSize = 0, + // To get the resolved requestors. + ELocPrivacyResolve + }; + +// Buffer granularity +const TInt KPosBufFlatExpandSize = 100; + +#endif // PRIVACYINTERNAL_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/inc/locutilsdebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/inc/locutilsdebug.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2010 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: LocUtilsDebug contains debug macros. +* +*/ + + +#ifndef LOCUTILSDEBUG_H +#define LOCUTILSDEBUG_H + +// INCLUDES +#include "locutilsdebugconfig.hrh" + +#include + + +// MACROS +#define DEBUG(TEXT) { \ + _LIT( KText, #TEXT ); \ + Debug(KText) \ + } + +#define LOC(TEXT, ARG1) { \ + _LIT( KText, #TEXT ); \ + Debug( KText, (ARG1) ); \ + } + +#define LOC2(TEXT, ARG1, ARG2) { \ + _LIT( KText, #TEXT ); \ + Debug( KText,(ARG1), (ARG2) ); \ + } + +#define LOC3(TEXT, ARG1, ARG2, ARG3) { \ + _LIT( KText, #TEXT ); \ + Debug( KText, (ARG1), (ARG2), (ARG3) ); \ + } + +IMPORT_C void Debug( TRefByValue aText, ...); + +/** +* By using component specific debug macros unnecessary +* debug prints can be avoided. +* Also component specific debugging is possible by compiling +* only certain components when LOC_ENABLE_DEBUG_PRINT is defined. +*/ + +#ifdef LOC_ENABLE_DEBUG_PRINT + +#define LOCUTILSDEBUG(TEXT) DEBUG(TEXT); +#define LOCUTILSDEBUG1(TEXT, ARG1) LOC(TEXT, ARG1); +#define LOCUTILSDEBUG2(TEXT, ARG1, ARG2) LOC2(TEXT, ARG1, ARG2); +#define LOCUTILSDEBUG3(TEXT, ARG1, ARG2, ARG3) LOC3(TEXT, ARG1, ARG2, ARG3); + +#else + +#define LOCUTILSDEBUG(TEXT) ; +#define LOCUTILSDEBUG1(TEXT, ARG1) ; +#define LOCUTILSDEBUG2(TEXT, ARG1, ARG2) ; +#define LOCUTILSDEBUG3(TEXT, ARG1, ARG2, ARG3) ; + +#endif + +#endif // LOCUTILSDEBUG_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/inc/locutilsdebugconfig.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/inc/locutilsdebugconfig.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2010 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 the main build-time configuration file of Loc Utils +* +*/ + + +#ifndef LOCUTILSDEBUGCONFIG_HRH_ +#define LOCUTILSDEBUGCONFIG_HRH_ + +// INCLUDES + +// Flags for development: + + +// Defined LOC_ENABLE_DEBUG_PRINT flag enables debug prints to a file. + +//#define LOC_ENABLE_DEBUG_PRINT + +#endif // LOCUTILSDEBUGCONFIG_HRH_ + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/install/privacydialogs_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/install/privacydialogs_stub.pkg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,40 @@ +; +; Copyright (c) 2010 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: Stub Package file for Privacy dialogs +; +; +; Languages +&EN + +; Header +#{"privacydialog"}, (0x101f7a86), 1, 0, 0, TYPE = SA + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Hb custom device dialog plugin +"" - "z:\sys\bin\posverificationdialogplugin.dll" +"" - "z:\resource\plugins\devicedialogs\posverificationdialogplugin.qtplugin" + +; Qt engine dll +"" - "z:\sys\bin\locnotificationengine.dll" + +;Symbian components +"" - "z:\sys\bin\contactresolversession.dll" +"" - "z:\sys\bin\locprivacysrv.exe" +"" - "z:\sys\bin\locutils.dll" +"" - "z:\sys\bin\locverifierdlg.dll" diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/install/privacydialogs_stub.sis Binary file locationsystemui/locationsysui/privacyverifiernotifierui/install/privacydialogs_stub.sis has changed diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/bwins/locnotificationengineu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/bwins/locnotificationengineu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,4 @@ +EXPORTS + ?ResolveRequestorsL@CLocRequestorUtilsResolver@@QAEXAAV?$RPointerArray@VCPosRequestor@@@@@Z @ 1 NONAME ; void CLocRequestorUtilsResolver::ResolveRequestorsL(class RPointerArray &) + ?NewL@CLocRequestorUtilsResolver@@SAPAV1@XZ @ 2 NONAME ; class CLocRequestorUtilsResolver * CLocRequestorUtilsResolver::NewL(void) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/eabi/locnotificationengineu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/eabi/locnotificationengineu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,4 @@ +EXPORTS + _ZN26CLocRequestorUtilsResolver18ResolveRequestorsLER13RPointerArrayI13CPosRequestorE @ 1 NONAME + _ZN26CLocRequestorUtilsResolver4NewLEv @ 2 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/inc/locrequestorutilsresolver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/inc/locrequestorutilsresolver.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2010 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: Requestor utilities, supports Resolving of Requestors. +* +*/ + + +#ifndef CLOCREQUESTORUTILSRESOLVER_H +#define CLOCREQUESTORUTILSRESOLVER_H + +// INCLUDES +#include + +//FORWARD DECLARATION +class CPosRequestor; +class QLocNotificationEngine; + +// CLASS DECLARATION + +/** +* +* +* +*/ +class CLocRequestorUtilsResolver : public CBase + { + public: // Constructors and destructor + + /** + * Symbian OS constructor + * @param None + * @return new object + */ + IMPORT_C static CLocRequestorUtilsResolver* NewL(); + + /** + * Destructor. + */ + ~CLocRequestorUtilsResolver(); + + public: // Implement base class virtual methods + /** + * Resolve the requestors. + * @param[IN,OUT] aRequestors Array of Requestors,ownership is transferred to caller + + */ + IMPORT_C void ResolveRequestorsL( + RPointerArray& aRequestors ); + + + private: // Constructors + /** + * C++ default constructor. + */ + CLocRequestorUtilsResolver(); + + /** + * The Symbian 2nd Phase Constructor is always Private + */ + void ConstructL(); + + + + private: // member data + + // Qt implementation class for notification engine.Ownership remains with object + QLocNotificationEngine* iEngine; + }; + +#endif // CLOCREQUESTORUTILSRESOLVER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/inc/qlocnotificationengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/inc/qlocnotificationengine.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings engine class. +* +*/ + +#ifndef QLOCNOTIFICATIONENGINE_H +#define QLOCNOTIFICATIONENGINE_H + +#include + +class QContactManager; + +/** + * This class is used as a container for Pos requestor data which needs to be resolved. + * After resolution the result is returned in the same class. QPosRequestorData is used + * so as to avoid exposing CPosRequestorData to + */ + +class QPosRequestorData + { + +public : + enum IdFormat + { + /** The requestor ID format is unknown. */ + EIdFormatUnknown, + /** The requestor is identified by name. */ + EIdFormatGenericName, + /** The requestor is identified by phone number. */ + EIdFormatPhoneNumber, + /** The requestor is identified by URL. */ + EIdFormatUrl, + /** The requestor is identified by email address. */ + EIdFormatEmail, + /** The requestor is identified by the URL of the SIP session. */ + EIdFormatSIPUrl, + /** The requestor is identified by the IMS public identity. */ + EIdFormatIMSPublicIdentity, + /** The requestor is identified by Mobile identification Number. */ + EIdFormatMIN, + /** The requestor is identified by Mobile Directory Number. */ + EIdFormatMDN + }; +public: + /* + * Default construtor + */ + QPosRequestorData(); + + /* + * Destructor for QPosRequestorData + */ + ~QPosRequestorData(); + +public: + /* + * Setter method for QPosRequestorData + * @param idFormat - Field in which string needs to be searched for resolution + * @param idString - String which needs to be resolved + */ + void setPosRequestorData(const QPosRequestorData::IdFormat& idFormat, const QString& idString); + + /* + * Getter method for QPosRequestorData + * @param idFormat - Field in which string needs to be searched for resolution + * @param idString - String which needs to be resolved \ after resolution the result is stored in this + */ + void getPosRequestorData(QPosRequestorData::IdFormat& idFormat, QString& idString) const; + +private: + + // contains string to be resolve - string after resolution is stored in this + QString mIdString; + //idformat of the string to be searched - indicates in what field the string needs to be searched in + IdFormat mIdFormat; + }; + +/** + * QLocNotificationEngine class provides a Qt interface to perform operations such as + * requestor resolution, activating indicators for missed location notfications etc. + * + */ + +class QLocNotificationEngine + { + +public: + /** + * Default constructor + * This throws an error if construction fails. + */ + QLocNotificationEngine(); + + /** + * Destructor + */ + ~QLocNotificationEngine(); + +public: + /* + * Resolves requestor from phoebook + * @param[IN,OUT] posRequestorData resolved requestors + */ + void processRequestors(QPosRequestorData& posRequestorData); + +private: // data member + // Contact manager instance + QtMobility::QContactManager* mContactManager; + + }; + +#endif // QLOCNOTIFICATIONENGINE_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/locnotificationengine.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/locnotificationengine.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,43 @@ +# 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: LocNotificationEngine pro file +TEMPLATE = lib +TARGET = locnotificationengine +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb +CONFIG += mobility +MOBILITY = contacts + +# Uncomment following line to disable logging +# DEFINES += QT_NO_DEBUG_OUTPUT +MOC_DIR = moc +OBJECTS_DIR = obj + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +LIBS += -leposprvtyp + +# Input +SOURCES += src/locrequestorutilsresolver.cpp \ + src/qlocnotificationengine.cpp +HEADERS += inc/locrequestorutilsresolver.h \ + inc/qlocnotificationengine.h +symbian: { + TARGET.EPOCALLOWDLLDATA = 1 + DEFINES += BUILD_POSSETTINGS + DEFINES += PLUGINUID3=0x2002E705 + TARGET.UID3 = 0x2002E705 +} + +TARGET.CAPABILITY = All \ + -TCB diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/src/locrequestorutilsresolver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/src/locrequestorutilsresolver.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2010 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: Implementation of location notification engine class. +* +*/ + + +// INCLUDE FILES + + +#include "locrequestorutilsresolver.h" +#include "qlocnotificationengine.h" + +#include +#include + + +#include +#include +#include + + + + +// ============= CLocRequestorUtilsResolver MEMBER FUNCTIONS ================= + +// --------------------------------------------------------------------------- +// CLocRequestorUtilsResolver::NewL +// 2 Phase Constructor +// --------------------------------------------------------------------------- +// +EXPORT_C CLocRequestorUtilsResolver* CLocRequestorUtilsResolver::NewL() + { + CLocRequestorUtilsResolver* self = + new(ELeave) CLocRequestorUtilsResolver(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// destructor +// --------------------------------------------------------------------------- +// +CLocRequestorUtilsResolver::~CLocRequestorUtilsResolver() + { + delete iEngine; + iEngine = NULL; + } + +// --------------------------------------------------------------------------- +// The method resolves requestors by delegating requests to QPosRequestorData +// --------------------------------------------------------------------------- +// +EXPORT_C void CLocRequestorUtilsResolver::ResolveRequestorsL( + RPointerArray& aRequestors ) + { + //resolve requestors one by one by extracting the idFormat and idString + //from the requestor array + TInt count = aRequestors.Count(); + for(TInt iter = 0; iter < count; ++iter) + { + CPosRequestor::TRequestorIdFormat idFormat = aRequestors[iter]->RequestorIdFormat(); + QPosRequestorData::IdFormat qposidformat; + switch(idFormat) + { + + case CPosRequestor::EIdFormatGenericName: + qposidformat=QPosRequestorData::EIdFormatGenericName; + break; + + case CPosRequestor::EIdFormatPhoneNumber: + qposidformat=QPosRequestorData::EIdFormatPhoneNumber; + break; + case CPosRequestor::EIdFormatUrl: + qposidformat=QPosRequestorData::EIdFormatUrl; + break; + case CPosRequestor::EIdFormatEmail: + qposidformat=QPosRequestorData::EIdFormatEmail; + break; + case CPosRequestor::EIdFormatSIPUrl: + qposidformat=QPosRequestorData::EIdFormatSIPUrl; + break; + case CPosRequestor::EIdFormatIMSPublicIdentity: + qposidformat=QPosRequestorData::EIdFormatIMSPublicIdentity; + break; + case CPosRequestor::EIdFormatMIN: + qposidformat=QPosRequestorData::EIdFormatMIN; + break; + case CPosRequestor::EIdFormatMDN: + qposidformat=QPosRequestorData::EIdFormatMDN; + break; + case CPosRequestor::EIdFormatUnknown: + default: + qposidformat=QPosRequestorData::EIdFormatUnknown; + break; + } + //right now the phonebook has fields corresponding to email,phone number, URL only + //other cases are not supported by the phonebook + if(qposidformat == QPosRequestorData::EIdFormatEmail || + qposidformat == QPosRequestorData::EIdFormatPhoneNumber || + qposidformat == QPosRequestorData::EIdFormatUrl ) + { + //convert TDes to QString + QString qReqString((QChar*)aRequestors[iter]->RequestorIdString().Ptr(),aRequestors[iter]->RequestorIdString().Length()); + + QPosRequestorData posRequestor; + posRequestor.setPosRequestorData(qposidformat,qReqString); + + iEngine->processRequestors(posRequestor); + + QString retString; + posRequestor.getPosRequestorData(qposidformat,retString); + + //convert QString to TDes + TPtrC16 textPtr(reinterpret_cast(retString.utf16())); + + aRequestors[iter]->SetRequestorIdL(idFormat,textPtr); + } + } + } + + +// --------------------------------------------------------------------------- +// CLocRequestorUtilsResolver::CLocRequestorUtilsResolver +// C++ default constructor can NOT contain any code, that +// might leave. +// --------------------------------------------------------------------------- +// +CLocRequestorUtilsResolver::CLocRequestorUtilsResolver() + { + // Nothing to do. + } + +// --------------------------------------------------------------------------- +// CLocRequestorUtilsResolver::ConstructL +// Symbian Second Phase COnstructor +// --------------------------------------------------------------------------- +// +void CLocRequestorUtilsResolver::ConstructL() + { + try + { + iEngine = new QLocNotificationEngine(); + } + catch( int error ) + { + User::Leave(error); + } + } + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/src/qlocnotificationengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/src/qlocnotificationengine.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2010 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: Implementation of positioning settings engine class. +* +*/ + +#include "qlocnotificationengine.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +//--------------------------------------------------------------------- +// QLocNotificationEngine::QLocNotificationEngine() +// (other items were commented in a header). +//--------------------------------------------------------------------- +QLocNotificationEngine::QLocNotificationEngine() + { + //"symbian" is the string used to load the contact manager corresponding to the phonebook database + mContactManager = new QtMobility::QContactManager("symbian"); + } + +//------QLocNotificationEngine----------------------------------------- +// QLocNotificationEngine::~QLocNotificationEngine() +// (other items were commented in a header). +//--------------------------------------------------------------------- +QLocNotificationEngine::~QLocNotificationEngine() + { + delete mContactManager; + } + +//------QLocNotificationEngine----------------------------------------- +// QLocNotificationEngine::processRequestors +// Used to resolve requestors +// (other items were commented in a header). +//--------------------------------------------------------------------- +void QLocNotificationEngine::processRequestors(QPosRequestorData& posRequestorData) + { + + QtMobility::QContactDetailFilter filter; + + QString idString; + QPosRequestorData::IdFormat idFormat = QPosRequestorData::EIdFormatUnknown; + posRequestorData.getPosRequestorData(idFormat,idString); + + switch(idFormat) // set definition name based on the idformat to be searched for + { + case QPosRequestorData::EIdFormatPhoneNumber: + { + filter.setDetailDefinitionName(QtMobility::QContactPhoneNumber::DefinitionName, QtMobility::QContactPhoneNumber::FieldNumber); + } + break; + + case QPosRequestorData::EIdFormatEmail: + { + filter.setDetailDefinitionName(QtMobility::QContactEmailAddress::DefinitionName, QtMobility::QContactEmailAddress::FieldEmailAddress); + } + break; + case QPosRequestorData::EIdFormatUrl: + { + filter.setDetailDefinitionName(QtMobility::QContactUrl::DefinitionName,QtMobility::QContactUrl::ContextHome); + } + break; + + //other cases are not supported by the phonebook + default: //this case wont arise as other values will already have been filtered out + + break; + } + filter.setMatchFlags(QtMobility::QContactFilter::MatchExactly); + filter.setValue(idString); + + QList matchingContacts = mContactManager->contactIds(filter); + + if (matchingContacts.size() > 0) //if any contacts were found + { + + QtMobility::QContact match = mContactManager->contact(matchingContacts.at(0)); //return the first contact among the ones found + + // QtMobility::QContactDisplayLabel cdl = match.detail(QtMobility::QContactDisplayLabel::DefinitionName); + QString labelDetail = match.displayLabel(); + posRequestorData.setPosRequestorData(idFormat,labelDetail); //set back result + } + else + { + // if no contacts were found + + if( QPosRequestorData::EIdFormatPhoneNumber == idFormat ) + { + // Group the phone number according to current system locale + /* + QString isStringPh = HbNumberGrouping::formatPhoneNumber(idString,QLocale::system().country()); + posRequestorData.setPosRequestorData(idFormat,isStringPh); //set back result + */ + posRequestorData.setPosRequestorData(idFormat,idString); //set back result + } + } + + } + +//--------------------------------------------------------------------- +// QPosRequestorData::QPosRequestorData() +// Constructor for QPosRequestorData +// (other items were commented in a header). +//--------------------------------------------------------------------- +QPosRequestorData::QPosRequestorData() + { + + } + +//--------------------------------------------------------------------- +// QPosRequestorData::~QPosRequestorData() +// Destructor for QPosRequestorData +// (other items were commented in a header). +//--------------------------------------------------------------------- +QPosRequestorData::~QPosRequestorData() + { + + } + +//--------------------------------------------------------------------- +// QPosRequestorData::setPosRequestorData() +// Settermethod for QPosRequestorData +// (other items were commented in a header). +//--------------------------------------------------------------------- +void QPosRequestorData::setPosRequestorData(const QPosRequestorData::IdFormat& idFormat, const QString& idString) + { + mIdFormat = idFormat; + mIdString = idString; + } + +//--------------------------------------------------------------------- +// QPosRequestorData::getPosRequestorData() +// Gettermethod for QPosRequestorData +// (other items were commented in a header). +//--------------------------------------------------------------------- +void QPosRequestorData::getPosRequestorData(QPosRequestorData::IdFormat& idFormat, QString& idString) const + { + idFormat = mIdFormat; + idString = mIdString; + } + +// End of file. diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/group/locprivacyserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/group/locprivacyserver.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2010 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: Project definition file for server +* +*/ + +#include + +TARGET locnotificationserver.exe +EPOCSTACKSIZE 0x5000 +TARGETTYPE exe +UID 0x00000000 0x101f7a86 + +VENDORID VID_DEFAULT +CAPABILITY CAP_SERVER + +SOURCEPATH ../src +SOURCE locprivacyserverstartup.cpp +SOURCE locprivacyserver.cpp +SOURCE locprivacyserversession.cpp + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../locnotificationengine/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY bafl.lib +LIBRARY euser.lib +LIBRARY eposprvtyp.lib +LIBRARY eposutils.lib +LIBRARY efsrv.lib +LIBRARY estor.lib +LIBRARY locnotificationengine.lib + +// End of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacycommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacycommon.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 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: Server name and version definition. +* +*/ + +#ifndef PRIVACYCOMMON_H +#define PRIVACYCOMMON_H + +#include + +// CONSTANTS +_LIT(KLocPrivacyServerName, "!locnotificationserver"); + +const TUint KLocPrivacyServerMajorVersionNumber = 0; +const TUint KLocPrivacyServerMinorVersionNumber = 0; +const TUint KLocPrivacyServerBuildVersionNumber = 0; + +#endif // PRIVACYCOMMON_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyinternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyinternal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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: IPC enumerations and constant definition for server. +* +*/ + +#ifndef PRIVACYINTERNAL_H +#define PRIVACYINTERNAL_H + + + +//CONSTANTS + +// IPC enumerations +enum TPosPrivacyClientServer + { + // To get the size of modified buffer containing resolved requestors. + ELocPrivacyGetSize = 0, + // To get the resolved requestors. + ELocPrivacyResolve + }; + +// Buffer granularity +const TInt KPosBufFlatExpandSize = 100; + +#endif // PRIVACYINTERNAL_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserver.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2010 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: server class definition. +* +*/ + +#ifndef CLOCPRIVACYSERVER_H +#define CLOCPRIVACYSERVER_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CLocPrivacyServerSession; + +// CLASS DECLARATION + +/** + * The main server side class. + */ +class CLocPrivacyServer : public CServer2 + { +public: + // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CLocPrivacyServer* NewL(); + + /** + * Destructor. + */ + ~CLocPrivacyServer(); + +private: + + /** + * C++ constructor. + * + * @param aPriority Priority at which to run the server active object. + */ + CLocPrivacyServer( + /* IN */TInt aPriority); + + /** + * EPOC default constructor. + */ + void ConstructL(); + +public: + // New functions + + // Server priority. 950 is standard value. + enum + { + EPriority = 950 + }; + + /** + * Increment number of sessions. + */ + void IncrementSessions(); + + /** + * Decrement number of sessions. + * + * @param aSession Pointer to session that is calling + * DecrementSessions().It will be used in future. + */ + void DecrementSessions( + /* IN */CLocPrivacyServerSession* /*aSession */); + +public: + // Functions from base classes + + /** + * From CServer. + * + * @param aVersion the server version. + * @param aMessage The connect message from the client. + * @return a new session + */ + CSession2* NewSessionL( + /* IN */const TVersion& aVersion, + /* IN */const RMessage2& aMessage) const; + + /** + * From CActive. + * + * @param aError the error code of the server leave. + * @return always KErrNone. + */ + TInt RunError( + /* IN */TInt aError); + +private: + + // By default, prohibit copy constructor + CLocPrivacyServer(const CLocPrivacyServer&); + // Prohibit assigment operator + CLocPrivacyServer& operator=(const CLocPrivacyServer&); + +private: + // Data + TInt iNumSessions; + }; + +#endif // CLOCPRIVACYSERVER_H +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserverdebugpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserverdebugpanic.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2010 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: Panic code definitions for server. +* +*/ + +#ifndef LOCPRIVACYSERVERDEBUGPANIC_H +#define LOCPRIVACYSERVERDEBUGPANIC_H + +#include + +_LIT(KLocPrivSrvDebugPanicCategory, "Loc Priv debug"); + +enum TLocPrivSrvDebugPanic + { + // Unknown request recieved from client. + ELocPrivSrvPanicUnknownActivity = 0 + }; + +#endif // LOCPRIVACYSERVERDEBUGPANIC_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserversession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserversession.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2010 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: Server session class definition. +* +*/ + + +#ifndef CLOCPRIVACYSERVERSESSION_H +#define CLOCPRIVACYSERVERSESSION_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CPosPrivacyServer; +//class CPosPrivManager; +class RPosRequestorStack; + +// CLASS DECLARATION + +/** + * The EPos privacy server session class. + * + */ +class CLocPrivacyServerSession : public CSession2 + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aServer Reference to the server Active Object + * @return Pointer to a new instance of CPosPrivacyServerSession + */ + static CLocPrivacyServerSession* NewL( + /* IN */ CLocPrivacyServer& aServer + ); + + /** + * C++ destructor + */ + ~CLocPrivacyServerSession(); + + private: // Private Constructing + + /** + * C++ private constructor + */ + CLocPrivacyServerSession(); + + /** + * EPOC default constructor. + * @param aServer Reference to the server Active Object + */ + void ConstructL( + /* IN */ CLocPrivacyServer& aServer + ); + + public: // Functions from base classes + + /** + * From CSession2. + * This function services all requests from clients. + * + * @param aMessage the message that should be serviced + */ + void ServiceL( + /* IN */ const RMessage2& aMessage + ); + + private: // New functions + + /** + * Closes the session. + */ + void CloseSession(); + + // Contains the actual ServiceL code. + // + void DispatchL(const RMessage2& aMessage); + + + + private: + + // By default, prohibit copy constructor + CLocPrivacyServerSession( const CLocPrivacyServerSession& ); + // Prohibit assigment operator + CLocPrivacyServerSession& operator= ( const CLocPrivacyServerSession& ); + + private: // Data + // Buffer for hoding resolved requestors + CBufFlat* iBufFlat; + }; + +#endif // CLOCPRIVACYSERVERSESSION_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserverstartup.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/inc/locprivacyserverstartup.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 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: Class definition for server startup . +* +*/ + +#ifndef LOCPRIVACYSERVERSTARTUP_H +#define LOCPRIVACYSERVERSTARTUP_H + +// INCLUDES +#include + +// CLASS DECLARATION + +/** +* This class contains static functions which handles server startup. +*/ +class LocPrivacyServerStartup + { + + public: // New functions + + /** + * Server thread entry point + * + * @return error code + */ + static TInt StartServer(); + + private: // New functions + + static void StartServerL(); + + }; + +#endif // LOCPRIVACYSERVERSTARTUP_H + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserver.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2010 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: server class implementation. +* +*/ + +// INCLUDE FILES + +#include "locprivacyserver.h" +#include "locprivacycommon.h" +#include "locprivacyserversession.h" +#include "locprivacyserverdebugpanic.h" + + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CLocPrivacyServer::CLocPrivacyServer(TInt aPriority) + : CServer2(aPriority), + iNumSessions(0) + { + // This does not do anything. + __DECLARE_NAME(_S("CLocPrivacyServer")); + } + +// EPOC default constructor can leave. +void CLocPrivacyServer::ConstructL() + { + User::LeaveIfError(Start(KLocPrivacyServerName)); + } + +// Two-phased constructor +CLocPrivacyServer* CLocPrivacyServer::NewL() + { + CLocPrivacyServer* self = new (ELeave) CLocPrivacyServer(EPriority); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Destructor +CLocPrivacyServer::~CLocPrivacyServer() + { + } + +// --------------------------------------------------------- +// CLocPrivacyServer::IncrementSessions +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLocPrivacyServer::IncrementSessions() + { + iNumSessions++; + } + +// --------------------------------------------------------- +// CLocPrivacyServer::DecrementSessions +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLocPrivacyServer::DecrementSessions( + CLocPrivacyServerSession* /*aSession*/) + { + iNumSessions--; + if (iNumSessions == 0) + { + // Shutdown the server by shutting down the active scheduler. + CActiveScheduler::Stop(); + } + } + +// --------------------------------------------------------- +// CLocPrivacyServer::NewSessionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +CSession2* CLocPrivacyServer::NewSessionL( + const TVersion& /*aVersion*/, + const RMessage2& /*aMessage*/) const + { + + // Make new session + CLocPrivacyServerSession* newSession = CLocPrivacyServerSession::NewL( + const_cast(*this)); + + return newSession; + } + +// --------------------------------------------------------- +// CLocPrivacyServer::RunError +// This method is called by the active scheduler whenever an +// untrapped leave occurs in the server active object. +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CLocPrivacyServer::RunError(TInt aError) + { + Message().Complete(aError); + ReStart(); + return KErrNone; + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserversession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserversession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2010 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: Server session class implementation. +* +*/ + +// INCLUDE FILES +#include +#include +#include "locprivacyinternal.h" +#include "locprivacyserver.h" +#include "locprivacyserversession.h" +#include "locprivacyserverdebugpanic.h" +#include "locrequestorutilsresolver.h" +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// Two-phased constructor +CLocPrivacyServerSession* CLocPrivacyServerSession::NewL( + CLocPrivacyServer& aServer) + { + CLocPrivacyServerSession* self = new (ELeave) CLocPrivacyServerSession(); + CleanupStack::PushL(self); + self->ConstructL(aServer); + CleanupStack::Pop(); + return self; + } + +// Destructor +CLocPrivacyServerSession::~CLocPrivacyServerSession() + { + CloseSession(); + delete iBufFlat; + iBufFlat = NULL; + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CLocPrivacyServerSession::CLocPrivacyServerSession() : + CSession2(), iBufFlat(NULL) + { + // Doesn't really do anything according to the header file (e32def.h, + // lines 139 and 184) and the documentation doesn't mention it. + __DECLARE_NAME(_S("CLocPrivacyServerSession")); + } + +// EPOC default constructor +void CLocPrivacyServerSession::ConstructL(CLocPrivacyServer& aServer) + { + aServer.IncrementSessions(); + iBufFlat = CBufFlat::NewL(KPosBufFlatExpandSize); + } + +// --------------------------------------------------------- +// CLocPrivacyServerSession::ServiceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLocPrivacyServerSession::ServiceL(const RMessage2& aMessage) + { + TRAPD(err, DispatchL(aMessage)); + + aMessage.Complete(err); + + } + +// --------------------------------------------------------- +// CLocPrivacyServerSession::CloseSession +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLocPrivacyServerSession::CloseSession() + { + CLocPrivacyServer + * server = + static_cast (const_cast (Server())); + server->DecrementSessions(this); + } + +// --------------------------------------------------------- +// CLocPrivacyServerSession::DispatchL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CLocPrivacyServerSession::DispatchL(const RMessage2& aMessage) + { + switch ( aMessage.Function() ) + { + case ELocPrivacyGetSize: + + { + TInt desLength=0; + desLength = aMessage.GetDesLength( 1 ); + + CBufFlat* bufFlat1 = CBufFlat::NewL(desLength); + CleanupStack::PushL(bufFlat1); + bufFlat1->ResizeL(desLength); + + TPtr8 ptr(bufFlat1->Ptr(0)); + // Copy content to local buffer + aMessage.ReadL(1, ptr); + + RBufReadStream readStream(*bufFlat1); + CleanupClosePushL(readStream); + + RPosRequestorStack* requestors1 = new (ELeave) RPosRequestorStack; + CleanupStack::PushL(requestors1); + requestors1->InternalizeL(readStream); + + CLocRequestorUtilsResolver* res = + CLocRequestorUtilsResolver::NewL(); + CleanupStack::PushL(res); + + res->ResolveRequestorsL(*requestors1); + + + // use data member buffer and externalize + + RBufWriteStream writeStream; + // Reset the buffer + iBufFlat->Reset(); + writeStream.Open(*iBufFlat); + CleanupClosePushL(writeStream); + + requestors1->ExternalizeL(writeStream); + writeStream.CommitL(); + + // Find the new size + + TInt newsize = iBufFlat->Size(); + + CleanupStack::PopAndDestroy(&writeStream); + CleanupStack::PopAndDestroy(res); + CleanupStack::PopAndDestroy(requestors1); + CleanupStack::PopAndDestroy(&readStream); + CleanupStack::PopAndDestroy(bufFlat1); + + // write back new size + TPtr8 ptr1(reinterpret_cast (&newsize), + sizeof(newsize), sizeof(newsize)); + + aMessage.WriteL(0, ptr1); + } + break; + + case ELocPrivacyResolve: + { + TPtr8 ptr2 = iBufFlat->Ptr(0); + aMessage.WriteL(0, ptr2); + } + break; + + default: + aMessage.Panic(KLocPrivSrvDebugPanicCategory, + ELocPrivSrvPanicUnknownActivity); + break; + } + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserverstartup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locprivacyserver/src/locprivacyserverstartup.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2010 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: Implementation for server startup . +* +*/ + +// INCLUDE FILES +#include "locprivacyserverstartup.h" +#include "locprivacyserver.h" +#include "locprivacycommon.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// LocPrivacyServerStartup::StartServer +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt LocPrivacyServerStartup::StartServer() + { + __UHEAP_MARK; + + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + + TInt ret = KErrNoMemory; + + if (cleanupStack) + { + TRAP(ret, StartServerL()); + delete cleanupStack; + } + + __UHEAP_MARKEND; + + return ret; + } + +// ----------------------------------------------------------------------------- +// LocPrivacyServerStartup::StartServerL +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void LocPrivacyServerStartup::StartServerL() + { + // Rename thread to aid debugging + User::LeaveIfError(User::RenameThread(KLocPrivacyServerName)); + + // start scheduler and server + CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + + CLocPrivacyServer* server = CLocPrivacyServer::NewL(); + CleanupStack::PushL(server); + + CleanupStack::Pop(2, scheduler); // server + + RProcess::Rendezvous(KErrNone); + + CActiveScheduler::Start(); + + delete server; + delete scheduler; + } + +// ----------------------------------------------------------------------------- +// E32Main +// Server process entry-point +// Recover the startup parameters and run the server +// ----------------------------------------------------------------------------- +// +TInt E32Main() + { + return LocPrivacyServerStartup::StartServer(); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/bwins/locutils_32u.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/bwins/locutils_32u.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?Debug@@YAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 1 NONAME ; void Debug(class TRefByValue, ...) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/eabi/locutils_32u.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/eabi/locutils_32u.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z5Debug11TRefByValueIK7TDesC16Ez @ 1 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/group/locutils.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/group/locutils.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2010 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: Project definition file for Location Utils +* +*/ + + +// INCLUDES +#include "../inc/locutilsuid.hrh" + +#include +#include +#include // For the MW_LAYER_SYSTEMINCLUDE + +TARGET locutils.dll +TARGETTYPE dll +UID 0x0 0x101F84FB + +VENDORID VID_DEFAULT +CAPABILITY CAP_GENERAL_DLL + +SOURCEPATH ../src + +#ifdef LOC_ENABLE_DEBUG_PRINT +SOURCE locutilsdebug.cpp +#else +SOURCE locutilsdebugdummy.cpp +#endif + +// System Include +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE . +USERINCLUDE ../inc + +LIBRARY euser.lib +LIBRARY bafl.lib +LIBRARY efsrv.lib +LIBRARY sysutil.lib +LIBRARY eposprvtyp.lib + +#ifdef LOC_ENABLE_DEBUG_PRINT +LIBRARY flogger.lib +#endif + +LIBRARY CenRepNotifHandler.lib +LIBRARY CentralRepository.lib + +#if defined(WINS) +deffile ../bwins/locutils_32.def +#elif defined(EABI) +deffile ../eabi/locutils_32.def +#endif + +// End of file + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsdebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsdebug.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2010 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: LocUtilsDebug contains debug macros. +* +*/ + + +#ifndef LOCUTILSDEBUG_H +#define LOCUTILSDEBUG_H + +// INCLUDES +#include "locutilsdebugconfig.hrh" + +#include + + +// MACROS +#define DEBUG(TEXT) { \ + _LIT( KText, #TEXT ); \ + Debug(KText) \ + } + +#define LOC(TEXT, ARG1) { \ + _LIT( KText, #TEXT ); \ + Debug( KText, (ARG1) ); \ + } + +#define LOC2(TEXT, ARG1, ARG2) { \ + _LIT( KText, #TEXT ); \ + Debug( KText,(ARG1), (ARG2) ); \ + } + +#define LOC3(TEXT, ARG1, ARG2, ARG3) { \ + _LIT( KText, #TEXT ); \ + Debug( KText, (ARG1), (ARG2), (ARG3) ); \ + } + +IMPORT_C void Debug( TRefByValue aText, ...); + +/** +* By using component specific debug macros unnecessary +* debug prints can be avoided. +* Also component specific debugging is possible by compiling +* only certain components when LOC_ENABLE_DEBUG_PRINT is defined. +*/ + +#ifdef LOC_ENABLE_DEBUG_PRINT + +#define LOCUTILSDEBUG(TEXT) DEBUG(TEXT); +#define LOCUTILSDEBUG1(TEXT, ARG1) LOC(TEXT, ARG1); +#define LOCUTILSDEBUG2(TEXT, ARG1, ARG2) LOC2(TEXT, ARG1, ARG2); +#define LOCUTILSDEBUG3(TEXT, ARG1, ARG2, ARG3) LOC3(TEXT, ARG1, ARG2, ARG3); + +#else + +#define LOCUTILSDEBUG(TEXT) ; +#define LOCUTILSDEBUG1(TEXT, ARG1) ; +#define LOCUTILSDEBUG2(TEXT, ARG1, ARG2) ; +#define LOCUTILSDEBUG3(TEXT, ARG1, ARG2, ARG3) ; + +#endif + +#endif // LOCUTILSDEBUG_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsdebugconfig.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsdebugconfig.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2010 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 the main build-time configuration file of Loc Utils +* +*/ + + +#ifndef LOCUTILSDEBUGCONFIG_HRH_ +#define LOCUTILSDEBUGCONFIG_HRH_ + +// INCLUDES + +// Flags for development: + + +// Defined LOC_ENABLE_DEBUG_PRINT flag enables debug prints to a file. + +//#define LOC_ENABLE_DEBUG_PRINT + +#endif // LOCUTILSDEBUGCONFIG_HRH_ + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsuid.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/inc/locutilsuid.hrh Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010 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: Common header for Location Utils UIDs. +* +*/ + + +#ifndef LOCUTILSUID_H_ +#define LOCUTILSUID_H_ + +// MACROS + +/// Location utility component UID3 +#define LOCUTILS_UID3 0x101F84FB + +#endif // LOCUTILSUID_H_ + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/src/locutilsdebug.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/src/locutilsdebug.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2010 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: Contains debugging functions +* +*/ + + + +// INCLUDE FILES +#include "locutilsdebug.h" +#include +#include +// CONSTANTS + +/// Folder where the log resides +_LIT( KLocLogFolder, "Verifier" ); + +/// The name of the log file +_LIT( KLocLogFileName, "LocVerifier" ); + +/// The format in which the time is formatted in log +_LIT( KLocLogTimeFormat, "%02d.%02d:%02d:%06d "); + +/// The length of the string produced by KLocLogTimeFormat +const TInt KLocLogTimeFormatLength = 16; + +/// How many characters a log line can contain +const TInt KLocLogLineLength = 256; + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + + +// ----------------------------------------------------------------------------- +// Debug +// Generates a log file if c:\logs\locationsysui\ folder exists +// ----------------------------------------------------------------------------- +// +EXPORT_C void Debug( TRefByValue aText, ... ) + { + VA_LIST args; + VA_START( args, aText ); + + TBuf buf; + buf.FormatList( aText, args ); + + #ifdef _DEBUG + RDebug::Print(buf); + #endif + + RFileLogger logger; + + TInt ret=logger.Connect(); + if (ret==KErrNone) + { + logger.SetDateAndTime( EFalse,EFalse ); + logger.CreateLog( KLocLogFolder, KLocLogFileName, EFileLoggingModeAppend ); + TBuf timeStamp; + TTime now; + now.HomeTime(); + TDateTime dateTime; + dateTime = now.DateTime(); + timeStamp.Format( KLocLogTimeFormat, + dateTime.Hour(), dateTime.Minute(), + dateTime.Second(), dateTime.MicroSecond() ); + buf.Insert( 0, timeStamp ); + + logger.Write(buf); + } + + logger.Close(); + + VA_END( args ); + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locutils/src/locutilsdebugdummy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locutils/src/locutilsdebugdummy.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2010 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: Contains dummy implementation for debugging function +* +*/ + + +#include "locutilsdebug.h" + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// Debug +// ----------------------------------------------------------------------------- +// +EXPORT_C void Debug( TRefByValue /*aText*/, ... ) + { + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/group/locverifierdlg.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/group/locverifierdlg.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2010 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: Project definition file for Location Verification Dialog +* +*/ + + +// INCLUDES +#include "../inc/locverifieruid.h" +#include +#include + +TARGET locverifierdlg.dll +TARGETTYPE PLUGIN +UID 0x10009D8D KLocVerifierDlgUID3 + +CAPABILITY CAP_ECOM_PLUGIN + +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE lpdverifierplugin.cpp +SOURCE lpdrequestao.cpp +SOURCE lpdrequestorprocessor.cpp +SOURCE lpdverifierquerylauncher.cpp +SOURCE lpdnotifierquerylauncher.cpp +SOURCE lpdglobalplugindialog.cpp +SOURCE lpdquerylauncherbase.cpp +SOURCE lpddllmain.cpp + + +// System Include +APP_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE \epoc32\include\mw\hb\hbcore +SYSTEMINCLUDE \epoc32\include\mw\hb\hbwidgets + +USERINCLUDE . +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../locnotificationengine/inc + +SOURCEPATH ../rss +START RESOURCE 101f84fc.rss +TARGET locverifierdlg.rsc +END + +// EPos: +LIBRARY eposprvqnif.lib +// Location: +LIBRARY locnotificationengine.lib +// Symbian & Hb: +LIBRARY euser.lib +LIBRARY eiksrv.lib +LIBRARY eposprvtyp.lib +LIBRARY estor.lib bafl.lib +LIBRARY flogger.lib +LIBRARY HbCore.lib +LIBRARY HbWidgets.lib +LIBRARY QtCore.lib +LIBRARY locnotificationclient.lib +LIBRARY systemtoneservice.lib +LIBRARY locutils.lib diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/locverifierdlgdebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/locverifierdlgdebug.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2010 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: LocVerifierDlgDebug contains debug macros. +* +*/ + + +#ifndef LOCVERIFIERDLGDEBUG_H +#define LOCVERIFIERDLGDEBUG_H + +// INCLUDES +#include "locutilsdebug.h" +#include + + +// MACROS + +/** +* By using component specific debug macros unnecessary +* debug prints can be avoided. +* Also component specific debugging is possible by compiling +* only certain components when LOC_ENABLE_DEBUG_PRINT is defined. +*/ + +#ifdef LOC_ENABLE_DEBUG_PRINT +#define LOCVERIFIERDLGDEBUG(TEXT) DEBUG(TEXT); +#define LOCVERIFIERDLGDEBUG1(TEXT, ARG1) LOC(TEXT, ARG1); +#define LOCVERIFIERDLGDEBUG2(TEXT, ARG1, ARG2) LOC2(TEXT, ARG1, ARG2); +#define LOCVERIFIERDLGDEBUG3(TEXT, ARG1, ARG2, ARG3) LOC3(TEXT, ARG1, ARG2, ARG3); +#else +#define LOCVERIFIERDLGDEBUG(TEXT); +#define LOCVERIFIERDLGDEBUG1(TEXT, ARG1); +#define LOCVERIFIERDLGDEBUG2(TEXT, ARG1, ARG2); +#define LOCVERIFIERDLGDEBUG3(TEXT, ARG1, ARG2, ARG3); +#endif + +#endif /* LOCVERIFIERDLGDEBUG_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/locverifieruid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/locverifieruid.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010 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: Common header for Location application UIDs. +* +*/ + + +#ifndef LOCVERIFIERUID_H +#define LOCVERIFIERUID_H + +/// Location verifier dialog UID3 +#define KLocVerifierDlgUID3 0x101f84fc + +#define KNotifierUID2 0x101fdfae + +#endif // LOCVERIFIERUID_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpddlgobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpddlgobserver.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 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: Callback interface class. +* +*/ + + +#ifndef MLPDDLGOBSERVER_H +#define MLPDDLGOBSERVER_H + +// INCLUDES +#include + + +// CLASS DECLARATION + +/** +* Callback interface class. +* Implementor of this class gives a reference to itself when +* creating a global query dialog. A callback method is then +* called when the query is dismissed. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class MLpdDlgObserver + { + public: + + /** + * Pure virtual callback method. + * @param aResult code of the query + */ + virtual void HandleDlgDismissedL( TInt aResult) = 0; + }; + +#endif // MLPDDLGOBSERVER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdglobalplugindialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdglobalplugindialog.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2010 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: List query dialog suitable for verifier plug-in use. +* +*/ + + +#ifndef CLPDGLOBALPLUGINDIALOG_H +#define CLPDGLOBALPLUGINDIALOG_H + +// INCLUDES +#include +#include +#include + + +const TInt KReqBufferSize = 256; +// FORWARD DECLARATIONS +class MLpdDlgObserver; +class CLpdRequestorProcessor; +class CHbDeviceDialog; +// CLASS DECLARATION + +/** +* A list query dialog suitable for verifier plug-in use. +* utilizes MLpdDlgObserver +* for notifying when dialog is dismissed. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdGlobalPluginDialog : public CBase, + public MHbDeviceDialogObserver , + public MHbDeviceNotificationDialogObserver + + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aCallBack is notified when dialog is dismissed + * @return created object + */ + static CLpdGlobalPluginDialog* NewL( + MLpdDlgObserver& aCallBack); + + + /** + * C++ destructor. + */ + virtual ~CLpdGlobalPluginDialog(); + + public: // Functions from base classes + + + void RunVerificationQueryL(); + + void RunNotificationL(); + + + void SetRequestInfoL( CLpdRequestorProcessor* aRequestInfo ); + + + void Cancel(); + + void DataReceived(CHbSymbianVariantMap& aData); + + void DeviceDialogClosed(TInt aCompletionCode); + + void AddVerDlgHeadingParamL(); + + void AddQueryTextParamL(); + + void AddRequestorsParamL(); + + + + public: + void NotificationDialogActivated (const CHbDeviceNotificationDialogSymbian *aDialog); + + void NotificationDialogClosed (const CHbDeviceNotificationDialogSymbian *aDialog, TInt aCompletionCode); + + + + private: // Constructors and destructor + + /** + * Symbian 2nd Phase Constructor. + */ + void ConstructL(); + + /** + * C++ constructor. + * @param aCallBack is notified when dialog is dismissed + */ + CLpdGlobalPluginDialog( + MLpdDlgObserver& aCallBack); + + private: // Data + + // Object which is notified when query is dismissed + MLpdDlgObserver& iCallBack; + CHbDeviceDialogSymbian* iMsgBox; + CHbDeviceNotificationDialogSymbian* iNotification; + CLpdRequestorProcessor* iRequestInfo; + CHbSymbianVariantMap* mSymbianVariantMap; + TBool mDissmissed; + TBool isCancelled; + + + }; + +#endif // CLPDGLOBALPLUGINDIALOG_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdnotifierquerylauncher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdnotifierquerylauncher.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2010 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: Class which handles the dialog and expiration timer. +* +*/ + + +#ifndef CLPDNOTIFIERQUERYLAUNCHER_H +#define CLPDNOTIFIERQUERYLAUNCHER_H + +// INCLUDES +#include "lpdquerylauncherbase.h" +#include +#include + +// FORWARD DECLARATIONS + + +// CLASS DECLARATION + +/** +* Implements functionality for executing notifications. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdNotifierQueryLauncher : +public CLpdQueryLauncherBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aHandler of ther query result + * @return created object + */ + static CLpdNotifierQueryLauncher* NewL( MLpdResultHandler& aHandler ); + + /** + * Destructor. Call Cancel() first if you have launched a query. + */ + virtual ~CLpdNotifierQueryLauncher(); + + + protected: // Functions from base classes + + /** + * From CLpdQueryLauncherBase, called when dialog is dismissed. + */ + void ExtendedHandleDlgDismissedL(); + + void RequestType(TRequestType& aRequestType); + + private: // Constructors and destructors + + /** + * C++ constructor. + * @param aHandler of the query result + */ + CLpdNotifierQueryLauncher( MLpdResultHandler& aHandler ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + }; + +#endif // CLPDNOTIFIERQUERYLAUNCHER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdquerylauncherbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdquerylauncherbase.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2010 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: Abstract base class for queries. +* +*/ + + +#ifndef CLPDQUERYLAUNCHERBASE_H +#define CLPDQUERYLAUNCHERBASE_H + +// INCLUDES +#include "lpddlgobserver.h" + +#include +#include +#include + +#include + + +// SYSTEM INCLUDE + + +// FORWARD DECLARATIONS +class CLpdGlobalPluginDialog; +class CLpdMessagePluginDialog; +class MLpdResultHandler; +class CLpdRequestorProcessor; + + +// CLASS DECLARATION + +/** +* Base class which handles the dialog and expiration timer. +* Expiration timer can be used to ensure that if the user doesn't handle +* a dialog in certain time the dialog is closed. NOTE: In current +* implementation the timer is not started, i.e. dialogs never expire. +* Implementations of this class should notify a result handler +* when dialog result is available. This base class takes care of +* notifying possible timeout with KErrTimedOut. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdQueryLauncherBase : public CBase, public MLpdDlgObserver + { + +protected: + enum TRequestType + { + EVerification = 0, + ENotification, + EUnknown + }; + + + public: // Constructors and destructor + + /** + * Destructor. Exits possibly running dialog without callback. + */ + virtual ~CLpdQueryLauncherBase(); + + + public: // New functions, query setup and launching + + /** + * Method for setting text array. + * + */ + void SetRequestInfoL( CLpdRequestorProcessor* aRequestInfo ); + + + /** + * Method for launching query, note that it must have been + * correctly prepared first. + */ + void StartQueryL(); + + + virtual void RequestType(TRequestType& aRequestType); + + + public: // Functions from base classes + + /** + * From MLpdDlgObserver, called when dialog is dismissed. + * This method calls also pure virtual method + * ExtendedHandleDlgDismissedL(). + * @param aResult code of the query + */ + void HandleDlgDismissedL( TInt aResult); + + public: + void Cancel(); + protected: // Constructors and destructors + + /** + * C++ constructor. + * @param aHandler of the query result + */ + CLpdQueryLauncherBase( MLpdResultHandler& aHandler ); + + void ConstructL(); + + protected: // New functions + + /** + * This pure virtual method must be implemented + * by the derived class to handle the result code + * appropriately and to notify the observer of this + * class. + */ + virtual void ExtendedHandleDlgDismissedL() = 0; + + + protected: // Data + + // Reference to the result handler + MLpdResultHandler& iHandler; + + // Result code from the dialog + TInt iResult; + + // Pointer to the list query dialog + CLpdGlobalPluginDialog* iQueryDlg; // owns untils RunLD() called + + + }; + +#endif // CLPDQUERYLAUNCHERBASE_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdrequestao.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdrequestao.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2010 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: Active object which ensures that current call stack is run to +* completion before a new request is handled +* +*/ + + +#ifndef CLPDREQUESTAO_H +#define CLPDREQUESTAO_H + +// INCLUDES +#include +#include + + +// FORWARD DECLARATIONS +class CLpdVerifierPlugin; + +// CLASS DECLARATION + +/** +* Active object used by the verifier plugin. +* Ensures that current call stack is run to completion before a +* new request is handled. Otherwise access violations might occur. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdRequestAO : public CActive + { + public: // Constructors and destructors + + /** + * Two-phased constructor. + * @param aPlugin reference to the owner of this object + * @return created object + */ + static CLpdRequestAO* NewL( CLpdVerifierPlugin& aPlugin ); + + /** + * Destructor. + */ + virtual ~CLpdRequestAO(); + + public: // New functions + + /** + * Issues a request and completes it immediatelly, so that it + * will be handled as soon as previous request is run to completion. + */ + void ScheduleRequest(); + + + private: + + /** + * Private C++ default constructor. + * @param aPlugin reference to the owner of this object + */ + CLpdRequestAO( CLpdVerifierPlugin& aPlugin ); + + private: // Functions from base classes + + /** + * From CActive. + */ + void RunL(); + + /** + * From CActive. + */ + void DoCancel(); + + private: // Data + + // Verifier plugin + CLpdVerifierPlugin& iPlugin; // doesn't own + + +}; + +#endif // CLPDREQUESTAO_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdrequestorprocessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdrequestorprocessor.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2010 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: Processes requestor related data. +* +*/ + + +#ifndef CLPDREQUESTORPROCESSOR_H +#define CLPDREQUESTORPROCESSOR_H + +// INCLUDES +#include "locrequestorutilsresolver.h" +#include +#include +#include +#include +// FORWARD DECLARATIONS +class CPosPrivacyNotifier; + + +// CLASS DECLARATION + +/** +* This class reads, processes and owns requestor data. +* @lib locverifierdlg.dll +* @since 2.1 +*/ +class CLpdRequestorProcessor : public CBase + { + public: // Constructors and destructor + + enum TDialogType + { + /** Query dialog requested. */ + EQuery = 0, + /** Notification dialog requested. */ + ENotification + }; + + + + /** + * Two-phased constructor. + * @return created object + */ + static CLpdRequestorProcessor* NewL(); + + /** + * Destructor. + */ + virtual ~CLpdRequestorProcessor(); + + public: // New functions + + /** + * Reads requestor information from the privacy notifier. + * Uses RequestorIdValid() for id validity check. + * Calls UpdateRuleRequestorsL(). + * @param aPosNotifier reference + * @return ETrue if all requestor id's were valid, EFalse otherwise. + */ + TBool ReadRequestorsL( const CPosPrivacyNotifier& aPosNotifier ); + + /** + * Returns requestor array for reading. + * @return array of requestors + */ + const RPointerArray& Requestors() const; + + /** + * Resets requestor arrays and destroys requestor objects. + */ + void ResetAndDestroyRequestors(); + + + protected: // Constructors and destructors + + /** + * C++ constructor. + */ + CLpdRequestorProcessor(); + + protected: // New methods + + /** + * Handles assert errors. Panics in debug build but leaves in release + * build, as this component runs in EikSrv and must never panic. + */ + void HandleAssertErrorL() const; + + private: + TBool RequestorIdValid( + const CPosRequestor& aRequestor ); + + public: + RPointerArray iRequestors; + CPosRequestor::TRequestType iRequestType; + TPosRequestDecision iRequestDecision; + TDialogType iDialogType; + TPosNotificationReason iNotifReason; + + }; + +#endif // CLPDREQUESTORPROCESSOR_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdresulthandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdresulthandler.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2010 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: Callback interface class. +* +*/ + + +#ifndef MLPDRESULTHANDLER_H +#define MLPDRESULTHANDLER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CLpdQueryLauncherBase; + + +// CLASS DECLARATION + +/** +* Observer pattern for handling dialog result. Used by several +* classes deriving from CLpdQueryLauncherBase. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class MLpdResultHandler + { + public: // New functions + + /** + * Pure virtual observer method. + * @param aResultCode + */ + virtual void HandleVerificationResultL( TInt aResultCode ) = 0; + + /** + * Pure virtual observer method. + * @param aResultCode + */ + virtual void HandleNotificationResultL( TInt aResultCode ) = 0; + + /** + * Pure virtual observer method. Called if leave occurred in other + * callback methods. Used because it is not acceptable to propagate + * leave to AVKON dialog, plugin must clean up and continue with + * handling of request queue. + * @param aError code + */ + virtual void HandleLeave( TInt aError ) = 0; + }; + +#endif // MLPDRESULTHANDLER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdverifierplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdverifierplugin.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,224 @@ +/* +* Copyright (c) 2010 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: Verifier plug-in which derives from CPosPrivacyNotifier. +* +*/ + + +// INCLUDES + +#ifndef CLPDVERIFIERDLG_H +#define CLPDVERIFIERDLG_H + +#include "lpdrequestao.h" +#include "lpdresulthandler.h" + +#include +#include +#include +// SYSTEM INCLUDE +#include // For the 3.2 Flag + + +// FORWARD DECLARATIONS +class CLpdVerifierQueryLauncher; +class CLpdNotifierQueryLauncher; +class CLpdRequestorProcessor; +class CLocRequestorUtilsResolver; + + +// CLASS DECLARATION + +/** +* Verifier plug-in which derives from CPosPrivacyNotifier. +* Notifiers are based on RNotifier framework, and this particular +* notifier is used to launch a privacy query for accepting/rejecting +* privacy requests. It also shows informational notes and error +* messages, which are received as notification. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdVerifierPlugin : public CPosPrivacyNotifier, public MLpdResultHandler + { + // To allow calls to HandleNextRequest() from active object + friend class CLpdRequestAO; + + private: + + + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return created object + */ + static CLpdVerifierPlugin* NewL(); + + /** + * Destructor. + */ + virtual ~CLpdVerifierPlugin(); + + /** + * Method for cancelling query or freeing + * resources after finishing query. + */ + void FreeQueryResources(); + + public: // Functions from base classes + + /** + * From CPosPrivacyNotifier, called when a new request arrives. + * @param aRequestId identifier of received request + */ + void HandleNewRequestL( TPosQNRequestId aRequestId ); + + /** + * From CPosPrivacyNotifier, called when request has been cancelled + * @param aRequestId identifier of cancelled request + */ + void HandleRequestCancelled( TPosQNRequestId aRequestId ); + + /** + * From CPosPrivacyNotifier, called when all requests are cancelled. + */ + void HandleAllRequestCancelled(); + + /** + * From MLpdResultHandler, called when verification result is available. + * @param aResultCode + */ + void HandleVerificationResultL( TInt aResultCode ); + + /** + * From MLpdResultHandler, called when notification has been done. + * @param aResultCode + */ + void HandleNotificationResultL( TInt aResultCode ); + + /** + * From MLpdResultHandler, called if leave occurred in callback method + * @param aError code + */ + void HandleLeave( TInt aError ); + + + + + protected: // New functions + + /** + * Non-leaving internal method for handling next pending request. + */ + void HandleNextRequest(); + + /** + * Internal method for handling next pending request. + */ + void HandleNextRequestL(); + + /** + * Internal helper method used by HandleNextRequestL(). + */ + void HandleNextVerificationL(); + + /** + * Internal helper method used by HandleNextRequestL(). + */ + void HandleNextNotificationL(); + + /** + * Internal helper method used by HandleNextNotificationL(). + */ + void HandleNextNonPeriodicNotificationL(); + + + /** + * Internal helper method. + * Completes current request and continues queue handling. + */ + void CompleteCurrentAndContinue( TInt aResultCode ); + + /** + * Handles assert errors. Panics in debug build but leaves in release + * build, as this component runs in EikSrv and must never panic. + */ + void HandleAssertErrorL() const; + + /** + * Panics in debug build but does nothing in release build. + */ + void HandleDebugAssertError() const; + + + + + private: + + /** + * C++ default constructor. + */ + CLpdVerifierPlugin(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + + + /** + * Checks the type of request and helps to know + * if a given request is of SUPL periodic type + * @param aCurrentRequest request id + * @return CPosRequestor::TRequestType type of request enum + */ + CPosRequestor::TRequestType CheckRequestTypeL(); + + + private: // Data + + + + // Identifier of currently handled request + TPosQNRequestId iCurrentRequest; + + // Type of the current request, valid if iCurrentRequest valid + TRequestType iCurrentRequestType; + + // Result code of verifier query, needed if user cancels rule query + TInt iVerifyResult; + + + // Location request accept/reject query object + CLpdVerifierQueryLauncher* iVerifierQuery; // owns + + // Location request accept/reject query object + CLpdNotifierQueryLauncher* iNotifier; // owns + + // Active object, used to let requests run to + // completion instead of recursive calls. + CLpdRequestAO* iRequestActiveObject; // owns + + CLpdRequestorProcessor* iRtorProcessor; // owns + + CLocRequestorUtilsResolver* iUtils; // owns + + + }; + +#endif // CLPDVERIFIERDLG_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdverifierquerylauncher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/inc/lpdverifierquerylauncher.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2010 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: Class which handles the dialog and expiration timer. +* +*/ + + +#ifndef CLPDVERIFIERQUERYLAUNCHER_H +#define CLPDVERIFIERQUERYLAUNCHER_H + +// INCLUDES +#include "lpdquerylauncherbase.h" +#include +#include + + +// FORWARD DECLARATIONS +class CLpdGlobalPluginDialog; + + +// CLASS DECLARATION + +/** +* Implements functionality for executing verification queries. +* +* @lib locverifierdlg.lib +* @since 2.1 +*/ +class CLpdVerifierQueryLauncher : +public CLpdQueryLauncherBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aHandler of ther query result + * @return created object + */ + static CLpdVerifierQueryLauncher* NewL( + MLpdResultHandler& aHandler ); + + /** + * Destructor. Call Cancel() first if you have launched a query. + */ + virtual ~CLpdVerifierQueryLauncher(); + + public: // New functions + + + protected: // Functions from base classes + + /** + * From CLpdQueryLauncherBase, called when dialog is dismissed. + */ + void ExtendedHandleDlgDismissedL(); + + void RequestType(TRequestType& aRequestType); + + private: // Constructors and destructors + + /** + * C++ constructor. + * @param aHandler of the query result + */ + CLpdVerifierQueryLauncher( MLpdResultHandler& aHandler ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + + }; + +#endif // CLPDVERIFIERQUERYLAUNCHER_H + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/rss/101f84fc.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/rss/101f84fc.rss Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 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 file specifies the interface and implementation information +* for BTnotif Ecom Plugins. +* +*/ + + +#include "ecom/registryinfo.rh" +#include "uikon.hrh" +#include + +#define PRINOTDISPLAYNAME "TTNOTIFY2V2 Plugin 1" +#define PRINOTDEFAULTDATA "TTNOTIFY2V2" +#define PRINOTOPAQUEDATA "0" + +RESOURCE REGISTRY_INFO theInfo +{ + dll_uid = 0x101f84fc; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KUikonUidPluginInterfaceNotifiers; // ECOM Notifier Plugin + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10207243; + version_no = 1; + display_name = PRINOTDISPLAYNAME; + default_data = PRINOTDEFAULTDATA; + opaque_data = PRINOTOPAQUEDATA; + } + }; + } + }; +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpddllmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpddllmain.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2010 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: Dll entry point and plugin creation functions. +* +*/ + + +// INCLUDE FILES +#include "lpdverifierplugin.h" +#include +#include +#include + +// ============================= LOCAL FUNCTIONS =============================== + +LOCAL_C void CreateNotifiersL( + CArrayPtrFlat* aNotifiers ) + { + CLpdVerifierPlugin* notifier = CLpdVerifierPlugin::NewL(); + CleanupStack::PushL( notifier ); + aNotifiers->AppendL( notifier->NotifierBase() ); + CleanupStack::Pop( notifier ); // Do not destroy. This is handled by the FW. + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +LOCAL_C CArrayPtr* NotifierArray() + { + CArrayPtrFlat* notifiers = + new CArrayPtrFlat( 1 ); + if ( notifiers ) + { + TRAPD( err, CreateNotifiersL( notifiers ) ); + if ( err ) + { // release any notifiers we have created + TInt count = notifiers->Count(); + while ( --count >= 0 ) + { + ( *notifiers )[count]->Release(); + } + delete notifiers; + notifiers = NULL; + } + } + return notifiers; + } + +const TImplementationProxy ImplementationTable[] = + { +#ifdef __EABI__ + {{0x10207243},(TFuncPtr)NotifierArray} +#else + {{0x10207243},NotifierArray} +#endif + }; + +// ======== GLOBAL FUNCTIONS ======== + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy) ; + return ImplementationTable; + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdglobalplugindialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdglobalplugindialog.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,420 @@ +/* +* Copyright (c) 2010 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: List query dialog suitable for verifier plug-in use. +* +*/ + + +// INCLUDE FILES +#include "lpdglobalplugindialog.h" +#include "lpddlgobserver.h" +#include "lpdrequestorprocessor.h" + +#include +#include +#include +#include +#include +#include +#include + +_LIT(KNotifReqSeperator,","); +_LIT(KHeadingKey, "heading"); +_LIT(KQueryTextKey, "queryText"); +_LIT(KQueryText2Key, "queryText2"); +_LIT(KRequestorKey, "requestor"); +_LIT(KVerificationDlgType, "hb.posverifiction.dialog/1.0"); +_LIT(KLocTsFileName, "lilocationmw_"); +_LIT(KLocTsFilePath, "z://resource/qt/translations/"); +_LIT(KLocTsAFileAltPath, "c://resource/"); +//Translation String Ids +//Verification Dialog +_LIT(KRequestHeading, "txt_loe_title_location_request"); +_LIT(KSingleshotDecisionRejected, "txt_loe_info_your_location_will_not_be_shared_by_d"); +_LIT(KSingleshotDecisionAccepted, "txt_loe_info_your_location_will_be_shared_by_defau"); +_LIT(KSingleshotDecisionNotAvailable, "txt_loe_info_your_location_will_be_shared_with"); +_LIT(KPeriodicDecisionRejected, "txt_loe_info_your_location_will_not_be_shared_peri"); +_LIT(KPeriodicDecisionAccepted, "txt_loe_info_your_location_will_be_shared_periodic"); +_LIT(KPeriodicDecisionNotAvailable, "txt_loe_info_you_location_will_be_shared_periodica"); +_LIT(KRequestorText, "txt_loe_info_location_was_requested_by"); +_LIT(KUnknownRequestor, "txt_loe_info_unknown_requestor"); +//Notification +_LIT(KNotificationNotSent, "txt_loe_dpophead_your_location_not_sent_to"); +_LIT(KNotificationSent, "txt_loe_dpophead_your_location_sent_to"); + +const TInt KNotificationTimeout = 15000; +const TInt KMaxSize = 1024; +const TInt KVariantMaxSize = 256; +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdGlobalPluginDialog::CLpdGlobalPluginDialog +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdGlobalPluginDialog::CLpdGlobalPluginDialog( + MLpdDlgObserver& aCallBack + ) + : iCallBack( aCallBack ), + iMsgBox(NULL), + iNotification(NULL), + iRequestInfo(NULL) + { + } + +// ----------------------------------------------------------------------------- +// CLpdGlobalPluginDialog::ConstructL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +void CLpdGlobalPluginDialog::ConstructL() + { + iMsgBox = CHbDeviceDialogSymbian::NewL(); + iNotification = CHbDeviceNotificationDialogSymbian::NewL(this); + TBool result = + HbTextResolverSymbian::Init(KLocTsFileName, KLocTsFilePath); + if (!result) + { + HbTextResolverSymbian::Init(KLocTsFileName, KLocTsAFileAltPath); + } + } + +// ----------------------------------------------------------------------------- +// CLpdGlobalPluginDialog::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdGlobalPluginDialog* CLpdGlobalPluginDialog::NewL( + MLpdDlgObserver& aCallBack) + { + CLpdGlobalPluginDialog* self = + new( ELeave ) CLpdGlobalPluginDialog( aCallBack); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Destructor +CLpdGlobalPluginDialog::~CLpdGlobalPluginDialog() + { + delete iMsgBox; + iMsgBox = NULL; + + delete iNotification; + iNotification = NULL; + + delete iRequestInfo; + iRequestInfo=NULL; + + } + + +// ----------------------------------------------------------------------------- +// CLpdGlobalPluginDialog::RunLD +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdGlobalPluginDialog::RunVerificationQueryL() + { + mSymbianVariantMap = CHbSymbianVariantMap::NewL(); + CleanupStack::PushL(mSymbianVariantMap); + + AddVerDlgHeadingParamL(); + AddQueryTextParamL(); + AddRequestorsParamL(); + CSystemToneService* sts = CSystemToneService::Create(); + iMsgBox->Show(KVerificationDlgType, *mSymbianVariantMap, this); + if( sts ) + { + sts->PlayTone(CSystemToneService::ELocationRequest); + } + CSystemToneService::Delete(sts); + CleanupStack::Pop(mSymbianVariantMap); + } + +void CLpdGlobalPluginDialog::RunNotificationL() + { + if( EPosDecisionByRequestSource == iRequestInfo->iNotifReason || + EPosVerificationTimeout == iRequestInfo->iNotifReason ) + { + if ( EPosDecisionAccepted == iRequestInfo->iRequestDecision ) + { + HBufC* title = HbTextResolverSymbian::LoadL(KNotificationSent); + CleanupStack::PushL(title); + iNotification->SetTitleL(title->Des()); + CleanupStack::PopAndDestroy(title); + } + if( EPosDecisionRejected == iRequestInfo->iRequestDecision ) + { + HBufC* title = HbTextResolverSymbian::LoadL(KNotificationNotSent); + CleanupStack::PushL(title); + iNotification->SetTitleL(title->Des()); + CleanupStack::PopAndDestroy(title); + } + } + else + { + // Not supported + User::Leave(KErrNotSupported); + } + TBuf buf; + + TInt count= iRequestInfo->iRequestors.Count(); + if( count == 0 ) + { + HBufC* requestor = HbTextResolverSymbian::LoadL(KUnknownRequestor); + CleanupStack::PushL(requestor); + buf.Append(requestor->Des()); + CleanupStack::PopAndDestroy(requestor); + } + else + { + for(TInt i=0;i< count;i++ ) + { + if(i!=0) + { + buf.Append(KNotifReqSeperator); + } + buf.Append(iRequestInfo->iRequestors[i]->RequestorIdString()); + } + } + iNotification->SetTextL(buf); + iNotification->SetTimeout(KNotificationTimeout); + iNotification->EnableTouchActivation(ETrue); + iNotification->ShowL(); + } + +// ----------------------------------------------------------------------------- +// CLpdGlobalPluginDialog::SetMessageTextL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdGlobalPluginDialog::SetRequestInfoL( CLpdRequestorProcessor* aRequestInfo ) + { + if(iRequestInfo) + { + // clear and create again if already has been set before + delete iRequestInfo; + iRequestInfo=NULL; + } + iRequestInfo=CLpdRequestorProcessor::NewL(); + + iRequestInfo->iDialogType=aRequestInfo->iDialogType; + iRequestInfo->iNotifReason=aRequestInfo->iNotifReason; + iRequestInfo->iRequestDecision=aRequestInfo->iRequestDecision; + iRequestInfo->iRequestType=aRequestInfo->iRequestType; + + const RPointerArray& requestors = aRequestInfo->iRequestors; + + TInt count = requestors.Count(); + for(TInt i=0; i< count; i++ ) + { + CPosRequestor::TRequestorIdFormat idFormat; + TPtrC idString; + idFormat=requestors[i]->RequestorIdFormat(); + idString.Set(requestors[i]->RequestorIdString()); + + if( CPosRequestor::ERequestorService==requestors[i]->RequestType()) + { + CPosServiceRequestor* service = CPosServiceRequestor::NewL(idFormat,idString); + CleanupStack::PushL(service); + // Ownership transferred + iRequestInfo->iRequestors.Append(service); + CleanupStack::Pop(service); + } + else + { + CPosContactRequestor* contact = CPosContactRequestor::NewL(idFormat,idString); + CleanupStack::PushL(contact); + // Ownership transferred + iRequestInfo->iRequestors.Append(contact); + CleanupStack::Pop(contact); + } + + } + } + + + +void CLpdGlobalPluginDialog::Cancel() + { + // Close any running dialogs if any.Close() doesnt have any effect if dialog is not running + isCancelled = ETrue; + iMsgBox->Cancel(); + iNotification->Close(); + } + +void CLpdGlobalPluginDialog::NotificationDialogActivated( + const CHbDeviceNotificationDialogSymbian */*aDialog*/) + { + // Complete with KErrNone now + TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrNone )); + } + +void CLpdGlobalPluginDialog::NotificationDialogClosed( + const CHbDeviceNotificationDialogSymbian */*aDialog*/, + TInt aCompletionCode) + { + TRAP_IGNORE(iCallBack.HandleDlgDismissedL( aCompletionCode )); + } + +void CLpdGlobalPluginDialog::DataReceived(CHbSymbianVariantMap& /*aData*/) + { + mDissmissed = ETrue; + TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrAccessDenied )); + } + +void CLpdGlobalPluginDialog::DeviceDialogClosed(TInt /*aCompletionCode*/) + { + if (!mDissmissed && !isCancelled) + { + TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrNone )); + } + } + +void CLpdGlobalPluginDialog::AddVerDlgHeadingParamL() + { + HBufC* headingText = HbTextResolverSymbian::LoadL(KRequestHeading); + CleanupStack::PushL(headingText); + CHbSymbianVariant* heading = CHbSymbianVariant::NewL(headingText, + CHbSymbianVariant::EDes); + CleanupStack::PushL(heading); + mSymbianVariantMap->Add(KHeadingKey, heading ); + CleanupStack::Pop(heading); + CleanupStack::PopAndDestroy(headingText); + } + +void CLpdGlobalPluginDialog::AddQueryTextParamL() + { + HBufC * value = HBufC::NewL(KVariantMaxSize); + CleanupStack::PushL(value); + HBufC * value2 = HBufC::NewL(KVariantMaxSize); + CleanupStack::PushL(value2); + HBufC* requestorText = HbTextResolverSymbian::LoadL(KRequestorText); + CleanupStack::PushL(requestorText); + + if (CPosRequestor::ERequestSingleShot == iRequestInfo->iRequestType) + { + if (EPosDecisionNotAvailable == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KSingleshotDecisionNotAvailable); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + else if (EPosDecisionAccepted == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KSingleshotDecisionAccepted); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + value2->Des().Copy(requestorText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + else if (EPosDecisionRejected == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KSingleshotDecisionRejected); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + value2->Des().Copy(requestorText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + } + + else if (CPosRequestor::ERequestPeriodic == iRequestInfo->iRequestType) + { + if (EPosDecisionNotAvailable == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KPeriodicDecisionNotAvailable); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + else if (EPosDecisionAccepted == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KPeriodicDecisionAccepted); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + value2->Des().Copy(requestorText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + else if (EPosDecisionRejected == iRequestInfo->iRequestDecision) + { + HBufC* queryText = HbTextResolverSymbian::LoadL( + KPeriodicDecisionRejected); + CleanupStack::PushL(queryText); + value->Des().Copy(queryText->Des()); + value2->Des().Copy(requestorText->Des()); + CleanupStack::PopAndDestroy(queryText); + } + } + else + { + // Not supported + User::Leave(KErrNotSupported); + } + + CHbSymbianVariant* queryText = CHbSymbianVariant::NewL(value, + CHbSymbianVariant::EDes); + CleanupStack::PushL(queryText); + + CHbSymbianVariant* queryText2 = CHbSymbianVariant::NewL(value2, + CHbSymbianVariant::EDes); + CleanupStack::PushL(queryText2); + + if (value2->Length()!= 0) + { + mSymbianVariantMap->Add(KQueryText2Key, queryText2); + } + mSymbianVariantMap->Add(KQueryTextKey, queryText); + CleanupStack::Pop(queryText2); + CleanupStack::Pop(queryText); + CleanupStack::PopAndDestroy(3); + } + +void CLpdGlobalPluginDialog::AddRequestorsParamL() + { + + CDesC16ArrayFlat* array = new CDesC16ArrayFlat(8); + TInt reqCount = iRequestInfo->iRequestors.Count(); + if (!reqCount) + { + HBufC* requestor = HbTextResolverSymbian::LoadL(KUnknownRequestor); + CleanupStack::PushL(requestor); + array->AppendL(requestor->Des()); + CleanupStack::PopAndDestroy(requestor); + } + else + { + for (TInt i = 0; i < reqCount; ++i) + { + array->AppendL(iRequestInfo->iRequestors[i]->RequestorIdString()); + } + } + + TInt count = array->MdcaCount(); + MDesCArray* marray = static_cast (array); + CHbSymbianVariant* requestors = CHbSymbianVariant::NewL(marray, + CHbSymbianVariant::EDesArray); + mSymbianVariantMap->Add(KRequestorKey, requestors); + } + +// End of file + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdnotifierquerylauncher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdnotifierquerylauncher.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2010 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: Class which handles the dialog and expiration timer. +* +*/ + + +// INCLUDE FILES +#include "lpdnotifierquerylauncher.h" +#include "lpdglobalplugindialog.h" + +#include "lpdresulthandler.h" +#include + +// CONSTANTS + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdNotifierQueryLauncher::CLpdNotifierQueryLauncher +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdNotifierQueryLauncher::CLpdNotifierQueryLauncher( + MLpdResultHandler& aHandler ) + : CLpdQueryLauncherBase( aHandler ) + { + // Intentionally empty + } + +// ----------------------------------------------------------------------------- +// CLpdNotifierQueryLauncher::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CLpdNotifierQueryLauncher::ConstructL() + { + CLpdQueryLauncherBase::ConstructL(); + } + +// ----------------------------------------------------------------------------- +// CLpdNotifierQueryLauncher::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdNotifierQueryLauncher* CLpdNotifierQueryLauncher::NewL( + MLpdResultHandler& aHandler ) + { + CLpdNotifierQueryLauncher* self = new( ELeave ) + CLpdNotifierQueryLauncher( aHandler ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// Destructor +CLpdNotifierQueryLauncher::~CLpdNotifierQueryLauncher() + { + // Intentionally empty + } + + +// ----------------------------------------------------------------------------- +// CLpdNotifierQueryLauncher::ExtendedHandleDlgDismissedL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdNotifierQueryLauncher::ExtendedHandleDlgDismissedL() + { + iHandler.HandleNotificationResultL( iResult ); + } + + +// ----------------------------------------------------------------------------- +// CLpdNotifierQueryLauncher::RequestType +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdNotifierQueryLauncher::RequestType(TRequestType& aRequestType) + { + aRequestType = CLpdQueryLauncherBase::ENotification; + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdquerylauncherbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdquerylauncherbase.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2010 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: Abstract base class for queries. +* +*/ + + +// INCLUDE FILES + +#include "lpdquerylauncherbase.h" +#include "lpdresulthandler.h" +#include "lpdrequestorprocessor.h" + +#include "lpdglobalplugindialog.h" + + +// CONSTANTS + +// Unnamed namespace for local definitions + +#ifdef _DEBUG +//_LIT( KPanicText, "CLpdQueryLauncherBase" ); +enum TPanicCode + { + KLpdErrGeneral = 1 + }; +#endif + +// INCLUDE FILES +#include + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::CLpdQueryLauncherBase +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdQueryLauncherBase::CLpdQueryLauncherBase( MLpdResultHandler& aHandler ) + : iHandler( aHandler ), + iResult( KErrArgument ), + iQueryDlg( NULL ) + { + } + + + +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::~CLpdQueryLauncherBase +// Destructor +// ----------------------------------------------------------------------------- +// +CLpdQueryLauncherBase::~CLpdQueryLauncherBase() + { + delete iQueryDlg; + iQueryDlg = NULL; + } + + +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::ConstructL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdQueryLauncherBase::ConstructL() + { + iQueryDlg = CLpdGlobalPluginDialog::NewL(*this); + } +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::SetQueryTextArray +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdQueryLauncherBase::SetRequestInfoL( CLpdRequestorProcessor* aRequestInfo ) + { + iQueryDlg->SetRequestInfoL(aRequestInfo); + } + +void CLpdQueryLauncherBase::RequestType(TRequestType& aRequestType) + { + aRequestType = EUnknown; + } +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::StartQueryL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdQueryLauncherBase::StartQueryL() + { + TRequestType type; + RequestType( type ); + if( EVerification == type ) + { + iQueryDlg->RunVerificationQueryL(); + } + else if( ENotification == type ) + { + iQueryDlg->RunNotificationL(); + } + else + { + // do nothing now + } + + } + +void CLpdQueryLauncherBase::Cancel() + { + iQueryDlg->Cancel(); + } +// ----------------------------------------------------------------------------- +// CLpdQueryLauncherBase::HandleDlgDismissedL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdQueryLauncherBase::HandleDlgDismissedL( + TInt aResult ) + { + + iResult = aResult; + + TRAPD( err, ExtendedHandleDlgDismissedL() ); + if ( err ) + { + iHandler.HandleLeave( err ); + } + + } + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdrequestao.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdrequestao.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2010 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: Active object which ensures that current call stack is run to +* completion before a new request is handled +* +*/ + + +// INCLUDE FILES +#include "lpdrequestao.h" +#include "lpdverifierplugin.h" +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CLpdRequestAO::CLpdRequestAO +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdRequestAO::CLpdRequestAO( CLpdVerifierPlugin& aPlugin ) + : CActive( CActive::EPriorityHigh ), iPlugin( aPlugin ) + { + } + +// ----------------------------------------------------------------------------- +// CLpdRequestAO::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdRequestAO* CLpdRequestAO::NewL( CLpdVerifierPlugin& aPlugin ) + { + CLpdRequestAO* self = new( ELeave ) CLpdRequestAO( aPlugin ); + CActiveScheduler::Add(self); + // Nothing to do in the Second Phase Constructor + return self; + } + +// Destructor +CLpdRequestAO::~CLpdRequestAO() + { + Cancel(); + + } + +// ----------------------------------------------------------------------------- +// CLpdRequestAO::ScheduleRequest +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdRequestAO::ScheduleRequest() + { + Cancel(); + SetActive(); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CLpdRequestAO::RunL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdRequestAO::RunL() + { + iPlugin.HandleNextRequest(); + } + +// ----------------------------------------------------------------------------- +// CLpdRequestAO::DoCancel +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdRequestAO::DoCancel() + { + // Not important with this AO + } + + + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdrequestorprocessor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdrequestorprocessor.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2010 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: Processes requestor related data. +* +*/ + + +// INCLUDE FILES +#include "lpdrequestorprocessor.h" +#include "contactresolversession.h" + +#include "locverifierdlgdebug.h" +#include +#include +#include +#include + + +// Unnamed namespace for local definitions + +const TInt KRequestorsGranularity = 5; +#ifdef _DEBUG +_LIT( KPanicText, "CLpdRequestorProcessor" ); +enum TPanicCode + { + KLpdErrGeneral = 1 + }; +#endif + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::CLpdRequestorProcessor +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdRequestorProcessor::CLpdRequestorProcessor() +: iRequestors( KRequestorsGranularity) + { + } + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdRequestorProcessor* CLpdRequestorProcessor::NewL() + { + CLpdRequestorProcessor* self = new( ELeave ) CLpdRequestorProcessor; + // Nothing to do in the Second Phase Constructor + return self; + } + +// Destructor +CLpdRequestorProcessor::~CLpdRequestorProcessor() + { + iRequestors.ResetAndDestroy(); + iRequestors.Close(); + } + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::ReadRequestorsL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TBool CLpdRequestorProcessor::ReadRequestorsL( + const CPosPrivacyNotifier& aPosNotifier ) + { + __ASSERT_DEBUG( aPosNotifier.CurrentRequest() != KPosNullQNRequestId, + HandleAssertErrorL() ); + + this->ResetAndDestroyRequestors(); + + TBool allRequestorIdsValid = ETrue; + + // Let's read the requestors associated with the current request: + TInt nofRequestors = aPosNotifier.RequestorCountL(); + + for ( TInt i = 0; i < nofRequestors; i++ ) + { + CPosRequestor* requestor = aPosNotifier.RequestorLC( i ); + + if ( RequestorIdValid( *requestor ) ) + { // mark that some requestor id is invalid + allRequestorIdsValid = EFalse; + } + + User::LeaveIfError( iRequestors.Append( requestor ) ); + CleanupStack::Pop( requestor ); // iRequestors owns now the requestor + } + + if ( nofRequestors == 0 ) + { + allRequestorIdsValid = EFalse; // zero requestors == invalid + } + + RContactResolverSession resSession; + TInt err = resSession.Connect(); + + // If any error in connection,dont leave.Use un-resolved requestors + if( KErrNone == err ) + { + resSession.ResolveRequestorsL(iRequestors); + } + resSession.Close(); + + return allRequestorIdsValid; + } + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::ResetAndDestroyRequestors +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdRequestorProcessor::ResetAndDestroyRequestors() + { + iRequestors.ResetAndDestroy(); + } + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::RequestorIdValid +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TBool CLpdRequestorProcessor::RequestorIdValid( + const CPosRequestor& aRequestor ) + { + return( aRequestor.RequestorIdFormat() != CPosRequestor::EIdFormatUnknown ); + } + +// ----------------------------------------------------------------------------- +// CLpdRequestorProcessor::HandleAssertErrorL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdRequestorProcessor::HandleAssertErrorL() const + { + #ifdef _DEBUG + User::Panic( KPanicText, KLpdErrGeneral ); + #else + User::Leave( KErrCorrupt ); + #endif + } +// end of file diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdverifierplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdverifierplugin.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,552 @@ +/* + * Copyright (c) 2010 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: Verifier plug-in which derives from CPosPrivacyNotifier. + * + */ + +// INCLUDE FILES + +#include "lpdverifierplugin.h" + +#include "lpdrequestao.h" +#include "lpdrequestorprocessor.h" +#include "lpdverifierquerylauncher.h" +#include "lpdnotifierquerylauncher.h" +#include "locverifierdlgdebug.h" +#include "locutilsdebug.h" + +#include +#include +#include + +// INCLUDE FILES +#include + + + +const TInt KPrivSrvSecureId = 0x10281D45; +// CONSTANTS + +// Unnamed namespace for local definitions + +const MEikSrvNotifierBase2::TNotifierPriority KNotifierPriority = + MEikSrvNotifierBase2::ENotifierPriorityHigh; +const TUid KNotifierChannel = + { + 0x100065ac + }; +#ifdef _DEBUG +_LIT( KPanicText, "CLpdVerifierPlugin" ); +enum TPanicCode + { + KLpdErrGeneral = 1 + }; +#endif + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::CLpdVerifierPlugin +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdVerifierPlugin::CLpdVerifierPlugin() : + iCurrentRequest(KPosNullQNRequestId) + + { + + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::ConstructL() + { + BaseConstructL(KNotifierChannel, KNotifierPriority); + + iRtorProcessor = CLpdRequestorProcessor::NewL(); + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdVerifierPlugin* CLpdVerifierPlugin::NewL() + { + CLpdVerifierPlugin* self = new (ELeave) CLpdVerifierPlugin; + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// Destructor +CLpdVerifierPlugin::~CLpdVerifierPlugin() + { + // Destruction of this plugin should only occur only in shutdown + // or in severe problem situation. + + // A very special scenario is that base class construction leaves and + // this destructor is called. In that case CompleteAllRequests() causes + // access violation (noticed this by checking source code of base class). + if (NotifierBase()) + { // base class has been fully constructed, method call is safe + CompleteAllRequests(KErrGeneral); + } + + // It is enough to delete queries so when don't get callbacks. + FreeQueryResources(); + + delete iRequestActiveObject; + iRequestActiveObject = NULL; + delete iRtorProcessor; + iRtorProcessor = NULL; + + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNewRequestL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNewRequestL(TPosQNRequestId /*aRequestId */ ) + { + LOCVERIFIERDLGDEBUG( "CLpdVerifierPlugin::HandleNewRequestL" ); + + // Check whether the notifier is already handling a request + // If yes, do nothing for now. + if (iRequestActiveObject) + { + return; + } + else + { + iRequestActiveObject = CLpdRequestAO::NewL(*this); + iRequestActiveObject->ScheduleRequest(); + } + } + + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleRequestCancelled +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleRequestCancelled(TPosQNRequestId aRequestId) + { + LOCVERIFIERDLGDEBUG( "CLpdVerifierPlugin::HandleRequestCancelled" ); + // Check whether the request is coming from Uikon Server. + // If not reject this request. + if (!CheckClientSecureId(KPrivSrvSecureId)) + { + return; + } + + + if (aRequestId != iCurrentRequest) + { + return; + } + + + if (iCurrentRequestType == EQuery) + { // Verification was cancelled + __ASSERT_DEBUG( iVerifierQuery, HandleDebugAssertError() ); + LOCVERIFIERDLGDEBUG( "Verification cancelled" ); + iVerifierQuery->Cancel(); + } + else + { + // It must be a notification then, this case is not probable but + // we can cancel the dialog if this would happen. + __ASSERT_DEBUG( iCurrentRequestType == ENotification, + HandleDebugAssertError() ); + __ASSERT_DEBUG( iNotifier, HandleDebugAssertError() ); + LOCVERIFIERDLGDEBUG( "Notification cancelled" ); + iNotifier->Cancel(); + } + + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleAllRequestCancelled +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleAllRequestCancelled() + { + LOCVERIFIERDLGDEBUG( "CLpdVerifierPlugin::HandleAllRequestCancelled" ); + if (iCurrentRequest != KPosNullQNRequestId) + { // current request requires some specific behavior + HandleRequestCancelled(iCurrentRequest); + } + + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleVerificationResultL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleVerificationResultL(TInt aResultCode) + { + iVerifyResult = aResultCode; + + LOCVERIFIERDLGDEBUG1( "CLpdVerifierPlugin::HandleVerificationResultL(%d)", + iVerifyResult ); + + switch (iVerifyResult) + { + case KErrNone: // fall through + case KErrAccessDenied: + { + // No need for rules now in 3.0 + break; + } + case KErrTimedOut: + { // UI's internal timer expired + break; + } + case KErrCancel: + { + return; // don't handle next req. yet + } + case KErrAbort: // This is used for emergency call support + { + CompleteAllRequests(iVerifyResult); + // ScheduleRequest() allows the current call chain + // run to completion and resources are released after that. + iRequestActiveObject->ScheduleRequest(); + return; + } + default: + { + + break; + } + } + + CompleteCurrentAndContinue(iVerifyResult); // this request was handled + } +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNotificationResultL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNotificationResultL(TInt aResultCode) + { + + LOCVERIFIERDLGDEBUG1( "CLpdVerifierPlugin::HandleVerificationResultL(%d)", + aResultCode ); + CompleteRequest(iCurrentRequest, aResultCode); + iCurrentRequest = KPosNullQNRequestId; + + switch (aResultCode) + { + case KErrNone: // fall through + case KErrTimedOut: // fall through + { + break; + } + case KErrCancel: + { + break; + } + case KErrAbort: // This is used for emergency call support + { + CompleteAllRequests(aResultCode); + // ScheduleRequest() -> allows the current call chain + // run to completion and resources are released after that. + break; + } + default: + { + + break; + } + } + + iRequestActiveObject->ScheduleRequest(); // handle next req. + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleLeave +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleLeave(TInt /*aError*/) + { + LOCVERIFIERDLGDEBUG1( "CLpdVerifierPlugin::HandleLeave(%d)", aError); + // In this case user needs feedback about the error situation: + + + // In case of leave current request is completed with + // iVerifyResult, but queue handling is still continued. + // iVerifyResult is better completion code for request than aError. + CompleteCurrentAndContinue(iVerifyResult); + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNextRequest +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNextRequest() + { + TRAPD( err, HandleNextRequestL() ); + if (err) + { + // In case of leave current request is completed with + // error code, but queue handling is still continued. + + // If we couldn't start handling the request it is + // better not to confuse user with an error note. + + CompleteCurrentAndContinue(iVerifyResult); + } + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNextRequestL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNextRequestL() + { + + // It is better to free previous query resources here, because + // now all callback methods have finished (active object allowed + // run to completion) + this->FreeQueryResources(); + + // Read the next request: + RArray requests; + CleanupClosePushL(requests); + GetRequestsL(requests); + + if (requests.Count() == 0) + { // No more requests to handle + CleanupStack::PopAndDestroy(); // requests + // This is a very important step, it allows new requests + // to flow in ( see HandleNewRequestL() ): + delete iRequestActiveObject; + iRequestActiveObject = NULL; + return; + } + iCurrentRequest = requests[0]; + CleanupStack::PopAndDestroy(); // requests + SetCurrentRequestL(iCurrentRequest); + + // Check whether the request is coming from Uikon Server. If not reject this request. + if (!CheckClientSecureId(KPrivSrvSecureId)) + { + CompleteCurrentAndContinue(KErrPermissionDenied); + return; + } + + // Check the request type + iCurrentRequestType = RequestTypeL(iCurrentRequest); + + iRtorProcessor->ReadRequestorsL(*this); + + + + if (iCurrentRequestType == EQuery) + { + LOCVERIFIERDLGDEBUG( "New verification request received" ); + HandleNextVerificationL(); + } + else if (iCurrentRequestType == ENotification) + { + LOCVERIFIERDLGDEBUG( "New notification request received" ); + HandleNextNotificationL(); + } + else + { + User::Leave(KErrNotSupported); + } + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNextVerificationL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNextVerificationL() + { + __ASSERT_DEBUG( iCurrentRequest != KPosNullQNRequestId, + HandleAssertErrorL() ); + __ASSERT_DEBUG( !iVerifierQuery, HandleAssertErrorL() ); + + CPosRequestor::TRequestType reqType; + if (CheckRequestTypeL() == CPosRequestor::ERequestPeriodic) + reqType = CPosRequestor::ERequestPeriodic; + else + reqType = CPosRequestor::ERequestSingleShot; + + TPosRequestSource source(RequestSource()); + if (source == EPosRequestSourceNotAvailable) + { + CompleteCurrentAndContinue(KErrNone); + } + else + { + + TPosRequestDecision decision(QueryTimeoutStrategy()); + + iRtorProcessor->iRequestType=reqType; + iRtorProcessor->iRequestDecision=decision; + iRtorProcessor->iDialogType=CLpdRequestorProcessor::EQuery; + + iVerifierQuery = CLpdVerifierQueryLauncher::NewL(*this); + // Ownership NOT transferred + iVerifierQuery->SetRequestInfoL(iRtorProcessor); + + iVerifierQuery->StartQueryL(); + } + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNextNotificationL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNextNotificationL() + { + __ASSERT_DEBUG( iCurrentRequest != KPosNullQNRequestId, + HandleAssertErrorL() ); + + // There is no differentiation now for periodic and single shot notifications + HandleNextNonPeriodicNotificationL(); + } +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleNextNonPeriodicNotificationL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleNextNonPeriodicNotificationL() + { + + __ASSERT_DEBUG( iCurrentRequest != KPosNullQNRequestId, + HandleAssertErrorL() ); + __ASSERT_DEBUG( !iNotifier, HandleAssertErrorL() ); + + if (RequestSource() != EPosRequestSourceNetwork) + { // Notifications are supported only for network requests + User::Leave(KErrNotSupported); + } + + TPosNotificationReason reason = NotificationReason(); + TPosRequestDecision decision = LocationRequestDecision(); + iRtorProcessor->iNotifReason=reason; + iRtorProcessor->iDialogType=CLpdRequestorProcessor::ENotification; + iRtorProcessor->iRequestDecision=decision; + + iNotifier = CLpdNotifierQueryLauncher::NewL(*this); + iNotifier->SetRequestInfoL(iRtorProcessor); + iNotifier->StartQueryL(); + } + + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::CompleteCurrentAndContinue +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::CompleteCurrentAndContinue(TInt aResultCode) + { + if (iCurrentRequest != KPosNullQNRequestId) + { + CompleteRequest(iCurrentRequest, aResultCode); + } + iCurrentRequest = KPosNullQNRequestId; + + __ASSERT_DEBUG( iRequestActiveObject, HandleDebugAssertError() ); + iRequestActiveObject->ScheduleRequest(); // handle next req. + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::FreeQueryResources +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::FreeQueryResources() + { + iCurrentRequest = KPosNullQNRequestId; + delete iVerifierQuery; + iVerifierQuery = NULL; + iVerifyResult = KErrGeneral; + delete iNotifier; + iNotifier = NULL; + if (iRtorProcessor) + { // if already construction fails iRtorProcessor may + // be NULL, otherwise it points to an instance. + iRtorProcessor->ResetAndDestroyRequestors(); + } + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleAssertErrorL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleAssertErrorL() const + { +#ifdef _DEBUG + User::Panic(KPanicText, KLpdErrGeneral); +#else + User::Leave( KErrCorrupt ); +#endif + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::HandleDebugAssertError +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierPlugin::HandleDebugAssertError() const + { +#ifdef _DEBUG + User::Panic(KPanicText, KLpdErrGeneral); +#endif + } + + +// ----------------------------------------------------------------------------- +// CLpdVerifierPlugin::CheckRequestTypeL +// Checks the type of request and helps to know +// if a given request is of SUPL periodic type +// @param aCurrentRequest request id +// @return TRequestType type of request enum +// ----------------------------------------------------------------------------- +CPosRequestor::TRequestType CLpdVerifierPlugin::CheckRequestTypeL() + { + CPosRequestor::TRequestType reqType = CPosRequestor::ENetworkTypeUnknown; + if (RequestorCountL() > 0) + { + CPosRequestor* requestor = RequestorLC(0); + reqType = requestor->RequestType(); + CleanupStack::PopAndDestroy(requestor); + } + return reqType; + } + + +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdverifierquerylauncher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdverifierquerylauncher.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2010 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: Class which handles the dialog and expiration timer. +* +*/ + + +// INCLUDE FILES +#include "lpdverifierquerylauncher.h" +#include "lpdglobalplugindialog.h" +#include "lpdresulthandler.h" + +// CONSTANTS + + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CLpdVerifierQueryLauncher::CLpdVerifierQueryLauncher +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CLpdVerifierQueryLauncher::CLpdVerifierQueryLauncher( + MLpdResultHandler& aHandler ) + : CLpdQueryLauncherBase( aHandler ) + { + // Intentionally empty + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierQueryLauncher::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CLpdVerifierQueryLauncher::ConstructL() + { + CLpdQueryLauncherBase::ConstructL(); + } + +// ----------------------------------------------------------------------------- +// CLpdVerifierQueryLauncher::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CLpdVerifierQueryLauncher* CLpdVerifierQueryLauncher::NewL( + MLpdResultHandler& aHandler ) + { + CLpdVerifierQueryLauncher* self = + new( ELeave ) CLpdVerifierQueryLauncher( aHandler ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// Destructor +CLpdVerifierQueryLauncher::~CLpdVerifierQueryLauncher() + { + // Intentionally empty + } + + +// ----------------------------------------------------------------------------- +// CLpdVerifierQueryLauncher::ExtendedHandleDlgDismissedL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CLpdVerifierQueryLauncher::ExtendedHandleDlgDismissedL() + { + iHandler.HandleVerificationResultL( iResult ); + } + +void CLpdVerifierQueryLauncher::RequestType(TRequestType& aRequestType) + { + aRequestType = CLpdQueryLauncherBase::EVerification; + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/apilogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/apilogger.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2010 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + +#ifndef APILOGGER_H +#define APILOGGER_H + +#include +#include +#include +#include +#include + +using namespace std; + + +class ApiLogger + { + public: + static void OpenLogFile(); + static void CloseLogFile(); + static void MyOutputHandler(QtMsgType type, const char *msg); + }; + +#endif // APILOGGER_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/customdocumentloader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/customdocumentloader.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 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: Header file for Custom docml loader + * + */ + + +#ifndef CUSTOMDOCUMENTLOADER_H +#define CUSTOMDOCUMENTLOADER_H +#include + +//Forward Declarations + +class CustomDocumentLoader : public HbDocumentLoader +{ + +public: + + /** + * Constructor. + */ + CustomDocumentLoader(); + + /** + * Destructor. + */ + ~CustomDocumentLoader(); + +public: + + /** + * from base class + */ + QObject *createObject(const QString& type, const QString &name); + +}; + +#endif /* CUSTOMDOCUMENTLOADER_H */ diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/posverificationcustomdialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/posverificationcustomdialog.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2010 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: Header file for Custom PosVerification dialog + * + */ + +#ifndef POSVERIFICATIONCUSTOMDIALOG_H +#define POSVERIFICATIONCUSTOMDIALOG_H + +#include +#include +#include +#include + + +class CustomDocumentLoader; + +class PosVerificationCustomDialog : public HbDialog, + public HbDeviceDialogInterface + + { +Q_OBJECT +Q_PROPERTY( QString heading READ getHeading WRITE setHeading ) +Q_PROPERTY( QString queryText READ getQueryText WRITE setQueryText ) +Q_PROPERTY( QString queryText2 READ getQueryText2 WRITE setQueryText2 ) +Q_PROPERTY( QStringList requestor READ getRequestor WRITE setRequestor ) + +public: + + /* + * Constructor + */ + PosVerificationCustomDialog(); + + /** + * Destructor + */ + ~PosVerificationCustomDialog(); + +public: + /** + * This method gets the widget from the application desginer docml file. + * param[in]- loader, instance of CustomDocumentLoader + */ + void getWidgets(const CustomDocumentLoader &loader); + + //from HbDeviceDialogInterface +public: + /** + * Set device dialog widget parameters. This function may be called after the widget is created + * to update widget parameters. parameters contains widget parameters.The structure and meaning + * of parameters is a contract between the plugin and a client. + * @param[in] - parameters, QVariantMap, containing the key value pair for the properties + * @returns- bool, Returns true on success or false on failure. + */ + bool setDeviceDialogParameters(const QVariantMap ¶meters); + + /** + * Returns an error last occurred. Error code ranges are defined in HbDeviceDialog. + * The code is passed to a client by device dialog framework + * @returns- int, error code + */ + int deviceDialogError() const; + + /** + * Closes a device dialog widget gracefully. This function may called due to device dialog client + * calling HbDeviceDialog::cancel() or by device dialog service if it decides that a dialog needs + * to be closed. Device dialog widget may also close itself without this function being called. + * byClient is true if client initiated the closing. Otherwise the closing was initiated by the device + * dialog framework. The widget may also be deleted at any time ungracefully without closeDeviceDialog() + * being called. + */ + void closeDeviceDialog(bool byClient); + + /** + * Returns a pointer to a widget that implements the user interface of the device dialog. + * @returns- HbPopup, pointer to the widget + */ + HbPopup * deviceDialogWidget() const; + +signals: + void deviceDialogClosed(); + void deviceDialogData(QVariantMap data); + +private: + + /** + * This method is used to set the name of requestors + * requesting for position, in the verification dialog + * @param [in] - requestorList, list of names of the requestors + */ + void setRequestor(QStringList& requestorList); + + /** + * This method is used to gets the name of requestors + * requesting for position, in the verification dialog + * @returns - QStringList, list of names of the requestors + */ + QStringList getRequestor(); + + /** + * This method is used to set the heading for the dialog + * @param [in] - heading, string to be set as the heading for the dialog + */ + void setHeading(QString& heading); + + /** + * This method is used to get the heading for the dialog + * @returns - QString, heading for the dialog + */ + QString getHeading(); + + /** + * This method is used to set the query text to be displayed, depending on the + * policy. + * @param [in] - textQuery, string to be set as the query for the dialog + */ + void setQueryText(QString& textQuery); + + /** + * This method is used to get the query text displayed, depending on the + * policy. + * @returns - QString, query for the dialog + */ + QString getQueryText(); + + /** + * This method is used to set the query text to be displayed, depending on the + * policy. + * @param [in] - textQuery, string to be set as the query line 2 for the dialog + */ + void setQueryText2(QString& textQuery); + + /** + * This method is used to get the query text line 2 displayed, depending on the + * policy. + * @returns - QString, query line 2 for the dialog + */ + QString getQueryText2(); + + /** + * This method sets the properties for the widget. + * The property value is validated before the property is set. + * @param[in] - parameters, QVariantMap, containing the key value pair for the properties + * @returns- bool, Returns true on success or false on failure. + */ + bool setProperties(const QVariantMap& parameters); + +private slots: + /** + * This slot is called on acceting the query dialog + */ + void posVerificationdlgAccepted(); + + /** + * This slot is called on rejecting the query dialog + */ + void posVerificationdlgRejected(); + + //member data +private: + /** + * heading label for the device dialog + * Owns + */ + HbLabel * mHeadingLabel; + + /** + * primary action (SK1) for the device dialog + * owns + */ + HbAction * mPrimaryAction; + + /** + * query text label + * owns + */ + HbLabel * mQueryText; + + /** + * query text label (line 2) + * Changes as per the first query text + * owns + */ + HbLabel * mQueryText2; + + /** + * Widget containing the list of the requestors + * owns + */ + HbWidget * mRequestorList; + + /** + * list of names of the reqestors + * owns + */ + QStringList mRequestorListItems; + + /** + * secondry action (SK2) for the device dialog + * owns + */ + HbAction * mSecondryAction; + + }; + +#endif // POSVERIFICATIONCUSTOMDIALOG_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/posverificationdialogplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/inc/posverificationdialogplugin.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2010 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: Header file for Custom PosVerification dialog + * + */ + +#ifndef POSVERIFICATION_DIALOG_PLUGIN_H +#define POSVERIFICATION_DIALOG_PLUGIN_H + +#include +#include + +class PosVerificationDialogPlugin : public HbDeviceDialogPlugin + { +Q_OBJECT + +public: + /** + * Constructor + */ + PosVerificationDialogPlugin(); + + /** + * Destrcutor + */ + ~PosVerificationDialogPlugin(); + + /** + * Checks if client is allowed use the device dialog that the plugin creates. + * Device dialog service calls this function before creating a device dialog or + * attaching into an existing one if flag HbDeviceDialogPlugin::SecurityCheck is set. + * The implementation is operating system dependent. + * @returns- bool, Returns true if client is allowed to use the device dialog. + * @param[in] - deviceDialogType Device dialog type. + * @param[in] - parameters Device dialog parameters. + * @param[in] - securityInfo Information for security check. Content is operating system dependent. + * The format is pairs. Currently only Symbian is defined. + */ + + bool + accessAllowed(const QString ¬ificationType, + const QVariantMap ¶meters, + const QVariantMap &securityInfo) const; + + /** + * Create a device dialog instance compatible with the version requested. + * This could always be the latest version if it is backwards compatible with older versions. + * Device dialog framework is unaware of version numbers in type strings. It performs string + * comparison of the whole string when searching for a plugin + * @param[in] - deviceDialogType Device dialog type. + * @param[in] - parameters Device dialog parameters. + * @returns - HbDeviceDialogInterface, device dialog instance + */ + + HbDeviceDialogInterface *createDeviceDialog( + const QString &deviceDialogType, const QVariantMap ¶meters); + + /** + * Gets information of the device dialog created by the plugin. Device dialog manager calls + * this function before creating the device dialog widget to check HbDeviceDialogPlugin::DeviceDialogGroup, + * HbDeviceDialogPlugin::DeviceDialogFlag and priority. + * @returns - true if device dialog information returned is valid. + */ + + bool deviceDialogInfo(const QString &deviceDialogType, + const QVariantMap ¶meters, DeviceDialogInfo *info) const; + + /** + * Returns a list of device dialog types the plugin implements. A plugin may implement + * several device dialog types. By convention device dialog type strings should follow + * inverted domain name format + * @returns - list of device dialog types + */ + QStringList deviceDialogTypes() const; + + /** + * @returns - plugin flags + */ + HbDeviceDialogPlugin::PluginFlags pluginFlags() const; + + /** + * Returns an error last occurred. Error code ranges are defined in HbDeviceDialog. The code + * is passed to a client by device dialog framework + * @returns- errorcode + */ + int error() const; + +private: + + + /** + * instance of translator + * owns + */ + QTranslator * mTranslator; + }; + +#endif // POSVERIFICATION_DIALOG_PLUGIN_H diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/posverificationdialogplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/posverificationdialogplugin.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,48 @@ +# 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: project file for positioing settings in control panel +TEMPLATE = lib +TARGET = posverificationdialogplugin +DEPENDPATH += . +INCLUDEPATH += ../inc +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +CONFIG += hb \ + plugin +MOC_DIR = moc +OBJECTS_DIR = obj +RCC_DIR = rcc +RESOURCES = resources/posverificationdialog.qrc + +#Uncomment following line to disable logging +#DEFINES += QT_NO_DEBUG_OUTPUT + +# Platforms +SYMBIAN_PLATFORMS = WINSCW \ + ARMV5 +symbian::TARGET.UID3 = 0x2002E718 +SOURCES += src/apilogger.cpp \ + src/posverificationdialogplugin.cpp \ + src/customdocumentloader.cpp \ + src/posverificationcustomdialog.cpp +HEADERS += inc/apilogger.h \ + inc/posverificationdialogplugin.h \ + inc/customdocumentloader.h \ + inc/posverificationcustomdialog.h +symbian: { + TARGET.CAPABILITY = CAP_GENERAL_DLL + TARGET.EPOCALLOWDLLDATA = 1 + pluginstub.sources = posverificationdialogplugin.dll + + # This is for new exporting system coming in garden + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" + pluginstub.path = /resource/plugins/devicedialogs + DEPLOYMENT += pluginstub +} + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/resources/posverificationcustomdialog.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/resources/posverificationcustomdialog.docml Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/resources/posverificationdialog.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/resources/posverificationdialog.qrc Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ + + + posverificationcustomdialog.docml + + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/apilogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/apilogger.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2010 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 class provides function that help in logging entry and exit of APIs of classes +* +*/ + + +#include "apilogger.h" +#include + +const char* debugFileName("c://logs//lbs//posverificationdlg.txt"); +ofstream logfile; + +void ApiLogger::OpenLogFile() +{ + logfile.open(debugFileName, ios::app); +} + +void ApiLogger::CloseLogFile() +{ + logfile.flush(); + logfile.close(); +} + +void ApiLogger::MyOutputHandler(QtMsgType type, const char *msg) +{ + switch (type) { + case QtDebugMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; + break; + case QtCriticalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n"; + break; + case QtWarningMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n"; + break; + case QtFatalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << "\n"; + default: + break; + } + logfile.flush(); +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/customdocumentloader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/customdocumentloader.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2010 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 implements the custom dialog loader for posverification dialogs + * + */ + +#include "customdocumentloader.h" +#include "posverificationcustomdialog.h" + +// --------------------------------------------------------------------------- +// CustomDocumentLoader::CustomDocumentLoader() +// --------------------------------------------------------------------------- +// +CustomDocumentLoader::CustomDocumentLoader() + { + } + +// --------------------------------------------------------------------------- +// CustomDocumentLoader::~CustomDocumentLoader() +// --------------------------------------------------------------------------- +// +CustomDocumentLoader::~CustomDocumentLoader() + { + } + +// --------------------------------------------------------------------------- +// CustomDocumentLoader::createObject +// --------------------------------------------------------------------------- +// +QObject *CustomDocumentLoader::createObject(const QString& type, + const QString &name) + { + //for CustomDialog + if (type == PosVerificationCustomDialog::staticMetaObject.className()) + { + QObject *object = new PosVerificationCustomDialog; + object->setObjectName(name); + return object; + } + //default case + return HbDocumentLoader::createObject(type, name); + } diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/posverificationcustomdialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/posverificationcustomdialog.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2010 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 implements the custom dialog for positioning verification dialogs + * + */ + +#include "posverificationcustomdialog.h" +#include "customdocumentloader.h" + +#include +#include +#include + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::PosVerificationCustomDialog +//--------------------------------------------------------------- +PosVerificationCustomDialog::PosVerificationCustomDialog() : + mHeadingLabel(NULL), mPrimaryAction(NULL), mQueryText(NULL), mQueryText2( + NULL), mRequestorList(NULL), mRequestorListItems(NULL), + mSecondryAction(NULL) + { + qDebug() << "PosVerificationCustomDialog::PosVerificationCustomDialog()"; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::~PosVerificationCustomDialog +//--------------------------------------------------------------- +PosVerificationCustomDialog::~PosVerificationCustomDialog() + { + qDebug() + << "+PosVerificationCustomDialog::~PosVerificationCustomDialog()"; + /* + delete mHeadingLabel; + mHeadingLabel = NULL; + + delete mPrimaryAction; + mPrimaryAction = NULL; + + delete mQueryText; + mQueryText = NULL; + + mRequestorListItems.clear(); + + delete mRequestorList; + mRequestorList = NULL; + + delete mSecondryAction; + mSecondryAction = NULL; + */ + delete mQueryText2; + mQueryText2 = NULL; + + qDebug() + << "-PosVerificationCustomDialog::~PosVerificationCustomDialog()"; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setProperties +// Set properties +//--------------------------------------------------------------- + +bool PosVerificationCustomDialog::setProperties(const QVariantMap& parameters) + { + qDebug() << "+PosVerificationCustomDialog::setProperties()"; + QVariantMap::const_iterator i = parameters.constBegin(); + while (i != parameters.constEnd()) + { + QByteArray key = i.key().toAscii(); + qDebug() << "-PosVerificationCustomDialog::setProperties(): Key is " + << key; + qDebug() << "-PosVerificationCustomDialog::setProperties(): data is " + << key.constData(); + //check for the validity of the data + if (property(key.constData()).isValid()) + { + //sets the property values + setProperty(key.constData(), i.value()); + } + else + { + qDebug() + << "-PosVerificationCustomDialog::setProperties(): value - false"; + return false; + } + ++i; + } + qDebug() << "-PosVerificationCustomDialog::setProperties()"; + return true; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setDeviceDialogParameters +//--------------------------------------------------------------- +bool PosVerificationCustomDialog::setDeviceDialogParameters( + const QVariantMap ¶meters) + { + qDebug() << "+PosVerificationCustomDialog::setDeviceDialogParameters()"; + setModal(true); + setTimeout(HbPopup::NoTimeout); + qDebug() << "-PosVerificationCustomDialog::setDeviceDialogParameters()"; + return setProperties(parameters); + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::deviceDialogError +//--------------------------------------------------------------- +int PosVerificationCustomDialog::deviceDialogError() const + { + qDebug() << "PosVerificationCustomDialog::deviceDialogError()"; + return 0; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::closeDeviceDialog +//--------------------------------------------------------------- +void PosVerificationCustomDialog::closeDeviceDialog(bool byClient) + { + qDebug() << "+PosVerificationCustomDialog::closeDeviceDialog()"; + Q_UNUSED(byClient); + close(); + emit + deviceDialogClosed(); + qDebug() << "-PosVerificationCustomDialog::closeDeviceDialog()"; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::deviceDialogWidget +//--------------------------------------------------------------- +HbPopup* PosVerificationCustomDialog::deviceDialogWidget() const + { + qDebug() << "PosVerificationCustomDialog::deviceDialogWidget()"; + return const_cast (this); + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setHeading +//--------------------------------------------------------------- +void PosVerificationCustomDialog::setHeading(QString& heading) + { + qDebug() << "+PosVerificationCustomDialog::setHeading()" << heading; + mHeadingLabel->setPlainText(heading); + qDebug() << "-PosVerificationCustomDialog::setHeading()"; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::getHeading +//--------------------------------------------------------------- +QString PosVerificationCustomDialog::getHeading() + { + qDebug() << "PosVerificationCustomDialog::getHeading()"; + return mHeadingLabel->plainText(); + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setQueryText +//--------------------------------------------------------------- +void PosVerificationCustomDialog::setQueryText(QString& textQuery) + { + qDebug() << "+PosVerificationCustomDialog::setQueryText()" << textQuery; + mQueryText->setPlainText(textQuery); + qDebug() << "-PosVerificationCustomDialog::setQueryText()"; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::getQueryText +//--------------------------------------------------------------- +QString PosVerificationCustomDialog::getQueryText() + { + qDebug() << "PosVerificationCustomDialog::getQueryText()"; + return mQueryText->plainText(); + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setQueryText2 +//--------------------------------------------------------------- +void PosVerificationCustomDialog::setQueryText2(QString& textQuery) + { + qDebug() << "+PosVerificationCustomDialog::setQueryText2()" << textQuery; + mQueryText2 = new HbLabel(); + if (mQueryText2) + { + mQueryText2->clear(); + mQueryText2->setPlainText(textQuery); + mQueryText2->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + } + qDebug() << "-PosVerificationCustomDialog::setQueryText2()"; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::getQueryText2 +//--------------------------------------------------------------- +QString PosVerificationCustomDialog::getQueryText2() + { + qDebug() << "PosVerificationCustomDialog::getQueryText2()"; + if (mQueryText2) + { + return mQueryText2->plainText(); + } + return ""; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::getWidgets +//--------------------------------------------------------------- +void PosVerificationCustomDialog::getWidgets( + const CustomDocumentLoader &loader) + { + qDebug() << "+PosVerificationCustomDialog::getWidgets()"; + + mHeadingLabel = qobject_cast (loader.findWidget("heading")); + Q_ASSERT_X((mHeadingLabel != 0), "PosVerificationCustomDialog", "invalid DocML file"); + + mQueryText = qobject_cast (loader.findWidget("queryText_1")); + Q_ASSERT_X((mQueryText != 0), "PosVerificationCustomDialog", "invalid DocML file"); + + mRequestorList + = qobject_cast (loader.findWidget("requestors")); + Q_ASSERT_X((mRequestorList != 0), "PosVerificationCustomDialog", "invalid DocML file"); + + mPrimaryAction = qobject_cast (loader.findObject( + "qtl_dialog_softkey_2_left")); + Q_ASSERT_X((mPrimaryAction != 0), "PosVerificationCustomDialog", "invalid DocML file"); + QObject::connect(mPrimaryAction, SIGNAL(triggered()), this, + SLOT(posVerificationdlgAccepted())); + + mSecondryAction = qobject_cast (loader.findObject( + "qtl_dialog_softkey_2_right")); + Q_ASSERT_X((mSecondryAction != 0), "PosVerificationCustomDialog", "invalid DocML file"); + + QObject::connect(mSecondryAction, SIGNAL(triggered()), this, + SLOT(posVerificationdlgRejected())); + qDebug() << "-PosVerificationCustomDialog::getWidgets()"; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::setRequestor +//--------------------------------------------------------------- +void PosVerificationCustomDialog::setRequestor(QStringList& requestorList) + { + qDebug() << "+PosVerificationCustomDialog::setRequestor()"; + int rowadd = 1; + mRequestorListItems = requestorList; + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + if (!layout) + { + qDebug() << "setRequestor(): Creating layout failed"; + return; + } + + qreal margin = 0; + qreal leftmargin = 0; + style()->parameter("hb-param-margin-gene-middle-vertical", margin); + style()->parameter("hb-param-margin-gene-popup", leftmargin); + QSizePolicy policy; + policy.setHorizontalPolicy(QSizePolicy::Preferred); + policy.setVerticalPolicy(QSizePolicy::Ignored); + if (mQueryText2) + { + mQueryText2->setSizePolicy(policy); + mQueryText2->setAlignment(Qt::AlignTop); + layout->addItem(mQueryText2, 1, 0); + layout->setRowSpacing(1, margin); + layout->setContentsMargins(leftmargin, 0, 0, 0); + rowadd = 2; + } + + QStringList::const_iterator iterator; + for (iterator = requestorList.begin(); iterator != requestorList.end(); ++iterator) + { + int i = iterator - requestorList.begin(); + HbLabel * requestorName = new HbLabel(); + if (requestorName) + { + qDebug() << "setRequestor()" << *iterator; + requestorName->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); + requestorName->setPlainText(*iterator); + requestorName->setSizePolicy(policy); + requestorName->setAlignment(Qt::AlignTop); + + layout->addItem(requestorName, i + rowadd, 0); + layout->setRowSpacing(i + rowadd, margin); + layout->setContentsMargins(leftmargin, 0, 0, 0); + } + } + mRequestorList->setSizePolicy(policy); + mRequestorList->setLayout(layout); + qDebug() << "-PosVerificationCustomDialog::setRequestor()"; + } + +//--------------------------------------------------------------- +//PosVerificationCustomDialog::getRequestor +//--------------------------------------------------------------- +QStringList PosVerificationCustomDialog::getRequestor() + { + qDebug() << "PosVerificationCustomDialog::getRequestor()"; + return mRequestorListItems; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::posVerificationdlgAccepted +//--------------------------------------------------------------- +void PosVerificationCustomDialog::posVerificationdlgAccepted() + { + qDebug() << "+PosVerificationCustomDialog::posVerificationdlgAccepted()"; + emit + deviceDialogClosed(); + qDebug() << "-PosVerificationCustomDialog::posVerificationdlgAccepted()"; + } +//--------------------------------------------------------------- +//PosVerificationCustomDialog::posVerificationdlgRejected +//--------------------------------------------------------------- +void PosVerificationCustomDialog::posVerificationdlgRejected() + { + qDebug() << "+PosVerificationCustomDialog::posVerificationdlgRejected()"; + QVariantMap *data = new QVariantMap(); + QVariant value(-21); + if (data) + { + data->insert("errorCode", value); + emit + deviceDialogData(*data); + } + //data is currently not being used in the client side + emit + deviceDialogClosed(); + delete data; + qDebug() << "-PosVerificationCustomDialog::posVerificationdlgRejected()"; + } + +// End of File + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/posverificationdialogplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/posverificationdialogplugin/src/posverificationdialogplugin.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2010 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 file implements the plugin interface for positioning verification dialogs + * + */ +#include "posverificationdialogplugin.h" +//User Includes +#include "customdocumentloader.h" +#include "posverificationcustomdialog.h" +#include "apilogger.h" + +#include +#include + +//Carbide Application docml file +const char *POSVERFICATIONDIALOG_DOCML = + ":/xml/posverificationcustomdialog.docml"; + +// This plugin implements one custom dialog type +enum DeviceDlgType + { + PosVerificationDialogType + }; +static const struct + { + const char *mTypeString; + DeviceDlgType mType; + } verdlgtypes[] = + { + { + "hb.posverifiction.dialog/1.0", PosVerificationDialogType + } + }; + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::PosVerificationDialogPlugin() +// Constructor +//----------------------------------------------------------------------- +PosVerificationDialogPlugin::PosVerificationDialogPlugin() : + mTranslator(NULL) + { + qDebug() << "+PosVerificationDialogPlugin::PosVerificationDialogPlugin()"; + mTranslator = new QTranslator(); + + QString lang = QLocale::system().name(); + QString path = "z:/resource/qt/translations/"; + QString altpath = "c://resource/"; + bool loaded = false; + loaded = mTranslator->load(path + QString("lilocationmw_") + lang); + if (loaded == false) + { + loaded = mTranslator->load(altpath + QString("lilocationmw_") + lang); + } + if (loaded) + { + qApp->installTranslator(mTranslator); + } + //#ifndef QT_NO_DEBUG_OUTPUT + // ApiLogger::OpenLogFile(); + // qInstallMsgHandler(ApiLogger::MyOutputHandler); + //#endif + qDebug() << "-PosVerificationDialogPlugin::PosVerificationDialogPlugin()"; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::~PosVerificationDialogPlugin() +// Destructor +//----------------------------------------------------------------------- +PosVerificationDialogPlugin::~PosVerificationDialogPlugin() + { + qDebug() + << "+PosVerificationDialogPlugin::~PosVerificationDialogPlugin()"; + if (mTranslator) + { + if (mTranslator->isEmpty() == false) + qApp->removeTranslator(mTranslator); + delete mTranslator; + } + qDebug() + << "-PosVerificationDialogPlugin::~PosVerificationDialogPlugin()"; + //#ifndef QT_NO_DEBUG_OUTPUT + // ApiLogger::CloseLogFile(); + //#endif + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::accessAllowed +// Check if client is allowed to use device dialog widget +//----------------------------------------------------------------------- +bool PosVerificationDialogPlugin::accessAllowed( + const QString &deviceDialogType, const QVariantMap ¶meters, + const QVariantMap &securityInfo) const + { + qDebug() << "+PosVerificationDialogPlugin::accessAllowed()"; + Q_UNUSED(deviceDialogType) + Q_UNUSED(parameters) + Q_UNUSED(securityInfo) + + // This plugin doesn't perform operations that may compromise security. All clients + // are allowed to use. + qDebug() << "-PosVerificationDialogPlugin::accessAllowed()"; + return true; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::createDeviceDialog +// Create device dialog widget +//----------------------------------------------------------------------- +HbDeviceDialogInterface * PosVerificationDialogPlugin::createDeviceDialog( + const QString &deviceDialogType, const QVariantMap ¶meters) + { + qDebug() << "+PosVerificationDialogPlugin::createDeviceDialog(): Type" + << deviceDialogType; + int i; + PosVerificationCustomDialog * dialog = 0; + const int numTypes = sizeof(verdlgtypes) / sizeof(verdlgtypes[0]); + for (i = 0; i < numTypes; ++i) + { + if (verdlgtypes[i].mTypeString == deviceDialogType) + { + break; + } + } + if (i < numTypes) + { + switch (verdlgtypes[i].mType) + { + case PosVerificationDialogType: + { + CustomDocumentLoader loader; + bool ok = false; + loader.load(POSVERFICATIONDIALOG_DOCML, &ok); + Q_ASSERT_X(ok, "PosVerificationCustomDialog", "invalid DocML file"); + + if (ok) + { + dialog = qobject_cast ( + loader.findWidget("PosVerificationCustomDialog")); + if (dialog) + { + dialog->getWidgets(loader); + dialog->setDeviceDialogParameters(parameters); + qDebug() << "createDeviceDialog(): success"; + } + else + { + qDebug() + << "createDeviceDialog(): creation of device dialog failed"; + } + } + else + { + qDebug() << "createDeviceDialog(): loading docml failed"; + } + break; + } + default: + { + qDebug() << "createDeviceDialog(): default case"; + Q_ASSERT(false); + break; + } + } + } + else + { + qDebug() + << "createDeviceDialog(): Dialog type not supported by this plugin"; + } + qDebug() << "-PosVerificationDialogPlugin::createDeviceDialog()"; + return dialog; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::deviceDialogInfo +// Return information of device dialog the plugin creates +//----------------------------------------------------------------------- +bool PosVerificationDialogPlugin::deviceDialogInfo( + const QString &deviceDialogType, const QVariantMap ¶meters, + DeviceDialogInfo *info) const + { + qDebug() << "+PosVerificationDialogPlugin::deviceDialogInfo()"; + Q_UNUSED(parameters) + Q_UNUSED(deviceDialogType) + + info->group = GenericDeviceDialogGroup; + info->flags = NoDeviceDialogFlags; + info->priority = DefaultPriority; + qDebug() << "-PosVerificationDialogPlugin::deviceDialogInfo()"; + return true; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::deviceDialogTypes +// Return device dialog types this plugin implements +//----------------------------------------------------------------------- +QStringList PosVerificationDialogPlugin::deviceDialogTypes() const + { + qDebug() << "+PosVerificationDialogPlugin::deviceDialogTypes()"; + QStringList types; + const int numTypes = sizeof(verdlgtypes) / sizeof(verdlgtypes[0]); + for (int i = 0; i < numTypes; i++) + { + types.append(verdlgtypes[i].mTypeString); + } + qDebug() << "-PosVerificationDialogPlugin::deviceDialogTypes()"; + return types; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::pluginFlags +// Return plugin flags +//----------------------------------------------------------------------- +HbDeviceDialogPlugin::PluginFlags PosVerificationDialogPlugin::pluginFlags() const + { + qDebug() << "PosVerificationDialogPlugin::pluginFlags()"; + return NoPluginFlags; + } + +//----------------------------------------------------------------------- +// PosVerificationDialogPlugin::error +// Return last error +//----------------------------------------------------------------------- +int PosVerificationDialogPlugin::error() const + { + qDebug() << "PosVerificationDialogPlugin::error()"; + return 0; + } + +Q_EXPORT_PLUGIN2(posverificationdialogplugin, PosVerificationDialogPlugin) + diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/privacyverifiernotifierui.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/privacyverifiernotifierui.pro Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,34 @@ +# +# Copyright (c) 2010 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: project file for positioing settings in control panel +# + + +TEMPLATE = subdirs + +SYMBIAN_PLATFORMS = WINSCW ARMV5 + +SUBDIRS += locnotificationengine/locnotificationengine.pro +SUBDIRS += posverificationdialogplugin/posverificationdialogplugin.pro + +# Build.inf rules +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \ + "install/privacydialogs_stub.sis /epoc32/data/z/system/install/privacydialogs_stub.sis" \ + "rom/privacydialogs.iby CORE_MW_LAYER_IBY_EXPORT_PATH(privacydialogs.iby)" + +symbian { +BLD_INF_RULES.prj_mmpfiles = "./locutils/group/locutils.mmp" \ + "./locprivacyserver/group/locprivacyserver.mmp" \ + "./contactresolversession/group/contactresolversession.mmp" \ + "./locverifier/group/locverifierdlg.mmp" +} diff -r 6f8759468fd4 -r 7409e6184c90 locationsystemui/locationsysui/privacyverifiernotifierui/rom/privacydialogs.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationsystemui/locationsysui/privacyverifiernotifierui/rom/privacydialogs.iby Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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: IBY file for server component +* +*/ +#ifndef __PRIVACYDIALOGS_IBY__ +#define __PRIVACYDIALOGS_IBY__ + +#include +#if defined(__PRIVACYFRAMEWORK) +// Client library +file=ABI_DIR\BUILD_DIR\locnotificationclient.dll SHARED_LIB_DIR\locnotificationclient.dll +// Server +file=ABI_DIR\BUILD_DIR\locnotificationserver.exe PROGRAMS_DIR\locnotificationserver.exe +// Engine +file=ABI_DIR\BUILD_DIR\locnotificationengine.dll SHARED_LIB_DIR\locnotificationengine.dll +// Location Utils +file=ABI_DIR\BUILD_DIR\locutils.dll SHARED_LIB_DIR\locutils.dll +// Location Verifier Plug-in +ECOM_PLUGIN(locverifierdlg.dll,locverifierdlg.rsc) +// Custom device dialog plugin +file=ABI_DIR\BUILD_DIR\posverificationdialogplugin.dll SHARED_LIB_DIR\posverificationdialogplugin.dll +data=\epoc32\data\z\resource\plugins\devicedialogs\posverificationdialogplugin.qtplugin \resource\plugins\devicedialogs\posverificationdialogplugin.qtplugin +// stub sis +data=DATAZ_\system\install\privacydialogs_stub.sis system\install\privacydialogs_stub.sis +#endif // (__PRIVACYFRAMEWORK) + +#endif diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/group/bld.inf --- a/locationtriggering/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -19,7 +19,7 @@ #include PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS #ifdef CORE_MW_LAYER_IBY_EXPORT_PATH diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/ltcontainer/group/bld.inf --- a/locationtriggering/ltcontainer/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/ltcontainer/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -17,7 +17,7 @@ PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS ../inc/lbtcontainer.h |../../inc/lbtcontainer.h @@ -31,8 +31,7 @@ ../inc/lbtsecuritypolicy.h |../../inc/lbtsecuritypolicy.h // Registration file for backup and restore -../data/backup_registration.xml /epoc32/winscw/c/private/1028312B/backup_registration.xml -../data/backup_registration.xml /epoc32/data/z/private/1028312B/backup_registration.xml +../data/backup_registration.xml z:/private/1028312B/backup_registration.xml PRJ_MMPFILES diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/ltcontainer/inc/lbtcontainerutilities.h --- a/locationtriggering/ltcontainer/inc/lbtcontainerutilities.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/ltcontainer/inc/lbtcontainerutilities.h Thu Jul 22 16:37:56 2010 +0100 @@ -116,7 +116,7 @@ * * @return ETrue if the UIDs suffices the security polity, EFalse otherwise */ - static TBool LbtContainerUtilities::RunSecurityPolicy( TUid& aOwnerUid, + static TBool RunSecurityPolicy( TUid& aOwnerUid, TUid& aManagerUid, TSecureId& aStartupProcessUid, TLbtSecurityPolicy& aSecurityPolicy ); diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/rom/locationtriggering.iby --- a/locationtriggering/rom/locationtriggering.iby Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/rom/locationtriggering.iby Thu Jul 22 16:37:56 2010 +0100 @@ -51,8 +51,6 @@ // Backup and restore registeration file data=DATAZ_\private\1028312B\backup_registration.xml \private\1028312B\backup_registration.xml -// Central repository file -data=DATAZ_\private\10202be9\1028312F.txt \private\10202be9\1028312F.txt // Location Triggering Management Library file=ABI_DIR\BUILD_DIR\lbtmanager.dll SHARED_LIB_DIR\lbtmanager.dll diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/Additionaltests/bwins/Additionaltestsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/Additionaltests/bwins/Additionaltestsu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/Additionaltests/eabi/Additionaltestsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/Additionaltests/eabi/Additionaltestsu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI17CLbtEventObserver @ 2 NONAME + _ZTI20CTriggerFireObserver @ 3 NONAME + _ZTV17CLbtEventObserver @ 4 NONAME + _ZTV20CTriggerFireObserver @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/Additionaltests/inc/AsynOperationAO.h --- a/locationtriggering/tsrc/lbtengine_test/Additionaltests/inc/AsynOperationAO.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/Additionaltests/inc/AsynOperationAO.h Thu Jul 22 16:37:56 2010 +0100 @@ -96,7 +96,7 @@ void ListTriggerIdsList(RLbt& aLbt, RArray < TLbtTriggerId >& aTriggerIdList, CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); void CreateIterator(RLbt& aLbt,CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); - void CTriggerFireObserver::DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); + void DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); TInt GetFireCount( ) ; TInt GetError( ) ; @@ -104,7 +104,7 @@ void UpdateTriggersState(RLbt& aLbt, CLbtTriggerEntry::TLbtTriggerState aState, CActiveSchedulerWait* aWait,CLbtTriggerFilterBase * aFilter=NULL) ; - void CTriggerFireObserver::PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; + void PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; void RunL( ); diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/bwins/AdvancedTriggerSupervisionu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/bwins/AdvancedTriggerSupervisionu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/conf/AdvancedTriggerSupervision.cfg --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/conf/AdvancedTriggerSupervision.cfg Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/conf/AdvancedTriggerSupervision.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,119 @@ +[Test] +id 01 +title ATSTest1 +create AdvancedTriggerSupervision foobar +foobar ATSTest1 +delete foobar +[Endtest] +[Test] +id 02 +title ATSTest2 +create AdvancedTriggerSupervision foobar +foobar ATSTest2 +delete foobar +[Endtest] +[Test] +id 03 +title ATSTest3 +create AdvancedTriggerSupervision foobar +foobar ATSTest3 +delete foobar +[Endtest] +[Test] +id 04 +title ATSTest4 +create AdvancedTriggerSupervision foobar +foobar ATSTest4 +delete foobar +[Endtest] +[Test] +id 05 +title ATSTest5 +create AdvancedTriggerSupervision foobar +foobar ATSTest5 +delete foobar +[Endtest] +[Test] +id 06 +title ATSTest6 +create AdvancedTriggerSupervision foobar +foobar ATSTest6 +delete foobar +[Endtest] +[Test] +id 07 +title ATSTest7 +create AdvancedTriggerSupervision foobar +foobar ATSTest7 +delete foobar +[Endtest] +[Test] +id 08 +title ATSTest8 +create AdvancedTriggerSupervision foobar +foobar ATSTest8 +delete foobar +[Endtest] +[Test] +id 09 +title ATSTest9 +create AdvancedTriggerSupervision foobar +foobar ATSTest9 +delete foobar +[Endtest] +[Test] +id 10 +title ATSTest10 +create AdvancedTriggerSupervision foobar +foobar ATSTest10 +delete foobar +[Endtest] +[Test] +id 11 +title ATSTest11 +create AdvancedTriggerSupervision foobar +foobar ATSTest11 +delete foobar +[Endtest] +[Test] +id 12 +title ATSTest12 +create AdvancedTriggerSupervision foobar +foobar ATSTest12 +delete foobar +[Endtest] +[Test] +id 13 +title ATSTest13 +create AdvancedTriggerSupervision foobar +foobar ATSTest13 +delete foobar +[Endtest] +[Test] +id 14 +title ATSTest14 +create AdvancedTriggerSupervision foobar +foobar ATSTest14 +delete foobar +[Endtest] +[Test] +id 15 +title ATSTest15 +create AdvancedTriggerSupervision foobar +foobar ATSTest15 +delete foobar +[Endtest] +[Test] +id 16 +title ATSTest16 +create AdvancedTriggerSupervision foobar +foobar ATSTest16 +delete foobar +[Endtest] +[Test] +id 17 +title ATSTest17 +create AdvancedTriggerSupervision foobar +foobar ATSTest17 +delete foobar +[Endtest] diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/eabi/AdvancedTriggerSupervisionu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/eabi/AdvancedTriggerSupervisionu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AdvancedTriggerSupervision.h --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AdvancedTriggerSupervision.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AdvancedTriggerSupervision.h Thu Jul 22 16:37:56 2010 +0100 @@ -28,6 +28,9 @@ #include +// Forward declaration +class TCoordinate; + // CONSTANTS //const ?type ?constant_var = ?constant; @@ -134,7 +137,12 @@ */ void Delete(); void EnableSimPSYL(); - + + /** + * Gets current coordinate + */ + void GetCurrentCoordinateL( TCoordinate& aCoordinate ); + /** * Test methods are listed below. */ diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AsynOperationAO.h --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AsynOperationAO.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/inc/AsynOperationAO.h Thu Jul 22 16:37:56 2010 +0100 @@ -50,12 +50,21 @@ * Two-phased constructor. */ static CTriggerFireObserver* NewL( RLbt& aLbt,TCoordinate& aCoordinate ); + + + static CTriggerFireObserver* NewL(); /** * Destructor. */ ~CTriggerFireObserver(); + /** + * Request for current position + */ + void CurrentPositionL( TPositionInfo& aPositionInfo, + CActiveSchedulerWait* aWait ); + void TriggerFiredL( const TLbtTriggerFireInfo& aFireInfo ); @@ -97,12 +106,17 @@ * C++ default constructor. */ CTriggerFireObserver( TCoordinate& aCoordinate ); + + + CTriggerFireObserver(); /** * By default Symbian 2nd phase constructor is private. */ void ConstructL( RLbt& aLbt ); + void ConstructL(); + private: CLbtTriggerFiringEventNotifier* iNotifier; @@ -112,8 +126,15 @@ TLbtTriggerFireInfo iFireInfo; - - + /** + * Handle to positioner session + */ + RPositionServer iPosServer; + + /** + * Handle to positioner subsession + */ + RPositioner iPositioner; }; diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervision.cpp --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervision.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervision.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -131,7 +131,14 @@ CStifLogger::ETxt, CStifLogger::EFile, EFalse ); - + + RProcess process; + ret = process.Create(_L("lbsroot"), KNullDesC); + TRequestStatus status; + process.Rendezvous(status); + process.Resume(); + User::WaitForRequest(status); + process.Close(); } // ----------------------------------------------------------------------------- diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervisionBlocks.cpp --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervisionBlocks.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AdvancedTriggerSupervisionBlocks.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -174,6 +174,30 @@ CleanupStack::PopAndDestroy( idList ); CleanupStack::PopAndDestroy( db ); } + +// ----------------------------------------------------------------------------- +// CAdvancedTriggerSupervision::GetCurrentCoordinateL +// Returns current position +// ----------------------------------------------------------------------------- +// +void CAdvancedTriggerSupervision::GetCurrentCoordinateL( TCoordinate& aCoordinate ) + { + CTriggerFireObserver* notifier= CTriggerFireObserver::NewL(); + CleanupStack::PushL( notifier ); + CActiveSchedulerWait* wait = new ( ELeave ) CActiveSchedulerWait; + CleanupStack::PushL( wait ); + TPositionInfo positionInfo; + // Ownership of wait is transferred to notifier + notifier->CurrentPositionL( positionInfo,wait ); + CleanupStack::Pop( wait ); + wait->Start(); + TPosition position; + positionInfo.GetPosition( position ); + aCoordinate.SetCoordinate( position.Latitude(),position.Longitude(),position.Altitude() ); + CleanupStack::Pop( notifier ); // notifier + delete notifier; + } + // ----------------------------------------------------------------------------- // CAdvancedTriggerSupervision::RunMethodL // Run specified method. Contains also table of test mothods and their names. @@ -280,10 +304,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - coordinate.Move(90,2000); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + coordinate.Move(90,200); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -314,10 +338,12 @@ TReal32 trigDistance; TPosition firePosition; FireInfo = notifier->GetFiredTrigger(); + iLog->Log(_L("GFT")); FireInfo.iFiredPositionInfo.GetPosition(firePosition); + iLog->Log(_L("GP")); firePosition.Distance(coordinate,trigDistance); - if( trigDistance<=1000 && FireInfo.iTriggerId==trigId ) + if( FireInfo.iTriggerId==trigId ) { CleanupStack::PopAndDestroy( notifier ); @@ -400,10 +426,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - coordinate.Move(90,510); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + coordinate.Move(90,110); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); CleanupStack::PushL( circle ); @@ -437,7 +463,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance<=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -521,10 +547,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -558,7 +584,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance<=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -639,10 +665,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - coordinate.Move(90,2000); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + coordinate.Move(90,200); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -676,7 +702,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance>=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -760,10 +786,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - coordinate.Move(90,1010); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + coordinate.Move(90,110); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -797,7 +823,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance>=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -881,10 +907,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -918,7 +944,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance>=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -953,117 +979,117 @@ TInt CAdvancedTriggerSupervision::ATSTest7L( CStifItemParser& aItem ) { - iLog->Log(_L("Entering Test1")); - _LIT( KSimulationFile,"c:\\system\\data\\simu_move1.sps" ); - // _LIT( KSimulationFile0,"c:\\system\\data\\simu_move2.sps" ); + + iLog->Log(_L("Entering Test1")); + _LIT( KSimulationFile,"c:\\system\\data\\simu_move3.sps" ); +// _LIT( KSimulationFile0,"c:\\system\\data\\simu_move2.sps" ); + + RLbtServer lbtserver; + RLbt lbt; + iLog->Log(_L("Before connecting")); + User::LeaveIfError( lbtserver.Connect() ); + CleanupClosePushL( lbtserver ); + iLog->Log(_L("Connection to RLbtServer Passed ")); + User::LeaveIfError( lbt.Open(lbtserver)); + iLog->Log(_L("Subsession opened ")); + CleanupClosePushL( lbt ); + + //Enable only simpsy + EnableSimPSYL(); + //Clear all triggers + TRAP_IGNORE(lbt.DeleteTriggersL()) ; + CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); + iLog->Log(_L("Simulation PSY Repository object created")); +// User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile0)); + User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); + iLog->Log(_L("Simulation input file set ")); + CleanupStack::PopAndDestroy(repository); + + //Construct a startup trigger + CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); - RLbtServer lbtserver; - RLbt lbt; - iLog->Log(_L("Before connecting")); - User::LeaveIfError( lbtserver.Connect() ); - CleanupClosePushL( lbtserver ); - iLog->Log(_L("Connection to RLbtServer Passed ")); - User::LeaveIfError( lbt.Open(lbtserver)); - iLog->Log(_L("Subsession opened ")); - CleanupClosePushL( lbt ); - //Enable only simpsy - EnableSimPSYL(); - //Clear all triggers - TRAP_IGNORE(lbt.DeleteTriggersL()) ; - - CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); - iLog->Log(_L("Simulation PSY Repository object created")); -// User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile0)); - User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); - iLog->Log(_L("Simulation input file set ")); - CleanupStack::PopAndDestroy(repository); - - //Construct a startup trigger - CLbtStartupTrigger* trig = CLbtStartupTrigger::NewL(); - - //Push to cleanup stack - CleanupStack::PushL( trig ); - iLog->Log(_L("Startup Trigger Entry Created ")); - - // Set Name - trig->SetNameL(_L("Trigger1")); - trig->SetNameL(_L("abc")); - _LIT( KMyTriggerHandlingProcessName, "About.exe"); - // _LIT( KMyTriggerHandlingProcessName, "TestServerStarter.exe"); - // _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); - - TSecureId secureid; - trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); - - //set Requestor - CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; - CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; - TBuf ReqData=_L(""); - trig->SetRequestorL(ReqType,ReqFormat,ReqData); - // set condition + //Push to cleanup stack + CleanupStack::PushL( trig ); + iLog->Log(_L("Startup Trigger Entry Created ")); + + // Set Name + trig->SetNameL(_L("Trigger1")); + trig->SetNameL(_L("abc")); + _LIT( KMyTriggerHandlingProcessName, "About.exe"); +// _LIT( KMyTriggerHandlingProcessName, "TestServerStarter.exe"); +// _LIT( KMyTriggerHandlingProcessName, "ConsoleUI.exe"); - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); - CleanupStack::PushL( circle ); + TSecureId secureid; + trig->SetProcessId(KMyTriggerHandlingProcessName,secureid); + + //set Requestor +CRequestorBase::TRequestorType ReqType=CRequestorBase::ERequestorUnknown; +CRequestorBase::_TRequestorFormat ReqFormat=CRequestorBase::EFormatUnknown; +TBuf ReqData=_L(""); +trig->SetRequestorL(ReqType,ReqFormat,ReqData); + // set condition + +TCoordinate coordinate; +GetCurrentCoordinateL( coordinate ); + + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); + CleanupStack::PushL( circle ); + + + // ownership of circle object transferred to the condition object + CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( + circle, + CLbtTriggerConditionArea::EFireOnEnter); - - // ownership of circle object transferred to the condition object - CLbtTriggerConditionArea* condition=CLbtTriggerConditionArea::NewL( - circle, - CLbtTriggerConditionArea::EFireOnEnter); - - CleanupStack::Pop( circle ); + CleanupStack::Pop( circle ); + + trig->SetCondition(condition); // ownership transferred to object + + TLbtTriggerId trigId; + + + CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); + CleanupStack::PushL( notifier ); + + CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; - trig->SetCondition(condition); // ownership transferred to object - - TLbtTriggerId trigId; - - - CTriggerFireObserver* notifier= CTriggerFireObserver::NewL( lbt,coordinate); - CleanupStack::PushL( notifier ); + notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); + wait->Start( ); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); + circle2->SetRadius(500); + CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( + circle2, + CLbtTriggerConditionArea::EFireOnEnter); + + trig->SetCondition(condition2); + notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); + wait->Start( ); - CActiveSchedulerWait* wait=new(ELeave)CActiveSchedulerWait; - - notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); - wait->Start( ); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); - circle2->SetRadius(500); - CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( - circle2, - CLbtTriggerConditionArea::EFireOnEnter); - - trig->SetCondition(condition2); - notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); - wait->Start( ); - - iLog->Log(_L("Triggers Created")); - // notifier->StartNotification( wait ); - // wait->Start( ); - notifier->StartNotification( wait ); - wait->Start( ); - notifier->After(120000000); - wait->Start( ); - RArray Firedtriggers; - lbt.GetFiredTriggersL(Firedtriggers); - if(Firedtriggers.Count()==2) - { - CleanupStack::PopAndDestroy( notifier ); - CleanupStack::PopAndDestroy( trig ); - CleanupStack::Pop( &lbt ); - CleanupStack::PopAndDestroy( &lbtserver ); - return KErrNone; - } - else - { - CleanupStack::PopAndDestroy( notifier ); - CleanupStack::PopAndDestroy( trig ); - CleanupStack::Pop( &lbt ); - CleanupStack::PopAndDestroy( &lbtserver ); - return -99; - } - + iLog->Log(_L("Triggers Created")); + notifier->StartNotification( wait ); + wait->Start( ); + wait->Start( ); + RArray Firedtriggers; + lbt.GetFiredTriggersL(Firedtriggers); + if(Firedtriggers.Count()==2) + { + CleanupStack::PopAndDestroy( notifier ); + CleanupStack::PopAndDestroy( trig ); + CleanupStack::Pop( &lbt ); + CleanupStack::PopAndDestroy( &lbtserver ); + return KErrNone; + } + else + { + CleanupStack::PopAndDestroy( notifier ); + CleanupStack::PopAndDestroy( trig ); + CleanupStack::Pop( &lbt ); + CleanupStack::PopAndDestroy( &lbtserver ); + return -99; + } + +// return KErrNone; + } @@ -1127,10 +1153,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); CleanupStack::PushL( circle ); @@ -1153,7 +1179,7 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetRadius(500); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -1166,9 +1192,6 @@ iLog->Log(_L("Triggers Created")); notifier->StartNotification( wait ); wait->Start( ); - // notifier->StartNotification( wait ); - // wait->Start( ); - notifier->After(1200000000); wait->Start( ); RArray Firedtriggers; lbt.GetFiredTriggersL(Firedtriggers); @@ -1254,10 +1277,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,200); CleanupStack::PushL( circle ); @@ -1280,8 +1303,7 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); - circle2->SetRadius(250); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,200); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, CLbtTriggerConditionArea::EFireOnEnter); @@ -1293,11 +1315,8 @@ iLog->Log(_L("Triggers Created")); notifier->StartNotification( wait ); wait->Start( ); - // notifier->StartNotification( wait ); - // wait->Start( ); + wait->Start( ); - notifier->After(120000000); - wait->Start( ); RArray Firedtriggers; lbt.GetFiredTriggersL(Firedtriggers); CleanupStack::PopAndDestroy( notifier ); @@ -1377,9 +1396,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -1402,9 +1422,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); - circle2->SetRadius(500); - coordinate.Move(90,1000); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); + coordinate.Move(90,200); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -1417,9 +1436,6 @@ iLog->Log(_L("Triggers Created")); notifier->StartNotification( wait ); wait->Start( ); - // notifier->StartNotification( wait ); - // wait->Start( ); - notifier->After(120000000); wait->Start( ); RArray Firedtriggers; lbt.GetFiredTriggersL(Firedtriggers); @@ -1505,9 +1521,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -1531,8 +1548,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - coordinate.Move(90,500); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(90,100); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -1545,8 +1562,8 @@ iLog->Log(_L("Triggers Created")); notifier->StartNotification( wait ); wait->Start( ); - notifier->After(120000000); - wait->Start( ); + wait->Start( ); + iLog->Log(_L("Trigger Fired")); RArray Firedtriggers; lbt.GetFiredTriggersL(Firedtriggers); @@ -1581,7 +1598,7 @@ { iLog->Log(_L("Entering Test1")); - _LIT( KSimulationFile,"c:\\system\\data\\test3.nme" ); + _LIT( KSimulationFile,"c:\\system\\data\\simu_move2.sps" ); // _LIT( KSimulationFile0,"c:\\system\\data\\simu_move2.sps" ); RLbtServer lbtserver; @@ -1630,9 +1647,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -1655,21 +1673,18 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - TCoordinate coordinates[10]= + TCoordinate movCoordinates( coordinate.Latitude(),coordinate.Longitude() ); + + TCoordinate coordinates[4]; + // Initialise the coordinate + for( TInt i=0;i<4;i++ ) { - TCoordinate(62.5285,23.9385) , - TCoordinate(62.5267,23.9636), - TCoordinate(62.5167,23.9528), - /* TCoordinate(62.5141,23.9312), - TCoordinate(62.5296,23.9514), - TCoordinate(62.5269,23.9331), - TCoordinate(62.518,23.9401), - TCoordinate(62.5394,23.9439), - TCoordinate(62.5275,23.9223),*/ - TCoordinate(62.5331,23.9551)}; + movCoordinates.Move( 90,300 ); + coordinates[i] = movCoordinates; + } for(int i=0;i<4;i++) { - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); // coordinate.Move(45,100); circle->SetCenter(coordinates[i]); if(i%2==0) @@ -1697,11 +1712,14 @@ notifier->StartNotification( wait ); wait->Start( ); - notifier->After(600000000); - wait->Start( ); + wait->Start( ); + wait->Start( ); + wait->Start( ); + + RArray Firedtriggers; lbt.GetFiredTriggersL(Firedtriggers); - if(Firedtriggers.Count()==3) + if(Firedtriggers.Count()==4) { CleanupStack::PopAndDestroy( notifier ); CleanupStack::PopAndDestroy( trig ); @@ -1778,10 +1796,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); - // TCoordinate coordinate(62.4438,23.9385); - coordinate.Move(90,5000); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,10000); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); + coordinate.Move(90,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,2000); CleanupStack::PushL( circle ); @@ -1815,7 +1833,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance<=11500 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -1899,9 +1917,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -1925,8 +1944,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - coordinate.Move(90,2000); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(90,500); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -1954,7 +1973,7 @@ FireInfo.iFiredPositionInfo.GetPosition(firePosition); firePosition.Distance(coordinate,trigDistance); - if( trigDistance<=1000 && FireInfo.iTriggerId==trigId) + if( FireInfo.iTriggerId==trigId) { CleanupStack::PopAndDestroy( notifier ); @@ -2044,9 +2063,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,500); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -2070,8 +2090,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - coordinate.Move(90,2000); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,800); + coordinate.Move(90,300); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -2081,8 +2101,8 @@ notifier->CreateTriggers( lbt,*trig,trigIdtochange,ETrue,wait ); wait->Start( ); - coordinate.Move(90,2000); - CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,700); + coordinate.Move(90,400); + CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,100); circle3->SetCenter(coordinate); CLbtTriggerConditionArea* condition3=CLbtTriggerConditionArea::NewL( circle3, @@ -2194,9 +2214,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -2220,8 +2241,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - coordinate.Move(90,10000); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(90,500); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle2, @@ -2235,8 +2256,8 @@ // User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, KSimulationFile)); // notifier->After(3000000); // wait->Start( ); - coordinate.Move(270,5000); - CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(270,200); + CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,100); circle3->SetCenter(coordinate); CLbtTriggerConditionArea* condition3=CLbtTriggerConditionArea::NewL( circle3, @@ -2347,9 +2368,10 @@ trig->SetRequestorL(ReqType,ReqFormat,ReqData); // set condition - TCoordinate coordinate(62.5285,23.9385); + TCoordinate coordinate; + GetCurrentCoordinateL( coordinate ); - CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,1000); + CLbtGeoCircle* circle=CLbtGeoCircle::NewL(coordinate,100); CleanupStack::PushL( circle ); @@ -2373,8 +2395,8 @@ notifier->CreateTriggers( lbt,*trig,trigId,ETrue,wait ); wait->Start( ); - coordinate.Move(90,5000); - CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(90,500); + CLbtGeoCircle* circle3=CLbtGeoCircle::NewL(coordinate,100); circle3->SetCenter(coordinate); CLbtTriggerConditionArea* condition2=CLbtTriggerConditionArea::NewL( circle3, @@ -2384,8 +2406,8 @@ notifier->CreateTriggers( lbt,*trig,trigIdtochange,ETrue,wait ); wait->Start( ); - coordinate.Move(90,5000); - CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,500); + coordinate.Move(90,500); + CLbtGeoCircle* circle2=CLbtGeoCircle::NewL(coordinate,100); circle2->SetCenter(coordinate); CLbtTriggerConditionArea* condition3=CLbtTriggerConditionArea::NewL( circle2, diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AsynOperationAO.cpp --- a/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AsynOperationAO.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/AdvancedTriggerSupervision/src/AsynOperationAO.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -23,7 +23,7 @@ #include "AsynOperationAO.h" - +_LIT(KRequestor,"LBT test app"); // ============================ MEMBER FUNCTIONS =============================== @@ -40,6 +40,12 @@ CActiveScheduler::Add(this); } + +CTriggerFireObserver::CTriggerFireObserver( ):CTimer( CTimer::EPriorityStandard ) + { + CActiveScheduler::Add(this); + } + // ----------------------------------------------------------------------------- // CTriggerFireObserver::ConstructL // Symbian 2nd phase constructor can leave. @@ -55,6 +61,21 @@ } // ----------------------------------------------------------------------------- +// CTriggerFireObserver::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CTriggerFireObserver::ConstructL() + { + User::LeaveIfError( iPosServer.Connect() ); + User::LeaveIfError( iPositioner.Open( iPosServer ) ); + + // Set position requestor + User::LeaveIfError( iPositioner.SetRequestor( CRequestor::ERequestorService , + CRequestor::EFormatApplication , KRequestor ) ); + } + +// ----------------------------------------------------------------------------- // CTriggerFireObserver::NewL // Two-phased constructor. // ----------------------------------------------------------------------------- @@ -72,6 +93,20 @@ } +// ----------------------------------------------------------------------------- +// CTriggerFireObserver::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CTriggerFireObserver* CTriggerFireObserver::NewL() + { + CTriggerFireObserver* self = new (ELeave) CTriggerFireObserver(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + // Destructor CTriggerFireObserver::~CTriggerFireObserver() { @@ -81,10 +116,23 @@ delete iNotifier; delete iWait; // iWait=NULL; + iPositioner.Close(); + iPosServer.Close(); } +void CTriggerFireObserver::CurrentPositionL( TPositionInfo& aPositionInfo, + CActiveSchedulerWait* aWait ) + { + iWait = aWait; + // Get last known position. The processing of the result + // is done in RunL method + iPositioner.NotifyPositionUpdate( aPositionInfo, iStatus ); + // Set this active object active + SetActive(); + } + void CTriggerFireObserver::TriggerFiredL( const TLbtTriggerFireInfo& aFireInfo ) { iTriggerFireCount++; diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/bwins/CellbasedtriggerOperationsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/bwins/CellbasedtriggerOperationsu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/eabi/CellbasedtriggerOperationsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/eabi/CellbasedtriggerOperationsu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI17CLbtEventObserver @ 2 NONAME + _ZTI20CTriggerFireObserver @ 3 NONAME + _ZTV17CLbtEventObserver @ 4 NONAME + _ZTV20CTriggerFireObserver @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/inc/AsynOperationAO.h --- a/locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/inc/AsynOperationAO.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/CellbasedtriggerOperations/inc/AsynOperationAO.h Thu Jul 22 16:37:56 2010 +0100 @@ -84,7 +84,7 @@ void ListTriggerIdsList(RLbt& aLbt, RArray < TLbtTriggerId >& aTriggerIdList, CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); void CreateIterator(RLbt& aLbt,CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); - void CTriggerFireObserver::DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); + void DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); TInt GetFireCount( ) ; TInt GetError( ) ; @@ -92,7 +92,7 @@ void UpdateTriggersState(RLbt& aLbt, CLbtTriggerEntry::TLbtTriggerState aState, CActiveSchedulerWait* aWait,CLbtTriggerFilterBase * aFilter=NULL) ; - void CTriggerFireObserver::PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; + void PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; void RunL( ); diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/ClientServerSetup/bwins/ClientServerSetupu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/ClientServerSetup/bwins/ClientServerSetupu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/ClientServerSetup/eabi/ClientServerSetupu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/ClientServerSetup/eabi/ClientServerSetupu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/CreateSessiontrigger/bwins/CreateSessiontriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/CreateSessiontrigger/bwins/CreateSessiontriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/CreateSessiontrigger/eabi/CreateSessiontriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/CreateSessiontrigger/eabi/CreateSessiontriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/LbtCancellationTest/testlbtcancellation/bwins/testlbtcancellationu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/LbtCancellationTest/testlbtcancellation/bwins/testlbtcancellationu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/LbtCancellationTest/testlbtcancellation/eabi/testlbtcancellationu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/LbtCancellationTest/testlbtcancellation/eabi/testlbtcancellationu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/bwins/TestHybridTriggersu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/bwins/TestHybridTriggersu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/eabi/TestHybridTriggersu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/eabi/TestHybridTriggersu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI17CLbtEventObserver @ 2 NONAME + _ZTI20CTriggerFireObserver @ 3 NONAME + _ZTV17CLbtEventObserver @ 4 NONAME + _ZTV20CTriggerFireObserver @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/inc/AsynOperationAO.h --- a/locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/inc/AsynOperationAO.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locationtriggering/tsrc/lbtengine_test/TestHybridTriggers/inc/AsynOperationAO.h Thu Jul 22 16:37:56 2010 +0100 @@ -83,7 +83,7 @@ void ListTriggerIdsList(RLbt& aLbt, RArray < TLbtTriggerId >& aTriggerIdList, CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); void CreateIterator(RLbt& aLbt,CActiveSchedulerWait* aWait,CLbtListTriggerOptions* aListOptions=NULL); - void CTriggerFireObserver::DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); + void DeleteFilteredTriggers( RLbt& aLbt,CLbtTriggerFilterBase* aFilter,CActiveSchedulerWait* aWait ); TInt GetFireCount( ) ; TInt GetError( ) ; @@ -92,7 +92,7 @@ CActiveSchedulerWait* aWait,CLbtTriggerFilterBase * aFilter=NULL) ; void UpdateTrigger(RLbt& aLbt,CLbtTriggerEntry& aTrigger,TLbtTriggerAttributeFieldsMask aFieldMask,CActiveSchedulerWait* aWait, TLbtFireOnUpdate aFireOnUpdate) ; - void CTriggerFireObserver::PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; + void PopulateFromCurrentCell(CLbtGeoCell& cell,CActiveSchedulerWait* aWait ) ; void RunL( ); diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/UpdateTrigger/bwins/UpdateTriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/UpdateTrigger/bwins/UpdateTriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/UpdateTrigger/eabi/UpdateTriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/UpdateTrigger/eabi/UpdateTriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/createstartuptrigger/bwins/createstartuptriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/createstartuptrigger/bwins/createstartuptriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/createstartuptrigger/eabi/createstartuptriggeru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/createstartuptrigger/eabi/createstartuptriggeru.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/firingofstartuptriggerandlisttrigger/bwins/t_lbtltapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/firingofstartuptriggerandlisttrigger/bwins/t_lbtltapiu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/firingofstartuptriggerandlisttrigger/eabi/t_lbtltapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/firingofstartuptriggerandlisttrigger/eabi/t_lbtltapiu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/lbtPlatSecTest/testlbtplatsecurity/bwins/testlbtplatsecurityu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/lbtPlatSecTest/testlbtplatsecurity/bwins/testlbtplatsecurityu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/lbtPlatSecTest/testlbtplatsecurity/eabi/testlbtplatsecurityu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/lbtPlatSecTest/testlbtplatsecurity/eabi/testlbtplatsecurityu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/lbtbctest/bwins/lbtbctestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/lbtbctest/bwins/lbtbctestu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/lbtbctest/eabi/lbtbctestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/lbtbctest/eabi/lbtbctestu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI17CLbtEventObserver @ 2 NONAME + _ZTI20CTriggerFireObserver @ 3 NONAME + _ZTV17CLbtEventObserver @ 4 NONAME + _ZTV20CTriggerFireObserver @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/t_deletetriggers/bwins/t_deletetriggersu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/t_deletetriggers/bwins/t_deletetriggersu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/t_deletetriggers/eabi/t_deletetriggersu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/t_deletetriggers/eabi/t_deletetriggersu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTI22CDeleteTriggerObserver @ 3 NONAME + _ZTV20CTriggerFireObserver @ 4 NONAME + _ZTV22CDeleteTriggerObserver @ 5 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/t_lbtltapi/bwins/t_lbtltapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/t_lbtltapi/bwins/t_lbtltapiu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 6f8759468fd4 -r 7409e6184c90 locationtriggering/tsrc/lbtengine_test/t_lbtltapi/eabi/t_lbtltapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationtriggering/tsrc/lbtengine_test/t_lbtltapi/eabi/t_lbtltapiu.def Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI20CTriggerFireObserver @ 2 NONAME + _ZTV20CTriggerFireObserver @ 3 NONAME + diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_plat/supl_settings_api/tsrc/conf/settingsapi_test.cfg --- a/locsrv_plat/supl_settings_api/tsrc/conf/settingsapi_test.cfg Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_plat/supl_settings_api/tsrc/conf/settingsapi_test.cfg Thu Jul 22 16:37:56 2010 +0100 @@ -877,13 +877,6 @@ delete foobar [Endtest] -[Test] -title CancelTriggerSession -create settingsapi foobar -foobar CancelTriggerSession -delete foobar -[Endtest] - [Test] title SetTriggerEmptySessionName diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_plat/supl_settings_api/tsrc/eabi/settingsapiu.def --- a/locsrv_plat/supl_settings_api/tsrc/eabi/settingsapiu.def Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_plat/supl_settings_api/tsrc/eabi/settingsapiu.def Thu Jul 22 16:37:56 2010 +0100 @@ -2,4 +2,6 @@ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME _ZTI28CTerminalInitiatedRunSession @ 2 NONAME ; ## _ZTV28CTerminalInitiatedRunSession @ 3 NONAME ; ## + _ZTI16CSessionObserver @ 4 NONAME + _ZTV16CSessionObserver @ 5 NONAME diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_plat/supl_settings_api/tsrc/inc/settingsapi.h --- a/locsrv_plat/supl_settings_api/tsrc/inc/settingsapi.h Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_plat/supl_settings_api/tsrc/inc/settingsapi.h Thu Jul 22 16:37:56 2010 +0100 @@ -188,116 +188,112 @@ TInt RemoveServer_Invalid_negative(CStifItemParser& aItem); TInt RemoveServer_Id_NotExisting(CStifItemParser& aItem); TInt RemoveServer_Invalid_zero(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_Increase(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_Decrease(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_invalid_positive(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_priority0(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_Negative(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_InvalidServer(CStifItemParser& aItem); - TInt CSettingsApi::ChangePriority_invalidserverpriority(CStifItemParser& aItem); - TInt CSettingsApi::GetDefaultServer(); - TInt CSettingsApi::AddNewServerWithDefault(CStifItemParser& aItem); - TInt CSettingsApi::AddNewServerWithoutDefault(CStifItemParser& aItem); - TInt CSettingsApi::AddNewServer_Duplicate(CStifItemParser& aItem); - TInt CSettingsApi::GetSlpInfoFromId(TInt64 Slpid); - TInt CSettingsApi::GetSlpInfoFromId(CStifItemParser& aItem); - TInt CSettingsApi::GetSlpInfoFromId_invalid_positive(CStifItemParser& aItem); - TInt CSettingsApi::GetSlpInfoFromId_invalid_negative(CStifItemParser& aItem); - TInt CSettingsApi::GetSlpInfoFromId_invalid_zero(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress_invalidpositive(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress_invalidnegative(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress_invalidzero(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress_AddressNull(CStifItemParser& aItem); - TInt CSettingsApi::SetServerAddress_InvalidAddressId(CStifItemParser& aItem); - TInt CSettingsApi::GetServerAddress(CStifItemParser& aItem); - TInt CSettingsApi::GetServerAddress_invalidpositive(CStifItemParser& aItem); - TInt CSettingsApi::GetServerAddress_invalidnegative(CStifItemParser& aItem); - TInt CSettingsApi::GetServerAddress_invalidzero(CStifItemParser& aItem); - TInt CSettingsApi::GetServerAddress(TInt64 aSlpId1); - TInt CSettingsApi::SetIAPName_InvalidAddressId(CStifItemParser& aItem); - TInt CSettingsApi::SetIAPName_invalidzero(CStifItemParser& aItem); - TInt CSettingsApi::SetIAPName_invalidnegative(CStifItemParser& aItem); - TInt CSettingsApi::SetIAPName_invalidpositive(CStifItemParser& aItem); - TInt CSettingsApi::SetIAPName(CStifItemParser& aItem); - TInt CSettingsApi::GetIAPName_invalidzero(CStifItemParser& aItem); - TInt CSettingsApi::GetIAPName_invalidnegative(CStifItemParser& aItem); - TInt CSettingsApi::GetIAPName_invalidpositive(CStifItemParser& aItem); - TInt CSettingsApi::GetIAPName(CStifItemParser& aItem); - TInt CSettingsApi::GetIAPName(TInt64 aSlpId1); - TInt CSettingsApi::SetServerEnabledFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::SetServerEnabledFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::SetServerEnabledFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::SetServerEnabledFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::SetServerEnabledFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomeNwFlag(TInt64 aSlpId1); - TInt CSettingsApi::SetUsageInHomwNwFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::SetUsageInHomwNwFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::SetUsageInHomwNwFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::SetUsageInHomwNwFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::SetUsageInHomwNwFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetUsageInHomwNwFlag(TInt64 aSlpId1); - TInt CSettingsApi::AddNewServer_aServerAddress_Null(CStifItemParser& aItem); - TInt CSettingsApi::AddNewServer_aIapNAme_Null(CStifItemParser& aItem); - TInt CSettingsApi::SetDefaultServer_aServerAddress_Null(CStifItemParser& aItem); - TInt CSettingsApi::SetDefaultServerWithDefaultValues(CStifItemParser& aItem); - TInt CSettingsApi::SetAllParameter_aServerAddress_Null(CStifItemParser& aItem); - TInt CSettingsApi::SetAllParameter_WithDefaultValues(CStifItemParser& aItem); - TInt CSettingsApi::SetAllParameter_Invalid_Positive(CStifItemParser& aItem); - TInt CSettingsApi::SetAllParameter_Invalid_Negative(CStifItemParser& aItem); - TInt CSettingsApi::SetAllParameter_Invalid_Zero(CStifItemParser& aItem); - TInt CSettingsApi::GetServerEnabledFlag(TInt64 aSlpId1); - TInt CSettingsApi::SetEditableFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::SetEditableFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::SetEditableFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::SetEditableFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::SetEditableFlag_id_zero(CStifItemParser& aItem); - TBool CSettingsApi::IsSLPExists(CStifItemParser& aItem); - TBool CSettingsApi::IsSLPExists_invalid_negative(CStifItemParser& aItem); - TBool CSettingsApi::IsSLPExists_invalid_positive(CStifItemParser& aItem); - TBool CSettingsApi::IsSLPExists_invalid_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetAllSlp_sync(CStifItemParser& aItem); - TInt CSettingsApi::GetAllSlp_async(CStifItemParser& aItem); - TInt CSettingsApi::SetSimChangeRemoveFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::SetSimChangeRemoveFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::SetSimChangeRemoveFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::SetSimChangeRemoveFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::SetSimChangeRemoveFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetSimChangeRemoveFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::GetSimChangeRemoveFlag(TInt64 aSlpId1); - TInt CSettingsApi::GetSimChangeRemoveFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::GetSimChangeRemoveFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::GetSimChangeRemoveFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::GetSimChangeRemoveFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::GetEditableFlag_Etrue(CStifItemParser& aItem); - TInt CSettingsApi::GetEditableFlag(TInt64 aSlpId1); - TInt CSettingsApi::GetEditableFlag_EFalse(CStifItemParser& aItem); - TInt CSettingsApi::GetEditableFlag_id_negative(CStifItemParser& aItem); - TInt CSettingsApi::GetEditableFlag_id_positive(CStifItemParser& aItem); - TInt CSettingsApi::GetEditableFlag_id_zero(CStifItemParser& aItem); - TInt CSettingsApi::SetFallBack_ETrue(); - TInt CSettingsApi::SetFallBack_EFalse(); - TInt CSettingsApi::GetFallBack(); - TInt CSettingsApi::IsSLPExistsString(); - TInt CSettingsApi::IsSLPExistsString_Null(); - TInt CSettingsApi::IsSLPExistsString_invalid(); - TInt CSettingsApi::SlpCount(); - TInt CSettingsApi::GetSlpInfoFromAddress(CStifItemParser& aItem); - TInt CSettingsApi::GetSlpInfoFromAddress_invalid(CStifItemParser& aItem); - TInt CSettingsApi::ProductConfiguredServer1(); - TInt CSettingsApi::ProductConfiguredServer2(); - TInt CSettingsApi::ProductConfiguredServer3(); - TInt CSettingsApi::ProductConfiguredServer4(); + TInt ChangePriority_Increase(CStifItemParser& aItem); + TInt ChangePriority_Decrease(CStifItemParser& aItem); + TInt ChangePriority_invalid_positive(CStifItemParser& aItem); + TInt ChangePriority_priority0(CStifItemParser& aItem); + TInt ChangePriority_Negative(CStifItemParser& aItem); + TInt ChangePriority_InvalidServer(CStifItemParser& aItem); + TInt ChangePriority_invalidserverpriority(CStifItemParser& aItem); + TInt GetDefaultServer(); + TInt AddNewServerWithDefault(CStifItemParser& aItem); + TInt AddNewServerWithoutDefault(CStifItemParser& aItem); + TInt AddNewServer_Duplicate(CStifItemParser& aItem); + TInt GetSlpInfoFromId(TInt64 Slpid); + TInt GetSlpInfoFromId(CStifItemParser& aItem); + TInt GetSlpInfoFromId_invalid_positive(CStifItemParser& aItem); + TInt GetSlpInfoFromId_invalid_negative(CStifItemParser& aItem); + TInt GetSlpInfoFromId_invalid_zero(CStifItemParser& aItem); + TInt SetServerAddress(CStifItemParser& aItem); + TInt SetServerAddress_invalidpositive(CStifItemParser& aItem); + TInt SetServerAddress_invalidnegative(CStifItemParser& aItem); + TInt SetServerAddress_invalidzero(CStifItemParser& aItem); + TInt SetServerAddress_AddressNull(CStifItemParser& aItem); + TInt SetServerAddress_InvalidAddressId(CStifItemParser& aItem); + TInt GetServerAddress(CStifItemParser& aItem); + TInt GetServerAddress_invalidpositive(CStifItemParser& aItem); + TInt GetServerAddress_invalidnegative(CStifItemParser& aItem); + TInt GetServerAddress_invalidzero(CStifItemParser& aItem); + TInt GetServerAddress(TInt64 aSlpId1); + TInt SetIAPName_InvalidAddressId(CStifItemParser& aItem); + TInt SetIAPName_invalidzero(CStifItemParser& aItem); + TInt SetIAPName_invalidnegative(CStifItemParser& aItem); + TInt SetIAPName_invalidpositive(CStifItemParser& aItem); + TInt SetIAPName(CStifItemParser& aItem); + TInt GetIAPName_invalidzero(CStifItemParser& aItem); + TInt GetIAPName_invalidnegative(CStifItemParser& aItem); + TInt GetIAPName_invalidpositive(CStifItemParser& aItem); + TInt GetIAPName(CStifItemParser& aItem); + TInt GetIAPName(TInt64 aSlpId1); + TInt SetServerEnabledFlag_Etrue(CStifItemParser& aItem); + TInt SetServerEnabledFlag_EFalse(CStifItemParser& aItem); + TInt SetServerEnabledFlag_id_negative(CStifItemParser& aItem); + TInt SetServerEnabledFlag_id_positive(CStifItemParser& aItem); + TInt SetServerEnabledFlag_id_zero(CStifItemParser& aItem); + TInt GetServerEnabledFlag_id_negative(CStifItemParser& aItem); + TInt GetServerEnabledFlag_id_positive(CStifItemParser& aItem); + TInt GetServerEnabledFlag_id_zero(CStifItemParser& aItem); + TInt GetServerEnabledFlag_EFalse(CStifItemParser& aItem); + TInt GetServerEnabledFlag_Etrue(CStifItemParser& aItem); + TInt GetUsageInHomeNwFlag(TInt64 aSlpId1); + TInt SetUsageInHomwNwFlag_Etrue(CStifItemParser& aItem); + TInt SetUsageInHomwNwFlag_EFalse(CStifItemParser& aItem); + TInt SetUsageInHomwNwFlag_id_negative(CStifItemParser& aItem); + TInt SetUsageInHomwNwFlag_id_positive(CStifItemParser& aItem); + TInt SetUsageInHomwNwFlag_id_zero(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag_Etrue(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag_EFalse(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag_id_negative(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag_id_positive(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag_id_zero(CStifItemParser& aItem); + TInt GetUsageInHomwNwFlag(TInt64 aSlpId1); + TInt AddNewServer_aServerAddress_Null(CStifItemParser& aItem); + TInt AddNewServer_aIapNAme_Null(CStifItemParser& aItem); + TInt SetDefaultServer_aServerAddress_Null(CStifItemParser& aItem); + TInt SetDefaultServerWithDefaultValues(CStifItemParser& aItem); + TInt SetAllParameter_aServerAddress_Null(CStifItemParser& aItem); + TInt SetAllParameter_WithDefaultValues(CStifItemParser& aItem); + TInt SetAllParameter_Invalid_Positive(CStifItemParser& aItem); + TInt SetAllParameter_Invalid_Negative(CStifItemParser& aItem); + TInt SetAllParameter_Invalid_Zero(CStifItemParser& aItem); + TInt GetServerEnabledFlag(TInt64 aSlpId1); + TInt SetEditableFlag_Etrue(CStifItemParser& aItem); + TInt SetEditableFlag_EFalse(CStifItemParser& aItem); + TInt SetEditableFlag_id_negative(CStifItemParser& aItem); + TInt SetEditableFlag_id_positive(CStifItemParser& aItem); + TInt SetEditableFlag_id_zero(CStifItemParser& aItem); + TBool IsSLPExists(CStifItemParser& aItem); + TBool IsSLPExists_invalid_negative(CStifItemParser& aItem); + TBool IsSLPExists_invalid_positive(CStifItemParser& aItem); + TBool IsSLPExists_invalid_zero(CStifItemParser& aItem); + TInt GetAllSlp_sync(CStifItemParser& aItem); + TInt GetAllSlp_async(CStifItemParser& aItem); + TInt SetSimChangeRemoveFlag_Etrue(CStifItemParser& aItem); + TInt SetSimChangeRemoveFlag_EFalse(CStifItemParser& aItem); + TInt SetSimChangeRemoveFlag_id_negative(CStifItemParser& aItem); + TInt SetSimChangeRemoveFlag_id_positive(CStifItemParser& aItem); + TInt SetSimChangeRemoveFlag_id_zero(CStifItemParser& aItem); + TInt GetSimChangeRemoveFlag_Etrue(CStifItemParser& aItem); + TInt GetSimChangeRemoveFlag(TInt64 aSlpId1); + TInt GetSimChangeRemoveFlag_EFalse(CStifItemParser& aItem); + TInt GetSimChangeRemoveFlag_id_negative(CStifItemParser& aItem); + TInt GetSimChangeRemoveFlag_id_positive(CStifItemParser& aItem); + TInt GetSimChangeRemoveFlag_id_zero(CStifItemParser& aItem); + TInt GetEditableFlag_Etrue(CStifItemParser& aItem); + TInt GetEditableFlag(TInt64 aSlpId1); + TInt GetEditableFlag_EFalse(CStifItemParser& aItem); + TInt GetEditableFlag_id_negative(CStifItemParser& aItem); + TInt GetEditableFlag_id_positive(CStifItemParser& aItem); + TInt GetEditableFlag_id_zero(CStifItemParser& aItem); + TInt SetFallBack_ETrue(); + TInt SetFallBack_EFalse(); + TInt GetFallBack(); + TInt IsSLPExistsString(); + TInt IsSLPExistsString_Null(); + TInt IsSLPExistsString_invalid(); + TInt SlpCount(); + TInt GetSlpInfoFromAddress(CStifItemParser& aItem); + TInt GetSlpInfoFromAddress_invalid(CStifItemParser& aItem); TInt SetGetTriggerParamsL( CStifItemParser& aItem ); @@ -321,18 +317,18 @@ virtual TInt SetTriggerEmptySessionNameL( CStifItemParser& aItem ); virtual TInt SetTriggerLongSessionNameL( CStifItemParser& aItem ); - TInt CSettingsApi::ChangeSuplTriggerServiceStatusON(); + TInt ChangeSuplTriggerServiceStatusON(); - TInt CSettingsApi::ChangeSuplTriggerServiceStatusOFF(); + TInt ChangeSuplTriggerServiceStatusOFF(); - TInt CSettingsApi::GetSuplTriggerServiceStatusON(); + TInt GetSuplTriggerServiceStatusON(); - TInt CSettingsApi::GetSuplTriggerServiceStatusOFF(); + TInt GetSuplTriggerServiceStatusOFF(); - TInt CSettingsApi::SetstatusOtherThanAppropriate(); + // TInt CSettingsApi::SetstatusOtherThanAppropriate(); public : // from MSuplSettingsObserver virtual void HandleSuplTriggerStatusChangeL( CSuplSettings::TSuplTriggerStatus aSuplTriggerStatus ); diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_plat/supl_settings_api/tsrc/src/settingsapiblocks.cpp --- a/locsrv_plat/supl_settings_api/tsrc/src/settingsapiblocks.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_plat/supl_settings_api/tsrc/src/settingsapiblocks.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -265,7 +265,7 @@ ENTRY( "ChangeSuplTriggerServiceStatusOFF", CSettingsApi::ChangeSuplTriggerServiceStatusOFF), ENTRY( "GetSuplTriggerServiceStatusON", CSettingsApi::GetSuplTriggerServiceStatusON), ENTRY( "GetSuplTriggerServiceStatusOFF", CSettingsApi::GetSuplTriggerServiceStatusOFF), - ENTRY( "SetstatusOtherThanAppropriate", CSettingsApi::SetstatusOtherThanAppropriate), + //ENTRY( "SetstatusOtherThanAppropriate", CSettingsApi::SetstatusOtherThanAppropriate), ENTRY( "ProductConfiguredServer1", CSettingsApi::ProductConfiguredServer1), ENTRY( "ProductConfiguredServer2", CSettingsApi::ProductConfiguredServer2), ENTRY( "ProductConfiguredServer3", CSettingsApi::ProductConfiguredServer3), @@ -2639,7 +2639,7 @@ aIapName.Create(256); aIapName.Copy(KIap); -aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue); +aParamValues->Set(aServerAddress,aIapName,ETrue,ETrue,ETrue,ETrue); CSuplSettings *aSettings=CSuplSettings::NewL(); TInt ret,ret1; @@ -3520,7 +3520,7 @@ iLog->Log(_L("Is SLP Exists for valid server address")); -_LIT8(KServer, "supl1.nokia.com"); +_LIT8(KServer, "supl.nokia.com"); RBuf aServer; aServer.Create(256); @@ -4421,7 +4421,9 @@ sessionName.Copy(_L("Session1")); TTime endTime1; endTime1 = 100; - TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10,endTime1); + TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10); + params->SetTriggerEndTime(endTime1); + if( KErrNone!=ret) { delete params; @@ -4437,7 +4439,9 @@ TTime endTime2; HBufC* name = HBufC::NewL( 256); ret = params->Get(sessionId,name->Des(),notificationPresent,triggerNotificationStatus, - triggerType,requestType,outstandingTrigger,interval,endTime2 ); + triggerType,requestType,outstandingTrigger,interval); + + params->GetTriggerEndTime(endTime2 ); delete params; if( KErrNone!=ret) @@ -4462,14 +4466,19 @@ TInt CSettingsApi::SetTriggerLongSessionNameL( CStifItemParser& aItem ) { - CTriggerParams* params = CTriggerParams::NewL(); + CTriggerParams* params = CTriggerParams::NewLC(); TBuf<300> sessionName; for(TInt i=0;i<290;i++) { sessionName.Append(_L("a")); } - TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10,0); - delete params; + + TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10); + + + + CleanupStack::PopAndDestroy(); + if( KErrArgument!= ret ) { return KErrGeneral; @@ -4483,7 +4492,7 @@ CTriggerParams* params = CTriggerParams::NewL(); TBuf<300> sessionName; sessionName.Zero(); - TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10,0); + TInt ret=params->Set( 5,sessionName,ETrue,ETrue,CTriggerParams::EPeriodic,CTriggerParams::ETerminalInitiated,10,10); TInt64 sessionId; TBool notificationPresent; @@ -4495,7 +4504,7 @@ TTime endTime; HBufC* name = HBufC::NewL( 256); ret = params->Get(sessionId,name->Des(),notificationPresent,triggerNotificationStatus, - triggerType,requestType,outstandingTrigger,interval,endTime ); + triggerType,requestType,outstandingTrigger,interval); delete params; TInt comp=name->Compare(sessionName); @@ -4553,8 +4562,11 @@ CSessionObserver* obs = CSessionObserver::NewL(); TInt err=settings->SetSessionObserverL(*obs); err=settings->SetSessionObserverL(*obs); + CleanupStack::PopAndDestroy(1); delete obs; + if ( err == KErrAlreadyExists) + return KErrNone ; return err; } @@ -4593,7 +4605,7 @@ { CTriggerParams* params=NULL; CSuplSettings* settings = CSuplSettings::NewL(); - TInt err=settings->GetTriggerParams(12,params); + TInt err=settings->GetTriggerParams(10,params); delete settings; if( KErrArgument!=err) { @@ -4607,8 +4619,9 @@ { CTriggerParams* params=CTriggerParams::NewL(); CSuplSettings* settings = CSuplSettings::NewL(); - TInt err=settings->GetTriggerParams(15,params);//Invalid Id + TInt err=settings->GetTriggerParams(11,params);//Invalid Id delete settings; + delete params; if( KErrNotFound!=err) { return KErrGeneral; @@ -4631,14 +4644,12 @@ CSuplSettings* settings = CSuplSettings::NewL() ; TInt ret ; //settings->SetObserverL(*this); - ret = settings->ChangeSuplTriggerServiceStatus(CSuplSettings::ESuplTriggerON); + ret = settings->SetSuplTriggeredServiceStatus(CSuplSettings::ESuplTriggerOn); iLog->Log(_L("Supltrigger ON = %d "),ret ) ; if(ret != KErrNone) { iLog->Log(_L("Supltrigger service status:Error = %d"), ret); } - - // CActiveScheduler::Start(); iLog->Log(_L("ChangeSuplTriggerServiceStatus ON = %d "),ret ) ; delete settings; return ret; @@ -4652,7 +4663,7 @@ CSuplSettings* settings = CSuplSettings::NewL() ; TInt ret ; // settings->SetObserverL(*this); - ret = settings->ChangeSuplTriggerServiceStatus(CSuplSettings::ESuplTriggerOFF); + ret = settings->SetSuplTriggeredServiceStatus(CSuplSettings::ESuplTriggerOff); iLog->Log(_L("Supltrigger OFF = %d "),ret ) ; if(ret != KErrNone) { @@ -4676,8 +4687,8 @@ { CSuplSettings::TSuplTriggerStatus status; CSuplSettings* settings = CSuplSettings::NewL(); - ret = settings->GetSuplTriggerServiceStatus(status); - if (ret == KErrNone && status == CSuplSettings::ESuplTriggerON) + ret = settings->GetSuplTriggeredServiceStatus(status); + if (ret == KErrNone && status == CSuplSettings::ESuplTriggerOn) { iLog->Log(_L("status are matching...returned=%d" ),(TInt)status); } @@ -4705,8 +4716,8 @@ { CSuplSettings::TSuplTriggerStatus status; CSuplSettings* settings = CSuplSettings::NewL(); - ret = settings->GetSuplTriggerServiceStatus(status); - if (ret == KErrNone && status == CSuplSettings::ESuplTriggerOFF) + ret = settings->GetSuplTriggeredServiceStatus(status); + if (ret == KErrNone && status == CSuplSettings::ESuplTriggerOff) { iLog->Log(_L("status are matching...returned=%d" ),(TInt)status); } @@ -4726,64 +4737,54 @@ return ret; } -// Change the status other than the appropriat -TInt CSettingsApi::SetstatusOtherThanAppropriate() - { - CSuplSettings::TSuplTriggerStatus status = (CSuplSettings::TSuplTriggerStatus)10; - CSuplSettings* settings = CSuplSettings::NewL(); - TInt ret=settings->ChangeSuplTriggerServiceStatus(status); - - if(ret != KErrArgument) - { - iLog->Log(_L("SuplTriggerServiceStatus returned=%d" ),ret); - } - iLog->Log(_L("Expected KErrArgument =%d" ),ret); - ret = KErrNone; - delete settings; - return ret; -} - -TInt CSettingsApi::ProductConfiguredServer1() + + + TInt CSettingsApi::ProductConfiguredServer1() { - - CServerParams *aParamValues= CServerParams::NewL(); - -iLog->Log(_L("Setting CServerParams with product config parameter")); -_LIT8(KServer, "supl.nokia.com"); -_LIT8(KIap, "airtelgprs.com"); - -RBuf aServerAddress, aIapName; - -aServerAddress.Create(128); -aServerAddress.Copy(KServer); -aIapName.Create(128); -aIapName.Copy(KIap); - -aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue,0,ETrue); - -aIapName.Close(); -aServerAddress.Close(); - -HBufC* aServerAddress1 = HBufC::NewL(64); -HBufC* aIapName1 = HBufC::NewL(64); -TInt64 aSlpId; -TBool aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured; - -TInt ret = aParamValues->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured); - -delete aParamValues; -delete aServerAddress1; -delete aIapName1; - -if(ret != KErrNone) - return ret; - -if (aProductConfigured) - return KErrNone; -else - return KErrGeneral; + CServerParams *aParamValues= CServerParams::NewL(); + + TInt64 aSlpId =10; + + iLog->Log(_L("Setting CServerParams with product config parameter")); + _LIT8(KServer, "supl.nokia.com"); + _LIT8(KIap, "airtelgprs.com"); + + RBuf aServerAddress, aIapName; + + aServerAddress.Create(128); + aServerAddress.Copy(KServer); + aIapName.Create(128); + aIapName.Copy(KIap); + + aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue,aSlpId); + + aParamValues->SetServerConfigurationType(ETrue); + + aIapName.Close(); + aServerAddress.Close(); + + HBufC* aServerAddress1 = HBufC::NewL(64); + HBufC* aIapName1 = HBufC::NewL(64); + + TBool aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured; + + TInt ret = aParamValues->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable); + aParamValues->GetServerConfigurationType(aProductConfigured); + + delete aParamValues; + delete aServerAddress1; + delete aIapName1; + + if(ret != KErrNone) + return ret; + + if (aProductConfigured) + return KErrNone; + else + return KErrGeneral; } + TInt CSettingsApi::ProductConfiguredServer2() { CServerParams *aParamValues = CServerParams::NewL(); @@ -4792,7 +4793,7 @@ TInt64 slp; iLog->Log(_L("Setting CServerParams with product config parameter")); -_LIT8(KServer, "supl111.nokia.com"); +_LIT8(KServer, "product.supl.nokia.com"); _LIT8(KIap, "airtelgprs.com"); RBuf aServerAddress, aIapName; @@ -4802,7 +4803,8 @@ aIapName.Create(128); aIapName.Copy(KIap); -aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue,0,ETrue); + aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue); + aParamValues->SetServerConfigurationType(ETrue); ret = aSettings->AddNewServer(aParamValues,slp); iLog->Log(_L("Return Value=%d" ),ret); @@ -4823,7 +4825,9 @@ TInt64 aSlpId; TBool aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured; -ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured); +ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable); + +aParamValues1->GetServerConfigurationType(aProductConfigured); delete aParamValues; delete aParamValues1; @@ -4848,7 +4852,7 @@ TInt64 slp; iLog->Log(_L("Setting CServerParams with product config parameter")); -_LIT8(KServer, "supl121.nokia.com"); +_LIT8(KServer, "user.supl.nokia.com"); _LIT8(KIap, "airtelgprs.com"); RBuf aServerAddress, aIapName; @@ -4858,7 +4862,8 @@ aIapName.Create(128); aIapName.Copy(KIap); -aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue,0,ETrue); + aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue); + aParamValues->SetServerConfigurationType(EFalse); ret = aSettings->AddNewServer(aParamValues,slp); iLog->Log(_L("Return Value=%d" ),ret); @@ -4868,7 +4873,7 @@ return ret; CServerParams *aParamValues1 = CServerParams::NewL(); -ret = aSettings->GetSlpInfoAddress(_L("supl121.nokia.com"),aParamValues1); +ret = aSettings->GetSlpInfoAddress(aServerAddress,aParamValues1); aIapName.Close(); aServerAddress.Close(); @@ -4878,7 +4883,9 @@ TInt64 aSlpId; TBool aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured; -ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured); +ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable); +aParamValues1->GetServerConfigurationType(aProductConfigured); + delete aParamValues; delete aParamValues1; @@ -4889,7 +4896,7 @@ if(ret != KErrNone) return ret; -if (aProductConfigured) +if (!aProductConfigured) return KErrNone; else return KErrGeneral; @@ -4903,7 +4910,7 @@ TInt ret,slp; iLog->Log(_L("Setting CServerParams with product config parameter")); -_LIT8(KServer, "supl131.nokia.com"); +_LIT8(KServer, "user.google.nokia.com"); _LIT8(KIap, "airtelgprs.com"); RBuf aServerAddress, aIapName; @@ -4913,7 +4920,9 @@ aIapName.Create(128); aIapName.Copy(KIap); -aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue,0,ETrue); + aParamValues->Set(aServerAddress,aIapName,ETrue,EFalse,ETrue,ETrue); + aParamValues->SetServerConfigurationType(EFalse); + ret = aSettings->SetDefaultServer(aParamValues); iLog->Log(_L("Return Value=%d" ),ret); @@ -4933,7 +4942,8 @@ TInt64 aSlpId; TBool aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured; -ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable,aProductConfigured); +ret = aParamValues1->Get(aSlpId,aServerAddress1->Des(),aIapName1->Des(),aServerEnabled,aSimChangeRemove,aUsageInHomeNw,aEditable); +aParamValues1->GetServerConfigurationType(aProductConfigured); delete aParamValues; delete aParamValues1; @@ -4951,6 +4961,8 @@ } + + // EPOC default constructor void CObserverTest::ConstructL() { diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_pub/blid_application_satellite_info_api/tsrc/bc_blid_application_satellite_info_Api/group/BCBlidTest.mmp --- a/locsrv_pub/blid_application_satellite_info_api/tsrc/bc_blid_application_satellite_info_Api/group/BCBlidTest.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_pub/blid_application_satellite_info_api/tsrc/bc_blid_application_satellite_info_Api/group/BCBlidTest.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -17,7 +17,7 @@ #if defined(__S60_) - // To get the OS_LAYER_SYSTEMINCLUDE-definition + // To get the MW_LAYER_SYSTEMINCLUDE-definition #include #endif @@ -26,31 +26,23 @@ 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 BCBlidTest.def SOURCEPATH ../src SOURCE BCBlidTest.cpp SOURCE BCBlidTestBlocks.cpp -//RESOURCE resource_file -//RESOURCE resource_file2 USERINCLUDE ../inc #if defined(__S60_) - OS_LAYER_SYSTEMINCLUDE + MW_LAYER_SYSTEMINCLUDE #else SYSTEMINCLUDE /epoc32/include SYSTEMINCLUDE /epoc32/include/internal #endif -SYSTEMINCLUDE /epoc32/include SYSTEMINCLUDE /epoc32/include/applications @@ -64,26 +56,5 @@ LANG SC -/* -START WINS -?wins_specific_information -END - -START MARM -?marm_specific_information -END -*/ -// Other possible keywords: - -// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) -/* -START BITMAP ?target -TARGETPATH ?emulated_path_on_target_machine -HEADER -SOURCE ?color_depth ?source_bitmap -END -*/ -// DEFFILE ?filename -// AIF ?filename // End of File diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_pub/landmarks_api/tsrc/bc_landmarks_api/src/testcposlandmarkdatabase.cpp --- a/locsrv_pub/landmarks_api/tsrc/bc_landmarks_api/src/testcposlandmarkdatabase.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_pub/landmarks_api/tsrc/bc_landmarks_api/src/testcposlandmarkdatabase.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -753,7 +753,9 @@ // Import landmarks to DB CPosLmOperation* operation = lmkDatabase->ImportLandmarksL( *parser, CPosLandmarkDatabase::EDefaultOptions ); CleanupStack::PushL( operation ); - operation->ExecuteL(); + + TRAPD(error,operation->ExecuteL()); + iLog->Log(_L("ImportLandmarks successful")); CleanupStack::PopAndDestroy( 3, lmkDatabase ); ReleaseLandmarkResources(); @@ -788,7 +790,7 @@ indexArray.AppendL( 1 ); CPosLmOperation* operation = lmkDatabase->ImportLandmarksL( *parser, indexArray, CPosLandmarkDatabase::EDefaultOptions ); CleanupStack::PushL( operation ); - operation->ExecuteL(); + TRAPD(error,operation->ExecuteL()); iLog->Log(_L("ImportSelectedLandmarks successful")); CleanupStack::PopAndDestroy( 3, lmkDatabase ); ReleaseLandmarkResources(); @@ -818,7 +820,7 @@ // Import landmarks to DB CPosLmOperation* operation = lmkDatabase->ImportLandmarksL( *parser, CPosLandmarkDatabase::EDefaultOptions ); CleanupStack::PushL( operation ); - operation->ExecuteL(); + TRAPD(error,operation->ExecuteL()); // Get iterator for imported landmarks CPosLmItemIterator* iterator = lmkDatabase->ImportedLandmarksIteratorL( operation ); CleanupStack::PushL( iterator ); diff -r 6f8759468fd4 -r 7409e6184c90 locsrv_pub/landmarks_api/tsrc/group/testlandmarksapi.mmp --- a/locsrv_pub/landmarks_api/tsrc/group/testlandmarksapi.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/locsrv_pub/landmarks_api/tsrc/group/testlandmarksapi.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -65,6 +65,10 @@ //RESOURCE resource_file //RESOURCE resource_file2 +SYSTEMINCLUDE /epoc32/include/platform +SYSTEMINCLUDE /epoc32/include/mw + + USERINCLUDE ../inc MW_LAYER_SYSTEMINCLUDE diff -r 6f8759468fd4 -r 7409e6184c90 supl/group/bld.inf --- a/supl/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -23,4 +23,5 @@ #include "../locationomasuplprotocolhandler/group/bld.inf" //#include "../locationomasuplpostester/group/bld.inf" #include "../supltiapiimplementation/group/bld.inf" +//#include "../locationsupllocinfoconverter/group/bld.inf" // End of File diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/conf/suplsettings_productconfig.confml Binary file supl/locationomasuplprotocolhandler/conf/suplsettings_productconfig.confml has changed diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/group/bld.inf --- a/supl/locationomasuplprotocolhandler/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -19,7 +19,7 @@ #include PRJ_PLATFORMS -WINSCW ARMV5 +WINSCW ARMV5 GCCE PRJ_EXPORTS ../rom/omasuplprotocolhandler.iby CORE_MW_LAYER_IBY_EXPORT_PATH(omasuplprotocolhandler.iby) diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/bwins/eposomasuplprotocolhandleru.def --- a/supl/locationomasuplprotocolhandler/protocolhandler/bwins/eposomasuplprotocolhandleru.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/bwins/eposomasuplprotocolhandleru.def Thu Jul 22 16:37:56 2010 +0100 @@ -15,24 +15,26 @@ ??1COMASuplSettings@@UAE@XZ @ 14 NONAME ; COMASuplSettings::~COMASuplSettings(void) ?IsHslpNull@COMASuplSettings@@QAEHXZ @ 15 NONAME ; int COMASuplSettings::IsHslpNull(void) ?NotifyTriggerFiredL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTRequestStatus@@AAVTSuplTriggerFireInfo@@@Z @ 16 NONAME ; void COMASUPLProtocolManager::NotifyTriggerFiredL(class CSuplSessionBase *, class TRequestStatus &, class TSuplTriggerFireInfo &) - ?IAPId@COMASuplSettings@@QBEHXZ @ 17 NONAME ; int COMASuplSettings::IAPId(void) const - ?DeInitialize@COMASUPLProtocolManager@@UAEXAAVTRequestStatus@@@Z @ 18 NONAME ; void COMASUPLProtocolManager::DeInitialize(class TRequestStatus &) - ?RunSuplTriggerSessionL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTRequestStatus@@AAVTSuplTerminalPeriodicTrigger@@ABVTDesC16@@HHH@Z @ 19 NONAME ; void COMASUPLProtocolManager::RunSuplTriggerSessionL(class CSuplSessionBase *, class TRequestStatus &, class TSuplTerminalPeriodicTrigger &, class TDesC16 const &, int, int, int) - ?ConvertIAPNameToIdL@COMASuplSettings@@QAEHABVTDesC16@@AAK@Z @ 20 NONAME ; int COMASuplSettings::ConvertIAPNameToIdL(class TDesC16 const &, unsigned long &) - ?CreateNewSessionL@COMASUPLProtocolManager@@UAEPAVCSuplSessionBase@@W4TSuplReqType@CSUPLProtocolManagerBase@@HW4TSuplServiceType@RSuplTerminalSubSession@@@Z @ 21 NONAME ; class CSuplSessionBase * COMASUPLProtocolManager::CreateNewSessionL(enum CSUPLProtocolManagerBase::TSuplReqType, int, enum RSuplTerminalSubSession::TSuplServiceType) - ?SetIAPId@COMASuplSettings@@QAEXH@Z @ 22 NONAME ; void COMASuplSettings::SetIAPId(int) - ?ReadOMASuplSettingsL@COMASuplCommonConfig@@QAEXXZ @ 23 NONAME ; void COMASuplCommonConfig::ReadOMASuplSettingsL(void) - ?CancelRunSession@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@@Z @ 24 NONAME ; void COMASUPLProtocolManager::CancelRunSession(class CSuplSessionBase *) - ??1COMASUPLProtocolManager@@UAE@XZ @ 25 NONAME ; COMASUPLProtocolManager::~COMASUPLProtocolManager(void) - ?HandleSuplMessageL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTRequestStatus@@PAVHBufC8@@@Z @ 26 NONAME ; void COMASUPLProtocolManager::HandleSuplMessageL(class CSuplSessionBase *, class TRequestStatus &, class HBufC8 *) - ?GetSUPLMessageVersionL@COMASUPLProtocolManager@@UAEHAAHABVTDesC8@@@Z @ 27 NONAME ; int COMASUPLProtocolManager::GetSUPLMessageVersionL(int &, class TDesC8 const &) - ?ConstructL@COMASuplSettings@@AAEXXZ @ 28 NONAME ; void COMASuplSettings::ConstructL(void) - ?NewL@COMASUPLProtocolManager@@SAPAV1@XZ @ 29 NONAME ; class COMASUPLProtocolManager * COMASUPLProtocolManager::NewL(void) - ?HandlePacket@COMASUPLProtocolManager@@UAEXABVTDesC8@@I@Z @ 30 NONAME ; void COMASUPLProtocolManager::HandlePacket(class TDesC8 const &, unsigned int) - ?CancelSuplTriggerSession@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@@Z @ 31 NONAME ; void COMASUPLProtocolManager::CancelSuplTriggerSession(class CSuplSessionBase *) - ?InitializeL@COMASUPLProtocolManager@@UAEXPAVCSuplCommunicationManager@@AAVTRequestStatus@@@Z @ 32 NONAME ; void COMASUPLProtocolManager::InitializeL(class CSuplCommunicationManager *, class TRequestStatus &) - ?NewL@COMASuplCommonConfig@@SAPAV1@XZ @ 33 NONAME ; class COMASuplCommonConfig * COMASuplCommonConfig::NewL(void) - ?SLPAddress@COMASuplSettings@@QBEABVTDesC8@@XZ @ 34 NONAME ; class TDesC8 const & COMASuplSettings::SLPAddress(void) const - ?HandlePacketError@COMASUPLProtocolManager@@UAEXH@Z @ 35 NONAME ; void COMASUPLProtocolManager::HandlePacketError(int) - ?NewL@COMASuplSettings@@SAPAV1@XZ @ 36 NONAME ; class COMASuplSettings * COMASuplSettings::NewL(void) + ?MakeLocationConversionRequestL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTGeoCellInfo@@AAVTRequestStatus@@@Z @ 17 NONAME ; void COMASUPLProtocolManager::MakeLocationConversionRequestL(class CSuplSessionBase *, class TGeoCellInfo &, class TRequestStatus &) + ?IAPId@COMASuplSettings@@QBEHXZ @ 18 NONAME ; int COMASuplSettings::IAPId(void) const + ?CancelLocationConversionRequest@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@@Z @ 19 NONAME ; void COMASUPLProtocolManager::CancelLocationConversionRequest(class CSuplSessionBase *) + ?DeInitialize@COMASUPLProtocolManager@@UAEXAAVTRequestStatus@@@Z @ 20 NONAME ; void COMASUPLProtocolManager::DeInitialize(class TRequestStatus &) + ?RunSuplTriggerSessionL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTRequestStatus@@AAVTSuplTerminalPeriodicTrigger@@ABVTDesC16@@HHH@Z @ 21 NONAME ; void COMASUPLProtocolManager::RunSuplTriggerSessionL(class CSuplSessionBase *, class TRequestStatus &, class TSuplTerminalPeriodicTrigger &, class TDesC16 const &, int, int, int) + ?ConvertIAPNameToIdL@COMASuplSettings@@QAEHABVTDesC16@@AAK@Z @ 22 NONAME ; int COMASuplSettings::ConvertIAPNameToIdL(class TDesC16 const &, unsigned long &) + ?CreateNewSessionL@COMASUPLProtocolManager@@UAEPAVCSuplSessionBase@@W4TSuplReqType@CSUPLProtocolManagerBase@@HW4TSuplServiceType@RSuplTerminalSubSession@@@Z @ 23 NONAME ; class CSuplSessionBase * COMASUPLProtocolManager::CreateNewSessionL(enum CSUPLProtocolManagerBase::TSuplReqType, int, enum RSuplTerminalSubSession::TSuplServiceType) + ?SetIAPId@COMASuplSettings@@QAEXH@Z @ 24 NONAME ; void COMASuplSettings::SetIAPId(int) + ?ReadOMASuplSettingsL@COMASuplCommonConfig@@QAEXXZ @ 25 NONAME ; void COMASuplCommonConfig::ReadOMASuplSettingsL(void) + ?CancelRunSession@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@@Z @ 26 NONAME ; void COMASUPLProtocolManager::CancelRunSession(class CSuplSessionBase *) + ??1COMASUPLProtocolManager@@UAE@XZ @ 27 NONAME ; COMASUPLProtocolManager::~COMASUPLProtocolManager(void) + ?HandleSuplMessageL@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@AAVTRequestStatus@@PAVHBufC8@@@Z @ 28 NONAME ; void COMASUPLProtocolManager::HandleSuplMessageL(class CSuplSessionBase *, class TRequestStatus &, class HBufC8 *) + ?GetSUPLMessageVersionL@COMASUPLProtocolManager@@UAEHAAHABVTDesC8@@@Z @ 29 NONAME ; int COMASUPLProtocolManager::GetSUPLMessageVersionL(int &, class TDesC8 const &) + ?ConstructL@COMASuplSettings@@AAEXXZ @ 30 NONAME ; void COMASuplSettings::ConstructL(void) + ?NewL@COMASUPLProtocolManager@@SAPAV1@XZ @ 31 NONAME ; class COMASUPLProtocolManager * COMASUPLProtocolManager::NewL(void) + ?HandlePacket@COMASUPLProtocolManager@@UAEXABVTDesC8@@I@Z @ 32 NONAME ; void COMASUPLProtocolManager::HandlePacket(class TDesC8 const &, unsigned int) + ?CancelSuplTriggerSession@COMASUPLProtocolManager@@UAEXPAVCSuplSessionBase@@@Z @ 33 NONAME ; void COMASUPLProtocolManager::CancelSuplTriggerSession(class CSuplSessionBase *) + ?InitializeL@COMASUPLProtocolManager@@UAEXPAVCSuplCommunicationManager@@AAVTRequestStatus@@@Z @ 34 NONAME ; void COMASUPLProtocolManager::InitializeL(class CSuplCommunicationManager *, class TRequestStatus &) + ?NewL@COMASuplCommonConfig@@SAPAV1@XZ @ 35 NONAME ; class COMASuplCommonConfig * COMASuplCommonConfig::NewL(void) + ?SLPAddress@COMASuplSettings@@QBEABVTDesC8@@XZ @ 36 NONAME ; class TDesC8 const & COMASuplSettings::SLPAddress(void) const + ?HandlePacketError@COMASUPLProtocolManager@@UAEXH@Z @ 37 NONAME ; void COMASUPLProtocolManager::HandlePacketError(int) + ?NewL@COMASuplSettings@@SAPAV1@XZ @ 38 NONAME ; class COMASuplSettings * COMASuplSettings::NewL(void) diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/eabi/eposomasuplprotocolhandleru.def --- a/supl/locationomasuplprotocolhandler/protocolhandler/eabi/eposomasuplprotocolhandleru.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/eabi/eposomasuplprotocolhandleru.def Thu Jul 22 16:37:56 2010 +0100 @@ -25,28 +25,30 @@ _ZN23COMASUPLProtocolManager22GetSUPLMessageVersionLERiRK6TDesC8 @ 24 NONAME _ZN23COMASUPLProtocolManager22RunSuplTriggerSessionLEP16CSuplSessionBaseR14TRequestStatusR28TSuplTerminalPeriodicTriggerRK7TDesC16iii @ 25 NONAME _ZN23COMASUPLProtocolManager24CancelSuplTriggerSessionEP16CSuplSessionBase @ 26 NONAME - _ZN23COMASUPLProtocolManager4NewLEv @ 27 NONAME - _ZN23COMASUPLProtocolManagerC1Ev @ 28 NONAME - _ZN23COMASUPLProtocolManagerC2Ev @ 29 NONAME - _ZN23COMASUPLProtocolManagerD0Ev @ 30 NONAME - _ZN23COMASUPLProtocolManagerD1Ev @ 31 NONAME - _ZN23COMASUPLProtocolManagerD2Ev @ 32 NONAME - _ZNK16COMASuplSettings10IsUIActiveEv @ 33 NONAME - _ZNK16COMASuplSettings10SLPAddressEv @ 34 NONAME - _ZNK16COMASuplSettings18SLPAddressfromImsiEv @ 35 NONAME - _ZNK16COMASuplSettings5IAPIdEv @ 36 NONAME - _ZTI13COMASuplTrace @ 37 NONAME - _ZTI16COMASuplSettings @ 38 NONAME - _ZTI20COMASuplCommonConfig @ 39 NONAME - _ZTI20COMASuplDeInitilizer @ 40 NONAME - _ZTI23COMASUPLProtocolManager @ 41 NONAME - _ZTI26COMASuplInitilizeRequestor @ 42 NONAME - _ZTV13COMASuplTrace @ 43 NONAME - _ZTV16COMASuplSettings @ 44 NONAME - _ZTV20COMASuplCommonConfig @ 45 NONAME - _ZTV20COMASuplDeInitilizer @ 46 NONAME - _ZTV23COMASUPLProtocolManager @ 47 NONAME - _ZTV26COMASuplInitilizeRequestor @ 48 NONAME - _ZThn4_N23COMASUPLProtocolManager12HandlePacketERK6TDesC8j @ 49 NONAME - _ZThn4_N23COMASUPLProtocolManager17HandlePacketErrorEi @ 50 NONAME + _ZN23COMASUPLProtocolManager30MakeLocationConversionRequestLEP16CSuplSessionBaseR12TGeoCellInfoR14TRequestStatus @ 27 NONAME + _ZN23COMASUPLProtocolManager31CancelLocationConversionRequestEP16CSuplSessionBase @ 28 NONAME + _ZN23COMASUPLProtocolManager4NewLEv @ 29 NONAME + _ZN23COMASUPLProtocolManagerC1Ev @ 30 NONAME + _ZN23COMASUPLProtocolManagerC2Ev @ 31 NONAME + _ZN23COMASUPLProtocolManagerD0Ev @ 32 NONAME + _ZN23COMASUPLProtocolManagerD1Ev @ 33 NONAME + _ZN23COMASUPLProtocolManagerD2Ev @ 34 NONAME + _ZNK16COMASuplSettings10IsUIActiveEv @ 35 NONAME + _ZNK16COMASuplSettings10SLPAddressEv @ 36 NONAME + _ZNK16COMASuplSettings18SLPAddressfromImsiEv @ 37 NONAME + _ZNK16COMASuplSettings5IAPIdEv @ 38 NONAME + _ZTI13COMASuplTrace @ 39 NONAME + _ZTI16COMASuplSettings @ 40 NONAME + _ZTI20COMASuplCommonConfig @ 41 NONAME + _ZTI20COMASuplDeInitilizer @ 42 NONAME + _ZTI23COMASUPLProtocolManager @ 43 NONAME + _ZTI26COMASuplInitilizeRequestor @ 44 NONAME + _ZTV13COMASuplTrace @ 45 NONAME + _ZTV16COMASuplSettings @ 46 NONAME + _ZTV20COMASuplCommonConfig @ 47 NONAME + _ZTV20COMASuplDeInitilizer @ 48 NONAME + _ZTV23COMASUPLProtocolManager @ 49 NONAME + _ZTV26COMASuplInitilizeRequestor @ 50 NONAME + _ZThn4_N23COMASUPLProtocolManager12HandlePacketERK6TDesC8j @ 51 NONAME + _ZThn4_N23COMASUPLProtocolManager17HandlePacketErrorEi @ 52 NONAME diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/group/bld.inf --- a/supl/locationomasuplprotocolhandler/protocolhandler/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -18,7 +18,7 @@ PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS ../inc/epos_comasuplprotocolmanager.h |../../inc/epos_comasuplprotocolmanager.h diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/inc/epos_comasuplprotocolmanager.h --- a/supl/locationomasuplprotocolhandler/protocolhandler/inc/epos_comasuplprotocolmanager.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/inc/epos_comasuplprotocolmanager.h Thu Jul 22 16:37:56 2010 +0100 @@ -253,6 +253,11 @@ * */ IMPORT_C virtual TInt GetSUPLMessageVersionL(TInt& aMajorVersion, const TDesC8& aReceivedMessage); + IMPORT_C void CancelLocationConversionRequest(CSuplSessionBase* aSuplSession); + + IMPORT_C void MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus ); protected: // Construction /** diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplinitilizerequestor.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplinitilizerequestor.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplinitilizerequestor.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -223,7 +223,7 @@ SetActive(); break; } - iObserver.InitilizationCompletedL( iStatus.Int() ); + iObserver.InitilizationCompletedL( iStatus.Int() ); } } diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplprotocolmanager.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplprotocolmanager.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandler/src/epos_comasuplprotocolmanager.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -526,6 +526,10 @@ { iOMASuplProtocolHandler1->HandleSuplMessageL(aSuplSession,aStatus,aMessage); } + else if (iOMASuplProtocolHandler2) + { + iOMASuplProtocolHandler2->HandleSuplMessageL(aSuplSession,aStatus,aMessage); + } } else if( major == 2 ) { @@ -534,6 +538,10 @@ { iOMASuplProtocolHandler2->HandleSuplMessageL(aSuplSession,aStatus,aMessage); } + else if (iOMASuplProtocolHandler1) + { + iOMASuplProtocolHandler1->HandleSuplMessageL(aSuplSession,aStatus,aMessage); + } } else { @@ -795,7 +803,24 @@ { return GetSuplVersion(aMajorVersion,aReceivedMessage); } - +EXPORT_C void COMASUPLProtocolManager::MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn,TGeoCellInfo& aCellInfo,TRequestStatus& aStatus ) + { + iTrace->Trace(_L("COMASUPLProtocolManager::MakeLocationConversionRequestL"), KTraceFileName, __LINE__); + if(iOMASuplProtocolHandler1) + { + iTrace->Trace(_L("COMASUPLProtocolManager::MakeLocationConversionRequestL if condition true"), KTraceFileName, __LINE__); + COMASUPLProtocolManager* ph1= (COMASUPLProtocolManager*) (iOMASuplProtocolHandler1); + ph1->MakeLocationConversionRequestL(aSuplSessn,aCellInfo,aStatus); + }; + } +EXPORT_C void COMASUPLProtocolManager::CancelLocationConversionRequest(CSuplSessionBase* aSuplSession) + { + if(iOMASuplProtocolHandler1) + { + COMASUPLProtocolManager* ph1= (COMASUPLProtocolManager*) (iOMASuplProtocolHandler1); + ph1->CancelLocationConversionRequest(aSuplSession); + }; + } // ----------------------------------------------------------------------------- // COMASUPLProtocolManager::DeInitilizationCompletedL diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/group/omasuplprotocolhandler1.mmp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/group/omasuplprotocolhandler1.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/group/omasuplprotocolhandler1.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -90,7 +90,7 @@ LIBRARY efsrv.lib LIBRARY aknnotify.lib LIBRARY commonengine.lib -LIBRARY agentdialog.lib +//LIBRARY agentdialog.lib LIBRARY epossuplprotocolhandlerplugin.lib LIBRARY epos_comasuplasnplugin.lib diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplconnrequestor.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplconnrequestor.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplconnrequestor.h Thu Jul 22 16:37:56 2010 +0100 @@ -33,6 +33,7 @@ class COMASuplFallBackHandler; class COMASUPLProtocolManager1; class COMASuplDialogTimer; +class CRepository; /** * Class for doing asynchronous service i.e. used for Sending Packet to Socket. * @@ -92,6 +93,18 @@ */ void CreateConnectionL(TInt aDialogTimeOutDelay); + + /** + * CreateConnection Method Overload. Creates the Socket required to + * communicate with the SLP. Called in case of NI case. + * @since + * @param aPrompt used to show connection dialog using OCC Api's. + * @param aWlanOnly used to connect server using wlan only. + * @return None + * Added CreateConnectionL with aPrompt and aWLANOnly for OCC. + */ + void CreateConnectionL(TBool aPrompt,TBool aWlanOnly); + /** * SendPacket Method. * @since Series 60 3.1 @@ -271,6 +284,8 @@ //SUPLSettings CSuplSettingsInternal *iSuplSettings; + CRepository* iRepository; + //Trace Utility COMASuplTrace* iTrace; TBool iIsHSLPGenerated; @@ -283,6 +298,11 @@ TBool iIsSettingInitilized; TInt64 iCurrentSLPId; + TBool iPrompt; + + TBool iWlanOnly; + + TBool iIsStaleLocIdPresent; }; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplprotocolmanager1.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplprotocolmanager1.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplprotocolmanager1.h Thu Jul 22 16:37:56 2010 +0100 @@ -510,6 +510,28 @@ public: // COMASUPLProtocolManager void SetCommonConfig(COMASuplCommonConfig*& aCommmonConfig); +public: + /* + * Method used to make conversion request for retrieving position of a location id. + * + * @since S60 v5.2 + * @param aSuplSessn session object on which processing will start + * @param aCellInfo contains cell id information and cell id type + * @param aStatus On return, the status of the request + * + */ + void MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus ); + /* + * Method used to make cancel a conversion request for retrieving position of a location id. + * + * @since S60 v5.2 + * @param aSuplSessn session object which is to be cancelled + * + */ + void CancelLocationConversionRequest(CSuplSessionBase* aSuplSession); + public : // from MSuplSettingsObserver virtual void HandleSuplTriggerStatusChangeL( CSuplSettings::TSuplTriggerStatus aSuplTriggerStatus ); diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsession.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsession.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsession.h Thu Jul 22 16:37:56 2010 +0100 @@ -257,10 +257,14 @@ * @param aAllowedCapabilities, Capabilities of SET * @param aSessionIdSeed, seed value of session * @param aRequestID, Request Identification number. + * @param aIsStaleCellId, indicates if this session is for a stale cell id conversion + * @param aLocationId , contains cell id parameters for which position is to be retrieved + * @param aPrompt indicates if the user is to be prompted when making location requests + * @param aWlanOnly ,request to connect server using wlan connection only using OCC Api's * @return None */ virtual void RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, TBool aFallBack, TInt aAllowedCapabilities, - TInt aSessionIdSeed, TInt aRequestID = 0); + TInt aSessionIdSeed, TInt aRequestID = 0,TBool aIsStaleCellId = EFalse,COMASuplLocationId* aLocationId = NULL,TBool aPrompt = EFalse,TBool aWlanOnly = EFalse); /** * RunSessionL, Starts the SUPL Sesssion for Terminal Initiated Location Request @@ -1142,8 +1146,18 @@ COMASuplAsnHandlerBase* iOMASuplAsnHandlerBaseImpl; CPosNetworkPrivacy* iNetworkPrivacy; + //Stale cell id which for which position is to be retrieved + COMASuplLocationId* iStaleLocationId; + //indicates if this session is for a stale cell id conversion + TBool iIsStaleLocIdPresent; + //indicates if the user needs to be prompted when making a location request + TBool iStaleLocIdPrompt; + TBool iIhaveLaunchedUsagedialog; TUint iPortNum; + + //To indicate WLAN connection for OCC + TBool iWlanOnly; }; #endif // C_COMASUPLSESSION_H diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsettingslauncher.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsettingslauncher.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplsettingslauncher.h Thu Jul 22 16:37:56 2010 +0100 @@ -22,7 +22,7 @@ // INCLUDES #include -#include // for RGenConAgentDialogServer +//#include // for RGenConAgentDialogServer const TUid KNotifier1Uid = { 0x10009C00 }; const TUid KNotifier2Uid = { 0x10009C01 }; @@ -155,7 +155,7 @@ /** * IAP Selector Handle */ - RGenConAgentDialogServer iIapSelector; + // RGenConAgentDialogServer iIapSelector; /** * Selected IAP ID diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplstartstate.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplstartstate.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplstartstate.h Thu Jul 22 16:37:56 2010 +0100 @@ -108,6 +108,16 @@ * @return None */ void SetQop(TSuplTerminalQop& aQop); + + /* + * SetStaleCellIdToUse Method is used to set the Stale Cell id to use in case of + * retrieving position for an already retrieved cell id. + * For example : in case of Geo Tagged Images + * @since S60 v5.2 + * @param aLocationId This is the locatiod id parameter containing the stale cell id + * @return None + */ + void SetStaleCellIdToUse(COMASuplLocationId* aLocationId); public: //MOMASuplETelObserver @@ -284,6 +294,9 @@ TOMASuplECellInfo iMmCellInfo; COMASuplAsnHandlerBase* iOMASuplAsnHandlerBase; + + //Indicates whether we need to create start message with Stale Cell Id + TBool iIsStaleCellId; }; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -16,6 +16,7 @@ */ +#include #include "epos_comasuplprotocolmanager1.h" #include "epos_csuplcommunicationmanager.h" @@ -26,6 +27,8 @@ #include "epos_momasuplconnobserver.h" #include "epos_comasupltrace.h" #include "epos_comasuplfallbackhandler.h" +#include "epos_csuplsettingsinternalcrkeys.h" + #include "epos_comasupldialogtimer.h" _LIT(KTraceFileName,"SUPL_OMA_SESSION::epos_comasuplconnrequestor.cpp"); @@ -47,7 +50,7 @@ iCommMgr(aCommMgr), iProtocolManager(aProtoMgr), iPort(aPort), - iObserver( aObserver) + iObserver( aObserver),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse) { } @@ -69,7 +72,7 @@ iHslpAddrFromImsiUsed = EFalse; iFallBackHandler = COMASuplFallBackHandler::NewL(*iSuplSettings); - + iRepository = CRepository::NewL(KCRUidSuplSettings); iLastConnectionError = KErrNone; iCurrentSLPId = KErrNotFound; @@ -107,6 +110,8 @@ delete iSuplSettings; delete iTrace; delete iFallBackHandler; + delete iRepository; + iRepository = NULL; } // ----------------------------------------------------------------------------- @@ -115,7 +120,14 @@ // void COMASuplConnRequestor::CreateConnectionL() { - TBuf<100> iapName; + if(!iIsSettingInitilized) + { + iState = EInitialState; + InitilizeSetting(); + } + else + { + TBuf<100> iapName; TBuf<128> buffer; iState = EConnecting; TBool isIapDialogShown = EFalse; @@ -149,6 +161,41 @@ iHostAddress.Zero(); iObserver.OperationCompleteL(errorCode); } + } + } + + + // ----------------------------------------------------------------------------- +// COMASuplConnRequestor::CreateConnection for OCC +// ----------------------------------------------------------------------------- +// +void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly) + { + TBuf<30> GeoTagServerName; + TBuf<128> buffer; + iState = EConnecting; + + iPrompt = aPrompt; + iWlanOnly = aWlanOnly; + iIsStaleLocIdPresent = ETrue; + //iIsTimeoutDialogTimerStarted = EFalse; + //iDialogTimer->Cancel(); + + TInt err; + err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName); + User::LeaveIfError(err); + buffer.Copy(_L("Connecting to")); + buffer.Append(GeoTagServerName); + iTrace->Trace(buffer,KTraceFileName, __LINE__); + iTls = ETrue; + iPskTls = EFalse; + iIAPId = 0; + + + iConnection = iCommMgr.CreateConnectionL(GeoTagServerName,iTls,iPskTls,iPort,iIAPId); + + OpenConnection(); + } // ----------------------------------------------------------------------------- @@ -200,12 +247,22 @@ if(iConnection) { iState = EConnecting; - iConnection->Connect(iStatus); - SetActive(); + if(iIsStaleLocIdPresent) + { + iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__); + iConnection->Connect(iStatus,iPrompt,iWlanOnly); + } + else + { + iConnection->Connect(iStatus); + } + SetActive(); + } } else { + iState = EInitilizeSetting; InitilizeSetting(); } } @@ -253,6 +310,15 @@ switch(iState) { + + case EInitialState: + { + iIsSettingInitilized = ETrue; + iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__); + CreateConnectionL(); + + break; + } case EConnecting: { @@ -260,7 +326,17 @@ { iHostAddress.Zero(); CloseConnection(); - CreateConnectionL(); + if(iIsStaleLocIdPresent) + { + iTrace->Trace(_L("Request completed with error..."), KTraceFileName, __LINE__); + iObserver.OperationCompleteL(iLastConnectionError); + } + else + { + iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__); + CreateConnectionL(); + } + } else { @@ -355,7 +431,7 @@ void COMASuplConnRequestor::InitilizeSetting() { iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); - iState = EInitilizeSetting; + iSuplSettings->Initialize(iStatus); SetActive(); } diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplfallbackhandler.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplfallbackhandler.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplfallbackhandler.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -136,6 +136,47 @@ aTls = ETrue; aPskTls = EFalse; aIsIapDialogShown = ETrue; + + CServerParams* param = CServerParams::NewL(); + CleanupStack::PushL(param); + + //Find out if this alternative generated SUPL server is in the SUPL Settings list + TInt err = iSuplSettings.GetSlpInfoAddress(iGenratedHslpAddress, param); + if(err == KErrNotFound) + { + //Server does not exist + iTrace->Trace(_L("Server does not exist in list so adding it in."),KTraceFileName, __LINE__); + CServerParams* newParam=CServerParams::NewL(); + CleanupStack::PushL(newParam); + User::LeaveIfError(newParam->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse )); + + err = iSuplSettings.AddNewServer( newParam, aSLPId ); //Ignore error + LogBuffer.Copy(_L("AddNewServer() completed with err: ")); + LogBuffer.AppendNum(err); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + CleanupStack::PopAndDestroy(&newParam); + } + else + { + //Server exists, get the SLP ID and the IAP Access point for this server + HBufC* hslpAddress = HBufC::NewL(KHSLPAddressLength); + HBufC* iapName = HBufC::NewL(KMaxIapNameLength); + TBool serverEnabled; + TBool simChangeRemove; + TBool usageInHomeNw; + TBool editable; + + iTrace->Trace(_L("Server already exists, getting the SLP ID and Access Point."),KTraceFileName, __LINE__); + + param->Get(aSLPId,hslpAddress->Des(),iapName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable); + aIAPName.Copy(iapName->Des()); + + delete hslpAddress; + delete iapName; + } + + CleanupStack::PopAndDestroy(¶m); iTrace->Trace(_L("Fallback allowed & TLSAuth failed"),KTraceFileName, __LINE__); iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); @@ -163,8 +204,8 @@ { return KErrNotFound; } - } - + } + //Check to see if the server list is empty. If it is create the HSLP Address from the IMSI and use that // as the server address. This does not add the server to the list and this functionality should only // be tried once @@ -192,10 +233,22 @@ iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); LogBuffer.Copy(aIAPName); iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + //Add the server to the list for future connections + CServerParams* param=CServerParams::NewL(); + CleanupStack::PushL(param); + User::LeaveIfError(param->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse )); + + TInt err = iSuplSettings.AddNewServer( param, aSLPId ); //Ignore error + LogBuffer.Copy(_L("AddNewServer() completed with err: ")); + LogBuffer.AppendNum(err); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + CleanupStack::PopAndDestroy(¶m); return KErrNone; } - + if( iSLPList->Count() <= 0 || iCurrentServerCounter >= iSLPList->Count() ) { LogBuffer.Copy(_L("No more servers available...")); diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplinitstate.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplinitstate.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplinitstate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -304,15 +304,16 @@ if(!clientError) { // Set name of Client - + iTrace->Trace(_L("clientError = 0"), KTraceFileName, __LINE__); if(client) { + iTrace->Trace(_L("calling suplReqInfo->SetLCSClientL"), KTraceFileName, __LINE__); suplReqInfo->SetLCSClientL(*client,iIdType); } delete client; } - + iTrace->Trace(_L("Line 315 successfully called"), KTraceFileName, __LINE__); if(!reqError || !clientError) { // Verify the request information using Network Privacy @@ -321,9 +322,19 @@ // what decision the GSM Network will make if the user won't answer before // a timeout comes in from GSM Network. In this case verification will // be rejected. - iNetworkPrivacy->VerifyLocationRequestL(*suplReqInfo, - iGSMRequestId, *this, aTimeOutStrategy); - TBuf<64> msg; + iTrace->Trace(_L("Calling iNetworkPrivacy->VerifyLocationRequestL"), KTraceFileName, __LINE__); + TInt err = KErrNone; + + TRAP(err, iNetworkPrivacy->VerifyLocationRequestL(*suplReqInfo, + iGSMRequestId, *this, aTimeOutStrategy);) + + TBuf<64> msg; + msg.AppendNum(err); + iTrace->Trace(_L("Trap value: "), KTraceFileName, __LINE__); + iTrace->Trace(msg, KTraceFileName, __LINE__); + iTrace->Trace(_L("iNetworkPrivacy->VerifyLocationRequestL called "), KTraceFileName, __LINE__); + + msg.Copy(_L("1.0 Privacy Fw Generated Verification Request id:")); msg.AppendNum(iGSMRequestId); iTrace->Trace(msg, KTraceFileName, __LINE__); diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -443,7 +443,7 @@ } // Get the information from POS if(iPosRequestor) - User::LeaveIfError(iPosRequestor->GetSuplInfoL()); + User::LeaveIfError(iPosRequestor->GetSuplInfoL()); } // ----------------------------------------------------------------------------- diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplprotocolmanager1.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplprotocolmanager1.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplprotocolmanager1.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -46,6 +46,9 @@ #include "epos_comasupltimeouttimer.h" #include "epos_omasuplconstants.h" #include "epos_comasuplcommonconfig.h" +#include "epos_suplgeocellinfo.h" + +#include "epos_comasupllocationid.h" _LIT(KTraceFileName,"SUPL_OMA_PH::EPos_COMASUPLProtocolManager1.cpp"); @@ -106,13 +109,21 @@ { iSettingsLauncher->CancelLaunch(); }*/ - iSuplSettings->SetUIActive( EFalse ); + + if(iSuplSettings) + { + iSuplSettings->SetUIActive( EFalse ); + } DeleteAllSessions(); iSuplSessions.Reset(); iSuplSessions.Close(); - iTelServer.UnloadPhoneModule(iTsyName); + //Only attempt to unload the phone if the TSY has actually been initialised + if(iTsyName.Length() > 0) + { + iTelServer.UnloadPhoneModule(iTsyName); + } iQueuedPacket.Close(); @@ -2065,9 +2076,102 @@ iSuplInitTimeOut = aCommmonConfig->iSuplInitTimeOut; iPersistFailTimer = aCommmonConfig->iPersistFailTimer; } -void COMASUPLProtocolManager1::HandleSuplTriggerStatusChangeL( - CSuplSettings::TSuplTriggerStatus /*aSuplTriggerStatus*/ ) +void COMASUPLProtocolManager1::HandleSuplTriggerStatusChangeL(CSuplSettings::TSuplTriggerStatus /*aSuplTriggerStatus*/ ) +{ + +} + +// ----------------------------------------------------------------------------- +// COMASUPLProtocolManager1::MakeLocationConversionRequestL +// +// To make conversion request to retrieve position for a given cell id +// ----------------------------------------------------------------------------- +// +void COMASUPLProtocolManager1::MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus ) { - + iTrace->Trace(_L("COMASUPLProtocolManager1::MakeLocationConversionRequestL"), KTraceFileName, __LINE__); + TBuf<64> tempBuf; + + if ( iSuplSessions.Find(aSuplSessn) == KErrNotFound ) + { + TRequestStatus *status = &aStatus; + User::RequestComplete(status,KErrNotFound ); + return; + } + + CheckForSessionCount(); + iRunningSessionCount++; + + COMASuplLocationId* locationId = COMASuplLocationId::NewL(); + CleanupStack::PushL(locationId); + COMASuplLocationId::TOMASuplStatus status = COMASuplLocationId::EStale; + switch(aCellInfo.iGeoCellType) + { + case EGeoGsmCell: + { + iTrace->Trace(_L("COMASUPLProtocolManager1::MakeLocationConversionRequestL - Setting GSM Cell Info"), KTraceFileName, __LINE__); + COMASuplGSMCellInfo* cellInfo = COMASuplGSMCellInfo::NewL(); + cellInfo->SetSuplGSMCellInfo(aCellInfo.iMNC,aCellInfo.iMCC,aCellInfo.iCid,aCellInfo.iLac); + locationId->SetSuplLocationId(cellInfo,status); + } + break; + case EGeoWcdmaCell: + { + iTrace->Trace(_L("COMASUPLProtocolManager1::MakeLocationConversionRequestL - Setting WCDMA Cell Info"), KTraceFileName, __LINE__); + COMASuplCellInfo* cellInfo = COMASuplCellInfo::NewL(); + cellInfo->SetSuplCellInfo(aCellInfo.iMNC,aCellInfo.iMCC,aCellInfo.iCid); + locationId->SetSuplLocationId(cellInfo,status); + } + break; + } + CleanupStack::Pop(locationId); + tempBuf.Copy(_L("MCC = ")); + tempBuf.AppendNum(aCellInfo.iMCC); + iTrace->Trace(tempBuf, KTraceFileName, __LINE__); + tempBuf.Copy(_L("MNC = ")); + tempBuf.AppendNum(aCellInfo.iMNC); + iTrace->Trace(tempBuf, KTraceFileName, __LINE__); + tempBuf.Copy(_L("LAC = ")); + tempBuf.AppendNum(aCellInfo.iLac); + iTrace->Trace(tempBuf, KTraceFileName, __LINE__); + tempBuf.Copy(_L("CId = ")); + tempBuf.AppendNum(aCellInfo.iCid); + iTrace->Trace(tempBuf, KTraceFileName, __LINE__); + tempBuf.Copy(_L("Prompt = ")); + tempBuf.AppendNum(aCellInfo.iConnectionPrompt); + iTrace->Trace(tempBuf, KTraceFileName, __LINE__); + + TInt allowedCapabilities = KECID|KCID; + TInt requestID = 1000; + COMASuplSession* OMASession = static_cast(aSuplSessn); + OMASession->SetConfigurationParameters(iUT1_StartTimer,iUT2_PosInitTimer, iUT3_PosTimer,iPrivacyTimer,iSETMode, + iSuplUsage, iPersistFailTimer,iSuplInitTimeOut); + OMASession->RunSuplSessionL(aStatus,ETrue, KNullDesC,EFalse, allowedCapabilities,iRunningSessionCount,requestID,ETrue,locationId,aCellInfo.iConnectionPrompt,aCellInfo.iWlanOnly); + + } + +// ----------------------------------------------------------------------------- +// COMASUPLProtocolManager1::CancelLocationConversionRequest +// +// Cancel an ongoing conversion request +// ----------------------------------------------------------------------------- +// +void COMASUPLProtocolManager1::CancelLocationConversionRequest(CSuplSessionBase* aSuplSession) + { + // Log + iTrace->Trace(_L("COMASUPLProtocolManager1::CancelLocationConversionRequest"), KTraceFileName, __LINE__); + + // Check if the Session is valid + TInt index = iSuplSessions.Find(aSuplSession); + + if(KErrNotFound == index) + { + iTrace->Trace(_L("Cannot find Supl session."), KTraceFileName, __LINE__); + return; + } + aSuplSession->CancelRunSession(); + return ; } // end of file diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -128,7 +128,7 @@ iEtelRoamingCheck(EFalse), iIapDialogShown(EFalse), iIapDlgTimerExpired(EFalse), - iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase) + iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase),iWlanOnly(EFalse) { } @@ -435,7 +435,7 @@ // void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, TBool aFallBack, TInt aAllowedCapabilities, - TInt aSessionIdSeed,TInt aRequestID) + TInt aSessionIdSeed,TInt aRequestID,TBool aIsStaleCellId,COMASuplLocationId* aLocationId,TBool aPrompt,TBool aWlanOnly) { iSessionStartTime1.HomeTime(); @@ -448,7 +448,32 @@ iRequestID = aRequestID; iTrace->Trace(_L("Start COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - + + if(aIsStaleCellId) + { + iTrace->Trace(_L("Start COMASuplSession::RunSuplSession for Stale Cell Id"), KTraceFileName, __LINE__); + iIsStaleLocIdPresent = ETrue; + + + if(iStaleLocationId) + { + delete iStaleLocationId; + iStaleLocationId = NULL; + } + + iStaleLocationId = aLocationId; + iStaleLocIdPrompt = aPrompt; + iWlanOnly = aWlanOnly; //OCC + + iTrace->Trace(_L("Deleting pos requestor as session is for Stale Cell Id"), KTraceFileName, __LINE__); + delete iOMASuplPOSRequestor; + iOMASuplPOSRequestor = NULL; + + // Delete the POS Session + delete iPOSSession; + iPOSSession = NULL; + + } // Log Session Id TBuf<64> id; id.Append(_L("Session Id is ")); @@ -461,23 +486,27 @@ iTrace->Trace(id,KTraceFileName, __LINE__); iSETSessionUniqueId = aSessionIdSeed; - + + iIhaveLaunchedUsagedialog = EFalse; TInt networkMode = 1; networkMode = GetNetworkModeL(); - if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed ) - { - id.Copy(_L("The device is in OFFLINE mode.")); - iTrace->Trace(id,KTraceFileName, __LINE__); - iSessionObserver.TerminateSession(this, KErrGeneral); - return; - } - else - { - id.Copy(_L("The device is in ON LINE mode.")); - iTrace->Trace(id,KTraceFileName, __LINE__); - } + if(!iWlanOnly) //OCC + { + if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed ) + { + id.Copy(_L("The device is in OFFLINE mode.")); + iTrace->Trace(id,KTraceFileName, __LINE__); + iSessionObserver.TerminateSession(this, KErrGeneral); + return; + } + else + { + id.Copy(_L("The device is in ON LINE mode.")); + iTrace->Trace(id,KTraceFileName, __LINE__); + } + } //OCC if(aAllowedCapabilities == 0) { @@ -492,11 +521,35 @@ iSuplSessionId->SetSLPSessionID(NULL); iConnRequestor->SetDefaultParametersL(aHslpAddress,aFallBack); - - if (aFirstReq) - CheckForSuplUsageL(); - else - CheckForPreviousResultL(); + + id.Copy(_L("aFallBack value is ")); + id.AppendNum(aFallBack); + iTrace->Trace(id,KTraceFileName, __LINE__); + + if(!iWlanOnly) //OCC + { + iTrace->Trace(_L("iWLANOnly false COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); + + id.Copy(_L("aFirstReq value is ")); + id.AppendNum(aFirstReq); + iTrace->Trace(id,KTraceFileName, __LINE__); + + if (aFirstReq) + { + iTrace->Trace(_L("start CheckForSuplUsageL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); + CheckForSuplUsageL(); + } + else + { + iTrace->Trace(_L("start CheckForPreviousResultL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); + CheckForPreviousResultL(); + } + } + else + { + iTrace->Trace(_L("iWLANOnly true COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); + InitializeL(iRequestID); + } //OCC // Clear Position.... @@ -669,7 +722,13 @@ COMASuplStartState* startSuplState = static_cast (iSuplState); startSuplState->SetQop(iClientQop); } - //SMP Changes + if(iIsStaleLocIdPresent) + { + iTrace->Trace(_L("GenerateSuplStartL setting stale location id in supl start"), KTraceFileName, __LINE__); + COMASuplStartState* startSuplState = static_cast (iSuplState); + startSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL()); + } + iSuplSessionState = ESUPL_GENERATE; iSuplMsgType = ESUPL_START; SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating); TInt err = iSuplState->GenerateMessageL(); @@ -716,6 +775,12 @@ iTrace->Trace(msg, KTraceFileName, __LINE__); iSuplState = COMASuplPosInitState::NewL(iSETCapabilities, iMobilePhone, iUT2_PosInitTimer, iOMASuplPOSRequestor,iAllowedCapabilities,iRequestType, iPosMethod,iOMASuplAsnHandlerBaseImpl); + if(iIsStaleLocIdPresent) + { + iTrace->Trace(_L("COMASuplSession::GenerateSuplPosInitL() Setting Stale Location Id "), KTraceFileName, __LINE__); + COMASuplPosInitState* posInitSuplState = static_cast (iSuplState); + posInitSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL()); + } } iSuplState->SetMsgStateObserver(this); @@ -861,6 +926,7 @@ // void COMASuplSession::OperationCompleteL(TInt aErrorCode) { + iTrace->Trace(_L("COMASuplSession::OperationCompleteL"), KTraceFileName, __LINE__); TBuf<256> msg; if(KErrNone != aErrorCode) { @@ -873,6 +939,10 @@ HandleSuplErrorL(aErrorCode); return; } + + msg.Copy(_L("iSuplSessionState : ")); + msg.AppendNum(iSuplSessionState); + iTrace->Trace(msg, KTraceFileName, __LINE__); TInt err = KErrNone; @@ -934,7 +1004,15 @@ } else //terminal initiated case { - TRAP( err, iConnRequestor->CreateConnectionL() ); + iTrace->Trace(_L("Connection block."), KTraceFileName, __LINE__); + if(iIsStaleLocIdPresent) + { + TRAP( err, iConnRequestor->CreateConnectionL(iStaleLocIdPrompt,iWlanOnly) ); + } + else + { + TRAP( err, iConnRequestor->CreateConnectionL() ); + } } if(KErrNone != err) { @@ -1762,7 +1840,7 @@ TInt err = PosEstimate.GetConfidence(confidence); altitude = 0; if (altErr == KErrNone) - AltitudeInfo.GetAltitudeInfo(AltitudeDirection,altitude,AltitudeUncertainty); + AltitudeInfo.GetAltitudeInfo(AltitudeDirection,altitude,AltitudeUncertainty); PosEstimate.GetUncertainty(Uncertainty); Uncertainty.GetUncertainty(UncertaintySemiMajor,UncertaintySemiMinor, OrientationMajorAxis); @@ -4170,7 +4248,16 @@ HandleSuplInitErrorL(iNwInitCompletionCode); } else - InitializeL(iRequestID); + { + if (iRoaming) + HandleRoamingCheckCompleteL(KErrNone, EFalse); + else + { + iEtelRoamingCheck = ETrue; + iProtocolManager.CheckForRoaming(); + } + //InitializeL(iRequestID); + } /*} else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk) @@ -4268,85 +4355,10 @@ { iUsageHomeNW = aHomeNw; iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW); - //CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage(); - - /*if (usage == CSuplSettings::ESuplUsageAlwaysAsk) - { - TInt err = KErrNone; - if (!aHomeNw) - { - //iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); - //err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); - } - else - { - //iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__); - //err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse); - } - - if(KErrNone != err && KErrInUse == err) - { - iTrace->Trace(_L("Dialog in use, setting flag"), KTraceFileName, __LINE__); - SetSuplUsageFlag(); - } - if( KErrNone == err && iRequestType == ESUPL_NETWORK ) - { - iTrace->Trace(_L("Network Session , starting timer"), KTraceFileName, __LINE__); - COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); - TOMASuplQop qop; - TInt retVal = suplInit->Qop(qop); - TInt delay; - qop.Delay(delay); - //if delay is > 7, it is not valid - if (delay > 7) - delay = 0; - if(retVal == KErrNone && delay > 0) - { - TReal delayReal; - Math::Pow(delayReal, 2, (TReal)delay); - delay = (TInt) delayReal; - TBuf<128> msg(_L("Delay present in message, value is = ")); - msg.AppendNum(delay); - iTrace->Trace(msg, KTraceFileName, __LINE__); - isTimeoutDialogTimerStarted = ETrue; - iDialogTimer->StartTimer(delay); - } - else - { - if (iSuplInitTimeOut > 0) - { - TBuf<256> msg(_L("Delay value in CR is")); - msg.AppendNum(iSuplInitTimeOut); - iTrace->Trace(msg, KTraceFileName, __LINE__); - iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); - isTimeoutDialogTimerStarted = ETrue; - } - else - iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); - } - iDlgStartTime.HomeTime(); - } - else if (KErrNone != err) - { - iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); - HandleSuplErrorL(err); - } - - }*/ - //else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) - //{ - //if (!aHomeNw) - // { - //TInt err = KErrNone; - //if (!iSuplSettings->IsUIActive() ) - { - //iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); - //err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); if(iSuplMsgType == ESUPL_INIT) { iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__); - COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); TOMASuplQop qop; TInt retVal = suplInit->Qop(qop); @@ -4377,19 +4389,6 @@ iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); } } - } - - /* if(!iSuplSettings->IsUIActive() && KErrNone != err) - { - SetSuplUsageFlag(); - } - else - { - iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); - HandleSuplErrorL(err); - }*/ - - if (iNwInitError) { @@ -4397,13 +4396,15 @@ HandleSuplInitErrorL(iNwInitCompletionCode); } else - InitializeL(iRequestID); - + { + iTrace->Trace(_L("COMASuplSession::InitializeL called after roaming check"), KTraceFileName, __LINE__); + InitializeL(iRequestID); + } } - else - { - iSessionObserver.TerminateSession(this, KErrGeneral); - } + else + { + iSessionObserver.TerminateSession(this, KErrGeneral); + } } TInt COMASuplSession::SuplIpcSessionID() { diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplstartstate.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplstartstate.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplstartstate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -149,9 +149,24 @@ // TInt COMASuplStartState::GenerateMessageL() { - iTrace->Trace(_L("Start of COMASuplStartState::GenerateMessage"), KTraceFileName, __LINE__); - iLocationIDRequestor->GetLocationID(); - return KErrNone; + + iTrace->Trace(_L("Start of COMASuplStartState::GenerateMessage"), KTraceFileName, __LINE__); + //if no cell stale cell id is available, retrieve current cell id + if(!iIsStaleCellId) + { + iTrace->Trace(_L("COMASuplStartState::GenerateMessage stale cell id false"), KTraceFileName, __LINE__); + iLocationIDRequestor->GetLocationID(); + iTrace->Trace(_L("COMASuplStartState::GenerateMessage called get location id"), KTraceFileName, __LINE__); + } + else // dont retrieve current cell id as cell id was already provided + { + iGenerationStatus = EFalse; + iECId = EFalse; + iTrace->Trace(_L("COMASuplStartState::GenerateMessage stale cell id true"), KTraceFileName, __LINE__); + GetAssistceDataFromPluginL(KErrNone); + } + + return KErrNone; } // ----------------------------------------------------------------------------- @@ -996,4 +1011,15 @@ aCurrentCellId.iMCC = lRefMCC; aCurrentCellId.iLac = lRefLAC; } -} // End of File +} +void COMASuplStartState::SetStaleCellIdToUse(COMASuplLocationId* aLocationId) + { + if(iLocationId) + { + delete iLocationId; + iLocationId = NULL; + } + iLocationId = aLocationId; + iIsStaleCellId = ETrue; + } +// End of File diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/group/bld.inf --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -18,7 +18,7 @@ PRJ_PLATFORMS -DEFAULT +DEFAULT GCCE PRJ_EXPORTS diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/group/omasuplprotocolhandler2.mmp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/group/omasuplprotocolhandler2.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/group/omasuplprotocolhandler2.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -95,7 +95,7 @@ LIBRARY efsrv.lib LIBRARY aknnotify.lib LIBRARY commonengine.lib -LIBRARY agentdialog.lib +//LIBRARY agentdialog.lib LIBRARY epossuplprotocolhandlerplugin.lib LIBRARY epos_comasuplasnplugin.lib diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplconnrequestor.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplconnrequestor.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplconnrequestor.h Thu Jul 22 16:37:56 2010 +0100 @@ -289,6 +289,8 @@ TBool iIsSettingInitilized; TInt64 iCurrentSLPId; + + TBool iTriggerSession; }; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplfallbackhandler.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplfallbackhandler.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplfallbackhandler.h Thu Jul 22 16:37:56 2010 +0100 @@ -153,7 +153,6 @@ TTime iFallBackStartTime; TInt iAllowedFallBackTimerValue; - TBool iAttemptedBackupServer; }; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettings.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettings.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettings.h Thu Jul 22 16:37:56 2010 +0100 @@ -40,7 +40,7 @@ * @param None. * @return Instance of COMASuplSettings */ - static COMASuplSettings* COMASuplSettings::NewL(); + static COMASuplSettings* NewL(); /** * ~COMASuplSettings Method, Destructor diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettingslauncher.h --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettingslauncher.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplsettingslauncher.h Thu Jul 22 16:37:56 2010 +0100 @@ -22,7 +22,7 @@ // INCLUDES #include -#include // for RGenConAgentDialogServer +//#include // for RGenConAgentDialogServer const TUid KNotifier1Uid = { 0x10009C00 }; const TUid KNotifier2Uid = { 0x10009C01 }; @@ -155,7 +155,7 @@ /** * IAP Selector Handle */ - RGenConAgentDialogServer iIapSelector; + // RGenConAgentDialogServer iIapSelector; /** * Selected IAP ID diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplconnrequestor.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplconnrequestor.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplconnrequestor.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -47,7 +47,8 @@ iCommMgr(aCommMgr), iProtocolManager(aProtoMgr), iPort(aPort), - iObserver( aObserver) + iObserver( aObserver), + iTriggerSession(EFalse) { } @@ -116,6 +117,14 @@ // void COMASuplConnRequestor::CreateConnectionL(TBool aTriggerSession) { + if(!iIsSettingInitilized) + { + iTriggerSession = aTriggerSession; + iState = EInitialState; + InitilizeSetting(); + } + else + { TBuf<100> iapName; TBuf<128> buffer; iState = EConnecting; @@ -159,6 +168,7 @@ iObserver.OperationCompleteL(errorCode); } } + } // ----------------------------------------------------------------------------- // COMASuplConnRequestor::OpenConnection @@ -215,6 +225,7 @@ } else { + iState = EInitilizeSetting; InitilizeSetting(); } } @@ -261,6 +272,14 @@ switch(iState) { + case EInitialState: + { + iIsSettingInitilized = ETrue; + iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__); + CreateConnectionL(iTriggerSession); + + break; + } case EConnecting: { if(iLastConnectionError < 0) @@ -362,7 +381,7 @@ void COMASuplConnRequestor::InitilizeSetting() { iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); - iState = EInitilizeSetting; + iSuplSettings->Initialize(iStatus); SetActive(); } diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplfallbackhandler.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplfallbackhandler.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplfallbackhandler.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -115,11 +115,11 @@ { iTrace->Trace(_L("COMASuplFallBackHandler::GetNextSLPAddressL"),KTraceFileName, __LINE__); - _LIT(KFormatTxt,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); - - TBuf<256> LogBuffer; - - if( aLastErrorCode != KErrNone)// If its KErrNone then its means server name is asked first time and no need for Tls failure check + _LIT(KFormatTxt,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); + + TBuf<256> LogBuffer; + + if( aLastErrorCode != KErrNone)// If its KErrNone then its means server name is asked first time and no need for Tls failure check { if( CheckErrorCodeL(aLastErrorCode) ) @@ -135,6 +135,47 @@ aTls = ETrue; aPskTls = EFalse; aIsIapDialogShown = ETrue; + + CServerParams* param = CServerParams::NewL(); + CleanupStack::PushL(param); + + //Find out if this alternative generated SUPL server is in the SUPL Settings list + TInt err = iSuplSettings.GetSlpInfoAddress(iGenratedHslpAddress, param); + if(err == KErrNotFound) + { + //Server does not exist + iTrace->Trace(_L("Server does not exist in list so adding it in."),KTraceFileName, __LINE__); + CServerParams* newParam=CServerParams::NewL(); + CleanupStack::PushL(newParam); + User::LeaveIfError(newParam->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse )); + + err = iSuplSettings.AddNewServer( newParam, aSLPId ); //Ignore error + LogBuffer.Copy(_L("AddNewServer() completed with err: ")); + LogBuffer.AppendNum(err); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + CleanupStack::PopAndDestroy(&newParam); + } + else + { + //Server exists, get the SLP ID and the IAP Access point for this server + HBufC* hslpAddress = HBufC::NewL(KHSLPAddressLength); + HBufC* iapName = HBufC::NewL(KMaxIapNameLength); + TBool serverEnabled; + TBool simChangeRemove; + TBool usageInHomeNw; + TBool editable; + + iTrace->Trace(_L("Server already exists, getting the SLP ID and Access Point."),KTraceFileName, __LINE__); + + param->Get(aSLPId,hslpAddress->Des(),iapName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable); + aIAPName.Copy(iapName->Des()); + + delete hslpAddress; + delete iapName; + } + + CleanupStack::PopAndDestroy(¶m); iTrace->Trace(_L("Fallback allowed & TLSAuth failed"),KTraceFileName, __LINE__); iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); @@ -162,138 +203,151 @@ { return KErrNotFound; } - } - - //Check to see if the server list is empty. If it is create the HSLP Address from the IMSI and use that - // as the server address. This does not add the server to the list and this functionality should only - // be tried once - if(iSLPList->Count() <= 0 && (!iAttemptedBackupServer)) - { - iTrace->Trace(_L("Going to create and use alternative HSLP Address from IMSI"),KTraceFileName, __LINE__); + } + + //Check to see if the server list is empty. If it is create the HSLP Address from the IMSI and use that + // as the server address. This does not add the server to the list and this functionality should only + // be tried once + if(iSLPList->Count() <= 0 && (!iAttemptedBackupServer)) + { + iTrace->Trace(_L("Going to create and use alternative HSLP Address from IMSI"),KTraceFileName, __LINE__); + + iAttemptedBackupServer = ETrue; + + //Generate the HSLP Address + GenerateHslpAddressFromIMSIL(); - iAttemptedBackupServer = ETrue; + //Copy the generated address into the supplied function arguments + aHslpToBeUsedAddress.Copy(iGenratedHslpAddress); + aIAPName.Zero(); + aIAPName.Copy(iDefaultIAPName); + aTls = ETrue; + aPskTls = EFalse; + aIsIapDialogShown = ETrue; + + iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); + LogBuffer.Copy(aHslpToBeUsedAddress); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - //Generate the HSLP Address - GenerateHslpAddressFromIMSIL(); + iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); + LogBuffer.Copy(aIAPName); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + //Add the server to the list for future connections + CServerParams* param=CServerParams::NewL(); + CleanupStack::PushL(param); + User::LeaveIfError(param->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse )); + + TInt err = iSuplSettings.AddNewServer( param, aSLPId ); //Ignore error + LogBuffer.Copy(_L("AddNewServer() completed with err: ")); + LogBuffer.AppendNum(err); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + CleanupStack::PopAndDestroy(¶m); - //Copy the generated address into the supplied function arguments - aHslpToBeUsedAddress.Copy(iGenratedHslpAddress); - aIAPName.Zero(); - aIAPName.Copy(iDefaultIAPName); - aTls = ETrue; - aPskTls = EFalse; - aIsIapDialogShown = ETrue; - - iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); - LogBuffer.Copy(aHslpToBeUsedAddress); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); - LogBuffer.Copy(aIAPName); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - return KErrNone; - } - - if( iSLPList->Count() <= 0 || iCurrentServerCounter >= iSLPList->Count() ) + return KErrNone; + } + + if( iSLPList->Count() <= 0 || iCurrentServerCounter >= iSLPList->Count() ) + { + LogBuffer.Copy(_L("No more servers available...")); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + return KErrNotFound; + } + + iTrace->Trace(_L("Trying next server..."),KTraceFileName, __LINE__); + + //Fallback Timer... + if(aLastErrorCode == KErrNone) //This means, server name is asked for first time only... + { + iTrace->Trace(_L("Start Time: "),KTraceFileName, __LINE__); + iFallBackStartTime.HomeTime(); + LogBuffer.Zero(); + iFallBackStartTime.FormatL(LogBuffer,KFormatTxt); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + } + else + { + TTime currentTime; + currentTime.HomeTime(); + TTimeIntervalMicroSeconds diff = currentTime.MicroSecondsFrom(iFallBackStartTime); + + + iTrace->Trace(_L("Current Time: "),KTraceFileName, __LINE__); + LogBuffer.Zero(); + currentTime.FormatL(LogBuffer,KFormatTxt); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + LogBuffer.Copy(_L("Difference between time: ")); + LogBuffer.AppendNum(diff.Int64()); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + if( diff.Int64() > iAllowedFallBackTimerValue) { - LogBuffer.Copy(_L("No more servers available...")); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - return KErrNotFound; + LogBuffer.Copy(_L("Timeout happened...")); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + return KErrTimedOut; } - - iTrace->Trace(_L("Trying next server..."),KTraceFileName, __LINE__); - - //Fallback Timer... - if(aLastErrorCode == KErrNone) //This means, server name is asked for first time only... - { - iTrace->Trace(_L("Start Time: "),KTraceFileName, __LINE__); - iFallBackStartTime.HomeTime(); - LogBuffer.Zero(); - iFallBackStartTime.FormatL(LogBuffer,KFormatTxt); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - } - else + } + + if(aLastErrorCode == KErrNone) //This will be called only once...for first time only + { + aSLPId = (*iSLPList)[0].iSLPId; + aHslpToBeUsedAddress.Copy((*iSLPList)[0].iHSLPAddress); + aIAPName.Copy((*iSLPList)[0].iIapName); + aTls = (*iSLPList)[0].iTls; + aPskTls = (*iSLPList)[0].iPskTls; + aIsIapDialogShown = (*iSLPList)[0].iIsIAPDialgShown; + iCurrentServerCounter++; + + iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); + LogBuffer.Copy(aHslpToBeUsedAddress); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); + LogBuffer.Copy(aIAPName); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__); + LogBuffer.Delete(0,256); + LogBuffer.AppendNum(aIsIapDialogShown); + iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); + + return KErrNone; + } + else + { + if(iIsFallBackAllowed && CheckErrorCodeL(aLastErrorCode))// Do not fallback in case if IMSI generated address failed for previous try. { - TTime currentTime; - currentTime.HomeTime(); - TTimeIntervalMicroSeconds diff = currentTime.MicroSecondsFrom(iFallBackStartTime); - - - iTrace->Trace(_L("Current Time: "),KTraceFileName, __LINE__); - LogBuffer.Zero(); - currentTime.FormatL(LogBuffer,KFormatTxt); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - LogBuffer.Copy(_L("Difference between time: ")); - LogBuffer.AppendNum(diff.Int64()); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - if( diff.Int64() > iAllowedFallBackTimerValue) - { - LogBuffer.Copy(_L("Timeout happened...")); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - return KErrTimedOut; - } - } - - if(aLastErrorCode == KErrNone) //This will be called only once...for first time only - { - aSLPId = (*iSLPList)[0].iSLPId; - aHslpToBeUsedAddress.Copy((*iSLPList)[0].iHSLPAddress); - aIAPName.Copy((*iSLPList)[0].iIapName); - aTls = (*iSLPList)[0].iTls; - aPskTls = (*iSLPList)[0].iPskTls; - aIsIapDialogShown = (*iSLPList)[0].iIsIAPDialgShown; - iCurrentServerCounter++; - + aSLPId = (*iSLPList)[iCurrentServerCounter].iSLPId; + aHslpToBeUsedAddress.Copy((*iSLPList)[iCurrentServerCounter].iHSLPAddress); + aIAPName.Copy((*iSLPList)[iCurrentServerCounter].iIapName); + aTls = (*iSLPList)[iCurrentServerCounter].iTls; + aPskTls = (*iSLPList)[iCurrentServerCounter].iPskTls; + aIsIapDialogShown = (*iSLPList)[iCurrentServerCounter].iIsIAPDialgShown; + iCurrentServerCounter++; + iTrace->Trace(_L("Fallback allowed & TLSAuth passed"),KTraceFileName, __LINE__); iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); LogBuffer.Copy(aHslpToBeUsedAddress); iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - + iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); LogBuffer.Copy(aIAPName); iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - + iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__); LogBuffer.Delete(0,256); LogBuffer.AppendNum(aIsIapDialogShown); iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - return KErrNone; } else { - if(iIsFallBackAllowed && CheckErrorCodeL(aLastErrorCode))// Do not fallback in case if IMSI generated address failed for previous try. - { - aSLPId = (*iSLPList)[iCurrentServerCounter].iSLPId; - aHslpToBeUsedAddress.Copy((*iSLPList)[iCurrentServerCounter].iHSLPAddress); - aIAPName.Copy((*iSLPList)[iCurrentServerCounter].iIapName); - aTls = (*iSLPList)[iCurrentServerCounter].iTls; - aPskTls = (*iSLPList)[iCurrentServerCounter].iPskTls; - aIsIapDialogShown = (*iSLPList)[iCurrentServerCounter].iIsIAPDialgShown; - iCurrentServerCounter++; - iTrace->Trace(_L("Fallback allowed & TLSAuth passed"),KTraceFileName, __LINE__); - iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__); - LogBuffer.Copy(aHslpToBeUsedAddress); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__); - LogBuffer.Copy(aIAPName); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - - iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__); - LogBuffer.Delete(0,256); - LogBuffer.AppendNum(aIsIapDialogShown); - iTrace->Trace(LogBuffer,KTraceFileName, __LINE__); - return KErrNone; - } - else - { - return KErrNotFound; - } + return KErrNotFound; } + } + } // ----------------------------------------------------------------------------- diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplposinitstate.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplposinitstate.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplposinitstate.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -670,7 +670,7 @@ } // Position - if(iPosition) + if(iPosition && iRequestType == COMASuplSession::ESUPL_TERMINAL) { if(KErrNone == iPosition->Status() && !iIgnorePosData) //if iIgnorePosData is set do not use the pos data { @@ -800,6 +800,8 @@ } //if the current Cell id is the same as the Cell id when we made the request for assistance data then use the assistance data //and we have not already repeated a request before + //Comment to ignore coverity forward NULL error + //coverity[FORWARD_NULL :FALSE] if(!iRepeatedPosDataFetch && iLocationId->GetCellId() == aLocationId->GetCellId()) { iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id not changed since making last request, so continuing"), KTraceFileName, __LINE__); diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplprotocolmanager2.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplprotocolmanager2.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplprotocolmanager2.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -108,13 +108,21 @@ { iSettingsLauncher->CancelLaunch(); }*/ - iSuplSettings->SetUIActive( EFalse ); + + if(iSuplSettings) + { + iSuplSettings->SetUIActive( EFalse ); + } DeleteAllSessions(); iSuplSessions.Reset(); iSuplSessions.Close(); + //Only attempt to unload the phone if the TSY has actually been initialised + if(iTsyName.Length() > 0) + { iTelServer.UnloadPhoneModule(iTsyName); + } iQueuedPacket.Close(); diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplsession2.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplsession2.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplsession2.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -4767,10 +4767,16 @@ HandleSuplInitErrorL(iNwInitCompletionCode); } else - { - iTrace->Trace(_L("CheckForSuplUsageL, Initializing"), KTraceFileName, __LINE__); - InitializeL(iRequestID); - } + { + if (iRoaming) + HandleRoamingCheckCompleteL(KErrNone, EFalse); + else + { + iEtelRoamingCheck = ETrue; + iProtocolManager.CheckForRoaming(); + } + //InitializeL(iRequestID); + } /*} else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk) diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/provisioninghandler/group/epos_omasuplprovhandler.mmp --- a/supl/locationomasuplprotocolhandler/provisioninghandler/group/epos_omasuplprovhandler.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/provisioninghandler/group/epos_omasuplprovhandler.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -60,8 +60,9 @@ LIBRARY euser.lib LIBRARY provisioningengine.lib LIBRARY bafl.lib -LIBRARY apengine.lib + LIBRARY commdb.lib LIBRARY centralrepository.lib LIBRARY epos_csuplutils.lib LIBRARY epos_suplsettings.lib +LIBRARY cmmanager.lib \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp --- a/supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -20,7 +20,7 @@ #include #include -#include +//#include #include "epos_comasupltrace.h" #include "epos_comasuplsettings.h" @@ -30,6 +30,11 @@ #include "epos_omasuplprovhandler.hrh" #include +#include +#include +#include +#include + _LIT( KTraceSuplSettings, "epos_comasuplsettings.cpp" ); @@ -146,12 +151,59 @@ // TUint32 COMASuplSettings::IapIdFromWapIdL( TUint32 aWapId ) const { - CApUtils* apUtils = CApUtils::NewLC( *iCommsDb ); + /*CApUtils* apUtils = CApUtils::NewLC( *iCommsDb ); TUint32 iapId = NULL; iapId = apUtils->IapIdFromWapIdL( aWapId ); __ASSERT_ALWAYS( iapId, Panic( SuplAdapterInvalidId ) ); CleanupStack::PopAndDestroy( apUtils ); return iapId; + return ;*/ + + RCmManagerExt cmManager; + cmManager.OpenLC(); // CS:1 + RArray iapIds; + TUint32 iapId( 0 ); + + // First get all free IAP ID's. + cmManager.ConnectionMethodL( iapIds ); + CleanupClosePushL( iapIds ); // CS:2 + + // Then get IAP ID's from all destinations. + RArray destIds; + cmManager.AllDestinationsL( destIds ); + CleanupClosePushL( destIds ); // CS:3 + TInt destCount = destIds.Count(); + for ( TInt destIndex = 0; destIndex < destCount; destIndex++ ) + { + RCmDestinationExt dest = cmManager.DestinationL( + destIds[destIndex] ); + CleanupClosePushL( dest ); // CS:4 + TInt cmCount = dest.ConnectionMethodCount(); + for ( TInt cmIndex = 0; cmIndex < cmCount; cmIndex++ ) + { + TUint32 apId = dest.ConnectionMethodL( + cmIndex ).GetIntAttributeL( CMManager::ECmIapId ); + iapIds.AppendL( apId ); + } + CleanupStack::PopAndDestroy( &dest ); // CS:3 + } + // Finally, go through all connection methods and find correct IAP ID. + const TInt cmCount = iapIds.Count(); + for ( TInt counter = 0; counter < cmCount; counter++ ) + { + TUint32 id = cmManager.GetConnectionMethodInfoIntL( + iapIds[counter], CMManager::ECmWapId ); + if ( id == aWapId ) + { + iapId = iapIds[counter]; + // No need to go through rest of IAPs. + break; + } + } + // PopAndDestroy destIds, iapIds, cmManager. + CleanupStack::PopAndDestroy( 3, &cmManager ); // CS:0 + return iapId; + } diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler.iby --- a/supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler.iby Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler.iby Thu Jul 22 16:37:56 2010 +0100 @@ -65,8 +65,8 @@ #endif // __SYNCML_DM // Notifier -ECOM_PLUGIN(epos_omasuplnotifierplugin.dll,epos_omasuplnotifierplugin.rsc) -file=ABI_DIR\BUILD_DIR\epos_omasuplnotifier.dll SHARED_LIB_DIR\epos_omasuplnotifier.dll +//ECOM_PLUGIN(epos_omasuplnotifierplugin.dll,epos_omasuplnotifierplugin.rsc) +//file=ABI_DIR\BUILD_DIR\epos_omasuplnotifier.dll SHARED_LIB_DIR\epos_omasuplnotifier.dll // Storage Db Backup Registration File data=DATAZ_\private\1027509E\backup_registration.xml \private\1027509E\backup_registration.xml #endif //__OMA_SUPL_PLUGINS diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler_resource.iby --- a/supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler_resource.iby Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/rom/omasuplprotocolhandler_resource.iby Thu Jul 22 16:37:56 2010 +0100 @@ -29,7 +29,7 @@ #ifdef __OMA_SUPL_PLUGINS //Resource file for notifier -data=DATAZ_\resource\epos_omasuplnotifier.rsc resource\epos_omasuplnotifier.rsc +//data=DATAZ_\resource\epos_omasuplnotifier.rsc resource\epos_omasuplnotifier.rsc #endif //__OMA_SUPL_PLUGINS #endif // OMASUPLPROTOCOLHANDLER_RESOURCE_IBY diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/supllistener/group/bld.inf --- a/supl/locationomasuplprotocolhandler/supllistener/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/supllistener/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -19,12 +19,11 @@ PRJ_PLATFORMS -WINSCW ARMV5 +WINSCW ARMV5 GCCE PRJ_MMPFILES ./epos_omasupllistener.mmp // for backup restore PRJ_EXPORTS -../data/backup_registration.xml /epoc32/release/winscw/udeb/z/private/1027509E/backup_registration.xml -../data/backup_registration.xml /epoc32/data/z/private/1027509E/backup_registration.xml +../data/backup_registration.xml z:/private/1027509E/backup_registration.xml ../inc/epos_comasuplproductconfigcrkeys.h |../../../inc/epos_comasuplproductconfigcrkeys.h \ No newline at end of file diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationomasuplprotocolhandler/supllistener/inc/epos_comasuplsmslistenerbase.h --- a/supl/locationomasuplprotocolhandler/supllistener/inc/epos_comasuplsmslistenerbase.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationomasuplprotocolhandler/supllistener/inc/epos_comasuplsmslistenerbase.h Thu Jul 22 16:37:56 2010 +0100 @@ -112,7 +112,7 @@ * * @since S60 v3.1 */ - void COMASuplSmsListenerBase::SendL( const TPtr8& aMessage ); + void SendL( const TPtr8& aMessage ); // from base class CActive /** diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/conf/suplsettings.confml Binary file supl/locationsuplfw/conf/suplsettings.confml has changed diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/conf/suplsettings_102073D6.crml Binary file supl/locationsuplfw/conf/suplsettings_102073D6.crml has changed diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/group/bld.inf --- a/supl/locationsuplfw/gateway/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -23,13 +23,8 @@ WINSCW ARMV5 PRJ_EXPORTS -/**** -../Data/102073D2.txt /epoc32/RELEASE/winscw/UDEB/Z/private/10202be9/102073D2.txt -../Data/102073D2.txt /epoc32/data/Z/private/10202be9/102073D2.txt -*/ -../data/backup_registration.xml /epoc32/RELEASE/winscw/udeb/z/private/102073ca/backup_registration.xml -../data/backup_registration.xml /epoc32/data/z/private/102073ca/backup_registration.xml +../data/backup_registration.xml z:/private/102073ca/backup_registration.xml PRJ_MMPFILES epos_csuplserver.mmp diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/inc/epos_csuplipcsubsession.h --- a/supl/locationsuplfw/gateway/inc/epos_csuplipcsubsession.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/inc/epos_csuplipcsubsession.h Thu Jul 22 16:37:56 2010 +0100 @@ -126,6 +126,11 @@ void HandlePeriodicTriggerSessionWithServernameL(const RMessage2& aMessage); void HandleStopTriggerringSessionL(const RMessage2& aMessage); void HandleNotifyTriggerFiredL(const RMessage2& aMessage); + /* + * For Periodic Trigger Seesion + */ + void HandleLocationConversionL(const RMessage2& aMessage); + void HandleCancelLocationConversionL(const RMessage2& aMessage); private: // Data CSuplSessionBase* iSuplSession; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/inc/epos_csuplsessionmanager.h --- a/supl/locationsuplfw/gateway/inc/epos_csuplsessionmanager.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/inc/epos_csuplsessionmanager.h Thu Jul 22 16:37:56 2010 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include "epos_csuplecomeventwatcher.h" // FORWARD DECLARATIONS @@ -32,6 +33,7 @@ class CSuplSessionBase; class CSuplCommunicationManager; + // CLASS DECLARATION /** @@ -87,6 +89,14 @@ TInt GetSUPLMessageVersionL(TInt& aMajorVersion, const TDesC8& aReceivedMessage); + + void MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus + ); + + void CancelLocationConversionRequest(CSuplSessionBase *aSessn); + private: /** diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/inc/epos_csuplsessionrequest.h --- a/supl/locationsuplfw/gateway/inc/epos_csuplsessionrequest.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/inc/epos_csuplsessionrequest.h Thu Jul 22 16:37:56 2010 +0100 @@ -27,7 +27,7 @@ #include #include #include - +#include "epos_suplgeocellinfo.h" // CONSTANT DECLARATIONS // FORWARD DECLARATIONS @@ -99,6 +99,9 @@ void CancelTriggerringRequest(); void ProtocolHUnloaded(); + void MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn,TGeoCellInfo& aCellInfo ); + + void CancelLocationConversionRequest(); protected: // From CActive @@ -129,7 +132,9 @@ ESuplForwardMessage, ESuplStartTriggerRequest, ESuplStopTriggerRequest, - ESuplTriggerFiredNotifyRequest + ESuplTriggerFiredNotifyRequest, + ESuplLocationConversionRequest, + ESuplCancelLocationConversionRequest }; TSuplRequestStage iRequestPhase; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/src/epos_csuplipcsubsession.cpp --- a/supl/locationsuplfw/gateway/src/epos_csuplipcsubsession.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/src/epos_csuplipcsubsession.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -226,6 +226,19 @@ HandleNotifyTriggerFiredL(aMessage); break; } + case ESuplTerminalSubssnLocationConversion: + { + iMessage=aMessage; + iReqType = ESuplTerminalSubssnLocationConversion; + HandleLocationConversionL(aMessage); + break; + } + + case ESuplTerminalSubssnCancelLocationConversion: + { + HandleCancelLocationConversionL(aMessage); + break; + } default: User::Leave(KErrNotSupported); } @@ -734,5 +747,51 @@ CleanupStack::Pop(fireInfoBuf); } - +// --------------------------------------------------------- +// CSuplIPCSubSession::HandleLocationConversionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplIPCSubSession::HandleLocationConversionL(const RMessage2& aMessage) + { + DEBUG_TRACE("CSuplIPCSubSession::HandleLocationConversionL", __LINE__) + + if (iSuplSessnReq->IsActive()) + { + SuplGlobal::RequestComplete(aMessage, KErrAlreadyExists); + } + + if(iReqType==ESuplTerminalSubssnLocationConversion) + { + HBufC8* cellBuf = SuplGlobal::CopyClientBuffer8LC(aMessage,0); + + TGeoCellInfo& cellInfo = reinterpret_cast + (const_cast(*cellBuf->Ptr())); + + iSuplSessnReq->MakeLocationConversionRequestL( iSuplSession,cellInfo ); + + CleanupStack::PopAndDestroy(cellBuf); + } + + } + +// --------------------------------------------------------- +// CSuplIPCSubSession::HandleCancelLocationConversionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplIPCSubSession::HandleCancelLocationConversionL(const RMessage2& aMessage) + { + DEBUG_TRACE("CSuplIPCSubSession::HandleCancelLocationConversionL", __LINE__) + + if (!iSuplSessnReq->IsActive()||(iReqType!=ESuplTerminalSubssnLocationConversion)) + { + User::Leave(KErrNotFound); + } + iSuplSessnReq->CancelLocationConversionRequest(); + SuplGlobal::RequestComplete(aMessage, KErrNone); + CompleteRunSession(KErrCancel); + } // End of File diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/src/epos_csuplserver.cpp --- a/supl/locationsuplfw/gateway/src/epos_csuplserver.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/src/epos_csuplserver.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -264,7 +264,7 @@ } //if secure id is not equal to KSuplWapSecureId or KSuplWapSecureId, then perform capability check - if ((aMessage.SecureId() != KSuplWapSecureId && aMessage.SecureId() != KNetworkGatewaySID)) + if ((aMessage.SecureId() != KSuplWapSecureId && aMessage.SecureId() != KNetworkGatewaySID && aMessage.SecureId() != 0x102869DF)) { if (!aMessage.HasCapability(ECapabilityCommDD)) { @@ -322,8 +322,11 @@ static _LIT_SECURITY_POLICY_S0(allowSuplWapPolicy, KSuplWapSecureId); TBool isSuplWap = allowSuplWapPolicy().CheckPolicy(aMessage); - //Check if the request was made by one of the allowed processes else check for required capability - if (!isNetworkGateway && !isSuplWap ) + static _LIT_SECURITY_POLICY_S0(allowlocationserverPolicy, 0x102869DF); + TBool islocationserver = allowlocationserverPolicy().CheckPolicy(aMessage); + + //Check if the request was made by one of the allowed processes else check for required capability + if (!isNetworkGateway && !isSuplWap && !islocationserver) { if (!aMessage.HasCapability(ECapabilityCommDD)) { diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/src/epos_csuplsessionmanager.cpp --- a/supl/locationsuplfw/gateway/src/epos_csuplsessionmanager.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/src/epos_csuplsessionmanager.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -465,5 +465,49 @@ User::RequestComplete(status,KErrNotReady); } } +// --------------------------------------------------------- +// CSuplSessionManager::MakeLocationConversionRequestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplSessionManager::MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus + ) + { + DEBUG_TRACE("CSuplSessionManager::MakeLocationConversionRequestL", __LINE__) + TInt err = KErrNone; + if(iProtocolMgr && aSuplSessn) + { + DEBUG_TRACE("CSuplSessionManager::MakeLocationConversionRequestL if condition true", __LINE__) + TRAP(err,iProtocolMgr->MakeLocationConversionRequestL(aSuplSessn,aCellInfo,aStatus)); + DEBUG_TRACE("CSuplSessionManager::MakeLocationConversionRequestL err", __LINE__) + if(err!=KErrNone) + { + DEBUG_TRACE("CSuplSessionManager::MakeLocationConversionRequestL err not KErrNone", __LINE__) + TRequestStatus *status = &aStatus; + User::RequestComplete(status,KErrNotReady); + } + } + else + { + TRequestStatus *status = &aStatus; + User::RequestComplete(status,KErrNotReady); + } + } + +// --------------------------------------------------------- +// CSuplSessionManager::CancelLocationConversionRequest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplSessionManager::CancelLocationConversionRequest(CSuplSessionBase *aSessn) + { + DEBUG_TRACE("CSuplSessionManager::CancelLocationConversionRequest", __LINE__) + if(iProtocolMgr && aSessn) + iProtocolMgr->CancelLocationConversionRequest(aSessn); + } // End of File diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/gateway/src/epos_csuplsessionrequest.cpp --- a/supl/locationsuplfw/gateway/src/epos_csuplsessionrequest.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/gateway/src/epos_csuplsessionrequest.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -245,7 +245,13 @@ iNetObserver->CompleteForwardMessageL(iHandle); break; } - + case ESuplLocationConversionRequest: + case ESuplCancelLocationConversionRequest: + { + iRequestPhase = ESuplReqInactive; + iObserver->CompleteRunSession(err); + break; + } default : DebugPanic(EPosSuplServerPanicRequestInconsistency); } @@ -390,5 +396,33 @@ iSessnMgr.CancelTriggerringSession(iSuplSessn); //SetActive(); } - +// --------------------------------------------------------- +// CSuplSessionRequest::MakeLocationConversionRequestL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplSessionRequest::MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo ) + { + DEBUG_TRACE("CSuplSessionRequest::MakeLocationConversionRequestL", __LINE__) + iRequestPhase = ESuplLocationConversionRequest; + iStatus = KRequestPending; + iSessnMgr.MakeLocationConversionRequestL(aSuplSessn,aCellInfo,iStatus ); + SetActive(); + } + + +// --------------------------------------------------------- +// CSuplSessionRequest::CancelLocationConversionRequest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CSuplSessionRequest::CancelLocationConversionRequest() + { + DEBUG_TRACE("CSuplSessionRequest::CancelLocationConversionRequest", __LINE__) + iRequestPhase = ESuplCancelLocationConversionRequest; + iSessnMgr.CancelLocationConversionRequest(iSuplSessn); + } // End of File diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/bwins/epossuplprotocolhandlerpluginu.def --- a/supl/locationsuplfw/protocolhandlerapi/bwins/epossuplprotocolhandlerpluginu.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/bwins/epossuplprotocolhandlerpluginu.def Thu Jul 22 16:37:56 2010 +0100 @@ -1,26 +1,27 @@ EXPORTS - ?ConstructL@CSUPLProtocolManagerBase@@UAEXABVTUid@@@Z @ 1 NONAME ; void CSUPLProtocolManagerBase::ConstructL(class TUid const &) - ??0CSUPLProtocolManagerBase@@QAE@XZ @ 2 NONAME ; CSUPLProtocolManagerBase::CSUPLProtocolManagerBase(void) - ?CancelListenToMessages@CSuplConnection@@QAEXXZ @ 3 NONAME ; void CSuplConnection::CancelListenToMessages(void) - ?ImplementationUid@CSUPLProtocolManagerBase@@QBE?AVTUid@@XZ @ 4 NONAME ; class TUid CSUPLProtocolManagerBase::ImplementationUid(void) const - ?CancelSend@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 5 NONAME ; void CSuplConnection::CancelSend(class TRequestStatus &) - ?ListenToMessages@CSuplConnection@@QAEHXZ @ 6 NONAME ; int CSuplConnection::ListenToMessages(void) - ?GetSUPLMessageVersionL@CSUPLProtocolManagerBase@@UAEHAAHABVTDesC8@@@Z @ 7 NONAME ; int CSUPLProtocolManagerBase::GetSUPLMessageVersionL(int &, class TDesC8 const &) - ?Version@CSUPLProtocolManagerBase@@QBEHXZ @ 8 NONAME ; int CSUPLProtocolManagerBase::Version(void) const - ??1CSuplCommunicationManager@@UAE@XZ @ 9 NONAME ; CSuplCommunicationManager::~CSuplCommunicationManager(void) - ?Connect@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 10 NONAME ; void CSuplConnection::Connect(class TRequestStatus &) - ?GetPortNumberUsed@CSuplConnection@@QAEHXZ @ 11 NONAME ; int CSuplConnection::GetPortNumberUsed(void) - ?Initialize@CSuplCommunicationManager@@QAEHXZ @ 12 NONAME ; int CSuplCommunicationManager::Initialize(void) - ?GetLocalIPAddress@CSuplConnection@@QAEHAAVTInetAddr@@@Z @ 13 NONAME ; int CSuplConnection::GetLocalIPAddress(class TInetAddr &) - ?NewL@CSUPLProtocolManagerBase@@SAPAV1@ABVTDesC8@@@Z @ 14 NONAME ; class CSUPLProtocolManagerBase * CSUPLProtocolManagerBase::NewL(class TDesC8 const &) - ?NewL@CSuplCommunicationManager@@SAPAV1@XZ @ 15 NONAME ; class CSuplCommunicationManager * CSuplCommunicationManager::NewL(void) - ?Send@CSuplConnection@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 16 NONAME ; void CSuplConnection::Send(class TDesC8 const &, class TRequestStatus &) - ?CreateConnectionL@CSuplCommunicationManager@@QAEPAVCSuplConnection@@ABVTDesC16@@HHIH@Z @ 17 NONAME ; class CSuplConnection * CSuplCommunicationManager::CreateConnectionL(class TDesC16 const &, int, int, unsigned int, int) - ?CloseConnection@CSuplConnection@@QAEXXZ @ 18 NONAME ; void CSuplConnection::CloseConnection(void) - ?CancelConnect@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 19 NONAME ; void CSuplConnection::CancelConnect(class TRequestStatus &) - ?DestroyConnection@CSuplCommunicationManager@@QAEHPAVCSuplConnection@@@Z @ 20 NONAME ; int CSuplCommunicationManager::DestroyConnection(class CSuplConnection *) - ?NewL@CSUPLProtocolManagerBase@@SAPAV1@ABVTUid@@@Z @ 21 NONAME ; class CSUPLProtocolManagerBase * CSUPLProtocolManagerBase::NewL(class TUid const &) - ?SetPacketReceiver@CSuplCommunicationManager@@QAEXPAVMSuplPacketReceiver@@@Z @ 22 NONAME ; void CSuplCommunicationManager::SetPacketReceiver(class MSuplPacketReceiver *) - ??1CSUPLProtocolManagerBase@@UAE@XZ @ 23 NONAME ; CSUPLProtocolManagerBase::~CSUPLProtocolManagerBase(void) - ?CreateConnectionL@CSuplCommunicationManager@@QAEPAVCSuplConnection@@ABVTDesC16@@IH@Z @ 24 NONAME ; class CSuplConnection * CSuplCommunicationManager::CreateConnectionL(class TDesC16 const &, unsigned int, int) + ?Connect@CSuplConnection@@QAEXAAVTRequestStatus@@HH@Z @ 1 NONAME ; void CSuplConnection::Connect(class TRequestStatus &, int, int) + ?ConstructL@CSUPLProtocolManagerBase@@UAEXABVTUid@@@Z @ 2 NONAME ; void CSUPLProtocolManagerBase::ConstructL(class TUid const &) + ??0CSUPLProtocolManagerBase@@QAE@XZ @ 3 NONAME ; CSUPLProtocolManagerBase::CSUPLProtocolManagerBase(void) + ?CancelListenToMessages@CSuplConnection@@QAEXXZ @ 4 NONAME ; void CSuplConnection::CancelListenToMessages(void) + ?ImplementationUid@CSUPLProtocolManagerBase@@QBE?AVTUid@@XZ @ 5 NONAME ; class TUid CSUPLProtocolManagerBase::ImplementationUid(void) const + ?CancelSend@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 6 NONAME ; void CSuplConnection::CancelSend(class TRequestStatus &) + ?ListenToMessages@CSuplConnection@@QAEHXZ @ 7 NONAME ; int CSuplConnection::ListenToMessages(void) + ?GetSUPLMessageVersionL@CSUPLProtocolManagerBase@@UAEHAAHABVTDesC8@@@Z @ 8 NONAME ; int CSUPLProtocolManagerBase::GetSUPLMessageVersionL(int &, class TDesC8 const &) + ?Version@CSUPLProtocolManagerBase@@QBEHXZ @ 9 NONAME ; int CSUPLProtocolManagerBase::Version(void) const + ??1CSuplCommunicationManager@@UAE@XZ @ 10 NONAME ; CSuplCommunicationManager::~CSuplCommunicationManager(void) + ?Connect@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 11 NONAME ; void CSuplConnection::Connect(class TRequestStatus &) + ?GetPortNumberUsed@CSuplConnection@@QAEHXZ @ 12 NONAME ; int CSuplConnection::GetPortNumberUsed(void) + ?Initialize@CSuplCommunicationManager@@QAEHXZ @ 13 NONAME ; int CSuplCommunicationManager::Initialize(void) + ?GetLocalIPAddress@CSuplConnection@@QAEHAAVTInetAddr@@@Z @ 14 NONAME ; int CSuplConnection::GetLocalIPAddress(class TInetAddr &) + ?NewL@CSUPLProtocolManagerBase@@SAPAV1@ABVTDesC8@@@Z @ 15 NONAME ; class CSUPLProtocolManagerBase * CSUPLProtocolManagerBase::NewL(class TDesC8 const &) + ?NewL@CSuplCommunicationManager@@SAPAV1@XZ @ 16 NONAME ; class CSuplCommunicationManager * CSuplCommunicationManager::NewL(void) + ?Send@CSuplConnection@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 17 NONAME ; void CSuplConnection::Send(class TDesC8 const &, class TRequestStatus &) + ?CreateConnectionL@CSuplCommunicationManager@@QAEPAVCSuplConnection@@ABVTDesC16@@HHIH@Z @ 18 NONAME ; class CSuplConnection * CSuplCommunicationManager::CreateConnectionL(class TDesC16 const &, int, int, unsigned int, int) + ?CloseConnection@CSuplConnection@@QAEXXZ @ 19 NONAME ; void CSuplConnection::CloseConnection(void) + ?CancelConnect@CSuplConnection@@QAEXAAVTRequestStatus@@@Z @ 20 NONAME ; void CSuplConnection::CancelConnect(class TRequestStatus &) + ?DestroyConnection@CSuplCommunicationManager@@QAEHPAVCSuplConnection@@@Z @ 21 NONAME ; int CSuplCommunicationManager::DestroyConnection(class CSuplConnection *) + ?NewL@CSUPLProtocolManagerBase@@SAPAV1@ABVTUid@@@Z @ 22 NONAME ; class CSUPLProtocolManagerBase * CSUPLProtocolManagerBase::NewL(class TUid const &) + ?SetPacketReceiver@CSuplCommunicationManager@@QAEXPAVMSuplPacketReceiver@@@Z @ 23 NONAME ; void CSuplCommunicationManager::SetPacketReceiver(class MSuplPacketReceiver *) + ??1CSUPLProtocolManagerBase@@UAE@XZ @ 24 NONAME ; CSUPLProtocolManagerBase::~CSUPLProtocolManagerBase(void) + ?CreateConnectionL@CSuplCommunicationManager@@QAEPAVCSuplConnection@@ABVTDesC16@@IH@Z @ 25 NONAME ; class CSuplConnection * CSuplCommunicationManager::CreateConnectionL(class TDesC16 const &, unsigned int, int) diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/eabi/epossuplprotocolhandlerpluginu.def --- a/supl/locationsuplfw/protocolhandlerapi/eabi/epossuplprotocolhandlerpluginu.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/eabi/epossuplprotocolhandlerpluginu.def Thu Jul 22 16:37:56 2010 +0100 @@ -8,31 +8,32 @@ _ZN15CSuplConnection22CancelListenToMessagesEv @ 7 NONAME _ZN15CSuplConnection4SendERK6TDesC8R14TRequestStatus @ 8 NONAME _ZN15CSuplConnection7ConnectER14TRequestStatus @ 9 NONAME - _ZN24CSUPLProtocolManagerBase10ConstructLERK4TUid @ 10 NONAME - _ZN24CSUPLProtocolManagerBase22GetSUPLMessageVersionLERiRK6TDesC8 @ 11 NONAME - _ZN24CSUPLProtocolManagerBase4NewLERK4TUid @ 12 NONAME - _ZN24CSUPLProtocolManagerBase4NewLERK6TDesC8 @ 13 NONAME - _ZN24CSUPLProtocolManagerBaseC2Ev @ 14 NONAME - _ZN24CSUPLProtocolManagerBaseD0Ev @ 15 NONAME - _ZN24CSUPLProtocolManagerBaseD1Ev @ 16 NONAME - _ZN24CSUPLProtocolManagerBaseD2Ev @ 17 NONAME - _ZN25CSuplCommunicationManager10InitializeEv @ 18 NONAME - _ZN25CSuplCommunicationManager17CreateConnectionLERK7TDesC16iiji @ 19 NONAME - _ZN25CSuplCommunicationManager17CreateConnectionLERK7TDesC16ji @ 20 NONAME - _ZN25CSuplCommunicationManager17DestroyConnectionEP15CSuplConnection @ 21 NONAME - _ZN25CSuplCommunicationManager17SetPacketReceiverEP19MSuplPacketReceiver @ 22 NONAME - _ZN25CSuplCommunicationManager4NewLEv @ 23 NONAME - _ZN25CSuplCommunicationManagerD0Ev @ 24 NONAME - _ZN25CSuplCommunicationManagerD1Ev @ 25 NONAME - _ZN25CSuplCommunicationManagerD2Ev @ 26 NONAME - _ZNK24CSUPLProtocolManagerBase17ImplementationUidEv @ 27 NONAME - _ZNK24CSUPLProtocolManagerBase7VersionEv @ 28 NONAME - _ZTI15CSuplConnection @ 29 NONAME - _ZTI17CSuplSocketReader @ 30 NONAME - _ZTI24CSUPLProtocolManagerBase @ 31 NONAME - _ZTI25CSuplCommunicationManager @ 32 NONAME - _ZTV15CSuplConnection @ 33 NONAME - _ZTV17CSuplSocketReader @ 34 NONAME - _ZTV24CSUPLProtocolManagerBase @ 35 NONAME - _ZTV25CSuplCommunicationManager @ 36 NONAME + _ZN15CSuplConnection7ConnectER14TRequestStatusii @ 10 NONAME + _ZN24CSUPLProtocolManagerBase10ConstructLERK4TUid @ 11 NONAME + _ZN24CSUPLProtocolManagerBase22GetSUPLMessageVersionLERiRK6TDesC8 @ 12 NONAME + _ZN24CSUPLProtocolManagerBase4NewLERK4TUid @ 13 NONAME + _ZN24CSUPLProtocolManagerBase4NewLERK6TDesC8 @ 14 NONAME + _ZN24CSUPLProtocolManagerBaseC2Ev @ 15 NONAME + _ZN24CSUPLProtocolManagerBaseD0Ev @ 16 NONAME + _ZN24CSUPLProtocolManagerBaseD1Ev @ 17 NONAME + _ZN24CSUPLProtocolManagerBaseD2Ev @ 18 NONAME + _ZN25CSuplCommunicationManager10InitializeEv @ 19 NONAME + _ZN25CSuplCommunicationManager17CreateConnectionLERK7TDesC16iiji @ 20 NONAME + _ZN25CSuplCommunicationManager17CreateConnectionLERK7TDesC16ji @ 21 NONAME + _ZN25CSuplCommunicationManager17DestroyConnectionEP15CSuplConnection @ 22 NONAME + _ZN25CSuplCommunicationManager17SetPacketReceiverEP19MSuplPacketReceiver @ 23 NONAME + _ZN25CSuplCommunicationManager4NewLEv @ 24 NONAME + _ZN25CSuplCommunicationManagerD0Ev @ 25 NONAME + _ZN25CSuplCommunicationManagerD1Ev @ 26 NONAME + _ZN25CSuplCommunicationManagerD2Ev @ 27 NONAME + _ZNK24CSUPLProtocolManagerBase17ImplementationUidEv @ 28 NONAME + _ZNK24CSUPLProtocolManagerBase7VersionEv @ 29 NONAME + _ZTI15CSuplConnection @ 30 NONAME + _ZTI17CSuplSocketReader @ 31 NONAME + _ZTI24CSUPLProtocolManagerBase @ 32 NONAME + _ZTI25CSuplCommunicationManager @ 33 NONAME + _ZTV15CSuplConnection @ 34 NONAME + _ZTV17CSuplSocketReader @ 35 NONAME + _ZTV24CSUPLProtocolManagerBase @ 36 NONAME + _ZTV25CSuplCommunicationManager @ 37 NONAME diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/group/epos_suplprotocolhandlerplugin.mmp --- a/supl/locationsuplfw/protocolhandlerapi/group/epos_suplprotocolhandlerplugin.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/group/epos_suplprotocolhandlerplugin.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -55,5 +55,5 @@ LIBRARY flogger.lib /* LIBRARY gba.lib */ -exportunfrozen +//exportunfrozen epocallowdlldata diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplconnection.h --- a/supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplconnection.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplconnection.h Thu Jul 22 16:37:56 2010 +0100 @@ -88,6 +88,17 @@ * @return void * */ IMPORT_C void Connect(TRequestStatus &aStatus); + + /** + * A method that makes Socket Connection. + * @since Series 60 3.1 + * @return None + * @param aPrompt used to show connection prompt using OCC Api's. + * @param aWlanOnly used to differentiate connection for GPRS and WLAN using OCC Api's + */ + IMPORT_C void Connect(TRequestStatus &aStatus,TBool aPrompt,TBool aWlanOnly); + + IMPORT_C void CloseConnection(); @@ -395,6 +406,10 @@ // Number of client connected TInt iConnectClients; + TBool iPrompt; + + TBool iWlanOnly; + }; #endif // C_CSUPLCONNECTION_H diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplprotocolmanagerbase.h --- a/supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplprotocolmanagerbase.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/inc/epos_csuplprotocolmanagerbase.h Thu Jul 22 16:37:56 2010 +0100 @@ -29,7 +29,7 @@ //Forword Declarations class CSuplSessionBase; class CSuplCommunicationManager; - +class TGeoCellInfo; /** * Constant: KProtocolManagerInterfaceDefinitionUid @@ -374,7 +374,35 @@ */ virtual TInt GetSUPLMessageVersionL(TInt& aMajorVersion, const TDesC8& aReceivedMessage); - + /** + * Function: MakeLocationConversionRequestL + * + * @Description: Makes Location conversion request + * + * @Param: aSuplSessn,session object on which processing will start + * + * @Param: aCellInfo,cell information which needs to be converted to geo-coordinates + * + * @Param: aStatus, On return, the status of the request + * @Returns: returns None + */ + + virtual void MakeLocationConversionRequestL( CSuplSessionBase* aSuplSessn, + TGeoCellInfo& aCellInfo, + TRequestStatus& aStatus ) = 0; + + + /** + * Function: CancelLocationConversionRequest + * + * @Description: Cancels the conversion Request + * + * @Param: Session Object + * + * @Returns: None + */ + + virtual void CancelLocationConversionRequest(CSuplSessionBase* aSuplSession) = 0; public: // from MSuplPacketReceiver diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp --- a/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -139,7 +139,9 @@ iConnectStarted(EFalse), iSendInProgress(EFalse), iFirstPkt(EFalse), - iListenCount(0) + iListenCount(0), + iPrompt(EFalse), + iWlanOnly(EFalse) { iHostAddress.Zero(); CActiveScheduler::Add(this); @@ -992,6 +994,106 @@ iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, __LINE__); } + +// ----------------------------------------------------------------------------- +// CSuplConnection::Connect +// Makes a secure connection to Network +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// + +EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus,TBool aPrompt,TBool aWlanOnly) + { + + // Log + iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__); + iPrompt = aPrompt; + iWlanOnly = aWlanOnly; + + if (iState == EConnected) + { + aStatus = KRequestPending; + TRequestStatus *reqStatus = &aStatus; + User::RequestComplete(reqStatus, KErrNone); + iConnectClients++; + return; + } + + // Check if Connect() is started. If started, add status to Q + //if (iConnectStarted) + // { + aStatus = KRequestPending; + TRequestStatus *reqStatus = &aStatus; + iConnArray.Append(reqStatus); + // } + + if (!iConnectStarted) + { + iTrace->Trace(_L("CSuplConnection::Connect : Connection not started"), KTraceFileName, __LINE__); + // Connect only if not already connected + if(iState == ENotConnected || iState == EFailure) + { + iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), KTraceFileName, __LINE__); + iConnectStarted = ETrue; + +#ifndef __WINS__ + + iTrace->Trace(_L("CSuplConnection::Connect ExtendedConnPref"), KTraceFileName, __LINE__); + + TExtendedConnPref OCCPrefs; + TConnPrefList prefList; + + if(iWlanOnly) + { + iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__); + OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN); + OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); + } + else + { + iTrace->Trace(_L("CSuplConnection::Connect using OCC"), KTraceFileName, __LINE__); + iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__); + OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular); + OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); + } + + if(!iPrompt) + { + iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__); + OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); + } + else + { + iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__); + OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); + } + + + + TRAP_IGNORE(prefList.AppendL(&OCCPrefs)); + + + TInt ret = iConnection.Open(iSocketServ); + // Start an Outgoing Connection with overrides + iConnection.Start(prefList,iStatus); + // Set state to ERetriveIAP + iState = ERetriveIAP; + SetActive(); + + + +#else + ConnectIAP(); +#endif + } + } + else + iTrace->Trace(_L("CSuplConnection::Connect : Conn in progress, request queued"), KTraceFileName, __LINE__); + // Log + iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, __LINE__); + } + + // ----------------------------------------------------------------------------- // CSuplConnection::CompleteConnectStatus // Completes the request to cancel connection diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/settingsapi/inc/epos_csuplsettingsinternalcrkeys.h --- a/supl/locationsuplfw/settingsapi/inc/epos_csuplsettingsinternalcrkeys.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/settingsapi/inc/epos_csuplsettingsinternalcrkeys.h Thu Jul 22 16:37:56 2010 +0100 @@ -33,5 +33,6 @@ const TUint32 KSuplSessionDBEvent = 0x00000009; const TUint32 KSuplSessionDBChangedSessionId = 0x0000000A; const TUint32 KSuplSettingsTriggerServiceStatus = 0x0000000B; +const TUint32 KSuplGeoInfoConvServerName = 0x0000000C; #endif //SUPLSETTINGSINTERNALCRKEYS_H diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/bwins/epos_suplterminitiationu.def --- a/supl/locationsuplfw/terminalinitiationapi/bwins/epos_suplterminitiationu.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/terminalinitiationapi/bwins/epos_suplterminitiationu.def Thu Jul 22 16:37:56 2010 +0100 @@ -53,4 +53,7 @@ ?GetPosition@RSuplTerminalSubSession@@QAEHAAVTPositionInfoBase@@@Z @ 52 NONAME ; int RSuplTerminalSubSession::GetPosition(class TPositionInfoBase &) ?ConstructL@CSuplSubSessnPtrHolder@@IAEXHH@Z @ 53 NONAME ; void CSuplSubSessnPtrHolder::ConstructL(int, int) ?NewL@CSuplSubSessnPtrHolder@@SAPAV1@HH@Z @ 54 NONAME ; class CSuplSubSessnPtrHolder * CSuplSubSessnPtrHolder::NewL(int, int) + ?CancelLocationConversion@RSuplTerminalInternal@@QAEXXZ @ 55 NONAME ; void RSuplTerminalInternal::CancelLocationConversion(void) + ??0RSuplTerminalInternal@@QAE@XZ @ 56 NONAME ; RSuplTerminalInternal::RSuplTerminalInternal(void) + ?ConvertAreaInfoToCoordinates@RSuplTerminalInternal@@QAEXAAVTRequestStatus@@AAUTGeoCellInfo@@@Z @ 57 NONAME ; void RSuplTerminalInternal::ConvertAreaInfoToCoordinates(class TRequestStatus &, struct TGeoCellInfo &) diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/eabi/epos_suplterminitiationu.def --- a/supl/locationsuplfw/terminalinitiationapi/eabi/epos_suplterminitiationu.def Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/terminalinitiationapi/eabi/epos_suplterminitiationu.def Thu Jul 22 16:37:56 2010 +0100 @@ -68,4 +68,8 @@ _ZTV19CSuplTerminalParams @ 67 NONAME _ZTV22CSuplSubSessnPtrHolder @ 68 NONAME _ZTV23RSuplTerminalSubSession @ 69 NONAME + _ZN21RSuplTerminalInternal24CancelLocationConversionEv @ 70 NONAME + _ZN21RSuplTerminalInternal28ConvertAreaInfoToCoordinatesER14TRequestStatusR12TGeoCellInfo @ 71 NONAME + _ZN21RSuplTerminalInternalC1Ev @ 72 NONAME + _ZN21RSuplTerminalInternalC2Ev @ 73 NONAME diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/group/bld.inf --- a/supl/locationsuplfw/terminalinitiationapi/group/bld.inf Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/terminalinitiationapi/group/bld.inf Thu Jul 22 16:37:56 2010 +0100 @@ -23,6 +23,9 @@ PRJ_EXPORTS ../inc/epos_suplparameters.h MW_LAYER_PLATFORM_EXPORT_PATH(epos_suplparameters.h) +../inc/epos_suplterminalinternal.h |../../../inc/epos_suplterminalinternal.h +../inc/epos_suplgeocellinfo.h |../../../inc/epos_suplgeocellinfo.h + PRJ_MMPFILES epos_suplterminalapi.mmp diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/group/epos_suplterminalapi.mmp --- a/supl/locationsuplfw/terminalinitiationapi/group/epos_suplterminalapi.mmp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/terminalinitiationapi/group/epos_suplterminalapi.mmp Thu Jul 22 16:37:56 2010 +0100 @@ -33,6 +33,7 @@ SOURCE epos_suplterminalqop.cpp SOURCE epos_suplterminalparams.cpp SOURCE epos_suplterminalperiodictrigger.cpp +SOURCE epos_suplterminalinternal.cpp USERINCLUDE ../inc USERINCLUDE ../../../inc diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/inc/epos_suplgeocellinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/supl/locationsuplfw/terminalinitiationapi/inc/epos_suplgeocellinfo.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2002-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: Data structure to hold cell information for geo tagging purposes. +* +*/ + +/*! \file epos_suplgeocellinfo.h + \brief Triggering classes +*/ + +#ifndef __EPOS_SUPLGEOCELLINFO_H__ +#define __EPOS_SUPLGEOCELLINFO_H__ + +// ========================================== + +/** + * Cell types + */ +enum TGeoCellType + { + /** GSM Cell. */ + EGeoGsmCell = 0, + /** WCDMA cell. */ + EGeoWcdmaCell = 1 + }; + +/** + * Class defines detailed information for gsm/wcdma cell. + * + * @since S60 5.2 + */ +struct TGeoCellInfo + { + TInt iMNC; + TInt iMCC; + TInt iCid; + TInt iLac; + TBool iConnectionPrompt; + TBool iWlanOnly; + TGeoCellType iGeoCellType; + }; + +#endif //__EPOS_SUPLGEOCELLINFO_H__ diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/inc/epos_suplterminalinternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/supl/locationsuplfw/terminalinitiationapi/inc/epos_suplterminalinternal.h Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2002-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: SUPL Terminal Initiation internal class +* +*/ + +#ifndef __EPOS_SUPLTERMINALINTERNAL_H__ +#define __EPOS_SUPLTERMINALINTERNAL_H__ + + +#include + +#include "epos_suplgeocellinfo.h" + + +// Forward declarations + +/** + * This class is used to make request to convert area information to geo-coordinates. + */ +class RSuplTerminalInternal : public RSuplTerminalSubSession + { + + +public: + /** + * Constructor for RSuplTerminalInternal + * + */ + IMPORT_C RSuplTerminalInternal(); + + /** + * This is an asynchronous request to SUPL Server to determine position + * information corresponding to given area information. + * Client can have only one outstanding asynchronous request per sub-session. + * @param [OUT] aStatus to return result code + * @param[IN] aGeoCellInfo Cell information + * @return aStatus will have + * - KErrNone if request is completed sucessfully. + * - KErrCancel if the request was successfully cancelled + * - KErrNotReady if SUPL server is not ready to determine position information, + * client can retry after sometime. + * - KErrAlreadyExists if there is already an ongoing request on sub-session. + * - KErrServerTerminated if server got terminated due to some error + * - KErrNotSupported if function is called when Session is NOT Opened with SUPL_1_0 service + * - KErrGeneral for all other errors + * + */ + + IMPORT_C void ConvertAreaInfoToCoordinates( + TRequestStatus& aStatus, + TGeoCellInfo& aGeoCellInfo ); + + /** + * Cancels an outstanding asynchronous conversion request issued via ConvertAreaInfoToCoordinates + * Canceling requests is typically attempted when an client + * is closing down. + * + */ + IMPORT_C void CancelLocationConversion(); + +private: + //Cell Information + TGeoCellInfo iGeoCellInfo; + + //To check if conversion request has issued or not + TBool iConversionRequestIssued; + }; + +#endif // __EPOS_SUPLTERMINALINTERNAL_H__ diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/inc/epos_suplterminalipc.h --- a/supl/locationsuplfw/terminalinitiationapi/inc/epos_suplterminalipc.h Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/locationsuplfw/terminalinitiationapi/inc/epos_suplterminalipc.h Thu Jul 22 16:37:56 2010 +0100 @@ -61,7 +61,8 @@ ESuplTerminalSubssnStartPeriodicTriggerWithServer, ESuplTerminalSubssnNotifyTriggerFired, ESuplTerminalSubssnStopTriggerSession, - + ESuplTerminalSubssnLocationConversion, + ESuplTerminalSubssnCancelLocationConversion, ESuplSubssnCustomCodesBegin = ESuplCustomIpcOffset, }; diff -r 6f8759468fd4 -r 7409e6184c90 supl/locationsuplfw/terminalinitiationapi/src/epos_suplterminalinternal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/supl/locationsuplfw/terminalinitiationapi/src/epos_suplterminalinternal.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2002-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: Client-Server communication +* +*/ +#include +#include + +#include "epos_suplterminalinternal.h" +#include "epos_suplterminalipc.h" +#include "epos_suplterminalerrors.h" +#include "epos_suplterminalptrholder.h" + +//----------------------------------------------------------------------------- +// RSuplTerminalInternal +//----------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------- +// RSuplTerminalInternal::RSuplTerminalInternal() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C RSuplTerminalInternal::RSuplTerminalInternal() + : iConversionRequestIssued( EFalse ) + { + } + +// --------------------------------------------------------- +// RSuplTerminalInternal::ConvertAreaInfoToCoordinates +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +EXPORT_C void RSuplTerminalInternal::ConvertAreaInfoToCoordinates( TRequestStatus& aStatus, + TGeoCellInfo& aGeoCellInfo ) + { + __ASSERT_ALWAYS(SubSessionHandle(), + User::Panic(KSuplClientFault, ESuplServerBadHandle)); + + // Currently only SUPL 1.0 supports cell to geo-coordinates conversion. + if( iSuplService != ESUPL_1_0 ) + { + TRequestStatus *status = &aStatus; + User::RequestComplete(status,KErrNotSupported); + return; + } + + // Fill the values of data member + iGeoCellInfo.iMNC = aGeoCellInfo.iMNC; + iGeoCellInfo.iMCC = aGeoCellInfo.iMCC; + iGeoCellInfo.iCid = aGeoCellInfo.iCid; + iGeoCellInfo.iLac = aGeoCellInfo.iLac; + iGeoCellInfo.iConnectionPrompt = aGeoCellInfo.iConnectionPrompt; + iGeoCellInfo.iWlanOnly = aGeoCellInfo.iWlanOnly; //OCC + iGeoCellInfo.iGeoCellType = aGeoCellInfo.iGeoCellType; + + iPtrHolder->Ptr(0).Set( + reinterpret_cast(&iGeoCellInfo), + sizeof(iGeoCellInfo),sizeof(iGeoCellInfo)); + + TIpcArgs args; + + args.Set(0,&iPtrHolder->Ptr(0)); + iConversionRequestIssued = ETrue; + SendReceive(ESuplTerminalSubssnLocationConversion, args, aStatus); + } + +// --------------------------------------------------------- +// RSuplTerminalInternal::CancelLocationConversion +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +EXPORT_C void RSuplTerminalInternal::CancelLocationConversion() + { + __ASSERT_ALWAYS(SubSessionHandle(), + User::Panic(KSuplClientFault, ESuplServerBadHandle)); + if( iConversionRequestIssued ) + { + iConversionRequestIssued = EFalse; + SendReceive(ESuplTerminalSubssnCancelLocationConversion); + } + } +// end of file diff -r 6f8759468fd4 -r 7409e6184c90 supl/supltiapiimplementation/src/lbssupltirequestmanager.cpp --- a/supl/supltiapiimplementation/src/lbssupltirequestmanager.cpp Tue Jun 15 11:38:32 2010 +0100 +++ b/supl/supltiapiimplementation/src/lbssupltirequestmanager.cpp Thu Jul 22 16:37:56 2010 +0100 @@ -165,10 +165,12 @@ // void CCLbsSuplTiRequestManager::CloseSession() { - iTrace->Trace(_L("CCLbsSuplTiRequestManager::CloseSession() start"), KTraceFileName, __LINE__); + if(iTrace) + iTrace->Trace(_L("CCLbsSuplTiRequestManager::CloseSession() start"), KTraceFileName, __LINE__); iRequestorCollection.ResetAndDestroy(); //cancels all active requests iServer.Close(); - iTrace->Trace(_L("CCLbsSuplTiRequestManager::CloseSession() end"), KTraceFileName, __LINE__); + if(iTrace) + iTrace->Trace(_L("CCLbsSuplTiRequestManager::CloseSession() end"), KTraceFileName, __LINE__); } // ----------------------------------------------------------------------------- // CCLbsSuplTiRequestManager::FindSessionId