Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Account / JSAccount.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 /*
19  * @file        JSAttendee.h
20  *
21  * @version     0.1
22  */
23
24 #ifndef _JS_ACCOUNT_H_
25 #define _JS_ACCOUNT_H_
26
27 #include <string>
28 #include <vector>
29 #include <JavaScriptCore/JavaScript.h>
30 #include <CommonsJavaScript/PrivateObject.h>
31 #include <API/Account/EventAccount.h>
32 #include <API/Account/log.h>
33
34 using namespace TizenApis::Api::Account;
35 using namespace WrtDeviceApis::Commons;
36 using namespace WrtDeviceApis::CommonsJavaScript;
37
38 namespace TizenApis {
39 namespace Tizen1_0 {
40 namespace Account{
41
42 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<EventAccountPtr>::Type AccountPrivateObject;
43
44 class JSAccount
45 {
46   public:
47
48     static const JSClassDefinition* getClassInfo();
49
50     static JSClassRef getClassRef();
51
52    //TODO: check if createJSAccount is necessary.
53     static JSObjectRef createJSAccount(JSContextRef context, EventAccountPtr event);
54
55
56     static EventAccountPtr getIEvent(JSObjectRef object);
57
58     static void setIEvent(const EventAccountPtr &account,
59             JSContextRef ctx,
60             const JSObjectRef object);
61
62     static bool validate(JSContextRef ctx,
63             const JSObjectRef object,
64             JSValueRef* exception);
65
66   private:
67
68     /**
69      * The callback invoked when an object is first created.
70      */
71     static void initialize(JSContextRef context, JSObjectRef object);
72
73     /**
74      * The callback invoked when an object is finalized.
75      */
76     static void finalize(JSObjectRef object);
77
78     static JSValueRef getProperty(JSContextRef context,
79             JSObjectRef object,
80             JSStringRef propertyName,
81             JSValueRef* exception);
82
83     static bool setProperty(JSContextRef context,
84             JSObjectRef object,
85             JSStringRef propertyName,
86             JSValueRef value,
87             JSValueRef* exception);
88
89         static JSValueRef getServices(JSContextRef context,
90         JSObjectRef object,
91         JSStringRef propertyName,
92         JSValueRef* exception);
93
94         static bool setServices(JSContextRef context,
95         JSObjectRef object,
96         JSStringRef propertyName,
97         JSValueRef value,
98         JSValueRef* exception);
99
100         static JSObjectRef constructor(JSContextRef context,
101                         JSObjectRef object,
102                         size_t argumentCount,
103                         const JSValueRef arguments[],
104                         JSValueRef* exception);
105
106         /**
107                  * The callback invoked when an object is used as the target of an 'instanceof' expression.
108                  */
109                 static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
110
111
112     static JSClassRef m_jsClassRef;
113
114     /**
115      * This structure contains properties and callbacks that define a type of object.
116      */
117     static JSClassDefinition m_classInfo;
118
119     /**
120      * This member variable contains the initialization values for the static properties of this class.
121      * The values are given according to the data structure JSPropertySpec
122      */
123     static JSStaticValue m_property[];
124 };
125 }
126 }
127 }
128
129 #endif /* _JS_ATTENDEE_H_ */