Adapt the AIL filter used to new ones
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCCommand.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 //==========================================================================
11 /**
12  *  @file   CicoSCCommand.h
13  *
14  *  @brief  This file is definition of CicoSCCommand class
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_COMMAND_H__
18 #define __CICO_SC_COMMAND_H__
19
20 #include <string>
21 #include <boost/property_tree/ptree.hpp>
22
23 #include "CicoLog.h"
24
25 //==========================================================================
26 /**
27  *  @brief  command option variables
28  *          This class is abstract class
29  */
30 //==========================================================================
31 class CicoSCCommandOption
32 {
33 public:
34     /// default constructor
35     CicoSCCommandOption() {}
36
37     /// destructor
38     virtual ~CicoSCCommandOption() {}
39
40     /// dump log this class member variables
41     virtual void dump(void) {}
42 };
43
44 //==========================================================================
45 /**
46  *  @brief  This class holds the option of window control command
47  */
48 //==========================================================================
49 class CicoSCCmdWinCtrlOpt : public CicoSCCommandOption
50 {
51 public:
52     /// default constructor
53     CicoSCCmdWinCtrlOpt()
54         : nodeid(0), displayid(0), layerid(0),
55           zone(""), surfaceid(-1), animationType(0), animation(""), animationTime(0),
56           x(-1), y(-1), width(-1), height(-1), raise(-1),
57           visible(-1), active(-1), framerate(0), stride(-1), format(-1) {}
58
59     /// destructor
60     virtual ~CicoSCCmdWinCtrlOpt() {}
61
62     /// dump log this class member variables
63     void dump(void)
64     {
65         ICO_DBG("WinCtrlOpt: "
66                 "surfaceid=%08x layerid=%d nodeid=%d zone=%s "
67                 "animation=%s animaType=%x animaTime=%d "
68                 "x=%d y=%d w=%d h=%d raise=%d "
69                 "visible=%d active=%d framerate=%d stride=%d format=%d",
70                 surfaceid, layerid, nodeid, zone.c_str(),
71                 animation.c_str(), animationType, animationTime,
72                 x, y, width, height, raise,
73                 visible, active, framerate, stride, format);
74     }
75
76     int         nodeid;         //!< id of node
77     int         displayid;      //!< id of display
78     int         layerid;        //!< id of layer
79     std::string zone;           //!< name of display zone
80     int         surfaceid;      //!< id of surface
81     int         animationType;  //!< type of animation
82     std::string animation;      //!< name of animation
83     int         animationTime;  //!< time of animation
84     int         x;              //!< x position of window
85     int         y;              //!< y position of window
86     int         width;          //!< width of window
87     int         height;         //!< height of window
88     int         raise;          //!< status of raise(raise/lower)
89     int         visible;        //!< status of visible(visible/invisible)
90     int         active;         //!< status of active(active/nonactive):
91     int         framerate;      //!< frame rate for thumbnail
92     int         stride;         //!< stride for thumbnail
93     int         format;         //!< format of color for thumbnail
94 };
95
96 //==========================================================================
97 /**
98  *  @brief  This class holds the option of input device control command
99  */
100 //==========================================================================
101 class CicoSCCmdInputDevCtrlOpt : public CicoSCCommandOption
102 {
103 public:
104     /// default constructor
105     CicoSCCmdInputDevCtrlOpt()
106         : device(""), input(-1), surfaceid(-1), deviceno(-1),
107           fix(-1), keycode(-1), evtype(-1), evtime(0), evcode(-1),
108           evvalue(-1) {}
109
110     /// destructor
111     virtual ~CicoSCCmdInputDevCtrlOpt() {}
112
113     /// dump log this class member variables
114     void dump(void)
115     {
116         ICO_DBG("InputCtrlOpt: "
117                 "device=%s input=%d surfaceid=%08x deviceno=%d "
118                 "fix=%d keycode=%d evtype=%d evtime=%d evcode=%d evvalue=%d",
119                 device.c_str(), input, surfaceid, deviceno,
120                 fix, keycode, evtype, evtime, evcode, evvalue);
121     }
122
123     std::string device;     //!< name of input device
124     int         input;      //!< number of input
125     int         surfaceid;  //!< id of surface
126     int         deviceno;   //!< number of device
127     int         fix;        //!< status of fix
128     int         keycode;    //!< code of key
129     int         evtype;     //!< type of event
130     int         evtime;     //!< time of event
131     int         evcode;     //!< code of event
132     int         evvalue;    //!< value of event
133 };
134
135 //==========================================================================
136 /**
137  *  @brief  This class holds the option of user manager command
138  */
139 //==========================================================================
140 class CicoSCCmdUserMgrOpt : public CicoSCCommandOption
141 {
142 public:
143     /// default constructor
144     CicoSCCmdUserMgrOpt()
145         : user(""), pass(""), lastinfo("") {}
146
147     /// destructor
148     virtual ~CicoSCCmdUserMgrOpt() {}
149
150     /// dump log this class member variables
151     void dump(void)
152     {
153         ICO_DBG("UserMgrOpt: user=%s pass=%s lastinfo=%s",
154                 user.c_str(), pass.c_str(), lastinfo.c_str());
155     }
156
157     std::string user;
158     std::string pass;
159     std::string lastinfo;
160 };
161
162 //==========================================================================
163 /**
164  *  @brief  This class holds the option of resource control command
165  */
166 //==========================================================================
167 class CicoSCCmdResCtrlOpt : public CicoSCCommandOption
168 {
169 public:
170     /// default constructor
171     CicoSCCmdResCtrlOpt()
172         : dispres(false), dispzone(""), layerid(-1), winname(""), surfaceid(-1),
173           animation(""), animationTime(0),
174           ECU(""), display(""), layer(""), layout(""), area(""), dispatchApp(""),
175           role(""), resourceID(-1),
176           soundres(false), soundzone(""), soundname(""), adjust(0),
177           inputres(false), device(""), input(0), type(0) {}
178
179     /// destructor
180     virtual ~CicoSCCmdResCtrlOpt() {}
181
182     /// dump log this class member variables
183     void dump(void)
184     {
185         ICO_DBG("ResCtrlOpt: "
186                 "diapres=%s dispzone=%s layerid=%d winname=%s srufaceid=%08x "
187                 "animation=%s animatime=%d soundres=%s soundzone=%s"
188                 "soundname=%s soundid=%d adjust=%d inputres=%s "
189                 "device=%s input=%d type=%d",
190                 dispres ? "true" : "false",  dispzone.c_str(), layerid,
191                 winname.c_str(), surfaceid, animation.c_str(),
192                 animationTime, soundres ? "true" : "false",
193                 soundzone.c_str(), soundname.c_str(),
194                 soundid, adjust, inputres ? "true" : "false",
195                 device.c_str(), input, type);
196         ICO_DBG("ResCtrlOptEx: "
197                 "dispresEx=%s ECU=%s display=%s layer=%s layout=%s area=%s "
198                 "dispatchApp=%s role=%s resourceID=%d",
199                 dispresEx? "true": "false", ECU.c_str(), display.c_str(),
200                 layer.c_str(), layout.c_str(), area.c_str(), dispatchApp.c_str(),
201                 role.c_str(), resourceID);
202     }
203
204     bool        dispres;         //!< flag of display resource
205     std::string dispzone;        //!< name of display zone
206     int         layerid;         //!< id of window layer
207     std::string winname;         //!< name of window
208     int         surfaceid;       //!< id of surface
209     std::string animation;       //!< name of animation
210     int         animationTime;   //!< time of animation[ms]
211     bool        dispresEx;       //!< Expansion flag
212     std::string ECU;             //!< name to identify ECU
213     std::string display;         //!< name to identify Display in ECU
214     std::string layer;           //!< name to identify Layer in Display
215     std::string layout;          //!< name to identify Layout in Layer
216     std::string area;            //!< name to Output position in Layout
217     std::string dispatchApp;     //!< dispatch of application
218     std::string role;            //!< role of notice
219     int         resourceID;      //!< ID number of resource
220
221     bool        soundres;        //!< flag of sound resource
222     std::string soundzone;       //!< name of sound zone
223     std::string soundname;       //!< name of sound(stream)
224     int         soundid;         //!< id of sound(stream)
225     int         adjust;          //!< parameter of adjust
226
227     bool        inputres;        //!< flag of input resource
228     std::string device;          //!< name of input device
229     int         input;           //!< input
230
231     int         type;            //!<< type of request for display and sound
232 };
233
234 //==========================================================================
235 /**
236  *  @brief  This class holds the option of input device setting command
237  */
238 //==========================================================================
239 class CicoSCCmdInputDevSettingOpt: public CicoSCCommandOption
240 {
241 public:
242     /// default constructor
243     CicoSCCmdInputDevSettingOpt()
244         : winname(""), x(0), y(0), width(0), height(0), hotspot_x(0), hotspot_y(0),
245           cursor_x(0), cursor_y(0), cursor_width(0), cursor_height(0), attr(0) {}
246
247     /// destructor
248     virtual ~CicoSCCmdInputDevSettingOpt() {}
249
250     /// dump log this class member variables
251     void dump(void)
252     {
253         ICO_DBG("InputDevSettingOpt: winname=%s x=%d y=%d w=%d h=%d attr=%d",
254                 winname.c_str(), x, y, width, height, attr);
255     }
256
257     std::string winname;//!< window name of surface
258     short x;            //!< x position of input region
259     short y;            //!< y position of input region
260     short width;        //!< width of input region
261     short height;       //!< height of input region
262     short hotspot_x;    //!< hotspot of X relative coordinate
263     short hotspot_y;    //!< hotspot of Y relative coordinate
264     short cursor_x;     //!< cursor region X coordinate
265     short cursor_y;     //!< cursor region Y coordinate
266     short cursor_width; //!< cursor region width
267     short cursor_height;//!< cursor region height
268     int attr;           //!< attribute of input region
269 };
270
271 //==========================================================================
272 /**
273  *  @brief  This class holds command information
274  */
275 //==========================================================================
276 class CicoSCCommand
277 {
278 public:
279     // default constructor
280     CicoSCCommand();
281
282     // destructor
283     ~CicoSCCommand();
284
285     // parse from message of process communication
286     int parseMessage(const char *cmdMessage);
287
288     // dump log this class member variables
289     void dump(void);
290
291 private:
292     // get integer value
293     int getIntValue(const boost::property_tree::ptree & root,
294                     const char* key);
295
296     // get string value
297     std::string getStrValue(const boost::property_tree::ptree & root,
298                             const char* key);
299
300     // check exist object
301     bool isExistObject(const boost::property_tree::ptree & root,
302                        const char *key);
303
304     // parse window control options
305     void parseWinCtrlOpt(const boost::property_tree::ptree & root);
306
307     // parse input device control options
308     void parseInputDevCtrlOpt(const boost::property_tree::ptree & root);
309
310     // parse user control options
311     void parseUserMgrOpt(const boost::property_tree::ptree & root);
312
313     // parse resource control options
314     void parseResCtrlOpt(const boost::property_tree::ptree & root);
315
316     // parse input device setting options
317     void parseInputDevSettingOpt(const boost::property_tree::ptree & root);
318
319 public:
320     unsigned long       cmdid;  //!< id of command
321     std::string         appid;  //!< id of application
322     int                 pid;    //!< id of process
323     CicoSCCommandOption *opt;   //!< command option instance
324 };
325 #endif  // __CICO_SC_COMMAND_H__
326 // vim:set expandtab ts=4 sw=4: