wlanapitest/wlanhaitest/wlan/src/T_CCommsDatabaseData.cpp
branchRCL_3
changeset 42 a828660c511c
parent 40 5fb7af913dfd
child 43 d3d7683d16f5
equal deleted inserted replaced
40:5fb7af913dfd 42:a828660c511c
     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 #include "t_ccommsdatabasedata.h"
       
    21 
       
    22 /*@{*/
       
    23 //LIT's for commands of CT_CCommsDatabaseData
       
    24 _LIT(KCmdNewL,					"NewL");
       
    25 _LIT(KCmdDestructor,			"~");
       
    26 /*@}*/
       
    27 
       
    28 /**
       
    29  * Two phase constructor
       
    30  *
       
    31  * @leave	system wide error
       
    32  */
       
    33 CT_CCommsDatabaseData* CT_CCommsDatabaseData::NewL()
       
    34 	{
       
    35 	CT_CCommsDatabaseData* ret = new (ELeave) CT_CCommsDatabaseData();
       
    36 	CleanupStack::PushL(ret);
       
    37 	ret->ConstructL();
       
    38 	CleanupStack::Pop(ret);
       
    39 	return ret;
       
    40 	}
       
    41 
       
    42 /**
       
    43  * Public destructor
       
    44  */
       
    45 CT_CCommsDatabaseData::~CT_CCommsDatabaseData()
       
    46 	{
       
    47 	DestroyData();
       
    48 	}
       
    49 
       
    50 /**
       
    51  * Private constructor. First phase construction
       
    52  */
       
    53 
       
    54 CT_CCommsDatabaseData::CT_CCommsDatabaseData()
       
    55 :	iCommsDat(NULL)
       
    56 	{
       
    57 	}
       
    58 
       
    59 /**
       
    60  * Second phase construction
       
    61  *
       
    62  * @internalComponent
       
    63  *
       
    64  * @return	N/A
       
    65  *
       
    66  * @pre		None
       
    67  * @post	None
       
    68  *
       
    69  * @leave	system wide error
       
    70  */
       
    71 void CT_CCommsDatabaseData::ConstructL()
       
    72 	{
       
    73 	}
       
    74 
       
    75 /**
       
    76  * Return a pointer to the object that the data wraps
       
    77  *
       
    78  * @return	pointer to the object that the data wraps
       
    79  */
       
    80 TAny* CT_CCommsDatabaseData::GetObject()
       
    81 	{
       
    82 	return iCommsDat;
       
    83 	}
       
    84 
       
    85 /**
       
    86  * Process a command read from the Ini file
       
    87  * @param aCommand 			The command to process
       
    88  * @param aSection			The section get from the *.ini file of the project T_Wlan
       
    89  * @param aAsyncErrorIndex	Command index dor async calls to returns errors to
       
    90  * @return TBool			ETrue if the command is process
       
    91  * @leave					system wide error
       
    92  */
       
    93 TBool CT_CCommsDatabaseData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName&/* aSection*/, const TInt /*aAsyncErrorIndex*/)
       
    94 	{
       
    95 	TBool ret = ETrue;
       
    96 	
       
    97 	if(aCommand == KCmdNewL)
       
    98 		{
       
    99 		DoCmdNewL();
       
   100 		}
       
   101 	else if(aCommand == KCmdDestructor)
       
   102 		{
       
   103 		DoCmdDestructor();
       
   104 		}
       
   105 	else
       
   106 		{
       
   107 		ERR_PRINTF1(_L("Unknown command."));
       
   108 		ret = EFalse;
       
   109 		}
       
   110 	
       
   111 	return ret;
       
   112 	}
       
   113 
       
   114 
       
   115 /**
       
   116  * Command to create an Instance of CCommsDatabase class
       
   117  * @param 
       
   118  * @return 
       
   119  */
       
   120 void CT_CCommsDatabaseData::DoCmdNewL()
       
   121 	{
       
   122 	INFO_PRINTF1(_L("*START* CT_CCommsDatabaseData::DoCmdNewL"));
       
   123 	DestroyData();
       
   124 	
       
   125 	TRAPD(err,iCommsDat = CCommsDatabase::NewL(ETrue));	
       
   126 	if(err!=KErrNone)
       
   127 		 {
       
   128 		 ERR_PRINTF2(_L("CCommsDatabase* commsDat = CCommsDatabase::NewL(ETrue) left with error %d"), err);
       
   129 		 SetError(err);
       
   130 		 }
       
   131 	else
       
   132 		{
       
   133 		INFO_PRINTF1(_L("CCommsDatabase* commsDat = CCommsDatabase::NewL(ETrue) was create"));
       
   134 		}
       
   135 	
       
   136 	INFO_PRINTF1(_L("*END* CT_CCommsDatabaseData::DoCmdNewL"));
       
   137 	}
       
   138 
       
   139 /**
       
   140  * Command to destroy an Instance of CCommsDatabase class
       
   141  * @param
       
   142  * @return
       
   143  */
       
   144 void CT_CCommsDatabaseData::DoCmdDestructor()
       
   145 	{
       
   146 	INFO_PRINTF1(_L("*START* CT_CCommsDatabaseData::DoCmdDestructor"));
       
   147 	DestroyData();
       
   148  	INFO_PRINTF1(_L("*END* CT_CCommsDatabaseData::DoCmdDestructor"));
       
   149 	}
       
   150 
       
   151 /**
       
   152  *Helper function to DoCmdDelete command
       
   153  * @param
       
   154  * @return
       
   155  */
       
   156 void CT_CCommsDatabaseData::DestroyData()
       
   157 	{
       
   158 	if(iCommsDat)
       
   159 		{
       
   160 	    delete iCommsDat;
       
   161 	    iCommsDat = NULL;
       
   162 		}
       
   163 	}