summaryrefslogtreecommitdiff
path: root/mobile_src/Contact/JSContactRef.h
blob: 92b130a29b5c7dbdb042286fda9a36733321d3f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//
// 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        JSContactRef.h
 * @version     0.1
 * @brief       Declaration of the JSContactRef class
 */

#ifndef _TIZEN_CONTACT_JS_CONTACT_REF_H_
#define _TIZEN_CONTACT_JS_CONTACT_REF_H_

#include <JavaScriptCore/JavaScript.h>
#include <dpl/shared_ptr.h>
#include <CommonsJavaScript/PrivateObject.h>
#include <Commons/IEvent.h>
#include "ContactRef.h"

namespace DeviceAPI {
namespace Contact {

typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ContactRefPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSContactRefPriv;

class JSContactRef {
public:
	/*
	* This initializes this JS class in the JS Engine.
	*/
	static JSClassRef getClassRef();

	static bool isObjectOfClass(JSContextRef context, JSValueRef value);

	static ContactRefPtr getContactRef(JSContextRef context, JSValueRef value);

private:
   /**
	* The callback invoked when an object is first created.
	*/
	static void Initialize(JSContextRef context, JSObjectRef object);

   /**
	* The callback invoked when an object is finalized.
	*/
	static void Finalize(JSObjectRef object);

   /**
	* This structure contains properties and callbacks that define a type of object.
	*/
	static JSClassDefinition m_classInfo;

   /**
	* This structure describes a statically declared function property.
	*/
	static JSStaticFunction m_functions[];

	/**
	 * This member variable contains the initialization values for the static properties of this class.
	 * The values are given according to the data structure JSPropertySpec
	 */
	static JSStaticValue m_property[];

	static JSClassRef m_classRef;

	static JSObjectRef createJSObject(JSContextRef context, ContactRefPtr contactName);

	static ContactRefPtr getPrivData(JSObjectRef object);

	static JSObjectRef constructor(JSContextRef context,
			JSObjectRef constructor,
			size_t argumentCount,
			const JSValueRef arguments[],
			JSValueRef* exception);

	static bool hasInstance(JSContextRef context,
			JSObjectRef constructor,
			JSValueRef possibleInstance,
			JSValueRef* exception);

	static JSValueRef getAddressBookId(JSContextRef context,
			JSObjectRef object,
			JSStringRef propertyName,
			JSValueRef* exception);

	static bool setAddressBookId(JSContextRef context,
			JSObjectRef object,
			JSStringRef propertyName,
			JSValueRef value,
			JSValueRef* exception);

	static JSValueRef getContactId(JSContextRef context,
			JSObjectRef object,
			JSStringRef propertyName,
			JSValueRef* exception);

	static bool setContactId(JSContextRef context,
			JSObjectRef object,
			JSStringRef propertyName,
			JSValueRef value,
			JSValueRef* exception);

};

} // Contact
} // DeviceAPI

#endif // _TIZEN_CONTACT_JS_CONTACT_NAME_H_