179 // Gets bookmarks from Menu Content Service. |
179 // Gets bookmarks from Menu Content Service. |
180 // --------------------------------------------------------------------------- |
180 // --------------------------------------------------------------------------- |
181 // |
181 // |
182 void CMCSPluginSettingsBkmList::GetBookmarksFromMCSL() |
182 void CMCSPluginSettingsBkmList::GetBookmarksFromMCSL() |
183 { |
183 { |
184 TBool exists( EFalse ); |
|
185 CMenuFilter* filter = CMenuFilter::NewL(); |
184 CMenuFilter* filter = CMenuFilter::NewL(); |
186 CleanupStack::PushL( filter ); |
185 CleanupStack::PushL( filter ); |
187 filter->SetType( KMenuUrl ); |
186 filter->SetType( KMenuUrl ); |
188 const TInt rootId = iMenu.RootFolderL(); |
187 const TInt rootId = iMenu.RootFolderL(); |
189 RArray<TMenuItem> itemArray; |
188 RArray<TMenuItem> itemArray; |
190 CleanupClosePushL( itemArray ); |
189 CleanupClosePushL( itemArray ); |
191 iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
190 iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
192 TInt count( itemArray.Count() ); |
191 TInt count( itemArray.Count() ); |
193 for ( TInt i = 0; i < count; i++ ) |
192 for ( TInt i = 0; i < count; i++ ) |
194 { |
193 { |
|
194 TBool uidExists( EFalse ); |
|
195 TBool nameExists( EFalse ); |
|
196 TBool urlExists( EFalse ); |
195 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemArray[i] ); |
197 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemArray[i] ); |
196 CleanupStack::PushL( menuItem ); |
198 CleanupStack::PushL( menuItem ); |
197 TPtrC uid = menuItem->GetAttributeL( KMenuAttrUid, exists ); |
199 TPtrC uid = menuItem->GetAttributeL( KMenuAttrUid, uidExists ); |
198 TPtrC name = menuItem->GetAttributeL( KMenuAttrLongName, exists ); |
200 TPtrC name = menuItem->GetAttributeL( KMenuAttrLongName, nameExists ); |
199 TPtrC url = menuItem->GetAttributeL( KUrl, exists ); |
201 TPtrC url = menuItem->GetAttributeL( KUrl, urlExists ); |
200 // if exists, add it |
202 // if all attrib exists, add it ( url ignored ) |
201 if ( exists ) |
203 if ( uidExists && uid.Length() > 0 && |
|
204 nameExists && name.Length() > 0 ) |
202 { |
205 { |
203 AddBookmarkL( uid, name, url, EMCSBookmark ); |
206 AddBookmarkL( uid, name, url, EMCSBookmark ); |
204 } |
207 } |
205 |
|
206 CleanupStack::PopAndDestroy( menuItem ); |
208 CleanupStack::PopAndDestroy( menuItem ); |
207 } |
209 } |
208 |
210 |
209 CleanupStack::PopAndDestroy( &itemArray ); |
211 CleanupStack::PopAndDestroy( &itemArray ); |
210 CleanupStack::PopAndDestroy( filter ); |
212 CleanupStack::PopAndDestroy( filter ); |
214 // --------------------------------------------------------------------------- |
216 // --------------------------------------------------------------------------- |
215 // If bookmark was selected amongst Favourites, new menu item is created into MCS. |
217 // If bookmark was selected amongst Favourites, new menu item is created into MCS. |
216 // If predefined bookmark was selected, MCS menu item is retrieved |
218 // If predefined bookmark was selected, MCS menu item is retrieved |
217 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |
218 // |
220 // |
219 CMenuItem& CMCSPluginSettingsBkmList::ItemL( TInt aIndex ) |
221 CMenuItem* CMCSPluginSettingsBkmList::ItemL( TInt aIndex ) |
220 { |
222 { |
221 CMenuItem* menuItem( NULL ); |
223 CMenuItem* menuItem( NULL ); |
222 CBkmListItem* listItem = iListItems[aIndex]; |
224 CBkmListItem* listItem = iListItems[aIndex]; |
223 if ( listItem->iType == EFavBookmark ) |
225 if ( listItem->iType == EFavBookmark ) |
224 { |
226 { |
226 } |
228 } |
227 else |
229 else |
228 { |
230 { |
229 menuItem = MCSMenuItemL( *listItem->iUid, *listItem->iCaption, *listItem->iUrl ); |
231 menuItem = MCSMenuItemL( *listItem->iUid, *listItem->iCaption, *listItem->iUrl ); |
230 } |
232 } |
231 return *menuItem; |
233 return menuItem; |
232 } |
234 } |
233 |
235 |
234 // --------------------------------------------------------------------------- |
236 // --------------------------------------------------------------------------- |
235 // Tries to find menuitem with given UID, Name and Url in MCS, |
237 // Tries to find menuitem with given UID, Name and Url in MCS, |
236 // If it does not exist, it is created and saved there. |
238 // If it does not exist, it is created and saved there. |
273 CleanupClosePushL( itemArray ); |
275 CleanupClosePushL( itemArray ); |
274 iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
276 iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
275 if( itemArray.Count() > 0 ) |
277 if( itemArray.Count() > 0 ) |
276 { |
278 { |
277 item = CMenuItem::OpenL( iMenu, itemArray[0] ); |
279 item = CMenuItem::OpenL( iMenu, itemArray[0] ); |
278 CleanupStack::PushL( item ); |
280 if ( item ) |
279 iMenuItems.AppendL( item ); |
281 { |
280 CleanupStack::Pop( item ); |
282 CleanupStack::PushL( item ); |
|
283 iMenuItems.AppendL( item ); |
|
284 CleanupStack::Pop( item ); |
|
285 } |
281 } |
286 } |
282 CleanupStack::PopAndDestroy( &itemArray ); |
287 CleanupStack::PopAndDestroy( &itemArray ); |
283 CleanupStack::PopAndDestroy( filter ); |
288 CleanupStack::PopAndDestroy( filter ); |
284 return item; |
289 return item; |
285 } |
290 } |
298 listItem->iType = aType; |
303 listItem->iType = aType; |
299 if( aUrl.Length() > 0 ) |
304 if( aUrl.Length() > 0 ) |
300 { |
305 { |
301 listItem->iUrl = aUrl.AllocL(); |
306 listItem->iUrl = aUrl.AllocL(); |
302 } |
307 } |
|
308 else |
|
309 { |
|
310 listItem->iUrl = KNullDesC().AllocL(); |
|
311 } |
|
312 |
303 TLinearOrder<CBkmListItem> sortMethod(CBkmListItem::CompareCaption); |
313 TLinearOrder<CBkmListItem> sortMethod(CBkmListItem::CompareCaption); |
304 User::LeaveIfError(iListItems.InsertInOrderAllowRepeats(listItem, sortMethod)); |
314 User::LeaveIfError(iListItems.InsertInOrderAllowRepeats(listItem, sortMethod)); |
305 CleanupStack::Pop(listItem); |
315 CleanupStack::Pop(listItem); |
306 } |
316 } |
307 |
317 |