Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Contact / JSAddressBookChangeCallbackManager.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file        JSAddressBookChangeCallbackManager.h
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief
22  */
23
24 #ifndef _TIZEN_CONTACT_JS_ADDRESS_BOOK_CHANGE_CALLBACK_MANAGER_H_
25 #define _TIZEN_CONTACT_JS_ADDRESS_BOOK_CHANGE_CALLBACK_MANAGER_H_
26
27 #include <dpl/shared_ptr.h>
28 #include <Commons/IEvent.h>
29 #include <JavaScriptCore/JavaScript.h>
30
31 namespace TizenApis {
32 namespace Tizen1_0 {
33 namespace Contact {
34
35 class JSAddressBookChangeCallbackManager;
36 typedef DPL::SharedPtr<JSAddressBookChangeCallbackManager> JSAddressBookChangeCallbackManagerPtr;
37
38 class JSAddressBookChangeCallbackManager : public WrtDeviceApis::Commons::IEventPrivateData
39 {
40 private:
41         JSAddressBookChangeCallbackManager() {}
42         JSAddressBookChangeCallbackManager( JSContextRef context,
43                         JSObjectRef onContactsAdded = NULL,
44                         JSObjectRef onContactsUpdated = NULL,
45                         JSObjectRef onContactsDeleted = NULL,
46                         JSObjectRef onAddressBookReset = NULL,
47                         JSObjectRef onError = NULL );
48
49 public:
50         static JSAddressBookChangeCallbackManagerPtr createObject(JSContextRef context);
51
52         virtual ~JSAddressBookChangeCallbackManager();
53
54         void    setContext( JSContextRef context );
55         JSContextRef getContext() const { return m_context; }
56
57         void    setOnContactsAdded( JSValueRef onContactsAdded );
58         JSValueRef getOnContactsAdded() const;
59         void    setOnContactsUpdated( JSValueRef onContactsUpdated );
60         JSValueRef getOnContactsUpdated() const;
61         void    setOnContactsDeleted( JSValueRef onContactsDeleted );
62         JSValueRef getOnContactsDeleted() const;
63         void    setOnAddressBookReset( JSValueRef onAddressBookReset );
64         JSValueRef getOnAddressBookReset() const;
65         void    setOnError( JSValueRef onError );
66         JSValueRef getOnError() const;
67         void    setObject( JSObjectRef object );
68         JSObjectRef getObject() const;
69
70         void    callOnContactsAdded( JSValueRef contacts );
71         void    callOnContactsUpdated( JSValueRef contacts );
72         void    callOnContactsDeleted( JSValueRef contactIds );
73         void    callOnAddressBookReset( );
74         void    callOnError( JSValueRef error );
75
76 private:
77         void    makeCallback(JSContextRef context,
78                         JSObjectRef object,
79                         JSObjectRef callback,
80                         const char *szName,
81                         JSValueRef argv[],
82                         unsigned argc);
83
84         JSObjectRef  m_onContactsAdded;
85         JSObjectRef  m_onContactsUpdated;
86         JSObjectRef  m_onContactsDeleted;
87         JSObjectRef  m_onAddressBookReset;
88         JSObjectRef  m_onError;
89         JSContextRef m_context;
90         JSObjectRef  m_object;
91 };
92
93 } // Contact
94 } // Tizen1_0
95 } // TizenApis
96
97 #endif // _TIZEN_CONTACT_JS_ADDRESS_BOOK_CHANGE_CALLBACK_MANAGER_H_