loc_pub/landmarks_ui_selector_api/tsrc/bc/bcapplmkselector/src/lmkselectorblocks.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    LandmarkUi Content File
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // [INCLUDE FILES] - do not remove
       
    26 #include <e32svr.h>
       
    27 #include <StifParser.h>
       
    28 #include <Stiftestinterface.h>
       
    29 #include "LmkSelector.h"
       
    30 
       
    31 
       
    32 // EXTERNAL DATA STRUCTURES
       
    33 //extern  ?external_data;
       
    34 
       
    35 // EXTERNAL FUNCTION PROTOTYPES
       
    36 //extern ?external_function( ?arg_type,?arg_type );
       
    37 
       
    38 // CONSTANTS
       
    39 //const ?type ?constant_var = ?constant;
       
    40 
       
    41 // MACROS
       
    42 //#define ?macro ?macro_def
       
    43 
       
    44 // LOCAL CONSTANTS AND MACROS
       
    45 //const ?type ?constant_var = ?constant;
       
    46 //#define ?macro_name ?macro_def
       
    47 
       
    48 // MODULE DATA STRUCTURES
       
    49 //enum ?declaration
       
    50 //typedef ?declaration
       
    51 
       
    52 // LOCAL FUNCTION PROTOTYPES
       
    53 //?type ?function_name( ?arg_type, ?arg_type );
       
    54 
       
    55 // FORWARD DECLARATIONS
       
    56 //class ?FORWARD_CLASSNAME;
       
    57 
       
    58 // ============================= LOCAL FUNCTIONS ===============================
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // ?function_name ?description.
       
    62 // ?description
       
    63 // Returns: ?value_1: ?description
       
    64 //          ?value_n: ?description_line1
       
    65 //                    ?description_line2
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 /*
       
    69 ?type ?function_name(
       
    70     ?arg_type arg,  // ?description
       
    71     ?arg_type arg)  // ?description
       
    72     {
       
    73 
       
    74     ?code  // ?comment
       
    75 
       
    76     // ?comment
       
    77     ?code
       
    78     }
       
    79 */
       
    80 
       
    81 // ============================ MEMBER FUNCTIONS ===============================
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CLmkSelector::Delete
       
    85 // Delete here all resources allocated and opened from test methods.
       
    86 // Called from destructor.
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CLmkSelector::Delete()
       
    90     {
       
    91 
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CLmkSelector::RunMethodL
       
    96 // Run specified method. Contains also table of test mothods and their names.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TInt CLmkSelector::RunMethodL(
       
   100     CStifItemParser& aItem )
       
   101     {
       
   102 
       
   103     static TStifFunctionInfo const KFunctions[] =
       
   104         {
       
   105         // Copy this line for every implemented function.
       
   106         // First string is the function name used in TestScripter script file.
       
   107         // Second is the actual implementation member function.
       
   108         ENTRY( "Example", CLmkSelector::ExampleL ),
       
   109         ENTRY( "TestLmkNewL", CLmkSelector::TestLmkNewL ),
       
   110         ENTRY( "TestLmkSetMopParent", CLmkSelector::TestLmkSetMopParent ),
       
   111         ENTRY( "TestLmkExecuteLD", CLmkSelector::TestLmkExecuteLD ),
       
   112         ENTRY( "TestLmkExecuteLD2", CLmkSelector::TestLmkExecuteLD2 ),
       
   113         ENTRY( "TestCatNewL", CLmkSelector::TestCatNewL ),
       
   114         ENTRY( "TestCatSetMopParent", CLmkSelector::TestCatSetMopParent ),
       
   115         ENTRY( "TestCatExecuteLD", CLmkSelector::TestCatExecuteLD ),
       
   116         ENTRY( "TestCatExecuteLD2", CLmkSelector::TestCatExecuteLD2 ),
       
   117         //ADD NEW ENTRY HERE
       
   118         // [test cases entries] - Do not remove
       
   119 
       
   120         };
       
   121 
       
   122     const TInt count = sizeof( KFunctions ) /
       
   123                         sizeof( TStifFunctionInfo );
       
   124 
       
   125     return RunInternalL( KFunctions, count, aItem );
       
   126 
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CLmkSelector::ExampleL
       
   131 // Example test method function.
       
   132 // (other items were commented in a header).
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TInt CLmkSelector::ExampleL( CStifItemParser& aItem )
       
   136     {
       
   137 
       
   138     // Print to UI
       
   139     _LIT( KLmkSelector, "LmkSelector" );
       
   140     _LIT( KExample, "In Example" );
       
   141     TestModuleIf().Printf( 0, KLmkSelector, KExample );
       
   142     // Print to log file
       
   143     iLog->Log( KExample );
       
   144 
       
   145     TInt i = 0;
       
   146     TPtrC string;
       
   147     _LIT( KParam, "Param[%i]: %S" );
       
   148     while ( aItem.GetNextString ( string ) == KErrNone )
       
   149         {
       
   150         TestModuleIf().Printf( i, KLmkSelector,
       
   151                                 KParam, i, &string );
       
   152         i++;
       
   153         }
       
   154 
       
   155     return KErrNone;
       
   156 
       
   157     }
       
   158 
       
   159 
       
   160 
       
   161  void CLmkSelector::CreateNewLandmark()
       
   162     {
       
   163 
       
   164   TRAP_IGNORE(
       
   165 	CPosLandmarkDatabase* dBase = CPosLandmarkDatabase::OpenL();
       
   166 	CleanupStack::PushL( dBase );
       
   167 	if (dBase->IsInitializingNeeded())
       
   168 		{
       
   169 	ExecuteAndDeleteLD(dBase->InitializeL()); // Synchronous since no argument
       
   170 		}
       
   171 
       
   172 	CPosLmItemIterator*  iterator = dBase->LandmarkIteratorL();
       
   173     CleanupStack::PushL(iterator);
       
   174 
       
   175 
       
   176     if( iterator->NumOfItemsL() == 0 )
       
   177 	    {
       
   178 	    CPosLandmark* landmark = CPosLandmark::NewL();
       
   179 		CleanupStack::PushL( landmark );
       
   180 
       
   181 		landmark->SetLandmarkNameL(_L("Nokia"));
       
   182 
       
   183 		dBase->AddLandmarkL(*landmark);
       
   184 		CleanupStack::PopAndDestroy();//landmark
       
   185 	    }
       
   186 
       
   187  	CleanupStack::PopAndDestroy(2);	//iterator,dBase
       
   188  	)
       
   189 	}
       
   190 
       
   191 
       
   192 
       
   193 
       
   194 TInt CLmkSelector::TestLmkNewL( CStifItemParser& aItem )
       
   195 {
       
   196 			CLmkLandmarkSelectorDlg* aLmkSelectDlg = CLmkLandmarkSelectorDlg::NewL();
       
   197 			CleanupStack::PushL( aLmkSelectDlg );
       
   198 			CleanupStack::PopAndDestroy();
       
   199 			//delete aLmkSelectDlg;
       
   200 			//aLmkSelectDlg = NULL;
       
   201 
       
   202 			return KErrNone;
       
   203 }
       
   204 
       
   205 TInt CLmkSelector::TestLmkSetMopParent( CStifItemParser& aItem )
       
   206 {
       
   207       CLmkLandmarkSelectorDlg* iLmkSelectDlg = CLmkLandmarkSelectorDlg::NewL();
       
   208 			//iLmkSelectDlg->SetMopParent(this);
       
   209 			delete iLmkSelectDlg;
       
   210 			iLmkSelectDlg = NULL;
       
   211 	//		CleanupStack::Pop();
       
   212 			return KErrNone;
       
   213 }
       
   214 
       
   215 TInt CLmkSelector::TestLmkExecuteLD( CStifItemParser& aItem )
       
   216 {
       
   217 
       
   218 CreateNewLandmark();
       
   219 
       
   220 			TLmkItemIdDbCombiInfo selItem;
       
   221 			CLmkLandmarkSelectorDlg* iLmkSelectDlg = CLmkLandmarkSelectorDlg::NewL();
       
   222         	TRAPD( result, iLmkSelectDlg->ExecuteLD(selItem));
       
   223         	return KErrNone;
       
   224 }
       
   225 
       
   226 TInt CLmkSelector::TestLmkExecuteLD2( CStifItemParser& aItem )
       
   227 {
       
   228       RArray<TLmkItemIdDbCombiInfo> selItems;
       
   229 			CreateNewLandmark();
       
   230 			CLmkLandmarkSelectorDlg* iLmkSelectDlg = CLmkLandmarkSelectorDlg::NewL();
       
   231         	TRAPD( result, iLmkSelectDlg->ExecuteLD(selItems));
       
   232         	selItems.Close();
       
   233         	return KErrNone;
       
   234 }
       
   235 
       
   236 TInt CLmkSelector::TestCatNewL( CStifItemParser& aItem )
       
   237 {
       
   238       CLmkCategorySelectorDlg* iLmkCategoryDlg = CLmkCategorySelectorDlg::NewL();
       
   239 			delete iLmkCategoryDlg;
       
   240 			iLmkCategoryDlg = NULL;
       
   241 			return KErrNone;
       
   242 }
       
   243 
       
   244 TInt CLmkSelector::TestCatSetMopParent( CStifItemParser& aItem )
       
   245 {
       
   246 
       
   247 			engine = new (ELeave) CLmkEngine;
       
   248 			CLmkCategorySelectorDlg* iLmkCategoryDlg = CLmkCategorySelectorDlg::NewL();
       
   249 			iLmkCategoryDlg->SetMopParent(engine);
       
   250 			delete iLmkCategoryDlg;
       
   251 			iLmkCategoryDlg = NULL;
       
   252 			return KErrNone;
       
   253 }
       
   254 
       
   255 TInt CLmkSelector::TestCatExecuteLD( CStifItemParser& aItem )
       
   256 {
       
   257 			TLmkItemIdDbCombiInfo selItem;
       
   258 			//CreateNewLandmark();
       
   259 			CLmkCategorySelectorDlg* iLmkCategoryDlg = CLmkCategorySelectorDlg::NewL();
       
   260         	TRAPD( result, iLmkCategoryDlg->ExecuteLD(selItem));
       
   261 			//delete iLmkCategoryDlg;
       
   262 			//iLmkCategoryDlg = NULL;
       
   263 			return KErrNone;
       
   264 }
       
   265 
       
   266 TInt CLmkSelector::TestCatExecuteLD2( CStifItemParser& aItem )
       
   267 {
       
   268 					RArray<TLmkItemIdDbCombiInfo> selItems;
       
   269 					//CreateNewLandmark();
       
   270             CLmkCategorySelectorDlg* iLmkCategoryDlg = CLmkCategorySelectorDlg::NewL();
       
   271         	TRAPD( result, iLmkCategoryDlg->ExecuteLD(selItems));
       
   272         	//delete iLmkCategoryDlg;
       
   273 			//iLmkCategoryDlg = NULL;
       
   274         	selItems.Close();
       
   275         	return KErrNone;
       
   276 }
       
   277 // -----------------------------------------------------------------------------
       
   278 // CLmkSelector::?member_function
       
   279 // ?implementation_description
       
   280 // (other items were commented in a header).
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 /*
       
   284 TInt CLmkSelector::?member_function(
       
   285    CItemParser& aItem )
       
   286    {
       
   287 
       
   288    ?code
       
   289 
       
   290    }
       
   291 */
       
   292 
       
   293 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   294 // None
       
   295 
       
   296 //  [End of File] - Do not remove