66
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 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: Provides methods for calendar session for a client thread on the server-side.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
//debug
|
|
21 |
#include "calendarui_debug.h"
|
|
22 |
|
|
23 |
#include "CalSvrSession.h"
|
|
24 |
|
|
25 |
#include "CalenServer.h"
|
|
26 |
#include "CalSvrDef.h"
|
|
27 |
|
|
28 |
|
|
29 |
/**
|
|
30 |
* CCalSvrSession
|
|
31 |
**/
|
|
32 |
|
|
33 |
// construct/destruct
|
|
34 |
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
// ?classname::?member_function
|
|
37 |
// ?implementation_description
|
|
38 |
// (other items were commented in a header).
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CCalSvrSession::CCalSvrSession()
|
|
42 |
{
|
|
43 |
TRACE_ENTRY_POINT;
|
|
44 |
TRACE_EXIT_POINT;
|
|
45 |
}
|
|
46 |
|
|
47 |
// FIXME: this is never called ! Correct would have been createL
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// ?classname::?member_function
|
|
50 |
// ?implementation_description
|
|
51 |
// (other items were commented in a header).
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CCalSvrSession::ConstructL(CCalenServer& /*aServer*/)
|
|
55 |
{
|
|
56 |
TRACE_ENTRY_POINT;
|
|
57 |
TRACE_EXIT_POINT;
|
|
58 |
}
|
|
59 |
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
// ?classname::?member_function
|
|
62 |
// ?implementation_description
|
|
63 |
// (other items were commented in a header).
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CCalSvrSession::~CCalSvrSession()
|
|
67 |
{
|
|
68 |
TRACE_ENTRY_POINT;
|
|
69 |
|
|
70 |
PIM_TRAPD_HANDLE( DoDestructL() );
|
|
71 |
|
|
72 |
TRACE_EXIT_POINT;
|
|
73 |
}
|
|
74 |
|
|
75 |
void CCalSvrSession::DoDestructL()
|
|
76 |
{
|
|
77 |
TRACE_ENTRY_POINT;
|
|
78 |
|
|
79 |
CancelInitializeL();
|
|
80 |
|
|
81 |
if( iRegistered ) // if still registered
|
|
82 |
{
|
|
83 |
Server()->UnregisterUserL(*this);
|
|
84 |
iRegistered = EFalse;
|
|
85 |
}
|
|
86 |
|
|
87 |
TRACE_EXIT_POINT;
|
|
88 |
}
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// ?classname::?member_function
|
|
91 |
// ?implementation_description
|
|
92 |
// (other items were commented in a header).
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
CCalenServer* CCalSvrSession::Server() const
|
|
96 |
{
|
|
97 |
TRACE_ENTRY_POINT;
|
|
98 |
/**
|
|
99 |
* Return the Calendar server.
|
|
100 |
*
|
|
101 |
* This deliberately hides the CSession2 version of this
|
|
102 |
* function, to prevent lots of ugly casts around the code.
|
|
103 |
**/
|
|
104 |
CCalenServer* server = const_cast<CCalenServer*>(static_cast<const CCalenServer*>(CSession2::Server()));
|
|
105 |
|
|
106 |
TRACE_EXIT_POINT;
|
|
107 |
return server;
|
|
108 |
}
|
|
109 |
|
|
110 |
// service dispatcher - from CSession2
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
// ?classname::?member_function
|
|
114 |
// ?implementation_description
|
|
115 |
// (other items were commented in a header).
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
void CCalSvrSession::ServiceL(const RMessage2& aMessage)
|
|
119 |
{
|
|
120 |
TRACE_ENTRY_POINT;
|
|
121 |
|
|
122 |
switch (aMessage.Function())
|
|
123 |
{
|
|
124 |
case ECalSvrInitialize:
|
|
125 |
{
|
|
126 |
InitializeL(aMessage);
|
|
127 |
// Asynchronous service, message completion not done here
|
|
128 |
}
|
|
129 |
break;
|
|
130 |
|
|
131 |
case ECalSvrUninitialize:
|
|
132 |
{
|
|
133 |
UninitializeL();
|
|
134 |
aMessage.Complete(KErrNone);
|
|
135 |
}
|
|
136 |
break;
|
|
137 |
|
|
138 |
case ECalSvrCancelInitialize:
|
|
139 |
{
|
|
140 |
CancelInitializeL();
|
|
141 |
aMessage.Complete(KErrNone);
|
|
142 |
}
|
|
143 |
break;
|
|
144 |
|
|
145 |
default:
|
|
146 |
Server()->PanicClient(aMessage, EBadRequest);
|
|
147 |
|
|
148 |
}
|
|
149 |
|
|
150 |
TRACE_EXIT_POINT;
|
|
151 |
}
|
|
152 |
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
// ?classname::?member_function
|
|
155 |
// ?implementation_description
|
|
156 |
// (other items were commented in a header).
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
void CCalSvrSession::CancelInitializeL()
|
|
160 |
{
|
|
161 |
TRACE_ENTRY_POINT;
|
|
162 |
|
|
163 |
if(!iInitActive)
|
|
164 |
{
|
|
165 |
TRACE_EXIT_POINT;
|
|
166 |
return;
|
|
167 |
}
|
|
168 |
if(iRegistered)
|
|
169 |
{
|
|
170 |
Server()->UnregisterUserL(*this);
|
|
171 |
iRegistered = EFalse;
|
|
172 |
}
|
|
173 |
if(!iInitMessage.IsNull() )
|
|
174 |
{
|
|
175 |
iInitMessage.Complete(KErrCancel);
|
|
176 |
iInitActive = EFalse;
|
|
177 |
}
|
|
178 |
|
|
179 |
TRACE_EXIT_POINT;
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// ?classname::?member_function
|
|
184 |
// ?implementation_description
|
|
185 |
// (other items were commented in a header).
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CCalSvrSession::InitializeL(const RMessage2& aMessage)
|
|
189 |
{
|
|
190 |
TRACE_ENTRY_POINT;
|
|
191 |
|
|
192 |
__ASSERT_DEBUG(!iInitActive, User::Panic(_L("CalSvrSession::InitializeL"), 0));
|
|
193 |
__ASSERT_DEBUG(!iRegistered, User::Panic(_L("CalSvrSession::InitializeL"), 1));
|
|
194 |
iInitMessage = aMessage;
|
|
195 |
iInitActive = ETrue;
|
|
196 |
iRegistered = ETrue;
|
|
197 |
Server()->RegisterUserL(*this);
|
|
198 |
|
|
199 |
TRACE_EXIT_POINT;
|
|
200 |
}
|
|
201 |
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
// ?classname::?member_function
|
|
204 |
// ?implementation_description
|
|
205 |
// (other items were commented in a header).
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CCalSvrSession::UninitializeL()
|
|
209 |
{
|
|
210 |
TRACE_ENTRY_POINT;
|
|
211 |
|
|
212 |
__ASSERT_DEBUG(iRegistered, User::Panic(_L("CalSvrSession::UninitializeL"), 0));
|
|
213 |
CancelInitializeL(); // this will unregister if init active
|
|
214 |
if (iRegistered) // if still registered
|
|
215 |
{
|
|
216 |
Server()->UnregisterUserL(*this);
|
|
217 |
iRegistered = EFalse;
|
|
218 |
}
|
|
219 |
|
|
220 |
TRACE_EXIT_POINT;
|
|
221 |
}
|
|
222 |
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
// ?classname::?member_function
|
|
225 |
// ?implementation_description
|
|
226 |
// (other items were commented in a header).
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CCalSvrSession::DatabaseOpened()
|
|
230 |
{
|
|
231 |
TRACE_ENTRY_POINT;
|
|
232 |
|
|
233 |
HandleInitReady();
|
|
234 |
|
|
235 |
TRACE_EXIT_POINT;
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
// ?classname::?member_function
|
|
241 |
// ?implementation_description
|
|
242 |
// (other items were commented in a header).
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
//srinath
|
|
245 |
void CCalSvrSession::HandleError()
|
|
246 |
{
|
|
247 |
TRACE_ENTRY_POINT;
|
|
248 |
|
|
249 |
if(!iInitMessage.IsNull() )
|
|
250 |
{
|
|
251 |
iInitMessage.Complete(KErrNone);
|
|
252 |
}
|
|
253 |
|
|
254 |
TRACE_EXIT_POINT;
|
|
255 |
}
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// ?classname::?member_function
|
|
259 |
// ?implementation_description
|
|
260 |
// (other items were commented in a header).
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CCalSvrSession::DatabaseTemporarilyClosed()
|
|
264 |
{
|
|
265 |
TRACE_ENTRY_POINT;
|
|
266 |
|
|
267 |
// Do not do anything here.
|
|
268 |
// Client doesn't need to know anything about database being temporarily
|
|
269 |
// closed, because initialize/uninitialize mechanism is meant for
|
|
270 |
// optimization only. From client perspective, it is not real connection
|
|
271 |
// to agenda database, but "a guarantee" that someone is holding open
|
|
272 |
// connection to agenda database, so that subsequent connections from
|
|
273 |
// clients are cheaper.
|
|
274 |
//
|
|
275 |
// After restoring is completed, we need to be sure that there are
|
|
276 |
// no unnecessary notifications to clients.
|
|
277 |
// When we get DatabaseOpened after DatabaseTemporarilyClosed,
|
|
278 |
// there are two options:
|
|
279 |
// 1) Client has been already notified in HandleInitReady.
|
|
280 |
// In this case iInitActive is EFalse, and we don't inform
|
|
281 |
// client. Everything is ok.
|
|
282 |
// 2) Client has been notified yet, i.e. restore started in middle of
|
|
283 |
// CalenSvrDBManager opening connection to database. In this case
|
|
284 |
// we want client to be notified. And this happens as iInitActive
|
|
285 |
// is still ETrue.
|
|
286 |
TRACE_EXIT_POINT;
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Called by server when agenda observer notifies of change
|
|
291 |
**/
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
// ?classname::?member_function
|
|
294 |
// ?implementation_description
|
|
295 |
// (other items were commented in a header).
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
void CCalSvrSession::HandleInitReady()
|
|
299 |
{
|
|
300 |
TRACE_ENTRY_POINT;
|
|
301 |
|
|
302 |
if(iInitActive)
|
|
303 |
{
|
|
304 |
iInitMessage.Complete(KErrNone);
|
|
305 |
iInitActive = EFalse;
|
|
306 |
}
|
|
307 |
|
|
308 |
TRACE_EXIT_POINT;
|
|
309 |
}
|
|
310 |
|
|
311 |
|
|
312 |
// End of File
|