summaryrefslogtreecommitdiff
path: root/mobile_src/Contact/ContactQueue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Contact/ContactQueue.cpp')
-rwxr-xr-xmobile_src/Contact/ContactQueue.cpp242
1 files changed, 242 insertions, 0 deletions
diff --git a/mobile_src/Contact/ContactQueue.cpp b/mobile_src/Contact/ContactQueue.cpp
new file mode 100755
index 0000000..04f00a9
--- /dev/null
+++ b/mobile_src/Contact/ContactQueue.cpp
@@ -0,0 +1,242 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "ContactQueue.h"
+#include <dpl/singleton_impl.h>
+#include <Logger.h>
+
+
+
+IMPLEMENT_SINGLETON(DeviceAPI::Contact::ContactQueueManager)
+
+int count = 0;
+int mapIndex = 0;
+int currentIndex = 0;
+
+namespace DeviceAPI {
+namespace Contact {
+
+bool ContactQueueManager::empty()
+{
+ if(count > 0)
+ return false;
+ else
+ return true;
+}
+
+void ContactQueueManager::increaseQueueList()
+{
+ count++;
+ LoggerD("count : " << count);
+}
+
+void ContactQueueManager::decreaseQueueList()
+{
+ if(count > 0)
+ count--;
+ LoggerD("count : " << count);
+}
+
+void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookAddBatchPtr &event)
+{
+ LoggerD("push type : " << type);
+
+ queueProperties properties;
+ properties.addressBook = addressBook;
+ properties.addEvent = event;
+ properties.managertype = TYPEADDRESSBOOK;
+
+ switch(type)
+ {
+ case ADDBATCH:
+ properties.operation = ADDBATCH;
+ break;
+ case UPATEBATCH:
+ properties.operation = UPATEBATCH;
+ break;
+ case DELETEBATCH:
+ properties.operation = DELETEBATCH;
+ break;
+ default:
+ return;
+ }
+
+ mapIndex++;
+ m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
+}
+
+void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookUpdateBatchPtr &event)
+{
+ LoggerD("push type : " << type);
+
+ queueProperties properties;
+ properties.addressBook = addressBook;
+ properties.updateEvent = event;
+ properties.managertype = TYPEADDRESSBOOK;
+
+ switch(type)
+ {
+ case ADDBATCH:
+ properties.operation = ADDBATCH;
+ break;
+ case UPATEBATCH:
+ properties.operation = UPATEBATCH;
+ break;
+ case DELETEBATCH:
+ properties.operation = DELETEBATCH;
+ break;
+ default:
+ return;
+ }
+
+ mapIndex++;
+ m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
+}
+
+void ContactQueueManager::push(operationType type, AddressBook *addressBook, const EventAddressBookRemoveBatchPtr &event)
+{
+ LoggerD("push type : " << type);
+
+ queueProperties properties;
+ properties.addressBook = addressBook;
+ properties.removeEvent = event;
+ properties.managertype = TYPEADDRESSBOOK;
+
+ switch(type)
+ {
+ case ADDBATCH:
+ properties.operation = ADDBATCH;
+ break;
+ case UPATEBATCH:
+ properties.operation = UPATEBATCH;
+ break;
+ case DELETEBATCH:
+ properties.operation = DELETEBATCH;
+ break;
+ default:
+ return;
+ }
+
+ mapIndex++;
+ m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
+}
+
+void ContactQueueManager::push(operationType type, ContactManager *contactManager, const EventContactManagerUpdateBatchPtr &event)
+{
+ LoggerD("push type : " << type);
+
+ queueProperties properties;
+ properties.contactManager = contactManager;
+ properties.personUpdateEvent = event;
+ properties.managertype = TYPECONTACTMANAGER;
+
+ switch(type)
+ {
+ case UPATEBATCH:
+ properties.operation = UPATEBATCH;
+ break;
+ case DELETEBATCH:
+ properties.operation = DELETEBATCH;
+ break;
+ default:
+ return;
+ }
+
+ mapIndex++;
+ m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
+}
+
+void ContactQueueManager::push(operationType type, ContactManager *contactManager, const EventContactManagerRemoveBatchPtr &event)
+{
+ LoggerD("push type : " << type);
+
+ queueProperties properties;
+ properties.contactManager = contactManager;
+ properties.personRemoveEvent = event;
+ properties.managertype = TYPECONTACTMANAGER;
+
+ switch(type)
+ {
+ case UPATEBATCH:
+ properties.operation = UPATEBATCH;
+ break;
+ case DELETEBATCH:
+ properties.operation = DELETEBATCH;
+ break;
+ default:
+ return;
+ }
+
+ mapIndex++;
+ m_addressBookQueueMap.insert(std::make_pair(mapIndex, properties));
+}
+
+void ContactQueueManager::pop()
+{
+ currentIndex++;
+ LoggerD("currentIndex : " << currentIndex << " / mapIndex : " << mapIndex);
+
+ AddressBookQueueMap::iterator iter = m_addressBookQueueMap.find(currentIndex);
+ queueProperties properties = iter->second;
+
+ if(properties.managertype == TYPEADDRESSBOOK){
+ switch(properties.operation){
+ case ADDBATCH:
+ {
+ properties.addressBook->AddressBookAddBatch(properties.addEvent);
+ }
+ break;
+ case UPATEBATCH:
+ {
+ properties.addressBook->AddressBookUpdateBatch(properties.updateEvent);
+ }
+ break;
+ case DELETEBATCH:
+ {
+ properties.addressBook->AddressBookRemoveBatch(properties.removeEvent);
+ }
+ break;
+ default:
+ break;
+ }
+ }else if(properties.managertype == TYPECONTACTMANAGER){
+ switch(properties.operation){
+ case UPATEBATCH:
+ {
+ properties.contactManager->managerUpdateBatch(properties.personUpdateEvent);
+ }
+ break;
+ case DELETEBATCH:
+ {
+ properties.contactManager->managerRemoveBatch(properties.personRemoveEvent);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ m_addressBookQueueMap.erase(iter);
+ if(currentIndex == mapIndex){
+ currentIndex = 0;
+ mapIndex = 0;
+ }
+}
+
+} // Contact
+} // DeviceAPI
+