85
|
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"
|
87
|
33 |
#include "caclienttest_global.h"
|
85
|
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 |
*/
|
92
|
106 |
QSharedPointer<CaEntry> CaService::getEntry(int entryId) const
|
85
|
107 |
{
|
92
|
108 |
QList< QSharedPointer<CaEntry> > entries = getEntries(QList<int> () << entryId);
|
85
|
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];
|
87
|
113 |
} else {
|
92
|
114 |
return QSharedPointer<CaEntry>();
|
85
|
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 |
*/
|
92
|
138 |
QList< QSharedPointer<CaEntry> > CaService::getEntries(const QList<int> &entryIdList) const
|
85
|
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 |
*/
|
92
|
165 |
QList< QSharedPointer<CaEntry> > CaService::getEntries(const CaQuery &query) const
|
85
|
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 |
*/
|
92
|
219 |
QSharedPointer<CaEntry> CaService::createEntry(const CaEntry &entry) const
|
85
|
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 |
...
|
92
|
287 |
bool result = service->removeEntries( QList< QSharedPointer<CaEntry> >() << newItem );
|
85
|
288 |
\b Output:
|
|
289 |
result == true
|
|
290 |
\endcode
|
|
291 |
*/
|
92
|
292 |
bool CaService::removeEntries(const QList< QSharedPointer<CaEntry> > &entryList) const
|
85
|
293 |
{
|
|
294 |
QList<int> idList;
|
92
|
295 |
QSharedPointer<CaEntry> entry;
|
85
|
296 |
foreach(entry, entryList) {
|
87
|
297 |
idList << entry->id();
|
|
298 |
}
|
85
|
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,
|
87
|
361 |
int beforeEntryId) const
|
85
|
362 |
{
|
|
363 |
return insertEntriesIntoGroup(groupId, QList<int> () << entryId,
|
87
|
364 |
beforeEntryId);
|
85
|
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,
|
87
|
389 |
const CaEntry &entry, int beforeEntryId) const
|
85
|
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,
|
87
|
417 |
const QList<int> &entryIdList, int beforeEntryId) const
|
85
|
418 |
{
|
|
419 |
if (beforeEntryId < 0) {
|
|
420 |
qWarning(
|
|
421 |
"CaService::insertEntriesIntoGroup: beforeEntryId cannot be negative: %d",
|
|
422 |
beforeEntryId);
|
|
423 |
return false;
|
87
|
424 |
} else {
|
85
|
425 |
return m_d->insertEntriesIntoGroup(groupId, entryIdList,
|
87
|
426 |
beforeEntryId);
|
85
|
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,
|
92
|
452 |
const QList< QSharedPointer<CaEntry> > &entryList, int beforeEntryId) const
|
85
|
453 |
{
|
|
454 |
QList<int> idList;
|
92
|
455 |
QSharedPointer<CaEntry> entry;
|
85
|
456 |
foreach(entry, entryList) {
|
87
|
457 |
idList << entry->id();
|
|
458 |
}
|
85
|
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,
|
87
|
510 |
const CaEntry &entry) const
|
85
|
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,
|
87
|
538 |
const QList<int> &entryIdList) const
|
85
|
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,
|
92
|
566 |
const QList< QSharedPointer<CaEntry> > &entryList) const
|
85
|
567 |
{
|
|
568 |
QList<int> idList;
|
92
|
569 |
QSharedPointer<CaEntry> entry;
|
85
|
570 |
foreach(entry, entryList) {
|
87
|
571 |
idList << entry->id();
|
|
572 |
}
|
85
|
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 |
*/
|
87
|
581 |
bool CaServicePrivate::touch(const CaEntry &entry)
|
85
|
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,
|
87
|
638 |
const CaEntry &entry) const
|
85
|
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,
|
87
|
665 |
const QList<int> &entryIdList) const
|
85
|
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(
|
92
|
684 |
*newGroup, QList< QSharedPointer<CaEntry> >() << entryToAppend );
|
85
|
685 |
...
|
|
686 |
\b Output:
|
|
687 |
result == true
|
|
688 |
\endcode
|
|
689 |
*/
|
|
690 |
bool CaService::appendEntriesToGroup(const CaEntry &group,
|
92
|
691 |
const QList< QSharedPointer<CaEntry> > &entryList) const
|
85
|
692 |
{
|
|
693 |
QList<int> idList;
|
92
|
694 |
QSharedPointer<CaEntry> entry;
|
85
|
695 |
foreach(entry, entryList) {
|
87
|
696 |
idList << entry->id();
|
|
697 |
}
|
85
|
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,
|
87
|
747 |
const CaEntry &entry) const
|
85
|
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,
|
87
|
774 |
const QList<int> &entryIdList) const
|
85
|
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,
|
92
|
800 |
const QList< QSharedPointer<CaEntry> > &entryList) const
|
85
|
801 |
{
|
|
802 |
QList<int> idList;
|
92
|
803 |
QSharedPointer<CaEntry> entry;
|
85
|
804 |
foreach(entry, entryList) {
|
87
|
805 |
idList << entry->id();
|
|
806 |
}
|
85
|
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;
|
88
|
833 |
|
92
|
834 |
const QSharedPointer<CaEntry> temporaryEntry = getEntry(entryId);
|
88
|
835 |
|
92
|
836 |
if (!temporaryEntry.isNull()) {
|
85
|
837 |
result = executeCommand(*temporaryEntry, command);
|
|
838 |
}
|
|
839 |
return result;
|
|
840 |
}
|
|
841 |
|
|
842 |
/*!
|
|
843 |
Execute command.
|
|
844 |
\param entry entry.
|
|
845 |
\param command command.
|
|
846 |
\retval true if operation was successful.
|
|
847 |
|
|
848 |
\example
|
|
849 |
\code
|
|
850 |
...
|
|
851 |
CaEntry itemExecute;
|
|
852 |
itemExecute.setText("URL");
|
|
853 |
itemExecute.setTypeName("url");
|
|
854 |
itemExecute.setAttribute("url", "http://www.nokia.com");
|
|
855 |
CaEntry * entryExecute = service->createEntry(itemExecute->id());
|
|
856 |
bool result = service->executeCommand(*entryExecute, "open");
|
|
857 |
...
|
|
858 |
\b Output:
|
|
859 |
result == true
|
|
860 |
\endcode
|
|
861 |
*/
|
|
862 |
bool CaService::executeCommand(const CaEntry &entry, const QString &command) const
|
|
863 |
{
|
|
864 |
return m_d->executeCommand(entry, command);
|
|
865 |
}
|
|
866 |
|
|
867 |
/*!
|
|
868 |
Creates notifier.
|
|
869 |
\param const reference to CaNotifierFilter.
|
|
870 |
\retval pointer to created CaNotifier instance.
|
|
871 |
|
|
872 |
\code
|
|
873 |
...
|
|
874 |
// creating notifier with specified notifier filter
|
|
875 |
CaNotifierFilter notifierFilter;
|
|
876 |
notifierFilter.setIds( QList<int>() << newGroup->id() << newItem->id() );
|
|
877 |
notifierFilter.setEntryRole( ItemEntryRole | GroupEntryRole );
|
|
878 |
CaNotifier * notifier = service->createNotifier( notifierFilter );
|
|
879 |
...
|
|
880 |
\endcode
|
|
881 |
*/
|
87
|
882 |
CaNotifier *CaService::createNotifier(const CaNotifierFilter &filter) const
|
85
|
883 |
{
|
|
884 |
return m_d->createNotifier(filter);
|
|
885 |
}
|
|
886 |
|
|
887 |
/*!
|
|
888 |
Set new order of collection's items set by user.
|
|
889 |
\groupId Group id.
|
86
|
890 |
\param entryIdList consists of new order of items.
|
85
|
891 |
\retval true if new order of collection's items is set correctly,
|
|
892 |
otherwise return false.
|
|
893 |
*/
|
|
894 |
|
|
895 |
bool CaService::customSort(int groupId, QList<int> &entryIdList) const
|
|
896 |
{
|
|
897 |
return m_d->customSort(groupId, entryIdList);
|
|
898 |
}
|
|
899 |
|
|
900 |
/*!
|
|
901 |
Returns code of an error caused by the last executed operation.
|
|
902 |
\retval code of error, zero means no error.
|
|
903 |
|
|
904 |
\example
|
|
905 |
\code
|
|
906 |
...
|
|
907 |
CaEntry itemExecute;
|
|
908 |
itemExecute.setText("URL");
|
|
909 |
itemExecute.setTypeName("url");
|
|
910 |
itemExecute.setAttribute("url", "http://www.nokia.com");
|
|
911 |
CaEntry * entryExecute = service->createEntry(itemExecute->id());
|
|
912 |
bool result = service->executeCommand(*entryExecute, "open");
|
|
913 |
|
|
914 |
ErrorCode errorCode = lastError();
|
|
915 |
switch (errorCode) {
|
|
916 |
case NoErrorCode:
|
|
917 |
...
|
|
918 |
case BadArgumentErrorCode:
|
|
919 |
...
|
|
920 |
}
|
|
921 |
...
|
|
922 |
|
|
923 |
\endcode
|
|
924 |
*/
|
|
925 |
ErrorCode CaService::lastError() const
|
|
926 |
{
|
|
927 |
return m_d->lastError();
|
|
928 |
}
|
|
929 |
|
|
930 |
|
|
931 |
/*!
|
|
932 |
Constructor
|
|
933 |
\param servicePublic pointer to public service
|
|
934 |
*/
|
|
935 |
CaServicePrivate::CaServicePrivate(CaService *servicePublic) :
|
88
|
936 |
m_q(servicePublic), mProxy(new CaClientProxy)
|
85
|
937 |
{
|
|
938 |
const ErrorCode connectionResult = mProxy->connect();
|
|
939 |
|
|
940 |
USE_QWARNING_IF(connectionResult)
|
87
|
941 |
<< "CaServicePrivate::CaServicePrivate - unable to connect proxy";
|
85
|
942 |
|
|
943 |
mErrorCode = connectionResult;
|
|
944 |
}
|
|
945 |
|
|
946 |
/*!
|
|
947 |
destructor
|
|
948 |
*/
|
|
949 |
CaServicePrivate::~CaServicePrivate()
|
|
950 |
{
|
|
951 |
delete mProxy;
|
|
952 |
}
|
|
953 |
|
|
954 |
/*!
|
|
955 |
Search for entries.
|
|
956 |
\param entryIdList list of entry ids
|
|
957 |
\retval list of entries (pointers)
|
|
958 |
*/
|
92
|
959 |
QList< QSharedPointer<CaEntry> > CaServicePrivate::getEntries(const QList<int> &entryIdList) const
|
85
|
960 |
{
|
|
961 |
qDebug() << "CaServicePrivate::getEntries"
|
87
|
962 |
<< "entryIdList:" << entryIdList;
|
85
|
963 |
|
87
|
964 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::getEntries");
|
|
965 |
|
92
|
966 |
QList< QSharedPointer<CaEntry> > resultList;
|
85
|
967 |
|
|
968 |
mErrorCode = mProxy->getData(entryIdList, resultList);
|
|
969 |
|
|
970 |
// figure out whether all entries have been retrieved and
|
|
971 |
// store the operation status
|
|
972 |
if (mErrorCode == NoErrorCode
|
87
|
973 |
&& entryIdList.count() != resultList.count()) {
|
85
|
974 |
mErrorCode = NotFoundErrorCode;
|
|
975 |
}
|
87
|
976 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::getEntries");
|
85
|
977 |
|
|
978 |
qDebug() << "CaServicePrivate::getEntries mErrorCode:"
|
87
|
979 |
<< mErrorCode;
|
85
|
980 |
|
|
981 |
return resultList;
|
|
982 |
}
|
|
983 |
|
|
984 |
/*!
|
|
985 |
Fetches data from database.
|
|
986 |
\param query the query information to select specific entries.
|
|
987 |
\param placeholder list of entries for a specific select.
|
|
988 |
*/
|
92
|
989 |
QList< QSharedPointer<CaEntry> > CaServicePrivate::getEntries(const CaQuery &query) const
|
85
|
990 |
{
|
92
|
991 |
QList< QSharedPointer<CaEntry> > resultList;
|
85
|
992 |
|
|
993 |
mErrorCode = mProxy->getData(query, resultList);
|
|
994 |
|
|
995 |
qDebug() << "CaServicePrivate::getEntries mErrorCode:" << mErrorCode;
|
|
996 |
|
|
997 |
return resultList;
|
|
998 |
}
|
|
999 |
|
|
1000 |
/*!
|
|
1001 |
Search for entries and return their ids.
|
|
1002 |
\param query query
|
|
1003 |
\retval list of ids
|
|
1004 |
*/
|
|
1005 |
QList<int> CaServicePrivate::getEntryIds(const CaQuery &query) const
|
|
1006 |
{
|
87
|
1007 |
CACLIENTTEST_FUNC_ENTRY("CaItemModelList::getEntryIds");
|
|
1008 |
|
85
|
1009 |
QList<int> resultList;
|
|
1010 |
mErrorCode = mProxy->getEntryIds(query, resultList);
|
87
|
1011 |
CACLIENTTEST_FUNC_EXIT("CaItemModelList::getEntryIds");
|
85
|
1012 |
qDebug() << "CaServicePrivate::getEntryIds mErrorCode:" << mErrorCode;
|
|
1013 |
return resultList;
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
/*!
|
|
1017 |
Create copy of entry.
|
|
1018 |
\param query const reference to entry to copy
|
|
1019 |
\retval pointer to newely created copy
|
|
1020 |
*/
|
92
|
1021 |
QSharedPointer<CaEntry> CaServicePrivate::createEntry(const CaEntry &entry)
|
85
|
1022 |
{
|
|
1023 |
qDebug() << "CaServicePrivate::createEntry"
|
87
|
1024 |
<< "entry id:" << entry.id();
|
85
|
1025 |
|
87
|
1026 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::createEntry");
|
|
1027 |
|
85
|
1028 |
ErrorCode addDataResult = NoErrorCode;
|
|
1029 |
|
92
|
1030 |
QSharedPointer<CaEntry> newEntry (new CaEntry(entry.role()));
|
85
|
1031 |
|
92
|
1032 |
QScopedPointer<CaEntry> entryClone(new CaEntry(entry));
|
|
1033 |
const int nonExistingObjectId = 0;
|
|
1034 |
CaObjectAdapter::setId(*entryClone, nonExistingObjectId);
|
85
|
1035 |
|
92
|
1036 |
addDataResult =
|
|
1037 |
mProxy->addData(*entryClone, *newEntry);
|
85
|
1038 |
|
92
|
1039 |
// return empty pointer if nothing was added
|
85
|
1040 |
if (addDataResult != NoErrorCode) {
|
92
|
1041 |
newEntry.clear();
|
85
|
1042 |
}
|
92
|
1043 |
|
85
|
1044 |
mErrorCode = addDataResult;
|
|
1045 |
|
|
1046 |
qDebug() << "CaServicePrivate::createEntry mErrorCode:" << mErrorCode;
|
|
1047 |
|
87
|
1048 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::createEntry");
|
|
1049 |
|
85
|
1050 |
return newEntry;
|
|
1051 |
}
|
|
1052 |
|
|
1053 |
/*!
|
|
1054 |
Update entry.
|
|
1055 |
\param entry entry const reference of entry to update
|
|
1056 |
\retval true if operation was successful
|
|
1057 |
*/
|
|
1058 |
bool CaServicePrivate::updateEntry(const CaEntry &entry)
|
|
1059 |
{
|
|
1060 |
qDebug() << "CaServicePrivate::updateEntry"
|
87
|
1061 |
<< "entry id:" << entry.id();
|
|
1062 |
|
|
1063 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::updateEntry");
|
85
|
1064 |
|
|
1065 |
ErrorCode updateEntryResult = UnknownErrorCode;
|
|
1066 |
|
|
1067 |
if (entry.id() != 0) {
|
|
1068 |
try {
|
|
1069 |
QScopedPointer<CaEntry> updatedEntry(new CaEntry(entry.role()));
|
|
1070 |
|
|
1071 |
updateEntryResult = mProxy->addData(entry, *updatedEntry);
|
|
1072 |
|
87
|
1073 |
} catch (const std::bad_alloc &) {
|
85
|
1074 |
updateEntryResult = OutOfMemoryErrorCode;
|
|
1075 |
}
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
mErrorCode = updateEntryResult;
|
|
1079 |
|
|
1080 |
qDebug() << "CaServicePrivate::updateEntry mErrorCode on return:"
|
87
|
1081 |
<< mErrorCode;
|
|
1082 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::updateEntry");
|
85
|
1083 |
|
|
1084 |
return (updateEntryResult == NoErrorCode);
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
/*!
|
|
1088 |
Remove entries.
|
|
1089 |
\param entryIdList list of entries ids to remove
|
|
1090 |
\retval true if operation was successful
|
|
1091 |
*/
|
|
1092 |
bool CaServicePrivate::removeEntries(const QList<int> &entryIdList)
|
|
1093 |
{
|
|
1094 |
qDebug() << "CaServicePrivate::removeEntries"
|
87
|
1095 |
<< "entryIdList: " << entryIdList;
|
|
1096 |
|
|
1097 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::removeEntries");
|
85
|
1098 |
|
|
1099 |
mErrorCode = mProxy->removeData(entryIdList);
|
|
1100 |
|
|
1101 |
qDebug() << "CaServicePrivate::removeEntries mErrorCode:" << mErrorCode;
|
|
1102 |
|
87
|
1103 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::removeEntries");
|
|
1104 |
|
85
|
1105 |
return (mErrorCode == NoErrorCode);
|
|
1106 |
}
|
|
1107 |
|
|
1108 |
/*!
|
|
1109 |
Insert entry into a given group.
|
|
1110 |
\param groupId groupId.
|
|
1111 |
\param entryIdList list of entries ids to insert.
|
|
1112 |
\param beforeEntryId id of an entry before which the given entry is inserted.
|
|
1113 |
\retval true if operation was successful.
|
|
1114 |
*/
|
|
1115 |
bool CaServicePrivate::insertEntriesIntoGroup(
|
|
1116 |
int groupId,
|
|
1117 |
const QList<int> &entryIdList,
|
|
1118 |
int beforeEntryId) // all others are convenience methods implemented in terms of this one
|
|
1119 |
{
|
|
1120 |
qDebug() << "CaServicePrivate::insertEntriesIntoGroup"
|
87
|
1121 |
<< "groupId: " << groupId << " beforeEntryId: " << beforeEntryId
|
|
1122 |
<< "entryIdList: " << entryIdList;
|
|
1123 |
|
|
1124 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::insertEntriesIntoGroup");
|
85
|
1125 |
|
|
1126 |
mErrorCode = mProxy->insertEntriesIntoGroup(groupId, entryIdList, beforeEntryId);
|
|
1127 |
|
|
1128 |
qDebug() << "CaServicePrivate::insertEntriesIntoGroup mErrorCode:"
|
87
|
1129 |
<< mErrorCode;
|
|
1130 |
|
|
1131 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::insertEntriesIntoGroup");
|
85
|
1132 |
|
|
1133 |
return (mErrorCode == NoErrorCode);
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
/*!
|
|
1137 |
Remove entries from a given group.
|
|
1138 |
|
|
1139 |
\param groupId groupId.
|
|
1140 |
\param entryIDList list of entries ids to remove.
|
|
1141 |
\retval true if operation was successful.
|
|
1142 |
*/
|
|
1143 |
bool CaServicePrivate::removeEntriesFromGroup(
|
|
1144 |
int groupId,
|
|
1145 |
const QList<int> &entryIdList)
|
|
1146 |
{
|
|
1147 |
qDebug() << "CaServicePrivate::removeEntriesFromGroup"
|
87
|
1148 |
<< "groupId: " << groupId << "entryIdList" << entryIdList;
|
|
1149 |
|
|
1150 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::removeEntriesFromGroup");
|
85
|
1151 |
|
|
1152 |
mErrorCode = mProxy->removeEntriesFromGroup(groupId, entryIdList);
|
|
1153 |
|
|
1154 |
qDebug() << "CaServicePrivate::removeEntriesFromGroup mErrorCode:"
|
87
|
1155 |
<< mErrorCode;
|
|
1156 |
|
|
1157 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::removeEntriesFromGroup");
|
85
|
1158 |
|
|
1159 |
return (mErrorCode == NoErrorCode);
|
|
1160 |
}
|
|
1161 |
|
|
1162 |
/*!
|
|
1163 |
Place entries in a given group at the end.
|
|
1164 |
\param groupId groupId.
|
|
1165 |
\param entryIdList list of entries ids to prepend.
|
|
1166 |
\retval true if operation was successful.
|
|
1167 |
*/
|
|
1168 |
bool CaServicePrivate::appendEntriesToGroup(
|
|
1169 |
int groupId,
|
|
1170 |
const QList<int> &entryIdList)
|
|
1171 |
{
|
|
1172 |
qDebug() << "CaServicePrivate::appendEntriesToGroup"
|
87
|
1173 |
<< "groupId: " << groupId << "entryIdList: " << entryIdList;
|
|
1174 |
|
|
1175 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::appendEntriesToGroup");
|
85
|
1176 |
|
|
1177 |
const bool result = insertEntriesIntoGroup(
|
87
|
1178 |
groupId,
|
|
1179 |
entryIdList,
|
|
1180 |
CaClientProxy::AfterTheLastEntry);
|
85
|
1181 |
|
|
1182 |
qDebug() << "CaServicePrivate::appendEntriesToGroup result:"
|
87
|
1183 |
<< QString(result ? "true" : "false");
|
|
1184 |
|
|
1185 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::appendEntriesToGroup");
|
85
|
1186 |
|
|
1187 |
return result;
|
|
1188 |
}
|
|
1189 |
|
|
1190 |
/*!
|
|
1191 |
Place entries in a given group at the begin.
|
|
1192 |
\param groupId groupId.
|
|
1193 |
\param entryIdList list of entries ids to prepend.
|
|
1194 |
\retval true if operation was successful.
|
|
1195 |
*/
|
|
1196 |
bool CaServicePrivate::prependEntriesToGroup(int groupId,
|
87
|
1197 |
const QList<int> &entryIdList)
|
85
|
1198 |
{
|
|
1199 |
qDebug() << "CaServicePrivate::prependEntriesToGroup"
|
87
|
1200 |
<< "groupId: " << groupId << "entryIdList: " << entryIdList;
|
|
1201 |
|
|
1202 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::prependEntriesToGroup");
|
85
|
1203 |
|
|
1204 |
const bool result =
|
87
|
1205 |
insertEntriesIntoGroup(
|
|
1206 |
groupId,
|
|
1207 |
entryIdList,
|
|
1208 |
CaClientProxy::BeforeTheFirstEntry);
|
85
|
1209 |
|
|
1210 |
qDebug() << "CaServicePrivate::prependEntriesToGroup result:"
|
87
|
1211 |
<< QString(result ? "PASS" : "FAIL");
|
|
1212 |
|
|
1213 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::prependEntriesToGroup");
|
85
|
1214 |
|
|
1215 |
return result;
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
/*!
|
|
1219 |
Executes command on entry (fe. "open", "remove")
|
|
1220 |
\param const reference to an entry on which command will be issued
|
|
1221 |
\param string containing a command
|
|
1222 |
\retval boolean which is used as an error code return value, true means positive result
|
|
1223 |
*/
|
|
1224 |
bool CaServicePrivate::executeCommand(const CaEntry &entry,
|
87
|
1225 |
const QString &command)
|
85
|
1226 |
{
|
|
1227 |
qDebug() << "CaServicePrivate::executeCommand"
|
87
|
1228 |
<< "entry id:" << entry.id() << "command:" << command;
|
|
1229 |
|
|
1230 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand");
|
85
|
1231 |
|
87
|
1232 |
if (command == caCmdOpen) {
|
|
1233 |
touch(entry);
|
|
1234 |
}
|
85
|
1235 |
|
|
1236 |
mErrorCode = mProxy->executeCommand(entry, command);
|
|
1237 |
|
|
1238 |
qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:"
|
87
|
1239 |
<< mErrorCode;
|
|
1240 |
|
|
1241 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::executeCommand");
|
85
|
1242 |
|
|
1243 |
return (mErrorCode == NoErrorCode);
|
|
1244 |
}
|
|
1245 |
|
|
1246 |
/*!
|
|
1247 |
Creates new notifier. Factory class
|
|
1248 |
\param CaNotifierFilter which is used be new notifier
|
|
1249 |
\retval pointer to new Notifier
|
|
1250 |
*/
|
87
|
1251 |
CaNotifier *CaServicePrivate::createNotifier(const CaNotifierFilter &filter)
|
85
|
1252 |
{
|
|
1253 |
return new CaNotifier(new CaNotifierPrivate(filter));
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
/*!
|
|
1257 |
Set new order of collection's items set by user.
|
|
1258 |
\param groupId Group id.
|
|
1259 |
\param entryIdList consists of new order of items.
|
|
1260 |
\retval true if new order of collection's items is set correctly,
|
|
1261 |
otherwise return false.
|
|
1262 |
*/
|
|
1263 |
bool CaServicePrivate::customSort(int groupId, QList<int> &entryIdList)
|
|
1264 |
{
|
87
|
1265 |
CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::customSort");
|
|
1266 |
|
85
|
1267 |
mErrorCode = mProxy->customSort(entryIdList, groupId);
|
87
|
1268 |
|
|
1269 |
CACLIENTTEST_FUNC_EXIT("CaServicePrivate::customSort");
|
|
1270 |
|
85
|
1271 |
return (mErrorCode == NoErrorCode);
|
|
1272 |
}
|
|
1273 |
|
|
1274 |
/*!
|
|
1275 |
Returns code of an error caused by the last executed operation.
|
|
1276 |
\retval code of error, zero means no error.
|
|
1277 |
*/
|
|
1278 |
ErrorCode CaServicePrivate::lastError() const
|
|
1279 |
{
|
|
1280 |
return mErrorCode;
|
|
1281 |
}
|