resourcemgmt/hwresourcesmgr/light/src/HWRMLight.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2006-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 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 #include <hwrm/hwrmenhancedlight.h>
       
    22 #include "HWRMLight.h"
       
    23 #include "HWRMtrace.h"
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CHWRMLight::NewL
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CHWRMLight* CHWRMLight::NewL()
       
    51     {
       
    52     CHWRMLight* self = NewLC();
       
    53     
       
    54     CleanupStack::Pop(self);
       
    55 
       
    56     return self;
       
    57     }
       
    58    
       
    59 // -----------------------------------------------------------------------------
       
    60 // CHWRMLight::NewLC
       
    61 // Two-phased constructor. Leaves instance to CleanupStack.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CHWRMLight* CHWRMLight::NewLC()
       
    65     {
       
    66     COMPONENT_TRACE1(_L( "HWRM LightClient - CHWRMLight::NewLC()" ) );
       
    67 
       
    68     CHWRMLight* self = new(ELeave) CHWRMLight;
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL(NULL);
       
    71     return self;
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CHWRMLight::NewL
       
    76 // Two-phased constructor for creating a Light client with callbacks.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CHWRMLight* CHWRMLight::NewL(MHWRMLightObserver* aCallback)
       
    80     {
       
    81     CHWRMLight* self = NewLC(aCallback);
       
    82     
       
    83     CleanupStack::Pop(self);
       
    84 
       
    85     return self;
       
    86     }
       
    87    
       
    88 // -----------------------------------------------------------------------------
       
    89 // CHWRMLight::NewLC
       
    90 // Two-phased constructor for creating a Light client with callbacks.
       
    91 // Leaves instance to CleanupStack.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 EXPORT_C CHWRMLight* CHWRMLight::NewLC(MHWRMLightObserver* aCallback)
       
    95     {
       
    96     COMPONENT_TRACE2(_L( "HWRM LightClient - CHWRMLight::NewLC(0x%x)" ), aCallback );
       
    97 
       
    98     // Check that reference is not NULL
       
    99     if ( !aCallback )
       
   100         {
       
   101         User::Leave(KErrBadHandle);
       
   102         }
       
   103 
       
   104     CHWRMLight* self = new(ELeave) CHWRMLight;
       
   105     CleanupStack::PushL(self);
       
   106     self->ConstructL(aCallback);
       
   107    
       
   108     return self;
       
   109     }
       
   110 
       
   111 CHWRMLight::CHWRMLight()
       
   112 	{
       
   113 	}
       
   114 
       
   115 void CHWRMLight::ConstructL(MHWRMLightObserver* aCallback)
       
   116 	{
       
   117 	// publishedAll Light API is restricted to the following light targets:
       
   118 	TInt permittedTargets( CHWRMLight::EPrimaryDisplay | CHWRMLight::EPrimaryKeyboard |
       
   119                            CHWRMLight::ESecondaryDisplay | CHWRMLight::ESecondaryKeyboard |
       
   120                            CHWRMLight::ECustomTarget1 | CHWRMLight::ECustomTarget2 |
       
   121                            CHWRMLight::ECustomTarget3 | CHWRMLight::ECustomTarget4);
       
   122          
       
   123     if (aCallback == NULL)
       
   124     	{
       
   125     	iEnhanced = CHWRMEnhancedLight::NewL(permittedTargets);	
       
   126     	}
       
   127     else
       
   128     	{		
       
   129 		iEnhanced = CHWRMEnhancedLight::NewL(reinterpret_cast<MHWRMExtendedLightObserver*>(aCallback),
       
   130 						permittedTargets);
       
   131     	}
       
   132 	}
       
   133 
       
   134 EXPORT_C CHWRMLight::~CHWRMLight()
       
   135 	{
       
   136 	delete iEnhanced;
       
   137 	}	
       
   138 
       
   139 //
       
   140 // API functions forward calls to Extended Light Client
       
   141 //
       
   142 void CHWRMLight::ReserveLightL(TInt aTarget)
       
   143 	{
       
   144 	iEnhanced->ReserveLightL(aTarget);
       
   145 	}
       
   146 
       
   147 void CHWRMLight::ReserveLightL(TInt aTarget, TBool aRestoreState, TBool aForceNoCCoeEnv)
       
   148 	{
       
   149 	iEnhanced->ReserveLightL(aTarget,aRestoreState,aForceNoCCoeEnv);
       
   150 	}
       
   151 	
       
   152 void CHWRMLight::ReleaseLight(TInt aTarget)
       
   153 	{
       
   154 	iEnhanced->ReleaseLight(aTarget);
       
   155 	}
       
   156 	
       
   157 void CHWRMLight::LightOnL(TInt aTarget)
       
   158 	{
       
   159 	iEnhanced->LightOnL(aTarget);
       
   160 	}
       
   161 	
       
   162 void CHWRMLight::LightOnL(TInt aTarget, TInt aDuration)
       
   163 	{
       
   164 	iEnhanced->LightOnL(aTarget,aDuration);
       
   165 	}
       
   166 	
       
   167 void CHWRMLight::LightOnL(TInt aTarget, TInt aDuration, TInt aIntensity, TBool aFadeIn)
       
   168 	{
       
   169 	iEnhanced->LightOnL(aTarget,aDuration,aIntensity,aFadeIn);
       
   170 	}
       
   171 		                      
       
   172 void CHWRMLight::LightBlinkL(TInt aTarget)
       
   173 	{
       
   174 	iEnhanced->LightBlinkL(aTarget);
       
   175 	}
       
   176 	
       
   177 void CHWRMLight::LightBlinkL(TInt aTarget, TInt aDuration)
       
   178 	{
       
   179 	iEnhanced->LightBlinkL(aTarget,aDuration);
       
   180 	}
       
   181 		                         		                      
       
   182 void CHWRMLight::LightBlinkL(TInt aTarget, TInt aDuration, TInt aOnDuration, TInt aOffDuration, TInt aIntensity)
       
   183 	{
       
   184 	iEnhanced->LightBlinkL(aTarget,aDuration,aOnDuration,aOffDuration,aIntensity);
       
   185 	}
       
   186 	
       
   187 void CHWRMLight::LightOffL(TInt aTarget)
       
   188 	{
       
   189 	iEnhanced->LightOffL(aTarget);
       
   190 	}
       
   191 	
       
   192 void CHWRMLight::LightOffL(TInt aTarget, TInt aDuration)
       
   193 	{
       
   194 	iEnhanced->LightOffL(aTarget,aDuration);
       
   195 	}
       
   196 		                       
       
   197 void CHWRMLight::LightOffL(TInt aTarget, TInt aDuration, TBool aFadeOut)
       
   198 	{
       
   199 	iEnhanced->LightOffL(aTarget,aDuration,aFadeOut);
       
   200 	}
       
   201 	
       
   202 CHWRMLight::TLightStatus CHWRMLight::LightStatus(TInt aTarget) const
       
   203 	{
       
   204 	return static_cast<CHWRMLight::TLightStatus> (iEnhanced->LightStatus(aTarget));
       
   205 	}
       
   206 	
       
   207 TInt CHWRMLight::SupportedTargets() const
       
   208 	{
       
   209 	return iEnhanced->SupportedTargets();
       
   210 	}
       
   211 
       
   212 EXPORT_C void CHWRMLight::SetLightColorL(TInt aTarget, THWRMLightColor& aRGB)
       
   213     {
       
   214     iEnhanced->SetLightColorL(aTarget, aRGB);
       
   215     }
       
   216 
       
   217 EXPORT_C void CHWRMLight::SetLightDefaultColorL(TInt aTarget)
       
   218     {
       
   219     iEnhanced->SetLightDefaultColorL(aTarget);
       
   220     }
       
   221 
       
   222 EXPORT_C void CHWRMLight::LightOnL(TInt aTarget, TInt aDuration, const THWRMLightColor& aRGBParam)
       
   223     {
       
   224     iEnhanced->LightOnL(aTarget, aDuration, aRGBParam);
       
   225     }
       
   226 
       
   227 EXPORT_C void CHWRMLight::LightOnL(TInt aTarget, TInt aDuration, TInt aIntensity, TBool aFadeIn, 
       
   228                      const  THWRMLightColor& aRGBParam)
       
   229     {
       
   230     iEnhanced->LightOnL(aTarget, aDuration, aIntensity, aFadeIn, aRGBParam);
       
   231     }
       
   232 
       
   233 EXPORT_C void CHWRMLight::LightBlinkL(TInt aTarget, TInt aDuration, const THWRMLightColor& aRGBParam)
       
   234     {
       
   235     iEnhanced->LightBlinkL(aTarget, aDuration, aRGBParam);
       
   236     }
       
   237 
       
   238 EXPORT_C void CHWRMLight::LightBlinkL(TInt aTarget, TInt aDuration, TInt aOnDuration, TInt aOffDuration, 
       
   239                          TInt aIntensity, const THWRMLightColor& aRGBParam)
       
   240     {
       
   241     iEnhanced->LightBlinkL(aTarget, aDuration, aOnDuration, aOffDuration, aIntensity, aRGBParam);
       
   242     }
       
   243 
       
   244 
       
   245 
       
   246 //  End of File