1 /* |
|
2 * Copyright (c) 2008-2009 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: Base classes for multi-purpuse tasks |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 * @internal reviewed 31/07/2007 by Simon Brooks |
|
22 */ |
|
23 |
|
24 |
|
25 #include "glxtntask.h" |
|
26 |
|
27 #include <glxtracer.h> |
|
28 |
|
29 #include "mglxtnthumbnailcreatorclient.h" |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // Constructor |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CGlxtnTask::CGlxtnTask(const TGlxtnTaskId& aId, const TGlxMediaId& aItemId, |
|
36 MGlxtnThumbnailStorage* aStorage) |
|
37 : iState(EStarting), iId(aId), iItemId(aItemId), iStorage(aStorage) |
|
38 { |
|
39 TRACER("CGlxtnTask::CGlxtnTask()"); |
|
40 iPriority = CActive::EPriorityStandard; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // Destructor |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CGlxtnTask::~CGlxtnTask() |
|
48 { |
|
49 TRACER("CGlxtnTask::~CGlxtnTask()"); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // SetManager |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CGlxtnTask::SetManager(CGlxtnTaskManager* /*aManager*/) |
|
57 { |
|
58 TRACER("CGlxtnTask::SetManager()"); |
|
59 // No implementation - can be overridden by subclasses |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // StartL |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CGlxtnTask::StartL(TRequestStatus& aStatus) |
|
67 { |
|
68 TRACER("CGlxtnTask::StartL()"); |
|
69 __ASSERT_DEBUG(iState == EIdle || iState == EStarting, Panic(EGlxPanicIllegalState)); |
|
70 |
|
71 iState = EStarting; |
|
72 |
|
73 TBool active = DoStartL(aStatus); |
|
74 |
|
75 if (active) |
|
76 { |
|
77 iState = ERunning; |
|
78 } |
|
79 else |
|
80 { |
|
81 iState = EComplete; // Well, that was quick |
|
82 } |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // Cancel |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CGlxtnTask::Cancel() |
|
90 { |
|
91 TRACER("CGlxtnTask::Cancel()"); |
|
92 if ( ERunning == iState ) |
|
93 { |
|
94 DoCancel(); |
|
95 } |
|
96 |
|
97 iState = ECanceled; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // RunL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CGlxtnTask::RunL(TRequestStatus& aStatus) |
|
105 { |
|
106 TRACER("void CGlxtnTask::RunL()"); |
|
107 __ASSERT_DEBUG(iState == ERunning, Panic(EGlxPanicIllegalState)); |
|
108 |
|
109 TBool active = DoRunL(aStatus); |
|
110 |
|
111 if (!active) |
|
112 { |
|
113 iState = EComplete; // The task is done |
|
114 } |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // RunError |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CGlxtnTask::RunError(TInt aError) |
|
122 { |
|
123 TRACER("void CGlxtnTask::RunError()"); |
|
124 if ( !DoRunError(aError) ) |
|
125 { |
|
126 iState = EComplete; // The task is done |
|
127 } |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // SelfComplete |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CGlxtnTask::SelfComplete(TRequestStatus& aStatus) |
|
135 { |
|
136 TRACER("CGlxtnTask::SelfComplete()"); |
|
137 aStatus = KRequestPending; |
|
138 TRequestStatus* status = &aStatus; |
|
139 User::RequestComplete(status, KErrNone); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // Constructor |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CGlxtnClientTask::CGlxtnClientTask(const TGlxtnTaskId& aId, |
|
147 const TGlxMediaId& aItemId, MGlxtnThumbnailCreatorClient& aClient) : |
|
148 CGlxtnTask(aId, aItemId, aClient.ThumbnailStorage()), iClient(aClient) |
|
149 { |
|
150 TRACER("CGlxtnClientTask::CGlxtnClientTask()"); |
|
151 } |
|