|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Closed user group (CUG) publisher. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aidevstaplgres.rsg> |
|
20 #include <StringLoader.h> |
|
21 #include "aicugpublisher.h" |
|
22 #include "aicontentobserver.h" |
|
23 #include "ainetworkinfolistener.h" |
|
24 |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 CAiCUGPublisher::CAiCUGPublisher() |
|
29 { |
|
30 } |
|
31 |
|
32 |
|
33 void CAiCUGPublisher::ConstructL() |
|
34 { |
|
35 User::LeaveIfError( iSSSettings.Open() ); |
|
36 } |
|
37 |
|
38 |
|
39 CAiCUGPublisher* CAiCUGPublisher::NewL() |
|
40 { |
|
41 CAiCUGPublisher* self = new( ELeave ) CAiCUGPublisher; |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 CAiCUGPublisher::~CAiCUGPublisher() |
|
50 { |
|
51 //Cancel listenning CUG changes. |
|
52 iSSSettings.CancelAll( *this ); |
|
53 iSSSettings.Close(); |
|
54 delete iCugText; |
|
55 } |
|
56 |
|
57 |
|
58 void CAiCUGPublisher::ResumeL() |
|
59 { |
|
60 //Start listening CUG changes. |
|
61 TInt err = iSSSettings.Register( ESSSettingsCug, *this ); |
|
62 |
|
63 if( err == KErrNotSupported || |
|
64 err == KErrAlreadyExists ) |
|
65 { |
|
66 //CUG not supported, or already registered |
|
67 err = KErrNone; |
|
68 } |
|
69 |
|
70 User::LeaveIfError( err ); |
|
71 } |
|
72 |
|
73 |
|
74 void CAiCUGPublisher::Subscribe( MAiContentObserver& aObserver, |
|
75 MAiPropertyExtension& aExtension, |
|
76 MAiPublishPrioritizer& /*aPrioritizer*/, |
|
77 MAiPublisherBroadcaster& /*aBroadcaster*/ ) |
|
78 { |
|
79 iContentObserver = &aObserver; |
|
80 iExtension = &aExtension; |
|
81 } |
|
82 |
|
83 |
|
84 void CAiCUGPublisher::RefreshL( TBool /*aClean*/ ) |
|
85 { |
|
86 //Get current CUG value and publish it. |
|
87 TInt value; |
|
88 if ( iSSSettings.Get( ESSSettingsCug, value ) != KErrNone ) |
|
89 { |
|
90 value = ESSSettingsCugDefault; |
|
91 } |
|
92 |
|
93 UpdateCUGIndicatorL( value ); |
|
94 } |
|
95 |
|
96 |
|
97 void CAiCUGPublisher::PhoneSettingChanged( TSSSettingsSetting aSetting, |
|
98 TInt aNewValue ) |
|
99 { |
|
100 if( aSetting == ESSSettingsCug ) |
|
101 { |
|
102 TRAP_IGNORE( UpdateCUGIndicatorL( aNewValue ) ); |
|
103 } |
|
104 } |
|
105 |
|
106 |
|
107 void CAiCUGPublisher::UpdateCUGIndicatorL( TInt aValue ) |
|
108 { |
|
109 //Check if the CUG is valid |
|
110 if( iSSSettings.IsValueValidCugIndex( aValue ) ) |
|
111 { |
|
112 // Information already current, no need to update text |
|
113 if ( iCugValue != aValue ) |
|
114 { |
|
115 iCugValue = aValue; |
|
116 delete iCugText; |
|
117 iCugText = NULL; |
|
118 // Read CUG indicator format from resource file and publish |
|
119 // content as a text. |
|
120 iCugText = StringLoader::LoadL( |
|
121 R_ACTIVEIDLE_CUG_INDICATOR_FORMAT, |
|
122 aValue ); |
|
123 |
|
124 } |
|
125 if ( iCugText ) |
|
126 { |
|
127 iContentObserver->Publish( *iExtension, |
|
128 EAiDeviceStatusContentCUGIndicator, |
|
129 *iCugText, |
|
130 0 ); |
|
131 } |
|
132 else |
|
133 { |
|
134 iContentObserver->Clean( *iExtension, |
|
135 EAiDeviceStatusContentCUGIndicator, |
|
136 0 ); |
|
137 } |
|
138 } |
|
139 else |
|
140 { |
|
141 //CUG is not valid, call clean. |
|
142 iContentObserver->Clean( *iExtension, |
|
143 EAiDeviceStatusContentCUGIndicator, |
|
144 0 ); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 TBool CAiCUGPublisher::RefreshL( TInt aContentId, TBool aClean ) |
|
150 { |
|
151 if( aContentId == EAiDeviceStatusContentCUGIndicator ) |
|
152 { |
|
153 RefreshL( aClean ); |
|
154 return ETrue; |
|
155 } |
|
156 |
|
157 return EFalse; |
|
158 } |