tizen beta release
[framework/web/wrt-commons.git] / modules / ace / include / dpl / ace / WRT_INTERFACE.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 #ifndef _WRT_INERFACE_4_ACE_EXAMPLE_H_
17 #define _WRT_INERFACE_4_ACE_EXAMPLE_H_
18
19 #include <list>
20 #include <map>
21 #include <string>
22
23 #include <dpl/ace-dao-ro/wrt_db_types.h>
24
25 class Request;
26
27 enum WidgetExecutionPhase
28 {
29     WidgetExecutionPhase_Unknown           = 0,
30     WidgetExecutionPhase_WidgetInstall     = 1 << 0,
31     WidgetExecutionPhase_WidgetInstantiate = 1 << 1,
32     WidgetExecutionPhase_WebkitBind        = 1 << 2,
33     WidgetExecutionPhase_Invoke            = 1 << 3
34 };
35
36 struct RequestContext
37 {
38     const WidgetHandle Handle;
39     WidgetExecutionPhase Phase;
40
41     RequestContext(WidgetHandle handle,
42             WidgetExecutionPhase phase) :
43         Handle(handle),
44         Phase(phase)
45     {
46     }
47 };
48
49 // Pair of pointer to attribute name and pointer to list of value for
50 // this attribute name
51 typedef std::pair< const std::string* const, std::list<std::string>* >
52 ATTRIBUTE;
53
54 /*
55  * Each function should return 0 as success and positive value as error
56  *
57  * Possible return value:
58  * 0 - succes
59  * 1 - subjectId/resourceId name unknown
60  * 2 - unknown attribute name
61  * 4 - interface error
62  **/
63
64 /************** Web Runtime ********************/
65
66 class IWebRuntime
67 {
68   public:
69
70     /**
71      * gather and set attributes values for specified subjectId
72      * and attribute name
73      * @param subjectId is a name of subject (widget or internet site URI )
74      * @param attributes is a list of pairs(
75      *   first:   pointer to attribute name
76      *   second: list of values for attribute (std::string)   -
77      *   its a list of string (BONDI requirement), but usually there will
78      *   be only one string
79      * */
80     virtual int getAttributesValues(const Request &request,
81             std::list<ATTRIBUTE> *attributes) = 0;
82
83     /*return current sessionId */
84     virtual std::string getSessionId(const Request &request) = 0;
85
86     virtual ~IWebRuntime()
87     {
88     }
89 };
90
91 /************** Resource Information ********************/
92 class IResourceInformation
93 {
94   public:
95     /**
96      * gather and set attributes values for specified resourceId
97      * and attribute name
98      * @param resourceId is a name of subject (widget or internet site URI )
99      * @param attributes is a list of pairs(
100      *   first:   pointer to attribute name
101      *   second: list of values for attribute (std::string)  -
102      *   its a list of string (BONDI requirement), but usually there will
103      *   be only one string
104      * */
105     virtual int getAttributesValues(const Request &request,
106             std::list<ATTRIBUTE> *attributes) = 0;
107
108     virtual ~IResourceInformation()
109     {
110     }
111 };
112
113 /**************  Operation System  ********************/
114 class IOperationSystem
115 {
116   public:
117
118     /**
119      * gather and set attributes values for specified attribute name
120      * @param attributes is a list of pairs(
121      *   first:   pointer to attribute name
122      *   second: list of values for attribute (std::string)  -
123      *   its a list of string (BONDI requirement), but usually
124      *   there will be only one string
125      * */
126     virtual int getAttributesValues(const Request &request,
127             std::list<ATTRIBUTE> *attributes) = 0;
128
129     virtual ~IOperationSystem()
130     {
131     }
132 };
133
134 class IFunctionParam
135 {
136   public:
137     virtual int getAttributesValues(const Request &request,
138             std::list<ATTRIBUTE> *attributes) = 0;
139     virtual ~IFunctionParam()
140     {
141     }
142 };
143
144 #endif //_WRT_INERFACE_4_ACE_EXAMPLE_H_