graphics/wserv/src/T_DataBlankWindow.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "T_DataBlankWindow.h"
       
    19 
       
    20 /*@{*/
       
    21 _LIT(KDataClassname,	"RBlankWindow");
       
    22 
       
    23 //Commands
       
    24 _LIT(KCmdnew,						"new");
       
    25 _LIT(KCmdDestructor,				"~");
       
    26 _LIT(KCmdConstruct,					"Construct");
       
    27 _LIT(KCmdSetColor,					"SetColor");
       
    28 _LIT(KCmdSetSize,					"SetSize");
       
    29 _LIT(KCmdSetExtent,					"SetExtent");
       
    30 
       
    31 // Fields
       
    32 _LIT(KFldColor,						"color");
       
    33 _LIT(KFldHandle,					"handle");
       
    34 _LIT(KFldParent,					"parent");
       
    35 _LIT(KFldPoint,						"point");
       
    36 _LIT(KFldSize,						"size");
       
    37 _LIT(KFldWs,						"ws");
       
    38 
       
    39 ///	Logging
       
    40 _LIT(KLogError,						"Error=%d");
       
    41 _LIT(KLogMissingParameter,			"Missing parameter '%S'");
       
    42 /*@}*/
       
    43 
       
    44 //////////////////////////////////////////////////////////////////////
       
    45 // Construction/Destruction
       
    46 //////////////////////////////////////////////////////////////////////
       
    47 
       
    48 CT_DataBlankWindow* CT_DataBlankWindow::NewL()
       
    49 	{
       
    50 	CT_DataBlankWindow*	ret=new (ELeave) CT_DataBlankWindow();
       
    51 	CleanupStack::PushL(ret);
       
    52 	ret->ConstructL();
       
    53 	CleanupStack::Pop(ret);
       
    54 	return ret;
       
    55 	}
       
    56 
       
    57 CT_DataBlankWindow::CT_DataBlankWindow()
       
    58 :	CT_DataWindowBase()
       
    59 ,	iBlankWindow(NULL)
       
    60 	{
       
    61 	}
       
    62 
       
    63 void CT_DataBlankWindow::ConstructL()
       
    64 	{
       
    65 	}
       
    66 
       
    67 CT_DataBlankWindow::~CT_DataBlankWindow()
       
    68 	{
       
    69 	DestroyData();
       
    70 	}
       
    71 
       
    72 void CT_DataBlankWindow::SetObjectL(TAny* aAny)
       
    73 	{
       
    74 	DestroyData();
       
    75 	iBlankWindow = static_cast<RBlankWindow*> (aAny);
       
    76 	}
       
    77 
       
    78 void CT_DataBlankWindow::DisownObjectL()
       
    79 	{
       
    80 	iBlankWindow = NULL;
       
    81 	}
       
    82 
       
    83 void CT_DataBlankWindow::DestroyData()
       
    84 	{
       
    85 	delete iBlankWindow;
       
    86 	iBlankWindow=NULL;
       
    87 	}
       
    88 
       
    89 RWindowBase* CT_DataBlankWindow::GetWindowBase() const
       
    90 	{
       
    91 	return iBlankWindow;
       
    92 	}
       
    93 
       
    94 /**
       
    95 * Process a command read from the ini file
       
    96 *
       
    97 * @param aCommand			the command to process
       
    98 * @param aSection			the entry in the ini file requiring the command to be processed
       
    99 * @param aAsyncErrorIndex	index of command. used for async calls
       
   100 *
       
   101 * @return ETrue if the command is processed
       
   102 */
       
   103 TBool CT_DataBlankWindow::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   104 	{
       
   105 	TBool	ret = ETrue;
       
   106 
       
   107 	if ( aCommand==KCmdDestructor )
       
   108 		{
       
   109 		DestroyData();
       
   110 		}
       
   111 	else if ( aCommand==KCmdnew || aCommand==KDataClassname )
       
   112 		{
       
   113 		DoCmdnewL(aSection);
       
   114 		}
       
   115 	else if ( aCommand==KCmdConstruct )
       
   116 		{
       
   117 		DoCmdConstructL(aSection);
       
   118 		}
       
   119 	else if ( aCommand==KCmdSetColor )
       
   120 		{
       
   121 		DoCmdSetColor(aSection);
       
   122 		}
       
   123 	else if ( aCommand==KCmdSetSize )
       
   124 		{
       
   125 		DoCmdSetSize(aSection);
       
   126 		}
       
   127 	else if ( aCommand==KCmdSetExtent )
       
   128 		{
       
   129 		DoCmdSetExtent(aSection);
       
   130 		}
       
   131 	else
       
   132 		{
       
   133 		ret=CT_DataWindowBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   134 		}
       
   135 
       
   136 	return ret;
       
   137 	}
       
   138 
       
   139 
       
   140 void CT_DataBlankWindow::DoCmdnewL(const TDesC& aSection)
       
   141 	{
       
   142 	DestroyData();
       
   143 
       
   144 	// Get test data for command input parameter(s)
       
   145 	TPtrC	wsName;
       
   146 	RWsSession* ws=NULL;
       
   147 	if ( GetStringFromConfig(aSection, KFldWs, wsName) )
       
   148 		{
       
   149 		ws = static_cast<RWsSession*>(GetDataObjectL(wsName));
       
   150 		}
       
   151 
       
   152 	TInt	err;
       
   153 	if ( ws != NULL )
       
   154 		{
       
   155 		// Execute command and log parameters
       
   156 		INFO_PRINTF1(_L("execute new RBlankWindow(RWsSession)"));
       
   157 		TRAP( err,	iBlankWindow = new (ELeave) RBlankWindow(*ws) );
       
   158 		}
       
   159 	else
       
   160 		{
       
   161 		// Execute command and log parameters
       
   162 		INFO_PRINTF1(_L("execute new RBlankWindow()"));
       
   163 		TRAP( err,	iBlankWindow = new (ELeave) RBlankWindow() );
       
   164 		}
       
   165 
       
   166 	if ( err != KErrNone )
       
   167 		{
       
   168 		ERR_PRINTF2(KLogError, err);
       
   169 		SetError(err);
       
   170 		}
       
   171 
       
   172 	// No command output parameter to display and check
       
   173 	}
       
   174 
       
   175 
       
   176 void CT_DataBlankWindow::DoCmdConstructL(const TDesC& aSection)
       
   177 	{
       
   178 	TBool	dataOk=ETrue;
       
   179 
       
   180 	// Get test data for command input parameter(s)
       
   181 	TPtrC	parentName;
       
   182 	RWindowTreeNode*	parent=NULL;
       
   183 	if ( GetStringFromConfig(aSection, KFldParent, parentName) )
       
   184 		{
       
   185 		parent = static_cast<RWindowTreeNode*>(GetDataObjectL(parentName));
       
   186 		}
       
   187 	if ( parent==NULL )
       
   188 		{
       
   189 		dataOk=EFalse;
       
   190 		ERR_PRINTF2(KLogMissingParameter, &KFldParent);
       
   191 		SetBlockResult(EFail);
       
   192 		}
       
   193 
       
   194 	TInt	datHandle;
       
   195 	if ( !GetIntFromConfig(aSection, KFldHandle, datHandle) )
       
   196 		{
       
   197 		dataOk=EFalse;
       
   198 		ERR_PRINTF2(KLogMissingParameter, &KFldHandle);
       
   199 		SetBlockResult(EFail);
       
   200 		}
       
   201 
       
   202 	if ( dataOk )
       
   203 		{
       
   204 		// Execute command and log parameters
       
   205 		INFO_PRINTF1(_L("execute Construct(RWindowTreeNode, TUint32)"));
       
   206 		TInt	returnCode = iBlankWindow->Construct(*parent, datHandle);
       
   207 
       
   208 		// Check the command return code, if !=KErrNone then stop this command
       
   209 		if ( returnCode != KErrNone )
       
   210 			{
       
   211 			ERR_PRINTF2(KLogError, returnCode);
       
   212 			SetError(returnCode);
       
   213 			}
       
   214 
       
   215 		// No command output parameter to display and check
       
   216 		}
       
   217 	}
       
   218 
       
   219 
       
   220 void CT_DataBlankWindow::DoCmdSetColor(const TDesC& aSection)
       
   221 	{
       
   222 	// Get test data for command input parameter(s)
       
   223 	TRgb	datColor;
       
   224 	if ( GetRgbFromConfig(aSection, KFldColor, datColor) )
       
   225 		{
       
   226 		// Execute command and log parameters
       
   227 		INFO_PRINTF1(_L("execute SetColor(TRgb)"));
       
   228 		iBlankWindow->SetColor(datColor);
       
   229 		}
       
   230 	else
       
   231 		{
       
   232 		// Execute command and log parameters
       
   233 		INFO_PRINTF1(_L("execute SetColor()"));
       
   234 		iBlankWindow->SetColor();
       
   235 		}
       
   236 	}
       
   237 
       
   238 
       
   239 void CT_DataBlankWindow::DoCmdSetSize(const TDesC& aSection)
       
   240 	{
       
   241 	// Get test data for command input parameter(s)
       
   242 	TSize	datSize;
       
   243 	if ( !GetSizeFromConfig(aSection, KFldSize, datSize) )
       
   244 		{
       
   245 		ERR_PRINTF2(KLogMissingParameter, &KFldSize);
       
   246 		SetBlockResult(EFail);
       
   247 		}
       
   248 	else
       
   249 		{
       
   250 		// Execute command and log parameters
       
   251 		INFO_PRINTF1(_L("execute SetSize(TSize)"));
       
   252 		iBlankWindow->SetSize(datSize);
       
   253 		}
       
   254 	}
       
   255 
       
   256 
       
   257 void CT_DataBlankWindow::DoCmdSetExtent(const TDesC& aSection)
       
   258 	{
       
   259 	TBool	dataOk=ETrue;
       
   260 
       
   261 	// Get test data for command input parameter(s)
       
   262 	TPoint	datPoint;
       
   263 	if ( !GetPointFromConfig(aSection, KFldPoint, datPoint) )
       
   264 		{
       
   265 		dataOk=EFalse;
       
   266 		ERR_PRINTF2(KLogMissingParameter, &KFldPoint);
       
   267 		SetBlockResult(EFail);
       
   268 		}
       
   269 
       
   270 	TSize	datSize;
       
   271 	if ( !GetSizeFromConfig(aSection, KFldSize, datSize) )
       
   272 		{
       
   273 		dataOk=EFalse;
       
   274 		ERR_PRINTF2(KLogMissingParameter, &KFldSize);
       
   275 		SetBlockResult(EFail);
       
   276 		}
       
   277 
       
   278 	if ( dataOk )
       
   279 		{
       
   280 		// Execute command and log parameters
       
   281 		INFO_PRINTF1(_L("execute SetExtent(TPoint, TSize)"));
       
   282 		iBlankWindow->SetExtent(datPoint, datSize);
       
   283 		}
       
   284 	}