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()
101 m_appid.clear(); // PACKAGE NAME
102 m_icon.clear(); // ICON
103 m_name.clear(); // NAME
104 m_execPath.clear(); // EXEC
105 m_type.clear(); // TYPE
107 m_categories.clear(); // CATEGORIES
109 const CicoSCDefaultConf* oCSCDC;
110 oCSCDC = CicoSystemConfig::getInstance()->getDefaultConf();
111 if (NULL != oCSCDC) {
112 ICO_DBG("CicoAilItems::init base CicoSCDefaultConf");
113 m_nodeID = oCSCDC->node;
114 m_kindID = oCSCDC->appkind;
115 m_categoryID = oCSCDC->category;
117 m_display = oCSCDC->display;
118 m_layer = oCSCDC->layer;
119 m_displayZone = oCSCDC->displayzone;
121 m_sound = oCSCDC->sound;
122 m_soundZone = oCSCDC->soundzone;
124 m_inputDev = oCSCDC->inputdev;
125 m_switch = oCSCDC->inputsw;
128 ICO_DBG("CicoAilItems::init base define");
129 m_nodeID = DINITm_nodeID; // "run=xxx" xxx change to id
130 m_kindID = DINITm_kindID; // "kind=xxx" xxx change to id
131 m_categoryID = DINITm_categoryID; // "category=xxx" xxx change to id
133 m_display = DINITm_display; //
134 m_layer = DINITm_layer;
135 m_displayZone = DINITm_displayZone; // display zone
137 m_soundZone = DINITm_soundZone; // sound zone
138 m_sound = DINITm_sound;
140 m_inputDev = DINITm_inputDev; // input device
141 m_switch = DINITm_switch;
146 m_animationTime = DINITm_animationTime;
147 m_invisibleCPU = DINITm_invisibleCPU;
148 m_memnuOverlap = false;
149 m_autoStart = false; // auto start flag
153 m_resumeShow = false;
158 * @param pkg package name(appid) by ail information data
159 * @param icon icon path and file name by ail information data
160 * @param nam name by ail information data
161 * @param ctgry category by ail information data
162 * @param exe exec path by ail information data
163 * @param cateforys environ file data
165 void CicoAilItems::setup(const char* pkg, const char* icon,
166 const char* nam, const char* ctgry,
167 const char* typ, const char* exe,
168 std::string categorys, bool ndisp)
172 ICO_DBG("package name=%s", pkg? pkg: "(NULL)");
177 ICO_DBG("icon path=%s", icon? icon: "(NULL)");
182 ICO_DBG("name=%s", nam? nam: "(NULL)");
186 m_execPath.assign(exe);
187 ICO_DBG("exec path=%s", exe? exe: "(NULL)");
192 ICO_DBG("type=%s", typ? typ: "(NULL)");
195 categoryParse(categorys);
199 const string s_run("run");
200 const string s_kind("kind");
201 const string s_category("category");
202 const string s_display("display");
203 const string s_layer("layer");
204 const string s_dispzone("dispzone");
205 const string s_sound("sound");
206 const string s_input("input");
207 const string s_NoDisplay("NoDisplay");
208 const string s_Animation("Animation");
209 const string s_invisiblecpu("invisiblecpu");
210 const string s_noconfigure("noconfigure");
211 const string s_menuoverlap("menuoverlap");
212 const string s_auto("auto");
213 const string s_noauto("noauto");
215 const string s_soundzone("soundzone");
216 const string s_Animation_time("Animation_time");
219 * @brief category string parse
220 * @parm category string data split code ";"
222 void CicoAilItems::categoryParse(const std::string categorys)
225 if (categorys.empty()) {
226 ICO_TRA("end no category");
230 split(categorys, ';', x);
231 vector<string>::iterator it = x.begin(); // iterator
236 string soundZoneName;
242 dispZoneName.clear();
244 soundZoneName.clear();
245 inputDevName.clear();
248 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
250 ICO_DBG("category def size = %d", x.size());
251 for (it = x.begin(); it != x.end(); it++) {
254 if (0 == strncasecmp(it->c_str(), s_run.c_str(), s_run.size())) {
255 if (true == categoryParseRun(*it)) {
256 ICO_DBG("Parse OK %s", it->c_str());
262 if (0 == strncasecmp(it->c_str(), s_kind.c_str(), s_kind.size())) {
263 if (true == categoryParseKind(*it)) {
264 ICO_DBG("Parse OK %s", it->c_str());
270 if (0 == strncasecmp(it->c_str(), s_category.c_str(),
271 s_category.size())) {
272 if (true == categoryParseCategory(*it)) {
273 ICO_DBG("Parse OK %s", it->c_str());
279 if (0 == strncasecmp(it->c_str(), s_display.c_str(),
281 if (true == categoryParseGetValue(*it, s_display, displayName)) {
282 ICO_DBG("Parse OK %s", it->c_str());
288 if (0 == strncasecmp(it->c_str(), s_layer.c_str(), s_layer.size())) {
289 if (true == categoryParseGetValue(*it, s_layer, layerName)) {
290 ICO_DBG("Parse OK %s", it->c_str());
296 if (0 == strncasecmp(it->c_str(), s_dispzone.c_str(),
297 s_dispzone.size())) {
298 if (true == categoryParseGetValue(*it, s_dispzone, dispZoneName)) {
299 ICO_DBG("Parse OK %s", it->c_str());
305 if (0 == strncasecmp(it->c_str(), s_soundzone.c_str(),
306 s_soundzone.size())) {
307 if (true == categoryParseGetValue(*it, s_soundzone,
309 ICO_DBG("Parse OK %s", it->c_str());
313 if (0 == strncasecmp(it->c_str(), s_sound.c_str(), s_sound.size())) {
314 if (true == categoryParseGetValue(*it, s_sound, soundName)) {
315 ICO_DBG("Parse OK %s", it->c_str());
321 if (0 == strncasecmp(it->c_str(), s_input.c_str(), s_input.size())) {
322 if (true == categoryParseGetValue(*it, s_input, inputDevName)) {
323 ICO_DBG("Parse OK %s", it->c_str());
327 // TODO mk_k not get switchName
329 // TODO mk_k not get switchName
332 if (0 == strncasecmp(it->c_str(), s_NoDisplay.c_str(),
333 s_NoDisplay.size())) {
334 if (true == categoryParseNodisplay(*it)) {
335 ICO_DBG("Parse OK %s", it->c_str());
340 // Animation / Animation_time
341 if (0 == strncasecmp(it->c_str(), s_Animation.c_str(),
342 s_Animation.size())) {
343 if (true == categoryParseAnimation(*it)) {
344 ICO_DBG("Parse OK %s", it->c_str());
350 if (0 == strncasecmp(it->c_str(), s_invisiblecpu.c_str(),
351 s_invisiblecpu.size())) {
352 if (true == categoryParseInvisiblecpu(*it)) {
353 ICO_DBG("Parse OK %s", it->c_str());
359 if (0 == strncasecmp(it->c_str(), s_noconfigure.c_str(),
360 s_noconfigure.size())) {
361 if (true == categoryParseNoconfigure(*it)) {
362 ICO_DBG("Parse OK %s", it->c_str());
368 if (0 == strncasecmp(it->c_str(), s_menuoverlap.c_str(),
369 s_menuoverlap.size())) {
370 if (true == categoryParseMenuoverlap(*it)) {
371 ICO_DBG("Parse OK %s", it->c_str());
377 if (0 == strncasecmp(it->c_str(), s_auto.c_str(), s_auto.size())) {
378 if (true == categoryParseAuto(*it)) {
379 ICO_DBG("Parse OK %s", it->c_str());
385 if (0 == strncasecmp(it->c_str(), s_noauto.c_str(),
387 if (true == categoryParseNoauto(*it)) {
388 ICO_DBG("Parse OK %s", it->c_str());
393 int categoryID = CSCSC->getCategoryIdbyName(*it);
394 const char* ttt = it->c_str()? it->c_str(): "(NULL)";
395 ICO_DBG("Category %s->%d", ttt, categoryID);
396 if (-1 != categoryID) {
397 ICO_DBG("Category %d -> %d(%s)", m_categoryID, categoryID, ttt);
398 m_categoryID = categoryID;
402 ICO_DBG("Parse UNKNOWN %s", it->c_str());
404 categoryGetDisplay(displayName, layerName, dispZoneName);
405 categoryGetSound(soundName, soundZoneName);
406 categoryGetInput(inputDevName, switchName);
411 * @brief category string parse
412 * @param category string
413 * @retval true parse success
414 * @retval false parse fail
416 bool CicoAilItems::categoryParseRun(const string& s)
419 const char* ps = s.c_str();
420 int c = s_run.size();
426 // TODO mk_k START getHostID(..) request order
427 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
428 int nodeID = CSCSC->getNodeIdbyName(&ps[c+1]);
429 // TODO mk_k int nodeID = -1;
430 // TODO mk_k int nodeID = CSCSC->getHostID(&ps[c+1]);
431 // TODO mk_k END getHostID(..) request order
437 ICO_TRA("end %d", m_nodeID);
442 * @brief category string parse
443 * @param category string
444 * @retval true parse success
445 * @retval false parse fail
447 bool CicoAilItems::categoryParseKind(const string& s)
450 const char* ps = s.c_str();
451 int c = s_kind.size();
456 // "kind=xxx" xxx change to id
457 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
458 int kindID = CSCSC->getAppKindIdbyName(&ps[c+1]);
464 ICO_TRA("end %d", m_kindID);
469 * @brief category string parse
470 * @param category string
471 * @retval true parse success
472 * @retval false parse fail
474 bool CicoAilItems::categoryParseCategory(const string& s)
477 const char* ps = s.c_str();
478 int c = s_category.size();
481 return false; // not "category=xxx"
483 // "category=xxx" xxx change to id
484 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
485 int categoryID = CSCSC->getCategoryIdbyName(&ps[c+1]);
486 if (categoryID==-1) {
488 return false; // unkown category xxx
490 m_categoryID = categoryID;
491 ICO_TRA("end %d", m_categoryID);
497 * @param s "key=value" string
498 * @param k key string
499 * @param val store value
500 * @retval true get value success
501 * @retval false get not good
503 bool CicoAilItems::categoryParseGetValue(const std::string& s,
504 const std::string& k,
507 ICO_TRA("start, %s, %s", s.c_str(), k.c_str());
508 const char* ps = s.c_str();
511 #if 0 // TODO mk_k x!?
513 #endif // TODO mk_k x!?
515 #if 0 // TODO mk_k x!?
517 #endif // TODO mk_k x!?
520 #if 0 // TODO mk_k .[0-9] !?
521 else if (('.' == ps[c]) &&
522 (0 != isdigit((int)ps[c+1])) &&
524 x = (int) ps[c+1] - '0';
528 #endif // TODO mk_k .[0-9] !?
534 ICO_TRA("end %s", val.c_str());
540 * @param disp display key name
541 * @param layer display layer key name
542 * @param zone display zone key name
543 * @retval true parse success
544 * @retval false parse fail
546 bool CicoAilItems::categoryGetDisplay(const string& disp,
551 if (true == disp.empty()) {
552 ICO_TRA("end not get display's data");
556 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
557 m_display = CSCSC->getDisplayIdbyName(disp);
558 ICO_DBG("display %s->%d", disp.c_str(), m_display);
559 if (false == layer.empty()) {
560 m_layer = CSCSC->getLayerIdfbyName(disp, layer);
561 ICO_DBG("layer %s, %s->%d", disp.c_str(), layer.c_str(), m_layer);
563 if (false == zone.empty()) {
564 m_displayZone = CSCSC->getDizplayZoneIdbyName(disp, zone);
565 ICO_DBG("zone %s, %s->%d", disp.c_str(), zone.c_str(), m_displayZone);
567 ICO_TRA("end d:%d l:%d z:%d", m_display, m_layer, m_displayZone);
572 * @brief get sound config data
573 * @param sound name key
574 * @param soundZone name key
575 * @retval true get data
576 * @retval false param fail
578 bool CicoAilItems::categoryGetSound(const string& sound, const string& zone)
581 if (true == sound.empty()) {
582 ICO_TRA("end not get sound's data");
586 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
587 m_sound = CSCSC->getSoundIdbyName(sound);
588 ICO_DBG("sound %s->%d", sound.c_str(), m_sound);
589 if (false == zone.empty()) {
590 m_soundZone = CSCSC->getSoundZoneIdbyName(sound, zone);
591 ICO_DBG("zone %s, %s->%d", sound.c_str(), zone.c_str(), m_soundZone);
593 ICO_TRA("end s:%d z:%d", m_sound, m_soundZone);
597 bool CicoAilItems::categoryGetInput(const string& inputDev,
601 if (true == inputDev.empty()) {
602 ICO_TRA("end not get input Device's data");
606 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
607 m_inputDev = CSCSC->getInputDevIdbyName(inputDev);
608 ICO_DBG("sound %s->%d", inputDev.c_str(), m_sound);
609 if (false == sw.empty()) {
610 m_switch = CSCSC->getSwitchIdbyName(inputDev, sw);
611 ICO_DBG("switch %s, %s->%d", inputDev.c_str(), sw.c_str(), m_switch);
613 ICO_TRA("end idev:%d i:%d", m_inputDev, m_switch);
618 * @brief category string parse
619 * @param category string
620 * @retval true parse success
621 * @retval false parse fail
623 bool CicoAilItems::categoryParseNodisplay(const string& s)
626 const char* ps = s.c_str();
627 int c = s_NoDisplay.size();
630 return false; // not "NoDisplay=true/false"
632 if (0 == strcasecmp(&ps[c+1], "false")) {
638 ICO_TRA("end %s", m_noIcon? "true": "false");
643 * @brief category string parse
644 * @param category string
645 * @retval true parse success
646 * @retval false parse fail
648 bool CicoAilItems::categoryParseAnimation(const string& s)
651 const char* ps = s.c_str();
652 int c = s_Animation_time.size();
653 bool b_at = false; // animation time flag off
654 if (0 == strncasecmp(ps, s_Animation_time.c_str(), c)) {
655 b_at = true; // flag on
658 c = s_Animation.size(); // not Animation_time
662 return false; // not "Animation=xxx" / "Animation_time=xxx"
666 m_animationTime = (int)strtol(&ps[c+1], (char **)0, 0);
670 m_animation = &ps[c+1];
677 * @brief category string parse
678 * @param category string
679 * @retval true parse success
680 * @retval false parse fail
682 bool CicoAilItems::categoryParseInvisiblecpu(const string& s)
685 const char* ps = s.c_str();
686 int c = s_invisiblecpu.size();
689 return false; // not "invisibluecpu=xxx"
691 if (0 == strcasecmp(&ps[c+1], "yes")) {
692 m_invisibleCPU = 100;
694 else if (0 != strcasecmp(&ps[c+1], "no")) {
695 m_invisibleCPU = (int)strtol(&ps[c+1], (char **)0, 0);
700 ICO_TRA("end %s,%d", &ps[c+1], m_invisibleCPU);
705 * @brief category string parse
706 * @param category string
707 * @retval true parse success
708 * @retval false parse fail
710 bool CicoAilItems::categoryParseNoconfigure(const string&)
714 // m_noconfigure = true;
721 * @brief category string parse
722 * @param category string
723 * @retval true parse success
724 * @retval false parse fail
726 bool CicoAilItems::categoryParseMenuoverlap(const string&)
729 m_memnuOverlap = true;
735 * @brief category string parse
736 * @param category string
737 * @retval true parse success
738 * @retval false parse fail
740 bool CicoAilItems::categoryParseAuto(const string&)
749 * @brief category string parse
750 * @param category string
751 * @retval true parse success
752 * @retval false parse fail
754 bool CicoAilItems::categoryParseNoauto(const string&)
761 // vim:set expandtab ts=4 sw=4: