|
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: Viag Home Zone (VHZ) publisher. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include "activeidle2domaincrkeys.h" |
|
21 #include "aivhzpublisher.h" |
|
22 #include "aicontentobserver.h" |
|
23 #include "ainetworkinfolistener.h" |
|
24 |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 CAiVHZPublisher::CAiVHZPublisher() |
|
29 { |
|
30 } |
|
31 |
|
32 |
|
33 void CAiVHZPublisher::ConstructL() |
|
34 { |
|
35 iListener = CAiNetworkInfoListener::InstanceL(); |
|
36 |
|
37 CRepository* rep = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
38 CleanupStack::PushL( rep ); |
|
39 |
|
40 TBool value = EFalse; |
|
41 TInt err = rep->Get( KAIVHZInMainpane, value ); |
|
42 if( err == KErrNone ) |
|
43 { |
|
44 iVhzInMainpane = value; |
|
45 } |
|
46 CleanupStack::PopAndDestroy( rep ); |
|
47 } |
|
48 |
|
49 |
|
50 CAiVHZPublisher* CAiVHZPublisher::NewL() |
|
51 { |
|
52 CAiVHZPublisher* self = new( ELeave ) CAiVHZPublisher; |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 CAiVHZPublisher::~CAiVHZPublisher() |
|
61 { |
|
62 if( iListener ) |
|
63 { |
|
64 iListener->RemoveObserver( *this ); |
|
65 iListener->Release(); |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
70 void CAiVHZPublisher::ResumeL() |
|
71 { |
|
72 iListener->AddObserverL( *this ); |
|
73 } |
|
74 |
|
75 |
|
76 void CAiVHZPublisher::Subscribe( MAiContentObserver& aObserver, |
|
77 MAiPropertyExtension& aExtension, |
|
78 MAiPublishPrioritizer& /*aPrioritizer*/, |
|
79 MAiPublisherBroadcaster& /*aBroadcaster*/ ) |
|
80 { |
|
81 iContentObserver = &aObserver; |
|
82 iExtension = &aExtension; |
|
83 } |
|
84 |
|
85 |
|
86 void CAiVHZPublisher::RefreshL( TBool /*aClean*/ ) |
|
87 { |
|
88 const TNWInfo& nwInfo = iListener->NetworkInfo(); |
|
89 |
|
90 //Check if the Viag indicator in network info is different than none... |
|
91 if( nwInfo.iViagIndicatorType != ENWViagIndicatorTypeNone ) |
|
92 { |
|
93 //... and then publish it. |
|
94 if( !iVhzInMainpane ) |
|
95 { |
|
96 iContentObserver->Publish( *iExtension, |
|
97 EAiDeviceStatusContentVHZIndicator, |
|
98 nwInfo.iViagTextTag, |
|
99 0 ); |
|
100 } |
|
101 else |
|
102 { |
|
103 iContentObserver->Publish( *iExtension, |
|
104 EAiDeviceStatusContentVHZText, |
|
105 nwInfo.iViagTextTag, |
|
106 0 ); |
|
107 } |
|
108 } |
|
109 else |
|
110 { |
|
111 if( !iVhzInMainpane ) |
|
112 { |
|
113 iContentObserver->Clean( *iExtension, |
|
114 EAiDeviceStatusContentVHZIndicator, |
|
115 0 ); |
|
116 } |
|
117 else |
|
118 { |
|
119 iContentObserver->Clean( *iExtension, |
|
120 EAiDeviceStatusContentVHZText, |
|
121 0 ); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 |
|
127 void CAiVHZPublisher::HandleNetworkInfoChange( |
|
128 const MNWMessageObserver::TNWMessages& aMessage, |
|
129 const TNWInfo& /*aInfo*/, |
|
130 const TBool /*aShowOpInd*/ ) |
|
131 { |
|
132 //if home zone message has arrived, call refresh |
|
133 if ( aMessage == MNWMessageObserver::ENWMessageCurrentHomeZoneMessage ) |
|
134 { |
|
135 TRAP_IGNORE( RefreshL( ETrue ) ); |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 TBool CAiVHZPublisher::RefreshL( TInt aContentId, TBool aClean ) |
|
141 { |
|
142 if( aContentId == EAiDeviceStatusContentVHZIndicator ) |
|
143 { |
|
144 RefreshL( aClean ); |
|
145 return ETrue; |
|
146 } |
|
147 |
|
148 return EFalse; |
|
149 } |