installationservices/swidevicetools/source/swiconsole/src/cpreferences.cpp
changeset 0 ba25891c3a9e
child 21 5bddc28da627
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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 * CPreferences: This class is acts as an container for storing all the 
       
    16 * options provided in the command line.
       
    17 * @internalComponent
       
    18 *
       
    19 */
       
    20 
       
    21  
       
    22  #include "cpreferences.h"
       
    23  #include "swiconsoleerrors.h"
       
    24 
       
    25 CPreferences::CPreferences():
       
    26 				iLanguage(ELangNone),
       
    27 				iDrive(EKeyNull)
       
    28 	{
       
    29 	TInt i;
       
    30 	for(i = 0; i < EDialogTypeCount; ++i)
       
    31 		{
       
    32 		iDialogResponses[i] = ENotAnswered;
       
    33 		}
       
    34 	for(i = 0; i < EEventTypeCount; ++i)
       
    35 		{
       
    36 		iEventResponses[i] = ENotAnswered;
       
    37 		}
       
    38 	return;
       
    39 	}
       
    40 
       
    41 CPreferences* CPreferences::NewL()
       
    42 	{
       
    43 	CPreferences* self = CPreferences::NewLC();
       
    44 	CleanupStack::Pop(self);
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CPreferences* CPreferences::NewLC()
       
    49 	{
       
    50 	CPreferences* self = new (ELeave) CPreferences;
       
    51 	CleanupStack::PushL(self);
       
    52 	self->ConstructL();
       
    53 	return self;
       
    54 	}
       
    55 	
       
    56 CPreferences::~CPreferences()
       
    57 	{
       
    58 	iOptionList.Reset();
       
    59 	iPackageNameList.ResetAndDestroy();
       
    60 	iVendorNameList.ResetAndDestroy();
       
    61 	}
       
    62 
       
    63 
       
    64 // Checks whether an event is cancellable or not
       
    65 TInt8 CPreferences::GetCancellableEventOption(TEventType aEventType) const
       
    66 	{
       
    67 	__ASSERT_DEBUG(static_cast<TUint>(aEventType) < EEventTypeCount, User::Panic(KGeneralPanicString, KInvalidArgument));
       
    68 	
       
    69 	return iEventResponses[aEventType];
       
    70 	}
       
    71 
       
    72 // Retrieves the options selected for a dialog
       
    73 TInt8 CPreferences::GetDialogOption(TDialogType aDialogType) const
       
    74 	{
       
    75 	__ASSERT_DEBUG(static_cast<TUint>(aDialogType) < EDialogTypeCount, User::Panic(KGeneralPanicString, KInvalidArgument));
       
    76 	
       
    77 	return iDialogResponses[aDialogType];
       
    78 	}
       
    79 
       
    80 // Sets the response of dialogs
       
    81 void CPreferences::SetDialogOption(
       
    82 							TDialogType aDialogType, 
       
    83 							TInt8 aResponse)
       
    84 	{
       
    85 	__ASSERT_DEBUG(static_cast<TUint>(aDialogType) < EDialogTypeCount, User::Panic(KGeneralPanicString, KInvalidArgument));
       
    86 	
       
    87 	iDialogResponses[aDialogType] = aResponse;
       
    88 	return;
       
    89 	}
       
    90 
       
    91 
       
    92 // Sets the response of Cancellable event.
       
    93 void CPreferences::SetCancellableEventResponse(
       
    94 										TEventType aEventType, 
       
    95 										TInt8 aResponse)
       
    96 	{
       
    97 	__ASSERT_DEBUG(static_cast<TUint>(aEventType) < EEventTypeCount, User::Panic(KGeneralPanicString, KInvalidArgument));
       
    98 	
       
    99 	iEventResponses[aEventType] = aResponse;
       
   100 	return;
       
   101 	}
       
   102 
       
   103 void CPreferences::AddPackageNameL(const TDesC& aPackageName)
       
   104 	{
       
   105 	HBufC* ptr = aPackageName.AllocL();
       
   106 	// Ownership transfered to the list
       
   107 	iPackageNameList.Append(ptr);
       
   108 	}
       
   109 
       
   110 void CPreferences::AddVendorNameL(const TDesC& aVendorName)
       
   111 	{
       
   112 	HBufC* ptr = aVendorName.AllocL();
       
   113 	// Ownership transfered to the list
       
   114 	iVendorNameList.Append(ptr);
       
   115 	}
       
   116 
       
   117 TBool CPreferences::IsPackageNamePresent(const TDesC& aPackageName) const
       
   118 	{
       
   119 	for(TInt i = iPackageNameList.Count() - 1; i >= 0; --i)
       
   120 		{
       
   121 		if(0 == aPackageName.CompareF(iPackageNameList[i]->Des()))
       
   122 			{
       
   123 			return ETrue;
       
   124 			}
       
   125 		}
       
   126 	return EFalse;
       
   127 	}
       
   128 
       
   129 TBool CPreferences::IsVendorNamePresent(const TDesC& aVendorName) const
       
   130 	{
       
   131 	for(TInt i = iVendorNameList.Count() - 1; i >= 0; --i)
       
   132 		{
       
   133 		if(0 == aVendorName.CompareF(iVendorNameList[i]->Des()))
       
   134 			{
       
   135 			return ETrue;
       
   136 			}
       
   137 		}
       
   138 	return EFalse;
       
   139 	}
       
   140 
       
   141