|
1 /* |
|
2 * Copyright (c) 2002-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: CenRepListener listens to given Central Repository setting id and notifies its |
|
15 * observer if there is any change. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "hspscenreplistener.h" |
|
22 |
|
23 #include "hsps_builds_cfg.hrh" |
|
24 #include <centralrepository.h> |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // ChspsCenRepListener::ChspsCenRepListener |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 ChspsCenRepListener::ChspsCenRepListener( MhspsCenRepObserver& aObserver, |
|
34 const TUid& aRepositoryUid ) : |
|
35 CActive( EPriorityStandard ), |
|
36 iObserver( aObserver ), |
|
37 iRepositoryUid( aRepositoryUid ) |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // ChspsCenRepListener::ConstructL |
|
43 // Symbian 2nd phase constructor can leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void ChspsCenRepListener::ConstructL() |
|
47 { |
|
48 iRepository = CRepository::NewL( iRepositoryUid ); |
|
49 CActiveScheduler::Add( this ); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // ChspsCenRepListener::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 ChspsCenRepListener* ChspsCenRepListener::NewL( MhspsCenRepObserver& aObserver, |
|
58 const TUid& aRepositoryUid ) |
|
59 { |
|
60 ChspsCenRepListener* self = new(ELeave) ChspsCenRepListener( aObserver, |
|
61 aRepositoryUid ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // ------------------------------------------------------------------------------ |
|
71 // ChspsCenRepListener::~ChspsCenRepListener |
|
72 // |
|
73 // ------------------------------------------------------------------------------ |
|
74 // |
|
75 ChspsCenRepListener::~ChspsCenRepListener() |
|
76 { |
|
77 Cancel(); |
|
78 delete iRepository; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // ChspsCenRepListener::RunL |
|
83 // From CActive. Called when asynchronous request is completed. |
|
84 // Notifies the observer |
|
85 // (other items were commented in a header). |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void ChspsCenRepListener::RunL() |
|
89 { |
|
90 TUint32 status = static_cast<TUint32>( iStatus.Int() ); |
|
91 iObserver.HandleCenRepChangeL( status ); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // ChspsCenRepListener::DoCancel |
|
96 // From CActive. Called when asynchronous request is canceled |
|
97 // (other items were commented in a header). |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void ChspsCenRepListener::DoCancel() |
|
101 { |
|
102 if( IsActive() ) |
|
103 { |
|
104 iRepository->NotifyCancelAll(); |
|
105 } |
|
106 } |
|
107 |
|
108 // ------------------------------------------------------------------------------ |
|
109 // ChspsCenRepListener::Setup |
|
110 // Sets up the listener to listen to changes in Central Repository setting aId |
|
111 // (other items were commented in a header). |
|
112 // ------------------------------------------------------------------------------ |
|
113 // |
|
114 void ChspsCenRepListener::Setup( TUint32 aId ) |
|
115 { |
|
116 if( !IsActive() ) |
|
117 { |
|
118 iRepository->NotifyRequest( aId, iStatus ); |
|
119 iRepositoryUid.iUid = aId; |
|
120 SetActive(); |
|
121 } |
|
122 } |
|
123 |
|
124 // ------------------------------------------------------------------------------ |
|
125 // ChspsCenRepListener::SetupAll |
|
126 // Sets up the listener to listen to changes in Central Repository for all settings |
|
127 // (other items were commented in a header). |
|
128 // ------------------------------------------------------------------------------ |
|
129 // |
|
130 void ChspsCenRepListener::SetupAll() |
|
131 { |
|
132 if( !IsActive() ) |
|
133 { |
|
134 TInt err = iRepository->NotifyRequest( 0x00000000,0x00000000, iStatus ); |
|
135 SetActive(); |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 // End of File |