2 // Tizen Web Device API
3 // Copyright (c) 2013 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.
18 #include "ContactQueue.h"
19 #include <dpl/singleton_impl.h>
23 IMPLEMENT_SINGLETON(DeviceAPI::Contact::ContactQueueManager)
32 bool ContactQueueManager::empty()
34 LogDebug("count : " << count);
42 void ContactQueueManager::increaseQueueList()
45 LogDebug("count : " << count);
48 void ContactQueueManager::decreaseQueueList()
52 LogDebug("count : " << count);
55 void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookAddBatchPtr &event)
57 LogDebug("push type : " << type);
59 queueProperties properties;
60 properties.addressBook = addressBook;
61 properties.addEvent = event;
62 properties.managertype = TYPEADDRESSBOOK;
67 properties.operation = ADDBATCH;
70 properties.operation = UPATEBATCH;
73 properties.operation = DELETEBATCH;
80 LogDebug("mapIndex : " << mapIndex);
81 m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
84 void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookUpdateBatchPtr &event)
86 LogDebug("push type : " << type);
88 queueProperties properties;
89 properties.addressBook = addressBook;
90 properties.updateEvent = event;
91 properties.managertype = TYPEADDRESSBOOK;
96 properties.operation = ADDBATCH;
99 properties.operation = UPATEBATCH;
102 properties.operation = DELETEBATCH;
109 LogDebug("mapIndex : " << mapIndex);
110 m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
113 void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookRemoveBatchPtr &event)
115 LogDebug("push type : " << type);
117 queueProperties properties;
118 properties.addressBook = addressBook;
119 properties.removeEvent = event;
120 properties.managertype = TYPEADDRESSBOOK;
125 properties.operation = ADDBATCH;
128 properties.operation = UPATEBATCH;
131 properties.operation = DELETEBATCH;
138 LogDebug("mapIndex : " << mapIndex);
139 m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
142 void ContactQueueManager::push(operationType type, ContactManager *contactManager, const EventContactManagerUpdateBatchPtr &event)
144 LogDebug("push type : " << type);
146 queueProperties properties;
147 properties.contactManager = contactManager;
148 properties.personUpdateEvent = event;
149 properties.managertype = TYPECONTACTMANAGER;
154 properties.operation = UPATEBATCH;
157 properties.operation = DELETEBATCH;
164 LogDebug("mapIndex : " << mapIndex);
165 m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
168 void ContactQueueManager::push(operationType type, ContactManager *contactManager, const EventContactManagerRemoveBatchPtr &event)
170 LogDebug("push type : " << type);
172 queueProperties properties;
173 properties.contactManager = contactManager;
174 properties.personRemoveEvent = event;
175 properties.managertype = TYPECONTACTMANAGER;
180 properties.operation = UPATEBATCH;
183 properties.operation = DELETEBATCH;
190 LogDebug("mapIndex : " << mapIndex);
191 m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
194 void ContactQueueManager::pop()
197 LogDebug("currentIndex : " << currentIndex << " / mapIndex : " << mapIndex);
199 AddressBookQueueMap::iterator iter = m_addressBookQueueMap.find(currentIndex);
200 queueProperties properties = iter->second;
202 if(properties.managertype == TYPEADDRESSBOOK){
203 switch(properties.operation){
206 properties.addressBook->AddressBookAddBatch(properties.addEvent);
211 properties.addressBook->AddressBookUpdateBatch(properties.updateEvent);
216 properties.addressBook->AddressBookRemoveBatch(properties.removeEvent);
222 }else if(properties.managertype == TYPECONTACTMANAGER){
223 switch(properties.operation){
226 properties.contactManager->managerUpdateBatch(properties.personUpdateEvent);
231 properties.contactManager->managerRemoveBatch(properties.personRemoveEvent);
239 m_addressBookQueueMap.erase(iter);
240 if(currentIndex == mapIndex){