| 
sl@0
 | 
     1  | 
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
  | 
| 
sl@0
 | 
     2  | 
// All rights reserved.
  | 
| 
sl@0
 | 
     3  | 
// This material, including documentation and any related
  | 
| 
sl@0
 | 
     4  | 
// computer programs, is protected by copyright controlled by
  | 
| 
sl@0
 | 
     5  | 
// Nokia. All rights are reserved. Copying, including
  | 
| 
sl@0
 | 
     6  | 
// reproducing, storing, adapting or translating, any
  | 
| 
sl@0
 | 
     7  | 
// or all of this material requires the prior written consent of
  | 
| 
sl@0
 | 
     8  | 
// Nokia. This material also contains confidential
  | 
| 
sl@0
 | 
     9  | 
// information which may not be disclosed to others without the
  | 
| 
sl@0
 | 
    10  | 
// prior written consent of Nokia.
  | 
| 
sl@0
 | 
    11  | 
//
  | 
| 
sl@0
 | 
    12  | 
// Description:
  | 
| 
sl@0
 | 
    13  | 
// Render Orientation Tracking and Publication
  | 
| 
sl@0
 | 
    14  | 
// 
  | 
| 
sl@0
 | 
    15  | 
  | 
| 
sl@0
 | 
    16  | 
#include <hal.h>
  | 
| 
sl@0
 | 
    17  | 
#include <e32std.h>
  | 
| 
sl@0
 | 
    18  | 
#include "renderorientationtracker.h"
  | 
| 
sl@0
 | 
    19  | 
#include "rootwin.h"
  | 
| 
sl@0
 | 
    20  | 
#include "windowgroup.h"
  | 
| 
sl@0
 | 
    21  | 
#include "wstop.h"
  | 
| 
sl@0
 | 
    22  | 
#include "..\debuglog\DEBUGLOG.H"
  | 
| 
sl@0
 | 
    23  | 
  | 
| 
sl@0
 | 
    24  | 
extern CDebugLogBase* wsDebugLog;
  | 
| 
sl@0
 | 
    25  | 
  | 
| 
sl@0
 | 
    26  | 
/** Convert a TRenderOrientation value into a TDigitiserOrientation.
  | 
| 
sl@0
 | 
    27  | 
Note: The algorithm used makes use of the ordering of the values of the respective enums, 
  | 
| 
sl@0
 | 
    28  | 
thus this is checked for (at compile time) at the start of the function.
  | 
| 
sl@0
 | 
    29  | 
@param aWservOrientation A value from the TRenderOrientation enums.
  | 
| 
sl@0
 | 
    30  | 
@return The equivalent value from the TDigitiserOrientation enums.
  | 
| 
sl@0
 | 
    31  | 
*/
  | 
| 
sl@0
 | 
    32  | 
inline HALData::TDigitiserOrientation WservToDigitiser(TRenderOrientation aWservOrientation)
  | 
| 
sl@0
 | 
    33  | 
	{
 | 
| 
sl@0
 | 
    34  | 
	__ASSERT_COMPILE(EDisplayOrientationNormal+1 == EDisplayOrientation90CW);
  | 
| 
sl@0
 | 
    35  | 
	__ASSERT_COMPILE(EDisplayOrientationNormal+2 == EDisplayOrientation180);
  | 
| 
sl@0
 | 
    36  | 
	__ASSERT_COMPILE(EDisplayOrientationNormal+3 == EDisplayOrientation270CW);
  | 
| 
sl@0
 | 
    37  | 
	__ASSERT_COMPILE(HALData::EDigitiserOrientation_000+1 == HALData::EDigitiserOrientation_090);
  | 
| 
sl@0
 | 
    38  | 
	__ASSERT_COMPILE(HALData::EDigitiserOrientation_000+2 == HALData::EDigitiserOrientation_180);
  | 
| 
sl@0
 | 
    39  | 
	__ASSERT_COMPILE(HALData::EDigitiserOrientation_000+3 == HALData::EDigitiserOrientation_270);
  | 
| 
sl@0
 | 
    40  | 
	HALData::TDigitiserOrientation ret=static_cast<HALData::TDigitiserOrientation>
  | 
| 
sl@0
 | 
    41  | 
			(HALData::EDigitiserOrientation_000 + (aWservOrientation - EDisplayOrientationNormal));
  | 
| 
sl@0
 | 
    42  | 
	return ret;
  | 
| 
sl@0
 | 
    43  | 
	}
  | 
| 
sl@0
 | 
    44  | 
  | 
| 
sl@0
 | 
    45  | 
// Todo remove/undefine this for release
  | 
| 
sl@0
 | 
    46  | 
#define TECHVIEW_TESTMODE
  | 
| 
sl@0
 | 
    47  | 
  | 
| 
sl@0
 | 
    48  | 
CWsRenderOrienationTracker* CWsRenderOrienationTracker::NewL()
  | 
| 
sl@0
 | 
    49  | 
    {
 | 
| 
sl@0
 | 
    50  | 
    CWsRenderOrienationTracker* self = new(ELeave)CWsRenderOrienationTracker();
  | 
| 
sl@0
 | 
    51  | 
    CleanupStack::PushL(self);
  | 
| 
sl@0
 | 
    52  | 
    self->ConstructL();
  | 
| 
sl@0
 | 
    53  | 
    CleanupStack::Pop();
  | 
| 
sl@0
 | 
    54  | 
    return self;
  | 
| 
sl@0
 | 
    55  | 
    }
  | 
| 
sl@0
 | 
    56  | 
  | 
| 
sl@0
 | 
    57  | 
CWsRenderOrienationTracker::CWsRenderOrienationTracker()
  | 
| 
sl@0
 | 
    58  | 
    : CActive(CActive::EPriorityStandard),
  | 
| 
sl@0
 | 
    59  | 
      iRenderOrientationTrackingType(EDisplayOrientationNormal),
  | 
| 
sl@0
 | 
    60  | 
      iPublishedRenderOrientation(EDisplayOrientationNormal)
  | 
| 
sl@0
 | 
    61  | 
    {
 | 
| 
sl@0
 | 
    62  | 
    CActiveScheduler::Add(this);    
  | 
| 
sl@0
 | 
    63  | 
    }
  | 
| 
sl@0
 | 
    64  | 
  | 
| 
sl@0
 | 
    65  | 
void CWsRenderOrienationTracker::ConstructL()
  | 
| 
sl@0
 | 
    66  | 
    {    
 | 
| 
sl@0
 | 
    67  | 
    const TSecurityPolicy   KRenderOrientationReadSecurityPolicy(ECapability_None);
  | 
| 
sl@0
 | 
    68  | 
    const TSecurityPolicy   KRenderOrientationWriteSecurityPolicy(ECapabilityWriteDeviceData);
  | 
| 
sl@0
 | 
    69  | 
    
  | 
| 
sl@0
 | 
    70  | 
    // Define P&S Property to publish to
  | 
| 
sl@0
 | 
    71  | 
    TInt error = RProperty::Define( KRenderOrientationCategory,
  | 
| 
sl@0
 | 
    72  | 
                                    KRenderOrientationKey,
  | 
| 
sl@0
 | 
    73  | 
                                    RProperty::EInt,
  | 
| 
sl@0
 | 
    74  | 
                                    KRenderOrientationReadSecurityPolicy,
  | 
| 
sl@0
 | 
    75  | 
                                    KRenderOrientationWriteSecurityPolicy);
  | 
| 
sl@0
 | 
    76  | 
  | 
| 
sl@0
 | 
    77  | 
    // Attach the publisher for real-time publishing
  | 
| 
sl@0
 | 
    78  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
    79  | 
        error = iRenderOrientationPublisher.Attach( KRenderOrientationCategory,
  | 
| 
sl@0
 | 
    80  | 
                                                    KRenderOrientationKey);
  | 
| 
sl@0
 | 
    81  | 
  | 
| 
sl@0
 | 
    82  | 
    // Publish the initial value
  | 
| 
sl@0
 | 
    83  | 
    if(KErrNone == error)    
  | 
| 
sl@0
 | 
    84  | 
        error = DoPublishOrientation(EDisplayOrientationNormal);
  | 
| 
sl@0
 | 
    85  | 
    
  | 
| 
sl@0
 | 
    86  | 
    //Set the initial value to HAL
  | 
| 
sl@0
 | 
    87  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
    88  | 
        SetHALOrientation(EDisplayOrientationNormal);
  | 
| 
sl@0
 | 
    89  | 
    
  | 
| 
sl@0
 | 
    90  | 
    if (wsDebugLog && KErrNone!=error)
  | 
| 
sl@0
 | 
    91  | 
        {
 | 
| 
sl@0
 | 
    92  | 
        _LIT(logText,"Orientation Tracker: failed to initialise with error %d");
  | 
| 
sl@0
 | 
    93  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,logText,error);
  | 
| 
sl@0
 | 
    94  | 
        }    
  | 
| 
sl@0
 | 
    95  | 
    User::LeaveIfError(error);
  | 
| 
sl@0
 | 
    96  | 
    }
  | 
| 
sl@0
 | 
    97  | 
  | 
| 
sl@0
 | 
    98  | 
CWsRenderOrienationTracker::~CWsRenderOrienationTracker()
  | 
| 
sl@0
 | 
    99  | 
    {
 | 
| 
sl@0
 | 
   100  | 
    Cancel();
  | 
| 
sl@0
 | 
   101  | 
    iRenderOrientationPublisher.Delete(KRenderOrientationCategory, KRenderOrientationKey);
  | 
| 
sl@0
 | 
   102  | 
    iRenderOrientationPublisher.Close();
  | 
| 
sl@0
 | 
   103  | 
    }
  | 
| 
sl@0
 | 
   104  | 
  | 
| 
sl@0
 | 
   105  | 
/**
  | 
| 
sl@0
 | 
   106  | 
If the orientation of the given window group is useable updates aOrientationTrackingType with the orientation
  | 
| 
sl@0
 | 
   107  | 
  | 
| 
sl@0
 | 
   108  | 
@param Input: the window group to check
  | 
| 
sl@0
 | 
   109  | 
@param Output: the window group's orientation if usable ( otherwise unchanged )
  | 
| 
sl@0
 | 
   110  | 
@return KErrNone if the orienation is usable, KErrNotFound if the orientation is not useable, KErrNotSupported if the orientation is unknown
  | 
| 
sl@0
 | 
   111  | 
*/
  | 
| 
sl@0
 | 
   112  | 
TInt CWsRenderOrienationTracker::CheckWindowGroupOrientation(const CWsWindowGroup& aWinGroup, TRenderOrientationTrackingType& aOrientationTrackingType)
  | 
| 
sl@0
 | 
   113  | 
    {
 | 
| 
sl@0
 | 
   114  | 
    TInt error = KErrNone;
  | 
| 
sl@0
 | 
   115  | 
    TRenderOrientationTrackingType tempOrientationTrackingType = static_cast<TRenderOrientationTrackingType>(aWinGroup.WsOwner()->GetIndicatedAppOrientation());
  | 
| 
sl@0
 | 
   116  | 
    switch(tempOrientationTrackingType)
  | 
| 
sl@0
 | 
   117  | 
        {
 | 
| 
sl@0
 | 
   118  | 
        case EDisplayOrientationNormal:
  | 
| 
sl@0
 | 
   119  | 
        case EDisplayOrientation90CW:                
  | 
| 
sl@0
 | 
   120  | 
        case EDisplayOrientation180:
  | 
| 
sl@0
 | 
   121  | 
        case EDisplayOrientation270CW:            
  | 
| 
sl@0
 | 
   122  | 
        case EDisplayOrientationAuto:
  | 
| 
sl@0
 | 
   123  | 
            aOrientationTrackingType = tempOrientationTrackingType;
  | 
| 
sl@0
 | 
   124  | 
            break;
  | 
| 
sl@0
 | 
   125  | 
  | 
| 
sl@0
 | 
   126  | 
        case EDisplayOrientationIgnore:
  | 
| 
sl@0
 | 
   127  | 
            error = KErrNotFound;
  | 
| 
sl@0
 | 
   128  | 
            if (wsDebugLog)
  | 
| 
sl@0
 | 
   129  | 
                {
 | 
| 
sl@0
 | 
   130  | 
                _LIT(logText,"Orientation Tracker: winGroup %08x orientation is set to be ignored");
  | 
| 
sl@0
 | 
   131  | 
                wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText,reinterpret_cast<TInt>(&aWinGroup));
  | 
| 
sl@0
 | 
   132  | 
                }            
  | 
| 
sl@0
 | 
   133  | 
            break;
  | 
| 
sl@0
 | 
   134  | 
  | 
| 
sl@0
 | 
   135  | 
        default:
  | 
| 
sl@0
 | 
   136  | 
            error = KErrNotSupported;
  | 
| 
sl@0
 | 
   137  | 
            if (wsDebugLog)
  | 
| 
sl@0
 | 
   138  | 
                {
 | 
| 
sl@0
 | 
   139  | 
                _LIT(logText,"Orientation Tracker: winGroup %08x has undefined orientation, Error %d");                
  | 
| 
sl@0
 | 
   140  | 
                TBuf<LogTBufSize> buf;
  | 
| 
sl@0
 | 
   141  | 
                buf.Format(logText, &aWinGroup, error);                
  | 
| 
sl@0
 | 
   142  | 
                wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate,buf);
  | 
| 
sl@0
 | 
   143  | 
                }                          
  | 
| 
sl@0
 | 
   144  | 
            break;             
  | 
| 
sl@0
 | 
   145  | 
        }
  | 
| 
sl@0
 | 
   146  | 
    
  | 
| 
sl@0
 | 
   147  | 
    return error;
  | 
| 
sl@0
 | 
   148  | 
    }
  | 
| 
sl@0
 | 
   149  | 
  | 
| 
sl@0
 | 
   150  | 
/**
  | 
| 
sl@0
 | 
   151  | 
Checks that the given group window is appropriate for dictating the render orientation
  | 
| 
sl@0
 | 
   152  | 
  | 
| 
sl@0
 | 
   153  | 
@param Input:  The group window to check
  | 
| 
sl@0
 | 
   154  | 
@return ETrue is the group window is usable, else EFalse  
  | 
| 
sl@0
 | 
   155  | 
*/
  | 
| 
sl@0
 | 
   156  | 
TBool CWsRenderOrienationTracker::UseableGroupWindow(const CWsWindowGroup& aWinGroup) const
  | 
| 
sl@0
 | 
   157  | 
    {
 | 
| 
sl@0
 | 
   158  | 
#ifdef TECHVIEW_TESTMODE
  | 
| 
sl@0
 | 
   159  | 
    // for some reason IsFocusable seems to return 0 and 2, not 0 and 1
  | 
| 
sl@0
 | 
   160  | 
    return NULL!=aWinGroup.Child() &&
  | 
| 
sl@0
 | 
   161  | 
            (aWinGroup.IsFocusable() ? ETrue : EFalse);
  | 
| 
sl@0
 | 
   162  | 
#else    
  | 
| 
sl@0
 | 
   163  | 
    return (NULL!=aWinGroup.Child());     
  | 
| 
sl@0
 | 
   164  | 
#endif
  | 
| 
sl@0
 | 
   165  | 
    }
  | 
| 
sl@0
 | 
   166  | 
  | 
| 
sl@0
 | 
   167  | 
/**
  | 
| 
sl@0
 | 
   168  | 
Finds the topmost usable windowgroup which has a usable orientation, and outputs that orientation
  | 
| 
sl@0
 | 
   169  | 
  | 
| 
sl@0
 | 
   170  | 
@param Output: The current render orientation
  | 
| 
sl@0
 | 
   171  | 
@return KErrNone if successful, KErrNotFound if the focus window group is not usable, KErrNotSupported if an invalid orientation is found
  | 
| 
sl@0
 | 
   172  | 
*/
  | 
| 
sl@0
 | 
   173  | 
TInt CWsRenderOrienationTracker::GetFocusWindowOrientation(TRenderOrientationTrackingType& aOrientationTrackingType)
  | 
| 
sl@0
 | 
   174  | 
    {
 | 
| 
sl@0
 | 
   175  | 
    TInt error = KErrNone;
  | 
| 
sl@0
 | 
   176  | 
    CWsWindowGroup* focusWinGroup = CWsTop::FocusWindowGroup();    
  | 
| 
sl@0
 | 
   177  | 
    if(!focusWinGroup)
  | 
| 
sl@0
 | 
   178  | 
        {
 | 
| 
sl@0
 | 
   179  | 
        if(wsDebugLog)
  | 
| 
sl@0
 | 
   180  | 
            {
 | 
| 
sl@0
 | 
   181  | 
            _LIT(logText,"Orientation Tracker: focusWinGroup not found");
  | 
| 
sl@0
 | 
   182  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText);
  | 
| 
sl@0
 | 
   183  | 
            }
  | 
| 
sl@0
 | 
   184  | 
        error = KErrNotFound;
  | 
| 
sl@0
 | 
   185  | 
        }
  | 
| 
sl@0
 | 
   186  | 
    else
  | 
| 
sl@0
 | 
   187  | 
        {
 | 
| 
sl@0
 | 
   188  | 
        error = CheckWindowGroupOrientation(*focusWinGroup, aOrientationTrackingType);
  | 
| 
sl@0
 | 
   189  | 
        }
  | 
| 
sl@0
 | 
   190  | 
    return error;
  | 
| 
sl@0
 | 
   191  | 
    }
  | 
| 
sl@0
 | 
   192  | 
  | 
| 
sl@0
 | 
   193  | 
/**
  | 
| 
sl@0
 | 
   194  | 
Finds the topmost usable windowgroup which has a usable orientation, and outputs that orientation
  | 
| 
sl@0
 | 
   195  | 
  | 
| 
sl@0
 | 
   196  | 
@param Output: The current render orientation
  | 
| 
sl@0
 | 
   197  | 
@return KErrNone if successful, KErrNotSupported if an invalid orientation is found
  | 
| 
sl@0
 | 
   198  | 
*/
  | 
| 
sl@0
 | 
   199  | 
TInt CWsRenderOrienationTracker::FindOrientationFromWindowTree(TRenderOrientationTrackingType& aOrientationTrackingType)
  | 
| 
sl@0
 | 
   200  | 
    {
 | 
| 
sl@0
 | 
   201  | 
    TInt error = KErrNone;
  | 
| 
sl@0
 | 
   202  | 
    TRenderOrientationTrackingType tempOrientationTrackingType = iRenderOrientationTrackingType;
  | 
| 
sl@0
 | 
   203  | 
    CWsRootWindow* rootWin = CWsTop::CurrentFocusScreen()->RootWindow();
  | 
| 
sl@0
 | 
   204  | 
    TBool finished = EFalse;
  | 
| 
sl@0
 | 
   205  | 
    for(CWsWindowGroup* winGroup = rootWin->Child(); !finished && NULL != winGroup; winGroup = winGroup->NextSibling())
  | 
| 
sl@0
 | 
   206  | 
        {
 | 
| 
sl@0
 | 
   207  | 
        if (wsDebugLog)
  | 
| 
sl@0
 | 
   208  | 
            {
 | 
| 
sl@0
 | 
   209  | 
            _LIT(logText,"Orientation Tracker: winGroup %08x has priority %d, Orientation %d, Focusable %d, Child %08x");
  | 
| 
sl@0
 | 
   210  | 
            TBuf<LogTBufSize> buf;
  | 
| 
sl@0
 | 
   211  | 
            buf.Format(logText, winGroup, winGroup->OrdinalPriority(), winGroup->WsOwner()->GetIndicatedAppOrientation(),
  | 
| 
sl@0
 | 
   212  | 
                    winGroup->IsFocusable()?ETrue:EFalse, winGroup->Child());                                
  | 
| 
sl@0
 | 
   213  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,buf);
  | 
| 
sl@0
 | 
   214  | 
            }               
  | 
| 
sl@0
 | 
   215  | 
        // winGroup is a higher priority ordinal, so see if it has an orientation that can be used
  | 
| 
sl@0
 | 
   216  | 
        // although we're only interested in window groups with child windows otherwise nothing is visible anyway        
  | 
| 
sl@0
 | 
   217  | 
        if(UseableGroupWindow(*winGroup))
  | 
| 
sl@0
 | 
   218  | 
            {
 | 
| 
sl@0
 | 
   219  | 
            error = CheckWindowGroupOrientation(*winGroup, tempOrientationTrackingType);
  | 
| 
sl@0
 | 
   220  | 
            switch(error)
  | 
| 
sl@0
 | 
   221  | 
                {
 | 
| 
sl@0
 | 
   222  | 
                case KErrNone:
  | 
| 
sl@0
 | 
   223  | 
                    {
 | 
| 
sl@0
 | 
   224  | 
                    // List is in order, so just find the first one
  | 
| 
sl@0
 | 
   225  | 
                    if (wsDebugLog)
  | 
| 
sl@0
 | 
   226  | 
                        {
 | 
| 
sl@0
 | 
   227  | 
                        _LIT(logText,"Orientation Tracker: Found winGroup %08x with Orientation %d");
  | 
| 
sl@0
 | 
   228  | 
                        TBuf<LogTBufSize> buf;
  | 
| 
sl@0
 | 
   229  | 
                        buf.Format(logText, winGroup, winGroup->WsOwner()->GetIndicatedAppOrientation());                    
  | 
| 
sl@0
 | 
   230  | 
                        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,buf);
  | 
| 
sl@0
 | 
   231  | 
                        }
  | 
| 
sl@0
 | 
   232  | 
                    finished = ETrue;
  | 
| 
sl@0
 | 
   233  | 
                    break;
  | 
| 
sl@0
 | 
   234  | 
                    }
  | 
| 
sl@0
 | 
   235  | 
  | 
| 
sl@0
 | 
   236  | 
                case KErrNotFound:
  | 
| 
sl@0
 | 
   237  | 
                    // so keep searching
  | 
| 
sl@0
 | 
   238  | 
                    break;                    
  | 
| 
sl@0
 | 
   239  | 
                    
  | 
| 
sl@0
 | 
   240  | 
                case KErrNotSupported:
  | 
| 
sl@0
 | 
   241  | 
                default:
  | 
| 
sl@0
 | 
   242  | 
                    finished = ETrue;
  | 
| 
sl@0
 | 
   243  | 
                    break;
  | 
| 
sl@0
 | 
   244  | 
                    
  | 
| 
sl@0
 | 
   245  | 
                }
  | 
| 
sl@0
 | 
   246  | 
            
  | 
| 
sl@0
 | 
   247  | 
            }
  | 
| 
sl@0
 | 
   248  | 
        }
  | 
| 
sl@0
 | 
   249  | 
    // Safe even in error code as won't have been changed by CheckWindowGroupOrientation
  | 
| 
sl@0
 | 
   250  | 
    aOrientationTrackingType = tempOrientationTrackingType;
  | 
| 
sl@0
 | 
   251  | 
    
  | 
| 
sl@0
 | 
   252  | 
    return error;
  | 
| 
sl@0
 | 
   253  | 
    }
  | 
| 
sl@0
 | 
   254  | 
  | 
| 
sl@0
 | 
   255  | 
/**
  | 
| 
sl@0
 | 
   256  | 
First checks to see if the focus window group has a usable orientation, if so that is output.
  | 
| 
sl@0
 | 
   257  | 
Otherwise, finds the topmost usable windowgroup which has a usable orientation, and outputs that
  | 
| 
sl@0
 | 
   258  | 
  | 
| 
sl@0
 | 
   259  | 
@param Output: The current render orientation
  | 
| 
sl@0
 | 
   260  | 
@return KErrNone if successful, KErrNotSupported if an invalid orientation is found 
  | 
| 
sl@0
 | 
   261  | 
 */
  | 
| 
sl@0
 | 
   262  | 
TInt CWsRenderOrienationTracker::GetIndicatedOrientation(TRenderOrientationTrackingType& aOrientationTrackingType)
  | 
| 
sl@0
 | 
   263  | 
    {
 | 
| 
sl@0
 | 
   264  | 
    // First check the focus window group
  | 
| 
sl@0
 | 
   265  | 
    TInt error = GetFocusWindowOrientation(aOrientationTrackingType);
  | 
| 
sl@0
 | 
   266  | 
  | 
| 
sl@0
 | 
   267  | 
    // Don't look for another window if the focus window is usable
  | 
| 
sl@0
 | 
   268  | 
    // or if an error has occured, then don't change current orientation
  | 
| 
sl@0
 | 
   269  | 
    switch(error)
  | 
| 
sl@0
 | 
   270  | 
        {
 | 
| 
sl@0
 | 
   271  | 
        case KErrNone:
  | 
| 
sl@0
 | 
   272  | 
            {
 | 
| 
sl@0
 | 
   273  | 
            if(wsDebugLog)
  | 
| 
sl@0
 | 
   274  | 
                {
 | 
| 
sl@0
 | 
   275  | 
                _LIT(logText,"Orientation Tracker: Using focus window %08x for orientation");
  | 
| 
sl@0
 | 
   276  | 
                wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText,reinterpret_cast<TInt>(CWsTop::FocusWindowGroup()));
  | 
| 
sl@0
 | 
   277  | 
                }
  | 
| 
sl@0
 | 
   278  | 
            break;
  | 
| 
sl@0
 | 
   279  | 
            }
  | 
| 
sl@0
 | 
   280  | 
        
  | 
| 
sl@0
 | 
   281  | 
        case KErrNotFound:
  | 
| 
sl@0
 | 
   282  | 
            {
 | 
| 
sl@0
 | 
   283  | 
            // Can't use focus window group, so find the topmost windowgroup with a valid orientation
  | 
| 
sl@0
 | 
   284  | 
            error = FindOrientationFromWindowTree(aOrientationTrackingType);
  | 
| 
sl@0
 | 
   285  | 
            break;
  | 
| 
sl@0
 | 
   286  | 
            }
  | 
| 
sl@0
 | 
   287  | 
            
  | 
| 
sl@0
 | 
   288  | 
        default:
  | 
| 
sl@0
 | 
   289  | 
            // Unrecoverable error, abort and leave published orientation unchanged
  | 
| 
sl@0
 | 
   290  | 
            break;
  | 
| 
sl@0
 | 
   291  | 
        }
  | 
| 
sl@0
 | 
   292  | 
    
  | 
| 
sl@0
 | 
   293  | 
    return error;
  | 
| 
sl@0
 | 
   294  | 
    }
  | 
| 
sl@0
 | 
   295  | 
  | 
| 
sl@0
 | 
   296  | 
/**
  | 
| 
sl@0
 | 
   297  | 
Checks to see if the render orientation has changed, and publishes any new orientaion
  | 
| 
sl@0
 | 
   298  | 
via publish and subscribe
  | 
| 
sl@0
 | 
   299  | 
  | 
| 
sl@0
 | 
   300  | 
@see KRenderOrientationCategory
  | 
| 
sl@0
 | 
   301  | 
@see KRenderOrientationKey 
  | 
| 
sl@0
 | 
   302  | 
*/
  | 
| 
sl@0
 | 
   303  | 
void CWsRenderOrienationTracker::CheckRenderOrientation()
  | 
| 
sl@0
 | 
   304  | 
    {
 | 
| 
sl@0
 | 
   305  | 
    TRenderOrientationTrackingType newOrientationTrackingType = iRenderOrientationTrackingType;    
  | 
| 
sl@0
 | 
   306  | 
    TInt error = GetIndicatedOrientation(newOrientationTrackingType);
  | 
| 
sl@0
 | 
   307  | 
  | 
| 
sl@0
 | 
   308  | 
    // if the tracking type has changed...
  | 
| 
sl@0
 | 
   309  | 
    if(KErrNone == error && iRenderOrientationTrackingType != newOrientationTrackingType)
  | 
| 
sl@0
 | 
   310  | 
        {
 | 
| 
sl@0
 | 
   311  | 
        if(EDisplayOrientationAuto == iRenderOrientationTrackingType)
  | 
| 
sl@0
 | 
   312  | 
            {
 | 
| 
sl@0
 | 
   313  | 
            // change from auto type, so we need to cancel request for updates from the theme server        
  | 
| 
sl@0
 | 
   314  | 
            Cancel();
  | 
| 
sl@0
 | 
   315  | 
            }    
  | 
| 
sl@0
 | 
   316  | 
        iRenderOrientationTrackingType = newOrientationTrackingType;
  | 
| 
sl@0
 | 
   317  | 
        if(EDisplayOrientationAuto == iRenderOrientationTrackingType)
  | 
| 
sl@0
 | 
   318  | 
            {
 | 
| 
sl@0
 | 
   319  | 
            // Change to auto type, so we need to request updates from the theme server            
  | 
| 
sl@0
 | 
   320  | 
            // Attach to the Theme server to get orientation change updates
  | 
| 
sl@0
 | 
   321  | 
            error = iThemeOrientationProperty.Attach( KThemeOrientationCategory, KThemeOrientationKey );
  | 
| 
sl@0
 | 
   322  | 
            if (wsDebugLog)
  | 
| 
sl@0
 | 
   323  | 
                {
 | 
| 
sl@0
 | 
   324  | 
                if(KErrNone == error)
  | 
| 
sl@0
 | 
   325  | 
                    {
 | 
| 
sl@0
 | 
   326  | 
                    // Information Log
  | 
| 
sl@0
 | 
   327  | 
                    _LIT(logText,"Orientation Tracker: Attached to theme orientation property");
  | 
| 
sl@0
 | 
   328  | 
                    wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText);
  | 
| 
sl@0
 | 
   329  | 
                    }
  | 
| 
sl@0
 | 
   330  | 
                else
  | 
| 
sl@0
 | 
   331  | 
                    {
 | 
| 
sl@0
 | 
   332  | 
                    // Error Log
  | 
| 
sl@0
 | 
   333  | 
                    _LIT(logText,"Orientation Tracker: Error %d attaching to theme orientation property");
  | 
| 
sl@0
 | 
   334  | 
                    wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate,logText, error);                
  | 
| 
sl@0
 | 
   335  | 
                    }
  | 
| 
sl@0
 | 
   336  | 
                }              
  | 
| 
sl@0
 | 
   337  | 
            
  | 
| 
sl@0
 | 
   338  | 
            RequestDeviceOrientationNotification();
  | 
| 
sl@0
 | 
   339  | 
            }
  | 
| 
sl@0
 | 
   340  | 
        // See if the  has changed, and publish if it has        
  | 
| 
sl@0
 | 
   341  | 
        error = DoOrientationTracking();
  | 
| 
sl@0
 | 
   342  | 
        }
  | 
| 
sl@0
 | 
   343  | 
  | 
| 
sl@0
 | 
   344  | 
    if (wsDebugLog && KErrNone != error)
  | 
| 
sl@0
 | 
   345  | 
        {
 | 
| 
sl@0
 | 
   346  | 
        _LIT(logText,"Orientation Tracker: Error %d Checking Render Orientation");
  | 
| 
sl@0
 | 
   347  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,logText, error);
  | 
| 
sl@0
 | 
   348  | 
        }  
  | 
| 
sl@0
 | 
   349  | 
    }
  | 
| 
sl@0
 | 
   350  | 
  | 
| 
sl@0
 | 
   351  | 
/**
  | 
| 
sl@0
 | 
   352  | 
Requests notification of change of the theme server orientation
  | 
| 
sl@0
 | 
   353  | 
  | 
| 
sl@0
 | 
   354  | 
@Pre iThemeOrientationProperty has had Attach called on it
  | 
| 
sl@0
 | 
   355  | 
*/
  | 
| 
sl@0
 | 
   356  | 
void CWsRenderOrienationTracker::RequestDeviceOrientationNotification()
  | 
| 
sl@0
 | 
   357  | 
    {
 | 
| 
sl@0
 | 
   358  | 
    if(!IsActive())
  | 
| 
sl@0
 | 
   359  | 
        {
 | 
| 
sl@0
 | 
   360  | 
        if (wsDebugLog)
  | 
| 
sl@0
 | 
   361  | 
            {
 | 
| 
sl@0
 | 
   362  | 
            _LIT(logText,"Orientation Tracker: Subscribing to theme orientation property");
  | 
| 
sl@0
 | 
   363  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText);
  | 
| 
sl@0
 | 
   364  | 
            }          
  | 
| 
sl@0
 | 
   365  | 
        // Request for Theme Server Orientation P&S  
  | 
| 
sl@0
 | 
   366  | 
        iThemeOrientationProperty.Subscribe(iStatus);        
  | 
| 
sl@0
 | 
   367  | 
        SetActive();
  | 
| 
sl@0
 | 
   368  | 
        }
  | 
| 
sl@0
 | 
   369  | 
    }
  | 
| 
sl@0
 | 
   370  | 
  | 
| 
sl@0
 | 
   371  | 
/**
  | 
| 
sl@0
 | 
   372  | 
Cancels and closes (detaches) from the theme orientation publish and subscribe
  | 
| 
sl@0
 | 
   373  | 
*/
  | 
| 
sl@0
 | 
   374  | 
void CWsRenderOrienationTracker::CancelDeviceOrientationNotification()
  | 
| 
sl@0
 | 
   375  | 
    {
 | 
| 
sl@0
 | 
   376  | 
    // Cancel Request for Theme Server Orientation P&S  
  | 
| 
sl@0
 | 
   377  | 
    iThemeOrientationProperty.Cancel();
  | 
| 
sl@0
 | 
   378  | 
    iThemeOrientationProperty.Close();
  | 
| 
sl@0
 | 
   379  | 
    
  | 
| 
sl@0
 | 
   380  | 
    if (wsDebugLog)
  | 
| 
sl@0
 | 
   381  | 
        {
 | 
| 
sl@0
 | 
   382  | 
        _LIT(logText,"Orientation Tracker: Cancelled/closed theme orientation property");
  | 
| 
sl@0
 | 
   383  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,logText);
  | 
| 
sl@0
 | 
   384  | 
        }      
  | 
| 
sl@0
 | 
   385  | 
    }
  | 
| 
sl@0
 | 
   386  | 
  | 
| 
sl@0
 | 
   387  | 
/**
  | 
| 
sl@0
 | 
   388  | 
Called when the theme servers orientation has changed.
  | 
| 
sl@0
 | 
   389  | 
Re-requests unless cancelled
  | 
| 
sl@0
 | 
   390  | 
*/
  | 
| 
sl@0
 | 
   391  | 
void CWsRenderOrienationTracker::RunL()
  | 
| 
sl@0
 | 
   392  | 
    {
 | 
| 
sl@0
 | 
   393  | 
    TInt error = iStatus.Int();
  | 
| 
sl@0
 | 
   394  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
   395  | 
        {
 | 
| 
sl@0
 | 
   396  | 
        // Re-request
  | 
| 
sl@0
 | 
   397  | 
        RequestDeviceOrientationNotification();
  | 
| 
sl@0
 | 
   398  | 
    
  | 
| 
sl@0
 | 
   399  | 
        TInt error = DoOrientationTracking();
  | 
| 
sl@0
 | 
   400  | 
        if (wsDebugLog && KErrNone != error)
  | 
| 
sl@0
 | 
   401  | 
            {
 | 
| 
sl@0
 | 
   402  | 
            _LIT(logText,"Orientation Tracker: Error %d processing theme orientation property");
  | 
| 
sl@0
 | 
   403  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,logText, error);
  | 
| 
sl@0
 | 
   404  | 
            }         
  | 
| 
sl@0
 | 
   405  | 
        }
  | 
| 
sl@0
 | 
   406  | 
    else if (wsDebugLog && KErrCancel != error)
  | 
| 
sl@0
 | 
   407  | 
        {
 | 
| 
sl@0
 | 
   408  | 
        _LIT(logText,"Orientation Tracker: Error %d from theme orientation property, not resubscribed");
  | 
| 
sl@0
 | 
   409  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,logText, error);     
  | 
| 
sl@0
 | 
   410  | 
        }
  | 
| 
sl@0
 | 
   411  | 
    }
  | 
| 
sl@0
 | 
   412  | 
  | 
| 
sl@0
 | 
   413  | 
/**
  | 
| 
sl@0
 | 
   414  | 
Cancels the request for notification for changes to theme orientation
  | 
| 
sl@0
 | 
   415  | 
*/
  | 
| 
sl@0
 | 
   416  | 
void CWsRenderOrienationTracker::DoCancel()
  | 
| 
sl@0
 | 
   417  | 
    {
 | 
| 
sl@0
 | 
   418  | 
    CancelDeviceOrientationNotification();
  | 
| 
sl@0
 | 
   419  | 
    }
  | 
| 
sl@0
 | 
   420  | 
  | 
| 
sl@0
 | 
   421  | 
/**
  | 
| 
sl@0
 | 
   422  | 
Gets the orientation published from theme server
  | 
| 
sl@0
 | 
   423  | 
  | 
| 
sl@0
 | 
   424  | 
@param Output: the theme server orientation
  | 
| 
sl@0
 | 
   425  | 
@return KErrNone if successful, KErrNotSupported if the theme server returns an unknown orientation, else any of the system wide error codes 
  | 
| 
sl@0
 | 
   426  | 
*/
  | 
