81
|
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: Private data and helper classes used by class CntCache.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QEvent>
|
|
19 |
#include <QFile>
|
|
20 |
#include <QDir>
|
|
21 |
#include <hbapplication.h>
|
|
22 |
#include <hbstringutil.h>
|
|
23 |
#include <xqutils.h>
|
|
24 |
#include <xqsettingsmanager.h>
|
|
25 |
#include <xqsettingskey.h>
|
|
26 |
#include <e32base.h>
|
|
27 |
#include <s32mem.h>
|
|
28 |
#include <e32std.h>
|
|
29 |
#include <cntdb.h>
|
|
30 |
#include <cntuids.h>
|
|
31 |
#include <cntcacheitems.h>
|
|
32 |
#include <cntnamefetcher.h>
|
|
33 |
#include <cntdebug.h>
|
|
34 |
|
|
35 |
/*!
|
|
36 |
\class CntAllNamesJob
|
|
37 |
\brief Holds info about one job that fetches all names from the database.
|
|
38 |
|
|
39 |
\class CntSrvConnection
|
|
40 |
\brief Issues requests to CntSrv.
|
|
41 |
|
|
42 |
\class CntNameFetcher
|
|
43 |
\brief CntNameFetcher asynchronously fetches all contact names.
|
|
44 |
|
|
45 |
CntNameFetcher can only do one asynchronous job: fetch all contact names.
|
|
46 |
In addition, the class provides a number of synchronous functions:
|
|
47 |
- fetch one name
|
|
48 |
- read/write all names to/from a cache file
|
|
49 |
- compare two names; sort a list of names
|
|
50 |
|
|
51 |
Fetching from file cache is about 10 times faster than fetching from the
|
|
52 |
database, but the file cache may be out-of-date. The intended use is to
|
|
53 |
first fetch from the file cache and later synchronize with the database.
|
|
54 |
*/
|
|
55 |
|
|
56 |
// constants used when fetching names from CntSrv
|
|
57 |
#define KCntSearchResultList 99
|
|
58 |
#define KCntOpenDataBase 100
|
|
59 |
_LIT(KCntServerExe, "CNTSRV.EXE");
|
|
60 |
_LIT(KCntServerName, "CNTSRV");
|
|
61 |
const TInt KAsyncMessageSlots = 6;
|
|
62 |
const TInt KCntServerMajorVersionNumber=1;
|
|
63 |
const TInt KCntServerMinorVersionNumber=1;
|
|
64 |
const TInt KCntServerBuildVersionNumber=1;
|
|
65 |
static const QEvent::Type CntAsynchOperation = QEvent::User;
|
|
66 |
|
|
67 |
// constants used for file cache
|
|
68 |
const QString cacheFolder = "20022EF9";
|
|
69 |
const QString cacheFilename = "contactcache.dat";
|
|
70 |
|
|
71 |
// maximum number of scheduled jobs for name fetcher
|
|
72 |
const int MaxNameJobs = 1;
|
|
73 |
|
|
74 |
/*!
|
|
75 |
Internal class used by CntSrvConnection to issues requests to CntSrv.
|
|
76 |
*/
|
|
77 |
class CntSrvSession : public RSessionBase
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
CntSrvSession() { mConnected = false; }
|
|
81 |
~CntSrvSession() { RHandleBase::Close(); }
|
|
82 |
void executeSqlQueryL(const TDesC &sqlQuery, QList<CntNameCacheItem *> &names, CntNameOrder nameFormat, int sizeHintKB);
|
|
83 |
|
|
84 |
private:
|
|
85 |
void connectCntSrvL();
|
|
86 |
|
|
87 |
private:
|
|
88 |
bool mConnected;
|
|
89 |
};
|
|
90 |
|
|
91 |
CntSrvConnection::CntSrvConnection()
|
|
92 |
: mSession(NULL),
|
|
93 |
mIsAsynchronous(false)
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
CntSrvConnection::~CntSrvConnection()
|
|
98 |
{
|
|
99 |
disconnect();
|
|
100 |
|
|
101 |
if (mThread.isRunning()) {
|
|
102 |
mThread.quit();
|
|
103 |
mThread.wait();
|
|
104 |
}
|
|
105 |
|
|
106 |
delete mSession;
|
|
107 |
|
|
108 |
mNames.clear();
|
|
109 |
}
|
|
110 |
|
|
111 |
void CntSrvConnection::setAsynchronous()
|
|
112 |
{
|
|
113 |
mIsAsynchronous = true;
|
|
114 |
mThread.start();
|
|
115 |
moveToThread(&mThread);
|
|
116 |
}
|
|
117 |
|
|
118 |
bool CntSrvConnection::executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB)
|
|
119 |
{
|
|
120 |
CNT_ENTRY
|
|
121 |
|
|
122 |
if (!mSession) {
|
|
123 |
mSession = new CntSrvSession();
|
|
124 |
}
|
|
125 |
|
|
126 |
if (mIsAsynchronous) {
|
|
127 |
mSqlQuery = sqlQuery;
|
|
128 |
mNameFormat = nameFormat;
|
|
129 |
mSizeHintKB = sizeHintKB;
|
|
130 |
HbApplication::instance()->postEvent(this, new QEvent(CntAsynchOperation));
|
|
131 |
} else {
|
|
132 |
mNames.clear();
|
|
133 |
TPtrC queryPtr(sqlQuery.utf16(), sqlQuery.length());
|
|
134 |
TRAPD(err, mSession->executeSqlQueryL(queryPtr, mNames, nameFormat, sizeHintKB));
|
|
135 |
if (err != KErrNone) {
|
|
136 |
qDeleteAll(mNames);
|
|
137 |
mNames.clear();
|
|
138 |
CNT_EXIT
|
|
139 |
return false;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
CNT_EXIT
|
|
144 |
|
|
145 |
return true;
|
|
146 |
}
|
|
147 |
|
|
148 |
bool CntSrvConnection::event(QEvent *event)
|
|
149 |
{
|
|
150 |
if (event->type() == CntAsynchOperation) {
|
|
151 |
CNT_ENTRY
|
|
152 |
|
|
153 |
mNames.clear();
|
|
154 |
TPtrC ptr(mSqlQuery.utf16(), mSqlQuery.length());
|
|
155 |
TRAPD(err, mSession->executeSqlQueryL(ptr, mNames, mNameFormat, mSizeHintKB));
|
|
156 |
if (err != KErrNone) {
|
|
157 |
qDeleteAll(mNames);
|
|
158 |
mNames.clear();
|
|
159 |
}
|
|
160 |
emit namesRead();
|
|
161 |
qStableSort(mNames.begin(), mNames.end(), CntNameFetcher::compareNames);
|
|
162 |
delete mSession;
|
|
163 |
mSession = NULL;
|
|
164 |
emit namesSorted();
|
|
165 |
|
|
166 |
CNT_EXIT
|
|
167 |
|
|
168 |
return true;
|
|
169 |
}
|
|
170 |
|
|
171 |
return QObject::event(event);
|
|
172 |
}
|
|
173 |
|
|
174 |
/*!
|
|
175 |
Executes a special SQL query: the first column must be the contact id and
|
|
176 |
the subsequent columns must be varchar fields.
|
|
177 |
|
|
178 |
\param sqlQuery the SQL to execute
|
|
179 |
\param names the list where the results will be stored
|
|
180 |
\param nameFormat the format the names should be stored in
|
|
181 |
\param sizeHintKB the expected size of the buffer needed to fit the results; a too
|
|
182 |
small value will effectively double the fetch time, since the
|
|
183 |
buffer is then resized and the data refetched a second time
|
|
184 |
*/
|
|
185 |
void CntSrvSession::executeSqlQueryL(const TDesC& sqlQuery, QList<CntNameCacheItem*> &names, CntNameOrder nameFormat, int sizeHintKB)
|
|
186 |
{
|
|
187 |
int listSize = 0;
|
|
188 |
|
|
189 |
// read the ids and names from the database
|
|
190 |
if (!mConnected) {
|
|
191 |
connectCntSrvL();
|
|
192 |
}
|
|
193 |
|
|
194 |
// allocate tmeporary buffer
|
|
195 |
TInt bufferSize = sizeHintKB * 1024;
|
|
196 |
CBufFlat* buffer = CBufFlat::NewL(256);
|
|
197 |
CleanupStack::PushL(buffer);
|
|
198 |
|
|
199 |
// try to fetch the results, if the fetch fails with
|
|
200 |
// a positive value, it means the buffer was too small
|
|
201 |
// in this case the buffer is resized and the results
|
|
202 |
// are fetched again
|
|
203 |
for (TInt tries = 0; tries < 2 && bufferSize > 0; ++tries) {
|
|
204 |
buffer->ResizeL(bufferSize);
|
|
205 |
TPtr8 bufferPtr = buffer->Ptr(0);
|
|
206 |
TIpcArgs args;
|
|
207 |
args.Set(0, &bufferPtr);
|
|
208 |
args.Set(1, &sqlQuery);
|
|
209 |
bufferSize = SendReceive(KCntSearchResultList, args);
|
|
210 |
CNT_LOG_ARGS("buffer size =" << bufferSize)
|
|
211 |
User::LeaveIfError(bufferSize);
|
|
212 |
}
|
|
213 |
|
|
214 |
// store the formatted names into the list
|
|
215 |
RBufReadStream readStream;
|
|
216 |
TInt id;
|
|
217 |
TBuf<256> firstName;
|
|
218 |
TBuf<256> lastName;
|
|
219 |
|
|
220 |
readStream.Open(*buffer);
|
|
221 |
for (int i = 0; (id = readStream.ReadInt32L()) != 0; ++i) {
|
|
222 |
readStream >> firstName;
|
|
223 |
readStream >> lastName;
|
|
224 |
CntNameCacheItem* item = new (ELeave) CntNameCacheItem(
|
|
225 |
id,
|
|
226 |
QString::fromUtf16(firstName.Ptr(), firstName.Length()),
|
|
227 |
QString::fromUtf16(lastName.Ptr(), lastName.Length()),
|
|
228 |
nameFormat);
|
|
229 |
if (i >= listSize - 1) {
|
|
230 |
// if the list is runnning out of space, resize it;
|
|
231 |
// initial size is 1000 and after that it doubles
|
|
232 |
// every time it runs out of space
|
|
233 |
if (listSize == 0) {
|
|
234 |
listSize = 1000;
|
|
235 |
} else {
|
|
236 |
listSize *= 2;
|
|
237 |
}
|
|
238 |
QT_TRY {
|
|
239 |
names.reserve(listSize);
|
|
240 |
} QT_CATCH (...) {
|
|
241 |
// clean up and return
|
|
242 |
CleanupStack::PopAndDestroy(buffer);
|
|
243 |
qDeleteAll(names);
|
|
244 |
names.clear();
|
|
245 |
return;
|
|
246 |
}
|
|
247 |
}
|
|
248 |
names.append(item);
|
|
249 |
}
|
|
250 |
|
|
251 |
CleanupStack::PopAndDestroy(buffer);
|
|
252 |
}
|
|
253 |
|
|
254 |
/*!
|
|
255 |
Connect to / create a contacts server session.
|
|
256 |
*/
|
|
257 |
void CntSrvSession::connectCntSrvL()
|
|
258 |
{
|
|
259 |
// Assume the server is already running and attempt to create a session
|
|
260 |
// with a maximum of KAsyncMessageSlots message slots.
|
|
261 |
TInt err = CreateSession(KCntServerName,
|
|
262 |
TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber),
|
|
263 |
KAsyncMessageSlots);
|
|
264 |
|
|
265 |
// Server is not running
|
|
266 |
if (err == KErrNotFound) {
|
|
267 |
// Use the RProcess API to start the server.
|
|
268 |
RProcess server;
|
|
269 |
User::LeaveIfError(server.Create(KCntServerExe, KNullDesC));
|
|
270 |
|
|
271 |
// Enforce server to be at system default priority EPriorityForeground
|
|
272 |
server.SetPriority(EPriorityForeground);
|
|
273 |
|
|
274 |
// Synchronize with the server.
|
|
275 |
TRequestStatus reqStatus;
|
|
276 |
server.Rendezvous(reqStatus);
|
|
277 |
server.Resume();
|
|
278 |
|
|
279 |
// Server will call the reciprocal static synchronization call.
|
|
280 |
User::WaitForRequest(reqStatus);
|
|
281 |
server.Close();
|
|
282 |
User::LeaveIfError(reqStatus.Int());
|
|
283 |
|
|
284 |
// Create the server session.
|
|
285 |
User::LeaveIfError(CreateSession(KCntServerName,
|
|
286 |
TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber),
|
|
287 |
KAsyncMessageSlots));
|
|
288 |
} else {
|
|
289 |
User::LeaveIfError(err);
|
|
290 |
}
|
|
291 |
|
|
292 |
TIpcArgs args;
|
|
293 |
args.Set(0, &KNullDesC);
|
|
294 |
User::LeaveIfError(SendReceive(KCntOpenDataBase, args));
|
|
295 |
|
|
296 |
mConnected = true;
|
|
297 |
}
|
|
298 |
|
|
299 |
/*!
|
|
300 |
Creates a CntNameFetcher object.
|
|
301 |
*/
|
|
302 |
CntNameFetcher::CntNameFetcher()
|
|
303 |
: CntAbstractFetcher(MaxNameJobs),
|
|
304 |
mDbConnection(NULL),
|
|
305 |
mAsynchDbConnection(NULL),
|
|
306 |
mSettingsManager(NULL),
|
|
307 |
mNameFormatSetting(NULL),
|
|
308 |
mBufferSizeEstimate(0)
|
|
309 |
{
|
|
310 |
CNT_ENTRY
|
|
311 |
|
|
312 |
// get name format setting and listen to changes
|
|
313 |
mSettingsManager = new XQSettingsManager();
|
|
314 |
mNameFormatSetting = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, KCRCntSettings.iUid, KCntNameOrdering);
|
|
315 |
mNameFormat = static_cast<CntNameOrder>(mSettingsManager->readItemValue(*mNameFormatSetting, XQSettingsManager::TypeInt).toInt());
|
|
316 |
mSettingsManager->startMonitoring(*mNameFormatSetting, XQSettingsManager::TypeInt);
|
|
317 |
connect(mSettingsManager, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), this, SLOT(setNameFormat(const XQSettingsKey&, const QVariant&)));
|
|
318 |
|
|
319 |
// connect to contacts server
|
|
320 |
mDbConnection = new CntSrvConnection();
|
|
321 |
|
|
322 |
CNT_EXIT
|
|
323 |
}
|
|
324 |
|
|
325 |
/*!
|
|
326 |
Destroys a CntNameFetcher object.
|
|
327 |
*/
|
|
328 |
CntNameFetcher::~CntNameFetcher()
|
|
329 |
{
|
|
330 |
CNT_ENTRY
|
|
331 |
|
|
332 |
delete mSettingsManager;
|
|
333 |
delete mNameFormatSetting;
|
|
334 |
delete mDbConnection;
|
|
335 |
delete mAsynchDbConnection;
|
|
336 |
|
|
337 |
CNT_EXIT
|
|
338 |
}
|
|
339 |
|
|
340 |
/*!
|
|
341 |
Reads names from the file cache.
|
|
342 |
|
|
343 |
\return true if the names were read successfully from the cache file
|
|
344 |
|
|
345 |
*/
|
|
346 |
bool CntNameFetcher::readNamesFromCache(QList<CntNameCacheItem*> &names)
|
|
347 |
{
|
|
348 |
CNT_ENTRY
|
|
349 |
|
|
350 |
bool success = true;
|
|
351 |
quint32 itemCount;
|
|
352 |
quint32 nameFormat;
|
|
353 |
|
|
354 |
QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename);
|
|
355 |
if (!cacheFile.open(QIODevice::ReadOnly)) {
|
|
356 |
return false;
|
|
357 |
}
|
|
358 |
|
|
359 |
QDataStream in(&cacheFile);
|
|
360 |
|
|
361 |
mBufferSizeEstimate = 0;
|
|
362 |
QT_TRY {
|
|
363 |
// read header: nr of items, name format
|
|
364 |
in >> itemCount;
|
|
365 |
in >> nameFormat;
|
|
366 |
names.reserve(itemCount);
|
|
367 |
|
|
368 |
// populate list with names
|
|
369 |
while (itemCount-- > 0) {
|
|
370 |
CntNameCacheItem *item = CntNameCacheItem::internalize(in, (CntNameOrder) nameFormat);
|
|
371 |
names.append(item);
|
|
372 |
mBufferSizeEstimate += 4 + 2 * item->name().length();
|
|
373 |
}
|
|
374 |
} QT_CATCH (...) {
|
|
375 |
qDeleteAll(names);
|
|
376 |
names.clear();
|
|
377 |
success = false;
|
|
378 |
}
|
|
379 |
|
|
380 |
cacheFile.close();
|
|
381 |
|
|
382 |
CNT_EXIT
|
|
383 |
|
|
384 |
return success;
|
|
385 |
}
|
|
386 |
|
|
387 |
/*!
|
|
388 |
Write names to the file cache.
|
|
389 |
*/
|
|
390 |
bool CntNameFetcher::writeNamesToCache(const QList<CntNameCacheItem*> &names) const
|
|
391 |
{
|
|
392 |
CNT_ENTRY
|
|
393 |
|
|
394 |
bool success = true;
|
|
395 |
|
|
396 |
// create folder for cache file if it does not already exist
|
|
397 |
QString path = XQUtils::phoneMemoryRootPath() + cacheFolder;
|
|
398 |
if (!QDir(path).exists()) {
|
|
399 |
QDir dir(XQUtils::phoneMemoryRootPath());
|
|
400 |
if (!dir.mkdir(cacheFolder)) {
|
|
401 |
CNT_EXIT_ARGS("failed to create folder: " << path)
|
|
402 |
return false;
|
|
403 |
}
|
|
404 |
|
|
405 |
// have to use native Symbian code to make the dir hidden
|
|
406 |
RFs fs;
|
|
407 |
fs.Connect();
|
|
408 |
TPtrC pathPtr(path.utf16(), path.length());
|
|
409 |
if (fs.SetAtt(pathPtr, KEntryAttHidden, 0) != KErrNone) {
|
|
410 |
fs.Close();
|
|
411 |
return false;
|
|
412 |
}
|
|
413 |
fs.Close();
|
|
414 |
}
|
|
415 |
|
|
416 |
// open cache file for writing
|
|
417 |
QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename);
|
|
418 |
if (!cacheFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
|
419 |
CNT_EXIT_ARGS("failed to create file")
|
|
420 |
return false;
|
|
421 |
}
|
|
422 |
QDataStream out(&cacheFile);
|
|
423 |
|
|
424 |
// write the names to the cache file
|
|
425 |
QT_TRY {
|
|
426 |
// write header
|
|
427 |
out << names.size();
|
|
428 |
out << (quint32) mNameFormat;
|
|
429 |
|
|
430 |
// write list with names
|
|
431 |
foreach (CntNameCacheItem* name, names) {
|
|
432 |
name->externalize(out);
|
|
433 |
}
|
|
434 |
} QT_CATCH (...) {
|
|
435 |
success = false;
|
|
436 |
}
|
|
437 |
|
|
438 |
cacheFile.close();
|
|
439 |
|
|
440 |
CNT_EXIT
|
|
441 |
|
|
442 |
return success;
|
|
443 |
}
|
|
444 |
|
|
445 |
/*!
|
|
446 |
Reads the name of one contact from the contact database synchronously.
|
|
447 |
|
|
448 |
\param contactId the id of the contact
|
|
449 |
*/
|
|
450 |
CntNameCacheItem* CntNameFetcher::fetchOneName(QContactLocalId contactId) const
|
|
451 |
{
|
|
452 |
CNT_ENTRY
|
|
453 |
|
|
454 |
QString sqlQuery = QString("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1 AND contact_id=%1").arg(contactId);
|
|
455 |
mDbConnection->executeSqlQuery(sqlQuery, mNameFormat, 2);
|
|
456 |
|
|
457 |
if (mDbConnection->names().size() == 0) {
|
|
458 |
return NULL;
|
|
459 |
}
|
|
460 |
|
|
461 |
CNT_EXIT
|
|
462 |
|
|
463 |
return mDbConnection->names().at(0);
|
|
464 |
}
|
|
465 |
|
|
466 |
/*!
|
|
467 |
Reads the names of all contacts from the contact database asynchronously.
|
|
468 |
*/
|
|
469 |
void CntNameFetcher::processNextJob()
|
|
470 |
{
|
|
471 |
CNT_ENTRY
|
|
472 |
|
|
473 |
if (isProcessingJob() || !hasScheduledJobs()) {
|
|
474 |
return;
|
|
475 |
}
|
|
476 |
|
|
477 |
// there is only one type of job, so we can delete it without inspection
|
|
478 |
delete takeNextJob();
|
|
479 |
|
|
480 |
if (mBufferSizeEstimate == 0) {
|
|
481 |
mBufferSizeEstimate = 240 * 1024;
|
|
482 |
}
|
|
483 |
|
|
484 |
CNT_LOG_ARGS("buffer size =" << mBufferSizeEstimate)
|
|
485 |
|
|
486 |
mAsynchDbConnection = new CntSrvConnection();
|
|
487 |
mAsynchDbConnection->setAsynchronous();
|
|
488 |
connect(mAsynchDbConnection, SIGNAL(namesRead()), this, SIGNAL(databaseAccessComplete()));
|
|
489 |
connect(mAsynchDbConnection, SIGNAL(namesSorted()), this, SLOT(sendCompletionSignal()));
|
|
490 |
mAsynchDbConnection->executeSqlQuery("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1", mNameFormat, 16 + mBufferSizeEstimate / 1024);
|
|
491 |
|
|
492 |
CNT_EXIT
|
|
493 |
}
|
|
494 |
|
|
495 |
bool CntNameFetcher::isProcessingJob()
|
|
496 |
{
|
|
497 |
return (mAsynchDbConnection != NULL);
|
|
498 |
}
|
|
499 |
|
|
500 |
/*!
|
|
501 |
Sorts the names quickly and in a locale aware manner.
|
|
502 |
*/
|
|
503 |
void CntNameFetcher::sortNames(QList<CntNameCacheItem *> &names) const
|
|
504 |
{
|
|
505 |
CNT_ENTRY
|
|
506 |
|
|
507 |
qStableSort(names.begin(), names.end(), CntNameFetcher::compareNames);
|
|
508 |
|
|
509 |
CNT_EXIT
|
|
510 |
}
|
|
511 |
|
|
512 |
/*!
|
|
513 |
Compares a pair of contact names and returns true if the first
|
|
514 |
one should be presented before the second one in a list. This
|
|
515 |
static function is used e.g. when sorting lists of names.
|
|
516 |
*/
|
|
517 |
bool CntNameFetcher::compareNames(const CntNameCacheItem* a, const CntNameCacheItem* b)
|
|
518 |
{
|
|
519 |
QString aName = a->name();
|
|
520 |
QString bName = b->name();
|
|
521 |
|
|
522 |
if (aName.isEmpty()) {
|
|
523 |
return false;
|
|
524 |
} else if (bName.isEmpty()) {
|
|
525 |
return true;
|
|
526 |
}
|
|
527 |
|
|
528 |
return (HbStringUtil::compareC(aName, bName) < 0);
|
|
529 |
}
|
|
530 |
|
|
531 |
/*!
|
|
532 |
Notifies clients that the name format has changed. This function is called by the framework
|
|
533 |
if the name format settings is changed, see the constructor.
|
|
534 |
*/
|
|
535 |
void CntNameFetcher::setNameFormat(const XQSettingsKey &/*key*/, const QVariant &value)
|
|
536 |
{
|
|
537 |
CNT_ENTRY
|
|
538 |
|
|
539 |
bool ok = false;
|
|
540 |
CntNameOrder newNameFormat = static_cast<CntNameOrder>(value.toInt(&ok));
|
|
541 |
if (ok && newNameFormat != mNameFormat) {
|
|
542 |
mNameFormat = newNameFormat;
|
|
543 |
emit nameFormatChanged(mNameFormat);
|
|
544 |
}
|
|
545 |
|
|
546 |
CNT_EXIT
|
|
547 |
}
|
|
548 |
|
|
549 |
/*!
|
|
550 |
Emits the results of a completed asynch database operation.
|
|
551 |
*/
|
|
552 |
void CntNameFetcher::sendCompletionSignal()
|
|
553 |
{
|
|
554 |
CNT_ENTRY
|
|
555 |
|
|
556 |
emit namesAvailable(mAsynchDbConnection->names());
|
|
557 |
|
|
558 |
delete mAsynchDbConnection;
|
|
559 |
mAsynchDbConnection = NULL;
|
|
560 |
|
|
561 |
CNT_EXIT
|
|
562 |
}
|
|
563 |
|