|
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: |
|
15 * Messaging progress watching classes |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <msvapi.h> |
|
24 #include "muiudomainpan.h" |
|
25 #include "MuiuMsvSingleOpWatcher.h" |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KSingleOpWatcherPriority = KMaxTInt; |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // --------------------------------------------------------- |
|
34 // CMsvSingleOpWatcher::NewLC |
|
35 // |
|
36 // --------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C CMsvSingleOpWatcher* CMsvSingleOpWatcher::NewLC( MMsvSingleOpWatcher& aObserver ) |
|
39 { // static |
|
40 CMsvSingleOpWatcher* self = new( ELeave ) CMsvSingleOpWatcher( aObserver ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------- |
|
48 // CMsvSingleOpWatcher::NewL |
|
49 // |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CMsvSingleOpWatcher* CMsvSingleOpWatcher::NewL( MMsvSingleOpWatcher& aObserver ) |
|
53 { // static |
|
54 CMsvSingleOpWatcher* self = NewLC(aObserver); |
|
55 CleanupStack::Pop( self ); // self |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CMsvSingleOpWatcher::CMsvSingleOpWatcher |
|
62 // |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 CMsvSingleOpWatcher::CMsvSingleOpWatcher( MMsvSingleOpWatcher& aObserver ) |
|
66 : CActive( KSingleOpWatcherPriority ), iObserver( aObserver ) |
|
67 { |
|
68 CActiveScheduler::Add( this ); |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CMsvSingleOpWatcher::ConstructL |
|
74 // |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void CMsvSingleOpWatcher::ConstructL() |
|
78 { |
|
79 // Nothing to do, reserved for future use... |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CMsvSingleOpWatcher::~CMsvSingleOpWatcher |
|
85 // |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CMsvSingleOpWatcher::~CMsvSingleOpWatcher() |
|
89 { |
|
90 Cancel(); // Cancel any request, if outstanding. Calls Cancel on iOperation. |
|
91 delete iOperation; |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CMsvSingleOpWatcher::SetOperation |
|
97 // --- Setter --- |
|
98 // Must only be called once during the lifetime of a CMsvSingleOpWatcher object. |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void CMsvSingleOpWatcher::SetOperation(CMsvOperation* aOperation) |
|
102 { |
|
103 __ASSERT_DEBUG( !IsActive(), Panic( EMuiuSingleOpWatcherAlreadyActive ) ); |
|
104 __ASSERT_DEBUG( !iOperation, Panic( EMuiuSingleOpWatcherOperationAlreadySet ) ); |
|
105 __ASSERT_DEBUG( aOperation, Panic( EMuiuSingleOpWatcherOperationNull ) ); |
|
106 |
|
107 // |
|
108 // Take ownership of operation and set our active status so we're handled |
|
109 // by the active scheduler. |
|
110 iOperation = aOperation; |
|
111 iStatus = KRequestPending; |
|
112 SetActive(); |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CMsvSingleOpWatcher::Operation |
|
118 // --- Accessor --- |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C CMsvOperation& CMsvSingleOpWatcher::Operation() const |
|
122 { |
|
123 __ASSERT_DEBUG( iOperation, Panic( EMuiuSingleOpWatcherOperationNull ) ); |
|
124 return *iOperation; |
|
125 } |
|
126 |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CMsvSingleOpWatcher::DoCancel |
|
130 // --- From CActive --- |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CMsvSingleOpWatcher::DoCancel() |
|
134 { |
|
135 |
|
136 // Pass on cancel |
|
137 iOperation->Cancel(); |
|
138 } |
|
139 |
|
140 |
|
141 //------------------------------------ |
|
142 // CMsvSingleOpWatcher::RunL |
|
143 // --- From CActive --- |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CMsvSingleOpWatcher::RunL() |
|
147 { |
|
148 // |
|
149 // Inform client of watcher that the operation has completed |
|
150 iObserver.OpCompleted( *this, iStatus.Int() ); |
|
151 } |
|
152 |
|
153 // End of file |