|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "calenlocationutil.h" |
|
19 #include <mnproviderfinder.h> |
|
20 #include <aknPopup.h> |
|
21 #include <eikenv.h> |
|
22 #include <aknlists.h> |
|
23 #include <StringLoader.h> |
|
24 #include <Calendar.rsg> |
|
25 #include "calendarui_debug.h" |
|
26 |
|
27 _LIT(KNokiaVendorName, "Nokia gate5 GmbH"); |
|
28 const TInt KArrayGranularity = 5; |
|
29 |
|
30 // ---------------------------------------------------------------------------- |
|
31 // CCalenLocationUtil::ShowLocationReplaceNoticeL |
|
32 // API to tell claendar modules if Nokia maps provider is available in the device or not |
|
33 // (other items were commented in a header). |
|
34 // ---------------------------------------------------------------------------- |
|
35 EXPORT_C TBool CCalenLocationUtil::IsMapProviderAvailableL() |
|
36 { |
|
37 TBool providerAvailable = EFalse; |
|
38 RPointerArray<CMnProvider> providers; |
|
39 const CMnProvider::TServices neededServices = CMnProvider::EServiceNavigation | |
|
40 CMnProvider::EServiceMapView ; |
|
41 MnProviderFinder::FindProvidersL( providers, neededServices ); |
|
42 |
|
43 TInt count = providers.Count(); |
|
44 |
|
45 for(TInt i = 0; i < count; i++) |
|
46 { |
|
47 TPtrC vendorName; |
|
48 providers[i]->GetVendorName(vendorName); |
|
49 if(vendorName.Compare(KNokiaVendorName) == 0) |
|
50 { |
|
51 // Found provider for Nokia maps |
|
52 providerAvailable = ETrue; |
|
53 break; |
|
54 } |
|
55 } |
|
56 providers.ResetAndDestroy(); |
|
57 return providerAvailable; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CCalenLocationUtil::ShowLocationReplaceNoticeL |
|
62 // Utility function to display list query with three strings. |
|
63 // (other items were commented in a header). |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C TInt CCalenLocationUtil::ShowLocationAppendOrReplaceL(RPointerArray<HBufC>& aStrings) |
|
67 { |
|
68 TRACE_ENTRY_POINT; |
|
69 |
|
70 // Create listbox and PUSH it. |
|
71 CAknSinglePopupMenuStyleListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox; |
|
72 CleanupStack::PushL(list); |
|
73 |
|
74 // Create popup list and PUSH it. |
|
75 CAknPopupList* popupList = CAknPopupList::NewL(list, R_AVKON_SOFTKEYS_OK_CANCEL, |
|
76 AknPopupLayouts::EMenuWindow); |
|
77 CleanupStack::PushL(popupList); |
|
78 |
|
79 // initialize listbox. |
|
80 list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect); |
|
81 list->CreateScrollBarFrameL(ETrue); |
|
82 list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
83 CEikScrollBarFrame::EAuto); |
|
84 |
|
85 // Enable Marquee for the list |
|
86 list->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
87 CDesCArrayFlat* listItems = new( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
88 |
|
89 // Add the three strings to listitems |
|
90 HBufC* temp = aStrings[0]; |
|
91 listItems->AppendL(*temp); |
|
92 temp = aStrings[1]; |
|
93 listItems->AppendL(*temp); |
|
94 temp = aStrings[2]; |
|
95 listItems->AppendL(*temp); |
|
96 temp = NULL; |
|
97 |
|
98 CTextListBoxModel* model = list->Model(); |
|
99 model->SetItemTextArray(listItems); |
|
100 model->SetOwnershipType(ELbmOwnsItemArray); |
|
101 |
|
102 // Set title |
|
103 HBufC* title = NULL; |
|
104 title = CCoeEnv::Static()->AllocReadResourceLC( |
|
105 R_CALEN_QTN_UPDATE_LOCATION_TITLE ); |
|
106 popupList->SetTitleL(*title); |
|
107 CleanupStack::PopAndDestroy(title); |
|
108 // Show popup list. |
|
109 TInt popupOk = popupList->ExecuteLD(); |
|
110 CleanupStack::Pop(popupList); |
|
111 if (popupOk) |
|
112 { |
|
113 TInt index = list->CurrentItemIndex(); |
|
114 CleanupStack::PopAndDestroy(list); |
|
115 return index; |
|
116 } |
|
117 else |
|
118 { |
|
119 CleanupStack::PopAndDestroy(list); |
|
120 return KErrCancel; |
|
121 } |
|
122 |
|
123 TRACE_EXIT_POINT; |
|
124 } |
|
125 |
|
126 // End Of File |
|
127 |