wlanapitest/wlanhaitest/wlan/src/T_CCommsDbTableViewData.cpp
branchGCC_SURGE
changeset 37 1ff9bf2737cf
parent 29 d1f0fe5eccbe
parent 36 1c425781161e
equal deleted inserted replaced
29:d1f0fe5eccbe 37:1ff9bf2737cf
     1 /*
       
     2 * Copyright (c) 2005-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "t_ccommsdbtableviewdata.h"
       
    22 
       
    23 // CommsDat preferences setting class.
       
    24 #include <cdbpreftable.h>
       
    25 #include <commdbconnpref.h>
       
    26 
       
    27 /*@{*/
       
    28 //LIT for the data read from the ini file
       
    29 _LIT(KCommsDb,				"commsdb");
       
    30 /*@}*/
       
    31 
       
    32 /*@{*/
       
    33 //LIT's for the commands
       
    34 _LIT(KCmdNewL,				"NewL");
       
    35 _LIT(KCmdDestructor,		"~");
       
    36 /*@}*/
       
    37 
       
    38 /**
       
    39  * Two phase constructor
       
    40  *
       
    41  * @leave	system wide error
       
    42  */
       
    43 CT_CCommsDbTableViewData* CT_CCommsDbTableViewData::NewL()
       
    44 	{
       
    45 	CT_CCommsDbTableViewData* ret = new (ELeave) CT_CCommsDbTableViewData();
       
    46 	CleanupStack::PushL(ret);
       
    47 	ret->ConstructL();
       
    48 	CleanupStack::Pop(ret);
       
    49 	return ret;
       
    50 	}
       
    51 
       
    52 /**
       
    53  * Public destructor
       
    54  */
       
    55 CT_CCommsDbTableViewData::~CT_CCommsDbTableViewData()
       
    56 	{
       
    57 	DestroyData();
       
    58 	}
       
    59 
       
    60 /**
       
    61  * Private constructor. First phase construction
       
    62  */
       
    63 CT_CCommsDbTableViewData::CT_CCommsDbTableViewData()
       
    64 :	iSearchView(NULL)
       
    65 	{
       
    66 	}
       
    67 
       
    68 /**
       
    69  * Second phase construction
       
    70  *
       
    71  * @internalComponent
       
    72  *
       
    73  * @return	N/A
       
    74  *
       
    75  * @pre		None
       
    76  * @post	None
       
    77  *
       
    78  * @leave	system wide error
       
    79  */
       
    80 void CT_CCommsDbTableViewData::ConstructL()
       
    81 	{
       
    82 	}
       
    83 
       
    84 /**
       
    85  * Return a pointer to the object that the data wraps
       
    86  *
       
    87  * @return	pointer to the object that the data wraps
       
    88  */
       
    89 TAny* CT_CCommsDbTableViewData::GetObject()
       
    90 	{
       
    91 	return iSearchView;
       
    92 	}
       
    93 
       
    94 /**
       
    95 * Process a command read from the Ini file
       
    96 * @param aCommand 			The command to process
       
    97 * @param aSection			The section get from the *.ini file of the project T_Wlan
       
    98 * @param aAsyncErrorIndex	Command index dor async calls to returns errors to
       
    99 * @return TBool			    ETrue if the command is process
       
   100 * @leave					system wide error
       
   101 */
       
   102 
       
   103 TBool CT_CCommsDbTableViewData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt/* aAsyncErrorIndex*/)
       
   104 	{
       
   105 	TBool ret = ETrue;
       
   106 	if(aCommand == KCmdNewL)
       
   107 		{
       
   108 		DoCmdNewL(aSection);
       
   109 		}
       
   110 	else if(aCommand == KCmdDestructor)
       
   111 		{
       
   112 		DoCmdDestructor();
       
   113 		}
       
   114 	else
       
   115 		{
       
   116 		ERR_PRINTF1(_L("Unknown command."));
       
   117 		ret = EFalse;
       
   118 		}
       
   119 	return ret;
       
   120 	}
       
   121 
       
   122 
       
   123 
       
   124 
       
   125 /**
       
   126  * Command to create an instance of CCommsDbTableView class
       
   127  * @param aSection			The section in the ini file for this command
       
   128  * @return 
       
   129  */
       
   130 void CT_CCommsDbTableViewData::DoCmdNewL(const TTEFSectionName& aSection)
       
   131 	{
       
   132 	INFO_PRINTF1(_L("*START* CT_CCommsDbTableViewData::DoCmdNewL"));
       
   133 	DestroyData();
       
   134 	
       
   135 	TPtrC commsDbName;
       
   136 	const TUint32 KIAPMask = 0xffffffff;
       
   137 	TBool	dataOk = ETrue;
       
   138 	
       
   139 	//param from the ini file
       
   140 	if(!GetStringFromConfig(aSection, KCommsDb, commsDbName))
       
   141 		{
       
   142         ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCommsDb);
       
   143         SetBlockResult(EFail);
       
   144     	dataOk = EFalse;
       
   145 		}
       
   146 	
       
   147 	if (dataOk)
       
   148 		{
       
   149 		CCommsDatabase* acommsDat = static_cast<CCommsDatabase*>(GetDataObjectL(commsDbName));
       
   150 	  	//CCommsDatabase* acommsDat = CCommsDatabase::NewL(ETrue);
       
   151 		//iSearchView = acommsDat->OpenIAPTableViewMatchingBearerSetLC( KIAPMask, ECommDbConnectionDirectionOutgoing );
       
   152 		iSearchView = acommsDat->OpenIAPTableViewMatchingBearerSetLC( KIAPMask, ECommDbConnectionDirectionOutgoing );
       
   153 		CleanupStack::Pop();
       
   154 		}
       
   155   	
       
   156   	INFO_PRINTF1(_L("*END* CT_CCommsDbTableViewData::DoCmdNewL"));
       
   157 	}
       
   158 /**
       
   159  * Command for delete an instance of CCommsDbTableView class
       
   160  * @param
       
   161  * @return
       
   162  */
       
   163 void CT_CCommsDbTableViewData::DoCmdDestructor()
       
   164 	{
       
   165 	INFO_PRINTF1(_L("*START* CT_CCommsDbTableViewData::DoCmdDestructor"));
       
   166 	
       
   167 	//CleanupStack::Pop(iSearchView);
       
   168 	DestroyData();
       
   169 	
       
   170 	INFO_PRINTF1(_L("*END* CT_CCommsDbTableViewData::DoCmdDestructor"));
       
   171 	}
       
   172 
       
   173 /**
       
   174  * Helper function for the command DoCmdDelete
       
   175  * @param
       
   176  * @return
       
   177  */
       
   178 void CT_CCommsDbTableViewData::DestroyData()
       
   179 	{
       
   180 	if (iSearchView)
       
   181 		{
       
   182 		delete iSearchView;
       
   183 		iSearchView = NULL;
       
   184 		}
       
   185 	}