williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __APGTASK_H__ williamr@2: #define __APGTASK_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: class RWsSession; williamr@2: struct TKeyEvent; williamr@2: williamr@4: //gmahe. This is used in the below enum. williamr@2: /** @internalTechnology */ williamr@2: static const TInt KApaSystemEventsWithPowerMgmtCapabilityStart = 100; williamr@4: williamr@2: /** @internalTechnology */ williamr@2: static const TInt KApaSystemEventsWithPowerMgmtCapabilityEnd = 199; williamr@2: williamr@4: williamr@2: /** Defines the event types that a TApaTask object can send to its window group. williamr@2: williamr@2: The events are sent by TApaTask::SendSystemEvent() and are handled by CEikAppUi::HandleSystemEventL(). williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: @see TApaTask::SendSystemEvent() williamr@2: @see CEikAppUi williamr@2: @see CCoeAppUi::HandleSystemEventL() */ williamr@2: enum TApaSystemEvent williamr@2: { williamr@2: /** The task is being closed. */ williamr@2: EApaSystemEventShutdown=1, williamr@2: /** Reserved for future use. */ williamr@2: EApaSystemEventBackupStarting, williamr@2: /** Reserved for future use. */ williamr@2: EApaSystemEventBackupComplete, williamr@2: /** The task is being brought to the foreground. */ williamr@2: EApaSystemEventBroughtToForeground, williamr@2: /** Close any tasks including system tasks. williamr@2: Events in the range @c KApaSystemEventsWithPowerMgmtCapabilityStart to williamr@2: @c KApaSystemEventsWithPowerMgmtCapabilityEnd requires capability PowerMgmt*/ williamr@2: EApaSystemEventSecureShutdown = KApaSystemEventsWithPowerMgmtCapabilityStart williamr@2: }; williamr@2: williamr@2: #ifdef _UNICODE williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile16 williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile16 williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue16 williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue16 williamr@2: #else williamr@2: #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile8 williamr@2: #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile8 williamr@2: #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue8 williamr@2: #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue8 williamr@2: #endif williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TInt KUidApaMessageSwitchOpenFileValue16=0x10003A39; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TUid KUidApaMessageSwitchOpenFile16={KUidApaMessageSwitchOpenFileValue16}; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TInt KUidApaMessageSwitchCreateFileValue16=0x10003A3A; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TUid KUidApaMessageSwitchCreateFile16={KUidApaMessageSwitchCreateFileValue16}; williamr@2: williamr@2: class TApaTask williamr@2: /** Application task. williamr@2: williamr@2: A task is a running application. At any one time, for any given application, williamr@2: there may be zero, one, or more tasks running on a device. williamr@2: williamr@2: A task is identified by its association with the running application's window williamr@2: group. williamr@2: williamr@2: An instance of the TApaTaskList class is used to find and access specific williamr@2: tasks. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: @see TApaTaskList williamr@2: @see RWindowGroup williamr@2: @see RWsSession */ williamr@2: { williamr@2: public: williamr@2: williamr@2: IMPORT_C TApaTask(RWsSession& aWsSession); williamr@2: IMPORT_C void SetWgId(TInt aWgId); williamr@2: IMPORT_C TInt WgId() const; williamr@2: IMPORT_C TBool Exists() const; williamr@2: IMPORT_C TThreadId ThreadId() const; williamr@2: IMPORT_C void BringToForeground(); williamr@2: IMPORT_C void SendToBackground(); williamr@2: IMPORT_C void EndTask(); williamr@2: IMPORT_C void KillTask(); williamr@2: IMPORT_C void SendKey(TInt aKeyCode,TInt aModifiers); williamr@2: IMPORT_C void SendKey(const TKeyEvent& aKey); williamr@2: IMPORT_C void SendSystemEvent(TApaSystemEvent aEvent); williamr@2: IMPORT_C TInt SwitchOpenFile(const TDesC& aFilename); williamr@2: IMPORT_C TInt SwitchCreateFile(const TDesC& aFilename); williamr@2: IMPORT_C TInt SendMessage(TUid aUid, const TDesC8& aParams); williamr@2: williamr@2: private: williamr@2: TInt CheckSwitchFile() const; williamr@2: void SendSystemEvent(TApaSystemEvent aEvent, TEventCode aType); williamr@2: private: williamr@2: RWsSession& iWsSession; williamr@2: TInt iWgId; williamr@2: TInt iTApaTask_Reserved1; williamr@2: }; williamr@2: williamr@2: class TApaTaskList williamr@2: /** Accesses tasks running on a device. williamr@2: williamr@2: Tasks can be identified by document, application specific UID or by caption williamr@2: name. williamr@2: williamr@2: Users of this class can also cycle through a set of tasks running a specific williamr@2: application, bringing each one, in turn, into the foreground. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: @see TApaTask */ williamr@2: { williamr@2: public: williamr@2: /** Defines the direction in which tasks are cycled to the foreground. This is used williamr@2: by the CycleTasks() function. williamr@2: williamr@2: @see TApaTaskList::CycleTasks() */ williamr@2: enum TCycleDirection williamr@2: { williamr@2: /** Cycles the task list forwards, i.e. the foreground task is moved to background, williamr@2: bringing the next foremost task to the foreground. */ williamr@2: EForwards, williamr@2: /** Cycles the list backwards, i.e. the task furthest from the foreground is brought williamr@2: to the foreground, pushing what was the foremost task to the next ordinal williamr@2: position. */ williamr@2: EBackwards williamr@2: }; williamr@2: public: williamr@2: IMPORT_C TApaTaskList(RWsSession& aWsSession); williamr@2: IMPORT_C TApaTask FindApp(const TDesC& aAppName); williamr@2: IMPORT_C TApaTask FindDoc(const TDesC& aDocName); williamr@2: IMPORT_C TApaTask FindByPos(TInt aPos); williamr@2: IMPORT_C TApaTask FindApp(TUid aAppUid); williamr@2: IMPORT_C TInt CycleTasks(TUid aAppUid,TCycleDirection aDirection=EForwards); williamr@2: williamr@2: private: williamr@2: void FindByPosL(TApaTask& aTask,TInt aPos); williamr@2: private: williamr@2: RWsSession& iWsSession; williamr@2: TInt iTApaTaskList_Reserved1; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif