2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
18 #include "CicoAilItems.h"
20 #include "CicoSystemConfig.h"
21 #include "CicoLibString.h"
28 CicoAilItems::CicoAilItems()
37 * @param pkg package name(appid) by ail information data
38 * @param icon icon path and file name by ail information data
39 * @param nam name by ail information data
40 * @param ctgry category by ail information data
41 * @param exe exec path by ail information data
42 * @param cateforys environ file data
44 CicoAilItems::CicoAilItems(const char* pkg, const char* icon,
45 const char* nam, const char* ctgry,
46 const char* typ, const char* exe,
47 const std::string categorys, bool ndisp)
51 setup(pkg, icon, nam, ctgry, typ, exe, categorys, ndisp);
55 CicoAilItems::CicoAilItems(const CicoAilItems &s)
57 m_appid = s.m_appid; // PACKAGE NAME
58 m_icon = s.m_icon; // ICON
59 m_name = s.m_name; // NAME
60 m_execPath = s.m_execPath; // EXEC
61 m_type = s.m_type; // TYPE
63 m_categories = s.m_categories; // CATEGORIES
65 m_nodeID = s.m_nodeID; // "run=xxx" xxx change to id
66 m_kindID = s.m_kindID; // "kind=xxx" xxx change to id
67 m_categoryID = s.m_categoryID; // "category=xxx" xxx change to id
69 m_display = s.m_display; //
71 m_displayZone = s.m_displayZone; // display zone number
72 m_soundZone = s.m_soundZone; // sound zone number
74 m_inputDev = s.m_inputDev; // input device number
75 m_switch = s.m_switch;
76 m_noIcon = s.m_noIcon;
77 m_animation = s.m_animation;
78 m_animationTime = s.m_animationTime;
79 m_invisibleCPU = s.m_invisibleCPU;
80 m_memnuOverlap = s.m_memnuOverlap;
81 m_autoStart = s.m_autoStart; // auto start flag
84 m_location = s.m_location;
85 m_resumeShow = s.m_resumeShow;
91 CicoAilItems::~CicoAilItems()
99 void CicoAilItems::init()
102 m_appid.clear(); // PACKAGE NAME
103 m_icon.clear(); // ICON
104 m_name.clear(); // NAME
105 m_execPath.clear(); // EXEC
106 m_type.clear(); // TYPE
108 m_categories.clear(); // CATEGORIES
110 const CicoSCDefaultConf* oCSCDC;
111 oCSCDC = CicoSystemConfig::getInstance()->getDefaultConf();
112 if (NULL != oCSCDC) {
113 ICO_DBG("CicoAilItems::init base CicoSCDefaultConf");
114 m_nodeID = oCSCDC->node;
115 m_kindID = oCSCDC->appkind;
116 m_categoryID = oCSCDC->category;
118 m_display = oCSCDC->display;
119 m_layer = oCSCDC->layer;
120 m_displayZone = oCSCDC->displayzone;
122 m_sound = oCSCDC->sound;
123 m_soundZone = oCSCDC->soundzone;
125 m_inputDev = oCSCDC->inputdev;
126 m_switch = oCSCDC->inputsw;
129 ICO_DBG("CicoAilItems::init base define");
130 m_nodeID = DINITm_nodeID; // "run=xxx" xxx change to id
131 m_kindID = DINITm_kindID; // "kind=xxx" xxx change to id
132 m_categoryID = DINITm_categoryID; // "category=xxx" xxx change to id
134 m_display = DINITm_display; //
135 m_layer = DINITm_layer;
136 m_displayZone = DINITm_displayZone; // display zone
138 m_soundZone = DINITm_soundZone; // sound zone
139 m_sound = DINITm_sound;
141 m_inputDev = DINITm_inputDev; // input device
142 m_switch = DINITm_switch;
147 m_animationTime = DINITm_animationTime;
148 m_invisibleCPU = DINITm_invisibleCPU;
149 m_memnuOverlap = false;
150 m_autoStart = false; // auto start flag
154 m_resumeShow = false;
159 * @param pkg package name(appid) by ail information data
160 * @param icon icon path and file name by ail information data
161 * @param nam name by ail information data
162 * @param ctgry category by ail information data
163 * @param exe exec path by ail information data
164 * @param cateforys environ file data
166 void CicoAilItems::setup(const char* pkg, const char* icon,
167 const char* nam, const char* ctgry,
168 const char* typ, const char* exe,
169 std::string categorys, bool ndisp)
173 ICO_DBG("package name=%s", pkg? pkg: "(NULL)");
178 ICO_DBG("icon path=%s", icon? icon: "(NULL)");
183 ICO_DBG("name=%s", nam? nam: "(NULL)");
187 m_execPath.assign(exe);
188 ICO_DBG("exec path=%s", exe? exe: "(NULL)");
193 ICO_DBG("type=%s", typ? typ: "(NULL)");
196 categoryParse(categorys);
200 const string s_run("run");
201 const string s_kind("kind");
202 const string s_category("category");
203 const string s_display("display");
204 const string s_layer("layer");
205 const string s_dispzone("dispzone");
206 const string s_sound("sound");
207 const string s_input("input");
208 const string s_NoDisplay("NoDisplay");
209 const string s_Animation("Animation");
210 const string s_invisiblecpu("invisiblecpu");
211 const string s_noconfigure("noconfigure");
212 const string s_menuoverlap("menuoverlap");
213 const string s_auto("auto");
214 const string s_noauto("noauto");
216 const string s_soundzone("soundzone");
217 const string s_Animation_time("Animation_time");
220 * @brief category string parse
221 * @parm category string data split code ";"
223 void CicoAilItems::categoryParse(const std::string categorys)
226 if (categorys.empty()) {
227 ICO_TRA("end no category");
231 split(categorys, ';', x);
232 vector<string>::iterator it = x.begin(); // iterator
237 string soundZoneName;
243 dispZoneName.clear();
245 soundZoneName.clear();
246 inputDevName.clear();
249 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
251 ICO_DBG("category def size = %d", x.size());
252 for (it = x.begin(); it != x.end(); it++) {
255 if (0 == strncasecmp(it->c_str(), s_run.c_str(), s_run.size())) {
256 if (true == categoryParseRun(*it)) {
257 ICO_DBG("Parse OK %s", it->c_str());
263 if (0 == strncasecmp(it->c_str(), s_kind.c_str(), s_kind.size())) {
264 if (true == categoryParseKind(*it)) {
265 ICO_DBG("Parse OK %s", it->c_str());
271 if (0 == strncasecmp(it->c_str(), s_category.c_str(),
272 s_category.size())) {
273 if (true == categoryParseCategory(*it)) {
274 ICO_DBG("Parse OK %s", it->c_str());
280 if (0 == strncasecmp(it->c_str(), s_display.c_str(),
282 if (true == categoryParseGetValue(*it, s_display, displayName)) {
283 ICO_DBG("Parse OK %s", it->c_str());
289 if (0 == strncasecmp(it->c_str(), s_layer.c_str(), s_layer.size())) {
290 if (true == categoryParseGetValue(*it, s_layer, layerName)) {
291 ICO_DBG("Parse OK %s", it->c_str());
297 if (0 == strncasecmp(it->c_str(), s_dispzone.c_str(),
298 s_dispzone.size())) {
299 if (true == categoryParseGetValue(*it, s_dispzone, dispZoneName)) {
300 ICO_DBG("Parse OK %s", it->c_str());
306 if (0 == strncasecmp(it->c_str(), s_soundzone.c_str(),
307 s_soundzone.size())) {
308 if (true == categoryParseGetValue(*it, s_soundzone,
310 ICO_DBG("Parse OK %s", it->c_str());
314 if (0 == strncasecmp(it->c_str(), s_sound.c_str(), s_sound.size())) {
315 if (true == categoryParseGetValue(*it, s_sound, soundName)) {
316 ICO_DBG("Parse OK %s", it->c_str());
322 if (0 == strncasecmp(it->c_str(), s_input.c_str(), s_input.size())) {
323 if (true == categoryParseGetValue(*it, s_input, inputDevName)) {
324 ICO_DBG("Parse OK %s", it->c_str());
328 // TODO mk_k not get switchName
330 // TODO mk_k not get switchName
333 if (0 == strncasecmp(it->c_str(), s_NoDisplay.c_str(),
334 s_NoDisplay.size())) {
335 if (true == categoryParseNodisplay(*it)) {
336 ICO_DBG("Parse OK %s", it->c_str());
341 // Animation / Animation_time
342 if (0 == strncasecmp(it->c_str(), s_Animation.c_str(),
343 s_Animation.size())) {
344 if (true == categoryParseAnimation(*it)) {
345 ICO_DBG("Parse OK %s", it->c_str());
351 if (0 == strncasecmp(it->c_str(), s_invisiblecpu.c_str(),
352 s_invisiblecpu.size())) {
353 if (true == categoryParseInvisiblecpu(*it)) {
354 ICO_DBG("Parse OK %s", it->c_str());
360 if (0 == strncasecmp(it->c_str(), s_noconfigure.c_str(),
361 s_noconfigure.size())) {
362 if (true == categoryParseNoconfigure(*it)) {
363 ICO_DBG("Parse OK %s", it->c_str());
369 if (0 == strncasecmp(it->c_str(), s_menuoverlap.c_str(),
370 s_menuoverlap.size())) {
371 if (true == categoryParseMenuoverlap(*it)) {
372 ICO_DBG("Parse OK %s", it->c_str());
378 if (0 == strncasecmp(it->c_str(), s_auto.c_str(), s_auto.size())) {
379 if (true == categoryParseAuto(*it)) {
380 ICO_DBG("Parse OK %s", it->c_str());
386 if (0 == strncasecmp(it->c_str(), s_noauto.c_str(),
388 if (true == categoryParseNoauto(*it)) {
389 ICO_DBG("Parse OK %s", it->c_str());
394 int categoryID = CSCSC->getCategoryIdbyName(*it);
395 const char* ttt = it->c_str()? it->c_str(): "(NULL)";
396 ICO_DBG("Category %s->%d", ttt, categoryID);
397 if (-1 != categoryID) {
398 ICO_DBG("Category %d -> %d(%s)", m_categoryID, categoryID, ttt);
399 m_categoryID = categoryID;
403 ICO_DBG("Parse UNKOWN %s", it->c_str());
405 categoryGetDisplay(displayName, layerName, dispZoneName);
406 categoryGetSound(soundName, soundZoneName);
407 categoryGetInput(inputDevName, switchName);
412 * @brief category string parse
413 * @param category string
414 * @retval true parse success
415 * @retval false parse fail
417 bool CicoAilItems::categoryParseRun(const string& s)
420 const char* ps = s.c_str();
421 int c = s_run.size();
427 // TODO mk_k START getHostID(..) request order
428 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
429 int nodeID = CSCSC->getNodeIdbyName(&ps[c+1]);
430 // TODO mk_k int nodeID = -1;
431 // TODO mk_k int nodeID = CSCSC->getHostID(&ps[c+1]);
432 // TODO mk_k END getHostID(..) request order
438 ICO_TRA("end %d", m_nodeID);
443 * @brief category string parse
444 * @param category string
445 * @retval true parse success
446 * @retval false parse fail
448 bool CicoAilItems::categoryParseKind(const string& s)
451 const char* ps = s.c_str();
452 int c = s_kind.size();
457 // "kind=xxx" xxx change to id
458 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
459 int kindID = CSCSC->getAppKindIdbyName(&ps[c+1]);
465 ICO_TRA("end %d", m_kindID);
470 * @brief category string parse
471 * @param category string
472 * @retval true parse success
473 * @retval false parse fail
475 bool CicoAilItems::categoryParseCategory(const string& s)
478 const char* ps = s.c_str();
479 int c = s_category.size();
482 return false; // not "category=xxx"
484 // "category=xxx" xxx change to id
485 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
486 int categoryID = CSCSC->getCategoryIdbyName(&ps[c+1]);
487 if (categoryID==-1) {
489 return false; // unkown category xxx
491 m_categoryID = categoryID;
492 ICO_TRA("end %d", m_categoryID);
498 * @param s "key=value" string
499 * @param k key string
500 * @param val store value
501 * @retval true get value success
502 * @retval false get not good
504 bool CicoAilItems::categoryParseGetValue(const std::string& s,
505 const std::string& k,
508 ICO_TRA("start, %s, %s", s.c_str(), k.c_str());
509 const char* ps = s.c_str();
512 #if 0 // TODO mk_k x!?
514 #endif // TODO mk_k x!?
516 #if 0 // TODO mk_k x!?
518 #endif // TODO mk_k x!?
521 #if 0 // TODO mk_k .[0-9] !?
522 else if (('.' == ps[c]) &&
523 (0 != isdigit((int)ps[c+1])) &&
525 x = (int) ps[c+1] - '0';
529 #endif // TODO mk_k .[0-9] !?
535 ICO_TRA("end %s", val.c_str());
541 * @param disp display key name
542 * @param layer display layer key name
543 * @param zone display zone key name
544 * @retval true parse success
545 * @retval false parse fail
547 bool CicoAilItems::categoryGetDisplay(const string& disp,
552 if (true == disp.empty()) {
553 ICO_TRA("end not get display's data");
557 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
558 m_display = CSCSC->getDisplayIdbyName(disp);
559 ICO_DBG("display %s->%d", disp.c_str(), m_display);
560 if (false == layer.empty()) {
561 m_layer = CSCSC->getLayerIdfbyName(disp, layer);
562 ICO_DBG("layer %s, %s->%d", disp.c_str(), layer.c_str(), m_layer);
564 if (false == zone.empty()) {
565 m_displayZone = CSCSC->getDizplayZoneIdbyName(disp, zone);
566 ICO_DBG("zone %s, %s->%d", disp.c_str(), zone.c_str(), m_displayZone);
568 ICO_TRA("end d:%d l:%d z:%d", m_display, m_layer, m_displayZone);
573 * @brief get sound config data
574 * @param sound name key
575 * @param soundZone name key
576 * @retval true get data
577 * @retval false param fail
579 bool CicoAilItems::categoryGetSound(const string& sound, const string& zone)
582 if (true == sound.empty()) {
583 ICO_TRA("end not get sound's data");
587 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
588 m_sound = CSCSC->getSoundIdbyName(sound);
589 ICO_DBG("sound %s->%d", sound.c_str(), m_sound);
590 if (false == zone.empty()) {
591 m_soundZone = CSCSC->getSoundZoneIdbyName(sound, zone);
592 ICO_DBG("zone %s, %s->%d", sound.c_str(), zone.c_str(), m_soundZone);
594 ICO_TRA("end s:%d z:%d", m_sound, m_soundZone);
598 bool CicoAilItems::categoryGetInput(const string& inputDev,
602 if (true == inputDev.empty()) {
603 ICO_TRA("end not get input Device's data");
607 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
608 m_sound = CSCSC->getInputDevIdbyName(inputDev);
609 ICO_DBG("sound %s->%d", inputDev.c_str(), m_sound);
610 if (false == sw.empty()) {
611 m_switch = CSCSC->getSwitchIdbyName(inputDev, sw);
612 ICO_DBG("switch %s, %s->%d", inputDev.c_str(), sw.c_str(), m_switch);
614 ICO_TRA("end idev:%d i:%d", m_inputDev, m_switch);
619 * @brief category string parse
620 * @param category string
621 * @retval true parse success
622 * @retval false parse fail
624 bool CicoAilItems::categoryParseNodisplay(const string& s)
627 const char* ps = s.c_str();
628 int c = s_NoDisplay.size();
631 return false; // not "NoDisplay=true/false"
633 if (0 == strcasecmp(&ps[c+1], "false")) {
639 ICO_TRA("end %s", m_noIcon? "true": "false");
644 * @brief category string parse
645 * @param category string
646 * @retval true parse success
647 * @retval false parse fail
649 bool CicoAilItems::categoryParseAnimation(const string& s)
652 const char* ps = s.c_str();
653 int c = s_Animation_time.size();
654 bool b_at = false; // animation time flag off
655 if (0 == strncasecmp(ps, s_Animation_time.c_str(), c)) {
656 b_at = true; // flag on
659 c = s_Animation.size(); // not Animation_time
663 return false; // not "Animation=xxx" / "Animation_time=xxx"
667 m_animationTime = (int)strtol(&ps[c+1], (char **)0, 0);
671 m_animation = &ps[c+1];
678 * @brief category string parse
679 * @param category string
680 * @retval true parse success
681 * @retval false parse fail
683 bool CicoAilItems::categoryParseInvisiblecpu(const string& s)
686 const char* ps = s.c_str();
687 int c = s_invisiblecpu.size();
690 return false; // not "invisibluecpu=xxx"
692 if (0 == strcasecmp(&ps[c+1], "yes")) {
693 m_invisibleCPU = 100;
695 else if (0 != strcasecmp(&ps[c+1], "no")) {
696 m_invisibleCPU = (int)strtol(&ps[c+1], (char **)0, 0);
701 ICO_TRA("end %s,%d", &ps[c+1], m_invisibleCPU);
706 * @brief category string parse
707 * @param category string
708 * @retval true parse success
709 * @retval false parse fail
711 bool CicoAilItems::categoryParseNoconfigure(const string&)
715 // m_noconfigure = true;
722 * @brief category string parse
723 * @param category string
724 * @retval true parse success
725 * @retval false parse fail
727 bool CicoAilItems::categoryParseMenuoverlap(const string&)
730 m_memnuOverlap = true;
736 * @brief category string parse
737 * @param category string
738 * @retval true parse success
739 * @retval false parse fail
741 bool CicoAilItems::categoryParseAuto(const string&)
750 * @brief category string parse
751 * @param category string
752 * @retval true parse success
753 * @retval false parse fail
755 bool CicoAilItems::categoryParseNoauto(const string&)
762 // vim:set expandtab ts=4 sw=4: