|
1 /* |
|
2 * Copyright (c) 2002 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: This class handles the interaction with the scheduler and |
|
15 * updates the data needed by timed profiles to Central |
|
16 * Repository. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CPROFILETIMING_H |
|
23 #define CPROFILETIMING_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <csch_cli.h> |
|
27 #include <centralrepository.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class MProfilesLocalFeatures; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * The interface to the timed profile. |
|
36 * This class handles the interaction with the scheduler and updates the data |
|
37 * needed by timed profiles to Central Repository. |
|
38 * |
|
39 * @lib profileeng.lib |
|
40 * @since S60 3.2 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CProfileTiming ) : public CBase |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 */ |
|
49 static CProfileTiming* NewL( CRepository& aProfileRepository, |
|
50 MProfilesLocalFeatures& aFeatures ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 virtual ~CProfileTiming(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 /** |
|
60 * Times the profile with the given ID. |
|
61 * @param aPreviousId the ID of the profile to be activated after the |
|
62 * timer expires. This is the profile which was active before |
|
63 * the current profile was timed. |
|
64 * @param aTime the time when the timer expires. |
|
65 */ |
|
66 void SetTimedProfileL( TInt aPreviousId, TTime aTime ); |
|
67 |
|
68 /** |
|
69 * Deletes the newly-scheduled task for timed profile. This is used |
|
70 * only when update to Central Repository has failed. Does not return |
|
71 * any error codes or leave because this will be called only in error |
|
72 * situation and there isn't much that could do if this fails also. |
|
73 */ |
|
74 void RollbackTimedProfile(); |
|
75 |
|
76 /** |
|
77 * Cancels the current timed profile if one is active. |
|
78 * @returns the ID of the profile which was active before the |
|
79 * cancelled timed profile or KErrNotFound. |
|
80 */ |
|
81 TInt CancelTimedProfileL(); |
|
82 |
|
83 /** |
|
84 * Returns boolean value indicating whether there is currently an |
|
85 * active timing. |
|
86 * @return ETrue if the current active profile is timed, EFalse |
|
87 * otherwise. |
|
88 */ |
|
89 TBool IsTimingActiveL(); |
|
90 |
|
91 private: // New functions |
|
92 |
|
93 /** |
|
94 * Saves the data needed by timer task DLL and for cancelling the task |
|
95 * in Central Repository. |
|
96 * @param aPreviousId the ID of the profile which was active before the |
|
97 * timed profile. This is the profile which should be reactivated |
|
98 * when the timer goes off. |
|
99 * @param aHandleId the scheduling handle ID of the timed profile task. |
|
100 * @param aTaskId the task ID of the timed profile task. |
|
101 */ |
|
102 void SaveSchedulingData( TInt aPreviousId = -1, |
|
103 TInt aHandleId = -1, |
|
104 TInt aTaskId = -1 ); |
|
105 |
|
106 /** |
|
107 * Gets the information about current timed profile from Central |
|
108 * Repository. |
|
109 * @param aPreviousId contains the ID of the profile which should be |
|
110 * re-activated when the timer goes off on return. |
|
111 * @param aHandleId contains the ID of the scheduling handle of the |
|
112 * timed profile on return. |
|
113 * @param aTaskId contains the ID assigned for the task of the timed |
|
114 * profile on return. |
|
115 */ |
|
116 void GetSchedulingDataL( TInt& aPreviousId, TInt& aHandleId, |
|
117 TInt& aTaskId ); |
|
118 |
|
119 /** |
|
120 * Creates connection to the task scheduler. This method is not called |
|
121 * before the connection to the server is really needed. |
|
122 */ |
|
123 void ConnectToSchedulerL(); |
|
124 |
|
125 private: |
|
126 |
|
127 /** |
|
128 * C++ constructor. |
|
129 */ |
|
130 CProfileTiming( CRepository& aProfileRepository, |
|
131 MProfilesLocalFeatures& aFeatures ); |
|
132 |
|
133 /** |
|
134 * By default Symbian 2nd phase constructor is private. |
|
135 */ |
|
136 void ConstructL(); |
|
137 |
|
138 private: // Data |
|
139 // Profiles Central Repository reference |
|
140 CRepository& iRepository; |
|
141 |
|
142 // Profiles local features reference |
|
143 MProfilesLocalFeatures& iFeatures; |
|
144 |
|
145 // Own: Scheduler for scheduling profile timing tasks |
|
146 RScheduler iScheduler; |
|
147 |
|
148 // Own: Array used as container for the schedule of a timed profile |
|
149 CArrayFixFlat<TScheduleEntryInfo2>* iEntryList; |
|
150 |
|
151 // this is needed by ScheduleTask(), doesn't really contain anything |
|
152 TSchedulerItemRef iSchedulerItemRef; |
|
153 |
|
154 // Own: task data needed by ScheduleTask(), in practise this is empty |
|
155 HBufC* iTaskData; |
|
156 |
|
157 // Path to the DLL to be run by the scheduler when the timer goes off |
|
158 TFileName iTaskDllPath; |
|
159 |
|
160 // Task ID for rollback in case of errors |
|
161 TInt iTaskId; |
|
162 |
|
163 // Flag indicating whether the connection to the scheduler is open |
|
164 TBool iConnected; |
|
165 }; |
|
166 |
|
167 #endif // CPROFILETIMING_H |
|
168 |
|
169 // End of File |