|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AknAsyncDemoNotify.h" |
|
19 #include <aknNotifyStd.h> |
|
20 |
|
21 EXPORT_C CAknAsyncDemoNotify* CAknAsyncDemoNotify::NewL(const TCallBack& aCallBack) |
|
22 { |
|
23 CAknAsyncDemoNotify* self = new(ELeave) CAknAsyncDemoNotify(aCallBack); |
|
24 CleanupStack::PushL(self); |
|
25 self->ConstructL(); |
|
26 CleanupStack::Pop(); // self |
|
27 return self; |
|
28 } |
|
29 |
|
30 EXPORT_C CAknAsyncDemoNotify::~CAknAsyncDemoNotify() |
|
31 { |
|
32 Cancel(); |
|
33 iNotify.Close(); |
|
34 } |
|
35 |
|
36 EXPORT_C const TDesC8& CAknAsyncDemoNotify::Message() |
|
37 { |
|
38 return iBuf; |
|
39 } |
|
40 |
|
41 CAknAsyncDemoNotify::CAknAsyncDemoNotify(const TCallBack& aCallBack) |
|
42 : CActive(EPriorityNormal), iCallBack(aCallBack) |
|
43 { |
|
44 CActiveScheduler::Add(this); |
|
45 } |
|
46 |
|
47 void CAknAsyncDemoNotify::ConstructL() |
|
48 { |
|
49 QueueL(); |
|
50 } |
|
51 |
|
52 void CAknAsyncDemoNotify::QueueL() |
|
53 { |
|
54 User::LeaveIfError(iNotify.Connect()); |
|
55 iBuf.Zero(); |
|
56 iNotify.StartNotifierAndGetResponse(iStatus, KAknAsyncDemoNotifierUid, KNullDesC8, iBuf); |
|
57 SetActive(); |
|
58 } |
|
59 |
|
60 void CAknAsyncDemoNotify::DoCancel() |
|
61 { |
|
62 iNotify.CancelNotifier(KAknAsyncDemoNotifierUid); |
|
63 } |
|
64 |
|
65 void CAknAsyncDemoNotify::RunL() |
|
66 { |
|
67 User::LeaveIfError(iStatus.Int()); |
|
68 iCallBack.CallBack(); |
|
69 // This is some wierdness in notifiers - you have to entirely cancel, shut down |
|
70 // and reconnect between async requests. |
|
71 iNotify.CancelNotifier(KAknAsyncDemoNotifierUid); |
|
72 iNotify.Close(); |
|
73 QueueL(); |
|
74 } |
|
75 |
|
76 // End of File |