sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "rsdisplaychangeao.h" sl@0: #include "displaypolicy.h" sl@0: sl@0: CRsDisplayChangeNotifier::CRsDisplayChangeNotifier(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy) sl@0: :CActive(EPriorityHigh),iWsStatus(NULL) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: iNextLevelInterface = aNextLevelInterface; sl@0: iDisplayPolicy = aDisplayPolicy; sl@0: } sl@0: sl@0: CRsDisplayChangeNotifier* CRsDisplayChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy) sl@0: { sl@0: CRsDisplayChangeNotifier* self = new(ELeave) CRsDisplayChangeNotifier(aNextLevelInterface, aDisplayPolicy); sl@0: return self; sl@0: } sl@0: sl@0: void CRsDisplayChangeNotifier::IssueNotificationRequest() sl@0: { sl@0: iNextLevelInterface->NotifyOnDisplayChange(iStatus); sl@0: SetActive(); sl@0: } sl@0: void CRsDisplayChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus) sl@0: { sl@0: iWsStatus = &aStatus; sl@0: } sl@0: sl@0: void CRsDisplayChangeNotifier::CancelNotificationRequest() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CRsDisplayChangeNotifier::RunL() sl@0: { sl@0: //IssueNotificationRequest will overwrite iStatus, save a copy first; sl@0: TInt result = iStatus.Int(); sl@0: IssueNotificationRequest(); sl@0: sl@0: //calculate min UI buffer size depending on physical resolutions sl@0: TInt ret = iNextLevelInterface->NumberOfResolutions(); sl@0: RArray resolutions; sl@0: CleanupClosePushL(resolutions); sl@0: if(ret > 0) sl@0: { sl@0: //just ignore the error. if there's an error, an empty resolution list is passed in, and uibuffer sl@0: //will remain the previous size sl@0: iNextLevelInterface->GetResolutions(resolutions); sl@0: } sl@0: iDisplayPolicy->CalculateMinBufferSize(resolutions, ret); sl@0: CleanupStack::PopAndDestroy(&resolutions); sl@0: sl@0: if(iWsStatus && *iWsStatus == KRequestPending) sl@0: { sl@0: User::RequestComplete(iWsStatus, result); sl@0: } sl@0: } sl@0: sl@0: void CRsDisplayChangeNotifier::DoCancel() sl@0: { sl@0: iNextLevelInterface->NotifyOnDisplayChangeCancel(); sl@0: if(iWsStatus && *iWsStatus == KRequestPending) sl@0: User::RequestComplete(iWsStatus, KErrCancel); sl@0: } sl@0: sl@0: CRsDisplayChangeNotifier::~CRsDisplayChangeNotifier() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: CRsConfigChangeNotifier::CRsConfigChangeNotifier(MWsDisplayControl* aNextLevelInterface) sl@0: :CActive(EPriorityHigh), iWsStatus(NULL) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: iNextLevelInterface = aNextLevelInterface; sl@0: } sl@0: sl@0: CRsConfigChangeNotifier* CRsConfigChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface) sl@0: { sl@0: CRsConfigChangeNotifier* self = new(ELeave) CRsConfigChangeNotifier(aNextLevelInterface); sl@0: return self; sl@0: } sl@0: sl@0: void CRsConfigChangeNotifier::IssueNotificationRequest() sl@0: { sl@0: iNextLevelInterface->NotifyOnConfigChange(iStatus); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CRsConfigChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus) sl@0: { sl@0: iWsStatus = &aStatus; sl@0: } sl@0: sl@0: void CRsConfigChangeNotifier::CancelNotificationRequest() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CRsConfigChangeNotifier::RunL() sl@0: { sl@0: //IssueNotificationRequest will overwrite iStatus, save a copy first; sl@0: TInt result = iStatus.Int(); sl@0: IssueNotificationRequest(); sl@0: if(iWsStatus && *iWsStatus == KRequestPending) sl@0: { sl@0: User::RequestComplete(iWsStatus, result); sl@0: } sl@0: } sl@0: sl@0: void CRsConfigChangeNotifier::DoCancel() sl@0: { sl@0: iNextLevelInterface->NotifyOnConfigChangeCancel(); sl@0: if(iWsStatus && *iWsStatus == KRequestPending) sl@0: User::RequestComplete(iWsStatus, KErrCancel); sl@0: } sl@0: sl@0: CRsConfigChangeNotifier::~CRsConfigChangeNotifier() sl@0: { sl@0: Cancel(); sl@0: }