ImagePrint/ImagePrintEngine/DeviceProtocols/upnpprotocolfw2/src/cjobstateevents.cpp
branchRCL_3
changeset 21 d59c248c9d36
parent 0 d11fb78c4374
equal deleted inserted replaced
20:159fc2f68139 21:d59c248c9d36
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Declares CJobStateEvents class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <upnpcons.h> 
       
    20 
       
    21 #include "cjobstateevents.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // Constructors
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CJobStateEvents::NewL
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CJobStateEvents* CJobStateEvents::NewL()
       
    32 {
       
    33 	CJobStateEvents *self = NewLC();
       
    34 	CleanupStack::Pop();	// self
       
    35 	return self;
       
    36 }
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CJobStateEvents::NewLC
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CJobStateEvents* CJobStateEvents::NewLC()
       
    44 {
       
    45 	CJobStateEvents *self = NewLC(
       
    46 		KNullDesC8(), KNullDesC8(), KNullDesC8(), KNullDesC8(),
       
    47 		KNullDesC8(), KNullDesC8(), KNullDesC8());
       
    48 	return self;
       
    49 }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CJobStateEvents::NewL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CJobStateEvents* CJobStateEvents::NewL(
       
    56 				const TDesC8& aPrinterState, const TDesC8& aPrinterStateReasons, const TDesC8& aJobIdList, 
       
    57 				const TDesC8& aJobEndState,const TDesC8& aJobMediaSheetsCompleted,
       
    58 				const TDesC8& aContentCompleteList, const TDesC8& aJobAbortState)
       
    59 {
       
    60 	CJobStateEvents *self = NewLC(
       
    61 		aPrinterState, aPrinterStateReasons, aJobIdList,aJobEndState,
       
    62 		aJobMediaSheetsCompleted, aContentCompleteList, aJobAbortState);
       
    63 	CleanupStack::Pop();	// self
       
    64 	return self;
       
    65 }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CJobStateEvents::NewLC
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CJobStateEvents* CJobStateEvents::NewLC(
       
    73 				const TDesC8& aPrinterState, const TDesC8& aPrinterStateReasons, const TDesC8& aJobIdList, 
       
    74 				const TDesC8& aJobEndState,const TDesC8& aJobMediaSheetsCompleted,
       
    75 				const TDesC8& aContentCompleteList, const TDesC8& aJobAbortState)
       
    76 {
       
    77 	CJobStateEvents *self = new (ELeave) CJobStateEvents();
       
    78 	CleanupStack::PushL(self);
       
    79 	self->ConstructL(
       
    80 		aPrinterState, aPrinterStateReasons, aJobIdList,aJobEndState,
       
    81 		aJobMediaSheetsCompleted, aContentCompleteList, aJobAbortState);
       
    82 	return self;
       
    83 }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CJobStateEvents::NewL
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 CJobStateEvents* CJobStateEvents::NewL(CJobStateEvents &a)
       
    90 {
       
    91 	CJobStateEvents *self = NewLC(a);
       
    92 	CleanupStack::Pop();	// self
       
    93 	return self;
       
    94 }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CJobStateEvents::NewLC
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CJobStateEvents* CJobStateEvents::NewLC(CJobStateEvents &a)
       
   102 {
       
   103 	CJobStateEvents *self = new (ELeave) CJobStateEvents();
       
   104 	CleanupStack::PushL(self);
       
   105 	
       
   106 	User::LeaveIfNull( a.iPrinterState );
       
   107 	User::LeaveIfNull( a.iPrinterStateReasons );
       
   108 	User::LeaveIfNull( a.iJobIdList );
       
   109 	User::LeaveIfNull( a.iJobEndState );
       
   110 	User::LeaveIfNull( a.iJobMediaSheetsCompleted );
       
   111 	User::LeaveIfNull( a.iContentCompleteList );
       
   112 	User::LeaveIfNull( a.iJobAbortState );
       
   113 	
       
   114 	self->ConstructL(
       
   115 		a.iPrinterState->Des(), a.iPrinterStateReasons->Des(), a.iJobIdList->Des(), a.iJobEndState->Des(),
       
   116 		a.iJobMediaSheetsCompleted->Des(), a.iContentCompleteList->Des(), a.iJobAbortState->Des());
       
   117 	return self;
       
   118 }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CJobStateEvents::ConstructL
       
   122 // Two-phased constructor
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CJobStateEvents::ConstructL(
       
   126 				const TDesC8& aPrinterState, const TDesC8& aPrinterStateReasons, const TDesC8& aJobIdList, 
       
   127 				const TDesC8& aJobEndState,const TDesC8& aJobMediaSheetsCompleted,
       
   128 				const TDesC8& aContentCompleteList, const TDesC8& aJobAbortState)
       
   129 {
       
   130 	Delete();
       
   131 	iPrinterState = aPrinterState.AllocL();          
       
   132 	iPrinterStateReasons = aPrinterStateReasons.AllocL();   
       
   133 	iJobIdList = aJobIdList.AllocL();             
       
   134 	iJobEndState = aJobEndState.AllocL();           
       
   135 	iJobMediaSheetsCompleted = aJobMediaSheetsCompleted.AllocL();
       
   136     iContentCompleteList = aContentCompleteList.AllocL();
       
   137     iJobAbortState = aJobAbortState.AllocL();
       
   138 }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CJobStateEvents::ConstructL
       
   142 // Two-phased constructor
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CJobStateEvents::ConstructL(CJobStateEvents &a)
       
   146 {
       
   147 	ConstructL(
       
   148 		a.iPrinterState->Des(), a.iPrinterStateReasons->Des(), a.iJobIdList->Des(), a.iJobEndState->Des(),
       
   149 		a.iJobMediaSheetsCompleted->Des(), a.iContentCompleteList->Des(), a.iJobAbortState->Des());
       
   150 }
       
   151 
       
   152 // publics
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CJobStateEvents::ChangedEventL
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 TBool CJobStateEvents::ChangedEventL(const TDesC8 &aEvent, TJobStateEvent aEnum)
       
   159 {
       
   160 	TBool changed(EFalse);
       
   161 	
       
   162 	switch( aEnum )
       
   163 	{
       
   164 		case EPrinterState:
       
   165 			if(iPrinterState)
       
   166 			{
       
   167 				if(0 != aEvent.Compare(iPrinterState->Des()))
       
   168 				{
       
   169 					delete iPrinterState;
       
   170 					iPrinterState = NULL;
       
   171 				}
       
   172 				else break;
       
   173 			}
       
   174 			iPrinterState = aEvent.AllocL();
       
   175 			changed = ETrue;
       
   176 			break;
       
   177 		case EPrinterStateReasons:
       
   178 			if(iPrinterStateReasons)
       
   179 			{
       
   180 				if(0 != aEvent.Compare(iPrinterStateReasons->Des()))
       
   181 				{
       
   182 					delete iPrinterStateReasons;
       
   183 					iPrinterStateReasons = NULL;
       
   184 				}
       
   185 				else break;
       
   186 			}
       
   187 			iPrinterStateReasons = aEvent.AllocL();
       
   188 			changed = ETrue;
       
   189 			break;
       
   190 		case EJobIdList:
       
   191 			if(iJobIdList)
       
   192 			{
       
   193 				if(0 != aEvent.Compare(iJobIdList->Des()))
       
   194 				{	
       
   195 					delete iJobIdList;
       
   196 					iJobIdList = NULL;
       
   197 				}
       
   198 				else break;
       
   199 			}
       
   200 			iJobIdList = aEvent.AllocL();
       
   201 			changed = ETrue;
       
   202 			break;
       
   203 		case EJobEndState:
       
   204 			if(iJobEndState)
       
   205 			{
       
   206 				if(0 != aEvent.Compare(iJobEndState->Des()))
       
   207 				{
       
   208 					delete iJobEndState;
       
   209 					iJobEndState = NULL;
       
   210 				}
       
   211 				else break;
       
   212 			}
       
   213 			iJobEndState = aEvent.AllocL();
       
   214 			changed = ETrue;
       
   215 			break;
       
   216 		case EJobMediaSheetsCompleted:
       
   217 			if(iJobMediaSheetsCompleted)
       
   218 			{
       
   219 			if(0 != aEvent.Compare(iJobMediaSheetsCompleted->Des()))
       
   220 				{
       
   221 					delete iJobMediaSheetsCompleted;
       
   222 					iJobMediaSheetsCompleted = NULL;
       
   223 				}
       
   224 				else break;
       
   225 			}
       
   226 			iJobMediaSheetsCompleted = aEvent.AllocL();
       
   227 			changed = ETrue;
       
   228 			break;
       
   229 		case EContentCompleteList:
       
   230 			ContentCompleteL( aEvent, changed );
       
   231 			break;
       
   232 		case EJobAbortState:
       
   233 			JobAbortStateL( aEvent, changed );
       
   234 			break;
       
   235 		default:
       
   236 			break;
       
   237 	}
       
   238 	return changed;
       
   239 }
       
   240 void CJobStateEvents::ContentCompleteL ( const TDesC8 &aEvent, TBool& aChanged )
       
   241 	{
       
   242 	if(iContentCompleteList)
       
   243 	{
       
   244 		if(0 != aEvent.Compare(iContentCompleteList->Des()))
       
   245 		{
       
   246 			delete iContentCompleteList;
       
   247 			iContentCompleteList = NULL;
       
   248 		}
       
   249 		else return;
       
   250 	}
       
   251 	iContentCompleteList = aEvent.AllocL();
       
   252 	aChanged = ETrue;
       
   253 
       
   254 	}
       
   255 
       
   256 void CJobStateEvents::JobAbortStateL ( const TDesC8 &aEvent, TBool& aChanged )
       
   257 	{
       
   258 	if(iJobAbortState)
       
   259 		{
       
   260 			if(0 != aEvent.Compare(iJobAbortState->Des()))
       
   261 			{
       
   262 				delete iJobAbortState;
       
   263 				iJobAbortState = NULL;
       
   264 			}
       
   265 			else return;
       
   266 		}
       
   267 		iJobAbortState = aEvent.AllocL();
       
   268 		aChanged = ETrue;
       
   269 	}
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CJobStateEvents::~CJobStateEvents
       
   273 // C++ destructor
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 CJobStateEvents::~CJobStateEvents()
       
   277 {
       
   278 	Delete(); 
       
   279 }	
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CJobStateEvents::Delete
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CJobStateEvents::Delete()
       
   286 {
       
   287 	if(iPrinterState)
       
   288 		delete iPrinterState;
       
   289 	iPrinterState = NULL;
       
   290 	
       
   291 	if(iPrinterStateReasons)
       
   292 		delete iPrinterStateReasons; 
       
   293 	iPrinterStateReasons = NULL;
       
   294 	
       
   295 	if(iJobIdList)
       
   296 		delete iJobIdList;
       
   297 	iJobIdList = NULL;
       
   298 	
       
   299 	if(iJobEndState)
       
   300 		delete iJobEndState; 
       
   301 	iJobEndState = NULL;
       
   302 	
       
   303 	if(iJobMediaSheetsCompleted)
       
   304 		delete iJobMediaSheetsCompleted;
       
   305 	iJobMediaSheetsCompleted = NULL;
       
   306 	
       
   307 	if(iContentCompleteList)
       
   308 		delete iContentCompleteList; 
       
   309 	iContentCompleteList = NULL;
       
   310 	
       
   311 	if(iJobAbortState)
       
   312 		delete iJobAbortState;
       
   313 	iJobAbortState = NULL;
       
   314 }	
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CJobStateEvents::InitL
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 void CJobStateEvents::InitL()
       
   321 {
       
   322 	Delete();
       
   323 	iPrinterState = KNullDesC8().AllocL();          
       
   324 	iPrinterStateReasons = KNullDesC8().AllocL();   
       
   325 	iJobIdList = KNullDesC8().AllocL();             
       
   326 	iJobEndState = KNullDesC8().AllocL();           
       
   327 	iJobMediaSheetsCompleted = KNullDesC8().AllocL();
       
   328     iContentCompleteList = KNullDesC8().AllocL();
       
   329     iJobAbortState = KNullDesC8().AllocL();
       
   330 }
       
   331 
       
   332 // operators
       
   333 
       
   334 // -----------------------------------------------------------------------------
       
   335 // CJobStateEvents::operator==
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 TBool CJobStateEvents::operator==(const CJobStateEvents& a)
       
   339 {
       
   340 	if ( iPrinterState && a.iPrinterState )
       
   341 	{
       
   342 		if(0 != a.iPrinterState->Compare(iPrinterState->Des()))
       
   343 			return EFalse;
       
   344 	}else return EFalse;
       
   345 	if( iPrinterStateReasons && a.iPrinterStateReasons )
       
   346 	{
       
   347 		if(0 != a.iPrinterStateReasons->Compare(iPrinterStateReasons->Des()))
       
   348 			return EFalse;
       
   349 	}
       
   350 	if( iJobIdList && a.iJobIdList )
       
   351 	{
       
   352 		if(0 != a.iJobIdList->Compare(iJobIdList->Des()))
       
   353 			return EFalse;
       
   354 	}else return EFalse;
       
   355 	if( iJobEndState && a.iJobEndState )
       
   356 	{
       
   357 		if(0 != a.iJobEndState->Compare(iJobEndState->Des()))
       
   358 			return EFalse;
       
   359 	}else return EFalse;
       
   360 	if( iJobMediaSheetsCompleted && a.iJobMediaSheetsCompleted )
       
   361 	{
       
   362 		if(0 != a.iJobMediaSheetsCompleted->Compare(iJobMediaSheetsCompleted->Des()))
       
   363 			return EFalse;
       
   364 	}else return EFalse;
       
   365 	if( iContentCompleteList && a.iContentCompleteList )
       
   366 	{
       
   367 		if(0 != a.iContentCompleteList->Compare(iContentCompleteList->Des()))
       
   368 			return EFalse;
       
   369 	}else return EFalse;
       
   370 	if( iJobAbortState && a.iJobAbortState )
       
   371 	{
       
   372 		if(0 != a.iJobAbortState->Compare(iJobAbortState->Des()))
       
   373 			return EFalse;
       
   374 	}else return EFalse;
       
   375 	
       
   376 	return ETrue;	
       
   377 }
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // CJobStateEvents::operator!=
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 TBool CJobStateEvents::operator!=(const CJobStateEvents& a)
       
   384 {
       
   385 	return *this == a ? EFalse : ETrue;
       
   386 }
       
   387 
       
   388 // protected
       
   389 
       
   390 // -----------------------------------------------------------------------------
       
   391 // CJobStateEvents::CJobStateEvents
       
   392 // C++ default constructor
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 CJobStateEvents::CJobStateEvents()
       
   396 {
       
   397 }	
       
   398 
       
   399 // End Of File