|
1 /* |
|
2 * Copyright (c) 2006-2008 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 the License "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: Class for "Add/edit service list" in Settings UI.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknlists.h> |
|
22 #include <akntitle.h> |
|
23 #include <aknPopup.h> |
|
24 #include <aknViewAppUi.h> |
|
25 #include <barsread.h> |
|
26 #include <commdb.h> |
|
27 #include <StringLoader.h> |
|
28 |
|
29 #include "IptvEngineUids.h" |
|
30 #include <vcxnssettingsview.rsg> |
|
31 #include "vcxnsservicesettings.h" |
|
32 |
|
33 #include "CIptvService.h" |
|
34 #include "feedsettingsview.h" |
|
35 #include "feedsettingsviewaddoreditservice.h" |
|
36 #include "feedsettingsviewaddservicelistbox.h" |
|
37 #include "feedsettingsviewserviceselection.h" |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CVcxNsSettingsViewAddOrEditService::CVcxNsSettingsViewAddOrEditService() |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CVcxNsSettingsViewAddOrEditService::CVcxNsSettingsViewAddOrEditService( |
|
46 CVcxNsSettingsViewContainer* aParent, |
|
47 CVcxNsServiceSettings& aServiceSettings ) |
|
48 : iParent( aParent ), |
|
49 iServiceSettings( aServiceSettings ), |
|
50 iServiceType( ( CIptvService::TServiceType ) 0 ) |
|
51 { |
|
52 __ASSERT_DEBUG(iParent, User::Panic(KNullDesC, KErrBadHandle)); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CVcxNsSettingsViewAddOrEditService::NewL() |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CVcxNsSettingsViewAddOrEditService* CVcxNsSettingsViewAddOrEditService::NewL( |
|
60 CVcxNsSettingsViewContainer* aParent, |
|
61 CVcxNsServiceSettings& aServiceSettings ) |
|
62 { |
|
63 CVcxNsSettingsViewAddOrEditService* self = new ( ELeave ) |
|
64 CVcxNsSettingsViewAddOrEditService( aParent, aServiceSettings ); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CVcxNsSettingsViewAddOrEditService::ConstructL() |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CVcxNsSettingsViewAddOrEditService::ConstructL() |
|
76 { |
|
77 iListbox = new (ELeave) CVcxNsSettingsViewAddServiceListbox( |
|
78 iParent, |
|
79 iAddServiceName, |
|
80 iAddServiceAddress, |
|
81 iAddServicePluginType ); |
|
82 |
|
83 iListbox->SetContainerWindowL( *iParent ); |
|
84 iListbox->ConstructFromResourceL( R_VCSETTINGSVIEW_ADDSERVICE_LIST ); |
|
85 iListbox->SetRect(iParent->Rect()); |
|
86 iListbox->ListBox()->ActivateL(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CVcxNsSettingsViewAddOrEditService::~CVcxNsSettingsViewAddOrEditService() |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CVcxNsSettingsViewAddOrEditService::~CVcxNsSettingsViewAddOrEditService() |
|
94 { |
|
95 delete iListbox; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CVcxNsSettingsViewAddOrEditService::ActivateL() |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CVcxNsSettingsViewAddOrEditService::ActivateL() |
|
103 { |
|
104 |
|
105 iParent->SetTitleL( R_IPTV_TITLE_PANE_SETTINGS_TITLE ); |
|
106 |
|
107 iListbox->ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
108 CEikScrollBarFrame::EOff, |
|
109 CEikScrollBarFrame::EAuto ); |
|
110 iListbox->MakeVisible(ETrue); |
|
111 iListbox->DrawNow(); |
|
112 iListbox->ListBox()->UpdateScrollBarsL(); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CVcxNsSettingsViewAddOrEditService::Deactivate() |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CVcxNsSettingsViewAddOrEditService::Deactivate() |
|
120 { |
|
121 TRAP_IGNORE( iListbox->ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
122 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff) ); |
|
123 |
|
124 iListbox->MakeVisible(EFalse); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CVcxNsSettingsViewAddOrEditService::LoadL() |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CVcxNsSettingsViewAddOrEditService::LoadL( |
|
132 TBool aAdding, |
|
133 CIptvService::TServiceType aServiceType ) |
|
134 { |
|
135 // The "add/edit service list" is used for both adding a new service and |
|
136 // for editing an existing service. In both cases, the list just |
|
137 // needs to be initialized with references to correct data items. |
|
138 |
|
139 iServiceType = aServiceType; |
|
140 |
|
141 if (aAdding) // Adding a new service. |
|
142 { |
|
143 HBufC* defaultName = StringLoader::LoadLC(R_IPTV_NEW_SERVICE_DEFAULT); |
|
144 iAddServiceName = *defaultName; |
|
145 iAddServiceAddress.Zero(); |
|
146 CleanupStack::PopAndDestroy(defaultName); |
|
147 |
|
148 iListbox->LoadAddServiceInformationL(aAdding, |
|
149 iAddServiceName, |
|
150 iAddServiceAddress, |
|
151 iServiceType, |
|
152 iAddServicePluginType); |
|
153 } |
|
154 else // Editing an existing service. |
|
155 { |
|
156 CIptvService* iptvService = iParent->ServiceSelection()->GetCurrentServiceL(); |
|
157 |
|
158 if (iptvService) |
|
159 { |
|
160 iAddServiceName = iptvService->GetName(); |
|
161 iAddServiceAddress = iptvService->GetAddress(); |
|
162 iPreviousAddress = iAddServiceAddress; |
|
163 iAddServicePluginType = 0; |
|
164 |
|
165 delete iptvService; |
|
166 iptvService = NULL; |
|
167 |
|
168 iListbox->LoadAddServiceInformationL(aAdding, |
|
169 iAddServiceName, |
|
170 iAddServiceAddress, |
|
171 iServiceType, |
|
172 iAddServicePluginType); |
|
173 } |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CVcxNsSettingsViewAddOrEditService::SaveL() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CVcxNsSettingsViewAddOrEditService::SaveL() |
|
182 { |
|
183 iListbox->SaveAddServiceInformationL(); |
|
184 |
|
185 TUid epgUid; |
|
186 TUid iptvUid; |
|
187 TUid vodUid; |
|
188 |
|
189 switch (iServiceType) |
|
190 { |
|
191 case CIptvService::ELiveTv: |
|
192 break; |
|
193 |
|
194 case CIptvService::EVodCast: // fall through |
|
195 case CIptvService::EVod: |
|
196 { |
|
197 epgUid.iUid = KIptvRssPluginImplementationUid; |
|
198 iptvUid.iUid = 0x00000000; |
|
199 vodUid.iUid = IPTV_HTTP_VOD_DOWNLOAD_PLUGIN_IMPLEMENTATION_UID; |
|
200 } |
|
201 break; |
|
202 |
|
203 default: |
|
204 { |
|
205 epgUid.iUid = KIptvRssPluginImplementationUid; |
|
206 iptvUid.iUid = 0x00000000; |
|
207 vodUid.iUid = IPTV_HTTP_VOD_DOWNLOAD_PLUGIN_IMPLEMENTATION_UID; |
|
208 } |
|
209 break; |
|
210 } |
|
211 |
|
212 if (iListbox->IsAdding()) // Adding a new service. |
|
213 { |
|
214 CIptvIapList* iapList = CIptvIapList::NewL(); |
|
215 CleanupStack::PushL(iapList); |
|
216 |
|
217 // Get IAP list for the new service. |
|
218 iServiceSettings.GetIapListForNewServiceL(*iapList); |
|
219 // User defined services have special description until updated from EPG. |
|
220 HBufC* description = StringLoader::LoadLC(R_IPTV_USER_DEFINED_SERVICE); |
|
221 |
|
222 iServiceSettings.AddServiceL(iAddServiceName, |
|
223 iAddServiceAddress, |
|
224 *description, |
|
225 *iapList, |
|
226 iServiceType, |
|
227 epgUid, |
|
228 iptvUid, |
|
229 vodUid); |
|
230 |
|
231 CleanupStack::PopAndDestroy(description); |
|
232 CleanupStack::PopAndDestroy(iapList); |
|
233 } |
|
234 else // Editing an existing service. |
|
235 { |
|
236 CIptvService* iptvService = iParent->ServiceSelection()->GetCurrentServiceL(); |
|
237 |
|
238 if (iptvService) |
|
239 { |
|
240 CleanupStack::PushL(iptvService); |
|
241 |
|
242 iptvService->SetName(iAddServiceName); |
|
243 iptvService->SetAddress(iAddServiceAddress); |
|
244 iptvService->SetEpgPluginUid(epgUid); |
|
245 iptvService->SetVodPluginUid(vodUid); |
|
246 iptvService->SetIptvPluginUid(iptvUid); |
|
247 |
|
248 if ( iPreviousAddress.Length() > 0 ) |
|
249 { |
|
250 if ( iPreviousAddress.Compare( iAddServiceAddress ) != 0 ) |
|
251 { |
|
252 // Address has been modified |
|
253 } |
|
254 } |
|
255 iPreviousAddress.Zero(); |
|
256 |
|
257 // Update the information of service. |
|
258 iServiceSettings.UpdateServiceL(*iptvService); |
|
259 |
|
260 CleanupStack::PopAndDestroy(iptvService); |
|
261 } |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CVcxNsSettingsViewAddOrEditService::ListBox() |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 CVcxNsSettingsViewAddServiceListbox* CVcxNsSettingsViewAddOrEditService::ListBox() |
|
270 { |
|
271 __ASSERT_DEBUG(iListbox, User::Panic(KNullDesC, KErrBadHandle)); |
|
272 |
|
273 return iListbox; |
|
274 } |