1166 |
1171 |
1167 // Next take localized item names for seamless links. |
1172 // Next take localized item names for seamless links. |
1168 TInt contextId; |
1173 TInt contextId; |
1169 TInt resId = 0; |
1174 TInt resId = 0; |
1170 HBufC* name; |
1175 HBufC* name; |
1171 for (int i=0; i<items->Count(); i++) |
1176 |
1172 { |
1177 TBool browserService = ApiProvider().Preferences().ServiceFeature(); |
1173 if (!items->At(i)->IsHidden()) |
1178 TBool firstBoot = ApiProvider().Preferences().GetIntValue( KBrowserFirstBoot ); |
|
1179 TInt serviceUid = KErrNotFound; |
|
1180 |
|
1181 for(int i=0; i<items->Count(); i++) |
|
1182 { |
|
1183 if (!items->At(i)->IsHidden()) |
1174 { |
1184 { |
1175 contextId = items->At(i)->ContextId(); |
1185 contextId = items->At(i)->ContextId(); |
1176 resId = CBrowserFavouritesView::GetSeamlessFolderResourceID( |
1186 |
1177 contextId ); |
1187 if ( firstBoot && browserService ) |
1178 |
1188 { |
1179 if (resId) |
1189 //This is the first boot and we need to move Service top of the bookmarks. |
|
1190 //Here we save uid for Service item. |
|
1191 if ( contextId == KFavouritesServiceContextId ) |
|
1192 { |
|
1193 serviceUid = items->IndexToUid( i ); |
|
1194 } |
|
1195 } |
|
1196 |
|
1197 resId = CBrowserFavouritesView::GetSeamlessFolderResourceID( |
|
1198 contextId ); |
|
1199 if(resId) |
1180 { |
1200 { |
1181 name = iCoeEnv->AllocReadResourceLC( resId ); |
1201 name = iCoeEnv->AllocReadResourceLC( resId ); |
1182 items->At(i)->SetNameL(name->Des()); |
1202 items->At(i)->SetNameL(name->Des()); |
1183 CleanupStack::PopAndDestroy(); // name |
1203 CleanupStack::PopAndDestroy(); // name |
1184 } |
1204 } |
1186 else |
1206 else |
1187 { |
1207 { |
1188 items->Delete(i); |
1208 items->Delete(i); |
1189 i--; |
1209 i--; |
1190 } |
1210 } |
|
1211 } |
|
1212 |
|
1213 if ( firstBoot && browserService && serviceUid != KErrNotFound ) |
|
1214 { |
|
1215 //get current order array |
|
1216 CBrowserBookmarksOrder* currentOrder = CBrowserBookmarksOrder::NewLC(); |
|
1217 CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>( KGranularityHigh ); |
|
1218 CleanupStack::PushL( orderArray ); |
|
1219 |
|
1220 iModel->Database().GetData( KFavouritesRootUid, *currentOrder ); |
|
1221 orderArray->AppendL( &( currentOrder->GetBookMarksOrder()[0] ), currentOrder->GetBookMarksOrder().Count()); |
|
1222 |
|
1223 //First sort UI. Move Service |
|
1224 CFavouritesItem* serviceCopy = CFavouritesItem::NewLC(); |
|
1225 const CFavouritesItem* serviceItem = items->ItemByUid( serviceUid ); |
|
1226 if ( serviceItem ) |
|
1227 { |
|
1228 *serviceCopy = *serviceItem; |
|
1229 items->Delete( serviceUid ); |
|
1230 items->InsertL( 0, serviceCopy ); //ownership transfered |
|
1231 CleanupStack::Pop( serviceCopy ); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 User::Leave( KErrNotFound ); |
|
1236 } |
|
1237 |
|
1238 //Next change order in db. Move Service |
|
1239 orderArray->InsertL( 0, orderArray->At( serviceUid ) ); |
|
1240 orderArray->Delete( serviceUid+1 ); |
|
1241 |
|
1242 //save changes to db |
|
1243 currentOrder->SetBookMarksOrderL( *orderArray ); |
|
1244 iModel->Database().SetData( KFavouritesRootUid, *currentOrder ); |
|
1245 |
|
1246 CleanupStack::PopAndDestroy( 2 ); //orderArray, currentOrder |
|
1247 //service moved to top of the bookmark list. We can set firstboot value to false |
|
1248 // so now we can set firstboot value to false. |
|
1249 CRepository* repository = CRepository::NewLC( KCRUidBrowser ); |
|
1250 User::LeaveIfError( repository->Set(KBrowserFirstBoot, EFalse) ); |
|
1251 CleanupStack::PopAndDestroy( repository ); |
1191 } |
1252 } |
1192 |
1253 |
1193 CleanupStack::Pop(); // items: passing ownership to listbox. |
1254 CleanupStack::Pop(); // items: passing ownership to listbox. |
1194 iContainer->Listbox()->SetDataL |
1255 iContainer->Listbox()->SetDataL |
1195 ( items, /*ApiProvider().CommsModel(),*/ aKeepState ); |
1256 ( items, /*ApiProvider().CommsModel(),*/ aKeepState ); |