|
1 /* |
|
2 * Copyright (c) 2005 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: Notifier class implementation for SuplSettings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <centralrepository.h> |
|
22 |
|
23 #include "epos_csuplsettings.h" |
|
24 #include "epos_suplsessionnotifier.h" |
|
25 #include "epos_msuplsessionobserver.h" |
|
26 #include "epos_csuplsettingsinternalcrkeys.h" |
|
27 |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // |
|
34 CSuplSessionNotifier::CSuplSessionNotifier( MSuplSessionObserver& aObserver ) |
|
35 :CActive(CActive::EPriorityStandard), |
|
36 iObserver(aObserver) |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 |
|
42 // EPOC default constructor can leave. |
|
43 void CSuplSessionNotifier::ConstructL() |
|
44 { |
|
45 CActiveScheduler::Add(this); |
|
46 iRepository = CRepository::NewL(KCRUidSuplSettings); |
|
47 |
|
48 // Start listening |
|
49 StartListening(); |
|
50 } |
|
51 |
|
52 // Two-phased constructor. |
|
53 CSuplSessionNotifier* CSuplSessionNotifier::NewL( |
|
54 MSuplSessionObserver& aObserver) |
|
55 { |
|
56 CSuplSessionNotifier* self = |
|
57 new (ELeave) CSuplSessionNotifier(aObserver); |
|
58 |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(self); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // Destructor |
|
68 CSuplSessionNotifier::~CSuplSessionNotifier() |
|
69 { |
|
70 Cancel(); |
|
71 |
|
72 delete iRepository; |
|
73 iRepository = NULL; |
|
74 |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // CSuplSessionNotifier::RunL |
|
79 // (other items were commented in a header). |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CSuplSessionNotifier::RunL() |
|
83 { |
|
84 TInt event; |
|
85 iRepository->Get(KSuplSessionDBEvent, event); |
|
86 TReal sessionID; |
|
87 iRepository->Get(KSuplSessionDBChangedSessionId, sessionID); |
|
88 MSuplSessionObserver::TSuplSessionEventType eventType = (MSuplSessionObserver::TSuplSessionEventType)event; |
|
89 iObserver.HandleSuplSessionChangeL(eventType,sessionID); |
|
90 |
|
91 StartListening(); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CSuplSessionNotifier::DoCancel |
|
96 // (other items were commented in a header). |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CSuplSessionNotifier::DoCancel() |
|
100 { |
|
101 iRepository->NotifyCancel(KSuplSessionDBEvent); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CSuplSessionNotifier::RunError |
|
106 // (other items were commented in a header). |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 TInt CSuplSessionNotifier::RunError(TInt /*aError*/) |
|
110 { |
|
111 return KErrNone; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CSuplSessionNotifier::StartListening |
|
116 // (other items were commented in a header). |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 void CSuplSessionNotifier::StartListening() |
|
120 { |
|
121 iStatus = KRequestPending; |
|
122 |
|
123 // Request for notification for DB field change |
|
124 iRepository->NotifyRequest(KSuplSessionDBEvent, iStatus); |
|
125 SetActive(); |
|
126 } |
|
127 // End of File |