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