Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Contact / AddressBookController.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        AddressBookController.h
20  * @author      Kisub Song (kisubs.song@samsung.com)
21  * @version     0.1
22  * @brief
23  */
24
25 #ifndef _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
26 #define _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
27
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 <Security.h>
35 #include "IAddressBook.h"
36
37 namespace DeviceAPI {
38 namespace Contact {
39
40 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AddressBookPtr,
41                                                            WrtDeviceApis::CommonsJavaScript::NoOwnership> AddressBookPrivObject;
42
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;
48
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
57 {
58 public:
59         AddressBookController(JSContextRef context,
60                         AddressBookPtr addressBook);
61         virtual ~AddressBookController();
62 protected:
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);
68 };
69
70 typedef DPL::SharedPtr<AddressBookController> AddressBookControllerPtr;
71
72 //common part
73 class AddressBookAsyncAnswerHandler
74 {
75 public:
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);
84 };
85
86 } // Contact
87 } // DeviceAPI
88
89 #endif // _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_