2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file AddressBookController.h
19 * @author Kisub Song (kisubs.song@samsung.com)
24 #ifndef _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
25 #define _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
27 #include <dpl/log/log.h>
28 #include <dpl/shared_ptr.h>
29 #include <Commons/EventReceiver.h>
30 #include <Commons/EventListener.h>
31 #include <CommonsJavaScript/PrivateObject.h>
32 #include <CommonsJavaScript/JSPendingOperationPrivateObject.h>
33 #include <CommonsJavaScript/JSPendingOperation.h>
34 #include <API/Contact/IAddressBook.h>
40 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Contact::IAddressBookPtr,
41 WrtDeviceApis::CommonsJavaScript::NoOwnership> AddressBookPrivObject;
43 typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Contact::EventAddressBookAddBatch> EventAddressBookAddBatchEventAnswerReceiver;
44 typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Contact::EventAddressBookUpdateBatch> EventAddressBookUpdateBatchEventAnswerReceiver;
45 typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Contact::EventAddressBookRemoveBatch> EventAddressBookRemoveBatchEventAnswerReceiver;
46 typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Contact::EventAddressBookFind> EventAddressBookFindEventAnswerReceiver;
47 typedef WrtDeviceApis::Commons::EventListener<TizenApis::Api::Contact::EventAddressBookChangeListener> EventAddressBookChangeListenerListener;
49 class AddressBookController :
50 public EventAddressBookAddBatchEventAnswerReceiver,
51 public EventAddressBookUpdateBatchEventAnswerReceiver,
52 public EventAddressBookRemoveBatchEventAnswerReceiver,
53 public EventAddressBookFindEventAnswerReceiver,
54 public EventAddressBookChangeListenerListener,
55 public AddressBookPrivObject
58 AddressBookController(JSContextRef context,
59 TizenApis::Api::Contact::IAddressBookPtr addressBook);
60 virtual ~AddressBookController();
62 void OnAnswerReceived(const TizenApis::Api::Contact::EventAddressBookAddBatchPtr &event);
63 void OnAnswerReceived(const TizenApis::Api::Contact::EventAddressBookUpdateBatchPtr &event);
64 void OnAnswerReceived(const TizenApis::Api::Contact::EventAddressBookRemoveBatchPtr &event);
65 void OnAnswerReceived(const TizenApis::Api::Contact::EventAddressBookFindPtr &event);
66 void onAnswerReceived(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
69 typedef DPL::SharedPtr<AddressBookController> AddressBookControllerPtr;
71 // Pending operation objects
72 class AddressBookAddBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
75 AddressBookAddBatchPendingOperation(
76 DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
77 WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
80 virtual void handleCallingCallbacks();
83 class AddressBookUpdateBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
86 AddressBookUpdateBatchPendingOperation(
87 DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
88 WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
91 virtual void handleCallingCallbacks();
94 class AddressBookRemoveBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
97 AddressBookRemoveBatchPendingOperation(
98 DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
99 WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
102 virtual void handleCallingCallbacks();
105 class AddressBookFindPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
108 AddressBookFindPendingOperation(
109 DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
110 WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
113 virtual void handleCallingCallbacks();
117 class AddressBookAsyncAnswerHandler
120 static void addBatch(const TizenApis::Api::Contact::EventAddressBookAddBatchPtr &event);
121 static void updateBatch(const TizenApis::Api::Contact::EventAddressBookUpdateBatchPtr &event);
122 static void removeBatch(const TizenApis::Api::Contact::EventAddressBookRemoveBatchPtr &event);
123 static void find(const TizenApis::Api::Contact::EventAddressBookFindPtr &event);
124 static void changeListenerError(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
125 static void changeListenerContactAdded(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
126 static void changeListenerContactUpdated(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
127 static void changeListenerContactRemoved(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
128 static void changeListenerAddressBookReset(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
135 #endif // _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_