appfw/apparchitecture/inc/APGTASK.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-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 #ifndef __APGTASK_H__
       
    17 #define __APGTASK_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <w32std.h>
       
    21 
       
    22 class RWsSession;
       
    23 struct TKeyEvent;
       
    24 
       
    25 //gmahe. This is used in the below enum.
       
    26 /** @internalTechnology */
       
    27 static const TInt KApaSystemEventsWithPowerMgmtCapabilityStart = 100;
       
    28 
       
    29 /** @internalTechnology */
       
    30 static const TInt KApaSystemEventsWithPowerMgmtCapabilityEnd = 199;
       
    31 
       
    32 
       
    33 /** Defines the event types that a TApaTask object can send to its window group.
       
    34 
       
    35 The events are sent by TApaTask::SendSystemEvent() and are handled by CEikAppUi::HandleSystemEventL().
       
    36 
       
    37 @publishedAll
       
    38 @released
       
    39 @see TApaTask::SendSystemEvent()
       
    40 @see CEikAppUi
       
    41 @see CCoeAppUi::HandleSystemEventL() */
       
    42 enum TApaSystemEvent
       
    43 	{
       
    44 	/** The task is being closed. */
       
    45 	EApaSystemEventShutdown=1,
       
    46 	/** Reserved for future use. */
       
    47 	EApaSystemEventBackupStarting,
       
    48 	/** Reserved for future use. */
       
    49 	EApaSystemEventBackupComplete,
       
    50 	/** The task is being brought to the foreground. */
       
    51 	EApaSystemEventBroughtToForeground,
       
    52 	/** Close any tasks including system tasks. 
       
    53 	Events in the range @c KApaSystemEventsWithPowerMgmtCapabilityStart to 
       
    54 	@c KApaSystemEventsWithPowerMgmtCapabilityEnd requires capability PowerMgmt*/
       
    55 	EApaSystemEventSecureShutdown = KApaSystemEventsWithPowerMgmtCapabilityStart
       
    56 	};
       
    57 
       
    58 #ifdef _UNICODE
       
    59 /**
       
    60 @publishedAll
       
    61 @released
       
    62 */
       
    63 #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile16
       
    64 
       
    65 /**
       
    66 @publishedAll
       
    67 @released
       
    68 */
       
    69 #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile16
       
    70 
       
    71 /**
       
    72 @publishedAll
       
    73 @released
       
    74 */
       
    75 #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue16
       
    76 
       
    77 /**
       
    78 @publishedAll
       
    79 @released
       
    80 */
       
    81 #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue16
       
    82 #else
       
    83 #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile8
       
    84 #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile8
       
    85 #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue8
       
    86 #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue8
       
    87 #endif
       
    88 
       
    89 /**
       
    90 @internalComponent
       
    91 */
       
    92 const TInt KUidApaMessageSwitchOpenFileValue16=0x10003A39;
       
    93 
       
    94 /**
       
    95 @internalComponent
       
    96 */
       
    97 const TUid KUidApaMessageSwitchOpenFile16={KUidApaMessageSwitchOpenFileValue16};
       
    98 
       
    99 /**
       
   100 @internalComponent
       
   101 */
       
   102 const TInt KUidApaMessageSwitchCreateFileValue16=0x10003A3A;
       
   103 
       
   104 /**
       
   105 @internalComponent
       
   106 */
       
   107 const TUid KUidApaMessageSwitchCreateFile16={KUidApaMessageSwitchCreateFileValue16};
       
   108 
       
   109 class TApaTask
       
   110 /** Application task.
       
   111 
       
   112 A task is a running application. At any one time, for any given application, 
       
   113 there may be zero, one, or more tasks running on a device.
       
   114 
       
   115 A task is identified by its association with the running application's window 
       
   116 group.
       
   117 
       
   118 An instance of the TApaTaskList class is used to find and access specific 
       
   119 tasks.
       
   120 
       
   121 @publishedAll
       
   122 @released
       
   123 @see TApaTaskList
       
   124 @see RWindowGroup
       
   125 @see RWsSession */
       
   126 	{
       
   127 public:
       
   128 
       
   129 	IMPORT_C TApaTask(RWsSession& aWsSession);
       
   130 	IMPORT_C void SetWgId(TInt aWgId);
       
   131 	IMPORT_C TInt WgId() const;
       
   132 	IMPORT_C TBool Exists() const;
       
   133 	IMPORT_C TThreadId ThreadId() const;
       
   134 	IMPORT_C void BringToForeground();
       
   135 	IMPORT_C void SendToBackground();
       
   136 	IMPORT_C void EndTask();
       
   137 	IMPORT_C void KillTask();
       
   138 	IMPORT_C void SendKey(TInt aKeyCode,TInt aModifiers);
       
   139 	IMPORT_C void SendKey(const TKeyEvent& aKey);
       
   140 	IMPORT_C void SendSystemEvent(TApaSystemEvent aEvent);
       
   141 	IMPORT_C TInt SwitchOpenFile(const TDesC& aFilename);
       
   142 	IMPORT_C TInt SwitchCreateFile(const TDesC& aFilename);
       
   143 	IMPORT_C TInt SendMessage(TUid aUid, const TDesC8& aParams);
       
   144 
       
   145 private:
       
   146 	TInt CheckSwitchFile() const;
       
   147 	void SendSystemEvent(TApaSystemEvent aEvent, TEventCode aType);
       
   148 private:
       
   149 	RWsSession& iWsSession;
       
   150 	TInt iWgId;
       
   151 	TInt iTApaTask_Reserved1;
       
   152 	};
       
   153 
       
   154 class TApaTaskList
       
   155 /** Accesses tasks running on a device.
       
   156 
       
   157 Tasks can be identified by document, application specific UID or by caption 
       
   158 name.
       
   159 
       
   160 Users of this class can also cycle through a set of tasks running a specific 
       
   161 application, bringing each one, in turn, into the foreground.
       
   162 
       
   163 @publishedAll
       
   164 @released
       
   165 @see TApaTask */
       
   166 	{
       
   167 public:	
       
   168 	/** Defines the direction in which tasks are cycled to the foreground. This is used 
       
   169 	by the CycleTasks() function.
       
   170 
       
   171 	@see TApaTaskList::CycleTasks() */
       
   172 	enum TCycleDirection
       
   173 		{
       
   174 		/** Cycles the task list forwards, i.e. the foreground task is moved to background, 
       
   175 		bringing the next foremost task to the foreground. */
       
   176 		EForwards,
       
   177 		/** Cycles the list backwards, i.e. the task furthest from the foreground is brought 
       
   178 		to the foreground, pushing what was the foremost task to the next ordinal 
       
   179 		position. */
       
   180 		EBackwards
       
   181 		};
       
   182 public:
       
   183 	IMPORT_C TApaTaskList(RWsSession& aWsSession);
       
   184 	IMPORT_C TApaTask FindApp(const TDesC& aAppName);
       
   185 	IMPORT_C TApaTask FindDoc(const TDesC& aDocName);
       
   186 	IMPORT_C TApaTask FindByPos(TInt aPos);
       
   187 	IMPORT_C TApaTask FindApp(TUid aAppUid);
       
   188 	IMPORT_C TInt CycleTasks(TUid aAppUid,TCycleDirection aDirection=EForwards);
       
   189 
       
   190 private:
       
   191 	void FindByPosL(TApaTask& aTask,TInt aPos);
       
   192 private:
       
   193 	RWsSession& iWsSession;
       
   194 	TInt iTApaTaskList_Reserved1;
       
   195 	};
       
   196 
       
   197 
       
   198 #endif