tsrc/Apastub/inc/apgtask.h
changeset 22 496ad160a278
parent 0 f0cf47e981f9
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #if !defined(__APGTASK_H__)
       
    20 #define __APGTASK_H__
       
    21 
       
    22 #if !defined(__E32BASE_H__)
       
    23 #include <e32base.h>
       
    24 #endif
       
    25 
       
    26 #include <w32std.h>
       
    27 
       
    28 class RWsSession;
       
    29 struct TKeyEvent;
       
    30 
       
    31 /** @internalTechnology */
       
    32 static const TInt KApaSystemEventsWithPowerMgmtCapabilityStart = 100;
       
    33 /** @internalTechnology */
       
    34 static const TInt KApaSystemEventsWithPowerMgmtCapabilityEnd = 199;
       
    35 
       
    36 /** Defines the event types that a TApaTask object can send to its window group.
       
    37 
       
    38 The events are sent by TApaTask::SendSystemEvent() and are handled by CEikAppUi::HandleSystemEventL().
       
    39 
       
    40 @publishedAll
       
    41 @released
       
    42 @see TApaTask::SendSystemEvent()
       
    43 @see CEikAppUi
       
    44 @see CCoeAppUi::HandleSystemEventL() */
       
    45 enum TApaSystemEvent
       
    46     {
       
    47     /** The task is being closed. */
       
    48     EApaSystemEventShutdown=1,
       
    49     /** Reserved for future use. */
       
    50     EApaSystemEventBackupStarting,
       
    51     /** Reserved for future use. */
       
    52     EApaSystemEventBackupComplete,
       
    53     /** The task is being brought to the foreground. */
       
    54     EApaSystemEventBroughtToForeground,
       
    55     /** Close any tasks including system tasks.
       
    56     Events in the range @c KApaSystemEventsWithPowerMgmtCapabilityStart to
       
    57     @c KApaSystemEventsWithPowerMgmtCapabilityEnd requires capability PowerMgmt*/
       
    58     EApaSystemEventSecureShutdown = KApaSystemEventsWithPowerMgmtCapabilityStart
       
    59     };
       
    60 
       
    61 #ifdef _UNICODE
       
    62 /**
       
    63 @publishedAll
       
    64 @released
       
    65 */
       
    66 #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile16
       
    67 
       
    68 /**
       
    69 @publishedAll
       
    70 @released
       
    71 */
       
    72 #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile16
       
    73 
       
    74 /**
       
    75 @publishedAll
       
    76 @released
       
    77 */
       
    78 #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue16
       
    79 
       
    80 /**
       
    81 @publishedAll
       
    82 @released
       
    83 */
       
    84 #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue16
       
    85 #else
       
    86 #define KUidApaMessageSwitchOpenFile KUidApaMessageSwitchOpenFile8
       
    87 #define KUidApaMessageSwitchCreateFile KUidApaMessageSwitchCreateFile8
       
    88 #define KUidApaMessageSwitchOpenFileValue KUidApaMessageSwitchOpenFileValue8
       
    89 #define KUidApaMessageSwitchCreateFileValue KUidApaMessageSwitchCreateFileValue8
       
    90 #endif
       
    91 
       
    92 /**
       
    93 @internalComponent
       
    94 */
       
    95 const TInt KUidApaMessageSwitchOpenFileValue16=0x10003A39;
       
    96 
       
    97 /**
       
    98 @internalComponent
       
    99 */
       
   100 const TUid KUidApaMessageSwitchOpenFile16={KUidApaMessageSwitchOpenFileValue16};
       
   101 
       
   102 /**
       
   103 @internalComponent
       
   104 */
       
   105 const TInt KUidApaMessageSwitchCreateFileValue16=0x10003A3A;
       
   106 
       
   107 /**
       
   108 @internalComponent
       
   109 */
       
   110 const TUid KUidApaMessageSwitchCreateFile16={KUidApaMessageSwitchCreateFileValue16};
       
   111 
       
   112 class TApaTask
       
   113 /** Application task.
       
   114 
       
   115 A task is a running application. At any one time, for any given application,
       
   116 there may be zero, one, or more tasks running on a device.
       
   117 
       
   118 A task is identified by its association with the running application's window
       
   119 group.
       
   120 
       
   121 An instance of the TApaTaskList class is used to find and access specific
       
   122 tasks.
       
   123 
       
   124 @publishedAll
       
   125 @released
       
   126 @see TApaTaskList
       
   127 @see RWindowGroup
       
   128 @see RWsSession */
       
   129     {
       
   130 public:
       
   131 
       
   132     IMPORT_C TApaTask(RWsSession& aWsSession);
       
   133     IMPORT_C void SetWgId(TInt aWgId);
       
   134     IMPORT_C TInt WgId() const;
       
   135     IMPORT_C TBool Exists();
       
   136     IMPORT_C TThreadId ThreadId() const;
       
   137     IMPORT_C void BringToForeground();
       
   138     IMPORT_C void SendToBackground();
       
   139     IMPORT_C void EndTask();
       
   140     IMPORT_C void KillTask();
       
   141     IMPORT_C void SendKey(TInt aKeyCode,TInt aModifiers);
       
   142     IMPORT_C void SendKey(const TKeyEvent& aKey);
       
   143     IMPORT_C void SendSystemEvent(TApaSystemEvent aEvent);
       
   144     IMPORT_C TInt SwitchOpenFile(const TDesC& aFilename);
       
   145     IMPORT_C TInt SwitchCreateFile(const TDesC& aFilename);
       
   146     IMPORT_C TInt SendMessage(TUid aUid, const TDesC8& aParams);
       
   147 
       
   148 private:
       
   149     TInt CheckSwitchFile() const;
       
   150     void SendSystemEvent(TApaSystemEvent aEvent, TEventCode aType);
       
   151 
       
   152 public: // Stubbed data
       
   153     RWsSession& iWsSession;
       
   154     TInt iWgId;
       
   155     TInt iTApaTask_Reserved1;
       
   156 
       
   157     enum KApaTaskCalledFunction
       
   158         {
       
   159         ENone, 
       
   160         EFindApp,
       
   161         EExists,
       
   162         EBringToForeground,
       
   163         ESendToBackground,
       
   164         EEndTask,
       
   165         EKillTask
       
   166         };
       
   167         
       
   168 
       
   169 
       
   170     static TBool iApplicationExist;        
       
   171     static TInt iApaTaskCalledFunction;
       
   172 
       
   173 
       
   174     };
       
   175 
       
   176 class TApaTaskList
       
   177 /** Accesses tasks running on a device.
       
   178 
       
   179 Tasks can be identified by document, application specific UID or by caption
       
   180 name.
       
   181 
       
   182 Users of this class can also cycle through a set of tasks running a specific
       
   183 application, bringing each one, in turn, into the foreground.
       
   184 
       
   185 @publishedAll
       
   186 @released
       
   187 @see TApaTask */
       
   188     {
       
   189 public:
       
   190     /** Defines the direction in which tasks are cycled to the foreground. This is used
       
   191     by the CycleTasks() function.
       
   192 
       
   193     @see TApaTaskList::CycleTasks() */
       
   194     enum TCycleDirection
       
   195         {
       
   196         /** Cycles the task list forwards, i.e. the foreground task is moved to background,
       
   197         bringing the next foremost task to the foreground. */
       
   198         EForwards,
       
   199         /** Cycles the list backwards, i.e. the task furthest from the foreground is brought
       
   200         to the foreground, pushing what was the foremost task to the next ordinal
       
   201         position. */
       
   202         EBackwards
       
   203         };
       
   204 public:
       
   205     IMPORT_C TApaTaskList(RWsSession& aWsSession);
       
   206     IMPORT_C TApaTask FindApp(const TDesC& aAppName);
       
   207     IMPORT_C TApaTask FindDoc(const TDesC& aDocName);
       
   208     IMPORT_C TApaTask FindByPos(TInt aPos);
       
   209     IMPORT_C TApaTask FindApp(TUid aAppUid);
       
   210     IMPORT_C TInt CycleTasks(TUid aAppUid,TCycleDirection aDirection=EForwards);
       
   211 
       
   212 private:
       
   213     void FindByPosL(TApaTask& aTask,TInt aPos);
       
   214 public:
       
   215     RWsSession& iWsSession;
       
   216     TInt iTApaTaskList_Reserved1;
       
   217     
       
   218     enum KCalledFunction
       
   219         {
       
   220         ENone, 
       
   221         EFindApp
       
   222         };
       
   223         
       
   224     
       
   225     
       
   226     static TInt iCalledFunction;
       
   227     };
       
   228 
       
   229 
       
   230 #endif