2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file ContactManager.cpp
20 * @author Kisub Song (kisubs.song@samsung.com)
25 #include "ContactManager.h"
28 #include <Commons/Regex.h>
29 #include "ContactFactory.h"
30 #include "IAddressBook.h"
31 #include "ContactsSvcWrapper.h"
32 #include "ContactsSvcObjectConverter.h"
33 #include "ContactUtility.h"
34 #include "PersonFilterValidator.h"
35 #include "PersonSearchEngine.h"
37 #include "ContactQueue.h"
44 using namespace WrtDeviceApis::Commons;
45 using namespace DeviceAPI::Tizen;
47 ContactManager::ContactManager() : m_eventMapAcc(0)
49 ContactsSvcWrapperSingleton::Instance();
52 ContactManager::~ContactManager()
54 if(m_contactManagerEmitters.size() != 0)
56 ContactsSvcChangeListenerManagerSingleton::Instance().unregisterPersonsChangeListener(this);
60 void ContactManager::OnRequestReceived(const EventContactManagerGetAddressBookPtr &event)
66 std::string addressBookId = event->getAddressBookId();
67 if(addressBookId.empty())
69 //when database is not opened then set result as failed
70 ThrowMsg(NotFoundException, "invalid Address book");
73 AddressBookPtr addressBook =
74 ContactsSvcWrapperSingleton::Instance().getAddressBook(addressBookId);
76 event->setAddressBook(addressBook);
77 event->setResult(true);
78 event->setExceptionCode(ExceptionCodes::None);
80 Catch(PlatformException)
82 //when database is not opened then set result as failed
83 LoggerE("Contact DB not opened : " << _rethrown_exception.GetMessage());
84 event->setResult(false);
85 event->setExceptionCode(ExceptionCodes::PlatformException);
88 Catch(NotFoundException)
90 //when database is not opened then set result as failed
91 LoggerE("Not found : " << _rethrown_exception.GetMessage());
92 event->setResult(false);
93 event->setExceptionCode(ExceptionCodes::NotFoundException);
97 LoggerE("Unknown exception : " << _rethrown_exception.GetMessage());
98 event->setResult(false);
99 event->setExceptionCode(ExceptionCodes::UnknownException);
104 void ContactManager::OnRequestReceived(const EventContactManagerGetAddressBooksPtr &event)
110 AddressBookArrayPtr addressBookArray =
111 ContactsSvcWrapperSingleton::Instance().getAddressBooks();
113 event->setAddressBooks(addressBookArray);
114 event->setResult(true);
115 event->setExceptionCode(ExceptionCodes::None);
117 Catch (PlatformException)
119 //when database is not opened then set result as failed
120 LoggerE("Contact DB is not opened.");
121 event->setResult(false);
122 event->setExceptionCode(ExceptionCodes::PlatformException);
127 LoggerE("Unknown exception : " << _rethrown_exception.GetMessage());
128 event->setResult(false);
129 event->setExceptionCode(ExceptionCodes::UnknownException);
134 void ContactManager::OnRequestReceived(const EventContactManagerGetDefaultAddressBookPtr &event)
140 AddressBookPtr defaultAddressBook =
141 ContactsSvcWrapperSingleton::Instance().getDefaultAddressBook();
143 event->setDefaultAddressBook(defaultAddressBook);
144 event->setResult(true);
145 event->setExceptionCode(ExceptionCodes::None);
147 Catch (PlatformException)
149 //when database is not opened then set result as failed
150 LoggerE("Contact DB is not opened.");
151 event->setResult(false);
152 event->setExceptionCode(ExceptionCodes::PlatformException);
157 LoggerE("Unknown exception : " << _rethrown_exception.GetMessage());
158 event->setResult(false);
159 event->setExceptionCode(ExceptionCodes::UnknownException);
164 void ContactManager::OnRequestReceived(const EventContactManagerGetUnifiedAddressBookPtr &event)
170 AddressBookPtr unifiedAddressBook =
171 ContactsSvcWrapperSingleton::Instance().getUnifiedAddressBook();
173 event->setUnifiedAddressBook(unifiedAddressBook);
174 event->setResult(true);
175 event->setExceptionCode(ExceptionCodes::None);
177 Catch (PlatformException)
179 //when database is not opened then set result as failed
180 LoggerE("Contact DB is not opened.");
181 event->setResult(false);
182 event->setExceptionCode(ExceptionCodes::PlatformException);
187 LoggerE("Unknown exception : " << _rethrown_exception.GetMessage());
188 event->setResult(false);
189 event->setExceptionCode(ExceptionCodes::UnknownException);
194 void ContactManager::OnRequestReceived(const EventContactManagerGetPtr &event)
199 contacts_record_h contacts_record = NULL;
202 if(!event->getIdIsSet())
203 ThrowMsg(InvalidArgumentException, "Invalid person");
205 string personId = event->getId();
207 int personIdInt = ContactUtility::strToInt(personId);
209 errorCode = contacts_db_get_record(_contacts_person._uri, personIdInt, &contacts_record);
210 if(errorCode != CONTACTS_ERROR_NONE)
212 ThrowMsg(NotFoundException, "No person : " << errorCode);
214 PersonPtr person = PersonPtr(new Person());
216 ContactsSvcObjectConverter::convertToAbstract(contacts_record, person);
218 event->setPerson(person);
219 event->setResult(true);
221 } Catch (NotFoundException) {
222 LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage());
223 event->setExceptionCode(ExceptionCodes::NotFoundException);
224 event->setResult(false);
226 } Catch (PlatformException) {
227 LoggerE("Error during getting person : " << _rethrown_exception.GetMessage());
228 event->setExceptionCode(ExceptionCodes::PlatformException);
229 event->setResult(false);
231 } Catch (InvalidArgumentException) {
232 LoggerE("Invalid Arguments : " << _rethrown_exception.GetMessage());
233 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
234 event->setResult(false);
237 LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
238 event->setExceptionCode(ExceptionCodes::UnknownException);
239 event->setResult(false);
242 if(contacts_record != NULL)
243 contacts_record_destroy(contacts_record, true);
246 void ContactManager::OnRequestReceived(const EventContactManagerUpdatePtr &event)
252 contacts_record_h contacts_record = NULL;
253 PersonPtr person(NULL);
256 if(!event->getPersonIsSet())
257 ThrowMsg(InvalidArgumentException, "Persons were not set.");
259 person = event->getPerson();
261 ThrowMsg(InvalidArgumentException, "No persons.");
263 if(!person->getIdIsSet())
264 ThrowMsg(InvalidArgumentException, "Person object is wrong");
266 } Catch(InvalidArgumentException) {
267 LoggerE("Invalid arguments for updating persons : " << _rethrown_exception.GetMessage());
268 event->setResult(false);
269 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
275 int id = ContactUtility::strToInt(person->getId());
276 errorCode = contacts_db_get_record(_contacts_person._uri, id, &contacts_record);
277 if (errorCode == CONTACTS_ERROR_INVALID_PARAMETER)
278 ThrowMsg(NotFoundException, "Error during executing contacts_db_get_record()");
279 else if (errorCode != CONTACTS_ERROR_NONE) {
280 LoggerE("error code : " << errorCode);
281 ThrowMsg(PlatformException, "Error during executing contacts_db_get_record()");
284 ContactsSvcObjectConverter::convertToPlatform(person, contacts_record);
286 errorCode = contacts_db_update_record(contacts_record);
287 if (errorCode == CONTACTS_ERROR_INVALID_PARAMETER)
288 ThrowMsg(NotFoundException, "Error during executing contacts_db_update_record()");
289 else if (errorCode != CONTACTS_ERROR_NONE) {
290 LoggerE("error code : " << errorCode);
291 ThrowMsg(PlatformException, "Error during executing contacts_db_update_record()");
294 event->setResult(true);
295 event->setExceptionCode(ExceptionCodes::None);
297 Catch (NotFoundException)
299 LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage());
300 event->setResult(false);
301 event->setExceptionCode(ExceptionCodes::NotFoundException);
303 Catch (PlatformException) {
304 LoggerE("Error during updating person : " << _rethrown_exception.GetMessage());
305 event->setResult(false);
306 event->setExceptionCode(ExceptionCodes::PlatformException);
309 LoggerE("Error during display_contact_id person : " << _rethrown_exception.GetMessage());
310 event->setResult(false);
311 event->setExceptionCode(ExceptionCodes::PlatformException);
314 if(contacts_record != NULL)
315 contacts_record_destroy(contacts_record, true);
320 void ContactManager::managerUpdateBatch(const EventContactManagerUpdateBatchPtr &event)
324 contacts_list_h contacts_list = NULL;
325 PersonArrayPtr persons(NULL);
327 if(!event->getPersonsIsSet())
328 ThrowMsg(InvalidArgumentException, "Persons were not set.");
330 persons = event->getPersons();
332 ThrowMsg(InvalidArgumentException, "No persons.");
334 errorCode = contacts_list_create(&contacts_list);
335 if(errorCode != CONTACTS_ERROR_NONE){
336 if(contacts_list != NULL)
337 contacts_list_destroy(contacts_list, false);
338 ThrowMsg(PlatformException, "Fail to create contacts_list_h");
341 for(PersonArray::iterator i = persons->begin(); i != persons->end(); i++)
343 contacts_record_h contacts_record = NULL;
344 PersonPtr person = *i;
348 int personIdInt = ContactUtility::strToInt(person->getId());
349 errorCode = contacts_db_get_record(_contacts_person._uri, personIdInt, &contacts_record);
350 if(errorCode != CONTACTS_ERROR_NONE)
352 ThrowMsg(NotFoundException, "No person");
355 ContactsSvcObjectConverter::convertToPlatform(person, contacts_record);
357 errorCode = contacts_list_add(contacts_list, contacts_record);
358 if(errorCode != CONTACTS_ERROR_NONE)
360 ThrowMsg(PlatformException, "Error during add to list");
363 Catch(NotFoundException)
365 if(contacts_list != NULL)
366 contacts_list_destroy(contacts_list, false);
367 ThrowMsg(NotFoundException, "Error during converting contact object");
368 // LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage());
371 Catch(PlatformException)
373 if(contacts_list != NULL)
374 contacts_list_destroy(contacts_list, false);
375 ThrowMsg(NotFoundException, "Error during converting contact object");
376 // LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage());
381 KeySharePtrPair *keyPair = new KeySharePtrPair();
382 keyPair->key = m_eventMapAcc;
383 keyPair->contactManager = this;
384 errorCode = contacts_db_update_records_async(contacts_list, personsUpdateBatchResultCallback, (void*)keyPair);
385 if(errorCode != CONTACTS_ERROR_NONE)
388 if(contacts_list != NULL)
389 contacts_list_destroy(contacts_list, false);
390 ThrowMsg(PlatformException, "Error during contacts_db_update_records_async");
393 errorCode = contacts_list_destroy(contacts_list, true);
394 contacts_list = NULL;
395 if(errorCode != CONTACTS_ERROR_NONE)
398 ThrowMsg(PlatformException, "Error during contacts_list_destroy");
401 pair<long, EventContactManagerUpdateBatchPtr> keyEventPair(m_eventMapAcc, event);
402 m_updateBatchEventMap.insert(keyEventPair);
407 void ContactManager::OnRequestReceived(const EventContactManagerUpdateBatchPtr &event)
413 bool isEmpty = ContactQueueManagerSingleton::Instance().empty();
415 managerUpdateBatch(event);
417 ContactQueueManagerSingleton::Instance().push(ContactQueueManager::UPATEBATCH, this, event);
419 ContactQueueManagerSingleton::Instance().increaseQueueList();
420 event->switchToManualAnswer();
422 Catch (NotFoundException)
424 LoggerE("NotFoundException during updating persons : " << _rethrown_exception.GetMessage());
425 event->setResult(false);
426 event->setExceptionCode(ExceptionCodes::NotFoundException);
428 Catch (PlatformException)
430 LoggerE("PlatformException during updating persons : " << _rethrown_exception.GetMessage());
431 event->setResult(false);
432 event->setExceptionCode(ExceptionCodes::PlatformException);
434 Catch(InvalidArgumentException)
436 LoggerE("InvalidArgumentException during updating persons : " << _rethrown_exception.GetMessage());
437 event->setResult(false);
438 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
442 LoggerE("Error during updating persons : " << _rethrown_exception.GetMessage());
443 event->setResult(false);
444 event->setExceptionCode(ExceptionCodes::PlatformException);
448 void ContactManager::OnRequestReceived(const EventContactManagerRemovePtr &event)
455 if(!event->getPersonIdIsSet())
456 ThrowMsg(InvalidArgumentException, "Persons were not set.");
458 string personIdStr = event->getPersonId();
460 if(!validate("^[0-9]+$", personIdStr, VALIDATE_MATCH_CASELESS))
461 ThrowMsg(InvalidArgumentException, "invalid" );
464 istringstream iss(personIdStr);
467 ThrowMsg(InvalidArgumentException, "wrong" );
470 int errorCode = contacts_db_delete_record(_contacts_person._uri, personId);
471 if(errorCode == CONTACTS_ERROR_INVALID_PARAMETER)
472 ThrowMsg(NotFoundException, "Error during executing contacts_db_delete_record()");
473 else if (errorCode != CONTACTS_ERROR_NONE)
474 ThrowMsg(PlatformException, "Error during executing contacts_db_delete_record()");
476 event->setResult(true);
477 event->setExceptionCode(ExceptionCodes::None);
479 Catch (InvalidArgumentException)
481 LoggerE("Invalid person : " << _rethrown_exception.GetMessage());
482 event->setResult(false);
483 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
486 Catch (NotFoundException)
488 LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage());
489 event->setResult(false);
490 event->setExceptionCode(ExceptionCodes::NotFoundException);
493 Catch (PlatformException) {
494 LoggerE("Error during removing person : " << _rethrown_exception.GetMessage());
495 event->setResult(false);
496 event->setExceptionCode(ExceptionCodes::PlatformException);
500 LoggerE("Error during removing person : " << _rethrown_exception.GetMessage());
501 event->setResult(false);
502 event->setExceptionCode(ExceptionCodes::PlatformException);
507 void ContactManager::managerRemoveBatch(const EventContactManagerRemoveBatchPtr &event)
511 StringArrayPtr personIds(NULL);
513 if(!event->getPersonIdsIsSet())
514 ThrowMsg(InvalidArgumentException, "Person IDs were not set.");
516 personIds = event->getPersonIds();
518 ThrowMsg(InvalidArgumentException, "No person.");
520 int *ids = new int[personIds->size()];
523 if(errorCode != CONTACTS_ERROR_NONE)
525 ThrowMsg(PlatformException, "Fail to create contacts_list_h");
528 for(StringArray::iterator i = personIds->begin(); i != personIds->end(); i++)
530 string personIdStr = *i;
536 if(!validate("^[0-9]+$", personIdStr, VALIDATE_MATCH_CASELESS))
537 ThrowMsg(InvalidArgumentException, "invalid" );
541 istringstream iss(personIdStr);
546 ThrowMsg(InvalidArgumentException, "wrong" );
549 ids[count] = personId;
552 Catch(InvalidArgumentException)
554 ThrowMsg(InvalidArgumentException, "Error during converting person object");
555 // LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage());
560 KeySharePtrPair *keyPair = new KeySharePtrPair();
561 keyPair->key = m_eventMapAcc;
562 keyPair->contactManager = this;
563 errorCode = contacts_db_delete_records_async(_contacts_person._uri, ids, count, personsRemoveBatchResultCallback, (void*)keyPair);
570 if(errorCode != CONTACTS_ERROR_NONE)
573 ThrowMsg(PlatformException, "Error during add to list");
576 pair<long, EventContactManagerRemoveBatchPtr> keyEventPair(m_eventMapAcc, event);
577 m_removeBatchEventMap.insert(keyEventPair);
582 void ContactManager::OnRequestReceived(const EventContactManagerRemoveBatchPtr &event)
588 bool isEmpty = ContactQueueManagerSingleton::Instance().empty();
590 managerRemoveBatch(event);
592 ContactQueueManagerSingleton::Instance().push(ContactQueueManager::DELETEBATCH, this, event);
594 ContactQueueManagerSingleton::Instance().increaseQueueList();
595 event->switchToManualAnswer();
597 Catch (NotFoundException)
599 LoggerE("NotFoundException during deleting persons : " << _rethrown_exception.GetMessage());
600 event->setResult(false);
601 event->setExceptionCode(ExceptionCodes::NotFoundException);
603 Catch (PlatformException)
605 LoggerE("PlatformException during deleting persons : " << _rethrown_exception.GetMessage());
606 event->setResult(false);
607 event->setExceptionCode(ExceptionCodes::PlatformException);
609 Catch(InvalidArgumentException)
611 LoggerE("InvalidArgumentException during deleting persons : " << _rethrown_exception.GetMessage());
612 event->setResult(false);
613 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
617 LoggerE("Error during deleting persons : " << _rethrown_exception.GetMessage());
618 event->setResult(false);
619 event->setExceptionCode(ExceptionCodes::PlatformException);
623 void ContactManager::OnRequestReceived(const EventContactManagerFindPtr &event)
628 PersonSearchEnginePtr searchEngine(new PersonSearchEngine());
630 if(event->getFilterIsSet())
632 FilterPtr filter = event->getFilter();
634 FilterValidatorPtr validator = PersonFilterValidatorFactory::getPersonFilterValidator();
635 bool success = filter->validate(validator);
638 ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
640 searchEngine->setCondition(filter);
643 if (event->getSortModeIsSet())
644 searchEngine->setSortMode(event->getSortMode());
646 searchEngine->setSortMode();
648 event->setPersons(searchEngine->getResult());
649 event->setResult(true);
651 } Catch (NotFoundException) {
652 LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage());
653 event->setExceptionCode(ExceptionCodes::NotFoundException);
654 event->setResult(false);
656 } Catch (PlatformException) {
657 LoggerE("Error during finding person : " << _rethrown_exception.GetMessage());
658 event->setExceptionCode(ExceptionCodes::PlatformException);
659 event->setResult(false);
661 } Catch (InvalidArgumentException) {
662 LoggerE("Invalid Arguments : " << _rethrown_exception.GetMessage());
663 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
664 event->setResult(false);
666 } Catch (Exception) {
667 LoggerE("Error during finding person : " << _rethrown_exception.GetMessage());
668 event->setExceptionCode(ExceptionCodes::PlatformException);
669 event->setResult(false);
673 void ContactManager::OnRequestReceived(const EventContactManagerAddChangeListenerPtr &event)
678 if(!event->getEmitterIsSet())
679 ThrowMsg(InvalidArgumentException, "Invalid arguments.");
681 EventContactManagerChangeListenerEmitterPtr emitter = event->getEmitter();
683 ThrowMsg(InvalidArgumentException, "Invalid arguments.");
685 if(m_contactManagerEmitters.size() == 0)
687 LoggerD("Watch registered initially");
689 ContactsSvcChangeListenerManagerSingleton::Instance().registerPersonsChangeListener(this);
692 m_contactManagerEmitters.attach(emitter);
694 long id = ContactsSvcChangeListenerManagerSingleton::Instance().getWatchIdAndInc();
695 m_watchIdMap[id] = emitter->getId();
698 event->setResult(true);
700 } Catch (NotFoundException) {
701 LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage());
702 event->setExceptionCode(ExceptionCodes::NotFoundException);
703 event->setResult(false);
705 } Catch (PlatformException) {
706 LoggerE("Error during addListner person : " << _rethrown_exception.GetMessage());
707 event->setExceptionCode(ExceptionCodes::PlatformException);
708 event->setResult(false);
710 } Catch (InvalidArgumentException) {
711 LoggerE("Invalid Arguments : " << _rethrown_exception.GetMessage());
712 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
713 event->setResult(false);
715 } Catch (Exception) {
716 LoggerE("Error during addListner person : " << _rethrown_exception.GetMessage());
717 event->setExceptionCode(ExceptionCodes::PlatformException);
718 event->setResult(false);
722 void ContactManager::OnRequestReceived(const EventContactManagerRemoveChangeListenerPtr &event)
727 if(!event->getIdIsSet())
728 ThrowMsg(InvalidArgumentException, "Invalid arguments.");
730 long id = event->getId();
731 if(m_watchIdMap.find(id) == m_watchIdMap.end())
732 ThrowMsg(NotFoundException, "No watchId 1 ");
734 //DPL::Mutex::ScopedLock lock(&m_addressBookEmittersMutex);
735 bool success = m_contactManagerEmitters.detach(m_watchIdMap[id]);
737 ThrowMsg(NotFoundException, "No watchId 2 ");
739 m_watchIdMap.erase(id);
741 if(m_contactManagerEmitters.size() == 0)
743 LoggerD("No watcher is registered. unsubscribing from person service.");
745 ContactsSvcChangeListenerManagerSingleton::Instance().unregisterPersonsChangeListener(this);
748 event->setResult(true);
750 } Catch (NotFoundException) {
751 LoggerE("WatchId doesn't exist : " << _rethrown_exception.GetMessage());
752 event->setExceptionCode(ExceptionCodes::NotFoundException);
753 event->setResult(false);
755 } Catch (PlatformException) {
756 LoggerE("Error during removeListner person : " << _rethrown_exception.GetMessage());
757 event->setExceptionCode(ExceptionCodes::PlatformException);
758 event->setResult(false);
760 } Catch (InvalidArgumentException) {
761 LoggerE("Invalid Arguments : " << _rethrown_exception.GetMessage());
762 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
763 event->setResult(false);
765 } Catch (Exception) {
766 LoggerE("Error during removeListner person : " << _rethrown_exception.GetMessage());
767 event->setExceptionCode(ExceptionCodes::PlatformException);
768 event->setResult(false);
772 void ContactManager::onContactsSvcPersonsAdded(PersonArrayPtr &persons)
774 EventInfoContactManagerChangeAddedPtr personsAdded(new EventInfoContactManagerChangeAdded());
775 personsAdded->setPersons(persons);
776 EventInfoContactManagerChangePtr event = DPL::StaticPointerCast<EventInfoContactManagerChange>(personsAdded);
777 EventContactManagerChangeListenerPtr listener(new EventContactManagerChangeListener(event));
778 m_contactManagerEmitters.emit(listener);
781 void ContactManager::onContactsSvcPersonsUpdated(PersonArrayPtr &persons)
783 EventInfoContactManagerChangeUpdatedPtr personsUpdated(new EventInfoContactManagerChangeUpdated());
784 personsUpdated->setPersons(persons);
785 EventInfoContactManagerChangePtr event = DPL::StaticPointerCast<EventInfoContactManagerChange>(personsUpdated);
786 EventContactManagerChangeListenerPtr listener(new EventContactManagerChangeListener(event));
787 m_contactManagerEmitters.emit(listener);
790 void ContactManager::onContactsSvcPersonsRemoved(StringArrayPtr &personIds)
792 EventInfoContactManagerChangeRemovedPtr personsRemoved(new EventInfoContactManagerChangeRemoved());
793 personsRemoved->setPersonIds(personIds);
794 EventInfoContactManagerChangePtr event = DPL::StaticPointerCast<EventInfoContactManagerChange>(personsRemoved);
795 EventContactManagerChangeListenerPtr listener(new EventContactManagerChangeListener(event));
796 m_contactManagerEmitters.emit(listener);
799 void ContactManager::personsUpdateBatchResultCallback(int error, void *user_data)
803 if(user_data == NULL)
805 LoggerE("user_data is NULL");
809 KeySharePtrPair *keyPair = (KeySharePtrPair*)user_data;
811 long key = keyPair->key;
812 ContactManager *contactManager = keyPair->contactManager;
816 contactManager->personsUpdateBatchResultCallback(error, key);
819 void ContactManager::personsUpdateBatchResultCallback(int error, long key)
821 EventContactManagerUpdateBatchPtr event;
823 EventContactManagerUpdateBatchMap::iterator iter;
824 iter = m_updateBatchEventMap.find(key);
825 if(iter == m_updateBatchEventMap.end())
827 LoggerE("No event for key : " << key);
831 event = iter->second;
832 m_updateBatchEventMap.erase(iter);
834 if(error != CONTACTS_ERROR_NONE)
836 LoggerE("persons_db_result_cb gives error : " << error);
837 event->setResult(false);
838 event->setExceptionCode(ExceptionCodes::PlatformException);
839 EventRequestReceiver<EventContactManagerUpdateBatch>::ManualAnswer(event);
843 event->setResult(true);
844 event->setExceptionCode(ExceptionCodes::None);
845 EventRequestReceiver<EventContactManagerUpdateBatch>::ManualAnswer(event);
848 void ContactManager::personsRemoveBatchResultCallback(int error, void *user_data)
852 if(user_data == NULL)
854 LoggerE("user_data is NULL");
858 KeySharePtrPair *keyPair = (KeySharePtrPair*)user_data;
860 long key = keyPair->key;
861 ContactManager *contactManager = keyPair->contactManager;
865 contactManager->personsRemoveBatchResultCallback(error, key);
868 void ContactManager::personsRemoveBatchResultCallback(int error, long key)
870 EventContactManagerRemoveBatchPtr event;
872 EventContactManagerRemoveBatchMap::iterator iter;
873 iter = m_removeBatchEventMap.find(key);
874 if(iter == m_removeBatchEventMap.end())
876 LoggerE("No event for key : " << key);
880 event = iter->second;
881 m_removeBatchEventMap.erase(iter);
883 if(error != CONTACTS_ERROR_NONE)
885 LoggerE("persons_db_result_cb gives error : " << error);
886 event->setResult(false);
887 event->setExceptionCode(ExceptionCodes::PlatformException);
888 EventRequestReceiver<EventContactManagerRemoveBatch>::ManualAnswer(event);
892 event->setResult(true);
893 event->setExceptionCode(ExceptionCodes::None);
894 EventRequestReceiver<EventContactManagerRemoveBatch>::ManualAnswer(event);