bug fix: TC-1152
[profile/ivi/ico-uxf-homescreen.git] / lib / common / CicoSystemConfig.cpp
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   CicoSystemConfig.cpp
13  *
14  *  @brief  This file implementation of CicoSystemConfig class
15  */
16 /*========================================================================*/
17
18 #include <ico_log.h>
19 #include <boost/property_tree/ptree.hpp>
20 #include <boost/property_tree/json_parser.hpp>
21 #include <boost/foreach.hpp>
22 #include <boost/optional.hpp>
23 #include <tzplatform_config.h>
24
25 #include "ico_syc_private.h"
26 #include "CicoSystemConfig.h"
27 #include "CicoConf.h"
28 #include "CicoGKeyFileConfig.h"
29
30 using namespace boost::property_tree;
31 //==========================================================================
32 //  private static variable
33 //==========================================================================
34 CicoSystemConfig* CicoSystemConfig::ms_myInstance = NULL;
35
36 //--------------------------------------------------------------------------
37 /**
38  *  @brief  default constructor
39  */
40 //--------------------------------------------------------------------------
41 CicoSystemConfig::CicoSystemConfig()
42 {
43     m_typeTable[""]          = ICO_NODETYPE_CENTER;
44     m_typeTable["center"]    = ICO_NODETYPE_CENTER;
45     m_typeTable["meter"]     = ICO_NODETYPE_METER;
46     m_typeTable["remote"]    = ICO_NODETYPE_REMOTE;
47     m_typeTable["passenger"] = ICO_NODETYPE_PASSENGER;
48     m_typeTable["rear"]      = ICO_NODETYPE_REAR;
49     m_typeTable["rearleft"]  = ICO_NODETYPE_REARLEFT;
50     m_typeTable["rearright"] = ICO_NODETYPE_REARRIGHT;
51
52     m_displayTypeTable[""]          = ICO_DISPLAYTYPE_CENTER;
53     m_displayTypeTable["center"]    = ICO_DISPLAYTYPE_CENTER;
54     m_displayTypeTable["meter"]     = ICO_DISPLAYTYPE_METER;
55     m_displayTypeTable["remote"]    = ICO_DISPLAYTYPE_REMOTE;
56     m_displayTypeTable["passenger"] = ICO_DISPLAYTYPE_PASSENGER;
57     m_displayTypeTable["rear"]      = ICO_DISPLAYTYPE_REAR;
58     m_displayTypeTable["rearleft"]  = ICO_DISPLAYTYPE_REARLEFT;
59     m_displayTypeTable["rearright"] = ICO_DISPLAYTYPE_REARRIGHT;
60
61     //
62     m_categoryTalbe[""]              = ICO_POLICY_ALWAYS;
63     m_categoryTalbe["always"]        = ICO_POLICY_ALWAYS;
64     m_categoryTalbe["run"]           = ICO_POLICY_RUNNING;
65     m_categoryTalbe["park"]          = ICO_POLICY_PARKED;
66     m_categoryTalbe["shift_park"]    = ICO_POLICY_SHIFT_PARKING;
67     m_categoryTalbe["shift_back"]    = ICO_POLICY_SHIFT_REVERSES;
68     m_categoryTalbe["shift_rev"]     = ICO_POLICY_SHIFT_REVERSES;
69     m_categoryTalbe["blinker_left"]  = ICO_POLICY_BLINKER_LEFT;
70     m_categoryTalbe["blinker_right"] = ICO_POLICY_BLINKER_RIGHT;
71
72     //
73     m_privilegeTable["almighty"]       = ICO_PRIVILEGE_ALMIGHTY;
74     m_privilegeTable["system"]         = ICO_PRIVILEGE_SYSTEM;
75     m_privilegeTable["system.audio"]   = ICO_PRIVILEGE_SYSTEM_AUDIO;
76     m_privilegeTable["system.visible"] = ICO_PRIVILEGE_SYSTEM_VISIBLE;
77     m_privilegeTable["maker"]          = ICO_PRIVILEGE_MAKER;
78     m_privilegeTable["certificate"]    = ICO_PRIVILEGE_CERTIFICATE;
79     m_privilegeTable["none"]           = ICO_PRIVILEGE_NONE;
80     m_privilegeTable[""]               = ICO_PRIVILEGE_NONE;
81     m_resourceConf = NULL;
82     m_userConf = NULL;
83 }
84
85 //--------------------------------------------------------------------------
86 /**
87  *  @brief  destructor
88  */
89 //--------------------------------------------------------------------------
90 CicoSystemConfig::~CicoSystemConfig()
91 {
92     // TODO
93 }
94
95 //--------------------------------------------------------------------------
96 /**
97  *  @brief  Get instance of CicoSystemConfig
98  *
99  *  @return  pointer of CicoSystemConfig object
100  */
101 //--------------------------------------------------------------------------
102 CicoSystemConfig*
103 CicoSystemConfig::getInstance(void)
104 {
105     if (NULL == ms_myInstance) {
106         ms_myInstance = new CicoSystemConfig();
107     }
108     return ms_myInstance;
109 }
110
111 //--------------------------------------------------------------------------
112 /**
113  *  @brief  Get instance of CicoSystemConfig
114  *
115  *  @param  [in]    confFile    config file name
116  *  @return true on success, false on error
117  */
118 //--------------------------------------------------------------------------
119 bool
120 CicoSystemConfig::load(const string & confFile)
121 {
122     try {
123         ptree root;
124         read_xml(confFile, root);
125
126         createNodeConfList(root);
127         createDisplayConfList(root);
128         createSoundConfList(root);
129         createPortConf(root);
130         createCategoryConf(root);
131         createAppKindConf(root);
132         createInputDevList(root);
133         createDefaultConf(root);
134         createResourceConf(root);
135         createUserConf(root);
136         createVehicleInfoConf(root);
137         createRoleConf(root);
138         createPositionOSConf(root);
139     }
140     catch (...) {
141         ICO_ERR("catch exception!");
142         return false;
143     }
144     return true;
145 }
146
147 //--------------------------------------------------------------------------
148 /**
149  *  @brief
150  *
151  *  @param  [in]
152  */
153 //--------------------------------------------------------------------------
154 const vector<CicoSCNodeConf*>&
155 CicoSystemConfig::getNodeConfList(void) const
156 {
157     return m_nodeConfList;
158 }
159
160 //--------------------------------------------------------------------------
161 /**
162  *  @brief
163  *
164  *  @param  [in]
165  */
166 //--------------------------------------------------------------------------
167 const vector<CicoSCDisplayConf*>&
168 CicoSystemConfig::getDisplayConfList(void) const
169 {
170     return m_displayConfList;
171 }
172
173 //--------------------------------------------------------------------------
174 /**
175  *  @brief
176  *
177  *  @param  [in]
178  */
179 //--------------------------------------------------------------------------
180 const vector<CicoSCSoundConf*>&
181 CicoSystemConfig::getSoundConfList(void) const
182 {
183     return m_soundConfList;
184 }
185
186 //--------------------------------------------------------------------------
187 /**
188  *  @brief
189  *
190  *  @param  [in]
191  */
192 //--------------------------------------------------------------------------
193 const vector<CicoSCInputDevConf*> &
194 CicoSystemConfig::getInputDevConfList(void) const
195 {
196     return m_inputDevConfList;
197 }
198
199 //--------------------------------------------------------------------------
200 /**
201  *  @brief
202  *
203  *  @param  [in]
204  */
205 //--------------------------------------------------------------------------
206 const vector<CicoSCCategoryConf*> &
207 CicoSystemConfig::getCategoryConfList(void) const
208 {
209     return m_categoryConfList;
210 }
211
212 //--------------------------------------------------------------------------
213 /**
214  *  @brief
215  *
216  *  @param  [in]
217  */
218 //--------------------------------------------------------------------------
219 const vector<CicoSCAppKindConf*> &
220 CicoSystemConfig::getAppKindConfList(void) const
221 {
222     return m_appKindConfList;
223 }
224
225 //--------------------------------------------------------------------------
226 /**
227  *  @brief
228  *
229  *  @param  [in]
230  */
231 //--------------------------------------------------------------------------
232 void
233 CicoSystemConfig::createNodeConfList(const ptree & root)
234 {
235     //<nodes>
236 //    if (root.not_found() == root.find("systemconfig")) {
237 //        ICO_ERR("nodes element not found");
238 //        return;
239 //    }
240     ptree nodes = root.get_child("systemconfig.nodes");
241
242     BOOST_FOREACH (const ptree::value_type& child, nodes) {
243         if (0 != strcmp(child.first.data(),"node")) {
244             ICO_ERR("unknown element(%s)", child.first.data());
245         }
246         optional<int> id = optional<int>(-1);
247         optional<string> name;
248         optional<string> type;
249         optional<string> address;
250
251         id = child.second.get_optional<int>("<xmlattr>.id");
252         if (false == id.is_initialized()) {
253             ICO_ERR("node.id attr not found");
254             continue;
255         }
256         name = child.second.get_optional<string>("<xmlattr>.name");
257         if (false == name.is_initialized()) {
258             ICO_ERR("node.name attr not found");
259             continue;
260         }
261         type = child.second.get_optional<string>("type");
262         if (false == type.is_initialized()) {
263             ICO_ERR("node.type element not found");
264             continue;
265         }
266         address = child.second.get_optional<string>("ipaddress");
267         if (false == address.is_initialized()) {
268             ICO_ERR("node.address element not found");
269             continue;
270         }
271
272         CicoSCNodeConf* nodeConf = new CicoSCNodeConf;
273         nodeConf->id      = id.get();
274         nodeConf->name    = name.get();
275         nodeConf->type    = m_typeTable[type.get()];
276         nodeConf->address = address.get();
277         m_nodeConfList.push_back(nodeConf);
278
279         nodeConf->dumpConf();
280     }
281 }
282
283 //--------------------------------------------------------------------------
284 /**
285  *  @brief
286  *
287  *  @param  [in]
288  */
289 //--------------------------------------------------------------------------
290 void
291 CicoSystemConfig::createDisplayConfList(const ptree & root)
292 {
293     //<displays>
294 //    if (root.not_found() != root.find("systemconfi.displays")) {
295 //        ICO_ERR("displays element not found");
296 //        return;
297 //    }
298
299     numDisplay = 0;
300     ptree displays = root.get_child("systemconfig.displays");
301     BOOST_FOREACH (const ptree::value_type& child, displays) {
302         optional<int> id = optional<int>(-1);
303         optional<string> name;
304         optional<string> node;
305         optional<int> no = optional<int>(-1);
306         optional<string> type;
307         optional<int> width = optional<int>(-1);
308         optional<int> height = optional<int>(-1);
309
310         id = child.second.get_optional<int>("<xmlattr>.id");
311         if (false == id.is_initialized()) {
312             ICO_ERR("display.id attr not found");
313             continue;
314         }
315         name = child.second.get_optional<string>("<xmlattr>.name");
316         if (false == name.is_initialized()) {
317             ICO_ERR("display.name attr not found");
318             continue;
319         }
320         node = child.second.get_optional<string>("node");
321         if (false == node.is_initialized()) {
322             ICO_ERR("display.node attr not found");
323             continue;
324         }
325         no = child.second.get_optional<int>("no");
326         if (false == no.is_initialized()) {
327             ICO_ERR("display.no element not found");
328             continue;
329         }
330         type = child.second.get_optional<string>("type");
331         if (false == type.is_initialized()) {
332             ICO_ERR("display.type element not found");
333             continue;
334         }
335         width = child.second.get_optional<int>("width");
336         if (false == width.is_initialized()) {
337             ICO_ERR("display.width element not found");
338             continue;
339         }
340         height = child.second.get_optional<int>("height");
341         if (false == height.is_initialized()) {
342             ICO_ERR("display.height element not found");
343             continue;
344         }
345
346         CicoSCDisplayConf* displayConf = new CicoSCDisplayConf();
347         displayConf->id     = id.get();
348         displayConf->name   = name.get();
349         displayConf->node   = getNodeIdbyName(node.get());
350         displayConf->no     = no.get();
351         displayConf->type   = m_displayTypeTable[type.get()];
352         displayConf->width  = width.get();
353         displayConf->height = height.get();
354
355         displayConf->dumpConf();
356
357         createLayerConf(child, displayConf);
358         createDisplayZoneConf(child, displayConf);
359
360         m_displayConfList.push_back(displayConf);
361         numDisplay ++;
362     }
363 }
364
365 //--------------------------------------------------------------------------
366 /**
367  *  @brief
368  *
369  *  @param  [in]
370  */
371 //--------------------------------------------------------------------------
372 void
373 CicoSystemConfig::createLayoutConfContainedArea(
374     const ptree::value_type& layout,
375     const optional<int>& layer_id, const optional<string>& layer_name,
376     const optional<int>& layout_id, const optional<string>& layout_name,
377     CicoSCDisplayConf* displayConf)
378 {
379     ptree areas = layout.second.get_child("areas");
380     BOOST_FOREACH (const ptree::value_type& area, areas) {
381         optional<int> id = optional<int>(-1);
382         optional<string> name;
383         optional<int> type = optional<int>(-1);
384         optional<bool> overlap = optional<bool>(false);
385
386         id = area.second.get_optional<int>("<xmlattr>.id");
387         if (false == id.is_initialized()) {
388             ICO_ERR("disply.layer.layout.area.id attr not found");
389             continue;
390         }
391         name = area.second.get_optional<string>("<xmlattr>.name");
392         if (false == name.is_initialized()) {
393             ICO_ERR("disply.layer.layout.area.name attr not found");
394             continue;
395         }
396         type = area.second.get_optional<int>("type");
397         if (false == type.is_initialized()) {
398             ICO_ERR("disply.layer.layout.area.type element not found");
399             continue;
400         }
401         overlap = area.second.get_optional<bool>("menuoverlap");
402         if (false == overlap.is_initialized()) {
403             ICO_ERR("disply.layer.layout.area.overlap element not found");
404             continue;
405         }
406
407         CicoSCLayerConf* layerConf = new CicoSCLayerConf();
408         layerConf->id          = layer_id.get();
409         layerConf->name        = layer_name.get();
410         layerConf->type        = type.get();
411         layerConf->menuoverlap = overlap.get();
412         layerConf->layout_id   = layout_id.get();
413         layerConf->layout_name = layout_name.get();
414         layerConf->area_id     = id.get();
415         layerConf->area_name   = name.get();
416
417         displayConf->layerConfList.push_back(layerConf);
418
419         layerConf->dumpConf();
420     }
421 }
422
423 //--------------------------------------------------------------------------
424 /**
425  *  @brief
426  *
427  *  @param  [in]
428  */
429 //--------------------------------------------------------------------------
430 void
431 CicoSystemConfig::createLayerConfContainedLayout(
432     const ptree::value_type& layer,
433     const optional<int>& layer_id, const optional<string>& layer_name,
434     CicoSCDisplayConf* displayConf)
435 {
436     ptree layouts = layer.second.get_child("layouts");
437     BOOST_FOREACH (const ptree::value_type& layout, layouts) {
438         optional<int> id = optional<int>(-1);
439         optional<string> name;
440
441         id = layout.second.get_optional<int>("<xmlattr>.id");
442         if (false == id.is_initialized()) {
443             ICO_ERR("disply.layer.layout.id attr not found");
444             continue;
445         }
446         name = layer.second.get_optional<string>("<xmlattr>.name");
447         if (false == name.is_initialized()) {
448             ICO_ERR("disply.layer.layout.name attr not found");
449             continue;
450         }
451         createLayoutConfContainedArea(layout, layer_id, layer_name, id, name,
452                                       displayConf);
453     }
454 }
455
456 //--------------------------------------------------------------------------
457 /**
458  *  @brief
459  *
460  *  @param  [in]
461  */
462 //--------------------------------------------------------------------------
463 void
464 CicoSystemConfig::createLayerConf(const ptree::value_type & child,
465                                     CicoSCDisplayConf* displayConf)
466 {
467     ptree layers = child.second.get_child("layers");
468     BOOST_FOREACH (const ptree::value_type& layer, layers) {
469         optional<int> id = optional<int>(-1);
470         optional<string> name;
471         optional<int> type = optional<int>(-1);
472         optional<bool> overlap = optional<bool>(false);
473
474         id = layer.second.get_optional<int>("<xmlattr>.id");
475         if (false == id.is_initialized()) {
476             ICO_ERR("disply.layer.id attr not found");
477             continue;
478         }
479         name = layer.second.get_optional<string>("<xmlattr>.name");
480         if (false == name.is_initialized()) {
481             ICO_ERR("disply.layer.name attr not found");
482             continue;
483         }
484         type = layer.second.get_optional<int>("type");
485         if (false == type.is_initialized()) {
486 //             ICO_ERR("disply.layer.type element not found");
487             createLayerConfContainedLayout(layer, id, name, displayConf);
488             continue;
489         }
490         overlap = layer.second.get_optional<bool>("menuoverlap");
491         if (false == overlap.is_initialized()) {
492             ICO_ERR("disply.layer.overlap element not found");
493             continue;
494         }
495
496         CicoSCLayerConf* layerConf = new CicoSCLayerConf();
497         layerConf->id          = id.get();
498         layerConf->name        = name.get();
499         layerConf->type        = type.get();
500         layerConf->menuoverlap = overlap.get();
501
502         displayConf->layerConfList.push_back(layerConf);
503
504         layerConf->dumpConf();
505     }
506 }
507
508 //--------------------------------------------------------------------------
509 /**
510  *  @brief
511  *
512  *  @param  [in]
513  */
514 //--------------------------------------------------------------------------
515 void
516 CicoSystemConfig::createDisplayZoneConf(const ptree::value_type & child,
517                                           CicoSCDisplayConf* displayConf)
518 {
519     ptree zones = child.second.get_child("zones");
520     BOOST_FOREACH (const ptree::value_type& zone, zones) {
521         optional<int>    id = optional<int>(-1);
522         optional<string> name;
523         optional<string> x;
524         optional<string> y;
525         optional<string> w;
526         optional<string> h;
527         optional<bool>   fixed;
528         optional<bool>   l;
529         optional<bool>   r;
530         optional<bool>   t;
531         optional<bool>   b;
532
533         id = zone.second.get_optional<int>("<xmlattr>.id");
534         if (false == id.is_initialized()) {
535             ICO_WRN("zone.id.attr not found");
536             continue;
537         }
538         name = zone.second.get_optional<string>("<xmlattr>.name");
539         if (false == name.is_initialized()) {
540             ICO_WRN("zone.name.attr not found");
541             continue;
542         }
543         x = zone.second.get_optional<string>("geometry.<xmlattr>.x");
544         if (false == x.is_initialized()) {
545             ICO_WRN("zone.geometry.x attr not found");
546             continue;
547         }
548         y = zone.second.get_optional<string>("geometry.<xmlattr>.y");
549         if (false == y.is_initialized()) {
550             ICO_WRN("zone.geometry.y attr not found");
551             continue;
552         }
553         w = zone.second.get_optional<string>("geometry.<xmlattr>.w");
554         if (false == w.is_initialized()) {
555             ICO_WRN("zone.geometry.w attr not found");
556             continue;
557         }
558         h = zone.second.get_optional<string>("geometry.<xmlattr>.h");
559         if (false == h.is_initialized()) {
560             ICO_WRN("zone.geometry.h attr not found");
561             continue;
562         }
563         fixed = zone.second.get_optional<bool>("aspect.<xmlattr>.Fixed");
564         if (false == fixed.is_initialized()) {
565             fixed = optional<bool>(false);
566         }
567         l = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignLeft");
568         if (false == l.is_initialized()) {
569             l = optional<bool>(false);
570         }
571         r = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignRight");
572         if (false == r.is_initialized()) {
573             r = optional<bool>(false);
574         }
575         t = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignTop");
576         if (false == t.is_initialized()) {
577             t = optional<bool>(false);
578         }
579         b = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignBottom");
580         if (false == b.is_initialized()) {
581             b = optional<bool>(false);
582         }
583
584         CicoSCDisplayZoneConf* zoneConf = new CicoSCDisplayZoneConf();
585         zoneConf->id         = id.get();
586         zoneConf->name       = name.get();
587         zoneConf->fullname   = displayConf->name + "." + name.get();
588         zoneConf->x          = calcGeometryExpr(x.get(), displayConf);
589         zoneConf->y          = calcGeometryExpr(y.get(), displayConf);
590         zoneConf->w          = calcGeometryExpr(w.get(), displayConf);
591         zoneConf->h          = calcGeometryExpr(h.get(), displayConf);
592         zoneConf->aspectFixed       = fixed.get();
593         zoneConf->aspectAlignLeft   = l.get();
594         zoneConf->aspectAlignRight  = r.get();
595         zoneConf->aspectAlignTop    = t.get();
596         zoneConf->aspectAlignBottom = b.get();
597         displayConf->zoneConfList.push_back(zoneConf);
598
599         zoneConf->dumpConf();
600     }
601 }
602
603 //--------------------------------------------------------------------------
604 /**
605  *  @brief
606  *
607  *  @param  [in]
608  */
609 //--------------------------------------------------------------------------
610 void
611 CicoSystemConfig::createSoundConfList(const ptree & root)
612 {
613     //<sound>
614     ptree sounds = root.get_child("systemconfig.sounds");
615     BOOST_FOREACH (const ptree::value_type& child, sounds) {
616         optional<int> id = optional<int>(-1);
617         optional<string> name;
618         optional<int> no = optional<int>(-1);
619
620         id = child.second.get_optional<int>("<xmlattr>.id");
621         if (false == id.is_initialized()) {
622             continue;
623         }
624
625         name = child.second.get_optional<string>("<xmlattr>.name");
626         if (false == name.is_initialized()) {
627             continue;
628         }
629
630         no = child.second.get_optional<int>("no");
631         if (false == no.is_initialized()) {
632             continue;
633         }
634
635         CicoSCSoundConf* soundConf = new CicoSCSoundConf();
636         soundConf->id   = id.get();
637         soundConf->name = name.get();
638         soundConf->no   = no.get();
639
640         soundConf->dumpConf();
641
642         createSoundZoneConf(child, soundConf);
643
644         m_soundConfList.push_back(soundConf);
645     }
646 }
647
648 //--------------------------------------------------------------------------
649 /**
650  *  @brief
651  *
652  *  @param  [in]
653  */
654 //--------------------------------------------------------------------------
655 void
656 CicoSystemConfig::createSoundZoneConf(const ptree::value_type & child,
657                                         CicoSCSoundConf* soundConf)
658 {
659     //<sound>
660     //  <zone>
661     //      ...
662     ptree zones = child.second.get_child("zones");
663     BOOST_FOREACH (const ptree::value_type& zone, zones) {
664         optional<int>    id = optional<int>(-1);
665         optional<string> name;
666
667         id = zone.second.get_optional<int>("<xmlattr>.id");
668         if (false == id.is_initialized()) {
669             continue;
670         }
671         name = zone.second.get_optional<string>("<xmlattr>.name");
672         if (false == name.is_initialized()) {
673             continue;
674         }
675
676         CicoSCSoundZoneConf* zoneConf = new CicoSCSoundZoneConf();
677         zoneConf->id       = id.get();
678         zoneConf->name     = name.get();
679         zoneConf->fullname = soundConf->name + "." + name.get();
680         soundConf->zoneConfList.push_back(zoneConf);
681
682         zoneConf->dumpConf();
683     }
684 }
685
686 //--------------------------------------------------------------------------
687 /**
688  *  @brief
689  *
690  *  @param  [in]
691  */
692 //--------------------------------------------------------------------------
693 void
694 CicoSystemConfig::createPortConf(const ptree & root)
695 {
696     // <ports>
697     ptree ports = root.get_child("systemconfig.ports");
698     BOOST_FOREACH (const ptree::value_type& child, ports) {
699         optional<int> id = optional<int>(-1);
700         optional<string> name;
701
702         id = child.second.get_optional<int>("<xmlattr>.id");
703         if (false == id.is_initialized()) {
704             continue;
705         }
706         name = child.second.get_optional<string>("<xmlattr>.name");
707         if (false == name.is_initialized()) {
708             continue;
709         }
710
711         switch (id.get()) {
712         case 0:
713             // TODO
714             m_sysconPort = atoi(child.second.data().c_str());
715             break;
716         case 1:
717             m_soundPluginPort = atoi(child.second.data().c_str());
718             break;
719         default:
720             break;
721         }
722     }
723 }
724
725 //--------------------------------------------------------------------------
726 /**
727  *  @brief
728  *
729  *  @param  [in]
730  */
731 //--------------------------------------------------------------------------
732 void
733 CicoSystemConfig::createCategoryConf(const ptree & root)
734 {
735     //<category>
736     ptree categorys = root.get_child("systemconfig.categorys");
737     BOOST_FOREACH (const ptree::value_type& child, categorys) {
738         optional<int> id = optional<int>(-1);
739         optional<string> name;
740         optional<string> type;
741         optional<string> view;
742         optional<string> sound;
743         optional<string> input;
744         optional<int> priority = optional<int>(-1);
745         optional<int> r_ctrl = optional<int>(-1);
746
747         id = child.second.get_optional<int>("<xmlattr>.id");
748         if (false == id.is_initialized()) {
749             continue;
750         }
751         name = child.second.get_optional<string>("<xmlattr>.name");
752         if (false == name.is_initialized()) {
753             continue;
754         }
755         type = child.second.get_optional<string>("type");
756         if (false == type.is_initialized()) {
757             continue;
758         }
759         view = child.second.get_optional<string>("view");
760         if (false == view.is_initialized()) {
761             continue;
762         }
763         sound = child.second.get_optional<string>("sound");
764         if (false == sound.is_initialized()) {
765             continue;
766         }
767         input= child.second.get_optional<string>("input");
768         if (false == sound.is_initialized()) {
769             continue;
770         }
771         priority = child.second.get_optional<int>("priority");
772         if (false == priority.is_initialized()) {
773             continue;
774         }
775         r_ctrl = child.second.get_optional<int>("r_ctrl");
776         if (false == r_ctrl.is_initialized()) {
777             continue;
778         }
779
780         CicoSCCategoryConf* categoryConf = new CicoSCCategoryConf();
781         categoryConf->id       = id.get();
782         categoryConf->name     = name.get();
783         categoryConf->type     = type.get();
784         categoryConf->view     = m_categoryTalbe[view.get()];
785         categoryConf->sound    = m_categoryTalbe[sound.get()];
786         categoryConf->input    = m_categoryTalbe[input.get()];
787         categoryConf->priority = priority.get();
788         categoryConf->rctrl    = r_ctrl.get();
789         m_categoryConfList.push_back(categoryConf);
790         categoryConf->dumpConf();
791     }
792 }
793
794 //--------------------------------------------------------------------------
795 /**
796  *  @brief
797  *
798  *  @param  [in]
799  */
800 //--------------------------------------------------------------------------
801 void
802 CicoSystemConfig::createAppKindConf(const ptree & root)
803 {
804     // <appkinds>
805     ptree appkinds = root.get_child("systemconfig.appkinds");
806     BOOST_FOREACH (const ptree::value_type& child, appkinds) {
807         optional<int> id = optional<int>(-1);
808         optional<string> name;
809         optional<string> privilege;
810         optional<int> priority = optional<int>(-1);
811
812         id = child.second.get_optional<int>("<xmlattr>.id");
813         if (false == id.is_initialized()) {
814             continue;
815         }
816
817         name = child.second.get_optional<string>("<xmlattr>.name");
818         if (false == name.is_initialized()) {
819             continue;
820         }
821
822         privilege = child.second.get_optional<string>("privilege");
823         if (false == name.is_initialized()) {
824             continue;
825         }
826
827         priority = child.second.get_optional<int>("priority");
828         if (false == priority.is_initialized()) {
829             continue;
830         }
831
832         CicoSCAppKindConf* appKindConf = new CicoSCAppKindConf();
833         appKindConf->id        = id.get();
834         appKindConf->name      = name.get();
835         appKindConf->privilege = m_privilegeTable[privilege.get()];
836         appKindConf->priority  = priority.get();
837         m_appKindConfList.push_back(appKindConf);
838         appKindConf->dumpConf();
839     }
840 }
841
842 //--------------------------------------------------------------------------
843 /**
844  *  @brief
845  *
846  *  @param  [in]
847  */
848 //--------------------------------------------------------------------------
849 void
850 CicoSystemConfig::createInputDevList(const ptree & root)
851 {
852     //<inputs>
853     ptree inputs = root.get_child("systemconfig.inputs");
854     BOOST_FOREACH (const ptree::value_type& child, inputs) {
855         optional<int> id = optional<int>(-1);
856         optional<string> name;
857
858         id = child.second.get_optional<int>("<xmlattr>.id");
859         if (false == id.is_initialized()) {
860             continue;
861         }
862
863         name = child.second.get_optional<string>("<xmlattr>.name");
864         if (false == name.is_initialized()) {
865             continue;
866         }
867
868         CicoSCInputDevConf* inputDevConf = new CicoSCInputDevConf();
869         inputDevConf->id   = id.get();
870         inputDevConf->name = name.get();
871         inputDevConf->dumpConf();
872
873         createSwitchList(child, inputDevConf);
874         m_inputDevConfList.push_back(inputDevConf);
875     }
876 }
877
878 //--------------------------------------------------------------------------
879 /**
880  *  @brief
881  *
882  *  @param  [in]
883  */
884 //--------------------------------------------------------------------------
885 void
886 CicoSystemConfig::createSwitchList(const ptree::value_type & child,
887                                      CicoSCInputDevConf* inputDevConf)
888 {
889     ptree switchs = child.second.get_child("switchs");
890     BOOST_FOREACH (const ptree::value_type& zone, switchs) {
891         optional<int> id = optional<int>(-1);
892         optional<string> name;
893         optional<string> appid;
894
895         id = zone.second.get_optional<int>("<xmlattr>.id");
896         if (false == id.is_initialized()) {
897             continue;
898         }
899
900         name = zone.second.get_optional<string>("<xmlattr>.name");
901         if (false == name.is_initialized()) {
902             continue;
903         }
904
905         appid = zone.second.get_optional<string>("<xmlattr>.appid");
906         if (false == appid.is_initialized()) {
907             continue;
908         }
909
910         CicoSCSwitchConf* switchConf = new CicoSCSwitchConf();
911         switchConf->id    = id.get();
912         switchConf->name  = name.get();
913         switchConf->appid = appid.get();
914         switchConf->dumpConf();
915         inputDevConf->switchConfList.push_back(switchConf);
916     }
917 }
918
919 //--------------------------------------------------------------------------
920 /**
921  *  @brief
922  *
923  *  @param  [in]
924  */
925 //--------------------------------------------------------------------------
926 void
927 CicoSystemConfig::createDefaultConf(const ptree & root)
928 {
929     // <default>
930     ptree defaults = root.get_child("systemconfig.default");
931
932     optional<string> node;
933     optional<string> appkind;
934     optional<string> category;
935     optional<string> display;
936     optional<string> layer;
937     optional<string> displayzone;
938     optional<string> sound;
939     optional<string> soundzone;
940     optional<string> inputdev;
941     optional<string> inputsw;
942
943     node = defaults.get_optional<string>("node");
944     if (false == node.is_initialized()) {
945         ICO_WRN("default.node element not found");
946     }
947
948     appkind = defaults.get_optional<string>("appkind");
949     if (false == appkind.is_initialized()) {
950         ICO_WRN("default.appkind element not found");
951     }
952
953     category = defaults.get_optional<string>("category");
954     if (false == category.is_initialized()) {
955         ICO_WRN("default.category element not found");
956     }
957
958     display = defaults.get_optional<string>("display");
959     if (false == display.is_initialized()) {
960         ICO_WRN("default.display element not found");
961     }
962
963     layer = defaults.get_optional<string>("layer");
964     if (false == layer.is_initialized()) {
965         ICO_WRN("default.layer element not found");
966     }
967
968     displayzone = defaults.get_optional<string>("displayzone");
969     if (false == displayzone.is_initialized()) {
970         ICO_WRN("default.displayzone element not found");
971     }
972
973     sound = defaults.get_optional<string>("sound");
974     if (false == sound.is_initialized()) {
975         ICO_WRN("default.sound element not found");
976     }
977
978     soundzone = defaults.get_optional<string>("soundzone");
979     if (false == soundzone.is_initialized()) {
980         ICO_WRN("default.soundzone element not found");
981     }
982
983     inputdev = defaults.get_optional<string>("inputdev");
984     if (false == inputdev.is_initialized()) {
985         ICO_WRN("default.inputdev element not found");
986     }
987
988     inputsw = defaults.get_optional<string>("inputsw");
989     if (false == inputsw.is_initialized()) {
990         ICO_WRN("default.inputdsw element not found");
991     }
992
993     m_defaultConf = new CicoSCDefaultConf();
994
995     m_defaultConf->node        = getNodeIdbyName(node.get());
996     m_defaultConf->appkind     = getAppKindIdbyName(appkind.get());
997     m_defaultConf->category    = getCategoryIdbyName(category.get());
998     m_defaultConf->display     = getDisplayIdbyName(display.get());
999     m_defaultConf->layer       = getLayerIdfbyName(display.get(), layer.get());
1000     m_defaultConf->displayzone = getDizplayZoneIdbyName(display.get(),
1001                                                       displayzone.get());
1002     m_defaultConf->sound       = getSoundIdbyName(sound.get());
1003     m_defaultConf->soundzone   = getSoundZoneIdbyName(sound.get(),
1004                                                     soundzone.get());
1005     m_defaultConf->inputdev    = getInputDevIdbyName(inputdev.get());
1006     m_defaultConf->inputsw     = getSwitchIdbyName(inputdev.get(),
1007                                                  inputsw.get());
1008
1009 #define ICO_SYC_TOP_EVN         "SYSCON_TOPDIR"
1010     /* decide top directory in all configurations       */
1011     const char *topdir = getenv(ICO_SYC_TOP_EVN);
1012     if (NULL ==  topdir) {
1013         topdir = tzplatform_mkpath(TZ_SYS_RO_APP, ICO_SYC_PACKAGE_SYSTEMCONTROLLER);
1014     }
1015     m_defaultConf->topdir = topdir;
1016
1017 #define ICO_SYC_CONFIG_ENV  "SYSCON_CONFDIR"
1018     /* decide top directory in configuration file's     */
1019     const char *confdir = getenv(ICO_SYC_CONFIG_ENV);
1020     if (NULL != confdir) {
1021         m_defaultConf->confdir = confdir;
1022     }
1023     else {
1024         m_defaultConf->confdir = m_defaultConf->topdir;
1025         m_defaultConf->confdir.append("/");
1026         m_defaultConf->confdir.append(ICO_SYC_CONFIGPATH_PACKAGE_CONFIG);
1027     }
1028
1029     m_defaultConf->dumpConf();
1030 }
1031
1032 //--------------------------------------------------------------------------
1033 /**
1034  *  @brief  resource config class object create
1035  *
1036  *  @param  [in]
1037  */
1038 //--------------------------------------------------------------------------
1039 void getArray(ptree& t, vector<int>& vec);
1040 static const char* g_resource_cpu = "systemconfig.resource_cpu_control";
1041 void
1042 CicoSystemConfig::createResourceConf(const ptree & root)
1043 {
1044     m_resourceConf = new CicoSCResourceConf;
1045     ptree rc = root.get_child(g_resource_cpu);
1046     bool b = false;
1047     bool bApp = false;
1048
1049     ptree lcl_pt;
1050     string fPath;
1051     bool bF = false;
1052     if ((CicoSCDefaultConf*)0 != m_defaultConf) {
1053         fPath = m_defaultConf->confdir;
1054         fPath += string("/");
1055         fPath += string("system_sysres.json");
1056         struct stat buff;
1057         /* file check */
1058         memset(&buff, 0, sizeof(buff));
1059         if (0 == stat(fPath.c_str(), &buff)) {
1060             read_json(fPath.c_str(), lcl_pt);
1061             bF = true;
1062         }
1063     }
1064     if (true==bF) {
1065         try{
1066             if (boost::optional<std::string> function =
1067                 lcl_pt.get_optional<std::string>("function")) {
1068                 string v = function.get();
1069                 if (0 == v.compare("yes")) {
1070                     b = true;
1071                 }
1072                 else if (0 == v.compare("app")) {
1073                     bApp = true;
1074                 }
1075             }
1076         }
1077         catch (...) {
1078             ICO_WRN("NG json file(%s)", fPath.c_str());
1079             b = false;
1080             bApp = false;
1081         }
1082     }
1083     else {
1084         optional<string> opts = rc.get_optional<string>("do_it");
1085         if (true == opts.is_initialized()) {
1086             string v = opts.get();
1087             if (0 == v.compare("yes")) {
1088                 b = true;
1089             }
1090             else if (0 == v.compare("app")) {
1091                 bApp = true;
1092             }
1093         }
1094     }
1095     m_resourceConf->m_bDoIt = b;
1096     m_resourceConf->m_bDoItApp = bApp;
1097
1098     string dirnm;
1099     if (true == bF) {
1100         try {
1101             if (boost::optional<std::string> ctrl_dir_path =
1102                 lcl_pt.get_optional<std::string>("ctrl_dir_path")) {
1103                 dirnm = ctrl_dir_path.get();
1104             }
1105         }
1106         catch (...) {
1107             ICO_WRN("NG json file(%s)", fPath.c_str());
1108         }
1109     }
1110     else {
1111         optional<string> opts2 = rc.get_optional<string>("ctrl_dir_path");
1112         if (true == opts2.is_initialized()) {
1113             dirnm = opts2.get();
1114         }
1115     }
1116     if (true == dirnm.empty()) {
1117         dirnm = "/sys/fs/cgroup/cpu,cpuacct/SCprivate";
1118     }
1119     m_resourceConf->m_cpuCGRPPath = dirnm;
1120     if (false == b) {
1121         return;
1122     }
1123     optional<string> opts;
1124
1125     opts = rc.get_optional<string>("sampling_wait");
1126     if (true == opts.is_initialized()) {
1127         m_resourceConf->m_sampling = atoi(opts.get().c_str());
1128     }
1129
1130     opts = rc.get_optional<string>("log");
1131     if (true == opts.is_initialized()) {
1132         string v = opts.get();
1133         if (0 == v.compare("true")) {
1134             m_resourceConf->m_bLog = true;
1135         }
1136     }
1137
1138     opts = rc.get_optional<string>("retry_cnt");
1139     if (true == opts.is_initialized()) {
1140         m_resourceConf->m_retryCnt = atoi(opts.get().c_str());
1141     }
1142
1143     opts = rc.get_optional<string>("low_limit_value");
1144     if (true == opts.is_initialized()) {
1145         m_resourceConf->m_lowLimitVal = atoi(opts.get().c_str());
1146     }
1147
1148     opts = rc.get_optional<string>("high_limit_value");
1149     if (true == opts.is_initialized()) {
1150         m_resourceConf->m_highLimitVal = atoi(opts.get().c_str());
1151     }
1152
1153     BOOST_FOREACH(ptree::value_type& child, rc) {
1154         optional<int> id = optional<int>(-1);
1155         optional<string> name;
1156         id = child.second.get_optional<int>("<xmlattr>.id");
1157         if (false == id.is_initialized()) {
1158             continue;
1159         }
1160         name = child.second.get_optional<string>("<xmlattr>.name");
1161         if (false == name.is_initialized()) {
1162             continue;
1163         }
1164         ptree pth = child.second.get_child("hight_array");
1165         ptree ptl = child.second.get_child("low_array");
1166
1167         CicoSCCpuResourceGrp* obj = new CicoSCCpuResourceGrp;
1168         obj->m_id    = id.get();
1169         obj->m_bDoIt = b;
1170         obj->m_grpNm = name.get();
1171         getArray(pth, obj->m_hight);
1172         getArray(ptl, obj->m_low);
1173         m_resourceConf->m_cpuCtrl.push_back(obj);
1174     }
1175     m_resourceConf->dumpConf();
1176 }
1177
1178 //--------------------------------------------------------------------------
1179 /**
1180  *  @brief  vechicle information config class object create
1181  *
1182  *  @param  [in]
1183  */
1184 //--------------------------------------------------------------------------
1185 void
1186 CicoSystemConfig::createVehicleInfoConf(const ptree & root)
1187 {
1188     m_vehicleInfoConf = new CicoSCVehicleInfoConf();
1189
1190     ptree child = root.get_child("systemconfig.vehicle_info");
1191
1192     optional<int> retryCnt;
1193     optional<int> waitTime;
1194
1195     retryCnt = child.get_optional<int>("retryCnt");
1196     if (false == retryCnt.is_initialized()) {
1197         ICO_WRN("vehicle_info.retryCnt element not found");
1198         retryCnt = optional<int>(0);
1199     }
1200
1201     waitTime = child.get_optional<int>("waitTime");
1202     if (false == waitTime.is_initialized()) {
1203         ICO_WRN("vehicle_info.waitTime element not found");
1204         waitTime = optional<int>(0);
1205     }
1206
1207     m_vehicleInfoConf->retryCnt = retryCnt.get();
1208     m_vehicleInfoConf->waitTime = waitTime.get();
1209
1210     BOOST_FOREACH (const ptree::value_type& vinfo, child) {
1211         optional<int> id;
1212         optional<string> name;
1213         optional<string> objname;
1214         optional<string> property;
1215         optional<int> zone;
1216         optional<string> type;
1217
1218         id = vinfo.second.get_optional<int>("<xmlattr>.id");
1219         if (false == id.is_initialized()) {
1220             continue;
1221         }
1222
1223         name = vinfo.second.get_optional<string>("<xmlattr>.name");
1224         if (false == name.is_initialized()) {
1225             continue;
1226         }
1227
1228         property = vinfo.second.get_optional<string>("property");
1229         if (false == property.is_initialized()) {
1230             continue;
1231         }
1232
1233         objname = vinfo.second.get_optional<string>("objname");
1234         if (false == objname.is_initialized()) {
1235             continue;
1236         }
1237
1238         zone = vinfo.second.get_optional<int>("zone");
1239         if (false == zone.is_initialized()) {
1240             continue;
1241         }
1242
1243         type = vinfo.second.get_optional<string>("type");
1244         if (false == type.is_initialized()) {
1245             continue;
1246         }
1247
1248         CicoSCVIPropertyConf* viprop = new CicoSCVIPropertyConf();
1249         viprop->id       = id.get();
1250         viprop->name     = name.get();
1251         viprop->objname  = objname.get();
1252         viprop->property = property.get();
1253         viprop->zone     = zone.get();
1254         viprop->typestr  = type.get();
1255         viprop->type     = viprop->typeStrToInt(viprop->typestr);
1256         m_vehicleInfoConf->properties[id.get()] = viprop;
1257     }
1258
1259     m_vehicleInfoConf->dumpConf();
1260 }
1261
1262 //--------------------------------------------------------------------------
1263 /**
1264  *  @brief  user config class object create
1265  *
1266  *  @param  [in]
1267  */
1268 //--------------------------------------------------------------------------
1269 static const char* g_login_user_conf = "systemconfig.login_user";
1270 void
1271 CicoSystemConfig::createUserConf(const ptree & root)
1272 {
1273     m_userConf = new CicoSCUserConf;
1274     ptree rc = root.get_child(g_login_user_conf);
1275     optional<string> opts = rc.get_optional<string>("parent_dir");
1276     if (true == opts.is_initialized()) {
1277         string v = opts.get();
1278         if (! v.empty()) {
1279             m_userConf->m_parent_dir = tzplatform_mkpath(TZ_USER_HOME, v.c_str());
1280         }
1281     }
1282     if (m_userConf->m_parent_dir.empty())   {
1283         m_userConf->m_parent_dir = tzplatform_mkpath(TZ_USER_HOME, ICO_SYC_CONFIGPATH_HOME);
1284     }
1285     m_userConf->dumpConf();
1286 }
1287
1288 //--------------------------------------------------------------------------
1289 /**
1290  *  @brief
1291  *
1292  *  @param  [in]
1293  */
1294 //--------------------------------------------------------------------------
1295 int
1296 CicoSystemConfig::calcGeometryExpr(const string & expr,
1297                                      CicoSCDisplayConf* conf)
1298 {
1299     int     val = 0;
1300     int     wval;
1301     int     i, j, sign;
1302     char    word[32];
1303
1304     j = 0;
1305     sign = 0;
1306     for (i = 0; ; i++)  {
1307         if (expr[i] == ' ')  continue;
1308         if ((expr[i] == 0) || (expr[i] == '+') || (expr[i] == '-') ||
1309             (expr[i] == '*') || (expr[i] == '-') || (expr[i] == '/'))  {
1310             if (j > 0)  {
1311                 word[j] = 0;
1312                 if ((strcasecmp(word, "dispw") == 0) ||
1313                     (strcasecmp(word, "width") == 0))   {
1314                     wval = conf->width;
1315                 }
1316                 else if ((strcasecmp(word, "disph") == 0) ||
1317                          (strcasecmp(word, "heigh") == 0))  {
1318                     wval = conf->height;
1319                 }
1320                 else    {
1321                     wval = strtol(word, (char **)0, 0);
1322                 }
1323                 j = 0;
1324                 if (sign >= 10) {
1325                     wval = 0 - wval;
1326                 }
1327                 switch (sign % 10)  {
1328                 case 0:                     /* assign       */
1329                     val = wval;
1330                     break;
1331                 case 1:                     /* '+'          */
1332                     val += wval;
1333                     break;
1334                 case 2:                     /* '-'          */
1335                     val -= wval;
1336                     break;
1337                 case 3:                     /* '*'          */
1338                     val *= wval;
1339                     break;
1340                 case 4:                     /* '/'          */
1341                     val /= wval;
1342                     break;
1343                 default:
1344                     break;
1345                 }
1346                 sign = 0;
1347                 if (expr[i] == '+')      sign = 1;
1348                 else if (expr[i] == '-') sign = 2;
1349                 else if (expr[i] == '*') sign = 3;
1350                 else if (expr[i] == '/') sign = 4;
1351                 else                    sign = 0;
1352             }
1353             else    {
1354                 if ((sign > 0) && (expr[i] == '-'))  {
1355                     sign += 10;
1356                 }
1357                 else    {
1358                     if (expr[i] == '+')      sign = 1;
1359                     else if (expr[i] == '-') sign = 2;
1360                     else if (expr[i] == '*') sign = 3;
1361                     else if (expr[i] == '/') sign = 4;
1362                     else                     sign = 0;
1363                 }
1364             }
1365             if (expr[i] == 0)    break;
1366         }
1367         else    {
1368             if (j < ((int)sizeof(word)-1))  {
1369                 word[j++] = expr[i];
1370             }
1371         }
1372     }
1373     return val;
1374 }
1375
1376 //--------------------------------------------------------------------------
1377 /**
1378  *  @brief
1379  *
1380  *  @param  [in]
1381  */
1382 //--------------------------------------------------------------------------
1383 const CicoSCNodeConf*
1384 CicoSystemConfig::findNodeConfbyName(const string & name)
1385 {
1386     vector<CicoSCNodeConf*>::const_iterator itr;
1387     itr = m_nodeConfList.begin();
1388     for (; itr != m_nodeConfList.end(); ++itr) {
1389         const CicoSCNodeConf* conf = (*itr);
1390         if (name == conf->name) {
1391             return conf;
1392         }
1393     }
1394
1395     return NULL;
1396 }
1397
1398 //--------------------------------------------------------------------------
1399 /**
1400  *  @brief
1401  *
1402  *  @param  [in]
1403  */
1404 //--------------------------------------------------------------------------
1405 const CicoSCDisplayConf*
1406 CicoSystemConfig::findDisplayConfbyName(const string & name)
1407 {
1408     vector<CicoSCDisplayConf*>::const_iterator itr;
1409     itr = m_displayConfList.begin();
1410     for (; itr != m_displayConfList.end(); ++itr) {
1411         const CicoSCDisplayConf* conf = (*itr);
1412         if (name == conf->name) {
1413             return conf;
1414         }
1415     }
1416
1417     return NULL;
1418 }
1419
1420 //--------------------------------------------------------------------------
1421 /**
1422  *  @brief
1423  *
1424  *  @param  [in]
1425  */
1426 //--------------------------------------------------------------------------
1427 const CicoSCDisplayConf*
1428 CicoSystemConfig::findDisplayConfbyName(const string& ECU, const string& name)
1429 {
1430     int nodeId = getNodeIdbyName(ECU);
1431     vector<CicoSCDisplayConf*>::const_iterator itr;
1432     itr = m_displayConfList.begin();
1433     for (; itr != m_displayConfList.end(); ++itr) {
1434         const CicoSCDisplayConf* conf = (*itr);
1435         if ((name == conf->name)&&(nodeId == conf->node)) {
1436             return conf;
1437         }
1438     }
1439
1440     return NULL;
1441 }
1442
1443 //--------------------------------------------------------------------------
1444 /**
1445  *  @brief
1446  *
1447  *  @param  [in]
1448  */
1449 //--------------------------------------------------------------------------
1450 const CicoSCDisplayConf*
1451 CicoSystemConfig::findDisplayConfbyId(int id)
1452 {
1453     vector<CicoSCDisplayConf*>::const_iterator itr;
1454     itr = m_displayConfList.begin();
1455     for (; itr != m_displayConfList.end(); ++itr) {
1456         const CicoSCDisplayConf* conf = (*itr);
1457         if (id == conf->id) {
1458             return conf;
1459         }
1460     }
1461     return NULL;
1462 }
1463
1464 //--------------------------------------------------------------------------
1465 /**
1466  *  @brief
1467  *
1468  *  @param  [in]
1469  */
1470 //--------------------------------------------------------------------------
1471 const CicoSCLayerConf*
1472 CicoSystemConfig::findLayerConfbyName(const string & displayName,
1473                                         const string & layerName)
1474 {
1475     const CicoSCDisplayConf* displayConf = NULL;
1476     displayConf = findDisplayConfbyName(displayName);
1477     if (NULL == displayConf) {
1478         return NULL;
1479     }
1480
1481     vector<CicoSCLayerConf*>::const_iterator itr;
1482     itr = displayConf->layerConfList.begin();
1483     for (; itr != displayConf->layerConfList.end(); ++itr) {
1484         const CicoSCLayerConf* conf = (*itr);
1485 //        if (layerName == conf->name) {
1486         if ((layerName == conf->name) && (-1 == conf->layout_id)) {
1487             return conf;
1488         }
1489     }
1490
1491     return NULL;
1492 }
1493
1494 //--------------------------------------------------------------------------
1495 /**
1496  *  @brief
1497  *
1498  *  @param  [in]
1499  */
1500 //--------------------------------------------------------------------------
1501 const CicoSCLayerConf*
1502 CicoSystemConfig::findLayerConfbyName(const string& ECU,
1503                                       const string& display,
1504                                       const string& layer,
1505                                       const string& layout,
1506                                       const string& area)
1507 {
1508     const CicoSCDisplayConf* displayConf = NULL;
1509     displayConf = findDisplayConfbyName(ECU, display);
1510     if (NULL == displayConf) {
1511         return NULL;
1512     }
1513
1514     vector<CicoSCLayerConf*>::const_iterator itr;
1515     itr = displayConf->layerConfList.begin();
1516     for (; itr != displayConf->layerConfList.end(); ++itr) {
1517         const CicoSCLayerConf* conf = (*itr);
1518         if ((layer == conf->name)&&(layout == conf->layout_name)&&
1519             (area == conf->area_name)) {
1520             return conf;
1521         }
1522     }
1523
1524     return NULL;
1525 }
1526
1527 //--------------------------------------------------------------------------
1528 /**
1529  *  @brief
1530  *
1531  *  @param  [in]
1532  */
1533 //--------------------------------------------------------------------------
1534 const CicoSCLayerConf*
1535 CicoSystemConfig::findLayerConfbyIdx(int displayid, int idx)
1536 {
1537     const CicoSCDisplayConf* displayConf = NULL;
1538     displayConf = findDisplayConfbyId(displayid);
1539     if (NULL == displayConf) {
1540         return NULL;
1541     }
1542
1543     vector<CicoSCLayerConf*>::const_iterator itr;
1544     itr = displayConf->layerConfList.begin();
1545     for (; itr != displayConf->layerConfList.end(); ++itr) {
1546         const CicoSCLayerConf* conf = (*itr);
1547         if (idx <= 0)   {
1548             return conf;
1549         }
1550         idx --;
1551     }
1552     return NULL;
1553 }
1554
1555 //--------------------------------------------------------------------------
1556 /**
1557  *  @brief
1558  *
1559  *  @param  [in]
1560  */
1561 //--------------------------------------------------------------------------
1562 const CicoSCDisplayZoneConf*
1563 CicoSystemConfig::findDisplayZoneConfbyName(const string & displayName,
1564                                               const string & zoneName)
1565 {
1566 //    ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Enter"
1567 //            "(displayName=%s zoneNmae=%s)",
1568 //            displayName.c_str(), zoneName.c_str());
1569
1570     const CicoSCDisplayConf* displayConf = NULL;
1571     displayConf = findDisplayConfbyName(displayName);
1572     if (NULL == displayConf) {
1573 //        ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1574         return NULL;
1575     }
1576
1577     vector<CicoSCDisplayZoneConf*>::const_iterator itr;
1578     itr = displayConf->zoneConfList.begin();
1579     for (; itr != displayConf->zoneConfList.end(); ++itr) {
1580         const CicoSCDisplayZoneConf* conf = (*itr);
1581         if (zoneName == conf->name) {
1582 //            ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave"
1583 //                    "(0x%08x)", conf);
1584             return conf;
1585         }
1586     }
1587
1588 //    ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1589     return NULL;
1590 }
1591
1592 //--------------------------------------------------------------------------
1593 /**
1594  *  @brief
1595  *
1596  *  @param  [in]
1597  */
1598 //--------------------------------------------------------------------------
1599 const CicoSCSoundConf*
1600 CicoSystemConfig::findSoundConfbyName(const string & name)
1601 {
1602     vector<CicoSCSoundConf*>::const_iterator itr;
1603     itr = m_soundConfList.begin();
1604     for (; itr != m_soundConfList.end(); ++itr) {
1605         const CicoSCSoundConf* conf = (*itr);
1606         if (name == conf->name) {
1607             return conf;
1608         }
1609     }
1610
1611     return NULL;
1612 }
1613
1614 //--------------------------------------------------------------------------
1615 /**
1616  *  @brief
1617  *
1618  *  @param  [in]
1619  */
1620 //--------------------------------------------------------------------------
1621 const CicoSCSoundZoneConf*
1622 CicoSystemConfig::findSoundZoneConfbyName(const string & soundName,
1623                                             const string & zoneName)
1624 {
1625 //    ICO_TRA("CicoSystemConfig::findSoundZoneConfbyName Enter"
1626 //            "(soundName=%s zoneNmae=%s)",
1627 //            soundName.c_str(), zoneName.c_str());
1628
1629     const CicoSCSoundConf* soundConf = NULL;
1630     soundConf = findSoundConfbyName(soundName);
1631     if (NULL == soundConf) {
1632         return NULL;
1633     }
1634
1635     vector<CicoSCSoundZoneConf*>::const_iterator itr;
1636     itr = soundConf->zoneConfList.begin();
1637     for (; itr != soundConf->zoneConfList.end(); ++itr) {
1638         const CicoSCSoundZoneConf* conf = (*itr);
1639         if (zoneName == conf->name) {
1640             return conf;
1641         }
1642     }
1643
1644     return NULL;
1645 }
1646
1647 //--------------------------------------------------------------------------
1648 /**
1649  *  @brief
1650  *
1651  *  @param  [in]
1652  */
1653 //--------------------------------------------------------------------------
1654 const CicoSCInputDevConf*
1655 CicoSystemConfig::findInputDevConfbyName(const string & name)
1656 {
1657     vector<CicoSCInputDevConf*>::const_iterator itr;
1658     itr = m_inputDevConfList.begin();
1659     for (; itr != m_inputDevConfList.end(); ++itr) {
1660         const CicoSCInputDevConf* conf = (*itr);
1661         if (name == conf->name) {
1662             return conf;
1663         }
1664     }
1665
1666     return NULL;
1667 }
1668
1669 //--------------------------------------------------------------------------
1670 /**
1671  *  @brief
1672  *
1673  *  @param  [in]
1674  */
1675 //--------------------------------------------------------------------------
1676 const CicoSCSwitchConf*
1677 CicoSystemConfig::findSwitchConfbyName(const string & inputDevName,
1678                                          const string & switchName)
1679 {
1680     const CicoSCInputDevConf* inputDevConf = NULL;
1681     inputDevConf = findInputDevConfbyName(inputDevName);
1682     if (NULL == inputDevConf) {
1683         ICO_WRN("name(%s) input device config not found.",
1684                  inputDevName.c_str());
1685         return NULL;
1686     }
1687
1688     vector<CicoSCSwitchConf*>::const_iterator itr;
1689     itr = inputDevConf->switchConfList.begin();
1690     for (; itr != inputDevConf->switchConfList.end(); ++itr) {
1691         const CicoSCSwitchConf* conf = (*itr);
1692         if (switchName == conf->name) {
1693             return conf;
1694         }
1695     }
1696
1697     ICO_WRN("name(%s) switch config not found.", switchName.c_str());
1698     return NULL;
1699 }
1700
1701 //--------------------------------------------------------------------------
1702 /**
1703  *  @brief
1704  *
1705  *  @param  [in]
1706  */
1707 //--------------------------------------------------------------------------
1708 const CicoSCAppKindConf*
1709 CicoSystemConfig::findAppKindConfbyName(const string & name)
1710 {
1711     vector<CicoSCAppKindConf*>::const_iterator itr;
1712     itr = m_appKindConfList.begin();
1713     for (; itr != m_appKindConfList.end(); ++itr) {
1714         const CicoSCAppKindConf* conf = (*itr);
1715         if (name == conf->name) {
1716             return conf;
1717         }
1718     }
1719
1720     return NULL;
1721 }
1722
1723 //--------------------------------------------------------------------------
1724 /**
1725  *  @brief
1726  *
1727  *  @param  [in]
1728  */
1729 //--------------------------------------------------------------------------
1730 const CicoSCDisplayZoneConf*
1731 CicoSystemConfig::findDisplayZoneConfbyId(int id)
1732 {
1733     vector<CicoSCDisplayConf*>::const_iterator itr;
1734     itr = m_displayConfList.begin();
1735     for (; itr != m_displayConfList.end(); ++itr) {
1736         vector<CicoSCDisplayZoneConf*>::const_iterator itr2;
1737         itr2 = (*itr)->zoneConfList.begin();
1738         for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1739             if (id == (*itr2)->id) {
1740                 return *itr2;
1741             }
1742         }
1743     }
1744
1745     return NULL;
1746 }
1747
1748 //--------------------------------------------------------------------------
1749 /**
1750  *  @brief
1751  *
1752  *  @param  [in]
1753  */
1754 //--------------------------------------------------------------------------
1755 const CicoSCSoundZoneConf*
1756 CicoSystemConfig::findSoundZoneConfbyId(int id)
1757 {
1758     vector<CicoSCSoundConf*>::const_iterator itr;
1759     itr = m_soundConfList.begin();
1760     for (; itr != m_soundConfList.end(); ++itr) {
1761         vector<CicoSCSoundZoneConf*>::const_iterator itr2;
1762         itr2 = (*itr)->zoneConfList.begin();
1763         for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1764             if (id == (*itr2)->id) {
1765                 return *itr2;
1766             }
1767         }
1768     }
1769
1770     return NULL;
1771 }
1772
1773 //--------------------------------------------------------------------------
1774 /**
1775  *  @brief
1776  *
1777  *  @param  [in]
1778  */
1779 //--------------------------------------------------------------------------
1780 const CicoSCCategoryConf*
1781 CicoSystemConfig::findCategoryConfbyName(const string & name)
1782 {
1783     vector<CicoSCCategoryConf*>::const_iterator itr;
1784     itr = m_categoryConfList.begin();
1785     for (; itr != m_categoryConfList.end(); ++itr) {
1786         const CicoSCCategoryConf* conf = (*itr);
1787         if (name == conf->name) {
1788             //return const_cast<CicoSCCategoryConf*>(itr->pointer);
1789             return conf;
1790         }
1791     }
1792
1793     return NULL;
1794 }
1795
1796 //--------------------------------------------------------------------------
1797 /**
1798  *  @brief
1799  *
1800  *  @param  [in]
1801  */
1802 //--------------------------------------------------------------------------
1803 const CicoSCCategoryConf*
1804 CicoSystemConfig::findCategoryConfbyId(int id)
1805 {
1806     vector<CicoSCCategoryConf*>::const_iterator itr;
1807     itr = m_categoryConfList.begin();
1808     for (; itr != m_categoryConfList.end(); ++itr) {
1809         const CicoSCCategoryConf* conf = (*itr);
1810         if (id == conf->id) {
1811             return conf;
1812         }
1813     }
1814
1815     return NULL;
1816 }
1817
1818 //--------------------------------------------------------------------------
1819 /**
1820  *  @brief
1821  *
1822  *  @param  [in]
1823  */
1824 //--------------------------------------------------------------------------
1825 const CicoSCAppKindConf *
1826 CicoSystemConfig::findAppKindConfbyId(int id)
1827 {
1828     vector<CicoSCAppKindConf*>::const_iterator itr;
1829     itr = m_appKindConfList.begin();
1830     for (; itr != m_appKindConfList.end(); ++itr) {
1831         if (id == (*itr)->id) {
1832             return *itr;
1833         }
1834     }
1835
1836     return NULL;
1837 }
1838
1839 //--------------------------------------------------------------------------
1840 /**
1841  *  @brief
1842  *
1843  *  @param  [in]
1844  */
1845 //--------------------------------------------------------------------------
1846 const CicoSCDefaultConf*
1847 CicoSystemConfig::getDefaultConf(void)
1848 {
1849     return m_defaultConf;
1850 }
1851
1852 //--------------------------------------------------------------------------
1853 /**
1854  *  @brief
1855  *
1856  *  @param  [in]
1857  */
1858 //--------------------------------------------------------------------------
1859 int
1860 CicoSystemConfig::getNodeIdbyName(const string & name)
1861 {
1862     const CicoSCNodeConf* conf = NULL;
1863     conf = findNodeConfbyName(name);
1864     if (NULL == conf) {
1865         return -1;
1866     }
1867
1868     return conf->id;
1869 }
1870
1871 //--------------------------------------------------------------------------
1872 /**
1873  *  @brief
1874  *
1875  *  @param  [in]
1876  */
1877 //--------------------------------------------------------------------------
1878 int
1879 CicoSystemConfig::getDisplayIdbyName(const string & name)
1880 {
1881     const CicoSCDisplayConf* conf = NULL;
1882     conf = findDisplayConfbyName(name);
1883     if (NULL == conf) {
1884         return -1;
1885     }
1886
1887     return conf->id;
1888 }
1889
1890 //--------------------------------------------------------------------------
1891 /**
1892  *  @brief
1893  *
1894  *  @param  [in]
1895  */
1896 //--------------------------------------------------------------------------
1897 int
1898 CicoSystemConfig::getDisplayIdbyNo(int no)
1899 {
1900     vector<CicoSCDisplayConf*>::const_iterator itr;
1901     itr = m_displayConfList.begin();
1902     for (; itr != m_displayConfList.end(); ++itr) {
1903         const CicoSCDisplayConf* conf = (*itr);
1904         if (no == conf->no) {
1905             return conf->id;
1906         }
1907     }
1908     return -1;
1909 }
1910
1911 //--------------------------------------------------------------------------
1912 /**
1913  *  @brief
1914  *
1915  *  @param  [in]
1916  */
1917 //--------------------------------------------------------------------------
1918 int
1919 CicoSystemConfig::getDisplayIdbyType(int type)
1920 {
1921     vector<CicoSCDisplayConf*>::const_iterator itr;
1922     itr = m_displayConfList.begin();
1923     for (; itr != m_displayConfList.end(); ++itr) {
1924         const CicoSCDisplayConf* conf = (*itr);
1925         if (type == conf->type) {
1926             return conf->id;
1927         }
1928     }
1929     return -1;
1930 }
1931
1932 //--------------------------------------------------------------------------
1933 /**
1934  *  @brief
1935  *
1936  *  @param  [in]
1937  */
1938 //--------------------------------------------------------------------------
1939 int
1940 CicoSystemConfig::getNumberofDisplay(void)
1941 {
1942     return numDisplay;
1943 }
1944
1945 //--------------------------------------------------------------------------
1946 /**
1947  *  @brief
1948  *
1949  *  @param  [in]
1950  */
1951 //--------------------------------------------------------------------------
1952 int
1953 CicoSystemConfig::getLayerIdfbyName(const string & displayName,
1954                                       const string & layerName)
1955 {
1956     const CicoSCLayerConf* conf = NULL;
1957     conf = findLayerConfbyName(displayName, layerName);
1958     if (NULL == conf) {
1959         return -1;
1960     }
1961
1962     return conf->id;
1963 }
1964
1965 //--------------------------------------------------------------------------
1966 /**
1967  *  @brief
1968  *
1969  *  @param  [in]
1970  */
1971 //--------------------------------------------------------------------------
1972 int
1973 CicoSystemConfig::getLayerIdfbyName(const string& ECU,
1974                                     const string& display,
1975                                     const string& layer,
1976                                     const string& layout,
1977                                     const string& area)
1978 {
1979     const CicoSCLayerConf* conf = NULL;
1980     conf = findLayerConfbyName(ECU, display, layer, layout, area);
1981     if (NULL == conf) {
1982         return -1;
1983     }
1984
1985     return conf->id;
1986 }
1987
1988 //--------------------------------------------------------------------------
1989 /**
1990  *  @brief
1991  *
1992  *  @param  [in]
1993  */
1994 //--------------------------------------------------------------------------
1995 int
1996 CicoSystemConfig::getDizplayZoneIdbyName(const string & displayName,
1997                                            const string & zoneName)
1998 {
1999     const CicoSCDisplayZoneConf* conf = NULL;
2000     conf = findDisplayZoneConfbyName(displayName, zoneName);
2001     if (NULL == conf) {
2002         return -1;
2003     }
2004
2005     return conf->id;
2006 }
2007
2008 //--------------------------------------------------------------------------
2009 /**
2010  *  @brief
2011  *
2012  *  @param  [in]
2013  */
2014 //--------------------------------------------------------------------------
2015 int
2016 CicoSystemConfig::getDizplayZoneIdbyFullName(const string & zoneFullName)
2017 {
2018     string::size_type index = zoneFullName.find(".", 0);
2019     if (string::npos == index) {
2020         return -1;
2021     }
2022     string displayName = zoneFullName.substr(0, index);
2023     string zoneName    = zoneFullName.substr(index+1);
2024
2025     const CicoSCDisplayZoneConf* conf = NULL;
2026     conf = findDisplayZoneConfbyName(displayName, zoneName);
2027     if (NULL == conf) {
2028         return -1;
2029     }
2030
2031     return conf->id;
2032 }
2033
2034 //--------------------------------------------------------------------------
2035 /**
2036  *  @brief
2037  *
2038  *  @param  [in]
2039  */
2040 //--------------------------------------------------------------------------
2041 int
2042 CicoSystemConfig::getSoundIdbyName(const string & name)
2043 {
2044     const CicoSCSoundConf* conf = NULL;
2045     conf = findSoundConfbyName(name);
2046     if (NULL == conf) {
2047         return -1;
2048     }
2049
2050     return conf->id;
2051 }
2052
2053 //--------------------------------------------------------------------------
2054 /**
2055  *  @brief
2056  *
2057  *  @param  [in]
2058  */
2059 //--------------------------------------------------------------------------
2060 int
2061 CicoSystemConfig::getSoundZoneIdbyName(const string & soundName,
2062                                          const string & zoneName)
2063 {
2064     const CicoSCSoundZoneConf* conf = NULL;
2065     conf = findSoundZoneConfbyName(soundName, zoneName);
2066     if (NULL == conf) {
2067         return -1;
2068     }
2069
2070     return conf->id;
2071 }
2072
2073 //--------------------------------------------------------------------------
2074 /**
2075  *  @brief
2076  *
2077  *  @param  [in]
2078  */
2079 //--------------------------------------------------------------------------
2080 int
2081 CicoSystemConfig::getSoundZoneIdbyFullName(const string & zoneFullName)
2082 {
2083     string::size_type index = zoneFullName.find(".", 0);
2084     if (string::npos == index) {
2085         return -1;
2086     }
2087     string soundName = zoneFullName.substr(0, index);
2088     string zoneName  = zoneFullName.substr(index+1);
2089
2090     const CicoSCSoundZoneConf* conf = NULL;
2091     conf = findSoundZoneConfbyName(soundName, zoneName);
2092     if (NULL == conf) {
2093         return -1;
2094     }
2095
2096     return conf->id;
2097 }
2098
2099 //--------------------------------------------------------------------------
2100 /**
2101  *  @brief
2102  *
2103  *  @param  [in]
2104  */
2105 //--------------------------------------------------------------------------
2106 int
2107 CicoSystemConfig::getInputDevIdbyName(const string & name)
2108 {
2109     const CicoSCInputDevConf* conf = NULL;
2110     conf = findInputDevConfbyName(name);
2111     if (NULL == conf) {
2112         return -1;
2113     }
2114
2115     return conf->id;
2116 }
2117
2118 //--------------------------------------------------------------------------
2119 /**
2120  *  @brief
2121  *
2122  *  @param  [in]
2123  */
2124 //--------------------------------------------------------------------------
2125 int
2126 CicoSystemConfig::getSwitchIdbyName(const string & inputDevName,
2127                                       const string & switchName)
2128 {
2129     const CicoSCSwitchConf* conf = NULL;
2130     conf = findSwitchConfbyName(inputDevName, switchName);
2131     if (NULL == conf) {
2132         return -1;
2133     }
2134
2135     return conf->id;
2136 }
2137
2138 //--------------------------------------------------------------------------
2139 /**
2140  *  @brief
2141  *
2142  *  @param  [in]
2143  */
2144 //--------------------------------------------------------------------------
2145 int
2146 CicoSystemConfig::getAppKindIdbyName(const string & name)
2147 {
2148     const CicoSCAppKindConf* conf = NULL;
2149     conf = findAppKindConfbyName(name);
2150     if (NULL == conf) {
2151         return -1;
2152     }
2153
2154     return conf->id;
2155 }
2156
2157 //--------------------------------------------------------------------------
2158 /**
2159  *  @brief
2160  *
2161  *  @param  [in]
2162  */
2163 //--------------------------------------------------------------------------
2164 int
2165 CicoSystemConfig::getCategoryIdbyName(const string & name)
2166 {
2167     const CicoSCCategoryConf* conf = NULL;
2168     conf = findCategoryConfbyName(name);
2169     if (NULL == conf) {
2170         return -1;
2171     }
2172
2173     return conf->id;
2174 }
2175
2176 //--------------------------------------------------------------------------
2177 /**
2178  *  @brief  get category config object class
2179  *
2180  *  @param  [in]
2181  */
2182 //--------------------------------------------------------------------------
2183 const CicoSCCategoryConf*
2184 CicoSystemConfig::getCategoryObjbyCaategoryID(int id)
2185 {
2186     if (-1 == id) {
2187         return NULL;
2188     }
2189     vector<CicoSCCategoryConf*>::const_iterator itr;
2190     itr = m_categoryConfList.begin();
2191     for (; itr != m_categoryConfList.end(); ++itr) {
2192         const CicoSCCategoryConf* conf = (*itr);
2193         if (id == conf->id) {
2194             //return const_cast<CicoSCCategoryConf*>(itr->pointer);
2195             return conf;
2196         }
2197     }
2198     return NULL;
2199 }
2200
2201 //--------------------------------------------------------------------------
2202 /**
2203  *  @brief  array xml tree to vector<int>
2204  *
2205  *  @param  [in]
2206  */
2207 //--------------------------------------------------------------------------
2208 CicoSCVehicleInfoConf*
2209 CicoSystemConfig::getVehicleInfoConf(void)
2210 {
2211     return m_vehicleInfoConf;
2212 }
2213
2214 //--------------------------------------------------------------------------
2215 /**
2216  *  @brief  array xml tree to vector<int>
2217  *
2218  *  @param  [in]
2219  */
2220 //--------------------------------------------------------------------------
2221 void getArray(ptree& t, vector<int>& vec)
2222 {
2223     vec.clear();
2224     BOOST_FOREACH (const ptree::value_type& child, t) {
2225         const int value = lexical_cast<int>(child.second.data());
2226         vec.push_back(value);
2227     }
2228 }
2229
2230 //--------------------------------------------------------------------------
2231 /**
2232  *  @brief  get state number from id key
2233  *
2234  *  @param  [in]
2235  */
2236 //--------------------------------------------------------------------------
2237 short CicoSystemConfig::getRoleStt(const string& key)
2238 {
2239     if ((CicoSCRoleConf*)NULL == m_roleConf) {
2240         return ICO_SYC_ROLE_CONF_DEF;
2241     }
2242     short r;
2243     map<string, short>::iterator p;
2244     p = m_roleConf->m_stt.find(key);
2245     if (p == m_roleConf->m_stt.end()) {
2246         r = m_roleConf->m_def;
2247     }
2248     else {
2249         r = p->second;
2250     }
2251     return r;
2252 }
2253
2254 //--------------------------------------------------------------------------
2255 /**
2256  *  @brief  array xml tree to vector<int>
2257  *
2258  *  @param  [in]
2259  */
2260 //--------------------------------------------------------------------------
2261 void CicoSystemConfig::createRoleConf(const ptree& root)
2262 {
2263     m_roleConf = new CicoSCRoleConf();
2264
2265     ptree roles = root.get_child("systemconfig.on_screen_roles");
2266     BOOST_FOREACH (const ptree::value_type& role, roles) {
2267         optional<string>  id;
2268         optional<int>     stt;
2269         id = role.second.get_optional<string>("<xmlattr>.id");
2270         if (false == id.is_initialized()) {
2271             continue;
2272         }
2273         stt =  role.second.get_optional<int>("<xmlattr>.state");
2274         if (false == stt.is_initialized()) {
2275             continue;
2276         }
2277         string v_key = id.get();
2278         int v_stt = stt.get();
2279         if (0 == v_key.compare(ICO_SYC_ROLE_CONF_DEF_STR)) { // default define
2280             m_roleConf->m_def = (short)v_stt;
2281         }
2282         else if (0 == v_key.compare(ICO_SYC_ROLE_CONF_RST_STR)) { // reset event number
2283             m_roleConf->m_rst = (short)v_stt;
2284         }
2285         else {
2286             m_roleConf->m_stt.insert(pair<string, short>(v_key, (short)v_stt));
2287         }
2288     }
2289     m_roleConf->dumpConf();
2290 }
2291
2292 //--------------------------------------------------------------------------
2293 /**
2294  *  @brief  position OnScreen Config
2295  *
2296  *  @param  [in]
2297  */
2298 //--------------------------------------------------------------------------
2299 void CicoSystemConfig::createPositionOSConf(const ptree& root)
2300 {
2301     ptree posc = root.get_child("systemconfig.on_screen_position");
2302
2303     int x = ICO_SYC_ONSCREEN_WINDOW_START_X;
2304     int y = ICO_SYC_ONSCREEN_WINDOW_START_Y;
2305     int w = ICO_SYC_ONSCREEN_WINDOW_WIDTH;
2306     int h = ICO_SYC_ONSCREEN_WINDOW_HEIGHT;
2307
2308     optional<string> optsx = posc.get_optional<string>("x");
2309     if (true == optsx.is_initialized()) {
2310         x = atoi(optsx.get().c_str());
2311     }
2312
2313     optional<string> optsy = posc.get_optional<string>("y");
2314     if (true == optsy.is_initialized()) {
2315         y = atoi(optsy.get().c_str());
2316     }
2317
2318     optional<string> optsw = posc.get_optional<string>("w");
2319     if (true == optsw.is_initialized()) {
2320         w = atoi(optsw.get().c_str());
2321     }
2322
2323     optional<string> optsh = posc.get_optional<string>("h");
2324     if (true == optsh.is_initialized()) {
2325         h = atoi(optsh.get().c_str());
2326     }
2327
2328     m_positionOSConf = new CicoSCPositionOSConf(x, y, w, h);
2329     m_positionOSConf->dumpConf();
2330 }
2331
2332 // vim:set expandtab ts=4 sw=4: