|
1 /* |
|
2 * Copyright (c) 2008 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: CMSPropertyWatcher class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // Include Files |
|
21 #include <mediaservant.rsg> |
|
22 |
|
23 #include "mspropertywatcher.h" |
|
24 #include "msdebug.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CMSPropertyWatcher::CMSPropertyWatcher |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CMSPropertyWatcher::CMSPropertyWatcher() |
|
34 : CActive(CActive::EPriorityStandard) |
|
35 { |
|
36 LOG(_L("[MediaServant]\t CMSPropertyWatcher::CMSPropertyWatcher")); |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CMSPropertyWatcher::NewL |
|
42 // Two-phased constructor. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CMSPropertyWatcher* CMSPropertyWatcher::NewL() |
|
46 { |
|
47 LOG(_L("[MediaServant]\t CMSPropertyWatcher::NewL")); |
|
48 |
|
49 CMSPropertyWatcher* self = CMSPropertyWatcher::NewLC(); |
|
50 CleanupStack::Pop( self ); |
|
51 |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CMSPropertyWatcher::NewLC |
|
57 // Two-phased constructor. |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CMSPropertyWatcher* CMSPropertyWatcher::NewLC() |
|
61 { |
|
62 LOG(_L("[MediaServant]\t CMSPropertyWatcher::NewLC")); |
|
63 |
|
64 CMSPropertyWatcher* self = new ( ELeave ) CMSPropertyWatcher(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CMSPropertyWatcher::ConstructL |
|
73 // Symbian 2nd phase constructor can leave. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CMSPropertyWatcher::ConstructL() |
|
77 { |
|
78 LOG(_L("[MediaServant]\t CMSPropertyWatcher::ConstructL")); |
|
79 |
|
80 // Define new property |
|
81 TInt err = RProperty::Define( KCmPropertyCat, |
|
82 KCmProperty, |
|
83 RProperty::EByteArray, |
|
84 sizeof(TCmProgressInfo)); |
|
85 if (err != KErrAlreadyExists) |
|
86 { |
|
87 User::LeaveIfError(err); |
|
88 } |
|
89 |
|
90 User::LeaveIfError(iProgressInfo .Attach(KCmPropertyCat,KCmProperty)); |
|
91 CActiveScheduler::Add(this); |
|
92 } |
|
93 |
|
94 |
|
95 // Destructor |
|
96 CMSPropertyWatcher::~CMSPropertyWatcher() |
|
97 { |
|
98 LOG(_L("[MediaServant]\t CMSPropertyWatcher::~CMSPropertyWatcher")); |
|
99 |
|
100 Cancel(); |
|
101 iProgressInfo.Close(); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CMSPropertyWatcher::StartL |
|
106 // Starts active object |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CMSPropertyWatcher::StartL() |
|
110 { |
|
111 RunL(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CMSPropertyWatcher::Stop |
|
116 // Stops active object |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void CMSPropertyWatcher::Stop() |
|
120 { |
|
121 Cancel(); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CMSPropertyWatcher::RunL |
|
126 // Called when asyncronous request is ready |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CMSPropertyWatcher::RunL() |
|
130 { |
|
131 LOG(_L("[MediaServant]\t CMSPropertyWatcher::RunL")); |
|
132 |
|
133 // resubscribe before processing new value to prevent missing updates |
|
134 iProgressInfo.Subscribe( iStatus ); |
|
135 SetActive(); |
|
136 |
|
137 TCmProgressInfo info; |
|
138 |
|
139 // initialise values on info to remove compilation warning |
|
140 info.iService = ECmServiceNone; // Service identifier |
|
141 info.iTotalItems = KErrNone; // Total count of items |
|
142 info.iProcessedItems = KErrNone; // Processed items |
|
143 info.iItemsToTransferPerService = KErrNone; // Remaining items per service |
|
144 |
|
145 TPckgBuf< TCmProgressInfo > paramspkg( info ); |
|
146 |
|
147 // get value |
|
148 if ( iProgressInfo.Get( |
|
149 KCmPropertyCat,KCmProperty,paramspkg ) == KErrNotFound ) |
|
150 { |
|
151 } |
|
152 else |
|
153 { |
|
154 // inform observer |
|
155 iObserver->PropertyChangedL( |
|
156 paramspkg().iService, |
|
157 paramspkg().iTotalItems, |
|
158 paramspkg().iProcessedItems, |
|
159 paramspkg().iItemsToTransferPerService ); |
|
160 } |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CMSPropertyWatcher::DoCancel |
|
165 // Cancels active object |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CMSPropertyWatcher::DoCancel() |
|
169 { |
|
170 LOG(_L("[MediaServant]\t CMSPropertyWatcher::DoCancel")); |
|
171 |
|
172 iProgressInfo.Cancel(); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CMSPropertyWatcher::RunError |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CMSPropertyWatcher::RunError( TInt /*aError*/ ) |
|
180 { |
|
181 return KErrNone; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CMSPropertyWatcher::SetObserver |
|
186 // Set observer |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CMSPropertyWatcher::SetObserver( MMSPropertyObserver* aObserver ) |
|
190 { |
|
191 LOG(_L("[MediaServant]\t CMSPropertyWatcher::SetObserver")); |
|
192 |
|
193 iObserver = aObserver; |
|
194 } |
|
195 // End of file |