summaryrefslogtreecommitdiff
path: root/mobile_src/Contact/ContactManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Contact/ContactManager.h')
-rw-r--r--mobile_src/Contact/ContactManager.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/mobile_src/Contact/ContactManager.h b/mobile_src/Contact/ContactManager.h
new file mode 100644
index 0000000..e3da4fe
--- /dev/null
+++ b/mobile_src/Contact/ContactManager.h
@@ -0,0 +1,134 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 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.
+//
+
+/**
+ * @file ContactManager.h
+ * @version 0.1
+ * @brief
+ */
+
+#ifndef _PLATFORM_CONTACT_CONTACT_MANAGER_H_
+#define _PLATFORM_CONTACT_CONTACT_MANAGER_H_
+
+#include <dpl/mutex.h>
+#include "IContactManager.h"
+#include "AddressBook.h"
+#include "ContactsSvcWrapper.h"
+#include "ContactsSvcChangeListenerManager.h"
+
+namespace DeviceAPI {
+namespace Contact {
+
+class ContactManager: public IContactManager, public IContactsSvcPersonsChangeListener
+{
+public:
+ ContactManager();
+ virtual ~ContactManager();
+
+ virtual void getAddressBook(const EventContactManagerGetAddressBookPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void getDefaultAddressBook(const EventContactManagerGetDefaultAddressBookPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void getUnifiedAddressBook(const EventContactManagerGetUnifiedAddressBookPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void get(const EventContactManagerGetPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void update(const EventContactManagerUpdatePtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void remove(const EventContactManagerRemovePtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void addChangeListener(const EventContactManagerAddChangeListenerPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ virtual void removeChangeListener(const EventContactManagerRemoveChangeListenerPtr &event)
+ {
+ OnRequestReceived(event);
+ }
+
+ void managerUpdateBatch(const EventContactManagerUpdateBatchPtr &event);
+ void managerRemoveBatch(const EventContactManagerRemoveBatchPtr &event);
+
+protected:
+ virtual void OnRequestReceived(const EventContactManagerGetAddressBookPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerGetAddressBooksPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerGetDefaultAddressBookPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerGetUnifiedAddressBookPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerGetPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerUpdatePtr &event);
+ virtual void OnRequestReceived(const EventContactManagerUpdateBatchPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerRemovePtr &event);
+ virtual void OnRequestReceived(const EventContactManagerRemoveBatchPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerFindPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerAddChangeListenerPtr &event);
+ virtual void OnRequestReceived(const EventContactManagerRemoveChangeListenerPtr &event);
+
+ virtual void onContactsSvcPersonsAdded(PersonArrayPtr &persons);
+ virtual void onContactsSvcPersonsUpdated(PersonArrayPtr &persons);
+ virtual void onContactsSvcPersonsRemoved(StringArrayPtr &personIds);
+
+private:
+ static void personsUpdateBatchResultCallback(int error, void *user_data);
+ void personsUpdateBatchResultCallback(int error, long key);
+
+ static void personsRemoveBatchResultCallback(int error, void *user_data);
+ void personsRemoveBatchResultCallback(int error, long key);
+
+ typedef WrtDeviceApis::Commons::Emitters<EventContactManagerChangeListenerEmitter> ContactManagerChangedEmitter;
+ ContactManagerChangedEmitter m_contactManagerEmitters;
+
+ typedef std::map<long, EventContactManagerChangeListenerEmitter::IdType> WatchIdMap;
+ WatchIdMap m_watchIdMap;
+
+ struct KeySharePtrPair
+ {
+ long key;
+ ContactManager *contactManager;
+ };
+
+ typedef std::map<long, EventContactManagerUpdateBatchPtr> EventContactManagerUpdateBatchMap;
+ EventContactManagerUpdateBatchMap m_updateBatchEventMap;
+
+ typedef std::map<long, EventContactManagerRemoveBatchPtr> EventContactManagerRemoveBatchMap;
+ EventContactManagerRemoveBatchMap m_removeBatchEventMap;
+
+ long m_eventMapAcc;
+};
+
+} // Contact
+} // DeviceAPI
+
+#endif // _PLATFORM_CONTACT_CONTACT_MANAGER_H_