bug fix: TIVI-1997, TIVI-2161, An action is inaccurate when the menu of HomeScreen...
[profile/ivi/ico-uxf-homescreen.git] / lib / common / CicoConf.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   CicoConf.h
13  *
14  *  @brief  This file is definition of SystemConfigs
15  */
16 //==========================================================================
17 #ifndef __CICO_CONF_H__
18 #define __CICO_CONF_H__
19
20 #include <string>
21 #include <vector>
22 #include <map>
23 #include <sstream>
24
25 #include <ico_log.h>
26 #include "CicoCommonDef.h"
27    
28 //==========================================================================
29 /**
30  *  @brief  enumeration of node type
31  */
32 //==========================================================================
33 typedef enum _node_type {
34     ICO_NODETYPE_CENTER     = 0,    ///< Center display
35     ICO_NODETYPE_METER      = 1,    ///< Meter display
36     ICO_NODETYPE_REMOTE     = 2,    ///< Information device(mobile device)
37     ICO_NODETYPE_PASSENGER  = 3,    ///< Passenger display
38     ICO_NODETYPE_REAR       = 4,    ///< Rear-seat entertainment
39     ICO_NODETYPE_REARLEFT   = 5,    ///< Rear-seat entertainment(Left)
40     ICO_NODETYPE_REARRIGHT  = 6,    ///< Rear-seat entertainment(right)
41 } ico_nodetype_e;
42
43 //==========================================================================
44 /**
45  *  @brief  enumeration of display type
46  */
47 //==========================================================================
48 typedef enum _display_type {
49     ICO_DISPLAYTYPE_CENTER    = 0,  ///< Center display
50     ICO_DISPLAYTYPE_METER     = 1,  ///< Meter display
51     ICO_DISPLAYTYPE_REMOTE    = 2,  ///< Information device(mobile device)
52     ICO_DISPLAYTYPE_PASSENGER = 3,  ///< Passenger display
53     ICO_DISPLAYTYPE_REAR      = 4,  ///< Rear-seat display
54     ICO_DISPLAYTYPE_REARLEFT  = 5,  ///< Rear-seat display(left)
55     ICO_DISPLAYTYPE_REARRIGHT = 6,  ///< Rear-seat display(right)
56 } ico_display_type_e;
57
58 //==========================================================================
59 /**
60  *  @brief  enumeration of policy type
61  */
62 //==========================================================================
63 typedef enum _policy {
64     ICO_POLICY_ALWAYS         = 0,  ///< No control
65     ICO_POLICY_RUNNING        = 1,  ///< Running only
66     ICO_POLICY_PARKED         = 2,  ///< Parked only
67     ICO_POLICY_SHIFT_PARKING  = 3,  ///< Shift-position is park
68     ICO_POLICY_SHIFT_REVERSES = 4,  ///< Shift-position is reverses
69     ICO_POLICY_BLINKER_LEFT   = 5,  ///< Blinker is left
70     ICO_POLICY_BLINKER_RIGHT  = 6,  ///< Blinker is right
71 } ico_policy_e;
72
73 //==========================================================================
74 /**
75  *  @brief  enumeration of application privilege
76  */
77 //==========================================================================
78 typedef enum _privilege {
79     ICO_PRIVILEGE_ALMIGHTY       = 0,   ///< almighty privilege
80     ICO_PRIVILEGE_SYSTEM         = 1,   ///< system level
81     ICO_PRIVILEGE_SYSTEM_AUDIO   = 2,   ///< system level(audio only)
82     ICO_PRIVILEGE_SYSTEM_VISIBLE = 3,   ///< system level(visible only)
83     ICO_PRIVILEGE_MAKER          = 4,   ///< maker level
84     ICO_PRIVILEGE_CERTIFICATE    = 5,   ///< certificated
85     ICO_PRIVILEGE_NONE           = 6,   ///< no privilege
86 } ico_privilege_e;
87
88 #define ICO_SYC_CONFIG_APPATTR  "app_attr.conf" //TODO
89
90 //==========================================================================
91 /**
92  *  @brief  This class holds display information of system config
93  */
94 //==========================================================================
95 class CicoSCNodeConf
96 {
97 public:
98     /// default constructor
99     CicoSCNodeConf()
100         : id(-1), name(""), address(""), type(-1) {}
101
102     /// destructor
103     virtual ~CicoSCNodeConf() {}
104
105     /// dump log this class member variables
106     void dumpConf(void)
107     {
108         ICO_DBG("node: id=%d name=%s address=%s type=%d",
109                  id, name.c_str(), address.c_str(), type);
110     }
111
112 public:
113     int         id;      ///< node id
114     std::string name;    ///< node name
115     std::string address; ///< node ip address
116     int         type;    ///< node type
117 };
118
119 //==========================================================================
120 /**
121  *  @brief  This class holds layer information of system config
122  */
123 //==========================================================================
124 class CicoSCLayerConf
125 {
126 public:
127     /// default constructor
128     CicoSCLayerConf()
129         : id(-1), name(""), type(-1), menuoverlap(false) {}
130
131     /// destructor
132     virtual ~CicoSCLayerConf() {}
133
134     /// dump log this class member variables
135     void dumpConf(void)
136     {
137         ICO_DBG("  layer: id=%d name=%s type=%d menuoverlap=%s",
138                 id, name.c_str(), type, menuoverlap ? "true" : "false");
139     }
140
141 public:
142     int         id;          ///< layer id
143     std::string name;        ///< layer name
144     int         type;        ///< layer type
145     bool        menuoverlap; ///< menu overlap flag
146 };
147
148 //==========================================================================
149 /**
150  *  @brief  This class holds display zone information of system config
151  */
152 //==========================================================================
153 class CicoSCDisplayZoneConf
154 {
155 public:
156     /// default constructor
157     CicoSCDisplayZoneConf()
158         : id(-1), name(""), fullname(""), x(-1), y(-1), w(-1), h(-1),
159           aspectFixed(false), aspectAlignLeft(false),
160           aspectAlignRight(false), aspectAlignTop(false),
161           aspectAlignBottom(false) {}
162
163     /// destructor
164     virtual ~CicoSCDisplayZoneConf() {}
165
166     /// dump log this class member variables
167     void dumpConf(void)
168     {
169         ICO_DBG("  zone: id=%d name=%s fullname=%s x/y=%d/%d "
170                 "w/h=%d/%d aspect(fixed=%s l/r=%s/%s t/b=%s/%s",
171                 id, name.c_str(), fullname.c_str(), x, y, w, h,
172                 aspectFixed       ? "true" : "false",
173                 aspectAlignLeft   ? "true" : "false",
174                 aspectAlignRight  ? "true" : "false",
175                 aspectAlignTop    ? "true" : "false",
176                 aspectAlignBottom ? "true" : "false");
177     }
178
179 public:
180     int               id;         ///< display zone id
181     std::string       name;       ///< display zone name
182     std::string       fullname;   ///< display zone fullname
183     int               x;          ///< display zone x position
184     int               y;          ///< display zone y position
185     int               w;          ///< display zone width
186     int               h;          ///< display zone height
187
188     /// fixed asppect ratio flag
189     bool aspectFixed;
190     /// horizontal direction to aligned at the left
191     bool aspectAlignLeft;   
192     /// horizontal direction to aligned at the right
193     bool aspectAlignRight;
194     /// vertical direction is aligned at the top
195     bool aspectAlignTop;
196     /// vertical direction is aligned at the bottom
197     bool aspectAlignBottom;
198 };
199
200 //==========================================================================
201 /**
202  *  @brief  This class holds display information of system config
203  */
204 //==========================================================================
205 class CicoSCDisplayConf
206 {
207 public:
208     /// default constructor
209     CicoSCDisplayConf()
210         : id(-1), name(""), node(-1), no(-1),
211           type(-1), width(-1), height(-1), inch(-1) {}
212
213     /// destructor
214     virtual ~CicoSCDisplayConf() {}
215
216     /// dump log this class member variables
217     void dumpConf(void)
218     {
219         ICO_DBG("display: id=%d name=%s node=%d no=%d "
220                 "type=%d width=%d height=%d inch=%d",
221                 id, name.c_str(), node, no, type, width, height, inch);
222     }
223
224 public:
225     int         id;      ///< display id
226     std::string name;    ///< display name
227     int         node;    ///< display node id
228     int         no;      ///< display number
229     int         type;    ///< display type
230     int         width;   ///< display width resolution
231     int         height;  ///< display height resolution
232     int         inch;    ///< display inch size
233
234     // layer config list
235     std::vector<CicoSCLayerConf*> layerConfList;
236
237     // zone config list
238     std::vector<CicoSCDisplayZoneConf*> zoneConfList;
239 };
240
241 //==========================================================================
242 /**
243  *  @brief  This class holds sound zone information of system config
244  */
245 //==========================================================================
246 class CicoSCSoundZoneConf
247 {
248 public:
249     /// default constructor
250     CicoSCSoundZoneConf()
251         : id(-1), name(""), fullname("") {}
252
253     /// destructor
254     virtual ~CicoSCSoundZoneConf() {}
255
256     /// dump log this class member variables
257     void dumpConf(void)
258     {
259         ICO_DBG(" zone: id=%d name=%s fullname=%s",
260                 id, name.c_str(), fullname.c_str());
261     }
262
263 public:
264     int         id;         ///< sound zone id
265     std::string name;       ///< sound zone name
266     std::string fullname;   ///< sound zone full name
267 };
268
269 //==========================================================================
270 /**
271  *  @brief  This class holds sound information of system config
272  */
273 //==========================================================================
274 class CicoSCSoundConf
275 {
276 public:
277     /// default constructor
278     CicoSCSoundConf()
279         : id(-1), name(""), no(-1) {}
280
281     /// destructor
282     virtual ~CicoSCSoundConf() {}
283
284     /// dump log this class member variables
285     void dumpConf(void)
286     {
287         ICO_DBG("sound: id=%d name=%s no=%d", id, name.c_str(), no);
288     }
289
290 public:
291     int    id;          ///< sound id
292     std::string name;   ///< sound name
293     int    no;          ///< sound number
294     std::vector<CicoSCSoundZoneConf*>  zoneConfList; ///< sound config list
295 };
296
297 //==========================================================================
298 /**
299  *  @brief  This class holds category information of system config
300  */
301 //==========================================================================
302 class CicoSCCategoryConf
303 {
304 public:
305     /// default constructor
306     CicoSCCategoryConf()
307         : id(-1), name(""), type(""),
308           view(-1), sound(-1), input(-1), priority(0), rctrl(-1) {}
309
310     /// destructor
311     virtual ~CicoSCCategoryConf() {}
312
313     /// dump log this class member variables
314     void dumpConf(void)
315     {
316         ICO_DBG("category: id=%d name=%s type=%s "
317                  "view=%d sound=%d input=%d priority=%d",
318                  id, name.c_str(), type.c_str(),
319                  view, sound, input, priority);
320     }
321
322 public:
323     int         id;         ///< category id
324     std::string name;       ///< category name
325     std::string type;       ///< category type
326     int         view;       ///< category view
327     int         sound;      ///< category sound
328     int         input;      ///< category input
329     int         priority;   ///< category priority
330     int         rctrl;      ///< resource control information
331 };
332
333 //==========================================================================
334 /**
335  *  @brief  This class holds application kind information of system config
336  */
337 //==========================================================================
338 class CicoSCAppKindConf
339 {
340 public:
341     enum _privilege {
342         PRIVILEGE_ALMIGHTY       = 0, ///< almighty privilege
343         PRIVILEGE_SYSTEM         = 1, ///< system level
344         PRIVILEGE_SYSTEM_AUDIO   = 2, ///< system level(audio only)
345         PRIVILEGE_SYSTEM_VISIBLE = 3, ///< system level(visible only)
346         PRIVILEGE_MAKER          = 4, ///< maker level
347         PRIVILEGE_CERTIFICATE    = 5, ///< certificated
348         PRIVILEGE_NONE           = 6, ///< no privilege
349     };
350
351     /// default constructor
352     CicoSCAppKindConf()
353         : id(-1), name(""), privilege(-1), priority(0){}
354
355     /// destructor
356     virtual ~CicoSCAppKindConf() {}
357
358     /// dump log this class member variables
359     void dumpConf(void)
360     {
361         ICO_DBG("appkind: id=%d name=%s priority=%d priority=%d",
362                  id, name.c_str(), privilege, priority);
363     }
364
365 public:
366     int         id;         ///< application kind id
367     std::string name;       ///< application kind name
368     int         privilege;  ///< application privilege
369     int         priority;   ///< application priority
370 };
371
372 //==========================================================================
373 /**
374  *  @brief  This class holds input device switch information of system config
375  */
376 //==========================================================================
377 class CicoSCSwitchConf
378 {
379 public:
380     /// default constructor
381     CicoSCSwitchConf()
382         : id(-1), name(""), appid(""), keycode(0){}
383
384     /// destructor
385     virtual ~CicoSCSwitchConf() {}
386
387     /// dump log this class member variables
388     void dumpConf(void)
389     {
390         ICO_DBG("  switch: id=%d name=%s appid=%s",
391                  id, name.c_str(), appid.c_str());
392     }
393
394 public:
395     int         id;         ///< input device switch id
396     std::string name;       ///< input device switch name
397     std::string appid;      ///< fixed assign apllication name
398     int         keycode;    ///< keycode of input device switch
399 };
400
401 //==========================================================================
402 /**
403  *  @brief  This class holds input device information of system config
404  */
405 //==========================================================================
406 class CicoSCInputDevConf
407 {
408 public:
409     /// default constructor
410     CicoSCInputDevConf()
411         : id(-1), name("") {}
412
413     /// destructor
414     virtual ~CicoSCInputDevConf() {}
415
416     /// dump log this class member variables
417     void dumpConf(void)
418     {
419         ICO_DBG("inputdev: id=%d name=%s", id, name.c_str());
420     }
421
422 public:
423     int         id;     ///< input device id
424     std::string name;   ///< input device name
425     std::vector<CicoSCSwitchConf*> switchConfList;  ///< switch list
426 };
427
428 //==========================================================================
429 /**
430  *  @brief  This class holds default information of system config
431  */
432 //==========================================================================
433 class CicoSCDefaultConf
434 {
435 public:
436     /// default constructor
437     CicoSCDefaultConf()
438         : topdir(""), confdir(""),
439           node(-1), appkind(-1), category(-1), display(-1), 
440           layer(-1), displayzone(-1), sound(-1), soundzone(-1),
441           inputdev(-1), inputsw(-1) {};
442
443     /// destructor
444     virtual ~CicoSCDefaultConf() {}
445
446     /// dump log this class member variables
447     void dumpConf(void)
448     {
449         ICO_DBG("default: topdir=%s confdir=%s "
450                 "node=%d appkind=%d category=%d "
451                 "display=%d layer=%d displayzone=%d "
452                 "sound=%d soundzone=%d inputdev=%d inputsw=%d",
453                 topdir.c_str(), confdir.c_str(),
454                 node, appkind, category, display, layer, displayzone,
455                 sound, soundzone, inputdev, inputsw);
456     }
457
458 public:
459     std::string topdir;         ///< top directory path
460     std::string confdir;        ///< config directory path
461     int         node;           ///< default application node id
462     int         appkind;        ///< default application kind
463     int         category;       ///< default application category
464     int         display;        ///< default application display
465     int         layer;          ///< default application display layer
466     int         displayzone;    ///< default application display zone
467     int         sound;          ///< default application sound
468     int         soundzone;      ///< default application sound zone
469     int         inputdev;       ///< default input device
470     int         inputsw;        ///< default input device switch
471 };
472
473 //==========================================================================
474 /**
475  *  @brief  This class holds cpu resource group information of system config
476  */
477 //==========================================================================
478 class CicoSCCpuResourceGrp
479 {
480 public:
481     /// default constructor
482     CicoSCCpuResourceGrp()
483         :m_id(-1), m_bDoIt(false), m_grpNm("") {}
484
485     /// destructor
486     virtual ~CicoSCCpuResourceGrp() {}
487
488     /// dump log this class member variables
489     void dumpConf(void)
490     {
491         std::stringstream hightlist;
492         {
493             std::vector<int>::iterator itr = m_hight.begin();
494             for (; itr != m_hight.end(); ++itr) {
495                 hightlist << " " << *itr;
496             }
497
498         }
499
500         std::stringstream lowlist;
501         {
502             std::vector<int>::iterator itr = m_low.begin();
503             for (; itr != m_low.end(); ++itr) {
504                 lowlist << " " << *itr;
505             }
506
507         }
508
509         ICO_DBG("cpu reousrce group; id=%d doIt=%s grpNm=%s, high=%d, low=%d",
510                 m_id, m_bDoIt? "true": "false", m_grpNm.c_str(),
511                 hightlist.str().c_str(), lowlist.str().c_str());
512     };
513
514 public:
515     int              m_id;      ///< cpu resource group id
516     bool             m_bDoIt;   ///< cpu resouce control enable flag
517     std::string      m_grpNm;   ///< cpu resource group name
518     std::vector<int> m_hight;   ///< hight threshold list
519     std::vector<int> m_low;     ///< low threshold list
520 };
521
522 //==========================================================================
523 /**
524  *  @brief  This class holds system resource information of system config
525  */
526 //==========================================================================
527 class CicoSCResourceConf
528 {
529 public:
530     /// default constructor
531     CicoSCResourceConf()
532         :m_bDoIt(false), m_bDoItApp(false), m_bLog(false), m_cpuCGRPPath(""),
533         m_sampling(-1), m_retryCnt(5), m_lowLimitVal(25),
534         m_highLimitVal(90) {}
535
536     /// destructor
537     virtual ~CicoSCResourceConf() {}
538
539     /// dump log this class member variables
540     void dumpConf(void)
541     {
542         ICO_DBG("do:%s,%s log:%s, dir:%s, smpl:%d r:%d l:%d h:%d sz:%d",
543                 m_bDoIt? "true": "false", m_bDoItApp? "true": "false",
544                 m_bLog? "true": "false", m_cpuCGRPPath.c_str(), m_sampling,
545                 m_retryCnt, m_lowLimitVal, m_highLimitVal, m_cpuCtrl.size());
546     }
547
548 public:
549     bool        m_bDoIt;        ///< resource control enable flag
550     bool        m_bDoItApp;
551     bool        m_bLog;         ///< resource control log enable flag
552     std::string m_cpuCGRPPath;  ///< cpu cgroup path
553     int         m_sampling;     ///< sampling period
554     int         m_retryCnt;     ///< retry count
555     int         m_lowLimitVal;  ///< low limit value
556     int         m_highLimitVal; ///< high limit value
557     std::vector<CicoSCCpuResourceGrp*> m_cpuCtrl; ///< cpu control config list
558 };
559
560 //==========================================================================
561 /**
562  *  @brief  This class holds user information of system config
563  */
564 //==========================================================================
565 class CicoSCUserConf
566 {
567 public:
568     /// default constructor
569     CicoSCUserConf() :m_parent_dir("/home/app/ico") {}
570     /// destructor
571     virtual ~CicoSCUserConf() {}
572
573     /// dump log this class member variables
574     void dumpConf(void)
575     {
576         ICO_DBG("parent dir:%s", m_parent_dir.c_str());
577     }
578
579 public:
580     std::string m_parent_dir;  ///< parent dir
581 };
582
583 //==========================================================================
584 /**
585  *  @brief  This class holds vehicle information property of system config
586  */
587 //==========================================================================
588 class CicoSCVIPropertyConf
589 {
590 public:
591     /// default constructor
592     CicoSCVIPropertyConf()
593         : name(""), objname(""), property(""), typestr(""),
594           type(ICO_TYPE_UNKNOW) {}
595
596     /// destructor
597     virtual ~CicoSCVIPropertyConf() {}
598
599     /// dump log this class member variables
600     void dumpConf(void)
601     {
602         ICO_DBG("vehicle_info: id=%02d name=%s objname=%s property=%s "
603                 "zone=%d typestr=%s type=%d",
604                 id, name.c_str(), objname.c_str(), property.c_str(),
605                 zone, typestr.c_str(), type);
606     }
607
608     int typeStrToInt(const std::string & str)
609     {
610         int ret = ICO_TYPE_UNKNOW;
611         if (0 == typestr.compare("BOOLEAN")) {
612             ret = ICO_TYPE_BOOLEAN;
613         }
614         else if (0 == typestr.compare("INT8")) {
615             ret = ICO_TYPE_INT8;
616         }
617         else if ((0 == typestr.compare("UINT8")) ||
618                  (0 == typestr.compare("BYTE"))) {
619             ret = ICO_TYPE_UINT8;
620         }
621         else if (0 == typestr.compare("INT16")) {
622             ret = ICO_TYPE_INT16;
623         }
624         else if (0 == typestr.compare("UINT16")) {
625             ret = ICO_TYPE_UINT16;
626         }
627         else if (0 == typestr.compare("INT32")) {
628             ret = ICO_TYPE_INT32;
629         }
630         else if (0 == typestr.compare("UINT32")) {
631             ret = ICO_TYPE_UINT32;
632         }
633         else if (0 == typestr.compare("INT64")) {
634             ret = ICO_TYPE_INT64;
635         }
636         else if (0 == typestr.compare("UINT64")) {
637             ret = ICO_TYPE_UINT64;
638         }
639         else if (0 == typestr.compare("DOUBLE")) {
640             ret = ICO_TYPE_DOUBLE;
641         }
642         else if (0 == typestr.compare("STRING")) {
643             ret = ICO_TYPE_STRING;
644         }
645         else {
646             ret = ICO_TYPE_UNKNOW;
647         }
648         return ret;
649     }
650
651 public:
652     int id;
653     std::string name;
654     std::string objname;
655     std::string property;
656     int zone;
657     std::string typestr;
658     int type;
659 };
660
661 //==========================================================================
662 /**
663  *  @brief  This class holds vehicle information of system config
664  */
665 //==========================================================================
666 class CicoSCVehicleInfoConf
667 {
668 public:
669     /// default constructor
670     CicoSCVehicleInfoConf() : retryCnt(0), waitTime(0) {}
671
672     /// destructor
673     virtual ~CicoSCVehicleInfoConf() {}
674
675     /// dump log this class member variables
676     void dumpConf(void)
677     {
678         ICO_DBG("vehicle info: retry=%d waitTime=%d", retryCnt, waitTime);
679         std::map<int, CicoSCVIPropertyConf*>::iterator itr;
680         itr = properties.begin();
681         for(; itr != properties.end(); ++itr) {
682             itr->second->dumpConf();
683         }
684     }
685
686 public:
687     ///< retry count
688     int retryCnt;
689
690     ///< retry wait time[ms]
691     int waitTime;
692
693     ///< parent dir
694     std::map<int, CicoSCVIPropertyConf*> properties;
695 };
696
697 #endif  // __CICO_CONF_H__
698 // vim:set expandtab ts=4 sw=4: