os/graphics/windowing/windowserverplugins/openwfc/src/rsdisplaychangeao.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-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 #include "rsdisplaychangeao.h"
    17 #include "displaypolicy.h"
    18 
    19 CRsDisplayChangeNotifier::CRsDisplayChangeNotifier(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy)
    20 :CActive(EPriorityHigh),iWsStatus(NULL)
    21 	{
    22 	CActiveScheduler::Add(this);
    23 	iNextLevelInterface = aNextLevelInterface;
    24 	iDisplayPolicy = aDisplayPolicy;
    25 	}
    26 
    27 CRsDisplayChangeNotifier* CRsDisplayChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy)
    28 	{
    29 	CRsDisplayChangeNotifier* self = new(ELeave) CRsDisplayChangeNotifier(aNextLevelInterface, aDisplayPolicy);
    30 	return self;
    31 	}
    32 
    33 void CRsDisplayChangeNotifier::IssueNotificationRequest()
    34 	{
    35 	iNextLevelInterface->NotifyOnDisplayChange(iStatus);
    36 	SetActive();
    37 	}
    38 void CRsDisplayChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus)
    39 	{
    40 	iWsStatus = &aStatus;
    41 	}
    42 
    43 void CRsDisplayChangeNotifier::CancelNotificationRequest()
    44 	{
    45 	Cancel();
    46 	}
    47 
    48 void CRsDisplayChangeNotifier::RunL()
    49 	{
    50 	//IssueNotificationRequest will overwrite iStatus, save a copy first;
    51 	TInt result = iStatus.Int();
    52 	IssueNotificationRequest();
    53 	
    54 	//calculate min UI buffer size depending on physical resolutions
    55 	TInt ret = iNextLevelInterface->NumberOfResolutions();
    56 	RArray<MDisplayControlBase::TResolution> resolutions;
    57 	CleanupClosePushL(resolutions);
    58 	if(ret > 0)
    59 		{
    60 		//just ignore the error. if there's an error, an empty resolution list is passed in, and uibuffer
    61 		//will remain the previous size
    62 		iNextLevelInterface->GetResolutions(resolutions);
    63 		}
    64 	iDisplayPolicy->CalculateMinBufferSize(resolutions, ret);				
    65 	CleanupStack::PopAndDestroy(&resolutions);
    66 	
    67 	if(iWsStatus && *iWsStatus == KRequestPending)
    68 		{
    69 		User::RequestComplete(iWsStatus, result);
    70 		}
    71 	}
    72 
    73 void CRsDisplayChangeNotifier::DoCancel()
    74 	{
    75 	iNextLevelInterface->NotifyOnDisplayChangeCancel();
    76 	if(iWsStatus && *iWsStatus == KRequestPending)
    77 		User::RequestComplete(iWsStatus, KErrCancel);
    78 	}
    79 
    80 CRsDisplayChangeNotifier::~CRsDisplayChangeNotifier()
    81 	{
    82 	Cancel();
    83 	}
    84 
    85 CRsConfigChangeNotifier::CRsConfigChangeNotifier(MWsDisplayControl* aNextLevelInterface)
    86 :CActive(EPriorityHigh), iWsStatus(NULL)
    87 	{
    88 	CActiveScheduler::Add(this);
    89 	iNextLevelInterface = aNextLevelInterface;
    90 	}
    91 
    92 CRsConfigChangeNotifier* CRsConfigChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface)
    93 	{
    94 	CRsConfigChangeNotifier* self = new(ELeave) CRsConfigChangeNotifier(aNextLevelInterface);
    95 	return self;
    96 	}
    97 
    98 void CRsConfigChangeNotifier::IssueNotificationRequest()
    99 	{
   100 	iNextLevelInterface->NotifyOnConfigChange(iStatus);
   101 	SetActive();
   102 	}
   103 
   104 void CRsConfigChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus)
   105 	{
   106 	iWsStatus = &aStatus;
   107 	}
   108 
   109 void CRsConfigChangeNotifier::CancelNotificationRequest()
   110 	{
   111 	Cancel();
   112 	}
   113 
   114 void CRsConfigChangeNotifier::RunL()
   115 	{
   116 	//IssueNotificationRequest will overwrite iStatus, save a copy first;
   117 	TInt result = iStatus.Int();
   118 	IssueNotificationRequest();
   119 	if(iWsStatus && *iWsStatus == KRequestPending)
   120 		{
   121 		User::RequestComplete(iWsStatus, result);
   122 		}
   123 	}
   124 
   125 void CRsConfigChangeNotifier::DoCancel()
   126 	{
   127 	iNextLevelInterface->NotifyOnConfigChangeCancel();
   128 	if(iWsStatus && *iWsStatus == KRequestPending)
   129 		User::RequestComplete(iWsStatus, KErrCancel);
   130 	}
   131 
   132 CRsConfigChangeNotifier::~CRsConfigChangeNotifier()
   133 	{
   134 	Cancel();
   135 	}