genericservices/taskscheduler/SCHSVR/SCHCLI.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2004-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 // class CClientProxy
       
    15 // -scheduler's representation of client
       
    16 // -contains info scheduler needs to start real client in its own process	
       
    17 // -reference-counted: deleted when no tasks & no sessions reference it
       
    18 // 
       
    19 //
       
    20 
       
    21 #ifndef __SCHCLI_H__
       
    22 #define __SCHCLI_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 // Classes referenced
       
    27 class RFs;
       
    28 class CScheduledTask;
       
    29 class RWriteStream;
       
    30 class CFileStore;
       
    31 class CSchLogManager;
       
    32 
       
    33 
       
    34 /**
       
    35 @internalComponent
       
    36 */
       
    37 NONSHARABLE_CLASS(CClientProxy) : public CBase
       
    38 	{
       
    39 public:
       
    40 	static CClientProxy* NewL(RFs& aFsSession, 
       
    41 							RReadStream& aStream,
       
    42 							CSchLogManager& aLogManager);
       
    43 	static CClientProxy* NewL(RFs& aFsSession, 
       
    44 							const TDesC& aFileName, 
       
    45 							TInt aPriority,
       
    46 							CSchLogManager& aLogManager);
       
    47 	~CClientProxy();
       
    48 
       
    49 private:
       
    50 	CClientProxy(RFs& aFsSession,CSchLogManager& aLogManager);
       
    51 	CClientProxy(RFs& aFsSession, TInt aPriority,CSchLogManager& aLogManager);
       
    52 	void ConstructL(const TDesC& aFileName); 
       
    53 
       
    54 public:
       
    55 	TBool IsEqual(const TDesC& aFilename, TInt aPriority) const;
       
    56 	void ExecuteTasks();
       
    57 	void AddTask(CScheduledTask& aTask);
       
    58 	void RemoveTask(CScheduledTask* aTask);
       
    59 	void RemoveDueTasks();
       
    60 	void TransferTasks(CClientProxy& aTargetClient);
       
    61 
       
    62 	// sharing stuff
       
    63 	inline void DecUsers();			
       
    64 	inline void IncUsers();				
       
    65 	inline TInt Users() const;	
       
    66 
       
    67 	// execution
       
    68 	inline void ReadyToExecute();		
       
    69 	inline TBool IsReadyToExecute() const;
       
    70 
       
    71 	// list capability
       
    72 	inline static TInt Offset();
       
    73 	inline void Remove();// remove youself from que
       
    74 
       
    75 	inline const TDesC& ExecutorFileName() const { return *iFileName; }
       
    76 	TDblQueIter<CScheduledTask> TaskIterator();
       
    77 	TInt Priority() const;
       
    78 
       
    79 public:
       
    80 	void InternalizeL(RReadStream& aStream);
       
    81 	void ExternalizeL(RWriteStream& aStream) const;
       
    82 
       
    83 private: // internal functions
       
    84 	void DoExecuteTasksL();
       
    85 	CArrayPtr<CScheduledTask>* DueTasksL();// copy the due tasks into an array
       
    86 
       
    87 	// called before running the task
       
    88 	TInt DoExecuteTasks(const CArrayPtr<CScheduledTask>& aTasks, 
       
    89 						const TDesC& aFileName);
       
    90 
       
    91 	void DoExecuteTasksL(const CArrayPtr<CScheduledTask>& aTasks, 
       
    92 						const TDesC& aFileName,
       
    93 						const TDesC& aErrorMessage);
       
    94 
       
    95 	void SaveTasksToFileL(const CArrayPtr<CScheduledTask>& aTasks, 
       
    96 						const TDesC& aFileName);// save 'em to a new file
       
    97 	void SaveTasksL(CFileStore& aStore, const CArrayPtr<CScheduledTask>& aTasks);
       
    98 	CFileStore* CreateStoreL(const TDesC& aName, TUint aFileMode);// needed so we can call store->CreateLC() in a trap
       
    99 	
       
   100 private: // member data
       
   101 	RFs& iFsSession;
       
   102 	TBool iReadyToExecute;
       
   103 	TInt iUsers;// for sharing
       
   104 	HBufC* iFileName;// name of supplied ExeDll thingie
       
   105 	//
       
   106 	TPriQueLink iPriLink;// owned by scheduler & kept in priority que
       
   107 	TPriQue<CScheduledTask> iTasks;
       
   108 	CSchLogManager& iSchLogManager;
       
   109 	};
       
   110 
       
   111 #include "SCHCLI.INL"
       
   112 #endif