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 AddressBookController.h
20 * @author Kisub Song (kisubs.song@samsung.com)
25 #ifndef _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
26 #define _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_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>
35 #include "IAddressBook.h"
40 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AddressBookPtr,
41 WrtDeviceApis::CommonsJavaScript::NoOwnership> AddressBookPrivObject;
43 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventAddressBookAddBatch> EventAddressBookAddBatchEventAnswerReceiver;
44 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventAddressBookUpdateBatch> EventAddressBookUpdateBatchEventAnswerReceiver;
45 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventAddressBookRemoveBatch> EventAddressBookRemoveBatchEventAnswerReceiver;
46 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventAddressBookFind> EventAddressBookFindEventAnswerReceiver;
47 typedef WrtDeviceApis::Commons::EventListener<EventAddressBookChangeListener> EventAddressBookChangeListenerListener;
49 class AddressBookController :
50 public EventAddressBookAddBatchEventAnswerReceiver,
51 public EventAddressBookUpdateBatchEventAnswerReceiver,
52 public EventAddressBookRemoveBatchEventAnswerReceiver,
53 public EventAddressBookFindEventAnswerReceiver,
54 public EventAddressBookChangeListenerListener,
55 public DeviceAPI::Common::SecurityAccessor,
56 public AddressBookPrivObject
59 AddressBookController(JSContextRef context,
60 AddressBookPtr addressBook);
61 virtual ~AddressBookController();
63 void OnAnswerReceived(const EventAddressBookAddBatchPtr &event);
64 void OnAnswerReceived(const EventAddressBookUpdateBatchPtr &event);
65 void OnAnswerReceived(const EventAddressBookRemoveBatchPtr &event);
66 void OnAnswerReceived(const EventAddressBookFindPtr &event);
67 void onAnswerReceived(const EventAddressBookChangeListenerPtr &event);
70 typedef DPL::SharedPtr<AddressBookController> AddressBookControllerPtr;
73 class AddressBookAsyncAnswerHandler
76 static void addBatch(const EventAddressBookAddBatchPtr &event);
77 static void updateBatch(const EventAddressBookUpdateBatchPtr &event);
78 static void removeBatch(const EventAddressBookRemoveBatchPtr &event);
79 static void find(const EventAddressBookFindPtr &event);
80 static void changeListenerError(const EventAddressBookChangeListenerPtr &event);
81 static void changeListenerContactAdded(const EventAddressBookChangeListenerPtr &event);
82 static void changeListenerContactUpdated(const EventAddressBookChangeListenerPtr &event);
83 static void changeListenerContactRemoved(const EventAddressBookChangeListenerPtr &event);
89 #endif // _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_