| 
sl@0
 | 
   427  | 
TInt CWsRenderOrienationTracker::GetThemeOrientation(TRenderOrientation& aThemeOrientation)
  | 
| 
sl@0
 | 
   428  | 
    { 
 | 
| 
sl@0
 | 
   429  | 
    TInt themeOrientation=EDisplayOrientationNormal;
  | 
| 
sl@0
 | 
   430  | 
    TInt error = iThemeOrientationProperty.Get(themeOrientation);
  | 
| 
sl@0
 | 
   431  | 
    if(wsDebugLog && KErrNone != error)
  | 
| 
sl@0
 | 
   432  | 
        {
 | 
| 
sl@0
 | 
   433  | 
        _LIT(logText,"Orientation Tracker: Error %d getting theme orientation property");
  | 
| 
sl@0
 | 
   434  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate,logText, error);     
  | 
| 
sl@0
 | 
   435  | 
        }
  | 
| 
sl@0
 | 
   436  | 
    
  | 
| 
sl@0
 | 
   437  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
   438  | 
        {
 | 
| 
sl@0
 | 
   439  | 
        // Translate the received orientation    
  | 
| 
sl@0
 | 
   440  | 
        switch(themeOrientation)
  | 
| 
sl@0
 | 
   441  | 
            {           
 | 
| 
sl@0
 | 
   442  | 
            case EDisplayOrientationNormal:
  | 
| 
sl@0
 | 
   443  | 
            case EDisplayOrientation90CW:
  | 
| 
sl@0
 | 
   444  | 
            case EDisplayOrientation180:
  | 
| 
sl@0
 | 
   445  | 
            case EDisplayOrientation270CW:
  | 
| 
sl@0
 | 
   446  | 
                // only update if orientation is supported
  | 
| 
sl@0
 | 
   447  | 
                aThemeOrientation = static_cast<TRenderOrientation>(themeOrientation);
  | 
| 
sl@0
 | 
   448  | 
                break;
  | 
| 
sl@0
 | 
   449  | 
            
  | 
| 
sl@0
 | 
   450  | 
            default:
  | 
| 
sl@0
 | 
   451  | 
                error = KErrNotSupported;
  | 
| 
sl@0
 | 
   452  | 
                if (wsDebugLog)
  | 
| 
sl@0
 | 
   453  | 
                    {
 | 
| 
sl@0
 | 
   454  | 
                    _LIT(logText,"Orientation Tracker: Unsupported orientation %d from theme orientation property, Error %d");
  | 
| 
sl@0
 | 
   455  | 
                    TBuf<LogTBufSize> buf;
  | 
| 
sl@0
 | 
   456  | 
                    buf.Format(logText, themeOrientation, error);
  | 
| 
sl@0
 | 
   457  | 
                    wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate,buf);     
  | 
| 
sl@0
 | 
   458  | 
                    }                
  | 
| 
sl@0
 | 
   459  | 
                break;
  | 
| 
sl@0
 | 
   460  | 
            }
  | 
| 
sl@0
 | 
   461  | 
        }
  | 
| 
sl@0
 | 
   462  | 
    return error;  
  | 
| 
sl@0
 | 
   463  | 
    }
  | 
| 
sl@0
 | 
   464  | 
  | 
| 
sl@0
 | 
   465  | 
/**
  | 
| 
sl@0
 | 
   466  | 
Processes the indicated orientation into an actual orientation
  | 
| 
sl@0
 | 
   467  | 
  | 
| 
sl@0
 | 
   468  | 
@return KErrNone for success, KErrNotSupported if the orientation is unknown, else any of the system wide error codes
  | 
| 
sl@0
 | 
   469  | 
*/
  | 
| 
sl@0
 | 
   470  | 
TInt CWsRenderOrienationTracker::DoOrientationTracking()
  | 
| 
sl@0
 | 
   471  | 
    {
 | 
| 
sl@0
 | 
   472  | 
    TInt error = KErrNone;
  | 
| 
sl@0
 | 
   473  | 
    TRenderOrientation newDeviceOrientation;
  | 
| 
sl@0
 | 
   474  | 
    switch(iRenderOrientationTrackingType)
  | 
| 
sl@0
 | 
   475  | 
        {
 | 
| 
sl@0
 | 
   476  | 
        case EDisplayOrientationNormal:
  | 
| 
sl@0
 | 
   477  | 
        case EDisplayOrientation90CW:                
  | 
| 
sl@0
 | 
   478  | 
        case EDisplayOrientation180:
  | 
| 
sl@0
 | 
   479  | 
        case EDisplayOrientation270CW:            
  | 
| 
sl@0
 | 
   480  | 
            newDeviceOrientation = iRenderOrientationTrackingType;
  | 
| 
sl@0
 | 
   481  | 
            break;
  | 
| 
sl@0
 | 
   482  | 
            
  | 
| 
sl@0
 | 
   483  | 
        case EDisplayOrientationAuto:
  | 
| 
sl@0
 | 
   484  | 
            error = GetThemeOrientation(newDeviceOrientation);
  | 
| 
sl@0
 | 
   485  | 
            break;
  | 
| 
sl@0
 | 
   486  | 
                      
  | 
| 
sl@0
 | 
   487  | 
        default:
  | 
| 
sl@0
 | 
   488  | 
            error = KErrNotSupported;
  | 
| 
sl@0
 | 
   489  | 
            if (wsDebugLog)
  | 
| 
sl@0
 | 
   490  | 
                {
 | 
| 
sl@0
 | 
   491  | 
                _LIT(logText,"Orientation Tracker: Unsupported orientation tracking type %d, error %d");
  | 
| 
sl@0
 | 
   492  | 
                TBuf<LogTBufSize> buf;
  | 
| 
sl@0
 | 
   493  | 
                buf.Format(logText, iRenderOrientationTrackingType, error);
  | 
| 
sl@0
 | 
   494  | 
                wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate,buf);     
  | 
| 
sl@0
 | 
   495  | 
                }              
  | 
| 
sl@0
 | 
   496  | 
            break;            
  | 
| 
sl@0
 | 
   497  | 
        }    
  | 
