commonuisupport/uikon/coresrc/EIKDEBUG.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 #include <eikenv.h>
       
    19 #include <eikappui.h>
       
    20 #include <eikdebug.h>
       
    21 #include <s32file.h>
       
    22 
       
    23 #include "eikdebugprefs.h"
       
    24 
       
    25 // The dial dialog preferences UID incremented by 1
       
    26 const TUid KEikDebugPreferencesUID={0x10000167};
       
    27 
       
    28 //
       
    29 //	class CEikDebugPreferences
       
    30 //
       
    31 
       
    32 /**
       
    33  *
       
    34  * Constructs a new <code>CEikDebugPreferences</code> object.
       
    35  *
       
    36  * @since    7.0
       
    37  * @return "CEikDebugPreferences*"
       
    38  *           Pointer to the new <code>CEikDebugPreferences</code> object.
       
    39  *
       
    40  */
       
    41 EXPORT_C CEikDebugPreferences* CEikDebugPreferences::New()
       
    42 	{
       
    43 	return new CEikDebugPreferences;
       
    44 	}
       
    45 
       
    46 /**
       
    47  *
       
    48  * Constructs a new <code>CEikDebugPreferences</code> object. Object is
       
    49  * not placed on to the cleanup stack.
       
    50  *
       
    51  * @since   7.0
       
    52  * @return "CEikDebugPreferences*"
       
    53  *			 Pointer to the new <code>CEikDebugPreferences</code> object.
       
    54  */
       
    55 EXPORT_C CEikDebugPreferences* CEikDebugPreferences::NewL()
       
    56 	{
       
    57 	return new(ELeave) CEikDebugPreferences;
       
    58 	}
       
    59 
       
    60 /**
       
    61  *
       
    62  * Constructs a new <code>CEikDebugPreferences</code> object, and
       
    63  * pushes itself on to the cleanup stack.
       
    64  *
       
    65  * @since 7.0
       
    66  * @return "CEikDebugPreferences*"
       
    67  *			 Pointer to the new <code>CEikDebugPreferences</code> object.
       
    68  * 
       
    69  */
       
    70 EXPORT_C CEikDebugPreferences* CEikDebugPreferences::NewLC()
       
    71 	{
       
    72 	CEikDebugPreferences* self=new(ELeave) CEikDebugPreferences;
       
    73 	CleanupStack::PushL(self);
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 CEikDebugPreferences::CEikDebugPreferences()
       
    78 :	iFlags(0)
       
    79 	{
       
    80 	}
       
    81 
       
    82 EXPORT_C CEikDebugPreferences::~CEikDebugPreferences()
       
    83 	{
       
    84 	}
       
    85 
       
    86 /**
       
    87  * Wrapper around the <code>void CEikDebugPreferences::RestoreL(RFs& aFileServerSession)</code>.
       
    88  * Also, trap harness is created, using<code>CTrapCleanup::New()</code>, if already
       
    89  * not present for the current thread.
       
    90  * 
       
    91  * @param	  "RFs& aFileServerSession"
       
    92  *			   Current session with the File Server.
       
    93  * @return	  "TInt"
       
    94  *             Returns one of the system wide error codes.  
       
    95  * @since      7.0
       
    96  */
       
    97 EXPORT_C TInt CEikDebugPreferences::Restore(RFs& aFileServerSession)
       
    98 	{
       
    99 	CTrapCleanup* trapCleanup=NULL;
       
   100 	if (User::TrapHandler()==NULL)
       
   101 		{
       
   102 		trapCleanup=CTrapCleanup::New();
       
   103 		}
       
   104 	TRAPD(error, CEikDebugPreferences::RestoreL(aFileServerSession));
       
   105 	delete trapCleanup;
       
   106 	return error;
       
   107 	}
       
   108 
       
   109 EXPORT_C void CEikDebugPreferences::RestoreL(RFs& aFileServerSession)
       
   110 	{
       
   111 	CDictionaryStore* iniFile=CDictionaryFileStore::SystemLC(aFileServerSession);
       
   112 	if (iniFile->IsPresentL(KEikDebugPreferencesUID))
       
   113 		{
       
   114 		RDictionaryReadStream stream;
       
   115 		stream.OpenLC(*iniFile,KEikDebugPreferencesUID);
       
   116 		InternalizeL(stream);
       
   117 		CleanupStack::PopAndDestroy(&stream);
       
   118 		}
       
   119 	CleanupStack::PopAndDestroy(iniFile);
       
   120 	}
       
   121 
       
   122 EXPORT_C void CEikDebugPreferences::StoreL(RFs& aFileServerSession)
       
   123 	{
       
   124 	CDictionaryStore* iniFile=CDictionaryFileStore::SystemLC(aFileServerSession);
       
   125 	
       
   126 	RDictionaryWriteStream stream;
       
   127 	stream.AssignLC(*iniFile,KEikDebugPreferencesUID);
       
   128 	ExternalizeL(stream);
       
   129 	stream.CommitL();
       
   130 	CleanupStack::PopAndDestroy(); // stream
       
   131 
       
   132 	iniFile->CommitL();
       
   133 	CleanupStack::PopAndDestroy(); //iniFile
       
   134 	}
       
   135 
       
   136 EXPORT_C void CEikDebugPreferences::SetKeysOn(const TBool& aDebugKeysOn)
       
   137 	{
       
   138 	if(aDebugKeysOn)
       
   139 		{
       
   140 		iFlags|=EFlagDebugKeysOn;
       
   141 		}
       
   142 	else
       
   143 		{
       
   144 		iFlags&=~EFlagDebugKeysOn;
       
   145 		}
       
   146 	}
       
   147 
       
   148 EXPORT_C TBool CEikDebugPreferences::KeysOn() const
       
   149 	{
       
   150 	return iFlags & EFlagDebugKeysOn;
       
   151 	}
       
   152 
       
   153 /**
       
   154 Externalises the debug preferences object to a write stream.
       
   155 @internalComponent
       
   156 */
       
   157 EXPORT_C void CEikDebugPreferences::ExternalizeL(RWriteStream& aStream) const
       
   158 	{
       
   159 	aStream.WriteInt16L(CEikonEnv::Version().iBuild);
       
   160 	aStream.WriteUint8L(iFlags);
       
   161 	}
       
   162 
       
   163 /**
       
   164 Internalises the debug preferences object from a read stream.
       
   165 @internalComponent
       
   166 */
       
   167 EXPORT_C void CEikDebugPreferences::InternalizeL(RReadStream& aStream)
       
   168 	{
       
   169 	aStream.ReadInt16L(); // the version - this is not currently used and so is discarded
       
   170 	iFlags = aStream.ReadUint8L();
       
   171 	}
       
   172