diff -r 156f692b1687 -r b99b84bcd2d1 activityfw/tsutils/inc/tswindowgroupsobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/tsutils/inc/tswindowgroupsobserver.h Wed Jun 23 18:33:40 2010 +0300 @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + */ +#ifndef TSWINDOWGROUPSOBSERVER_H +#define TSWINDOWGROUPSOBSERVER_H + +#include "tsresourcemanager.h" + +/** + * Interface declare mathods to notify about window server events + */ +class MTsWindowGroupsObserver +{ +public: + /** + * Method notidy about window group changes. + * @param rsc - resource manager + * @param wgs - list of window groups associated with running applications + */ + virtual void HandleWindowGroupChanged(MTsResourceManager &rsc, + const TArray & wgs) =0; +}; + +/** + * Interface declare methods to subscribe windo server events + */ +class MTsWindowGroupsMonitor +{ +public: + /** + * Method make subscription for window server events + * @param observer - events observer + */ + virtual void SubscribeL(MTsWindowGroupsObserver & observer) =0; + + /** + * Method cancel subscription for window server events + * @param observer - events observer + */ + virtual void Cancel(MTsWindowGroupsObserver &) =0; +}; + +/** + * Window server observer implementation. Class automaticly subscribe / cancel subscription + * at construction / destruction level. + * + */ +class CTsWindowGroupsObserver: public CBase, + public MTsWindowGroupsObserver +{ +public: + /** + * Destructor + * Function automaticly cancel subscrption to window server events + */ + IMPORT_C ~CTsWindowGroupsObserver(); + +protected: + /** + * First phase constructor + */ + IMPORT_C CTsWindowGroupsObserver(MTsWindowGroupsMonitor &); + + /** + * Second phase constructor. + * Function automaticly subscribe window server events + */ + IMPORT_C void BaseConstructL(); + +private: + MTsWindowGroupsMonitor & mMonitor; +}; + +/** + * Window server monitor implementation. + */ +class CTsWindowGroupsMonitor: public CActive, + public MTsWindowGroupsMonitor + +{ +public: + /** + * Two phase constructor + */ + IMPORT_C static CTsWindowGroupsMonitor* NewL(MTsResourceManager &); + + /** + * Destructor + */ + IMPORT_C ~CTsWindowGroupsMonitor(); + + /** + * @see MTsWindowGroupsMonitor::SubscribeL + */ + IMPORT_C void SubscribeL(MTsWindowGroupsObserver &); + + /** + * @see MTsWindowGroupsMonitor::Cancel + */ + IMPORT_C void Cancel(MTsWindowGroupsObserver &); + +protected: + /** + * @see CActive::RunL + */ + void RunL(); + + /** + * @see CActive::DoCancel + */ + void DoCancel(); + + /** + * @see CActive::RunError + */ + TInt RunError(TInt error); + +private: + /** + * First phase constructor + */ + CTsWindowGroupsMonitor(MTsResourceManager &); + + /** + * Second phase constructor + */ + void ConstructL(); + + /** + * Function subscribe for event to window server and activate object + */ + void Subscribe(); + + /** + * Function provide window server event to observers + */ + void ProvideEventL(); + + /** + * Function provide window server event to observer + */ + void ProvideEventL(TWsEvent, MTsWindowGroupsObserver &); + +private: + /** + * Registry of subscribed observers + */ + RPointerArray mObservers; + + /** + * Resources manager + */ + MTsResourceManager &mResources; + + /** + * Monitor window group + */ + RWindowGroup mWg; +}; +#endif //TSWINDOWGROUPSOBSERVER_H