// EIKSRV.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__EIKSRV_H__)
#define __EIKSRV_H__

#if !defined(__EIKAPPUI_H__)
#include <eikappui.h>
#endif

#if !defined(__EIKENV_H__)
#include <eikenv.h>
#endif

#if !defined(__APGTASK_H__)
#include <apgtask.h>
#endif

class TEikPasswordModeCategory : public TRegistryCategory
	{
public:
	IMPORT_C TEikPasswordModeCategory();
	IMPORT_C void PasswordMode(TPasswordMode& aMode) const; 
	IMPORT_C TInt SetPasswordMode(TPasswordMode aMode);
	};

//
// CEikServAppUi
//

class CEikServNotifyServer;
class CEikServBackupServer;
class CEikServAlarmAlertServer;
class CEikKeyWindow;
class CEikUndertaker;
class CEikPasswordControl;
class CEikTaskListDialog;

class CEikServAppUi : public CEikAppUi
    {
public:
	enum TTaskCycleDirection { EBackwards, EForwards };
	enum TEikServServers { EAlwlSvr=0x01, EApaSvr=0x02 };
public:
	IMPORT_C static CEikServAppUi* NewLC();
	IMPORT_C void NotifyAlarmServerOfTaskChange() const;
	IMPORT_C void LaunchTaskListL() const;
	IMPORT_C void CycleTasks(TTaskCycleDirection aDirection) const;
public:
    void ConstructL();
	CEikServAppUi();
	~CEikServAppUi();
	void HandleThreadExitL(RThread& aThread);
	void HandleTaskListExitL();
	inline RWindowGroup& AlertGroupWin() const;
	void BringAlertGroupWinForwards(TBool aForwards);
private: // framework
	virtual void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination);
	virtual void HandleSystemEventL(const TWsEvent& aEvent);
	virtual void HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent);
    virtual void HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
	virtual void HandleSwitchOnEventL(CCoeControl* aDestination);
private: // specific
	void SetSystemTime() const;
	void EnsureExternalKeyHandlerAppStreamExistsL();
	void UpdateTaskListL();
	void HandleErrorMessageEvent(const TWsErrorMessage& aErrorMessage);
	void HandleOomEvent();
	void HandleBacklightError(TInt aError);
	void HandleWservLoggingError(TInt aError);
//	void SetDriveNames();
	static TInt RestartServerCallback(TAny* aObj);
	void RestartServer();
private:
	friend class CEikServKeyFilter;
	friend class CEikPasswordControl;
	TInt32 iExternalKeys[3];
	TInt32 iScreenCaptureKey;
	TInt32 iHelpKey;

	RWindowGroup iAlertGroupWin;
	TInt iAlertGroupForwardsCount;

	RWindowGroup iOffScreenGroupWin;
	CEikKeyWindow* iSidebarWindow;
	CEikKeyWindow* iAppbarWindow;
	TInt iResourceFileOffset;

	CEikPasswordControl* iPasswordControl;
	CEikTaskListDialog* iTaskListDialog;

	TBool iExternalKeyHandlerRunning;
	TThreadId iExternalKeyHandlerThreadId;

	TBool iHelpAppRunning;
	TThreadId iHelpAppThreadId;

	CEikServNotifyServer* iNotifyServer;
	CEikServBackupServer* iBackupRestoreServer;
	CEikServAlarmAlertServer* iAlarmAlertServer;

	CEikUndertaker* iUndertaker;
	CPeriodic* iServerRestarter;
	TInt iServerToRestart;
	};

inline RWindowGroup& CEikServAppUi::AlertGroupWin() const { return((RWindowGroup&)iAlertGroupWin); }
      
#endif
