|
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: caservice.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QMetaType> |
|
19 #include <QCoreApplication> |
|
20 #include <QString> |
|
21 #include <QDebug> |
|
22 |
|
23 #include "caservice.h" |
|
24 #include "caservice_p.h" |
|
25 #include "caquery.h" |
|
26 #include "caentry.h" |
|
27 #include "canotifier.h" |
|
28 #include "canotifier_p.h" |
|
29 #include "cadefs.h" |
|
30 |
|
31 #include "caclientproxy.h" |
|
32 #include "caobjectadapter.h" |
|
33 #include "caclienttest_global.h" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 /*! |
|
38 |
|
39 \class CaService. |
|
40 \brief This class operates on data, anable creating and inserting new entry |
|
41 to DB, removing entry from DB, update entry or get entry from DB, execute |
|
42 command on entry and create notifier to notify client about changes onto DB. |
|
43 |
|
44 CaService class uses singleton design pattern, so that it contains static |
|
45 method called instance() to get instance of a class. |
|
46 |
|
47 \code |
|
48 QSharedPointer<CaService> service = CaService::instance(); |
|
49 \endcode |
|
50 |
|
51 For every operations on data is used always one instantiation of a class. |
|
52 Below are examples how to create data and work on those ones. |
|
53 |
|
54 */ |
|
55 |
|
56 // Initialization of a static member variable. |
|
57 QWeakPointer<CaService> CaService::m_instance = QWeakPointer<CaService>(); |
|
58 /*! |
|
59 Constructor. |
|
60 \param parent pointer to a parent. It defaults to NULL. |
|
61 */ |
|
62 CaService::CaService(QObject *parent) : |
|
63 QObject(parent), m_d(new CaServicePrivate(this)) |
|
64 { |
|
65 |
|
66 } |
|
67 |
|
68 /*! |
|
69 Returns a pointer to the instance of the CaService class. |
|
70 \retval A pointer to the instance of the CaService class. |
|
71 */ |
|
72 QSharedPointer<CaService> CaService::instance() |
|
73 { |
|
74 QSharedPointer<CaService> service(m_instance); |
|
75 if (!service) { |
|
76 // Register custom types used as types of signal parameters. |
|
77 qRegisterMetaType<ChangeType> ("ChangeType"); |
|
78 qRegisterMetaType<CaEntry> ("CaEntry"); |
|
79 |
|
80 service = QSharedPointer<CaService>(new CaService); |
|
81 m_instance = service.toWeakRef(); |
|
82 } |
|
83 return service; |
|
84 } |
|
85 |
|
86 /*! |
|
87 Destructor. |
|
88 */ |
|
89 CaService::~CaService() |
|
90 { |
|
91 delete m_d; |
|
92 } |
|
93 |
|
94 /*! |
|
95 Search for an entry |
|
96 \param entryId id of the entry to find. |
|
97 \retval pointer to the found entry. |
|
98 |
|
99 \example |
|
100 \code |
|
101 ... |
|
102 CaEntry * entryFromDB = service->getEntry( newItem->id() ); |
|
103 |
|
104 \endcode |
|
105 */ |
|
106 CaEntry *CaService::getEntry(int entryId) const |
|
107 { |
|
108 QList<CaEntry *> entries = getEntries(QList<int> () << entryId); |
|
109 if (entries.count()) { |
|
110 // there should be exactly one entry with specified ID if present |
|
111 Q_ASSERT(entries.count() == 1); |
|
112 return entries[0]; |
|
113 } else { |
|
114 return NULL; |
|
115 } |
|
116 } |
|
117 |
|
118 /*! |
|
119 Search for entries. |
|
120 \param entryIdList list of ids. |
|
121 \return list of found entries. |
|
122 |
|
123 \example |
|
124 \code |
|
125 ... |
|
126 QList<CaEntry *> entriesFromDB = service->getEntries( |
|
127 QList<int>() << newItem->id() << newGroup->id() ); |
|
128 QList<int> idsList; |
|
129 QStringList textEntry; |
|
130 CaEntry *entry(NULL); |
|
131 foreach( entry, entriesFromDB ) { |
|
132 idsList << entry->id(); |
|
133 textEntry << entry->text(); |
|
134 } |
|
135 |
|
136 \endcode |
|
137 */ |
|
138 QList<CaEntry *> CaService::getEntries(const QList<int> &entryIdList) const |
|
139 { |
|
140 return m_d->getEntries(entryIdList); |
|
141 } |
|
142 |
|
143 /*! |
|
144 Search for entries. |
|
145 \param query query |
|
146 \retval list of entries |
|
147 |
|
148 \example |
|
149 \code |
|
150 ... |
|
151 CaQuery query; |
|
152 query.setEntryRoles( ItemEntryRole | GroupEntryRole ); |
|
153 query.setEntryTypeNames( QStringList() << "TypeNameGroup" << "ItemNameGroup" ); |
|
154 QList<CaEntry *> entriesFromDB = service->getEntries( query ); |
|
155 QList<int> idsList; |
|
156 QStringList typeNames; |
|
157 CaEntry *entry(NULL); |
|
158 foreach( entry, entriesFromDB ) { |
|
159 idsList << entry->id(); |
|
160 typeNames << entry->entryTypeName(); |
|
161 } |
|
162 |
|
163 \endcode |
|
164 */ |
|
165 QList<CaEntry *> CaService::getEntries(const CaQuery &query) const |
|
166 { |
|
167 return m_d->getEntries(query); |
|
168 } |
|
169 |
|
170 /*! |
|
171 Search for entries and return their ids. |
|
172 \param query query |
|
173 \retval list of ids |
|
174 |
|
175 \example |
|
176 \code |
|
177 ... |
|
178 CaQuery query; |
|
179 query.setEntryRoles( ItemEntryRole | GroupEntryRole ); |
|
180 query.setEntryTypeNames( QStringList() << "TypeNameGroup" << "ItemNameGroup" ); |
|
181 QList<int> entriesIdsFromDB = service->getEntryIds( query ); |
|
182 QList<int> idsList; |
|
183 QStringList typeNames; |
|
184 int id( -1 ); |
|
185 foreach( id, entriesIdsFromDB ) { |
|
186 idsList << id |
|
187 typeNames << entry->entryTypeName(); |
|
188 } |
|
189 |
|
190 \endcode |
|
191 */ |
|
192 QList<int> CaService::getEntryIds(const CaQuery &query) const |
|
193 { |
|
194 return m_d->getEntryIds(query); |
|
195 } |
|
196 |
|
197 /*! |
|
198 Create copy of entry. |
|
199 \param entry entry to copy |
|
200 \retval pointer to newely created copy |
|
201 |
|
202 \example |
|
203 \code |
|
204 ... |
|
205 // creating new entry and add to DB |
|
206 CaEntry group( GroupEntryRole ); |
|
207 group.setText( "TextGroup" ); |
|
208 group.setTypeName( "TypeNameGroup" ); |
|
209 |
|
210 CaEntry item( ItemEntryRole ); |
|
211 item.setText( "TextItem" ); |
|
212 item.setTypeName( "TypeNameItem" ); |
|
213 |
|
214 CaEntry * newGroup = service->createEntry( group ); |
|
215 CaEntry * newItem = service->createEntry( item ); |
|
216 ... |
|
217 \endcode |
|
218 */ |
|
219 CaEntry *CaService::createEntry(const CaEntry &entry) const |
|
220 { |
|
221 return m_d->createEntry(entry); |
|
222 } |
|
223 |
|
224 /*! |
|
225 Remove entry. |
|
226 \param entryId id of an entry to remove |
|
227 \retval true if operation was successful |
|
228 |
|
229 \example |
|
230 \code |
|
231 ... |
|
232 bool result = service->removeEntry( newItem->id() ); |
|
233 \b Output: |
|
234 result == true |
|
235 \endcode |
|
236 */ |
|
237 bool CaService::removeEntry(int entryId) const |
|
238 { |
|
239 return removeEntries(QList<int> () << entryId); |
|
240 } |
|
241 |
|
242 /*! |
|
243 Remove entries. |
|
244 \param entry entry to remove |
|
245 \retval true if operation was successful |
|
246 |
|
247 \example |
|
248 \code |
|
249 ... |
|
250 bool result = service->removeEntry( *newItem ); |
|
251 \b Output: |
|
252 result == true |
|
253 \endcode |
|
254 */ |
|
255 bool CaService::removeEntry(const CaEntry &entry) const |
|
256 { |
|
257 return removeEntry(entry.id()); |
|
258 } |
|
259 |
|
260 /*! |
|
261 Remove entries. |
|
262 All others are convenience methods implemented in terms of this one. |
|
263 \param entryIdList list of ids of entries to remove |
|
264 \retval true if operation was successful |
|
265 |
|
266 \example |
|
267 \code |
|
268 ... |
|
269 bool result = service->removeEntries( QList<int>() << newItem->id() ); |
|
270 \b Output: |
|
271 result == true |
|
272 \endcode |
|
273 */ |
|
274 bool CaService::removeEntries(const QList<int> &entryIdList) const |
|
275 { |
|
276 return m_d->removeEntries(entryIdList); |
|
277 } |
|
278 |
|
279 /*! |
|
280 Remove entries. |
|
281 \param entryList list of entries to remove |
|
282 \retval true if operation was successful |
|
283 |
|
284 \example |
|
285 \code |
|
286 ... |
|
287 bool result = service->removeEntries( QList<CaEntry *>() << newItem ); |
|
288 \b Output: |
|
289 result == true |
|
290 \endcode |
|
291 */ |
|
292 bool CaService::removeEntries(const QList<CaEntry *> &entryList) const |
|
293 { |
|
294 QList<int> idList; |
|
295 CaEntry *entry(NULL); |
|
296 foreach(entry, entryList) { |
|
297 idList << entry->id(); |
|
298 } |
|
299 return removeEntries(idList); |
|
300 } |
|
301 |
|
302 /*! |
|
303 Update entry. |
|
304 \param entry entry to update |
|
305 \retval true if operation was successful |
|
306 |
|
307 \example |
|
308 \code |
|
309 ... |
|
310 newItem->setAttribute( "attrName", "attrValue" ); |
|
311 bool result = service->updateEntry( *newItem ); |
|
312 \b Output: |
|
313 result == true |
|
314 \endcode |
|
315 */ |
|
316 bool CaService::updateEntry(const CaEntry &entry) const |
|
317 { |
|
318 return m_d->updateEntry(entry); |
|
319 } |
|
320 |
|
321 /*! |
|
322 Performs touch operation on entry. |
|
323 \param entry of entry to be touched |
|
324 \retval boolean with result of operation |
|
325 |
|
326 \example |
|
327 \code |
|
328 ... |
|
329 bool result = service->touch( newItem ); |
|
330 \b Output: |
|
331 result == true |
|
332 \endcode |
|
333 */ |
|
334 bool CaService::touch(const CaEntry &entry) const |
|
335 { |
|
336 return m_d->touch(entry); |
|
337 } |
|
338 |
|
339 /*! |
|
340 Insert entry into a given group. |
|
341 \param groupId id of a group. |
|
342 \param entryId id of an entry to insert. |
|
343 \param beforeEntryId id of an entry before which the given entry is inserted. |
|
344 \retval true if operation was successful. |
|
345 |
|
346 \example |
|
347 \code |
|
348 ... |
|
349 CaEntry itemToAdd; |
|
350 itemToAdd.setText( "TextAdd" ); |
|
351 itemToAdd.setTypeName( "TypeNameAdd" ); |
|
352 CaEntry * entryToAdd = service->createEntry( itemToAdd ); |
|
353 ... |
|
354 bool result = service->insertEntryIntoGroup( |
|
355 newGroup->id(), entryToAdd->id(), newItem->id()); |
|
356 \b Output: |
|
357 result == true |
|
358 \endcode |
|
359 */ |
|
360 bool CaService::insertEntryIntoGroup(int groupId, int entryId, |
|
361 int beforeEntryId) const |
|
362 { |
|
363 return insertEntriesIntoGroup(groupId, QList<int> () << entryId, |
|
364 beforeEntryId); |
|
365 } |
|
366 |
|
367 /*! |
|
368 Insert entry into a given group. |
|
369 \param group group. |
|
370 \param entry entry to insert. |
|
371 \param beforeEntryId id of an entry before which the given entry is inserted. |
|
372 \retval true if operation was successful. |
|
373 |
|
374 \example |
|
375 \code |
|
376 ... |
|
377 CaEntry itemToAdd; |
|
378 itemToAdd.setText( "TextAdd" ); |
|
379 itemToAdd.setTypeName( "TypeNameAdd" ); |
|
380 CaEntry * entryToAdd = service->createEntry( itemToAdd ); |
|
381 ... |
|
382 bool result = service->insertEntryIntoGroup( |
|
383 *newGroup, *entryToAdd, newItem->id()); |
|
384 \b Output: |
|
385 result == true |
|
386 \endcode |
|
387 */ |
|
388 bool CaService::insertEntryIntoGroup(const CaEntry &group, |
|
389 const CaEntry &entry, int beforeEntryId) const |
|
390 { |
|
391 return insertEntryIntoGroup(group.id(), entry.id(), beforeEntryId); |
|
392 } |
|
393 |
|
394 /*! |
|
395 Insert entries into a given group. |
|
396 All others are convenience methods implemented in terms of this one. |
|
397 \param groupId id of a group. |
|
398 \param entryIdList list of ids of entries to insert. |
|
399 \param beforeEntryId id of an entry before which the given entry is inserted. |
|
400 \retval true if operation was successful. |
|
401 |
|
402 \example |
|
403 \code |
|
404 ... |
|
405 CaEntry itemToAdd; |
|
406 itemToAdd.setText( "TextAdd" ); |
|
407 itemToAdd.setTypeName( "TypeNameAdd" ); |
|
408 CaEntry * entryToAdd = service->createEntry( itemToAdd ); |
|
409 ... |
|
410 bool result = service->insertEntriesIntoGroup( |
|
411 newGroup->id(), QList<int>() << entryToAdd->id(), newItem->id()); |
|
412 \b Output: |
|
413 result == true |
|
414 \endcode |
|
415 */ |
|
416 bool CaService::insertEntriesIntoGroup(int groupId, |
|
417 const QList<int> &entryIdList, int beforeEntryId) const |
|
418 { |
|
419 if (beforeEntryId < 0) { |
|
420 qWarning( |
|
421 "CaService::insertEntriesIntoGroup: beforeEntryId cannot be negative: %d", |
|
422 beforeEntryId); |
|
423 return false; |
|
424 } else { |
|
425 return m_d->insertEntriesIntoGroup(groupId, entryIdList, |
|
426 beforeEntryId); |
|
427 } |
|
428 } |
|
429 |
|
430 /*! |
|
431 Insert entry into a given group. |
|
432 \param group group. |
|
433 \param entryList list of entries (pointers) to insert. |
|
434 \param beforeEntryId id of an entry before which the given entry is inserted. |
|
435 \retval true if operation was successful. |
|
436 |
|
437 \example |
|
438 \code |
|
439 ... |
|
440 CaEntry itemToAdd; |
|
441 itemToAdd.setText( "TextAdd" ); |
|
442 itemToAdd.setTypeName( "TypeNameAdd" ); |
|
443 CaEntry * entryToAdd = service->createEntry( itemToAdd ); |
|
444 ... |
|
445 bool result = service->insertEntriesIntoGroup( |
|
446 *newGroup, QList<CaEntry *>() << entryToAdd, newItem->id()); |
|
447 \b Output: |
|
448 result == true |
|
449 \endcode |
|
450 */ |
|
451 bool CaService::insertEntriesIntoGroup(const CaEntry &group, |
|
452 const QList<CaEntry *> &entryList, int beforeEntryId) const |
|
453 { |
|
454 QList<int> idList; |
|
455 CaEntry *entry(NULL); |
|
456 foreach(entry, entryList) { |
|
457 idList << entry->id(); |
|
458 } |
|
459 return insertEntriesIntoGroup(group.id(), idList, beforeEntryId); |
|
460 } |
|
461 |
|
462 /*! |
|
463 Remove entry from a given group. |
|
464 \param groupId id of a group. |
|
465 \param entryId id of entry to remove. |
|
466 \retval true if operation was successful. |
|
467 |
|
468 \example |
|
469 \code |
|
470 ... |
|
471 CaEntry itemToAddRemove; |
|
472 itemToAddRemove.setText( "TextAddRemove" ); |
|
473 itemToAddRemove.setTypeName( "TypeNameAddRemove" ); |
|
474 CaEntry * entryToAddRemove = service->createEntry( itemToAddRemove ); |
|
475 service->prependEntryToGroup( *newGroup, *entryToAddRemove ); |
|
476 ... |
|
477 bool result = service->removeEntryFromGroup( |
|
478 newGroup->id(), entryToAddRemove->id()); |
|
479 \b Output: |
|
480 result == true |
|
481 \endcode |
|
482 */ |
|
483 bool CaService::removeEntryFromGroup(int groupId, int entryId) const |
|
484 { |
|
485 return removeEntriesFromGroup(groupId, QList<int> () << entryId); |
|
486 } |
|
487 |
|
488 /*! |
|
489 Remove entry from a given group. |
|
490 \param group group. |
|
491 \param entryId id of entry to remove. |
|
492 \retval true if operation was successful. |
|
493 |
|
494 \example |
|
495 \code |
|
496 ... |
|
497 CaEntry itemToAddRemove; |
|
498 itemToAddRemove.setText( "TextAddRemove" ); |
|
499 itemToAddRemove.setTypeName( "TypeNameAddRemove" ); |
|
500 CaEntry * entryToAddRemove = service->createEntry( itemToAddRemove ); |
|
501 service->prependEntryToGroup( *newGroup, *entryToAddRemove ); |
|
502 ... |
|
503 bool result = service->removeEntryFromGroup( |
|
504 *newGroup, *entryToAddRemove ); |
|
505 \b Output: |
|
506 result == true |
|
507 \endcode |
|
508 */ |
|
509 bool CaService::removeEntryFromGroup(const CaEntry &group, |
|
510 const CaEntry &entry) const |
|
511 { |
|
512 return removeEntryFromGroup(group.id(), entry.id()); |
|
513 } |
|
514 |
|
515 /*! |
|
516 Remove entries from a given group. |
|
517 All others are convenience methods implemented in terms of this one. |
|
518 \param groupId id of a group. |
|
519 \param entryIdList list of ids of entries to remove. |
|
520 \retval true if operation was successful. |
|
521 |
|
522 \example |
|
523 \code |
|
524 ... |
|
525 CaEntry itemToAddRemove; |
|
526 itemToAddRemove.setText( "TextAddRemove" ); |
|
527 itemToAddRemove.setTypeName( "TypeNameAddRemove" ); |
|
528 CaEntry * entryToAddRemove = service->createEntry( itemToAddRemove ); |
|
529 service->prependEntryToGroup( *newGroup, *entryToAddRemove ); |
|
530 ... |
|
531 bool result = service->removeEntriesFromGroup( |
|
532 newGroup->id(), QList<int>() << entryToAddRemove->id() ); |
|
533 \b Output: |
|
534 result == true |
|
535 \endcode |
|
536 */ |
|
537 bool CaService::removeEntriesFromGroup(int groupId, |
|
538 const QList<int> &entryIdList) const |
|
539 { |
|
540 return m_d->removeEntriesFromGroup(groupId, entryIdList); |
|
541 } |
|
542 |
|
543 /*! |
|
544 Remove entries from a given group. |
|
545 All others are convenience methods implemented in terms of this one. |
|
546 \param group group. |
|
547 \param entryList list of entries (pointers) to remove. |
|
548 \retval true if operation was successful. |
|
549 |
|
550 \example |
|
551 \code |
|
552 ... |
|
553 CaEntry itemToAddRemove; |
|
554 itemToAddRemove.setText( "TextAddRemove" ); |
|
555 itemToAddRemove.setTypeName( "TypeNameAddRemove" ); |
|
556 CaEntry * entryToAddRemove = service->createEntry( itemToAddRemove ); |
|
557 service->prependEntryToGroup( *newGroup, *entryToAddRemove ); |
|
558 ... |
|
559 bool result = service->removeEntriesFromGroup( |
|
560 *newGroup, QList<CaEntry *>() << entryToAddRemove ); |
|
561 \b Output: |
|
562 result == true |
|
563 \endcode |
|
564 */ |
|
565 bool CaService::removeEntriesFromGroup(const CaEntry &group, |
|
566 const QList<CaEntry *> &entryList) const |
|
567 { |
|
568 QList<int> idList; |
|
569 CaEntry *entry(NULL); |
|
570 foreach(entry, entryList) { |
|
571 idList << entry->id(); |
|
572 } |
|
573 return removeEntriesFromGroup(group.id(), idList); |
|
574 } |
|
575 |
|
576 /*! |
|
577 Performs touch operation on entry. |
|
578 \param entry to be touched |
|
579 \retval boolean with result of operation |
|
580 */ |
|
581 bool CaServicePrivate::touch(const CaEntry &entry) |
|
582 { |
|
583 qDebug() << "CaServicePrivate::touch" << "entryId: " << entry.id(); |
|
584 |
|
585 mErrorCode = mProxy->touch(entry); |
|
586 |
|
587 qDebug() << "CaServicePrivate::touch mErrorCode:" << mErrorCode; |
|
588 |
|
589 return (mErrorCode == NoErrorCode); |
|
590 } |
|
591 |
|
592 /*! |
|
593 Place entries in a given group at the end. |
|
594 \param groupId id of a group. |
|
595 \param entryId id of entry to append. |
|
596 \retval true if operation was successful. |
|
597 |
|
598 \example |
|
599 \code |
|
600 ... |
|
601 CaEntry itemToAppend; |
|
602 itemToAppend.setText( "TextAppend" ); |
|
603 itemToAppend.setTypeName( "TypeNameAppend" ); |
|
604 CaEntry * entryToAppend = service->createEntry( itemToAppend ); |
|
605 bool result = service->appendEntryToGroup( |
|
606 newGroup->id(), entryToAppend->id() ); |
|
607 ... |
|
608 \b Output: |
|
609 result == true |
|
610 \endcode |
|
611 */ |
|
612 bool CaService::appendEntryToGroup(int groupId, int entryId) const |
|
613 { |
|
614 return appendEntriesToGroup(groupId, QList<int> () << entryId); |
|
615 } |
|
616 |
|
617 /*! |
|
618 Place entries in a given group at the end. |
|
619 \param group group. |
|
620 \param entry entry to append. |
|
621 \retval true if operation was successful. |
|
622 |
|
623 \example |
|
624 \code |
|
625 ... |
|
626 CaEntry itemToAppend; |
|
627 itemToAppend.setText( "TextAppend" ); |
|
628 itemToAppend.setTypeName( "TypeNameAppend" ); |
|
629 CaEntry * entryToAppend = service->createEntry( itemToAppend ); |
|
630 bool result = service->appendEntryToGroup( |
|
631 *newGroup, *entryToAppend ); |
|
632 ... |
|
633 \b Output: |
|
634 result == true |
|
635 \endcode |
|
636 */ |
|
637 bool CaService::appendEntryToGroup(const CaEntry &group, |
|
638 const CaEntry &entry) const |
|
639 { |
|
640 return appendEntryToGroup(group.id(), entry.id()); |
|
641 } |
|
642 |
|
643 /*! |
|
644 Place entries in a given group at the end. |
|
645 All others are convenience methods implemented in terms of this one. |
|
646 \param groupId group. |
|
647 \param entryIdList list of ids of entries to append. |
|
648 \retval true if operation was successful. |
|
649 |
|
650 \example |
|
651 \code |
|
652 ... |
|
653 CaEntry itemToAppend; |
|
654 itemToAppend.setText( "TextAppend" ); |
|
655 itemToAppend.setTypeName( "TypeNameAppend" ); |
|
656 CaEntry * entryToAppend = service->createEntry( itemToAppend ); |
|
657 bool result = service->appendEntriesToGroup( |
|
658 newGroup->id(), QList<int>() << entryToAppend->id() ); |
|
659 ... |
|
660 \b Output: |
|
661 result == true |
|
662 \endcode |
|
663 */ |
|
664 bool CaService::appendEntriesToGroup(int groupId, |
|
665 const QList<int> &entryIdList) const |
|
666 { |
|
667 return m_d->appendEntriesToGroup(groupId, entryIdList); |
|
668 } |
|
669 |
|
670 /*! |
|
671 Place entries in a given group at the end. |
|
672 \param group group. |
|
673 \param entryList list of entries to append. |
|
674 \retval true if operation was successful. |
|
675 |
|
676 \example |
|
677 \code |
|
678 ... |
|
679 CaEntry itemToAppend; |
|
680 itemToAppend.setText( "TextAppend" ); |
|
681 itemToAppend.setTypeName( "TypeNameAppend" ); |
|
682 CaEntry * entryToAppend = service->createEntry( itemToAppend ); |
|
683 bool result = service->appendEntriesToGroup( |
|
684 *newGroup, QList<CaEntry *>() << entryToAppend ); |
|
685 ... |
|
686 \b Output: |
|
687 result == true |
|
688 \endcode |
|
689 */ |
|
690 bool CaService::appendEntriesToGroup(const CaEntry &group, |
|
691 const QList<CaEntry *> &entryList) const |
|
692 { |
|
693 QList<int> idList; |
|
694 CaEntry *entry(NULL); |
|
695 foreach(entry, entryList) { |
|
696 idList << entry->id(); |
|
697 } |
|
698 return appendEntriesToGroup(group.id(), idList); |
|
699 } |
|
700 |
|
701 /*! |
|
702 Place entries in a given group at the beginning. |
|
703 \param groupId id of a group. |
|
704 \param entryId id of entry to prepend. |
|
705 \retval true if operation was successful. |
|
706 |
|
707 \example |
|
708 \code |
|
709 ... |
|
710 CaEntry itemToPrepend; |
|
711 itemToPrepend.setText( "TextPrepend" ); |
|
712 itemToPrepend.setTypeName( "TypeNamePrepend" ); |
|
713 CaEntry * entryToPrepend = service->createEntry( itemToPrepend ); |
|
714 bool result = service->prependEntryToGroup( |
|
715 newGroup->id(), entryToPrepend->id() ); |
|
716 ... |
|
717 \b Output: |
|
718 result == true |
|
719 \endcode |
|
720 */ |
|
721 bool CaService::prependEntryToGroup(int groupId, int entryId) const |
|
722 { |
|
723 return prependEntriesToGroup(groupId, QList<int> () << entryId); |
|
724 } |
|
725 |
|
726 /*! |
|
727 Place entries in a given group at the beginning. |
|
728 \param group group. |
|
729 \param entry entry to prepend. |
|
730 \retval true if operation was successful. |
|
731 |
|
732 \example |
|
733 \code |
|
734 ... |
|
735 CaEntry itemToPrepend; |
|
736 itemToPrepend.setText( "TextPrepend" ); |
|
737 itemToPrepend.setTypeName( "TypeNamePrepend" ); |
|
738 CaEntry * entryToPrepend = service->createEntry( itemToPrepend ); |
|
739 bool result = service->prependEntryToGroup( |
|
740 *newGroup, *entryToPrepend ); |
|
741 ... |
|
742 \b Output: |
|
743 result == true |
|
744 \endcode |
|
745 */ |
|
746 bool CaService::prependEntryToGroup(const CaEntry &group, |
|
747 const CaEntry &entry) const |
|
748 { |
|
749 return prependEntryToGroup(group.id(), entry.id()); |
|
750 } |
|
751 |
|
752 /*! |
|
753 Place entries in a given group at the beginning. |
|
754 All others are convenience methods implemented in terms of this one. |
|
755 \param groupId group. |
|
756 \param entryIdList list of ids of entries to prepend. |
|
757 \retval true if operation was successful. |
|
758 |
|
759 \example |
|
760 \code |
|
761 ... |
|
762 CaEntry itemToPrepend; |
|
763 itemToPrepend.setText( "TextPrepend" ); |
|
764 itemToPrepend.setTypeName( "TypeNamePrepend" ); |
|
765 CaEntry * entryToPrepend = service->createEntry( itemToPrepend ); |
|
766 bool result = service->prependEntriesToGroup( |
|
767 newGroup->id(), QList<int>() << entryToPrepend->id() ); |
|
768 ... |
|
769 \b Output: |
|
770 result == true |
|
771 \endcode |
|
772 */ |
|
773 bool CaService::prependEntriesToGroup(int groupId, |
|
774 const QList<int> &entryIdList) const |
|
775 { |
|
776 return m_d->prependEntriesToGroup(groupId, entryIdList); |
|
777 } |
|
778 |
|
779 /*! |
|
780 Place entries in a given group at the begin. |
|
781 \param group group. |
|
782 \param entryList list of entries to prepend. |
|
783 \retval true if operation was successful. |
|
784 |
|
785 \example |
|
786 \code |
|
787 ... |
|
788 CaEntry itemToPrepend; |
|
789 itemToPrepend.setText( "TextPrepend" ); |
|
790 itemToPrepend.setTypeName( "TypeNamePrepend" ); |
|
791 CaEntry * entryToPrepend = service->createEntry( itemToPrepend ); |
|
792 bool result = service->prependEntriesToGroup( |
|
793 *newGroup, QList<CaEntry *>() << entryToPrepend ); |
|
794 ... |
|
795 \b Output: |
|
796 result == true |
|
797 \endcode |
|
798 */ |
|
799 bool CaService::prependEntriesToGroup(const CaEntry &group, |
|
800 const QList<CaEntry *> &entryList) const |
|
801 { |
|
802 QList<int> idList; |
|
803 CaEntry *entry(NULL); |
|
804 foreach(entry, entryList) { |
|
805 idList << entry->id(); |
|
806 } |
|
807 return prependEntriesToGroup(group.id(), idList); |
|
808 } |
|
809 |
|
810 /*! |
|
811 Execute command. |
|
812 \param entryId id of an entry. |
|
813 \param command command. |
|
814 \retval true if operation was successful. |
|
815 |
|
816 \example |
|
817 \code |
|
818 ... |
|
819 CaEntry itemExecute; |
|
820 itemExecute.setText("Application"); |
|
821 itemExecute.setTypeName("application"); |
|
822 itemExecute.setAttribute("application:uid", "0x12345678"); |
|
823 CaEntry * entryExecute = service->createEntry(itemExecute->id()); |
|
824 bool result = service->executeCommand(entryExecute->id(), "remove"); |
|
825 ... |
|
826 \b Output: |
|
827 result == true |
|
828 \endcode |
|
829 */ |
|
830 bool CaService::executeCommand(int entryId, const QString &command) const |
|
831 { |
|
832 bool result = false; |
|
833 |
|
834 CaEntry *const temporaryEntry = getEntry(entryId); |
|
835 |
|
836 if (temporaryEntry != NULL) { |
|
837 result = executeCommand(*temporaryEntry, command); |
|
838 delete temporaryEntry; |
|
839 } |
|
840 |
|
841 return result; |
|
842 } |
|
843 |
|
844 /*! |
|
845 Execute command. |
|
846 \param entry entry. |
|
847 \param command command. |
|
848 \retval true if operation was successful. |
|
849 |
|
850 \example |
|
851 \code |
|
852 ... |
|
853 CaEntry itemExecute; |
|
854 itemExecute.setText("URL"); |
|
855 itemExecute.setTypeName("url"); |
|
856 itemExecute.setAttribute("url", "http://www.nokia.com"); |
|
857 CaEntry * entryExecute = service->createEntry(itemExecute->id()); |
|
858 bool result = service->executeCommand(*entryExecute, "open"); |
|
859 ... |
|
860 \b Output: |
|
861 result == true |
|
862 \endcode |
|
863 */ |
|
864 bool CaService::executeCommand(const CaEntry &entry, const QString &command) const |
|
865 { |
|
866 return m_d->executeCommand(entry, command); |
|
867 } |
|
868 |
|
869 /*! |
|
870 Creates notifier. |
|
871 \param const reference to CaNotifierFilter. |
|
872 \retval pointer to created CaNotifier instance. |
|
873 |
|
874 \code |
|
875 ... |
|
876 // creating notifier with specified notifier filter |
|
877 CaNotifierFilter notifierFilter; |
|
878 notifierFilter.setIds( QList<int>() << newGroup->id() << newItem->id() ); |
|
879 notifierFilter.setEntryRole( ItemEntryRole | GroupEntryRole ); |
|
880 CaNotifier * notifier = service->createNotifier( notifierFilter ); |
|
881 ... |
|
882 \endcode |
|
883 */ |
|
884 CaNotifier *CaService::createNotifier(const CaNotifierFilter &filter) const |
|
885 { |
|
886 return m_d->createNotifier(filter); |
|
887 } |
|
888 |
|
889 /*! |
|
890 Set new order of collection's items set by user. |
|
891 \groupId Group id. |
|
892 \param entryIdList consists of new order of items. |
|
893 \retval true if new order of collection's items is set correctly, |
|
894 otherwise return false. |
|
895 */ |
|
896 |
|
897 bool CaService::customSort(int groupId, QList<int> &entryIdList) const |
|
898 { |
|
899 return m_d->customSort(groupId, entryIdList); |
|
900 } |
|
901 |
|
902 /*! |
|
903 Returns code of an error caused by the last executed operation. |
|
904 \retval code of error, zero means no error. |
|
905 |
|
906 \example |
|
907 \code |
|
908 ... |
|
909 CaEntry itemExecute; |
|
910 itemExecute.setText("URL"); |
|
911 itemExecute.setTypeName("url"); |
|
912 itemExecute.setAttribute("url", "http://www.nokia.com"); |
|
913 CaEntry * entryExecute = service->createEntry(itemExecute->id()); |
|
914 bool result = service->executeCommand(*entryExecute, "open"); |
|
915 |
|
916 ErrorCode errorCode = lastError(); |
|
917 switch (errorCode) { |
|
918 case NoErrorCode: |
|
919 ... |
|
920 case BadArgumentErrorCode: |
|
921 ... |
|
922 } |
|
923 ... |
|
924 |
|
925 \endcode |
|
926 */ |
|
927 ErrorCode CaService::lastError() const |
|
928 { |
|
929 return m_d->lastError(); |
|
930 } |
|
931 |
|
932 |
|
933 /*! |
|
934 Constructor |
|
935 \param servicePublic pointer to public service |
|
936 */ |
|
937 CaServicePrivate::CaServicePrivate(CaService *servicePublic) : |
|
938 m_q(servicePublic), mProxy(new CaClientProxy()) |
|
939 { |
|
940 const ErrorCode connectionResult = mProxy->connect(); |
|
941 |
|
942 USE_QWARNING_IF(connectionResult) |
|
943 << "CaServicePrivate::CaServicePrivate - unable to connect proxy"; |
|
944 |
|
945 mErrorCode = connectionResult; |
|
946 } |
|
947 |
|
948 /*! |
|
949 destructor |
|
950 */ |
|
951 CaServicePrivate::~CaServicePrivate() |
|
952 { |
|
953 delete mProxy; |
|
954 } |
|
955 |
|
956 /*! |
|
957 Search for entries. |
|
958 \param entryIdList list of entry ids |
|
959 \retval list of entries (pointers) |
|
960 */ |
|
961 QList<CaEntry *> CaServicePrivate::getEntries(const QList<int> &entryIdList) const |
|
962 { |
|
963 qDebug() << "CaServicePrivate::getEntries" |
|
964 << "entryIdList:" << entryIdList; |
|
965 |
|
966 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::getEntries"); |
|
967 |
|
968 QList<CaEntry *> resultList; |
|
969 |
|
970 mErrorCode = mProxy->getData(entryIdList, resultList); |
|
971 |
|
972 // figure out whether all entries have been retrieved and |
|
973 // store the operation status |
|
974 if (mErrorCode == NoErrorCode |
|
975 && entryIdList.count() != resultList.count()) { |
|
976 mErrorCode = NotFoundErrorCode; |
|
977 } |
|
978 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::getEntries"); |
|
979 |
|
980 qDebug() << "CaServicePrivate::getEntries mErrorCode:" |
|
981 << mErrorCode; |
|
982 |
|
983 return resultList; |
|
984 } |
|
985 |
|
986 /*! |
|
987 Fetches data from database. |
|
988 \param query the query information to select specific entries. |
|
989 \param placeholder list of entries for a specific select. |
|
990 */ |
|
991 QList<CaEntry *> CaServicePrivate::getEntries(const CaQuery &query) const |
|
992 { |
|
993 QList<CaEntry *> resultList; |
|
994 |
|
995 mErrorCode = mProxy->getData(query, resultList); |
|
996 |
|
997 qDebug() << "CaServicePrivate::getEntries mErrorCode:" << mErrorCode; |
|
998 |
|
999 return resultList; |
|
1000 } |
|
1001 |
|
1002 /*! |
|
1003 Search for entries and return their ids. |
|
1004 \param query query |
|
1005 \retval list of ids |
|
1006 */ |
|
1007 QList<int> CaServicePrivate::getEntryIds(const CaQuery &query) const |
|
1008 { |
|
1009 CACLIENTTEST_FUNC_ENTRY("CaItemModelList::getEntryIds"); |
|
1010 |
|
1011 QList<int> resultList; |
|
1012 mErrorCode = mProxy->getEntryIds(query, resultList); |
|
1013 CACLIENTTEST_FUNC_EXIT("CaItemModelList::getEntryIds"); |
|
1014 qDebug() << "CaServicePrivate::getEntryIds mErrorCode:" << mErrorCode; |
|
1015 return resultList; |
|
1016 } |
|
1017 |
|
1018 /*! |
|
1019 Create copy of entry. |
|
1020 \param query const reference to entry to copy |
|
1021 \retval pointer to newely created copy |
|
1022 */ |
|
1023 CaEntry *CaServicePrivate::createEntry(const CaEntry &entry) |
|
1024 { |
|
1025 qDebug() << "CaServicePrivate::createEntry" |
|
1026 << "entry id:" << entry.id(); |
|
1027 |
|
1028 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::createEntry"); |
|
1029 |
|
1030 CaEntry *newEntry = NULL; |
|
1031 ErrorCode addDataResult = NoErrorCode; |
|
1032 |
|
1033 try { |
|
1034 newEntry = new CaEntry(entry.role()); |
|
1035 |
|
1036 QScopedPointer<CaEntry> entryClone(new CaEntry(entry)); |
|
1037 |
|
1038 const int nonExistingObjectId = 0; |
|
1039 |
|
1040 CaObjectAdapter::setId(*entryClone, nonExistingObjectId); |
|
1041 |
|
1042 addDataResult = |
|
1043 mProxy->addData(*entryClone, *newEntry); |
|
1044 } catch (const std::bad_alloc &) { |
|
1045 addDataResult = OutOfMemoryErrorCode; |
|
1046 } |
|
1047 |
|
1048 if (addDataResult != NoErrorCode) { |
|
1049 delete newEntry; |
|
1050 newEntry = NULL; |
|
1051 } |
|
1052 |
|
1053 mErrorCode = addDataResult; |
|
1054 |
|
1055 qDebug() << "CaServicePrivate::createEntry mErrorCode:" << mErrorCode; |
|
1056 |
|
1057 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::createEntry"); |
|
1058 |
|
1059 return newEntry; |
|
1060 } |
|
1061 |
|
1062 /*! |
|
1063 Update entry. |
|
1064 \param entry entry const reference of entry to update |
|
1065 \retval true if operation was successful |
|
1066 */ |
|
1067 bool CaServicePrivate::updateEntry(const CaEntry &entry) |
|
1068 { |
|
1069 qDebug() << "CaServicePrivate::updateEntry" |
|
1070 << "entry id:" << entry.id(); |
|
1071 |
|
1072 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::updateEntry"); |
|
1073 |
|
1074 ErrorCode updateEntryResult = UnknownErrorCode; |
|
1075 |
|
1076 if (entry.id() != 0) { |
|
1077 try { |
|
1078 QScopedPointer<CaEntry> updatedEntry(new CaEntry(entry.role())); |
|
1079 |
|
1080 updateEntryResult = mProxy->addData(entry, *updatedEntry); |
|
1081 |
|
1082 } catch (const std::bad_alloc &) { |
|
1083 updateEntryResult = OutOfMemoryErrorCode; |
|
1084 } |
|
1085 } |
|
1086 |
|
1087 mErrorCode = updateEntryResult; |
|
1088 |
|
1089 qDebug() << "CaServicePrivate::updateEntry mErrorCode on return:" |
|
1090 << mErrorCode; |
|
1091 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::updateEntry"); |
|
1092 |
|
1093 return (updateEntryResult == NoErrorCode); |
|
1094 } |
|
1095 |
|
1096 /*! |
|
1097 Remove entries. |
|
1098 \param entryIdList list of entries ids to remove |
|
1099 \retval true if operation was successful |
|
1100 */ |
|
1101 bool CaServicePrivate::removeEntries(const QList<int> &entryIdList) |
|
1102 { |
|
1103 qDebug() << "CaServicePrivate::removeEntries" |
|
1104 << "entryIdList: " << entryIdList; |
|
1105 |
|
1106 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::removeEntries"); |
|
1107 |
|
1108 mErrorCode = mProxy->removeData(entryIdList); |
|
1109 |
|
1110 qDebug() << "CaServicePrivate::removeEntries mErrorCode:" << mErrorCode; |
|
1111 |
|
1112 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::removeEntries"); |
|
1113 |
|
1114 return (mErrorCode == NoErrorCode); |
|
1115 } |
|
1116 |
|
1117 /*! |
|
1118 Insert entry into a given group. |
|
1119 \param groupId groupId. |
|
1120 \param entryIdList list of entries ids to insert. |
|
1121 \param beforeEntryId id of an entry before which the given entry is inserted. |
|
1122 \retval true if operation was successful. |
|
1123 */ |
|
1124 bool CaServicePrivate::insertEntriesIntoGroup( |
|
1125 int groupId, |
|
1126 const QList<int> &entryIdList, |
|
1127 int beforeEntryId) // all others are convenience methods implemented in terms of this one |
|
1128 { |
|
1129 qDebug() << "CaServicePrivate::insertEntriesIntoGroup" |
|
1130 << "groupId: " << groupId << " beforeEntryId: " << beforeEntryId |
|
1131 << "entryIdList: " << entryIdList; |
|
1132 |
|
1133 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::insertEntriesIntoGroup"); |
|
1134 |
|
1135 mErrorCode = mProxy->insertEntriesIntoGroup(groupId, entryIdList, beforeEntryId); |
|
1136 |
|
1137 qDebug() << "CaServicePrivate::insertEntriesIntoGroup mErrorCode:" |
|
1138 << mErrorCode; |
|
1139 |
|
1140 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::insertEntriesIntoGroup"); |
|
1141 |
|
1142 return (mErrorCode == NoErrorCode); |
|
1143 } |
|
1144 |
|
1145 /*! |
|
1146 Remove entries from a given group. |
|
1147 |
|
1148 \param groupId groupId. |
|
1149 \param entryIDList list of entries ids to remove. |
|
1150 \retval true if operation was successful. |
|
1151 */ |
|
1152 bool CaServicePrivate::removeEntriesFromGroup( |
|
1153 int groupId, |
|
1154 const QList<int> &entryIdList) |
|
1155 { |
|
1156 qDebug() << "CaServicePrivate::removeEntriesFromGroup" |
|
1157 << "groupId: " << groupId << "entryIdList" << entryIdList; |
|
1158 |
|
1159 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::removeEntriesFromGroup"); |
|
1160 |
|
1161 mErrorCode = mProxy->removeEntriesFromGroup(groupId, entryIdList); |
|
1162 |
|
1163 qDebug() << "CaServicePrivate::removeEntriesFromGroup mErrorCode:" |
|
1164 << mErrorCode; |
|
1165 |
|
1166 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::removeEntriesFromGroup"); |
|
1167 |
|
1168 return (mErrorCode == NoErrorCode); |
|
1169 } |
|
1170 |
|
1171 /*! |
|
1172 Place entries in a given group at the end. |
|
1173 \param groupId groupId. |
|
1174 \param entryIdList list of entries ids to prepend. |
|
1175 \retval true if operation was successful. |
|
1176 */ |
|
1177 bool CaServicePrivate::appendEntriesToGroup( |
|
1178 int groupId, |
|
1179 const QList<int> &entryIdList) |
|
1180 { |
|
1181 qDebug() << "CaServicePrivate::appendEntriesToGroup" |
|
1182 << "groupId: " << groupId << "entryIdList: " << entryIdList; |
|
1183 |
|
1184 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::appendEntriesToGroup"); |
|
1185 |
|
1186 const bool result = insertEntriesIntoGroup( |
|
1187 groupId, |
|
1188 entryIdList, |
|
1189 CaClientProxy::AfterTheLastEntry); |
|
1190 |
|
1191 qDebug() << "CaServicePrivate::appendEntriesToGroup result:" |
|
1192 << QString(result ? "true" : "false"); |
|
1193 |
|
1194 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::appendEntriesToGroup"); |
|
1195 |
|
1196 return result; |
|
1197 } |
|
1198 |
|
1199 /*! |
|
1200 Place entries in a given group at the begin. |
|
1201 \param groupId groupId. |
|
1202 \param entryIdList list of entries ids to prepend. |
|
1203 \retval true if operation was successful. |
|
1204 */ |
|
1205 bool CaServicePrivate::prependEntriesToGroup(int groupId, |
|
1206 const QList<int> &entryIdList) |
|
1207 { |
|
1208 qDebug() << "CaServicePrivate::prependEntriesToGroup" |
|
1209 << "groupId: " << groupId << "entryIdList: " << entryIdList; |
|
1210 |
|
1211 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::prependEntriesToGroup"); |
|
1212 |
|
1213 const bool result = |
|
1214 insertEntriesIntoGroup( |
|
1215 groupId, |
|
1216 entryIdList, |
|
1217 CaClientProxy::BeforeTheFirstEntry); |
|
1218 |
|
1219 qDebug() << "CaServicePrivate::prependEntriesToGroup result:" |
|
1220 << QString(result ? "PASS" : "FAIL"); |
|
1221 |
|
1222 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::prependEntriesToGroup"); |
|
1223 |
|
1224 return result; |
|
1225 } |
|
1226 |
|
1227 /*! |
|
1228 Executes command on entry (fe. "open", "remove") |
|
1229 \param const reference to an entry on which command will be issued |
|
1230 \param string containing a command |
|
1231 \retval boolean which is used as an error code return value, true means positive result |
|
1232 */ |
|
1233 bool CaServicePrivate::executeCommand(const CaEntry &entry, |
|
1234 const QString &command) |
|
1235 { |
|
1236 qDebug() << "CaServicePrivate::executeCommand" |
|
1237 << "entry id:" << entry.id() << "command:" << command; |
|
1238 |
|
1239 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand"); |
|
1240 |
|
1241 if (command == caCmdOpen) { |
|
1242 touch(entry); |
|
1243 } |
|
1244 |
|
1245 mErrorCode = mProxy->executeCommand(entry, command); |
|
1246 |
|
1247 qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:" |
|
1248 << mErrorCode; |
|
1249 |
|
1250 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::executeCommand"); |
|
1251 |
|
1252 return (mErrorCode == NoErrorCode); |
|
1253 } |
|
1254 |
|
1255 /*! |
|
1256 Creates new notifier. Factory class |
|
1257 \param CaNotifierFilter which is used be new notifier |
|
1258 \retval pointer to new Notifier |
|
1259 */ |
|
1260 CaNotifier *CaServicePrivate::createNotifier(const CaNotifierFilter &filter) |
|
1261 { |
|
1262 return new CaNotifier(new CaNotifierPrivate(filter)); |
|
1263 } |
|
1264 |
|
1265 /*! |
|
1266 Set new order of collection's items set by user. |
|
1267 \param groupId Group id. |
|
1268 \param entryIdList consists of new order of items. |
|
1269 \retval true if new order of collection's items is set correctly, |
|
1270 otherwise return false. |
|
1271 */ |
|
1272 bool CaServicePrivate::customSort(int groupId, QList<int> &entryIdList) |
|
1273 { |
|
1274 CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::customSort"); |
|
1275 |
|
1276 mErrorCode = mProxy->customSort(entryIdList, groupId); |
|
1277 |
|
1278 CACLIENTTEST_FUNC_EXIT("CaServicePrivate::customSort"); |
|
1279 |
|
1280 return (mErrorCode == NoErrorCode); |
|
1281 } |
|
1282 |
|
1283 /*! |
|
1284 Returns code of an error caused by the last executed operation. |
|
1285 \retval code of error, zero means no error. |
|
1286 */ |
|
1287 ErrorCode CaServicePrivate::lastError() const |
|
1288 { |
|
1289 return mErrorCode; |
|
1290 } |