|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Active object for monitoring the refresh event. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <RSatSession.h> |
|
22 #include <RSatRefresh.h> |
|
23 |
|
24 #include "CSatRefreshMonitor.h" |
|
25 #include "SatLog.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CSatRefreshMonitor::CSatRefreshMonitor |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSatRefreshMonitor::CSatRefreshMonitor( |
|
36 RSatRefresh& aRefresh, |
|
37 MSatRefreshObserver& aObserver ) : |
|
38 CActive( CActive::EPriorityStandard ), |
|
39 iObserver( aObserver ), |
|
40 iRefresh( aRefresh ), |
|
41 iChangedFiles(), |
|
42 iChangedFilesPckg( iChangedFiles ), |
|
43 iType( ERefreshTypeNotSet ), |
|
44 iTypePckg( iType ) |
|
45 { |
|
46 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::CSatRefreshMonitor calling" ) |
|
47 |
|
48 CActiveScheduler::Add( this ); |
|
49 |
|
50 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::CSatRefreshMonitor exiting" ) |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSatRefreshMonitor::NewL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CSatRefreshMonitor* CSatRefreshMonitor::NewL( |
|
59 RSatRefresh& aRefresh, |
|
60 MSatRefreshObserver& aObserver ) |
|
61 { |
|
62 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::NewL calling" ) |
|
63 |
|
64 CSatRefreshMonitor* self = |
|
65 new ( ELeave ) CSatRefreshMonitor( aRefresh, aObserver ); |
|
66 |
|
67 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::NewL exiting" ) |
|
68 return self; |
|
69 } |
|
70 |
|
71 // Destructor |
|
72 CSatRefreshMonitor::~CSatRefreshMonitor() |
|
73 { |
|
74 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::~CSatRefreshMonitor calling" ) |
|
75 |
|
76 Cancel(); |
|
77 |
|
78 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::~CSatRefreshMonitor exiting" ) |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CSatRefreshMonitor::Start |
|
83 // Starts monitoring the refresh event. |
|
84 // (other items were commented in a header). |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CSatRefreshMonitor::Start() |
|
88 { |
|
89 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::Start calling" ) |
|
90 |
|
91 if ( !IsActive() ) |
|
92 { |
|
93 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::Start set active" ) |
|
94 iRefresh.NotifyRefresh( iTypePckg, iChangedFilesPckg, iStatus ); |
|
95 SetActive(); |
|
96 } |
|
97 |
|
98 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::Start exiting" ) |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSatRefreshMonitor::RunL |
|
103 // Notifies the observer about refresh event. |
|
104 // (other items were commented in a header). |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSatRefreshMonitor::RunL() |
|
108 { |
|
109 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::RunL calling" ) |
|
110 const TInt err( iStatus.Int() ); |
|
111 |
|
112 if ( KErrNone == err ) |
|
113 { |
|
114 iObserver.Refresh( iType, iChangedFiles ); |
|
115 Start(); |
|
116 } |
|
117 else if ( KErrInUse == err ) |
|
118 { |
|
119 LOG( SIMPLE, "SATCLIENT: Attempt to restart, cancelled" ) |
|
120 } |
|
121 else if ( KErrServerTerminated == err ) |
|
122 { |
|
123 LOG( SIMPLE, "SATCLIENT: Server terminated" ) |
|
124 } |
|
125 else if ( KErrCancel != err ) |
|
126 { |
|
127 LOG2( SIMPLE, "SATCLIENT: RunL error: %i", err ) |
|
128 Start(); |
|
129 } |
|
130 else |
|
131 { |
|
132 LOG( SIMPLE, "SATCLIENT: Cancelled" ) |
|
133 } |
|
134 |
|
135 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::RunL exiting" ) |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CSatRefreshMonitor::DoCancel |
|
140 // Cancels the request. |
|
141 // (other items were commented in a header). |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CSatRefreshMonitor::DoCancel() |
|
145 { |
|
146 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::DoCancel calling" ) |
|
147 |
|
148 iRefresh.CancelNotifyRefresh(); |
|
149 |
|
150 LOG( SIMPLE, "SATCLIENT: CSatRefreshMonitor::DoCancel exiting" ) |
|
151 } |
|
152 |
|
153 // End of File |