author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 23 | 50974a8b132e |
parent 5 | 989d2f495d90 |
child 38 | ea43c23d28d2 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2009 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 the License "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 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// STLport regression testsuite component. |
|
20 |
// To compile as a separate example, please #define MAIN. |
|
21 |
||
22 |
#include <e32base.h> |
|
23 |
////#include <senduiconsts.h> |
|
24 |
#include "messagingservice.h" |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
25 |
#include <badesca.h> |
5 | 26 |
|
27 |
#include <f32file.h> |
|
28 |
#include "messageheader.h" |
|
29 |
#ifdef MAIN |
|
30 |
#define ReqNotification main |
|
31 |
#endif |
|
32 |
||
33 |
/** |
|
34 |
* Callback class for asynchronous SAPI message header |
|
35 |
*/ |
|
36 |
class CMsgCallbackHeader : public CMsgCallbackBase |
|
37 |
{ |
|
38 |
public: |
|
39 |
||
40 |
static CMsgCallbackHeader* NewL(CActiveSchedulerWait* aWaitSchedular, CMessagingService*s); |
|
41 |
||
42 |
virtual ~CMsgCallbackHeader(){} |
|
43 |
||
44 |
virtual void NotifyResultL(TInt aErrCode, TAny* aResult); |
|
45 |
||
46 |
private: |
|
47 |
||
48 |
CMsgCallbackHeader(CActiveSchedulerWait* aWaitSchedular, CMessagingService*s):iWaitSchedular(aWaitSchedular), iservice(s){ } |
|
49 |
||
50 |
CActiveSchedulerWait* iWaitSchedular; |
|
51 |
CMessagingService* iservice; |
|
52 |
}; |
|
53 |
||
54 |
class CTestAsync : public CActive |
|
55 |
{ |
|
56 |
public: |
|
57 |
static CTestAsync* NewL(); |
|
58 |
~CTestAsync(); |
|
59 |
void Start(); |
|
60 |
TInt Result(); |
|
61 |
void CancelNotification() |
|
62 |
{ |
|
63 |
iMessagingService->CancelNotification(ENewMessage, NULL); |
|
64 |
iCallBack = NULL; |
|
65 |
} |
|
66 |
||
67 |
private: |
|
68 |
void ConstructL(); |
|
69 |
CTestAsync(); |
|
70 |
||
71 |
virtual void DoCancel(); |
|
72 |
virtual void RunL(); |
|
73 |
||
74 |
||
75 |
void TestFunc(); |
|
76 |
||
77 |
||
78 |
||
79 |
private: |
|
80 |
CActiveSchedulerWait* iWaitSchedular; |
|
81 |
CMessagingService* iMessagingService; |
|
82 |
CMsgCallbackHeader* iCallBack; |
|
83 |
TInt iResult; |
|
84 |
}; |
|
85 |
||
86 |
// --------------------------------------------------------------------------- |
|
87 |
// Gives the result of asynchronous SAPI |
|
88 |
// --------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
void CMsgCallbackHeader::NotifyResultL( TInt aErrCode, TAny* aResult ) |
|
91 |
{ |
|
92 |
CMessageHeader* header = (CMessageHeader*)aResult; |
|
93 |
||
94 |
CFilterParamInfo* filterParams = CFilterParamInfo::NewL(); |
|
95 |
||
96 |
filterParams->SetMessageIdFilter( header->MessageId() ); |
|
97 |
||
98 |
CMsvEntrySelection* entrySelection = NULL; |
|
99 |
||
100 |
iservice->GetIdListL( filterParams, 0, NULL, entrySelection ); |
|
101 |
||
102 |
if ( entrySelection && ( entrySelection->Count() > 0 )) |
|
103 |
{ |
|
104 |
TInt result = KErrNone; |
|
105 |
} |
|
106 |
||
107 |
entrySelection->Reset(); |
|
108 |
delete entrySelection; |
|
109 |
delete filterParams; |
|
110 |
||
111 |
iWaitSchedular->AsyncStop(); |
|
112 |
||
113 |
||
114 |
} |
|
115 |
||
116 |
CMsgCallbackHeader* CMsgCallbackHeader::NewL(CActiveSchedulerWait* aWaitSchedular, CMessagingService* s) |
|
117 |
{ |
|
118 |
CMsgCallbackHeader* self = new (ELeave) CMsgCallbackHeader(aWaitSchedular, s); |
|
119 |
return self; |
|
120 |
} |
|
121 |
||
122 |
CTestAsync* CTestAsync::NewL() |
|
123 |
{ |
|
124 |
CTestAsync* self = new(ELeave) CTestAsync(); |
|
125 |
self->ConstructL(); |
|
126 |
return self; |
|
127 |
} |
|
128 |
||
129 |
CTestAsync::~CTestAsync() |
|
130 |
{ |
|
131 |
Cancel(); |
|
132 |
||
133 |
if(iWaitSchedular->IsStarted()) |
|
134 |
iWaitSchedular->AsyncStop(); |
|
135 |
||
136 |
if(iMessagingService) |
|
137 |
delete iMessagingService; |
|
138 |
||
139 |
if(iWaitSchedular) |
|
140 |
delete iWaitSchedular; |
|
141 |
} |
|
142 |
||
143 |
void CTestAsync::ConstructL() |
|
144 |
{ |
|
145 |
CActiveScheduler::Add(this); |
|
146 |
iMessagingService = CMessagingService::NewL(); |
|
147 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
148 |
} |
|
149 |
||
150 |
CTestAsync::CTestAsync() : |
|
151 |
CActive(EPriorityStandard) |
|
152 |
{ |
|
153 |
} |
|
154 |
||
155 |
void CTestAsync::DoCancel() |
|
156 |
{ |
|
157 |
||
158 |
} |
|
159 |
||
160 |
void CTestAsync::RunL() |
|
161 |
{ |
|
162 |
TestFunc(); |
|
163 |
} |
|
164 |
||
165 |
void CTestAsync::Start() |
|
166 |
{ |
|
167 |
iCallBack = CMsgCallbackHeader::NewL(iWaitSchedular, iMessagingService); |
|
168 |
SetActive(); |
|
169 |
TRequestStatus* temp = &iStatus; |
|
170 |
User::RequestComplete(temp, KErrNone); |
|
171 |
iWaitSchedular->Start(); |
|
172 |
} |
|
173 |
||
174 |
TInt CTestAsync::Result() |
|
175 |
{ |
|
176 |
return iResult; |
|
177 |
} |
|
178 |
||
179 |
void CTestAsync::TestFunc() |
|
180 |
{ |
|
181 |
||
182 |
TRAPD(err, iMessagingService->RequestNotification(ENewMessage, iCallBack)); |
|
183 |
} |
|
184 |
||
185 |
int ReqNotification(int, char**) |
|
186 |
{ |
|
187 |
__UHEAP_MARK; |
|
188 |
CTestAsync* test = CTestAsync::NewL(); |
|
189 |
||
190 |
test->Start(); |
|
191 |
||
192 |
test->CancelNotification(); |
|
193 |
||
194 |
delete test; |
|
195 |
__UHEAP_MARKEND; |
|
196 |
return KErrNone; |
|
197 |
||
198 |
||
199 |
||
200 |
return 0; |
|
201 |
} |