|
1 /* |
|
2 * Copyright (c) 2010 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 * Maptile service implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <centralrepository.h> |
|
21 |
|
22 #include "maptileservice.h" |
|
23 #include "maptiledblookuptable.h" |
|
24 |
|
25 // CONSTANTS |
|
26 // Maptile interface uid |
|
27 const TUid KUidMapTileInterface = { 0x2002E6E8 }; |
|
28 // Central Repository Key IDs |
|
29 const TInt KEnableLocationFeature = 0x1; |
|
30 const TInt KLocationFeatureAppContacts = 0x1; |
|
31 const TInt KLocationFeatureAppCalendar = 0x2; |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // MapTileService::isLocationFeatureEnabled() |
|
36 // Checks whether location feature is enabled or disabled |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 bool MapTileService::isLocationFeatureEnabled(AppType appType) |
|
40 { |
|
41 |
|
42 //Create the centrep with uid 0x2002C3A8 |
|
43 bool iLocationFeatureEnabled = false; |
|
44 |
|
45 CRepository* centralRepository = NULL; |
|
46 |
|
47 TRAPD( err, centralRepository = CRepository::NewL( KUidMapTileInterface ) ); |
|
48 if ( KErrNone == err ) |
|
49 { |
|
50 TInt repValue; |
|
51 |
|
52 //Get the Location feature flag |
|
53 int ret=0; |
|
54 if ( appType == AppTypeContacts ) |
|
55 { |
|
56 ret = centralRepository->Get( KEnableLocationFeature , repValue ); |
|
57 } |
|
58 else if ( appType == AppTypeCalendar ) |
|
59 { |
|
60 ret = centralRepository->Get( KEnableLocationFeature , repValue ); |
|
61 } |
|
62 |
|
63 if ( ret == KErrNone && repValue == 1 ) |
|
64 { |
|
65 iLocationFeatureEnabled = true; |
|
66 } |
|
67 |
|
68 delete centralRepository; |
|
69 } |
|
70 |
|
71 return iLocationFeatureEnabled; |
|
72 |
|
73 } |
|
74 |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // MapTileService::getMapTileImage() |
|
78 // Gets the maptile image path associated with a contact. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 QString MapTileService::getMapTileImage( int id, AddressType sourceType ) |
|
82 { |
|
83 |
|
84 //Image file to return; |
|
85 |
|
86 //Maptile database instance |
|
87 CLookupMapTileDatabase* mapTileDatabase = NULL; |
|
88 |
|
89 TRAPD( err, mapTileDatabase = CLookupMapTileDatabase::NewL( |
|
90 KMapTileLookupDatabaseName ) ); |
|
91 if ( KErrNone == err ) |
|
92 { |
|
93 TLookupItem lookupItem; |
|
94 lookupItem.iUid = id; |
|
95 switch( sourceType ) |
|
96 { |
|
97 case AddressPlain: |
|
98 lookupItem.iSource = ESourceCalendar; |
|
99 break; |
|
100 case AddressPreference: |
|
101 lookupItem.iSource = ESourceContactsPref; |
|
102 break; |
|
103 case AddressWork: |
|
104 lookupItem.iSource = ESourceContactsWork; |
|
105 break; |
|
106 case AddressHome: |
|
107 lookupItem.iSource = ESourceContactsHome; |
|
108 break; |
|
109 default: |
|
110 break; |
|
111 } |
|
112 |
|
113 TRAP( err , mapTileDatabase->FindEntryL( lookupItem ) ); |
|
114 |
|
115 //delet the database instance |
|
116 delete mapTileDatabase; |
|
117 |
|
118 //if entry available returns the file path otherwise NULL. |
|
119 if ( KErrNone == err ) |
|
120 { |
|
121 //Get the image path |
|
122 QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), |
|
123 lookupItem.iFilePath.Length()); |
|
124 return imageFile; |
|
125 } |
|
126 } |
|
127 |
|
128 return QString(); |
|
129 } |
|
130 |
|
131 // End of file |
|
132 |