63 Add entry to MRU database |
63 Add entry to MRU database |
64 \param displayName |
64 \param displayName |
65 \param emailAddress |
65 \param emailAddress |
66 \return success, was the update operation successful |
66 \return success, was the update operation successful |
67 */ |
67 */ |
68 bool EmailMRU::updateMRU(QString displayName, QString emailAddress) |
68 bool EmailMRU::updateMRU(const QString &displayName, const QString &emailAddress) |
69 { |
69 { |
70 NM_FUNCTION; |
70 NM_FUNCTION; |
71 |
71 |
72 bool success = false; |
72 bool success = false; |
73 qint32 foundEntryIndex = searchForAddress(emailAddress); |
73 qint32 foundEntryIndex = searchForAddress(emailAddress); |
139 Writes to central repository |
139 Writes to central repository |
140 \param index where to write |
140 \param index where to write |
141 \param value what to write |
141 \param value what to write |
142 \return success, whether write operation succeeded |
142 \return success, whether write operation succeeded |
143 */ |
143 */ |
144 bool EmailMRU::writeCenRep(qint32 index, QString value) |
144 bool EmailMRU::writeCenRep(qint32 index, const QString &value) |
145 { |
145 { |
146 NM_FUNCTION; |
146 NM_FUNCTION; |
147 |
147 |
148 XQCentralRepositorySettingsKey writeKey(emailMruRepositoryKey, index); |
148 XQCentralRepositorySettingsKey writeKey(emailMruRepositoryKey, index); |
149 bool success = mRepositoryManager->writeItemValue(writeKey, value); |
149 bool success = mRepositoryManager->writeItemValue(writeKey, value); |
229 /*! |
230 /*! |
230 Checks if MRU list already contains the address |
231 Checks if MRU list already contains the address |
231 \param address to search |
232 \param address to search |
232 \return entry index of found address, zero if not found |
233 \return entry index of found address, zero if not found |
233 */ |
234 */ |
234 qint32 EmailMRU::searchForAddress(QString address) |
235 qint32 EmailMRU::searchForAddress(const QString &address) |
235 { |
236 { |
236 NM_FUNCTION; |
237 NM_FUNCTION; |
237 |
238 |
238 quint32 partialKey(0x00000000); |
239 quint32 partialKey(0x00000000); |
239 quint32 bitMask(0x00000000); |
240 quint32 bitMask(0x00000000); |
273 Updates displayname and sets entry as newest |
274 Updates displayname and sets entry as newest |
274 \param entryIndex to update |
275 \param entryIndex to update |
275 \param newDisplayName |
276 \param newDisplayName |
276 \return success was update operation successfull |
277 \return success was update operation successfull |
277 */ |
278 */ |
278 bool EmailMRU::updateEntry(qint32 entryIndex, QString newDisplayName) |
279 bool EmailMRU::updateEntry(qint32 entryIndex, const QString &newDisplayName) |
279 { |
280 { |
280 NM_FUNCTION; |
281 NM_FUNCTION; |
281 |
282 |
282 // Save address |
283 // Save address |
283 QString address = readCenRep(addressKeyByEntryIndex(entryIndex)); |
284 QString address = readCenRep(addressKeyByEntryIndex(entryIndex)); |
284 |
285 |
285 // Move all entries following the one to be updated |
286 // Move all entries following the one to be updated |
286 // until we go past the newest entry |
287 // until we go past the newest entry |
287 for (qint32 i = entryIndex, j = 0; i != mLatestIndex;) { |
288 for (qint32 i = entryIndex, j = 0; i != mLatestIndex;) { |
288 j = i+1; |
289 j = i+1; |
289 if (j > emailAddressHistorySize) j = 1; |
290 |
|
291 if (j > emailAddressHistorySize) { |
|
292 j = 1; |
|
293 } |
290 |
294 |
291 moveEntry(j, i); |
295 moveEntry(j, i); |
292 |
|
293 i++; |
296 i++; |
294 if (i > emailAddressHistorySize) i = 1; |
297 |
|
298 if (i > emailAddressHistorySize) { |
|
299 i = 1; |
|
300 } |
295 } |
301 } |
296 |
302 |
297 // Write the updated entry as the newest entry |
303 // Write the updated entry as the newest entry |
298 return writeEntry(mLatestIndex, newDisplayName, address); |
304 return writeEntry(mLatestIndex, newDisplayName, address); |
299 } |
305 } |
303 \param entryIndex to write |
309 \param entryIndex to write |
304 \param displayName |
310 \param displayName |
305 \param emailAddress |
311 \param emailAddress |
306 \return success was update operation successfull |
312 \return success was update operation successfull |
307 */ |
313 */ |
308 bool EmailMRU::writeEntry(qint32 entryIndex, QString displayName, QString emailAddress) |
314 bool EmailMRU::writeEntry(qint32 entryIndex, const QString &displayName, |
|
315 const QString &emailAddress) |
309 { |
316 { |
310 NM_FUNCTION; |
317 NM_FUNCTION; |
311 |
318 |
312 bool nameSuccess = false; |
319 bool nameSuccess = false; |
313 bool addressSuccess = false; |
320 bool addressSuccess = false; |