| 
sl@0
 | 
   498  | 
  | 
| 
sl@0
 | 
   499  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
   500  | 
        {
 | 
| 
sl@0
 | 
   501  | 
        error = PublishOrientation(newDeviceOrientation);
  | 
| 
sl@0
 | 
   502  | 
        }
  | 
| 
sl@0
 | 
   503  | 
    
  | 
| 
sl@0
 | 
   504  | 
    return error;
  | 
| 
sl@0
 | 
   505  | 
    }
  | 
| 
sl@0
 | 
   506  | 
  | 
| 
sl@0
 | 
   507  | 
/**
  | 
| 
sl@0
 | 
   508  | 
Publishes the given value
  | 
| 
sl@0
 | 
   509  | 
  | 
| 
sl@0
 | 
   510  | 
@param The render orientation to publish
  | 
| 
sl@0
 | 
   511  | 
@return KErrNone for success, else any of the system wide erro codes
  | 
| 
sl@0
 | 
   512  | 
*/
  | 
| 
sl@0
 | 
   513  | 
TInt CWsRenderOrienationTracker::DoPublishOrientation(const TRenderOrientation aRenderOrientation)
  | 
| 
sl@0
 | 
   514  | 
    {
 | 
| 
sl@0
 | 
   515  | 
    TInt error = iRenderOrientationPublisher.Set(aRenderOrientation);
  | 
| 
sl@0
 | 
   516  | 
         
  | 
| 
sl@0
 | 
   517  | 
    // if it's published OK, then remember the newly published value
  | 
| 
sl@0
 | 
   518  | 
    if(KErrNone == error)
  | 
| 
sl@0
 | 
   519  | 
        {
 | 
| 
sl@0
 | 
   520  | 
        iPublishedRenderOrientation = aRenderOrientation;
  | 
| 
sl@0
 | 
   521  | 
        if(wsDebugLog)
  | 
| 
sl@0
 | 
   522  | 
            {
 | 
| 
sl@0
 | 
   523  | 
            _LIT(logText,"Orientation Tracker: Published render orientation %d");
  | 
| 
sl@0
 | 
   524  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, logText, aRenderOrientation);
  | 
| 
sl@0
 | 
   525  | 
            }
  | 
| 
sl@0
 | 
   526  | 
        }
  | 
| 
sl@0
 | 
   527  | 
    else if(wsDebugLog)
  | 
| 
sl@0
 | 
   528  | 
        {
 | 
| 
sl@0
 | 
   529  | 
        _LIT(logText,"Orientation Tracker: Error %d setting render orientation property");
  | 
| 
sl@0
 | 
   530  | 
        wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate, logText, error);                   
  | 
| 
sl@0
 | 
   531  | 
        }
  | 
| 
sl@0
 | 
   532  | 
    return error;
  | 
| 
sl@0
 | 
   533  | 
    }
  | 
| 
sl@0
 | 
   534  | 
  | 
| 
sl@0
 | 
   535  | 
void CWsRenderOrienationTracker::SetHALOrientation(const TRenderOrientation aRenderOrientation)
  | 
| 
sl@0
 | 
   536  | 
    {
 | 
| 
sl@0
 | 
   537  | 
    // If the render orientation is EDisplayOrientationAuto then don't update HAL
  | 
| 
sl@0
 | 
   538  | 
    // The application and HAL should always have the same state for the orientation.
  | 
| 
sl@0
 | 
   539  | 
    if(EDisplayOrientationAuto != aRenderOrientation)
  | 
| 
sl@0
 | 
   540  | 
        {
 | 
| 
sl@0
 | 
   541  | 
        TInt error = HAL::Set(CWsTop::CurrentFocusScreen()->ScreenNumber(), HALData::EDigitiserOrientation, WservToDigitiser(iPublishedRenderOrientation));
  | 
| 
sl@0
 | 
   542  | 
        //Just log the error if there is one.
  | 
| 
sl@0
 | 
   543  | 
        if(wsDebugLog && error != KErrNone)
  | 
| 
sl@0
 | 
   544  | 
            {
 | 
| 
sl@0
 | 
   545  | 
            _LIT(logText,"Orientation Tracker: Error %d setting digitiser orientation");
  | 
| 
sl@0
 | 
   546  | 
            wsDebugLog->MiscMessage(CDebugLogBase::ELogIntermediate, logText, error);           
  | 
| 
sl@0
 | 
   547  | 
            } 
  | 
| 
sl@0
 | 
   548  | 
        }
  | 
| 
sl@0
 | 
   549  | 
    }
  | 
| 
sl@0
 | 
   550  | 
  | 
| 
sl@0
 | 
   551  | 
/**
  | 
| 
sl@0
 | 
   552  | 
If the current orientation differs from the previously published value then publishes the current value
  | 
| 
sl@0
 | 
   553  | 
  | 
| 
sl@0
 | 
   554  | 
@param The render orientation to check and publish
  | 
| 
sl@0
 | 
   555  | 
@return KErrNone for success, else any of the system wide erro codes
  | 
| 
sl@0
 | 
   556  | 
*/
  | 
| 
sl@0
 | 
   557  | 
TInt CWsRenderOrienationTracker::PublishOrientation(const TRenderOrientation aRenderOrientation)
  | 
| 
sl@0
 | 
   558  | 
    {
 | 
| 
sl@0
 | 
   559  | 
    TInt error = KErrNone;
  | 
| 
sl@0
 | 
   560  | 
  
  | 
| 
sl@0
 | 
   561  | 
    if(aRenderOrientation != iPublishedRenderOrientation)
  | 
| 
sl@0
 | 
   562  | 
        {
 | 
| 
sl@0
 | 
   563  | 
        // If the device Orientation has changed, publish it
  | 
| 
sl@0
 | 
   564  | 
        error = DoPublishOrientation(aRenderOrientation);
  | 
| 
sl@0
 | 
   565  | 
        if(KErrNone == error)
  | 
| 
sl@0
 | 
   566  | 
            SetHALOrientation(aRenderOrientation);
  | 
| 
sl@0
 | 
   567  | 
        }
  | 
| 
sl@0
 | 
   568  | 
    return error;
  | 
| 
sl@0
 | 
   569  | 
    }
  | 
| 
sl@0
 | 
   570  | 
  |