28
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Creates SMS message if Event in MailBox has occurred.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include <mceoutevent.h>
|
|
21 |
#include <mcemanager.h>
|
|
22 |
|
|
23 |
#include "ipvmbxbase.h"
|
|
24 |
#include "ipvmbxlogger.h"
|
|
25 |
#include "ipvmbxpanic.h"
|
|
26 |
#include "ipvmbxengine.h"
|
|
27 |
|
|
28 |
|
|
29 |
const TInt KMinReSubscribeDelta = 600; // 10 min
|
|
30 |
const TInt KMaxReSubscribeDelta = 86400; // 24 h
|
|
31 |
|
|
32 |
_LIT8( KEventHeader8, "message-summary" );
|
|
33 |
|
|
34 |
|
|
35 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
36 |
|
|
37 |
// ----------------------------------------------------------------------------
|
|
38 |
// C++ default constructor can NOT contain any code, that
|
|
39 |
// might leave.
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CIpVmbxBase::CIpVmbxBase(
|
|
43 |
CIpVmbxEngine& aVmbxEngine,
|
|
44 |
CMceManager& aMceManager ) :
|
|
45 |
iSipProfile( NULL ),
|
|
46 |
iMceOutEvent( NULL ),
|
|
47 |
iMceManager( aMceManager ),
|
|
48 |
iVmbxEngine( aVmbxEngine )
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
// Symbian 2nd phase constructor can leave.
|
|
55 |
// ----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
void CIpVmbxBase::ConstructL( TDesC8& aVoiceMailUri8 )
|
|
58 |
{
|
|
59 |
if ( iVmbxUri8.MaxLength() >= aVoiceMailUri8.Length() )
|
|
60 |
{
|
|
61 |
iVmbxUri8.Copy( aVoiceMailUri8 );
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
// ----------------------------------------------------------------------------
|
|
67 |
// Two-phased constructor.
|
|
68 |
// ----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CIpVmbxBase* CIpVmbxBase::NewL(
|
|
71 |
CIpVmbxEngine& aVmbxEngine,
|
|
72 |
TDesC8& aVoiceMailUri8,
|
|
73 |
CMceManager& aMceManager )
|
|
74 |
{
|
|
75 |
IPVMEPRINT( "CIpVmbxBase::NewL" );
|
|
76 |
|
|
77 |
CIpVmbxBase* self = new( ELeave ) CIpVmbxBase(
|
|
78 |
aVmbxEngine,
|
|
79 |
aMceManager );
|
|
80 |
CleanupStack::PushL( self );
|
|
81 |
self->ConstructL( aVoiceMailUri8 );
|
|
82 |
CleanupStack::Pop( self );
|
|
83 |
|
|
84 |
return self;
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
// ----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
CIpVmbxBase::~CIpVmbxBase()
|
|
93 |
{
|
|
94 |
IPVMEPRINT( "CIpVmbxBase::~CIpVmbxBase - IN" );
|
|
95 |
|
|
96 |
delete iMceOutEvent;
|
|
97 |
|
|
98 |
IPVMEPRINT( "CIpVmbxBase::~CIpVmbxBase - OUT" );
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
// ----------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
// ----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CIpVmbxBase::Initialize(
|
|
107 |
TUint32 aServiceProviderId,
|
|
108 |
CSIPProfile& aSipProfile )
|
|
109 |
{
|
|
110 |
iServiceProviderId = aServiceProviderId;
|
|
111 |
iSipProfile = &aSipProfile;
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
// ----------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
// ----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CIpVmbxBase::SubscribeL( TInt aReSubscribe )
|
|
120 |
{
|
|
121 |
IPVMEPRINT( "CIpVmbxAppBase::SubscribeL - IN" );
|
|
122 |
|
|
123 |
if ( aReSubscribe < KMinReSubscribeDelta )
|
|
124 |
{
|
|
125 |
// Resubscribe shouldn't occur too often
|
|
126 |
aReSubscribe = KMinReSubscribeDelta;
|
|
127 |
}
|
|
128 |
else
|
|
129 |
if ( aReSubscribe > KMaxReSubscribeDelta )
|
|
130 |
{
|
|
131 |
// Resubscribe shouldn't occur too infrequently
|
|
132 |
aReSubscribe = KMaxReSubscribeDelta;
|
|
133 |
}
|
|
134 |
|
|
135 |
TUint32 resubscribeInterval = ( TUint32 ) aReSubscribe;
|
|
136 |
|
|
137 |
IPVMEPRINT2( "CIpVmbxAppBase::SubscribeL - resubscribe interval=%d",
|
|
138 |
resubscribeInterval );
|
|
139 |
|
|
140 |
__ASSERT_DEBUG( !iMceOutEvent, Panic( KErrAlreadyExists ) );
|
|
141 |
|
|
142 |
if ( !iMceOutEvent )
|
|
143 |
{
|
|
144 |
iMceOutEvent = CMceOutEvent::NewL(
|
|
145 |
iMceManager,
|
|
146 |
*iSipProfile,
|
|
147 |
iVmbxUri8,
|
|
148 |
KEventHeader8,
|
|
149 |
resubscribeInterval );
|
|
150 |
}
|
|
151 |
else
|
|
152 |
{
|
|
153 |
User::Leave( KErrAlreadyExists );
|
|
154 |
}
|
|
155 |
|
|
156 |
if ( CMceEvent::EIdle == iMceOutEvent->State() )
|
|
157 |
{
|
|
158 |
iMceOutEvent->SubscribeL();
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
User::Leave( KErrNotReady );
|
|
163 |
}
|
|
164 |
iState = ESubscribing;
|
|
165 |
|
|
166 |
IPVMEPRINT( "CIpVmbxAppBase::SubscribeL - OUT" );
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
// ----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
// ----------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CIpVmbxBase::TerminateEventL()
|
|
175 |
{
|
|
176 |
IPVMEPRINT( "CIpVmbxAppBase::TerminateEventL - IN" );
|
|
177 |
|
|
178 |
if ( iMceOutEvent && CMceEvent::EActive == iMceOutEvent->State() )
|
|
179 |
{
|
|
180 |
iMceOutEvent->TerminateL();
|
|
181 |
iState = ETerminating;
|
|
182 |
}
|
|
183 |
else
|
|
184 |
{
|
|
185 |
User::Leave( KErrNotReady );
|
|
186 |
}
|
|
187 |
|
|
188 |
IPVMEPRINT( "CIpVmbxAppBase::TerminateEventL - OUT" );
|
|
189 |
}
|
|
190 |
|
|
191 |
|
|
192 |
// ----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
// ----------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void CIpVmbxBase::DeleteEvent()
|
|
197 |
{
|
|
198 |
delete iMceOutEvent;
|
|
199 |
iMceOutEvent = NULL;
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
// ----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
// ----------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CIpVmbxBase::Cancel()
|
|
208 |
{
|
|
209 |
iState = EDisabled;
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
TUint32 CIpVmbxBase::ServiceProviderId() const
|
|
218 |
{
|
|
219 |
return iServiceProviderId;
|
|
220 |
}
|
|
221 |
|
|
222 |
|
|
223 |
// ----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
// ----------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
const TDesC8& CIpVmbxBase::VmbxUrl() const
|
|
228 |
{
|
|
229 |
return iVmbxUri8;
|
|
230 |
}
|
|
231 |
|
|
232 |
|
|
233 |
// ----------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
// ----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CIpVmbxBase::SetStateRegistered()
|
|
238 |
{
|
|
239 |
iState = ERegistered;
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
// ----------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
// ----------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
CIpVmbxBase::TIpVmbxBaseStates CIpVmbxBase::State() const
|
|
248 |
{
|
|
249 |
return iState;
|
|
250 |
}
|
|
251 |
|
|
252 |
|
|
253 |
// ----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
// ----------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CIpVmbxBase::SetAccountMessageCount( TInt aTotalCount, TInt aNewCount )
|
|
258 |
{
|
|
259 |
iTotalMessageCount = aTotalCount;
|
|
260 |
iNewMessageCount = aNewCount;
|
|
261 |
}
|
|
262 |
|
|
263 |
|
|
264 |
// ----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
// ----------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CIpVmbxBase::AccountMessageCount( TInt& aTotalCount, TInt& aNewCount )
|
|
269 |
{
|
|
270 |
aTotalCount = iTotalMessageCount;
|
|
271 |
aNewCount = iNewMessageCount;
|
|
272 |
}
|
|
273 |
|