13 * |
13 * |
14 * Description: mailbox branding object |
14 * Description: mailbox branding object |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
|
19 |
|
20 #include "emailmailboxinfo_p.h" |
|
21 #include "nmutilitiescommonheaders.h" |
18 #include "nmutilitiescommonheaders.h" |
22 #include "nmcenrepkeys.h" |
19 |
23 #include <QRegExp> |
20 // data type match the types used by the corresponding APIs |
24 #include <QStringList> |
21 const long int NmEmailCenrep = 0x2001E277; |
25 |
22 const unsigned long int NmWlbBrandName = 0xfffffffb; |
26 const unsigned long int partialKey = 0x0; |
23 const unsigned long int NmWlbMailboxName = 0xfffffffc; |
27 const unsigned long int bitMask = 0x0F000000; |
24 const unsigned long int NmWlbIconPath = 0xfffffffd; |
|
25 |
|
26 const unsigned long int NmPartialKey = 0x0; |
|
27 const unsigned long int NmBitMask = 0x0F000000; |
28 |
28 |
29 EmailMailboxInfoPrivate* EmailMailboxInfoPrivate::mSelf = NULL; |
29 EmailMailboxInfoPrivate* EmailMailboxInfoPrivate::mSelf = NULL; |
30 qint32 EmailMailboxInfoPrivate::mReferenceCount = 0; |
30 int EmailMailboxInfoPrivate::mReferenceCount = 0; |
31 |
31 |
32 const QString KBrandNameGmail("Gmail"); |
32 const QString NmBrandNameGmail("Gmail"); |
33 const QString KBrandNameGoogleMail("Google Mail"); |
33 const QString NmBrandNameGoogleMail("Google Mail"); |
34 |
34 |
35 const QString KMCCGermany("262"); |
35 const QString NmMCCGermany("262"); |
36 const QString KMCCUK1("234"); |
36 const QString NmMCCUK1("234"); |
37 const QString KMCCUK2("235"); |
37 const QString NmMCCUK2("235"); |
38 |
38 |
39 const quint8 KGermanyTzId = 36; |
39 const quint8 NmGermanyTzId = 36; |
40 const quint8 KUKTzId = 104; |
40 const quint8 NmUKTzId = 104; |
41 |
41 |
42 using namespace NmBrandingApi; |
|
43 using namespace QtMobility; |
42 using namespace QtMobility; |
44 |
43 |
45 /*! |
44 /*! |
46 private constructor |
45 private constructor |
47 */ |
46 */ |
126 /*! |
120 /*! |
127 returns branding icon of given domain |
121 returns branding icon of given domain |
128 \param branding identifier |
122 \param branding identifier |
129 \return branding icon |
123 \return branding icon |
130 */ |
124 */ |
131 QString EmailMailboxInfoPrivate::icon(const QVariant &identifier) |
125 QString EmailMailboxInfoPrivate::icon(const QString &identifier) |
132 { |
126 { |
133 NM_FUNCTION; |
127 NM_FUNCTION; |
134 |
128 |
135 QString returnValue = ""; |
129 QString returnValue = ""; |
136 QString domainName = ""; |
130 |
137 if (identifier.canConvert<QString> ()) { |
131 if (identifier.length() > 0) { |
138 domainName = identifier.value<QString> (); |
132 processCenRepRecords(identifier); |
139 int delimIndex = domainName.lastIndexOf('@'); |
|
140 if(delimIndex >= 0) { |
|
141 domainName = domainName.mid(delimIndex + 1); |
|
142 } |
|
143 } |
|
144 |
|
145 if (domainName.length() > 0){ |
|
146 processCenRepRecords(domainName); |
|
147 returnValue = mTempIcon; |
133 returnValue = mTempIcon; |
148 } |
134 } |
149 |
135 |
150 return returnValue; |
136 return returnValue; |
151 } |
137 } |
164 |
150 |
165 XQSettingsManager cenRepManager; |
151 XQSettingsManager cenRepManager; |
166 |
152 |
167 if (brandingId == mWlbDomainName) { |
153 if (brandingId == mWlbDomainName) { |
168 found = true; |
154 found = true; |
169 XQCentralRepositorySettingsKey wlbNameKey(EMAIL_CENREP, WLB_MAILBOX_NAME); |
155 XQCentralRepositorySettingsKey wlbNameKey(NmEmailCenrep, NmWlbMailboxName); |
170 XQCentralRepositorySettingsKey wlbIconKey(EMAIL_CENREP, WLB_ICON_PATH); |
156 XQCentralRepositorySettingsKey wlbIconKey(NmEmailCenrep, NmWlbIconPath); |
171 |
157 |
172 icon = cenRepManager.readItemValue(wlbIconKey, XQSettingsManager::TypeString).value<QString> (); |
158 icon = cenRepManager.readItemValue( |
173 name = cenRepManager.readItemValue(wlbNameKey, XQSettingsManager::TypeString).value<QString> (); |
159 wlbIconKey, XQSettingsManager::TypeString).value<QString> (); |
|
160 |
|
161 name = cenRepManager.readItemValue( |
|
162 wlbNameKey, XQSettingsManager::TypeString).value<QString> (); |
174 } |
163 } |
175 else { |
164 else { |
176 XQCentralRepositorySearchCriteria sCriteria(EMAIL_CENREP, partialKey, bitMask); |
165 XQCentralRepositorySearchCriteria sCriteria(NmEmailCenrep, NmPartialKey, NmBitMask); |
177 XQCentralRepositoryUtils cenrepUtils(cenRepManager); |
166 XQCentralRepositoryUtils cenrepUtils(cenRepManager); |
178 QList<XQCentralRepositorySettingsKey> foundKeys = cenrepUtils.findKeys(sCriteria); |
167 QList<XQCentralRepositorySettingsKey> foundKeys = cenrepUtils.findKeys(sCriteria); |
179 |
168 |
180 foreach(XQCentralRepositorySettingsKey key, foundKeys) |
169 int count = foundKeys.count(); |
181 { |
170 for (int i = 0; i < count && !found; i++) { |
|
171 XQCentralRepositorySettingsKey key = foundKeys[i]; |
|
172 |
182 QString dataRow = ""; |
173 QString dataRow = ""; |
183 if (mBrandingDataMap.contains(key.key())) { |
174 if (mBrandingDataMap.contains(key.key())) { |
184 dataRow = mBrandingDataMap.value(key.key()); |
175 dataRow = mBrandingDataMap.value(key.key()); |
185 } |
176 } |
186 //first we put every spotted data row to map |
177 //first we put every spotted data row to map |
187 else { |
178 else { |
188 QVariant brandingDataRaw = cenRepManager.readItemValue(key, |
179 QVariant brandingDataRaw = cenRepManager.readItemValue( |
189 XQSettingsManager::TypeString); |
180 key, XQSettingsManager::TypeString); |
190 if (brandingDataRaw.canConvert<QString>()) { |
181 |
191 dataRow = brandingDataRaw.value<QString>(); |
182 dataRow = brandingDataRaw.toString(); // empty if cannot be converted |
192 mBrandingDataMap.insert(key.key(), dataRow); |
183 mBrandingDataMap.insert(key.key(), dataRow); |
193 } |
|
194 } |
184 } |
195 |
185 |
196 // then we check if this row contains matching data |
186 // then we check if this row contains matching data |
197 QStringList cenRepRecord = dataRow.split(";"); |
187 QStringList cenRepRecord = dataRow.split(";"); |
198 |
188 |
199 if (cenRepRecord.size() < 4) { |
189 if (cenRepRecord.size() >= 3) { |
200 continue; |
190 |
201 } |
191 QRegExp regExp(cenRepRecord.at(0)); |
202 |
192 regExp.setCaseSensitivity(Qt::CaseInsensitive); |
203 if (!brandingId.contains(cenRepRecord.at(0), Qt::CaseInsensitive)) { |
193 |
204 continue; |
194 if (regExp.exactMatch(brandingId)) { //match |
205 } |
195 found = true; |
206 |
196 icon = "z:/resource/apps/" + cenRepRecord.at(2) + ".svg"; |
207 QRegExp regExp(cenRepRecord.at(1)); |
197 name = cenRepRecord.at(1); |
208 regExp.setCaseSensitivity(Qt::CaseInsensitive); |
198 } |
209 |
|
210 if (regExp.exactMatch(brandingId)) { //match |
|
211 found = true; |
|
212 icon = "z:/resource/apps/" + cenRepRecord.at(3) + ".svg"; |
|
213 name = cenRepRecord.at(2); |
|
214 break; |
|
215 } |
199 } |
216 } |
200 } |
217 } |
201 } |
218 if (!found ) { |
202 if (!found ) { |
219 //get default icon and name |
203 //get default icon and name |
220 icon = "qtg_large_email"; |
204 icon = "qtg_large_email"; |
|
205 // If "." does not match anywhere in the string, split() returns a single-element list |
|
206 // containing brandingId string => no safety check needed |
221 QStringList domain = brandingId.split("."); |
207 QStringList domain = brandingId.split("."); |
222 if (domain.size() > 0) { |
208 name = domain.at(0); |
223 name = domain.at(0); |
|
224 } |
|
225 } |
209 } |
226 mTempIcon = icon; |
210 mTempIcon = icon; |
227 mTempName = name; |
211 mTempName = name; |
228 } |
212 } |
229 |
213 |
230 /*! |
214 /*! |
231 gets current country code |
215 gets current country code |
232 \return current country id |
216 \return current country id |
233 */ |
217 */ |
234 quint8 EmailMailboxInfoPrivate::getCurrentCountryL() const |
218 int EmailMailboxInfoPrivate::getCurrentCountryL() const |
235 { |
219 { |
236 NM_FUNCTION; |
220 NM_FUNCTION; |
|
221 |
|
222 int countryId = NmNotFoundError; |
237 |
223 |
238 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
224 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
239 |
225 |
240 CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL( |
226 CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL( |
241 CTzLocalizedTimeZone::ECurrentZone); |
227 CTzLocalizedTimeZone::ECurrentZone); |
242 CleanupStack::PushL(city); |
228 |
243 |
229 if (city) { |
244 CTzLocalizedCityGroup* cityGroup = localizer->GetCityGroupL(city->GroupId()); |
230 CleanupStack::PushL(city); |
245 |
231 |
246 TUint8 countryId = cityGroup->Id(); |
232 CTzLocalizedCityGroup* cityGroup = localizer->GetCityGroupL(city->GroupId()); |
247 |
233 |
248 delete cityGroup; |
234 if (cityGroup) { |
249 cityGroup = NULL; |
235 countryId = cityGroup->Id(); |
250 |
236 |
251 CleanupStack::PopAndDestroy(2, localizer); |
237 delete cityGroup; |
|
238 cityGroup = NULL; |
|
239 |
|
240 } |
|
241 CleanupStack::PopAndDestroy(city); |
|
242 } |
|
243 |
|
244 CleanupStack::PopAndDestroy(localizer); |
252 |
245 |
253 return countryId; |
246 return countryId; |
254 } |
247 } |
255 |
248 |
256 /*! |
249 /*! |