lib/notification/Makefile
lib/apps-framework/Makefile
lib/misc/Makefile
- lib/misc/state-machine/Makefile
- lib/system-controller/Makefile
src/Makefile
- src/syscond/Makefile
src/homescreen/Makefile
src/statusbar/Makefile
src/onscreen/Makefile
tool/Makefile
tool/notification/Makefile
- tests/Makefile
- tests/system-controller/Makefile
- tests/system-controller/apps-framework/Makefile])
+ tests/Makefile])
AC_PROG_RANLIB([ranlib])
AC_OUTPUT
+++ /dev/null
-[Unit]
-Description=ico system controller
-Requires=weston.service
-After=weston.service
-Wants=ico-device-input-controller.service ico-vic-carsim.service
-
-[Service]
-Environment=TIZEN_PLATFORMLOGGING_MODE=1
-Environment=TIZEN_DLOG_LEVEL=1
-Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%U/dbus/user_bus_socket
-ExecStart=/bin/sh -l -c "/usr/apps/org.tizen.ico.system-controller/bin/IcoSysconDaemon --user app"
-
+++ /dev/null
-# Description=Path activation for ico-system-controller
-
-[Path]
-PathExists=/run/user/5000/wayland-0
-Unit=ico-system-controller.service
-
-[Install]
-WantedBy=weston.target
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.ico.system-controller" version="0.9.21" install-location="internal-only">
- <label>system-controller</label>
- <author email="" href=""> </author>
- <description>ico system-controller</description>
- <ui-application appid="org.tizen.ico.system-controller" exec="/usr/apps/org.tizen.ico.system-controller/bin/IcoSysconDaemon" nodisplay="true" multiple="false" type="capp" taskmanage="false">
- <label>system-controller</label>
- <icon></icon>
- </ui-application>
-</manifest>
common \
notification \
apps-framework \
- misc \
- system-controller
+ misc
-SUBDIRS=\
- state-machine
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <string>
-#include <vector>
-#include <ctype.h>
-#include <string.h>
-
-#include "CicoBlockParser.h"
-
-
-/**
- * Perform a block classification defined string.
- * perform a json parse
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * error message store
- */
-std::string CicoBlockParser::m_err;
-
-/**
- * @brief CicoBlockParser::CicoBlockParser
- * @ constructor
- * @ initial member variables
- */
-CicoBlockParser::CicoBlockParser()
-{
- m_void = (void*)0;
- m_jsonTmp = (char*)0;
-}
-
-/**
- * @brief CicoBlockParser::~CicoBlockParser
- * @ Destructor
- * @ release memory under the management
- */
-CicoBlockParser::~CicoBlockParser()
-{
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) {
- delete (m_childs[i]);
- }
- m_childs.clear();
-
- if ((char*)0 != m_jsonTmp) {
- delete[] m_jsonTmp;
- m_jsonTmp = (char*)0;
- }
-
-}
-
-/**
- * @brief CicoBlockParser::getStateMachineParts
- * @ get stateMachine block
- * @param str
- * @return true: get success/false:get fail
- */
-bool CicoBlockParser::getStateMachineParts(const char* str)
-{
-
- size_t tmp_sz = strlen(str);
- char tmp_s[tmp_sz+1];
- tmp_s[0]='\0';
- size_t t2sz = spaceLess(tmp_s, str); // strip string set workspace
-
- char* tmpstr = tmp_s;
- const char* tmpend = tmpstr+t2sz;
-
- const char* key0 = D_PTF1; // "stateMachine"
- bool dqF = false; // flag double quotate
- char* sttM = (char*)0;
- char* ts = tmpstr;
- const char* errq = (char*)0;
- for (; *ts != '\0'; ts++) {
- if ((true == dqF) && ('\"' == *ts)) { // double quotate ?
- dqF = false; // end string part
- errq = (char*)0;
- continue; // continue of for *ts != 0
- }
-
- if ((false == dqF) && ('\"' == *ts)) { // double quotate ?
- if (0 == strncmp(ts, key0, strlen(key0))) { // stateMachine ?
- sttM = ts;
- break; // break of for *ts != 0
- }
- else {
- dqF = true; // start string part
- errq = ts;
- continue; // continue of for *ts != 0
- }
- }
- if (tmpend == ts) {
- break; // break of for *ts != 0
- }
- }
-
- if ((char*)0 != sttM) {
- m_kind = STTMAC;
- if ((char*)0 != getBrackets(sttM, tmpend)) {
- return true;
- }
- }
- else {
- std::string errhead;
- if (errq) {
- getErrorHead(errhead, errq);
- }
- else {
- getErrorHead(errhead, tmpstr);
- }
- std::ostringstream stream;
- stream << "define error(\"" << errhead << "\")";
- m_err = stream.str();
- }
- return false;
-}
-
-/**
- * @brief CicoBlockParser::getBrackets
- * @ get state/finalState/historyState/event block
- * @param tmpstr string top
- * @param tmpend string end
- * @return !=0:next string pointer ==0:get failure
- */
-const char* CicoBlockParser::getBrackets(char* tmpstr, const char* tmpend)
-{
- // block hea key word
- const char* key1 = D_PTS1; // "\"state\""
- const char* key2 = D_PTS2; // "\"finalState\""
- const char* key3 = D_PTS3; // "\"historyState\""
- const char* key4 = D_PTS4; // "\"event\""
- std::string errhead;
- getErrorHead(errhead, tmpstr);
- int bracketsCnt = 0; // counter
- bool dqF = false; // flag double quotate
- char* ts = tmpstr;
- const char* te = tmpend;
-
- if ('\"' == *ts) {
- dqF = true;
- }
- ts++;
-
- while ('\0' != *ts) { // Repeat until you find the stop code
- if ((true == dqF) && ('\"' == *ts)) { // Is it the end of the string ?
- dqF = false; // end string part
- ts++; // next code
- continue; // continue of while
- }
- if ((false == dqF) && ('\"' == *ts)) { // Is it the start of the string ?
- const char* tr = (char*)0;
- if (0 == strncmp(ts, key1, strlen(key1))) { // Is it parts of state
- CicoBlockParser* smdp = new CicoBlockParser;
- m_childs.push_back(smdp);
- smdp->m_kind = STT;
- tr = smdp->getBrackets(ts, te);
- }
- else if (0 == strncmp(ts, key2, strlen(key2))) {
- CicoBlockParser* smdp = new CicoBlockParser;
- m_childs.push_back(smdp);
- smdp->m_kind = FSTT;
- tr = smdp->getBrackets(ts, te);
- }
- else if (0 == strncmp(ts, key3, strlen(key3))) {
- CicoBlockParser* smdp = new CicoBlockParser;
- m_childs.push_back(smdp);
- smdp->m_kind = HSTT;
- tr = smdp->getBrackets(ts, te);
- }
- else if (0 == strncmp(ts, key4, strlen(key4))) {
- CicoBlockParser* smdp = new CicoBlockParser;
- m_childs.push_back(smdp);
- smdp->m_kind = EV;
- tr = smdp->getBrackets(ts, te);
- }
- else {
- dqF = true; // start of the string
- ts++;
- continue; // continue of while
- }
- if ((char*)0 == tr) {
- return tr;
- }
- if (',' == *(ts-1)) {
- ts--;
- }
-#if 0
- if ('\0'==*tr) { // stop code
- ts = '\0'; // set stop code
- }
- else {
- strcpy(ts , tr);
- }
- te = ts + strlen(ts);
-#else
- char* s = ts;
- for (const char* d = tr; d < te; s++, d++) {
- *s = *d;
- }
- *s = '\0';
- te = s;
-#endif
- }
-
- if ((false == dqF) && ('{' == *ts)) {
- bracketsCnt++;
- ts++;
- continue; // continue of while
- }
-
- if ((false == dqF) && ('}' == *ts)) {
- bracketsCnt--;
- if (0 < bracketsCnt) {
- ts++;
- continue; // continue of while
- }
- else if (0 == bracketsCnt) {
- size_t szt = ts - tmpstr;
- m_parts.assign(tmpstr, szt+1);
- ts++;
- return ts;
- }
- else {
- if (m_err.empty()) {
- std::ostringstream stream;
- stream<<"r-brackets mis.:"<<errhead;
- m_err = stream.str();
- }
- return (char*)0;
- }
- }
- if (te == ts) {
- break; // break of while
- }
- ts++;
- }
- if (m_err.empty()) {
- std::ostringstream stream;
- stream<<"syntax:"<<errhead;
- m_err = stream.str();
- }
- return (char*)0;
-}
-
-
-/**
- * @brief CicoBlockParser::getErrorHead
- * @ error message parts edit
- * @param errhead output message
- * @param strtop message edit source
- */
-void CicoBlockParser::getErrorHead(std::string& errhead, const char* strtop)
-{
- int edsz = 49; // get header string max size
- char tmperr[edsz]; // temp. area
- const char* s = strtop;
- char* d = tmperr;
- int dqCnt = 0; // double quotate counter
- for (int k = 0; k < (edsz-1); k++) {
- *d = *s++; // copy code;
- if ('\"' == *d) { // double quotate ?
- dqCnt++; // count up
- if (6==dqCnt) {
- d++; // set position stop code
- break; // break of for k
- }
- }
- d++; // next store position
- if ('\0' == *s) { // stop code
- break; // break of for k
- }
- }
- *d='\0'; // stop code
- errhead.assign(tmperr);
-}
-
-/**
- * string less space code
- * @brief CicoBlockParser::spaceLess
- * @param s source
- * @param d store area
- * @return store string size
- */
-int CicoBlockParser::spaceLess(char* d, const char* s) const
-{
- size_t dsz = 0; // return value
- char* dd = d; // work pointer set destination
- bool dqF = false; // flag double quotate
- bool cmtF = false; // comment flag
- const char* ss = s; // work pointer source set
- for (; *ss != '\0'; ss++) { // loop string size
- // "(double quotate) block check
- if ((false == cmtF) && (false == dqF) && ('\"' == *ss)) {
- dqF = true; // start string part
- }
- else if ((false == cmtF) && (true == dqF) && ('\"' == *ss)) {
- dqF = false; // end string part
- }
- // comment(/* .. */) block check
- else if ((false == cmtF) && (false == dqF) &&
- ('/' == *ss) && ('*' == *(ss+1))) {
- cmtF = true; // start comment part
- }
- else if ((ss != s) && (true == cmtF) && (false == dqF) &&
- ('/' == *ss) && ('*' == *(ss-1))) {
- cmtF = false; // end comment part
- continue;
- }
- bool storeF = false; // store flag off
- if (true == dqF) { // string part ?
- storeF = true; // store flag on
- }
- else if ((false == cmtF) && (0 == isspace(*ss))) { // is not space code
- storeF = true; // store flag on
- }
- if (true == storeF) { // is flag on ?
- *dd = *ss; // code copy
- dd++; // pointer up
- *dd='\0'; // Stop code insert
- dsz++; // store string size count
- }
- }
- return dsz;
-}
-
-/**
- * @brief CicoBlockParser::jsonParse
- * @param objectname
- * @return true:parse success false:parse fail
- */
-bool CicoBlockParser::jsonParse(const char* objectname)
-{
- std::string tmpstr("{");
- tmpstr += m_parts;
- tmpstr += std::string("}");
- size_t sz = tmpstr.size();
- m_jsonTmp = new char[sz+1];
- strcpy(m_jsonTmp, tmpstr.c_str());
- char* start = m_jsonTmp;
- char* end = m_jsonTmp + sz;
- m_err = picojson::parse(m_v, start, end);
- if (!m_err.empty()) {
- if ((char*)0 != m_jsonTmp) {
- delete[] m_jsonTmp;
- m_jsonTmp = (char*)0;
- }
- return false;
- }
- if (false == m_v.get(objectname).is<picojson::object>()) {
- m_err = std::string("get error(");
- m_err += std::string(objectname);
- m_err += std::string(")");
- if ((char*)0 != m_jsonTmp) {
- delete[] m_jsonTmp;
- m_jsonTmp = (char*)0;
- }
- return false;
- }
- return true;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOBLOCKPARSER_H
-#define CICOBLOCKPARSER_H
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-#include "picojson.h"
-
-/**
- * Part head string define
- */
-#define D_PTF1 "\"stateMachine\""
-#define D_PTS1 "\"state\""
-#define D_PTS2 "\"finalState\""
-#define D_PTS3 "\"historyState\""
-#define D_PTS4 "\"event\""
-
-
-/**
- * Perform a block classification defined string.
- * perform a json parse
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief The CicoBlockParser class
- */
-class CicoBlockParser{
-public:
- enum E_PARTSKIND{
- UNKNOWN = 0, // unknown
- STTMAC = 1, // state machine
- STT, // state
- HSTT, // history state
- FSTT, // final state
- EV // event
- };
- CicoBlockParser();
- virtual ~CicoBlockParser();
-
-
- bool getStateMachineParts(const char* tmpstr);
- const std::string& getError();
- int spaceLess(char* d, const char* s) const;
- void* getVoid() const;
- void setVoid(void* v);
- bool jsonParse(const char* objectname);
- bool isJsonParse() const;
- void getErrorHead(std::string& errhead, const char* strtop);
-public:
- E_PARTSKIND m_kind;
- std::string m_parts;
- std::vector<CicoBlockParser*> m_childs;
- picojson::value m_v;
-
-protected:
- const char* getBrackets(char* tmpstr, const char* tmpend);
-
-private:
- static std::string m_err;
- void* m_void;
- char* m_jsonTmp;
-};
-
-/**
- * @brief get error message
- * @return error message
- */
-inline const std::string& CicoBlockParser::getError()
-{
- return m_err;
-}
-
-/**
- * @brief get void pointer
- * @return void pointer
- */
-inline void* CicoBlockParser::getVoid() const
-{
- return m_void;
-}
-
-/**
- * @brief set void pointer
- * @param v register void pointer
- */
-inline void CicoBlockParser::setVoid(void* v)
-{
- m_void = v;
-}
-
-/**
- * @brief json parse condhition
- * @return treu:parse / false:not parse
- */
-inline bool CicoBlockParser::isJsonParse() const
-{
- if ((char*)0 != m_jsonTmp) {
- return true;
- }
- return false;
-}
-
-#endif // CICOBLOCKPARSER_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include "CicoEvent.h"
-
-
-
-/**
- * Event delivery class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-
-/**
- * @brief CicoEvent::CicoEvent
- */
-CicoEvent::CicoEvent():
- m_ev(0), m_tov(EEvtGCUnset), m_gcvi(0), m_gcvd(0.0), m_adVal((void*)0)
-{
-}
-
-/**
- * @brief CicoEvent::CicoEvent
- * @param ev event number
- * @param adval Additional information user
- */
-CicoEvent::CicoEvent(unsigned short ev, void* adval):
- m_ev(ev), m_tov(EEvtGCUnset), m_gcvi(0), m_gcvd(0.0), m_adVal(adval)
-{
-}
-
-/**
- * @brief CicoEvent::CicoEvent
- * @param ev event number
- * @param gcv Comparison value of guard condition
- * @param adval Additional information user
- */
-CicoEvent::CicoEvent(unsigned short ev, int gcv, void* adval):
- m_ev(ev), m_tov(EEvtGCInt), m_gcvi(gcv), m_gcvd(0.0), m_adVal(adval)
-{
-}
-
-/**
- * @brief CicoEvent::CicoEvent
- * @param oev copy source
- */
-CicoEvent::CicoEvent(const CicoEvent& oev)
-{
- *this = oev;
-}
-
-/**
- * @brief CicoEvent::CicoEvent
- * @param ev event number
- * @param gcv Comparison value of guard condition
- * @param adval Additional information user
- */
-CicoEvent::CicoEvent(unsigned short ev, double gcv, void* adval):
- m_ev(ev), m_tov(EEvtGCDouble), m_gcvi(0), m_gcvd(gcv), m_adVal(adval)
-{
-}
-
-/**
- * @brief CicoEvent::CicoEvent
- * @param ev event number
- * @param gcv Comparison value of guard condition
- * @param adval Additional information user
- */
-CicoEvent::CicoEvent(unsigned short ev, const std::string& gcv, void* adval):
- m_ev(ev), m_tov(EEvtGCStr), m_gcvi(0), m_gcvd(0.0), m_gcvs(gcv), m_adVal(adval)
-{
-}
-
-/**
- * @brief CicoEvent::~CicoEvent
- */
-CicoEvent::~CicoEvent()
-{
- m_adVal = (void*)0;
-}
-
-/**
- * @brief isEventMatch
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:match false:mismatch
- */
-bool isEventMatch(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_ev == b.m_ev) {
- return true;
- }
- return false;
-}
-
-
-/**
- * @brief operator ==
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:match false:mismatch
- */
-bool operator==(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) {
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi == b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd == b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs == b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief operator !=
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:mismatch false:match
- */
-bool operator!=(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) {
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi != b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd != b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs != b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief operator >
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:greater than false not greater than
- */
-bool operator>(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) {
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi > b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd > b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs > b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief operator >=
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:greater than or equal false:not greater than or equal
- */
-bool operator>=(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) { //
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi >= b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd >= b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs >= b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief operator <
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:less than false:not less than
- */
-bool operator<(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) {
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi < b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd < b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs < b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief operator <=
- * @param a Comparison target A
- * @param b Comparison target B
- * @return true:less than or equal false:not less than or equal
- */
-bool operator<=(const CicoEvent& a, const CicoEvent& b)
-{
- if (a.m_tov == b.m_tov) {
- if (CicoEvent::EEvtGCUnset == a.m_tov) {
- return false;
- }
- else if (CicoEvent::EEvtGCInt == a.m_tov) {
- if (a.m_gcvi <= b.m_gcvi) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCDouble == a.m_tov) {
- if (a.m_gcvd <= b.m_gcvd) {
- return true;
- }
- return false;
- }
- else if (CicoEvent::EEvtGCStr == a.m_tov) {
- if (a.m_gcvs <= b.m_gcvs) {
- return true;
- }
- return false;
- }
- }
- return false;
-}
-
-/**
- * @brief CicoEvent::operator =
- * @param s copy source
- */
-void CicoEvent::operator=(const CicoEvent& s)
-{
- m_ev = s.m_ev;
- m_tov = s.m_tov;
- m_gcvi = s.m_gcvi;
- m_gcvd = s.m_gcvd;
- m_gcvs = s.m_gcvs;
- m_adVal = s.m_adVal;
-}
-
-/**
- * @brief getLogPartF
- * @param e edit target
- * @param l log string output
- */
-void getLogPartF(const CicoEvent& e, std::string& l)
-{
- std::stringstream stm;
- stm << "EV:{" << e.getEV() << ":"; // EV:{9999:[99/99.9/"xxx"]} image edit
-
- switch (e.getVTG()) {
- case CicoEvent::EEvtGCInt:
- stm << e.getGCVi();
- break;
- case CicoEvent::EEvtGCDouble:
- stm << e.getGCVd();
- break;
- case CicoEvent::EEvtGCStr:
- stm << "\"" << e.getGCVs() << "\"";
- break;
- default:
- break;
- }
- stm << "}";
- l = stm.str();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOEVENT_H
-#define CICOEVENT_H
-
-#include <iostream>
-#include <string>
-
-
-/**
- * Event delivery class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * @brief The CicoEvent class
- */
-class CicoEvent {
-public:
- enum E_EvType {
- Resv = 0, //
- Start = 1, // start of state-machine
- Stop = 2, // stop of state-machine
- History = 101, //
- DetectTheEnd = 201, //
- User = 1000, // user
- MaxUser = 65535 // user max
- };
-
- // type of value
- enum E_TOV { // Type the value of the guard condition
- EEvtGCUnset = 0, // unset
- EEvtGCInt, // Integer number
- EEvtGCDouble, // Floating point
- EEvtGCStr // String
- };
- // Constructior
- CicoEvent();
- CicoEvent(unsigned short ev, void* adval = 0);
- CicoEvent(unsigned short ev, int gcv, void* adval = 0);
- CicoEvent(unsigned short ev, double gcv, void* adval = 0);
- CicoEvent(unsigned short ev, const std::string& gcv,
- void* adval = 0);
- CicoEvent(const CicoEvent& oev);
-
- // destructor
- virtual ~CicoEvent();
-
- unsigned short getEV() const;
- void setEV(unsigned short ev);
-
- int getGCVi() const;
- double getGCVd() const;
- const std::string& getGCVs() const;
- void setGCV(int gcv);
- void setGCV(double gcv);
- void setGCV(const std::string& gcv);
-
- E_TOV getVTG() const;
-
- void* getAdVal() const;
- void setAdVal(void* adval);
-
- friend bool isEventMatch(const CicoEvent& a, const CicoEvent& b);
-
- friend bool operator==(const CicoEvent& a, const CicoEvent& b);
- friend bool operator!=(const CicoEvent& a, const CicoEvent& b);
- friend bool operator>(const CicoEvent& a, const CicoEvent& b);
- friend bool operator>=(const CicoEvent& a, const CicoEvent& b);
- friend bool operator<(const CicoEvent& a, const CicoEvent& b);
- friend bool operator<=(const CicoEvent& a, const CicoEvent& b);
-
- void operator=(const CicoEvent& s);
-
-protected:
- unsigned short m_ev; // event number
- E_TOV m_tov; // Type the value of the guard condition
- int m_gcvi; // store Integer number
- double m_gcvd; // store Floating point
- std::string m_gcvs; // store String
-
-private:
- void* m_adVal; // Additional information value
-
-};
-
-/**
- * @brief get event number
- * @return event number
- */
-inline unsigned short CicoEvent::getEV() const
-{
- return m_ev; // event number
-}
-
-/**
- * @brief register event number
- * @param ev event number
- */
-inline void CicoEvent::setEV(unsigned short ev)
-{
- m_ev = ev; // event number
-}
-
-/**
- * @brief get Comparison value of guard condition
- * @return Comparison value of guard condition
- */
-inline int CicoEvent::getGCVi() const
-{
- return m_gcvi; // Type the value of the guard condition
-}
-
-/**
- * @brief get Comparison value of guard condition
- * @return Comparison value of guard condition
- */
-inline double CicoEvent::getGCVd() const
-{
- return m_gcvd; // Type the value of the guard condition
-}
-
-/**
- * @brief get Comparison value of guard condition
- * @return Comparison value of guard condition
- */
-inline const std::string& CicoEvent::getGCVs() const
-{
- return m_gcvs;
-}
-
-/**
- * @brief get type of guard condition value
- * @return type of guard condition value
- */
-inline CicoEvent::E_TOV CicoEvent::getVTG() const
-{
- return m_tov;
-}
-
-/**
- * @brief register Comparison value of guard condition
- * @param gcv Comparison value of guard condition
- */
-inline void CicoEvent::setGCV(int gcv)
-{
- m_tov = EEvtGCInt;
- m_gcvi = gcv;
-}
-
-/**
- * @brief register Comparison value of guard condition
- * @param gcv Comparison value of guard condition
- */
-inline void CicoEvent::setGCV(double gcv)
-{
- m_tov = EEvtGCDouble;
- m_gcvd = gcv;
-}
-
-/**
- * @brief register Comparison value of guard condition
- * @param gcv Comparison value of guard condition
- */
-inline void CicoEvent::setGCV(const std::string& gcv)
-{
- m_tov = EEvtGCStr;
- m_gcvs = gcv;
-}
-
-/**
- * @brief get Additional information user
- * @return Additional information user
- */
-inline void* CicoEvent::getAdVal() const
-{
- return m_adVal;
-}
-
-/**
- * @brief register Additional information user
- * @param adval Additional information user
- */
-inline void CicoEvent::setAdVal(void* adval)
-{
- m_adVal = adval;
-}
-
-#endif // CICOEVENT_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <iostream>
-#include <string>
-#include <vector>
-#include <algorithm>
-#include <sstream>
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateCore.h"
-
-
-/**
- * event infomation class
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param ev base event data
- */
-CicoEventInfo::CicoEventInfo(unsigned short ev):
- CicoEvent(ev)
-{
- m_JGCE = Ejnj; //
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(unsigned short ev, const std::string& gcstr,
- int value):
- CicoEvent(ev, value)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(unsigned short ev, const std::string& gcstr,
- double value):
- CicoEvent(ev, value)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(unsigned short ev, const std::string& gcstr,
- const std::string& value):
- CicoEvent(ev, value)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param name event name
- * @param ev event number
- */
-CicoEventInfo::CicoEventInfo(const std::string& name, unsigned short ev):
- CicoEvent(ev), m_name(name)
-{
- m_JGCE = Ejnj;
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param name event name
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr, int value):
- CicoEvent(ev, value), m_name(name)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param name event name
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr, double value):
- CicoEvent(ev, value), m_name(name)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param name event name
- * @param ev event number
- * @param gcstr operator kind
- * @param value Comparison value
- */
-CicoEventInfo::CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr,
- const std::string& value):
- CicoEvent(ev, value), m_name(name)
-{
- m_JGCE = chgGCType(gcstr); // string change to enum
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
-}
-
-/**
- * @brief CicoEventInfo::CicoEventInfo
- * @param ei copy source
- */
-CicoEventInfo::CicoEventInfo(const CicoEventInfo& ei):
- CicoEvent()
-{
- m_JGCE = Ejnj;
- m_transition = (CicoStateCore*)0; // Initialize the pointer value
- *this = ei;
-}
-
-/**
- * @brief CicoEventInfo::~CicoEventInfo
- */
-CicoEventInfo::~CicoEventInfo()
-{
- if (false == m_vEvt.empty()) {
- m_vEvt.clear();
- }
- if (false == m_vJGCE.empty()) {
- m_vJGCE.clear();
- }
- if (false == m_vAgc.empty()) {
- m_vAgc.clear();
- }
-// m_transition = (CicoStateCore*)0;
-}
-
-/**
- * @brief CicoEventInfo::addAndGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addAndGurdCondition(const std::string& gcstr, int value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_AND);
- return true;
-}
-
-/**
- * @brief CicoEventInfo::addAndGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addAndGurdCondition(const std::string& gcstr, double value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_AND);
- return true;
-}
-
-/**
- * @brief CicoEventInfo::addAndGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addAndGurdCondition(const std::string& gcstr,
- const std::string& value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_AND);
- return true;
-}
-
-/**
- * @brief CicoEventInfo::addOrGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addOrGurdCondition(const std::string& gcstr, int value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_OR);
- return true;
-}
-
-
-/**
- * @brief CicoEventInfo::addOrGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addOrGurdCondition(const std::string& gcstr,
- double value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_OR);
- return true;
-}
-
-/**
- * @brief CicoEventInfo::addOrGurdCondition
- * @param gcstr operator kind
- * @param value Comparison value
- * @return true:added success false:added fail
- */
-bool CicoEventInfo::addOrGurdCondition(const std::string& gcstr,
- const std::string& value)
-{
- CicoEvent e(m_ev, value);
- E_JGCE j = chgGCType(gcstr); // string change to enum
- if (Ejnj == j) {
- return false;
- }
- addGurdCondition(e, j, EAGC_OR);
- return true;
-}
-
-/**
- * @brief CicoEventInfo::Judge
- * @param ev event data
- * @param sm compare trigger state-object
- * @return true:event match false:event Mismatch
- */
-bool CicoEventInfo::Judge(const CicoEvent& ev, const CicoStateCore* sm) const
-{
- if (m_ev != ev.getEV()) { //
- return false; // event number mismatch
- }
- // The event number matches
- if (Ejnj == m_JGCE) { // Without guard condition
- return true; // event match !
- }
- // check guard condition
- bool bR = checkGurdCondition(m_JGCE, *((CicoEvent*)this), ev, sm); // return value
-
- int sz = m_vEvt.size();
- for (int i=0; i<sz; i++) {
- bool bR2 = checkGurdCondition(m_vJGCE[i], m_vEvt[i], ev, sm);
- E_AGC agc = m_vAgc[i];
- if (EAGC_AND == agc) {
- bR &= bR2;
- }
- else if (EAGC_OR == agc) {
- bR |= bR2;
- }
- else {
- return false;
- }
- }
- return bR;
-}
-
-/**
- * @brief CicoEventInfo::checkGurdCondition
- * @param j operator
- * @param base event data
- * @param rec event data
- * @param sm compair trigger state-object
- * @return treu:match false:Mismatch
- */
-bool CicoEventInfo::checkGurdCondition(E_JGCE j, const CicoEvent& base,
- const CicoEvent& rec,
- const CicoStateCore* sm) const
-{
- bool bR = false; // return value init.
- if ((Ein == j)||(Enot == j)) { // Guard condition of active state object
- const CicoStateCore* stt = (CicoStateCore*)0;
- if (EEvtGCInt == base.getVTG()) {
- stt = getStateF(sm, base.getGCVi());
- }
- else if (EEvtGCStr == base.getVTG()) {
- stt = getStateF(sm, base.getGCVs());
- }
- if ((CicoStateCore*)0 == stt) {
- return false;
- }
- bR = checkActive(j, *stt);
- }
- else { // Remaining comparisons
- bR = checkCompare(j, base, rec);
- }
- return bR;
-}
-
-/**
- * @brief CicoEventInfo::checkActive
- * @param j in or not operator
- * @param stt check target
- * @return true:event match false:event Mismatch
- */
-bool CicoEventInfo::checkActive(E_JGCE j, const CicoStateCore& stt) const
-{
- if (Ein == j) {
- if (true == stt.isActive()) {
- return true;
- }
- }
- else if (Enot == j) {
- if (false == stt.isActive()) {
- return true;
- }
- }
- return false;
-}
-
-/**
- * @brief CicoEventInfo::checkCompare
- * @param j operator
- * @param base Comparison Event
- * @param rec Comparison Event
- * @return true:match false:Mismatch
- */
-bool CicoEventInfo::checkCompare(E_JGCE j, const CicoEvent& base,
- const CicoEvent& rec) const
-{
- bool bR = false;
- switch (j) {
- case Ejeq: // equal
- if (base == rec) {
- bR = true;
- }
- break;
- case Ejne: // Not equal
- if (base != rec) {
- bR = true;
- }
- break;
- case Ejgt: // greater than
- if (base < rec) {
- bR = true;
- }
- break;
- case Ejge: // greater than or equal
- if (base <= rec) {
- bR = true;
- }
- break;
- case Ejlt: // less than
- if (base > rec) {
- bR = true;
- }
- break;
- case Ejle: // less than or equal
- if (base >= rec) {
- bR = true;
- }
- break;
- default: // ERROR
- break;
- }
- return bR;
-}
-
-/**
- * @brief CicoEventInfo::addGurdCondition
- * @param e Comparison Event
- * @param j operator infomation(==/!=/>/>=/</<=/in/not)
- * @param a and/or
- */
-void CicoEventInfo::addGurdCondition(CicoEvent& e, E_JGCE j, E_AGC a)
-{
- if (Ejnj == m_JGCE) {
- E_TOV tov = e.getVTG();
- if (EEvtGCInt == tov) {
- setGCV(e.getGCVi());
- m_JGCE = j;
- }
- else if (EEvtGCDouble == tov) {
- setGCV(e.getGCVd());
- m_JGCE = j;
- }
- else if (EEvtGCStr == tov) {
- setGCV(e.getGCVs());
- m_JGCE = j;
- }
- }
- else {
- m_vEvt.push_back(e);
- m_vJGCE.push_back(j);
- m_vAgc.push_back(a);
- }
-}
-
-/**
- * @brief CicoEventInfo::chgGCType
- * @param gcstr string operator
- * @return enum operator
- */
-CicoEventInfo::E_JGCE CicoEventInfo::chgGCType(const std::string& gcstr) const
-{
- if (gcstr == DEFJGCE_EQ) { // "="
- return Ejeq; // equal
- }
- else if (gcstr == DEFJGCE_NE) { // "!="
- return Ejne; // Not equal
- }
- else if (gcstr == DEFJGCE_GT) { // "<"
- return Ejgt; // greater than
- }
- else if (gcstr == DEFJGCE_GE) { // "<="
- return Ejge; // greater than or equal
- }
- else if (gcstr == DEFJGCE_GE2) { // "=<"
- return Ejge; // greater than or equal
- }
- else if (gcstr == DEFJGCE_LT) { // ">"
- return Ejlt; // less than
- }
- else if (gcstr == DEFJGCE_LE) { // ">="
- return Ejle; // less than or equal
- }
- else if (gcstr == DEFJGCE_LE2) { // "=>"
- return Ejle; // less than or equal
- }
- else { //
- std::string s(gcstr); // copy string
- transform(s.begin(), s.end(), s.begin(), tolower); // converted to lower case
- if (s == DEFJGCE_IN) { // "in"
- return Ein; // in active state object
- }
- else if (s == DEFJGCE_NOT) { // "not"
- return Enot; // not active state object
- }
- else {
- /*
- * _D_ERROR
- */
- }
- }
- return Ejnj; // Not Judgment
-}
-
-/**
- * @brief CicoEventInfo::operator =
- * @param s copy source
- */
-void CicoEventInfo::operator=(const CicoEventInfo& s)
-{
- // CicoEvent Block
- setEV(s.getEV());
- E_TOV tov = s.getVTG();
- switch (tov) {
- case EEvtGCInt:
- setGCV(s.getGCVi());
- break;
- case EEvtGCDouble:
- setGCV(s.getGCVd());
- break;
- case EEvtGCStr:
- setGCV(s.getGCVs());
- break;
- default:
- break;
- }
-
- setAdVal(s.getAdVal());
-
- // CicoEventInfo Block
- m_name = s.m_name; // copy event name
- m_JGCE = s.m_JGCE; // copy Judgment guard condition expression
- int sz = s.m_vEvt.size(); // get vector member size
- for (int i = 0; i < sz; i++) { // vector menber size loop
- m_vEvt.push_back(s.m_vEvt[i]);
- m_vJGCE.push_back(s.m_vJGCE[i]);
- m_vAgc.push_back(s.m_vAgc[i]);
- }
- m_transition = s.m_transition; //
-}
-
-/**
- * @brief getLogPartF
- * @param e log target
- * @param l store log string
- */
-void getLogPartF(const CicoEventInfo& e, std::string& l)
-{
- const char* opstr[] = {
- "??", // Ejnj Not Judgment
- DEFJGCE_EQ, // "=" Ejeq equal
- DEFJGCE_NE, // "!=" Ejne Not equal
- DEFJGCE_LT, // "<" Ejlt less than
- DEFJGCE_LE, // "<=" Ejle less than or equal
- DEFJGCE_GT, // ">" Ejgt greater than
- DEFJGCE_GE, // ">=" Ejge greater than or equal
- DEFJGCE_IN, // "in" Ein in active state object
- DEFJGCE_NOT, // "not" Enot not active state object
- };
- std::stringstream stm;
- stm << "EI:{";
- if (!((e.getName()).empty())) {
- stm << "\"" << e.getName() << "\"";
- }
- stm << ":" << e.getEV() << ":";
- CicoEventInfo::E_JGCE jgce = e.getGCType();
- if (CicoEventInfo::Ejnj != jgce) {
- stm << opstr[jgce];
- }
- bool bInNot = false;
- if ((CicoEventInfo::Ein == jgce)||
- (CicoEventInfo::Enot == jgce)) {
- bInNot = true;
- stm << "(";
- }
- switch (jgce) {
- case CicoEvent::EEvtGCInt:
- stm << e.getGCVi();
- break;
- case CicoEvent::EEvtGCDouble:
- stm << e.getGCVd();
- break;
- case CicoEvent::EEvtGCStr:
- stm << "\"" << e.getGCVs() << "\"";
- break;
- default: // CicoEvent::EEvtGCUnset
- break;
- }
- if (true == bInNot) {
- stm << ")";
- }
-// if (0 != e->m_vAgc.size()) {
-// stm << ":{...}";
-// }
- stm << "}";
- l = stm.str();
-}
-
-/**
- * @brief operator ==
- * @param a Comparison target A
- * @param b Comparison target B
- * @return
- */
-bool operator==(const CicoEventInfo& a, const CicoEventInfo& b)
-{
- if (a.getEV() == b.getEV()) { // event No. match
- bool anm = a.m_name.empty();
- bool bnm = b.m_name.empty();
- if ((true == anm) && (true == bnm)) { //
- return true;
- }
- else if ((false == anm) && (false == bnm)) {
- if (a.m_name == b.m_name) {
- return true;
- }
- }
- }
- return false;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOEVENTINFO_H
-#define CICOEVENTINFO_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoEvent.h"
-
-#ifndef CICOSTATECORE_H
-class CicoStateCore;
-#endif
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-#define DEFJGCE_EQ "="
-#define DEFJGCE_NE "!="
-#define DEFJGCE_LT "<"
-#define DEFJGCE_LE2 "=<"
-#define DEFJGCE_LE "<="
-#define DEFJGCE_GT ">"
-#define DEFJGCE_GE2 "=>"
-#define DEFJGCE_GE ">="
-#define DEFJGCE_IN "in"
-#define DEFJGCE_NOT "not"
-
-
-/**
- * event infomation object class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * @brief The CicoEventInfo class
- */
-class CicoEventInfo : public CicoEvent
-{
-public:
- // type of added guard condition
- enum E_AGC {
- EAGC_NON = 0, // none
- EAGC_AND = 1, // AND
- EAGC_OR // OR
- };
-
- // Judgment guard condition expression
- enum E_JGCE {
- Ejnj = 0, // Not Judgment
- Ejeq = 1, // equal
- Ejne, // Not equal
- Ejlt, // less than
- Ejle, // less than or equal
- Ejgt, // greater than
- Ejge, // greater than or equal
- Ein, // in active state object
- Enot // not active state object
- };
-
- // Constructior
- CicoEventInfo(unsigned short ev);
- CicoEventInfo(unsigned short ev, const std::string& gcstr,
- int value);
- CicoEventInfo(unsigned short ev, const std::string& gcstr,
- double value);
- CicoEventInfo(unsigned short ev, const std::string& gcstr,
- const std::string& value);
-
- CicoEventInfo(unsigned short ev, const std::string& gcstr,
- CicoState* stt);
-
- CicoEventInfo(const std::string& name, unsigned short ev);
- CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr, int value);
- CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr, double value);
- CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr,
- const std::string& value);
- CicoEventInfo(const std::string& name, unsigned short ev,
- const std::string& gcstr, CicoState* stt);
- CicoEventInfo(const CicoEventInfo& ei);
- // destructor
- virtual ~CicoEventInfo();
-
- bool addAndGurdCondition(const std::string& gcstr, int value);
- bool addAndGurdCondition(const std::string& gcstr, double value);
- bool addAndGurdCondition(const std::string& gcstr,
- const std::string& value);
-
- bool addOrGurdCondition(const std::string& gcstr, int value);
- bool addOrGurdCondition(const std::string& gcstr, double value);
- bool addOrGurdCondition(const std::string& gcstr,
- const std::string& value);
-
- bool Judge(const CicoEvent& ev, const CicoStateCore* sm) const;
-
- const std::string& getName() const;
- void setName(const std::string& name);
-
- CicoStateCore* getTransition() const;
- void setTransition(CicoStateCore* transition);
-
- void operator=(const CicoEventInfo& s);
- friend bool operator==(const CicoEventInfo& a, const CicoEventInfo& b);
-
- E_JGCE getGCType() const;
-
-protected:
-
- E_JGCE chgGCType(const std::string& gcstr) const;
-
- bool checkGurdCondition(E_JGCE j, const CicoEvent& base,
- const CicoEvent& rec,
- const CicoStateCore* sm) const;
- bool checkActive(E_JGCE j, const CicoStateCore& stt) const;
- bool checkCompare(E_JGCE j, const CicoEvent& base,
- const CicoEvent& rec) const;
-
- void addGurdCondition(CicoEvent& e, E_JGCE j, E_AGC a);
-
- friend const CicoStateCore* getState(const CicoStateCore* s,
- const int value);
- friend const CicoStateCore* getState(const CicoStateCore* s,
- const std::string& name);
-
-private:
-
- std::string m_name; // event name
- E_JGCE m_JGCE; // guard condition
- std::vector<CicoEvent> m_vEvt; // additional guard condition
- std::vector<E_JGCE> m_vJGCE; //
- std::vector<E_AGC> m_vAgc; //
- CicoStateCore* m_transition; // Transition destination
-
-};
-
-/**
- * @brief CicoEventInfo::getName
- * @return event identification name
- */
-inline const std::string& CicoEventInfo::getName() const
-{
- return m_name;
-}
-
-/**
- * @brief CicoEventInfo::setName
- * @ set event name
- * @param name event identification name
- */
-inline void CicoEventInfo::setName(const std::string& name)
-{
- m_name = name;
-}
-
-/**
- * @brief CicoEventInfo::getTransition
- * @ get object destination state
- * @return registered transition state-object pointer
- */
-inline CicoStateCore* CicoEventInfo::getTransition() const
-{
- return m_transition;
-}
-
-/**
- * @brief CicoEventInfo::setTransition
- * @ set object destination state
- * @param transition pointer state object
- */
-inline void CicoEventInfo::setTransition(CicoStateCore* transition)
-{
- m_transition = transition;
-}
-
-/**
- * @brief CicoEventInfo::getGCType
- * @return
- */
-inline CicoEventInfo::E_JGCE CicoEventInfo::getGCType() const
-{
- return m_JGCE;
-}
-
-#endif // CICOEVENTINFO_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoStateCore.h"
-#include "CicoFinalState.h"
-
-
-/**
- * final state object class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(CicoState* parent):
- CicoStateCore(EFinalState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param name Identification name
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(const std::string& name, CicoState* parent):
- CicoStateCore(EFinalState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param value Identification number
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(int value, CicoState* parent):
- CicoStateCore(EFinalState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param name Identification name
- * @param value Identification number
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(const std::string& name, int value,
- CicoState* parent):
- CicoStateCore(EFinalState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(CicoStateMachine* parent):
- CicoStateCore(EFinalState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param name Identification name
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(const std::string& name,
- CicoStateMachine* parent):
- CicoStateCore(EFinalState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param value Identification number
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(int value, CicoStateMachine* parent):
- CicoStateCore(EFinalState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::CicoFinalState
- * @param name Identification name
- * @param value Identification number
- * @param parent parent object
- */
-CicoFinalState::CicoFinalState(const std::string& name, int value,
- CicoStateMachine* parent):
- CicoStateCore(EFinalState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoFinalState::start
- * @param ev
- * @return
- */
-bool CicoFinalState::start(const CicoEvent& ev, bool)
-{
- m_activeState = true; // activate
- onEntry(ev); // entry
- m_activeState = false; // deactivate
- stateEndF(m_parent, ev);
- return true;
-}
-
-/**
- * @brief CicoFinalState::setParent
- * @param parent parent object
- */
-void CicoFinalState::setParent(CicoState* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
-
-/**
- * @brief CicoFinalState::setParent
- * @param parent parent object
- */
-void CicoFinalState::setParent(CicoStateMachine* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOFINALSTATE_H
-#define CICOFINALSTATE_H
-
-#include <iostream>
-#include <string>
-
-#include "CicoStateCore.h"
-
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-
-/**
- * final state object class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * @brief The CicoFinalState class
- */
-class CicoFinalState :public CicoStateCore
-{
-public:
- // Constructior
- CicoFinalState(CicoState* parent=0);
- CicoFinalState(const std::string& name, CicoState* parent=0);
- CicoFinalState(int value, CicoState* parent=0);
- CicoFinalState(const std::string& name, int value,
- CicoState* parent=0);
- CicoFinalState(CicoStateMachine* parent);
- CicoFinalState(const std::string& name,
- CicoStateMachine* parent);
- CicoFinalState(int value, CicoStateMachine* parent);
- CicoFinalState(const std::string& name, int value,
- CicoStateMachine* parent);
- void setParent(CicoState* parent);
- void setParent(CicoStateMachine* parent);
-
- void addEntryAction(CicoStateAction* action, int addval = 0);
-
-protected:
- virtual bool start(const CicoEvent& ev, bool parent=false);
-
-private:
-
-};
-
-/**
- * @brief CicoFinalState::addEntryAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoFinalState::addEntryAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addEntryAction(action, addval);
-}
-
-#endif // CICOFINALSTATE_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoStateCore.h"
-#include "CicoHistoryState.h"
-
-/**
- * history state object class
- * @author m.kamoshida
- * @version 0.1
- */
-
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(CicoState* parent):
- CicoStateCore(EHistoryState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param name Identification name
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(const std::string& name, CicoState* parent):
- CicoStateCore(EHistoryState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param value Identification number
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(int value, CicoState* parent):
- CicoStateCore(EHistoryState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param name Identification name
- * @param value Identification number
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(const std::string& name, int value,
- CicoState* parent):
- CicoStateCore(EHistoryState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(CicoStateMachine* parent):
- CicoStateCore(EHistoryState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param name Identification name
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(const std::string& name,
- CicoStateMachine* parent):
- CicoStateCore(EHistoryState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param value Identification number
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(int value, CicoStateMachine* parent):
- CicoStateCore(EHistoryState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::CicoHistoryState
- * @param name Identification name
- * @param value Identification number
- * @param parent parent object
- */
-CicoHistoryState::CicoHistoryState(const std::string& name, int value,
- CicoStateMachine* parent):
- CicoStateCore(EHistoryState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoHistoryState::~CicoHistoryState
- */
-CicoHistoryState::~CicoHistoryState()
-{
- m_vDState.clear();
- m_vHState.clear();
-}
-
-/**
- * @brief CicoHistoryState::addDefaultState
- * @param stts default state object
- */
-void CicoHistoryState::addDefaultState(std::vector<CicoState*> stts)
-{
- int sz = stts.size();
- for (int i = 0; i < sz; i++) {
- m_vDState.push_back(stts[i]);
- }
-}
-
-/**
- * @brief CicoHistoryState::addDefaultState
- * @param stts default state object
- */
-void CicoHistoryState::addDefaultState(CicoState* stt)
-{
- m_vDState.push_back(stt);
-}
-
-/**
- * @brief CicoHistoryState::holdHistory
- */
-void CicoHistoryState::holdHistory()
-{
- bool bR = false;
- if ((CicoStateCore*)0 != m_parent) { // exist is parent
- // Discard the previous history
- m_vHState.clear();
- std::vector<const CicoState*> t;
- // Stores the new history
- if (Deep == m_historyType) { // deep history ?
- /*
- * Deep history
- */
- bR = getCurrentStateF(m_parent, t, CicoStateCore::ELvlBttm);
- }
- else {
- /*
- * Shallow history
- */
- bR = getCurrentStateF(m_parent, t, CicoStateCore::ELvlTop);
- }
- if (false == bR) {
- /*
- * _D_ERROR
- */
- }
- else {
- int sz = t.size();
- for (int i = 0; i < sz; i++) {
- m_vHState.push_back((CicoState*)t[i]);
- }
- }
- }
- else {
- /*
- * _D_ERROR
- */
- }
-}
-
-/**
- * @brief CicoHistoryState::start
- * @param ev trigger event data
- * @return
- */
-bool CicoHistoryState::start(const CicoEvent& ev, bool)
-{
- toActivate(ev);
-
- toDeactivate(ev);
-
- int szH = m_vHState.size();
- int szD = m_vDState.size();
- if (0 != szH) {
- for (int i = 0; i < szH; i++) {
- CicoStateCore* t = (CicoStateCore*)m_vHState[i];
- startF(t, ev, false);
- }
- }
- else if (0 != szD) {
- for (int i = 0; i < szD; i++) {
- CicoStateCore* t =(CicoStateCore*)m_vDState[i];
- startF(t, ev, true);
- }
- }
- else {
- /*
- * _D_ERROR
- */
- startF(m_parent, ev, true);
- }
- return true;
-}
-
-/**
- * @brief getCurrentStateF
- * @param stt get top
- * @param states store active state objects area
- * @param policy get poicy
- * @return true:get success false:get fail
- */
-bool getCurrentStateF(CicoStateCore* stt,
- std::vector<const CicoState*>& states,
- CicoStateCore::E_GetPolicy policy)
-{
- return stt->getCurrentState(states, policy);
-}
-
-/**
- * @brief CicoHistoryState::setParent
- * @param parent parent object
- */
-void CicoHistoryState::setParent(CicoState* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
-
-/**
- * @brief CicoHistoryState::setParent
- * @param parent parent object
- */
-void CicoHistoryState::setParent(CicoStateMachine* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CICOHISTORYSTATE_H
-#define CICOHISTORYSTATE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoStateCore.h"
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-/**
- * history state object class
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief The CicoHistoryState class
- */
-class CicoHistoryState : public CicoStateCore
-{
-public:
- // history type
- enum E_HType {
- Shallow = 1, // Shallow History
- Deep // Deep History
- };
- // constructor
- CicoHistoryState(CicoState* parent=0);
- CicoHistoryState(const std::string& name, CicoState* parent=0);
- CicoHistoryState(int value, CicoState* parent=0);
- CicoHistoryState(const std::string& name, int value,
- CicoState* parent=0);
- CicoHistoryState(CicoStateMachine* parent);
- CicoHistoryState(const std::string& name,
- CicoStateMachine* parent);
- CicoHistoryState(int value, CicoStateMachine* parent);
- CicoHistoryState(const std::string& name, int value,
- CicoStateMachine* parent);
-
- // destructor
- ~CicoHistoryState();
-
- void addDefaultState(std::vector<CicoState*> stts);
- void addDefaultState(CicoState* stt);
-
- E_HType getHistoryType() const;
- void setHistoryType(E_HType type);
-
- void setParent(CicoState* parent);
- void setParent(CicoStateMachine* parent);
-
- void addEntryAction(CicoStateAction* action, int addval = 0);
-
- void addExitAction(CicoStateAction* action, int addval = 0);
-
-protected:
- virtual bool start(const CicoEvent& ev, bool parent=false);
-
- virtual void holdHistory();
-
-private:
- E_HType m_historyType; // history type
- std::vector<CicoState*> m_vDState; // store default area
- std::vector<CicoState*> m_vHState; // store history area
-};
-
-/**
- * @brief CicoHistoryState::getHistoryType
- * @return history type(Shallow or Deep)
- */
-inline CicoHistoryState::E_HType CicoHistoryState::getHistoryType() const
-{
- return m_historyType;
-}
-
-/**
- * @brief CicoHistoryState::setHistoryType
- * @ set history type
- * @param type history type(Shallow or Deep)
- */
-inline void CicoHistoryState::setHistoryType(E_HType type)
-{
- m_historyType = type;
-}
-
-/**
- * @brief CicoHistoryState::addEntryAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoHistoryState::addEntryAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addEntryAction(action, addval);
-}
-
-/**
- * @brief CicoHistoryState::addExitAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoHistoryState::addExitAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addExitAction(action, addval);
-}
-
-#endif // CICOHISTORYSTATE_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoStateCore.h"
-#include "CicoState.h"
-
-/**
- * State object class definition
- * I represent the state. The state identified by the name or number
- * Depending on the event information of the member variable, perform -
- * the determination of the transition, the transition
- * I used during the transition or identification number, name identification.
- * Please be sure to set either.
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief CicoState::CicoState
- * @param parent parent object
- */
-CicoState::CicoState(CicoState* parent):
- CicoStateCore(EState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param name Identification name
- * @param parent parent object
- */
-CicoState::CicoState(const std::string& name, CicoState* parent):
- CicoStateCore(EState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param value Identification number
- * @param parent parent object
- */
-CicoState::CicoState(int value, CicoState* parent):
- CicoStateCore(EState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param name Identification name
- * @param value Identification number
- * @param parent parent object
- */
-CicoState::CicoState(const std::string& name, int value, CicoState* parent):
- CicoStateCore(EState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param parent parent object
- */
-CicoState::CicoState(CicoStateMachine* parent):
- CicoStateCore(EState, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param name Identification name
- * @param parent parent object
- */
-CicoState::CicoState(const std::string& name, CicoStateMachine* parent):
- CicoStateCore(EState, name, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param value Identification number
- * @param parent parent object
- */
-CicoState::CicoState(int value, CicoStateMachine* parent):
- CicoStateCore(EState, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::CicoState
- * @param name Identification name
- * @param value Identification number
- * @param parentparent object
- */
-CicoState::CicoState(const std::string& name, int value,
- CicoStateMachine* parent):
- CicoStateCore(EState, name, value, (CicoStateCore*)parent)
-{
-}
-
-/**
- * @brief CicoState::~CicoState
- */
-CicoState::~CicoState()
-{
-}
-
-/**
- * @brief CicoState::addState
- * @param state child object
- */
-void CicoState::addState(CicoState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addState
- * @param state child object
- */
-void CicoState::addState(CicoFinalState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addState
- * @param state child object
- */
-void CicoState::addState(CicoHistoryState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addTransition
- * @param evInf transition trigger data
- * @param state Transition destination
- */
-void CicoState::addTransition(const CicoEventInfo& evInf, CicoState* state)
-{
- CicoStateCore::addTransition(evInf, (CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addTransition
- * @param evInf transition trigger data
- * @param state Transition destination
- */
-void CicoState::addTransition(const CicoEventInfo& evInf, CicoFinalState* state)
-{
- CicoStateCore::addTransition(evInf, (CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addTransition
- * @param evInf transition trigger data
- * @param state Transition destination
- */
-void CicoState::addTransition(const CicoEventInfo& evInf, CicoHistoryState* state)
-{
- CicoStateCore::addTransition(evInf, (CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::setFinishTransition
- * @param state Transition destination
- */
-void CicoState::setFinishTransition(CicoState* state)
-{
- CicoStateCore::setFinishTransition((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::setFinishTransition
- * @param state
- * @param state Transition destination
- */
-void CicoState::setFinishTransition(CicoFinalState* state)
-{
- CicoStateCore::setFinishTransition((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::setFinishTransition
- * @param state Transition destination
- */
-void CicoState::setFinishTransition(CicoHistoryState* state)
-{
- CicoStateCore::setFinishTransition((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addInitState
- * @param state start position
- */
-void CicoState::addInitState(CicoState* state)
-{
- CicoStateCore::addInitState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoState::addInitState
- * @param state start position
- */
-void CicoState::addInitState(CicoHistoryState* state)
-{
- CicoStateCore::addInitState((CicoStateCore*)state);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOSTATE_H
-#define CICOSTATE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoStateCore.h"
-
-#ifndef CICOFINALSTATE_H
-class CicoFinalState;
-#endif
-
-#ifndef CICOHISTORYSTATE_H
-class CicoHistoryState;
-#endif
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-/**
- * State object class definition
- * I represent the state. The state identified by the name or number
- * Depending on the event information of the member variable, perform -
- * the determination of the transition, the transition
- * I used during the transition or identification number, name identification.
- * Please be sure to set either.
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief The CicoState class
- */
-class CicoState : public CicoStateCore
-{
-public:
- // Constructior
- CicoState(CicoState* parent=0);
- CicoState(const std::string& name, CicoState* parent=0);
- CicoState(int value, CicoState* parent=0);
- CicoState(const std::string& name, int value,
- CicoState* parent=0);
- CicoState(CicoStateMachine* parent);
- CicoState(const std::string& name, CicoStateMachine* parent);
- CicoState(int value, CicoStateMachine* parent);
- CicoState(const std::string& name, int value,
- CicoStateMachine* parent);
- // destructor
- virtual ~CicoState();
-
- // registration of child
- void addState(CicoState* state);
- void addState(CicoFinalState* state);
- void addState(CicoHistoryState* state);
-
- // registration of event and transition
- void addTransition(const CicoEventInfo& evInf, CicoState* state);
- void addTransition(const CicoEventInfo& evInf,
- CicoFinalState* state);
- void addTransition(const CicoEventInfo& evInf,
- CicoHistoryState* state);
-
- // registration of finish transition
- void setFinishTransition(CicoState* state);
- void setFinishTransition(CicoFinalState* state);
- void setFinishTransition(CicoHistoryState* state);
-
- // registration of start position
- void addInitState(CicoState* state);
- void addInitState(CicoHistoryState* state);
-
- bool getCurrentState(std::vector<const CicoState*>& states,
- CicoStateCore::E_GetPolicy policy=CicoStateCore::ELvlBttm);
- const CicoState* getCurrentState();
-
-
- void addEntryAction(CicoStateAction* action, int addval = 0);
-
- void addExitAction(CicoStateAction* action, int addval = 0);
-
- void addDoAction(CicoStateAction* action, int addval = 0);
-
- void setParent(CicoState* parent);
- void setParent(CicoStateMachine* parent);
-
-protected:
-private:
-
-};
-
-/**
- * @brief CicoState::addEntryAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoState::addEntryAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addEntryAction(action, addval);
-}
-
-/**
- * @brief CicoState::addExitAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoState::addExitAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addExitAction(action, addval);
-}
-
-/**
- * @brief CicoState::addDoAction
- * @param action register callback action class
- * @param addval additional value
- */
-inline void CicoState::addDoAction(CicoStateAction* action, int addval)
-{
- CicoStateCore::addDoAction(action, addval);
-}
-
-/**
- * @brief CicoState::getCurrentState
- * @param states active state-object pointers store area
- * @param policy get policy
- * @return true:get success / false:get fail
- */
-inline bool CicoState::getCurrentState(std::vector<const CicoState*>& states,
- CicoStateCore::E_GetPolicy policy)
-{
- return CicoStateCore::getCurrentState(states, policy);
-
-}
-
-/**
- * @brief CicoState::getCurrentState
- * @return active state-object pointer
- */
-inline const CicoState* CicoState::getCurrentState()
-{
- return (CicoState*)CicoStateCore::getCurrentState();
-
-}
-
-/**
- * @brief CicoState::setParent
- * @ set parent(state-object or stateMachine-object)
- * @param parent state-object pointer
- */
-inline void CicoState::setParent(CicoState* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
-
-/**
- * @brief CicoState::setParent
- * @ set parent(state object or stateMachine object)
- * @param parent
- */
-inline void CicoState::setParent(CicoStateMachine* parent)
-{
- CicoStateCore::setParent((CicoStateCore*)parent);
-}
-
-#endif // CICOSTATE_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "CicoStateAction.h"
-
-/**
- * Base class for action execution of entry / exit / do
- * @author m.kamoshida
- * @version 0.1
- */
-/**
- * @brief CicoStateAction::CicoStateAction
- */
-CicoStateAction::CicoStateAction()
-{
-}
-
-/**
- * @brief CicoStateAction::onEntry
- * @param const CicoEvent& trigger event data
- * @param const CicoState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onEntry(const CicoEvent&, const CicoState*, int)
-{
-}
-
-/**
- * @brief CicoStateAction::onEntry
- * @param const CicoEvent& trigger event data
- * @param const CicoFinalState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onEntry(const CicoEvent&, const CicoFinalState*, int)
-{
-}
-
-/**
- * @brief CicoStateAction::onEntry
- * @param const CicoEvent& trigger event data
- * @param const CicoHistoryState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onEntry(const CicoEvent&, const CicoHistoryState*, int)
-{
-}
-
-
-/**
- * @brief CicoStateAction::onExit
- * @param const CicoEvent& trigger event data
- * @param const CicoState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onExit(const CicoEvent&, const CicoState*, int)
-{
-}
-
-/**
- * @brief CicoStateAction::onExit
- * @param const CicoEvent& trigger event data
- * @param const CicoHistoryState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onExit(const CicoEvent&, const CicoHistoryState*, int)
-{
-}
-
-
-/**
- * @brief CicoStateAction::onDo
- * @param const CicoEvent& trigger event data
- * @param const CicoState* Object of the caller
- * @param int Added value at the time of registration action
- */
-void CicoStateAction::onDo(const CicoEvent&, const CicoState*, int)
-{
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOSTATEACTION_H
-#define CICOSTATEACTION_H
-
-#include "CicoEvent.h"
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOHISTORYSTATE_H
-class CicoHistoryState;
-#endif
-
-#ifndef CICOFINALSTATE_H
-class CicoFinalState;
-#endif
-
-/**
- * Base class for action execution of entry / exit / do
- * @author m.kamoshida
- * @version 0.1
- */
-/**
- * @brief The CicoStateAction class
- */
-class CicoStateAction
-{
-public:
- // Constructior
- CicoStateAction();
-
- virtual void onEntry(const CicoEvent& ev, const CicoState* stt,
- int addval);
- virtual void onEntry(const CicoEvent& ev, const CicoFinalState* stt,
- int addval);
- virtual void onEntry(const CicoEvent& ev, const CicoHistoryState* stt,
- int addval);
-
- virtual void onExit(const CicoEvent& ev, const CicoState* stt,
- int addval);
- virtual void onExit(const CicoEvent& ev, const CicoHistoryState* stt,
- int addval);
-
- virtual void onDo(const CicoEvent& ev, const CicoState* stt,
- int addval);
-
-private:
-};
-
-#endif // CICOSTATEACTION_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateAction.h"
-#include "CicoStateCore.h"
-#include "CicoState.h"
-#include "CicoStateInternal.h"
-
-extern bool SttMdbg;
-
-/**
- * It is the core definition of the state transition
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief CicoStateCore::CicoStateCore
- * @param ts type of state-object class
- * @param parent parent state-object
- */
-CicoStateCore::CicoStateCore(E_TOSO ts, CicoStateCore* parent):
- m_eType(ts)
-{
- m_activeState = false;
- m_value = 0;
- m_parent = (CicoStateCore*)0;
- m_existHistoy = false;
- m_stateTermination = (CicoStateCore*)0;
- // Set the parent-child relationship
- addStateF(parent, this);
- initTransition();
- initStartPosition();
- initSttAction();
-}
-
-/**
- * @brief CicoStateCore::CicoStateCore
- * @param ts type of state-object class
- * @param name Identification name
- * @param parent parent state-object
- */
-CicoStateCore::CicoStateCore(E_TOSO ts, const std::string& name,
- CicoStateCore* parent):
- m_name(name), m_eType(ts)
-{
- m_activeState = false;
- m_value = 0;
- m_parent = (CicoStateCore*)0;
- m_existHistoy = false;
- m_stateTermination = (CicoStateCore*)0;
- // Set the parent-child relationship
- addStateF(parent, this);
- initTransition();
- initStartPosition();
- initSttAction();
-}
-
-/**
- * @brief CicoStateCore::CicoStateCore
- * @param ts type of state-object class
- * @param name Identification name
- * @param value Identification number
- * @param parent parent state-object
- */
-CicoStateCore::CicoStateCore(E_TOSO ts, const std::string& name, int value,
- CicoStateCore* parent):
- m_name(name), m_value(value), m_eType(ts)
-{
- m_activeState = false;
- m_parent = (CicoStateCore*)0;
- m_existHistoy = false;
- m_stateTermination = (CicoStateCore*)0;
- // Set the parent-child relationship
- addStateF(parent, this);
- initTransition();
- initStartPosition();
- initSttAction();
-}
-
-/**
- * @brief CicoStateCore::CicoStateCore
- * @param ts type of state-object class
- * @param value Identification number
- * @param parent parent state-object
- */
-CicoStateCore::CicoStateCore(E_TOSO ts, int value, CicoStateCore* parent):
- m_value(value), m_eType(ts)
-{
- m_activeState = false;
- m_parent = (CicoStateCore*)0;
- m_existHistoy = false;
- m_stateTermination = (CicoStateCore*)0;
- // Set the parent-child relationship
- addStateF(parent, this);
- initTransition();
- initStartPosition();
- initSttAction();
-}
-
-/**
- * @brief CicoStateCore::~CicoStateCore
- */
-CicoStateCore::~CicoStateCore()
-{
- // Release area childs state-object
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) {
- delete (m_childs[i]);
- }
- m_childs.clear();
- // transition area clear
- clearTransition();
- // start position area clear
- clearStartPosition();
- // entry/exit/do action are clear
- clearSttAction();
-}
-
-/**
- * state-object activate
- * @param ev trigger event
- * @return
- */
-/**
- * @brief CicoStateCore::start
- * @param ev trigger event data
- * @param parent Operation in the direction of the parent
- * @return true:Activation success false:Activation fail
- */
-bool CicoStateCore::start(const CicoEvent& ev, bool parent)
-{
- if (true == m_activeState) { // Already running state-object
- return false; // do not do anything
- }
-
- toActivate(ev);
-
- if (false == parent) { // Has no parent(Avoid the initialization of the parent)
- return true; // do not do anything
- }
-
- int sz = m_childs.size(); //
- if (0 == sz) { //
- return true; //
- }
-
- // operate starting position
- if (EPDir == m_startPosition.suk) {
- startF(m_startPosition.u.d, ev, true);
- return true;
- }
- else if (EPVec == m_startPosition.suk) {
- // Perform a plurality of start position
- int sz2 = m_startPosition.u.v->size();
- for (int i = 0; i < sz2; i++) {
- startF((*m_startPosition.u.v)[i], ev, true);
- }
- return true;
- }
-
- // Start position is not registered
-#if 0
- {
- std::string s;
- getLogPartF(this, s);
- _INFO("START POSITION IS NOT REGISTERED:%s", s.c_str());
- }
-#endif
- bool dup = false; // duplication
- CicoStateCore* chs = (CicoStateCore*)0;
- for (int i = 0; i < sz; i++) {
- if (true == m_childs[i]->isHistoryState()) {
- if ((CicoStateCore*)0 != chs) {
- dup = true;
- }
- else {
- chs = m_childs[i];
- }
- }
- }
- if (((CicoStateCore*)0 != chs) && (false == dup)) {
- startF(chs, ev, true);
- return true;
- }
- std::vector<CicoStateCore*> sto;
- if (1 != sz) { //
- int cnt = 0;
- getRegisteredInit(sto, cnt);
- if (1 != cnt) {
- {
- std::string s;
- getLogPartF(this, s);
- _ERR("START POSITION IS UNKNOWN:%d:%s", cnt,s.c_str());
- }
- return false;
- }
- }
- else {
- sto.push_back(m_childs[0]);
- }
- sz = sto.size();
- for (int i = 0; i < sz; i++) { //
- startF(sto[i], ev, true); //
- }
- return true;
-}
-
-/**
- * @brief CicoStateCore::stop
- * @param ev trigger event data
- * @return true:Deactivation success false:Deactivation fail
- */
-bool CicoStateCore::stop(const CicoEvent& ev)
-{
- if (false == m_activeState) {
- return false;
- }
- toDeactivate(ev);
- return true;
-}
-
-/**
- * @brief CicoStateCore::setParent
- * @param parent registration parent data
- */
-void CicoStateCore::setParent(CicoStateCore* parent)
-{
- m_parent = parent;
-}
-
-
-/**
- * @brief setParentF
- * @param stt registration target
- * @param parent registration parent data
- */
-void setParentF(CicoStateCore* stt, CicoStateCore* parent)
-{
- stt->setParent(parent);
-}
-
-/**
- * @brief CicoStateCore::setName
- * @param name Identification name
- */
-void CicoStateCore::setName(const std::string& name)
-{
- m_name = name;
-}
-
-/**
- * @brief CicoStateCore::addState
- * @param state child registration data
- */
-void CicoStateCore::addState(CicoStateCore* state)
-{
- if ((CicoStateCore*)0 != state) { // If the parameters are correct
- m_childs.push_back(state); // Recognized as a child
- state->setParent(this); // I'm a parent
- if (true == state->isHistoryState()) { // history state object
- m_existHistoy = true; // flag on
- }
- }
-}
-
-/**
- * @brief CicoStateCore::addTransition
- * @param evInf event registration
- * @param state Transition destination data
- */
-void CicoStateCore::addTransition(const CicoEventInfo& evInf,
- CicoStateCore* state)
-{
- CicoEventInfo *ei = new CicoEventInfo(evInf); // copy object
- ei->setTransition(state); // Set the destination state object
-
- if (EPUnused == m_eventInfo.suk) { // unused
- m_eventInfo.u.d = ei;
- m_eventInfo.suk = EPDir;
- }
- else if (EPDir == m_eventInfo.suk) {
- CicoEventInfo* tmp = m_eventInfo.u.d;
- m_eventInfo.u.d = (CicoEventInfo*)0;
- m_eventInfo.u.v = new std::vector<CicoEventInfo*>;
- m_eventInfo.suk = EPVec;
- m_eventInfo.u.v->push_back(tmp);
- m_eventInfo.u.v->push_back(ei);
- }
- else if (EPVec == m_eventInfo.suk) {
- m_eventInfo.u.v->push_back(ei);
- }
-}
-
-/**
- * @brief CicoStateCore::addInitState
- * @param state start position data
- */
-void CicoStateCore::addInitState(CicoStateCore* state)
-{
- if (EPUnused == m_startPosition.suk) {
- m_startPosition.u.d = state;
- m_startPosition.suk = EPDir;
- }
- else if (EPDir == m_startPosition.suk) {
- CicoStateCore* tmp = m_startPosition.u.d;
- m_startPosition.u.d = (CicoStateCore*)0;
-
- m_startPosition.u.v = new std::vector<CicoStateCore*>;
- m_startPosition.u.v->push_back(tmp);
- m_startPosition.u.v->push_back(state);
- m_startPosition.suk = EPVec;
- }
- else if (EPVec == m_startPosition.suk) {
- m_startPosition.u.v->push_back(state);
- }
-}
-
-/**
- * @brief CicoStateCore::setFinishTransition
- * @param state Transition destination termination detection
- */
-void CicoStateCore::setFinishTransition(CicoStateCore* state)
-{
- m_stateTermination = state;
-}
-
-/**
- * @brief CicoStateCore::addEntryAction
- * @param action registration action
- * @param addval registration additional value number
- */
-void CicoStateCore::addEntryAction(CicoStateAction* action, int addval)
-{
- if ((CicoStateAction*)0 == action) {
- return;
- }
- addAction(m_entry, action, addval);
-}
-
-/**
- * @brief CicoStateCore::addExitAction
- * @param action registration action
- * @param addval registration additional value number
- */
-void CicoStateCore::addExitAction(CicoStateAction* action, int addval)
-{
- if ((CicoStateAction*)0 == action) {
- return;
- }
- addAction(m_exit, action, addval);
-}
-
-/**
- * @brief CicoStateCore::addDoAction
- * @param action registration action
- * @param addval registration additional value number
- */
-void CicoStateCore::addDoAction(CicoStateAction* action, int addval)
-{
- if ((CicoStateAction*)0 == action) {
- return;
- }
- addAction(m_do, action, addval);
-}
-
-/**
- * @brief CicoStateCore::addAction
- * @param ssa Registration destination
- * @param action registration action
- * @param addval registration additional value number
- */
-void CicoStateCore::addAction(stSttAction& ssa, CicoStateAction* action, int addval)
-{
- if (EPUnused == ssa.suk) {
- ssa.u.d.dcsa = action;
- ssa.u.d.dav = addval;
- ssa.suk = EPDir;
- }
- else if (EPDir == ssa.suk) {
- CicoStateAction* tmpActn = ssa.u.d.dcsa;
- int tmpAddval = ssa.u.d.dav;
- ssa.u.d.dcsa = (CicoStateAction*)0;
- ssa.u.d.dav = 0;
- ssa.u.v.vcsa = new std::vector<CicoStateAction*>; // entry action
- ssa.u.v.vav = new std::vector<int>; // entry action additional value
- ssa.suk = EPVec;
- ssa.u.v.vcsa->push_back(tmpActn);
- ssa.u.v.vav->push_back(tmpAddval);
- ssa.u.v.vcsa->push_back(action);
- ssa.u.v.vav->push_back(addval);
-
- }
- else if (EPVec == ssa.suk) {
- ssa.u.v.vcsa->push_back(action);
- ssa.u.v.vav->push_back(addval);
- }
-}
-
-/**
- * @brief CicoStateCore::toActivate
- * @param ev Trigger event data
- */
-void CicoStateCore::toActivate(const CicoEvent& ev)
-{
-
- if (true == m_activeState) {
- return;
- }
-
- if ((CicoStateCore*)0 != m_parent) {
- toActivateF(m_parent, ev);
- }
-
- m_activeState = true; // activate
-
- onEntry(ev); // entry
- if (SttMdbg) {
- std::string sl;
- getLogPartF(this, sl);
- std::string el;
- getLogPartF(ev, el);
- _DBG("%s.toActivate(%s)", sl.c_str(), el.c_str());
- }
-}
-
-/**
- * @brief toActivateF
- * @param stt Activate target
- * @param ev Trigger event data
- */
-void toActivateF(CicoStateCore* stt, const CicoEvent& ev)
-{
- if (stt) {
- stt->toActivate(ev);
- }
-}
-
-/**
- * @brief CicoStateCore::toDeactivate
- * @param ev Trigger event data
- */
-void CicoStateCore::toDeactivate(const CicoEvent& ev)
-{
- if (false == m_activeState) {
- return;
- }
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) {
- toDeactivateF(m_childs[i], ev);
- }
- onExit(ev); // exit
- m_activeState = false; // not active
- if (SttMdbg) {
- std::string sl;
- getLogPartF(this, sl);
- std::string el;
- getLogPartF(ev, el);
- _DBG("%s.toDeactivate(%s)", sl.c_str(), el.c_str());
- }
-}
-
-/**
- * @brief toDeactivateF
- * @param stt Deactivate target
- * @param ev Trigger event data
- */
-void toDeactivateF(CicoStateCore* stt, const CicoEvent& ev)
-{
- if (stt) {
- stt->toDeactivate(ev);
- }
-}
-
-
-/**
- * @brief CicoStateCore::onEntry
- * @param ev Trigger event data
- */
-void CicoStateCore::onEntry(const CicoEvent& ev)
-{
- if (EPDir == m_entry.suk) {
- onEntryRun(m_entry.u.d.dcsa, ev, m_entry.u.d.dav);
- }
- else if (EPVec == m_entry.suk) {
- int sz = m_entry.u.v.vcsa->size();
- for (int i = 0; i < sz; i++) {
- onEntryRun((*m_entry.u.v.vcsa)[i], ev, (*m_entry.u.v.vav)[i]);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::onEntryRun
- * @param run target object
- * @param ev Trigger event data
- * @param val additional value number
- */
-void CicoStateCore::onEntryRun(CicoStateAction* run, const CicoEvent& ev,
- int val)
-{
- if (run) {
- if (true == isState()) {
- run->onEntry(ev, (CicoState*)this, val);
- }
- else if (true == isFinalState()) {
- run->onEntry(ev, (CicoFinalState*)this, val);
- }
- else if (true == isHistoryState()) {
- run->onEntry(ev, (CicoHistoryState*)this, val);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::onExit
- * @param ev Trigger event data
- */
-void CicoStateCore::onExit(const CicoEvent& ev)
-{
- if (EPDir == m_exit.suk) {
- onExitRun(m_exit.u.d.dcsa, ev, m_exit.u.d.dav);
- }
- else if (EPVec == m_exit.suk) {
- int sz = m_exit.u.v.vcsa->size();
- for (int i = 0; i < sz; i++) {
- onExitRun((*m_exit.u.v.vcsa)[i], ev, (*m_exit.u.v.vav)[i]);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::onExitRun
- * @param run target object
- * @param ev Trigger event data
- * @param val additional value number
- */
-void CicoStateCore::onExitRun(CicoStateAction* run, const CicoEvent& ev,
- int val)
-{
- if (run) {
- if (true == isState()) {
- run->onExit(ev, (CicoState*)this, val);
- }
- else if (true == isHistoryState()) {
- run->onExit(ev, (CicoHistoryState*)this, val);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::onDo
- * @param ev Trigger event data
- */
-void CicoStateCore::onDo(const CicoEvent& ev)
-{
- if (EPDir == m_do.suk) {
- onDoRun(m_do.u.d.dcsa, ev, m_do.u.d.dav);
- }
- else if (EPVec == m_do.suk) {
- int sz = m_do.u.v.vcsa->size();
- for (int i = 0; i < sz; i++) {
- onDoRun((*m_do.u.v.vcsa)[i], ev, (*m_do.u.v.vav)[i]);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::onDoRun
- * @param run target object
- * @param ev Trigger event data
- * @param val additional value number
- */
-void CicoStateCore::onDoRun(CicoStateAction* run, const CicoEvent& ev, int val)
-{
- if (run) {
- if (true == isState()) {
- run->onDo(ev, (CicoState*)this, val);
- }
- }
-}
-
-/**
- * @brief CicoStateCore::getActiveSonar
- * @param stt store objects
- * @param impact store impact data
- * @return true:get success fail:get fail
- */
-bool CicoStateCore::getActiveSonar(std::vector<CicoState*>& stt,
- std::vector<E_ActiveImpact>& impact)
-{
- if (false == m_activeState) {
- return false;
- }
- stt.push_back((CicoState*)this);
- impact.push_back(Single);
- int szbk = impact.size();
-
- bool bR = getActiveSonarChild(stt, impact);
- if (true==bR) {
- impact[ szbk-1 ] = Follower; // Single -> Follower
- }
- return true;
-}
-
-/**
- * @brief CicoStateCore::getActiveSonarChild
- * @param stt store objects
- * @param impact store impact data
- * @return true:get success fail:get fail
- */
-bool CicoStateCore::getActiveSonarChild(std::vector<CicoState*>& stt,
- std::vector<E_ActiveImpact>& impact)
-{
- bool bR = false;
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) {
- bR |= (m_childs[i])->getActiveSonar(stt, impact);
- }
- return bR;
-}
-
-/**
- * @brief CicoStateCore::eventTest
- * @param ev event data
- * @param sm my state-machine object
- * @return true:Transition occurs false:The transition has not occurred
- */
-const CicoEventInfo* CicoStateCore::eventTest(const CicoEvent& ev,
- const CicoStateCore* sm) const
-{
- const CicoEventInfo* r = (CicoEventInfo*)0;
- if (EPDir == m_eventInfo.suk) {
- if (true == m_eventInfo.u.d->Judge(ev, sm)) {
- r = m_eventInfo.u.d;
- }
- }
- else if (EPVec == m_eventInfo.suk) {
- int sz = m_eventInfo.u.v->size();
- for (int i = 0; i < sz; i++) {
- const CicoEventInfo* t = (*m_eventInfo.u.v)[i];
- if (true == t->Judge(ev, sm)) { // event match?
- r = t;
- break; // break of for i<sz
- }
- }
- }
- return r;
-}
-
-/**
- * @brief eventTestF
- * @param stt event test target
- * @param ev event data
- * @param sm stt state-machine object
- * @return true:Transition occurs false:The transition has not occurred
- */
-const CicoEventInfo* eventTestF(const CicoStateCore* stt,
- const CicoEvent& ev,
- const CicoStateCore* sm)
-{
- if (stt) {
- return stt->eventTest(ev, sm);
- }
- return (CicoEventInfo*)0;
-}
-
-/**
- * @brief addStateF
- * @param parent parent state-object
- * @param state child state-object
- */
-void addStateF(CicoStateCore* parent, CicoStateCore* state)
-{
- if (parent) {
- parent->addState(state);
- }
-}
-
-/**
- * @brief CicoStateCore::holdHistory
- */
-void CicoStateCore::holdHistory()
-{
- if (false == m_existHistoy) { // have historyState under
- return; // no have is return
- }
- // Ihave history state-object Stores a history
- int sz = m_childs.size(); // get child count
- for (int i = 0; i < sz; i++) { //
- CicoStateCore* t = (m_childs[i]); //
- if (true == t->isHistoryState()) { // is historyState-object?
- holdHistoryF(t);
- }
- }
-}
-
-/**
- * @brief holdHistoryF
- * @param s target state-object
- */
-void holdHistoryF(CicoStateCore* s)
-{
- if (s) {
- s->holdHistory();
- }
-}
-
-/**
- * @brief CicoStateCore::getCurrentState
- * @param states store active state-object data area
- * @param policy get policy
- * @return true:get success false:get fail
- */
-bool CicoStateCore::getCurrentState(std::vector<const CicoState*>& states,
- E_GetPolicy policy)
-{
-
- bool bR = false;
-
- if (ELvlTop == policy) { //
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) {
- CicoStateCore* t = m_childs[i];
- if (true == t->isActive()) { // active ?
- bR = true;
- states.push_back((CicoState*)t);
- }
- }
- }
- else {
- std::vector<CicoState*> stt;
- std::vector<E_ActiveImpact> impact;
- if (true == getActiveSonarChild(stt, impact)) {
- if (ELvlAll == policy) { //
- int sz = impact.size(); //
- for (int i = 0; i < sz; i++) {
- states.push_back(stt[i]);
- }
- bR = true;
- }
- else {
- int sz = impact.size(); //
- for (int i = 0; i < sz; i++) {
- if (Single == impact[i]) {
- bR = true;
- states.push_back(stt[i]);
- }
- }
- }
- }
- }
- return bR;
-}
-
-/**
- * @brief CicoStateCore::getCurrentState
- * @return not 0:active state-object 0:not have active state-object
- */
-const CicoState* CicoStateCore::getCurrentState()
-{
- CicoState* r = (CicoState*)0;
- int sz = m_childs.size();
- for (int i = 0; i < sz; i++) { //
- CicoStateCore* t = m_childs[i];
- if (true == t->isActive()) { // active ?
- r = (CicoState*)t; //
- break; // break of for i
- }
- }
- return r;
-}
-
-/**
- * @brief CicoStateCore::isRegisteredInit
- * @return true:have start position false:not have start position
- */
-bool CicoStateCore::isRegisteredInit() const
-{
- if (EPUnused == m_startPosition.suk) {
- return false;
- }
- return true;
-}
-
-/**
- * @brief CicoStateCore::getRegisteredInit
- * @param stt store start position objects
- * @param cnt store count
- */
-void CicoStateCore::getRegisteredInit(std::vector<CicoStateCore*>& stt,
- int& cnt)
-{
- // operate starting position
- if (EPDir == m_startPosition.suk) {
- stt.push_back(m_startPosition.u.d);
- cnt++;
- }
- else if (EPVec == m_startPosition.suk) {
- // Perform a plurality of start position
- int sz = m_startPosition.u.v->size();
- for (int i = 0; i < sz; i++) {
- stt.push_back((*m_startPosition.u.v)[i]);
- }
- cnt++;
- }
- int sz = m_childs.size(); //
- for (int i = 0; i < sz; i++) { //
- m_childs[i]->getRegisteredInit(stt, cnt);
- }
-}
-
-/**
- * @brief CicoStateCore::stateEnd
- * @param ev trigger event
- */
-void CicoStateCore::stateEnd(const CicoEvent& ev)
-{
- int sz = m_childs.size();
- bool b = false;
- for (int i = 0; i < sz; i++) {
- if (true == (m_childs[i])->isActive()) {
- b = true;
- break; // break of for i
- }
- }
- if (true == b) {
- return;
- }
- if ((CicoStateCore*)0 != m_stateTermination) {
- CicoEventInfo ei("DetectTheEnd", CicoEvent::DetectTheEnd);
- onTransition(ev, this, m_stateTermination);
- return;
- }
- stop(ev);
- stateEndF(m_parent, ev);
-}
-
-/**
- * @brief stateEndF
- * @param stt target objects
- * @param ev trigger event
- */
-void stateEndF(CicoStateCore* stt, const CicoEvent& ev)
-{
- if (stt) {
- stt->stateEnd(ev);
- }
-}
-
-/**
- * @brief CicoStateCore::onTransition
- * @param ev trigger event
- * @param s Transition source
- * @param d Transition destination
- */
-void CicoStateCore::onTransition(const CicoEvent& ev, CicoStateCore* s, CicoStateCore* d)
-{
- std::vector<CicoStateCore*> stpstt;
- stpstt.push_back(s);
-
- std::vector<CicoStateCore*> rts;
- getRoots(s, rts);
- int szs = rts.size();
- if (0!=szs) {
- std::vector<CicoStateCore*> rtd;
- getRoots(d, rtd);
- int szd = rtd.size();
- for (int i = 0; i < szs; i++) {
- for (int j = 0; j < szd; j++) {
- if (rts[i] == rtd[j]) {
- rts[i] = (CicoStateCore*)0;
- break; // break of for j
- }
- }
- if ((CicoStateCore*)0==rts[i]) {
- break; // break of for i
- }
- }
- for (int i = 0; i < szs; i++) {
- if ((CicoStateCore*)0==rts[i]) {
- break; // break of for i
- }
- stpstt.push_back(rts[i]);
- }
- }
- int sz = stpstt.size();
- // store history
- for (int i = 0; i < sz; i++) {
- holdHistoryF(stpstt[i]);
- }
- // stop Transition source
- for (int i = 0; i < sz; i++) {
- (stpstt[i])->stop(ev);
- }
- // start Transition destination
- startF(d, ev, true);
- {
- std::string sl;
- getLogPartF(s, sl);
- std::string el;
- getLogPartF(ev, el);
- std::string dl;
- getLogPartF(d, dl);
- _INFO("TRANSITION:%s-%s->%s", sl.c_str(), el.c_str(), dl.c_str());
- }
-}
-
-/**
- * @brief CicoStateCore::getRoots
- * @param stt base object
- * @param roots store roots object
- */
-void CicoStateCore::getRoots(const CicoStateCore* stt,
- std::vector<CicoStateCore*>& roots)
-{
- const CicoStateCore* p = stt->getParent();
- while ((CicoStateCore*)0 != p) {
- if (true == p->isStateMachine()) { // stateMachine class Object
- break; // breack of while
- }
- roots.push_back((CicoStateCore*)p); // set parent
- p = p->getParent(); // get parent
- }
-}
-
-/**
- * @brief CicoStateCore::onDoExec
- * @param ev triger event
- * @return true:execute false:not execute
- */
-bool CicoStateCore::onDoExec(const CicoEvent& ev)
-{
- bool bR = false;
- if (EPUnused != m_do.suk) {
- onDo(ev);
- bR = true;
- {
- std::string sl;
- getLogPartF(this, sl);
- std::string el;
- getLogPartF(ev, el);
- //_INFO("%s.onDoExec(%s).onDo", sl.c_str(), el.c_str());
- _INFO("TRANSITION:%s-%s(onDo)", sl.c_str(), el.c_str());
- }
- }
- else if (EPUnused != m_entry.suk) {
- onEntry(ev);
- bR = true;
- {
- std::string sl;
- getLogPartF(this, sl);
- std::string el;
- getLogPartF(ev, el);
- // _INFO("%s.onDoExec(%s).onEntry", sl.c_str(), el.c_str());
- _INFO("TRANSITION:%s-%s(onEntry)", sl.c_str(), el.c_str(), sl.c_str());
- }
- }
- else {
- bR = false;
- {
- std::string sl;
- getLogPartF(this, sl);
- std::string el;
- getLogPartF(ev, el);
- _INFO("TRANSITION:%s-%s->%s(no tran.)", sl.c_str(), el.c_str(), sl.c_str());
- }
- }
- return bR;
-}
-
-/**
- * @brief onDoExecF
- * @param s target objects
- * @param ev trigger event
- * @return true:execute false:not execute
- */
-bool onDoExecF(CicoStateCore* s, const CicoEvent& ev)
-{
- if (s) {
- return s->onDoExec(ev);
- }
- return false;
-}
-
-/**
- * @brief CicoStateCore::getState
- * @param value Identification number
- * @return not 0:machi Identification number object
- *@ 0:not find
- */
-const CicoStateCore* CicoStateCore::getState(const int value) const
-{
- if (m_value == value) {
- return this;
- }
- int sz = m_childs.size();
- if (0 != sz) {
- for (int i = 0; i < sz; i++) {
- const CicoStateCore* r;
- r = getStateF(m_childs[i], value);
- if ((CicoStateCore*)0 != r) {
- return r;
- }
- }
- }
- return (CicoStateCore*)0;
-}
-
-/**
- * @brief CicoStateCore::getObjects
- * @param obj store object area
- */
-void CicoStateCore::getObjects(std::vector<CicoStateCore*>& obj)
-{
- obj.push_back(this); // store my state-object pointer
- int sz = m_childs.size();
- for (int i=0; i<sz; i++) {
- m_childs[i]->getObjects(obj); // store childs state-object pointer
- }
-}
-
-/**
- * @brief CicoStateCore::getEventInfo
- * @param name event name
- * @param ev event number
- * @return not 0:machi event object 0:not find
- */
-const CicoEventInfo* CicoStateCore::getEventInfo(const std::string& name,
- unsigned short ev) const
-{
- const CicoEventInfo tei(name, ev);
- const CicoEventInfo* r = (CicoEventInfo*)0;
- if (EPDir == m_eventInfo.suk) {
- if (tei == *m_eventInfo.u.d) {
- r = m_eventInfo.u.d;
- }
- }
- else if (EPVec == m_eventInfo.suk) {
- int sz = m_eventInfo.u.v->size();
- for (int i =0; i < sz; i++) {
- const CicoEventInfo* t = (*m_eventInfo.u.v)[i];
- if (tei == *t) {
- r = t;
- break; // break of for i<sz
- }
- }
- }
- return (CicoEventInfo*)r; // not find
-}
-
-/**
- * @brief getStateF
- * @param s search object top
- * @param value find Identification number
- * @return not 0:match object 0:not find
- */
-const CicoStateCore* getStateF(const CicoStateCore* s, const int value)
-{
- if (s) {
- return s->CicoStateCore::getState(value);
- }
- return (CicoStateCore*)0;
-}
-
-/**
- * @brief CicoStateCore::getState
- * @param name find Identification name
- * @return not 0:match object 0:not find
- */
-const CicoStateCore* CicoStateCore::getState(const std::string& name) const
-{
- if (m_name == name) {
- return this;
- }
- int sz = m_childs.size();
- if (0 != sz) {
- for (int i = 0; i < sz; i++) {
- const CicoStateCore* r;
- r = getStateF(m_childs[i], name);
- if ((CicoStateCore*)0 != r) {
- return r;
- }
- }
- }
- return (CicoStateCore*)0;
-}
-
-/**
- * @brief getStateF
- * @param s search object top
- * @param name find Identification name
- * @return not 0:match object 0:not find
- */
-const CicoStateCore* getStateF(const CicoStateCore* s, const std::string& name)
-{
- if (s) {
- return s->CicoStateCore::getState(name);
- }
- return (CicoStateCore*)0;
-}
-
-/**
- * @brief startF
- * @param s start target object
- * @param e trigger event data
- * @param parent Operation in the direction of the parent
- * @return true:Activation success false:Activation fail
- */
-bool startF(CicoStateCore* s, const CicoEvent& e, bool parent)
-{
- bool bR = false;
- if (s) {
- bR = s->start(e, parent);
- }
- return bR;
-}
-
-/**
- * @brief getLogPartF
- * @param s log target
- * @param l store message area
- */
-void getLogPartF(const CicoStateCore* s, std::string& l)
-{
- std::stringstream stm;
- switch (s->m_eType) { // type my class
- case CicoStateCore::EStateMachine:
- stm << "SM:{"; // SM:{"name":999} image edit
- break;
- case CicoStateCore::EState:
- stm << "S:{"; // S:{"name":999} image edit
- break;
- case CicoStateCore::EHistoryState:
- stm << "HS:{"; // HS:{"name":999} image edit
- break;
- case CicoStateCore::EFinalState:
- stm << "FS:{"; // FS:{"name":999} image edit
- break;
- default:
- stm << "??:{"; // ??:{"name":999} image edit
- break;
- }
- if (!s->getName().empty()) {
- stm << "\"" << s->getName() << "\"";
- }
- stm << ":" << s->getValue() << "}";
- l = stm.str();
-}
-
-/**
- * @brief CicoStateCore::initTransition
- */
-void CicoStateCore::initTransition()
-{
- m_eventInfo.suk = EPUnused; // unused
- // pointer clear
- m_eventInfo.u.d = (CicoEventInfo*)0;
- m_eventInfo.u.v = (std::vector<CicoEventInfo*>*)0;
-}
-
-/**
- * @brief CicoStateCore::initStartPosition
- */
-void CicoStateCore::initStartPosition()
-{
- m_startPosition.suk = EPUnused; // unused
- // pointer clear
- m_startPosition.u.d = (CicoStateCore*)0;
- m_startPosition.u.v = (std::vector<CicoStateCore*>*)0;
-}
-
-/**
- * @brief CicoStateCore::initSttAction
- */
-void CicoStateCore::initSttAction()
-{
- // entry action
- m_entry.suk = EPUnused; // unused
- // entry action pointer clear
- m_entry.u.d.dcsa = (CicoStateAction*)0;
- m_entry.u.d.dav = 0;
- m_entry.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- m_entry.u.v.vav = (std::vector<int>*)0;
-
- // exit action
- m_exit.suk = EPUnused; // unused
- // exit action pointer clear
- m_exit.u.d.dcsa = (CicoStateAction*)0;
- m_exit.u.d.dav = 0;
- m_exit.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- m_exit.u.v.vav = (std::vector<int>*)0;
-
- // do action
- m_do.suk = EPUnused; // unused
- // do action pointer clear
- m_do.u.d.dcsa = (CicoStateAction*)0;
- m_do.u.d.dav = 0;
- m_do.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- m_do.u.v.vav = (std::vector<int>*)0;
-}
-
-/**
- * @brief CicoStateCore::clearTransition
- */
-void CicoStateCore::clearTransition()
-{
- if (EPVec == m_eventInfo.suk) {
- if ((std::vector<CicoEventInfo*>*)0 != m_eventInfo.u.v) {
- int sz = m_eventInfo.u.v->size();
- for (int i = 0; i < sz; i++) {
- delete (*m_eventInfo.u.v)[i];
- }
- m_eventInfo.u.v->clear(); // vector entry data clear
- delete m_eventInfo.u.v;
- m_eventInfo.u.v = (std::vector<CicoEventInfo*>*)0;
- }
- }
- else if (EPDir == m_eventInfo.suk) {
- delete m_eventInfo.u.d;
- m_eventInfo.u.d = (CicoEventInfo*)0;
- }
- m_eventInfo.suk = EPUnused; // unused
-}
-
-/**
- * @brief CicoStateCore::clearStartPosition
- */
-void CicoStateCore::clearStartPosition()
-{
- if (EPVec == m_startPosition.suk) {
- if ((std::vector<CicoStateCore*>*)0 != m_startPosition.u.v) {
- m_startPosition.u.v->clear();
- delete m_startPosition.u.v;
- m_startPosition.u.v = (std::vector<CicoStateCore*>*)0;
- }
- }
- else if (EPDir == m_startPosition.suk) {
- m_startPosition.u.d = (CicoStateCore*)0;
- }
- m_startPosition.suk = EPUnused; // unused
-}
-
-/**
- * @brief CicoStateCore::clearSttAction
- */
-void CicoStateCore::clearSttAction()
-{
- // entry action
- if (EPVec == m_entry.suk) {
- if ((std::vector<CicoStateAction*>*)0 != m_entry.u.v.vcsa) {
- m_entry.u.v.vcsa->clear();
- delete m_entry.u.v.vcsa;
- m_entry.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- }
- if ((std::vector<int>*)0 != m_entry.u.v.vav) {
- m_entry.u.v.vav->clear();
- delete m_entry.u.v.vav;
- m_entry.u.v.vav = (std::vector<int>*)0;
- }
- }
- else if (EPDir == m_entry.suk) {
- m_entry.u.d.dcsa = (CicoStateAction*)0;
- m_entry.u.d.dav = 0;
- }
- m_entry.suk = EPUnused; // unused
-
- // exit action
- if (EPVec == m_exit.suk) {
- if ((std::vector<CicoStateAction*>*)0 != m_exit.u.v.vcsa) {
- m_exit.u.v.vcsa->clear();
- delete m_exit.u.v.vcsa;
- m_exit.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- }
- if ((std::vector<int>*)0 != m_exit.u.v.vav) {
- m_exit.u.v.vav->clear();
- delete m_exit.u.v.vav;
- m_exit.u.v.vav = (std::vector<int>*)0;
- }
- }
- else if (EPDir == m_exit.suk) {
- m_exit.u.d.dcsa = (CicoStateAction*)0;
- m_exit.u.d.dav = 0;
- }
- m_exit.suk = EPUnused; // unused
-
- // do action
- if (EPVec == m_do.suk) {
- if ((std::vector<CicoStateAction*>*)0 != m_do.u.v.vcsa) {
- m_do.u.v.vcsa->clear();
- delete m_do.u.v.vcsa;
- m_do.u.v.vcsa = (std::vector<CicoStateAction*>*)0;
- }
- if ((std::vector<int>*)0 != m_do.u.v.vav) {
- m_do.u.v.vav->clear();
- delete m_do.u.v.vav;
- m_do.u.v.vav = (std::vector<int>*)0;
- }
- }
- else if (EPDir == m_do.suk) {
- m_do.u.d.dcsa = (CicoStateAction*)0;
- m_do.u.d.dav = 0;
- }
- m_do.suk = EPUnused; // unused
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOSTATECORE_H
-#define CICOSTATECORE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoEvent.h"
-
-#ifndef CICOEVENTINFO_H
-class CicoEventInfo;
-#endif
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOSTATEACTION_H
-class CicoStateAction;
-#endif
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-#ifndef CICOSTAEACTION_H
-class CicoStateAction;
-#endif
-
-#ifndef CICOHISTORYSTATE_H
-class CicoHistoryState;
-#endif
-
-
-/**
- * It is the core definition of the state transition
- * @author m.kamoshida
- * @version 0.1
- */
-/**
- * @brief The CicoStateCore class
- */
-class CicoStateCore {
-public:
- // Type of state object
- enum E_TOSO {
- EStateMachine = 0, // kind of stateMachine object
- EState, // kind of state object
- EHistoryState, // kind of history state object
- EFinalState // kind of final state 0bject
- };
-
- enum E_GetPolicy { // get current state policy
- ELvlTop = 0, // First-degree active state
- ELvlAll, // ALL active state
- ELvlBttm // Buttom active state
- };
- // Constructior
- CicoStateCore(E_TOSO ts, CicoStateCore* parent =0);
- CicoStateCore(E_TOSO ts, const std::string& name,
- CicoStateCore* parent =0);
- CicoStateCore(E_TOSO ts, const std::string& name, int value,
- CicoStateCore* parent =0);
- CicoStateCore(E_TOSO ts, int value, CicoStateCore* parent =0);
-
- // destructor
- virtual ~CicoStateCore();
-
- // Identification name get/set
- const std::string& getName() const;
- void setName(const std::string& name);
-
- // Identification number get/set
- int getValue() const;
- void setValue(int value);
-
- // get parent
- const CicoStateCore* getParent() const;
-
- // active/inactive get
- bool isActive() const; // active state
-
- // get object kind
- E_TOSO getType() const;
- bool isStateMachine() const;
- bool isState() const;
- bool isFinalState() const;
- bool isHistoryState() const;
-
- bool isRegisteredInit() const;
-
- // c-wrapper I/F
- void getObjects(std::vector<CicoStateCore*>& obj);
- const CicoEventInfo* getEventInfo(const std::string& name,
- unsigned short ev) const;
-protected:
- /**
- * union kind type
- */
- enum E_SttUnionKind {
- EPUnused = 0, // unused
- EPDir, // pointer direct
- EPVec // pointer vector
- };
-
- /**
- * event infomation define
- */
- typedef struct {
- E_SttUnionKind suk;
- union {
- CicoEventInfo* d; // direct pointer
- std::vector<CicoEventInfo*>* v; // vecter pointers
- } u;
- } stEventInfo;
-
- /**
- * start position define
- */
- typedef struct {
- E_SttUnionKind suk; // union kind
- union {
- CicoStateCore* d; // direct pointer
- std::vector<CicoStateCore*>* v; // vector pointers
- } u;
- } stStartPosition;
-
- /**
- * StateAction define
- */
- typedef struct {
- CicoStateAction* dcsa; // direct pointer
- int dav; // additional value
- } stDirSttAction;
-
- typedef struct {
- std::vector<CicoStateAction*>* vcsa; // vector pointers
- std::vector<int>* vav; // vector additional values
- } stVecSttAction;
-
- typedef struct {
- E_SttUnionKind suk; // union kind
- union {
- stDirSttAction d; // direct data
- stVecSttAction v; // vector datas
- } u;
- } stSttAction;
-
- // my area operations
- void initTransition();
- void initStartPosition();
- void initSttAction();
-
- void clearTransition();
- void clearStartPosition();
- void clearSttAction();
-
-
-
- void setParent(CicoStateCore* parent);
- friend void setParentF(CicoStateCore* stt, CicoStateCore* parent);
-
-
- void addState(CicoStateCore* state);
- friend void addStateF(CicoStateCore* parent, CicoStateCore* state);
-
-
- void setFinishTransition(CicoStateCore* state);
-
-
- void addTransition(const CicoEventInfo& evInf,
- CicoStateCore* state);
-
-
- void addInitState(CicoStateCore* state);
-
-
- void addEntryAction(CicoStateAction* action, int addval);
-
-
- void addExitAction(CicoStateAction* action, int addval);
-
-
- void addDoAction(CicoStateAction* action, int addval);
-
-
- void addAction(stSttAction& ssa, CicoStateAction* action,
- int addval);
-
-
- void toActivate(const CicoEvent& ev);
- friend void toActivateF(CicoStateCore* stt, const CicoEvent& ev);
-
-
- void toDeactivate(const CicoEvent& ev);
- friend void toDeactivateF(CicoStateCore* stt, const CicoEvent& ev);
-
-
- void onEntry(const CicoEvent& ev);
- void onExit(const CicoEvent& ev);
- void onDo(const CicoEvent& ev);
- void onEntryRun(CicoStateAction* run, const CicoEvent& ev, int val);
- void onExitRun(CicoStateAction* run, const CicoEvent& ev, int val);
- void onDoRun(CicoStateAction* run, const CicoEvent& ev, int val);
-
- enum E_ActiveImpact {
- Single = 0, // is Active
- Follower // is Follower active
- };
- // get active state-objects
- bool getActiveSonar(std::vector<CicoState*>& stt,
- std::vector<E_ActiveImpact>& impact);
- //
- bool getActiveSonarChild(std::vector<CicoState*>& stt,
- std::vector<E_ActiveImpact>& impact);
-
- //
- const CicoEventInfo* eventTest(const CicoEvent& ev,
- const CicoStateCore* sm) const;
- //
- friend const CicoEventInfo* eventTestF(const CicoStateCore* stt,
- const CicoEvent& ev,
- const CicoStateCore* sm);
-
- // start state-object Activation
- virtual bool start(const CicoEvent& ev, bool parent = true);
- friend bool startF(CicoStateCore* s, const CicoEvent& ev, bool parent);
-
- // stop state-object Deactivation
- virtual bool stop(const CicoEvent& ev);
-
- //
- virtual void holdHistory(); // Hold History
- friend void holdHistoryF(CicoStateCore* s);
-
- //
- bool getCurrentState(std::vector<const CicoState*>& states,
- E_GetPolicy policy);
- const CicoState* getCurrentState(); //
- friend bool getCurrentStateF(CicoStateCore* stt,
- std::vector<const CicoState*>& states,
- E_GetPolicy policy);
-
- void getRegisteredInit(std::vector<CicoStateCore*>& stt, int& cnt);
-
- //
- void stateEnd(const CicoEvent& ev);
- friend void stateEndF(CicoStateCore* stt, const CicoEvent& ev);
-
- // The transition from s to d
- void onTransition(const CicoEvent& ev, CicoStateCore* s, CicoStateCore* d);
-
- //
- void getRoots(const CicoStateCore* stt, std::vector<CicoStateCore*>& roots);
-
- // do action system
- bool onDoExec(const CicoEvent& ev);
- friend bool onDoExecF(CicoStateCore* s, const CicoEvent& ev);
-
- //
- const CicoStateCore* getState(const int value) const;
- const CicoStateCore* getState(const std::string& name) const;
- friend const CicoStateCore* getStateF(const CicoStateCore* s,
- const int value);
- friend const CicoStateCore* getStateF(const CicoStateCore* s,
- const std::string& name);
-
- // log
- friend void getLogPartF(const CicoStateCore* s, std::string& l);
-
-protected:
- bool m_activeState;
- std::string m_name; // identification name
- int m_value; // identification number
- E_TOSO m_eType; // type my class
- CicoStateCore* m_parent; // parent state object
- std::vector<CicoStateCore*> m_childs; // Child state-objects
- bool m_existHistoy; // flag History holder
- CicoStateCore* m_stateTermination; //
- // transition datas
- stEventInfo m_eventInfo;
- // start position
- stStartPosition m_startPosition;
- // entry action
- stSttAction m_entry;
- // exit action
- stSttAction m_exit;
- // do action
- stSttAction m_do;
-
-private:
-
-};
-
-/**
- * @brief CicoStateCore::getName
- * @ get state-object identification nemae
- * @return state-object identification name
- */
-inline const std::string& CicoStateCore::getName() const
-{
- return m_name;
-}
-
-/**
- * @brief CicoStateCore::getValue
- * @ get state-object identification number
- * @return state-object identification number
- */
-inline int CicoStateCore::getValue() const
-{
- return m_value;
-}
-
-/**
- * @brief CicoStateCore::setValue
- * @ set state-object identification number
- * @paran value identification number
- */
-inline void CicoStateCore::setValue(int value)
-{
- m_value = value;
-}
-
-/**
- * @brief CicoStateCore::getParent
- * @return not 0:parent state-object pointer / 0:none parent
- */
-inline const CicoStateCore* CicoStateCore::getParent() const
-{
- return m_parent; // parent state object
-}
-
-/**
- * @brief CicoStateCore::getType
- * @return type of state-object class
- */
-inline CicoStateCore::E_TOSO CicoStateCore::getType() const
-{
- return m_eType;
-}
-
-/**
- * @brief CicoStateCore::isActive
- * get active/notactive status
- * @return active state true:active / false:not active
- */
-inline bool CicoStateCore::isActive() const
-{
- return m_activeState;
-}
-
-/**
- * @brief CicoStateCore::isStateMachine
- * @return true:stateMachine-object
- * @ false:none stateMachine-object
- */
-inline bool CicoStateCore::isStateMachine() const
-{
- if (EStateMachine == m_eType) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateCore::isState
- * @return true:state-object
- * @ false:none state-object
- */
-inline bool CicoStateCore::isState() const
-{
- if (EState == m_eType) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateCore::isFinalState
- * @return true:finalState-object
- * @ false:none finaltate-object
- */
-inline bool CicoStateCore::isFinalState() const
-{
- if (EFinalState == m_eType) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateCore::isHistoryState
- * @return true:historyState-object
- * @ false:none historystate-object
- */
-inline bool CicoStateCore::isHistoryState() const
-{
- if (EHistoryState == m_eType) {
- return true;
- }
- return false;
-}
-/**
- * @brief getLogPartF
- * @param e
- * @param l
- */
-void getLogPartF(const CicoEvent& e, std::string& l);
-
-/**
- * @brief getLogPartF
- * @param e
- * @param l
- */
-void getLogPartF(const CicoEventInfo& e, std::string& l);
-
-#endif // CICOSTATECORE_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOSTATEINTERNAL_H
-#define CICOSTATEINTERNAL_H
-
-/**
- * state machine internal
- * log define
- * LOG_CICO, LOG_CONSOLE,
- */
-
-#include <cstdio>
-#include <cstdlib>
-
-#define LOG_TAG "STT_MCN"
-
-#ifdef LOG_CICO
-# include <ico_log.h>
-# define _ERR(fmt, ...) ICO_ERR(fmt, ##__VA_ARGS__)
-# define _INFO(fmt, ...) ICO_INF(fmt, ##__VA_ARGS__)
-# define _DBG(fmt, ...) ICO_DBG(fmt, ##__VA_ARGS__)
-#else // LOG_ICO
-# ifdef LOG_CONSOLE
-
-# define _ERR(fmt, arg...) \
- do {fprintf(stderr, "SttM: " fmt "\n", ##arg);}while (0)
-
-# define _INFO(fmt, arg...) \
- do {fprintf(stdout, fmt "\n", ##arg);} while (0)
-
-# define _DBG(fmt, arg...) \
- do { \
- if (getenv("SttM_DEBUG")) { \
- fprintf(stdout, fmt "\n",##arg); \
- }while (0)
-# else // LOG_CONSOLE
-# include <dlog.h>
-# ifdef _DLOG_H_
-
-# define _ERR(fmt, arg...) \
- do { \
- fprintf(stderr, "SttM: " fmt "\n", ##arg); \
- LOGE(fmt, ##arg); \
- }while (0)
-
-# define _INFO(...) LOGI(__VA_ARGS__)
-
-# define _DBG(...) LOGD(__VA_ARGS__)
-# else // _DLOG_H_
-# define _ERR(fmt, arg...)
-
-# define _INFO(fmt, arg...)
-
-# define _DBG(fmt, arg...)
-
-# endif // _DLOG_H_
-# endif // LOG_CONSOLE
-#endif // LOG_ICO
-
-#endif // CICOSTATEINTERNAL_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateCore.h"
-#include "CicoState.h"
-#include "CicoHistoryState.h"
-#include "CicoFinalState.h"
-#include "CicoStateMachine.h"
-#include "CicoStateInternal.h"
-
-#if 1
-bool SttMdbg = false;
-#else
-bool SttMdbg = true;
-#endif
-
-/**
- * state-machine object class definition
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief CicoStateMachine::CicoStateMachine
- * @param value Identification number
- */
-CicoStateMachine::CicoStateMachine(int value):
- CicoStateCore(EStateMachine, value)
-{
- m_eventExec = false; // During event processing flag
-}
-
-/**
- * @brief CicoStateMachine::CicoStateMachine
- * @param name Identification name
- * @param value Identification number
- */
-CicoStateMachine::CicoStateMachine(const std::string& name, int value):
- CicoStateCore(EStateMachine, name, value)
-{
- m_eventExec = false; // During event processing flag
-}
-
-/**
- * @brief CicoStateMachine::eventEntry
- * @param ev delivery of the event
- * @return true:Transition occurs false:The transition has not occurred
- */
-bool CicoStateMachine::eventEntry(const CicoEvent& ev)
-{
- if (SttMdbg) {
- std::string el;
- getLogPartF(ev, el);
- _DBG("CicoStateMachine::eventEntry(%s)", el.c_str());
- }
- if (true == m_eventExec) { // Execution of the request will not be accepted during execution
- if (SttMdbg) {
- _DBG("CicoStateMachine::eventEntry() not be accepted");
- }
- return false;
- }
- m_eventExec = true; // During event processing flag
-
- std::vector<CicoState*> stt; // store active state-objects
- std::vector<CicoStateCore::E_ActiveImpact> impact; // inpact flag area
- if (false == getActiveSonarChild(stt, impact)) { // get active objects and flags
- // get fail
- m_eventExec = false; // During event processing flag off
- if (SttMdbg) {
- _DBG("false=CicoStateMachine::eventEntry() P1");
- }
- return false;
- }
- int sz = stt.size();
- if (0==sz) {
- m_eventExec = false; // During event processing flag off
- if (SttMdbg) {
- _DBG("false=CicoStateMachine::eventEntry() P2");
- }
- return false;
- }
- bool bR = false;
- for (int i=0; i< sz; i++) { // sz is get active state-objects count
- CicoStateCore* s = (CicoStateCore*)stt[i]; // get target
- if (false == s->isActive()) { // inactive ?
- continue; // next state-object
- }
- const CicoEventInfo* evi = eventTestF(s, ev, this); //
- if ((CicoEventInfo*)0 == evi) { //
- continue; // next state-objects
- }
- CicoStateCore* ds = evi->getTransition(); // Gets the transition destination
- /*
- * ev transition event trigger
- * s transition source
- * evi registration event data
- * ds transition destination
- */
- if (SttMdbg) {
- std::string eil;
- getLogPartF(*evi, eil);
- _DBG("CicoStateMachine::eventEntry match %s", eil.c_str());
- }
- if (((CicoStateCore*)0 != ds) && (s != ds)) {
- onTransition(ev, s, ds); // transition request
- bR = true;
- }
- else {
- bR = onDoExecF(s, ev);
- }
- }
- m_eventExec = false; // During event processing flag off
- if (SttMdbg) {
- _DBG("%s=CicoStateMachine::eventEntry() P3", bR?"true":"false");
- }
- return bR;
-}
-
-/**
- * @brief CicoStateMachine::eventTest
- * @param ev delivery of the event
- * @return true:Transition occurs false:The transition has not occurred
- */
-bool CicoStateMachine::eventTest(const CicoEvent& ev)
-{
- if (SttMdbg) {
- std::string el;
- getLogPartF(ev, el);
- _DBG("CicoStateMachine::eventTest(%s)", el.c_str());
- }
- if (true == m_eventExec) { // Execution of the request will not be accepted during execution
- if (SttMdbg) {
- _DBG("CicoStateMachine::eventTest() not be accepted");
- }
- return false;
- }
- std::vector<CicoState*> stt;
- std::vector<CicoStateCore::E_ActiveImpact> impact;
- if (false == getActiveSonarChild(stt, impact)) {
- // get fail
- if (SttMdbg) {
- _DBG("false=CicoStateMachine::eventTest() P1");
- }
- return false;
- }
- int sz = stt.size();
- if (0==sz) {
- if (SttMdbg) {
- _DBG("false=CicoStateMachine::eventTest() P2");
- }
- return false;
- }
- bool bR = false;
- for (int i=0; i< sz; i++) {
- CicoStateCore* s = (CicoStateCore*)stt[i];
- if (false == s->isActive()) {
- continue;
- }
- const CicoEventInfo* evi = eventTestF(s, ev, this);
- if ((CicoEventInfo*)0 != evi) {
- bR = true;
- break;
- }
- }
- if (SttMdbg) {
- _DBG("%s=CicoStateMachine::() P3", bR?"true":"false");
- }
- return bR;
-}
-
-
-/**
- * @brief CicoStateMachine::start
- * @return true:start success false:start fail
- */
-bool CicoStateMachine::start()
-{
- CicoEvent e(CicoEvent::Start);
- return CicoStateCore::start(e);
-}
-
-/**
- * @brief CicoStateMachine::stop
- * @return true:stop success false:stop fail
- */
-bool CicoStateMachine::stop()
-{
- CicoEvent e(CicoEvent::Stop);
- return CicoStateCore::stop(e);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef CICOSTATEMACHINE_H
-#define CICOSTATEMACHINE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include "CicoStateCore.h"
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOFINALSTATE_H
-class CicoFinalState;
-#endif
-
-#ifndef CICOHISTORYSTATE_H
-class CicoHistoryState;
-#endif
-
-
-/**
- * state-machine object class definition
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief The CicoStateMachine class
- * state-machine object class definition
- */
-class CicoStateMachine : public CicoStateCore
-{
-public:
- // Constructior
- CicoStateMachine(int value = 0);
- CicoStateMachine(const std::string& name, int value = 0);
-
- // registration state/historyState/fainalState objects
- void addState(CicoState* state);
- void addState(CicoFinalState* state);
- void addState(CicoHistoryState* state);
-
- // registration start position
- void addInitState(CicoState* state);
- void addInitState(CicoHistoryState* state);
-
- // start state-machine
- bool start();
-
- // Delivery of the event
- bool eventEntry(const CicoEvent& ev);
- // Test event delivery
- bool eventTest(const CicoEvent& ev);
-
- // stop state-machine
- bool stop();
-
- // Acquisition of state-objects is registered
- const CicoStateCore* getState(const int value) const;
- const CicoStateCore* getState(const std::string& name) const;
-
- // get current active state-objects
- bool getCurrentState(std::vector<const CicoState*>& states,
- CicoStateCore::E_GetPolicy policy=CicoStateCore::ELvlBttm);
- const CicoState* getCurrentState();
-
-protected:
-private:
- bool m_eventExec; // During event processing flag
-};
-
-/**
- * @brief CicoStateMachine::addState
- * @param state register child state-object pointer
- */
-inline void CicoStateMachine::addState(CicoState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoStateMachine::addState
- * @param state register child state-object pointer
- */
-inline void CicoStateMachine::addState(CicoFinalState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoStateMachine::addState
- * @param state register child state-object pointer
- */
-inline void CicoStateMachine::addState(CicoHistoryState* state)
-{
- CicoStateCore::addState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoStateMachine::addInitState
- * @param state
- * @param state state-object pointer is tart position
- */
-inline void CicoStateMachine::addInitState(CicoState* state)
-{
- CicoStateCore::addInitState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoStateMachine::addInitState
- * @param state state-object pointer is tart positions
- */
-inline void CicoStateMachine::addInitState(CicoHistoryState* state)
-{
- CicoStateCore::addInitState((CicoStateCore*)state);
-}
-
-/**
- * @brief CicoStateMachine::getCurrentState
- * @param states active state-object pointers store area
- * @param policy get policy
- * @return true:get success / false get fail
- */
-inline bool CicoStateMachine::getCurrentState(std::vector<const CicoState*>& states,
- CicoStateCore::E_GetPolicy policy)
-{
- return CicoStateCore::getCurrentState(states, policy);
-}
-
-/**
- * @brief CicoStateMachine::getCurrentState
- * @ get active state-object
- * @return active state-object pointer
- */
-inline const CicoState* CicoStateMachine::getCurrentState()
-{
- return CicoStateCore::getCurrentState();
-}
-
-/**
- * @brief CicoStateMachine::getState
- * @param value state-object identification number
- * @return not 0:state-object pointer/0 get fail
- */
-inline const CicoStateCore* CicoStateMachine::getState(const int value) const
-{
- return CicoStateCore::getState(value);
-}
-
-/**
- * @brief CicoStateMachine::getState
- * @param name state-object identification name
- * @return not 0:state-object pointer/0 get fail
- */
-inline const CicoStateCore* CicoStateMachine::getState(const std::string& name) const
-{
- return CicoStateCore::getState(name);
-}
-
-#endif // CICOSTATEMACHINE_H
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <fstream>
-
-#include "CicoBlockParser.h"
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateCore.h"
-#include "CicoState.h"
-#include "CicoHistoryState.h"
-#include "CicoFinalState.h"
-#include "CicoStateMachine.h"
-#include "CicoStateMachineCreator.h"
-
-#include "picojson.h"
-
-/**
- * state-machine produce from the definition file or string
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief CicoStateMachineCreator::createFile
- * @ state-machine produce from the definition file
- * @param filename state-machine definition file
- * @return not 0: create stateMachine-object pointer
- * @ 0:create fail
- */
-CicoStateMachine* CicoStateMachineCreator::createFile(const std::string& filename)
-{
- m_err.clear();
- char tmp[512];
- std::string readtmp("");
- std::ifstream ifs;
- ifs.open(filename.c_str());
- if (ifs) {
- while (!ifs.eof()) {
- ifs.getline(tmp, sizeof(tmp));
- readtmp += std::string(tmp);
- }
- ifs.close();
- }
- if (!readtmp.empty()) {
- return create(readtmp.c_str());
- }
- else {
- m_err = std::string("file fail");
- }
- return (CicoStateMachine*)0;
-}
-
-/**
- * @brief CicoStateMachineCreator::create
- * @ state-machine produce from the definition string
- * @param sttdef state-machine definition string
- * @return not 0: create stateMachine-object pointer
- * @ 0:create fail
- */
-CicoStateMachine* CicoStateMachineCreator::create(const char* sttdef)
-{
- m_err.clear();
- CicoBlockParser cbp;
- if (false == cbp.getStateMachineParts(sttdef)) { // parse
- m_err = cbp.getError();
- return (CicoStateMachine*)0;
- }
- if (CicoBlockParser::STTMAC != cbp.m_kind) { // Failure to obtain staeMachine
- m_err = "Failure to obtain staeMachine";
- return (CicoStateMachine*)0;
- }
- CreateStateObjects(cbp);
- CicoStateMachine* csm = (CicoStateMachine*)cbp.getVoid();
- if (!m_err.empty()) {
- if ((CicoStateMachine*)0 != csm) {
- delete csm;
- }
- return (CicoStateMachine*)0;
- }
- setConnect(cbp, csm);
- if (!m_err.empty()) {
- if ((CicoStateMachine*)0 != csm) {
- delete csm;
- }
- return (CicoStateMachine*)0;
- }
- return csm;
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateStateObjects
- * @param cbp state-object json definition parts
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::CreateStateObjects(CicoBlockParser& cbp, CicoStateCore* parent)
-{
- if (CicoBlockParser::EV == cbp.m_kind) {
- return;
- }
- switch (cbp.m_kind) {
- case CicoBlockParser::STTMAC: // stateMachine
- CreateStateMachine(cbp);
- break;
- case CicoBlockParser::STT: // state
- CreateState(cbp, parent);
- break;
- case CicoBlockParser::HSTT: // history state
- CreateHistoryState(cbp, parent);
- break;
- case CicoBlockParser::FSTT: // final state
- CreateFinalState(cbp, parent);
- break;
- default:
- break;
- }
- if (!m_err.empty()) {
- return;
- }
- CicoStateCore* my = (CicoStateCore*)cbp.getVoid();
- if ((CicoStateCore*)0 == my) {
- m_err = "create error state object";
- return;
- }
- int sz = cbp.m_childs.size();
- for (int i=0; i<sz; i++) {
- CreateStateObjects(*cbp.m_childs[i], my);
- if (!m_err.empty()) {
- return;
- }
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateStateMachine
- * @param cbp definition stateMachine-object json parts
- */
-void CicoStateMachineCreator::CreateStateMachine(CicoBlockParser& cbp)
-{
- if (false == cbp.isJsonParse()) {
- if (false == cbp.jsonParse(DKstateMachine)) {
- m_err = cbp.getError();
- return;
- }
- }
- picojson::object o = cbp.m_v.get(DKstateMachine).get<picojson::object>();
- std::string name;
- int value = 0;
- bool bn = parseName(o, name);
- bool bv = parseValueI(o, value);
- if ((true == bn) || (true == bv)) {
- CicoStateMachine* csm = new CicoStateMachine(name, value);
- cbp.setVoid((void*)csm);
- }
- else {
- std::ostringstream stream;
- if (false == cbp.m_parts.empty()) {
- std::string h;
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- stream << "stateMachine define error:" << h;
- }
- else {
- stream << "stateMachine unkown";
- }
- m_err = stream.str();
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateState
- * @param cbp definition state-object json parts
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::CreateState(CicoBlockParser& cbp,
- CicoStateCore* parent)
-{
- if (false == cbp.isJsonParse()) {
- if (false == cbp.jsonParse(DKstate)) {
- m_err = cbp.getError();
- return;
- }
- }
- picojson::object o = cbp.m_v.get(DKstate).get<picojson::object>();
- std::string name;
- int value = 0;
- bool bn = parseName(o, name);
- bool bv = parseValueI(o, value);
- if ((true == bn) || (true == bv)) {
- CicoState* cs = (CicoState*)0;
- if (true == parent->isStateMachine()) {
- cs = new CicoState(name, value, (CicoStateMachine*)parent);
- }
- else if (true == parent->isState()) {
- cs = new CicoState(name, value, (CicoState*)parent);
- }
-
- if ((CicoState*)0 != cs) {
- cbp.setVoid((void*)cs);
- }
- }
- else {
- std::ostringstream stream;
- if (false == cbp.m_parts.empty()) {
- std::string h;
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- stream << "state define error:" << h;
- }
- else {
- stream << "state unkown";
- }
- m_err = stream.str();
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateHistoryState
- * @param cbp definition historyState-object json parts
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::CreateHistoryState(CicoBlockParser& cbp,
- CicoStateCore* parent)
-{
- if (false == cbp.isJsonParse()) {
- if (false == cbp.jsonParse(DKhistoryState)) {
- m_err = cbp.getError();
- return;
- }
- }
- std::string h;
- if (false == cbp.m_parts.empty()) {
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- }
- picojson::object o = cbp.m_v.get(DKhistoryState).get<picojson::object>();
- std::string name;
- int value = 0;
- bool bn = parseName(o, name);
- bool bv = parseValueI(o, value);
- CicoHistoryState::E_HType eht = CicoHistoryState::Shallow;
- if (false == parseHistoryType(o, eht)) {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "history type define error:" << h;
- }
- else {
- stream << "history unkown";
- }
- m_err = stream.str();
- return;
- }
- if ((true == bn) || (true == bv)) {
- CicoHistoryState* chs = (CicoHistoryState*)0;
- if (true == parent->isStateMachine()) {
- chs = new CicoHistoryState(name, value, (CicoStateMachine*)parent);
- }
- else if (true == parent->isState()) {
- chs = new CicoHistoryState(name, value, (CicoState*)parent);
- }
-
- if ((CicoHistoryState*)0 != chs) {
- cbp.setVoid((void*)chs);
- chs->setHistoryType(eht);
- }
- }
- else {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "historyState define error:" << h;
- }
- else {
- stream << "historyState unkown";
- }
- m_err = stream.str();
- return;
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateFinalState
- * @param cbp definition finalState-object json parts
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::CreateFinalState(CicoBlockParser& cbp,
- CicoStateCore* parent)
-{
- if (false == cbp.isJsonParse()) {
- if (false == cbp.jsonParse(DKfinalState)) {
- m_err = cbp.getError();
- return;
- }
- }
- picojson::object o = cbp.m_v.get(DKfinalState).get<picojson::object>();
- std::string name;
- int value = 0;
- bool bn = parseName(o, name);
- bool bv = parseValueI(o, value);
- if ((true == bn) || (true == bv)) {
- CicoFinalState* cfs = (CicoFinalState*)0;
- if (true == parent->isStateMachine()) {
- cfs = new CicoFinalState(name, value, (CicoStateMachine*)parent);
- }
- else if (true == parent->isState()) {
- cfs = new CicoFinalState(name, value, (CicoState*)parent);
- }
-
- if ((CicoFinalState*)0 != cfs) {
- cbp.setVoid((void*)cfs);
- }
- }
- else {
- std::ostringstream stream;
- if (false == cbp.m_parts.empty()) {
- std::string h;
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- stream << "finalState define error:" << h;
- }
- else {
- stream << "finalState unkown";
- }
- m_err = stream.str();
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::setConnect
- * Registration of transition information
- * @param cbp definition json parts
- * @param csm stateMachine object pointer
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::setConnect(CicoBlockParser& cbp,
- CicoStateMachine* csm,
- CicoStateCore* parent)
-{
- switch (cbp.m_kind) {
- case CicoBlockParser::STTMAC: // stateMachine
- setConnectStateMachine(cbp, csm);
- break;
- case CicoBlockParser::STT: // state
- setConnectState(cbp, csm);
- break;
- case CicoBlockParser::HSTT: // history state
- setConnectHistoryState(cbp, csm);
- break;
- case CicoBlockParser::FSTT: // final state
- break;
- case CicoBlockParser::EV: // event
- CreateEvent(cbp, csm, parent);
- break;
- default:
- break;
- }
- if (!m_err.empty()) {
- return;
- }
- CicoStateCore* childsParent = (CicoStateCore*)cbp.getVoid();
- int sz = cbp.m_childs.size();
- for (int i=0; i<sz; i++) {
- setConnect(*cbp.m_childs[i], csm, childsParent);
- if (!m_err.empty()) {
- return;
- }
- }
-
-}
-
-/**
- * @brief CicoStateMachineCreator::setConnectStateMachine
- * Acquisition and registration of the starting position
- * @param cbp definition json parts
- * @param csm stateMachine object pointer
- */
-void CicoStateMachineCreator::setConnectStateMachine(CicoBlockParser& cbp,
- CicoStateMachine* csm)
-{
- setInitial(cbp, DKstateMachine, csm);
-}
-
-/**
- * @brief CicoStateMachineCreator::setInitial
- * Acquisition and registration of the starting position
- * @param cbp definition json parts
- * @param key json object parse key
- * @param csm stateMachine object pointer
-
- */
-void CicoStateMachineCreator::setInitial(CicoBlockParser& cbp, const char* key,
- CicoStateMachine* csm)
-{
- CicoStateCore* csc = (CicoStateCore*)cbp.getVoid();
- if ((CicoStateCore*)0 == csc) {
- m_err = std::string("have no stateCore Pointer");
- return;
- }
- picojson::object o = cbp.m_v.get(key).get<picojson::object>();
- picojson::value& vini = o[DKinitial];
- std::vector<CicoStateCore*> vec;
- std::string err;
- if (false == parseStateObject(vini, vec, csm, err)) {
- std::string tmp("initial ");
- tmp += m_err;
- m_err = tmp;
- return;
- }
- int sz = vec.size();
- if (0 == sz) {
- vini = o[DKinitial2];
- if (false == parseStateObject(vini, vec, csm, err)) {
- std::string tmp("i ");
- tmp += m_err;
- m_err = tmp;
- return;
- }
- }
- sz = vec.size();
- if (0 == sz) {
- return;
- }
- for (int i = 0; i < sz; i++) {
- addInitial(csc, vec[i]);
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::addInitial
- * registration of the starting position
- * @param tgt registration target
- * @param dat registration position data
- */
-void CicoStateMachineCreator::addInitial(CicoStateCore* tgt,
- CicoStateCore* dat)
-{
- CicoStateMachine* tgt1 = (CicoStateMachine*)0;
- CicoState* tgt2 = (CicoState*)0;
- if (tgt->isStateMachine()) {
- tgt1 = (CicoStateMachine*)tgt;
- }
- else if (tgt->isState()) {
- tgt2 = (CicoState*)tgt;
- }
- else {
- m_err = std::string("target type mismatch");
- return;
- }
-
- if (dat->isState()) {
- if (tgt1) {
- tgt1->addInitState((CicoState*)dat);
- }
- else if (tgt2) {
- tgt2->addInitState((CicoState*)dat);
- }
- }
- else if (dat->isHistoryState()) {
- if (tgt1) {
- tgt1->addInitState((CicoHistoryState*)dat);
- }
- else if (tgt2) {
- tgt2->addInitState((CicoHistoryState*)dat);
- }
- }
- else {
- m_err = std::string("get pointer type mismatch");
- return;
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::setConnectState
- * Acquisition and registration of the starting position
- * and finish position to state-object
- * @param cbp definition json parts
- * @param csm stateMachine object pointer
- */
-void CicoStateMachineCreator::setConnectState(CicoBlockParser& cbp,
- CicoStateMachine* csm)
-{
- setInitial(cbp, DKstate, csm);
- setFinish(cbp, DKstate, csm);
-}
-
-/**
- * @brief CicoStateMachineCreator::setFinish
- * Acquisition and registration of the and finish position
- * @param cbp definition json parts
- * @param key json parse get key
- * @param csm stateMachine object pointer
- */
-void CicoStateMachineCreator::setFinish(CicoBlockParser& cbp, const char* key,
- CicoStateMachine* csm)
-{
- CicoStateCore* csc = (CicoStateCore*)cbp.getVoid();
- if ((CicoStateCore*)0 == csc) {
- m_err = std::string("have no stateCore Pointer");
- return;
- }
- if (false == csc->isState()) {
- m_err = std::string("have no state Pointer");
- return;
- }
- CicoState* tgt = (CicoState*)csc;
- const CicoStateCore* dat = (CicoStateCore*)0;
- picojson::object o = cbp.m_v.get(key).get<picojson::object>();
- picojson::value& vf = o[DKfinish];
- std::vector<CicoStateCore*> vec;
- std::string err;
- if (false == parseStateObject(vf, vec, csm, err)) {
- std::string tmp("finish ");
- tmp += err;
- m_err = tmp;
- return;
- }
- int sz = vec.size();
- if (0 == sz) {
- vf = o[DKfinish2];
- if (false == parseStateObject(vf, vec, csm, err)) {
- std::string tmp("finish ");
- tmp += err;
- m_err = tmp;
- return;
- }
- }
- std::string h;
- if (false == cbp.m_parts.empty()) {
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- }
- sz = vec.size();
- if (1 < sz) {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "finish is multiple:" << h;
- }
- else {
- stream << "finish is multiple";
- }
- m_err = stream.str();
- }
- if (1 == sz ) {
- dat = vec[0];
- if (dat->isState()) {
- tgt->setFinishTransition((CicoState*)dat);
- }
- else if (dat->isHistoryState()) {
- tgt->setFinishTransition((CicoHistoryState*)dat);
- }
- else if (dat->isFinalState()) {
- tgt->setFinishTransition((CicoFinalState*)dat);
- }
- else {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "finish is mismatch:" << h;
- }
- else {
- stream << "finish is mismatch";
- }
- m_err = stream.str();
- }
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::setConnectHistoryState
- * @param cbp definition json parts
- * @param csm stateMachine object pointer
- */
-void CicoStateMachineCreator::setConnectHistoryState(CicoBlockParser& cbp,
- CicoStateMachine* csm)
-{
- CicoStateCore* csc = (CicoStateCore*)cbp.getVoid();
- if ((CicoState*)0 == csc) {
- m_err = std::string("have no stateCore Pointer");
- return;
- }
- if (false == csc->isHistoryState()) {
- m_err = std::string("have no historyState Pointer");
- return;
- }
- CicoHistoryState* chs = (CicoHistoryState*)csc;
- setDefault(cbp, chs, csm);
-}
-
-/**
- * @brief CicoStateMachineCreator::setDefault
- * @param cbp definition json parts
- * @param chs historyState-objects
- * @param csm stateMachine object pointer
- */
-void CicoStateMachineCreator::setDefault(CicoBlockParser& cbp,
- CicoHistoryState* chs,
- CicoStateMachine* csm)
-{
- picojson::object o = cbp.m_v.get(DKhistoryState).get<picojson::object>();
- picojson::value& vd = o[DKdefault];
- std::vector<CicoStateCore*> vec;
- std::string err;
- if (false == parseStateObject(vd, vec, csm, err)) {
- std::string tmp("default ");
- tmp += err;
- m_err = tmp;
- return;
- }
- int sz = vec.size();
- if (0 == sz) {
- vd = o[DKdefault2];
- if (false == parseStateObject(vd, vec, csm, err)) {
- std::string tmp("d ");
- tmp += err;
- m_err = tmp;
- return;
- }
- }
- sz = vec.size();
- if (0 == sz) {
- return;
- }
- for (int i = 0; i < sz; i++) {
- addDefault(chs, vec[i]);
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::addDefault
- * @param chs registration target
- * @param csc default position object
- */
-void CicoStateMachineCreator::addDefault(CicoHistoryState* chs, CicoStateCore* csc)
-{
- if (false == csc->isState()) {
- m_err = std::string("have no state Pointer");
- return;
- }
- chs->addDefaultState((CicoState*)csc);
-}
-
-/**
- * @brief CicoStateMachineCreator::CreateEvent
- * registration of event triger and transition
- * @param cbp definition json parts
- * @param csm stateMachine object pointer
- * @param parent Hierarchical information
- */
-void CicoStateMachineCreator::CreateEvent(CicoBlockParser& cbp,
- CicoStateMachine* csm,
- CicoStateCore* parent)
-{
- if ((CicoState*)0 == parent) {
- m_err = std::string("have no stateCore Parent");
- return;
- }
- if (false == parent->isState()) {
- m_err = std::string("no State Parent");
- return;
- }
- std::string h;
- if (false == cbp.m_parts.empty()) {
- cbp.getErrorHead(h, cbp.m_parts.c_str());
- }
- if (false == cbp.isJsonParse()) {
- if (false == cbp.jsonParse(DKevent)) {
- m_err = cbp.getError();
- return;
- }
- }
- CicoState* cs = (CicoState*)parent;
- picojson::object o = cbp.m_v.get(DKevent).get<picojson::object>();
- // get name
- std::string name;
- parseName(o, name);
- // get value
- int value = 0;
- if (false == parseValueI(o, value)) {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "value is mismatch:" << h;
- }
- else {
- stream << "value is mismatch";
- }
- m_err = stream.str();
- return;
- }
- CicoEventInfo evi(name, (unsigned short)value);
- // tarnsition get
- picojson::value& vd = o[DKtransition];
- std::vector<CicoStateCore*> vec;
- std::string err;
- if (false == parseStateObject(vd, vec, csm, err)) {
- std::string tmp("transition ");
- tmp += err;
- m_err = tmp;
- return;
- }
- int sz = vec.size();
- if (0 == sz) {
- vd = o[DKtransition2];
- if (false == parseStateObject(vd, vec, csm, err)) {
- std::string tmp("t ");
- tmp += err;
- m_err = tmp;
- return;
- }
- }
- sz = vec.size();
- if (1 != sz) {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "transition is mismatch:" << h;
- }
- else {
- stream << "transition is mismatch";
- }
- m_err = stream.str();
- return;
- }
- const CicoStateCore* trs = vec[0];
- // get guard condition
- picojson::value& vgc = o[DKguardCondition];
- if (false == regGuardCondition(vgc, evi)) {
- vgc = o[DKguardCondition2];
- regGuardCondition(vgc, evi);
- }
- // register event infomation
- if (trs->isState()) {
- cs->addTransition(evi, (CicoState*)trs);
- }
- else if (trs->isHistoryState()) {
- cs->addTransition(evi, (CicoHistoryState*)trs);
- }
- else if (trs->isFinalState()) {
- cs->addTransition(evi, (CicoFinalState*)trs);
- }
- else {
- std::ostringstream stream;
- if (false == h.empty()) {
- stream << "transition is mismatch:" << h;
- }
- else {
- stream << "transition is mismatch";
- }
- m_err = stream.str();
- return;
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::regGuardCondition
- * @param v json parse data
- * @param evi registration of event target
- * @return
- */
-bool CicoStateMachineCreator::regGuardCondition(picojson::value& v,
- CicoEventInfo& evi)
-{
- bool r = false;
- if (v.is<picojson::array>()) {
- picojson::array& arry = v.get<picojson::array>();
- for (picojson::array::const_iterator it = arry.begin();
- it != arry.end(); it++) {
- std::string vdata;
- if (it->is<picojson::object>()) {
- picojson::object ogc = it->get<picojson::object>();
- setGuardCondition(evi, ogc);
- r = true;
- }
- }
- }
- else if (v.is<picojson::object>()) {
- picojson::object ogc = v.get<picojson::object>();
- setGuardCondition(evi, ogc);
- r = true;
- }
- return r;
-}
-
-/**
- * @brief CicoStateMachineCreator::setGuardCondition
- * @param evi registration of event target
- * @param o definition gurd condition data of event
- */
-void CicoStateMachineCreator::setGuardCondition(CicoEventInfo& evi, picojson::object& o)
-{
- std::string op;
- if (false == parseOperator(o, op)) {
- m_err = std::string("operator unkown");
- return;
- }
- bool bAnd = false;
- std::string j;
- if (true ==parseJoin(o, j)) {
- if (std::string(DVand)==j) {
- bAnd = true;
- }
- else if (std::string(DVor)!=j) {
- m_err = std::string("join unkown");
- return;
- }
- }
- int num;
- double dbl;
- std::string str;
- if (true == parseValueIS(o, num, str)) {
- if (str.empty()) {
- if (true == bAnd) {
- evi.addAndGurdCondition(op, num);
- }
- else {
- evi.addOrGurdCondition(op, num);
- }
- }
- else {
- if (true == bAnd) {
- evi.addAndGurdCondition(op, str);
- }
- else {
- evi.addOrGurdCondition(op, str);
- }
- }
- }
- else if (true == parseValuedD(o, dbl)) {
- if (true == bAnd) {
- evi.addAndGurdCondition(op, dbl);
- }
- else {
- evi.addOrGurdCondition(op, dbl);
- }
- }
- else {
- m_err = std::string("value,valued unkown");
- return;
- }
-}
-
-/**
- * @brief CicoStateMachineCreator::getJsonString
- * @param v json parse value
- * @param str store json parse value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::getJsonString(picojson::value& v,
- std::string& str)
-{
- if (v.is<std::string>()) {
- str = v.get<std::string>();
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::getJsonNumber
- * @param v json parse value
- * @param num store json parse value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::getJsonNumber(picojson::value& v, int& num)
-{
- if (v.is<double>()) {
- num = (int)v.get<double>();
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::getJsonDouble
- * @param v json parse value
- * @param d store json parse value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::getJsonDouble(picojson::value& v, double& d)
-{
- if (v.is<double>()) {
- d = (double)v.get<double>();
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseName
- * @param o json parse objects
- * @param nm store json parse "name" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseName(picojson::object& o, std::string& nm)
-{
- picojson::value& vnm = o[DKname];
- if (true == getJsonString(vnm, nm)) {
- return true;
- }
- vnm = o[DKname2];
- if (true == getJsonString(vnm, nm)) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseValueI
- * @param o json parse objects
- * @param v store json parse "value" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseValueI(picojson::object& o, int& v)
-{
- picojson::value& vvl = o[DKvalue];
- if (true == getJsonNumber(vvl, v)) {
- return true;
- }
- vvl = o[DKvalue2];
- if (true == getJsonNumber(vvl, v)) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseValueIS
- * @param o json parse objects
- * @param n store json parse "value" object value
- * @param s store json parse "value" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseValueIS(picojson::object& o, int& n,
- std::string& s)
-{
- picojson::value& vvl = o[DKvalue];
- if (true == getJsonNumber(vvl, n)) {
- s.clear();
- return true;
- }
- else if (true == getJsonString(vvl, s)) {
- return true;
- }
- vvl = o[DKvalue2];
- if (true == getJsonNumber(vvl, n)) {
- s.clear();
- return true;
- }
- else if (true == getJsonString(vvl, s)) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseValuedD
- * @param o json parse objects
- * @param v store json parse "valued" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseValuedD(picojson::object& o, double& v)
-{
- picojson::value& vvl = o[DKvalued];
- if (true == getJsonDouble(vvl, v)) {
- return true;
- }
- vvl = o[DKvalued2];
- if (true == getJsonDouble(vvl, v)) {
- return true;
- }
- return false;
-}
-
-
-/**
- * @brief CicoStateMachineCreator::parseHistoryType
- * @param o json parse objects
- * @param e store json parse "type" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseHistoryType(picojson::object& o,
- CicoHistoryState::E_HType& e)
-{
- picojson::value& vty = o[DKtype];
- std::string tmp;
- if (false == getJsonString(vty, tmp)) {
- vty = o[DKtype2];
- if (false == getJsonString(vty, tmp)) {
- return false;
- }
- }
- if (false == tmp.empty()) {
- if (std::string(DVShallow) == tmp) {
- e = CicoHistoryState::Shallow;
- return true;
- }
- else if (std::string(DVDeep) == tmp) {
- e = CicoHistoryState::Deep;
- return true;
- }
- }
- return false;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseStateObject
- * @param v json parse value
- * @param vec store state-objects pointer array
- * @param csm stateMachine object pointer
- * @param err store gat fail error message
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseStateObject(picojson::value& v,
- std::vector<CicoStateCore*>& vec,
- CicoStateMachine* csm,
- std::string& err)
-{
- if (v.is<picojson::array>()) {
- picojson::array& arry = v.get<picojson::array>();
- for (picojson::array::const_iterator it = arry.begin();
- it != arry.end(); it++) {
- std::string vdata;
- if (it->is<std::string>()) {
- std::string v = it->get<std::string>();
- const CicoStateCore* csc = csm->getState(v);
- if ((CicoStateCore*)0 == csc) {
- std::ostringstream stream;
- stream << "state is not find:V:\"" << v << "\"";
- err = stream.str();
- return false;
- }
- vec.push_back((CicoStateCore*)csc);
- }
- else if (it->is<double>()) {
- int v = (int) it->get<double>();
- const CicoStateCore* csc = csm->getState(v);
- if ((CicoStateCore*)0 == csc) {
- std::ostringstream stream;
- stream << "state is not find:V:" << v;
- err = stream.str();
- return false;
- }
- vec.push_back((CicoStateCore*)csc);
- }
- }
- }
- else if (v.is<double>()) {
- int vi = (int) v.get<double>();
- const CicoStateCore* csc = csm->getState(vi);
- if ((CicoStateCore*)0 == csc) {
- std::ostringstream stream;
- stream << "state is not find:S:" << vi;
- err = stream.str();
- return false;
- }
- vec.push_back((CicoStateCore*)csc);
- }
- else if (v.is<std::string>()) {
- std::string vs = v.get<std::string>();
- const CicoStateCore* csc = csm->getState(vs);
- if ((CicoStateCore*)0 == csc) {
- std::ostringstream stream;
- stream << "state is not find:S:\"" << vs << "\"";
- err = stream.str();
- return false;
- }
- vec.push_back((CicoStateCore*)csc);
- }
- return true;
-}
-
-/**
- * @brief CicoStateMachineCreator::parseOperator
- * @param o json parse object
- * @param op store json "operation" object value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseOperator(picojson::object& o, std::string& op)
-{
- picojson::value& vop = o[DKoperator];
- if (true == getJsonString(vop, op)) {
- return true;
- }
- vop = o[DKoperator2];
- if (true == getJsonString(vop, op)) {
- return true;
- }
- return false;
-}
-
-
-/**
- * @brief CicoStateMachineCreator::parseJoin
- * @param o json parse object
- * @param j store "join" value
- * @return true:get success false:get fail
- */
-bool CicoStateMachineCreator::parseJoin(picojson::object& o, std::string& j)
-{
- picojson::value& vnm = o[DKjoin];
- if (true == getJsonString(vnm, j)) {
- return true;
- }
- vnm = o[DKjoin2];
- if (true == getJsonString(vnm, j)) {
- return true;
- }
- return false;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef CICOSTATEMACHINECREATOR_H
-#define CICOSTATEMACHINECREATOR_H
-#include <iostream>
-#include <string>
-#include <vector>
-#include "CicoBlockParser.h"
-#include "CicoEventInfo.h"
-
-#ifndef CICOSTATECORE_H
-class CicoStateCore;
-#endif
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-#ifndef CICOSTATE_H
-class CicoState;
-#endif
-
-#ifndef CICOFINALSTATE_H
-class CicoFinalState;
-#endif
-
-#ifndef CICOHISTORYSTATE_H
-class CicoHistoryState;
-#endif
-
-#define DKstateMachine "stateMachine"
-#define DKstate "state"
-#define DKfinalState "finalState"
-#define DKhistoryState "historyState"
-#define DKevent "event"
-
-#define DKname "name"
-#define DKname2 "n"
-#define DKvalue "value"
-#define DKvalue2 "v"
-#define DKinitial "initial"
-#define DKinitial2 "i"
-#define DKfinish "finish"
-#define DKfinish2 "f"
-#define DKdefault "default"
-#define DKdefault2 "d"
-#define DKguardCondition "guardCondition"
-#define DKguardCondition2 "g"
-#define DKoperator "operator"
-#define DKoperator2 "o"
-#define DKtransition "transition"
-#define DKtransition2 "t"
-#define DKtype "type"
-#define DKtype2 "ht"
-#define DKvalued "valued"
-#define DKvalued2 "vd"
-#define DKjoin "join"
-#define DKjoin2 "j"
-
-#define DVShallow "Shallow"
-#define DVDeep "Deep"
-#define DVand "and"
-#define DVor "or"
-
-
-/**
- * StateMachine-Object creator
- * @author m.kamoshida
- * @version 0.1
- */
-
-/**
- * @brief The CicoStateMachineCreator class
- * @ state-machine produce from the definition file or string
- */
-class CicoStateMachineCreator
-{
-public:
- CicoStateMachine* createFile(const std::string& filename);
-
- CicoStateMachine* create(const char* sttdef);
- const std::string& getError();
-
-protected:
- void CreateStateObjects(CicoBlockParser& cbp,
- CicoStateCore* parent = 0);
- void CreateStateMachine(CicoBlockParser& cbp);
- void CreateState(CicoBlockParser& cbp, CicoStateCore* parent);
- void CreateHistoryState(CicoBlockParser& cbp,
- CicoStateCore* parent);
- void CreateFinalState(CicoBlockParser& cbp, CicoStateCore* parent);
-
- void setConnect(CicoBlockParser& cbp, CicoStateMachine* csm,
- CicoStateCore* parent=0);
-
- void setConnectStateMachine(CicoBlockParser& cbp,
- CicoStateMachine* csm);
- void setConnectState(CicoBlockParser& cbp, CicoStateMachine* csm);
- void setConnectHistoryState(CicoBlockParser& cbp,
- CicoStateMachine* csm);
- void setInitial(CicoBlockParser& cbp, const char* key,
- CicoStateMachine* csm);
- void addInitial(CicoStateCore* tgt, CicoStateCore* dat);
-
- void setFinish(CicoBlockParser& cbp, const char* key,
- CicoStateMachine* csm);
-
- void setDefault(CicoBlockParser& cbp, CicoHistoryState* chs,
- CicoStateMachine* csm);
- void addDefault(CicoHistoryState* chs, CicoStateCore* csc);
-
-
- void CreateEvent(CicoBlockParser& cbp, CicoStateMachine* csm,
- CicoStateCore* parent);
-
- bool regGuardCondition(picojson::value& v, CicoEventInfo& evi);
- void setGuardCondition(CicoEventInfo& evi, picojson::object& o);
-
- bool getJsonString(picojson::value& v, std::string& str);
- bool getJsonNumber(picojson::value& v, int& num);
- bool getJsonDouble(picojson::value& v, double& d);
- bool parseName(picojson::object& o, std::string& nm);
-
- bool parseValueI(picojson::object& o, int& v);
- bool parseValueIS(picojson::object& o, int& n, std::string& s);
-
- bool parseValuedD(picojson::object& o, double& v);
-
- bool parseHistoryType(picojson::object& o,
- CicoHistoryState::E_HType& e);
-
- bool parseStateObject(picojson::value& v,
- std::vector<CicoStateCore*>& vec,
- CicoStateMachine* csm, std::string& err);
-
- bool parseOperator(picojson::object& o, std::string& op);
- bool parseJoin(picojson::object& o, std::string& j);
-
-private:
- std::string m_err;
-
-};
-
-/**
- * @brief CicoStateMachineCreator::getError
- * @ get error message
- * @return error message
- */
-inline const std::string& CicoStateMachineCreator::getError()
-{
- return m_err;
-}
-
-#endif // CICOSTATEMACHINECREATOR_H
+++ /dev/null
-AM_CPPFLAGS = $(GCC_CXXFLAGS) -DLOG_CICO
-#AM_CPPFLAGS = $(GCC_CXXFLAGS) -DLOG_CONSOLE
-#AM_CPPFLAGS = $(GCC_CXXFLAGS)
-
-lib_LTLIBRARIES = \
- libico-state-machine.la
-
-libico_state_machine_la_LDFLAGS = -version-info 0:9:0
-
-libico_state_machine_la_SOURCES = \
- CicoStateCore.cpp \
- CicoEvent.cpp \
- CicoEventInfo.cpp \
- CicoStateMachine.cpp \
- CicoState.cpp \
- CicoFinalState.cpp \
- CicoHistoryState.cpp \
- CicoStateAction.cpp \
- CicoStateMachineCreator.cpp \
- CicoBlockParser.cpp \
- ico_StateMachine_CWrapper.cpp
-
-libico_state_machine_la_CPPFLAGS = \
- $(GCC_CXXFLAGS) \
- -DLOG_CICO \
- @DLOG_CFLAGS@ \
- -I../../../include \
- -I/usr/include/ico-util
-
-libico_state_machine_la_LIBADD = \
- @DLOG_LIBS@
-
-AM_LDFLAGS = -module -avoid-version -rpath $(libdir)
-
-install-exec-hook:
- mkdir -p $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoBlockParser.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoEvent.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoEventInfo.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoFinalState.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoHistoryState.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoState.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoStateAction.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoStateCore.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoStateMachine.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- install -m 644 CicoStateMachineCreator.h $(INSTALL_ROOT)/$(includedir)/ico-state-machine
-
-uninstall:
- rm -rf $(INSTALL_ROOT)/$(includedir)/ico-state-machine
- rm -rf $(INSTALL_ROOT)/$(libdir)/libico-state-machine*
-
-.FORCE :
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <vector>
-#include <iostream>
-#include <string>
-#include <vector>
-#include <fstream>
-
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateAction.h"
-#include "CicoStateCore.h"
-#include "CicoState.h"
-#include "CicoHistoryState.h"
-#include "CicoFinalState.h"
-#include "CicoStateMachine.h"
-#include "CicoStateMachineCreator.h"
-#include "ico_StateMachine_CWrapper.h"
-#include "CicoStateInternal.h"
-
-/**
- * stateMachine C Wrapper functions
- */
-
-static std::vector<CicoStateCore*> stateObjects;
-static std::vector<CicoEventInfo*> evInfObjects;
-static std::vector<void*> callbackFnc;
-
-StateMachineCWrapperErr_E sttmerr;
-
-
-/**
- * @brief GCOpKind
- * @ Definitions used in the function ico_sttm_addTransitionGCI ,
- * @ ico_sttm_addTransitionGCD , ico_sttm_addTransitionGCS
- * @ ico_sttm_addGCI , ico_sttm_addGCD , ico_sttm_addGCS
- */
-const char* GCOpKind[] = {
- "",
- DEFJGCE_EQ, // "=" Guard condition is equal to
- DEFJGCE_NE, // "!=" Guard condition is not equal to
- DEFJGCE_LT, // "<" Guard condition is less than
- DEFJGCE_LE, // "<=" Guard condition is less than or equal
- DEFJGCE_GT, // ">" Guard condition is greater than
- DEFJGCE_GE, // ">=" Guard condition is greater than or equal
- DEFJGCE_IN, // "in" Guard condition is the state of the state-object
- DEFJGCE_NOT, // "not" Guard condition is the state of the state-object
-};
-
-/**
- * @brief getID2ObjSTT
- * @ c-wrapper local ID to CicoStateCore pointer
- * @param id c-wrapper local ID
- * @return not 0:get success
- * @ 0:get faile
- */
-CicoStateCore* getID2ObjSTT(int id)
-{
- int sz = stateObjects.size();
- if ((1 > id) || (id > sz)) {
- return (CicoStateCore*)0;
- }
- return stateObjects[(id-1)];
-}
-
-
-/**
- * @brief getID2ObjSTTX
- * @ c-wrapper local ID to CicoStateCore pointer
- * @param id c-wrapper local ID
- * @return not 0:get success
- * @ 0:get faile
- */
-extern "C" void* getID2ObjSTTX(int id)
-{
- return (void*)getID2ObjSTT(id);
-}
-
-/**
- * @brief getObjSTT2ID
- * @ CicoStateCore pointer to c-wrapper local ID
- * @param stt
- * @return not 0:get success(c-wrapper local ID)
- * @ 0:get faile
- */
-int getObjSTT2ID(const CicoStateCore* stt)
-{
- int r = 0;
- int sz = stateObjects.size();
- for (int i=0; i<sz; i++) {
- if (stt == stateObjects[i]) {
- r = i+1;
- break; // break of for i<sz
- }
- }
- return r;
-}
-
-/**
- * @brief getID2ObjEV
- * @ c-wrapper local ID to CicoEventInfo pointer
- * @param id c-wrapper local ID
- * @return not 0:CicoEventInfo pointer
- * @ 0:get faile
- */
-CicoEventInfo* getID2ObjEV(int id)
-{
- int sz = evInfObjects.size();
- if ((1 > id) || (id > sz)) {
- return (CicoEventInfo*)0;
- }
- return evInfObjects[(id-1)];
-}
-
-/**
- * @brief supplementName
- * @ supplement name
- * @param name
- * @return supplement name
- */
-const char* supplementName(const char* name)
-{
- static const char* emptychar = "";
- if ((char*)0 == name) {
- return emptychar;
- }
- return name;
-}
-
-/* Registration system */
-/**
- * @brief Create an stateMachine-object and state-object with the specified file
- * @param file faile path pseudo-json
- * @return not 0:stateMachine-object Id no.(c-wrapper local ID)
- * @ 0:create error
- */
-extern "C" int ico_sttm_createStateMachineFile(const char* file)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachineCreator csmc;
- CicoStateMachine* csm = csmc.createFile(file);
- if ((CicoStateMachine*)0 == csm) {
- sttmerr = STTMCREATEERR;
- _DBG("ico_sttm_createStateMachineFile %s", csmc.getError().c_str());
- return 0;
- }
- csm->getObjects(stateObjects);
- int r = 0;
- int sz = stateObjects.size();
- for (int i = 0; i < sz; i++) {
- if (stateObjects[i] == csm) { // match object pointer
- r = i+1; // get return value
- break; // break of for i<sz
- }
- }
- return r;
-}
-
-
-/**
- * @brief Create an stateMachine-object and state-object with the specified text
- * @param buff text pseudo-json
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-extern "C" int ico_sttm_createStateMachineText(const char* buff)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachineCreator csmc;
- CicoStateMachine* csm = csmc.create(buff);
- if ((CicoStateMachine*)0 == csm) {
- sttmerr = STTMCREATEERR;
- _DBG("ico_sttm_createStateMachineText %s", csmc.getError().c_str());
- return 0;
- }
- csm->getObjects(stateObjects); // get all state-objects
- int r = 0; //
- int sz = stateObjects.size(); //
- for (int i = 0; i < sz; i++) { //
- if (stateObjects[i] == csm) { // match object pointer
- r = i+1; // get return value
- break; // break of for i<sz
- }
- }
- return r;
-}
-
-/**
- * @brief Create stateMachine-object
- * @param name stateMachine-object name (Option)
- * @param value stateMachine-object ID no.
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-extern "C" int ico_sttm_createStateMachine(const char* name, int value)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachine* csm;
- const char* sname = supplementName(name);
- csm = new CicoStateMachine(sname, value);
- if ((CicoStateMachine*)0 == csm) {
- sttmerr = STTMNEWERR;
- _ERR("ico_sttm_createStateMachine \"%s\", %d", sname, value);
- return 0;
- }
- stateObjects.push_back(csm);
- return stateObjects.size();
-}
-
-/**
- * @brief Create state-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name state-object name (Option)
- * @param value state-object ID no.
- * @return not 0:state-object ID no.(c-wrapper local ID)
- * @ 0:create faile
- */
-extern "C" int ico_sttm_createState(int parent, const char* name, int value)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(name);
- CicoStateCore* cscParent = getID2ObjSTT(parent); // ID to state-object
- if ((CicoStateCore*)0 == cscParent) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_createState >>%d<<, \"%s\", %d", parent, sname,value);
- return 0;
- }
- CicoState* cs = (CicoState*)0;
- if (cscParent->isStateMachine()) {
- cs = new CicoState(sname, value, (CicoStateMachine*)cscParent);
- }
- else if (cscParent->isState()) {
- cs = new CicoState(sname, value, (CicoState*)cscParent);
- }
- if ((CicoState*)0 == cs) {
- sttmerr = STTMNEWERR;
- _ERR("ico_sttm_createState %d(%s:%d:%d), \"%s\", %d",
- parent, cscParent->getName().c_str(), cscParent->getValue(),
- (int)cscParent->getType(), sname, value);
- return 0;
- }
- stateObjects.push_back(cs);
- return stateObjects.size();
-}
-
-/**
- * @brief Create historyState-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name historyState-object name (Option)
- * @param value historyState-object ID no.
- * @return not 0:historyState-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-extern "C" int ico_sttm_createHState(int parent, const char* name, int value,
- HISTORY_TYPE_E typ)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(name);
- CicoStateCore* cscParent = getID2ObjSTT(parent); // ID to state-object
- if ((CicoStateCore*)0 == cscParent) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_createHState >>%d<<, \"%s\", %d, %d", parent, sname, value, (int)typ);
- return 0;
- }
- CicoHistoryState* chs = (CicoHistoryState*)0;
- if (cscParent->isStateMachine()) {
- chs = new CicoHistoryState(sname, value, (CicoStateMachine*)cscParent);
- }
- else if (cscParent->isState()) {
- chs = new CicoHistoryState(sname, value, (CicoState*)cscParent);
- }
- if ((CicoHistoryState*)0 == chs) {
- sttmerr = STTMNEWERR;
- _ERR("ico_sttm_createHState >>%d(%s:%d:%d)<<, \"%s\", %d, %d",
- parent, cscParent->getName().c_str(), cscParent->getValue(),
- (int)cscParent->getType(), sname, value, (int)typ);
- return 0;
- }
- if (E_SHALLOW == typ) {
- chs->setHistoryType(CicoHistoryState::Shallow);
- }
- else if (E_DEEP == typ) {
- chs->setHistoryType(CicoHistoryState::Deep);
- }
- else {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_createHState %d(%s:%d:%d), \"%s\", %d,>>%d<<",
- parent, cscParent->getName().c_str(), cscParent->getValue(),
- (int)cscParent->getType(), sname, value, (int)typ);
- delete chs;
- return 0;
- }
- stateObjects.push_back((CicoStateCore*)chs);
- return stateObjects.size();
-}
-
-/**
- * @brief Create finalState-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name finalState-object name (Option)
- * @param value finalState-object ID no.
- * @return not 0:finalState-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-extern "C" int ico_sttm_createFState(int parent, const char* name, int value)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(name);
- CicoStateCore* cscParent = getID2ObjSTT(parent); // ID to state-object
- if ((CicoStateCore*)0 == cscParent) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_createFState >>%d<<, \"%s\", %d", parent, sname, value);
- return 0;
- }
- CicoFinalState* cfs = (CicoFinalState*)0;
- if (cscParent->isStateMachine()) {
- cfs = new CicoFinalState(sname, value, (CicoStateMachine*)cscParent);
- }
- else if (cscParent->isState()) {
- cfs = new CicoFinalState(sname, value, (CicoState*)cscParent);
- }
- if ((CicoFinalState*)0 == cfs) {
- sttmerr = STTMNEWERR;
- _ERR("ico_sttm_createFState >>%d(%s:%d:%d)<<, \"%s\", %d",
- parent, cscParent->getName().c_str(), cscParent->getValue(),
- (int)cscParent->getType(), sname, value);
- return 0;
- }
- stateObjects.push_back((CicoStateCore*)cfs);
- return stateObjects.size();
-}
-
-/**
- * @brief Registration of transition events
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param trCWId of transition destination(c-wrapper local ID)
- * @param evi Registration event
- * @param fname function name of the caller
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-int ico_sttm_addTransitionX(int sCWId, int trCWId, CicoEventInfo& evi,
- const char* fname)
-{
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("%s >>%d<<, \"%s\", %d, ..., %d",
- fname, sCWId, evi.getName().c_str(), (int)evi.getEV(),
- trCWId);
- return 0;
- }
- CicoStateCore* cscTrans = getID2ObjSTT(trCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTrans) {
- sttmerr = STTMNOTFIND;
- _DBG("%s %d, \"%s\", %d, ...,>>%d<<",
- fname, sCWId, evi.getName().c_str(), (int)evi.getEV(),
- trCWId);
- return 0;
- }
- if (false == cscTarget->isState()) {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("%s >>%d(%s:%d:%d)<<, \"%s\", %d, ..., %d",
- fname, sCWId, cscTarget->getName().c_str(),
- cscTarget->getValue(), (int)cscTarget->getType(),
- evi.getName().c_str(), (int)evi.getEV(), trCWId);
- return 0;
- }
- CicoState* csTgt = (CicoState*)cscTarget;
- if (true == cscTrans->isState()) {
- csTgt->addTransition(evi, (CicoState*)cscTrans);
- }
- else if (true == cscTrans->isFinalState()) {
- csTgt->addTransition(evi, (CicoFinalState*)cscTrans);
- }
- else if (true == cscTrans->isHistoryState()) {
- csTgt->addTransition(evi, (CicoHistoryState*)cscTrans);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("%s %d, \"%s\", %d, ...,>>%d(%s:%d:%d)<<",
- fname, sCWId, evi.getName().c_str(), (int)evi.getEV(),
- trCWId, cscTarget->getName().c_str(),
- cscTarget->getValue(), (int)cscTarget->getType());
- return 0;
- }
- const CicoEventInfo* t = csTgt->getEventInfo(evi.getName(), evi.getEV());
- evInfObjects.push_back((CicoEventInfo*)t);
- return evInfObjects.size();
-}
-
-/**
- * @brief Registration of transition events
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param name event name
- * @param ev event no.(Use the 1000-65535)
- * @param trCWId of transition destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransition(int sCWId,
- const char* evname, unsigned short ev,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(evname);
- CicoEventInfo evi(sname, ev);
- int r = ico_sttm_addTransitionX(sCWId, trCWId, evi, "ico_sttm_addTransition");
- return r;
-}
-
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param name state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param trVal state-object identification value destination
- * @param namTrns state-object Identification name destination
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransition_V_(int smCWId, int value,
- const char* evname, unsigned short ev,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransition_VV >>%d<<,>>%d<<, %s,%d, %d", smCWId,
- value, evname, ev, trCWId);
- return 0;
- }
- return ico_sttm_addTransition(id, evname, ev, trCWId);
-}
-
-extern "C" int ico_sttm_addTransition_VV(int smCWId, int value,
- const char* evname, unsigned short ev,
- int trVal)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrieveSVal(smCWId, trVal);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransition_VV >>%d<<, %d, %s,%d,>>%d<<", smCWId,
- value, evname, ev, trVal);
- return 0;
- }
- return ico_sttm_addTransition_V_(smCWId, value, evname, ev, idT);
-}
-
-extern "C" int ico_sttm_addTransitionVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- int trVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransitionVVV >>%d<<, %d, %s,%d, %d", smVal,
- value, evname, ev, trVal);
- return 0;
- }
- return ico_sttm_addTransition_VV(id, value, evname, ev, trVal);
-}
-
-extern "C" int ico_sttm_addTransition_N_(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransitionVVV >>%d<<,>>%s<<, %s,%d,%d", smCWId,
- name, evname, ev, trCWId);
- return 0;
- }
- return ico_sttm_addTransition(id, evname, ev, trCWId);
-
-
-}
-extern "C" int ico_sttm_addTransition_NN(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrivevSName(smCWId, trNm);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransitionVVV >>%d<<, %s, %s,%d,>>%s<<", smCWId,
- name, evname, ev, trNm);
- return 0;
- }
- return ico_sttm_addTransition_N_(smCWId, name, evname, ev, idT);
-}
-
-extern "C" int ico_sttm_addTransitionNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- const char* trNm)
-{
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransitionNNN >>%s<<, %s, %s, %d, %s", smNm,
- name, evname, ev, trNm);
- return 0;
- }
- return ico_sttm_addTransition_NN(id, name, evname, ev, trNm);
-}
-
-/**
- * @brief Registration of transition events
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param name event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trCWId destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransitionGCI(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv, int trCWId)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(evname);
- CicoEventInfo evi(sname, ev, GCOpKind[gce], gcv);
- int r = ico_sttm_addTransitionX(sCWId, trCWId, evi, "ico_sttm_addTransitionGCI");
- return r;
-}
-
-extern "C" int ico_sttm_addTransitionGCD(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(evname);
- CicoEventInfo evi(sname, ev, GCOpKind[gce], gcv);
- int r = ico_sttm_addTransitionX(sCWId, trCWId, evi, "ico_sttm_addTransitionGCD");
- return r;
-}
-
-extern "C" int ico_sttm_addTransitionGCS(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- const char* sname = supplementName(evname);
- CicoEventInfo evi(sname, ev, GCOpKind[gce], gcv);
- int r = ico_sttm_addTransitionX(sCWId, trCWId, evi, "ico_sttm_addTransitionGCS");
- return r;
-}
-
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trCWId destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransGCI_V_(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- int trCWId)
-{
-
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCI_V_ >>%d<<,>>%d<<, %s, %d, %d, %d, %d",
- smCWId, value, evname, ev, (int)gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCI(id, evname, ev, gce, gcv, trCWId);
-}
-
-extern "C" int ico_sttm_addTransGCD_V_(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCD_V_ >>%d<<,>>%d<<, %s, %d, %d, %f, %d",
- smCWId, value, evname, ev, (int)gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCD(id, evname, ev, gce, gcv, trCWId);
-}
-
-extern "C" int ico_sttm_addTransGCS_V_(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCD_V_ >>%d<<,>>%d<<, %s, %d, %d, %s, %d",
- smCWId, value, evname, ev, (int)gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCS(id, evname, ev, gce, gcv, trCWId);
-}
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trVl value is state-object identification number transition, destination
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransGCI_VV(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrieveSVal(smCWId, trVl);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCI_VV >>%d<<, %d, %s, %d, %d, %d,>>%d<<",
- smCWId, value, evname, ev, (int)gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCI_V_(smCWId, value, evname, ev, gce, gcv, idT);
-}
-
-extern "C" int ico_sttm_addTransGCD_VV(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrieveSVal(smCWId, trVl);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCD_VV >>%d<<, %d, %s, %d, %d, %f,>>%d<<",
- smCWId, value, evname, ev, (int)gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCD_V_(smCWId, value, evname, ev, gce, gcv, idT);
-}
-
-extern "C" int ico_sttm_addTransGCS_VV(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrieveSVal(smCWId, trVl);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _ERR("ico_sttm_addTransGCS_VV >>%d<<, %d, %s, %d, %d, %s,>>%d<<",
- smCWId, value, evname, ev, (int)gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCS_V_(smCWId, value, evname, ev, gce, gcv, idT);
-}
-
-
-
-extern "C" int ico_sttm_addTransGCIVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCIVVV >>%d<<, %d, %s, %d, %d, %d, %d", smVal,
- value, evname, ev, gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCI_VV(id, value, evname, ev, gce, gcv, trVl);
-}
-
-extern "C" int ico_sttm_addTransGCDVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCIVVV >>%d<<, %d, %s, %d, %d, %f, %d", smVal,
- value, evname, ev, gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCD_VV(id, value, evname, ev, gce, gcv, trVl);
-}
-
-extern "C" int ico_sttm_addTransGCSVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCSVVV >>%d<<, %d, %s, %d, %d, %s, %d", smVal,
- value, evname, ev, gce, gcv, trVl);
- return 0;
- }
- return ico_sttm_addTransGCS_VV(id, value, evname, ev, gce, gcv, trVl);
-}
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param transition destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransGCI_N_(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCI_N_ >>%d<<, %s, %s, %d, %d, %d, %d", smCWId,
- name, evname, ev, gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCI(id, evname, ev, gce, gcv, trCWId);
-}
-
-extern "C" int ico_sttm_addTransGCD_N_(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCD_N_ >>%d<<, %s, %s, %d, %d, %f, %d", smCWId,
- name, evname, ev, gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCD(id, evname, ev, gce, gcv, trCWId);
-}
-
-extern "C" int ico_sttm_addTransGCS_N_(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCD_N_ >>%d<<, %s, %s, %d, %d, %s, %d", smCWId,
- name, evname, ev, gce, gcv, trCWId);
- return 0;
- }
- return ico_sttm_addTransitionGCS(id, evname, ev, gce, gcv, trCWId);
-}
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trNm name is state-object Identification name destination
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-extern "C" int ico_sttm_addTransGCI_NN(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrivevSName(smCWId, trNm);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCI_NN >>%d<<, %s, %s, %d, %d, %d,>>%s<<", smCWId,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCI_N_(smCWId, name, evname, ev, gce, gcv, idT);
-}
-
-extern "C" int ico_sttm_addTransGCD_NN(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrivevSName(smCWId, trNm);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCD_NN >>%d<<, %s, %s, %d, %d, %f,>>%s<<", smCWId,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCD_N_(smCWId, name, evname, ev, gce, gcv, idT);
-}
-
-extern "C" int ico_sttm_addTransGCS_NN(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrivevSName(smCWId, trNm);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addTransGCS_NN >>%d<<, %s, %s, %d, %d, %s,>>%s<<", smCWId,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCS_N_(smCWId, name, evname, ev, gce, gcv, idT);
-}
-
-extern "C" int ico_sttm_addTransGCINNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- _DBG("ico_sttm_addTransGCINNN >>%s<<, %s, %s, %d, %d, %d, %s", smNm,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCI_NN(id, name, evname, ev, gce, gcv, trNm);
-}
-
-extern "C" int ico_sttm_addTransGCDNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- _DBG("ico_sttm_addTransGCDNNN >>%s<<, %s, %s, %d, %d, %f, %s", smNm,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCD_NN(id, name, evname, ev, gce, gcv, trNm);
-}
-
-extern "C" int ico_sttm_addTransGCSNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- _DBG("ico_sttm_addTransGCSNNN >>%s<<, %s, %s, %d, %d, %s, %s", smNm,
- name, evname, ev, gce, gcv, trNm);
- return 0;
- }
- return ico_sttm_addTransGCS_NN(id, name, evname, ev, gce, gcv, trNm);
-}
-
-
-/**
- * @brief add guard condition
- * @param evi register target
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return true:Success
- * @ false:added failure
- */
-bool addGC(CicoEventInfo* evi, GC_JOIN_E j, GC_OP_KIND_E gce, int gcv)
-{
- if (E_GC_AND == j) {
- return evi->addAndGurdCondition(GCOpKind[gce], gcv);
- }
- else if (E_GC_OR == j) {
- return evi->addOrGurdCondition(GCOpKind[gce], gcv);
- }
- return false;
-}
-
-
-bool addGC(CicoEventInfo* evi, GC_JOIN_E j, GC_OP_KIND_E gce, double gcv)
-{
- if (E_GC_AND == j) {
- return evi->addAndGurdCondition(GCOpKind[gce], gcv);
- }
- else if (E_GC_OR == j) {
- return evi->addOrGurdCondition(GCOpKind[gce], gcv);
- }
- return false;
-}
-
-
-bool addGC(CicoEventInfo* evi, GC_JOIN_E j, GC_OP_KIND_E gce, const char* gcv)
-{
- if (E_GC_AND == j) {
- return evi->addAndGurdCondition(GCOpKind[gce], gcv);
- }
- else if (E_GC_OR == j) {
- return evi->addOrGurdCondition(GCOpKind[gce], gcv);
- }
- return false;
-}
-
-/**
- * @brief add guard condition
- * @param evId ID no. to be registered(c-wrapper local event-ID)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-extern "C" int ico_sttm_addGCI(int evId, GC_JOIN_E j, GC_OP_KIND_E gce, int gcv)
-{
- sttmerr = STTMNOERROR;
- CicoEventInfo* eviTarget = getID2ObjEV(evId);
- if ((CicoEventInfo*)0 == eviTarget) {
- sttmerr = STTMEVNOTFIND;
- _DBG("ico_sttm_addGCI >>%d<<,%d, %d, %d",evId, (int)j, (int)gce, gcv);
- return 0;
- }
- if (false == addGC(eviTarget, j, gce, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addGCI ,>>%d<<, %d, %d, %d",evId, (int)j, (int)gce, gcv);
- }
- return evId;
-}
-
-extern "C" int ico_sttm_addGCD(int evId, GC_JOIN_E j, GC_OP_KIND_E gce, double gcv)
-{
- sttmerr = STTMNOERROR;
- CicoEventInfo* eviTarget = getID2ObjEV(evId);
- if ((CicoEventInfo*)0 == eviTarget) {
- sttmerr = STTMEVNOTFIND;
- _DBG("ico_sttm_addGCD >>%d<<,%d, %d, %f",evId, (int)j, (int)gce, gcv);
- return 0;
- }
- if (false == addGC(eviTarget, j, gce, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addGCD %d,>>%d<<, %d, %f",evId, (int)j, (int)gce, gcv);
- return 0;
- }
- return evId;
-}
-
-extern "C" int ico_sttm_addGCS(int evId, GC_JOIN_E j, GC_OP_KIND_E gce,
- const char* gcv)
-{
- sttmerr = STTMNOERROR;
- if ((char*)0==gcv) {
- sttmerr = STTMEVNOTFIND;
- _DBG("ico_sttm_addGCS %d,%d, %d,>>nill<<",evId, (int)j, (int)gce);
- return 0;
- }
- CicoEventInfo* eviTarget = getID2ObjEV(evId);
- if ((CicoEventInfo*)0 == eviTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCS >>%d<<,%d, %d, \"%s\"",evId, (int)j, (int)gce,
- gcv);
- return 0;
- }
- if (false == addGC(eviTarget, j, gce, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addGCS %d,>>%d<<, %d, \"%s\"",evId, (int)j, (int)gce, gcv);
- return 0;
- }
- return evId;
-}
-
-/**
- * @brief ico_sttm_getStateMachineX
- * @param smCWId stateMachine-object ID
- * @param fname calling function Name
- * @return not 0:get success 0:get fail
- */
-CicoStateMachine* ico_sttm_getStateMachineX(int smCWId, const char* fname)
-{
- CicoStateCore* cscTarget = getID2ObjSTT(smCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("%s >>%d<<",fname, smCWId);
- return (CicoStateMachine*)0;
- }
- if (false == cscTarget->isStateMachine()) {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("%s >>%d(%s:%d:%d)<<", fname, smCWId,
- cscTarget->getName().c_str(), cscTarget->getValue(),
- (int)cscTarget->getType());
- return (CicoStateMachine*)0;
- }
- return (CicoStateMachine*)cscTarget;
-}
-
-/**
- * @brief add guard condition
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-
-CicoStateCore* getStateObject(int smCWId, int value, const char* fnc)
-{
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, fnc);
- if ((CicoStateMachine*)0 == csm) {
- sttmerr = STTMNOTFIND;
- _DBG("%s>>%d<<, %d", fnc, smCWId, value);
- return 0;
- }
- const CicoStateCore* csc = csm->getState(value);
- if ((CicoStateCore*)0 == csc) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d,>>%d<<", fnc, smCWId, value);
- return 0;
- }
- return (CicoStateCore*)csc;
-}
-
-
-CicoStateCore* getStateObject(int smCWId, const char* name, const char* fnc)
-{
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, fnc);
- if ((CicoStateMachine*)0 == csm) {
- sttmerr = STTMNOTFIND;
- _DBG("%s>>%d<<, %s", fnc, smCWId, name);
- return 0;
- }
- const CicoStateCore* csc = csm->getState(name);
- if ((CicoStateCore*)0 == csc) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d,>>%s<<", fnc, smCWId, name);
- return 0;
- }
- return (CicoStateCore*)csc;
-}
-
-
-CicoEventInfo* getEventInfoV(int smCWId, int value,
- const char* evname, unsigned short ev,
- const char* fnc)
-{
- CicoStateCore* csc;
- csc = getStateObject(smCWId, value, fnc);
- if ((CicoStateCore*)0 == csc) {
- return 0;
- }
- const CicoEventInfo* t = csc->getEventInfo(evname, ev);
- if ((CicoEventInfo*)0 == t) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %d,>>%s, %d<<", fnc, smCWId, value, evname, ev);
- return 0;
- }
- return (CicoEventInfo*)t;
-}
-
-
-CicoEventInfo* getEventInfoN(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- const char* fnc)
-{
- CicoStateCore* csc;
- csc = getStateObject(smCWId, name, fnc);
- if ((CicoStateCore*)0 == csc) {
- return 0;
- }
- const CicoEventInfo* t = csc->getEventInfo(evname, ev);
- if ((CicoEventInfo*)0 == t) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %s,>>%s, %d<<", fnc, smCWId, name, evname, ev);
- return 0;
- }
- return (CicoEventInfo*)t;
-}
-
-
-/**
- * @brief add guard condition
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-extern "C" int ico_sttm_addGCI_V(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCI_V";
- CicoEventInfo* t;
- t = getEventInfoV(smCWId, value, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %d, %s, %d, >> %d, %d, %d<<", fnc, smCWId, value,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-
-extern "C" int ico_sttm_addGCD_V(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCD_V";
- CicoEventInfo* t;
- t = getEventInfoV(smCWId, value, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %d, %s, %d, >> %d, %d, %f<<", fnc, smCWId, value,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-extern "C" int ico_sttm_addGCS_V(int smCWId, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCS_V";
- CicoEventInfo* t;
- t = getEventInfoV(smCWId, value, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %d, %s, %d, >> %d, %d, %s<<", fnc, smCWId, value,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-/**
- * @brief add guard condition
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-extern "C" int ico_sttm_addGCIVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCIVV >>%d<<, %d, %s, %d, %d, %d, %d", smVal,
- value, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCI_V(id, value, evname, ev, j, gc, gcv);
-}
-
-extern "C" int ico_sttm_addGCDVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCDVV >>%d<<, %d, %s, %d, %d, %d, %f", smVal,
- value, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCD_V(id, value, evname, ev, j, gc, gcv);
-}
-
-extern "C" int ico_sttm_addGCSVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCSVV >>%d<<, %d, %s, %d, %d, %d, %s", smVal,
- value, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCS_V(id, value, evname, ev, j, gc, gcv);
-}
-
-
-/**
- * @brief add guard condition
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-extern "C" int ico_sttm_addGCI_N(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCI_N";
- CicoEventInfo* t;
- t = getEventInfoN(smCWId, name, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %s, %s, %d, >> %d, %d, %d<<", fnc, smCWId, name,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-extern "C" int ico_sttm_addGCD_N(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCD_N";
- CicoEventInfo* t;
- t = getEventInfoN(smCWId, name, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %s, %s, %d, >> %d, %d, %f<<", fnc, smCWId, name,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-
-extern "C" int ico_sttm_addGCS_N(int smCWId, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- const char* fnc = "ico_sttm_addGCS_N";
- CicoEventInfo* t;
- t = getEventInfoN(smCWId, name, evname, ev, fnc);
- if ((CicoEventInfo*)0 == t) {
- return 0;
- }
- if (false == addGC(t, j, gc, gcv)) {
- sttmerr = STTMPARAMERR;
- _DBG("%s %d, %s, %s, %d, >> %d, %d, %s<<", fnc, smCWId, name,
- evname, ev, (int)j, (int)gc, gcv);
- return 0;
- }
- return 1;
-}
-
-/**
- * @brief add guard condition
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-extern "C" int ico_sttm_addGCINN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCINN >>%s<<, %s, %s, %d, %d, %d, %d", smNm,
- name, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCI_N(id, name, evname, ev, j, gc, gcv);
-}
-
-extern "C" int ico_sttm_addGCDNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCDNN >>%s<<, %s, %s, %d, %d, %d, %f", smNm,
- name, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCD_N(id, name, evname, ev, j, gc, gcv);
-}
-
-extern "C" int ico_sttm_addGCSNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addGCSNN >>%s<<, %s, %s, %d, %d, %d, %s", smNm,
- name, evname, ev, j, gc, gcv);
- return 0;
- }
- return ico_sttm_addGCS_N(id, name, evname, ev, j, gc, gcv);
-}
-
-/**
- * @brief callback call entryAction/exitAction/doAction
- * @param ev callback function parameter(trigger event)
- * @param sCWId callback function parameter
- * @param fnc callback function
- */
-extern "C" {
- void callbackActionC(st_event* ev, int sCWId, void* vfnc)
- {
- void (*fnc)(st_event*, int) = (void (*)(st_event*, int))vfnc;
- fnc(ev, sCWId);
- }
-}
-
-/**
- * @breif callback action for c++
- * @param ev trigger event
- * @param state-objects the action occurred
- */
-void callbackActionCPP(const CicoEvent& ev, const CicoStateCore* stt, int vec)
-{
- int sz = callbackFnc.size();
- if ((1 > vec) || (sz < vec)) {
- return;
- }
-
- int sCWId = getObjSTT2ID(stt);
- if (0 == sCWId) { // state-objects outside the control
- return; //
- }
-
- st_event stev;
- stev.ev = ev.getEV();
-
- CicoEvent::E_TOV tov = ev.getVTG();
- if ( CicoEvent::EEvtGCInt == tov) {
- stev.uk = E_NUMBER;
- stev.u.i = ev.getGCVi();
- }
- else if (CicoEvent::EEvtGCDouble == tov) {
- stev.uk = E_DOUBLE;
- stev.u.d = ev.getGCVd();
- }
- else if (CicoEvent::EEvtGCStr == tov) {
- stev.uk = E_STRING;
- stev.u.s = ev.getGCVs().c_str();
- }
- else {
- stev.uk = E_NONE;
- }
- stev.v = ev.getAdVal();
-
- callbackActionC(&stev, sCWId, callbackFnc[vec-1]);
- return;
-}
-
-#ifndef CWAPPERCALLBACKACTION_H
-#define CWAPPERCALLBACKACTION_H
-/**
- * C Wrapper call back CicoStateAction
- */
-class CicoCWrapperCallbackAction :public CicoStateAction
-{
-public:
- CicoCWrapperCallbackAction();
- // entry-Action
- void onEntry(const CicoEvent& ev, const CicoState* stt, int addval);
- void onEntry(const CicoEvent& ev, const CicoFinalState* stt, int addval);
- void onEntry(const CicoEvent& ev, const CicoHistoryState* stt,
- int addval);
- // exit-Action
- void onExit(const CicoEvent& ev, const CicoState* stt, int addval);
- void onExit(const CicoEvent& ev, const CicoHistoryState* stt, int addval);
-
- // doAction
- void onDo(const CicoEvent& ev, const CicoState* stt, int addval);
-};
-#endif // CWAPPERCALLBACKACTION_H
-
-/**
- * @brief cnstractor
- */
-CicoCWrapperCallbackAction::CicoCWrapperCallbackAction()
-{
-}
-
-/**
- * @brief entry Action callback
- * @param ev trigger event data
- * @param stt entery state-object
- * @param addval Additional information
- */
-void CicoCWrapperCallbackAction::onEntry(const CicoEvent& ev,
- const CicoState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-void CicoCWrapperCallbackAction::onEntry(const CicoEvent& ev,
- const CicoFinalState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-void CicoCWrapperCallbackAction::onEntry(const CicoEvent& ev,
- const CicoHistoryState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-/**
- * @brief exit Action callback
- * @param ev trigger event data
- * @param stt exit state-object
- * @param addval Additional information
- */
-void CicoCWrapperCallbackAction::onExit(const CicoEvent& ev,
- const CicoState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-void CicoCWrapperCallbackAction::onExit(const CicoEvent& ev,
- const CicoHistoryState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-/**
- * @brief do Action callback
- * @param ev trigger event data
- * @param stt active state-object
- * @param addval Additional information
- */
-void CicoCWrapperCallbackAction::onDo(const CicoEvent& ev,
- const CicoState* stt, int addval)
-{
- callbackActionCPP(ev, (CicoStateCore*)stt, addval);
-}
-
-/**
- * Declaration of the class CicoCWrapperCallbackAction
- */
-CicoCWrapperCallbackAction cWprActn;
-
-
-/* registration entry-Action,exit-Action,do-action callback */
-/**
- * @brief Callback registration
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:Failure
- */
-extern "C" int ico_sttm_addEntryAction(int sCWId, void (*fnc)(st_event*, int))
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* csc = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == csc) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addEntryAction >>%d<<, fnc", sCWId);
- return 0;
- }
- if (0 == fnc) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addEntryAction %d,>>fnc(0x0)<<", sCWId);
- return 0;
- }
-
- callbackFnc.push_back((void*)fnc);
- int addval = callbackFnc.size();
-
- if (true == csc->isState()) {
- CicoState* cs = (CicoState*)csc;
- cs->addEntryAction((CicoStateAction*)&cWprActn, addval);
- }
- else if (true == csc->isFinalState()) {
- CicoFinalState* cfs = (CicoFinalState*)csc;
- cfs->addEntryAction((CicoStateAction*)&cWprActn, addval);
- }
- else if (true == csc->isHistoryState()) {
- CicoHistoryState* chs = (CicoHistoryState*)csc;
- chs->addEntryAction((CicoStateAction*)&cWprActn, addval);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_addEntryAction >>%d(%s:%d:%d)<<,fnc", sCWId,
- csc->getName().c_str(), csc->getValue(), (int)csc->getType());
- return 0;
- }
- return sCWId;
-}
-
-
-extern "C" int ico_sttm_addExitAction(int sCWId, void (*fnc)(st_event*, int))
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* csc = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == csc) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addExitAction >>%d<<, fnc", sCWId);
- return 0;
- }
- if (0 == fnc) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addExitAction %d,>>fnc(0x0)<<", sCWId);
- return 0;
- }
-
- callbackFnc.push_back((void*)fnc);
- int addval = callbackFnc.size();
-
- if (true == csc->isState()) {
- CicoState* cs = (CicoState*)csc;
- cs->addExitAction((CicoStateAction*)&cWprActn, addval);
- }
- else if (true == csc->isHistoryState()) {
- CicoHistoryState* chs = (CicoHistoryState*)csc;
- chs->addExitAction((CicoStateAction*)&cWprActn, addval);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_addExitAction >>%d(%s:%d:%d)<<,fnc", sCWId,
- csc->getName().c_str(), csc->getValue(), (int)csc->getType());
- return 0;
- }
- return sCWId;
-}
-
-
-extern "C" int ico_sttm_addDoAction(int sCWId, void (*fnc)(st_event*, int))
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* csc = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == csc) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDoAction >>%d<<, fnc", sCWId);
- return 0;
- }
- if (0 == fnc) {
- sttmerr = STTMPARAMERR;
- _DBG("ico_sttm_addDoAction %d,>>fnc(0x0)<<", sCWId);
- return 0;
- }
-
- callbackFnc.push_back((void*)fnc);
- int addval = callbackFnc.size();
-
- if (true == csc->isState()) {
- CicoState* cs = (CicoState*)csc;
- cs->addDoAction((CicoStateAction*)&cWprActn, addval);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_addDoAction >>%d(%s:%d:%d)<<,fnc", sCWId,
- csc->getName().c_str(), csc->getValue(), (int)csc->getType());
- return 0;
- }
- return sCWId;
-}
-
-/**
- * @brief Callback registration
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addEntryAction_V(int smCWId, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int lid = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addEntryAction_V >>%d<<,>>%d<<, .", smCWId, value);
- return 0;
- }
- return ico_sttm_addEntryAction(lid, fnc);
-}
-
-extern "C" int ico_sttm_addExitAction_V(int smCWId, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int lid = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addExitAction_V >>%d<<,>>%d<<, .", smCWId, value);
- return 0;
- }
- return ico_sttm_addExitAction(lid, fnc);
-}
-
-extern "C" int ico_sttm_addDoAction_V(int smCWId, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int lid = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDoAction_V >>%d<<,>>%d<<, .", smCWId, value);
- return 0;
- }
- return ico_sttm_addDoAction(lid, fnc);
-}
-
-/**
- * @brief Callback registration
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addEntryActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addEntryActionVV >>%d<<, %d, .", smVal, value);
- return 0;
- }
- return ico_sttm_addEntryAction_V(id, value, fnc);
-}
-
-extern "C" int ico_sttm_addExitActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addExitActionVV >>%d<<, %d, .", smVal, value);
- return 0;
- }
- return ico_sttm_addExitAction_V(id, value, fnc);
-}
-
-extern "C" int ico_sttm_addDoActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDoActionVV >>%d<<, %d, .", smVal, value);
- return 0;
- }
- return ico_sttm_addDoAction_V(id, value, fnc);
-}
-
-
-/**
- * @brief Callback registration
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addEntryAction_N(int smCWId, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- int lid = ico_sttm_retrivevSName(smCWId, name);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addEntryAction_N >>%d<<,>>%s<<, .", smCWId, name);
- return 0;
- }
- return ico_sttm_addEntryAction(lid, fnc);
-}
-
-extern "C" int ico_sttm_addExitAction_N(int smCWId, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- int lid = ico_sttm_retrivevSName(smCWId, name);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addExitAction_N >>%d<<,>>%s<<, .", smCWId, name);
- return 0;
- }
- return ico_sttm_addExitAction(lid, fnc);
-}
-
-extern "C" int ico_sttm_addDoAction_N(int smCWId, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- int lid = ico_sttm_retrivevSName(smCWId, name);
- if (0 == lid) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDoAction_N >>%d<<,>>%s<<, .", smCWId, name);
- return 0;
- }
- return ico_sttm_addDoAction(lid, fnc);
-}
-
-/**
- * @brief Callback registration
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addEntryActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addEntryActionNN >>%s<<, %s, .", smNm, name);
- return 0;
- }
- return ico_sttm_addEntryAction_N(id, name, fnc);
-}
-
-extern "C" int ico_sttm_addExitActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addExitActionNN >>%s<<, %s, .", smNm, name);
- return 0;
- }
- return ico_sttm_addExitAction_N(id, name, fnc);
-}
-
-extern "C" int ico_sttm_addDoActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId))
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDoActionNN >>%s<<, %s, .", smNm, name);
- return 0;
- }
- return ico_sttm_addDoAction_N(id, name, fnc);
-}
-
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param trCWId finish transition destination(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:set Failure
- */
-extern "C" int ico_sttm_setFinishTransition(int sCWId, int trCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransition >>%d<<, %d", sCWId, trCWId);
- return 0;
- }
- CicoStateCore* cscTrans = getID2ObjSTT(trCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTrans) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransition %d,>>%d<<", sCWId, trCWId);
- return 0;
- }
- if (false == cscTarget->isState()) {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_setFinishTransition >>%d(%s:%d:%d)<<, %d", sCWId,
- cscTarget->getName().c_str(), cscTarget->getValue(),
- (int)cscTarget->getType(), trCWId);
- return 0;
- }
- CicoState* cs = (CicoState*) cscTarget;
- if (true == cscTrans->isState()) {
- cs->setFinishTransition((CicoState*)cscTrans);
- }
- else if (true == cscTrans->isFinalState()) {
- cs->setFinishTransition((CicoFinalState*)cscTrans);
- }
- else if (true == cscTrans->isHistoryState()) {
- cs->setFinishTransition((CicoHistoryState*)cscTrans);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_setFinishTransition %d,>>%d(%s:%d:%d)<<", sCWId,
- trCWId, cscTarget->getName().c_str(),
- cscTarget->getValue(), (int)cscTarget->getType());
- return 0;
- }
- return sCWId;
-}
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param trCWId finish transition destination(c-wrapper local ID)
- * @param trVl value is state-object identification number transition destination
- * @return not 0:Success
- * @ 0:set Failure
- */
-extern "C" int ico_sttm_setFinishTransition_V_(int smCWId, int value,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- _DBG("ico_sttm_setFinishTransition_V_ >> %d, %d<<, %d",smCWId, value, trCWId);
- return 0;
- }
- return ico_sttm_setFinishTransition(id, trCWId);
-}
-
-extern "C" int ico_sttm_setFinishTransition_VV(int smCWId, int value,
- int trVl)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrieveSVal(smCWId, trVl);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransition_VV >>%d<<, %d,>>%d<<",smCWId, value, trVl);
- return 0;
- }
- return ico_sttm_setFinishTransition_V_(smCWId, value, idT);
-}
-
-extern "C" int ico_sttm_setFinishTransitionVVV(int smVal, int value, int trVl)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransitionVVV >>%d<<, %d, %d", smVal,
- value, trVl);
- return 0;
- }
- return ico_sttm_setFinishTransition_VV(id, value, trVl);
-}
-
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param trCWId finish transition destination(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:set Failure
- */
-extern "C" int ico_sttm_setFinishTransition_N_(int smCWId, const char* name,
- int trCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransition_N_ >>%d, %s<<, %d",smCWId, name, trCWId);
- return 0;
- }
- return ico_sttm_setFinishTransition(id, trCWId);
-}
-
-extern "C" int ico_sttm_setFinishTransition_NN(int smCWId, const char* name,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int idT = ico_sttm_retrivevSName(smCWId, trNm);
- if (0 == idT) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransition_NN >>%d<<, %s,>>%s<<",smCWId,
- name, trNm);
- return 0;
- }
- return ico_sttm_setFinishTransition_N_(smCWId, name, idT);
-}
-
-extern "C" int ico_sttm_setFinishTransitionNNN(const char* smNm,
- const char* name,
- const char* trNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setFinishTransitionNNN >>%s<<, %s, %s", smNm, name,
- trNm);
- return 0;
- }
- return ico_sttm_setFinishTransition_NN(id, name, trNm);
-
-}
-
-
-/**
- * @brief Registration of default history state-objectss
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param dfCWId default transition destination(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addDefault(int sCWId, int dfCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefault >>%d<<, %d", sCWId, dfCWId);
- return 0;
- }
- CicoStateCore* cscDef = getID2ObjSTT(dfCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscDef) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefault %d,>>%d<<", sCWId, dfCWId);
- return 0;
- }
- if (false == cscTarget->isHistoryState()) {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_addDefault >>%d(%s:%d:%d)<<, %d", sCWId,
- cscTarget->getName().c_str(), cscTarget->getValue(),
- (int)cscTarget->getType(), dfCWId);
- return 0;
- }
- CicoHistoryState* chs = (CicoHistoryState*) cscTarget;
- if (true == cscDef->isState()) {
- chs->addDefaultState((CicoState*)cscDef);
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_addDefault %d,>>%d(%s:%d:%d)<<", sCWId,
- dfCWId, cscTarget->getName().c_str(),
- cscTarget->getValue(), (int)cscTarget->getType());
- return 0;
- }
- return sCWId;
-}
-
-/**
- * @brief Registration of default history state-objectss
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param dfCWId default transition destination(c-wrapper local ID)
- * @param dfVal value is state-object identification number
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addDefault_V_(int smCWId, int value, int dfCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefaultV >>%d, %d<<, %d", smCWId, value, dfCWId);
- return 0;
- }
- return ico_sttm_addDefault(id, dfCWId);
-}
-
-extern "C" int ico_sttm_addDefault_VV(int smCWId, int value, int dfVal)
-{
- sttmerr = STTMNOERROR;
- int dfCWId = ico_sttm_retrieveSVal(smCWId, dfVal);
- if (0 == dfCWId) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefaultVV >>%d<<, %d,>>%d<<", smCWId, value, dfVal);
- return 0;
- }
- return ico_sttm_addDefault_V_(smCWId, value, dfCWId);
-}
-
-extern "C" int ico_sttm_addDefaultVVV(int smVal, int value, int dfVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefaultVVV >>%d<<, %d,>>%d<<", smVal, value,
- dfVal);
- return 0;
- }
- return ico_sttm_addDefault_VV(id, value, dfVal);
-}
-
-/**
- * @brief Registration of default history state-objectss
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param dfCWId default transition destination(c-wrapper local ID)
- * @param dfNm name is state-object Identification name
- * @return not 0:Success
- * @ 0:added Failure
- */
-extern "C" int ico_sttm_addDefault_N_(int smCWId, const char* name, int dfCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefault_N_ >>%d, %s<<, %d",smCWId, name, dfCWId);
- return 0;
- }
- return ico_sttm_addDefault(id, dfCWId);
-}
-
-extern "C" int ico_sttm_addDefault_NN(int smCWId, const char* name, const char* dfNm)
-{
- sttmerr = STTMNOERROR;
- int idD = ico_sttm_retrivevSName(smCWId, dfNm);
- if (0 == idD) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefault_NN >>%d<<, %s,>>%s<<", smCWId, name, dfNm);
- return 0;
- }
- return ico_sttm_addDefault_N_(smCWId, name, idD);
-}
-
-extern "C" int ico_sttm_addDefaultNNN(const char* smNm, const char* name,
- const char* dfNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addDefaultNNN >>%s<<, %s, %s", smNm, name, dfNm);
- return 0;
- }
- return ico_sttm_addDefault_NN(id, name, dfNm);
-}
-
-/**
- * @breif Registration of start position state-objects
- * @param ID stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @param sCWId start position state-object ID no.(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:add failure
- */
-extern "C" int ico_sttm_addStartPosition(int CWId, int sCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(CWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setStartPosition >>%d<<, %d", CWId, sCWId);
- return 0;
- }
- CicoStateCore* cscIni = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscIni) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_setStartPosition %d,>>%d<<", CWId, sCWId);
- return 0;
- }
- CicoState* cs = (CicoState*)0;
- CicoHistoryState* chs = (CicoHistoryState*)0;
- if (true == cscIni->isState()) {
- cs = (CicoState*)cscIni;
- }
- else if (true == cscIni->isHistoryState()) {
- chs = (CicoHistoryState*)cscIni;
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_setStartPosition %d,>>%d(%s:%d:%d)<<", CWId, sCWId,
- cscIni->getName().c_str(), cscIni->getValue(),
- (int)cscIni->getType());
- return 0;
- }
- if (true == cscTarget->isStateMachine()) {
- CicoStateMachine* csm = (CicoStateMachine*)cscTarget;
- if ((CicoState*)0 != cs) {
- csm->addInitState(cs);
- }
- else {
- csm->addInitState(chs);
- }
- }
- else if (true == cscTarget->isState()) {
- CicoState* csT = (CicoState*)cscTarget;
- if ((CicoState*)0 != cs) {
- csT->addInitState(cs);
- }
- else {
- csT->addInitState(chs);
- }
- }
- else {
- sttmerr = STTMTYPEMISMATCH;
- _DBG("ico_sttm_setStartPosition >>%d(%s:%d:%d)<<, %d", CWId,
- cscTarget->getName().c_str(), cscTarget->getValue(),
- (int)cscTarget->getType(), sCWId);
- return 0;
- }
- return CWId;
-}
-
-
-
-/**
- * @breif Registration of start position state-objects
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param sCWId start position state-object ID no.(c-wrapper local ID)
- * @param value spVal is state-object identification number
- * @return not 0:Success
- * @ 0:set failure
- */
-extern "C" int ico_sttm_addStartPosition_V_(int smCWId, int value, int sCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveSVal(smCWId, value);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPosition_V_ >>%d, %d<<, %d",smCWId, value, sCWId);
- return 0;
- }
- return ico_sttm_addStartPosition(id, sCWId);
-}
-
-
-extern "C" int ico_sttm_addStartPosition_VV(int smCWId, const int value, int spVal)
-{
- sttmerr = STTMNOERROR;
- int idSP = ico_sttm_retrieveSVal(smCWId, spVal);
- if (0 == idSP) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPosition_VV >>%d<<, %d,>>%d<<",smCWId, value, spVal);
- return 0;
- }
- return ico_sttm_addStartPosition_V_(smCWId, value, idSP);
-}
-
-extern "C" int ico_sttm_addStartPositionVVV(int smVal, int value, int spVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionVVV >>%d<<, %d, %d", smVal, value,
- spVal);
- return 0;
- }
- return ico_sttm_addStartPosition_VV(id, value, spVal);
-}
-
-extern "C" int ico_sttm_addStartPositionSMVV(int smVal, int spVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionSMVV >>%d<<, %d", smVal, spVal);
- return 0;
- }
- int idSP = ico_sttm_retrieveSVal(id, spVal);
- if (0 == idSP) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionSMVV %d,>>%d<<",smVal, spVal);
- return 0;
- }
- return ico_sttm_addStartPosition(id, idSP);
-}
-
-
-/**
- * @breif Registration of start position state-objects
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param name name is state-object Identification name
- * @param sCWId start position state-object ID no.(c-wrapper local ID)
- * @param name spNm is state-object Identification name
- * @return not 0:Success
- * @ 0:set failure
- */
-extern "C" int ico_sttm_addStartPosition_N_(int smCWId, const char* name, int sCWId)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrivevSName(smCWId, name);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPosition_N_ >>%d, %s<<, %d",smCWId, name, sCWId);
- return 0;
- }
- return ico_sttm_addStartPosition(id, sCWId);
-}
-
-extern "C" int ico_sttm_addStartPosition_NN(int smCWId, const char* name,
- const char* spNm)
-{
- sttmerr = STTMNOERROR;
- int idSP = ico_sttm_retrivevSName(smCWId, spNm);
- if (0 == idSP) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPosition_NN >>%d<<, %s,>>%s<<",smCWId, name,
- spNm);
- return 0;
- }
- return ico_sttm_addStartPosition_N_(smCWId, name, idSP);
-}
-
-extern "C" int ico_sttm_addStartPositionNNN(const char* smNm, const char* name,
- const char* spNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionNNN >>%s<<, %s, %s", smNm, name,
- spNm);
- return 0;
- }
- return ico_sttm_addStartPosition_NN(id, name, spNm);
-}
-
-extern "C" int ico_sttm_addStartPositionSMNN(const char* smNm, const char* spNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionSMNN >>%s<<, %s", smNm, spNm);
- return 0;
- }
- int idSP = ico_sttm_retrivevSName(id, spNm);
- if (0 == idSP) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_addStartPositionSMNN %s,>>%s<<",smNm, spNm);
- return 0;
- }
- return ico_sttm_addStartPosition(id, idSP);
-}
-
-
-/* Operational system */
-/**
- * @breif start stateMachine
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @return not 0:Success
- * @ 0:start Failure
- */
-extern "C" int ico_sttm_start(int smCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachine* csm = ico_sttm_getStateMachineX(smCWId, "ico_sttm_start");
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- return csm->start()? smCWId:0;
-}
-
-
-
-extern "C" int ico_sttm_startV(int smVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_startV >>%d<<", smVal);
- return 0;
- }
- return ico_sttm_start(id);
-}
-
-extern "C" int ico_sttm_startN(const char* smNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_startN >>%s<<", smNm);
- return 0;
- }
- return ico_sttm_start(id);
-}
-
-/**
- * @breif stop stateMachine
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @return not 0:Success
- * @ 0:stop Failure
- */
-extern "C" int ico_sttm_stop(int smCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachine* csm = ico_sttm_getStateMachineX(smCWId, "ico_sttm_stop");
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- return csm->stop()? smCWId:0;
-}
-
-extern "C" int ico_sttm_stopV(int smVal)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_stopV >>%d<<", smVal);
- return 0;
- }
- return ico_sttm_stop(id);
-}
-
-extern "C" int ico_sttm_stopN(const char* smNm)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_stopN >>%s<<", smNm);
- return 0;
- }
- return ico_sttm_stop(id);
-}
-
-bool ico_sttm_eventX(int smCWId, CicoEvent& ev, const char* fname)
-{
- CicoStateMachine* csm = ico_sttm_getStateMachineX(smCWId, fname);
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- return csm->eventEntry(ev);
-}
-
-/**
- * @brief Issue an event
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param ev event No.(Use the 1000-65535)
- * @param gcv Comparison value of guard condition
- * @param info Additional information user
- * @return not 0:Success on Transition
- * @ 0: none Transition
- */
-extern "C" int ico_sttm_event(int smCWId, unsigned short ev, void* info)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, info);
- return ico_sttm_eventX(smCWId, oev, "ico_sttm_event")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventGCI(int smCWId, unsigned short ev, int gcv, void* info)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv, info);
- return ico_sttm_eventX(smCWId, oev, "ico_sttm_eventGCI")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventGCD(int smCWId, unsigned short ev, double gcv, void* info)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv, info);
- return ico_sttm_eventX(smCWId, oev, "ico_sttm_eventGCD")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventGCS(int smCWId, unsigned short ev, const char* gcv, void* info)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv, info);
- return ico_sttm_eventX(smCWId, oev, "ico_sttm_eventGCS")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventV(int smVal, unsigned short ev, void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventV >>%d<<, %d, .", smVal, ev);
- return 0;
- }
- return ico_sttm_event(id, ev, info);
-}
-
-extern "C" int ico_sttm_eventGCIV(int smVal, unsigned short ev, int gcv,
- void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCIV >>%d<<, %d, %d, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCI(id, ev, gcv, info);
-}
-
-extern "C" int ico_sttm_eventGCDV(int smVal, unsigned short ev, double gcv,
- void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCDV >>%d<<, %d, %f, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCD(id, ev, gcv, info);
-}
-
-extern "C" int ico_sttm_eventGCSV(int smVal, unsigned short ev,
- const char* gcv, void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCSV >>%d<<, %d, %s, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCS(id, ev, gcv, info);
-}
-
-extern "C" int ico_sttm_eventN(const char* smNm, unsigned short ev, void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventN >>%s<<, %d, .", smNm, ev);
- return 0;
- }
- return ico_sttm_event(id, ev, info);
-}
-
-extern "C" int ico_sttm_eventGCIN(const char* smNm, unsigned short ev, int gcv,
- void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCIN >>%s<<, %d, %d, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCI(id, ev, gcv, info);
-}
-
-extern "C" int ico_sttm_eventGCDN(const char* smNm, unsigned short ev, double gcv,
- void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCDN >>%s<<, %d, %f, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCD(id, ev, gcv, info);
-}
-
-extern "C" int ico_sttm_eventGCSN(const char* smNm, unsigned short ev, const char* gcv,
- void* info)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCSN >>%s<<, %d, %s, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventGCS(id, ev, gcv, info);
-}
-
-
-
-bool ico_sttm_eventTestX(int smCWId, CicoEvent& ev, const char* fname)
-{
- CicoStateMachine* csm = ico_sttm_getStateMachineX(smCWId, fname);
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- return csm->eventTest(ev);
-}
-
-/**
- * @brief Test of the transition
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param ev event No.(Use the 1000-65535)
- * @param gcv Comparison value of guard condition
- * @param info Additional information user
- * @return not 0:Success on Transition
- * @ 0: none Transition
- */
-extern "C" int ico_sttm_eventTest(int smCWId, unsigned short ev)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev);
- return ico_sttm_eventTestX(smCWId, oev, "ico_sttm_eventTest")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventTestGCI(int smCWId, unsigned short ev, int gcv)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv);
- return ico_sttm_eventTestX(smCWId, oev, "ico_sttm_eventTestGCI")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventTestGCD(int smCWId, unsigned short ev, double gcv)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv);
- return ico_sttm_eventTestX(smCWId, oev, "ico_sttm_eventTestGCD")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventTestGCS(int smCWId, unsigned short ev, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- CicoEvent oev(ev, gcv);
- return ico_sttm_eventTestX(smCWId, oev, "ico_sttm_eventTestGCS")? smCWId:0;
-}
-
-extern "C" int ico_sttm_eventTestV(int smVal, unsigned short ev)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestV >>%d<<, %d, .", smVal, ev);
- return 0;
- }
- return ico_sttm_eventTest(id, ev);
-}
-
-extern "C" int ico_sttm_eventTestGCIV(int smVal, unsigned short ev, int gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventGCIV >>%d<<, %d, %d, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCI(id, ev, gcv);
-}
-
-extern "C" int ico_sttm_eventTestGCDV(int smVal, unsigned short ev, double gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestGCDV >>%d<<, %d, %f, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCD(id, ev, gcv);
-}
-
-extern "C" int ico_sttm_eventTestGCSV(int smVal, unsigned short ev, const char* gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestGCSV >>%d<<, %d, %s, .", smVal, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCS(id, ev, gcv);
-}
-
-extern "C" int ico_sttm_eventTestN(const char* smNm, unsigned short ev)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestN >>%s<<, %d, .", smNm, ev);
- return 0;
- }
- return ico_sttm_eventTest(id, ev);
-}
-
-extern "C" int ico_sttm_eventTestGCIN(const char* smNm, unsigned short ev, int gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestGCIN >>%s<<, %d, %d, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCI(id, ev, gcv);
-}
-
-extern "C" int ico_sttm_eventTestGCDN(const char* smNm, unsigned short ev, double gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestGCDN >>%s<<, %d, %f, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCD(id, ev, gcv);
-}
-
-extern "C" int ico_sttm_eventTestGCSN(const char* smNm, unsigned short ev,
- const char* gcv)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_eventTestGCSN >>%s<<, %d, %s, .", smNm, ev, gcv);
- return 0;
- }
- return ico_sttm_eventTestGCS(id, ev, gcv);
-}
-
-/**
- * @brief retrieve stateMachine-object
- * @param value/name stateMachine-object ID no. / name
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:not find
- */
-extern "C" int ico_sttm_retrieveMVal(int value)
-{
- sttmerr = STTMNOERROR;
- int r = 0;
- int sz = stateObjects.size();
- for (int i = 0; i< sz; i++) {
- if (true == stateObjects[i]->isStateMachine()) {
- if (value == stateObjects[i]->getValue() ) {
- r = i+1;
- break; // break of for i<sz
- }
- }
- }
- return r;
-}
-
-extern "C" int ico_sttm_retrieveMName(const char* name)
-{
- sttmerr = STTMNOERROR;
- std::string oname(name);
- int r = 0;
- int sz = stateObjects.size();
- for (int i = 0; i< sz; i++) {
- if (true == stateObjects[i]->isStateMachine()) {
- if (oname == stateObjects[i]->getName()) {
- r = i+1;
- break; // break of for i<sz
- }
- }
- }
- return r;
-}
-
-/**
- * @brief retrieve state-object(state/historyState/finalState)
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value/name state(state/historyState/finalState)-object ID no. / name
- * @return not 0:state-object ID no.(c-wrapper local ID)
- * @ 0:not find
- */
-extern "C" int ico_sttm_retrieveSVal(int smCWId, int value)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, "ico_sttm_retrieveSVal");
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- const CicoStateCore* csc = csm->getState(value);
- if ((CicoStateCore*)0 == csc) {
- _DBG("ico_sttm_retrieveSVal %d, >>%d<<", smCWId, value);
- return 0;
- }
- return getObjSTT2ID(csc);
-}
-
-extern "C" int ico_sttm_retrivevSName(int smCWId, const char* name)
-{
- sttmerr = STTMNOERROR;
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, "ico_sttm_retrivevSName");
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- const CicoStateCore* csc = csm->getState(name);
- if ((CicoStateCore*)0 == csc) {
- _DBG("ico_sttm_retrivevSName %d, >>%s<<", smCWId, name);
- return 0;
- }
- return getObjSTT2ID(csc);
-}
-
-
-/**
- * @brief object check
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @return not 0:stateMachine-object
- * @ 0:no stateMachine-object
- */
-extern "C" int ico_sttm_isStateMachine(int smCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(smCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isStateMachine >>%d<<", smCWId);
- return 0;
- }
- return cscTarget->isStateMachine()? smCWId:0;
-}
-
-/**
- * @brief object check
- * @param sCWId state-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-extern "C" int ico_sttm_isState(int sCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isState >>%d<<", sCWId);
- return 0;
- }
- return cscTarget->isState()? sCWId:0;
-}
-
-
-/**
- * @brief object check
- * @param sCWId historyState-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-extern "C" int ico_sttm_isHistoryState(int sCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isHistoryState >>%d<<", sCWId);
- return 0;
- }
- return cscTarget->isHistoryState()? sCWId:0;
-}
-
-
-/**
- * @brief object check
- * @param sCWId finalState-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-extern "C" int ico_sttm_isFinalState(int sCWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(sCWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isFinalState >>%d<<", sCWId);
- return 0;
- }
- return cscTarget->isFinalState()? sCWId:0;
-}
-
-/**
- * @brief get state-object running
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param X[] Enter the active state-objects(c-wrapper local ID) or value or name
- * @param size of array sCWIds or values or names
- * @param value true:get value false:get c-wrapper ID
- * @param p top or all or bottom get position is getCurrentState parameter
- * @param fname call function name
- * @return Number of registered X
- * @ -1:size over
- */
-int ico_sttm_getActiveStateX(int smCWId, int X[], size_t arysz, bool value,
- CicoStateCore::E_GetPolicy p, const char* fname)
-{
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, fname);
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- std::vector<const CicoState*> stt;
- if (false == csm->getCurrentState(stt, p)) {
- _DBG("%s NO ACTIVE STATEMACHINE(\"%s\":%d)",fname,
- csm->getName().c_str(), csm->getValue());
- return 0;
- }
- int r = 0;
- int sz = stt.size();
- for (int i = 0; i < sz; i++) {
- if ( r >= (int)arysz ) {
- r = -1;
- break; // break of for i<sz
- }
- if (true == value) {
- X[r] = stt[i]->getValue(); // set state-object value
- r++;
- }
- else {
- X[r] = getObjSTT2ID(stt[i]); // set state-object C-wrapper local ID
- if (0 != X[r]) {
- r++;
- }
- }
- }
- if (0 == r) {
- sttmerr = STTMNOTFIND;
- _DBG("%s get size %d -> %d",fname, sz, r);
- return 0;
- }
- return r;
-}
-int ico_sttm_getActiveState_NX(int smCWId, const char* X[], size_t arysz,
- CicoStateCore::E_GetPolicy p, const char* fname)
-{
- CicoStateMachine* csm;
- csm = ico_sttm_getStateMachineX(smCWId, fname);
- if ((CicoStateMachine*)0 == csm) {
- return 0;
- }
- std::vector<const CicoState*> stt;
- if (false == csm->getCurrentState(stt, p)) {
- _DBG("%s NO ACTIVE STATEMACHINE(\"%s\":%d)",fname,
- csm->getName().c_str(), csm->getValue());
- return 0;
- }
- int r = 0;
- int sz = stt.size();
- for (int i = 0; i < sz; i++) {
- if ( r >= (int)arysz ) {
- r = -1;
- break; // break of for i<sz
- }
- X[r] = stt[i]->getName().c_str(); // set state-object name
- r++;
- }
- if (0 == r) {
- sttmerr = STTMNOTFIND;
- _DBG("%s get size %d -> %d",fname, sz, r);
- return 0;
- }
- return r;
-}
-
-
-/**
- * @brief get state-object running true
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects value
- * @param names[] Enter the active state-objects names
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-extern "C" int ico_sttm_getActiveState(int smCWId, int sCWIds[], size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, sCWIds, sz, false,
- CicoStateCore::ELvlBttm,
- "ico_sttm_getActiveState");
-}
-
-extern "C" int ico_sttm_getActiveState_V(int smCWId, int values[], size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, values, sz, true,
- CicoStateCore::ELvlBttm,
- "ico_sttm_getActiveState_V");
-}
-
-extern "C" int ico_sttm_getActiveStateVV(int smVal, int values[], size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateVV >>%d<<, ., %d", smVal, sz);
- return 0;
- }
- return ico_sttm_getActiveStateX(id, values, sz, true,
- CicoStateCore::ELvlBttm,
- "ico_sttm_getActiveStateVV");
-}
-
-extern "C" int ico_sttm_getActiveState_N(int smCWId, const char* names[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveState_NX(smCWId, names, sz,
- CicoStateCore::ELvlBttm,
- "ico_sttm_getActiveState_N");
-}
-
-extern "C" int ico_sttm_getActiveStateNN(const char* smNm, const char* names[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateNN >>%s<<, ., %d", smNm, sz);
- return 0;
- }
- return ico_sttm_getActiveState_NX(id, names, sz,
- CicoStateCore::ELvlBttm,
- "ico_sttm_getActiveStateNN");
-}
-
-/**
- * @brief get state-object running directly under
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects value
- * @param names[] Enter the active state-objects names
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-extern "C" int ico_sttm_getActiveStateDirectlyUnder(int smCWId, int sCWIds[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, sCWIds, sz, false,
- CicoStateCore::ELvlTop,
- "ico_sttm_getActiveStateDirectlyUnder");
-}
-extern "C" int ico_sttm_getActiveStateDirectlyUnder_V(int smCWId,
- int values[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, values, sz, true,
- CicoStateCore::ELvlTop,
- "ico_sttm_getActiveStateDirectlyUnder_V");
-}
-
-extern "C" int ico_sttm_getActiveStateDirectlyUnderVV(int smVal, int values[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateDirectlyUnderVV >>%d<<, ., %d",
- smVal, sz);
- return 0;
- }
- return ico_sttm_getActiveStateX(id, values, sz, true,
- CicoStateCore::ELvlTop,
- "ico_sttm_getActiveStateDirectlyUnderVV");
-}
-
-extern "C" int ico_sttm_getActiveStateDirectlyUnder_N(int smCWId,
- const char* names[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveState_NX(smCWId, names, sz,
- CicoStateCore::ELvlTop,
- "ico_sttm_getActiveStateDirectlyUnder_N");
-}
-
-extern "C" int ico_sttm_getActiveStateDirectlyUnderNN(const char* smNm,
- const char* names[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateDirectlyUnderNN >>%s<<, ., %d", smNm, sz);
- return 0;
- }
- return ico_sttm_getActiveState_NX(id, names, sz,
- CicoStateCore::ELvlTop,
- "ico_sttm_getActiveStateDirectlyUnderNN");
-}
-
-/**
- * @brief get state-object running all
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects value
- * @param names[] Enter the active state-objects names
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-extern "C" int ico_sttm_getActiveStateAll(int smCWId, int sCWIds[], size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, sCWIds, sz, false,
- CicoStateCore::ELvlAll,
- "ico_sttm_getActiveStateAll");
-}
-
-extern "C" int ico_sttm_getActiveStateAll_V(int smCWId, int values[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveStateX(smCWId, values, sz, true,
- CicoStateCore::ELvlAll,
- "ico_sttm_getActiveStateAll_V");
-}
-
-extern "C" int ico_sttm_getActiveStateAllVV(int smVal, int values[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateAllVV >>%d<<, ., %d", smVal, sz);
- return 0;
- }
- return ico_sttm_getActiveStateX(id, values, sz, true,
- CicoStateCore::ELvlAll,
- "ico_sttm_getActiveStateAllVV");
-}
-
-extern "C" int ico_sttm_getActiveStateAll_N(int smCWId, const char* names[],
- size_t sz)
-{
- sttmerr = STTMNOERROR;
- return ico_sttm_getActiveState_NX(smCWId, names, sz,
- CicoStateCore::ELvlAll,
- "ico_sttm_getActiveStateAll_N");
-}
-
-extern "C" int ico_sttm_getActiveStateAllNN(const char* smNm,
- const char* names[], size_t sz)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getActiveStateAllNN >>%s<<, ., %d", smNm, sz);
- return 0;
- }
- return ico_sttm_getActiveState_NX(id, names, sz,
- CicoStateCore::ELvlAll,
- "ico_sttm_getActiveStateAllNN");
-}
-
-/**
- * @brief get name value
- * @param CWId stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @return name
- */
-extern "C" const char* ico_sttm_getName(int CWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(CWId); // CWId to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getName >>%d<<", CWId);
- return 0;
- }
- return cscTarget->getName().c_str();
-}
-
-/**
- * @brief get value
- * @param CWId stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @return value
- */
-extern "C" int ico_sttm_getValue(int CWId)
-{
- sttmerr = STTMNOERROR;
- CicoStateCore* cscTarget = getID2ObjSTT(CWId); // ID to state-object
- if ((CicoStateCore*)0 == cscTarget) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_getValue >>%d<<", CWId);
- return 0;
- }
- return cscTarget->getValue();
-}
-
-/**
- * @brief get error code
- * @return error code
- */
-StateMachineCWrapperErr_E ico_sttm_errcode()
-{
- return sttmerr;
-}
-
-/**
- * @breif get operation state
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param value value is state-object identification number
- * @param name name is state-object Identification name
- * @return OPERATION_STATE_E
- */
-extern "C" OPERATION_STATE_E ico_sttm_isActiveSttM(int smCWId)
-{
- return ico_sttm_isActiveStt(smCWId);
-}
-
-/**
- *
- */
-extern "C" OPERATION_STATE_E ico_sttm_isActiveStt(int sCWId)
-{
- sttmerr = STTMNOERROR;
- int sz = stateObjects.size();
- if ((0 < sCWId) && (sCWId <= sz)) {
- if (true == stateObjects[sCWId-1]->isActive()) {
- return E_STT_ACTIVE;
- }
- }
- else {
- sttmerr = STTMPARAMERR;
- }
- return E_STT_INACTIVE;
-}
-
-extern "C" OPERATION_STATE_E ico_sttm_isActive_V(int smCWId, int value)
-{
- sttmerr = STTMNOERROR;
- int lid = ico_sttm_retrieveSVal(smCWId, value);
- if (0 != lid) {
- return ico_sttm_isActiveStt(lid);
- }
- else {
- sttmerr = STTMNOTFIND;
- }
- return E_STT_INACTIVE;
-}
-
-extern "C" OPERATION_STATE_E ico_sttm_isActiveVV(int smVal, int value)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMVal(smVal);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isActiveVV >>%d<<, %d", smVal, value);
- return E_STT_INACTIVE;
- }
- return ico_sttm_isActive_V(id, value);
-}
-
-extern "C" OPERATION_STATE_E ico_sttm_isActive_N(int smCWId, const char* name)
-{
- sttmerr = STTMNOERROR;
- int lid = ico_sttm_retrivevSName(smCWId, name);
- if (0 != lid) {
- return ico_sttm_isActiveStt(lid);
- }
- else {
- sttmerr = STTMNOTFIND;
- }
- return E_STT_INACTIVE;
-}
-
-extern "C" OPERATION_STATE_E ico_sttm_isActiveNN(const char* smNm,
- const char* name)
-{
- sttmerr = STTMNOERROR;
- int id = ico_sttm_retrieveMName(smNm);
- if (0 == id) {
- sttmerr = STTMNOTFIND;
- _DBG("ico_sttm_isActiveNN >>%s<<, %s", smNm, name);
- return E_STT_INACTIVE;
- }
- return ico_sttm_isActive_N(id, name);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
- *
- * Contact:
- *
- * Licensed under the Apache License, Version 2.0 (the License){}
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __ICO_STATEMACHIN_CWRAPPER_H__
-#define __ICO_STATEMACHIN_CWRAPPER_H__
-
-/**
- * stateMachine-c++ objects to C
- * C Wrapper functions
- * @author m.kamoshida
- * @version 0.1
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * STATE MACHINE C-WAPPER ERROR CODE
- *
- */
-typedef enum E_StateMachineCWrapperErr {
- STTMNOERROR = 0, // No error
- STTMNOTFIND = 1, // state-object not find
- STTMTYPEMISMATCH, // state-object type mismatch
- STTMCREATEERR, // CREATE ERROR
- STTMNEWERR, // new ERROR
- STTMEVNOTFIND, // eventinfo-object not find
- STTMPARAMERR // PARAMETER MISMATCH
-} StateMachineCWrapperErr_E;
-
-/**
- * enum of history type
- */
-typedef enum E_HISTORY_TYPE
-{
- E_UNKOWNHISTORYTYPE = 0,
- E_SHALLOW = 1, // Shallow history
- E_DEEP // Deep history
-} HISTORY_TYPE_E;
-
-/**
- * enum of join logical operator
- */
-typedef enum E_GC_JOIN
-{
- E_GC_AND = 1,
- E_GC_OR
-} GC_JOIN_E;
-
-/**
- * enum of value type
- */
-typedef enum E_EV_VAL_KIND
-{
- E_NONE = 0,
- E_NUMBER,
- E_DOUBLE,
- E_STRING
-} EV_VAL_KIND_E;
-
-/**
- * enum of guard condition operate
- */
-typedef enum E_GC_OP_KIND
-{
- GC_OP_NON = 0,
- GC_OP_EQ = 1, // "=" Guard condition is equal to
- GC_OP_NE, // "!=" Guard condition is not equal to
- GC_OP_LT, // "<" Guard condition is less than
- GC_OP_LE, // "<=" Guard condition is less than or equal
- GC_OP_GT, // ">" Guard condition is greater than
- GC_OP_GE, // ">=" Guard condition is greater than or equal
- GC_OP_IN, // "in" Guard condition is the state of the state-object
- GC_OP_NOT // "not" Guard condition is the state of the state-object
-} GC_OP_KIND_E;
-
-
-typedef enum E_OPERATION_STATE // state-object operation state
-{
- E_STT_INACTIVE =0, // INACTIVE
- E_STT_ACTIVE // ACTIVE
-} OPERATION_STATE_E;
-
-/**
- * call back infomation parameter
- * Where entry-action and exit-action, do-action use call back
- */
-typedef struct
-{
- unsigned short ev; // event no.
- EV_VAL_KIND_E uk; // union 'u' kind
- union { //
- int i; // Used if the uk == E_NUMBER
- double d; // Used if the uk == E_DOUBLE
- const char* s; // Used if the uk == E_STRING
- } u; //
- void* v; // Additional information user
-} st_event;
-
-/**
- * @brief Create an stateMachine-object and state-object with the specified file
- * @param file faile path pseudo-json
- * @return not 0:stateMachine-object Id no.(c-wrapper local ID)
- * @ 0:create error
- */
-int ico_sttm_createStateMachineFile(const char* file);
-
-/**
- * @brief Create an stateMachine-object and state-object with the specified text
- * @param buff text pseudo-json
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-int ico_sttm_createStateMachineText(const char* buff);
-
-/**
- * @brief Create stateMachine-object
- * @param name stateMachine-object identification name
- * @param value stateMachine-object identification number.
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-int ico_sttm_createStateMachine(const char* name, int value);
-
-/**
- * @brief Create state-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name state-object identification name
- * @param value state-object identification number
- * @return not 0:state-object ID no.(c-wrapper local ID)
- * @ 0:create faile
- */
-int ico_sttm_createState(int parent, const char* name, int value);
-
-
-/**
- * @brief Create historyState-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name historyState-object identification name
- * @param value historyState-object identification number
- * @param type Shallow/Deep history type
- * @return not 0:historyState-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-int ico_sttm_createHState(int parent, const char* name, int value,
- HISTORY_TYPE_E type);
-
-
-/**
- * @brief Create finalState-object
- * @param parent parent ID no.(c-wrapper local ID)
- * @param name finalState-object identification name
- * @param value finalState-object identification number
- * @return not 0:finalState-object ID no.(c-wrapper local ID)
- * @ 0:create error
- */
-int ico_sttm_createFState(int parent, const char* name, int value);
-
-
-/**
- * @brief Registration of transition events
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param evname event identification name
- * @param ev event no.(Use the 1000-65535) identification number
- * @param trCWId of transition destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-/* Please try a unique name in the naming event since the search key */
-int ico_sttm_addTransition(int sCWId,
- const char* evname, unsigned short ev,
- int trCWId);
-
-
-/**
- * @brief Registration of transition events
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param trVal state-object identification value destination
- * @param trCWId of transition destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-int ico_sttm_addTransitionVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- int trVal);
-
-/**
- * @brief Registration of transition events
- * @param smNm stateMachine-object identification name
- * @param name state-object identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param namTrns state-object Identification name destination
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param trCWId of transition destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local ID)
- * @ 0:added error
- */
-int ico_sttm_addTransitionNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- const char* trNm);
-
-/**
- * @brief Registration of transition events
- * @param sCWId state-object ID no.(c-wrapper local ID)
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trCWId destination(c-wrapper local ID)
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-/* Please try a unique name in the naming event since the search key */
-int ico_sttm_addTransitionGCI(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- int trCWId);
-
-int ico_sttm_addTransitionGCD(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- int trCWId);
-
-int ico_sttm_addTransitionGCS(int sCWId,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- int trCWId);
-
-/**
- * @brief Registration of transition events
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trVl value is state-object identification number transition, destination
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- */
-int ico_sttm_addTransGCIVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv, int trVl);
-
-int ico_sttm_addTransGCDVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv, int trVl);
-
-int ico_sttm_addTransGCSVVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv, int trVl);
-
-/**
- * @brief Registration of transition events
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @param trNm name is state-object Identification name destination
- * @return not 0:ID no. of the event to register(c-wrapper local event-ID)
- * @ 0:added error
- * construction ico_sttm_createStateMachineFile or ico_sttm_createStateMachineText
- * it can not be used
- */
-int ico_sttm_addTransGCINNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, int gcv,
- const char* trNm);
-
-int ico_sttm_addTransGCDNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, double gcv,
- const char* trNm);
-
-int ico_sttm_addTransGCSNNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_OP_KIND_E gce, const char* gcv,
- const char* trNm);
-
-
-/**
- * @brief add guard condition
- * @param evId ID no. to be registered(c-wrapper local event-ID)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- * construction ico_sttm_createStateMachineFile or ico_sttm_createStateMachineText
- * it can not be used
- */
-int ico_sttm_addGCI(int evId, GC_JOIN_E j, GC_OP_KIND_E gc, int gcv);
-int ico_sttm_addGCD(int evId, GC_JOIN_E j, GC_OP_KIND_E gc, double gcv);
-int ico_sttm_addGCS(int evId, GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv);
-
-/**
- * @brief add guard condition
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-int ico_sttm_addGCIVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv);
-int ico_sttm_addGCDVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv);
-int ico_sttm_addGCSVV(int smVal, int value,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv);
-
-/**
- * @brief add guard condition
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param evname event name
- * @param ev event no.(Use the 1000-65535)
- * @param j logical operator
- * @param gce operator of guard condition
- * @param gcv Comparison value of guard condition
- * @return not 0:Success
- * @ 0:added failure
- */
-int ico_sttm_addGCINN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, int gcv);
-
-int ico_sttm_addGCDNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, double gcv);
-
-int ico_sttm_addGCSNN(const char* smNm, const char* name,
- const char* evname, unsigned short ev,
- GC_JOIN_E j, GC_OP_KIND_E gc, const char* gcv);
-
-
-/**
- * @brief Callback registration
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addEntryAction(int sCWId, void (*fnc)(st_event* ev, int sCWId));
-int ico_sttm_addExitAction(int sCWId, void (*fnc)(st_event* ev, int sCWId));
-int ico_sttm_addDoAction(int sCWId, void (*fnc)(st_event* ev, int sCWId));
-
-
-/**
- * @brief Callback registration
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addEntryActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId));
-int ico_sttm_addExitActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId));
-int ico_sttm_addDoActionVV(int smVal, int value,
- void (*fnc)(st_event* ev, int sCWId));
-
-/**
- * @brief Callback registration
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param fanc callback function
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addEntryActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId));
-
-int ico_sttm_addExitActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId));
-
-int ico_sttm_addDoActionNN(const char* smNm, const char* name,
- void (*fnc)(st_event* ev, int sCWId));
-
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param trCWId finish transition destination(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:set Failure
- */
-int ico_sttm_setFinishTransition(int sCWId, int trCWId);
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param trVl value is state-object identification number transition destination
- * @return not 0:Success
- * @ 0:set Failure
- */
-int ico_sttm_setFinishTransitionVVV(int smVal, int value, int trVl);
-
-/**
- * @brief Registration at the time of termination detection transition destination
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @return not 0:Success
- * @ 0:set Failure
- */
-int ico_sttm_setFinishTransitionNNN(const char* smNm, const char* name,
- const char* trNm);
-
-/**
- * @brief Registration of default history state-objectss
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param dfCWId default transition destination(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addDefault(int sCWId, int dfCWId);
-
-
-/**
- * @brief Registration of default history state-objectss
- * @param value value is state-object identification number
- * @param dfVal value is state-object identification number
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addDefaultVVV(int smVal, int value, int dfVal);
-
-/**
- * @brief Registration of default history state-objectss
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param dfNm name is state-object Identification name
- * @return not 0:Success
- * @ 0:added Failure
- */
-int ico_sttm_addDefaultNNN(const char* smNm, const char* name,
- const char* dfNm);
-
-/**
- * @breif Registration of start position state-objects
- * @param ID stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @param sCWId start position state-object ID no.(c-wrapper local ID)
- * @return not 0:Success
- * @ 0:set failure
- */
-int ico_sttm_addStartPosition(int CWId, int sCWId);
-
-
-/**
- * @breif Registration of start position state-objects
- * @param smVal value is stateMachine-object identification number
- * @param value value is state-object identification number
- * @param value spVal is state-object identification number
- * @return not 0:Success
- * @ 0:set failure
- */
-int ico_sttm_addStartPositionSMVV(int smVal, int spVal);
-
-int ico_sttm_addStartPositionVVV(int smVal, int value, int spVal);
-
-
-/**
- * @breif Registration of start position state-objects
- * @param smNm stateMachine-object Identification name
- * @param name name is state-object Identification name
- * @param name spNm is state-object Identification name
- * @return not 0:Success
- * @ 0:set failure
- */
-int ico_sttm_addStartPositionSMNN(const char* smNm, const char* spNm);
-
-int ico_sttm_addStartPositionNNN(const char* smNm, const char* name,
- const char* spNm);
-
-
-/**
- * @breif start stateMachine
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @return not 0:Success
- * @ 0:start Failure
- */
-int ico_sttm_startV(int smVal);
-
-int ico_sttm_startN(const char* smNm);
-
-int ico_sttm_start(int smCWId);
-
-
-/**
- * @breif stop stateMachine
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @return not 0:Success
- * @ 0:stop Failure
- */
-int ico_sttm_stopV(int smVal);
-
-int ico_sttm_stopN(const char* smNm);
-
-int ico_sttm_stop(int smCWId);
-
-
-/**
- * @brief Issue an event
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param ev event No.(Use the 1000-65535)
- * @param gcv Comparison value of guard condition
- * @param info Additional information user
- * @return not 0:Success on Transition
- * @ 0: none Transition
- */
-int ico_sttm_eventV(int smVal, unsigned short ev, void* info);
-int ico_sttm_eventGCIV(int smVal, unsigned short ev, int gcv, void* info);
-int ico_sttm_eventGCDV(int smVal, unsigned short ev, double gcv, void* info);
-int ico_sttm_eventGCSV(int smVal, unsigned short ev, const char* gcv,
- void* info);
-
-int ico_sttm_eventN(const char* smNm, unsigned short ev, void* info);
-int ico_sttm_eventGCIN(const char* smNm, unsigned short ev, int gcv,
- void* info);
-int ico_sttm_eventGCDN(const char* smNm, unsigned short ev, double gcv,
- void* info);
-int ico_sttm_eventGCSN(const char* smNm, unsigned short ev, const char* gcv,
- void* info);
-
-int ico_sttm_event(int smCWId, unsigned short ev, void* info);
-int ico_sttm_eventGCI(int smCWId, unsigned short ev, int gcv, void* info);
-int ico_sttm_eventGCD(int smCWId, unsigned short ev, double gcv, void* info);
-int ico_sttm_eventGCS(int smCWId, unsigned short ev, const char* gcv,
- void* info);
-
-/**
- * @brief Test of the transition
- * @param smCWId stateMachine-object ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param ev event No.(Use the 1000-65535)
- * @param gcv Comparison value of guard condition
- * @param info Additional information user
- * @return not 0:Success on Transition
- * @ 0: none Transition
- */
-int ico_sttm_eventTestV(int smVal, unsigned short ev);
-int ico_sttm_eventTestGCIV(int smVal, unsigned short ev, int gcv);
-int ico_sttm_eventTestGCDV(int smVal, unsigned short ev, double gcv);
-int ico_sttm_eventTestGCSV(int smVal, unsigned short ev, const char* gcv);
-
-int ico_sttm_eventTestN(const char* smNm, unsigned short ev);
-int ico_sttm_eventTestGCIN(const char* smNm, unsigned short ev, int gcv);
-int ico_sttm_eventTestGCDN(const char* smNm, unsigned short ev, double gcv);
-int ico_sttm_eventTestGCSN(const char* smNm, unsigned short ev,
- const char* gcv);
-
-int ico_sttm_eventTest(int smCWId, unsigned short ev);
-int ico_sttm_eventTestGCI(int smCWId, unsigned short ev, int gcv);
-int ico_sttm_eventTestGCD(int smCWId, unsigned short ev, double gcv);
-int ico_sttm_eventTestGCS(int smCWId, unsigned short ev, const char* gcv);
-
-/**
- * @brief retrieve stateMachine-object
- * @param value/name stateMachine-object ID no. / name
- * @return not 0:stateMachine-object ID no.(c-wrapper local ID)
- * @ 0:not find
- */
-int ico_sttm_retrieveMVal(int value);
-int ico_sttm_retrieveMName(const char* name);
-
-
-/**
- * @brief retrieve state-object(state/historyState/finalState)
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param value/name state(state/historyState/finalState)-object ID no. / name
- * @return not 0:state-object ID no.(c-wrapper local ID)
- * @ 0:not find
- */
-int ico_sttm_retrieveSVal(int smCWId, int value);
-int ico_sttm_retrivevSName(int smCWId, const char* name);
-
-
-/**
- * @brief object check
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @return not 0:stateMachine-object
- * @ 0:no stateMachine-object
- */
-int ico_sttm_isStateMachine(int smCWId);
-
-/**
- * @brief object check
- * @param sCWId state-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-int ico_sttm_isState(int sCWId);
-
-/**
- * @brief object check
- * @param sCWId historyState-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-int ico_sttm_isHistoryState(int sCWId);
-
-/**
- * @brief object check
- * @param sCWId finalState-object ID no.(c-wrapper local ID)
- * @return not 0:state-object
- * @ 0:no state-object
- */
-int ico_sttm_isFinalState(int sCWId);
-
-/**
- * @brief get state-object running true
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects identification number
- * @param names[] Enter the active state-objects identification name
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-int ico_sttm_getActiveState(int smCWId, int sCWIds[], size_t sz);
-
-int ico_sttm_getActiveStateVV(int smVal, int values[], size_t sz);
-
-int ico_sttm_getActiveStateNN(const char* smNm, const char* names[],
- size_t sz);
-
-/**
- * @brief get state-object running directly under
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects value
- * @param names[] Enter the active state-objects names
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-int ico_sttm_getActiveStateDirectlyUnder(int smCWId, int sCWIds[], size_t sz);
-
-int ico_sttm_getActiveStateDirectlyUnderVV(int smval, int values[], size_t sz);
-
-int ico_sttm_getActiveStateDirectlyUnderNN(const char* smNm,
- const char* names[], size_t sz);
-
-/**
- * @brief get state-object running all
- * @param smCWId stateMachine-object ID no.(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param sCWIds[] Enter the active state-objects(c-wrapper local ID)
- * @param values[] Enter the active state-objects value
- * @param names[] Enter the active state-objects names
- * @param size of array sCWIds or values or names
- * @return Number of registered sCWIds
- * @ -1:size over
- */
-int ico_sttm_getActiveStateAll(int smCWId, int sCWIds[], size_t sz);
-
-int ico_sttm_getActiveStateAllVV(int smVal, int values[], size_t sz);
-
-int ico_sttm_getActiveStateAllNN(const char* smNm, const char* names[],
- size_t sz);
-
-/**
- * @brief get name value
- * @param CWId stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @return not 0:identification name 0:get fail
- */
-const char* ico_sttm_getName(int CWId);
-
-
-/**
- * @brief get name value
- * @param CWId stateMachine-object/state-object ID no.(c-wrapper local ID)
- * @return not 0:identification value 0:get fail
- */
-int ico_sttm_getValue(int CWId);
-
-
-/**
- * @breif get operation state
- * @param smCWId ID no. to eb registered stateMachine-object(c-wrapper local ID)
- * @param sCWId ID no. to be registered(c-wrapper local ID)
- * @param smVal value is stateMachine-object identification number
- * @param smNm stateMachine-object Identification name
- * @param value value is state-object identification number
- * @param name name is state-object Identification name
- * @return OPERATION_STATE_E
- */
-OPERATION_STATE_E ico_sttm_isActiveSttM(int smCWId);
-
-OPERATION_STATE_E ico_sttm_isActiveStt(int sCWId);
-
-OPERATION_STATE_E ico_sttm_isActiveVV(int smVal, int value);
-
-OPERATION_STATE_E ico_sttm_isActiveNN(const char* smNm, const char* name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of __ICO_STATEMACHIN_CWRAPPER_H__ */
+++ /dev/null
-/* Copyright 2009 Cybozu Labs, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY CYBOZU LABS, INC. ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL CYBOZU LABS, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are
- * those of the authors and should not be interpreted as representing official
- * policies, either expressed or implied, of Cybozu Labs, Inc.
- *
- */
-#ifndef picojson_h
-#define picojson_h
-
-#include <cassert>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <iostream>
-#include <iterator>
-#include <map>
-#include <string>
-#include <vector>
-
-#ifdef _MSC_VER
- #define SNPRINTF _snprintf_s
- #pragma warning(push)
- #pragma warning(disable : 4244) // conversion from int to char
-#else
- #define SNPRINTF snprintf
-#endif
-
-namespace picojson {
-
- enum {
- null_type,
- boolean_type,
- number_type,
- string_type,
- array_type,
- object_type
- };
-
- struct null {};
-
- class value {
- public:
- typedef std::vector<value> array;
- typedef std::map<std::string, value> object;
- protected:
- int type_;
- union {
- bool boolean_;
- double number_;
- std::string* string_;
- array* array_;
- object* object_;
- };
- public:
- value();
- value(int type, bool);
- explicit value(bool b);
- explicit value(double n);
- explicit value(const std::string& s);
- explicit value(const array& a);
- explicit value(const object& o);
- ~value();
- value(const value& x);
- value& operator=(const value& x);
- template <typename T> bool is() const;
- template <typename T> const T& get() const;
- template <typename T> T& get();
- operator bool() const;
- const value& get(size_t idx) const;
- const value& get(const std::string& key) const;
- std::string to_str() const;
- template <typename Iter> void serialize(Iter os) const;
- std::string serialize() const;
- };
-
- typedef value::array array;
- typedef value::object object;
-
- inline value::value() : type_(null_type) {}
-
- inline value::value(int type, bool) : type_(type) {
- switch (type) {
-#define INIT(p, v) case p##type: p = v; break
- INIT(boolean_, false);
- INIT(number_, 0.0);
- INIT(string_, new std::string());
- INIT(array_, new array());
- INIT(object_, new object());
-#undef INIT
- default: break;
- }
- }
-
- inline value::value(bool b) : type_(boolean_type) {
- boolean_ = b;
- }
-
- inline value::value(double n) : type_(number_type) {
- number_ = n;
- }
-
- inline value::value(const std::string& s) : type_(string_type) {
- string_ = new std::string(s);
- }
-
- inline value::value(const array& a) : type_(array_type) {
- array_ = new array(a);
- }
-
- inline value::value(const object& o) : type_(object_type) {
- object_ = new object(o);
- }
-
- inline value::~value() {
- switch (type_) {
-#define DEINIT(p) case p##type: delete p; break
- DEINIT(string_);
- DEINIT(array_);
- DEINIT(object_);
-#undef DEINIT
- default: break;
- }
- }
-
- inline value::value(const value& x) : type_(x.type_) {
- switch (type_) {
-#define INIT(p, v) case p##type: p = v; break
- INIT(boolean_, x.boolean_);
- INIT(number_, x.number_);
- INIT(string_, new std::string(*x.string_));
- INIT(array_, new array(*x.array_));
- INIT(object_, new object(*x.object_));
-#undef INIT
- default: break;
- }
- }
-
- inline value& value::operator=(const value& x) {
- if (this != &x) {
- this->~value();
- new (this) value(x);
- }
- return *this;
- }
-
-#define IS(ctype, jtype) \
- template <> inline bool value::is<ctype>() const { \
- return type_ == jtype##_type; \
- }
- IS(null, null)
- IS(bool, boolean)
- IS(int, number)
- IS(double, number)
- IS(std::string, string)
- IS(array, array)
- IS(object, object)
-#undef IS
-
-#define GET(ctype, var) \
- template <> inline const ctype& value::get<ctype>() const { \
- return var; \
- } \
- template <> inline ctype& value::get<ctype>() { \
- return var; \
- }
- GET(bool, boolean_)
- GET(double, number_)
- GET(std::string, *string_)
- GET(array, *array_)
- GET(object, *object_)
-#undef GET
-
- inline value::operator bool() const {
- switch (type_) {
- case null_type:
- return false;
- case boolean_type:
- return boolean_;
- case number_type:
- return number_ != 0;
- case string_type:
- return ! string_->empty();
- default:
- return true;
- }
- }
-
- inline const value& value::get(size_t idx) const {
- static value s_null;
- assert(is<array>());
- return idx < array_->size() ? (*array_)[idx] : s_null;
- }
-
- inline const value& value::get(const std::string& key) const {
- static value s_null;
- assert(is<object>());
- object::const_iterator i = object_->find(key);
- return i != object_->end() ? i->second : s_null;
- }
-
- inline std::string value::to_str() const {
- switch (type_) {
- case null_type: return "null";
- case boolean_type: return boolean_ ? "true" : "false";
- case number_type: {
- char buf[256];
- SNPRINTF(buf, sizeof(buf), "%f", number_);
- return buf;
- }
- case string_type: return *string_;
- case array_type: return "array";
- case object_type: return "object";
- default: assert(0);
-#ifdef _MSC_VER
- __assume(0);
-#endif
- }
- }
-
- template <typename Iter> void copy(const std::string& s, Iter oi) {
- std::copy(s.begin(), s.end(), oi);
- }
-
- template <typename Iter> void serialize_str(const std::string& s, Iter oi) {
- *oi++ = '"';
- for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
- switch (*i) {
-#define MAP(val, sym) case val: copy(sym, oi); break
- MAP('"', "\\\"");
- MAP('\\', "\\\\");
- MAP('/', "\\/");
- MAP('\b', "\\b");
- MAP('\f', "\\f");
- MAP('\n', "\\n");
- MAP('\r', "\\r");
- MAP('\t', "\\t");
-#undef MAP
- default:
- if ((unsigned char)*i < 0x20 || *i == 0x7f) {
- char buf[7];
- SNPRINTF(buf, sizeof(buf), "\\u%04x", *i & 0xff);
- copy(buf, buf + 6, oi);
- } else {
- *oi++ = *i;
- }
- break;
- }
- }
- *oi++ = '"';
- }
-
- template <typename Iter> void value::serialize(Iter oi) const {
- switch (type_) {
- case string_type:
- serialize_str(*string_, oi);
- break;
- case array_type: {
- *oi++ = '[';
- for (array::const_iterator i = array_->begin(); i != array_->end(); ++i) {
- if (i != array_->begin()) {
- *oi++ = ',';
- }
- i->serialize(oi);
- }
- *oi++ = ']';
- break;
- }
- case object_type: {
- *oi++ = '{';
- for (object::const_iterator i = object_->begin();
- i != object_->end();
- ++i) {
- if (i != object_->begin()) {
- *oi++ = ',';
- }
- serialize_str(i->first, oi);
- *oi++ = ':';
- i->second.serialize(oi);
- }
- *oi++ = '}';
- break;
- }
- default:
- copy(to_str(), oi);
- break;
- }
- }
-
- inline std::string value::serialize() const {
- std::string s;
- serialize(std::back_inserter(s));
- return s;
- }
-
- template <typename Iter> class input {
- protected:
- Iter cur_, end_;
- int last_ch_;
- bool ungot_;
- int line_;
- public:
- input(const Iter& first, const Iter& last) : cur_(first), end_(last), last_ch_(-1), ungot_(false), line_(1) {}
- int getc() {
- if (ungot_) {
- ungot_ = false;
- return last_ch_;
- }
- if (cur_ == end_) {
- last_ch_ = -1;
- return -1;
- }
- if (last_ch_ == '\n') {
- line_++;
- }
- last_ch_ = *cur_++ & 0xff;
- return last_ch_;
- }
- void ungetc() {
- if (last_ch_ != -1) {
- assert(! ungot_);
- ungot_ = true;
- }
- }
- Iter cur() const { return cur_; }
- int line() const { return line_; }
- void skip_ws() {
- while (1) {
- int ch = getc();
- if (! (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
- ungetc();
- break;
- }
- }
- }
- int expect(int expect) {
- skip_ws();
- if (getc() != expect) {
- ungetc();
- return false;
- }
- return true;
- }
- bool match(const std::string& pattern) {
- for (std::string::const_iterator pi(pattern.begin());
- pi != pattern.end();
- ++pi) {
- if (getc() != *pi) {
- ungetc();
- return false;
- }
- }
- return true;
- }
- };
-
- template<typename Iter> inline int _parse_quadhex(input<Iter> &in) {
- int uni_ch = 0, hex;
- for (int i = 0; i < 4; i++) {
- if ((hex = in.getc()) == -1) {
- return -1;
- }
- if ('0' <= hex && hex <= '9') {
- hex -= '0';
- } else if ('A' <= hex && hex <= 'F') {
- hex -= 'A' - 0xa;
- } else if ('a' <= hex && hex <= 'f') {
- hex -= 'a' - 0xa;
- } else {
- in.ungetc();
- return -1;
- }
- uni_ch = uni_ch * 16 + hex;
- }
- return uni_ch;
- }
-
- template<typename Iter> inline bool _parse_codepoint(std::string& out, input<Iter>& in) {
- int uni_ch;
- if ((uni_ch = _parse_quadhex(in)) == -1) {
- return false;
- }
- if (0xd800 <= uni_ch && uni_ch <= 0xdfff) {
- if (0xdc00 <= uni_ch) {
- // a second 16-bit of a surrogate pair appeared
- return false;
- }
- // first 16-bit of surrogate pair, get the next one
- if (in.getc() != '\\' || in.getc() != 'u') {
- in.ungetc();
- return false;
- }
- int second = _parse_quadhex(in);
- if (! (0xdc00 <= second && second <= 0xdfff)) {
- return false;
- }
- uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff);
- uni_ch += 0x10000;
- }
- if (uni_ch < 0x80) {
- out.push_back(uni_ch);
- } else {
- if (uni_ch < 0x800) {
- out.push_back(0xc0 | (uni_ch >> 6));
- } else {
- if (uni_ch < 0x10000) {
- out.push_back(0xe0 | (uni_ch >> 12));
- } else {
- out.push_back(0xf0 | (uni_ch >> 18));
- out.push_back(0x80 | ((uni_ch >> 12) & 0x3f));
- }
- out.push_back(0x80 | ((uni_ch >> 6) & 0x3f));
- }
- out.push_back(0x80 | (uni_ch & 0x3f));
- }
- return true;
- }
-
- template<typename Iter> inline bool _parse_string(value& out, input<Iter>& in) {
- // gcc 4.1 cannot compile if the below two lines are merged into one :-(
- out = value(string_type, false);
- std::string& s = out.get<std::string>();
- while (1) {
- int ch = in.getc();
- if (ch < ' ') {
- in.ungetc();
- return false;
- } else if (ch == '"') {
- return true;
- } else if (ch == '\\') {
- if ((ch = in.getc()) == -1) {
- return false;
- }
- switch (ch) {
-#define MAP(sym, val) case sym: s.push_back(val); break
- MAP('"', '\"');
- MAP('\\', '\\');
- MAP('/', '/');
- MAP('b', '\b');
- MAP('f', '\f');
- MAP('n', '\n');
- MAP('r', '\r');
- MAP('t', '\t');
-#undef MAP
- case 'u':
- if (! _parse_codepoint(s, in)) {
- return false;
- }
- break;
- default:
- return false;
- }
- } else {
- s.push_back(ch);
- }
- }
- return false;
- }
-
- template <typename Iter> inline bool _parse_array(value& out, input<Iter>& in) {
- out = value(array_type, false);
- array& a = out.get<array>();
- if (in.expect(']')) {
- return true;
- }
- do {
- a.push_back(value());
- if (! _parse(a.back(), in)) {
- return false;
- }
- } while (in.expect(','));
- return in.expect(']');
- }
-
- template <typename Iter> inline bool _parse_object(value& out, input<Iter>& in) {
- out = value(object_type, false);
- object& o = out.get<object>();
- if (in.expect('}')) {
- return true;
- }
- do {
- value key, val;
- if (in.expect('"')
- && _parse_string(key, in)
- && in.expect(':')
- && _parse(val, in)) {
- o[key.to_str()] = val;
- } else {
- return false;
- }
- } while (in.expect(','));
- return in.expect('}');
- }
-
- template <typename Iter> inline bool _parse_number(value& out, input<Iter>& in) {
- std::string num_str;
- while (1) {
- int ch = in.getc();
- if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-' || ch == '.'
- || ch == 'e' || ch == 'E') {
- num_str.push_back(ch);
- } else {
- in.ungetc();
- break;
- }
- }
- char* endp;
- out = value(strtod(num_str.c_str(), &endp));
- return endp == num_str.c_str() + num_str.size();
- }
-
- template <typename Iter> inline bool _parse(value& out, input<Iter>& in) {
- in.skip_ws();
- int ch = in.getc();
- switch (ch) {
-#define IS(ch, text, val) case ch: \
- if (in.match(text)) { \
- out = val; \
- return true; \
- } else { \
- return false; \
- }
- IS('n', "ull", value());
- IS('f', "alse", value(false));
- IS('t', "rue", value(true));
-#undef IS
- case '"':
- return _parse_string(out, in);
- case '[':
- return _parse_array(out, in);
- case '{':
- return _parse_object(out, in);
- default:
- if (('0' <= ch && ch <= '9') || ch == '-') {
- in.ungetc();
- return _parse_number(out, in);
- }
- break;
- }
- in.ungetc();
- return false;
- }
-
- // obsolete, use the version below
- template <typename Iter> inline std::string parse(value& out, Iter& pos, const Iter& last) {
- std::string err;
- pos = parse(out, pos, last, &err);
- return err;
- }
-
- template <typename Iter> inline Iter parse(value& out, const Iter& first, const Iter& last, std::string* err) {
- input<Iter> in(first, last);
- if (! _parse(out, in) && err != NULL) {
- char buf[64];
- SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line());
- *err = buf;
- while (1) {
- int ch = in.getc();
- if (ch == -1 || ch == '\n') {
- break;
- } else if (ch >= ' ') {
- err->push_back(ch);
- }
- }
- }
- return in.cur();
- }
-
- inline std::string parse(value& out, std::istream& is) {
- std::string err;
- parse(out, std::istreambuf_iterator<char>(is.rdbuf()),
- std::istreambuf_iterator<char>(), &err);
- return err;
- }
-
- template <typename T> struct last_error_t {
- static std::string s;
- };
- template <typename T> std::string last_error_t<T>::s;
-
- inline void set_last_error(const std::string& s) {
- last_error_t<bool>::s = s;
- }
-
- inline const std::string& get_last_error() {
- return last_error_t<bool>::s;
- }
-
- inline bool operator==(const value& x, const value& y) {
- if (x.is<null>())
- return y.is<null>();
-#define PICOJSON_CMP(type) \
- if (x.is<type>()) \
- return y.is<type>() && x.get<type>() == y.get<type>()
- PICOJSON_CMP(bool);
- PICOJSON_CMP(double);
- PICOJSON_CMP(std::string);
- PICOJSON_CMP(array);
- PICOJSON_CMP(object);
-#undef PICOJSON_CMP
- assert(0);
-#ifdef _MSC_VER
- __assume(0);
-#endif
- return false;
- }
-
- inline bool operator!=(const value& x, const value& y) {
- return ! (x == y);
- }
-}
-
-inline std::istream& operator>>(std::istream& is, picojson::value& x)
-{
- picojson::set_last_error(std::string());
- std::string err = picojson::parse(x, is);
- if (! err.empty()) {
- picojson::set_last_error(err);
- is.setstate(std::ios::failbit);
- }
- return is;
-}
-
-inline std::ostream& operator<<(std::ostream& os, const picojson::value& x)
-{
- x.serialize(std::ostream_iterator<char>(os));
- return os;
-}
-#ifdef _MSC_VER
- #pragma warning(pop)
-#endif
-
-#endif
-#ifdef TEST_PICOJSON
-#ifdef _MSC_VER
- #pragma warning(disable : 4127) // conditional expression is constant
-#endif
-
-using namespace std;
-
-static void plan(int num)
-{
- printf("1..%d\n", num);
-}
-
-static void ok(bool b, const char* name = "")
-{
- static int n = 1;
- printf("%s %d - %s\n", b ? "ok" : "ng", n++, name);
-}
-
-template <typename T> void is(const T& x, const T& y, const char* name = "")
-{
- if (x == y) {
- ok(true, name);
- } else {
- ok(false, name);
- }
-}
-
-#include <algorithm>
-
-int main(void)
-{
- plan(61);
-
-#define TEST(in, type, cmp, serialize_test) { \
- picojson::value v; \
- const char* s = in; \
- string err = picojson::parse(v, s, s + strlen(s)); \
- ok(err.empty(), in " no error"); \
- ok(v.is<type>(), in " check type"); \
- is(v.get<type>(), cmp, in " correct output"); \
- is(*s, '\0', in " read to eof"); \
- if (serialize_test) { \
- is(v.serialize(), string(in), in " serialize"); \
- } \
- }
- TEST("false", bool, false, true);
- TEST("true", bool, true, true);
- TEST("90.5", double, 90.5, false);
- TEST("\"hello\"", string, string("hello"), true);
- TEST("\"\\\"\\\\\\/\\b\\f\\n\\r\\t\"", string, string("\"\\/\b\f\n\r\t"),
- true);
- TEST("\"\\u0061\\u30af\\u30ea\\u30b9\"", string,
- string("a\xe3\x82\xaf\xe3\x83\xaa\xe3\x82\xb9"), false);
- TEST("\"\\ud840\\udc0b\"", string, string("\xf0\xa0\x80\x8b"), false);
-#undef TEST
-
-#define TEST(type, expr) { \
- picojson::value v; \
- const char *s = expr; \
- string err = picojson::parse(v, s, s + strlen(s)); \
- ok(err.empty(), "empty " #type " no error"); \
- ok(v.is<picojson::type>(), "empty " #type " check type"); \
- ok(v.get<picojson::type>().empty(), "check " #type " array size"); \
- }
- TEST(array, "[]");
- TEST(object, "{}");
-#undef TEST
-
- {
- picojson::value v;
- const char *s = "[1,true,\"hello\"]";
- string err = picojson::parse(v, s, s + strlen(s));
- ok(err.empty(), "array no error");
- ok(v.is<picojson::array>(), "array check type");
- is(v.get<picojson::array>().size(), size_t(3), "check array size");
- ok(v.get(0).is<double>(), "check array[0] type");
- is(v.get(0).get<double>(), 1.0, "check array[0] value");
- ok(v.get(1).is<bool>(), "check array[1] type");
- ok(v.get(1).get<bool>(), "check array[1] value");
- ok(v.get(2).is<string>(), "check array[2] type");
- is(v.get(2).get<string>(), string("hello"), "check array[2] value");
- }
-
- {
- picojson::value v;
- const char *s = "{ \"a\": true }";
- string err = picojson::parse(v, s, s + strlen(s));
- ok(err.empty(), "object no error");
- ok(v.is<picojson::object>(), "object check type");
- is(v.get<picojson::object>().size(), size_t(1), "check object size");
- ok(v.get("a").is<bool>(), "check property exists");
- is(v.get("a").get<bool>(), true,
- "check property value");
- is(v.serialize(), string("{\"a\":true}"), "serialize object");
- }
-
-#define TEST(json, msg) do { \
- picojson::value v; \
- const char *s = json; \
- string err = picojson::parse(v, s, s + strlen(s)); \
- is(err, string("syntax error at line " msg), msg); \
- } while (0)
- TEST("falsoa", "1 near: oa");
- TEST("{]", "1 near: ]");
- TEST("\n\bbell", "2 near: bell");
- TEST("\"abc\nd\"", "1 near: ");
-#undef TEST
-
- {
- picojson::value v1, v2;
- const char *s;
- string err;
- s = "{ \"b\": true, \"a\": [1,2,\"three\"], \"d\": 2 }";
- err = picojson::parse(v1, s, s + strlen(s));
- s = "{ \"d\": 2.0, \"b\": true, \"a\": [1,2,\"three\"] }";
- err = picojson::parse(v2, s, s + strlen(s));
- ok((v1 == v2), "check == operator in deep comparison");
- }
-
- {
- picojson::value v1, v2;
- const char *s;
- string err;
- s = "{ \"b\": true, \"a\": [1,2,\"three\"], \"d\": 2 }";
- err = picojson::parse(v1, s, s + strlen(s));
- s = "{ \"d\": 2.0, \"a\": [1,\"three\"], \"b\": true }";
- err = picojson::parse(v2, s, s + strlen(s));
- ok((v1 != v2), "check != operator for array in deep comparison");
- }
-
- {
- picojson::value v1, v2;
- const char *s;
- string err;
- s = "{ \"b\": true, \"a\": [1,2,\"three\"], \"d\": 2 }";
- err = picojson::parse(v1, s, s + strlen(s));
- s = "{ \"d\": 2.0, \"a\": [1,2,\"three\"], \"b\": false }";
- err = picojson::parse(v2, s, s + strlen(s));
- ok((v1 != v2), "check != operator for object in deep comparison");
- }
-
- {
- picojson::value v1, v2;
- const char *s;
- string err;
- s = "{ \"b\": true, \"a\": [1,2,\"three\"], \"d\": 2 }";
- err = picojson::parse(v1, s, s + strlen(s));
- picojson::object& o = v1.get<picojson::object>();
- o.erase("b");
- picojson::array& a = o["a"].get<picojson::array>();
- picojson::array::iterator i;
- i = std::remove(a.begin(), a.end(), picojson::value(std::string("three")));
- a.erase(i, a.end());
- s = "{ \"a\": [1,2], \"d\": 2 }";
- err = picojson::parse(v2, s, s + strlen(s));
- ok((v1 == v2), "check erase()");
- }
-
- return 0;
-}
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoLog.h
- *
- * @brief This file is definition of dubug log functions
- */
-//==========================================================================
-#ifndef __CICO_LOG_H__
-#define __CICO_LOG_H__
-
-#include <ico_log.h>
-
-#endif // __CICO__LOG_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-#include <memory>
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
-#include <cstdio>
-#include <string>
-#include <vector>
-#include <sstream>
-#include <utility>
-
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/json_parser.hpp>
-#include <boost/foreach.hpp>
-#include <boost/optional.hpp>
-
-#include "CicoLog.h"
-#include "CicoSCCommand.h"
-#include "CicoSCSysResourceController.h"
-#include "CicoSCAppResourceController.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoSCUserManager.h"
-#include "CicoConf.h"
-#include "CicoSystemConfig.h"
-#include "CicoLibString.h"
-#include <Ecore.h>
-//#include <Ecore_Evas.h>
-
-/**
- * @brief constructor
- */
-CicoSCAppResourceController::CicoSCAppResourceController()
-{
- ICO_TRA("start");
- m_bDoItApp = false;
- m_filepath.clear();
- ICO_TRA("end");
-}
-
-/**
- * @brief destructor
- */
-CicoSCAppResourceController::~CicoSCAppResourceController()
-{
- ICO_TRA("start");
- ICO_TRA("end");
-}
-
-/**
- * @brief startAppResource
- */
-bool CicoSCAppResourceController::initAppResource()
-{
- ICO_TRA("start");
- if (true == m_bDoIt) {
- ICO_TRA("end");
- return false;
- }
- if (0 == m_rConf) {
- ICO_TRA("end");
- return false;
- }
- m_bDoItApp = m_rConf->m_bDoItApp;
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- m_filepath.clear();
- ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief startAppResource
- */
-bool CicoSCAppResourceController::startAppResource(const string& un)
-{
- ICO_TRA("start %s", un.c_str());
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
-
- string fn;
- getAppResourceFilePath(un, fn);
- if (false == orderApps(fn)) {
- ICO_TRA("end");
- return false;
- }
- m_filepath = fn;
- ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief get application resouce file path
- * @param un user name
- * @param fi file path application resource file
- */
-void CicoSCAppResourceController::getAppResourceFilePath(const string& un,
- string& fp) const
-{
- CicoSCUserManager *cscum = CicoSCUserManager::getInstance();
- cscum->getWorkingDir(un, fp);
- fp += D_STRappResource;
-}
-
-/**
- * @brief oder application resource
- */
-bool CicoSCAppResourceController::orderApps(const string& filepath)
-{
- ICO_TRA("start");
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- clearApps();
-
- if (false == readApps(filepath)) {
- ICO_TRA("end fail:read");
- return false;
- }
-
- // read finish
- if (0 == m_vAppid.size()) {
- ICO_TRA("end fail read2");
- return false;
- }
- init_cgroup_app_dir();
- init_cgroup_app_cpushare();
- return false;
-}
-
-/**
- * @brief read app
- * @param filepath file name (full path)
- */
-bool CicoSCAppResourceController::readApps(const string& filepath)
-{
- ICO_TRA("start file:%s", filepath.c_str());
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- bool bR = false;
- double d1 = 1024.0;
- double d2 = 100.0;
-#if 0 // TODO
- // text file read
- ifstream ifs(filepath.c_str());
- char sBuff[256];
- while(ifs.getline(sBuff,sizeof(sBuff))) {
- string tagApp(sBuff);
- if (true == tagApp.empty()) {
- continue;
- }
- vector<string> vTmp;
- split(tagApp, ',', vTmp);
- if (2 == vTmp.size()) {
- string appid = trim(vTmp[0]);
- string share = trim(vTmp[1]);
- int iShare = atoi(share.c_str());
- if (0 != iShare) {
- if (100 < iShare) {
- ICO_DBG("change %d -> 100", iShare);
- iShare = 100;
- }
- iShare = (int)(d1 * ((double)iShare) / d2);
- ICO_DBG("TARGET_OK %s, %d", appid.c_str(), iShare);
- m_vAppid.push_back(appid);
- m_vShares.push_back(iShare);
- bR = true;
- }
- else {
- ICO_DBG("TARGET_NG %s, >> %s <<", appid.c_str(), share.c_str());
- }
-
- }
- else {
- ICO_DBG("TARGET_NG >> %s <<", sBuff);
- }
- vTmp.clear();
- }
- ifs.close();
-#else
- struct stat buff;
- /* file check */
- memset(&buff, 0, sizeof(buff));
- if (0 != stat(filepath.c_str(), &buff)) {
- ICO_TRA("end");
- return false;
- }
- bool bStt=true;
- // json read
- try {
- ptree pt;
- read_json(filepath.c_str(), pt);
- // cpu_shares
- BOOST_FOREACH (const ptree::value_type& child,
- pt.get_child(DSTRcpu_shares)) {
- const ptree& info = child.second;
-
- string appid;
- int iShareO;
- // cpu_shares.share
- if (boost::optional<int> iVal = info.get_optional<int>(DSTRshare)) {
- iShareO = iVal.get();
- }
- else {
- ICO_DBG("NG get share");
- bStt=false;
- break; // break of BOOST_FOREACH
- }
-
- // cpu_shares.appid
- if (boost::optional<std::string> sVal =
- info.get_optional<std::string>(DSTRappid)) {
- appid = sVal.get();
- }
- else {
- ICO_DBG("NG get appid");
- bStt=false;
- break; // break of BOOST_FOREACH
- }
- // DATA get!
- int iShare = iShareO;
- if (100 < iShare) {
- iShare = 100;
- }
- iShare = (int)(d1 * ((double)iShare) / d2);
- ICO_DBG("TARGET_GET %d(%d), %s", iShare, iShareO, appid.c_str());
- m_vAppid.push_back(appid);
- m_vShares.push_back(iShare);
- bR = true;
- }
- }
- catch (...) {
- ICO_WRN("NG read(%s)", filepath.c_str());
- bStt = false;
- }
- if (false == bStt) {
- m_vAppid.clear();
- m_vShares.clear();
- ICO_TRA("end %d", (int)bR);
- return false;
- }
-#endif
- ICO_DBG("read %d, %d, %d, %d", m_vAppid.size(), m_vShares.size(),
- m_RCCpuTasks.size(), m_RCCpuShares.size());
- ICO_TRA("end %d", (int)bR);
- return bR;
-}
-
-/**
- * @brief initialize cgroup application
- */
-void CicoSCAppResourceController::init_cgroup_app_dir()
-{
- ICO_TRA("start");
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return;
- }
- string sTasks(D_STRtasks);
- string sShares(D_STRcpushares);
- string t1(m_rConf->m_cpuCGRPPath);
- chkAndAddSlash(t1);
-
- string tDir1(m_rConf->m_cpuCGRPPath);
- vector<string> d;
- d.push_back(tDir1);
- chkAndAddSlash(tDir1);
-
- vector<string>::iterator it = m_vAppid.begin();
- for (; it != m_vAppid.end(); it++) {
- // make cgroup apps directroy full path
- string tDir2(tDir1);
- tDir2 += *it;
- d.push_back(tDir2);
- chkAndAddSlash(tDir2);
- // make cgroup tasks file full path
- string tDir3tasks(tDir2);
- tDir3tasks += sTasks;
- m_RCCpuTasks.push_back(tDir3tasks);
- // make cgroup cpu.shares file full path
- string tDir4cpushare(tDir2);
- tDir4cpushare += sShares;
- m_RCCpuShares.push_back(tDir4cpushare);
- }
- make_directorys(d);
- ICO_TRA("end");
- return;
-}
-
-/**
- * @brief initialize cgroup application
- */
-void CicoSCAppResourceController::init_cgroup_app_cpushare()
-{
- ICO_TRA("start");
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return;
- }
-
- vector<string>::iterator itDir = m_RCCpuShares.begin();
- vector<int>::iterator itShare = m_vShares.begin();
- while (itDir != m_RCCpuShares.end()) {
- replaceCgroupFile(*itDir, *itShare);
- ++itDir;
- ++itShare;
- }
- ICO_TRA("end");
- return;
-}
-
-/**
- * @brief clear Apps
- */
-bool CicoSCAppResourceController::clearApps()
-{
- ICO_TRA("start");
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- m_vAppid.clear();
- m_vShares.clear();
- m_RCCpuTasks.clear();
- m_RCCpuShares.clear();
- ICO_TRA("end fail:read");
- return true;
-}
-
-/**
- * @brief entry
- * @param appid
- * @param pid
- */
-bool CicoSCAppResourceController::entryApp(const string& appid, int pid)
-{
- ICO_TRA("start appid(%s), pid(%d)", appid.c_str(), pid);
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- vector<string>::iterator itTasks = m_RCCpuTasks.begin();
- vector<string>::iterator itAppid = m_vAppid.begin();
- string tasks;
- tasks.clear();
- while (itTasks != m_RCCpuTasks.end()) {
- if (0 == (*itAppid).compare(appid.c_str())) {
- tasks = *itTasks;
- break;
- }
- ++itTasks;
- ++itAppid;
- }
- if (true == tasks.empty()) {
- ICO_TRA("end no match appid");
- return false;
- }
- replaceCgroupFile(tasks, pid);
- ICO_TRA("end write cgroup %s, %d", tasks.c_str(), pid);
- return true;
-}
-
-/**
- * @brief entry application's
- * @param vAulItem
- */
-bool CicoSCAppResourceController::entryApps(vector<CicoAulItems>& vAulItem)
-{
- ICO_TRA("start size(%d)", vAulItem.size());
- if (false == m_bDoItApp) {
- ICO_TRA("end");
- return false;
- }
- bool bR = false;
- vector<CicoAulItems>::iterator it = vAulItem.begin();
- while (it != vAulItem.end()) {
- entryApp(it->m_appid, it->m_pid);
- bR = true;
- ++it;
- }
- ICO_TRA("end %s", bR? "true": "false");
- return bR;
-}
-
-/**
- * @brief create applications Resource file
- * @param file path create target
- */
-void CicoSCAppResourceController::createAppResourceFile(const string& filepath)
-{
- ICO_TRA("start %s", filepath.c_str());
-#if 0
- ofstream ofs;
- ofs.open(filepath.c_str(), ios::trunc);
- const vector<CicoAilItems>& vAil =
- CicoSCLifeCycleController::getInstance()->getAilList();
- vector<CicoAilItems>::const_iterator it = vAil.begin();
- for (; it != vAil.end(); ++it) {
- ofs << (*it).m_appid << ",100" << endl;
- }
- ofs.close();
-#else
- try{
- ptree pt;
- ptree child;
-
- const vector<CicoAilItems>& vAil =
- CicoSCLifeCycleController::getInstance()->getAilList();
- vector<CicoAilItems>::const_iterator it = vAil.begin();
- for (; it != vAil.end(); ++it) {
- {
- ptree info;
- info.put(DSTRshare, 100);
- info.put(DSTRappid, (*it).m_appid.c_str());
- child.push_back(std::make_pair("", info));
- }
- }
- pt.add_child(DSTRcpu_shares, child);
- write_json(filepath.c_str(), pt);
- }
- catch (std::exception const& e) {
- ICO_WRN("catch exception %s", e.what());
- }
- catch (...) {
- ICO_WRN("NG write(%s)", filepath.c_str());
- }
-
-#endif
- ICO_TRA("end");
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief CicoSCAppResourceController
- * SystemController resource
- * Application Resouce Controller
- *
- * @date Aug-05-2013 create start
- */
-
-#ifndef CICOSCAPPRESOURCECONTROLLER_H
-#define CICOSCAPPRESOURCECONTROLLER_H
-#include <cstddef>
-#include <string>
-#include <vector>
-
-#include "CicoAilItems.h"
-#include "CicoAulItems.h"
-#include "CicoSCSysResourceController.h"
-
-#define D_STRappResource "appResource.json"
-#define DSTRcpu_shares "cpu_shares"
-#define DSTRshare "share"
-#define DSTRappid "appid"
-/**
- * @brief System Controller Application Resource Controller class
- */
-class CicoSCAppResourceController : public CicoSCSysResourceController
-{
-public:
- CicoSCAppResourceController();
- ~CicoSCAppResourceController();
-
- bool initAppResource();
- bool startAppResource(const std::string& un);
- bool clearApps();
-
- bool isAppResource();
-
- bool entryApp(const std::string& appid, int pid);
- bool entryApps(std::vector<CicoAulItems>& vAulItem);
-
- void getAppResourceFilePath(const std::string& un, std::string& fp) const;
- void createAppResourceFile(const std::string& filepath);
-protected:
- bool orderApps(const std::string& filepath);
- bool readApps(const std::string& filepath);
- void init_cgroup_app_dir();
- void init_cgroup_app_cpushare();
-
-protected:
- bool m_bDoItApp;
-private:
-
- std::vector<std::string> m_vAppid;
- std::vector<int> m_vShares;
- std::string m_filepath;
-};
-
-inline bool CicoSCAppResourceController::isAppResource()
-{
- return m_bDoItApp;
-}
-
-#endif // CICOSCAPPRESOURCECONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCCommand.cpp
- *
- * @brief This file is implementation of CicoSCCommand class
- */
-//==========================================================================
-
-#include <iostream>
-#include <sstream>
-#include <exception>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/json_parser.hpp>
-#include <boost/foreach.hpp>
-#include <boost/optional.hpp>
-using namespace std;
-using namespace boost;
-using namespace boost::property_tree;
-
-#include "CicoSCCommand.h"
-#include "CicoLog.h"
-#include "ico_syc_error.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "ico_syc_mrp_resource_private.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCCommand::CicoSCCommand()
- : cmdid(0), appid(""), pid(-1), opt(NULL)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCCommand::~CicoSCCommand()
-{
- delete opt;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create command
- *
- * @param [in] message message of interprocess communication
- *
- * @note
- * message format(json format)
- * key name of "appid", "command", "pid" is common command propety.
- * <pre>
- * {
- * "appid": (string) application id,
- * "command": (int) command id,
- * "pid": (int) process id
- * ...
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-int
-CicoSCCommand::parseMessage(const char *message)
-{
-// ICO_TRA("CicoSCCommand::parseMessage Enter(%s)", message);
- try {
- stringstream jsonString(message);
- ptree root;
- read_json(jsonString, root);
-
- this->appid = getStrValue(root, MSG_PRMKEY_APPID);
- this->cmdid = getIntValue(root, MSG_PRMKEY_CMD);
- this->pid = getIntValue(root, MSG_PRMKEY_PID);
-
- switch ((this->cmdid & MSG_CMD_TYPE_MASK)) {
- case MSG_CMD_TYPE_WINCTRL:
- parseWinCtrlOpt(root);
- break;
- case MSG_CMD_TYPE_INPUTCTRL:
- parseInputDevCtrlOpt(root);
- break;
- case MSG_CMD_TYPE_USERMGR:
- parseUserMgrOpt(root);
- break;
- case MSG_CMD_TYPE_RESOURCEMGR:
- parseResCtrlOpt(root);
- break;
- case MSG_CMD_TYPE_INPUTDEVSETTING:
- parseInputDevSettingOpt(root);
- break;
- default:
- break;
- }
-
- // dump log command variables
- dump();
- }
- catch (std::exception const& e)
- {
- ICO_WRN("catch exception %s", e.what());
-// ICO_TRA("CicoSCCommand::parseMessage Leave(EINVAL)");
- return ICO_SYC_EINVAL;
- }
-
-// ICO_TRA("CicoSCCommand::parseMessage Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::dump(void)
-{
- ICO_INF("Command: cmdid=0x%08x appid=%s pid=%d", cmdid, appid.c_str(), pid);
- if (NULL != this->opt) {
- this->opt->dump();
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get integer value by key
- *
- * @param [in] root root object of json object
- * @param [in] key Key to get the value
- *
- * @return integer value on success, INT_MAX on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCCommand::getIntValue(const ptree & root, const char* key)
-{
- int intValue = -1;
- try {
- intValue = root.get<int>(key);
- }
- catch (std::exception const& e)
- {
- //ICO_WRN("catch exception %s", e.what());
- return intValue;
- }
- return intValue;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get string value by key
- *
- * @param [in] root root object of json object
- * @param [in] key Key to get the value
- *
- * @return string value on success, empty string on error
- */
-//--------------------------------------------------------------------------
-string
-CicoSCCommand::getStrValue(const ptree & root, const char* key)
-{
- string strValue = "";
- try {
- strValue = root.get<string>(key);
- }
- catch (std::exception const& e)
- {
- //ICO_WRN("catch exception %s", e.what());
- return strValue;
- }
-
- if (strValue == "null") {
- strValue = "";
- }
-
- return strValue;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief query whether the object exists
- *
- * @param [in] root root object of json object
- * @param [in] key Key to get the value
- *
- * @return true on exist, false on not exist
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCCommand::isExistObject(const ptree & root, const char *key)
-{
- try {
- (void)root.get_child(key);
- }
- catch (std::exception const& e)
- {
- //ICO_WRN("catch exception %s", e.what());
- return false;
- }
-
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create window control options
- *
- * @param [in] root root object of json object
- *
- * @note
- * message format of window control(json format)
- * <pre>
- * {
- * "arg": {
- * "surface": (int) surface id
- * "layer": (int) layer id
- * "node": (int) node id
- * "zone": (string) display zone name
- * "anim_name": (string) animation name
- * "anim_time": (int) animation time
- * "pos_x": (int) window x position
- * "pos_y": (int) window y position
- * "width": (int) window width
- * "height": (int) window height
- * "raise": (int) raise flag
- * "visible": (int) visible flag
- * "active": (int) active flag
- * "stride": (int) stride
- * "format": (int) format
- * "framerate": (int) frame rate
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::parseWinCtrlOpt(const ptree & root)
-{
- CicoSCCmdWinCtrlOpt* options = new CicoSCCmdWinCtrlOpt();
- this->opt = options;
-
- options->surfaceid = getIntValue(root, "arg.surface");
- options->layerid = getIntValue(root, "arg.layer");
- options->nodeid = getIntValue(root, "arg.node");
- options->zone = getStrValue(root, "arg.zone");
- options->animation = getStrValue(root, "arg.anim_name");
- options->animationType = getIntValue(root, "arg.anim_type");
- if (-1 == options->animationType) {
- options->animationType = 0xff;
- }
- options->animationTime = getIntValue(root, "arg.anim_time");
- if (-1 == options->animationTime) {
- options->animationTime = 0;
- }
- options->x = getIntValue(root, "arg.pos_x");
- options->y = getIntValue(root, "arg.pos_y");
- options->width = getIntValue(root, "arg.width");
- options->height = getIntValue(root, "arg.height");
- options->raise = getIntValue(root, "arg.raise");
- options->visible = getIntValue(root, "arg.visible");
- options->active = getIntValue(root, "arg.active");
- options->stride = getIntValue(root, "arg.stride");
- options->format = getIntValue(root, "arg.format");
- options->framerate = getIntValue(root, "arg.framerate");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create input device control options
- *
- * @param [in] root root object of json object
- *
- * @note
- * message format of input device control(json format)
- * <pre>
- * {
- * "arg": {
- * "device": (string) device name
- * "input_num": (int) input number
- * "surface": (int) surface id
- * "deviceno": (int) device number
- * "alloc_type": (int) allocation type
- * "keycode": (int) key code
- * "ev_type": (int) event type
- * "ev_time": (int) event time
- * "ev_code": (int) event cord
- * "ev_value": (int) event value
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::parseInputDevCtrlOpt(const ptree & root)
-{
- CicoSCCmdInputDevCtrlOpt* options = new CicoSCCmdInputDevCtrlOpt();
- this->opt = options;
-
- options->device = getStrValue(root, "arg.device");
- options->input = getIntValue(root, "arg.input_num");
- options->surfaceid = getIntValue(root, "arg.surface");
- options->deviceno = getIntValue(root, "arg.deviceno");
- options->fix = getIntValue(root, "arg.alloc_type");
- options->keycode = getIntValue(root, "arg.keycode");
- options->evtype = getIntValue(root, "arg.ev_type");
- options->evtime = getIntValue(root, "arg.ev_time");
- options->evcode = getIntValue(root, "arg.ev_code");
- options->evvalue = getIntValue(root, "arg.ev_value");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create user manager options
- *
- * @param [in] root root object of json object
- *
- * @note
- * message format of user manager options(json format)
- * <pre>
- * {
- * "arg": {
- * "user": (string) user name
- * "password": (string) user password
- * "lastinof": (string) information of application last state
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::parseUserMgrOpt(const ptree & root)
-{
- CicoSCCmdUserMgrOpt* options = new CicoSCCmdUserMgrOpt();
- this->opt = options;
-
- options->user = getStrValue(root, "arg.user");
- options->pass = getStrValue(root, "arg.password");
- options->lastinfo = getStrValue(root, "arg.lastinfo");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create resource manage options
- *
- * @param [in] root root object of json object
- *
- * @note
- * message format of resource manage options(json format)
- * <pre>
- * {
- * "res": {
- * "window": {
- * "zone": (string) window zone,
- * "name": (string) window's surface name,
- * "id": (string) window id
- * "ECU":
- * "display":
- * "layer":
- * "layout":
- * "area":
- * "dispatchApp":
- * "role":
- * "resourceId":
- * },
- * "sound": {
- * "zone": (string) sound zone,
- * "name": (string) sound's stream name,
- * "id": (string) sound id,
- * "adjust": (int) sound adjust type
- * },
- * "input": {
- * "name": (string) input device name,
- * "event": (int) input event id
- * }
- * "type": (int) basic or interruption
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::parseResCtrlOpt(const ptree & root)
-{
- CicoSCCmdResCtrlOpt* options = new CicoSCCmdResCtrlOpt();
- this->opt = options;
-
- if (true == isExistObject(root, "res.window")) {
- options->dispres = true;
- options->dispzone = getStrValue(root, "res.window.zone");
- options->winname = getStrValue(root, "res.window.name");
- options->surfaceid = getIntValue(root, "res.window.id");
- bool bEx = true;
- options->ECU = getStrValue(root, "res.window.ECU");
- if (true == options->ECU.empty()) {
- bEx = false;
- }
- options->display = getStrValue(root, "res.window.display");
- if (true == options->display.empty()) {
- bEx = false;
- }
- options->layer = getStrValue(root, "res.window.layer");
- if (true == options->layer.empty()) {
- bEx = false;
- }
- options->layout = getStrValue(root, "res.window.layout");
- if (true == options->layout.empty()) {
- bEx = false;
- }
- options->area = getStrValue(root, "res.window.area");
- if (true == options->area.empty()) {
- bEx = false;
- }
- options->dispatchApp= getStrValue(root, "res.window.dispatchApp");
- options->role = getStrValue(root, "res.window.role");
- options->resourceID= getIntValue(root, "res.window.resourceId");
- options->dispresEx = bEx;
- }
-
- if (true == isExistObject(root, "res.sound")) {
- options->soundres = true;
- options->soundzone = getStrValue(root, "res.sound.zone");
- options->soundname = getStrValue(root, "res.sound.name");
- options->soundid = getIntValue(root, "res.sound.id");
- options->adjust = getIntValue(root, "res.sound.adjust");
- }
-
- if (true == isExistObject(root, "res.input")) {
- options->inputres = true;
- options->device = getStrValue(root, "res.input.name");
- options->input = getIntValue(root, "res.input.event");
- }
-
- options->type = getIntValue(root, "res.type");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief parse from message, create input device setting options
- *
- * @param [in] root root object of json object
- *
- * @note
- * message format of input device setting(json format)
- * <pre>
- * {
- * "region": {
- * "winname": (string) window name,
- * "pos_x": (int) position x,
- * "pos_y": (int) position y,
- * "width": (int) width,
- * "height": (int) height,
- * "hotspot_x": (int) cursor hotspot x,
- * "hotspot_y": (int) cursor hotspot y,
- * "cursor_x": (int) cursor position x,
- * "cursor_y": (int) cursor position y,
- * "cursor_width": (int) cursor width,
- * "cursor_height":(int) cursor height,
- * "attr": (int) attribute
- * }
- * }
- * </pre>
- */
-//--------------------------------------------------------------------------
-void
-CicoSCCommand::parseInputDevSettingOpt(const ptree & root)
-{
- CicoSCCmdInputDevSettingOpt* options = new CicoSCCmdInputDevSettingOpt();
- this->opt = options;
-
- if (true == isExistObject(root, "region")) {
- options->winname = getStrValue(root, "region.winname");
- options->x = getIntValue(root, "region.pos_x");
- options->y = getIntValue(root, "region.pos_y");
- options->width = getIntValue(root, "region.width");
- options->height = getIntValue(root, "region.height");
- options->hotspot_x = getIntValue(root, "region.hotspot_x");
- options->hotspot_y = getIntValue(root, "region.hotspot_y");
- options->cursor_x = getIntValue(root, "region.cursor_x");
- options->cursor_y = getIntValue(root, "region.cursor_y");
- options->cursor_width = getIntValue(root, "region.cursor_width");
- options->cursor_height = getIntValue(root, "region.cursor_height");
- options->attr = getIntValue(root, "region.attr");
- }
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCCommand.h
- *
- * @brief This file is definition of CicoSCCommand class
- */
-//==========================================================================
-#ifndef __CICO_SC_COMMAND_H__
-#define __CICO_SC_COMMAND_H__
-
-#include <string>
-#include <boost/property_tree/ptree.hpp>
-
-#include "CicoLog.h"
-
-//==========================================================================
-/**
- * @brief command option variables
- * This class is abstract class
- */
-//==========================================================================
-class CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCommandOption() {}
-
- /// destructor
- virtual ~CicoSCCommandOption() {}
-
- /// dump log this class member variables
- virtual void dump(void) {}
-};
-
-//==========================================================================
-/**
- * @brief This class holds the option of window control command
- */
-//==========================================================================
-class CicoSCCmdWinCtrlOpt : public CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCmdWinCtrlOpt()
- : nodeid(0), displayid(0), layerid(0),
- zone(""), surfaceid(-1), animationType(0), animation(""), animationTime(0),
- x(-1), y(-1), width(-1), height(-1), raise(-1),
- visible(-1), active(-1), framerate(0), stride(-1), format(-1) {}
-
- /// destructor
- virtual ~CicoSCCmdWinCtrlOpt() {}
-
- /// dump log this class member variables
- void dump(void)
- {
- ICO_DBG("WinCtrlOpt: "
- "surfaceid=%08x layerid=%d nodeid=%d zone=%s "
- "animation=%s animaType=%x animaTime=%d "
- "x=%d y=%d w=%d h=%d raise=%d "
- "visible=%d active=%d framerate=%d stride=%d format=%d",
- surfaceid, layerid, nodeid, zone.c_str(),
- animation.c_str(), animationType, animationTime,
- x, y, width, height, raise,
- visible, active, framerate, stride, format);
- }
-
- int nodeid; //!< id of node
- int displayid; //!< id of display
- int layerid; //!< id of layer
- std::string zone; //!< name of display zone
- int surfaceid; //!< id of surface
- int animationType; //!< type of animation
- std::string animation; //!< name of animation
- int animationTime; //!< time of animation
- int x; //!< x position of window
- int y; //!< y position of window
- int width; //!< width of window
- int height; //!< height of window
- int raise; //!< status of raise(raise/lower)
- int visible; //!< status of visible(visible/invisible)
- int active; //!< status of active(active/nonactive):
- int framerate; //!< frame rate for thumbnail
- int stride; //!< stride for thumbnail
- int format; //!< format of color for thumbnail
-};
-
-//==========================================================================
-/**
- * @brief This class holds the option of input device control command
- */
-//==========================================================================
-class CicoSCCmdInputDevCtrlOpt : public CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCmdInputDevCtrlOpt()
- : device(""), input(-1), surfaceid(-1), deviceno(-1),
- fix(-1), keycode(-1), evtype(-1), evtime(0), evcode(-1),
- evvalue(-1) {}
-
- /// destructor
- virtual ~CicoSCCmdInputDevCtrlOpt() {}
-
- /// dump log this class member variables
- void dump(void)
- {
- ICO_DBG("InputCtrlOpt: "
- "device=%s input=%d surfaceid=%08x deviceno=%d "
- "fix=%d keycode=%d evtype=%d evtime=%d evcode=%d evvalue=%d",
- device.c_str(), input, surfaceid, deviceno,
- fix, keycode, evtype, evtime, evcode, evvalue);
- }
-
- std::string device; //!< name of input device
- int input; //!< number of input
- int surfaceid; //!< id of surface
- int deviceno; //!< number of device
- int fix; //!< status of fix
- int keycode; //!< code of key
- int evtype; //!< type of event
- int evtime; //!< time of event
- int evcode; //!< code of event
- int evvalue; //!< value of event
-};
-
-//==========================================================================
-/**
- * @brief This class holds the option of user manager command
- */
-//==========================================================================
-class CicoSCCmdUserMgrOpt : public CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCmdUserMgrOpt()
- : user(""), pass(""), lastinfo("") {}
-
- /// destructor
- virtual ~CicoSCCmdUserMgrOpt() {}
-
- /// dump log this class member variables
- void dump(void)
- {
- ICO_DBG("UserMgrOpt: user=%s pass=%s lastinfo=%s",
- user.c_str(), pass.c_str(), lastinfo.c_str());
- }
-
- std::string user;
- std::string pass;
- std::string lastinfo;
-};
-
-//==========================================================================
-/**
- * @brief This class holds the option of resource control command
- */
-//==========================================================================
-class CicoSCCmdResCtrlOpt : public CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCmdResCtrlOpt()
- : dispres(false), dispzone(""), layerid(-1), winname(""), surfaceid(-1),
- animation(""), animationTime(0),
- ECU(""), display(""), layer(""), layout(""), area(""), dispatchApp(""),
- role(""), resourceID(-1),
- soundres(false), soundzone(""), soundname(""), adjust(0),
- inputres(false), device(""), input(0), type(0) {}
-
- /// destructor
- virtual ~CicoSCCmdResCtrlOpt() {}
-
- /// dump log this class member variables
- void dump(void)
- {
- ICO_DBG("ResCtrlOpt: "
- "diapres=%s dispzone=%s layerid=%d winname=%s srufaceid=%08x "
- "animation=%s animatime=%d soundres=%s soundzone=%s"
- "soundname=%s soundid=%d adjust=%d inputres=%s "
- "device=%s input=%d type=%d",
- dispres ? "true" : "false", dispzone.c_str(), layerid,
- winname.c_str(), surfaceid, animation.c_str(),
- animationTime, soundres ? "true" : "false",
- soundzone.c_str(), soundname.c_str(),
- soundid, adjust, inputres ? "true" : "false",
- device.c_str(), input, type);
- ICO_DBG("ResCtrlOptEx: "
- "dispresEx=%s ECU=%s display=%s layer=%s layout=%s area=%s "
- "dispatchApp=%s role=%s resourceID=%d",
- dispresEx? "true": "false", ECU.c_str(), display.c_str(),
- layer.c_str(), layout.c_str(), area.c_str(), dispatchApp.c_str(),
- role.c_str(), resourceID);
- }
-
- bool dispres; //!< flag of display resource
- std::string dispzone; //!< name of display zone
- int layerid; //!< id of window layer
- std::string winname; //!< name of window
- int surfaceid; //!< id of surface
- std::string animation; //!< name of animation
- int animationTime; //!< time of animation[ms]
- bool dispresEx; //!< Expansion flag
- std::string ECU; //!< name to identify ECU
- std::string display; //!< name to identify Display in ECU
- std::string layer; //!< name to identify Layer in Display
- std::string layout; //!< name to identify Layout in Layer
- std::string area; //!< name to Output position in Layout
- std::string dispatchApp; //!< dispatch of application
- std::string role; //!< role of notice
- int resourceID; //!< ID number of resource
-
- bool soundres; //!< flag of sound resource
- std::string soundzone; //!< name of sound zone
- std::string soundname; //!< name of sound(stream)
- int soundid; //!< id of sound(stream)
- int adjust; //!< parameter of adjust
-
- bool inputres; //!< flag of input resource
- std::string device; //!< name of input device
- int input; //!< input
-
- int type; //!<< type of request for display and sound
-};
-
-//==========================================================================
-/**
- * @brief This class holds the option of input device setting command
- */
-//==========================================================================
-class CicoSCCmdInputDevSettingOpt: public CicoSCCommandOption
-{
-public:
- /// default constructor
- CicoSCCmdInputDevSettingOpt()
- : winname(""), x(0), y(0), width(0), height(0), hotspot_x(0), hotspot_y(0),
- cursor_x(0), cursor_y(0), cursor_width(0), cursor_height(0), attr(0) {}
-
- /// destructor
- virtual ~CicoSCCmdInputDevSettingOpt() {}
-
- /// dump log this class member variables
- void dump(void)
- {
- ICO_DBG("InputDevSettingOpt: winname=%s x=%d y=%d w=%d h=%d attr=%d",
- winname.c_str(), x, y, width, height, attr);
- }
-
- std::string winname;//!< window name of surface
- short x; //!< x position of input region
- short y; //!< y position of input region
- short width; //!< width of input region
- short height; //!< height of input region
- short hotspot_x; //!< hotspot of X relative coordinate
- short hotspot_y; //!< hotspot of Y relative coordinate
- short cursor_x; //!< cursor region X coordinate
- short cursor_y; //!< cursor region Y coordinate
- short cursor_width; //!< cursor region width
- short cursor_height;//!< cursor region height
- int attr; //!< attribute of input region
-};
-
-//==========================================================================
-/**
- * @brief This class holds command information
- */
-//==========================================================================
-class CicoSCCommand
-{
-public:
- // default constructor
- CicoSCCommand();
-
- // destructor
- ~CicoSCCommand();
-
- // parse from message of process communication
- int parseMessage(const char *cmdMessage);
-
- // dump log this class member variables
- void dump(void);
-
-private:
- // get integer value
- int getIntValue(const boost::property_tree::ptree & root,
- const char* key);
-
- // get string value
- std::string getStrValue(const boost::property_tree::ptree & root,
- const char* key);
-
- // check exist object
- bool isExistObject(const boost::property_tree::ptree & root,
- const char *key);
-
- // parse window control options
- void parseWinCtrlOpt(const boost::property_tree::ptree & root);
-
- // parse input device control options
- void parseInputDevCtrlOpt(const boost::property_tree::ptree & root);
-
- // parse user control options
- void parseUserMgrOpt(const boost::property_tree::ptree & root);
-
- // parse resource control options
- void parseResCtrlOpt(const boost::property_tree::ptree & root);
-
- // parse input device setting options
- void parseInputDevSettingOpt(const boost::property_tree::ptree & root);
-
-public:
- unsigned long cmdid; //!< id of command
- std::string appid; //!< id of application
- int pid; //!< id of process
- CicoSCCommandOption *opt; //!< command option instance
-};
-#endif // __CICO_SC_COMMAND_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSCDisplay.cpp
- *
- * @brief This file implementation of CicoSCDisplay class
- */
-/*========================================================================*/
-
-#include <string>
-#include <vector>
-using namespace std;
-
-#include "CicoSCDisplay.h"
-#include "CicoSCLayer.h"
-#include "CicoSCDisplayZone.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCDisplay::CicoSCDisplay()
- : displayid(-1),
- type(-1),
- nodeid(-1),
- displayno(-1),
- width(-1),
- height(-1),
- pWidth(-1),
- pHeight(-1),
- orientation(ORIENTATION_HORIZONTAL),
- name("")
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCDisplay::~CicoSCDisplay()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCDisplay::dump(void)
-{
- ICO_DBG("CicoSCDisplay: displayid=%d type=%d nodeid=%d displayno=%d "
- "width=%d height=%d pWidth=%d pHeight=%d "
- "orientation =%d name=%s",
- displayid, type, nodeid, displayno, width, height,
- pWidth, pHeight, orientation, name.c_str());
-
- {
- vector<CicoSCLayer*>::iterator itr;
- itr = layerList.begin();
- for (; itr != layerList.end(); ++itr) {
- (*itr)->dump();
- }
- }
-
- {
- std::map<unsigned int, CicoSCDisplayZone*>::iterator itr;
- itr = zoneList.begin();
- for (; itr != zoneList.end(); ++itr) {
- itr->second->dump();
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find CicoSCDisplayZone instance by fullname
- */
-//--------------------------------------------------------------------------
-CicoSCDisplayZone*
-CicoSCDisplay::findDisplayZonebyFullName(const string & fullname)
-{
-// ICO_TRA("CicoSCDisplay:findDisplayZonebyFullName Enter"
-// "(fullname=%s)", fullname.c_str());
-
- std::map<unsigned int, CicoSCDisplayZone*>::iterator itr;
- itr = zoneList.begin();
- for (; itr != zoneList.end(); ++itr) {
- if (itr->second->fullname == fullname) {
-// ICO_TRA("CicoSCDisplay:findDisplayZonebyFullName Leave(found)");
- return itr->second;
- }
- }
-
-// ICO_TRA("CicoSCDisplay:findDisplayZonebyFullName Leave(not found)");
- return NULL;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCDisplay.h
- *
- * @brief This file is definition of CicoSCDisplay class
- */
-//==========================================================================
-#ifndef __CICO_SC_DISPLAY_H__
-#define __CICO_SC_DISPLAY_H__
-
-#include <string>
-#include <vector>
-#include <map>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCLayer;
-class CicoSCDisplayZone;
-
-//==========================================================================
-/**
- * @brief This class hold display information
- */
-//==========================================================================
-class CicoSCDisplay
-{
-public:
- // default constructor
- CicoSCDisplay();
-
- // destructor
- ~CicoSCDisplay();
-
- // dump log this class member variables
- void dump(void);
-
- // find display zone
- CicoSCDisplayZone* findDisplayZonebyFullName(const string & fullname);
-
-private:
- /// assignment operator
- CicoSCDisplay& operator=(const CicoSCDisplay &object);
-
- /// copy constructor
- CicoSCDisplay(const CicoSCDisplay &object);
-
-public:
- ///< definition value of horizontal
- const static int ORIENTATION_HORIZONTAL = 0;
- ///< definition value of vertical
- const static int ORIENTATION_VERTICAL = 1;
-
- int displayid; ///< display id
- int type; ///< display type
- int nodeid; ///< node id
- int displayno; ///< consecutive numbers
- int width; ///< the number of the lateral pixels
- int height; ///< the number of vertical pixels
- int pWidth; ///< compositor width
- int pHeight; ///< compositor height
- int orientation; ///< screen orientation
- std::string name; ///< display name
-
- /// list of display layer
- std::vector<CicoSCLayer*> layerList;
-
- /// list of display zone
- std::map<unsigned int, CicoSCDisplayZone*> zoneList;
-};
-#endif // __CICO_SC_DISPLAY_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSCDisplayZone.h
- *
- * @brief This file implementation of CicoSCDisplayZone class
- */
-/*========================================================================*/
-
-#include "CicoSCDisplayZone.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCDisplayZone::CicoSCDisplayZone()
- : zoneid(-1), x(-1), y(-1), width(-1), height(-1), fullname(""),
- displayedWindow(NULL), aspectFixed(false), aspectAlignLeft(false),
- aspectAlignRight(false), aspectAlignTop(false), aspectAlignBottom(false)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCDisplayZone::~CicoSCDisplayZone()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log CicoSCDisplayZone member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCDisplayZone::dump(void)
-{
- ICO_DBG("CicoSCDisplayZone: zoneid=%d "
- "x/y=%d/%d w/h=%d/%d fullname=%s window=0x%08x "
- "aspect(fixed=%s l/r=%s/%s t/b=%s/%s",
- zoneid, x, y, width, height, fullname.c_str(), displayedWindow,
- aspectFixed ? "true" : "false",
- aspectAlignLeft ? "true" : "false",
- aspectAlignRight ? "true" : "false",
- aspectAlignTop ? "true" : "false",
- aspectAlignBottom ? "true" : "false");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCDisplayZone.h
- *
- * @brief This file is definition of CicoSCDisplayZone class
- */
-//==========================================================================
-#ifndef __CICO_SC_DISPLAYZONE_H__
-#define __CICO_SC_DISPLAYZONE_H__
-
-#include <string>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCWindow;
-
-//==========================================================================
-/**
- * @brief This class hold display zone information
- */
-//==========================================================================
-class CicoSCDisplayZone
-{
-public:
- // default constructor
- CicoSCDisplayZone();
-
- // destructor
- virtual ~CicoSCDisplayZone();
-
- // dump log CicoSCDisplay member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCDisplayZone& operator=(const CicoSCDisplayZone &object);
-
- // copy constructor
- CicoSCDisplayZone(const CicoSCDisplayZone &object);
-
-public:
- int zoneid; ///< display zone id
- int x; ///< display zone x position
- int y; ///< display zone y position
- int width; ///< display zone width
- int height; ///< display zone height
- std::string fullname; ///< full name of layer
- CicoSCWindow *displayedWindow; ///< current displayed window
-
- /// fixed asppect ratio flag
- bool aspectFixed;
- /// horizontal direction to aligned at the left
- bool aspectAlignLeft;
- /// horizontal direction to aligned at the right
- bool aspectAlignRight;
- /// vertical direction is aligned at the top
- bool aspectAlignTop;
- /// vertical direction is aligned at the bottom
- bool aspectAlignBottom;
-};
-#endif // __CICO_SC_DISPLAYZONE_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCInputController.cpp
- *
- * @brief This file is implementation of CicoSCInputController class
- */
-//==========================================================================
-
-#include <string>
-#include <vector>
-using namespace std;
-
-#include "CicoSCInputController.h"
-#include "CicoSCWayland.h"
-#include "CicoLog.h"
-#include "CicoSCSwitch.h"
-#include "CicoSCInputDev.h"
-#include "ico_syc_error.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "ico_syc_private.h"
-#include "CicoSystemConfig.h"
-#include "CicoConf.h"
-#include "CicoSCCommand.h"
-#include "CicoSCServer.h"
-#include "CicoSCMessage.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCInputController::CicoSCInputController()
-{
- CicoSCWayland* wayland = CicoSCWayland::getInstance();
- wayland->addWaylandIF(ICO_WL_INPUT_MGR_CTRL_IF, this);
- wayland->addWaylandIF(ICO_WL_EXINPUT_IF, this);
- wayland->addWaylandIF(ICO_WL_INPUT_MGR_DEV_IF, this);
-
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCInputController::~CicoSCInputController()
-{
-}
-
-#if 0 //TODO
-int
-initDB(void)
-{
- const vector<CicoSCInputDevConf*>& inputDevConfList =
- CicoSystemConfig::getInstance()->getInputDevConfList();
- vector<CicoSCInputDevConf*>::const_iterator itr;
- itr = inputDevConfList.begin();
- for (; itr != inputDevConfList.end(); ++itr) {
- const CicoSCInputDevConf *iconf = const_cast<CicoSCInputDevConf*>(*itr);
- CicoSCInputDev *device = new CicoSCInputDev();
-
- device->devcie = iconf->name;
-
- vector<CicoSCSwitchConf*>::const_iterator itr2;
- itr2 = iconf->switchConfList.begin();
- for (; itr2 != dconf->switchConfList.end(); ++itr2) {
- const CicoSCSwitchConf *sconf = const_cast<CicoSCSwitchConf*>(*itr2);
-
- CicoSCSwitch *sw = new CicoSCSwitch();
- sw->swname = sconf->name;
- sw->input = sconf->id;
- devcie->switchList.push_back(sw);
- }
-
-
-
-
- }
-
-}
-#endif
-
-//--------------------------------------------------------------------------
-/**
- * @brief executes an input control process corresponding to the command
- *
- * @param cmd command
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputController::handleCommand(const CicoSCCommand *cmd)
-{
- ICO_TRA("CicoSCInputController::handleCommand Enter"
- "(cmdid=0x%08x)", cmd->cmdid);
-
- CicoSCCmdInputDevCtrlOpt *opt;
- CicoSCCmdInputDevSettingOpt *set_opt;
-
- switch (cmd->cmdid) {
- case MSG_CMD_ADD_INPUT:
- opt = static_cast<CicoSCCmdInputDevCtrlOpt*>(cmd->opt);
- addInputApp(cmd->appid, opt->device, opt->input, opt->fix,
- opt->keycode);
- break;
- case MSG_CMD_DEL_INPUT:
- opt = static_cast<CicoSCCmdInputDevCtrlOpt*>(cmd->opt);
- delInputApp(cmd->appid, opt->device, opt->input);
- break;
- case MSG_CMD_SET_REGION:
- set_opt = static_cast<CicoSCCmdInputDevSettingOpt*>(cmd->opt);
- setInputRegion(cmd->appid, set_opt->winname, set_opt->x, set_opt->y,
- set_opt->width, set_opt->height,
- set_opt->hotspot_x, set_opt->hotspot_y,
- set_opt->cursor_x, set_opt->cursor_y,
- set_opt->cursor_width, set_opt->cursor_height, set_opt->attr);
- break;
- case MSG_CMD_UNSET_REGION:
- set_opt = static_cast<CicoSCCmdInputDevSettingOpt*>(cmd->opt);
- unsetInputRegion(cmd->appid, set_opt->winname, set_opt->x, set_opt->y,
- set_opt->width, set_opt->height);
- break;
- default:
- ICO_WRN("Unknown Command(0x%08x)", cmd->cmdid);
- break;
- }
-
- ICO_TRA("CicoSCInputController::handleCommand Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief register input device control application
- *
- * @param [in] appid application id
- * @param [in] device input device name
- * @param [in] input input number
- * @parma [in] fix fixed assign flag
- * @parma [in] keycode assigned keycode value
- */
-//--------------------------------------------------------------------------
-int
-CicoSCInputController::addInputApp(const string &appid,
- const string &device,
- int input,
- int fix,
- int keycode)
-{
- ICO_TRA("CicoSCInputController::addInputApp Enter"
- "(appid=%s device=%s input=%d fix=%d keycode=%d)",
- appid.c_str(), device.c_str(), input, fix, keycode);
-
- CicoSCWlInputMgrIF::addInputApp(appid.c_str(), device.c_str(),
- input, fix, keycode);
-
- ICO_TRA("CicoSCInputController::addInputApp Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief unregister input device control application
- *
- * @param [in] appid application id
- * @param [in] device input device name
- * @param [in] input input number
- */
-//--------------------------------------------------------------------------
-int
-CicoSCInputController::delInputApp(const string &appid,
- const string &device,
- int input)
-{
- ICO_TRA("CicoSCInputController::delInputApp Enter"
- "(appid=%s device=%s input=%d)",
- appid.c_str(), device.c_str(), input);
-
- CicoSCWlInputMgrIF::delInputApp(appid.c_str(), device.c_str(), input);
-
- ICO_TRA("CicoSCInputController::delInputApp Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set input region information
- *
- * @param [in] appid application id
- * @param [in] winname window name
- * @param [in] x region x positon
- * @param [in] y region y positon
- * @param [in] width region width
- * @param [in] height region height
- * @param [in] hotspot_x hotspot x position
- * @param [in] hotspot_y hotspot y position
- * @param [in] cursor_x cursor x position
- * @param [in] cursor_y cursor y position
- * @param [in] cursor_width cursor width
- * @param [in] cursor_height cursor height
- * @param [in] attr region attribute
- */
-//--------------------------------------------------------------------------
-int
-CicoSCInputController::setInputRegion(const string &appid,
- const string &winname,
- int x,
- int y,
- int width,
- int height,
- int hotspot_x,
- int hotspot_y,
- int cursor_x,
- int cursor_y,
- int cursor_width,
- int cursor_height,
- int attr)
-{
- char target[ICO_SYC_MAX_LEN];
-
- snprintf(target, ICO_SYC_MAX_LEN-1, "%s@%s", winname.c_str(), appid.c_str());
-
- ICO_TRA("CicoSCInputController::setInputRegion Enter"
- "(target=%s x=%d y=%d width=%d height=%d "
- "hotspot=%d/%d cursor=%d/%d-%d/%d attr=%d)",
- target, x, y, width, height, hotspot_x, hotspot_y,
- cursor_x, cursor_y, cursor_width, cursor_height, attr);
-
- CicoSCWlInputMgrIF::setInputRegion(target, x, y, width, height,
- hotspot_x, hotspot_y, cursor_x, cursor_y,
- cursor_width, cursor_height, attr);
-
- ICO_TRA("CicoSCInputController::setInputRegion Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief unset input region information
- *
- * @param [in] appid application id
- * @param [in] winname window name
- * @param [in] x region x positon
- * @param [in] y region y positon
- * @param [in] width region width
- * @param [in] height region height
- */
-//--------------------------------------------------------------------------
-int
-CicoSCInputController::unsetInputRegion(const string &appid,
- const string &winname,
- int x,
- int y,
- int width,
- int height)
-{
- char target[ICO_SYC_MAX_LEN];
-
- snprintf(target, ICO_SYC_MAX_LEN-1, "%s@%s", winname.c_str(), appid.c_str());
-
- ICO_TRA("CicoSCInputController::unsetInputRegion Enter"
- "(target=%s x=%d y=%d width=%d height=%d", target, x, y, width, height);
-
- CicoSCWlInputMgrIF::unsetInputRegion(target, x, y, width, height);
-
- ICO_TRA("CicoSCInputController::unsetInputRegion Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input switch information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] type input device type (as enum type)
- * @param [in] swname input switch name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputController::capabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code)
-{
- ICO_TRA("CicoSCInputController::capabilitiesCB Enter",
- "device=%s type=%s swname=%s input=%s codename=%s code=%d",
- device, type, swname, input, codename, code);
-
- // create CicoSCInputDev object
- CicoSCInputDev *inputdev = findInputDev(device);
- if (NULL == inputdev) {
- inputdev = new CicoSCInputDev();
- inputdev->device = device;
- inputdev->type = type;
- }
-
- CicoSCSwitch *sw = findInputSwitch(device, input);
- if (NULL == sw) {
- sw = new CicoSCSwitch();
- sw->input = input;
- sw->code.push_back(code);
- sw->codename.push_back(codename);
- }
- else {
- sw->input = input;
- }
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- const CicoSCSwitchConf *swconf = NULL;
- swconf = sysConf->findSwitchConfbyName(device, swname);
- if (NULL != swconf) {
- if (false == swconf->appid.empty()) {
- addInputApp(swconf->appid, inputdev->device,
- input,CicoSCSwitch::SWITCH_FIX, swconf->keycode);
- sw->fix = true;
- }
- }
-
- ICO_TRA("CicoSCInputController::capabilitiesCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input code information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputController::codeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code)
-{
- ICO_TRA("CicoSCInputController::codeCB Enter"
- "(device=%s input=%d codename=%s code=%d)",
- device, input, codename, code);
-
- CicoSCSwitch *sw = findInputSwitch(device, input);
- if (NULL != sw) {
- ICO_ERR("codeCB: device=%s input=%d not found.");
- return;
- }
-
- if (sw->code.size() >= CicoSCSwitch::SWITCH_CODE_MAX) {
- ICO_ERR("codeCB: device=%s input=%d number of codes overflow.");
- return;
- }
-
- for (unsigned int i = 0; i < sw->code.size(); ++i) {
- if (sw->code[i] == code) {
- ICO_WRN("codeCB: device=%s input=%d code=%d already exist.");
- return;
- }
- }
-
- sw->code.push_back(code);
- sw->codename.push_back(codename);
-
- ICO_TRA("CicoSCInputController::codeCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for switch input
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] time input time of millisecond
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] code input switch code
- * @param [in] state Of/Off status
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputController::inputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state)
-{
- ICO_TRA("CicoSCInputController::inputCB Enter"
- "time=%d device=%s input=%d code=%d state=%d",
- time, device, input, code, state);
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", ICO_SYC_EV_WIN_CREATE);
- message->addArgObject("device", device);
- message->addArgObject("time", time);
- message->addArgObject("input", input);
- message->addArgObject("code", code);
- message->addArgObject("state", state);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- ICO_TRA("CicoSCInputController::inputCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for change input region
- *
- * @param [in] data user data
- * @param [in] ico_input_mgr_dev wayland ico_exinput interface
- * @param [in] region input regions
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputController::regionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_dev,
- struct wl_array *region)
-{
- ICO_TRA("CicoSCInputController::regionCB Enter");
- ICO_TRA("CicoSCInputController::regionCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find input device information
- *
- * @param [in] device input device name
- *
- * @return CicoSCInputDev instance on found, NULL on not found
- */
-//--------------------------------------------------------------------------
-CicoSCInputDev*
-CicoSCInputController::findInputDev(const char *device)
-{
- vector<CicoSCInputDev*>::iterator itr;
- itr = m_inputDevList.begin();
- for (; itr != m_inputDevList.end(); ++itr) {
- CicoSCInputDev* inputdev = const_cast<CicoSCInputDev*>(*itr);
- if (inputdev->device == device) {
- return inputdev;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find input device switch information
- *
- * @param [in] device input device name
- * @param [in] input input number
- *
- * @return CicoSCSwitch instance on found, NULL on not found
- */
-//--------------------------------------------------------------------------
-CicoSCSwitch*
-CicoSCInputController::findInputSwitch(const char *device, int input)
-{
- const CicoSCInputDev *inputdev = findInputDev(device);
- if (NULL == inputdev) {
- return NULL;
- }
-
- vector<CicoSCSwitch*>::const_iterator itr;
- itr = inputdev->switchList.begin();
- for (; itr != inputdev->switchList.end(); ++itr) {
- CicoSCSwitch* sw = const_cast<CicoSCSwitch*>(*itr);
- if (sw->input == input) {
- return sw;
- }
- }
- return NULL;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCInputController.h
- *
- * @brief This file is definition of CicoSCInputController class
- */
-//==========================================================================
-#ifndef __CICO_SC_INPUT_CONTROLLER_H__
-#define __CICO_SC_INPUT_CONTROLLER_H__
-
-#include <string>
-#include <vector>
-
-#include "CicoSCWlInputMgrIF.h"
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCCommand;
-class CicoSCInputDev;
-class CicoSCSwitch;
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class is controller of input device
- */
-//--------------------------------------------------------------------------
-class CicoSCInputController : public CicoSCWlInputMgrIF
-{
-public:
- // default constructor
- CicoSCInputController();
-
- // destructor
- ~CicoSCInputController();
-
- // initialize input device information
- int initDB(void);
-
- // executes an input control process corresponding to the command
- void handleCommand(const CicoSCCommand *cmd);
-
- // register input device control application
- int addInputApp(const std::string &appid,
- const std::string &device,
- int input,
- int fix,
- int keycode);
-
- // unregister input device control application
- int delInputApp(const std::string &appid,
- const std::string &device,
- int input);
-
- // set input region information
- int setInputRegion(const std::string &appid,
- const std::string &winname,
- int x,
- int y,
- int width,
- int height,
- int hotspot_x,
- int hotspot_y,
- int cursor_x,
- int cursor_y,
- int cursor_width,
- int cursor_height,
- int attr);
-
- // unset input region information
- int unsetInputRegion(const std::string &appid,
- const std::string &winname,
- int x,
- int y,
- int width,
- int height);
-
- // callback to application for input switch information
- void capabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // callback to application for input code information
- void codeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // callback to application for switch input
- void inputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state);
-
- // callback to application for change input region
- void regionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_device,
- struct wl_array *region);
-
-protected:
- // assignment operator
- CicoSCInputController& operator=(const CicoSCInputController &object);
-
- // copy constructor
- CicoSCInputController(const CicoSCInputController &object);
-
-private:
- // find input device information
- CicoSCInputDev* findInputDev(const char *device);
-
- // find input device switch information
- CicoSCSwitch* findInputSwitch(const char *device, int input);
-
-private:
- /// input device information list
- std::vector<CicoSCInputDev*> m_inputDevList;
-};
-#endif // __CICO_SC_INPUT_CONTROLLER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCInputDev.cpp
- *
- * @brief This file is implementation of CicoSCInputDev class
- */
-//==========================================================================
-
-#include <string>
-#include <vector>
-using namespace std;
-
-#include "CicoSCInputDev.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCInputDev::CicoSCInputDev()
- : device(""), type(-1)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCInputDev::~CicoSCInputDev()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCInputDev::dump(void)
-{
- ICO_DBG("CicoSCInputDev: device=%d type=%d", device.c_str(), type);
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCInputDev.h
- *
- * @brief This file is definition of CicoSCInputDev class
- */
-//==========================================================================
-#ifndef __CICO_SC_INPUT_DEV_H__
-#define __CICO_SC_INPUT_DEV_H__
-
-#include <string>
-#include <vector>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCSwitch;
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class hold input device information
- */
-//--------------------------------------------------------------------------
-class CicoSCInputDev
-{
-public:
- // default constructor
- CicoSCInputDev();
-
- // destructor
- virtual ~CicoSCInputDev();
-
- // dump log this class member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCInputDev& operator=(const CicoSCInputDev &object);
-
- // copy constructor
- CicoSCInputDev(const CicoSCInputDev &object);
-
-public:
- std::string device; //!< input device name
- int type; //!< type
-
- std::vector<CicoSCSwitch*> switchList; //!< switch list
-};
-#endif // __CICO_SC_INPUT_DEV_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCLastInfo.h
- *
- * @brief This file is definition of CicoSCLastInfo class
- */
-//==========================================================================
-#ifndef __CICO_SC_LAST_INFO_H__
-#define __CICO_SC_LAST_INFO_H__
-
-#include <string>
-
-#include "CicoLog.h"
-
-//==========================================================================
-/**
- * @brief This class hold application's last information
- */
-//==========================================================================
-class CicoSCLastInfo
-{
-public:
- // default constructor
- CicoSCLastInfo()
- : appid(""), lastinfo("") {}
-
- // destructor
- ~CicoSCLastInfo() {}
-
- // dump log this class member variables
- void dumpLastInfo(void)
- {
- ICO_DBG("CicoSCLastInfo: appid=%s lastinfo=%s",
- appid.c_str(), lastinfo.c_str());
- }
-
-public:
- std::string appid; ///< application id
- std::string lastinfo; ///< application's last information
-};
-#endif // __CICO_SC_LAST_INFO_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSCLayer.cpp
- *
- * @brief This file is implementation of CicoSCLayer class
- */
-/*========================================================================*/
-
-#include <stdlib.h>
-#include <string.h>
-#include "CicoSCLayer.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCLayer::CicoSCLayer()
- : layerid(-1), type(-1), width(-1), height(-1),
- displayid(-1), numsurfaces(0), menuoverlap(false)
-
-{
- surfaceids = (int *)malloc(ICO_SC_LAYER_TABLE_INITIAL * sizeof(int));
- if (surfaceids) {
- maxsurfaces = ICO_SC_LAYER_TABLE_INITIAL;
- }
- else {
- maxsurfaces = 0;
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCLayer::~CicoSCLayer()
-{
- if (surfaceids) {
- maxsurfaces = 0;
- numsurfaces = 0;
- free(surfaceids);
- surfaceids = NULL;
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief addSurface
- */
-//--------------------------------------------------------------------------
-void
-CicoSCLayer::addSurface(int surfaceid, bool top)
-{
- int idx, idx2;
- int *wksurfaceids;
- ICO_DBG("CicoSCLayer::addSurface(%08x,%d)", surfaceid, top);
-
- idx2 = 0;
- for (idx = 0; idx < numsurfaces; idx++) {
- if (surfaceids[idx] != surfaceid) {
- surfaceids[idx2++] = surfaceids[idx];
- }
- }
- numsurfaces = idx2;
-
- if (numsurfaces >= maxsurfaces) {
- maxsurfaces = numsurfaces + ICO_SC_LAYER_TABLE_EXTENSION;
- wksurfaceids = (int *)malloc(maxsurfaces * sizeof(int));
- if (! wksurfaceids) {
- ICO_ERR("CicoSCLayer::addSurface: Out of Memory");
- return;
- }
- if (surfaceids) {
- memcpy(wksurfaceids, surfaceids, numsurfaces * sizeof(int));
- free(surfaceids);
- }
- surfaceids = wksurfaceids;
- }
- if (top) {
- surfaceids[numsurfaces] = surfaceid;
- }
- else {
- for (idx = numsurfaces; idx > 0; idx--) {
- surfaceids[idx] = surfaceids[idx-1];
- }
- surfaceids[0] = surfaceid;
- }
- numsurfaces ++;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief removeSurface
- */
-//--------------------------------------------------------------------------
-void
-CicoSCLayer::removeSurface(int surfaceid)
-{
- int idx, idx2;
- ICO_DBG("CicoSCLayer::removeSurface(%08x)", surfaceid);
-
- idx2 = 0;
- for (idx = 0; idx < numsurfaces; idx++) {
- if (surfaceids[idx] != surfaceid) {
- surfaceids[idx2++] = surfaceids[idx];
- }
- }
- numsurfaces = idx2;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief is_topSurface
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCLayer::is_topSurface(int surfaceid)
-{
- return (numsurfaces > 0) && (surfaceids[numsurfaces-1] == surfaceid);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief is_buttomSurface
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCLayer::is_buttomSurface(int surfaceid)
-{
- return (numsurfaces > 0) && (surfaceids[0] == surfaceid);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief getSurfaces
- */
-//--------------------------------------------------------------------------
-const int *
-CicoSCLayer::getSurfaces(int *retsurfaces)
-{
- *retsurfaces = numsurfaces;
- return surfaceids;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCLayer::dump(void)
-{
- ICO_DBG("CicoSCLayer: layerid=%d type=%d width=%d height=%d "
- "displayid =%d menuoverlap=%s",
- layerid, type, width, height, displayid,
- menuoverlap ? "true" : "false");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCLayer.h
- *
- * @brief This file is definition of CicoSCLayer class
- */
-//==========================================================================
-#ifndef __CICO_SC_LAYER_H__
-#define __CICO_SC_LAYER_H__
-
-#include "CicoCommonDef.h"
-
-#define ICO_SC_LAYER_TABLE_INITIAL 50 // layer table initial size
-#define ICO_SC_LAYER_TABLE_EXTENSION 50 // layer table extension size
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class hold layer information
- */
-//--------------------------------------------------------------------------
-class CicoSCLayer
-{
-public:
- // default constructor
- CicoSCLayer();
-
- // destructor
- virtual ~CicoSCLayer();
-
- // surface
- void addSurface(int surfaceid, bool top);
- void removeSurface(int surfaceid);
- const int *getSurfaces(int *retsurfaces);
- bool is_topSurface(int surfaceid);
- bool is_buttomSurface(int surfaceid);
-
- // dump log this class member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCLayer& operator=(const CicoSCLayer &object);
-
- // copy constructor
- CicoSCLayer(const CicoSCLayer &object);
-
-public:
- int layerid; //!< layer id
- int type; //!< enum ico_window_mgr_layer_attr
- int width; //!< The number of the lateral pixels
- int height; //!< The number of vertical pixels
- int displayid; //!< display ID
-
- int *surfaceids; //!< surface ID list
- int numsurfaces; //!< current number of surfaces
- int maxsurfaces; //!< max number of surfaces
- bool menuoverlap; //!< overlap menu window flag
-};
-#endif // __CICO_SC_LAYER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#include <string>
-#include <vector>
-#include <cstdio>
-#include <cstdlib>
-#include <glib.h>
-#include <ail.h>
-#include <aul/aul.h>
-#include <bundle.h>
-#include <sys/stat.h>
-
-#include "ico_syc_error.h"
-#include "CicoLog.h"
-#include "CicoAulItems.h"
-#include "CicoAilItems.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoConf.h"
-#include "CicoSystemConfig.h"
-#include "CicoSCSysResourceController.h"
-#include "CicoSCAppResourceController.h"
-#include "Cico_aul_listen_app.h"
-
-using namespace std;
-
-
-CicoSCLifeCycleController* CicoSCLifeCycleController::ms_myInstance = NULL;
-
-const char* DAilTypeFilPrm_Menu="menu";
-const char* DAilTypeFilPrm_App="Application";
-const char* DNil = "(nil)";
-const char* sectAppAttr = "app-attributes";
-const char* DNull = "(null)";
-
-#define APP_CONF_AIL_NULL_STR DNull
-
-/**
- * @brief
- * @param req_id
- * @param pkg_type
- * @param pkg_name package name
- * @param key "start"/"end"/"install_percent"/"command" strings
- * @param val "ok"/"error"/"0.000000"-"100.000000" strings
- * @param pmsg pkgmgr message
- * @param data user data
- */
-static int CSCLCCpkgmgr_handler(int req_id, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val, const void *pmsg, void *data)
-{
- CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
- return
- CSCLCCpkgmgr_handlerX(req_id, pkg_type, pkg_name, key, val, pmsg, x);
-}
-
-/**
- * @brief ail_filter_list_appinfo_foreach callback function
- * @param appinfo appinfo_h the appinfo's handle
- * @param data user data
- * @retval AIL_CB_RET_CONTINUE return if you continue iteration
- * @retval AIL_CB_RET_CANCEL return if you cancel iteration
- */
-static ail_cb_ret_e CSCLCCail_list_appinfo_cb(const ail_appinfo_h appinfo,
- void *data, uid_t uid)
-{
- CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
- return CSCLCCail_list_appinfo_cbX(appinfo, x, uid);
-}
-
-/**
- * @brief applications are launched. callback function
- * @param pid
- * @param data user data
- */
-static int CSCLCCapp_launch_handler(int pid, void *data)
-{
- CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
- return CSCLCCapp_launch_handlerX(pid, x);
-}
-
-/**
- * @brief applications die. callback function
- * @param pid
- * @param data user data
- */
-static int CSCLCCapp_dead_handler(int pid, void *data)
-{
- CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
- return CSCLCCapp_dead_handlerX(pid, x);
-}
-
-/**
- * @brief This API get application appid by pid
- * @param pid
- * @param appid store appid string
- * @param len appid buffer size
- * @ret aul_app_get_appid_bypid return value
- * @retval AUL_R_OK - success
- * @retval AUL_R_ERROR - no such a appid
- */
-int Xaul_app_get_appid_bypid(int pid, char *appid, int len)
-{
- int r = aul_app_get_appid_bypid(pid, appid, len);
- if (AUL_R_OK == r) {
- return r;
- }
- char fn[128];
- sprintf(fn, "/proc/%d/cmdline", pid);
- string tmp;
- ifstream ifs(fn);
- ifs >> tmp;
- ifs.close();
- const char* p = tmp.c_str();
- int sz = strlen(p);
- int i = sz - 2;
- while (0 <= i) {
- if ('/' == p[i]) {
- strncpy(appid, &p[i+1], len);
- break; // break of while i
- }
- i--;
- }
- return r;
-}
-
-/**
- * @brief contractor
- */
-CicoSCLifeCycleController::CicoSCLifeCycleController()
-{
- m_gconf = (GKeyFile*)NULL;
- m_pc = (pkgmgr_client*)NULL;
-#if 0
- m_RC = new CicoSCSysResourceController;
- m_RC->startSysResource();
-#else
- m_RC = new CicoSCAppResourceController;
- if (false == m_RC->startSysResource()) {
- m_RC->initAppResource();
- }
-#endif
- ailRenewFlagOff();
- initAIL();
- initAUL();
-
- CicoSCLifeCycleController::ms_myInstance = this;
-}
-
-/**
- * @brief destructor
- */
-CicoSCLifeCycleController::~CicoSCLifeCycleController()
-{
- delete m_RC;
- CicoSCLifeCycleController::ms_myInstance = NULL;
-}
-
-CicoSCLifeCycleController*
-CicoSCLifeCycleController::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCLifeCycleController();
- }
- return ms_myInstance;
-}
-
-/**
- * @brief application launch
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::launch(const char* appid, bundle* b)
-{
- ICO_TRA("start %s", appid);
- // appid check AIL table exist
- if (NULL == findAIL(appid)) {
- ICO_TRA("end fail(not find)");
- return ICO_SYC_ENOSYS;
- }
- ICO_PRF("CHG_APP_STA request app=%s", appid);
- int r = aul_launch_app(appid, b);
- if (0 > r) {
- ICO_TRA("end fail(%d)", r);
- return ICO_SYC_ENOSYS;
- }
- ICO_TRA("end success(%d)", r);
- return ICO_SYC_EOK;
-}
-
-/**
- * @brief application launch
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::launch(const std::string& appid, bundle* b)
-{
- return launch((const char*)appid.c_str(), b);
-}
-
-/**
- * @brief application terminate
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::terminate(const char* appid)
-{
- ICO_TRA("CicoSCLifeCycleController::terminate %s", appid);
- int r = ICO_SYC_EOK;
- vector<int> pids;
- if (true == getPIDs(appid, pids)) {
- vector<int>::iterator it;
- for(it = pids.begin(); it != pids.end(); ++it) {
- int tr = terminateR(*it);
- if (ICO_SYC_EOK != tr) {
- r = tr;
- }
- }
- }
- else {
- ICO_TRA("end ICO_SYC_EPERM");
- return ICO_SYC_EPERM;
- }
- ICO_TRA("end %d", r);
- return r;
-}
-
-/**
- * @brief application terminate
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::terminate(const std::string& appid)
-{
- return terminate((const char*)appid.c_str());
-}
-
-/**
- * @brief application terminate
- * @param pid
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::terminate(int pid)
-{
- ICO_TRA("CicoSCLifeCycleController::terminate %d", pid);
- const CicoAulItems* t = findAUL(pid);
- if ((NULL == t) || (0 == t)) {
- ICO_TRA("not find");
- return ICO_SYC_EPERM;
- }
- return terminateR(pid);
-}
-
-/**
- * @brief application terminate
- * @param pid
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ENOSYS error
- */
-int CicoSCLifeCycleController::terminateR(int pid)
-{
- ICO_TRA("CicoSCLifeCycleController::terminateR %d", pid);
- int r = aul_terminate_pid(pid);
- if (r < 0) {
- ICO_DBG("terminate error pid:%d, r:%d", pid, r);
- return ICO_SYC_ENOSYS;
- }
- return ICO_SYC_EOK;
-}
-
-/**
- * @brief application suspend
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::suspend(const char* appid)
-{
- int r = ICO_SYC_EOK;
- vector<int> pids;
- if (true == getPIDs(appid, pids)) {
- vector<int>::iterator it;
- for(it = pids.begin(); it != pids.end(); ++it) {
- int tr = suspend(*it);
- if (ICO_SYC_EOK != tr) {
- r = tr;
- }
- }
- }
- else {
- ICO_TRA("end ICO_SYC_EPERM");
- return ICO_SYC_EPERM;
- }
- ICO_TRA("end %d", r);
- return r;
-}
-
-/**
- * @brief application suspend
- * @param appid application id
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::suspend(const std::string& appid)
-{
- return suspend((const char*)appid.c_str());
-}
-
-/**
- * @brief application suspend
- * @param pid
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(does not exist)
- * @retval ICO_SYC_EBUSY error(already launch)
- * @retval ICO_SYC_EPERM error(no authority)
- */
-int CicoSCLifeCycleController::suspend(int pid)
-{
-// TODO mk_k Not currently supported
-// TODO mk_k What do I do now?
- return ICO_SYC_EPERM;
-}
-
-/**
- * @brief appid is running check
- * @param appid package
- * @return running status
- * @retval true is running
- * @retval false not running
- */
-bool CicoSCLifeCycleController::isRunning(const char* appid)
-{
- ICO_TRA("start %s", appid);
- bool r = false;
-#if 0 // TODO mk_k
- vector<CicoAulItems>::iterator it;
- for (it = m_aul.begin(); it != m_aul.end(); ++it) {
- it->update_appid();
- if (0 == strcasecmp(it->m_appid.c_str(), appid)) {
- r = true;
- break;
- }
- }
-#else
- int sz = m_aul.size();
- for (int i = 0; i < sz; i++) {
- m_aul[i].update_appid();
- if (0 == strcasecmp(m_aul[i].m_appid.c_str(), appid)) {
- r = true;
- break;
- }
- }
-#endif
- ICO_TRA("end %s", r? "true": "false");
- return r;
-}
-
-/**
- * @brief appid is running check
- * @param appid package
- * @return running status
- * @retval true is running
- * @retval false not running
- */
-bool CicoSCLifeCycleController::isRunning(const std::string& appid)
-{
- return isRunning((const char*)appid.c_str());
-}
-
-/**
- * @brief find ail data
- * @param appid find key
- * @return CicoAilItems class pointer
- * @retval NULL is not find
- */
-const CicoAilItems* CicoSCLifeCycleController::findAIL(const char* appid) const
-{
- ICO_TRA("start");
- const CicoAilItems* r = NULL;
- int sz = m_ail.size();
- for (int i = 0; i < sz; i++) {
- if (0 == strcasecmp(m_ail[i].m_appid.c_str(), appid)) {
- r = m_ail[i].p();
- break; // break of for
- }
- }
- ICO_TRA("end %x", r);
- return r;
-}
-
-/**
- * @brief find ail data
- * @param appid find key
- * @return CicoAilItems class pointer
- * @retval NULL is not find
- */
-const CicoAilItems* CicoSCLifeCycleController::findAIL(const std::string& appid) const
-{
-// ICO_TRA("call findAIL(const char*)");
- return findAIL((const char*)appid.c_str());
-}
-
-/**
- * @brief get launched apprication pid
- * @param appid target application appid
- * @return pid
- */
-bool CicoSCLifeCycleController::getPIDs(const char* appid, std::vector<int>& pids) const
-{
- ICO_TRA("start %s", appid);
- bool r = false;
-#if 0 // TODO mk_k
- vector<CicoAulItems>::iterator it;
- for (it = m_aul.begin(); it != m_aul.end(); ++it) {
- it->update_appid();
- if (0 == strcasecmp(it->m_appid.c_str(), appid)) {
- pids.push_back(it->m_pid);
- r = true;
- }
- }
-#else
- int sz = m_aul.size();
- for (int i = 0; i < sz; i++) {
- CicoAulItems* t = (CicoAulItems*)m_aul[i].p();
- t->update_appid();
- if (0 == strcasecmp(t->m_appid.c_str(), appid)) {
- pids.push_back(t->m_pid);
- r = true;
- }
- }
-#endif
- ICO_TRA("end %d %s", pids.size(), r? "true": "false");
- return r;
-}
-
-/**
- * @brief get launched apprication pid
- * @param appid target application appid
- * @return pid
- */
-bool CicoSCLifeCycleController::getPIDs(std::string& appid, std::vector<int>& pids) const
-{
- return getPIDs((const char*)appid.c_str(), pids);
-}
-
-/**
- * @brief get launched apprication pid
- * @param appid target application appid
- * @return pid
- */
-const CicoAulItems* CicoSCLifeCycleController::findAUL(int pid)
-{
- ICO_TRA("start %d", pid);
- const CicoAulItems* r = NULL;
- int sz = m_aul.size();
- for (int i = 0; i < sz; i++) {
- CicoAulItems* t = (CicoAulItems*)m_aul[i].p();
- t->update_appid();
- if (t->m_pid == pid) {
- r = t;
- ICO_DBG("find %d -> %s", pid, t->m_appid.c_str());
- break; // break of for
- }
- }
- ICO_TRA("end %x", r);
- return r;
-}
-
-
-/**
- * @brief ail information data initialization
- */
-void CicoSCLifeCycleController::initAIL()
-{
- ICO_TRA("start %x", m_pc);
- createAilItems();
- if ((pkgmgr_client*)NULL == m_pc) {
- m_pc = pkgmgr_client_new(PC_LISTENING);
- ICO_TRA("pkgmgr client new %x", m_pc);
- int r = pkgmgr_client_listen_status(m_pc, CSCLCCpkgmgr_handler,
- (void*)this);
- ICO_TRA("pkgmgr_client_listen_status %d", r);
-// if (PKGMGR_R_OK != r)
- // pkgmgr_client_listen_status return is
- // request_id (>0) if success, error code(<0) if fail
- // PKGMGR_R_OK success (PKGMGR_R_OK is 0)
- if (0 > r) {
- pkgmgr_client_free(m_pc);
- m_pc = NULL;
- }
- }
- ICO_TRA("end %x", m_pc);
-}
-
-/**
- * @brief
- */
-int CSCLCCpkgmgr_handlerX(int req_id, const char *pkg_type, const char *pkg_name,
- const char *key, const char *val, const void *pmsg,
- CicoSCLifeCycleController* x)
-{
-// TODO mk_k packages install/uninstall handler Determination of the result undecided
- ICO_TRA("pkgmgr t:%s, n:%s, k:%s, v:%s, m:%s",pkg_type, pkg_name, key,
- val, pmsg);
- if ((NULL == x) || (0 == x)) {
- ICO_TRA("end user data none");
- return -1;
- }
- if (strcasecmp(key, "end") == 0) {
- if (strcasecmp(val, "ok") == 0) {
- ICO_DBG("receive end:ok");
- x->renewAIL();
- }
- }
- ICO_TRA("end");
- return 0;
-// TODO mk_k packages install/uninstall handler Determination of the result undecided
-}
-
-/**
- * @brief AIL list renew
- */
-void CicoSCLifeCycleController::renewAIL()
-{
- ICO_TRA("start");
- vector<CicoAilItems> old = m_ail;
- m_ail.clear();
- int cnt =0;
- while (false == createAilItems()) {
- if (cnt > 500) {
- m_ail.clear();
- m_ail = old;
- break;
- }
- cnt++;
- usleep(10000);
- }
- if (cnt > 500) {
- ICO_TRA("end error AIL I/F");
- return ;
- }
-#if 0 // TODO mk_k I do not know unnecessary
- vector<string> add_appid;
- vector<string> remove_appid;
-
- vector<CicoAulItems>::iterator it_n;
- vector<CicoAulItems>::iterator it_o;
- for(it_n = m_aul.begin(); it_n != m_aul.end(); ++it_n) {
- bool bingo = false;
- for(it_o = old.begin(); it_o != old.end(); ++it_o) {
- if (it_n->m_appid.compaire(it_o->m_appid)) {
- bingo = true;
- }
- }
- if (false == bingo) {
- add_appid.push_back(it_n->m_appid);
- }
- }
- for(it_o = old.begin(); it_o != old.end(); ++it_o) {
- bool bingo = false;
- for(it_n = m_aul.begin(); it_n != m_aul.end(); ++it_n) {
- if (it_o->m_appid.compaire(it_n->m_appid)) {
- bingo = true;
- }
- }
- if (false == bingo) {
- remove_appid.push_back(it_o->m_appid);
- }
- }
-
- if (0 != add_appid.size()) {
-// TODO mk_k install
- }
- if (0 != remove_appid.size()) {
-// TODO mk_k uninstall
- }
-#endif
- old.clear();
- ailRenewFlagOn();
- ICO_TRA("end");
- return;
-}
-
-/**
- * @brief ail_filter_list_appinfo_foreach callback function
- * @param appinfo appinfo_h the appinfo's handle
- * @param x CicoSCLifeCycleController class pointer
- * @retval AIL_CB_RET_CONTINUE return if you continue iteration
- * @retval AIL_CB_RET_CANCEL return if you cancel iteration
- *
- */
-ail_cb_ret_e CSCLCCail_list_appinfo_cbX(const ail_appinfo_h appinfo,
- CicoSCLifeCycleController* x, uid_t uid)
-{
- ICO_TRA("start");
- if ((NULL == x) || (0 == x)) {
- ICO_TRA("end bad end")
- return AIL_CB_RET_CANCEL;
- }
- char *pkg;
- char *icn;
- char *nm;
- char *ctgry;
- char *typ;
- char *exe;
- bool bndsp = false;
- /* get package name for appid */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, uid, &pkg);
- if (strcmp(pkg, APP_CONF_AIL_NULL_STR) == 0) {
- pkg = NULL;
- }
- /* get icon path */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_ICON_STR, uid, &icn);
- if (strcmp(icn, APP_CONF_AIL_NULL_STR) == 0) {
- icn = NULL;
- }
- else if (icn != NULL) {
- struct stat buff;
- /* file check */
- memset(&buff, 0, sizeof(buff));
- if (stat(icn, &buff) == 0) {
- if (S_ISDIR(buff.st_mode)) {
- /* is directory */
- ICO_DBG("%s is directory", icn);
- icn = NULL;
- }
- }
- else {
- /* is not exist */
- icn = NULL;
- }
- }
- /* get name */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_NAME_STR, uid, &nm);
- if (strcmp(nm, APP_CONF_AIL_NULL_STR) == 0) {
- nm = NULL;
- }
- /* get category */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_CATEGORIES_STR, uid, &ctgry);
- if (strcmp(ctgry, APP_CONF_AIL_NULL_STR) == 0) {
- ctgry = NULL;
- }
- /* get type */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_TYPE_STR, uid, &typ);
- if (strcmp(typ, APP_CONF_AIL_NULL_STR) == 0) {
- typ = NULL;
- }
- /* get exec */
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_EXEC_STR, uid, &exe);
- if (strcmp(exe, APP_CONF_AIL_NULL_STR) == 0) {
- exe = NULL;
- }
- ail_appinfo_get_bool(appinfo, AIL_PROP_NODISPLAY_BOOL, &bndsp);
- ICO_DBG("pkg:%s icn:%s nm:%s ctg:%s ty:%s exe:%s ds:%s", pkg? pkg:DNil,
- icn? icn:DNil, nm? nm:DNil, ctgry? ctgry:DNil, typ? typ:DNil,
- exe? exe:DNil, bndsp? "true":"false");
- if (false == x->addAIL(pkg, icn, nm, ctgry, typ, exe, bndsp)) {
- ICO_TRA("end bad end")
- return AIL_CB_RET_CANCEL;
- }
- ICO_TRA("end")
- return AIL_CB_RET_CONTINUE;
-}
-
-/**
- * @brief create information ail data
- * @retval true success
- * @retval false fail create
- */
-bool CicoSCLifeCycleController::createAilItems()
-{
- ICO_TRA("start");
- m_ail.clear(); // clear items
- if (NULL == m_gconf) {
- m_gconf = g_key_file_new();
- GString* gsfp = g_string_new("xx");
- CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
- g_string_printf(gsfp, "%s/%s", CSCSC->getDefaultConf()->confdir.c_str(),
- ICO_SYC_CONFIG_APPATTR);
- GError *gerr = NULL;
- int flg;
- flg = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
- if (!g_key_file_load_from_file(m_gconf, gsfp->str, (GKeyFileFlags)flg, &gerr)) {
- ICO_ERR("load error conf:%s %s", (char*)gsfp->str, gerr->message);
- g_key_file_free(m_gconf);
- m_gconf = NULL;
- g_string_free(gsfp, TRUE);
- return false;
- }
- g_string_free(gsfp, TRUE);
- }
- int r;
- uid_t uid = getuid();
- ail_filter_h fil;
- ail_filter_new(&fil);
- r = ail_filter_add_str(fil, AIL_PROP_TYPE_STR, DAilTypeFilPrm_Menu);
- r = ail_filter_list_usr_appinfo_foreach(fil, CSCLCCail_list_appinfo_cb,
- (void*)this, uid);
- ail_filter_destroy(fil);
- if (r != AIL_ERROR_OK) {
- if (m_gconf) {
- g_key_file_free(m_gconf);
- m_gconf = NULL;
- }
- ICO_TRA("end menu read NG(AIL)=%d", r);
- return false;
- }
-
- ail_filter_new(&fil);
- r = ail_filter_add_str(fil, AIL_PROP_TYPE_STR, DAilTypeFilPrm_App);
- r = ail_filter_list_usr_appinfo_foreach(fil, CSCLCCail_list_appinfo_cb,
- (void*)this, uid);
- ail_filter_destroy(fil);
- if (r != AIL_ERROR_OK) {
- if (m_gconf) {
- g_key_file_free(m_gconf);
- m_gconf = NULL;
- }
- ICO_TRA("end Application read NG(AIL)=%d", r);
- return false;
- }
- if (m_gconf) {
- g_key_file_free(m_gconf);
- m_gconf = NULL;
- }
- ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief ail information data add one item
- * @param sPkg string package (appid)
- * @param sIco string icon full path
- * @param sNm string name
- * @param sCtg string categoies
- * @param sTyp string type
- * @param sExe string exec name
- * @param bndsp bool nodisplay value
- * @return method status
- * @retval true success added item
- * @retval false fail added item
- */
-bool CicoSCLifeCycleController::addAIL(const char* sPkg, const char* sIco,
- const char* sNm, const char* sCtg,
- const char* sTyp, const char* sExe,
- bool bndsp)
-{
- ICO_TRA("start pkg(%s)", sPkg? sPkg: "(NULL)");
- string category;
- getCategory(sPkg, sNm, sCtg, category);
- CicoAilItems CSCAI(sPkg, sIco, sNm, sCtg, sTyp, sExe, category, bndsp);
- m_ail.push_back(CSCAI);
- ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief get category data
- * @param sPkg ail package(appid) (get key)
- * @param sNm ail name (get key)
- * @param sCtg ail categories (get key)
- * @param category read config file category string define
- */
-void CicoSCLifeCycleController::getCategory(const char* sPkg, const char* sNm,
- const char* sCtg,
- std::string& category)
-{
- ICO_TRA("start pkg(%s)", sPkg? sPkg: "(NULL)");
- category.clear();
- GError *gerr;
- char *appCtgry;
- int appCtgryType;
- char addCtgry[400];
- int addCtgryLen;
- char work[80];
-
- /* get default category of this application */
- addCtgry[0] = 0;
- gerr = NULL;
- appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, sPkg, &gerr);
- if (gerr == NULL) {
- appCtgryType = 0;
- }
- else {
- g_clear_error(&gerr);
- gerr = NULL;
- appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, sNm, &gerr);
- if (gerr == NULL) {
- appCtgryType = 1;
- }
- }
- addCtgryLen = 0;
- if (gerr != NULL) {
- g_clear_error(&gerr);
- }
- else {
- for (int i = 1;; i++) {
- strncpy(&addCtgry[addCtgryLen], appCtgry,
- sizeof(addCtgry)-addCtgryLen-2);
- addCtgry[sizeof(addCtgry)-2] = 0;
- addCtgryLen = strlen(addCtgry);
- if (addCtgryLen > 0) {
- if (addCtgry[addCtgryLen-1] != ';') {
- strcpy(&addCtgry[addCtgryLen++], ";");
- }
- }
- snprintf(work, sizeof(work)-1, "%s.%d",
- appCtgryType == 0 ? sPkg : sNm, i);
- gerr = NULL;
-
- if (NULL != appCtgry) {
- g_free(appCtgry);
- appCtgry = NULL;
- }
-
- appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, work, &gerr);
- if (gerr != NULL) {
- g_clear_error(&gerr);
- break;
- }
- }
- }
- if (NULL != appCtgry) {
- g_free(appCtgry);
- appCtgry = NULL;
- }
- g_clear_error(&gerr);
-
- /* get category */
- if (NULL != sCtg) {
- strncpy(&addCtgry[addCtgryLen], sCtg, sizeof(addCtgry)-addCtgryLen-1);
- addCtgry[sizeof(addCtgry)-1] = 0;
- }
- if (addCtgry[0]) {
- category.assign(addCtgry);
- ICO_DBG("category=%s", category.c_str());
- }
- ICO_TRA("end");
-}
-
-/**
- * @brief aul information data initialization
- */
-void CicoSCLifeCycleController::initAUL()
-{
- ICO_TRA("start");
- aul_listen_app_launch_signal_add(CSCLCCapp_launch_handler, (void*)this);
- aul_listen_app_dead_signal_add(CSCLCCapp_dead_handler, (void*)this);
- ICO_TRA("end");
-}
-
-/**
- * @brief
- */
-void CicoSCLifeCycleController::enterAUL(const char* appid, int pid,
- const CicoSCWindow* obj, int aulstt)
-{
- ICO_TRA("start");
- bool bPushBack = true;
- int sz = m_aul.size();
- for (int i = 0; i < sz; i++) {
- CicoAulItems* t = (CicoAulItems*) m_aul[i].p();
- t->update_appid();
- if (t->m_pid == pid) {
- bPushBack = false; // push_back flag off
- if (NULL == obj) {
- // Do not replace to NULL
- ICO_DBG("Do not replace to NULL %d", t->m_CSCWptrs.size());
- break; // break of for
- }
- else {
- ICO_DBG("add window info. %d, %x", t->m_CSCWptrs.size(), obj);
- t->enterWindow(obj);
- break; // break of for
- }
- }
- }
- if (true == bPushBack) { // push back flag on?
- // AUL list Unregistered
- ICO_DBG("push_back(AUL(%s, %d, %x))", appid, pid, obj);
- int ctgry = DINITm_categoryID;
- const CicoAilItems* ailObj = findAIL(appid);
- if ((NULL != ailObj) && (0 != ailObj)) {
- ctgry = ailObj->m_categoryID;
- }
- CicoAulItems entryAUL(appid, pid, ctgry, aulstt, obj);
- m_aul.push_back(entryAUL);
- if (-1 != entryAUL.m_cpucgroup) {
- m_RC->entryCgroupCPU(pid, entryAUL.m_cpucgroup);
- }
- m_RC->entryApp(appid, pid);
- }
- ICO_TRA("end");
-}
-
-/**
- * @brief application resource function is runnning
- * @ret bool runnning state
- * @retval true application resource runnning
- * @retval true application resource stopping
- */
-bool CicoSCLifeCycleController::isAppResource() const
-{
- if (NULL == m_RC) {
- return false;
- }
- return m_RC->isAppResource();
-}
-
-/**
- * @brief
- * @param anem user login name
- */
-bool CicoSCLifeCycleController::startAppResource(const string& name)
-{
- ICO_TRA("start");
- if (NULL == m_RC) {
- ICO_TRA("end");
- return false;
- }
- bool bR = m_RC->startAppResource(name);
- ICO_TRA("end %s", bR? "true": "false");
- return bR;
-}
-
-/**
- * @brief
- * @param anem user login name
- */
-void CicoSCLifeCycleController::createAppResourceFile(const string& user)
-{
- ICO_TRA("start");
- if (NULL == m_RC) {
- ICO_TRA("end");
- return;
- }
- if (false == m_RC->isAppResource()) {
- ICO_TRA("end");
- return;
- }
- string file;
- m_RC->getAppResourceFilePath(user, file);
- struct stat buff;
- /* file check */
- memset(&buff, 0, sizeof(buff));
- if (0 != stat(file.c_str(), &buff)) {
- m_RC->createAppResourceFile(file);
- }
- ICO_TRA("end");
-}
-
-/**
- * @brief
- */
-bool CicoSCLifeCycleController::removeAUL(int pid)
-{
- ICO_TRA("start %d", pid);
- bool r = false;
- vector<CicoAulItems>::iterator it;
- for(it = m_aul.begin(); it != m_aul.end(); ++it) {
- if (pid == it->m_pid) {
- ICO_DBG("erase appid=%s", it->m_appid.c_str());
- m_aul.erase(it);
- r = true;
- break;
- }
- }
- ICO_TRA("end %s", r? "true":"false");
- return r;
-}
-
-/**
- * @brief
- * @param x CicoSCLifeCycleController class pointer
- */
-int CSCLCCapp_launch_handlerX(int pid, CicoSCLifeCycleController* x)
-{
- ICO_TRA("start %d, %x", pid, x);
- if ((NULL == x) || (0 == x)) {
- ICO_TRA("end user data is NULL");
- return -1;
- }
- char appid[255];
- memset(appid, 0, sizeof(appid));
- int iR = Xaul_app_get_appid_bypid(pid, appid, sizeof(appid)); // pid to appid
- ICO_PRF("CHG_APP_STA notice app=%s, pid=%d, rval=%d", appid, pid, iR);
- x->enterAUL(appid, pid, NULL, iR);
- ICO_TRA("end %s %d", appid, pid);
- return 0;
-}
-
-
-/**
- * @brief applications die. callback function
- * @param pid
- * @param data user data
- * @param x CicoSCLifeCycleController class pointer
- */
-int CSCLCCapp_dead_handlerX(int pid, CicoSCLifeCycleController* x)
-{
- ICO_TRA("start %d, %x", pid, x);
- if ((NULL == x) || (0 == x)) {
- ICO_TRA("end user data is NULL");
- return -1;
- }
- if (false == x->removeAUL(pid)) {
- ICO_TRA("end dead %d fail", pid);
- return -1;
- }
- ICO_TRA("end dead %d success", pid);
- return 0;
-}
-
-/**
- * @brief AUL infomaton list
- * @return AUL information item list Container
- */
-const std::vector<CicoAulItems>& CicoSCLifeCycleController::getAulList()
-{
- int sz = m_aul.size();
- for (int i = 0; i < sz; i++) {
- CicoAulItems* t = (CicoAulItems*)m_aul[i].p();
- t->update_appid();
- }
- return m_aul;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-#ifndef CICOSCLIFECYCLECONTROLLER_H
-#define CICOSCLIFECYCLECONTROLLER_H
-#include <glib.h>
-#include <vector>
-#include <map>
-#include <ail.h>
-#include <aul/aul.h>
-#include <package-manager.h>
-
-#include "CicoAilItems.h"
-#include "CicoAulItems.h"
-
-
-#ifndef __CICO_SC_WINDOW_H__
-class CicoSCWindow;
-#endif
-
-#if 0
-#ifndef CICOSCSYSRESOURCECONTROLLER_H
-class CicoSCSysResourceController;
-#endif
-#else
-#ifndef CICOSCAPPRESOURCECONTROLLER_H
-class CicoSCAppResourceController;
-#endif
-#endif
-
-class CicoSCLifeCycleController {
-public:
- CicoSCLifeCycleController();
- ~CicoSCLifeCycleController();
-
- static CicoSCLifeCycleController* getInstance(void);
-
- // Starting application
- int launch(const char* appid, bundle* b = NULL);
- int launch(const std::string& appid, bundle* b = NULL);
- // Stopping application
- int terminate(const char* appid);
- int terminate(const std::string& appid);
- int terminate(int pid);
- // suspend application
- int suspend(const char* appid);
- int suspend(const std::string& appid);
- int suspend(int pid);
- // run application check
- bool isRunning(const char* appid);
- bool isRunning(const std::string& appid);
-
- const std::vector<CicoAilItems>& getAilList() const;
- const CicoAilItems* findAIL(const char* appid) const;
- const CicoAilItems* findAIL(const std::string& appid) const;
- bool isAilRenew() const;
- void ailRenewFlagOff();
-
- const std::vector<CicoAulItems>& getAulList();
-// TODO mk_k Should I think about the multiple return values start
-/*
- const CicoAulItems* findAUL(const char* appid) const;
- const CicoAulItems* findAUL(const std::string& appid) const;
-*/
- const CicoAulItems* findAUL(int pid);
- bool getPIDs(const char* appid, std::vector<int>& pids) const;
- bool getPIDs(std::string& appid, std::vector<int>& pids) const;
- void enterAUL(const char* appid, int pid, const CicoSCWindow* obj = NULL,
- int aulstt = AUL_R_OK);
-
- bool isAppResource() const;
- bool startAppResource(const std::string& name);
- void createAppResourceFile(const std::string& user);
-protected:
- void initAIL();
- friend ail_cb_ret_e CSCLCCail_list_appinfo_cbX(const ail_appinfo_h appinfo,
- CicoSCLifeCycleController* x, uid_t uid);
- bool createAilItems();
-
- friend
- int CSCLCCpkgmgr_handlerX(int req_id, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val, const void *pmsg,
- CicoSCLifeCycleController *x);
- void renewAIL();
- void ailRenewFlagOn();
- void initAUL();
- friend int CSCLCCapp_launch_handlerX(int pid,
- CicoSCLifeCycleController *x);
- friend int CSCLCCapp_dead_handlerX(int pid, CicoSCLifeCycleController *x);
-
- int terminateR(int pid);
- void getCategory(const char* sPkg, const char* sNm, const char* sCtg,
- std::string& category);
- bool addAIL(const char* sPkg, const char* sIco, const char* sNm,
- const char* sCtg, const char* sTyp, const char* sExe,
- bool bndsp);
- bool removeAUL(int pid);
-private:
- static CicoSCLifeCycleController* ms_myInstance;
-
-protected:
- std::vector<CicoAilItems> m_ail;
- std::vector<CicoAulItems> m_aul;
- GKeyFile* m_gconf;
- pkgmgr_client* m_pc;
-#if 0
- CicoSCSysResourceController* m_RC;
-#else
- CicoSCAppResourceController* m_RC;
-#endif
- bool m_ailRenew;
-};
-
-/**
- * @brief AIL infomaton list
- * @return AIL information item list Container
- */
-inline
-const std::vector<CicoAilItems>& CicoSCLifeCycleController::getAilList() const
-{
- return m_ail;
-}
-
-
-/**
- * @brief AIL change flag is on?
- * @ret bool
- * @retval true change flag on
- * @retval false change flag off
- */
-inline bool CicoSCLifeCycleController::isAilRenew() const
-{
- return m_ailRenew;
-}
-
-/**
- * @brief AIL change flag off set
- */
-inline void CicoSCLifeCycleController::ailRenewFlagOff()
-{
- m_ailRenew = false;
-}
-
-/**
- * @brief AIL change flag on set
- */
-inline void CicoSCLifeCycleController::ailRenewFlagOn()
-{
- m_ailRenew = true;
-}
-
-#endif // CICOSCLIFECYCLECONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCMessage.cpp
- *
- * @brief This file implementation of CicoSCMessage class
- */
-//==========================================================================
-
-#include <string>
-#include <limits.h>
-
-#include "CicoSCMessage.h"
-#include "CicoLog.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-unsigned int CicoSCMessage::ms_counter = 0;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCMessage::CicoSCMessage()
-{
- if (ms_counter == UINT_MAX) {
- ms_counter = 0;
- }
- m_id = ++ms_counter;
- m_generator = json_generator_new();
- m_root = json_node_new(JSON_NODE_OBJECT);
- m_rootObj = json_object_new();
- m_argObj = json_object_new();
- m_array = json_array_new();
- m_data.clear();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCMessage::~CicoSCMessage()
-{
- //ICO_TRA("CicoSCMessage::~CicoSCMessage Enter");
- json_array_unref(m_array);
- json_object_unref(m_rootObj);
- json_object_unref(m_argObj);
- json_node_free(m_root);
- g_object_unref(m_generator);
- //ICO_TRA("CicoSCMessage::~CicoSCMessage Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get message id
- *
- * @return id of message
- */
-//--------------------------------------------------------------------------
-unsigned int
-CicoSCMessage::getId(void)
-{
- return m_id;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add root object for char pointer type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for char pointer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addRootObject(const char * key, const char * value)
-{
-// ICO_DBG("json_object_set_string_member(%s, %s) called.", key, value);
- json_object_set_string_member(m_rootObj, key, value);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add root object for string type
- *
- * @param [in] key keyname of object
- * @param [in] value value of object for string type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addRootObject(const char * key, const std::string & value)
-{
-// ICO_DBG("json_object_set_string_member(%s, %s) called.", key, value.c_str());
- json_object_set_string_member(m_rootObj, key, value.c_str());
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add root object for integer type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for integer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addRootObject(const char * key, int value)
-{
-// ICO_DBG("json_object_set_int_member(%s, %d) called.", key, value);
- json_object_set_int_member(m_rootObj, key, value);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add argument object for char pointer type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for char pointer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addArgObject(const char * key, const char * value)
-{
-// ICO_DBG("json_object_set_string_member(%s, %s) called.", key, value);
- json_object_set_string_member(m_argObj, key, value);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add argument object for string type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for string type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addArgObject(const char * key, const std::string & value)
-{
-// ICO_DBG("json_object_set_string_member(%s, %s) called.", key, value.c_str());
- json_object_set_string_member(m_argObj, key, value.c_str());
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add argument object for integer type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for integer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addArgObject(const char * key, int value)
-{
-// ICO_DBG("json_object_set_int_member(%s, %d) called.", key, value);
- json_object_set_int_member(m_argObj, key, value);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add argument object for array type
- *
- * @param [in] key key name of array
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addArgObject(const char * key)
-{
- // count up reference
- json_array_ref(m_array);
-
-// ICO_DBG("json_object_set_array_member(%s) called.", key);
- json_object_set_array_member(m_argObj, key, m_array);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add array element for char pointer type
- *
- * @param [in] value value of object for char pointer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addElmArray(const char * value)
-{
-// ICO_DBG("json_array_add_string_element(%s) called.", value);
- json_array_add_string_element(m_array, value);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add array element for string type
- *
- * @param [in] value value of object for string type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::addElmArray(const std::string & value)
-{
-// ICO_DBG("json_array_add_string_element(%s) called.", value.c_str());
- json_array_add_string_element(m_array, value.c_str());
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get destination handle
- *
- * @return pointer of destination handle
- */
-//--------------------------------------------------------------------------
-CicoSCUwsHandle*
-CicoSCMessage::getHandle(void)
-{
- return m_uwsHandle;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set destination handle
- *
- * @param [in] handle destination handle
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::setHandle(CicoSCUwsHandle* handle)
-{
- m_uwsHandle = handle;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get message data
- *
- * @return pointer of message data
- */
-//--------------------------------------------------------------------------
-const char*
-CicoSCMessage::getData(void)
-{
- // count up reference
- json_object_ref(m_rootObj);
- json_object_ref(m_argObj);
-
- json_object_set_object_member(m_rootObj, "arg", m_argObj);
- json_node_take_object(m_root, m_rootObj);
- json_generator_set_root(m_generator, m_root);
- gsize len = 0;
- gchar* data = json_generator_to_data(m_generator, &len);
- m_data = data;
- g_free(data);
- return m_data.c_str();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get application id of destination
- *
- * @return application id
- */
-//--------------------------------------------------------------------------
-const std::string &
-CicoSCMessage::getSendToAppid(void)
-{
- return m_toAppid;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set application id of destination
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessage::setSendToAppid(const std::string & appid)
-{
- m_toAppid = appid;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCMessage.h
- *
- * @brief This file is definition of CicoSCMessage class
- */
-//==========================================================================
-#ifndef __CICO_SC_MESSAGE_H__
-#define __CICO_SC_MESSAGE_H__
-
-#include <string>
-
-#include <json-glib/json-glib.h>
-
-//==========================================================================
-// forward declaration
-//==========================================================================
-class CicoSCUwsHandle;
-
-//==========================================================================
-/**
- * @brief This class hold communication message
- */
-//==========================================================================
-class CicoSCMessage
-{
-public:
- // default constructor
- CicoSCMessage();
-
- // destructor
- virtual ~CicoSCMessage();
-
- // get message id
- unsigned int getId(void);
-
- // add root object for char pointer type
- void addRootObject(const char * key, const char * value);
-
- // add root object for string type
- void addRootObject(const char * key, const std::string & value);
-
- // add root object for integer type
- void addRootObject(const char * key, int value);
-
- // add argument object for char pointer type
- void addArgObject(const char * key, const char * value);
-
- // add argument object for string type
- void addArgObject(const char * key, const std::string & value);
-
- // add argument object for integer type
- void addArgObject(const char * key, int value);
-
- // add argument object for array type
- void addArgObject(const char * key);
-
- // add element to array for char pointer type
- void addElmArray(const char * value);
-
- // add element to array for string type
- void addElmArray(const std::string & value);
-
- // get destination handle
- CicoSCUwsHandle* getHandle(void);
-
- // set destination handle
- void setHandle(CicoSCUwsHandle* handle);
-
- // get message data
- virtual const char* getData(void);
-
- // set application id of destination
- void setSendToAppid(const std::string & appid);
-
- // get application id of destination
- const std::string & getSendToAppid(void);
-
-private:
- // assignment operator
- CicoSCMessage& operator=(const CicoSCMessage &object);
-
- // copy constructor
- CicoSCMessage(const CicoSCMessage &object);
-
-protected:
- static unsigned int ms_counter; //!< message id counter
- int m_id; //!< message id
- CicoSCUwsHandle *m_uwsHandle; //!< communication handler
- JsonGenerator *m_generator; //!< json generator
- JsonNode *m_root; //!< json root node
- JsonObject *m_rootObj; //!< json root objects
- JsonObject *m_argObj; //!< json arg objects
- JsonArray *m_array; //!< json array
- std::string m_toAppid; //!< send to appid
- std::string m_data; //!< json format data
-};
-#endif // __CICO_SC_MESSAGE_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCMessageRes.cpp
- *
- * @brief This file implementation of CicoSCMessage class
- */
-//==========================================================================
-
-#include <string>
-#include <limits.h>
-
-#include "CicoSCMessage.h"
-#include "CicoSCMessageRes.h"
-#include "CicoLog.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCMessageRes::CicoSCMessageRes()
-{
- m_winObj = json_object_new();
- m_sndObj = json_object_new();
- m_inpObj = json_object_new();
- m_winCnt = 0;
- m_sndCnt = 0;
- m_inpCnt = 0;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCMessageRes::~CicoSCMessageRes()
-{
- //ICO_TRA("Enter");
- json_object_unref(m_winObj);
- json_object_unref(m_sndObj);
- json_object_unref(m_inpObj);
- //ICO_TRA("Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add argument object for char pointer type
- *
- * @param [in] key key name of object
- * @param [in] value value of object for char pointer type
- */
-//--------------------------------------------------------------------------
-void
-CicoSCMessageRes::addWinObject(const char * key, const char * value)
-{
- json_object_set_string_member(m_winObj, key, value);
- m_winCnt++;
-}
-
-void
-CicoSCMessageRes::addSndObject(const char * key, const char * value)
-{
- json_object_set_string_member(m_sndObj, key, value);
- m_sndCnt++;
-}
-
-void
-CicoSCMessageRes::addInpObject(const char * key, const char * value)
-{
- json_object_set_string_member(m_inpObj, key, value);
- m_inpCnt++;
-}
-
-void
-CicoSCMessageRes::addWinObject(const char * key, const std::string & value)
-{
- json_object_set_string_member(m_winObj, key, value.c_str());
- m_winCnt++;
-}
-
-void
-CicoSCMessageRes::addSndObject(const char * key, const std::string & value)
-{
- json_object_set_string_member(m_sndObj, key, value.c_str());
- m_sndCnt++;
-}
-
-void
-CicoSCMessageRes::addInpObject(const char * key, const std::string & value)
-{
- json_object_set_string_member(m_inpObj, key, value.c_str());
- m_inpCnt++;
-}
-
-void
-CicoSCMessageRes::addWinObject(const char * key, int value)
-{
- json_object_set_int_member(m_winObj, key, value);
- m_winCnt++;
-}
-
-void
-CicoSCMessageRes::addSndObject(const char * key, int value)
-{
- json_object_set_int_member(m_sndObj, key, value);
- m_sndCnt++;
-}
-
-void
-CicoSCMessageRes::addInpObject(const char * key, int value)
-{
- json_object_set_int_member(m_inpObj, key, value);
- m_inpCnt++;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get message data
- *
- * @return pointer of message data
- */
-//--------------------------------------------------------------------------
-const char*
-CicoSCMessageRes::getData(void)
-{
- // count up reference
- json_object_ref(m_rootObj);
- json_object_ref(m_argObj);
- json_object_ref(m_winObj);
- json_object_ref(m_sndObj);
- json_object_ref(m_inpObj);
-
- if (0 != m_winCnt) {
- json_object_set_object_member(m_argObj, "window", m_winObj);
- }
- if (0 != m_sndCnt) {
- json_object_set_object_member(m_argObj, "sound", m_sndObj);
- }
- if (0 != m_inpCnt) {
- json_object_set_object_member(m_argObj, "input", m_inpObj);
- }
-
- json_object_set_object_member(m_rootObj, "res", m_argObj);
- json_node_take_object(m_root, m_rootObj);
- json_generator_set_root(m_generator, m_root);
- gsize len = 0;
- gchar* data = json_generator_to_data(m_generator, &len);
- m_data = data;
- g_free(data);
- return m_data.c_str();
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCMessageRes.h
- *
- * @brief This file is definition of CicoSCMessage class
- */
-//==========================================================================
-#ifndef __CICO_SC_MESSAGE_RES_H__
-#define __CICO_SC_MESSAGE_RES_H__
-
-#include <string>
-
-#include <json-glib/json-glib.h>
-#include "CicoSCMessage.h"
-
-//==========================================================================
-// forward declaration
-//==========================================================================
-
-//==========================================================================
-/**
- * @brief This class hold communication message
- */
-//==========================================================================
-class CicoSCMessageRes :public CicoSCMessage
-{
-public:
- // default constructor
- CicoSCMessageRes();
-
- // destructor
- ~CicoSCMessageRes();
-
- // add argument object for char pointer type
- void addWinObject(const char * key, const char * value);
-
- // add argument object for string type
- void addWinObject(const char * key, const std::string & value);
-
- // add argument object for integer type
- void addWinObject(const char * key, int value);
-
- // add argument object for char pointer type
- void addSndObject(const char * key, const char * value);
-
- // add argument object for string type
- void addSndObject(const char * key, const std::string & value);
-
- // add argument object for integer type
- void addSndObject(const char * key, int value);
-
- // add argument object for char pointer type
- void addInpObject(const char * key, const char * value);
-
- // add argument object for string type
- void addInpObject(const char * key, const std::string & value);
-
- // add argument object for integer type
- void addInpObject(const char * key, int value);
-
- // get message data
- virtual const char* getData(void);
-
-private:
-
-private:
- JsonObject *m_winObj; //!< json window objects
- JsonObject *m_sndObj; //!< json sound objects
- JsonObject *m_inpObj; //!< json input objects
- int m_winCnt;
- int m_sndCnt;
- int m_inpCnt;
-};
-#endif // __CICO_SC_MESSAGE_RES_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCPolicyDef.h
- *
- * @brief This file is definition of StateMachine state and event for policy
- */
-//==========================================================================
-#ifndef __CICO_SC_POLICY_DEF_H__
-#define __CICO_SC_POLICY_DEF_H__
-
-// running state id
-#define STID_DRIVING 1000
-#define STID_DRIVING_STOPPING 1001
-#define STID_DRIVING_RUNNING 1002
-
-// shift position state
-#define STID_SHIFTPOS_PARKING 2001
-#define STID_SHIFTPOS_REVERSE 2002
-#define STID_SHIFTPOS_OTHER 2003
-
-// winker state id
-#define STID_WINKER_OFF 3001
-#define STID_WINKER_RIGHT 3002
-#define STID_WINKER_LEFT 3003
-
-// camera state id
-#define STID_CAMERA 4000
-#define STID_CAMERA_OFF 4001
-#define STID_CAMERA_BACK 4002
-#define STID_CAMERA_RIGHT 4003
-#define STID_CAMERA_LEFT 4004
-
-// winker state id
-#define STID_NIGHTMODE 5000
-#define STID_NIGHTMODE_OFF 5001
-#define STID_NIGHTMODE_ON 5002
-
-// driving regulation state id
-#define STID_DRVREGULATION 9000
-#define STID_DRVREGULATION_OFF 9001
-#define STID_DRVREGULATION_ON 9002
-
-// display0 zone state id
-#define STID_DISPLAY0_ZONE 10000
-#define STID_DISPLAY0_ZONE1 10001
-#define STID_DISPLAY0_ZONE2 10002
-#define STID_DISPLAY0_ZONE3 10003
-#define STID_DISPLAY0_ZONE4 10004
-#define STID_DISPLAY0_ZONE5 10005
-#define STID_DISPLAY0_ZONE6 10006
-#define STID_DISPLAY0_ZONE7 10007
-#define STID_DISPLAY0_ZONE8 10008
-#define STID_DISPLAY0_ZONE9 10009
-#define STID_DISPLAY0_ZONE10 10010
-#define STID_DISPLAY0_ZONE11 10011
-#define STID_DISPLAY0_ZONE12 10012
-#define STID_DISPLAY0_ZONE13 10013
-#define STID_DISPLAY0_ZONE14 10014
-#define STID_DISPLAY0_ZONE15 10015
-#define STID_DISPLAY0_ZONE16 10016
-#define STID_DISPLAY0_ZONE17 10017
-#define STID_DISPLAY0_ZONE18 10018
-#define STID_DISPLAY0_ZONE19 10019
-#define STID_DISPLAY0_ZONE20 10020
-#define STID_DISPLAY0_NOOWER 10999
-
-// display1 zone state id
-#define STID_DISPLAY1_ZONE 11000
-#define STID_DISPLAY1_ZONE1 11001
-#define STID_DISPLAY1_ZONE2 11002
-#define STID_DISPLAY1_ZONE3 11003
-#define STID_DISPLAY1_ZONE4 11004
-#define STID_DISPLAY1_ZONE5 11005
-#define STID_DISPLAY1_ZONE6 11006
-#define STID_DISPLAY1_ZONE7 11007
-#define STID_DISPLAY1_ZONE8 11008
-#define STID_DISPLAY1_ZONE9 11009
-#define STID_DISPLAY1_ZONE10 11010
-#define STID_DISPLAY1_ZONE11 11011
-#define STID_DISPLAY1_ZONE12 11012
-#define STID_DISPLAY1_ZONE13 11013
-#define STID_DISPLAY1_ZONE14 11014
-#define STID_DISPLAY1_ZONE15 11015
-#define STID_DISPLAY1_ZONE16 11016
-#define STID_DISPLAY1_ZONE17 11017
-#define STID_DISPLAY1_ZONE18 11018
-#define STID_DISPLAY1_ZONE19 11019
-#define STID_DISPLAY1_ZONE20 11020
-#define STID_DISPLAY1_NOOWER 11999
-
-// display0 category state id
-#define STID_DISPLAY0_CATEGORY 12000
-#define STID_DISPLAY0_CATEGORY1 12001
-#define STID_DISPLAY0_CATEGORY2 12002
-#define STID_DISPLAY0_CATEGORY3 12003
-#define STID_DISPLAY0_CATEGORY4 12004
-#define STID_DISPLAY0_CATEGORY5 12005
-#define STID_DISPLAY0_CATEGORY6 12006
-#define STID_DISPLAY0_CATEGORY7 12007
-#define STID_DISPLAY0_CATEGORY8 12008
-#define STID_DISPLAY0_CATEGORY9 12009
-#define STID_DISPLAY0_CATEGORY10 12010
-#define STID_DISPLAY0_CATEGORY11 12011
-#if 1
-#define STID_DISP0_ZONE2_CATEGORY 12100
-#define STID_DISP0_ZONE2_CATEGORY1 12101
-#define STID_DISP0_ZONE2_CATEGORY2 12102
-#define STID_DISP0_ZONE2_CATEGORY3 12103
-#define STID_DISP0_ZONE2_CATEGORY4 12104
-#define STID_DISP0_ZONE2_CATEGORY5 12105
-#define STID_DISP0_ZONE2_CATEGORY6 12106
-#define STID_DISP0_ZONE2_CATEGORY7 12107
-#define STID_DISP0_ZONE2_CATEGORY8 12108
-#define STID_DISP0_ZONE2_CATEGORY9 12109
-#define STID_DISP0_ZONE2_CATEGORY10 12110
-#define STID_DISP0_ZONE2_CATEGORY11 12111
-#define STID_DISP0_ZONE3_CATEGORY 12200
-#define STID_DISP0_ZONE3_CATEGORY1 12201
-#define STID_DISP0_ZONE3_CATEGORY2 12202
-#define STID_DISP0_ZONE3_CATEGORY3 12203
-#define STID_DISP0_ZONE3_CATEGORY4 12204
-#define STID_DISP0_ZONE3_CATEGORY5 12205
-#define STID_DISP0_ZONE3_CATEGORY6 12206
-#define STID_DISP0_ZONE3_CATEGORY7 12207
-#define STID_DISP0_ZONE3_CATEGORY8 12208
-#define STID_DISP0_ZONE3_CATEGORY9 12209
-#define STID_DISP0_ZONE3_CATEGORY10 12210
-#define STID_DISP0_ZONE3_CATEGORY11 12211
-#endif
-
-// display1 category state id
-#define STID_DISPLAY1_CATEGORY 13000
-#define STID_DISPLAY1_CATEGORY1 13001
-#define STID_DISPLAY1_CATEGORY2 13002
-#define STID_DISPLAY1_CATEGORY3 13003
-#define STID_DISPLAY1_CATEGORY4 13004
-#define STID_DISPLAY1_CATEGORY5 13005
-#define STID_DISPLAY1_CATEGORY6 13006
-#define STID_DISPLAY1_CATEGORY7 13007
-#define STID_DISPLAY1_CATEGORY8 13008
-#define STID_DISPLAY1_CATEGORY9 13009
-#define STID_DISPLAY1_CATEGORY10 13010
-#define STID_DISPLAY1_CATEGORY11 13011
-
-// onscreen state id
-#define STID_ONSCREEN 14000
-#define STID_ONSCREEN_WARNING 14001
-#define STID_ONSCREEN_ATTENTION 14002
-#define STID_ONSCREEN_MESSAGE 14003
-
-// interrput display0 zone1 state id
-#define STID_INTTERPUT_D0_Z1 15000
-#define STID_INTTERPUT_D0_Z1_PRI1 15001
-#define STID_INTTERPUT_D0_Z1_PRI2 15002
-#define STID_INTTERPUT_D0_Z1_PRI3 15003
-#define STID_INTTERPUT_D0_Z1_INVISIBLE 15999
-
-// interrput display0 zone2 state id
-#define STID_INTTERPUT_D0_Z2 16000
-#define STID_INTTERPUT_D0_Z2_PRI1 16001
-#define STID_INTTERPUT_D0_Z2_PRI2 16002
-#define STID_INTTERPUT_D0_Z2_PRI3 16003
-#define STID_INTTERPUT_D0_Z2_INVISIBLE 16999
-
-// interrput display0 zone3 state id
-#define STID_INTTERPUT_D0_Z3 17000
-#define STID_INTTERPUT_D0_Z3_PRI1 17001
-#define STID_INTTERPUT_D0_Z3_PRI2 17002
-#define STID_INTTERPUT_D0_Z3_PRI3 17003
-#define STID_INTTERPUT_D0_Z3_INVISIBLE 17999
-
-// sound zone state id
-#define STID_SOUND_ZONE 20000
-#define STID_SOUND_ZONE1 20001
-#define STID_SOUND_ZONE2 20002
-#define STID_SOUND_ZONE3 20003
-
-// display0 category state id
-#define STID_SOUND_CATEGORY 22000
-#define STID_SOUND_CATEGORY1 22001
-#define STID_SOUND_CATEGORY2 22002
-#define STID_SOUND_CATEGORY3 22003
-#define STID_SOUND_CATEGORY4 22004
-#define STID_SOUND_CATEGORY5 22005
-#define STID_SOUND_CATEGORY6 22006
-#define STID_SOUND_CATEGORY7 22007
-#define STID_SOUND_CATEGORY8 22008
-#define STID_SOUND_CATEGORY9 22009
-#define STID_SOUND_CATEGORY10 22010
-#define STID_SOUND_CATEGORY11 22011
-
-// interrupt display0 zone1 state id
-#define STID_INTTERPUT_S_Z1 25000
-#define STID_INTTERPUT_S_Z1_PRI1 25001
-#define STID_INTTERPUT_S_Z1_PRI2 25002
-#define STID_INTTERPUT_S_Z1_PRI3 25003
-#define STID_INTTERPUT_S_Z1_INVISIBLE 25999
-
-// interrupt display0 zone2 state id
-#define STID_INTTERPUT_S_Z2 26000
-#define STID_INTTERPUT_S_Z2_PRI1 26001
-#define STID_INTTERPUT_S_Z2_PRI2 26002
-#define STID_INTTERPUT_S_Z2_PRI3 26003
-#define STID_INTTERPUT_S_Z2_INVISIBLE 26999
-
-// interrupt display0 zone3 state id
-#define STID_INTTERPUT_S_Z3 27000
-#define STID_INTTERPUT_S_Z3_PRI1 27001
-#define STID_INTTERPUT_S_Z3_PRI2 27002
-#define STID_INTTERPUT_S_Z3_PRI3 27003
-#define STID_INTTERPUT_S_Z3_INVISIBLE 27999
-
-// steering switch state id
-#define STID_INPUT1_NOTUSING 30001
-#define STID_INPUT1_USING 30002
-#define STID_INPUT2_NOTUSING 30101
-#define STID_INPUT2_USING 30102
-
-// event id
-#define EVID_VELOCTY 1000
-#define EVID_SHIFTPOS 2000
-#define EVID_TURN_OFF 3000
-#define EVID_TURN_LEFT 3001
-#define EVID_TURN_RIGHT 3002
-#define EVID_CAMERA 4000
-#define EVID_NIGHTMODE 5000
-#define EVID_DRVREGULATION 9000
-
-#define EVID_DISPLAY_ZONE_ACQUIRE 10000
-#define EVID_DISPLAY_ZONE_RELEASE 10999
-
-#if 1
-#define ZONEID_CENTER_FULL 1
-#define ZONEID_CENTER_UPPER 2
-#define ZONEID_CENTER_LOWER 3
-#endif
-
-
-#define EVID_DISPLAY0_CATEGORY 12000
-#if 1
-#define EVID_DISP0_ZONE2_CATEGORY 12100
-#define EVID_DISP0_ZONE3_CATEGORY 12200
-#endif
-#define EVID_DISPLAY1_CATEGORY 13000
-
-#define EVID_ONSCREEN 14000
-
-#define EVID_INTTERPUT_D0_Z1 15000
-#define EVID_INTTERPUT_D0_Z2 16000
-#define EVID_INTTERPUT_D0_Z3 17000
-
-#define EVID_SOUND_ZONE 20000
-#define EVID_SOUND_ZONE_NOUSE 20999
-
-#define EVID_SOUND_CATEGORY 22000
-#define EVID_SOUND_CATEGORY_UNKNOWN 22999
-
-#define EVID_INTTERPUT_S_Z1 25000
-#define EVID_INTTERPUT_S_Z1_NOOUTPUT 25999
-#define EVID_INTTERPUT_S_Z2 26000
-#define EVID_INTTERPUT_S_Z2_NOOUTPUT 26999
-#define EVID_INTTERPUT_S_Z3 27000
-#define EVID_INTTERPUT_S_Z3_NOOUTPUT 27999
-
-#define EVID_INPUT1_ACQUIRE 30000
-#define EVID_INPUT1_RELEASE 30001
-
-#define EVID_INPUT2_ACQUIRE 30100
-#define EVID_INPUT2_RELEASE 30101
-
-#endif // __CICO_SC_POLICY_DEF_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCPolicyManager.cpp
- *
- * @brief This file implementation of CicoSCPolicyManager class
- */
-//==========================================================================
-
-#include <string>
-
-#include <Ecore.h>
-
-#include "CicoSCPolicyManager.h"
-#include "CicoStateMachine.h"
-#include "CicoState.h"
-#include "CicoHistoryState.h"
-#include "CicoStateMachineCreator.h"
-#include "CicoSCPolicyDef.h"
-#include "CicoSCResourceManager.h"
-#include "CicoLog.h"
-#include "ico_syc_error.h"
-#include "CicoSCServer.h"
-#include "CicoSCMessage.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "ico_syc_type.h"
-#include "CicoCommonDef.h"
-#include "CicoSCVInfoManager.h"
-#include "CicoSCVInfo.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCPolicyManager::CicoSCPolicyManager(CicoSCResourceManager* resourceMgr)
- : m_initialized(false),
- m_ecoreEvHandler(NULL),
- m_stateMachine(NULL),
- m_resourceMgr(resourceMgr)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCPolicyManager::~CicoSCPolicyManager()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize policy manager
- */
-//--------------------------------------------------------------------------
-int
-CicoSCPolicyManager::initialize(void)
-{
- ICO_TRA("CicoSCPolicyManager::initialize Enter");
-
- int ret = initStateMachine();
- if (ICO_SYC_EOK != ret) {
- return ret;
- }
-
- CicoSCVInfoManager* vinfomgr = CicoSCVInfoManager::getInstance();
- m_ecoreEvHandler = ecore_event_handler_add(
- vinfomgr->getEcoreEvType(),
- CicoSCPolicyManager::changedVehicleInfoCB,
- this);
-
- vinfomgr->getVehicleInfo(ICO_VINFO_NIGHT_MODE);
- vinfomgr->getVehicleInfo(ICO_VINFO_DRIVING_MODE);
-
- ICO_TRA("CicoSCPolicyManager::initialize Leave");
- return ret;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief terminate policy manager
- */
-//--------------------------------------------------------------------------
-void
-CicoSCPolicyManager::terminate(void)
-{
- ICO_TRA("CicoSCPolicyManager::terminate Enter");
- ICO_TRA("CicoSCPolicyManager::terminate Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief
- */
-//--------------------------------------------------------------------------
-void
-CicoSCPolicyManager::onChangedVehicleInfo(int type, void *event)
-{
- ICO_TRA("CicoSCPolicyManager::onChangedVehicleInfo Enter");
-
- if (NULL == event) {
- ICO_WRN("data is null");
- return;
- }
-
- if (CicoSCVInfoManager::getInstance()->getEcoreEvType() != type) {
- ICO_WRN("unknown ecore event type(%d)", type);
- return;
- }
-
- bool chgCamera = false;
- bool chgRegulation = false;
- bool chgNightMode = false;
-
- CicoSCVInfo* vinfo = static_cast<CicoSCVInfo*>(event);
- switch (vinfo->getProperty()) {
- case ICO_VINFO_VEHICLE_SPEED:
- ICO_DBG("ICO_VINFO_VEHICLE_SPEED : %d", vinfo->getInt32Value());
-// (void)sendSMEvent(EVID_VELOCTY, (int)vinfo->getInt32Value());
-// if (true == sendSMEvent(EVID_DRVREGULATION)) {
-// chgRegulation = true;
-// }
- break;
- case ICO_VINFO_SHIFT_POSITION:
- ICO_DBG("ICO_VINFO_SHIFT_POSITION : %d", vinfo->getUint8Value());
- (void)sendSMEvent(EVID_SHIFTPOS, (int)vinfo->getUint8Value());
- if (true == sendSMEvent(EVID_CAMERA)) {
- chgCamera = true;
- }
- break;
- case ICO_VINFO_LIGHT_LEFT:
- ICO_DBG("ICO_VINFO_LIGHT_LEFT : %s",
- vinfo->getBooleanValue() ? "true" : "false");
- if (false == vinfo->getBooleanValue()) {
- (void)sendSMEvent(EVID_TURN_OFF);
- }
- else {
- (void)sendSMEvent(EVID_TURN_LEFT);
- }
- if (true == sendSMEvent(EVID_CAMERA)) {
- chgCamera = true;
- }
- break;
- case ICO_VINFO_LIGHT_RIGHT:
- ICO_DBG("ICO_VINFO_LIGHT_RIGHT: %s",
- vinfo->getBooleanValue() ? "true" : "false");
- if (false == vinfo->getBooleanValue()) {
- (void)sendSMEvent(EVID_TURN_OFF);
- }
- else {
- (void)sendSMEvent(EVID_TURN_RIGHT);
- }
- if (true == sendSMEvent(EVID_CAMERA)) {
- chgCamera = true;
- }
- break;
- case ICO_VINFO_NIGHT_MODE:
- ICO_DBG("ICO_VINFO_NIGHT_MODE : %d", vinfo->getUint32Value());
- chgNightMode = sendSMEvent(EVID_NIGHTMODE, (int)vinfo->getUint32Value());
- break;
- case ICO_VINFO_DRIVING_MODE:
- ICO_DBG("ICO_VINFO_DRIVING_MODE : %d", vinfo->getUint32Value());
- chgRegulation = sendSMEvent(EVID_DRVREGULATION, (int)vinfo->getUint32Value());
- break;
- default:
- ICO_WRN("not such key (%d)", vinfo->getProperty());
- break;
- }
-
- if (true == chgRegulation) {
- ICO_DBG("true == chgRegulation");
- // notify changed state to resource manager
- CicoState* state =
- (CicoState*)m_stateMachine->getState(STID_DRVREGULATION);
- if (NULL != state) {
- vector<const CicoState*> currents;
- state->getCurrentState(currents, CicoStateCore::ELvlTop);
- if (0 != currents.size()) {
- ICO_DBG("current=%s", currents[0]->getName().c_str());
- notifyChangedState(currents[0]->getValue());
- }
- }
-
- // Notify regulation changed state
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
- message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_REGULATION);
- if (true == m_policyStates[STID_DRVREGULATION_ON]->isActive()) {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
- }
- else {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
- }
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
- }
-
- if (true == chgCamera) {
- ICO_DBG("true == chgCamera");
- // notify changed state to resource manager
- CicoState* state = (CicoState*)m_stateMachine->getState(STID_CAMERA);
- if (NULL != state) {
- vector<const CicoState*> currents;
- state->getCurrentState(currents, CicoStateCore::ELvlTop);
- if (0 != currents.size()) {
- ICO_DBG("current=%s", currents[0]->getName().c_str());
- notifyChangedState(currents[0]->getValue());
- }
- }
- }
-
- if (true == chgNightMode) {
- ICO_DBG("true == chgNightMode");
- // Notify NightMode changed state
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
- message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_NIGHTMODE);
- if (true == m_policyStates[STID_NIGHTMODE_ON]->isActive()) {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
- }
- else {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
- }
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
- }
-
- ICO_TRA("CicoSCPolicyManager::onChangedVehicleInfo Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief
- */
-//--------------------------------------------------------------------------
-Eina_Bool
-CicoSCPolicyManager::changedVehicleInfoCB(void *data, int type, void *event)
-{
- static_cast<CicoSCPolicyManager*>(data)->onChangedVehicleInfo(type, event);
- return EINA_TRUE;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get policy states
- */
-//--------------------------------------------------------------------------
-const std::map<int, const CicoState*>&
-CicoSCPolicyManager::getPolicyStates(void)
-{
- return m_policyStates;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize state machine
- */
-//--------------------------------------------------------------------------
-int
-CicoSCPolicyManager::initStateMachine(void)
-{
- ICO_TRA("CicoSCPolicyManager::initStateMachine Enter");
-
- CicoStateMachineCreator creator;
-
- //TODO
- m_stateMachine = creator.createFile("/usr/apps/org.tizen.ico.system-controller/res/config/policy.json");
- if (NULL == m_stateMachine) {
- ICO_ERR("CicoStateMachineCreator::createFile failed.(reason:%s)",
- creator.getError().c_str());
- return ICO_SYC_ENOSYS;
- }
-
- int ret = m_stateMachine->start();
- if (ret == 0) {
- ICO_ERR("CicoStateMachine::start failed.");
- ICO_TRA("CicoSCPolicyManager::initStateMachine Leave(ENOSYS)");
- return ICO_SYC_ENOSYS;
- }
-
- vector<CicoStateCore*> objects;
- m_stateMachine->getObjects(objects);
- vector<CicoStateCore*>::iterator itr;
- itr = objects.begin();
- for (; itr != objects.end(); ++itr) {
- const CicoState* state = static_cast<const CicoState*>(*itr);
- m_policyStates[state->getValue()] = state;
-#if 1 //-- { debug dump
- ICO_DBG("State=[%-45s] Active=%s",
- state->getName().c_str(),
- state->isActive() ? "true" : "false");
-#endif //-- } debug dump
- }
-
- {
- std::map<int, const CicoState*>::iterator itr;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE1);
- m_dispZoneStates[1] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE2);
- m_dispZoneStates[2] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE3);
- m_dispZoneStates[3] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE4);
- m_dispZoneStates[4] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE5);
- m_dispZoneStates[5] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE6);
- m_dispZoneStates[6] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE7);
- m_dispZoneStates[7] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE8);
- m_dispZoneStates[8] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE9);
- m_dispZoneStates[9] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE10);
- m_dispZoneStates[10] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE11);
- m_dispZoneStates[11] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE12);
- m_dispZoneStates[12] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE13);
- m_dispZoneStates[13] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE14);
- m_dispZoneStates[14] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE15);
- m_dispZoneStates[15] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE16);
- m_dispZoneStates[16] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE17);
- m_dispZoneStates[17] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE18);
- m_dispZoneStates[18] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE19);
- m_dispZoneStates[19] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY0_ZONE20);
- m_dispZoneStates[20] = itr != m_policyStates.end() ? itr->second : NULL;
-
- itr = m_policyStates.find(STID_DISPLAY1_ZONE1);
- m_dispZoneStates[21] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE2);
- m_dispZoneStates[22] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE3);
- m_dispZoneStates[23] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE4);
- m_dispZoneStates[24] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE5);
- m_dispZoneStates[25] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE6);
- m_dispZoneStates[26] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE7);
- m_dispZoneStates[27] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE8);
- m_dispZoneStates[28] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE9);
- m_dispZoneStates[29] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE10);
- m_dispZoneStates[30] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE11);
- m_dispZoneStates[31] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE12);
- m_dispZoneStates[32] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE13);
- m_dispZoneStates[33] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE14);
- m_dispZoneStates[34] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE15);
- m_dispZoneStates[35] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE16);
- m_dispZoneStates[36] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE17);
- m_dispZoneStates[37] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE18);
- m_dispZoneStates[38] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE19);
- m_dispZoneStates[39] = itr != m_policyStates.end() ? itr->second : NULL;
- itr = m_policyStates.find(STID_DISPLAY1_ZONE20);
- m_dispZoneStates[40] = itr != m_policyStates.end() ? itr->second : NULL;
- }
-
- m_soundZoneStates.push_back(NULL);
- m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE1]);
- m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE2]);
- m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE3]);
-
- m_inputStates.push_back(NULL);
- m_inputStates.push_back(m_policyStates[STID_INPUT1_USING]);
- m_inputStates.push_back(m_policyStates[STID_INPUT2_USING]);
-
- ICO_TRA("CicoSCPolicyManager::initStateMachine Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief query whether a state transition
- *
- * @param [in] event_id trigger event id
- *
- * @return true on test success, false on test failed
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCPolicyManager::testSMEvent(unsigned short event_id)
-{
- CicoEvent event(event_id);
- return m_stateMachine->eventTest(event);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief query whether a state transition
- *
- * @param [in] event_id trigger event id
- * @param [in] value trigger optional integer value
- *
- * @return true on test success, false on test failed
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCPolicyManager::testSMEvent(unsigned short event_id, int value)
-{
- CicoEvent event(event_id, value);
- return m_stateMachine->eventTest(event);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief send tigger event
- *
- * @param [in] event_id trigger event id
- *
- * @return true on state transition, false on not state transition
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCPolicyManager::sendSMEvent(unsigned short event_id)
-{
- CicoEvent event(event_id);
- return m_stateMachine->eventEntry(event);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief send tigger event
- *
- * @param [in] event_id trigger event id
- * @param [in] value trigger optional integer value
- *
- * @return true on state transition, false on not state transition
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCPolicyManager::sendSMEvent(unsigned short event_id, int value)
-{
- CicoEvent event(event_id, value);
- return m_stateMachine->eventEntry(event);
-}
-
-bool
-CicoSCPolicyManager::acquireDisplayResource(int type, int zoneid, int priority)
-{
- ICO_TRA("CicoSCPolicyManager::acquireDisplayResource Enter"
- "(type=0x%08x zoneid=%d priority=%d)", type, zoneid, priority);
-
- bool chg = false;
-
- if (RESID_TYPE_BASIC == type) {
-#if 1
- unsigned short category_ev = EVID_DISPLAY0_CATEGORY;
- if (ZONEID_CENTER_UPPER == zoneid) {
- category_ev = EVID_DISP0_ZONE2_CATEGORY;
-
- }
- else if (ZONEID_CENTER_LOWER == zoneid) {
- category_ev = EVID_DISP0_ZONE3_CATEGORY;
- }
-
- bool zoneChg = testSMEvent(EVID_DISPLAY_ZONE_ACQUIRE, zoneid);
- bool cateChg = testSMEvent(category_ev, priority);
- ICO_DBG("zoneChg=%d cateChg=%d", zoneChg, cateChg);
- if ((true == zoneChg) && (true == cateChg)) {
- sendSMEvent(EVID_DISPLAY_ZONE_ACQUIRE, zoneid);
- sendSMEvent(category_ev, priority);
- chg = true;
- }
-#else
- bool zoneChg = testSMEvent(EVID_DISPLAY_ZONE_ACQUIRE, zoneid);
- bool cateChg = testSMEvent(EVID_DISPLAY0_CATEGORY, priority);
- ICO_DBG("zoneChg=%d cateChg=%d", zoneChg, cateChg);
- if ((true == zoneChg) && (true == cateChg)) {
- sendSMEvent(EVID_DISPLAY_ZONE_ACQUIRE, zoneid);
- sendSMEvent(EVID_DISPLAY0_CATEGORY, priority);
- chg = true;
- }
-#endif
-#if 0 //-- { debug dump
- else {
- std::map<int, const CicoState*>::iterator itr;
- itr = m_policyStates.begin();
- for (; itr != m_policyStates.end(); ++itr) {
- ICO_DBG("State=[%-45s] Active=%s",
- itr->second->getName().c_str(),
- itr->second->isActive() ? "true" : "false");
- }
- }
-#endif //-- } debug dump
- }
- else if (RESID_TYPE_INTERRUPT == type) {
- if (1 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_D0_Z1, priority);
- }
- else if (2 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_D0_Z2, priority);
- }
- else if (3 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_D0_Z3, priority);
- }
- }
- else if (RESID_TYPE_ONSCREEN == type) {
- chg = sendSMEvent(EVID_ONSCREEN, priority);
- }
- ICO_TRA("CicoSCPolicyManager::acquireDisplayResource Leave(%s)",
- chg ? "true" : "false");
- return chg;
-}
-
-bool
-CicoSCPolicyManager::releaseDisplayResource(int zoneid, int priority)
-{
- return sendSMEvent(EVID_DISPLAY_ZONE_RELEASE, zoneid);
-}
-
-bool
-CicoSCPolicyManager::acquireSoundResource(int type, int zoneid, int priority)
-{
- ICO_TRA("CicoSCPolicyManager::acquireSoundResource Enter"
- "(type=0x%08x zoneid=%d priority=%d)", type, zoneid, priority);
-
- bool chg = false;
-
- if (RESID_TYPE_BASIC == type) {
- bool zoneChg = testSMEvent(EVID_SOUND_ZONE, zoneid);
- bool cateChg = testSMEvent(EVID_SOUND_CATEGORY, priority);
- ICO_DBG("zoneChg=%d cateChg=%d", zoneChg, cateChg);
- if ((true == zoneChg) && (true == cateChg)) {
- sendSMEvent(EVID_SOUND_ZONE, zoneid);
- sendSMEvent(EVID_SOUND_CATEGORY, priority);
- chg = true;
- }
- }
- else if (RESID_TYPE_INTERRUPT == type) {
- if (1 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z1, priority);
- }
- else if (2 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z2, priority);
- }
- else if (3 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z3, priority);
- }
- }
-
- ICO_TRA("CicoSCPolicyManager::acquireSoundResource Leave(%s)",
- chg ? "true" : "false");
- return chg;
-}
-
-bool
-CicoSCPolicyManager::releaseSoundResource(int type, int zoneid)
-{
- ICO_TRA("CicoSCPolicyManager::acquireSoundResource Enter"
- "(type=%d zoneid=%d)", type, zoneid);
-
- bool chg = false;
- if (RESID_TYPE_BASIC == type) {
- chg = sendSMEvent(EVID_SOUND_ZONE_NOUSE);
- chg = sendSMEvent(EVID_SOUND_CATEGORY_UNKNOWN);
- }
- else if (RESID_TYPE_INTERRUPT == type) {
- if (1 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z1_NOOUTPUT);
- }
- else if (2 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z2_NOOUTPUT);
- }
- else if (3 == zoneid) {
- chg = sendSMEvent(EVID_INTTERPUT_S_Z3_NOOUTPUT);
- }
- }
-
- ICO_TRA("CicoSCPolicyManager::acquireSoundResource Leave(%s)",
- chg ? "true" : "false");
-
- return true;
-}
-
-bool
-CicoSCPolicyManager::acquireInputResource(int input, int priority)
-{
- ICO_TRA("CicoSCPolicyManager::acquireInputResource Enter"
- "(input=%d priority=%d)", input, priority);
-
- bool chg = false;
-
- if (1 == input) {
- chg = testSMEvent(EVID_INPUT1_ACQUIRE, input);
- if (true == chg) {
- sendSMEvent(EVID_INPUT1_ACQUIRE, input);
- }
- }
- else if (2 == input) {
- chg = testSMEvent(EVID_INPUT2_ACQUIRE, input);
- if (true == chg) {
- sendSMEvent(EVID_INPUT2_ACQUIRE, input);
- }
- }
-
- ICO_TRA("CicoSCPolicyManager::acquireInputResource Leave(%s)",
- chg ? "true" : "false");
- return chg;
-}
-
-bool
-CicoSCPolicyManager::releaseInputResource(int input)
-{
- if (1 == input) {
- (void)sendSMEvent(EVID_INPUT1_RELEASE, input);
- }
- else if (2 == input) {
- (void)sendSMEvent(EVID_INPUT2_RELEASE, input);
- }
- return true;
-}
-
-void
-CicoSCPolicyManager::notifyChangedState(int state)
-{
- m_resourceMgr->receiveChangedState(state);
-}
-
-bool
-CicoSCPolicyManager::getDispZoneState(int zoneid)
-{
- if (0 >= zoneid) {
- return false;
- }
-
- // find state instance
- std::map<int, const CicoState*>::iterator itr;
- itr = m_dispZoneStates.find(zoneid);
- if (itr == m_dispZoneStates.end()) {
- return false;
- }
-
- // if state instance is null
- if (NULL == itr->second) {
- return false;
- }
-
- return itr->second->isActive();
-}
-
-bool
-CicoSCPolicyManager::getSoundZoneState(int zoneid) const
-{
- if ((0 < zoneid) && ((int)m_soundZoneStates.size()-1 > zoneid)) {
- return m_soundZoneStates[zoneid]->isActive();
- }
- return false;
-}
-
-bool
-CicoSCPolicyManager::getInputState(int input) const
-{
- if ((0 < input) && ((int)m_inputStates.size()-1 > input)) {
- return m_inputStates[input]->isActive();
- }
- return false;
-}
-
-bool
-CicoSCPolicyManager::getRegulation(void)
-{
- return m_policyStates[STID_DRVREGULATION_ON]->isActive();
-}
-
-bool
-CicoSCPolicyManager::isExistDisplayZoneOwer(int zoneid)
-{
- if ((zoneid >= ICO_DISPLAY0_ZONEID_MIN) &&
- (zoneid <= ICO_DISPLAY0_ZONEID_MAX)) {
- return !m_policyStates[STID_DISPLAY0_NOOWER]->isActive();
- }
- if ((zoneid >= ICO_DISPLAY1_ZONEID_MIN) &&
- (zoneid <= ICO_DISPLAY1_ZONEID_MAX)) {
- return !m_policyStates[STID_DISPLAY1_NOOWER]->isActive();
- }
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief notify connected
- */
-//--------------------------------------------------------------------------
-void
-CicoSCPolicyManager::notifyConnected(const std::string & appid)
-{
- // Notify regulation changed state
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
- message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_REGULATION);
- if (true == m_policyStates[STID_DRVREGULATION_ON]->isActive()) {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
- }
- else {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
- }
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- // Notify NightMode changed state
- message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
- message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_NIGHTMODE);
- if (true == m_policyStates[STID_NIGHTMODE_ON]->isActive()) {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
- }
- else {
- message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
- }
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCPolicyManager.h
- *
- * @brief This file is definition of CicoSCPolicyManager class
- */
-//==========================================================================
-#ifndef __CICO_SC_POLICY_MANAGER_H__
-#define __CICO_SC_POLICY_MANAGER_H__
-
-#include <Ecore.h>
-#include <Eina.h>
-#include <dbus/dbus.h>
-
-#include <map>
-#include <vector>
-#include <string>
-using namespace std;
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoStateMachine;
-class CicoState;
-class CicoSCResourceManager;
-
-//==========================================================================
-/*
- * @brief This class manages the policy of resource
- */
-//==========================================================================
-class CicoSCPolicyManager
-{
-public:
- // constructor
- CicoSCPolicyManager(CicoSCResourceManager* resourceMgr=NULL);
-
- // destructor
- ~CicoSCPolicyManager();
-
- // initialize resource manager
- int initialize(void);
-
- // terminate resource manager
- void terminate(void);
-
- bool acquireDisplayResource(int type, int zoneid, int priority);
- bool releaseDisplayResource(int zoneid, int category);
-
- bool acquireSoundResource(int type, int zoneid, int priority);
- bool releaseSoundResource(int input, int priority);
-
- bool acquireInputResource(int input, int priority);
- bool releaseInputResource(int input);
-
- bool testSMEvent(unsigned short event_id);
- bool testSMEvent(unsigned short event_id, int value);
-
- bool sendSMEvent(unsigned short event_id);
- bool sendSMEvent(unsigned short event_id, int value);
-
- void notifyChangedState(int state);
-
- // get states
- const std::map<int, const CicoState*>& getPolicyStates(void);
-
- bool getDispZoneState(int zoneid);
- bool getSoundZoneState(int zoneid) const;
- bool getInputState(int input) const;
- bool getRegulation(void);
-
- bool isExistDisplayZoneOwer(int zoneid);
-
- // notify connected process
- void notifyConnected(const std::string & appid);
-
-private:
- // default constructor
- CicoSCPolicyManager();
-
- // assignment operator
- CicoSCPolicyManager& operator=(const CicoSCPolicyManager &object);
-
- // copy constructor
- CicoSCPolicyManager(const CicoSCPolicyManager &object);
-
- // initialize state machine
- int initStateMachine(void);
-
- // callback function for changed vehicle informantion
- void onChangedVehicleInfo(int type, void *event);
-
-private:
- // callback function for changed vehicle informantion
- static Eina_Bool changedVehicleInfoCB(void *data, int type, void *event);
-
-private:
- // initialized flag
- bool m_initialized;
-
- // ecore event handler
- Ecore_Event_Handler* m_ecoreEvHandler;
-
- // CicoStateMachine instance
- CicoStateMachine *m_stateMachine;
-
- // CicoSCResourceManager instance
- CicoSCResourceManager *m_resourceMgr;
-
- // state list
- std::map<int, const CicoState*> m_policyStates;
-
- // display zone state list
- std::map<int, const CicoState*> m_dispZoneStates;
-
- // sound zone state list
- std::vector<const CicoState*> m_soundZoneStates;
-
- // input state list
- std::vector<const CicoState*> m_inputStates;
-};
-#endif // __CICO_SC_POLICY_MANAGER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCResourceManager.cpp
- *
- * @brief This file implementation of CicoSCResourceManager class
- */
-//==========================================================================
-
-#include <sstream>
-using namespace std;
-
-#include "CicoSCResourceManager.h"
-#include "CicoLog.h"
-#include "ico_syc_error.h"
-#include "ico_syc_mrp_resource_private.h"
-
-#include "ico_syc_msg_cmd_def.h"
-#include "CicoSystemConfig.h"
-#include "CicoConf.h"
-#include "CicoSCCommand.h"
-#include "CicoSCPolicyManager.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoAilItems.h"
-#include "CicoSCWindow.h"
-#include "CicoSCWindowController.h"
-#include "CicoSCInputController.h"
-#include "CicoSCPolicyDef.h"
-#include "CicoSCMessage.h"
-#include "CicoSCMessageRes.h"
-#include "CicoSCServer.h"
-
-struct CompDisplayResourceRequest
-{
- CompDisplayResourceRequest(const resource_request_t *req)
- : m_req(req) {}
-
- bool operator() (const resource_request_t *req)
- {
- if (NULL == req) {
- return false;
- }
- ICO_DBG("appid=%s:%s", req->appid, m_req->appid);
- if ((0 == strcmp(m_req->appid, req->appid)) &&
- (m_req->pid == req->pid) &&
- ((m_req->resid & RESID_TYPE_MASK) == (req->resid & RESID_TYPE_MASK)) &&
- (m_req->surfaceid == req->surfaceid)) {
- return true;
- }
- return false;
- }
-
- const resource_request_t *m_req;
-};
-
-struct CompSoundResourceRequest
-{
- CompSoundResourceRequest(const resource_request_t *req)
- : m_req(req) {}
-
- bool operator() (const resource_request_t *req)
- {
- if (NULL == req) {
- return false;
- }
-
- ICO_DBG("appid=%s:%s", req->appid, m_req->appid);
- if ((0 == strcmp(m_req->appid, req->appid)) &&
- (m_req->pid == req->pid) &&
- ((m_req->resid & RESID_TYPE_MASK) == (req->resid & RESID_TYPE_MASK)) &&
- (m_req->soundid == req->soundid)) {
- return true;
- }
- return false;
- }
-
- const resource_request_t *m_req;
-};
-
-struct CompInputResourceRequest
-{
- CompInputResourceRequest(const resource_request_t *req)
- : m_req(req) {}
-
- bool operator() (const resource_request_t *req)
- {
- if (NULL == req) {
- return false;
- }
-
- ICO_DBG("appid=%s:%s", req->appid, m_req->appid);
- if ((0 == strcmp(m_req->appid, req->appid)) &&
- (0 == strcmp(m_req->device, req->device)) &&
- (m_req->pid == req->pid) &&
- ((m_req->resid & RESID_TYPE_MASK) == (req->resid & RESID_TYPE_MASK))) {
- return true;
- }
- return false;
- }
-
- const resource_request_t *m_req;
-};
-
-
-CicoSCResourceManager::CicoSCResourceManager()
- : m_policyMgr(NULL), m_winCtrl(NULL), m_inputCtrl(NULL),
- m_animaName("Fade"), m_animaTime(400)
-{
- m_policyMgr = new CicoSCPolicyManager(this);
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- list<resource_request_t*> l;
-
- {
- // initialize display current request and waiting queue
- const vector<CicoSCDisplayConf*>& dispConfList
- = sysConf->getDisplayConfList();
- vector<CicoSCDisplayConf*>::const_iterator itr;
- itr = dispConfList.begin();
- for (; itr != dispConfList.end(); ++itr) {
- vector<CicoSCDisplayZoneConf*>::iterator itr2;
- itr2 = (*itr)->zoneConfList.begin();
- for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
- m_curDispResOwerReq[(*itr2)->id] = NULL;
- }
- }
- }
-
- {
- // initialize sound current request and waiting queue
- const vector<CicoSCSoundConf*>& soundConfList
- = sysConf->getSoundConfList();
- vector<CicoSCSoundConf*>::const_iterator itr;
- itr = soundConfList.begin();
- for (; itr != soundConfList.end(); ++itr) {
- vector<CicoSCSoundZoneConf*>::iterator itr2;
- itr2 = (*itr)->zoneConfList.begin();
- for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
- m_curSoundResReq[(*itr2)->id] = NULL;
- m_soundReqQueue[(*itr2)->id] = l;
- }
- }
- }
-
- {
- // initialize input current request and waiting queue
- const vector<CicoSCInputDevConf*>& inputDevConfList
- = sysConf->getInputDevConfList();
- vector<CicoSCInputDevConf*>::const_iterator itr;
- itr = inputDevConfList.begin();
- for (; itr != inputDevConfList.end(); ++itr) {
- vector<CicoSCSwitchConf*>::iterator itr2;
- itr2 = (*itr)->switchConfList.begin();
- for (; itr2 != (*itr)->switchConfList.end(); ++itr2) {
- m_curInputResReq[(*itr2)->id] = NULL;
- m_inputReqQueue[(*itr2)->id] = l;
- }
- }
- }
- m_rrtHO = (resource_request_t*)NULL;
-}
-
-CicoSCResourceManager::~CicoSCResourceManager()
-{
- delete m_policyMgr;
-}
-
-int
-CicoSCResourceManager::initialize(void)
-{
- ICO_TRA("CicoSCResourceManager::initialize Enter");
-
- int ret = ICO_SYC_EOK;
-
- ret = ico_syc_mrp_init(enforceSound, this);
- if (ICO_SYC_EOK != ret) {
- ICO_TRA("CicoSCResourceManager::initialize Leave");
- return ret;
- }
-
- ret = m_policyMgr->initialize();
- if (ICO_SYC_EOK != ret) {
- ICO_TRA("CicoSCResourceManager::initialize Leave");
- return ret;
- }
-
-
- ICO_TRA("CicoSCResourceManager::initialize Leave");
- return ret;
-}
-
-void
-CicoSCResourceManager::terminate(void)
-{
- ICO_TRA("CicoSCResourceManager::terminate Enter");
- m_policyMgr->terminate();
- ico_syc_mrp_term();
- ICO_TRA("CicoSCResourceManager::terminate Leave");
-}
-
-void
-CicoSCResourceManager::handleCommand(const CicoSCCommand &cmd,
- bool internal)
-{
- ICO_TRA("CicoSCResourceManager::handleCommand Enter"
- "(cmdid=0x%08x internal=%s)",
- cmd.cmdid, internal ? "true" : "false");
-
- CicoSCCmdResCtrlOpt *opt = (CicoSCCmdResCtrlOpt*)cmd.opt;
-
- // request command from application or internal
- int reqtype = internal ? REQTYPE_AUTO : REQTYPE_APP;
- if ((MSG_CMD_CREATE_RES == cmd.cmdid) ||
- (MSG_CMD_ACQUIRE_RES == cmd.cmdid)) {
-
- if (true == opt->dispres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_DISPLAY,
- reqtype,
- cmd);
- if (MSG_CMD_CREATE_RES == cmd.cmdid) {
- acquireDisplayResource(req, false);
- }
- else {
- // cmdid is MSG_CMD_ACQUIRE_RES
- if (true == isTypeOnScreen(*req)) {
- acquireOnScreenDisplayResource(req);
- }
- else
- if ((true == m_policyMgr->getRegulation()) &&
- (false == isMatchDisplayed())) {
- updateDispResRegulationPreProc(req);
- updateDisplayResourceRegulation(STID_DRVREGULATION_ON);
- }
- else {
- acquireDisplayResource(req);
- }
- }
-
- }
- if (true == opt->soundres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_SOUND,
- reqtype,
- cmd);
- if ((true == m_policyMgr->getRegulation()) &&
- (false == isMatchDisplayed())) {
- updateSoundResRegulationPreProc(req);
- updateSoundResourceRegulation(STID_DRVREGULATION_ON);
- }
- else {
- acquireSoundResource(req);
- }
-
- }
- if (true == opt->inputres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_INPUT,
- reqtype,
- cmd);
- if ((true == m_policyMgr->getRegulation()) &&
- (false == isMatchDisplayed())) {
- updateInputResRegulationPreProc(req);
- updateInputResourceRegulation(STID_DRVREGULATION_ON);
- }
- else {
- acquireInputResource(req);
- }
- }
- }
- else if ((MSG_CMD_RELEASE_RES == cmd.cmdid) ||
- (MSG_CMD_DESTORY_RES == cmd.cmdid)) {
-
- if (true == opt->dispres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_DISPLAY,
- reqtype,
- cmd);
- if (true == isTypeOnScreen(*req)) {
- releaseOnScreenDisplayResource(req);
- }
- else {
- releaseDisplayResource(req);
- }
- }
- if (true == opt->soundres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_SOUND,
- reqtype,
- cmd);
- releaseSoundResource(req);
- }
- if (true == opt->inputres) {
- resource_request_t *req = newResourceRequest(RESID_KIND_INPUT,
- reqtype,
- cmd);
- releaseInputResource(req);
- }
- }
- else {
- ICO_WRN("Unknown command");
- }
-
- ICO_TRA("CicoSCResourceManager::handleCommand Leave");
-}
-
-void
-CicoSCResourceManager::setWindowController(CicoSCWindowController *winCtrl)
-{
- m_winCtrl = winCtrl;
-}
-
-void
-CicoSCResourceManager::setInputController(CicoSCInputController *inputCtrl)
-{
- m_inputCtrl = inputCtrl;
-}
-
-#if 0
-resource_request_t *
-CicoSCResourceManager::popDispResReq(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::popDispResReq Enter");
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_dispReqQueue.begin();
- CompDisplayResourceRequest comp(req);
- for (; itr != m_dispReqQueue.end(); ++itr) {
- list<resource_request_t*>::iterator itr2;
- itr2 = find_if(itr->second.begin(), itr->second.end(), comp);
- if (itr->second.end() != itr2) {
- ICO_DBG("Dequeue waiting display request queue zone=%d req=0x%08x",
- itr->first, *itr2);
- m_dispReqQueue[req->dispzoneid].erase(itr2);
- ICO_TRA("CicoSCResourceManager::popDispResReq Leave"
- "(0x%08x)", *itr2);
- return *itr2;
- }
- }
-
- ICO_TRA("CicoSCResourceManager::popDispResReq Leave(NULL)");
- return NULL;
-}
-#endif
-
-resource_request_t *
-CicoSCResourceManager::popSoundResReq(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::popSoundResReq Enter");
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_soundReqQueue.begin();
- CompSoundResourceRequest comp(req);
- for (; itr != m_soundReqQueue.end(); ++itr) {
- list<resource_request_t*>::iterator itr2;
- itr2 = find_if(itr->second.begin(), itr->second.end(), comp);
- if (itr->second.end() != itr2) {
- ICO_DBG("Dequeue waiting sound request queue"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- *itr2, itr->first, (*itr2)->soundzone, (*itr2)->appid);
- m_soundReqQueue[req->soundzoneid].erase(itr2);
- ICO_TRA("CicoSCResourceManager::popSoundResReq Leave"
- "(0x%08x)", *itr2);
- return *itr2;
- }
- }
- ICO_TRA("CicoSCResourceManager::popSoundResReq Leave(NULL)");
- return NULL;
-}
-
-resource_request_t *
-CicoSCResourceManager::popInputResReq(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::popInputResReq Enter");
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_inputReqQueue.begin();
- CompInputResourceRequest comp(req);
- for (; itr != m_inputReqQueue.end(); ++itr) {
- list<resource_request_t*>::iterator itr2;
- itr2 = find_if(itr->second.begin(), itr->second.end(), comp);
- if (itr->second.end() != itr2) {
- ICO_DBG("Dequeue waiting input request queue"
- "(req=0x%08x input:%d appid=%s)",
- *itr2, (*itr2)->input, (*itr2)->appid);
- m_inputReqQueue[req->input].erase(itr2);
- ICO_TRA("CicoSCResourceManager::popInputResReq Leave"
- "(0x%08x)", *itr2);
- return *itr2;
- }
- }
-
- ICO_TRA("CicoSCResourceManager::popDispResReq Leave(NULL)");
- return NULL;
-}
-
-
-bool
-CicoSCResourceManager::acquireDisplayResource(resource_request_t *newreq,
- bool control)
-{
- ICO_TRA("CicoSCResourceManager::acquireDisplayResource Enter");
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- const CicoSCAppKindConf *appKindConf = NULL;
- appKindConf = sysConf->findAppKindConfbyId(newreq->appkind);
- if (NULL == appKindConf) {
- ICO_ERR("not found CicoSCAppKindConf instance");
- ICO_TRA("CicoSCResourceManager::acquireDisplayResource Leave(false)");
- return false;
- }
-
- if ((appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_ALMIGHTY) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM_VISIBLE)) {
-
- if ((NULL != m_winCtrl) && (true == control)) {
- m_winCtrl->show(newreq->surfaceid,
- newreq->animation,
- newreq->animationTime);
- }
- delResourceRequest(newreq);
-
- ICO_DBG("kind of system application");
- ICO_TRA("CicoSCResourceManager::acquireDisplayResource Leave(true)");
- return true;
- }
-
- // if exist current ower request, pop request
- resource_request_t *req = findCurDispResOwerReq(newreq);
- int chgzone = -1;
- if (NULL != req) {
- ICO_DBG("dispzoneid=%d/%d zone=%s/%s",
- req->dispzoneid, newreq->dispzoneid,
- req->dispzone, newreq->dispzone);
- if (req->dispzoneid != newreq->dispzoneid) {
- req = popCurDispResOwerReq(req);
- m_policyMgr->releaseDisplayResource(req->dispzoneid, req->prio);
- chgzone = newreq->dispzoneid;
- }
- }
-
- // if exist in wating request list, pop request
- if (NULL == req) {
- req = popWaitingDispResReq(newreq);
- if (NULL != req) {
- ICO_DBG("dispzoneid=%d/%d zone=%s/%s",
- req->dispzoneid, newreq->dispzoneid,
- req->dispzone, newreq->dispzone);
- if (req->dispzoneid != newreq->dispzoneid) {
- chgzone = newreq->dispzoneid;
- }
- }
- else {
- req = newreq;
- }
- }
-
- bool displayMatch = false;
- //
- if (req != newreq) {
- char zoneO[128],zoneN[128];
- zoneO[0] = zoneN[0] = '\0';
- if ((NULL != req) && (NULL != req->dispzone)) {
- char* d = zoneO;
- const char* s = req->dispzone;
- while ('\0' != *s) { // is stop code
- if ('.' == *s) { // DISPLAY.ZONE found a period
- break; // break of while
- }
- *d++ = *s++; // char copy
- }
- *d='\0'; // set stop code
- }
- if ((NULL != newreq) && (NULL != newreq->dispzone)) {
- char* d = zoneO;
- const char* s = newreq->dispzone;
- while ('\0' != *s) { // is stop code
- if ('.' == *s) { // DISPLAY.ZONE found a period
- break; // break of while
- }
- *d++ = *s++; // char copy
- }
- *d='\0'; // set stop code
- }
- if ((0 != strlen(zoneO)) || (0 != strlen(zoneN))) {
- if (0 == strcmp(zoneO, zoneN)) {
- displayMatch = true;
- }
- }
- // update request data
- req->dispzoneid = newreq->dispzoneid;
- free(req->dispzone);
- req->dispzone = strdup(newreq->dispzone);
- req->layerid = newreq->layerid;
- free(req->animation);
- req->animation = strdup(newreq->animation);
- req->animationTime = newreq->animationTime;
-
- // delete new request
- delResourceRequest(newreq);
- }
-
- if (false == control) {
- ICO_TRA("Enqueue waiting display resource request"
- "(req=0x%08x appid=%s)", req, req->appid);
- m_waitingDispResReq.push_front(req);
-#if 1 //DEBUG
- dumpWaitingDispResReq();
-#endif //DEBUG
- return true;
- }
-
- int type = req->resid & RESID_TYPE_MASK;
- bool state = m_policyMgr->acquireDisplayResource(type,
- req->dispzoneid,
- req->prio);
- if ((true == state) && (false == displayMatch)){
- updateDisplayResource(req, chgzone);
- }
- else {
- if ((-1 != chgzone) || (true == displayMatch)) {
- if (NULL != m_winCtrl) {
- // move request window
- m_winCtrl->setGeometry(req->surfaceid, req->dispzone, req->layerid,
- req->animation, req->animationTime,
- req->animation, req->animationTime);
- }
- }
- else {
- // just in case, hide window
- if (NULL != m_winCtrl) {
- // hide request window
- m_winCtrl->hide(req->surfaceid, NULL, 0);
- }
- }
- ICO_DBG("Enqueue waiting display resource request"
- "(req=0x%08x appid=%s)", req, req->appid);
- m_waitingDispResReq.push_front(req);
-#if 1 //DEBUG
- dumpWaitingDispResReq();
-#endif //DEBUG
- }
-
- ICO_TRA("CicoSCResourceManager::acquireDisplayResource Leave");
- return true;
-}
-
-void
-CicoSCResourceManager::releaseDisplayResource(resource_request_t *newreq)
-{
- ICO_TRA("CicoSCResourceManager::releaseDisplayResource Enter"
- "(newreq=0x%08x)", newreq);
-
- // if exist in wating request list, pop request
- resource_request_t *req = popWaitingDispResReq(newreq);
- if (NULL != req) {
- delResourceRequest(req);
- delResourceRequest(newreq);
- ICO_TRA("CicoSCResourceManager::releaseDisplayResource Leave");
- return;
- }
-
- // if exist current ower request, pop request
- req = popCurDispResOwerReq(newreq);
- if (NULL != req) {
- m_policyMgr->releaseDisplayResource(req->dispzoneid, req->prio);
- delResourceRequest(req);
- }
- delResourceRequest(newreq);
-
- list<resource_request_t*>::iterator itr;
- itr = m_waitingDispResReq.begin();
- for (; itr != m_waitingDispResReq.end(); ++itr) {
- if (NULL != m_curDispResOwerReq[(*itr)->dispzoneid]) {
- continue;
- }
- int type = (*itr)->resid & RESID_TYPE_MASK;
- bool active = m_policyMgr->acquireDisplayResource(type,
- (*itr)->dispzoneid,
- (*itr)->prio);
- if (true == active) {
- resource_request_t* popreq = popWaitingDispResReq(*itr);
- updateDisplayResource(popreq);
- m_winCtrl->activeCB(NULL, NULL, popreq->surfaceid, -1);
- break;
- }
- }
-
- ICO_TRA("CicoSCResourceManager::releaseDisplayResource Leave");
-}
-
-bool
-CicoSCResourceManager::acquireSoundResource(resource_request_t *newreq)
-{
- ICO_TRA("CicoSCResourceManager::acquireSoundResource Enter");
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- const CicoSCAppKindConf *appKindConf = NULL;
- appKindConf = sysConf->findAppKindConfbyId(newreq->appkind);
- if (NULL == appKindConf) {
- ICO_ERR("not found CicoSCAppKindConf instance");
- ICO_TRA("CicoSCResourceManager::acquireSoundResource Leave(false)");
- return false;
- }
-
- if ((appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_ALMIGHTY) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM_AUDIO)) {
-
- delResourceRequest(newreq);
-
- ICO_DBG("kind of system application");
- ICO_TRA("CicoSCResourceManager::acquireSoundResource Leave(true)");
- return true;
- }
-
- resource_request_t *req = popSoundResReq(newreq);
- if (NULL == req) {
- req = newreq;
- }
-
- // is change zone?
- CompSoundResourceRequest comp(req);
- if (true == comp(m_curSoundResReq[req->soundzoneid])) {
- ICO_DBG("already acquired appid=%s pid=%d soundid=0x%08x",
- req->appid, req->pid, req->soundid);
- ICO_TRA("CicoSCResourceManager::acquireSoundResource Leave(true)");
- // free new request
- delResourceRequest(newreq);
- return true;
- }
-
- int type = req->resid & RESID_TYPE_MASK;
- bool state = m_policyMgr->acquireSoundResource(type,
- req->soundzoneid,
- req->prio);
- if (true == state) {
- updateSoundResource(req);
- }
- else {
- ICO_DBG("Enqueue waiting sound request queue"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- req, req->soundzoneid, req->soundzone, req->appid);
- m_soundReqQueue[req->soundzoneid].push_front(req);
- }
-
- ICO_TRA("CicoSCResourceManager::acquireSoundResource Leave");
- return true;
-}
-
-void
-CicoSCResourceManager::releaseSoundResource(resource_request_t *newreq)
-{
- ICO_TRA("CicoSCResourceManager::releaseSoundResource Enter");
-
- bool curchg = false;
- CompSoundResourceRequest comp(newreq);
- for (int i = 0; i < (int)m_curSoundResReq.size(); ++i) {
- if (NULL == m_curSoundResReq[i]) {
- continue;
- }
-
- if (true == comp(m_curSoundResReq[i])) {
- ICO_DBG("Dequeue current sound resource ower request"
- "(req=0x%08x zoneid=%02d:%s appid=%s)",
- m_curSoundResReq[i], m_curSoundResReq[i]->dispzoneid,
- m_curSoundResReq[i]->dispzone,
- m_curSoundResReq[i]->appid);
- ICO_PRF("CHG_GUI_RES sound deprived zone=%02d:%s appid=%s",
- m_curSoundResReq[i]->dispzoneid,
- m_curSoundResReq[i]->dispzone,
- m_curSoundResReq[i]->appid);
- ico_syc_mrp_release_sound_resource(m_curSoundResReq[i]);
- delResourceRequest(newreq);
- delResourceRequest(m_curSoundResReq[i]);
- m_curSoundResReq[i] = NULL;
- curchg = true;
- break;
- }
- }
-
- // If current request is not changed,
- // remove the request from the waiting queue.
- if (false == curchg) {
- resource_request_t *req = popSoundResReq(newreq);
- if (NULL != req) {
- ico_syc_mrp_release_sound_resource(req);
- delResourceRequest(req);
- req = NULL;
- }
- delResourceRequest(newreq);
- ICO_TRA("CicoSCResourceManager::releaseSoundResource Leave");
- return;
- }
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_soundReqQueue.begin();
- for (; itr != m_soundReqQueue.end(); ++itr) {
- list<resource_request_t*>::iterator itr2;
- itr2 = itr->second.begin();
- for (; itr2 != itr->second.end(); ++itr2) {
- if (NULL != m_curSoundResReq[(*itr2)->soundzoneid]) {
- continue;
- }
-
- int type = (*itr2)->resid & RESID_TYPE_MASK;
- bool active = m_policyMgr->acquireSoundResource(type,
- (*itr2)->soundzoneid,
- (*itr2)->prio);
- if (true == active) {
- resource_request_t* req = *itr2;
- ICO_DBG("Dequeue waiting sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- *itr2, itr->first, (*itr2)->soundzone, (*itr2)->appid);
- itr->second.erase(itr2);
- updateSoundResource(req);
- break;
- }
- }
- }
-
- ICO_TRA("CicoSCResourceManager::releaseSoundResource Leave");
-}
-
-bool
-CicoSCResourceManager::acquireInputResource(resource_request_t *newreq)
-{
- ICO_TRA("CicoSCResourceManager::acquireInputResource Enter");
-
- resource_request_t *req = popInputResReq(newreq);
- if (NULL == req) {
- req = newreq;
- }
-
- // is change zone?
- CompInputResourceRequest comp(req);
- if (true == comp(m_curInputResReq[req->input])) {
- ICO_DBG("already acquired appid=%s pid=%d input=0x%08x",
- req->appid, req->pid, req->input);
- ICO_TRA("CicoSCResourceManager::acquireInputResource Leave(true)");
- // free new request
- delResourceRequest(newreq);
- return true;
- }
-
- bool state = m_policyMgr->acquireInputResource(req->input, req->prio);
- if (true == state) {
- updateInputResource(req);
- }
- else {
- ICO_DBG("Enqueue waiting input request queue"
- "(req=0x%08x input:%d appid=%s)", req, req->input, req->appid);
- m_inputReqQueue[req->input].push_front(req);
- }
-
- ICO_TRA("CicoSCResourceManager::acquireInputResource Leave(true)");
- return true;
-}
-
-void
-CicoSCResourceManager::releaseInputResource(resource_request_t *newreq)
-{
- ICO_TRA("CicoSCResourceManager::releaseInputResource Enter");
- bool curchg = false;
- CompInputResourceRequest comp(newreq);
- for (int i = 0; i < (int)m_curInputResReq.size(); ++i) {
- if (NULL == m_curInputResReq[i]) {
- continue;
- }
-
- if (true == comp(m_curInputResReq[i])) {
- if (NULL != m_inputCtrl) {
- m_inputCtrl->delInputApp(m_curInputResReq[i]->appid,
- m_curInputResReq[i]->device,
- m_curInputResReq[i]->input);
- }
- ICO_DBG("Dequeue current input resource ower request"
- "(req=0x%08x input=%d appid=%s)",
- m_curInputResReq[i], m_curInputResReq[i]->input,
- m_curInputResReq[i]->appid);
- ICO_PRF("CHG_GUI_RES input deprived input=%d appid=%s",
- m_curInputResReq[i]->input, m_curInputResReq[i]->appid);
- delResourceRequest(newreq);
- delResourceRequest(m_curInputResReq[i]);
- m_curInputResReq[i] = NULL;
- curchg = true;
- break;
- }
- }
-
- // If current request is not changed,
- // remove the request from the waiting queue.
- if (false == curchg) {
- resource_request_t *req = popInputResReq(newreq);
- if (NULL != req) {
- delResourceRequest(req);
- req = NULL;
- }
- delResourceRequest(newreq);
- ICO_TRA("CicoSCResourceManager::releaseInputResource Leave");
- return;
- }
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_inputReqQueue.begin();
- for (; itr != m_inputReqQueue.end(); ++itr) {
- list<resource_request_t*>::iterator itr2;
- itr2 = itr->second.begin();
- for (; itr2 != itr->second.end(); ++itr2) {
- if (NULL != m_curInputResReq[(*itr2)->input]) {
- continue;
- }
- bool active = m_policyMgr->acquireInputResource((*itr2)->input,
- (*itr2)->prio);
- if (true == active) {
- resource_request_t* req = *itr2;
- ICO_DBG("Dequeue waiting input request queue "
- "(req=0x%08x input:%d appid=%s)",
- *itr2, (*itr2)->input, (*itr2)->appid);
- itr->second.erase(itr2);
- updateInputResource(req);
- break;
- }
- }
- }
- ICO_TRA("CicoSCResourceManager::releaseInputResource Leave");
-}
-
-resource_request_t *
-CicoSCResourceManager::newResourceRequest(int resid,
- int reqtype,
- const CicoSCCommand &cmd)
-{
- ICO_TRA("CicoSCResourceManager::newResourceRequest Enter");
-
- resource_request_t *req = NULL;
- req = (resource_request_t*)calloc(1, sizeof(resource_request_t));
- CicoSCCmdResCtrlOpt *opt = (CicoSCCmdResCtrlOpt*)cmd.opt;
- CicoSystemConfig *systemConfig = CicoSystemConfig::getInstance();
-
- req->reqtype = reqtype;
-
- CicoSCLifeCycleController *lifeCycle =
- CicoSCLifeCycleController::getInstance();
- const CicoAilItems* ailItem = lifeCycle->findAIL(cmd.appid);
- if (NULL != ailItem) {
- req->category = ailItem->m_categoryID;
- req->appkind = ailItem->m_kindID;
- }
-
- req->prio = req->category;
-
- req->released = 0;
-
- /* set resource id */
- switch (opt->type) {
- case ICO_SYC_RES_INTERRUPT:
- req->resid = RESID_TYPE_INTERRUPT;
- break;
- case ICO_SYC_RES_ONSCREEN:
- req->resid = RESID_TYPE_ONSCREEN;
- break;
- default: // include case ICO_SYC_RES_BASIC:
- req->resid = RESID_TYPE_BASIC;
- break;
- }
- req->resid |= resid;
-
- req->resid |= RESID_CMD_RELEASE;
- if (MSG_CMD_ACQUIRE_RES == cmd.cmdid) {
- req->resid |= RESID_CMD_ACQUIRE;
- }
-
- /* set application information */
- req->appid = strdup(cmd.appid.c_str());
- req->pid = cmd.pid;
- req->state = RES_STATE_WAITING;
-
- if (resid == RESID_KIND_DISPLAY) {
- req->dispzone = strdup(opt->dispzone.c_str());
- req->dispzoneid = systemConfig->getDizplayZoneIdbyFullName(req->dispzone);
- req->layerid = opt->layerid;
- req->winname = strdup(opt->winname.c_str());
- req->surfaceid = opt->surfaceid;
- req->id = opt->surfaceid;
- req->animation = strdup(opt->animation.c_str());
- req->animationTime = opt->animationTime;
- req->bEx = opt->dispresEx;
- req->ECU = strdup(opt->ECU.c_str()); // name to identify ECU
- req->display = strdup(opt->display.c_str()); // name to identify Display in ECU
- req->layer = strdup(opt->layer.c_str()); // name to identify Layer in Display
- req->layout = strdup(opt->layout.c_str()); // name to identify layout in Layer
- req->area = strdup(opt->area.c_str()); // name to Output position in Layout
- req->dispatchApp= strdup(opt->dispatchApp.c_str()); // dispatch of application
- req->role = strdup(opt->role.c_str()); // role of notice
- req->resourceId = opt->resourceID; // ID number of resource
- }
- else if (resid == RESID_KIND_SOUND) {
- req->soundzone = strdup(opt->soundzone.c_str());
- req->soundzoneid = systemConfig->getSoundZoneIdbyFullName(req->soundzone);
- ICO_DBG("req->soundzoneid=%d", req->soundzoneid);
- req->soundname = strdup(opt->soundname.c_str());
- req->soundid = opt->soundid;
- req->soundadjust = opt->adjust;
- req->id = opt->soundid;
- }
- else if (resid == RESID_KIND_INPUT) {
- req->device = strdup(opt->device.c_str());
- req->input = opt->input;
- req->id = opt->input;
- }
-
- ICO_TRA("CicoSCResourceManager::newResourceRequest Leave"
- "(req=0x%08x appid=%s)", req, req->appid);
- return req;
-}
-
-void
-CicoSCResourceManager::delResourceRequest(resource_request_t *req)
-{
- if (NULL == req) return;
-
- free(req->appid);
- free(req->dispzone);
- free(req->winname);
- free(req->animation);
- free(req->soundzone);
- free(req->soundname);
- free(req->device);
- free(req->ECU); // name to identify ECU
- free(req->display); // name to identify Display in ECU
- free(req->layer); // name to identify Layer in Display
- free(req->layout); // name to identify layout in Layer
- free(req->area); // name to Output position in Layout
- free(req->dispatchApp); // origin of application
- free(req->role); // role of notice
- free(req);
-}
-
-void
-CicoSCResourceManager::enforceSound(unsigned short state,
- resource_request_t *req,
- void *user_data)
-{
- ICO_TRA("CicoSCResourceManager::enforceSound Enter");
- /* NOP */
- ICO_TRA("CicoSCResourceManager::enforceSound Leave");
-}
-
-// receive changed state
-void
-CicoSCResourceManager::receiveChangedState(int state)
-{
- ICO_TRA("CicoSCResourceManager::receiveChangedState Enter"
- "(state=%d)", state);
-
- if (STID_DRVREGULATION_ON == state) {
- if (true == isMatchDisplayed()) {
- updateDisplayResourceRegulation(state);
- updateSoundResourceRegulation(state);
- updateInputResourceRegulation(state);
- }
- }
- else {
- updateDisplayResourceRegulation(state);
- updateSoundResourceRegulation(state);
- updateInputResourceRegulation(state);
- }
-
- ICO_TRA("CicoSCResourceManager::receiveChangedState Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get policy manager instance
- *
- * @return resource manager instace
- */
-//--------------------------------------------------------------------------
-CicoSCPolicyManager *
-CicoSCResourceManager::getPolicyManager(void)
-{
- return m_policyMgr;
-}
-
-void
-CicoSCResourceManager::updateDisplayResource(resource_request_t *req,
- int chgzoneid)
-{
- ICO_TRA("CicoSCResourceManager::updateDisplayResource Enter"
- "(req=0x%08x)", req);
-
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.find(req->dispzoneid);
- if ((m_curDispResOwerReq.end() != itr) && (NULL != itr->second)) {
- // already ower
- if (itr->second == req) {
- ICO_DBG("already ower appid=%s pid=%d surfaceid=%08x",
- req->appid, req->pid, req->surfaceid);
- // show request window
- m_winCtrl->show(req->surfaceid, req->animation, req->animationTime);
-#if 0
- m_winCtrl->activeCB(NULL, NULL, req->surfaceid, -1);
-#endif
- ICO_TRA("CicoSCResourceManager::updateDisplayResource Leave");
- return;
- }
- resource_request_t *popreq = popCurDispResOwerReq(itr->second);
- if (NULL != popreq) {
- if (NULL != m_winCtrl) {
- // hide current window
- m_winCtrl->hide(popreq->surfaceid, NULL, 0);
- }
-
- // state change to waiting
- popreq->state = RES_STATE_WAITING;
- // enqueue request
- ICO_DBG("Enqueue waiting display resource request"
- "(req=0x%08x zone=%02d:%s appid=%s",
- popreq, popreq->dispzoneid,
- popreq->dispzone, popreq->appid);
- m_waitingDispResReq.push_front(popreq);
-#if 1 //DEBUG
- dumpWaitingDispResReq();
-#endif //DEBUG
- }
- }
-
- std::map<unsigned int, resource_request_t*>::iterator itr2;
- itr2 = m_curDispResOwerReq.begin();
- for (; itr2 != m_curDispResOwerReq.end(); ++itr2) {
- resource_request_t *tmpreq = itr2->second;
-
- if (true == m_policyMgr->getDispZoneState(itr2->first)) {
- continue;
- }
-
- if (NULL == itr2->second) {
- continue;
- }
-
- ICO_DBG("Dequeue current display resource ower request"
- "(req=0x%08x zoneid=%02d:%s appid=%s)",
- tmpreq, tmpreq->dispzoneid, tmpreq->dispzone, tmpreq->appid);
- ICO_PRF("CHG_GUI_RES display deprived zone=%02d:%s appid=%s",
- tmpreq->dispzoneid, tmpreq->dispzone, tmpreq->appid);
- itr2->second = NULL;
-
- // hide current window
- m_winCtrl->hide(tmpreq->surfaceid, NULL, 0);
-
- ICO_DBG("Enqueue waiting display resource request"
- "(req=0x%08x zone=%02d:%s appid=%s",
- tmpreq, tmpreq->dispzoneid, tmpreq->dispzone, tmpreq->appid);
- m_waitingDispResReq.push_front(tmpreq);
- }
-
- if (NULL != m_winCtrl) {
- int ret = ICO_SYC_EOK;
- if (-1 != chgzoneid) {
- // move request window
- ret = m_winCtrl->setGeometry(req->surfaceid, req->dispzone,
- req->layerid,
- req->animation, req->animationTime,
- req->animation, req->animationTime);
- if (ICO_SYC_EOK != ret) {
- return;
- }
- }
-
- // show request window
- m_winCtrl->show(req->surfaceid, req->animation, req->animationTime);
- }
- // state change to acquired
- req->state = RES_STATE_ACQUIRED;
- // update current zone request
- ICO_DBG("Enqueue current display resource ower request"
- "(req=0x%08x zoneid=%02d:%s appid=%s)",
- req, req->dispzoneid, req->dispzone, req->appid);
- ICO_PRF("CHG_GUI_RES display acquired zone=%02d:%s appid=%s",
- req->dispzoneid, req->dispzone, req->appid);
- m_curDispResOwerReq[req->dispzoneid] = req;
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
-#endif //DEBUG
-
- // if current zone ower not exist after zone change
- if (-1 != chgzoneid) {
- list<resource_request_t*>::iterator itr;
- itr = m_waitingDispResReq.begin();
- for (; itr != m_waitingDispResReq.end(); ++itr) {
- if (m_curDispResOwerReq[(*itr)->dispzoneid] != NULL) {
- continue;
- }
-
- if (true == m_policyMgr->isExistDisplayZoneOwer((*itr)->dispzoneid)) {
- continue;
- }
-
- int type = (*itr)->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireDisplayResource(type,
- (*itr)->dispzoneid,
- (*itr)->prio);
- if (true == active) {
- resource_request_t* req = *itr;
- ICO_DBG("Dequeue waiting display resource request"
- "(req=0x%08x zone=%02d:%s appid=%s)",
- *itr, (*itr)->dispzoneid,
- (*itr)->dispzone, (*itr)->appid);
- m_waitingDispResReq.erase(itr);
-#if 1 //DEBUG
- dumpWaitingDispResReq();
-#endif //DEBUG
- updateDisplayResource(req);
-#if 0
- m_winCtrl->active(req->surfaceid, -1);
-#endif
- break;
- }
- }
- }
-
- ICO_TRA("CicoSCResourceManager::updateDisplayResource Leave");
-}
-
-void
-CicoSCResourceManager::updateSoundResource(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::updateSoundResource Enter"
- "(req=0x%08x)", req);
- for (int i = 0; i < (int)m_curSoundResReq.size(); ++i) {
- ICO_DBG("zoneid=%d active=%d current=0x%08x",
- i, m_policyMgr->getSoundZoneState(i), m_curSoundResReq[i]);
-
- if (NULL == m_curSoundResReq[i]) {
- continue;
- }
-
- if ((i == req->soundzoneid) ||
- (false == m_policyMgr->getSoundZoneState(i))) {
-
- // state change to waiting
- m_curSoundResReq[i]->state = RES_STATE_WAITING;
- // enqueue request
- ICO_DBG("Enqueue waiting sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- m_curSoundResReq[i], i,
- m_curSoundResReq[i]->soundzone, m_curSoundResReq[i]->appid);
- m_soundReqQueue[i].push_front(m_curSoundResReq[i]);
-
- // initialize current zone request
- ICO_DBG("Dequeue current sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- m_curSoundResReq[i], i,
- m_curSoundResReq[i]->soundzone, m_curSoundResReq[i]->appid);
- ICO_PRF("CHG_GUI_RES sound deprived zone=%02d:%s appid=%s",
- i, m_curSoundResReq[i]->soundzone,
- m_curSoundResReq[i]->appid);
- m_curSoundResReq[i] = NULL;
- }
- }
-
- if (req != m_curSoundResReq[req->soundzoneid]) {
- ico_syc_mrp_acquire_sound_resource(req);
- ico_syc_mrp_active_app(req->appid);
-
- // state change to acquired
- req->state = RES_STATE_ACQUIRED;
- // update current zone request
- ICO_DBG("Enqueue current sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- req, req->soundzoneid, req->soundzone, req->appid);
- ICO_PRF("CHG_GUI_RES sound acquired zone=%02d:%s appid=%s",
- req->soundzoneid, req->soundzone, req->appid);
- m_curSoundResReq[req->soundzoneid] = req;
- }
- ICO_TRA("CicoSCResourceManager::updateSoundResource Leave");
-}
-
-void
-CicoSCResourceManager::updateInputResource(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::updateInputResource Enter"
- "(req=0x%08x)", req);
- for (int i = 0; i < (int)m_curInputResReq.size(); ++i) {
- ICO_DBG("input=%d active=%d current=0x%08x",
- i, m_policyMgr->getInputState(i), m_curInputResReq[i]);
-
- if (NULL == m_curInputResReq[i]) {
- continue;
- }
-
- if ((i == req->input) ||
- (false == m_policyMgr->getInputState(i))) {
-
- if (NULL != m_inputCtrl) {
- // add input control
- m_inputCtrl->delInputApp(req->appid, req->device, req->input);
- }
-
- // state change to waiting
- m_curInputResReq[i]->state = RES_STATE_WAITING;
- // enqueue request
- ICO_DBG("Enqueue waiting input request queue "
- "(req=0x%08x input:%d appid=%s)",
- m_curInputResReq[i], i, m_curInputResReq[i]->appid);
- m_inputReqQueue[i].push_front(m_curInputResReq[i]);
- // initialize current zone request
- ICO_DBG("Dequeue current input request queue "
- "(req=0x%08x input:%d appid=%s)",
- m_curInputResReq[i],
- m_curInputResReq[i]->input, m_curInputResReq[i]->appid);
- ICO_PRF("CHG_GUI_RES input deprived input=%d appid=%s",
- m_curInputResReq[i]->input,
- m_curInputResReq[i]->appid);
- m_curInputResReq[i] = NULL;
- }
- }
-
- if (req != m_curInputResReq[req->input]) {
- // delete input control
- m_inputCtrl->addInputApp(req->appid, req->device, req->input, 0, 0);
- // state change to acquired
- req->state = RES_STATE_ACQUIRED;
- // update current zone request
- ICO_DBG("Enqueue current input request queue "
- "(req=0x%08x input:%d appid=%s)", req, req->input, req->appid);
- ICO_PRF("CHG_GUI_RES input acquired input=%d appid=%s",
- req->input, req->appid);
- m_curInputResReq[req->input] = req;
- }
- ICO_TRA("CicoSCResourceManager::updateInputResource Leave");
-}
-
-void
-CicoSCResourceManager::updateDisplayResourceRegulation(int state)
-{
- ICO_TRA("CicoSCResourceManager::updateDisplayResourceRegulation Enter"
- "(state=%d)", state);
-
- if (STID_DRVREGULATION_ON == state) {
- bool curchg = false;
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- resource_request_t *current = itr->second;
- if (NULL == current) {
- continue;
- }
-
- int type = current->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireDisplayResource(type,
- current->dispzoneid,
- current->prio);
- if (false == active) {
- if (NULL != m_winCtrl) {
- // hide current window
- m_winCtrl->hide(current->surfaceid,
- m_animaName.c_str(), m_animaTime);
- }
- curchg = true;
- }
- }
-
- if (false == curchg) {
- ICO_TRA("CicoSCResourceManager::updateDisplayResourceRegulation "
- "Leave");
- return;
- }
-
- list<resource_request_t*>::iterator itr2;
- itr2 = m_waitingDispResReq.begin();
- for (; itr2 != m_waitingDispResReq.end(); ++itr2) {
- int type = (*itr2)->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireDisplayResource(type,
- (*itr2)->dispzoneid,
- (*itr2)->prio);
- if (true == active) {
- if (NULL != m_winCtrl) {
- // show current window
- m_winCtrl->show((*itr2)->surfaceid,
- m_animaName.c_str(), m_animaTime);
- }
- break;
- }
- }
- }
- else if (STID_DRVREGULATION_OFF == state) {
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- resource_request_t *current = itr->second;
- if (NULL == current) {
- if (true == m_policyMgr->isExistDisplayZoneOwer(itr->first)) {
- if (NULL != m_winCtrl) {
- int surfaceid = m_winCtrl->getDisplayedWindow(itr->first);
-
-#if 0
- if ((surfaceid > 0) && (NULL != itr->second) &&
- (itr->second->surfaceid != surfaceid)) {
- m_winCtrl->hide(surfaceid,
- m_animaName.c_str(),
- m_animaTime);
- }
-#else
- if (surfaceid > 0) {
- m_winCtrl->hide(surfaceid,
- m_animaName.c_str(),
- m_animaTime);
- }
-
-#endif
- }
- continue;
- }
- list<resource_request_t*>::iterator itr2;
- itr2 = m_waitingDispResReq.begin();
- for (; itr2 != m_waitingDispResReq.end(); ++itr2) {
- resource_request_t *req = *itr2;
- if (itr->first != (unsigned int)req->dispzoneid) {
- continue;
- }
- int type = req->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireDisplayResource(type,
- req->dispzoneid,
- req->prio);
- if (true == active) {
- ICO_DBG("Dequeue waiting display resource request"
- "(req=0x%08x zone=%02d:%s appid=%s)",
- req, req->dispzoneid,
- req->dispzone, req->appid);
- m_waitingDispResReq.erase(itr2);
- ICO_DBG("Enqueue current display resource request"
- "(req=0x%08x zone=%02d:%s appid=%s)",
- req, req->dispzoneid,
- req->dispzone, req->appid);
- ICO_PRF("CHG_GUI_RES display acquired zone=%02d:%s "
- "appid=%s",
- req->dispzoneid, req->dispzone, req->appid);
- m_curDispResOwerReq[req->dispzoneid] = req;
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
- dumpWaitingDispResReq();
-#endif //DEBUG
- m_winCtrl->show(req->surfaceid,
- m_animaName.c_str(), m_animaTime);
- m_winCtrl->active(req->surfaceid, -1);
- break;
- }
- }
- }
- else {
- int type = current->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireDisplayResource(type,
- current->dispzoneid,
- current->prio);
- if (true == active) {
- if (NULL != m_winCtrl) {
- int surfaceid = m_winCtrl->getDisplayedWindow(
- itr->second->dispzoneid);
- if ((itr->second->surfaceid != surfaceid) &&
- (surfaceid > 0)) {
- m_winCtrl->hide(surfaceid,
- m_animaName.c_str(), m_animaTime);
- }
-
- // show current window
- m_winCtrl->show(current->surfaceid,
- m_animaName.c_str(), m_animaTime);
- }
- }
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
- dumpWaitingDispResReq();
-#endif //DEBUG
- }
- }
- }
-
- ICO_TRA("CicoSCResourceManager::updateDisplayResourceRegulation Leave");
-}
-
-void
-CicoSCResourceManager::updateSoundResourceRegulation(int state)
-{
- ICO_TRA("CicoSCResourceManager::updateSoundResourceRegulation Enter"
- "(state=%d)", state);
-
- bool curchg = false;
- for (int i = 0; i < (int)m_curSoundResReq.size(); ++i) {
- resource_request_t *current = m_curSoundResReq[i];
- if (NULL == current) {
- continue;
- }
-
- int type = current->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireSoundResource(type,
- current->soundzoneid,
- current->prio);
- if (false == active) {
- // state change to waiting
- current->state = RES_STATE_WAITING;
- // enqueue request
- ICO_DBG("Enqueue waiting sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- current, i, current->soundzone, current->appid);
- m_soundReqQueue[i].push_front(current);
- // initialize current zone request
- m_curSoundResReq[i] = NULL;
- curchg = true;
- }
- }
-
- if ((false == curchg) && (STID_DRVREGULATION_ON == state)) {
- ICO_TRA("CicoSCResourceManager::updateSoundResourceRegulation Leave");
- return;
- }
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_soundReqQueue.begin();
- for (; itr != m_soundReqQueue.end(); ++itr) {
- if (NULL != m_curSoundResReq[itr->first]) {
- continue;
- }
-
- list<resource_request_t*>::iterator itr2;
- itr2 = itr->second.begin();
- for (; itr2 != itr->second.end(); ++itr2) {
- int type = (*itr2)->resid & RESID_TYPE_MASK;
- bool active = false;
- active = m_policyMgr->acquireSoundResource(type,
- (*itr2)->soundzoneid,
- (*itr2)->prio);
- if (true == active) {
- resource_request_t* req = *itr2;
- ICO_DBG("Dequeue waiting sound request queue "
- "(req=0x%08x zone:%02d:%s appid=%s)",
- *itr2, itr->first, (*itr2)->soundzone, (*itr2)->appid);
- itr->second.erase(itr2);
- updateSoundResource(req);
- break;
- }
- }
- }
-
- ICO_TRA("CicoSCResourceManager::updateSoundResourceRegulation Leave");
-}
-
-void
-CicoSCResourceManager::updateInputResourceRegulation(int state)
-{
- ICO_TRA("CicoSCResourceManager::updateInputResourceRegulation Enter"
- "(state=%d)", state);
-
- bool curchg = false;
- for (int i = 0; i < (int)m_curInputResReq.size(); ++i) {
- resource_request_t *current = m_curInputResReq[i];
- if (NULL == current) {
- continue;
- }
-
- bool active = false;
- active = m_policyMgr->acquireInputResource(current->input,
- current->prio);
- if (false == active) {
- if (NULL != m_inputCtrl) {
- // hide current window
- m_inputCtrl->delInputApp(current->appid,
- current->device,
- current->input);
- }
- // state change to waiting
- current->state = RES_STATE_WAITING;
- // enqueue request
- ICO_DBG("Enqueue waiting input request queue "
- "(req=0x%08x input:%d appid=%s)",
- current, i, current->appid);
- m_inputReqQueue[i].push_front(current);
- // initialize current zone request
- m_curInputResReq[i] = NULL;
- curchg = true;
- }
- }
-
- if ((false == curchg) && (STID_DRVREGULATION_ON == state)) {
- ICO_TRA("CicoSCResourceManager::updateInputResourceRegulation Leave");
- return;
- }
-
- map<int, list<resource_request_t*> >::iterator itr;
- itr = m_inputReqQueue.begin();
- for (; itr != m_inputReqQueue.end(); ++itr) {
- if (NULL != m_curInputResReq[itr->first]) {
- continue;
- }
-
- list<resource_request_t*>::iterator itr2;
- itr2 = itr->second.begin();
- for (; itr2 != itr->second.end(); ++itr2) {
- bool active = false;
- active = m_policyMgr->acquireInputResource((*itr2)->input,
- (*itr2)->prio);
- if (true == active) {
- resource_request_t* req = *itr2;
- ICO_DBG("Dequeue waiting input request queue "
- "(req=0x%08x input:%d appid=%s)",
- *itr2, (*itr2)->input, (*itr2)->appid);
- itr->second.erase(itr2);
- updateInputResource(req);
- break;
- }
- }
- }
-
- ICO_TRA("CicoSCResourceManager::updateInputResourceRegulation Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find currnet dipalay resource ower request
- *
- * @param [in] request compare requset
- *
- * @return request object on same requeset found, NULL on not found
- */
-//--------------------------------------------------------------------------
-resource_request_t *
-CicoSCResourceManager::findCurDispResOwerReq(resource_request_t *req)
-{
- if (NULL == req) {
- ICO_WRN("invalid argument. req is null");
- return NULL;
- }
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- CompDisplayResourceRequest comp(req);
- if (true == comp(itr->second)) {
- return itr->second;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief pop currnet dipalay resource ower request from list
- *
- * @param [in] request compare requset
- *
- * @return request object on same requeset found, NULL on not found
- */
-//--------------------------------------------------------------------------
-resource_request_t *
-CicoSCResourceManager::popCurDispResOwerReq(resource_request_t *req)
-{
- if (NULL == req) {
- ICO_WRN("invalid argument. req is null");
- return NULL;
- }
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- CompDisplayResourceRequest comp(req);
- if (true == comp(itr->second)) {
- ICO_DBG("Dequeue current display resource ower request"
- "(req=0x%08x zoneid=%02d:%s appid=%s)",
- itr->second, itr->first,
- itr->second->dispzone, itr->second->appid);
- ICO_PRF("CHG_GUI_RES display deprived zone=%02d:%s appid=%s",
- itr->first, itr->second->dispzone, itr->second->appid);
- resource_request_t *findreq = itr->second;
- itr->second = NULL;
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
-#endif //DEBUG
- return findreq;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump currnet dipalay resource ower request
- */
-//--------------------------------------------------------------------------
-void
-CicoSCResourceManager::dumpCurDispResOwerReq(void)
-{
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- if (NULL == itr->second) {
- ICO_DBG("current req=0x%08x zone=%02d:(null) appid=(null)",
- itr->second, itr->first);
- }
- else {
- ICO_DBG("current req=0x%08x zone=%02d:%s appid=%s",
- itr->second, itr->first, itr->second->dispzone,
- itr->second->appid);
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find waiting dipalay resource request
- *
- * @param [in] request compare requset
- *
- * @return request object on same requeset found, NULL on not found
- */
-//--------------------------------------------------------------------------
-resource_request_t *
-CicoSCResourceManager::findWaitingDispResReq(resource_request_t *req)
-{
- if (NULL == req) {
- ICO_WRN("invalid argument. req is null");
- return NULL;
- }
- CompDisplayResourceRequest comp(req);
- std::list<resource_request_t*>::iterator itr;
- itr = find_if(m_waitingDispResReq.begin(), m_waitingDispResReq.end(), comp);
- if (m_waitingDispResReq.end() != itr) {
- return *itr;
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief pop waiting dipalay resource request from waiting list
- *
- * @param [in] request compare requset
- *
- * @return request object on same requeset found, NULL on not found
- */
-//--------------------------------------------------------------------------
-resource_request_t *
-CicoSCResourceManager::popWaitingDispResReq(resource_request_t *req)
-{
- if (NULL == req) {
- ICO_WRN("invalid argument. req is null");
- return NULL;
- }
- CompDisplayResourceRequest comp(req);
- std::list<resource_request_t*>::iterator itr;
- itr = find_if(m_waitingDispResReq.begin(), m_waitingDispResReq.end(), comp);
- if (m_waitingDispResReq.end() != itr) {
- ICO_DBG("Dequeue waiting display resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- *itr, (*itr)->dispzoneid, (*itr)->dispzone, (*itr)->appid);
- resource_request_t *findreq = *itr;
- m_waitingDispResReq.erase(itr);
-#if 1 //DEBUG
- dumpWaitingDispResReq();
-#endif //DEBUG
- return findreq;
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump waiting dipalay resource request
- */
-//--------------------------------------------------------------------------
-void
-CicoSCResourceManager::dumpWaitingDispResReq(void)
-{
- std::list<resource_request_t*>::iterator itr;
- itr = m_waitingDispResReq.begin();
- for (; itr != m_waitingDispResReq.end(); ++itr) {
- if (NULL == *itr) {
- ICO_DBG("waiting req=null");
- }
- else {
- ICO_DBG("waiting req=0x%08x zone=%02d:%s appid=%s",
- *itr, (*itr)->dispzoneid, (*itr)->dispzone, (*itr)->appid);
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief update display request for regulation pre-process
- */
-//--------------------------------------------------------------------------
-void
-CicoSCResourceManager::updateDispResRegulationPreProc(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Enter");
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
- dumpWaitingDispResReq();
-#endif //DEBUG
-
- if (NULL == req) {
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Leave");
- return;
- }
-
- if (false == m_policyMgr->getRegulation()) {
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Leave");
- return;
- }
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- const CicoSCAppKindConf *appKindConf = NULL;
- appKindConf = sysConf->findAppKindConfbyId(req->appkind);
- if (NULL == appKindConf) {
- ICO_ERR("not found CicoSCAppKindConf instance");
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Leave");
- return;
- }
-
- if ((appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_ALMIGHTY) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM_VISIBLE)) {
-
- if (NULL != m_winCtrl) {
- m_winCtrl->show(req->surfaceid,
- req->animation,
- req->animationTime);
- }
- delResourceRequest(req);
-
- ICO_DBG("kind of system application");
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Leave");
- return;
- }
-
- int surfaceid = req->surfaceid;
- if (NULL != m_winCtrl) {
- surfaceid = m_winCtrl->getDisplayedWindow(req->dispzoneid);
- if (-1 == surfaceid) {
- ICO_WRN("displayed surface id is invalid.");
- surfaceid = req->surfaceid;
- }
- }
-
- if (req->surfaceid != surfaceid) {
- ICO_WRN("req->surfaceid(%08x) != displayedsurfaceid(%08x)",
- req->surfaceid, surfaceid);
- }
-
- resource_request_t *curreq = NULL;
- int min = ICO_DISPLAY0_ZONEID_MIN;
- int max = ICO_DISPLAY0_ZONEID_MAX;
- if ((req->dispzoneid >= min) && (req->dispzoneid <= max)) {
- for (int i = min; i <= max; ++i) {
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.find(i);
- if (itr != m_curDispResOwerReq.end()) {
- if (NULL != itr->second) {
- curreq = itr->second;
- break;
- }
- }
- }
- }
-
- min = ICO_DISPLAY1_ZONEID_MIN;
- max = ICO_DISPLAY1_ZONEID_MAX;
- if ((NULL == curreq) &&
- (req->dispzoneid >= min) && (req->dispzoneid <= max)) {
- for (int i = min; i <= max; ++i) {
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.find(i);
- if (itr != m_curDispResOwerReq.end()) {
- if (NULL != itr->second) {
- curreq = itr->second;
- break;
- }
- }
- }
- }
-
-#if 0
- resource_request_t *curreq = NULL;
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.find(req->dispzoneid);
- if (itr != m_curDispResOwerReq.end()) {
- curreq = itr->second;
- }
-#endif
-
- if (NULL != curreq) {
- ICO_DBG("Dequeue current display resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->dispzoneid, curreq->dispzone, curreq->appid);
- ICO_PRF("CHG_GUI_RES display deprived zone=%02d:%s appid=%s",
- curreq->dispzoneid, curreq->dispzone, curreq->appid);
- m_curDispResOwerReq[curreq->dispzoneid] = NULL;
-
- if (curreq->surfaceid != req->surfaceid) {
- resource_request_t *waitreq = popWaitingDispResReq(req);
- ICO_DBG("Enqueue waiting display resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->dispzoneid,
- curreq->dispzone, curreq->appid);
- m_waitingDispResReq.push_front(curreq);
-
- if (NULL != waitreq) {
- ICO_DBG("Enqueue current display resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- waitreq, waitreq->dispzoneid,
- waitreq->dispzone, waitreq->appid);
- ICO_PRF("CHG_GUI_RES display acquired zone=%02d:%s appid=%s",
- waitreq->dispzoneid, waitreq->dispzone, waitreq->appid);
- m_curDispResOwerReq[waitreq->dispzoneid] = waitreq;
- }
- }
- else {
- ICO_DBG("Enqueue current display resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->dispzoneid,
- curreq->dispzone, curreq->appid);
- ICO_PRF("CHG_GUI_RES display acquired zone=%02d:%s appid=%s",
- curreq->dispzoneid, curreq->dispzone, curreq->appid);
- m_curDispResOwerReq[curreq->dispzoneid] = curreq;
- }
- }
- delResourceRequest(req);
-
-#if 1 //DEBUG
- dumpCurDispResOwerReq();
- dumpWaitingDispResReq();
-#endif //DEBUG
- ICO_TRA("CicoSCResourceManager::updateDispResRegulationPreProc Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief update sound request for regulation pre-process
- */
-//--------------------------------------------------------------------------
-void
-CicoSCResourceManager::updateSoundResRegulationPreProc(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::updateSoundResRegulationPreProc Enter");
-
- if (NULL == req) {
- return;
- }
-
- if (false == m_policyMgr->getRegulation()) {
- return;
- }
-
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
- const CicoSCAppKindConf *appKindConf = NULL;
- appKindConf = sysConf->findAppKindConfbyId(req->appkind);
- if (NULL == appKindConf) {
- ICO_ERR("not found CicoSCAppKindConf instance");
- ICO_TRA("CicoSCResourceManager::updateSoundResRegulationPreProc Leave");
- return;
- }
-
- if ((appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_ALMIGHTY) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM) ||
- (appKindConf->privilege == CicoSCAppKindConf::PRIVILEGE_SYSTEM_AUDIO)) {
-
- delResourceRequest(req);
-
- ICO_DBG("kind of system application");
- ICO_TRA("CicoSCResourceManager::updateSoundResRegulationPreProc Leave");
- return;
- }
-
- resource_request_t *curreq = NULL;
- std::map<int, resource_request_t*>::iterator itr;
- itr = m_curSoundResReq.find(req->soundzoneid);
- if (itr != m_curSoundResReq.end()) {
- curreq = itr->second;
- }
-
- if (NULL != curreq) {
- ICO_DBG("Dequeue current sound resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->soundzoneid, curreq->soundzone, curreq->appid);
- ICO_PRF("CHG_GUI_RES sound deprived zone=%02d:%s appid=%s",
- curreq->soundzoneid, curreq->soundzone, curreq->appid);
- m_curSoundResReq[curreq->soundzoneid] = NULL;
-
- if (0 != strcmp(curreq->appid, req->appid)) {
- resource_request_t *waitreq = popSoundResReq(req);
- ICO_DBG("Enqueue waiting sound resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->soundzoneid,
- curreq->soundzone, curreq->appid);
- m_soundReqQueue[curreq->soundzoneid].push_front(curreq);
-
- if (NULL != waitreq) {
- ICO_DBG("Enqueue current sound resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- waitreq, waitreq->soundzoneid,
- waitreq->soundzone, waitreq->appid);
- ICO_PRF("CHG_GUI_RES sound acquired zone=%02d:%s appid=%s",
- waitreq->soundzoneid, waitreq->soundzone,
- waitreq->appid);
- m_curSoundResReq[curreq->soundzoneid] = waitreq;
- }
- }
- else {
- ICO_DBG("Enqueue current sound resource request"
- "(req=0x%08x zone:%02d:%s appid=%s)",
- curreq, curreq->soundzoneid,
- curreq->soundzone, curreq->appid);
- ICO_PRF("CHG_GUI_RES sound acquired zone=%d:%s appid=%s",
- curreq->soundzoneid, curreq->soundzone, curreq->appid);
- m_curSoundResReq[curreq->soundzoneid] = curreq;
- }
- }
- delResourceRequest(req);
- ICO_TRA("CicoSCResourceManager::updateSoundResRegulationPreProc Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief update input request for regulation pre-process
- */
-//--------------------------------------------------------------------------
-void
-CicoSCResourceManager::updateInputResRegulationPreProc(resource_request_t *req)
-{
- ICO_TRA("CicoSCResourceManager::updateInputResRegulationPreProc Enter");
-
- if (NULL == req) {
- return;
- }
-
- if (false == m_policyMgr->getRegulation()) {
- return;
- }
-
- resource_request_t *curreq = NULL;
- std::map<int, resource_request_t*>::iterator itr;
- itr = m_curInputResReq.find(req->input);
- if (itr != m_curInputResReq.end()) {
- curreq = itr->second;
- }
-
- if (NULL != curreq) {
- ICO_DBG("Dequeue current input resource request"
- "(req=0x%08x input:%d appid=%s)",
- curreq, curreq->input, curreq->appid);
- ICO_PRF("CHG_GUI_RES input deprived input=%d appid=%s",
- curreq->input, curreq->appid);
- m_curInputResReq[curreq->input] = NULL;
-
- if (0 != strcmp(curreq->appid, req->appid)) {
- resource_request_t *waitreq = popInputResReq(req);
- ICO_DBG("Enqueue waiting input resource request"
- "(req=0x%08x input:%d appid=%s)",
- curreq, curreq->input, curreq->appid);
- m_inputReqQueue[curreq->input].push_front(curreq);
-
- if (NULL != waitreq) {
- ICO_DBG("Enqueue current input resource request"
- "(req=0x%08x input:%d appid=%s)",
- waitreq, waitreq->input, waitreq->appid);
- ICO_PRF("CHG_GUI_RES input acquired input=%d appid=%s",
- waitreq->input, waitreq->appid);
- m_curInputResReq[curreq->input] = waitreq;
- }
- }
- else {
- ICO_DBG("Enqueue current input resource request"
- "(req=0x%08x input:%d appid=%s)",
- curreq, curreq->input, curreq->appid);
- ICO_PRF("CHG_GUI_RES input acquired input=%d appid=%s",
- curreq->input, curreq->appid);
- m_curInputResReq[curreq->input] = curreq;
- }
- }
- delResourceRequest(req);
- ICO_TRA("CicoSCResourceManager::updateInputResRegulationPreProc Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief compare displayed surface and ower surface
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCResourceManager::isMatchDisplayed(void)
-{
- bool ret = false;
- std::map<unsigned int, resource_request_t*>::iterator itr;
- itr = m_curDispResOwerReq.begin();
- for (; itr != m_curDispResOwerReq.end(); ++itr) {
- if (NULL == itr->second) {
- continue;
- }
- if (NULL != m_winCtrl) {
- int surfaceid = m_winCtrl->getDisplayedWindow(
- itr->second->dispzoneid);
- std::map<unsigned int, resource_request_t*>::iterator itr2;
- itr2 = m_curDispResOwerReq.begin();
- for (; itr2 != m_curDispResOwerReq.end(); ++itr2) {
- if (NULL == itr2->second) {
- continue;
- }
- if ((itr2->second->surfaceid == surfaceid)) {
- ret = true;
- break; // break of for itr2
- }
- }
- }
- if (true == ret) {
- break; // break of for itr
- }
- }
- return ret;
-}
-
-bool
-CicoSCResourceManager::acquireOnScreenDisplayResource(resource_request_t *newreq)
-{
- ICO_TRA("Enter (%08x)", newreq);
- if (NULL == newreq) {
- ICO_TRA("Leave param is NULL pointer");
- return false;
- }
- CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
-
- if (0 == newreq->role_stt) {
- newreq->role_stt = sysConf->getRoleStt(newreq->role);
- }
- m_OnScreenItems.push_back(newreq);
-
- const resource_request_t* rrtHO = getNoticeOfHighOder();
- if (NULL == rrtHO) {
- ICO_TRA("Leave %s, %d is not notice", newreq->role, newreq->resourceId);
- return false;
- }
-#if 1
- const CicoSCWindow* nwo = m_winCtrl->findWindowObj(newreq->pid,
- newreq->resourceId);
-#endif
- const CicoSCWindow* bwo = NULL; // before window oject
- const CicoSCWindow* awo = NULL; // after window object
-
- if (NULL != m_rrtHO) {
- bwo = m_winCtrl->findWindowObj(m_rrtHO->pid, m_rrtHO->resourceId);
- }
- if (NULL != rrtHO) {
- awo = m_winCtrl->findWindowObj(rrtHO->pid, rrtHO->resourceId);
- }
- if ((NULL == m_rrtHO) && (NULL != rrtHO)) { // none -> on notice
- ICO_TRA("_____ OPEN Layer \"%s\":%d", rrtHO->role, rrtHO->resourceId);
- if (NULL != awo) {
- m_winCtrl->showLayer(awo->displayid, awo->layerid);
- }
- else {
- ICO_WRN("ON SCREEN none layer");
- }
- }
-#if 1
- if ((NULL != nwo) && (awo != nwo) && (bwo != nwo)) {
- ICO_TRA("_____ HIDW new REQUEST %x:%s:%d", newreq, newreq->role,
- newreq->resourceId);
- m_winCtrl->hide(nwo->surfaceid, NULL, 0);
- }
-#endif
- if (rrtHO != m_rrtHO) { // change Hige Oder notice
- if (NULL != m_rrtHO) {
- ICO_TRA("_____ HIDE surface %x:%s:%d", m_rrtHO, m_rrtHO->role,
- m_rrtHO->resourceId);
- if (NULL != bwo) {
- m_winCtrl->hide(bwo->surfaceid, NULL, 0);
- }
- else {
- ICO_WRN("ON SCREEN none Hide control");
- }
- resCB(ICO_SYC_EV_RES_WAITING, *m_rrtHO);
- }
- ICO_TRA("_____ SHOW surface %x:%s:%d", rrtHO, rrtHO->role, rrtHO->resourceId);
- if (NULL != awo) {
- m_winCtrl->show(awo->surfaceid, NULL, 0);
- }
- else {
- ICO_WRN("ON SCREEN none show control");
- }
- resCB(ICO_SYC_EV_RES_ACQUIRE, *rrtHO);
- ICO_TRA("_____ change %x -> %x", m_rrtHO, rrtHO);
- m_rrtHO = rrtHO;
- }
-//- if (m_rrtHO != newreq) {
-//- resCB(ICO_SYC_EV_RES_WAITING, *newreq);
-//- }
- else {
- ICO_TRA("_____ no change %x", m_rrtHO);
- if (NULL != awo) {
- m_winCtrl->show(awo->surfaceid, NULL, 0);
- m_winCtrl->raise(awo->surfaceid, NULL, 0);
- }
- if (m_rrtHO != newreq) {
- resCB(ICO_SYC_EV_RES_WAITING, *newreq);
- }
- }
- ICO_TRA("Leave");
- return true;
-}
-
-bool
-CicoSCResourceManager::releaseOnScreenDisplayResource(resource_request_t *req)
-{
- ICO_TRA("Enter %08x", req);
- if (NULL == req) {
- ICO_TRA("Leave param is NULL pointer");
- return false;
- }
- resource_request_t* tgt = NULL;
- list<resource_request_t*>::iterator itr = m_OnScreenItems.begin();
- for (; itr != m_OnScreenItems.end(); ++itr) {
- if ((req->pid == (*itr)->pid) &&
- (req->resourceId == (*itr)->resourceId)) {
- tgt = (*itr);
- break; // break of for itr
- }
- }
-
- if (NULL != tgt) {
- ICO_TRA("_____ erase list %x", tgt);
- m_OnScreenItems.erase(itr);
- }
-
- const resource_request_t* rrtHO = getNoticeOfHighOder();
-
- const CicoSCWindow* bwo = NULL; // before window oject
- const CicoSCWindow* awo = NULL; // after window object
- if (NULL != m_rrtHO) {
- bwo = m_winCtrl->findWindowObj(m_rrtHO->pid, m_rrtHO->resourceId);
- }
- if (NULL != rrtHO) {
- awo = m_winCtrl->findWindowObj(rrtHO->pid, rrtHO->resourceId);
- }
-
- if ((NULL == rrtHO) && (NULL == m_rrtHO)) {
- ICO_WRN("ON SCREEN Resource NG");
- if (NULL != tgt) {
- resCB(ICO_SYC_EV_RES_RELEASE, *tgt);
- delResourceRequest(tgt);
- }
- delResourceRequest(req);
- ICO_TRA("Leave ON SCREEN Resource NG");
- return false;
- }
-
- if (rrtHO != m_rrtHO) {
- if (NULL != m_rrtHO) {
- if (NULL != bwo) {
- m_winCtrl->hide(bwo->surfaceid, NULL, 0);
- if (m_rrtHO != tgt) {
- ICO_DBG("_____ NG Control OnScreen Resource %x(%d, %d), %x",
- m_rrtHO, m_rrtHO->pid, m_rrtHO->resourceId, tgt);
- resCB(ICO_SYC_EV_RES_WAITING, *m_rrtHO);
- }
- }
- else {
- ICO_WRN("ON SCREEN Hide control NG");
- }
- }
- if (NULL != rrtHO) {
- if (NULL != awo) {
- m_winCtrl->show(awo->surfaceid, NULL, 0);
- m_winCtrl->raise(awo->surfaceid, NULL, 0);
- resCB(ICO_SYC_EV_RES_ACQUIRE, *rrtHO);
- }
- else {
- ICO_WRN("ON SCREEN Hide control NG");
- }
- }
- else {
- if (NULL != bwo) {
- m_winCtrl->hideLayer(bwo->displayid, bwo->layerid);
- }
- else {
- ICO_WRN("ON SCREEN layer hide control NG");
- }
- }
- m_rrtHO = rrtHO;
- }
- else {
- ICO_TRA("_____ no change");
- }
- // memory free
- if (NULL != tgt) {
- resCB(ICO_SYC_EV_RES_RELEASE, *tgt);
- delResourceRequest(tgt);
- }
- delResourceRequest(req);
- ICO_TRA("Leave");
- return true;
-}
-
-bool
-CicoSCResourceManager::resCB(const ico_syc_ev_e ev, const resource_request_t& p) const
-{
- ICO_TRA("Enter %d", (int)ev);
- if ((NULL == p.appid) || (0 == strlen(p.appid))) {
- ICO_TRA("Leave false");
- return false;
- }
- if (false == p.bEx) {
- ICO_TRA("Leave false");
- return false;
- }
- int nEv = -1;
- if (ICO_SYC_EV_RES_ACQUIRE == ev) {
- nEv = MSG_CMD_ACQUIRE_RES;
- }
- else if (ICO_SYC_EV_RES_DEPRIVE == ev) {
- nEv = MSG_CMD_DEPRIVE_RES;
- }
- else if (ICO_SYC_EV_RES_WAITING == ev) {
- nEv = MSG_CMD_WAITING_RES;
- }
- else if (ICO_SYC_EV_RES_REVERT == ev) {
- nEv = MSG_CMD_REVERT_RES;
- }
- else if (ICO_SYC_EV_RES_RELEASE == ev) {
- nEv = MSG_CMD_RELEASE_RES;
- }
- else if (ICO_SYC_EV_RES_WINDOW_ID == ev) {
- nEv = MSG_CMD_WINDOW_ID_RES;
- }
- else {
- ICO_TRA("Leave false ev(%d) is not supp.",(int)ev);
- return false;
- }
-
- bool r;
- r = resCB(p.appid, nEv, p.ECU, p.display, p.layer, p.layout, p.area,
- p.dispatchApp, p.role, p.resourceId);
- ICO_TRA("Leave %s", r? "true":"false");
- return r;
-}
-
-bool
-CicoSCResourceManager::resCB(const char* sendToAppid, const int ev,
- const char* ECU, const char* display,
- const char* layer, const char* layout,
- const char* area, const char* dispatchApp,
- const char* role, uint32_t resourceId) const
-{
- ICO_TRA("Enter");
- if (NULL == sendToAppid) {
- ICO_TRA("Leave false");
- return false;
- }
- CicoSCMessageRes* msg = new CicoSCMessageRes();
- msg->addRootObject("command", ev);
- if (NULL != ECU) {
- msg->addWinObject("ECU", ECU);
- }
- if (NULL != display) {
- msg->addWinObject("display", display);
- }
- if (NULL != layer) {
- msg->addWinObject("layer", layer);
- }
- if (NULL != layout) {
- msg->addWinObject("layout", layout);
- }
- if (NULL != area) {
- msg->addWinObject("area", area);
- }
- if (NULL != dispatchApp) {
- msg->addWinObject("dispatchApp", dispatchApp);
- }
- if (NULL != role) {
- msg->addWinObject("role", role);
- }
- msg->addWinObject("resourceId", resourceId);
- CicoSCServer *cscs = CicoSCServer::getInstance();
- int r = cscs->sendMessage(sendToAppid, (CicoSCMessage*)msg);
- if (ICO_SYC_EOK != r) {
- ICO_TRA("Leave false(%d)", r);
- return false;
- }
- ICO_TRA("Leave true");
- return true;
-}
-
-const resource_request_t* CicoSCResourceManager::getNoticeOfHighOder()
-{
- ICO_TRA("Enter (%d)", (int)m_OnScreenItems.size());
- const CicoSCRoleConf* rC = CicoSystemConfig::getInstance()->getRoleConf();
- m_policyMgr->sendSMEvent(rC->m_rst); // RESET OnScreen State
- const resource_request_t* r = NULL;
- list<resource_request_t*>::iterator itr = m_OnScreenItems.begin();
- for (; itr != m_OnScreenItems.end(); ++itr) {
- short hEv = (*itr)->role_stt;
- if ((ICO_SYC_ROLE_CONF_DEF == hEv) || (0 == hEv)) {
- continue; // continue of for itr
- }
- bool test = m_policyMgr->testSMEvent(hEv);
- if (true == m_policyMgr->sendSMEvent(hEv)) {
- r = (*itr);
- }
- else if (true == test) {
- r = (*itr);
- }
- }
- ICO_TRA("Leave %x", r);
- return r;
-}
-
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCResourceManager.h
- *
- * @brief This file is definition of CicoSCResourceManager class
- */
-//==========================================================================
-#ifndef __CICO_SC_RESOURCE_MANAGER_H__
-#define __CICO_SC_RESOURCE_MANAGER_H__
-
-#include <list>
-#include <vector>
-#include <map>
-using namespace std;
-
-#include "ico_syc_mrp_resource_private.h"
-#include "ico_syc_appresctl.h"
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCCommand;
-class CicoSCPolicyManager;
-class CicoSCWindowController;
-class CicoSCInputController;
-
-//==========================================================================
-/*
- * @brief This class manages resources
- */
-//==========================================================================
-class CicoSCResourceManager
-{
-public:
- // default constructor
- CicoSCResourceManager();
-
- // destructor
- ~CicoSCResourceManager();
-
- // initialize resource manager
- int initialize(void);
-
- // terminate resource manager
- void terminate(void);
-
- // handling command
- void handleCommand(const CicoSCCommand &cmd, bool internal=false);
-
- // set CicoSCWindowController instance
- void setWindowController(CicoSCWindowController *winCtrl);
-
- // set CicoSCInputController instance
- void setInputController(CicoSCInputController *inputCtrl);
-
- // receive changed state
- void receiveChangedState(int state);
-
- // get resource manager instance
- CicoSCPolicyManager * getPolicyManager(void);
-
-private:
- // assignment operator
- CicoSCResourceManager& operator=(const CicoSCResourceManager &object);
-
- // copy constructor
- CicoSCResourceManager(const CicoSCResourceManager &object);
-
- bool acquireDisplayResource(resource_request_t *newreq,
- bool control = true);
- void releaseDisplayResource(resource_request_t *newreq);
-
- bool acquireSoundResource(resource_request_t *newreq);
- void releaseSoundResource(resource_request_t *newreq);
-
- bool acquireInputResource(resource_request_t *newreq);
- void releaseInputResource(resource_request_t *newreq);
-
- resource_request_t* newResourceRequest(int resid,
- int reqtype,
- const CicoSCCommand &cmd);
-
- void delResourceRequest(resource_request_t *req);
-
- static void enforceSound(unsigned short state,
- resource_request_t *req,
- void *user_data);
-
- resource_request_t * popDispResReq(resource_request_t *req);
-
- resource_request_t * popSoundResReq(resource_request_t *req);
-
- resource_request_t * popInputResReq(resource_request_t *req);
-
- void updateDisplayResource(resource_request_t *req, int chgzoneid=-1);
- void updateSoundResource(resource_request_t *req);
- void updateInputResource(resource_request_t *req);
-
- void updateDisplayResourceRegulation(int state);
- void updateSoundResourceRegulation(int state);
- void updateInputResourceRegulation(int state);
-
- void updateDispResRegulationPreProc(resource_request_t *req);
- void updateSoundResRegulationPreProc(resource_request_t *req);
- void updateInputResRegulationPreProc(resource_request_t *req);
-
- resource_request_t * findCurDispResOwerReq(resource_request_t *req);
- resource_request_t * popCurDispResOwerReq(resource_request_t *req);
- void dumpCurDispResOwerReq(void);
-
- resource_request_t * findWaitingDispResReq(resource_request_t *req);
- resource_request_t * popWaitingDispResReq(resource_request_t *req);
- void dumpWaitingDispResReq(void);
-
- bool isMatchDisplayed(void);
- bool acquireOnScreenDisplayResource(resource_request_t *req);
- bool releaseOnScreenDisplayResource(resource_request_t *req);
- const resource_request_t* getNoticeOfHighOder();
- bool resCB(const ico_syc_ev_e ev, const resource_request_t& p) const;
- bool resCB(const char* sendToAppid, const int ev, const char* ECU,
- const char* display, const char* layer, const char* layout,
- const char* area, const char* dispatchApp, const char* role,
- uint32_t resourceId) const;
- bool isTypeBaseic(const resource_request_t& p);
- bool isTypeInterrupt(const resource_request_t& p);
- bool isTypeOnScreen(const resource_request_t& p);
-private:
- CicoSCPolicyManager *m_policyMgr;
- CicoSCWindowController *m_winCtrl;
- CicoSCInputController *m_inputCtrl;
-
- // pair zoneid and request
- std::map<unsigned int, resource_request_t*> m_curDispResOwerReq;
- std::map<int, resource_request_t*> m_curSoundResReq;
- std::map<int, resource_request_t*> m_curInputResReq;
-
- std::list<resource_request_t*> m_waitingDispResReq;
- map<int, list<resource_request_t*> > m_soundReqQueue;
- map<int, list<resource_request_t*> > m_inputReqQueue;
- std::list<resource_request_t*> m_OnScreenItems;
- const resource_request_t* m_rrtHO; // resource_request_t of High Oder
-
- // show/hide animation name at regulation on or off
- const std::string m_animaName;
-
- // show/hide animation time at regulation on or off
- int m_animaTime;
-};
-
-//==========================================================================
-/**
- * @brief check type is basic
- * @param p resorce request info
- * @ret bool
- * @retval true: basic
- * @retval false: not basic
- */
-inline bool CicoSCResourceManager::isTypeBaseic(const resource_request_t& p)
-{
- return (RESID_TYPE_BASIC == (p.resid & RESID_TYPE_MASK));
-}
-
-//==========================================================================
-/**
- * @brief check type is interrupt
- * @param p resorce request info
- * @ret bool
- * @retval true: interrupt
- * @retval false: not interrupt
- */
-inline bool CicoSCResourceManager::isTypeInterrupt(const resource_request_t& p)
-{
- return (RESID_TYPE_INTERRUPT == (p.resid & RESID_TYPE_MASK));
-}
-
-//==========================================================================
-/**
- * @brief check type is onscreen
- * @param p resorce request info
- * @ret bool
- * @retval true: onscreen
- * @retval false: not onscreen
- */
-//==========================================================================
-inline bool CicoSCResourceManager::isTypeOnScreen(const resource_request_t& p)
-{
- return (RESID_TYPE_ONSCREEN == (p.resid & RESID_TYPE_MASK));
-}
-#endif // __CICO_SC_RESOURCE_MANAGER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCServer.cpp
- *
- * @brief This file implementation of CicoSCServer class
- */
-//==========================================================================
-
-#include <sstream>
-using namespace std;
-
-#include "CicoSCServer.h"
-#include "CicoSCCommand.h"
-#include "CicoSCMessage.h"
-#include "CicoLog.h"
-#include "ico_syc_error.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "CicoSCWindowController.h"
-#include "CicoSCInputController.h"
-#include "CicoSCUserManager.h"
-#include "CicoSCUser.h"
-#include "CicoSCResourceManager.h"
-#include "CicoSCPolicyManager.h"
-
-class CicoSCUwsHandler
-{
-public:
- CicoSCUwsHandler()
- : uwsContext(NULL), id(NULL), fd(-1), serviceFlag(false),
- ecoreFdHandler(NULL), appid("") {}
- void dump(void) const {
- ICO_DBG("uwsContext=0x%08x fd=%d service=%s "
- "ecoreFdHandler=0x%08x appid=%s",
- uwsContext, fd, serviceFlag ? "true" : "false",
- ecoreFdHandler, appid.c_str());
- }
- struct ico_uws_context *uwsContext;
- void* id;
- int fd;
- bool serviceFlag;
- Ecore_Fd_Handler *ecoreFdHandler;
- string appid;
-};
-
-//==========================================================================
-// private static variable
-//==========================================================================
-CicoSCServer* CicoSCServer::ms_myInstance = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCServer::CicoSCServer()
- : m_uwsContext(NULL), m_windowCtrl(NULL),
- m_inputCtrl(NULL) , m_userMgr(NULL), m_resourceMgr(NULL),
- m_policyMgr(NULL), m_dispatchProcessing(false)
-{
- CicoSCServer::ms_myInstance = this;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCServer::~CicoSCServer()
-{
- CicoSCServer::ms_myInstance = NULL;
- if (NULL != m_uwsContext) {
- ico_uws_close(m_uwsContext);
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get CicoSCServer instance
- *
- * @return CicoSCServer instance
- */
-//--------------------------------------------------------------------------
-CicoSCServer*
-CicoSCServer::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCServer();
- }
-
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set window controller instance
- *
- * @param [in] windowCtrl controller instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::setWindowCtrl(CicoSCWindowController *windowCtrl)
-{
- m_windowCtrl = windowCtrl;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set input controller instance
- *
- * @param [in] inputCtrl controller instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::setInputCtrl(CicoSCInputController *inputCtrl)
-{
- m_inputCtrl= inputCtrl;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set user manager
- *
- * @param [in] userMgr user manager instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::setUserMgr(CicoSCUserManager *userMgr)
-{
- m_userMgr = userMgr;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set resource manager instance
- *
- * @param [in] resourceMgr resouce manager instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::setResourceMgr(CicoSCResourceManager *resourceMgr)
-{
- m_resourceMgr = resourceMgr;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set policy manager instance
- *
- * @param [in] policyMgr policy manager instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::setPolicyMgr(CicoSCPolicyManager *policyMgr)
-{
- m_policyMgr = policyMgr;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief startup server
- *
- * @param [in] port websocket port
- * @param [in] protocol websocket protocol name
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ENOSYS error(connection fail)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCServer::startup(int port, const char *protocol)
-{
- /* create uir string ":PORT" */
- stringstream uri;
- uri << ":" << port;
-
- /* create context */
- ICO_DBG("called: ico_uws_create_context(port=%s protocol=%s)",
- uri.str().c_str(), protocol);
- m_uwsContext = ico_uws_create_context(uri.str().c_str(), protocol);
- if (NULL == m_uwsContext) {
- ICO_ERR("ico_uws_create_context() failed.");
- return ICO_SYC_ENOSYS;
- }
- ico_uws_service(m_uwsContext);
-
- /* set callback */
- int ret = ico_uws_set_event_cb(m_uwsContext, uwsReceiveEventCB,
- (void *)this);
- if (ret != ICO_UWS_ERR_NONE) {
- ICO_ERR("ico_uws_set_event_cb() failed(%d).", ret);
- return ICO_SYC_ENOSYS;
- }
- ico_uws_service(m_uwsContext);
-
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief teardown server
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::teardown(void)
-{
- ICO_TRA("CicoSCServer::teardown Enter");
- {
- std::list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
- if (NULL != (*itr)->ecoreFdHandler) {
- ecore_main_fd_handler_del((*itr)->ecoreFdHandler);
- (*itr)->ecoreFdHandler = NULL;
- }
- delete(*itr);
- }
- m_uwsHandlerList.clear();
- }
-
- {
- std::list<CicoSCMessage*>::iterator itr;
- itr = m_sendMsgQueue.begin();
- for (; itr != m_sendMsgQueue.end(); ++itr) {
- delete(*itr);
- }
- m_sendMsgQueue.clear();
- }
-
- {
- std::list<CicoSCCommand*>::iterator itr;
- itr = m_recvCmdQueue.begin();
- for (; itr != m_recvCmdQueue.end(); ++itr) {
- delete(*itr);
- }
- }
-
- if (NULL != m_uwsContext) {
- ico_uws_close(m_uwsContext);
- m_uwsContext = NULL;
- }
- ICO_TRA("CicoSCServer::teardown Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add poll websocket file destructor
- *
- * @param [in] handler websocket handler
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::addPollFd(CicoSCUwsHandler *handler)
-{
- ICO_TRA("CicoSCServer::addPollFd Enter(fd=%d)", handler->fd);
- Ecore_Fd_Handler_Flags flags;
- flags = (Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_ERROR);
-
- handler->ecoreFdHandler = ecore_main_fd_handler_add(handler->fd, flags,
- ecoreFdCallback,
- this, NULL, NULL);
-
- ICO_DBG("Enqueue uwsHandler(0x%08x)", handler);
- m_uwsHandlerList.push_back(handler);
-
- ICO_TRA("CicoSCServer::addPollFd Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief delete poll websocket file destructor
- *
- * @param [in] handler websocket handler
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::delPollFd(CicoSCUwsHandler *handler)
-{
- ICO_TRA("CicoSCServer::delPollFd Enter");
-
- if (NULL == handler) {
- ICO_WRN("handler is null");
- ICO_TRA("CicoSCServer::delPollFd Leave");
- return;
- }
-
- if (NULL != handler->ecoreFdHandler) {
- ecore_main_fd_handler_del(handler->ecoreFdHandler);
- handler->ecoreFdHandler = NULL;
- }
-
- list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
- if (*itr == handler) {
- ICO_DBG("Dequeue uwsHandler(0x%08x)", *itr);
- m_uwsHandlerList.erase(itr);
- break;
- }
- }
- delete handler;
-
- ICO_TRA("CicoSCServer::delPollFd Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dispatch receive message process and send message process
- *
- * @param [in] handler websocket handler
- *
- * @return websocket handler instance on find, NULL on not found
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::dispatch(const CicoSCUwsHandler *handler)
-{
-// ICO_TRA("CicoSCServer::dispatch Enter(handler=0x%08x)", handler);
-
- if (NULL == handler) {
- ICO_WRN("handler is null");
- ICO_TRA("CicoSCServer::dispatch Leave");
- return;
- }
-
- ico_uws_service(handler->uwsContext);
-
- // There is a possibility that after calling ico_uws_service function,
- // the file is deleted. Check whether handler not the disabled.
- if (false == isExistUwsHandler(handler)) {
- ICO_TRA("CicoSCServer::dispatch Leave");
- return;
- }
-
- if (true == m_dispatchProcessing) {
- ICO_TRA("CicoSCServer::dispatch Leave(disptch processing)");
- return;
- }
-
- m_dispatchProcessing = true;
- list<CicoSCCommand*>::iterator itr;
- itr = m_recvCmdQueue.begin();
- while(itr != m_recvCmdQueue.end()) {
- ICO_DBG("Dequeue command(0x%08x)", (*itr)->cmdid);
- CicoSCCommand *cmd = *itr;
- itr = m_recvCmdQueue.erase(itr);
- switch (cmd->cmdid & MSG_CMD_TYPE_MASK) {
- case MSG_CMD_TYPE_WINCTRL:
- //ICO_DBG("command : MSG_CMD_TYPE_WINCTRL");
- m_windowCtrl->handleCommand(cmd);
- break;
- case MSG_CMD_TYPE_INPUTCTRL:
- //ICO_DBG("command : MSG_CMD_TYPE_INPUTCTRL");
- m_inputCtrl->handleCommand(cmd);
- break;
- case MSG_CMD_TYPE_USERMGR:
- //ICO_DBG("command : MSG_CMD_TYPE_USERMGR");
- m_userMgr->handleCommand(cmd);
- break;
- case MSG_CMD_TYPE_RESOURCEMGR:
- //ICO_DBG("command : MSG_CMD_TYPE_RESOURCEMGR");
- m_resourceMgr->handleCommand(*cmd);
- break;
- case MSG_CMD_TYPE_INPUTDEVSETTING:
- //ICO_DBG("command : MSG_CMD_TYPE_INPUTDEVSETTING");
- m_inputCtrl->handleCommand(cmd);
- break;
- default:
- ICO_WRN("command: Unknown type");
- break;
- }
- delete cmd;
- }
- m_dispatchProcessing = false;
-
- if (NULL == handler->ecoreFdHandler) {
- ICO_ERR("ecoreFdHandler is null");
- ICO_TRA("CicoSCServer::dispatch Leave");
- return;
- }
-
- Eina_Bool flag = ecore_main_fd_handler_active_get(handler->ecoreFdHandler,
- ECORE_FD_WRITE);
- if (EINA_TRUE == flag) {
-// ICO_DBG("start send message");
- list<CicoSCMessage*>::iterator send_itr;
- send_itr = m_sendMsgQueue.begin();
- while (send_itr != m_sendMsgQueue.end()) {
-// ICO_DBG("m_sendMsgQueue.size=%d", m_sendMsgQueue.size());
- CicoSCMessage* msg = *send_itr;
- CicoSCUwsHandler *sendHandler = findUwsHandler(msg->getSendToAppid());
- if (handler != sendHandler) {
- ++send_itr;
- continue;
- }
- send_itr = m_sendMsgQueue.erase(send_itr);
- ICO_DBG("Dequeue Message(id=%d)", msg->getId());
- if ((NULL != sendHandler) && (true == sendHandler->serviceFlag)) {
- const char *data = msg->getData();
- ICO_DBG("<<<SEND appid=%s id=0x%08x msg=%s",
- sendHandler->appid.c_str(), sendHandler->id, data);
-// ICO_DBG("called: ico_usw_send called(context=0x%08x id=0x%08x)",
-// sendHandler->uwsContext, sendHandler->id);
- ico_uws_send(sendHandler->uwsContext, sendHandler->id,
- (unsigned char *)data, strlen(data));
-
- delete msg;
-
- usleep(200);
- }
- }
-
- Ecore_Fd_Handler_Flags flags;;
- flags = (Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_ERROR);
-
- ecore_main_fd_handler_active_set(handler->ecoreFdHandler, flags);
- }
-
-// ICO_TRA("CicoSCServer::dispatch Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief send message to application client
- *
- * @param [in] appid application id of destination
- * @param [in] msg message
- *
- * @return ICO_SYC_EOK on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCServer::sendMessage(const string & appid, CicoSCMessage* msg)
-{
- ICO_TRA("CicoSCServer::sendMessage Enter(appid=%s, msg=%s)",
- appid.c_str(), msg->getData());
-
- msg->setSendToAppid(appid);
- ICO_DBG("Enqueue Message(id=%d)", msg->getId());
- m_sendMsgQueue.push_back(msg);
-
- CicoSCUwsHandler *handler = findUwsHandler(appid);
- if (NULL != handler) {
- Ecore_Fd_Handler_Flags flags;
- flags = (Ecore_Fd_Handler_Flags)(ECORE_FD_READ |
- ECORE_FD_WRITE |
- ECORE_FD_ERROR);
-
- ecore_main_fd_handler_active_set(handler->ecoreFdHandler, flags);
-
- dispatch(handler);
- }
-
- ICO_TRA("CicoSCServer::sendMessage Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief send message to homescreen
- *
- * @param [in] msg message
- *
- * @return ICO_SYC_EOK on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCServer::sendMessageToHomeScreen(CicoSCMessage* msg)
-{
- // if user change processing(homescree is not running)
- if (true == m_userMgr->isStoppingNow()) {
- ICO_DBG("homescreen not running");
- delete msg;
- return ICO_SYC_ENOENT;
- }
-
- const CicoSCUser *loginUser = m_userMgr->getLoginUser();
- if (NULL == loginUser) {
- ICO_WRN("homescreen unknown");
- delete msg;
- return ICO_SYC_ENOENT;
- }
- return sendMessage(loginUser->homescreen, msg);
-}
-
-//--------------------------------------------------------------------------
-/*
- * @brief websocket utility callback function
- *
- * @param [in] context context
- * @param [in] event event kinds
- * @param [in] id client id
- * @param [in] detail event detail
- * @param [in] data user data
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::uwsReceiveEventCB(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data)
-{
- if (NULL == user_data) {
- ICO_ERR("user_data is NULL");
- return;
- }
-
- CicoSCServer* server = static_cast<CicoSCServer*>(user_data);
- server->receiveEventCB(context, event, id, detail, user_data);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief ecore file destructor callback fucntion
- *
- * @param [in] data user data
- * @param [in] handler ecore file destructor handler
- *
- * @return ECORE_CALLBACK_RENEW on retry , ECORE_CALLBACK_CANCEL on cancel
- */
-//--------------------------------------------------------------------------
-Eina_Bool
-CicoSCServer::ecoreFdCallback(void *data, Ecore_Fd_Handler *ecoreFdhandler)
-{
-// ICO_TRA("CicoSCServer::ecoreFdCallback Enter");
-
- CicoSCUwsHandler *handler = NULL;
- handler = static_cast<CicoSCServer*>(data)->findUwsHandler(ecoreFdhandler);
- if (NULL != handler) {
- static_cast<CicoSCServer*>(data)->dispatch(handler);
- }
-
-// ICO_TRA("CicoSCServer::ecoreFdCallback Leave");
- return ECORE_CALLBACK_RENEW;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief websocket callback function
- *
- * @param [in] context websocket context
- * @param [in] event changed event
- * @param [in] id source applicatin id
- * @param [in] detail event detail information
- * @param [in] user_data user data
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::receiveEventCB(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data)
-{
-// ICO_TRA("CicoSCServer::receiveEventCB Enter");
-
- switch (event) {
- case ICO_UWS_EVT_CLOSE:
- ICO_DBG(">>>RECV ICO_UWS_EVT_CLOSE(id=%p)", id);
-// ICO_TRA("CicoSCServer::receiveEventCB Leave");
- return;
- case ICO_UWS_EVT_ERROR:
- ICO_DBG(">>>RECV ICO_UWS_EVT_ERROR(id=%p, err=%d)",
- id, detail->_ico_uws_error.code);
-// ICO_TRA("CicoSCServer::receiveEventCB Leave");
- return;
- default:
- break;
- }
-
- // find handler
- CicoSCUwsHandler *handler = findUwsHandler(context, id);
- // If not found handler, create new handler
- if (NULL == handler) {
- handler = new CicoSCUwsHandler();
- handler->uwsContext = (struct ico_uws_context*)context;
- handler->id = (void*)(id);
- handler->serviceFlag = false;
- }
-
- switch (event) {
- case ICO_UWS_EVT_OPEN:
- ICO_DBG(">>>RECV ICO_UWS_EVT_OPEN(id=%p)", id);
- break; // break of switch event
- case ICO_UWS_EVT_CLOSE:
- ICO_DBG(">>>RECV ICO_UWS_EVT_CLOSE(id=%p)", id);
- delete handler;
- break; // break of switch event
- case ICO_UWS_EVT_RECEIVE:
- {
- ICO_DBG(">>>RECV ICO_UWS_EVT_RECEIVE(id=%p, msg=%s, len=%d)",
- id, (char *)detail->_ico_uws_message.recv_data,
- detail->_ico_uws_message.recv_len);
-
- // convert message to command
- CicoSCCommand *cmd = new CicoSCCommand();
- cmd->parseMessage((const char*)detail->_ico_uws_message.recv_data);
-
- // update handler appid
- if (cmd->cmdid == MSG_CMD_SEND_APPID) {
- if (0 == cmd->appid.length()) {
- ICO_WRN("command argument invalid appid null");
- delete cmd;
- break; // break of switch event
- }
- handler->appid = cmd->appid;
- handler->serviceFlag = true;
- ICO_DBG("handler.appid=%s", handler->appid.c_str());
-
- Ecore_Fd_Handler_Flags flags;
- flags = (Ecore_Fd_Handler_Flags)(ECORE_FD_READ |
- ECORE_FD_WRITE |
- ECORE_FD_ERROR);
-
- ecore_main_fd_handler_active_set(handler->ecoreFdHandler, flags);
-
- notifyConnected(handler->appid);
- delete cmd;
- break; // break of switch event
- }
-
- // Enqueue command
- ICO_DBG("Enqueue command(0x%08x)", cmd->cmdid);
- m_recvCmdQueue.push_back(cmd);
- break; // break of switch event
- }
- case ICO_UWS_EVT_ADD_FD:
- ICO_DBG(">>>RECV ICO_UWS_EVT_ADD_FD(id=%p, fd=%d)",
- id, detail->_ico_uws_fd.fd);
- handler->fd = detail->_ico_uws_fd.fd;
- addPollFd(handler);
- break; // break of switch event
- case ICO_UWS_EVT_DEL_FD:
- ICO_DBG(">>>RECV ICO_UWS_EVT_DEL_FD(id=%p, fd=%d, appid=%s)",
- id, detail->_ico_uws_fd.fd, handler->appid.c_str());
- clearRecvCmdQueue(handler->appid);
- clearSendMsgQueue(handler->appid);
- delPollFd(handler);
- break; // break of switch event
- default:
- break; // break of switch event
- }
-// ICO_TRA("CicoSCServer::receiveEventCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief clear receive command queue
- *
- * @param [in] appid clear command application id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::clearRecvCmdQueue(const std::string & appid)
-{
- ICO_TRA("CicoSCServer::clearCmdQueue Enter(appid=%s)", appid.c_str());
-
- std::list<CicoSCCommand*>::iterator itr;
- itr = m_recvCmdQueue.begin();
- for (; itr != m_recvCmdQueue.end(); ) {
- if (0 == appid.compare((*itr)->appid)) {
- ICO_DBG("Dequeue command(0x%08x)", (*itr)->cmdid);
- delete *itr;
- itr = m_recvCmdQueue.erase(itr);
- }
- else {
- ++itr;
- }
- }
-
- ICO_TRA("CicoSCServer::clearCmdQueue Leave")
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief clear send message queue
- *
- * @param [in] appid clear message application id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::clearSendMsgQueue(const std::string & appid)
-{
- ICO_TRA("CicoSCServer::clearMsgQueue Enter(appid=%s)", appid.c_str())
-
- std::list<CicoSCMessage*>::iterator itr;
- itr = m_sendMsgQueue.begin();
- while(itr != m_sendMsgQueue.end()) {
- if (0 == appid.compare((*itr)->getSendToAppid())) {
- ICO_DBG("Dequeue Message(id=%d)", (*itr)->getId());
- delete *itr;
- itr = m_sendMsgQueue.erase(itr);
- }
- else {
- ++itr;
- }
- }
-
- ICO_TRA("CicoSCServer::clearMsgQueue Leave")
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find websocket handler by context and id
- *
- * @param [in] context websocket context
- * @param [in] id id
- *
- * @return websocket handler instance on find, NULL on not found
- */
-//--------------------------------------------------------------------------
-CicoSCUwsHandler*
-CicoSCServer::findUwsHandler(const struct ico_uws_context *context,
- const void *id)
-{
- list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
-// ICO_DBG("handler->context=%p handler->id=%p context=%p id=%p",
-// (*itr)->uwsContext, (*itr)->id, context, id);
- if (((*itr)->uwsContext == context) &&
- ((*itr)->id == id)) {
- return *itr;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find websocket handler by ecore file destructor handler
- *
- * @param [in] ecoreFdHandler ecore file destructor handler
- *
- * @return websocket handler instance on find, NULL on not found
- */
-//--------------------------------------------------------------------------
-CicoSCUwsHandler*
-CicoSCServer::findUwsHandler(const Ecore_Fd_Handler *ecoreFdHandler)
-{
- list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
- if ((*itr)->ecoreFdHandler == ecoreFdHandler) {
- return *itr;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find websocket handler by appid
- *
- * @param [in] addid application id
- *
- * @return websocket handler instance on find, NULL on not found
- */
-//--------------------------------------------------------------------------
-CicoSCUwsHandler*
-CicoSCServer::findUwsHandler(const string & appid)
-{
- list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
-// ICO_DBG("handler->id=%p handler->appid=%s appid=%s",
-// (*itr)->id, (*itr)->appid.c_str(), appid.c_str());
- if ((*itr)->appid == appid) {
- return *itr;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find websocket handler by appid
- *
- * @param [in] handler websocket handler instance
- *
- * @return true on exist, false on not exist
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCServer::isExistUwsHandler(const CicoSCUwsHandler *handler)
-{
- list<CicoSCUwsHandler*>::iterator itr;
- itr = m_uwsHandlerList.begin();
- for (; itr != m_uwsHandlerList.end(); ++itr) {
- if (*itr == handler) {
- return true;
- }
- }
- return false;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief notify information to homescreen on connected
- *
- * @param [in] appid application id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCServer::notifyConnected(const std::string & appid)
-{
- const CicoSCUser *loginUser = m_userMgr->getLoginUser();
- if (NULL == loginUser) {
- ICO_WRN("homescreen unknown");
- return;
- }
-
- // if appid equal homescreen
- if (0 == loginUser->homescreen.compare(appid)) {
- if (NULL != m_policyMgr) {
- m_policyMgr->notifyConnected(appid);
- }
- }
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCServer.h
- *
- * @brief This file is definition of CicoSCServer class
- */
-//==========================================================================
-#ifndef __CICO_SC_SERVER_H__
-#define __CICO_SC_SERVER_H__
-
-#include <list>
-#include <string>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include <ico_uws.h>
-
-//==========================================================================
-// forward declaration
-//==========================================================================
-class CicoSCUwsHandler;
-class CicoSCMessage;
-class CicoSCCommand;
-class CicoSCWindowController;
-class CicoSCInputController;
-class CicoSCUserManager;
-class CicoSCResourceManager;
-class CicoSCPolicyManager;
-
-//==========================================================================
-/**
- * @brief This class has function of interprocess message server
- */
-//==========================================================================
-class CicoSCServer
-{
-public:
- // get CicoSCServer instance
- static CicoSCServer* getInstance();
-
- // set window controller instance
- void setWindowCtrl(CicoSCWindowController* windowCtrl);
-
- // set input controller instance
- void setInputCtrl(CicoSCInputController* inputCtrl);
-
- // set input controller instance
- void setUserMgr(CicoSCUserManager* userMgr);
-
- // set resource manager instance
- void setResourceMgr(CicoSCResourceManager* resourceMgr);
-
- // set resource manager instance
- void setPolicyMgr(CicoSCPolicyManager* policyMgr);
-
- // startup server
- int startup(int port, const char *protocol);
-
- // startup server
- void teardown(void);
-
- // send message to application client
- int sendMessage(const std::string & appid, CicoSCMessage* msg);
-
- // send message to homescreen
- int sendMessageToHomeScreen(CicoSCMessage* msg);
-
- // websocket callback function
- void receiveEventCB(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data);
-
- // clear receive command queue
- void clearRecvCmdQueue(const std::string & appid);
-
- // clear send message queue
- void clearSendMsgQueue(const std::string & appid);
-
-private:
- // default constructor
- CicoSCServer();
-
- // destructor
- ~CicoSCServer();
-
- // assignment operator
- CicoSCServer& operator=(const CicoSCServer &object);
-
- // copy constructor
- CicoSCServer(const CicoSCServer &object);
-
- // websocket utility callback function
- static void uwsReceiveEventCB(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data);
-
- // ecore file destructor callback fucntion
- static Eina_Bool ecoreFdCallback(void *data,
- Ecore_Fd_Handler *handler);
-
- // add poll websocket file destructor
- void addPollFd(CicoSCUwsHandler *handler);
-
- // delete poll websocket file destructor
- void delPollFd(CicoSCUwsHandler *handler);
-
- // dispatch receive message process and send message process
- void dispatch(const CicoSCUwsHandler *handler);
-
- // find websocket handle by context and id
- CicoSCUwsHandler* findUwsHandler(const struct ico_uws_context *context,
- const void *id);
-
- // find websocket handle by ecore file destructor handler
- CicoSCUwsHandler* findUwsHandler(const Ecore_Fd_Handler *ecoreFdHandler);
-
- // find websocket handle by appid
- CicoSCUwsHandler* findUwsHandler(const std::string & appid);
-
- // query whether the handler exists
- bool isExistUwsHandler(const CicoSCUwsHandler *handler);
-
- // notify connected appilication
- void notifyConnected(const std::string & appid);
-
-private:
- static CicoSCServer* ms_myInstance; ///< this class instance
-
- struct ico_uws_context *m_uwsContext; ///< websocket utility context
-
- CicoSCWindowController *m_windowCtrl; ///< window controller instance
- CicoSCInputController *m_inputCtrl; ///< input controller instance
- CicoSCUserManager *m_userMgr; ///< user manager instance
- CicoSCResourceManager *m_resourceMgr; ///< resource manager instance
- CicoSCPolicyManager *m_policyMgr; ///< policy manager instance
-
- bool m_dispatchProcessing;
-
- /// websocket handler list
- std::list<CicoSCUwsHandler*> m_uwsHandlerList;
-
- /// send message queue
- std::list<CicoSCMessage*> m_sendMsgQueue;
-
- /// recieve message queue
- std::list<CicoSCCommand*> m_recvCmdQueue;
-};
-#endif // __CICO_SC_SERVER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCSwitch.cpp
- *
- * @brief This file implementation of CicoSCSwitch class
- */
-//==========================================================================
-
-#include <vector>
-#include <string>
-using namespace std;
-
-#include "CicoSCSwitch.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCSwitch::CicoSCSwitch()
- : swname(""), input(-1), fix(false)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCSwitch::~CicoSCSwitch()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCSwitch::dump(void)
-{
- ICO_DBG("CicoSCSwitch: swname=%s input=%d fix=%d numCode=%d",
- swname.c_str(), input, fix);
- for (unsigned int i = 0; i < code.size(); ++i) {
- ICO_DBG("CicoSCSwitch: [%d] code=%d codename=%s",
- i, code[i], codename[i].c_str());
- }
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCSwitch.h
- *
- * @brief This file is definition of CicoSCSwitch class
- */
-//==========================================================================
-#ifndef __CICO_SC_SWITCH_H__
-#define __CICO_SC_SWITCH_H__
-
-#include <vector>
-#include <string>
-
-//==========================================================================
-/**
- * @brief This class hold input device switch information
- */
-//==========================================================================
-class CicoSCSwitch
-{
-public:
- // default constructor
- CicoSCSwitch();
-
- // destructor
- virtual ~CicoSCSwitch();
-
- // dump log CicoSCSwitch member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCSwitch& operator=(const CicoSCSwitch &object);
-
- // copy constructor
- CicoSCSwitch(const CicoSCSwitch &object);
-
-public:
- static const int SWITCH_NOFIX = 0;
- static const int SWITCH_FIX = 1;
- static const unsigned int SWITCH_CODE_MAX = 8;
- std::string swname; //!< input switch name
- int input; //!< input switch number
- bool fix; //!< fixed application switch
- std::vector<int> code; //!< input switch code value
- std::vector<string> codename; //!< input switch code name
-};
-#endif // __CICO_SC_SWITCH_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-#include <memory>
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
-#include <cstdio>
-
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "CicoLog.h"
-#include "CicoEvent.h"
-#include "CicoEventInfo.h"
-#include "CicoStateCore.h"
-#include "CicoState.h"
-#include "CicoHistoryState.h"
-#include "CicoFinalState.h"
-#include "CicoStateMachine.h"
-#include "CicoStateMachineCreator.h"
-#include "CicoSCSysResourceMonitor.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoSCSysResourceController.h"
-#include "CicoConf.h"
-#include "CicoSystemConfig.h"
-#include <Ecore.h>
-//#include <Ecore_Evas.h>
-
-const int gEV1000 = 1000; // CPU event
-const int gEV1001 = 1001; // MEMORY event
-
-const string gstrSRCCPU_LOW = "SRCCPU_LOW";
-const string gstrSRCCPU_HIGH = "SRCCPU_HIGH";
-const string gstrSRCMEM_LOW = "SRCMEM_LOW";
-const string gstrSRCMEM_HIGH = "SRCMEM_HIGH";
-
-static const string gstrStateMachineFileName = "CicoSCSysResourceSM.json";
-
-bool g_RC_LOG = false;
-int g_samplingWaitTimer = 200;
-
-Ecore_Timer* g_SCResourceWatch = 0;
-static Eina_Bool ico_SCResourceWatch(void *data)
-{
- if (g_RC_LOG) ICO_TRA("start data(%x)", data);
- if ((NULL == data) || (0 == data)) {
- if (g_RC_LOG) ICO_TRA("end");
- return ECORE_CALLBACK_RENEW;
- }
- CicoSCSysResourceController* oCSCSRC = (CicoSCSysResourceController*)data;
- oCSCSRC->watch();
-// double tVal = (double)g_samplingWaitTimer / 100;
-// ecore_timer_add(g_samplingWaitTimer, ico_SCResourceWatch, data);
- if (g_RC_LOG) ICO_TRA("end");
- return ECORE_CALLBACK_RENEW;
-}
-
-
-/**
- * @brief constructor
- */
-CicoSCSysResourceController::CicoSCSysResourceController()
-{
- ICO_TRA("start");
- m_cgrpCPU = 0;
- m_cgrpMEM = 0;
- m_cpu = -1;
- m_mem = -1;
- m_bDoIt = false;
- m_rConf = CicoSystemConfig::getInstance()->getResourceConf();
- if (0 != m_rConf) {
- g_RC_LOG = m_rConf->m_bLog;
- if (-1 != m_rConf->m_sampling) {
- g_samplingWaitTimer = m_rConf->m_sampling;
- }
- }
- // cpu,cpuacct cgroup init
- ICO_TRA("end");
-}
-
-/**
- * @brief destructor
- */
-CicoSCSysResourceController::~CicoSCSysResourceController()
-{
- ICO_TRA("start");
- if (0 != g_SCResourceWatch) {
- ecore_timer_del(g_SCResourceWatch);
- }
-
- if ((CicoStateMachine*)0 != m_stt) {
- m_stt->stop();
- delete m_stt;
- m_stt = (CicoStateMachine*)0;
- ICO_TRA("delete CicoStateMachine");
- }
-
- if ((CicoSRCCPU_LOW*)0 != m_SRCCPU_LOW) {
- delete m_SRCCPU_LOW;
- m_SRCCPU_LOW = (CicoSRCCPU_LOW*)0;
- ICO_TRA("delete CicoSRCCPU_LOW");
- }
-
- if ((CicoSRCCPU_HIGH*)0 != m_SRCCPU_HIGH) {
- delete m_SRCCPU_HIGH;
- m_SRCCPU_HIGH = (CicoSRCCPU_HIGH*)0;
- ICO_TRA("delete CicoSRCCPU_HIGH");
- }
-
- if ((CicoSRCMEM_LOW*)0 != m_SRCMEM_LOW) {
- delete m_SRCMEM_LOW;
- m_SRCMEM_LOW = (CicoSRCMEM_LOW*)0;
- ICO_TRA("delete CicoSRCMEM_LOW");
- }
-
- if ((CicoSRCMEM_HIGH*)0 != m_SRCMEM_HIGH) {
- delete m_SRCMEM_HIGH;
- m_SRCMEM_HIGH = (CicoSRCMEM_HIGH*)0;
- ICO_TRA("delete CicoSRCMEM_HIGH");
- }
-
- if ((CicoSCSysResourceMonitor*)0 != m_monitor) {
- delete m_monitor;
- m_monitor = (CicoSCSysResourceMonitor*)0;
- ICO_TRA("delete CicoSCSysResourceMonitor");
- }
- ICO_TRA("end");
-}
-
-/**
- * @brief startWatch
- */
-bool CicoSCSysResourceController::startSysResource()
-{
- ICO_TRA("start");
- if (0 == m_rConf) {
- ICO_TRA("end");
- return false;
- }
- m_bDoIt = m_rConf->m_bDoIt;
- if (false == m_bDoIt) {
- ICO_TRA("end");
- return false;
- }
- // cpu,cpuacct cgroup init
- init_cgroup(); // cgroup
- m_monitor = new CicoSCSysResourceMonitor();
- CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
- string filePath(CSCSC->getDefaultConf()->confdir);
- filePath += string("/");
- filePath += gstrStateMachineFileName;
-
- CicoStateMachineCreator csmc;
- m_stt = csmc.createFile(filePath);
- if ((CicoStateMachine*)0 == m_stt) {
- ICO_ERR("state machine create error(%s)", filePath.c_str());
- ICO_TRA("end");
- return false;
- }
-
- m_SRCCPU_LOW = new CicoSRCCPU_LOW(this);
- m_SRCCPU_HIGH = new CicoSRCCPU_HIGH(this);
- m_SRCMEM_LOW = new CicoSRCMEM_LOW(this);
- m_SRCMEM_HIGH = new CicoSRCMEM_HIGH(this);
-
- CicoState* s = (CicoState*)m_stt->getState(gstrSRCCPU_LOW);
- if ((CicoState*)0 != s) {
- s->addEntryAction(m_SRCCPU_LOW);
- s->addDoAction(m_SRCCPU_LOW);
- }
- s = (CicoState*)m_stt->getState(gstrSRCCPU_HIGH);
- if ((CicoState*)0 != s) {
- s->addEntryAction(m_SRCCPU_HIGH);
- s->addDoAction(m_SRCCPU_HIGH);
- }
- s = (CicoState*)m_stt->getState(gstrSRCMEM_LOW);
- if ((CicoState*)0 != s) {
- s->addEntryAction(m_SRCMEM_LOW);
- s->addDoAction(m_SRCMEM_LOW);
- }
- s = (CicoState*)m_stt->getState(gstrSRCMEM_HIGH);
- if ((CicoState*)0 != s) {
- s->addEntryAction(m_SRCMEM_HIGH);
- s->addDoAction(m_SRCMEM_HIGH);
- }
- m_stt->start();
- double tVal = (double)g_samplingWaitTimer / 100;
- ICO_TRA("ECORE_TIMER(%f)", tVal);
- g_SCResourceWatch = ecore_timer_add(tVal, ico_SCResourceWatch, this);
- ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief watch
- * @return true:change level false:no change
- */
-bool CicoSCSysResourceController::watch()
-{
- if (g_RC_LOG) ICO_TRA("start");
- if ((CicoSCSysResourceMonitor*)0 == m_monitor) {
- if (g_RC_LOG) ICO_TRA("end false");
- return false;
- }
- bool r = false;
- m_monitor->monitoring();
- int cpu = m_monitor->getCPUuser(); // application cpu
- if (-1 != cpu) {
- cpu /= 100;
- CicoEvent ev(gEV1000, cpu);
- bool b = m_stt->eventEntry(ev);
- if (g_RC_LOG) ICO_TRA("cpu %c, %d->%d", b? 't': 'f', m_cpu, cpu);
- m_cpu = cpu;
- r = true;
- }
- int mem = m_monitor->getUsageFreeMem(); // free memory
- if (-1 != mem) {
- mem = (10000 - mem)/100; // free->used memory calc
- CicoEvent ev(gEV1001, mem);
- m_stt->eventEntry(ev);
- m_mem = mem;
- r = true;
- }
- if (g_RC_LOG) ICO_TRA("end %s", r? "true": "false");
- return r;
-}
-
-/**
- * @brief CPU share control request
- * @param pulus true:level up / false level down
- */
-void CicoSCSysResourceController::resourceControlCPUShares(bool bHight)
-{
- ICO_TRA("start %s", bHight? "true": "false");
- if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
- ICO_TRA("end");
- return;
- }
- if (true == m_rConf->m_cpuCtrl.empty()) {
- ICO_TRA("end");
- return;
- }
- int newCgrpCPU = -1;
- int sz = m_rConf->m_cpuCtrl.size();
- for (int i = 0; i < sz; i++) {
- if (true == m_RCCpuShares[i].empty()) { // write target none
- continue; // next target
- }
- int sharesVal = -1; // initialize cpu.shares value
- if (true == bHight) {
- if (m_cgrpCPU < (int)m_rConf->m_cpuCtrl[i]->m_hight.size()) {
- sharesVal = m_rConf->m_cpuCtrl[i]->m_hight[m_cgrpCPU];
- newCgrpCPU = m_cgrpCPU + 1;
- ICO_DBG("m_hight[%d]=%d", m_cgrpCPU, sharesVal);
- }
- }
- else {
- if (0 != m_cgrpCPU) {
- int tmp = m_cgrpCPU - 1;
- if (tmp < (int)m_rConf->m_cpuCtrl[i]->m_low.size()) {
- sharesVal = m_rConf->m_cpuCtrl[i]->m_low[tmp];
- newCgrpCPU = tmp;
- ICO_DBG("m_low[%d]=%d", tmp, sharesVal);
- }
- }
- }
- if (0 <= sharesVal) {
- replaceCgroupFile(m_RCCpuShares[i], sharesVal);
- }
-// else if (-9 == sharesVal) {
-// }
- }
- if (-1 != newCgrpCPU) { // control level value check
- ICO_DBG("control level %d -> %d", m_cgrpCPU, newCgrpCPU);
- m_cgrpCPU = newCgrpCPU; // set next control level
- }
- ICO_TRA("end");
-}
-
-bool CicoSCSysResourceController::replaceCgroupFile(const std::string& tgt,
- int val)
-{
- char sv[64];
- sprintf(sv, "%d", val);
- return replaceCgroupFile(tgt, sv);
-}
-
-bool CicoSCSysResourceController::replaceCgroupFile(const std::string& tgt,
- const char* val)
-{
- ICO_TRA("start");
- if (true == tgt.empty()) {
- ICO_TRA("end");
- return false;
- }
- FILE *fp = fopen(tgt.c_str(), "wt");
- if (0 == fp) {
- ICO_TRA("end open error %s", tgt.c_str());
- return false;
- }
- fprintf(fp, val);
- fclose(fp);
- ICO_TRA("end Cmd(echo %s > %s", val, tgt.c_str());
- return true;
-}
-
-/**
- * @brief memory limit control request
- * @param pulus true:level up / false level down
- */
-void CicoSCSysResourceController::resourceControlMemLimit(bool bHight)
-{
- ICO_TRA("start");
- if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
- ICO_TRA("end");
- return;
- }
- // TODO mk_k coming soon
- if (true == bHight) {
- // coming soon
- ICO_TRA("hight (true)");
- }
- else {
- // coming soon
- ICO_TRA("low (false)");
- }
-// m_cgrpMEM++;
- ICO_TRA("end");
-}
-
-
-
-/**
- * @brief
- *
- */
-bool CicoSCSysResourceController::entryCgroupCPU(int pid, int grpNo)
-{
- ICO_TRA("start pid(%d), cgrpNo(%d)", pid, grpNo);
- if (((0 > grpNo) || ((int)m_RCCpuTasks.size() <= grpNo)) ||
- ((NULL == m_rConf) || (false == m_rConf->m_bDoIt))) {
- ICO_TRA("end %d", m_RCCpuTasks.size());
- return false;
- }
-#if 1
- struct stat statbuf;
- char procdir[128];
- sprintf(procdir, "/proc/%d/task", pid);
- if (0 != stat(procdir, &statbuf)) {
- ICO_TRA("end %s ng dir", procdir);
- return false;
- }
- DIR *dp;
- dp = opendir(procdir);
- if(dp == NULL) {
- ICO_TRA("end opendir error");
- return false;
- }
- struct dirent *ent;
- while((ent = readdir(dp)) != NULL){
- if (0 != isdigit(ent->d_name[0])) {
- ICO_DBG("echo %s > %s", ent->d_name, m_RCCpuTasks[grpNo].c_str());
- replaceCgroupFile(m_RCCpuTasks[grpNo], ent->d_name);
- }
- }
- closedir(dp);
- ICO_TRA("end");
- return true;
-#else
- return replaceCgroupFile(m_RCCpuTasks[grpNo], pid);
-#endif
-}
-
-/**
- * @brief initialize cgroup
- */
-void CicoSCSysResourceController::init_cgroup()
-{
- ICO_TRA("start");
- init_cgroup_cpu();
- // memory cgroup directory get
- init_cgroup_memory();
- ICO_TRA("end");
-}
-
-/**
- * @brief initialize cgroup cpu
- */
-void CicoSCSysResourceController::init_cgroup_cpu()
-{
- ICO_TRA("start");
- if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
- ICO_TRA("end");
- return;
- }
- string ss("/");
- string sTasks(D_STRtasks);
- string sShares(D_STRcpushares);
- string t1(m_rConf->m_cpuCGRPPath);
- if ('/' != t1[t1.size()-1]) {
- t1 += ss;
- }
- vector<string> d;
- d.push_back(m_rConf->m_cpuCGRPPath);
- int sz = m_rConf->m_cpuCtrl.size();
- for (int i = 0; i < sz; i++) {
- CicoSCCpuResourceGrp* obj = m_rConf->m_cpuCtrl[i];
- string t2;
- if (0 != obj) {
- t2 = t1;
- t2 += obj->m_grpNm;
- }
- else {
- t2.clear();
- }
- d.push_back(t2);
- string t3(t2);
- string t4(t2);
- if (false == t2.empty()) {
- if ('/' != t2[t2.size()-1]) {
- t3 += ss;
- t4 += ss;
- }
- t3 += sTasks;
- t4 += sShares;
- }
- m_RCCpuTasks.push_back(t3);
- m_RCCpuShares.push_back(t4);
- }
- make_directorys(d);
- ICO_TRA("end");
- return;
-}
-
-/**
- * @brief initialize cgroup memory
- */
-void CicoSCSysResourceController::init_cgroup_memory()
-{
- ICO_TRA("start");
- if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
- ICO_TRA("end error config class");
- return;
- }
- // Coming Soon
- ICO_TRA("end");
- return;
-}
-
-/**
- * @brief make directory
- * @param d create directory target
- */
-void CicoSCSysResourceController::make_directorys(std::vector<std::string> dir)
-{
- ICO_TRA("start");
- int sz = dir.size();
- for (int i = 0; i < sz; i++) {
- if (true == dir[i].empty()) {
- continue;
- }
- const char* dpath = dir[i].c_str();
- struct stat stat_buf;
- if (0 != stat(dpath, &stat_buf)) {
- // drwxr-xr-x
- int r = mkdir(dpath, S_IRUSR| S_IWUSR| S_IXUSR| S_IRGRP|
- S_IXGRP| S_IROTH| S_IXOTH);
- ICO_DBG("%s create status(%d)", dpath, r);
- }
- }
- ICO_TRA("end");
-}
-
-/**
- * @brief Class ico System Resource Controller CPU LOW level
- * constructor
- */
-CicoSRCCPU_LOW::CicoSRCCPU_LOW(CicoSCSysResourceController* obj):
- m_cntlr(obj)
-{
- ICO_TRA("constructor");
- m_val = -1; // cpu or memory usage value
- m_baseVal = -1; // cpu or memory base usage value
- m_cnt = 0;
- m_rConf = CicoSystemConfig::getInstance()->getResourceConf();
-}
-
-/**
- * @brief Class ico System Resource Controller CPU LOW level
- * destructor
- */
-CicoSRCCPU_LOW::~CicoSRCCPU_LOW()
-{
- ICO_TRA("destructor");
- m_cntlr = NULL;
-}
-
-/**
- * @brief resource control entry state
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCCPU_LOW::onEntry(const CicoEvent& ev, const CicoState* stt, int)
-{
- int v1 = ev.getEV();
- int v2 = ev.getGCVi();
- if (g_RC_LOG) ICO_TRA("start %s,%d,%d CicoSRCCPU_LOW::", stt->getName().c_str(), v1, v2);
- m_baseVal = v2;
- m_val = m_baseVal;
- m_cnt = m_rConf->m_retryCnt;
- if (g_RC_LOG) ICO_TRA("end cnt(%d) CicoSRCCPU_LOW::", m_cnt);
-}
-
-/**
- * @brief cpu usage low resource control
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCCPU_LOW::onDo(const CicoEvent& ev, const CicoState* stt, int)
-{
- int valN = ev.getGCVi();
- if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)CicoSRCCPU_LOW::", m_val, valN);
-#if 0
- if (valN > m_val) {
- // When the value is greater than the previous
- if (g_RC_LOG) ICO_TRA("end n(%d)->o(%d) CicoSRCCPU_LOW::", m_val, valN);
- return;
- }
- // When the value is less than the previous
- int t = ((double)valN / (double)m_baseVal)*100;
- if (50 <= t) {
- m_cntlr->resourceControlCPUShares(false);
- if (g_RC_LOG) ICO_DBG("CHG %d->%d CicoSRCCPU_LOW::",m_baseVal, valN);
- m_baseVal = valN;
- }
-#else
- if (valN < m_rConf->m_lowLimitVal) {
- m_cnt--;
- if (0 >= m_cnt) {
- m_cntlr->resourceControlCPUShares(false);
- if (g_RC_LOG) ICO_DBG("CHG %d->%d CicoSRCCPU_LOW::",m_baseVal, valN);
- m_cnt = m_rConf->m_retryCnt;
- m_baseVal = valN;
- }
- }
- else {
- if (g_RC_LOG) ICO_DBG("cnt rst V(%d) CicoSRCCPU_LOW::", valN);
- m_cnt = m_rConf->m_retryCnt;
- }
-#endif
- m_val = valN;
- if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_LOW::");
-}
-
-
-/**
- * @brief resource control exit state
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCCPU_LOW::onExit(const CicoEvent&, const CicoState*, int)
-{
- if (g_RC_LOG) ICO_TRA("start CicoSRCCPU_LOW::");
- m_baseVal = -1;
- m_val = -1;
- if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_LOW::");
-}
-
-/**
- * @brief Class ico System Resource Controller CPU HIGH level
- * constructor
- */
-CicoSRCCPU_HIGH::CicoSRCCPU_HIGH(CicoSCSysResourceController* obj):
- CicoSRCCPU_LOW(obj)
-{
- ICO_TRA("constructor");
-}
-
-/**
- * @brief Class ico System Resource Controller CPU HIGH level
- * destructor
- */
-CicoSRCCPU_HIGH::~CicoSRCCPU_HIGH()
-{
- ICO_TRA("destructor");
-}
-
-/**
- * @brief cpu usage high resource control
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCCPU_HIGH::onDo(const CicoEvent& ev, const CicoState* stt, int)
-{
- int valN = ev.getGCVi();
- if (g_RC_LOG) ICO_TRA("start o(%d), n(%d) CicoSRCCPU_HIGH::", m_val, valN);
-#if 0
- if (valN <= m_val) {
- // When the value is less than the previous
- if (g_RC_LOG) ICO_TRA("n(%d)<=o(%d) CicoSRCCPU_HIGH::", valN, m_val);
- return;
- }
- // When the value is greater than the previous
- int t = ((double)(100-valN) / (double)(100-m_baseVal))*100;
- if (50 <= t) {
- m_cntlr->resourceControlCPUShares(true);
- if (g_RC_LOG) ICO_DBG("%d->%d CicoSRCCPU_HIGH::", m_baseVal, valN);
- m_baseVal = valN;
- }
-#else
- if (valN > m_rConf->m_highLimitVal) {
- m_cnt--;
- if (g_RC_LOG) ICO_DBG("cnt(%d) CicoSRCCPU_HIGH::", m_cnt);
- if (0 >= m_cnt) {
- m_cntlr->resourceControlCPUShares(true);
- if (g_RC_LOG) ICO_DBG("CicoSRCCPU_HIGH:: %d->%d",m_baseVal, valN);
- m_cnt = m_rConf->m_retryCnt;
- m_baseVal = valN;
- }
- }
- else {
- if (g_RC_LOG) ICO_DBG("CicoSRCCPU_HIGH:: (%d)", valN);
- m_cnt = m_rConf->m_retryCnt;
- }
-#endif
- m_val = valN;
- if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_HIGH::");
-}
-
-/**
- * @brief Class ico System Resource Controller MEMory LOW level
- * constructor
- */
-CicoSRCMEM_LOW::CicoSRCMEM_LOW(CicoSCSysResourceController* obj):
- CicoSRCCPU_LOW(obj)
-{
- ICO_TRA("constructor CicoSRCMEM_LOW::");
-}
-
-/**
- * @brief Class ico System Resource Controller MEMory LOW level
- * constructor
- */
-CicoSRCMEM_LOW::~CicoSRCMEM_LOW()
-{
- ICO_TRA("destructor CicoSRCMEM_LOW::");
-}
-
-/**
- * @brief memory usage low resource control
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCMEM_LOW::onDo(const CicoEvent& ev, const CicoState* stt, int)
-{
- int valN = ev.getGCVi();
- if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)", m_val, valN);
- if (valN >= m_val) {
- // When the value is greater than the previous
- if (g_RC_LOG) ICO_TRA("n(%d)>=o(%d)", valN, m_val);
- return;
- }
- // When the value is less than the previous
- int t = ((double)valN / (double)m_baseVal)*100;
- if (50 <= t) {
- m_cntlr->resourceControlMemLimit(false);
- if (g_RC_LOG) ICO_TRA("BASE CHG %d->%d",m_baseVal, valN);
- m_baseVal = valN;
- }
- m_val = valN;
- if (g_RC_LOG) ICO_TRA("end");
-
-}
-
-/**
- * @brief Class ico System Resource Controller MEMory HIGH level
- * constructor
- */
-CicoSRCMEM_HIGH::CicoSRCMEM_HIGH(CicoSCSysResourceController* obj):
- CicoSRCCPU_LOW(obj)
-{
- ICO_TRA("constructor");
-}
-
-/**
- * @brief Class ico System Resource Controller MEMory HIGH level
- * destructor
- */
-CicoSRCMEM_HIGH::~CicoSRCMEM_HIGH()
-{
- ICO_TRA("destructor");
-}
-
-/**
- * @brief memory usage high resource control
- * @param ev event data
- * @param stt state object
- */
-void CicoSRCMEM_HIGH::onDo(const CicoEvent& ev, const CicoState* stt, int)
-{
- int valN = ev.getGCVi();
- if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)", m_val, valN);
- if (valN <= m_val) {
- // When the value is less than the previous
- ICO_TRA("end");
- return;
- }
- // When the value is greater than the previous
- int t = ((double)(100-valN) / (double)(100-m_baseVal))*100;
- if (50 <= t) {
- m_cntlr->resourceControlMemLimit(true);
- if (g_RC_LOG) ICO_TRA("BASE CHG %d -> %d", m_baseVal, valN);
- m_baseVal = valN;
- }
- m_val = valN;
- if (g_RC_LOG) ICO_TRA("end");
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief CicoSCSysResourceController
- * SystemController resource watcher
- * CPU/FreeMemory monitoring
- *
- * @date Aug-05-2013 create start
- */
-
-#ifndef CICOSCSYSRESOURCECONTROLLER_H
-#define CICOSCSYSRESOURCECONTROLLER_H
-#include <cstddef>
-
-#include "CicoStateAction.h"
-
-#ifndef CICOSTATEMACHINE_H
-class CicoStateMachine;
-#endif
-
-#ifndef CICOSCSYSRESOURCEMONITOR_H
-class CicoSCSysResourceMonitor;
-#endif
-
-#ifndef __CICO_SC_CONF_H__
-class CicoSCResourceConf;
-#endif
-
-#define D_STRtasks "tasks"
-#define D_STRcpushares "cpu.shares"
-
-class CicoSCSysResourceController;
-
-/**
- * @brief Class ico System Resource Controller CPU LOW level
- */
-class CicoSRCCPU_LOW : public CicoStateAction
-{
-public: // member method
- CicoSRCCPU_LOW(CicoSCSysResourceController* obj);
- virtual ~CicoSRCCPU_LOW();
-
- virtual void onEntry(const CicoEvent& ev, const CicoState* stt, int addval);
- virtual void onDo(const CicoEvent& ev, const CicoState* stt, int addval);
- virtual void onExit(const CicoEvent& ev, const CicoState* stt,
- int addval);
-protected: // member Variable
- int m_val; // cpu or memory usage value
- int m_baseVal; // cpu or memory base usage value
- int m_cnt;
- CicoSCSysResourceController* m_cntlr;
- const CicoSCResourceConf* m_rConf;
-};
-
-/**
- * @brief Class ico System Resource Controller CPU HIGH level
- */
-class CicoSRCCPU_HIGH : public CicoSRCCPU_LOW
-{
-public: // member method
- CicoSRCCPU_HIGH(CicoSCSysResourceController* obj);
- virtual ~CicoSRCCPU_HIGH();
- void onDo(const CicoEvent& ev, const CicoState* stt, int addval);
-
-protected: // member Variable
-};
-
-/**
- * @brief Class ico System Resource Controller MEMory LOW level
- */
-class CicoSRCMEM_LOW : public CicoSRCCPU_LOW
-{
-public: // member method
- CicoSRCMEM_LOW(CicoSCSysResourceController* obj);
- virtual ~CicoSRCMEM_LOW();
- void onDo(const CicoEvent& ev, const CicoState* stt, int addval);
-protected: // member Variable
-};
-
-/**
- * @brief Class ico System Resource Controller MEMory HIGH level
- */
-class CicoSRCMEM_HIGH : public CicoSRCCPU_LOW
-{
-public: // member method
- CicoSRCMEM_HIGH(CicoSCSysResourceController* obj);
- virtual ~CicoSRCMEM_HIGH();
- void onDo(const CicoEvent& ev, const CicoState* stt, int addval);
-protected: // member Variable
-};
-
-/**
- * @brief System Controller System Resource Controller class
- */
-class CicoSCSysResourceController
-{
-public:
- CicoSCSysResourceController();
- ~CicoSCSysResourceController();
-
- bool isWactchAllReady() const;
-
- bool startSysResource(); // start cgroup controll
-
- bool watch(); // watch request (please interval call)
- const CicoSCSysResourceMonitor& getMonitor() const;
- int getCpuUsge() const;
- int getMemoryUsge() const;
-
- void resourceControlCPUShares(bool bHight);
- void resourceControlMemLimit(bool bHight);
- bool entryCgroupCPU(int pid, int grpNo);
-protected:
- void init_cgroup();
- void init_cgroup_cpu();
- void init_cgroup_memory();
- void make_directorys(std::vector<std::string> dir);
- bool replaceCgroupFile(const std::string& tgt, int val);
- bool replaceCgroupFile(const std::string& tgt, const char* val);
-
-protected:
- CicoSCSysResourceMonitor* m_monitor;
- const CicoSCResourceConf* m_rConf;
- std::vector<std::string> m_RCCpuTasks;
- std::vector<std::string> m_RCCpuShares;
- bool m_bDoIt;
-private:
- CicoStateMachine* m_stt;
-
- CicoSRCCPU_LOW* m_SRCCPU_LOW;
- CicoSRCCPU_HIGH* m_SRCCPU_HIGH;
- CicoSRCMEM_LOW* m_SRCMEM_LOW;
- CicoSRCMEM_HIGH* m_SRCMEM_HIGH;
-
- int m_cpu;
- int m_mem;
- int m_cgrpCPU;
- int m_cgrpMEM;
-};
-
-/**
- * @brief
- * @return
- */
-inline
-bool CicoSCSysResourceController::isWactchAllReady() const
-{
- if ((-1 != m_cpu) && (-1 != m_mem)) {
- return true;
- }
- return false;
-}
-
-/**
- * @brief get monitor class
- * return monitor class
- */
-inline const CicoSCSysResourceMonitor&
- CicoSCSysResourceController::getMonitor() const
-{
- return *m_monitor;
-}
-
-/**
- * @brief get CPU usage
- * @return CPU usage
- */
-inline int CicoSCSysResourceController::getCpuUsge() const
-{
- return m_cpu;
-}
-
-/**
- * @brief get CPU usage
- * @return CPU usage
- */
-inline int CicoSCSysResourceController::getMemoryUsge() const
-{
- return m_mem;
-}
-
-#endif // CICOSCSYSRESOURCECONTROLLER_H
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#include <iostream>
-#include <string>
-#include <fstream>
-#include <memory>
-#include <cstdlib>
-#include <cstring>
-#include "CicoLog.h"
-#include "CicoSCSysResourceMonitor.h"
-using namespace std;
-extern bool g_RC_LOG;
-
-const char* rdTgtCPU = "/proc/stat";
-const char sP1C = 'c';
-const char sP2P = 'p';
-const char sP3U = 'u';
-const int nDmyCpuCnt = 17; // CPU(16) + Total(1)
-
-const double dCarryUp = 10000;
-
-const char* rdTgtMEM = "/proc/meminfo";
-const string rdMEMTag1 = "MemFree:";
-const string rdMEMTag2 = "MemTotal:";
-
-/**
- * @brief Constructor
- */
-CicoSCSysResourceMonitor::CicoSCSysResourceMonitor()
-{
- ICO_TRA("start constructor");
- m_CPUcnt = 0;
- m_old = (stat_data_t*)0;
- m_current = (stat_data_t*)0;
- m_calc = (stat_data_t*)0;
- m_totalMem = 0;
- m_freeMem = 0;
- m_usageFreeMem = -1;
- m_allready = false;
- ICO_TRA("end constructor");
-}
-
-/**
- * @brief destructor
- */
-CicoSCSysResourceMonitor::~CicoSCSysResourceMonitor()
-{
- ICO_TRA("start destructor");
- if ((stat_data_t*)0 != m_old) {
- delete[] m_old;
- m_old = (stat_data_t*)0;
- }
- if ((stat_data_t*)0 != m_current) {
- delete[] m_current;
- m_current = (stat_data_t*)0;
- }
- if ((stat_data_t*)0 != m_calc) {
- delete[] m_calc;
- m_calc = (stat_data_t*)0;
- }
- ICO_TRA("end destructor");
-}
-
-/**
- * @brief system usage
- * @param cpu core cpu position -1:all 0-n:cpu position
- * @return cpu usage(return value/100 = 0.00 - 100.00%)
- * -1:get fail
- */
-int CicoSCSysResourceMonitor::getCPUtime(E_USAGETYPE e, int cpu) const
-{
- if (g_RC_LOG) ICO_TRA("start %d, %d", e, cpu);
- if (false == isAllReady()) {
- ICO_TRA("is no ready!");
- return -1;
- }
- int n = cpu + 1;
- if ((0 > n) || (m_CPUcnt <= n)) {
- if (g_RC_LOG) ICO_TRA("end cpu count error %d, %d", n, m_CPUcnt);
- return -1;
- }
- int r = -1;
- switch(e) {
- case E_user: // 1) Time spent in user mode.
- r = m_calc[n].user;
- break;
- case E_nice: // 2) Time spent in user mode with low priority (nice).
- r = m_calc[n].nice;
- break;
- case E_system: // 3) Time spent in system mode.
- r = m_calc[n].system;
- break;
- case E_idle: // 4) Time spent in the idle task.
- r = m_calc[n].idle;
- break;
- case E_iowait: // 5) Time waiting for I/O to complete.
- r = m_calc[n].iowait;
- break;
- case E_irq: // 6) Time servicing interrupts.
- r = m_calc[n].irq;
- break;
- case E_softirq: // 7) Time servicing softirqs.
- r = m_calc[n].softirq;
- break;
- case E_steal: // 8) Time stolen
- r = m_calc[n].steal;
- break;
- case E_guest: // 9) Time Guest OS
- r = m_calc[n].guest;
- break;
- case E_guest_nice: // 10) Time guest OS(nice)
- r = m_calc[n].guest_nice;
- break;
- default:
- break;
- }
- if (g_RC_LOG) ICO_TRA("end success ret(%d)", r);
- return r;
-}
-
-/**
- * @brief monitoring
- */
-void CicoSCSysResourceMonitor::monitoring()
-{
- if (g_RC_LOG) ICO_TRA("call getResource");
- getResource();
-}
-
-/**
- * @brief getResource
- * CPU usage and free memory size get
- */
-void CicoSCSysResourceMonitor::getResource()
-{
- if (g_RC_LOG) ICO_TRA("call get resource CPU,MEM");
- getResourceCPU();
- getResourceMEM();
-}
-
-/**
- * @brief getResourceCPU
- */
-void CicoSCSysResourceMonitor::getResourceCPU()
-{
- if (0 == m_CPUcnt) {
- m_CPUcnt = createCurrentCPU();
- size_t sz = m_CPUcnt + 1;
- if (0 == m_old) {
- m_old = new stat_data_t[sz];
- }
- if (0 == m_calc) {
- m_calc = new stat_data_t[sz];
- }
- ICO_DBG("cpu count is %d", m_CPUcnt);
- return;
- }
- if (((stat_data_t*)0 == m_old) || ((stat_data_t*)0 == m_current) ||
- ((stat_data_t*)0 == m_calc)) {
- ICO_DBG("error none new area");
- return;
- }
- // set old value
- size_t sz = m_CPUcnt + 1;
- memcpy(m_old, m_current, sizeof(stat_data_t)*sz);
- // read current value
- readCurrentCPU();
- // calc CPU usage
- for (size_t i=0; i < sz; i++) {
- usageCalcCPU(m_old[i], m_current[i], m_calc[i]);
- }
- m_allready = true;
- if (g_RC_LOG) ICO_TRA("calc");
-}
-
-/**
- * @brief CPU usage first read
- * area allocation and read
- * CPU core count
- * @return CPU core count
- */
-int CicoSCSysResourceMonitor::createCurrentCPU()
-{
- if (0 != m_current) {
- ICO_TRA("ret(0) current is zero!");
- return 0;
- }
- int cnt = 0;
- stat_data_t tmp[nDmyCpuCnt];
- memset(tmp, 0, sizeof(tmp));
- cnt = readProcStatCPU(tmp, nDmyCpuCnt-1);
- if (0 == cnt) {
- ICO_TRA("ret(0) cnt is zero!");
- return 0;
- }
- size_t sz = cnt + 1;
- m_current = new stat_data_t[sz];
- memcpy(m_current, tmp, sizeof(stat_data_t)*sz);
- ICO_TRA("ret cpu core count(%d)", cnt);
- return cnt;
-}
-
-/**
- * @brief CPU usage read
- */
-void CicoSCSysResourceMonitor::readCurrentCPU()
-{
- readProcStatCPU(m_current, m_CPUcnt);
-}
-
-/**
- * @brief read /proc/stat CPU information
- * @param sdtp destination read value
- * @param cpucnt CPU core count
- * @return read CPU count
- */
-int CicoSCSysResourceMonitor::readProcStatCPU(stat_data_t* sdtp, const int cpucnt)
-{
- int r = 0;
- int sztmp = cpucnt;
- string tag;
- ifstream ifs(rdTgtCPU);
- while(ifs >> tag) {
- int tgt=-1;
- const char* tags = tag.c_str();
- if ((sP1C == tags[0]) && (sP2P == tags[1]) && (sP3U == tags[2])) {
- if ('\0' == tags[3]) { // "cpu"
- tgt = 0;
- }
- else { // "cpuX" X = 0 - 9
- if (0 != isdigit(tags[3])) {
- int tmp_tgt = atoi(&tags[3]);
- if ((0 <= tmp_tgt) && (tmp_tgt < cpucnt)) {
- tgt = tmp_tgt + 1;
- }
- }
- }
- }
- if (-1 != tgt) {
- // get now value
- ifs >> sdtp[tgt].user;
- ifs >> sdtp[tgt].nice;
- ifs >> sdtp[tgt].system;
- ifs >> sdtp[tgt].idle;
- ifs >> sdtp[tgt].iowait;
- ifs >> sdtp[tgt].irq;
- ifs >> sdtp[tgt].softirq;
- ifs >> sdtp[tgt].steal;
- ifs >> sdtp[tgt].guest;
- ifs >> sdtp[tgt].guest_nice;
- if (0 != tgt) {
- sztmp--;
- r++;
- }
- }
- if (0==sztmp) {
- break; // break of while
- }
- }
- ifs.close();
- if (g_RC_LOG) ICO_TRA("ret(%d)", r);
- return r;
-}
-
-/**
- * @brief CPU usage calc
- * @param old previous value
- * @param current value of this time
- * @param calc distnation calculated value
- * @return true:calc success false:calc fail
- */
-bool CicoSCSysResourceMonitor::usageCalcCPU(const stat_data_t& old,
- const stat_data_t& current,
- stat_data_t& calc)
-{
- if (g_RC_LOG) ICO_TRA("start");
- double ttl = 0;
- double duser = current.user - old.user;
- ttl += duser;
- double dnice = current.nice - old.nice;
- ttl += dnice;
- double dsystem = current.system - old.system;
- ttl += dsystem;
- double didle = current.idle - old.idle;
- ttl += didle;
- double diowait = current.iowait - old.iowait;
- ttl += diowait;
- double dirq = current.irq - old.irq;
- ttl += dirq;
- double dsoftirq = current.softirq - old.softirq;
- ttl += dsoftirq;
- double dsteal = current.steal - old.steal;
- ttl += dsteal;
- double dguest = current.guest - old.guest;
- ttl += dguest;
- double dguest_nice = current.guest_nice - old.guest_nice;
- ttl += dguest_nice;
- if (0 == ttl) { // must not be divided by ZERO
- if (g_RC_LOG) ICO_TRA("end divide zero!?");
- return false;
- }
- calc.user = (int)(duser / ttl * dCarryUp);
- calc.nice = (int)(dnice / ttl * dCarryUp);
- calc.system = (int)(dsystem / ttl * dCarryUp);
- calc.idle = (int)(didle / ttl * dCarryUp);
- calc.iowait = (int)(diowait / ttl * dCarryUp);
- calc.irq = (int)(dirq / ttl * dCarryUp);
- calc.softirq = (int)(dsoftirq / ttl * dCarryUp);
- calc.steal = (int)(dsteal / ttl * dCarryUp);
- calc.guest = (int)(dguest / ttl * dCarryUp);
- calc.guest_nice = (int)(dguest_nice / ttl * dCarryUp);
- if (g_RC_LOG) ICO_TRA("end");
- return true;
-}
-
-/**
- * @brief get resource free memory
- */
-void CicoSCSysResourceMonitor::getResourceMEM()
-{
- if (g_RC_LOG) ICO_TRA("start");
- if (0 >= m_totalMem) {
- readProcMeminfo(true);
- }
- else {
- readProcMeminfo();
- }
- if (g_RC_LOG) ICO_TRA("end");
-}
-
-/**
- * @brief read /proc/meminfo
- * @param ttlMem total memory read flag
- */
-void CicoSCSysResourceMonitor::readProcMeminfo(bool ttlMem)
-{
-#if 0
- if (g_RC_LOG) ICO_TRA("start %s", ttlMem? "true": "false");
- string tag;
- ifstream ifs(rdTgtMEM);
- bool tgt1 = false;
- bool tgt2 = ttlMem; // total memory get flag set
- while(ifs >> tag) {
- if (true == tgt2) { // flag on
- if (rdMEMTag2 == tag) { // is total memory tag?
- ifs >> m_totalMem; // total memory size get
- tgt2 = false; // flag off
- }
- }
- if (rdMEMTag1 == tag) { // is free memory tag
- ifs >> m_freeMem; // get free memory size
- tgt1 = true; // get flag on
- }
- if ((true == tgt1) && (false == tgt2)) {
- break; // break of while
- }
- }
- ifs.close();
- if (0 != m_totalMem) {
- if (true == tgt1) {
- m_usageFreeMem = (int)
- (((double)m_freeMem / (double)m_totalMem) * 10000);
- }
- }
- else {
- m_usageFreeMem = -1;
- }
- if (g_RC_LOG) ICO_TRA("end usage free mem st.(%d)", m_usageFreeMem);
-#else
- m_usageFreeMem = -1;
- return;
-#endif
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief CicoSCSysResourceMonitor
- * SystemController resource monitor
- * CPU/FreeMemory monitoring
- *
- * @date Jul-02-2013 create start
- */
-
-#ifndef CICOSCSYSRESOURCEMONITOR_H
-#define CICOSCSYSRESOURCEMONITOR_H
-
-#include <sys/types.h>
-#include <vector>
-
-
-/**
- * /proc/stat cpu/cpuX data struct type
- */
-typedef struct t_stat_data {
- int user; // 1) Time spent in user mode.
- int nice; // 2) Time spent in user mode with low priority (nice).
- int system; // 3) Time spent in system mode.
- int idle; // 4) Time spent in the idle task.
- // This value should be USER_HZ times the second entry
- // in the /proc/uptime pseudo-file.
- int iowait; // 5) Time waiting for I/O to complete.
- int irq; // 6) Time servicing interrupts.
- int softirq; // 7) Time servicing softirqs.
- int steal; // 8) Time stolen
- // 8) stolen time
- int guest; // 9) Time guest OS
- int guest_nice; // 10) Time guest OS(nice)
-} stat_data_t;
-
-class CicoSCSysResourceMonitorP {
-public: // member method
- CicoSCSysResourceMonitorP(pid_t pid);
- CicoSCSysResourceMonitorP(const CicoSCSysResourceMonitorP& s);
-
-
-
-
-
-public: // member Variable
- pid_t m_pid;
- int m_utime_o;
- int m_stime_o;
- int m_vsize_o;
-/*
-
- /proc/[pid]/stat
- 01)pid, 02)comm, 03)state, 04)ppid, 05)pgrp, 06)session, 07)tty_nr, 08)tpgid
- 09)flags, 10)minflt, 11)cminflt, 12)majflt, 13)cmajflt, 14)utime, 15)stime
- 16)cutime, 17)cstime, 18)priority, 19)nice, 20)num_threads, 21)itrealvalue
- 22)starttime, 23)vsize, 24)rss, 25)rsslim, 26)startcode, 27)endcode
- 28)startstack, 29)kstkesp, 30)kstkeip, 31)signal, 32)blocked, 33)sigignore
- 34)sigcatch, 35)wchan, 36)nswap, 37)cnswap, 38)exit_signal, 39)processor
- 40)rt_priority, 41)policy, 42)delayacct_blkio_ticks, 43)guest_time
- 44)cguest_time
-*/
-};
-
-
-
-
-
-/**
- * @brief Resource monitoring
- */
-class CicoSCSysResourceMonitor {
-public:
- CicoSCSysResourceMonitor();
- ~CicoSCSysResourceMonitor();
-
- enum E_USAGETYPE{
- E_user = 0, // 1) Time spent in user mode.
- E_nice, // 2) Time spent in user mode with low priority (nice).
- E_system, // 3) Time spent in system mode.
- E_idle, // 4) Time spent in the idle task.
- E_iowait, // 5) Time waiting for I/O to complete.
- E_irq, // 6) Time servicing interrupts.
- E_softirq, // 7) Time servicing softirqs.
- E_steal, // 8) Time stolen
- E_guest, // 9) Time Guest OS
- E_guest_nice // 10) Time guest OS(nice)
- };
- bool isAllReady() const;
- // cpu
- int getCPUCount() const; // get number of cpu cores
-
- // @param cpu -1:total 0:cpu0 1:cpu1 n:cpuN
- // @retval 0 - 10000(retval/100 = 0.00 - 100.00%)
- int getCPUuser(int cpu=-1) const;
- int getCPUsystem(int cpu=-1) const;
- int getCPUtime(E_USAGETYPE e, int cpu=-1) const;
-
- // memory
- unsigned int getFreeMemSize() const; // free memory size maybe kB
- unsigned int getTotalMemSize() const; // total memory size maybe kB
- int getUsageFreeMem() const; // usage free memory
-
- // controller
- void monitoring();
-
- // process monitoring entry and remove
- void addTarget(pid_t pid);
- void removeTarget(pid_t pid);
-// std::vector<Xxxxx>& get
-protected:
- void getResource();
- void getResourceCPU();
- void getResourceMEM();
-private:
- int createCurrentCPU();
- void readCurrentCPU();
- int readProcStatCPU(stat_data_t* sdtp, const int cpucnt);
- bool usageCalcCPU(const stat_data_t& old, const stat_data_t& current,
- stat_data_t& calc);
- void readProcMeminfo(bool ttlMem=false);
-protected:
- int m_CPUcnt; // CPU core count
- stat_data_t* m_old; // CPU time of previous value
- stat_data_t* m_current; // CPU time of this time
- stat_data_t* m_calc; // usage CPU time
- unsigned int m_totalMem; // total memory size maybe kB
- unsigned int m_freeMem; // free memory size maybe kB
- int m_usageFreeMem; // usage free memory
-private:
- bool m_allready;
-};
-
-/**
- * @brief monitoring all ready
- * @return true:ok false:not good
- */
-inline bool CicoSCSysResourceMonitor::isAllReady() const
-{
- return m_allready;
-}
-
-/**
- * @brief cpu core count
- * @return cpum_usageFreeMem core count
- */
-inline int CicoSCSysResourceMonitor::getCPUCount() const
-{
- return m_CPUcnt;
-}
-
-/**
- * @brief user usage
- * @param cpu core cpu position -1:all 0-n:cpu position
- * @return cpu usage
- * @retval 0 - 10000 (value/100 = 0.00 - 100.00%)
- * @retval -1:get fail
- */
-inline int CicoSCSysResourceMonitor::getCPUuser(int cpu) const
-{
- return getCPUtime(E_user,cpu);
-}
-
-/**
- * @brief system usage
- * @param cpu core cpu position -1:all 0-n:cpu position
- * @return cpu usage
- * @retval 0 - 10000 (value/100 = 0.00 - 100.00%)
- * @retval -1:get fail
- */
-inline int CicoSCSysResourceMonitor::getCPUsystem(int cpu) const
-{
- return getCPUtime(E_system,cpu);
-}
-
-/**
- * @brief free memory size
- * @return free memory size maybe(kB)
- */
-inline unsigned int CicoSCSysResourceMonitor::getFreeMemSize() const
-{
- return m_freeMem;
-}
-
-/**
- * @brief total memory size
- * @return free memory size maybe(kB)
- */
-inline unsigned int CicoSCSysResourceMonitor::getTotalMemSize() const
-{
- return m_totalMem;
-}
-
-/**
- * @brief usage free memory
- * @return usage
- * @retval -1:during measurement
- * @retval 0 - 10000(value / 100 = 0.00% - 100.00%)
- */
-inline int CicoSCSysResourceMonitor::getUsageFreeMem() const // usage free memory
-{
- return m_usageFreeMem;
-}
-
-#endif // CICOSCSYSRESOURCEMONITOR_H
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSCUser.cpp
- *
- * @brief This file implementation of CicoSCUser class
- */
-/*========================================================================*/
-
-#include "CicoSCUser.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCUser::CicoSCUser()
- : name(""), passwd(""), homescreen(""), autolaunch(true)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCUser::~CicoSCUser()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUser::dump(void)
-{
- ICO_DBG("CicoSCUser: name=%s, pass=%s, homescreen=%s autolaunch=%s",
- name.c_str(), passwd.c_str(), homescreen.c_str(),
- autolaunch ? "true" : "false");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCUser.h
- *
- * @brief This file is definition of CicoSCUser class
- */
-//==========================================================================
-#ifndef __CICO_SC_USER_H__
-#define __CICO_SC_USER_H__
-
-#include <string>
-#include <vector>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCLastInfo;
-
-//==========================================================================
-/**
- * @brief This class hold user information
- */
-//==========================================================================
-class CicoSCUser
-{
-public:
- // default constructor
- CicoSCUser();
-
- // destructor
- virtual ~CicoSCUser();
-
- // dump log this class member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCUser& operator=(const CicoSCUser &object);
-
- // copy constructor
- CicoSCUser(const CicoSCUser &object);
-
-public:
- std::string name; ///< user name
- std::string passwd; ///< password
- std::string homescreen; ///< application ID of user uses homescreen
- bool autolaunch; ///< homescreen autolaunch flag
-
- std::vector<CicoSCLastInfo*> lastInfoList; ///< list of last information
-};
-#endif // __CICO_SC_USER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSCUserManager.cpp
- *
- * @brief This file implementation of CicoSCUserManager class
- */
-/*========================================================================*/
-
-#include <sys/stat.h>
-#include <dirent.h>
-
-#include <fstream>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
-#include <cstdio>
-using namespace boost;
-using namespace boost::property_tree;
-
-#include "ico_syc_error.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "ico_syc_public.h"
-
-#include "CicoLog.h"
-
-#include "CicoSCCommand.h"
-#include "CicoSCLastInfo.h"
-#include "CicoAulItems.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoSCMessage.h"
-#include "CicoSCServer.h"
-#include "CicoSCUserManager.h"
-#include "CicoSCUser.h"
-#include "CicoConf.h"
-#include "CicoSystemConfig.h"
-#include "Cico_aul_listen_app.h"
-
-using namespace std;
-
-//==========================================================================
-//
-// definition
-//
-//==========================================================================
-#define ICO_SYC_DEFAULT_PATH "/home/app/ico"
-#define ICO_SYC_APP_INFO "runningApp.info"
-#define ICO_SYC_APP_INFO_DEF "defaultApps.info"
-#define ICO_SYC_LASTINFO_DIR (char*)"/lastinfo/"
-#define ICO_SYC_LASTUSER_FILE (char*)"/home/app/ico/lastuser.txt"
-#define ICO_SYC_CHGUSR_FLAG_DIR "/tmp/ico"
-#define ICO_SYC_CHGUSR_FLAG_FIL "changeUser.flag"
-
-void chkAndAddSlash(string& s);
-
-/**
- * @brief applications die. callback function
- * @param pid
- * @param data user data
- * @return int
- * @retval -1: parameter error
- * @retval 0: handler execute
- */
-static int CSCUMapp_dead_handler(int pid, void *data)
-{
- CicoSCUserManager* x = (CicoSCUserManager*)data;
- if ((NULL == x) || (0 == x)) {
- return -1;
- }
- x->appDeadHandler(pid);
- return 0;
-}
-
-//==========================================================================
-//
-// private static variable
-//
-//==========================================================================
-CicoSCUserManager* CicoSCUserManager::ms_myInstance = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCUserManager::CicoSCUserManager()
- : m_login("")
-{
- ICO_TRA("start");
- aul_listen_app_dead_signal_add(CSCUMapp_dead_handler, (void*)this);
- m_vppa.clear();
- m_waitName.clear();
- m_waitHS.clear();
- m_wait = false;
- // login-user application information file
- m_uConfig = CicoSystemConfig::getInstance()->getUserConf();
- if ((NULL == m_uConfig) || (true == m_uConfig->m_parent_dir.empty())) {
- m_parentDir = ICO_SYC_DEFAULT_PATH;
- }
- else {
- m_parentDir = m_uConfig->m_parent_dir;
- }
- chkAndAddSlash(m_parentDir);
-
- // flag file
- m_flagPath = ICO_SYC_CHGUSR_FLAG_DIR;
- struct stat st;
- int ret = stat(m_flagPath.c_str(), &st);
- if (0 != ret) {
- mkdir(m_flagPath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
- }
- chkAndAddSlash(m_flagPath);
- m_flagPath += ICO_SYC_CHGUSR_FLAG_FIL;
- ICO_TRA("end");
-
- CicoSCUserManager::ms_myInstance = this;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCUserManager::~CicoSCUserManager()
-{
- ICO_TRA("CicoSCUserManager::~CicoSCUserManager Enter");
-
- // clear homescreen list
- m_homescreenList.clear();
-
- // clear userlist
- vector<CicoSCUser*>::iterator itr;
- itr = m_userList.begin();
- for (; itr != m_userList.end(); ++itr) {
- CicoSCUser *user = const_cast<CicoSCUser*>(*itr);
- // clear list of last information
- vector<CicoSCLastInfo*>::iterator info_itr;
- info_itr = user->lastInfoList.begin();
- for (; info_itr != user->lastInfoList.end(); ++info_itr) {
- // free memory
- delete *info_itr;
- }
- // free memory
- delete *itr;
- }
- m_userList.clear();
- m_vppa.clear();
-
- CicoSCUserManager::ms_myInstance = NULL;
-
- ICO_TRA("CicoSCUserManager::~CicoSCUserManager Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get instance of CicoSCUserManager
- *
- * @return pointer of CicoSCUserManager object
- */
-//--------------------------------------------------------------------------
-CicoSCUserManager*
-CicoSCUserManager::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCUserManager();
- }
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Handle command
- *
- * @param [in] cmd control command
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::handleCommand(const CicoSCCommand * cmd)
-{
- ICO_TRA("CicoSCUserManager::handleCommand Enter(%d)", cmd->cmdid);
-
- CicoSCCmdUserMgrOpt *opt = static_cast<CicoSCCmdUserMgrOpt*>(cmd->opt);
-
- switch (cmd->cmdid) {
- case MSG_CMD_CHANGE_USER:
- // change user
- changeUser(opt->user, opt->pass);
- break;
- case MSG_CMD_GET_USERLIST:
- // get userlist
- userlistCB(cmd->appid);
- break;
- case MSG_CMD_GET_LASTINFO:
- // get last information
- lastinfoCB(cmd->appid);
- break;
- case MSG_CMD_SET_LASTINFO:
- // set application's last information
- setLastInfo(cmd->appid, opt->lastinfo);
- break;
- default:
- ICO_WRN("Unknown Command(0x%08x)", cmd->cmdid);
- break;
- }
-
- ICO_TRA("CicoSCUserManager::handleCommand Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Load configuration file
- *
- * @param [in] confFile configuration file path
- * @return 0 on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCUserManager::load(const string & confFile)
-{
- ICO_TRA("CicoSCUserManager::load Enter (%s)", confFile.c_str());
-
- ptree root;
- // read config file (xml)
- read_xml(confFile, root);
-
- // create lists
- createUserList(root);
- createHomeScreenList(root);
- // set login user name
- setLoginUser(root);
-
- ICO_TRA("CicoSCUserManager::load Leave(EOK)");
-
- // always success
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Initialize CicoSCUserManager
- * This API must call after load() API
- *
- * @return 0 on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCUserManager::initialize(void)
-{
- ICO_TRA("CicoSCUserManager::initialize Enter");
-
- // get login user information
- const CicoSCUser *user = findUserConfbyName(m_login);
- if (NULL == user) {
- ICO_ERR("user not found");
- ICO_TRA("CicoSCUserManager::initialize Leave(ENXIO)");
- return ICO_SYC_ENXIO;
- }
-
- // launch homescreen
- if (true == user->autolaunch) {
- launchHomescreenReq(user->name, user->homescreen);
- }
- else {
- ICO_DBG("launch homescreen skip");
- }
-
- // load last information
- loadLastInfo();
-
- // make root directory
- string root_dir = m_uConfig->m_parent_dir;
- struct stat st;
- int ret = stat(root_dir.c_str(), &st);
- if (0 != ret) {
- mkdir(root_dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
- }
- // make user's directory
- string user_dir = m_parentDir + m_login;
- chkAndAddSlash(user_dir);
- ret = stat(user_dir.c_str(), &st);
- if (0 != ret) {
- mkdir(user_dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
- }
-
- // save last user
- saveLastUser();
-
- ICO_TRA("CicoSCUserManager::initialize Leave(EOK)");
-
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get login user information
- *
- * @return pointer of CicoSCUser
- */
-//--------------------------------------------------------------------------
-const CicoSCUser*
-CicoSCUserManager::getLoginUser(void)
-{
- return findUserConfbyName(m_login);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get userlist
- *
- * @return pointer of userlist
- */
-//--------------------------------------------------------------------------
-const vector<CicoSCUser*>&
-CicoSCUserManager::getUserList(void)
-{
- return m_userList;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get homescreen list
- *
- * @return pointer of homescreen list
- */
-//--------------------------------------------------------------------------
-const vector<string>&
-CicoSCUserManager::getHomeScreenList(void)
-{
- return m_homescreenList;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Change login user
- *
- * @param [in] name user name
- * @param [in] passwd password
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::changeUser(const string & name, const string & passwd)
-{
- ICO_TRA("CicoSCUserManager::changeUser Enter"
- "(user=%s pass=%s)", name.c_str(), passwd.c_str());
-
- char tmpText[128];
- sprintf(tmpText, "CHG USER[%s]->[%s]", m_login.c_str(), name.c_str());
-
- string oldUsr = m_login; /* get before login user */
- const CicoSCUser *conf = NULL;
- // check all user logoff
- if ((name.empty()) || (name[0] == ' ')) {
- ICO_TRA("CicoSCUserManager::changeUser Leave(all user logoff)");
- flagFileOn();
- killingAppsAndHS(oldUsr);
- return;
- }
-
- // if changed user name is same last user name
- if (0 == name.compare(m_login)) {
- ICO_TRA("CicoSCUserManager::changeUser Leave(request is same user)");
- return;
- }
-
- // get user config
- conf = findUserConfbyName(name);
- if (NULL == conf) {
- ICO_TRA("CicoSCUserManager::changeUser Leave(ENXIO)");
- return;
- }
-
- // check password
- if (passwd != conf->passwd) {
- ICO_TRA("CicoSCUserManager::changeUser Leave(EINVAL)");
- return;
- }
-
- flagFileOn();
-
-#if 0
- // Imprinting to file, that file is application's running information
- string usr_dir_old;
- getWorkingDir(oldUsr, usr_dir_old);
- string outfilename = usr_dir_old + ICO_SYC_APP_INFO;
- impritingLastApps(outfilename);
-#endif
-
- // killing running application and homeScreen
- killingAppsAndHS(oldUsr);
- CicoSCLifeCycleController* csclcc = CicoSCLifeCycleController::getInstance();
- csclcc->startAppResource(name);
-
- // check wheather directory exists
- vector<string> mk_dir_info;
- mk_dir_info.push_back(m_uConfig->m_parent_dir);
- string usr_dir;
- getWorkingDir(conf->name, usr_dir);
- mk_dir_info.push_back(usr_dir);
- vector<string>::iterator it = mk_dir_info.begin();
- for (; it != mk_dir_info.end(); it++) {
- const char* dir = (*it).c_str();
- struct stat st;
- if (0 == stat(dir, &st)) {
- continue; // continue of for
- }
- mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO);
- }
- csclcc->createAppResourceFile(name);
-
- if (0 != m_vppa.size()) {
- // wait dead signal recieve
- m_waitName = conf->name;
- m_waitHS = conf->homescreen;
- m_wait = true;
- // run call launchHomescreenReq is appDeadHandler !
- ICO_TRA("CicoSCUserManager::changeUser Leave(WAIT:%s)", m_waitName.c_str());
- return;
- }
- // change homescreen application
- sleep(2); // wait 2 sec for dead all applications
- launchHomescreenReq(conf->name, conf->homescreen);
- // change login user
- m_login = conf->name;
- saveLastUser();
- ICO_DBG("login user changed (user=%s)", m_login.c_str());
- ICO_INF("%s", tmpText);
- flagFileOff();
- m_waitName.clear();
- m_waitHS.clear();
- m_wait = false;
- ICO_TRA("CicoSCUserManager::changeUser Leave(EOK)");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief imprinting to file, that file is application's running information
- * @param usrnam target user name
- * @return bool
- * @retval true success
- * @retval false fail
- */
-//--------------------------------------------------------------------------
-bool CicoSCUserManager::impritingLastApps(const string& ofnm)
-{
- ICO_TRA("CicoSCUserManager::impritingLastApps Enter");
- vector<string> vs;
- CicoSCLifeCycleController* oCSCLCC;
- oCSCLCC = CicoSCLifeCycleController::getInstance();
- if ((NULL == oCSCLCC) || (0 == oCSCLCC)) {
- ICO_ERR(" CicoSCLifeCycleController is null");
- ICO_TRA("CicoSCUserManager::impritingLastApps Leave(false)");
- return false;
- }
- const vector<CicoAulItems>& aulList = oCSCLCC->getAulList();
- for (int i=aulList.size() ; i != 1; i--) {
- const CicoAulItems* pO = aulList[i-1].p();
- if ((NULL == pO) || (0 == pO)) {
- continue;
- }
- if (pO->m_appid == "org.tizen.ico.login") {
- continue;
- }
- if (pO->m_appid == "org.tizen.ico.statusbar") {
- continue;
- }
- if (pO->m_appid == "org.tizen.ico.homescreen") {
- continue;
- }
- vs.push_back(pO->m_appid);
- }
-
- if (0 == vs.size()) {
- remove(ofnm.c_str());
- ICO_TRA("CicoSCUserManager::impritingLastApps Leave(app none)");
- return true;
- }
- ofstream ofs;
- ofs.open(ofnm.c_str(), ios::trunc);
- vector<string>::iterator it = vs.begin();
- for (; it != vs.end(); it++) {
- ofs << *it << endl;
- }
- ofs.close();
- ICO_TRA("CicoSCUserManager::impritingLastApps app = %d", vs.size());
- return false;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief killing running applications and homeScreen
- * @param usrnam target user name
- * @return bool
- * @retval true success
- * @retval false fail
- */
-//--------------------------------------------------------------------------
-bool CicoSCUserManager::killingAppsAndHS(const string&)
-{
- ICO_TRA("CicoSCUserManager::killingAppsAndHS Enter");
-
- m_vppa.clear();
- CicoSCLifeCycleController* oCSCLCC;
- oCSCLCC = CicoSCLifeCycleController::getInstance();
- if ((NULL == oCSCLCC) || (0 == oCSCLCC)) {
- ICO_TRA("CicoSCUserManager::killingAppsAndHS Leave(ENXIO)");
- return false;
- }
- bool r = false;
- const vector<CicoAulItems>& aulList = oCSCLCC->getAulList();
- vector<int> pids;
- for (int i=aulList.size() ; i != 0; i--) {
- const CicoAulItems* pObj = aulList[i-1].p();
- if ((NULL == pObj) || (0 == pObj)) {
- continue;
- }
- ICO_DBG("CicoSCUserManager::killingAppsAndHS Tgt:%d(%s)", pObj->m_pid,
- pObj->m_appid.c_str());
- pids.push_back(pObj->m_pid);
- m_vppa.push_back(pairPidAppid(pObj->m_pid, pObj->m_appid));
- r = true;
- }
- int sz = pids.size();
- for (int j=0; j < sz; j++) {
- oCSCLCC->terminate(pids[j]);
- }
- ICO_TRA("CicoSCUserManager::killingAppsAndHS Leave(ret=%s)",
- r? "true": "false");
- return r;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief homescreen launch request
- * @param usrnam target user name
- * @return bool
- * @retval true success
- * @retval false fail
- */
-//--------------------------------------------------------------------------
-void CicoSCUserManager::getWorkingDir(const string& usr, string& dir)
-{
- dir = m_parentDir;
- dir += usr;
- chkAndAddSlash(dir);
- return;
-}
-//--------------------------------------------------------------------------
-/**
- * @brief homescreen launch request
- * @param usrnam target user name
- * @return bool
- * @retval true success
- * @retval false fail
- */
-//--------------------------------------------------------------------------
-bool CicoSCUserManager::launchHomescreenReq(const string& usr,
- const string& appid_hs)
-{
- string usr_dir;
- getWorkingDir(usr, usr_dir);
- // set login-user history file path
- string a_prmfn = usr_dir + ICO_SYC_APP_INFO;
- // set default history file path
- string d_prmfn = m_parentDir + string(ICO_SYC_APP_INFO_DEF);
-
- bundle *b;
- b = bundle_create();
- // bundle add login-user name
- bundle_add(b, ICO_SYC_APP_BUNDLE_KEY1, usr.c_str());
- // bundle add login-user history file path
- bundle_add(b, ICO_SYC_APP_BUNDLE_KEY2, a_prmfn.c_str());
- // bundle add default history file path
- bundle_add(b, ICO_SYC_APP_BUNDLE_KEY3, d_prmfn.c_str());
- // bundle add flag file path
- bundle_add(b, ICO_SYC_APP_BUNDLE_KEY4, m_flagPath.c_str());
-
- ICO_DBG("launch homescreen (user=%s, appid=%s, parm=%s, %s)",
- usr.c_str(), appid_hs.c_str(), a_prmfn.c_str(), d_prmfn.c_str());
-
- CicoSCLifeCycleController* oCSCLCC;
- oCSCLCC = CicoSCLifeCycleController::getInstance();
- int r = oCSCLCC->launch(appid_hs.c_str(), b);
-
- bundle_free(b);
-
- if (ICO_SYC_EOK != r) {
- ICO_DBG("CicoSCUserManager::launchHomescreenReq false(%d)", r);
- return false;
- }
- ICO_DBG("CicoSCUserManager::launchHomescreenReq true(ICO_SYC_EOK)");
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log m_userList member variables
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::dumpUserList(void)
-{
- vector<CicoSCUser*>::iterator itr;
- itr = m_userList.begin();
- for (; itr != m_userList.end(); ++itr) {
- const CicoSCUser* conf = const_cast<CicoSCUser*>(*itr);
- ICO_DBG("user name=%s, pass=%s, homescreen=%s",
- (conf->name).c_str(), (conf->passwd).c_str(),
- (conf->homescreen).c_str());
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log m_homescreenList member variables
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::dumpHomeScreenList(void)
-{
- vector<string>::iterator itr;
- itr = m_homescreenList.begin();
- for (; itr != m_homescreenList.end(); ++itr) {
- ICO_DBG("homescreen=%s", (*itr).c_str());
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Callback of "get userlist"
- *
- * @param [in] appid application id to send message
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::userlistCB(const string & appid)
-{
- ICO_TRA("CicoSCUserManager::userlistCB Enter (%s)", appid.c_str());
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_GET_USERLIST);
- message->addRootObject("appid", appid);
- // set number of user
- message->addArgObject("user_num", m_userList.size());
- // set user list
- vector<CicoSCUser*>::iterator itr;
- itr = m_userList.begin();
- for (; itr != m_userList.end(); ++itr) {
- const CicoSCUser* conf = const_cast<CicoSCUser*>(*itr);
- message->addElmArray(conf->name);
- }
- message->addArgObject("user_list");
-
- // set login user name
- message->addArgObject("user_login", m_login);
-
- CicoSCServer::getInstance()->sendMessage(appid, message);
-
- ICO_TRA("CicoSCUserManager::userlistCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Callback of "get application's last information"
- *
- * @param [in] appid application id to send message
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::lastinfoCB(const string & appid)
-{
- ICO_TRA("CicoSCUserManager::lastinfoCB Enter(%s)", appid.c_str());
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_GET_LASTINFO);
- message->addRootObject("appid", appid);
-
- CicoSCUser* user = const_cast<CicoSCUser*>(findUserConfbyName(m_login));
- // search application's last information
- vector<CicoSCLastInfo*>::iterator itr;
- itr = user->lastInfoList.begin();
- for (; itr != user->lastInfoList.end(); ++itr) {
- const CicoSCLastInfo *info = const_cast<CicoSCLastInfo*>(*itr);
- if (appid == info->appid) {
- // set last information
- message->addArgObject("lastinfo", info->lastinfo);
- break;
- }
- }
-
- CicoSCServer::getInstance()->sendMessage(appid, message);
-
- ICO_TRA("CicoSCUserManager::lastinfoCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Save last user name to last user file
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::saveLastUser(void)
-{
- ICO_TRA("CicoSCUserManager::saveLastUser Enter(name=%s)", m_login.c_str());
-
- // output last user name to file
- std::ofstream stream;
- string file = ICO_SYC_LASTUSER_FILE;
- stream.open(file.c_str());
- stream << m_login << std::endl;
- stream.close();
-
- ICO_TRA("CicoSCUserManager::saveLastUser Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Load last user name from last user file
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::loadLastUser(void)
-{
- ICO_TRA("CicoSCUserManager::loadLastUser Enter");
-
- // check weather file exists
- struct stat st;
- int ret = stat(ICO_SYC_LASTUSER_FILE, &st);
- if (0 != ret) {
- // last user file does not exist
- ICO_TRA("CicoSCUserManager::loadLastUser Leave");
- return;
- }
-
- // load last user name
- std::ifstream stream;
- stream.open(ICO_SYC_LASTUSER_FILE);
- stream >> m_login;
- stream.close();
-
- // check login name is valid
- if (false == m_login.empty()) {
- bool bValid = false;
- vector<CicoSCUser*>::iterator it = m_userList.begin();
- while (it != m_userList.end()) {
- if (0 == (*it)->name.compare(m_login)) {
- bValid = true;
- break;
- }
- ++it;
- }
- if (false == bValid) {
- ICO_WRN("last user NG!, user name \"%s\" clear", m_login.c_str());
- m_login.clear();
- }
- }
-
- ICO_TRA("CicoSCUserManager::loadLastUser Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Load application's last information
- *
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::loadLastInfo()
-{
- ICO_TRA("CicoSCUserManager::loadLastInfo Enter(name=%s)", m_login.c_str());
-
- if (m_login.empty()) {
- ICO_ERR("m_login is empty");
- ICO_TRA("CicoSCUserManager::loadLastInfo Leave(m_login is empty)");
- return;
- }
-
- // get login user object
- CicoSCUser* loginUser = NULL;
- loginUser = const_cast<CicoSCUser*>(findUserConfbyName(m_login));
- // check login user
- if (NULL == loginUser) {
- // login user does not exist in the user list
- ICO_ERR("login user not found");
- ICO_TRA("CicoSCUserManager::setLastInfo Leave(login user not found)");
- return;
- }
-
- // check weather file exists
- struct stat st;
- string dir = m_parentDir + m_login + ICO_SYC_LASTINFO_DIR;
- int ret = stat(dir.c_str(), &st);
- if (0 != ret) {
- // lastinfo directory does not exist
- ICO_WRN("lastinfo directory dose not exist)");
- ICO_TRA("CicoSCUserManager::loadLastInfo Leave(dir dose not exist)");
- return;
- }
-
- // get file list
- struct dirent **filelist;
- int filenum = scandir(dir.c_str(), &filelist, NULL, NULL);
- for (int i = 0; i < filenum; ++i) {
- string filename = filelist[i]->d_name;
- string::size_type index = filename.find(".txt");
- if (string::npos != index) {
- // load last information from file
- string infofile = dir + filename;
- string info;
- std::ifstream stream;
- stream.open(infofile.c_str());
- std::getline(stream, info);
- stream.close();
-
- // get appid (erase ".txt" from filename)
- filename.erase(index, filename.size());
- // create new object
- CicoSCLastInfo* lastInfo = new CicoSCLastInfo;
- // set application's information
- lastInfo->appid = filename;
- lastInfo->lastinfo = info;
- // add to list
- loginUser->lastInfoList.push_back(lastInfo);
- }
- free(filelist[i]);
- }
- free(filelist);
-
- ICO_TRA("CicoSCUserManager::loadLastInfo Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Set login user information
- *
- * @param [in] root pointer of ptree object
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::setLoginUser(const ptree & root)
-{
- ICO_TRA("CicoSCUserManager::setLoginUser Enter");
-
- // load last user name
- loadLastUser();
-
- if (m_login.empty()) {
- // get user name from config file
- ptree default_user = root.get_child("userconfig.default");
-
- int check_flag = 0;
- BOOST_FOREACH (const ptree::value_type& child, default_user) {
- if (0 != strcmp(child.first.data(), "user")) {
- ICO_ERR("unknown element (%s)", child.first.data());
- }
-
- optional<string> name;
- name = child.second.get_optional<string>("name");
- if (false == name.is_initialized()) {
- ICO_ERR("user.name element not found");
- continue;
- }
- m_login = name.get();
- check_flag++;
- }
-
- // default user name does not exist in the m_userList
- if (check_flag == 0) {
- vector<CicoSCUser*>::iterator itr;
- itr = m_userList.begin();
- const CicoSCUser* conf = const_cast<CicoSCUser*>(*itr);
- m_login = conf->name;
- }
- }
-
- // dump data
- ICO_DBG("login user name: %s", m_login.c_str());
-
- ICO_TRA("CicoSCUserManager::setLoginUser Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Create userlist
- *
- * @param [in] root pointer of ptree object
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::createUserList(const ptree & root)
-{
- ICO_TRA("CicoSCUserManager::createUserList Enter");
-
- ptree homescreens = root.get_child("userconfig.users");
-
- BOOST_FOREACH (const ptree::value_type& child, homescreens) {
- if (0 != strcmp(child.first.data(), "user")) {
- ICO_ERR("unknown element (%s)", child.first.data());
- }
-
- // get value
- optional<string> name;
- optional<string> passwd;
- optional<string> homescreen;
- optional<string> autolaunch;
-
- name = child.second.get_optional<string>("name");
- if (false == name.is_initialized()) {
- ICO_ERR("user.name element not found");
- continue;
- }
- passwd = child.second.get_optional<string>("passwd");
- if (false == passwd.is_initialized()) {
- ICO_ERR("user.passwd element not found");
- continue;
- }
- autolaunch = child.second.get_optional<string>("hs.<xmlattr>.autolaunch");
- if (false == autolaunch.is_initialized()) {
- autolaunch = optional<string>("true");
- }
- homescreen = child.second.get_optional<string>("hs");
- if (false == homescreen.is_initialized()) {
- ICO_ERR("user.hs element not found");
- continue;
- }
-
- CicoSCUser* userConf = new CicoSCUser;
- userConf->name = name.get();
- userConf->passwd = passwd.get();
- userConf->homescreen = homescreen.get();
- userConf->autolaunch = (autolaunch.get().compare("false") == 0) ? false : true;
- // dump data
- userConf->dump();
-
- // add object to the list
- m_userList.push_back(userConf);
- }
-
- ICO_TRA("CicoSCUserManager::createUserList Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Create homescreen list
- *
- * @param [in] root pointer of ptree object
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::createHomeScreenList(const ptree & root)
-{
- ICO_TRA("CicoSCUserManager::createHomeScreenList Enter");
-
- ptree homescreens = root.get_child("userconfig.homescreens");
-
- BOOST_FOREACH (const ptree::value_type& child, homescreens) {
- if (0 != strcmp(child.first.data(), "homescreen")) {
- ICO_ERR("unknown element (%s)", child.first.data());
- }
- // get value
- optional<string> name;
- name = child.second.get_optional<string>("<xmlattr>.name");
- if (false == name.is_initialized()) {
- ICO_ERR("homescreen.name attr not found");
- continue;
- }
- // add value to the list
- m_homescreenList.push_back(name.get());
- }
- // dump data
- dumpHomeScreenList();
-
- ICO_TRA("CicoSCUserManager::createHomeScreenList Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Set last user information
- *
- * @param [in] appid application id
- * @param [in] info application's last information
- * @return none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCUserManager::setLastInfo(const string & appid, const string & info)
-{
- ICO_TRA("CicoSCUserManager::setLastInfo Enter(appid: %s, info: %s)",
- appid.c_str(), info.c_str());
-
- CicoSCUser* loginUser = NULL;
- CicoSCLastInfo* lastInfo = NULL;
-
- // get login user object
- loginUser = const_cast<CicoSCUser*>(findUserConfbyName(m_login));
- // check login user
- if (NULL == loginUser) {
- // login user does not exist in the user list
- ICO_ERR("login user does not exist in the user list");
- ICO_TRA("CicoSCUserManager::setLastInfo Leave");
- return;
- }
-
- // check whether lastinfo object exists
- vector<CicoSCLastInfo*>::iterator info_itr;
- info_itr = loginUser->lastInfoList.begin();
- for (; info_itr != loginUser->lastInfoList.end(); ++info_itr) {
- CicoSCLastInfo *linfo = const_cast<CicoSCLastInfo*>(*info_itr);
- if (appid == linfo->appid) {
- lastInfo = linfo;
- break;
- }
- }
-
- if (NULL == lastInfo) {
- // create new object
- lastInfo = new CicoSCLastInfo;
- // set application's information
- lastInfo->appid = appid;
- lastInfo->lastinfo = info;
- // add to list
- loginUser->lastInfoList.push_back(lastInfo);
- }
- else {
- // update application's last information
- lastInfo->lastinfo = info;
- }
-
- // check wheather directory exists
- string info_dir = m_parentDir + m_login + ICO_SYC_LASTINFO_DIR;
- struct stat st;
- int ret = stat(info_dir.c_str(), &st);
- if (0 != ret) {
- // make directory
- mkdir(info_dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
- }
-
- // output application's last information to file
- std::ofstream stream;
- string file = info_dir + lastInfo->appid + ".txt";
- stream.open(file.c_str());
- stream << lastInfo->lastinfo << std::endl;
- stream.close();
-
- // dump data
- ICO_DBG("login user=%s", (loginUser->name).c_str());
- lastInfo->dumpLastInfo();
-
- ICO_TRA("CicoSCUserManager::setLastInfo Leave(EOK)");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Find user configuration by user name
- *
- * @param [in] name user name
- * @return pointer of CicoSCUser data on success, NULL on error
- */
-//--------------------------------------------------------------------------
-const CicoSCUser*
-CicoSCUserManager::findUserConfbyName(const string & name)
-{
-// ICO_TRA("CicoSCUserManager::findUserConfbyName Enter (%s)", name.c_str());
-
- vector<CicoSCUser*>::iterator itr;
- itr = m_userList.begin();
- for (; itr != m_userList.end(); ++itr) {
- const CicoSCUser* conf = const_cast<CicoSCUser*>(*itr);
- if (name == conf->name) {
-// ICO_TRA("CicoSCUserManager::findUserConfbyName Leave(%s)",
-// conf->name);
- return conf;
- }
- }
-
-// ICO_TRA("CicoSCUserManager::findUserConfbyName Leave(NULL)");
- return NULL;
-}
-
-/**
- * @brief flag file on(create)
- */
-void CicoSCUserManager::flagFileOn(const char* text)
-{
- if (true == m_flagPath.empty()) {
- ICO_DBG("FLAG(FILE) empty");
- return;
- }
- const char* f = m_flagPath.c_str();
- ofstream oFlagFile;
- oFlagFile.open(f, ios::trunc);
- if ((NULL != text) && (0 != text) && (0 != strlen(text))) {
- oFlagFile << text << endl;
- }
- oFlagFile.close();
- ICO_DBG("FILE(%s) create(FLAG ON)", f);
-}
-
-/**
- * @brief flag file off(remove)
- */
-void CicoSCUserManager::flagFileOff()
-{
- if (true == m_flagPath.empty()) {
- ICO_DBG("FLAG(FILE) empty");
- return;
- }
- const char* f = m_flagPath.c_str();
- struct stat st;
- int r = stat(f, &st);
- if (0 != r) {
- ICO_DBG("FILE(%s) is Nothing", f);
- return;
- }
- remove(f);
- ICO_DBG("FILE(%s) FLAG off(remove)", f);
- return;
-}
-
-/**
- * @brief app dead Handler
- * @param pid dead pid
- * @return bool
- * @retval true pid is target
- * @retval false pid is no target
- */
-bool CicoSCUserManager::appDeadHandler(int pid)
-{
- ICO_TRA("start (%d)", pid);
- if (false == m_wait) {
- ICO_TRA("end");
- return false;
- }
- ICO_DBG("dead app(%d)", pid);
- bool bBINGO = false;
- string appid;
- vector<pairPidAppid>::iterator it = m_vppa.begin(); // iterator set begin
- while(it != m_vppa.end()) { // loop to the last data
- if ((*it).first == pid) {
- appid = (*it).second;
- m_vppa.erase(it);
- bBINGO = true;
- break; // break of while it
- }
- ++it; // next data
- }
- if (false == bBINGO) {
- ICO_TRA("end FAIL pid(%d)", pid);
- return false;
- }
-#if 1
- int sz = m_vppa.size();
- if (0 != sz) {
- ICO_TRA("end contenue wait(%d)", sz);
- return true;
- }
-#else
- if (0 != appid.compare(m_waitHS)) {
- ICO_TRA("end contenue wait(%s)", appid.c_str());
- return true;
- }
-#endif
- char tmpText[128];
- sprintf(tmpText, "CHG USER[%s]->[%s]", m_login.c_str(), m_waitName.c_str());
-
- // change homescreen application
- sleep(2); // wait 2 sec for dead all applications
- launchHomescreenReq(m_waitName, m_waitHS);
- // change login user
- m_login = m_waitName;
- saveLastUser();
- ICO_DBG("login user changed (user=%s)", m_login.c_str());
- ICO_INF("%s", tmpText);
- flagFileOff();
- m_waitName.clear();
- m_waitHS.clear();
- m_wait = false;
- ICO_TRA("end homescreen start req.(%s)", appid.c_str());
- return true;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCUserManager.h
- *
- * @brief This file is definition of CicoSCUserManager class
- */
-//==========================================================================
-#ifndef __CICO_SC_USER_MANAGER_H__
-#define __CICO_SC_USER_MANAGER_H__
-
-#include <string.h>
-#include <vector>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCCommand;
-class CicoSCUser;
-class CicoSCUserConf;
-
-typedef std::pair<int, std::string> pairPidAppid;
-
-//==========================================================================
-/*
- * @brief This class manages control of user and access to user information
- */
-//==========================================================================
-class CicoSCUserManager
-{
-public:
- // get CicoSCUserManager instance
- static CicoSCUserManager* getInstance(void);
-
- // handle command
- void handleCommand(const CicoSCCommand * cmd);
-
- // load configuration file
- int load(const std::string & confFile);
- // initialize
- int initialize(void);
-
- // get information
- const CicoSCUser* getLoginUser(void);
- const std::vector<CicoSCUser*>& getUserList(void);
- const std::vector<std::string>& getHomeScreenList(void);
-
- // change user
- void changeUser(const std::string & name, const std::string & passwd);
- void cloaseUser();
-
- // dump log
- void dumpUserList(void);
- void dumpHomeScreenList(void);
-
- // application daed watcher
- bool appDeadHandler(int pid);
-
- bool isStoppingNow();
-
- // working user directory make
- void getWorkingDir(const std::string& usr, std::string& dir);
- const std::string& getHomeDir() const;
-private:
- // default constructor
- CicoSCUserManager();
-
- // destructor
- ~CicoSCUserManager();
-
- // assignment operator
- CicoSCUserManager& operator=(const CicoSCUserManager &object);
-
- // copy constructor
- CicoSCUserManager(const CicoSCUserManager &object);
-
- // callback
- void userlistCB(const std::string & appid);
- void lastinfoCB(const std::string & appid);
-
- // save last user name to file
- void saveLastUser(void);
- // load last user name from file
- void loadLastUser(void);
- // load last information from file
- void loadLastInfo(void);
-
- // set login user info from config file
- void setLoginUser(const boost::property_tree::ptree & root);
- // create list from config file
- void createUserList(const boost::property_tree::ptree & root);
- void createHomeScreenList(const boost::property_tree::ptree & root);
-
- // set application's last information
- void setLastInfo(const std::string & appid, const std::string & info);
-
- // find user config by user name
- const CicoSCUser* findUserConfbyName(const std::string & name);
-
- // Imprinting to file, that file is application's running information
- bool impritingLastApps(const std::string& ofnm);
-
- // Killing running application and homeScreen
- bool killingAppsAndHS(const std::string& usrnm);
-
- // launch homescreen request
- bool launchHomescreenReq(const std::string& usr,
- const std::string& appid_hs);
-
- // flag file control
- void flagFileOn(const char* text = NULL);
- void flagFileOff();
-
-private:
- static CicoSCUserManager* ms_myInstance; ///< CicoSCUserManager Object
-
- std::string m_login; ///< Login User Name
- std::vector<CicoSCUser*> m_userList; ///< User List
- std::vector<std::string> m_homescreenList; ///< HomeScreen List
- std::string m_parentDir; /// login-user use directory
- const CicoSCUserConf* m_uConfig;
- std::string m_flagPath; /// history save control flag file
- std::vector<pairPidAppid> m_vppa; /// app dead watcher
- bool m_wait; /// app dead wait flag
- std::string m_waitName; /// wait backup login name
- std::string m_waitHS; /// wait backup homescreen appid
-};
-
-/**
- * @brief get Homescreen Stopping Status
- * @ret bool
- * @retval true: stopping now
- * @retval false: no stop
- *
- */
-inline bool CicoSCUserManager::isStoppingNow(){
- return !m_vppa.empty();
-}
-
-/**
- * @brief close User
- */
-inline void CicoSCUserManager::cloaseUser()
-{
- flagFileOn();
- killingAppsAndHS(m_login);
-}
-
-/**
- *
- */
-inline const std::string& CicoSCUserManager::getHomeDir() const
-{
- return m_parentDir;
-}
-
-#endif // __CICO_SC_USER_MANAGER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCVInfo.h
- *
- * @brief This file is definition of CicoSCVInfo class
- */
-//==========================================================================
-#ifndef __CICO_SC_VINFO_H__
-#define __CICO_SC_VINFO_H__
-
-#include <ico_dbus_amb_efl.h>
-
-//--------------------------------------------------------------------------
-/**
- * @brief Enumerations of vehicle information property
- */
-//--------------------------------------------------------------------------
-typedef enum _ico_vinfo_prop {
- ICO_VINFO_VEHICLE_SPEED = 1, ///< vehicle speed
- ICO_VINFO_SHIFT_POSITION, ///< shift position
- ICO_VINFO_LIGHT_LEFT, ///< light left(Turn left)
- ICO_VINFO_LIGHT_RIGHT, ///< light right(Turn right)
- ICO_VINFO_NIGHT_MODE, ///< night mode
- ICO_VINFO_DRIVING_MODE, ///< driving mode
-
- ICO_VINFO_MAX ///< maximum number of type
-} ico_vinfo_prop_e;
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class holds vehicle information
- */
-//--------------------------------------------------------------------------
-class CicoSCVInfo
-{
-public:
- // default constructor
- CicoSCVInfo(int type, int prop, union dbus_value_variant value)
- : m_type(type), m_prop(prop), m_value(value) {}
-
- // destructor
- virtual ~CicoSCVInfo() {}
-
- // get value type
- int getType(void) { return m_type; }
-
- // get property
- int getProperty(void) { return m_prop; }
-
- // get boolean value
- bool getBooleanValue(void) { return (m_value.bval != 0) ? true : false; }
-
- // get int8_t value
- int8_t getint8Value(void) { return m_value.yval; }
-
- // get uint8_t value
- uint8_t getUint8Value(void) { return m_value.yval; }
-
- // get int16_t value
- int16_t getInt16Value(void) { return m_value.i16val; }
-
- // get uint16_t value
- uint16_t getUint16Value(void) { return m_value.ui16val; }
-
- // get int32_t value
- int32_t getInt32Value(void) { return m_value.i32val; }
-
- // get uint32_t value
- uint32_t getUint32Value(void) { return m_value.ui32val; }
-
- // get int64_t value
- int64_t getInt64Value(void) { return m_value.i64val; }
-
- // get uint64_t value
- uint64_t getUint64Value(void) { return m_value.ui64val; }
-
- // get double value
- double getDoubleValue(void) { return m_value.dval; }
-
- // get string value
- const char* getStringValue(void) { return (const char*)m_value.sval; }
-
-private:
- // default constructor
- CicoSCVInfo();
-
- // assignment operator
- CicoSCVInfo& operator=(const CicoSCVInfo &object);
-
- // copy constructor
- CicoSCVInfo(const CicoSCVInfo &object);
-
-private:
- // type of value
- int m_type;
-
- // property id of vehicle information
- int m_prop;
-
- // vehicle information value
- union dbus_value_variant m_value;
-};
-#endif // __CICO_SC_VINFO_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCVInfoManager.cpp
- *
- * @brief This file implementation of CicoSCVInfoManager class
- */
-//==========================================================================
-
-#include <string>
-
-#include <Ecore.h>
-
-#include "CicoLog.h"
-#include <ico_dbus_amb_efl.h>
-#include "CicoSCVInfoManager.h"
-#include "CicoSystemConfig.h"
-#include "CicoConf.h"
-#include "CicoSCVInfo.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-CicoSCVInfoManager* CicoSCVInfoManager::ms_myInstance = NULL;
-int CicoSCVInfoManager::ms_ecoreEvType= 0;
-dbus_type CicoSCVInfoManager::ms_dbusTypes[ICO_TYPE_MAX];
-int CicoSCVInfoManager::ms_retryCnt = 0;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCVInfoManager::CicoSCVInfoManager()
- : m_initialized(false)
-{
- ms_dbusTypes[ICO_TYPE_UNKNOW] = DBUS_TYPE_INT32;
- ms_dbusTypes[ICO_TYPE_BOOLEAN] = DBUS_TYPE_BOOLEAN;
- ms_dbusTypes[ICO_TYPE_INT8] = DBUS_TYPE_BYTE;
- ms_dbusTypes[ICO_TYPE_UINT8] = DBUS_TYPE_BYTE;
- ms_dbusTypes[ICO_TYPE_INT16] = DBUS_TYPE_INT16;
- ms_dbusTypes[ICO_TYPE_UINT16] = DBUS_TYPE_UINT16;
- ms_dbusTypes[ICO_TYPE_INT32] = DBUS_TYPE_INT32;
- ms_dbusTypes[ICO_TYPE_UINT32] = DBUS_TYPE_UINT32;
- ms_dbusTypes[ICO_TYPE_INT64] = DBUS_TYPE_INT64;
- ms_dbusTypes[ICO_TYPE_UINT64] = DBUS_TYPE_UINT64;
- ms_dbusTypes[ICO_TYPE_DOUBLE] = DBUS_TYPE_DOUBLE;
- ms_dbusTypes[ICO_TYPE_STRING] = DBUS_TYPE_STRING;
-
- ms_ecoreEvType = ecore_event_type_new();
-
- CicoSCVInfoManager::ms_myInstance = this;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCVInfoManager::~CicoSCVInfoManager()
-{
- CicoSCVInfoManager::ms_myInstance = NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get instance of CicoSystemConfig
- *
- * @return pointer of CicoSystemConfig object
- */
-//--------------------------------------------------------------------------
-CicoSCVInfoManager*
-CicoSCVInfoManager::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCVInfoManager();
- }
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief startup communication of vehicle information
- *
- * @return result
- * @retval true success
- * @retval false error
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCVInfoManager::startup(void)
-{
- ICO_TRA("CicoSCVInfoManager::startup Enter");
-
- if (true == m_initialized) {
- ICO_DBG("already initialized.");
- ICO_TRA("CicoSCVInfoManager::startup Leave(true)");
- }
-
- ICO_DBG("called: ico_dbus_amb_start");
- int ret = ico_dbus_amb_start();
- if (0 != ret) {
- ICO_ERR("ico_dbus_amb_start failed. ret=%d", ret);
- ICO_TRA("CicoSCVInfoManager::startup Leave(false)");
- return false;
- }
-
- m_initialized = true;
-
- startMonitoring();
-
-
- ICO_TRA("CicoSCVInfoManager::startup Leave(true)");
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief teardown communication of vehicle information
- *
- * @return result
- * @retval true success
- * @retval false error
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCVInfoManager::teardown(void)
-{
- ICO_TRA("CicoSCVInfoManager::teardown Enter");
-
- if (false == m_initialized) {
- ICO_DBG("not initialized.");
- ICO_TRA("CicoSCVInfoManager::teardown Leave(true)");
- }
-
- m_initialized = false;
-
- stopMonitoring();
-
- ICO_DBG("called: ico_dbus_amb_end");
- int ret = ico_dbus_amb_end();
- if (0 != ret) {
- ICO_ERR("ico_dbus_amb_end faile. ret=%d", ret);
- ICO_TRA("CicoSCVInfoManager::teardown Leave(false)");
- return false;
- }
-
- ICO_TRA("CicoSCVInfoManager::teardown Leave(true)");
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get ecore event type of changed vehicle information
- *
- * @return ecore event type
- */
-//--------------------------------------------------------------------------
-int
-CicoSCVInfoManager::getEcoreEvType(void)
-{
- return ms_ecoreEvType;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get vehicle information
- *
- * @param [in] property vehicle information property
- *
- * @return result
- * @retval true success
- * @retval false error
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCVInfoManager::getVehicleInfo(int property)
-{
- ICO_TRA("CicoSCVInfoManager::getVehicleInfo Enter(prop=%d)", property);
-
- if (false == m_initialized) {
- ICO_DBG("not initialized.");
- ICO_TRA("CicoSCVInfoManager::getVehicleInfo Leave(false)");
- return false;
- }
-
- CicoSystemConfig* sysconf = CicoSystemConfig::getInstance();
- CicoSCVehicleInfoConf* viconf = sysconf->getVehicleInfoConf();
- std::map<int, CicoSCVIPropertyConf*>::iterator itr;
- itr = viconf->properties.find(property);
- if (itr == viconf->properties.end()) {
- ICO_WRN("not found propetry(%d)", property);
- return false;
- }
-
- ICO_DBG("called: ico_dbus_amb_get(objname=%s prop=%s zone=%d type=%d)",
- itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone,
- ms_dbusTypes[itr->second->type]);
- int ret = ico_dbus_amb_get(itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone,
- ms_dbusTypes[itr->second->type],
- CicoSCVInfoManager::dbusAMBGetCB,
- itr->second);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_get failed. ret=%d", ret);
- ICO_TRA("CicoSCVInfoManager::getVehicleInfo Leave(false)");
- return false;
- }
-
- ICO_TRA("CicoSCVInfoManager::getVehicleInfo Leave(true)");
- return true;
-}
-
-//==========================================================================
-// private functions
-//==========================================================================
-
-//--------------------------------------------------------------------------
-/**
- * @brief start vehicle information monitoring
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::startMonitoring(void)
-{
- ICO_TRA("CicoSCVInfoManager::startMonitoring Enter");
-
- CicoSystemConfig* sysconf = CicoSystemConfig::getInstance();
- CicoSCVehicleInfoConf* viconf = sysconf->getVehicleInfoConf();
- std::map<int, CicoSCVIPropertyConf*>::iterator itr;
- itr = viconf->properties.begin();
-
- for (; itr != viconf->properties.end(); ++itr) {
- ICO_DBG("called: ico_dbus_amb_find_property"
- "(objname=%s prop=%s zone=%d type=%d)",
- itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone,
- ms_dbusTypes[itr->second->type]);
- int ret = ico_dbus_amb_find_property(itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone,
- ms_dbusTypes[itr->second->type],
- CicoSCVInfoManager::dbusAMBFindCB,
- itr->second);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_find_property failed. ret=%d", ret);
- }
- }
-
- ICO_TRA("CicoSCVInfoManager::startMonitoring Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief stop vehicle information monitoring
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::stopMonitoring(void)
-{
- ICO_TRA("CicoSCVInfoManager::stopMonitoring Enter");
-
- CicoSystemConfig* sysconf = CicoSystemConfig::getInstance();
- CicoSCVehicleInfoConf* viconf = sysconf->getVehicleInfoConf();
- std::map<int, CicoSCVIPropertyConf*>::iterator itr;
- itr = viconf->properties.begin();
- for (; itr != viconf->properties.end(); ++itr) {
- ICO_DBG("called: ico_dbus_amb_unsubscribe"
- "(objname=%s prop=%s zone=%d type=%d)",
- itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone,
- ms_dbusTypes[itr->second->type]);
- int ret = ico_dbus_amb_unsubscribe(itr->second->objname.c_str(),
- itr->second->property.c_str(),
- itr->second->zone);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_subscribe failed. ret=%d", ret);
- }
- }
-
- ICO_TRA("CicoSCVInfoManager::stopMonitoring Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function of Ecore_End_Cb
- *
- * @param [in] user_data user data
- * @param [in] func_data funnction data
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::evVInfoFree(void* user_data, void* func_data)
-{
- ICO_TRA("CicoSCVInfoManager::evVInfoFree Enter");
- delete static_cast<CicoSCVInfo*>(func_data);
- ICO_TRA("CicoSCVInfoManager::evVInfoFree Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function of ecore timer
- *
- * @param [in] data user data
- */
-//--------------------------------------------------------------------------
-Eina_Bool
-CicoSCVInfoManager::ecoreRetryFindPropCB(void *data)
-{
- ICO_TRA("CicoSCVInfoManager::ecoreRetryFindPropCB Enter");
- if (NULL != data) {
- CicoSCVIPropertyConf* viProp = static_cast<CicoSCVIPropertyConf*>(data);
- ICO_DBG("called: ico_dbus_amb_find_property"
- "(objname=%s prop=%s zone=%d type=%d)",
- viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type]);
- int ret = ico_dbus_amb_find_property(viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type],
- CicoSCVInfoManager::dbusAMBFindCB,
- viProp);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_property failed. ret=%d", ret);
- }
-
- }
- ICO_TRA("CicoSCVInfoManager::ecoreRetryFindPropCB Leave(cancel)");
- return ECORE_CALLBACK_CANCEL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function of ico_dbus_amb_get result
- *
- * @param [in] objectname dbus object name
- * @param [in] property vehicle information's name
- * @param [in] type type of vechcle information
- * @param [in] data user data
- * @param [in] error error information
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::dbusAMBFindCB(const char *objectname,
- const char *property,
- dbus_type type,
- void *data,
- ico_dbus_error_t *error)
-{
- ICO_TRA("CicoSCVInfoManager::dbusAMBFindCB Enter"
- "(objname=%s prop=%s type=%d)",
- objectname, property, type);
-
- if (NULL == data) {
- ICO_WRN("data is null");
- return;
- }
-
- CicoSCVIPropertyConf* viProp = static_cast<CicoSCVIPropertyConf*>(data);
-
- // if find property is error, retry.
- if (NULL != error) {
- CicoSystemConfig* sysconf = CicoSystemConfig::getInstance();
- CicoSCVehicleInfoConf* viconf = sysconf->getVehicleInfoConf();
- ICO_DBG("retryCnt=%d/%d", ms_retryCnt, viconf->retryCnt);
- if (viconf->retryCnt > ms_retryCnt) {
- ms_retryCnt++;
- ICO_DBG("called: ecore_timer_add");
- Ecore_Timer *timer = NULL;
- timer = ecore_timer_add((double)viconf->waitTime/1000.0f,
- CicoSCVInfoManager::ecoreRetryFindPropCB,
- viProp);
- if (NULL == timer) {
- ICO_ERR("ecore_timer_add() failed.");
- }
-
- }
- ICO_TRA("CicoSCVInfoManager::dbusAMBFindCB Levae");
- return;
- }
-
- // get vehicle information
- ICO_DBG("called: ico_dbus_amb_get(objname=%s prop=%s zone=%d type=%d)",
- viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type]);
- int ret = ico_dbus_amb_get(viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type],
- CicoSCVInfoManager::dbusAMBGetCB,
- viProp);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_subscribe failed. ret=%d", ret);
- }
-
- // subscribe vehicle information
- ICO_DBG("called: ico_dbus_amb_subscribe"
- "(objname=%s prop=%s zone=%d type=%d)",
- viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type]);
- ret = ico_dbus_amb_subscribe(viProp->objname.c_str(),
- viProp->property.c_str(),
- viProp->zone,
- ms_dbusTypes[viProp->type],
- CicoSCVInfoManager::dbusAMBNotifyCB,
- viProp);
- if (0 != ret) {
- ICO_WRN("ico_dbus_amb_subscribe failed. ret=%d", ret);
- }
-
- ICO_TRA("CicoSCVInfoManager::dbusAMBFindCB Levae");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function of ico_dbus_amb_get result
- *
- * @param [in] objectname dbus object name
- * @param [in] property vehicle information's name
- * @param [in] type type of vechcle information
- * @param [in] value vechcle information's value
- * @param [in] data user data
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::dbusAMBGetCB(const char *objectname,
- const char *property,
- dbus_type type,
- union dbus_value_variant value,
- void *data)
-{
- ICO_TRA("CicoSCVInfoManager::dbusAMBGetCB Enter"
- "(objname=%s prop=%s type=%d)",
- objectname, property, type);
-
- if (NULL == data) {
- ICO_WRN("data is null");
- return;
- }
-
- CicoSCVIPropertyConf* viConf = static_cast<CicoSCVIPropertyConf*>(data);
-
- CicoSCVInfo* vinfo = new CicoSCVInfo(type, viConf->id, value);
- ecore_event_add(ms_ecoreEvType, vinfo,
- CicoSCVInfoManager::evVInfoFree, NULL);
-
- ICO_TRA("CicoSCVInfoManager::dbusAMBGetCB Levae");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function of ico_dbus_amb_get result
- *
- * @param [in] objectname dbus object name
- * @param [in] property vehicle information's name
- * @param [in] type type of vechcle information
- * @param [in] value vechcle information's value
- * @param [in] sequence number of sequence
- * @parma [in] tv recored time
- * @param [in] data user data
- */
-//--------------------------------------------------------------------------
-void
-CicoSCVInfoManager::dbusAMBNotifyCB(const char *objectname,
- const char *property,
- dbus_type type,
- union dbus_value_variant value,
- int sequence,
- struct timeval tv,
- void *data)
-{
- ICO_TRA("CicoSCVInfoManager::dbusAMBNotifyCB Enter"
- "(objname=%s prop=%s type=%d)",
- objectname, property, type);
-
- if (NULL == data) {
- ICO_WRN("data is null");
- return;
- }
-
- CicoSCVIPropertyConf* viConf = static_cast<CicoSCVIPropertyConf*>(data);
-
- CicoSCVInfo* vinfo = new CicoSCVInfo(type, viConf->id, value);
- ecore_event_add(ms_ecoreEvType, vinfo,
- CicoSCVInfoManager::evVInfoFree, NULL);
-
- ICO_TRA("CicoSCVInfoManager::dbusAMBNotifyCB Leave");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCVInfoManager.h
- *
- * @brief This file is definition of CicoSCVInfoManager class
- */
-//==========================================================================
-#ifndef __CICO_SC_VINFO_MANAGER_H__
-#define __CICO_SC_VINFO_MANAGER_H__
-
-#include <string>
-#include <map>
-
-#include <ico_dbus_amb_efl.h>
-#include "CicoCommonDef.h"
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-
-//==========================================================================
-/*
- * @brief This class manage vehicle information
- */
-//==========================================================================
-class CicoSCVInfoManager
-{
-public:
- // get CicoSCVInfoManager instance
- static CicoSCVInfoManager* getInstance(void);
-
- // startup communication of vehicle information
- bool startup(void);
-
- // teardown communication of vehicle information
- bool teardown(void);
-
- // get ecore event type
- int getEcoreEvType(void);
-
- // get vehicle information
- bool getVehicleInfo(int property);
-
-private:
- // default constructor
- CicoSCVInfoManager();
-
- // destructor
- ~CicoSCVInfoManager();
-
- // assignment operator
- CicoSCVInfoManager& operator=(const CicoSCVInfoManager &object);
-
- // copy constructor
- CicoSCVInfoManager(const CicoSCVInfoManager &object);
-
- // start vehicle information monitoring
- void startMonitoring(void);
-
- // stop vehicle information monitoring
- void stopMonitoring(void);
-
- // callback find vehicle information
- static void dbusAMBFindCB(const char *objectname,
- const char *property,
- dbus_type type,
- void *user_data,
- ico_dbus_error_t *error);
-
- // callback get vehicle information
- static void dbusAMBGetCB(const char *objectname,
- const char *property,
- dbus_type type,
- union dbus_value_variant value,
- void *user_data);
-
- // callback notify vehicle information
- static void dbusAMBNotifyCB(const char *objectname,
- const char *property,
- dbus_type type,
- union dbus_value_variant value,
- int sequence,
- struct timeval tv,
- void *user_data);
-
- // callback function of Ecore_End_Cb
- static void evVInfoFree(void* user_data, void* func_data);
-
- // callback function of ecore timer
- static Eina_Bool ecoreRetryFindPropCB(void *data);
-
-private:
- // CicoSCVInfoManager instannce
- static CicoSCVInfoManager* ms_myInstance;
-
- // ecore event type
- static int ms_ecoreEvType;
-
- // dbus_type table
- static dbus_type ms_dbusTypes[ICO_TYPE_MAX];
-
- static int ms_retryCnt;
-
- // initialized flag
- bool m_initialized;
-};
-#endif // __CICO_SC_VINFO_MANAGER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWayland.cpp
- *
- * @brief This file implementation of CicoSCWayland class
- */
-//==========================================================================
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <Ecore.h>
-
-#include <map>
-using namespace std;
-
-#include <wayland-client.h>
-#include <ico-uxf-weston-plugin/ico_window_mgr-client-protocol.h>
-#include <ilm/ilm_control.h>
-
-#include "CicoSCWayland.h"
-#include "CicoSCWlWinMgrIF.h"
-#include "CicoSCWindowController.h"
-#include "CicoLog.h"
-#include "ico_syc_error.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-CicoSCWayland* CicoSCWayland::ms_myInstance = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWayland::CicoSCWayland()
- : m_wlDisplay(NULL),
- m_wlRegistry(NULL),
- m_wlFd(-1),
- m_ecoreFdHandler(NULL)
-{
- // wayland callbacks
- m_wlListener.global = wlGlobalCB;
- m_wlListener.global_remove = NULL;
-
- CicoSCWayland::ms_myInstance = this;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWayland::~CicoSCWayland()
-{
- CicoSCWayland::ms_myInstance = NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get instance of CicoSCWayland
- *
- * @return instance of CicoSCWayland
- */
-//--------------------------------------------------------------------------
-CicoSCWayland*
-CicoSCWayland::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCWayland();
- }
-
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize wayland connection
- *
- * @return ICO_SYC_EOK on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWayland::initialize(void)
-{
- ICO_TRA("CicoSCWayland::initialize Enter");
-
- // initialize genivi ivi-shell
- if (ilm_init() != ILM_SUCCESS) {
- ICO_ERR("ilm_init failed.");
- ICO_TRA("CicoSCWayland::initialize Leave(EIO)");
- return ICO_SYC_EIO;
- }
-
- for (int i = 0; i < (5000/50); ++i) {
- m_wlDisplay = wl_display_connect(NULL);
- if (NULL != m_wlDisplay) {
- break;
- }
- usleep(50*1000);
- }
-
- if (NULL == m_wlDisplay) {
- ICO_ERR("wl_display_connect failed.");
- ICO_TRA("CicoSCWayland::initialize Leave(EIO)");
- return ICO_SYC_EIO;
- }
-
- ICO_DBG("called: wl_display_get_registry(wlDisplay=0x%08x)", m_wlDisplay);
- m_wlRegistry = wl_display_get_registry(m_wlDisplay);
- if (NULL == m_wlRegistry) {
- ICO_ERR("wl_display_get_registry failed.");
- ICO_TRA("CicoSCWayland::initialize Leave(EIO)");
- return ICO_SYC_EIO;
- }
-
- // add wayland global callbacks
- ICO_DBG("called: wl_registry_add_listener");
- wl_registry_add_listener(m_wlRegistry, &m_wlListener, this);
-
- int initCount = 0;
- int ifcount = m_wlInterfaceList.size();
- for (int i = 0; i < (500/20); ++i) {
- initCount = 0;
- map<string, CicoSCWaylandIF*>::iterator itr;
- itr = m_wlInterfaceList.begin();
- for (; itr != m_wlInterfaceList.end(); ++itr) {
- if(true == itr->second->isInitialized()) {
- initCount++;
- }
- }
- if (ifcount == initCount) {
- break;
- }
- ICO_DBG("called: wl_display_dispatch"
- "(wlDisplay=%p)", (void *)m_wlDisplay);
- wl_display_dispatch(m_wlDisplay);
- usleep(20*1000);
- }
-
- if (ifcount != initCount) {
- ICO_ERR("initialize interface time up NG");
- ICO_TRA("CicoSCWayland::initialize Leave(EIO)");
- return ICO_SYC_EIO;
- }
- else {
- ICO_DBG("initialize interface all OK");
- }
-
- // flush display
- ICO_DBG("called: wl_display_flush(wlDisplay=%p)", (void *)m_wlDisplay);
- wl_display_flush(m_wlDisplay);
-
- ICO_DBG("called: wl_display_get_fd(wlDisplay=%p)", (void *)m_wlDisplay);
- m_wlFd = wl_display_get_fd(m_wlDisplay);
- ICO_DBG("CicoSCWayland::initialize: Wayland/Weston fd=%d", m_wlFd);
-
- ICO_DBG("CicoSCWayland::initialize: Wayland/Weston connect OK");
-
- // initialize genivi callbacks
- CicoSCWindowController::getInstance()->initializeGeniviLMS();
-
- ICO_TRA("CicoSCWayland::initialize: Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief flush display
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWayland::flushDisplay(void)
-{
- if (NULL == m_wlDisplay) {
- ICO_ERR("wlDisplay == NULL");
- return;
- }
-// ICO_DBG("called: wl_display_flush(0x%08x)", (int)m_wlDisplay);
- int wlret = wl_display_flush(m_wlDisplay);
- if (-1 == wlret) {
- int error = wl_display_get_error(m_wlDisplay);
- ICO_ERR("wayland error(%d)", error);
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dispatch display
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWayland::dispatchDisplay(void)
-{
- if (NULL == m_wlDisplay) {
- ICO_ERR("wlDisplay == NULL");
- return;
- }
-// ICO_DBG("call wl_display_dispatch(0x%08x)", (int)m_wlDisplay);
- int wlret = wl_display_dispatch(m_wlDisplay);
- if (-1 == wlret) {
- int error = wl_display_get_error(m_wlDisplay);
- ICO_ERR("wl_display_dispatch failed. error(%d)", error);
-
- if (error == EINVAL) {
- exit(9);
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get wayland error
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWayland::getError(void)
-{
- if (NULL == m_wlDisplay) {
- ICO_ERR("wlDisplay == NULL");
- return -1;
- }
-
- ICO_DBG("fd=%d", wl_display_get_fd(m_wlDisplay));
- return wl_display_get_error(m_wlDisplay);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get wayland file destructor
- *
- * @return wayland file destructor
- */
-//--------------------------------------------------------------------------
-int CicoSCWayland::getWlFd(void)
-{
- return m_wlFd;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add wayland file destructor handler to ecore main
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EIO ecore_main_fd_handler_add failed
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWayland::addEcoreMainWlFdHandler(void)
-{
- ICO_TRA("CicoSCWayland::addEcoreMainWlFdHandler Enter");
- ICO_DBG("called: ecore_main_fd_handler_add(fd=%d)", m_wlFd);
- m_ecoreFdHandler = ecore_main_fd_handler_add(m_wlFd,
- ECORE_FD_READ,
- &waylandFdHandler,
- NULL,
- NULL,
- NULL);
- if (NULL == m_ecoreFdHandler) {
- ICO_ERR("ecore_main_fd_handler_add failed.");
- ICO_TRA("CicoSCWayland::addEcoreMainWlFdHandler Leave(EIO)");
- return ICO_SYC_EIO;
- }
- ecore_main_loop_iterate();
-
- int arg = 0;
- if (ioctl(m_wlFd, FIONREAD, &arg) < 0) {
- ICO_WRN("ioclt(FIONREAD) failed. errno=%d:%s", errno, strerror(errno));
- arg = 0;
- }
- if (arg > 0) {
- CicoSCWayland::getInstance()->dispatchDisplay();
- }
-
- ICO_TRA("CicoSCWayland::addEcoreMainWlFdHandler Leave");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief add wayland interface
- *
- * @param [in] name interface name
- * @param [in] interface interface instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWayland::addWaylandIF(const char *name, CicoSCWaylandIF* interface)
-{
- m_wlInterfaceList[name] = interface;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland global callback
- *
- * @param [in] data user data(unused)
- * @param [in] registry wayland registry
- * @param [in] name wayland display Id(unused)
- * @param [in] interface wayland interface name
- * @param [in] version wayland interface version number(unused)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWayland::globalCB(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version)
-{
- map<string, CicoSCWaylandIF*>::iterator itr;
- itr = m_wlInterfaceList.find(interface);
-
- if (m_wlInterfaceList.end() == itr) {
- ICO_DBG("skip interface=%s", interface);
- return;
- }
-
- CicoSCWaylandIF *wlIF = itr->second;
- wlIF->initInterface(data, registry, name, interface, version);
-
- // flush display
- wl_display_flush(m_wlDisplay);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland global callback
- *
- * @param [in] data user data
- * @param [in] registry wayland registry
- * @param [in] name wayland display Id(unused)
- * @param [in] interface wayland interface name
- * @param [in] version wayland interface version number(unused)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWayland::wlGlobalCB(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version)
-{
- if (NULL == data) {
- ICO_ERR("data == NULL");
- return;
- }
-
- static_cast<CicoSCWayland*>(data)->globalCB(data, registry, name,
- interface, version);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland global callback
- *
- * @param [in] data user data
- * @param [in] handler ecore file destructor handler
- *
- * @return ECORE_CALLBACK_RENEW on retry , ECORE_CALLBACK_CANCEL on cancel
- */
-//--------------------------------------------------------------------------
-Eina_Bool
-CicoSCWayland::waylandFdHandler(void *data, Ecore_Fd_Handler *handler)
-{
-// ICO_TRA("waylandFdHandler: Enter");
-
- CicoSCWayland::getInstance()->flushDisplay();
-
- int arg = 0;
- if (ioctl(CicoSCWayland::getInstance()->getWlFd(), FIONREAD, &arg) < 0) {
- ICO_WRN("ioclt(FIONREAD) failed. errno=%d:%s", errno, strerror(errno));
- arg = 0;
- }
-
-// ICO_DBG("waylandFdHandler: arg(%d))", arg);
- if (arg > 0) {
- CicoSCWayland::getInstance()->dispatchDisplay();
- }
-
- if (0 == arg) {
- ICO_ERR("wayland fd read error.");
- ICO_DBG("called: ecore_main_loop_quit()");
- ecore_main_loop_quit();
- return ECORE_CALLBACK_CANCEL;
- }
-
- CicoSCWayland::getInstance()->flushDisplay();
-// ICO_TRA("waylandFdHandler: Leave");
- return ECORE_CALLBACK_RENEW ;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWayland.h
- *
- * @brief This file is definition of CicoSCWayland class
- */
-//==========================================================================
-#ifndef __CICO_SC_WAYLAND_H__
-#define __CICO_SC_WAYLAND_H__
-
-#include <string>
-#include <map>
-
-#include <Ecore.h>
-
-#include <wayland-client.h>
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCWaylandIF;
-
-//==========================================================================
-/*
- * @brief This class controls wayland
- */
-//==========================================================================
-class CicoSCWayland {
-public:
- // get instance of CicoSCWayland
- static CicoSCWayland* getInstance();
-
- // initialize wayland connection
- int initialize(void);
-
- // flush display
- void flushDisplay(void);
-
- // dispatch display
- void dispatchDisplay(void);
-
- // get wayland error
- int getError(void);
-
- // get wayland file descriptor
- int getWlFd(void);
-
- // app ecore main wayland file descriptor handler
- int addEcoreMainWlFdHandler(void);
-
- // add wayland interface
- void addWaylandIF(const char *name, CicoSCWaylandIF* interface);
-
- // waylnad file descriptor handler
- static Eina_Bool waylandFdHandler(void *data, Ecore_Fd_Handler *handler);
-
- // wayland global callback function
- void globalCB(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version);
-
-private:
- // wayland standard callback function
- static void wlGlobalCB(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version);
-
-private:
- // default constructor
- CicoSCWayland();
-
- // destructor
- ~CicoSCWayland();
-
- // assignment operator
- CicoSCWayland& operator=(const CicoSCWayland &object);
-
- // copy constructor
- CicoSCWayland(const CicoSCWayland &object);
-
-private:
- /// my instance
- static CicoSCWayland *ms_myInstance;
-
- /// wayland's display
- struct wl_display *m_wlDisplay;
-
- /// wayland's registry
- struct wl_registry *m_wlRegistry;
-
- /// wayland's file descriptor
- int m_wlFd;
-
- /// ecore file descriptor handler
- Ecore_Fd_Handler *m_ecoreFdHandler;
-
- /// interface list
- std::map<std::string, CicoSCWaylandIF*> m_wlInterfaceList;
-
- // wayland common callbacks
- struct wl_registry_listener m_wlListener;
-};
-#endif // __CICO_SC_WAYLAND_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWaylandIF.cpp
- *
- * @brief This file implementation of CicoSCWaylandIF class
- */
-//==========================================================================
-
-#include "CicoSCWaylandIF.h"
-#include "CicoLog.h"
-
-const char * CicoSCWaylandIF::ICO_WL_WIN_MGR_IF = "ico_window_mgr";
-const char * CicoSCWaylandIF::ICO_WL_INPUT_MGR_CTRL_IF = "ico_input_mgr_control";
-const char * CicoSCWaylandIF::ICO_WL_EXINPUT_IF = "ico_exinput";
-const char * CicoSCWaylandIF::ICO_WL_INPUT_MGR_DEV_IF = "ico_input_mgr_device";
-const char * CicoSCWaylandIF::ICO_WL_IVI_APPLICATION_IF= "ivi_application";
-const char * CicoSCWaylandIF::ICO_WL_IVI_CONTROLLER_IF = "ivi_controller";
-const char * CicoSCWaylandIF::ICO_WL_OUTPUT_IF = "wl_output";
-
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWaylandIF::CicoSCWaylandIF()
- : m_initialized(false)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWaylandIF::~CicoSCWaylandIF()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- *
- * @param [in] date user data
- * @param [in] registry wayland registry
- * @param [in] name wayland display id
- * @parma [in] interface wayland interface name
- * @parma [in] version wayland interface version number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWaylandIF::initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version)
-{
- ICO_WRN("CicoSCWaylandIF::initInterface called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief inquire whether initialized
- *
- * @return true on initialized, false no not initialized
- * @retval true initialized
- * @retval false not initialized
- */
-//--------------------------------------------------------------------------
-bool
-CicoSCWaylandIF::isInitialized(void)
-{
- return m_initialized;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWaylandIF.h
- *
- * @brief This file is definition of CicoSCWaylandIF class
- */
-//==========================================================================
-#ifndef __CICO_SC_WAYLAND_IF_H__
-#define __CICO_SC_WAYLAND_IF_H__
-
-#include <wayland-client.h>
-
-//==========================================================================
-/*
- * @brief This class is abstract class of wayland interface
- */
-//==========================================================================
-class CicoSCWaylandIF {
-public:
- // initialize interface
- virtual void initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version);
-
- // inquire whether initialized
- bool isInitialized(void);
-
-protected:
- // default constructor
- CicoSCWaylandIF();
-
- // destructor
- virtual ~CicoSCWaylandIF();
-
- // assignment operator
- CicoSCWaylandIF& operator=(const CicoSCWaylandIF &object);
-
- // copy constructor
- CicoSCWaylandIF(const CicoSCWaylandIF &object);
-
-protected:
- /// interface name of wayland multi window manager
- static const char * ICO_WL_WIN_MGR_IF;
- /// interface name of wayland input manager control
- static const char * ICO_WL_INPUT_MGR_CTRL_IF;
- /// interface name of wayland exinput
- static const char * ICO_WL_EXINPUT_IF;
- /// interface name of wayland input manager device
- static const char * ICO_WL_INPUT_MGR_DEV_IF;
- /// interface name of genivi ivi_application
- static const char * ICO_WL_IVI_APPLICATION_IF;
- /// interface name of genivi ivi_controller
- static const char * ICO_WL_IVI_CONTROLLER_IF;
- /// interface name of wayland output
- static const char * ICO_WL_OUTPUT_IF;
-
- // initialized flag
- bool m_initialized;
-};
-#endif // __CICO_SC_WAYLAND_IF_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWindow.h
- *
- * @brief This file is implementation of CicoSCWindow class
- */
-//==========================================================================
-
-#include <string>
-using namespace std;
-
-#include "CicoSCWindow.h"
-#include "CicoSCWlWinMgrIF.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWindow::CicoSCWindow()
- : surfaceid(-1), name(""), appid(""), pid(-1),
- nodeid(-1), displayid(-1), layerid(-1), zone(""), zoneid(-1),
- subwindow(0), eventmask(0), srcwidth(0), srcheight(0), x(-1), y(-1),
- width(-1), height(-1), visible(false), raise(false), active(false)
-{
-// ICO_TRA("CicoSCWindow::CicoSCWindow Enter");
-// ICO_TRA("CicoSCWindow::CicoSCWindow Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWindow::~CicoSCWindow()
-{
- ICO_TRA("CicoSCWindow::~CicoSCWindow Enter");
- CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(surfaceid);
- ICO_TRA("CicoSCWindow::~CicoSCWindow Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief dump log this class member variables
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindow::dump(void)
-{
- ICO_DBG("CicoSCWindow: surfaceid=%08x name=%s appid=%s pid=%d "
- "nodeid=%d displayid=%d layerid=%d zone=%s zoneid=%d "
- "subwindow=%d eventmask=%d x=%d y=%d width=%d height=%d "
- "visible=%s raise=%s active=%s",
- surfaceid, name.c_str(), appid.c_str(), pid, nodeid, displayid,
- layerid, zone.c_str(), zoneid, subwindow, eventmask,
- x, y, width, height,
- visible ? "true" : "false", raise ? "true" : "false",
- active ? "true" : "false");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWindow.h
- *
- * @brief This file is definition of CicoSCWindow class
- */
-//==========================================================================
-#ifndef __CICO_SC_WINDOW_H__
-#define __CICO_SC_WINDOW_H__
-
-#include <string>
-
-//==========================================================================
-// define macro
-//==========================================================================
-#define ICO_SURFACEID_2_HOSTID(surfid) (((unsigned int)surfid) >> 24)
-#define ICO_SURFACEID_2_DISPLAYNO(surfid) (((unsigned int)surfid) >> 16)
-#define ICO_SURFACEID_2_NODEID(surfid) (((unsigned int)surfid) >> 16)
-#define ICO_SURFACEID_BASE(nodeid) (((unsigned int)nodeid) << 16)
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class holds window information
- */
-//--------------------------------------------------------------------------
-class CicoSCWindow
-{
-public:
- // default constructor
- CicoSCWindow();
-
- // destructor
- virtual ~CicoSCWindow();
-
- // dump log CicoSCWindow member variables
- void dump(void);
-
-private:
- // assignment operator
- CicoSCWindow& operator=(const CicoSCWindow &object);
-
- // copy constructor
- CicoSCWindow(const CicoSCWindow &object);
-
-public:
- int surfaceid; ///< surface id (window id)
- std::string name; ///< window name
- std::string appid; ///< application id
- int pid; ///< process id
-
- int nodeid; ///< node id
- int displayid; ///< display id
- int layerid; ///< layer id
- std::string zone; ///< display zone name
- int zoneid; ///< display zone id
- int subwindow; ///< main window(0) or sub window(!0)
- unsigned int eventmask; ///< event to receive through this window
- int srcwidth; ///< width of application frame buffer
- int srcheight; ///< height of application frame buffer
- int x; ///< upper left X coord of the window
- int y; ///< upper left Y coord of the window
- int width; ///< width of window
- int height; ///< height of window
- bool visible; ///< visibility
- bool raise; ///< raise/lower
- bool active; ///< active/inactive
-};
-#endif // __CICO_SC_WINDOW_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWindowController.cpp
- *
- * @brief This file implementation of CicoSCWindowController class
- */
-//==========================================================================
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <vector>
-#include <algorithm>
-using namespace std;
-
-#include "CicoSCWindow.h"
-#include "CicoSCWayland.h"
-#include "CicoSCWindowController.h"
-#include "CicoLog.h"
-
-#include "CicoSystemConfig.h"
-#include "CicoConf.h"
-#include "CicoSCDisplay.h"
-#include "CicoSCLayer.h"
-#include "CicoSCDisplayZone.h"
-#include "ico_syc_error.h"
-#include "ico_syc_type.h"
-#include "ico_syc_winctl.h"
-#include "CicoSCCommand.h"
-#include "ico_syc_msg_cmd_def.h"
-#include "CicoSCServer.h"
-#include "CicoSCMessage.h"
-#include "CicoSCMessageRes.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoSCResourceManager.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-CicoSCWindowController* CicoSCWindowController::ms_myInstance = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief get instance of CicoSCWindowController
- *
- * @return instance of CicoSCWindowController
- */
-//--------------------------------------------------------------------------
-CicoSCWindowController*
-CicoSCWindowController::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSCWindowController();
- }
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWindowController::CicoSCWindowController()
- : m_resMgr(NULL), m_physicalDisplayTotal(0)
-{
- CicoSCWayland* wayland = CicoSCWayland::getInstance();
- wayland->getInstance()->addWaylandIF(ICO_WL_WIN_MGR_IF, this);
- wayland->getInstance()->addWaylandIF(ICO_WL_IVI_APPLICATION_IF, this);
- wayland->getInstance()->addWaylandIF(ICO_WL_IVI_CONTROLLER_IF, this);
- wayland->getInstance()->addWaylandIF(ICO_WL_OUTPUT_IF, this);
- initDB();
-
- CicoSCWindowController::ms_myInstance = this;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWindowController::~CicoSCWindowController()
-{
- CicoSCWindowController::ms_myInstance = NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize display and window database
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::initDB(void)
-{
- ICO_TRA("CicoSCWindowController::initDB: Enter");
-
- const vector<CicoSCDisplayConf*>& displayList =
- CicoSystemConfig::getInstance()->getDisplayConfList();
- vector<CicoSCDisplayConf*>::const_iterator itr;
- itr = displayList.begin();
- for (; itr != displayList.end(); ++itr) {
- CicoSCDisplay *display = new CicoSCDisplay();
- display->displayid = (*itr)->id;
- display->type = (*itr)->type;
- display->nodeid = (*itr)->node;
- display->displayno = (*itr)->no;
- display->width = (*itr)->width;
- display->height = (*itr)->height;
- display->name = (*itr)->name;
-
- vector<CicoSCLayerConf*>::const_iterator itr2;
- itr2 = (*itr)->layerConfList.begin();
- for (; itr2 != (*itr)->layerConfList.end(); ++itr2) {
- CicoSCLayer *layer = new CicoSCLayer();
- layer->layerid = (*itr2)->id;
- layer->type = (*itr2)->type;
- layer->width = display->width;
- layer->height = display->height;
- layer->displayid = display->displayid;
- layer->menuoverlap = (*itr2)->menuoverlap;
- display->layerList.push_back(layer);
- }
-
- vector<CicoSCDisplayZoneConf*>::const_iterator itr3;
- itr3 = (*itr)->zoneConfList.begin();
- for (; itr3 != (*itr)->zoneConfList.end(); ++itr3) {
- CicoSCDisplayZone *zone = new CicoSCDisplayZone();
- zone->zoneid = (*itr3)->id;
- zone->x = (*itr3)->x;
- zone->y = (*itr3)->y;
- zone->width = (*itr3)->w;
- zone->height = (*itr3)->h;
- zone->fullname = (*itr3)->fullname;
- zone->aspectFixed = (*itr3)->aspectFixed;
- zone->aspectAlignLeft = (*itr3)->aspectAlignLeft;
- zone->aspectAlignRight = (*itr3)->aspectAlignRight;
- zone->aspectAlignTop = (*itr3)->aspectAlignTop;
- zone->aspectAlignBottom = (*itr3)->aspectAlignBottom;
- display->zoneList[zone->zoneid] = zone;
- }
- display->dump();
- m_displayList.push_back(display);
- }
-
- ICO_TRA("CicoSCWindowController::initDB: Leave");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set resource manager instance
- *
- * @param [in] resMgr resource manager instance
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::setResourceManager(CicoSCResourceManager *resMgr)
-{
- m_resMgr = resMgr;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief show a target window
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::show(int surfaceid,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::show Enter"
- "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
- surfaceid, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::show Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // update visible attr
- window->visible = true;
-
- // update current displayed window at display zone
- CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
- if (NULL != zone) {
- CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
- if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
- ICO_DBG("Entry display zone[%d] current displayed window"
- "(%08x:\"%s\")",
- zone->zoneid, window->surfaceid, window->appid.c_str());
- zone->displayedWindow = window;
- }
- }
-
- // set animation request to Multi Window Manager
- int raiseFlag = ICO_SYC_WIN_RAISE_NOCHANGE;
- if (type & ICO_SYC_WIN_SURF_RAISE) {
- raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
- }
- else if (type & ICO_SYC_WIN_SURF_LOWER) {
- raiseFlag = ICO_SYC_WIN_RAISE_LOWER;
- }
- else if (((type & ICO_SYC_WIN_SURF_NOCHANGE) == 0) &&
- (false == window->raise)) {
- raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
- }
- if ((NULL != animation) && (animation[0] != '\0')) {
- // set animation request to Multi Window Manager
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
- animation, animationTime);
- }
-
- // set raise/lower request (if need)
- if (raiseFlag != ICO_SYC_WIN_RAISE_NOCHANGE) {
- raiselower(window, (raiseFlag == ICO_SYC_WIN_RAISE_RAISE));
- }
-
- // set visible request to Multi Window Manager
- CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_SHOW);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::show Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief raise/lower a target window
- *
- * @param [in] window target window
- * @param [in] raise raise(true)/lower(false)
- *
- * @return nothing
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::raiselower(CicoSCWindow *window, bool raise)
-{
- ICO_TRA("CicoSCWindowController::raiselower(%08x,%d)", window->surfaceid, raise);
-
- window->raise = raise;
-
- CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
- if (! layer) {
- ICO_ERR("CicoSCWindowController::raiselower: surface.%08x has no layer(%d)",
- window->surfaceid, window->layerid);
- return;
- }
- if ((raise) && (layer->is_topSurface(window->surfaceid))) {
- ICO_DBG("CicoSCWindowController::raiselower %08x raise but top",
- window->surfaceid);
- }
- else if ((! raise) && (layer->is_buttomSurface(window->surfaceid))) {
- ICO_DBG("CicoSCWindowController::raiselower %08x lower but buttom",
- window->surfaceid);
- }
- else {
- layer->addSurface(window->surfaceid, raise);
-
- int nsurf;
- const int *surfs = layer->getSurfaces(&nsurf);
- ICO_TRA("CicoSCWindowControllerCicoSCWindowController layer.%d %d.%x %x %x %x",
- window->layerid, nsurf, surfs[0], surfs[1], surfs[2], surfs[3]);
- if (nsurf > 4) {
- ICO_TRA("CicoSCWindowControllerCicoSCWindowController .%x %x %x %x",
- surfs[4], surfs[5], surfs[6], surfs[7]);
- }
- if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::raiselower "
- "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief hide a target window
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::hide(int surfaceid,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::hide Enter"
- "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
- surfaceid, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::hide Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- if (false == window->visible) {
- ICO_DBG("already hide state");
- ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
- return ICO_SYC_EOK;
- }
-
- // update window attr
- window->visible = false;
-
- // update current displayed window at display zone
- CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
- if (NULL != zone) {
- CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
- if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
- (getDisplayedWindow(zone->zoneid) == surfaceid)) {
- ICO_DBG("Exit display zone[%d] current displayed window"
- "(%08x:\"%s\")",
- zone->zoneid, window->surfaceid, window->appid.c_str());
- zone->displayedWindow = NULL;
- }
- }
-
- // set animation request to Multi Window Manager
- if ((NULL != animation) && (animation[0] != '\0')) {
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
- animation, animationTime);
- }
-
- // set visible request to Multi Window Manager
- CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_LAYER_VISIBLE_HIDE);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief resize window(surface) size
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] w window width
- * @param [in] h window height
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(window dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::resize(int surfaceid,
- int w,
- int h,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::resize Enter"
- "(surfaceid=%08x h=%d w=%d animation=%s type=%x animationTime=%d)",
- surfaceid, w, h, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::resize Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- if ((NULL != animation) && (animation[0] != '\0')) {
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
- animation, animationTime);
- }
-
- // set visible request to Multi Window Manager
- window->width = w;
- window->height = h;
- CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, window->nodeid,
- window->x, window->y, w, h);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::resize Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief move window(surface) position
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] nodeid node id
- * @param [in] x window width
- * @param [in] y window height
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(window dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::move(int surfaceid,
- int nodeid,
- int x,
- int y,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::move Enter"
- "(surfaceid=%08x nodeid=%d x=%d y=%d "
- "animation=%s type=%x animationTime=%d)",
- surfaceid, nodeid, x, y, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("CicoSCWindowController::move not found window(%08x)", surfaceid);
- ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
- // check nodeid
- if (nodeid >= (int)m_physicalDisplayTotal) {
- ICO_WRN("CicoSCWindowController::move not found node(%d)", nodeid);
- ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- if ((NULL != animation) && (animation[0] != '\0')) {
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
- animation, animationTime);
- }
-
- int moveNodeId = ICO_SYC_WIN_NOCHANGE;
- if (nodeid >= 0) {
- moveNodeId = nodeid;
- }
-
- // set visible request to Multi Window Manager
- window->x = x;
- window->y = y;
- CicoSCWlWinMgrIF::setPositionsize(window->surfaceid,
- moveNodeId, x, y,
- window->width, window->height);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::move Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief raise window(surface)
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::raise(int surfaceid,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::raise Enter"
- "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
- surfaceid, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::raise Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- if ((NULL != animation) && (animation[0] != '\0')) {
- CicoSCWindowController::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
- animation, animationTime);
- }
- // set raise request to Multi Window Manager
- raiselower(window, true);
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::raise ilm_commitChanges() Error");
- }
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::raise Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set window(surface) geometry
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] nodeid node id
- * @param [in] layerid layer id
- * @param [in] x window x position
- * @param [in] y window y position
- * @param [in] w window width
- * @param [in] h window height
- * @param [in] resizeAnimation resize animation name
- * @param [in] resizeAnimationTime resize animation time
- * @param [in] moveAnimation move animation name
- * @param [in] moveanimationTime move animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(window dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setGeometry(int surfaceid,
- int nodeid,
- int layerid,
- int x,
- int y,
- int w,
- int h,
- const char *resizeAnimation,
- int resizeAnimationTime,
- const char *moveAnimation,
- int moveAnimationTime)
-{
- ICO_TRA("CicoSCWindowController::setGeometry Enter"
- "(surfaceid=%08x nodeid=%d layerid=%d x=%d y=%d w=%d h=%d "
- "resizeAnimation=%s resizeAnimationTime=%d "
- "moveAnimation=%s moveAnimationTime=%d)",
- surfaceid, nodeid, layerid, x, y, w, h,
- resizeAnimation, resizeAnimationTime,
- moveAnimation, moveAnimationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
- // check nodeid
- if (nodeid >= (int)m_physicalDisplayTotal) {
- ICO_WRN("CicoSCWindowController::setGeometry not found node(%d)", nodeid);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- const char *animation = "";
- if (NULL != resizeAnimation) {
- animation = resizeAnimation;
- }
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
- animation, resizeAnimationTime);
-
- if (NULL != moveAnimation) {
- animation = moveAnimation;
- }
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
- animation, moveAnimationTime);
-
- int moveNodeId = ICO_SYC_WIN_NOCHANGE;
- if (nodeid >= 0) {
- moveNodeId = nodeid;
- }
- else {
- moveNodeId = window->nodeid;
- }
-
- if (m_physicalDisplayTotal <= (unsigned int)moveNodeId) {
- ICO_WRN("nodeid(%d) is over physical display total(%d)",
- m_physicalDisplayTotal, nodeid);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
- return ICO_SYC_EINVAL;
- }
-
- int moveX = window->x;
- if (0 <= x) {
- moveX = x;
- window->x = x;
- }
-
- int moveY = window->y;
- if (0 <= y) {
- moveY = y;
- window->y = y;
- }
-
- int moveW = window->width;
- if (0 <= w) {
- moveW = w;
- window->width = w;
- }
-
- int moveH = window->height;
- if (0 <= h) {
- moveH = h;
- window->height = h;
- }
-
- // set window layer to Multi Window Manager
- if (0 <= layerid) {
- setWindowLayer(window->surfaceid, layerid);
- }
-
- // update window attr
- window->nodeid = moveNodeId;
-
- // set visible request to Multi Window Manager
- CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, moveNodeId,
- moveX, moveY, moveW, moveH);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set window(surface) geometry
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] layerid layer id
- * @param [in] nodeid node id
- * @param [in] zone display zone name
- * @param [in] resizeAnimation resize animation name
- * @param [in] resizeAnimationTime resize animation time
- * @param [in] moveAnimation move animation name
- * @param [in] moveanimationTime move animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(window dose not exist)
- * @retval ICO_SYC_EINVAL error(zone is null, zone name is invalid)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setGeometry(int surfaceid,
- const char *zone,
- int layerid,
- const char *resizeAnimation,
- int resizeAnimationTime,
- const char *moveAnimation,
- int moveAnimationTime)
-{
- ICO_TRA("CicoSCWindowController::setGeometry Enter"
- "(surfaceid=%08x zone=%s layerid=%d "
- "resizeAnimation=%s resizeAnimationTime=%d "
- "moveAnimation=%s moveAnimationTime=%d)",
- surfaceid, zone, layerid,
- resizeAnimation, resizeAnimationTime,
- moveAnimation, moveAnimationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // find zone information
- if ((NULL == zone) || ('\0' == zone[0])) {
- ICO_WRN("zone value is invalid");
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
- return ICO_SYC_EINVAL;
- }
-
- vector<CicoSCDisplay*>::iterator itr;
- itr = m_displayList.begin();
- CicoSCDisplayZone* dispzone = NULL;
- int displayno = 0;
- for (; itr != m_displayList.end(); ++itr) {
- dispzone = (*itr)->findDisplayZonebyFullName(zone);
- if (NULL != dispzone) {
- displayno = (*itr)->displayno;
- break;
- }
- }
- if (NULL == dispzone) {
- ICO_WRN("display zone name(%s) is invalid.", zone);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
- return ICO_SYC_EINVAL;
- }
- if (m_physicalDisplayTotal <= (unsigned int)displayno) {
- ICO_WRN("nodeid(%d) is over physical display total(%d)",
- m_physicalDisplayTotal, displayno);
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
- return ICO_SYC_EINVAL;
- }
-
- if (window->zoneid != dispzone->zoneid) {
- // update current displayed window at display zone
- CicoSCDisplayZone* olddispzone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
- if (NULL != olddispzone) {
- CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
- if ((NULL != layer) &&
- (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
- (getDisplayedWindow(olddispzone->zoneid) == surfaceid)) {
- ICO_DBG("Exit display zone[%d] current displayed window"
- "(%08x:\"%s\")",
- olddispzone->zoneid, window->surfaceid,
- window->appid.c_str());
- olddispzone->displayedWindow = NULL;
- }
- }
-
- CicoSCLayer *layer = findLayer(displayno, window->layerid);
- if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
- ICO_DBG("Entry display zone[%d] current displayed window"
- "(%08x:\"%s\")",
- dispzone->zoneid, window->surfaceid, window->appid.c_str());
- dispzone->displayedWindow = window;
- }
- }
-
- // update window attr
- window->zoneid = dispzone->zoneid;
- window->zone = dispzone->fullname;
- setAttributes(window->surfaceid);
-
- int ret = setGeometry(surfaceid, displayno, layerid,
- dispzone->x, dispzone->y,
- dispzone->width, dispzone->height,
- resizeAnimation, resizeAnimationTime,
- moveAnimation, moveAnimationTime);
-
- ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
- return ret;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief lower window(surface)
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] animation animation name
- * @param [in] animationTime animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::lower(int surfaceid,
- const char *animation,
- int animationTime)
-{
- int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
- animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
-
- ICO_TRA("CicoSCWindowController::lower Enter"
- "(surfaceid=08x animation=%s type=%x animationTime=%d)",
- surfaceid, animation, type, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::lower Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- if ((NULL != animation) && (animation[0] != '\0')) {
- CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
- (type & ICO_SYC_WIN_SURF_ONESHOT) ?
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
- ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
- ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
- animation, animationTime);
- }
-
- // set lower request to Multi Window Manager
- raiselower(window, false);
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::lower ilm_commitChanges() Error");
- }
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::lower Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set window(surface) animation
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] target target(pointer and/or keyboard)
- * @param [in] type set animation target
- * @param [in] animation animation information
- * @param [in] time animation time
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setWindowAnimation(int surfaceid, int type,
- const char *animation, int time)
-{
- CicoSCWindow *window = NULL;
-
- ICO_TRA("CicoSCWindowController::setWindowAnimation Enter"
- "(surfaceid=%08x, type=%x, animation=<%s>, time=%d)",
- surfaceid, type, animation ? animation : "(null)", time);
-
- // find window information in window list
- window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // set animation request to Multi Window Manager
- CicoSCWlWinMgrIF::setAnimation(surfaceid, type, animation, time);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set window layer
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] layer layer id
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(window or layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setWindowLayer(int surfaceid, int layerid)
-{
- ICO_TRA("CicoSCWindowController::setWindowLayer Enter"
- "(surfaceid=%08x layerid=%x)", surfaceid, layerid);
-
- // find window information in window list
- CicoSCWindow* window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
- if (window->layerid == layerid) {
- ICO_TRA("CicoSCWindowController::setWindowLayer Leave(same layer %d)", layerid);
- return ICO_SYC_EOK;
- }
-
- // find new layer information in layer list
- CicoSCLayer* layer = findLayer(window->displayid, layerid);
- if (NULL == layer) {
- ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT[disp=%d,layer=%d])",
- window->displayid, layerid);
- return ICO_SYC_ENOENT;
- }
-
- // find old layer information and remove surface if need
- CicoSCLayer* oldlayer = findLayer(window->displayid, window->layerid);
- if (oldlayer) {
- if (ilm_layerRemoveSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerRemoveSurface(%d,%08x)"
- " Error", window->layerid, window->surfaceid);
- }
- // must need ilm_commitChanges() after ilm_layerRemoveSurface()
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
- }
-
- oldlayer->removeSurface(window->surfaceid);
- int noldsurf;
- const int *oldsurfs = oldlayer->getSurfaces(&noldsurf);
- if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)oldsurfs, noldsurf)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer "
- "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, noldsurf);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
- }
- }
-
- // update window attr
- window->layerid = layerid;
-
- // set window layer request
- if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
- window->layerid, window->surfaceid);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
- }
-
- // add surface to new layer
- layer->addSurface(window->surfaceid, true);
- int nsurf;
- const int *surfs = layer->getSurfaces(&nsurf);
- if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer "
- "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
- }
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::setWindowLayer Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief show layer
- *
- * @param [in] displayid display id
- * @param [in] layerid layer id
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::showLayer(int displayid, int layerid)
-{
- ICO_TRA("CicoSCWindowController::showLayer Enter"
- "(displayid=%d layerid=%d)", displayid, layerid);
-
- // find layer information in layer list
- CicoSCLayer* layer = findLayer(displayid, layerid);
- if (NULL == layer) {
- ICO_WRN("not found layer information");
- ICO_TRA("CicoSCWindowController::showLayer Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_SHOW);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::showLayer Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief show layer
- *
- * @param [in] displayid display id
- * @param [in] layerid layer id
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::hideLayer(int displayid, int layerid)
-{
- ICO_TRA("CicoSCWindowController::hideLayer Enter"
- "displayid=%d layerid=%d)",
- displayid, layerid);
-
- // find layer information in layer list
- CicoSCLayer* layer = findLayer(displayid, layerid);
- if (NULL == layer) {
- ICO_WRN("not found layer information");
- ICO_TRA("CicoSCWindowController::hideLayer Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_HIDE);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::hideVisible Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief active window(surface)
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] target target(pointer and/or keyboard)
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::active(int surfaceid, int target)
-{
- CicoSCWindow *window = NULL;
-
- ICO_TRA("CicoSCWindowController::active Enter"
- "(surfaceid=%08x, target=%08x)", surfaceid, target);
-
- // find window information in window list
- if (surfaceid) {
- window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::active Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
- }
-
- if (target < 0) {
- target = 0xffff;
- }
-
- // set active request to Multi Window Manager
- CicoSCWlWinMgrIF::setActive(surfaceid, target);
-
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-
- // update visible attr
- if (window) {
- window->raise = true;
- }
-
- // update active window
- map<unsigned int, CicoSCWindow*>::iterator itr;
- itr = m_windowList.begin();
- for (; itr != m_windowList.end(); ++itr) {
- CicoSCWindow* window = itr->second;
- if ((surfaceid != 0) && (window->surfaceid == surfaceid)) {
- window->active = target;
- }
- else {
- if (target == 0) {
- window->active = 0;
- }
- else {
- window->active &= ~target;
- }
- }
- }
-
- ICO_TRA("CicoSCWindowController::active Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set surface map get
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] filepath surface image pixel file path
- *
- * @return ICO_SYC_EOK on success, other on error(currently EOK only)
- * @retval ICO_SYC_EOK success
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setmapGet(int surfaceid, const char *filepath)
-{
- ICO_TRA("CicoSCWindowController::setmapGet Enter");
-
- CicoSCWlWinMgrIF::setmapGet(surfaceid, filepath);
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::setmapGet Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief map surface
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] framerate surface change frame rate(frames par sec)
- * @param [in] filepath surface image pixel file path
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::mapSurface(int surfaceid, int framerate, const char *filepath)
-{
- ICO_TRA("CicoSCWindowController::mapSurface Enter(%08x,%d,%s)",
- surfaceid, framerate, filepath ? filepath : "(null)");
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::mapSurface Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- CicoSCWlWinMgrIF::mapSurface(surfaceid, framerate, filepath);
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::mapSurface Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief unmap surface
- *
- * @param [in] surfaceid wayland surface id
- *
- * @return ICO_SYC_EOK on success, other on error
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::unmapSurface(int surfaceid)
-{
- ICO_TRA("CicoSCWindowController::unmapSurface Enter(%08x)", surfaceid);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::unmapSurface Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- CicoSCWlWinMgrIF::unmapSurface(surfaceid);
- CicoSCWayland::getInstance()->flushDisplay();
-
- ICO_TRA("CicoSCWindowController::unmapSurface Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get displayed window by display zone id
- *
- * @param [in] zoneid display zone id
- *
- * @return surface id on success, -1 on not displayed
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::getDisplayedWindow(int zoneid)
-{
- const CicoSCDisplayZone* zone = findDisplayZone(zoneid);
- if (NULL == zone) {
- return -1;
- }
-
- if (NULL == zone->displayedWindow) {
- return -1;
- }
-
- return zone->displayedWindow->surfaceid;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief set surface attributes
- *
- * @param [in] surfaceid surface id
- *
- * @retval ICO_SYC_EOK success
- * @retval ICO_SYC_ESRCH error(not initialized)
- * @retval ICO_SYC_ENOENT error(layer dose not exist)
- */
-//--------------------------------------------------------------------------
-int
-CicoSCWindowController::setAttributes(int surfaceid)
-{
- ICO_TRA("CicoSCWindowController::setAttributes Enter"
- "(surfaceid=%08x)", surfaceid);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- // find zone
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL == zone) {
- ICO_WRN("not found zone information");
- ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- uint32_t attributes = 0;
- if (true == zone->aspectFixed) {
- attributes |= ICO_SYC_WIN_ASPECT_FIXED;
- if (true == zone->aspectAlignLeft) {
- attributes |= ICO_SYC_WIN_ASPECT_ALIGN_LEFT;
- }
- if (true == zone->aspectAlignRight) {
- attributes |= ICO_SYC_WIN_ASPECT_ALIGN_RIGHT;
- }
- if (true == zone->aspectAlignTop) {
- attributes |= ICO_SYC_WIN_ASPECT_ALIGN_TOP;
- }
- if (true == zone->aspectAlignBottom) {
- attributes |= ICO_SYC_WIN_ASPECT_ALIGN_BOTTOM;
- }
- }
- ICO_TRA("CicoSCWindowController::setAttributes Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland surface active callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid ico_window_mgr surface Id
- * @param [in] select select device(unused)
- * (0=not active/1=pointer/2=touch)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::activeCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t select)
-{
- ICO_TRA("CicoSCWindowController::activeCB Enter"
- "(surfaceid=%08x select=%d)", surfaceid, select);
-
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::activeCB Leave(not found window)");
- return;
- }
-
- if (0 == select) {
- ICO_TRA("CicoSCWindowController::activeCB Leave(not active)");
- return;
- }
-
- if (0 != window->active) {
- ICO_TRA("CicoSCWindowController::activeCB Leave(already active)");
- return;
- }
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_CHANGE_ACTIVE);
- message->addRootObject("appid", window->appid);
- message->addRootObject("pid", window->pid);
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("winname", window->name);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- ICO_TRA("CicoSCWindowController::activeCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface map event callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] event event
- * @param [in] surfaceid surface Id
- * @param [in] type surface type (EGL buffer/Shared memory)
- * @param [in] width surface width
- * @param [in] height surface height
- * @param [in] stride surface buffer(frame buffer) stride
- * @param [in] format surface buffer format
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::mapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format)
-{
- int command;
-
- ICO_TRA("CicoSCWindowController::mapSurfaceCB Enter(ev=%d surf=%x "
- "type=%d w/h=%d/%d stride=%d form=%x)",
- event, surfaceid, type, width, height, stride, format);
-
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- return;
- }
-
- // convert event to command
- switch (event) {
- case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
- case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
- case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
- command = MSG_CMD_MAP_THUMB;
- break;
- case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
- case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
- command = MSG_CMD_UNMAP_THUMB;
- break;
- default:
- ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(Unknown event(%d))", event);
- return;
- }
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", command);
- message->addRootObject("appid", window->appid);
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("attr", type);
- message->addArgObject("width", width);
- message->addArgObject("height", height);
- message->addArgObject("stride", stride);
- message->addArgObject("format", format);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface update event callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid surface Id
- * @param [in] visible visibility
- * @param [in] srcwidth application buffer width
- * @param [in] srcheight application buffer height
- * @param [in] x X
- * @param [in] y Y
- * @param [in] width width
- * @param [in] height height
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::updateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int visible,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height)
-{
- ICO_TRA("CicoSCWindowController::updateSurfaceCB: Enter(%08x %d,%d,%d,%d,%d,%d,%d)",
- surfaceid, visible, srcwidth, srcheight, x, y, width, height);
-
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("CicoSCWindowController::updateSurfaceCB: not found window(%08x)",
- surfaceid);
- ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
- return;
- }
-
- // update attr
- window->visible = visible;
- window->srcwidth = srcwidth;
- window->srcheight = srcheight;
- window->x = x;
- window->y = y;
- window->width = width;
- window->height = height;
- window->nodeid = window->layerid / ICO_SC_LAYERID_SCREENBASE;
-
- // notify to homescreen
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_CHANGE_ATTR);
- message->addRootObject("appid", window->appid);
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL != zone) {
- message->addArgObject("zone", zone->fullname);
- }
- else {
- message->addArgObject("zone", "");
- }
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("winname", window->name);
- message->addArgObject("node", window->nodeid);
- message->addArgObject("layer", window->layerid);
- message->addArgObject("pos_x", window->x);
- message->addArgObject("pos_y", window->y);
- message->addArgObject("width", window->width);
- message->addArgObject("height", window->height);
- message->addArgObject("raise", window->raise ? 1 : 0);
- message->addArgObject("visible", window->visible ? 1 : 0);
- message->addArgObject("active", window->active ? 1 : 0);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland surface destroy callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid ico_window_mgr surface Id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::destroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid)
-{
- ICO_TRA("CicoSCWindowController::destroySurfaceCB: Enter(%08x)", surfaceid);
-
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window(%08x)", surfaceid);
- ICO_TRA("CicoSCWindowController::destroySurfaceCB Leave");
- return;
- }
-
- // delete surface from layer
- CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
- if (NULL == layer) {
- ICO_TRA("CicoSCWindowController::destroySurfaceCB: surf.%08x not exist in layer.%d",
- surfaceid, window->layerid);
- }
- else {
- layer->removeSurface(surfaceid);
- }
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_DESTROY);
- message->addRootObject("appid", window->appid);
- message->addRootObject("pid", window->pid);
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("winname", window->name);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- // TODO delete window in application
- if (NULL != m_resMgr) {
- CicoSCCommand cmd;
- CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
-
- cmd.cmdid = MSG_CMD_DESTORY_RES;
- cmd.appid = window->appid;
- cmd.pid = window->pid;
- cmd.opt = opt;
-
- opt->dispres = true;
- opt->winname = window->name;
- opt->surfaceid = window->surfaceid;
-
- string fullname;
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL != zone) {
- opt->dispzone = zone->fullname;
- }
-
- opt->soundres = true;
- opt->soundname = window->appid;
- opt->soundid = 0;
- CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
- const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
- if (NULL != defconf) {
- const CicoSCSoundZoneConf *zoneconf =
- sysconf->findSoundZoneConfbyId(defconf->soundzone);
- if (NULL != zoneconf) {
- opt->soundzone = zoneconf->fullname;
- }
- }
- m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
- }
- // delete window in list
- m_windowList.erase(window->surfaceid);
- delete(window);
-
- ICO_TRA("CicoSCWindowController::destroySurfaceCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland update surface name callback
- *
- * @param [in] surfaceid surface Id
- * @param [in] winname surface name (title)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::updateWinnameCB(uint32_t surfaceid,
- const char *winname)
-{
- ICO_TRA("CicoSCWindowController::updateWinnameCB: Enter(%08x,<%s>)",
- surfaceid, winname ? winname : "(null)");
-
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("CicoSCWindowController::updateWinnameCB: not found window(%08x)",
- surfaceid);
- ICO_TRA("CicoSCWindowController::updateWinnameCB Leave");
- return;
- }
-
- window->name = winname;
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_NAME);
- message->addRootObject("appid", window->appid);
- message->addRootObject("pid", window->pid);
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("winname", window->name);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- ICO_TRA("CicoSCWindowController::updateWinnameCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display attribute callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] x display upper-left X coordinate
- * @param [in] y display upper-left Y coordinate
- * @param [in] physical_width display physical width
- * @param [in] physical_height display physical height
- * @param [in] subpixel display sub pixel
- * @param [in] make display maker
- * @param [in] model display model
- * @param [in] transform transform
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::outputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform)
-{
- ICO_TRA("CicoSCWindowController::outputGeometryCB Enter"
- "(x=%d y=%d physical_width=%d physical_height=%d "
- "subpixel=%d make=%s model=%s transform=%d)",
- x, y, physical_width, physical_height,
- subpixel, make, model, transform);
-
- ++m_physicalDisplayTotal;
- if (0 == m_displayList.size()) {
- ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
- "(display is zero)");
- return;
- }
-
- if (m_displayList.size() < m_physicalDisplayTotal) {
- ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
- "(display total unmatch)");
- return;
- }
-
- CicoSCDisplay* display = m_displayList.at(m_physicalDisplayTotal-1);
- switch (transform) {
- case WL_OUTPUT_TRANSFORM_90:
- case WL_OUTPUT_TRANSFORM_270:
- case WL_OUTPUT_TRANSFORM_FLIPPED_90:
- case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- display->pWidth = physical_height;
- display->pHeight = physical_width;
- display->orientation = CicoSCDisplay::ORIENTATION_VERTICAL;
- break;
- case WL_OUTPUT_TRANSFORM_NORMAL:
- case WL_OUTPUT_TRANSFORM_180:
- case WL_OUTPUT_TRANSFORM_FLIPPED:
- case WL_OUTPUT_TRANSFORM_FLIPPED_180:
- default:
- display->pWidth = physical_width;
- display->pHeight = physical_height;
- display->orientation = CicoSCDisplay::ORIENTATION_HORIZONTAL;
- break;
- }
- display->dump();
-
- ICO_TRA("CicoSCWindowController::outputGeometryCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display mode callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] flags flags
- * @param [in] width display width
- * @param [in] height display height
- * @param [in] refresh display refresh rate
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::outputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh)
-{
- ICO_TRA("CicoSCWindowController::outputModeCB Enter"
- "(flags=%d width=%d height=%d refresh=%d)",
- flags, width, height, refresh);
-
- if (0 == m_displayList.size()) {
- ICO_TRA("CicoSCWindowController::outputModeCB Leave(display is zero)");
- return;
- }
-
- CicoSCDisplay* display = m_displayList.at(0);
- if (flags & WL_OUTPUT_MODE_CURRENT) {
- if (display->orientation == CicoSCDisplay::ORIENTATION_VERTICAL) {
- display->pWidth = height;
- display->pHeight = width;
- }
- else {
- display->pWidth = width;
- display->pHeight = height;
- }
- display->dump();
- }
-
- ICO_TRA("CicoSCWindowController::outputModeCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland genivi ivi-shell surface create callback
- *
- * @param [in] data user data
- * @param [in] ivi_controller wayland ivi-controller plugin interface
- * @param [in] id_surface surface id
- * @param [in] pid surface creator process id
- * @param [in] title surface title
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::createSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title)
-{
- struct ilmSurfaceProperties SurfaceProperties;
-
- ICO_TRA("CicoSCWindowController::createSurfaceCB Enter"
- "(surfaceid=%08x,pid=%d)", id_surface, pid);
-
- if (ilm_getPropertiesOfSurface(id_surface, &SurfaceProperties) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB: ilm_getPropertiesOfSurface(%x) "
- "Error", id_surface);
- return;
- }
- ICO_TRA("createSurfaceCB: surface=%08x w/h=%d/%d->%d/%d",
- id_surface, SurfaceProperties.sourceWidth, SurfaceProperties.sourceHeight,
- SurfaceProperties.destWidth, SurfaceProperties.destHeight);
-
- CicoSCWindow* window = new CicoSCWindow();
- window->surfaceid = id_surface;
- int32_t svpid;
- const char *svtitle = CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(id_surface, &svpid);
- if (svtitle) {
- window->name = svtitle;
- window->pid = svpid;
- }
- else {
- window->name = title;
- window->pid = pid;
- }
- window->displayid = 0; // currently fixed 0
- window->raise = 1; // created surface is top of layer
- window->srcwidth = SurfaceProperties.sourceWidth;
- window->srcheight = SurfaceProperties.sourceHeight;
- window->width = SurfaceProperties.destWidth;
- window->height = SurfaceProperties.destHeight;
- window->layerid = 0;
-
- CicoSCLifeCycleController* appctrl;
- appctrl = CicoSCLifeCycleController::getInstance();
- const CicoAilItems* ailItem = NULL;
- const CicoAulItems* aulitem = appctrl->findAUL(window->pid);
- if (NULL == aulitem) {
- /* client does not exist in AppCore, search parent process */
- ICO_DBG("application information not found. search parent process");
-
- int fd;
- int cpid = pid;
- int ppid;
- int size;
- char *ppid_line;
- char procpath[PATH_MAX];
-
- while ((cpid > 1) && (aulitem == NULL)) {
- snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", cpid);
-
- fd = open(procpath, O_RDONLY);
- if (fd < 0) break;
-
- size = read(fd, procpath, sizeof(procpath));
- close(fd);
-
- if (size <= 0) break;
- ppid_line = strstr(procpath, "PPid");
-
- if (ppid_line == NULL) break;
- ppid = 0;
- sscanf(ppid_line, "PPid: %d", &ppid);
- if (ppid <= 1) break;
- ICO_DBG("application pid=%d parent=%d", cpid, ppid);
- cpid = ppid;
- aulitem = appctrl->findAUL(cpid);
- }
- }
- if (NULL != aulitem) {
- window->appid = aulitem->m_appid;
- ICO_DBG("appid=%s", window->appid.c_str());
- ailItem = appctrl->findAIL(window->appid.c_str());
- }
-
- if (NULL != ailItem) {
- window->layerid = ailItem->m_layer;
- window->zoneid = ailItem->m_displayZone;
- window->nodeid = ailItem->m_nodeID;
- if ((window->displayid >= 0) && (window->zoneid >= 0)) {
-
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL != zone) {
- window->zone = zone->fullname;
- window->x = zone->x;
- window->y = zone->y;
- window->width = zone->width;
- window->height = zone->height;
- }
- }
- }
- else{
- delete window;
- ICO_WRN("ail item not found.");
- ICO_TRA("CicoSCWindowController::createSurfaceCB Leave(ENOENT)");
- return;
- }
-
- if (ilm_surfaceSetDestinationRectangle(window->surfaceid, window->x, window->y,
- window->width, window->height) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB "
- "ilm_surfaceSetDestinationRectangle(%08x) Error", window->surfaceid);
- }
- else if (ilm_surfaceSetSourceRectangle(window->surfaceid, 0, 0,
- window->width, window->height) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB "
- "ilm_surfaceSetSourceRectangle(%08x) Error", window->surfaceid);
- }
- else if (ilm_surfaceSetOrientation(window->surfaceid, ILM_ZERO) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB "
- "ilm_surfaceSetOrientation(%08x) Error", window->surfaceid);
- }
- else if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
- }
-
- CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
- if (layer) {
- if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_layerAddSurface(%d,%08x) "
- "Error", window->layerid, window->surfaceid);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
- }
-
- layer->addSurface(window->surfaceid, true);
- int nsurf;
- const int *surfs = layer->getSurfaces(&nsurf);
- if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB: "
- "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
- }
- }
- // must set surfaceOpacity after surfcaeAddLayer
- if (ilm_surfaceSetOpacity(window->surfaceid , (t_ilm_float)1.0f) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB "
- "ilm_surfaceSetOpacity(%08x) Error", window->surfaceid);
- }
- else if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
- }
-
- appctrl->enterAUL(window->appid.c_str(), window->pid, window);
-
- // dump log window information
- window->dump();
-
- m_windowList[window->surfaceid] = window;
-
- // set surface attributes
- setAttributes(window->surfaceid);
-
- // send message
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_CREATE);
- message->addRootObject("appid", window->appid);
- message->addRootObject("pid", window->pid);
- message->addArgObject("surface", window->surfaceid);
- message->addArgObject("winname", window->name);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
-
- if (0 == window->appid.compare(ICO_SC_APPID_DEFAULT_ONS)) {
- CicoSCMessageRes *msgOS = new CicoSCMessageRes();
- msgOS->addRootObject("command", MSG_CMD_WINDOW_ID_RES);
- msgOS->addRootObject("appid", window->appid);
- msgOS->addRootObject("pid", window->pid);
- msgOS->addWinObject(MSG_PRMKEY_ECU, "");
- msgOS->addWinObject(MSG_PRMKEY_DISPLAY, "");
- msgOS->addWinObject(MSG_PRMKEY_LAYER, "");
- msgOS->addWinObject(MSG_PRMKEY_LAYOUT, "");
- msgOS->addWinObject(MSG_PRMKEY_AREA, "");
- msgOS->addWinObject(MSG_PRMKEY_DISPATCHAPP, "");
- msgOS->addWinObject(MSG_PRMKEY_ROLE, window->name);
- msgOS->addWinObject(MSG_PRMKEY_RESOURCEID, window->surfaceid);
- CicoSCServer::getInstance()->sendMessage(window->appid,
- (CicoSCMessage*)msgOS);
- }
-
- if (NULL != m_resMgr) {
- CicoSCCommand cmd;
- CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
-
- cmd.cmdid = MSG_CMD_CREATE_RES;
- cmd.appid = window->appid;
- cmd.pid = window->pid;
- cmd.opt = opt;
-
- opt->dispres = true;
- opt->winname = window->name;
- opt->surfaceid = window->surfaceid;
-
- string fullname;
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL != zone) {
- opt->dispzone = zone->fullname;
- }
-
-#if 1 //TODO
- opt->soundres = true;
- opt->soundname = window->appid;
- opt->soundid = 0;
- CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
- const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
- if (NULL != defconf) {
- const CicoSCSoundZoneConf *zoneconf =
- sysconf->findSoundZoneConfbyId(defconf->soundzone);
- if (NULL != zoneconf) {
- opt->soundzone = zoneconf->fullname;
- }
- }
-#endif
- m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
- }
- else {
- show(window->surfaceid, NULL, 0);
- }
- ICO_TRA("CicoSCWindowController::createSurfaceCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief genivi ivi-shell layer propaty callback
- *
- * @param [in] layer layer id
- * @param [in] LayerProperties layer properties
- * @param [in] mask change properties
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::wlGeniviLayerNotification(t_ilm_layer layer,
- struct ilmLayerProperties *LayerProperties,
- t_ilm_notification_mask mask)
-{
- ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Enter(%x,,%x)", layer, mask);
-
- if (mask & ILM_NOTIFICATION_VISIBILITY) {
- // change layer visibility, send message to HomeScreen
- CicoSCMessage *message = new CicoSCMessage();
- message->addRootObject("command", MSG_CMD_CHANGE_LAYER_ATTR);
- message->addRootObject("appid", "");
- message->addArgObject("layer", layer);
- message->addArgObject("visible", LayerProperties->visibility ? 1 : 0);
- CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
- }
- ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief setup Genivi ivi-shell layer managerment system finctions
- *
- * @param none
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::initializeGeniviLMS(void)
-{
- t_ilm_uint NumberOfScreens = 0;
- t_ilm_layer *pLayerId, *ppLayerId;
- t_ilm_int LayerNumber;
- t_ilm_uint *pScreenIds;
- struct ilmScreenProperties ScreenProperties;
- int idxs, idx1, idx2;
- int DisplayId, LayerId;
- const CicoSCDisplayConf *DisplayConf;
- const CicoSCLayerConf *LayerConf;
-
- // get all screen id
- if ((ilm_getScreenIDs(&NumberOfScreens, &pScreenIds) != ILM_SUCCESS) ||
- (NumberOfScreens <= 0)) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_getScreenIDs() Error(num=%d)", NumberOfScreens);
- return;
- }
- ICO_TRA("initializeGeniviLMS: Screens=%d.%x %x", NumberOfScreens, pScreenIds[0],
- NumberOfScreens >= 2 ? pScreenIds[1] : 0);
- if ((int)NumberOfScreens > CicoSystemConfig::getInstance()->getNumberofDisplay()) {
- ICO_WRN("CicoSCWindowController::initializeGeniviLMS # of screens physical=%d config=%d",
- NumberOfScreens, CicoSystemConfig::getInstance()->getNumberofDisplay());
- NumberOfScreens = (t_ilm_uint)CicoSystemConfig::getInstance()->getNumberofDisplay();
- }
-#if 1 /* At present, GENIVI (ivi-controller) is processing only one Display */
- for (idxs = (int)NumberOfScreens - 1; idxs >= 0; idxs--)
-#else
- for (idxs = 0; idxs < (int)NumberOfScreens; idxs++)
-#endif
- {
- if (ilm_getPropertiesOfScreen(pScreenIds[idxs], &ScreenProperties) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_getPropertiesOfScreen(%d.%x) Error", idxs, pScreenIds[idxs]);
- continue;
- }
- // It is referred to as Center when there is only one display
- if (NumberOfScreens == 1) {
- DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyType(ICO_NODETYPE_CENTER);
- }
- else {
- DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyNo((int)pScreenIds[idxs]);
- }
- ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
- "Screen[%d.%x] w/h=%d/%d layers=%d DisplayId=%d",
- idxs, pScreenIds[idxs], ScreenProperties.screenWidth,
- ScreenProperties.screenHeight, ScreenProperties.layerCount, DisplayId);
-
- if ((DisplayId < 0) ||
- ((DisplayConf = CicoSystemConfig::getInstance()->findDisplayConfbyId(DisplayId))
- == NULL)) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ScreenId.%x not found", pScreenIds[idxs]);
- }
- else {
- // set genivi layers
- for (idx1 = 0; ; idx1++) {
- LayerConf = CicoSystemConfig::getInstance()->
- findLayerConfbyIdx(DisplayId, idx1);
- if (! LayerConf) break;
- }
- pLayerId = (t_ilm_layer *)malloc(sizeof(t_ilm_layer) * idx1);
- ppLayerId = pLayerId;
- LayerNumber = 0;
-
- for (idx1 = 0; ; idx1++) {
- LayerConf = CicoSystemConfig::getInstance()->
- findLayerConfbyIdx(DisplayId, idx1);
- if (! LayerConf) break;
-
- LayerId = LayerConf->id + DisplayId * ICO_SC_LAYERID_SCREENBASE;
- for (idx2 = 0; idx2 < LayerNumber; idx2++) {
- if (LayerId == (int)pLayerId[idx2]) break;
- }
- if (idx2 < LayerNumber) {
- ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
- "layer.%d exist, Skip", LayerId);
- continue;
- }
-
- if (ilm_layerCreateWithDimension((t_ilm_layer *)&LayerId,
- DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerCreateWithDimension(%d,%d,%d) Error",
- LayerId, DisplayConf->width, DisplayConf->height);
- }
- else if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_commitChanges() Error");
- }
- else if (ilm_layerSetOpacity(LayerId, (t_ilm_float)1.0f) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerSetOpacity(%d) Error", LayerId);
- }
- else if (ilm_layerSetSourceRectangle(LayerId, 0, 0,
- DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerSetSourceRectangle(%d) Error", LayerId);
- }
- else if (ilm_layerSetDestinationRectangle(LayerId, 0, 0,
- DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerSetDestinationRectangle(%d) Error", LayerId);
- }
- else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerSetOrientation(%d) Error", LayerId);
- }
- else {
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_commitChanges() Error");
- }
- // SystemController default is layer visible
- if ((ilm_layerSetVisibility(LayerId, 1) != ILM_SUCCESS) ||
- (ilm_commitChanges() != ILM_SUCCESS)) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerSetVisibility() Error");
- }
- ICO_TRA("initializeGeniviLMS: layer=%d created(%d,%d)",
- LayerId, DisplayConf->width, DisplayConf->height);
- *ppLayerId = LayerId;
- ppLayerId ++;
- LayerNumber ++;
- }
- }
- if (LayerNumber > 0) {
- ICO_TRA("initializeGeniviLMS: layers %d.%d %d %d %d set to screen %x",
- LayerNumber, pLayerId[0], pLayerId[1], pLayerId[2], pLayerId[3],
- pScreenIds[idxs]);
- if (ilm_displaySetRenderOrder(pScreenIds[idxs], pLayerId, LayerNumber)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_displaySetRenderOrder(%d) Error", LayerNumber);
- }
- else if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_commitChanges() Error");
- }
- ppLayerId = pLayerId;
- for (idx2 = 0; idx2 < LayerNumber; idx2++) {
- if (ilm_layerAddNotification(*ppLayerId, wlGeniviLayerNotification)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
- "ilm_layerAddNotification(%d) Error", *ppLayerId);
- }
- ppLayerId ++;
- }
- }
- free(pLayerId);
- }
- }
- free(pScreenIds);
-}
-
-//==========================================================================
-// private method
-//==========================================================================
-
-//--------------------------------------------------------------------------
-/**
- * @brief find window object by surfaceid
- *
- * @param [in] surfaceid wayland surface id
- */
-//--------------------------------------------------------------------------
-CicoSCWindow*
-CicoSCWindowController::findWindow(int surfaceid)
-{
- map<unsigned int, CicoSCWindow*>::iterator itr;
- itr = m_windowList.find(surfaceid);
- if (m_windowList.end() == itr) {
- ICO_TRA("not found window object. surfaceid=%08x", surfaceid);
- return NULL;
- }
-
- return itr->second;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find window object by surfaceid
- *
- * @param [in] surfaceid wayland surface id
- */
-//--------------------------------------------------------------------------
-CicoSCLayer*
-CicoSCWindowController::findLayer(int displayid, int layerid)
-{
- vector<CicoSCDisplay*>::iterator itr;
- itr = m_displayList.begin();
- for (; itr != m_displayList.end(); ++itr) {
- if ((*itr)->displayid != displayid) {
- continue;
- }
- vector<CicoSCLayer*>::iterator itr2;
- itr2 = (*itr)->layerList.begin();
- for (; itr2 != (*itr)->layerList.end(); ++itr2) {
- if ((*itr2)->layerid == layerid) {
- return *itr2;
- }
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief find display zone by id
- */
-//--------------------------------------------------------------------------
-const CicoSCDisplayZone *
-CicoSCWindowController::findDisplayZone(int zoneid)
-{
- vector<CicoSCDisplay*>::iterator itr;
- itr = m_displayList.begin();
- for (; itr != m_displayList.end(); ++itr) {
- std::map<unsigned int, CicoSCDisplayZone*>::iterator itr2;
- itr2 = (*itr)->zoneList.find(zoneid);
- if ((*itr)->zoneList.end() != itr2) {
- return itr2->second;
- }
- }
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief handle command
- *
- * @param [in] cmd control command
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWindowController::handleCommand(const CicoSCCommand * cmd)
-{
-// ICO_TRA("CicoSCWindowController::handleCommand Enter(%d)", cmd->cmdid);
-
- CicoSCCmdWinCtrlOpt *opt = static_cast<CicoSCCmdWinCtrlOpt*>(cmd->opt);
-
- switch (cmd->cmdid) {
- case MSG_CMD_SHOW:
- ICO_DBG("command: MSG_CMD_SHOW");
- if (opt->animationTime & ICO_SYC_WIN_SURF_NORESCTL) {
- /* show command but not resource control (for HomeScreen) */
- (void)show(opt->surfaceid,
- opt->animation.c_str(),
- opt->animationTime);
- }
- else {
- /* show command (normal) */
- (void)notifyResourceManager(opt->surfaceid,
- NULL,
- opt->layerid,
- opt->animation.c_str(),
- opt->animationTime);
- }
- break;
- case MSG_CMD_HIDE:
- ICO_DBG("command: MSG_CMD_HIDE");
- (void)hide(opt->surfaceid, opt->animation.c_str(), opt->animationTime);
- break;
- case MSG_CMD_MOVE:
- {
- ICO_DBG("command: MSG_CMD_MOVE");
- CicoSCWindow *window = findWindow(opt->surfaceid);
- if (NULL == window) {
- break;
- }
- if (true == opt->zone.empty()) {
- (void)setGeometry(opt->surfaceid, opt->nodeid, opt->layerid,
- opt->x, opt->y, opt->width, opt->height,
- opt->animation.c_str(), opt->animationTime,
- opt->animation.c_str(), opt->animationTime);
- }
- else if (opt->zone == window->zone) {
- (void)setGeometry(opt->surfaceid, opt->zone.c_str(), opt->layerid,
- opt->animation.c_str(), opt->animationTime,
- opt->animation.c_str(), opt->animationTime);
- }
- else {
- (void)notifyResourceManager(opt->surfaceid,
- opt->zone.c_str(),
- opt->layerid,
- opt->animation.c_str(),
- opt->animationTime);
- }
- break;
- }
- case MSG_CMD_ANIMATION:
- ICO_DBG("command: MSG_CMD_ANIMATION");
- (void)setWindowAnimation(opt->surfaceid, opt->animationType,
- opt->animation.c_str(), opt->animationTime);
- break;
- case MSG_CMD_CHANGE_ACTIVE:
- ICO_DBG("command: MSG_CMD_CHANGE_ACTIVE");
- (void)active(opt->surfaceid, opt->active);
- break;
- case MSG_CMD_CHANGE_LAYER:
- ICO_DBG("command: MSG_CMD_CHANGE_LAYER");
- (void)setWindowLayer(opt->surfaceid, opt->layerid);
- break;
- case MSG_CMD_MAP_GET:
- ICO_DBG("command: MSG_CMD_MAP_GET");
- (void)setmapGet(opt->surfaceid, opt->animation.c_str());
- break;
- case MSG_CMD_MAP_THUMB:
- ICO_DBG("command: MSG_CMD_MAP_THUMB");
- (void)mapSurface(opt->surfaceid, opt->framerate, opt->animation.c_str());
- break;
- case MSG_CMD_UNMAP_THUMB:
- ICO_DBG("command: MSG_CMD_UNMAP_THUMB");
- (void)unmapSurface(opt->surfaceid);
- break;
- case MSG_CMD_SHOW_LAYER:
- ICO_DBG("command: MSG_CMD_SHOW_LAYER");
- (void)showLayer(opt->displayid, opt->layerid);
- break;
- case MSG_CMD_HIDE_LAYER:
- ICO_DBG("command: MSG_CMD_HIDE_LAYER");
- (void)hideLayer(opt->displayid, opt->layerid);
- break;
- default:
- ICO_WRN("command: Unknown(0x%08x)", cmd->cmdid);
- break;
- }
-
-// ICO_TRA("CicoSCWindowController::handleCommand Leave");
-}
-
-int
-CicoSCWindowController::notifyResourceManager(int surfaceid,
- const char *zone,
- int layerid,
- const char *animation,
- int animationTime)
-{
- ICO_TRA("CicoSCWindowController::notifyResourceManager Enter"
- "(surfaceid=%08x zone=%s layerid=%d "
- "animation=%s animationTime=%d)",
- surfaceid, zone, layerid, animation, animationTime);
-
- // find window information in window list
- CicoSCWindow *window = findWindow(surfaceid);
- if (NULL == window) {
- ICO_WRN("not found window information");
- ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
-
- CicoSCCommand cmd;
- CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
-
- cmd.cmdid = MSG_CMD_ACQUIRE_RES;
- cmd.appid = window->appid;
- cmd.pid = window->pid;
- cmd.opt = opt;
-
- opt->dispres = true;
- opt->winname = window->name;
- opt->layerid = layerid;
- opt->surfaceid = window->surfaceid;
- opt->animation = animation ? animation : "";
- opt->animationTime = animationTime;
- string fullname;
- if (NULL == zone) {
- const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
- if (NULL != zone) {
- opt->dispzone = zone->fullname;
- }
- else {
- ICO_WRN("not found zone information");
- ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
- return ICO_SYC_ENOENT;
- }
- }
- else {
- opt->dispzone = zone;
- }
-#if 1 //TODO
- opt->soundres = true;
- opt->soundname = window->appid;
- opt->soundid = 0;
- CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
- const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
- if (NULL != defconf) {
- const CicoSCSoundZoneConf *zoneconf =
- sysconf->findSoundZoneConfbyId(defconf->soundzone);
- if (NULL != zoneconf) {
- opt->soundzone = zoneconf->fullname;
- }
- }
-#endif
-
- m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
-
- ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(EOK)");
- return ICO_SYC_EOK;
-}
-
-const CicoSCWindow*
-CicoSCWindowController::findWindowObj(int32_t pid, uint32_t surfaceid) const
-{
- const CicoSCWindow* r = NULL;
- map<unsigned int, CicoSCWindow*>::const_iterator itr = m_windowList.begin();
- for (; itr != m_windowList.end(); ++itr) {
- const CicoSCWindow* tmp = itr->second;
- if ((pid == tmp->pid) && (surfaceid == (uint32_t)tmp->surfaceid)) {
- r = tmp;
- break; // break of for itr
- }
- }
- ICO_TRA("return %x", r);
- return r;
-}
-
-const CicoSCResourceManager*
-CicoSCWindowController::getResourceManager(void) const
-{
- return m_resMgr;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWindowController.h
- *
- * @brief This file is definition of CicoSCWindowController class
- */
-//==========================================================================
-#ifndef __CICO_SC_WINDOW_CONTROLLER_H__
-#define __CICO_SC_WINDOW_CONTROLLER_H__
-
-#include <vector>
-#include <map>
-
-using namespace std;
-
-#include "CicoSCWlWinMgrIF.h"
-
-#define ICO_SC_APPID_DEFAULT_ONS "org.tizen.ico.onscreen"
-#define ICO_SC_LAYERID_SCREENBASE 1000
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCCommand;
-class CicoSCDisplay;
-class CicoSCLayer;
-class CicoSCDisplayZone;
-class CicoSCWindow;
-class CicoSCResourceManager;
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class is controller of window
- */
-//--------------------------------------------------------------------------
-class CicoSCWindowController : public CicoSCWlWinMgrIF
-{
-public:
- // get instance of CicoSCWindowController
- static CicoSCWindowController* getInstance();
-
- // default constructor
- CicoSCWindowController();
-
- // copy constructor
- virtual ~CicoSCWindowController();
-
- int initDB(void);
-
- void handleCommand(const CicoSCCommand * cmd);
-
- //
- void setResourceManager(CicoSCResourceManager *resMgr);
-
- int show(int surfaceid,
- const char *animation,
- int animationTime);
-
- int hide(int surfaceid,
- const char *animation,
- int animationTime);
-
- int resize(int surfaceid,
- int w,
- int h,
- const char *animation,
- int animationTime);
-
- int move(int surfaceid,
- int nodeid,
- int x,
- int y,
- const char *animation,
- int animationTime);
-
- int setGeometry(int surfaceid,
- int nodeid,
- int layerid,
- int x,
- int y,
- int w,
- int h,
- const char *resizeAnimation,
- int resizeAnimationTime,
- const char *moveAnimation,
- int moveAnimationTime);
-
- int setGeometry(int surfaceid,
- const char *zone,
- int layerid,
- const char *resizeAnimation,
- int resizeAnimationTime,
- const char *moveAnimation,
- int moveAnimationTime);
-
- int raise(int surfaceid,
- const char *animation,
- int animationTime);
-
- int lower(int surfaceid, const char *animation, int animationTime);
-
- int setWindowAnimation(int surfaceid, int type, const char *animation, int time);
-
- int setWindowLayer(int surfaceid, int layerid);
-
- int showLayer(int displayid, int layerid);
-
- int hideLayer(int displayid, int layerid);
-
- int active(int surfaceid, int target);
-
- int setmapGet(int surfaceid, const char *filepath);
-
- int mapSurface(int surfaceid, int framerate, const char *filepath);
-
- int unmapSurface(int surfaceid);
-
- int getDisplayedWindow(int zoneid);
-
- int setAttributes(int surfaceid);
-
- void initializeGeniviLMS(void);
-
- static void wlGeniviLayerNotification(t_ilm_layer layer,
- struct ilmLayerProperties *LayerProperties,
- t_ilm_notification_mask mask);
- //
- virtual void activeCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t select);
-
- virtual void mapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format);
-
- virtual void updateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int visible,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height);
-
- virtual void destroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid);
-
- virtual void updateWinnameCB(uint32_t surfaceid,
- const char *winname);
-//
- virtual void outputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform);
-
- virtual void outputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh);
-
- virtual void createSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title);
-
- const CicoSCWindow* findWindowObj(int32_t pid, uint32_t surfaceid) const;
-
- const CicoSCResourceManager* getResourceManager(void) const;
-
-private:
- // assignment operator
- CicoSCWindowController& operator=(const CicoSCWindowController &object);
-
- // copy constructor
- CicoSCWindowController(const CicoSCWindowController &object);
-
- // find window object by surface id
- CicoSCWindow* findWindow(int surfaceid);
-
- // find layer object by display id and layer id
- CicoSCLayer* findLayer(int displayid, int layerid);
-
- // fine display zone by id
- const CicoSCDisplayZone * findDisplayZone(int zoneid);
-
- void raiselower(CicoSCWindow *window, bool raise);
-
- int notifyResourceManager(int surfaceid,
- const char *zone,
- int layerid,
- const char *animation,
- int animationTime);
-
-private:
- /// my instance
- static CicoSCWindowController *ms_myInstance;
-
- // resource manager instance
- CicoSCResourceManager *m_resMgr;
-
- // window object list
- map<unsigned int, CicoSCWindow*> m_windowList;
-
- // display object list
- vector<CicoSCDisplay*> m_displayList;
-
- // total of physical display
- unsigned int m_physicalDisplayTotal;
-};
-#endif // __CICO_SC_WINDOW_CONTROLLER_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full tWlExt of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWlInputMgrIF.cpp
- *
- * @brief This file implementation of CicoSCInputDev class
- */
-//==========================================================================
-
-#include <cstring>
-
-#include <string>
-using namespace std;
-
-#include "CicoSCWlInputMgrIF.h"
-#include "CicoSCWayland.h"
-#include "CicoLog.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWlInputMgrIF::CicoSCWlInputMgrIF()
- : m_inputmgr(NULL), m_exinput(NULL), m_inputmgrdev(NULL)
-{
- // ico_exinput listener
- m_exInputListener.capabilities = wlCapabilitiesCB;
- m_exInputListener.code = wlCodeCB;
- m_exInputListener.input = wlInputCB;
-
- // ico_input_mgr_device listener
- m_devListener.input_regions = wlRegionCB;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWlInputMgrIF::~CicoSCWlInputMgrIF()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize ico_input_mgr interfaces
- *
- * @param [in] data user data
- * @param [in] registry wayland registry
- * @param [in] name wayland display id
- * @parma [in] interface wayland interface name
- * @parma [in] version wayland interface version number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version)
-{
- ICO_TRA("CicoSCWlInputMgrIF::initInterface : Enter(interface=%s)",
- interface);
-
- if (0 == strcmp(interface, ICO_WL_INPUT_MGR_CTRL_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ico_input_mgr_control_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.", interface);
- ICO_TRA("CicoSCWlInputMgrIF::initInterface Leave",
- "(binding failed)");
- return;
- }
- m_inputmgr = (struct ico_input_mgr_control*)wlProxy;
- }
- else if (0 == strcmp(interface, ICO_WL_EXINPUT_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ico_exinput_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.", interface);
- ICO_TRA("CicoSCWlInputMgrIF::initInterface Leave",
- "(binding failed)");
- return;
- }
-
- m_exinput = (struct ico_exinput*)wlProxy;
- ico_exinput_add_listener(m_exinput,
- &m_exInputListener,
- this);
- }
- else if (0 == strcmp(interface, ICO_WL_INPUT_MGR_DEV_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ico_input_mgr_device_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.", interface);
- ICO_TRA("CicoSCWlInputMgrIF::initInterface Leave"
- "(binding failed)");
- return;
- }
-
- m_inputmgrdev = (struct ico_input_mgr_device*)wlProxy;
- ico_input_mgr_device_add_listener(m_inputmgrdev,
- &m_devListener,
- this);
- }
-
- if ((NULL != m_inputmgrdev) &&
- (NULL != m_inputmgr) &&
- (NULL != m_exinput)) {
- m_initialized = true;
- }
- ICO_TRA("CicoSCWlInputMgrIF::initInterface Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function ico_input_mgr_control_add_input_app
- *
- * @param [in] appid application id
- * @param [in] device input device name
- * @param [in] input input number
- * @parma [in] fix fixed assign flag
- * @parma [in] keycode assigned keycode value
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::addInputApp(const string &appid,
- const string &device,
- int input,
- int fix,
- int keycode)
-{
- ICO_DBG("called: ico_input_mgr_control_add_input_app"
- "(appid=%s device=%s input=%d fix=%d keycode=%d)",
- appid.c_str(), device.c_str(), input, fix, keycode);
- ico_input_mgr_control_add_input_app(m_inputmgr,appid.c_str(),
- device.c_str(), input, fix, keycode);
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function ico_input_mgr_control_del_input_app
- *
- * @param [in] appid application id
- * @param [in] device input device name
- * @param [in] input input number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::delInputApp(const string &appid,
- const string &device,
- int input)
-{
- ICO_DBG("called: ico_input_mgr_control_del_input_app"
- "(appid=%s device=%s input=%d)",
- appid.c_str(), device.c_str(), input);
- ico_input_mgr_control_del_input_app(m_inputmgr, appid.c_str(),
- device.c_str(), input);
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function ico_exinput_set_input_region
- *
- * @param [in] target target window name(winname@appid)
- * @param [in] x region x positon
- * @param [in] y region y positon
- * @param [in] width region width
- * @param [in] height region height
- * @param [in] hotspot_x hotspot x position
- * @param [in] hotspot_y hotspot y position
- * @param [in] cursor_x cursor x position
- * @param [in] cursor_y cursor y position
- * @param [in] cursor_width cursor width
- * @param [in] cursor_height cursor height
- * @param [in] attr region attribute
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::setInputRegion(const string &target,
- int x,
- int y,
- int width,
- int height,
- int hotspot_x,
- int hotspot_y,
- int cursor_x,
- int cursor_y,
- int cursor_width,
- int cursor_height,
- int attr)
-{
- ICO_DBG("called: ico_exinput_set_input_region"
- "(target=%s x/y=%d/%d w/h=%d/%d hot=%d/%d "
- "cursor=%d/%d-%d/%d attr=%d)",
- target.c_str(), x, y, width, height, hotspot_x, hotspot_y,
- cursor_x, cursor_y, cursor_width, cursor_height, attr);
- ico_exinput_set_input_region(m_exinput, target.c_str(), x, y,
- width, height, hotspot_x, hotspot_y, cursor_x,
- cursor_y, cursor_width, cursor_height,attr);
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function ico_exinput_unset_input_region
- *
- * @param [in] target target window name(winname@appid)
- * @param [in] x region x positon
- * @param [in] y region y positon
- * @param [in] width region width
- * @param [in] height region height
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::unsetInputRegion(const string &target,
- int x,
- int y,
- int width,
- int height)
-{
- ICO_DBG("called: ico_exinput_unset_input_region"
- "(target=%s x=%d y=%d width=%d height=%d",
- target.c_str(), x, y, width, height);
- ico_exinput_unset_input_region(m_exinput, target.c_str(),
- x, y, width, height);
- // flush display
- CicoSCWayland::getInstance()->flushDisplay();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input switch information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] type input device type (as enum type)
- * @param [in] swname input switch name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::capabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code)
-{
- ICO_WRN("CicoSCWlInputMgrIF::capabilitiesCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input code information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::codeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code)
-{
- ICO_WRN("CicoSCWlInputMgrIF::codeCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for switch input
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] time input time of millisecond
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] code input switch code
- * @param [in] state Of/Off status
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::inputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state)
-{
- ICO_WRN("CicoSCWlInputMgrIF::inputCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for change input region
- *
- * @param [in] data user data
- * @param [in] ico_input_mgr_dev wayland ico_exinput interface
- * @param [in] region input regions
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::regionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_dev,
- struct wl_array *region)
-{
- ICO_WRN("CicoSCWlInputMgrIF::regionCB called.");
-}
-
-//==========================================================================
-// private method
-//==========================================================================
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input switch information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] type input device type (as enum type)
- * @param [in] swname input switch name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::wlCapabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code)
-{
-// ICO_TRA("CicoSCWlInputMgrIF::wlCapabilitiesCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlCapabilitiesCB: data is null");
- return;
- }
- static_cast<CicoSCWlInputMgrIF*>(data)->capabilitiesCB(data, ico_exinput,
- device, type,
- swname, input,
- codename, code);
-// ICO_TRA("CicoSCWlInputMgrIF::wlCapabilitiesCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for input code information
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] codename input code name
- * @param [in] code input code number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::wlCodeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code)
-{
-// ICO_TRA("CicoSCWlInputMgrIF::wlCodeCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlCodeCB: data is null");
- return;
- }
- static_cast<CicoSCWlInputMgrIF*>(data)->codeCB(data, ico_exinput,
- device, input,
- codename, code);
-
-// ICO_TRA("CicoSCWlInputMgrIF::wlCodeCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for switch input
- *
- * @param [in] data user data
- * @param [in] ico_exinput wayland ico_exinput interface
- * @param [in] time input time of millisecond
- * @param [in] device input device name
- * @param [in] input input switch number
- * @param [in] code input switch code
- * @param [in] state Of/Off status
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::wlInputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state)
-{
-// ICO_TRA("CicoSCWlInputMgrIF::wlInputCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlInputCB: data is null");
- return;
- }
- static_cast<CicoSCWlInputMgrIF*>(data)->inputCB(data, ico_exinput,
- time, device, input,
- code, state);
-
-// ICO_TRA("CicoSCWlInputMgrIF::wlInputCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback to application for change input region
- *
- * @param [in] data user data
- * @param [in] ico_input_mgr_dev wayland ico_exinput interface
- * @param [in] region input regions
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlInputMgrIF::wlRegionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_dev,
- struct wl_array *region)
-{
-// ICO_TRA("CicoSCWlInputMgrIF::wlRegionCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlRegionCB: data is null");
- return;
- }
- static_cast<CicoSCWlInputMgrIF*>(data)->regionCB(data, ico_input_mgr_dev,
- region);
-
-// ICO_TRA("CicoSCWlInputMgrIF::wlRegionCB Leave");
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full tWlExt of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWlInputMgrIF.cpp
- *
- * @brief This file is definition of CicoSCInputDevConf class
- */
-//==========================================================================
-#ifndef __CICO_SC_WL_INPUT_MGR_IF_H__
-#define __CICO_SC_WL_INPUT_MGR_IF_H__
-
-#include <string>
-#include <ico-uxf-weston-plugin/ico_input_mgr-client-protocol.h>
-#include "CicoSCWaylandIF.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class is wayland interface of multi input manager
- */
-//--------------------------------------------------------------------------
-class CicoSCWlInputMgrIF : public CicoSCWaylandIF
-{
-public:
- // initialize interface
- void initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version);
-
- // capabilities callback function
- void capabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // code callback function
- void codeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // input callback function
- void inputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state);
-
- // region callback function
- void regionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_device,
- struct wl_array *region);
-
-protected:
- // default constructor
- CicoSCWlInputMgrIF();
-
- // destructor
- virtual ~CicoSCWlInputMgrIF();
-
- // assignment operator
- CicoSCWlInputMgrIF& operator=(const CicoSCWlInputMgrIF &object);
-
- // copy constructor
- CicoSCWlInputMgrIF(const CicoSCWlInputMgrIF &object);
-
- // wrapper function ico_input_mgr_control_add_input_app
- void addInputApp(const std::string &appid,
- const std::string &device,
- int input,
- int fix,
- int keycode);
-
- // wrapper function ico_input_mgr_control_del_input_app
- void delInputApp(const std::string &appid,
- const std::string &device,
- int input);
-
- // wrapper function ico_exinput_set_input_region
- void setInputRegion(const std::string &target,
- int x,
- int y,
- int width,
- int height,
- int hotspot_x,
- int hotspot_y,
- int cursor_x,
- int cursor_y,
- int cursor_width,
- int cursor_height,
- int attr);
-
- // wrapper function ico_exinput_unset_input_region
- void unsetInputRegion(const std::string &target,
- int x,
- int y,
- int width,
- int height);
-
-private:
- // ico_input_mgr(Multi Input Manager) callback functions
-
- // wayland capabilities callback function
- static void wlCapabilitiesCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t type,
- const char *swname,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // wayland code callback function
- static void wlCodeCB(void *data,
- struct ico_exinput *ico_exinput,
- const char *device,
- int32_t input,
- const char *codename,
- int32_t code);
-
- // wayland input callback function
- static void wlInputCB(void *data,
- struct ico_exinput *ico_exinput,
- uint32_t time,
- const char *device,
- int32_t input,
- int32_t code,
- int32_t state);
-
- // wayland region callback function
- static void wlRegionCB(void *data,
- struct ico_input_mgr_device *ico_input_mgr_device,
- struct wl_array *region);
-
-protected:
- // input manager interface
- struct ico_input_mgr_control *m_inputmgr;
-
- // extra input event interface
- struct ico_exinput *m_exinput;
-
- // input manage device interface
- struct ico_input_mgr_device *m_inputmgrdev;
-
-private:
- // exinput listener
- struct ico_exinput_listener m_exInputListener;
-
- // input manager device listener
- struct ico_input_mgr_device_listener m_devListener;
-
-};
-#endif // __CICO_SC_WL_INPUT_MGR_IF_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWlWinMgrIF.cpp
- *
- * @brief This file implementation of CicoSCWlInputMgrIF class
- */
-//==========================================================================
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <cstring>
-
-#include "ico_syc_type.h"
-#include "CicoSCWlWinMgrIF.h"
-#include "CicoSCWayland.h"
-#include "CicoLog.h"
-#include "CicoSystemConfig.h"
-#include "CicoConf.h"
-#include "CicoSCWindowController.h"
-
-//==========================================================================
-// static variables
-//==========================================================================
-struct ico_window_mgr *CicoSCWlWinMgrIF::m_winmgr = NULL;
-struct ivi_application *CicoSCWlWinMgrIF::m_ivi_app = NULL;
-struct ivi_controller *CicoSCWlWinMgrIF::m_ivi_ctrl = NULL;
-struct wl_output *CicoSCWlWinMgrIF::m_wloutput = NULL;
-
-int CicoSCWlWinMgrIF::m_id_surface = 0;
-
-struct creation_surface_wait *CicoSCWlWinMgrIF::m_wait_surface_creation = NULL;
-struct creation_surface_wait *CicoSCWlWinMgrIF::m_free_surface_creation = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSCWlWinMgrIF::CicoSCWlWinMgrIF()
-{
- // ico_window_mgr listener
- m_listener.window_active = wlActiveCB;
- m_listener.map_surface = wlMapSurfaceCB;
- m_listener.update_surface = wlUpdateSurfaceCB;
- m_listener.destroy_surface = wlDestroySurfaceCB;
-
- // genivi ivi_application listener
- m_ivi_app_listener.wl_shell_info = wlIviAppNativeShellInfoCB;
-
- // genivi ivi_controller listener
- m_ivi_ctrl_listener.screen = wlIviCtrlScreenCB;
- m_ivi_ctrl_listener.layer = wlIviCtrlLayerCB;
- m_ivi_ctrl_listener.surface = wlIviCtrlSurfaceCB;
- m_ivi_ctrl_listener.error = wlIviCtrlErrorCB;
- m_ivi_ctrl_listener.native_handle = wlIviCtrlNativeHandleCB;
-
- // wayland output listener
- m_wlOutputListener.geometry = wlOutputGeometryCB;
- m_wlOutputListener.mode = wlOutputModeCB;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSCWlWinMgrIF::~CicoSCWlWinMgrIF()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief initialize ico_window_mgr interfaces
- *
- * @param [in] data user data
- * @param [in] registry wayland registry
- * @param [in] name wayland display id
- * @parma [in] interface wayland interface name
- * @parma [in] version wayland interface version number
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version)
-{
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Enter(interface=%s)", interface);
-
- // check interface name
- if (0 == strcmp(interface, ICO_WL_WIN_MGR_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ico_window_mgr_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.",
- interface);
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
- return;
- }
-
-
- m_winmgr = (struct ico_window_mgr *)wlProxy;
- ico_window_mgr_add_listener(m_winmgr,
- &m_listener,
- this);
- }
- else if (0 == strcmp(interface, ICO_WL_IVI_APPLICATION_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind for ivi_application");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ivi_application_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.",
- interface);
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
- return;
- }
- m_ivi_app = (struct ivi_application *)wlProxy;
- ivi_application_add_listener(m_ivi_app,
- &m_ivi_app_listener,
- this);
- }
- else if (0 == strcmp(interface, ICO_WL_IVI_CONTROLLER_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind for ivi_controller");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &ivi_controller_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.",
- interface);
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
- return;
- }
- m_ivi_ctrl = (struct ivi_controller *)wlProxy;
- ivi_controller_add_listener(m_ivi_ctrl,
- &m_ivi_ctrl_listener,
- this);
- }
- else if (0 == strcmp(interface, ICO_WL_OUTPUT_IF)) {
- // get interface instance
- ICO_DBG("called: wl_registry_bind");
- void *wlProxy = wl_registry_bind(registry,
- name,
- &wl_output_interface,
- 1);
- if (NULL == wlProxy) {
- ICO_WRN("interface(%s) wl_registry_bind failed.",
- interface);
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
- return;
- }
-
- m_wloutput = (struct wl_output*)wlProxy;
- wl_output_add_listener(m_wloutput,
- &m_wlOutputListener,
- this);
- }
- else {
- ICO_WRN("unmatch interface");
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(unmatch interface)");
- return;
- }
-
- if((NULL != m_winmgr) && (NULL != m_wloutput)) {
- m_initialized = true;
- }
-
- ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_layerAddSurface
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] layer layer id
- * @param [in] oldlayer old layer id(if 0xffffffff, no old layer)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setWindowLayer(uint32_t surfaceid, uint32_t layer, uint32_t oldlayer)
-{
- // set window layer request to Multi Window Manager
- ICO_DBG("CicoSCWlWinMgrIF::setWindowLayer: "
- "surfaceid=%08x layer=%d->%d", surfaceid, oldlayer, layer);
-
- if (oldlayer == layer) {
- ICO_DBG("CicoSCWlWinMgrIF::setWindowLayer: new layer same as old, NOP");
- return;
- }
-
- // remove original layer
- if (oldlayer <= 0x7fffffff) {
- ICO_TRA("CicoSCWlWinMgrIF::setWindowLayer: remove surface %08x "
- "from layer(%d)", surfaceid, oldlayer);
- if (ilm_layerRemoveSurface(oldlayer, surfaceid) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_layerRemoveSurface(%d,%08x) "
- "Error", oldlayer, surfaceid);
- }
- // must need ilm_commitChanges() after ilm_layerRemoveSurface()
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_commitChanges Error");
- }
- }
- else {
- ICO_TRA("CicoSCWlWinMgrIF::setWindowLayer: surface %08x has no old layer(%d)",
- surfaceid, oldlayer);
- }
-
- // add new layer
- if (ilm_layerAddSurface(layer, surfaceid) != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
- layer, surfaceid);
- }
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_commitChanges Error");
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_surfaceSetDestinationRectangle
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] layer number of layer
- * @param [in] x
- * @param [in] y
- * @param [in] width
- * @param [in] height
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setPositionsize(uint32_t surfaceid, uint32_t node,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- // set position size request to Multi Window Manager
- ICO_DBG("called: ilm_surfaceSetDestinationRectangle"
- "(surfaceid=%08x node=%d x=%d y=%d w=%d h=%d)",
- surfaceid, node, x, y, width, height);
-
- if (ilm_surfaceSetDestinationRectangle(surfaceid, x, y, width, height)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_surfaceSetDestinationRectangle"
- "(%08x,%d,%d,%d,%d) Error", surfaceid, x, y, width, height);
- }
- else if (ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, width, height)
- != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_surfaceSetSourceRectangle"
- "(%08x,0,0,%d,%d) Error", surfaceid, width, height);
- }
- else if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_commitChanges() Error");
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_surfaceSetVisibility
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] visible visible state
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setVisible(uint32_t surfaceid, int32_t visible)
-{
- // set visible request to Multi Window Manager
- ICO_DBG("called: ilm_surfaceSetVisibility(surfaceid=%08x visible=%d)",
- surfaceid, visible);
- if ((visible == ICO_SYC_WIN_VISIBLE_SHOW) || (visible == ICO_SYC_WIN_VISIBLE_HIDE)) {
- ilm_surfaceSetVisibility(surfaceid, visible);
- if (ilm_commitChanges() != ILM_SUCCESS) {
- ICO_ERR("CicoSCWlWinMgrIF::setVisible: ilm_commitChanges() Error");
- }
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ico_window_mgr_set_animation
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] type transition type
- * @param [in] animation name of animation
- * @param [in] time time of animation
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setAnimation(uint32_t surfaceid, int32_t type,
- const char *animation, int32_t time)
-{
- ICO_DBG("called: ico_window_mgr_set_animation"
- "(surfaceid=%08x type=%d anima=%s time=%d)",
- surfaceid, type, animation, time);
- ico_window_mgr_set_animation(m_winmgr, surfaceid, type, animation, time);
- // need wayland flush for GENIVI layer management
- CicoSCWayland::getInstance()->flushDisplay();
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_SetKeyboardFocusOn
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] active flags or active device(unused)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setActive(uint32_t surfaceid, int32_t active)
-{
- ICO_DBG("called: ilm_SetKeyboardFocusOn"
- "(surfaceid=%08x active=%d)", surfaceid, active);
- if ((ilm_SetKeyboardFocusOn(surfaceid) != ILM_SUCCESS) ||
- (ilm_commitChanges() != ILM_SUCCESS)) {
- ICO_ERR("CicoSCWlWinMgrIF::setActive ilm_SetKeyboardFocusOn(%08x) Error", surfaceid);
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_layerSetVisibility
- *
- * @param [in] surfaceid wayland surface id
- * @param [in] layer id of layer
- * @param [in] visible visible state
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setLayerVisible(uint32_t layer, int32_t visible)
-{
- ICO_DBG("called: ilm_layerSetVisibility"
- "(layer=%d visible=%d)", layer, visible);
- if ((ilm_layerSetVisibility(layer, visible) != ILM_SUCCESS) ||
- (ilm_commitChanges() != ILM_SUCCESS)) {
- ICO_ERR("CicoSCWlWinMgrIF::setLayerVisible ilm_layerSetVisibility(%d,%d) Error",
- layer, visible);
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ilm_takeSurfaceScreenshot
- *
- * @param [in] surface id of wayland surface
- * @param [in] filepath surface image pixel file path
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::setmapGet(int surfaceid, const char *filepath)
-{
- ICO_DBG("called: ilm_takeSurfaceScreenshot(filepath=%s,, surface=%08x)",
- filepath ? filepath : "(null)", surfaceid);
- if ((ilm_takeSurfaceScreenshot(filepath, surfaceid) != ILM_SUCCESS) ||
- (ilm_commitChanges() != ILM_SUCCESS)) {
- ICO_ERR("CicoSCWlWinMgrIF::setmapGet ilm_takeSurfaceScreenshot(%s,%x) Error",
- filepath ? filepath : "(null)", surfaceid);
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ico_window_mgr_map_surface
- *
- * @param [in] surface id of wayland surface
- * @param [in] framerate interval of changed notify[frame per second]
- * @param [in] filepath surface image pixel file path
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::mapSurface(uint32_t surfaceid, int32_t framerate, const char *filepath)
-{
- ICO_DBG("called: ico_window_mgr_map_surface(surfaceid=%08x framerate=%d file=%s)",
- surfaceid, framerate, filepath ? filepath : "(null)");
- // currently GENIVI genivi-shell not support contents change, so use ico_window_mgr
- if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
- ico_window_mgr_map_surface(m_winmgr, surfaceid, framerate, filepath);
- }
- else {
- ico_window_mgr_map_surface(m_winmgr, surfaceid, framerate, " ");
- }
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wrapper function of ico_window_mgr_unmap_surface
- *
- * @param [in] surface id of wayland surface
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::unmapSurface(uint32_t surfaceid)
-{
- ICO_DBG("called: ico_window_mgr_unmap_surface"
- "(surfaceid=%08x)", surfaceid);
- // currently GENIVI genivi-shell not support contents change, so use ico_window_mgr
- ico_window_mgr_unmap_surface(m_winmgr, surfaceid);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get creation surface window name(title) and pid
- *
- * @param [in] id_surface surface id
- * @param [out] pid application process id
- */
-//--------------------------------------------------------------------------
-const char *
-CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(uint32_t id_surface, int *pid)
-{
- struct creation_surface_wait *tp = m_wait_surface_creation;
-
- while (tp) {
- if (tp->id_surface == id_surface) {
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(%x) pid=%d title=<%s>",
- id_surface, tp->pid, tp->title);
- *pid = tp->pid;
- return tp->title;
- }
- tp = tp->next;
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(%x) dose not exist", id_surface);
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief remove surface window
- *
- * @param [in] id_surface surface id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(uint32_t id_surface)
-{
- struct creation_surface_wait *tp = m_wait_surface_creation;
- struct creation_surface_wait *bp = NULL;
-
- while (tp) {
- if (tp->id_surface == id_surface) {
- if (bp) {
- bp->next = tp->next;
- }
- else {
- m_wait_surface_creation = tp->next;
- }
- tp->next = m_free_surface_creation;
- m_free_surface_creation = tp;
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(%x) removed", id_surface);
- return;
- }
- bp = tp;
- tp = tp->next;
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(%x) dose not exist", id_surface);
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland surface active callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid ico_window_mgr surface Id
- * @param [in] select select device(unused)
- * (0=not active/1=pointer/2=touch)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::activeCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t select)
-{
- ICO_WRN("CicoSCWlWinMgrIF::activeCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface map event callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] event event
- * @param [in] surfaceid surface Id
- * @param [in] type surface buffer type(EGL buffer/Shared memory)
- * @param [in] width surface width
- * @param [in] height surface height
- * @param [in] stride surface buffer(frame buffer) stride
- * @param [in] format surface buffer format
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::mapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format)
-{
- ICO_WRN("CicoSCWlWinMgrIF::mapSurfaceCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface update event callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid surface Id
- * @param [in] visible visibility
- * @param [in] srcwidth application buffer width
- * @param [in] srcheight application buffer height
- * @param [in] x X
- * @param [in] y Y
- * @param [in] width width
- * @param [in] height height
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::updateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int visible,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height)
-{
- ICO_WRN("CicoSCWlWinMgrIF::updateSurfaceCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland surface destroy callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid surface Id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::destroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid)
-{
- ICO_WRN("CicoSCWlWinMgrIF::destroySurfaceCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland update surface name callback
- *
- * @param [in] surfaceid surface Id
- * @param [in] winname surface name (title)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::updateWinnameCB(uint32_t surfaceid,
- const char *winname)
-{
- ICO_WRN("CicoSCWlWinMgrIF::updateWinnameCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display attribute callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] x display upper-left X coordinate
- * @param [in] y display upper-left Y coordinate
- * @param [in] physical_width display physical width
- * @param [in] physical_height display physical height
- * @param [in] subpixel display sub pixel
- * @param [in] make display maker
- * @param [in] model display model
- * @param [in] transform transform
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::outputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform)
-{
- ICO_WRN("CicoSCWlWinMgrIF::outputGeometryCB called.");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display mode callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] flags flags
- * @param [in] width display width
- * @param [in] height display height
- * @param [in] refresh display refresh rate
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::outputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh)
-{
- ICO_WRN("CicoSCWlWinMgrIF::outputModeCB called.");
-};
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland genivi ivi-surface create callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller plugin interface
- * @param [in] id_surface surface id
- * @param [in] pid surface creator process id
- * @param [in] title surface title
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::createSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title)
-{
- ICO_WRN("CicoSCWlWinMgrIF::createSurfaceCB called.");
-}
-
-//==========================================================================
-// private method
-//==========================================================================
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland surface active callback
- *
- * @param [in] data user data(unused)
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid ico_window_mgr surface Id
- * @param [in] select select device(unused)
- * (0=not active/1=pointer/2=touch)
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlActiveCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t select)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlActiveCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlActiveCB: data is null");
- return;
- }
- static_cast<CicoSCWlWinMgrIF*>(data)->activeCB(data, ico_window_mgr,
- surfaceid, select);
-// ICO_TRA("CicoSCWlWinMgrIF::wlActiveCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface map event callback
- *
- * @param [in] data user data
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] event event
- * @param [in] surfaceid surface Id
- * @param [IN] type buffer type(fixed ICO_WINDOW_MGR_MAP_TYPE_EGL)
- * @param [in] width surface width
- * @param [in] height surface height
- * @param [in] stride surface buffer(frame buffer) stride
- * @param [in] format surface buffer format
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlMapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlMapSurfaceCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlMapSurfaceCB: data is null");
- return;
- }
- static_cast<CicoSCWlWinMgrIF*>(data)->mapSurfaceCB(data, ico_window_mgr,
- event, surfaceid,
- type,
- width, height,
- stride, format);
-// ICO_TRA("CicoSCWlWinMgrIF::wlMapSurfaceCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface update event callback
- *
- * @param [in] data user data
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid surface Id
- * @param [in] visible visibility
- * @param [in] srcwidth application buffer width
- * @param [in] srcheight application buffer height
- * @param [in] x X
- * @param [in] y Y
- * @param [in] width width
- * @param [in] height height
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlUpdateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int visible,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlUpdateSurfaceCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlUpdateSurfaceCB: data is null");
- return;
- }
- static_cast<CicoSCWlWinMgrIF*>(data)->updateSurfaceCB(data, ico_window_mgr,
- surfaceid, visible,
- srcwidth, srcheight,
- x, y, width, height);
-// ICO_TRA("CicoSCWlWinMgrIF::wlUpdateSurfaceCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief surface destroy event callback
- *
- * @param [in] data user data
- * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
- * @param [in] surfaceid surface Id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlDestroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlDestroySurfaceCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlDestroySurfaceCB: data is null");
- return;
- }
- wlIviCtrlRemoveSurface(surfaceid);
-
- static_cast<CicoSCWlWinMgrIF*>(data)->destroySurfaceCB(data, ico_window_mgr,
- surfaceid);
-// ICO_TRA("CicoSCWlWinMgrIF::wlDestroySurfaceCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display attribute callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] x display upper-left X coordinate
- * @param [in] y display upper-left Y coordinate
- * @param [in] physical_width display physical width
- * @param [in] physical_height display physical height
- * @param [in] subpixel display sub pixel
- * @param [in] make display maker
- * @param [in] model display model
- * @param [in] transform transform
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlOutputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlOutputGeometryCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlOutputGeometryCB: data is null");
- return;
- }
- static_cast<CicoSCWlWinMgrIF*>(data)->outputGeometryCB(data, wl_output,
- x, y,
- physical_width,
- physical_height,
- subpixel,
- make,
- model,
- transform);
-// ICO_TRA("CicoSCWlWinMgrIF::wlOutputGeometryCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland display mode callback
- *
- * @param [in] data user data(unused)
- * @param [in] wl_output wayland wl_output interface
- * @param [in] flags flags
- * @param [in] width display width
- * @param [in] height display height
- * @param [in] refresh display refresh rate
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlOutputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh)
-{
-// ICO_TRA("CicoSCWlWinMgrIF::wlOutputModeCB Enter");
-
- if (NULL == data) {
- ICO_WRN("wlOutputGeometryCB: data is null");
- return;
- }
- static_cast<CicoSCWlWinMgrIF*>(data)->outputModeCB(data, wl_output, flags,
- width, height, refresh);
-// ICO_TRA("CicoSCWlWinMgrIF::wlOutputModeCB Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-application protocol create wl_surface callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_application wayland ivi-application interface
- * @param [in] pid application process id
- * @param [in] title surface title name
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB(void *data,
- struct ivi_application *ivi_application,
- int32_t pid, const char *title,
- uint32_t id_surface)
-{
- struct creation_surface_wait *tp;
- struct creation_surface_wait *tp2;
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Enter(%d,<%s>,%08x)",
- pid, title ? title : "(null)", id_surface);
-
- if (id_surface != 0) {
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(%08x is ivi-surface)",
- id_surface);
- return;
- }
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(data is null)");
- return;
- }
- if (title == NULL) {
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(no title)");
- return;
- }
-
- // if same pid and same title, skip
- tp = m_wait_surface_creation;
- while (tp) {
- if ((tp->pid == pid) && (strcmp(tp->title, title) == 0)) {
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(same title)");
- return;
- }
- tp = tp->next;
- }
-
- // get native surface info
- tp = m_free_surface_creation;
- if (tp) {
- m_free_surface_creation = tp->next;
- }
- else {
- tp = (struct creation_surface_wait *)malloc(sizeof(struct creation_surface_wait));
- if (! tp) {
- ICO_ERR("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: out of memory");
- return;
- }
- }
- memset(tp, 0, sizeof(struct creation_surface_wait));
- tp->next = m_wait_surface_creation;
- tp->pid = pid;
- strncpy(tp->title, title, ICO_SYC_MAX_WINNAME_LEN-1);
- tp->busy = SCWINMGR_GENIVI_BUSY_WAIT;
- tp2 = m_wait_surface_creation;
- while (tp2) {
- if (tp2->busy != SCWINMGR_GENIVI_BUSY_NONE) break;
- tp2 = tp2->next;
- }
- m_wait_surface_creation = tp;
- if (! tp2) {
- tp->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: "
- "call ivi_controller_get_native_handle(%d,<%s>)", pid, title);
- ivi_controller_get_native_handle(m_ivi_ctrl, pid, title);
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-controller protocol create screen callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller interface
- * @param [in] id_screen screen id
- * @param [in] screen screen information
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlScreenCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_screen,
- struct ivi_controller_screen *screen)
-{
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: Enter(%x)", id_screen);
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: data is null");
- return;
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-controller protocol create layer callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller interface
- * @param [in] id_layer layer id
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlLayerCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_layer)
-{
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: Enter(%x)", id_layer);
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: data is null");
- return;
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-controller protocol create surface callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller interface
- * @param [in] id_surface surface id
- * @param [in] pid surface creator process id
- * @param [in] title surface title
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title)
-{
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: Enter(%x)", id_surface);
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: data is null");
- return;
- }
-
- static_cast<CicoSCWlWinMgrIF*>(data)->
- createSurfaceCB(data, ivi_controller, id_surface, pid, title);
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-controller protocol error callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller interface
- * @param [in] error_code error code
- * @param [in] error_text error message
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlErrorCB(void *data,
- struct ivi_controller *ivi_controller,
- int32_t object_id, int32_t object_type,
- int32_t error_code, const char *error_text)
-{
- struct creation_surface_wait *tp;
- struct creation_surface_wait *tp2;
- struct creation_surface_wait *deltp;
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: Enter(%d[%d],%d,<%s>)",
- object_id, object_type, error_code, error_text ? error_text : "(null)");
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: data is null");
- return;
- }
-
- // search request wait
- tp = m_wait_surface_creation;
- tp2 = NULL;
- deltp = NULL;
- while (tp) {
- if (tp->busy == SCWINMGR_GENIVI_BUSY_WAIT) {
- tp2 = tp;
- }
- else if (tp->busy == SCWINMGR_GENIVI_BUSY_REQSURF) {
- deltp = tp;
- }
- else if (tp->busy != SCWINMGR_GENIVI_BUSY_NONE) {
- tp->busy = SCWINMGR_GENIVI_BUSY_NONE;
- }
- tp = tp->next;
- }
- if (deltp) {
- if (m_wait_surface_creation == deltp) {
- m_wait_surface_creation = deltp->next;
- }
- else {
- tp = m_wait_surface_creation;
- while(tp->next != deltp) {
- tp = tp->next;
- }
- if (tp) {
- tp->next = deltp->next;
- }
- }
- deltp->next = m_free_surface_creation;
- m_free_surface_creation = deltp;
- }
- if (tp2 != NULL) {
- tp2->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: "
- "call ivi_controller_get_native_handle(%d,<%s>)", tp2->pid, tp2->title);
- ivi_controller_get_native_handle(m_ivi_ctrl, tp2->pid, tp2->title);
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief wayland ivi-shell ivi-controller protocol native handle callback
- *
- * @param [in] data user data(unused)
- * @param [in] ivi_controller wayland ivi-controller interface
- * @param [in] surface weston_surface object
- */
-//--------------------------------------------------------------------------
-void
-CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB(void *data,
- struct ivi_controller *ivi_controller,
- struct wl_surface *surface)
-{
- struct creation_surface_wait *tp;
- struct creation_surface_wait *tp2;
- struct creation_surface_wait *tp3;
- struct creation_surface_wait *bp;
- uint32_t id_surface;
- int surface_count;
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Enter(surf=%p)", (void *)surface);
-
- if (NULL == data) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(data is null)");
- return;
- }
-
- // check same surface
- tp = m_wait_surface_creation;
- bp = NULL;
- while (tp) {
- if (tp->busy == SCWINMGR_GENIVI_BUSY_REQSURF) break;
- bp = tp;
- tp = tp->next;
- }
- if (! tp) {
- ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(no request)");
- return;
- }
- surface_count = 0;
- tp2 = NULL;
- tp3 = m_wait_surface_creation;
- while (tp3) {
- if ((tp != tp3) && (tp3->pid == tp->pid)) {
- surface_count ++;
- tp2 = tp3;
- }
- tp3 = tp3->next;
- }
- if (surface_count == 1) {
- // title change, delete old table
- id_surface = tp2->id_surface;
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: winname change"
- "(%08x,<%s>)", id_surface, tp->title);
- strcpy(tp2->title, tp->title);
- if (bp) {
- bp->next = tp->next;
- }
- else {
- m_wait_surface_creation = tp->next;
- }
- tp->next = m_free_surface_creation;
- m_free_surface_creation = tp;
-
- static_cast<CicoSCWlWinMgrIF*>(data)->updateWinnameCB(tp2->id_surface, tp2->title);
- }
- else {
- // create ivi-surface and bind to wl_surface
- m_id_surface ++;
- if (m_id_surface >= 0x00ffffff) m_id_surface = 1;
- id_surface = m_id_surface | SCWINMGR_GENIVI_NATIVE_SURFACE_ID;
-
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
- "call ivi_application_surface_create(%08x)", id_surface);
- if (ivi_application_surface_create(m_ivi_app, id_surface, surface) == NULL) {
- ICO_ERR("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
- "ivi_application_surface_create(%08x) Error", id_surface);
- if (bp) {
- bp->next = tp->next;
- }
- else {
- m_wait_surface_creation = tp->next;
- }
- tp->next = m_free_surface_creation;
- m_free_surface_creation = tp;
- }
- else {
- tp->surface = surface;
- tp->id_surface = id_surface;
- tp->busy = SCWINMGR_GENIVI_BUSY_REQBIND;
- }
- }
-
- // search request wait
- tp = m_wait_surface_creation;
- tp2 = NULL;
- while (tp) {
- if (tp->busy == SCWINMGR_GENIVI_BUSY_WAIT) {
- tp2 = tp;
- }
- else if (tp->busy != SCWINMGR_GENIVI_BUSY_NONE) {
- break;
- }
- tp = tp->next;
- }
- if ((tp == NULL) && (tp2 != NULL)) {
- tp2->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
- "call ivi_controller_get_native_handle(%d,<%s>)", tp2->pid, tp2->title);
- ivi_controller_get_native_handle(m_ivi_ctrl, tp2->pid, tp2->title);
- }
- ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(id_surface=%08x)", id_surface);
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSCWlWinMgrIF.h
- *
- * @brief This file is definition of CicoSCWlWinMgrIF class
- */
-//==========================================================================
-#ifndef __CICO_SC_WL_WINMGR_IF_H__
-#define __CICO_SC_WL_WINMGR_IF_H__
-
-#include <wayland-client.h>
-#include <ilm/ilm_client.h>
-#include <ilm/ilm_control.h>
-#include <ico-uxf-weston-plugin/ico_window_mgr-client-protocol.h>
-#include <weston/ivi-controller-client-protocol.h>
-#include <weston/ivi-application-client-protocol.h>
-
-#include "ico_syc_type.h"
-#include "CicoSCWaylandIF.h"
-#include "CicoSCWindow.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief This class is wayland interface of multi window manager
- */
-//--------------------------------------------------------------------------
-#define SCWINMGR_GENIVI_NATIVE_SURFACE_ID 0x40000000
-
-struct creation_surface_wait {
- struct creation_surface_wait *next;
- int32_t pid;
- uint32_t id_surface;
- struct wl_surface *surface;
- int32_t busy;
- char title[ICO_SYC_MAX_WINNAME_LEN];
-};
-#define SCWINMGR_GENIVI_BUSY_NONE 0
-#define SCWINMGR_GENIVI_BUSY_REQSURF 1
-#define SCWINMGR_GENIVI_BUSY_REQBIND 2
-#define SCWINMGR_GENIVI_BUSY_WAIT 3
-
-class CicoSCWlWinMgrIF : public CicoSCWaylandIF {
-public:
- virtual void initInterface(void *data,
- struct wl_registry *registry,
- uint32_t name,
- const char *interface,
- uint32_t version);
-
- virtual void activeCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t select);
-
- virtual void mapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format);
-
- virtual void updateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int visible,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height);
-
- virtual void destroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid);
-
- virtual void updateWinnameCB(uint32_t surfaceid,
- const char *winname);
- //
- virtual void outputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform);
-
- virtual void outputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh);
-
- virtual void createSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title);
-
- static void wlIviCtrlRemoveSurface(uint32_t id_surface);
-
-protected:
- // default constructor
- CicoSCWlWinMgrIF();
-
- // destructor
- virtual ~CicoSCWlWinMgrIF();
-
- // assignment operator
- CicoSCWlWinMgrIF& operator=(const CicoSCWlWinMgrIF &object);
-
- // copy constructor
- CicoSCWlWinMgrIF(const CicoSCWlWinMgrIF &object);
-
- // wrapper function ico_window_mgr_set_window_layer
- void setWindowLayer(uint32_t surfaceid, uint32_t layer, uint32_t oldlayer);
-
- // wrapper function ico_window_mgr_set_positionsize
- void setPositionsize(uint32_t surfaceid, uint32_t node,
- int32_t x, int32_t y, int32_t width, int32_t height);
-
- // wrapper function ico_window_mgr_set_visible
- void setVisible(uint32_t surfaceid, int32_t visible);
-
- // wrapper function of ico_window_mgr_set_animation
- void setAnimation(uint32_t surfaceid, int32_t type,
- const char *animation, int32_t time);
-
- // wrapper function of ico_window_mgr_set_active
- void setActive(uint32_t surfaceid, int32_t active);
-
- // wrapper function of ico_window_mgr_set_layer_visible
- void setLayerVisible(uint32_t layer, int32_t visible);
-
- // wrapper function of ilm_takeSurfaceScreenshot
- void setmapGet(int surfaceid, const char *filepath);
-
- // wrapper function of ico_window_mgr_map_surface
- void mapSurface(uint32_t surfaceid, int32_t framerate, const char *filepath);
-
- // wrapper function of ico_window_mgr_unmap_surface
- void unmapSurface(uint32_t surfaceid);
-
- static const char *wlIviCtrlGetSurfaceWaiting(uint32_t id_surface, int *pid);
-
-private:
- // ico_window_mgr(Multi Window Manager) callback functions
- static void wlActiveCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int32_t active);
-
- static void wlMapSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- int32_t event,
- uint32_t surfaceid,
- uint32_t type,
- int32_t width,
- int32_t height,
- int32_t stride,
- uint32_t format);
-
- static void wlUpdateSurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid,
- int layer,
- int srcwidth,
- int srcheight,
- int x,
- int y,
- int width,
- int height);
-
- static void wlDestroySurfaceCB(void *data,
- struct ico_window_mgr *ico_window_mgr,
- uint32_t surfaceid);
- //
- static void wlOutputGeometryCB(void *data,
- struct wl_output *wl_output,
- int32_t x,
- int32_t y,
- int32_t physical_width,
- int32_t physical_height,
- int32_t subpixel,
- const char *make,
- const char *model,
- int32_t transform);
-
- static void wlOutputModeCB(void *data,
- struct wl_output *wl_output,
- uint32_t flags,
- int32_t width,
- int32_t height,
- int32_t refresh);
-
- static void wlIviAppNativeShellInfoCB(void *data,
- struct ivi_application *ivi_application,
- int32_t pid,
- const char *title,
- uint32_t id_surface);
- static void wlIviCtrlScreenCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_screen,
- struct ivi_controller_screen *screen);
-
- static void wlIviCtrlLayerCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_layer);
-
- static void wlIviCtrlSurfaceCB(void *data,
- struct ivi_controller *ivi_controller,
- uint32_t id_surface,
- int32_t pid,
- const char *title);
-
- static void wlIviCtrlErrorCB(void *data,
- struct ivi_controller *ivi_controller,
- int32_t object_id,
- int32_t object_type,
- int32_t error_code,
- const char *error_text);
-
- static void wlIviCtrlNativeHandleCB(void *data,
- struct ivi_controller *ivi_controller,
- struct wl_surface *surface);
-
-protected:
- // ico_window_mgr listener
- struct ico_window_mgr_listener m_listener;
-
- // wayland output listener
- struct wl_output_listener m_wlOutputListener;
-
- // genivi ivi-application listener
- struct ivi_application_listener m_ivi_app_listener;
-
- // genivi ivi-controller listener
- struct ivi_controller_listener m_ivi_ctrl_listener;
-
- // Wayland's Window Manager PlugIn instance
- static struct ico_window_mgr *m_winmgr;
-
- // Wayland's genivi ivi_application instance
- static struct ivi_application *m_ivi_app;
-
- // Wayland's genivi ivi_controller instance
- static struct ivi_controller *m_ivi_ctrl;
-
- // Wayland's genivi ivi_controller_surface instance
- static struct ivi_controller_surface *m_ivi_ctrl_surf;
-
- // wayland output instance
- static struct wl_output *m_wloutput;
-
- // surface id for wayland/weston applications
- static int m_id_surface;
-
- // creation surface title name
- static struct creation_surface_wait *m_wait_surface_creation;
- static struct creation_surface_wait *m_free_surface_creation;
-};
-#endif // __CICO_SC_WL_WINMGR_IF_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-AM_CPPFLAGS = $(GCC_CXXFLAGS)
-
-noinst_LTLIBRARIES =\
- libico-system-controller.la
-
-#lib_LTLIBRARIES =\
-# libico-system-controller.la
-
-libico_system_controller_la_LDFLAGS = -version-info 0:9:0
-libico_system_controller_la_SOURCES = \
- CicoSCLifeCycleController.cpp \
- CicoSCWaylandIF.cpp \
- CicoSCWayland.cpp \
- CicoSCWlWinMgrIF.cpp \
- CicoSCWindow.cpp \
- CicoSCDisplay.cpp \
- CicoSCLayer.cpp \
- CicoSCDisplayZone.cpp \
- CicoSCWindowController.cpp \
- CicoSCWlInputMgrIF.cpp \
- CicoSCInputDev.cpp \
- CicoSCSwitch.cpp \
- CicoSCInputController.cpp \
- CicoSCServer.cpp \
- CicoSCCommand.cpp \
- CicoSCMessage.cpp \
- CicoSCMessageRes.cpp \
- CicoSCUser.cpp \
- CicoSCUserManager.cpp \
- CicoSCSysResourceController.cpp \
- CicoSCSysResourceMonitor.cpp \
- CicoSCAppResourceController.cpp \
- CicoSCResourceManager.cpp \
- ico_syc_mrp_resource.c \
- CicoSCPolicyManager.cpp \
- CicoSCVInfoManager.cpp
-
-libico_system_controller_la_CPPFLAGS = \
- $(GCC_CXXFLAGS) \
- @ECORE_CFLAGS@ \
- @EINA_CFLAGS@ \
- @GLIB_CFLAGS@ \
- @AIL_CFLAGS@ \
- @BUNDLE_CFLAGS@ \
- @AUL_CFLAGS@ \
- @PKGMGR_CFLAGS@ \
- @WAYLANDCLIENT_CFLAGS@ \
- @CAPIAPPFWAPPLICATION_CFLAGS@ \
- @JSONGLIB_CFLAGS@ \
- @MURPHYCOMMON_CFLAGS@ \
- @MURPHYDOMAINCONTROLLER_CFLAGS@ \
- @MURPHYECORE_CFLAGS@ \
- @MURPHYRESOURCE_CFLAGS@ \
- $(UWS_CFLAGS) \
- -I../../include \
- -I../common \
- -I../misc/state-machine
-
-libico_system_controller_la_LIBADD = \
- ../common/.libs/libico-common.a \
- @ECORE_LIBS@ \
- @EINA_LIBS@ \
- @GLIB_LIBS@ \
- @AIL_LIBS@ \
- @BUNDLE_LIBS@ \
- @AUL_LIBS@ \
- @PKGMGR_LIBS@ \
- @WAYLANDCLIENT_LIBS@ \
- @CAPIAPPFWAPPLICATION_LIBS@ \
- @JSONGLIB_LIBS@ \
- @MURPHYCOMMON_LIBS@ \
- @MURPHYDOMAINCONTROLLER_LIBS@ \
- @MURPHYECORE_LIBS@ \
- @MURPHYRESOURCE_LIBS@ \
- $(UWS_LIBS) \
- $(GENIVI_LIBS) \
- $(WESTONPLUGIN_LIBS)
-
-AM_LDFLAGS = -module -avoid-version -rpath $(libdir)
-
-.FORCE :
-
-# vim:set ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file ico_syc_mrp_resource.c
- *
- * @brief
- */
-//==========================================================================
-
-#include <murphy/common.h>
-#include <murphy/common/ecore-glue.h>
-#include <murphy/domain-control/client.h>
-
-#include <ico_log.h>
-#include "ico_syc_error.h"
-#include "ico_syc_mrp_resource_private.h"
-
-
-static void ico_syc_mrp_resource_cb(mrp_res_context_t *ctx,
- const mrp_res_resource_set_t *rs,
- void *userdata);
-
-static void ico_syc_mrp_state_cb(mrp_res_context_t *ctx,
- mrp_res_error_t err,
- void *userdata);
-
-static void ico_syc_mrp_connect_notify(mrp_domctl_t *dc,int connected,
- int errcode, const char *errmsg,
- void *user_data);
-
-static void ico_syc_mrp_data_notify(mrp_domctl_t *dc,
- mrp_domctl_data_t *tables,
- int ntable, void *user_data);
-
-static mrp_res_queue_item_t *
-ico_syc_mrp_create_queue_item(resource_request_t *req);
-static resource_request_t *
-ico_syc_mrp_find_request(int req_id, char *appid);
-#if 0
-static void ico_syc_mrp_process_input_queue(void);
-static void ico_syc_mrp_process_display_queue(void);
-#endif
-static void ico_syc_mrp_process_sound_queue(void);
-
-/* Murphy resource library */
-static bool mrp_res_connected = FALSE;
-static mrp_res_context_t *mrp_ctx = NULL;
-static mrp_mainloop_t *mrp_ml = NULL;
-static mrp_domctl_t *mrp_dc = NULL;
-
-static mrp_list_hook_t mrp_sound_wait_queue;
-
-static mrp_list_hook_t mrp_reqs;
-
-
-/*
- * tables for inserting and reading data from Murphy
- */
-
-#define ACTIVE_APP_COLUMNS \
- "zone varchar(128)," \
- "appid varchar(128)"
-
-#define ACTIVE_APP_INDEX "zone, appid"
-
-#define DISPLAY_OWNER_SELECT "*"
-#define DISPLAY_OWNER_WHERE NULL
-
-mrp_domctl_table_t ico_tables[] = {
- MRP_DOMCTL_TABLE("active_screen",
- ACTIVE_APP_COLUMNS,
- ACTIVE_APP_INDEX),
-};
-
-mrp_domctl_watch_t ico_watches[] = {
- MRP_DOMCTL_WATCH("display-owner",
- DISPLAY_OWNER_SELECT,
- DISPLAY_OWNER_WHERE, 0),
-};
-
-static ico_syc_mrp_enforce_sound_t ico_syc_mrp_enforce_soundCB = NULL;
-static void *cb_user_data = NULL;
-
-
-/*-------------------------------------------------------------------------*/
-/*
- * public functions
- */
-/*-------------------------------------------------------------------------*/
-int ico_syc_mrp_init(ico_syc_mrp_enforce_sound_t soundcb, void *user_data)
-
-{
-
- ICO_DBG("ico_syc_mrp_init: Enter");
-
- ico_syc_mrp_enforce_soundCB = soundcb;
- cb_user_data = user_data;
-
- mrp_list_init(&mrp_sound_wait_queue);
-
- mrp_list_init(&mrp_reqs);
-
- ICO_DBG("called: mrp_mainloop_ecore_get()");
- mrp_ml = mrp_mainloop_ecore_get();
-
- ICO_DBG("called: mrp_res_connecte()");
- mrp_ctx = mrp_res_create(mrp_ml, ico_syc_mrp_state_cb, NULL);
-
- if (!mrp_ctx) {
- ICO_ERR("ico_syc_mrp_init: Leave(mrp_res_create Error)");
- return ICO_SYC_EIO;
- }
-
- ICO_DBG("called: mrp_domctl_create()");
- mrp_dc = mrp_domctl_create("ico-homescreen", mrp_ml,
- ico_tables, MRP_ARRAY_SIZE(ico_tables),
- ico_watches, MRP_ARRAY_SIZE(ico_watches),
- ico_syc_mrp_connect_notify,
- ico_syc_mrp_data_notify, NULL);
-
- if (mrp_dc == NULL) {
- ICO_ERR("ico_syc_mrp_init: Leave(mrp_domctl_create Error)");
- return ICO_SYC_EIO;
- }
-
- ICO_DBG("called: mrp_domctl_connect()");
- if (!mrp_domctl_connect(mrp_dc, MRP_DEFAULT_DOMCTL_ADDRESS, 0)) {
- ICO_ERR("ico_syc_mrp_init: Leave(mrp_domctl_connect Error)");
- return ICO_SYC_EIO;
- }
-
- return ICO_SYC_EOK;
-}
-
-void ico_syc_mrp_term(void)
-{
- if (NULL != mrp_ctx) {
- mrp_res_destroy(mrp_ctx);
- }
-
- if (NULL != mrp_dc) {
- mrp_domctl_destroy(mrp_dc);
- }
-
- if (NULL != mrp_ml) {
- mrp_mainloop_destroy(mrp_ml);
- }
-}
-
-void
-ico_syc_mrp_add_request(resource_request_t *req)
-{
- /* store the request for Murphy */
- ICO_DBG("ico_syc_mrp_add_request: "
- "add request %p to mrp_reqs list", req);
- mrp_list_init(&req->hook);
- mrp_list_append(&mrp_reqs, &req->hook);
-
-}
-
-void
-ico_syc_mrp_del_request(resource_request_t *req)
-{
- if (NULL == req) {
- return;
- }
-
- resource_request_t *findreq = ico_syc_mrp_find_request(req->id,
- req->appid);
- if (NULL != findreq) {
- if (req->pid != findreq->pid) {
- ICO_DBG("ico_syc_mrp_del_request: pid not match");
- return;
- }
- }
- else {
- ICO_DBG("ico_syc_mrp_del_request: not found in req list");
- return;
- }
-
- ICO_DBG("ico_syc_mrp_del_request: "
- "del request %p to mrp_reqs list", req);
- mrp_list_delete(&req->hook);
-
- if (mrp_ctx && req->rset) {
- mrp_res_release_resource_set(req->rset);
- mrp_res_delete_resource_set(req->rset);
- req->rset = NULL;
- }
-}
-
-bool
-ico_syc_mrp_acquire_sound_resource(resource_request_t *newreq)
-{
- mrp_res_resource_set_t *rs;
-
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: Enter");
-
- resource_request_t *req = ico_syc_mrp_find_request(newreq->id,
- newreq->appid);
- if (NULL == req) {
- ico_syc_mrp_add_request(newreq);
- req = newreq;
- }
-
- if (mrp_ctx) {
- if (!mrp_res_connected) {
- mrp_res_queue_item_t *item;
-
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: "
- "resource context is not connected yet, queueing");
-
- item = ico_syc_mrp_create_queue_item(req);
- mrp_list_append(&mrp_sound_wait_queue, &item->hook);
-
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: Leave(true)");
- return true;
- }
-
- if (!req->rset) {
- int addprio = req->resid & RESID_TYPE_MASK;
- const char *resource_class =
- (addprio == RESID_TYPE_BASIC) ? "basic" : "emergency";
- mrp_res_resource_t *res;
- mrp_res_attribute_t *attr;
-
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: "
- "could not create resource for sound");
-
- ICO_DBG("called: mrp_res_create_resource_set()");
- rs = mrp_res_create_resource_set(mrp_ctx,
- resource_class,
- ico_syc_mrp_resource_cb,
- req);
-
- if (!rs) {
- ICO_ERR("ico_syc_mrp_acquire_sound_resource: "
- "could not create resource set for audio");
- return false;
- }
-
- ICO_DBG("called: mrp_res_set_autorelease()");
- if (!mrp_res_set_autorelease(FALSE, rs)) {
- ICO_ERR("ico_syc_mrp_acquire_sound_resource: "
- "failed to set auto release mode");
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: Leave(false)");
- return false;
- }
-
- ICO_DBG("called: mrp_res_create_resource");
- res = mrp_res_create_resource(rs, "audio_playback", TRUE, FALSE);
-
- if (!res) {
- ICO_ERR("ico_syc_mrp_acquire_sound_resource: "
- "could not create resource for audio");
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: Leave(false)");
- return false;
- }
-
- ICO_DBG("pid=%d category=%d appid=%s priority=%d",
- req->pid, req->category, req->appid, req->prio);
- attr = mrp_res_get_attribute_by_name(res, "pid");
- if (attr && attr->type == mrp_string) {
- char numbuf[16];
- int ret;
-
- ret = snprintf(numbuf, sizeof(numbuf), "%d", req->pid);
-
- if (ret > 0 && (size_t)ret < sizeof(numbuf)) {
- mrp_res_set_attribute_string(attr, numbuf);
- }
- }
- attr = mrp_res_get_attribute_by_name(res, "category");
- if (attr && attr->type == mrp_int32) {
- mrp_res_set_attribute_int(attr, req->category);
- }
-
- attr = mrp_res_get_attribute_by_name(res, "appid");
- if (attr && attr->type == mrp_string) {
- mrp_res_set_attribute_string(attr, req->appid);
- }
-
- attr = mrp_res_get_attribute_by_name(res, "priority");
- if (attr && attr->type == mrp_int32) {
- mrp_res_set_attribute_int(attr, 0/*req->prio*/);
- }
-
- req->rset = rs;
- req->released = 0;
- }
-
- ICO_DBG("called: mrp_res_acquire_resource_set()");
- mrp_res_acquire_resource_set(req->rset);
- }
-
- ICO_DBG("ico_syc_mrp_acquire_sound_resource: Leave(true)");
- return true;
-}
-
-bool
-ico_syc_mrp_release_sound_resource(resource_request_t *req)
-{
- ICO_DBG("ico_syc_mrp_release_sound_resource: Enter");
-
- ico_syc_mrp_del_request(req);
-#if 0
- if (mrp_ctx && req->rset) {
- if (REQTYPE_APP == req->reqtype) {
- mrp_res_release_resource_set(mrp_ctx, req->rset);
- req->released = 1;
- }
- else {
- mrp_res_release_resource_set(mrp_ctx, req->rset);
- mrp_res_delete_resource_set(mrp_ctx, req->rset);
- req->rset = NULL;
- }
- }
-#endif
- ICO_DBG("ico_syc_mrp_release_sound_resource: Leave(true)");
- return true;
-}
-
-/*-------------------------------------------------------------------------*/
-/*
- * private functions
- */
-/*-------------------------------------------------------------------------*/
-static mrp_res_queue_item_t *
-ico_syc_mrp_create_queue_item(resource_request_t *req)
-{
- mrp_res_queue_item_t *item = mrp_allocz(sizeof(mrp_res_queue_item_t));
- int ret = 0;
-
- ICO_DBG("ico_syc_mrp_create_queue_item: Enter");
-
- if (NULL == item) {
- ICO_ERR("mrp_allocz failed.");
- return NULL;
- }
-
- mrp_list_init(&item->hook);
-
- if (req->resid | RESID_KIND_SOUND) {
- item->req_id = req->soundid;
- item->zone_idx = req->soundzoneid;
- }
-
- item->prio = req->prio;
- item->res_type = req->resid;
-
- ret = snprintf(item->appid, MURPHY_APPID_MAXIMUM_LENGTH, "%s", req->appid);
-
- if (ret < 0 || ret >= MURPHY_APPID_MAXIMUM_LENGTH) {
- mrp_free(item);
- ICO_DBG("ico_syc_mrp_create_queue_item: Leave(NULL)");
- return NULL;
- }
-
- ICO_DBG("murphy: created queue item (id: %d, zone: %d, prio: %d, type: %d)",
- item->req_id, item->zone_idx, item->prio, item->res_type);
-
- ICO_DBG("ico_syc_mrp_create_queue_item: Leave(0x%08x)", item);
- return item;
-}
-
-static resource_request_t *
-ico_syc_mrp_find_request(int req_id, char *appid)
-{
- mrp_list_hook_t *p, *n;
- resource_request_t *req;
-
- ICO_DBG("ico_syc_mrp_find_request: Enter");
-
- /* go through all mrp_res_queue_item_t structs in the list */
-
- mrp_list_foreach(&mrp_reqs, p, n) {
- req = mrp_list_entry(p, typeof(*req), hook);
-
- ICO_DBG("ico_syc_mrp_find_request: req(id=%d appid=%s)",
- req->id, req->appid);
- if (req->id == req_id && strcmp(req->appid, appid) == 0) {
- ICO_DBG("ico_syc_mrp_find_request: Leave(0x%08x)", req);
- return req;
- }
- }
-
- ICO_DBG("ico_syc_mrp_find_request: Leave(NULL)");
- return NULL;
-}
-
-static void
-ico_syc_mrp_process_sound_queue(void)
-{
- mrp_list_hook_t *p, *n;
- mrp_res_queue_item_t *item;
-
- ICO_DBG("ico_syc_mrp_process_sound_queue: Enter");
-
- /* go through all mrp_res_queue_item_t structs in the list */
-
- mrp_list_foreach(&mrp_sound_wait_queue, p, n) {
- resource_request_t *req;
- item = mrp_list_entry(p, typeof(*item), hook);
-
- req = ico_syc_mrp_find_request(item->req_id, item->appid);
-
- if (req) {
- ico_syc_mrp_acquire_sound_resource(req);
- }
- else {
- ICO_WRN("murphy: application (appid: %s, id: %d, zone: %d)"
- " went away before resource handling",
- item->appid, item->req_id, item->zone_idx);
- }
-
- mrp_list_delete(&item->hook);
- mrp_free(item);
- }
-
- ICO_DBG("ico_syc_mrp_process_sound_queue: Leave");
-}
-
-static void
-ico_syc_mrp_resource_cb(mrp_res_context_t *ctx,
- const mrp_res_resource_set_t *rs,
- void *userdata)
-{
- resource_request_t *req = NULL;
-
- //mrp_res_queue_item_t *item = userdata;
- resource_request_t *item = userdata;
-
- unsigned short state = RES_STATE_ACQUIRED;
-
- ICO_DBG("ico_syc_mrp_resource_cb: Enter"
- "(req_id=%d appid=%s)", item->id, item->appid);
- //"(req_id=%d appid=%s)", item->req_id, item->appid);
-
- if (NULL == item) {
- return;
- }
-
- //if (item->res_type | RESID_KIND_SOUND) {
- if (item->resid & RESID_KIND_SOUND) {
- //req = ico_syc_mrp_find_request(item->req_id, item->appid);
- req = ico_syc_mrp_find_request(item->id, item->appid);
- ICO_DBG("RESID_KIND_SOUND req=0x%08x", req);
- }
-
- if (NULL == req) {
- ICO_ERR("murphy: the request wasn't found!");
- ICO_DBG("ico_syc_mrp_resource_cb: Leave");
- return;
- }
-
- if (!mrp_res_equal_resource_set(rs, req->rset)) {
- ICO_DBG("mrp_res_equal_resource_set : not match");
- ICO_DBG("ico_syc_mrp_resource_cb: Leave");
- return;
- }
-
- /* delete the previous set */
- ICO_DBG("called: mrp_res_delete_resource");
- mrp_res_delete_resource_set(req->rset);
-
- /* copy the new set into place */
- ICO_DBG("called: mrp_res_copy_resource_set");
- req->rset = mrp_res_copy_resource_set(rs);
-
- switch(req->rset->state) {
- case MRP_RES_RESOURCE_ACQUIRED:
- ICO_DBG("ico_syc_mrp_resource_cb: state=MRP_RES_RESOURCE_ACQUIRED");
- state = RES_STATE_ACQUIRED;
- break;
- case MRP_RES_RESOURCE_LOST:
- ICO_DBG("ico_syc_mrp_resource_cb: state=MRP_RES_RESOURCE_LOST");
- case MRP_RES_RESOURCE_AVAILABLE:
- ICO_DBG("ico_syc_mrp_resource_cb: state=MRP_RES_RESOURCE_AVAILABLE");
- if (req->released) {
- state = RES_STATE_RELEASED;
- }
- else {
- state = RES_STATE_WAITING;
- }
- break;
- default:
- ICO_WRN("ico_syc_mrp_resource_cb: state=UNKNOWN");
- state = RES_STATE_RELEASED;
- break;
- }
-
- /* send decision to client, if needed */
- if (req->reqtype == REQTYPE_APP) {
- if (req->state != state) {
-// TODO CicoSCServer::sendMessage();
-// if (ico_apf_resource_send_to_client(
-// req->appid, state, req->resid, req->device, req->id)
-// != ICO_APF_RESOURCE_E_NONE) {
-// ICO_WRN("murphy: failed to send decision to client (%s)",
-// req->appid);
-// }
- req->state = state;
- }
- }
-
- /* do the enforcing */
- if (req->resid & RESID_KIND_SOUND) {
- if (NULL != ico_syc_mrp_enforce_soundCB) {
- ico_syc_mrp_enforce_soundCB(state, req, cb_user_data);
- }
- }
- else {
- ICO_WRN("unknown resource id");
- }
-
- ICO_DBG("ico_syc_mrp_resource_cb: Leave");
-}
-
-static void
-ico_syc_mrp_state_cb(mrp_res_context_t *ctx,
- mrp_res_error_t err,
- void *userdata)
-{
- ICO_DBG("ico_syc_mrp_state_cb: Enter");
- if (err != MRP_RES_ERROR_NONE) {
- ICO_DBG("ico_syc_mrp_state_cb: state callback error(%d)", err);
- return;
- }
-
- switch (ctx->state)
- {
- case MRP_RES_CONNECTED:
- ICO_DBG("ico_syc_mrp_state_cb: connected to murphyd");
- mrp_res_connected = TRUE;
-
- /* process the queued resources */
- ico_syc_mrp_process_sound_queue();
- break;
- case MRP_RES_DISCONNECTED:
- ICO_DBG("ico_syc_mrp_state_cb: disconnected from murphyd");
- if (ctx) {
- mrp_res_destroy(ctx);
- mrp_ctx = NULL;
- }
- mrp_res_connected = FALSE;
- break;
- default:
- ICO_ERR("ico_syc_mrp_state_cb: state error");
- break;
- }
-
- ICO_DBG("ico_syc_mrp_state_cb: Leave");
-}
-
-static void
-ico_syc_mrp_connect_notify(mrp_domctl_t *dc,int connected,
- int errcode, const char *errmsg,
- void *user_data)
-{
- ICO_DBG("ico_syc_mrp_connect_notify: Enter");
- ICO_DBG("ico_syc_mrp_connect_notify: Leave");
-}
-
-static void
-ico_syc_mrp_data_notify(mrp_domctl_t *dc,
- mrp_domctl_data_t *tables,
- int ntable, void *user_data)
-{
- ICO_DBG("ico_syc_mrp_data_notify: Enter");
- ICO_DBG("ico_syc_mrp_data_notify: Leave");
-}
-
-static void
-ico_sys_mrp_export_notify(mrp_domctl_t *dc, int errcode,
- const char *errmsg, void *user_data)
-{
- MRP_UNUSED(dc);
- MRP_UNUSED(user_data);
-
- if (errcode != 0) {
- ICO_ERR("murphy: exporting data to Murphy failed "
- "(%d: %s).", errcode, errmsg);
- }
-}
-
-void
-ico_syc_mrp_active_app(const char *appid)
-{
- mrp_domctl_data_t tables[1];
- mrp_domctl_value_t values[2];
-
- ICO_DBG("ico_syc_mrp_active_app: active app '%s'", appid);
-
- memset(tables, 0, sizeof(tables));
- memset(values, 0, sizeof(values));
-
- tables[0].id = 0;
- tables[0].ncolumn = 2;
- tables[0].nrow = 1;
- tables[0].rows = mrp_allocz(sizeof(*tables[0].rows));
- tables[0].rows[0] = values;
-
- values[0].type = MRP_DOMCTL_STRING;
- values[0].str = "driver";
- values[1].type = MRP_DOMCTL_STRING;
- values[1].str = appid;
-
- ICO_DBG("called: mrp_domctl_set_data"
- "(tables[0].rows[0]={\"%s\",\"%s\"})",
- values[0].str, values[1].str);
- if (!mrp_domctl_set_data(mrp_dc, tables, 1,
- ico_sys_mrp_export_notify, NULL)) {
- ICO_DBG("ico_syc_mrp_active_app: "
- "failed to export active app data to Murphy");
- }
-
- mrp_free(tables[0].rows);
-}
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file ico_syc_mrp_resource_private.h
- *
- * @brief This file is definition of murpy ressource control
- */
-//==========================================================================
-
-#ifndef __ICO_SYC_MRP_RESOURCE_PRIVATE_H__
-#define __ICO_SYC_MRP_RESOURCE_PRIVATE_H__
-
-#include <murphy/plugins/resource-native/libmurphy-resource/resource-api.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define ICO_APC_REQTYPE_REQUEST 0 /* Request from application */
-#define ICO_APC_REQTYPE_CREATE 1 /* Request automatically */
-
-// TODO
-#define REQTYPE_APP 0
-#define REQTYPE_AUTO 1
-
-#define RESID_KIND_DISPLAY 0x00000001
-#define RESID_KIND_SOUND 0x00000002
-#define RESID_KIND_INPUT 0x00000004
-#define RESID_KIND_MASK 0x000000FF
-
-#define RESID_TYPE_BASIC 0x00000100
-#define RESID_TYPE_INTERRUPT 0x00000200
-#define RESID_TYPE_ONSCREEN 0x00000400
-#define RESID_TYPE_MASK 0x00000F00
-
-#define RESID_CMD_ACQUIRE 0x00001000
-#define RESID_CMD_RELEASE 0x00002000
-
-#define RES_STATE_ACQUIRED 1
-#define RES_STATE_DEPRIVED 2
-#define RES_STATE_WAITING 3
-#define RES_STATE_RELEASED 4
-
-#define MURPHY_APPID_MAXIMUM_LENGTH 128
-
-typedef struct {
- int req_id;
- char appid[MURPHY_APPID_MAXIMUM_LENGTH];
- int res_type;
- int zone_idx;
- int prio;
- mrp_list_hook_t hook;
-} mrp_res_queue_item_t;
-
-#define ICO_UXF_MAX_PROCESS_NAME 255
-#define ICO_UXF_MAX_DEVICE_NAME 255
-
-/* request information */
-typedef struct _resource_request {
- int id; /* request object */
- int prio; /* request priority */
- unsigned short reqtype; /* Request type */
- unsigned short category; /* Request category */
-
- int resid; /* resource id */
- char *appid; /* application id */
- int appkind; /* id of application kind */
- int pid; /* process id */
- int state; /* request state */
-
- char *dispzone; /* area of showing application window */
- int dispzoneid; /* area of showing application window */
- int layerid; /* layer of showing application window */
- char *winname; /* window's surface name */
- int surfaceid; /* window id */
- char *animation; /* name of animation */
- int animationTime; /* time of animation[ms] */
- bool bEx; /* Expansion flag */
- char *ECU; /* name to identify ECU */
- char *display; /* name to identify Display in ECU */
- char *layer; /* name to identify Layer in Display */
- char *layout; /* name to identify layout in Layer */
- char *area; /* name to Output position in Layout */
- char *dispatchApp; /* origin of application */
- char *role; /* role of notice kind */
- int role_stt; /* state number change from role */
- int resourceId; /* ID number of resource */
-
- char *soundzone; /* area of playing sound */
- int soundzoneid; /* area of playing sound */
- char *soundname; /* sound stream name */
- int soundid; /* sound id */
- int soundadjust; /* adjust action */
-
- char *device; /* input device name */
- int input; /* input event id */
-
- mrp_res_resource_set_t *rset; /* Murphy resource set */
- mrp_res_queue_item_t *res_data; /* identifier for the request */
- mrp_list_hook_t hook; /* keep track of requests */
- int released;
-
-} resource_request_t;
-
-typedef void (*ico_syc_mrp_enforce_sound_t)(unsigned short state,
- resource_request_t *req,
- void *user_data);
-
-
-int ico_syc_mrp_init(ico_syc_mrp_enforce_sound_t soundcb,
- void *user_data);
-void ico_syc_mrp_term(void);
-
-bool ico_syc_mrp_acquire_sound_resource(resource_request_t *req);
-bool ico_syc_mrp_release_sound_resource(resource_request_t *req);
-void ico_syc_mrp_active_app(const char *appid);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __ICO_SYC_MRP_RESOURCE_PRIVATE_H__ */
-/* vim:set expandtab ts=4 sw=4: */
This package provides the sample homescreen application.
-%package system-controller
-Summary: System controller for ICO HomeScreen
-Group: Automotive/ICO Homescreen
-Requires: %{name} = %{version}-%{release}
-Requires: weston >= 1.4
-Requires: weston-ivi-shell
-Requires: genivi-shell
-Requires: ico-uxf-weston-plugin >= 0.9.21
-Requires: ico-uxf-utilities >= 0.9.07
-Provides: system-controller
-Conflicts: murphy-system-controller
-
-%description system-controller
-A service to provide the low-level functionality that ICO HomeScreen
-requires.
-
-
%package system-controller-devel
Summary: Development files for %{name}
Group: Automotive/ICO Homescreen
rm -f %{TZ_SYS_RW_DESKTOP_APP}/org.tizen.ico.homescreen.desktop
rm -f %{TZ_SYS_RW_DESKTOP_APP}/org.tizen.ico.statusbar.desktop
rm -f %{TZ_SYS_RW_DESKTOP_APP}/org.tizen.ico.onscreen.desktop
-rm -f %{TZ_SYS_RW_DESKTOP_APP}/org.tizen.ico.system-controller.desktop
pkg_initdb
ail_initdb
%{TZ_SYS_RW_PACKAGES}/org.tizen.ico.statusbar.xml
%{TZ_SYS_RW_PACKAGES}/org.tizen.ico.onscreen.xml
%{_libdir}/libico-appfw.*
-%{_libdir}/libico-state-machine.*
%{_bindir}/ico_clear_screen
%{_bindir}/ico_change_loginuser
%{_bindir}/ico_del_notification
%{_datadir}/icons/default/small/org.tizen.ico.homescreen.png
%{_datadir}/icons/default/small/org.tizen.ico.statusbar.png
%{_datadir}/icons/default/small/org.tizen.ico.onscreen.png
-%TZ_SYS_RW_APP/org.tizen.ico.system-controller/res/config
-
-%files system-controller
-%defattr(-,root,root,-)
-%manifest %{name}.manifest
-%{_datadir}/packages/org.tizen.ico.system-controller.xml
-%{_unitdir_user}/ico-uxf-wait-launchpad-ready.path
-%{_unitdir_user}/weston.target.wants/ico-uxf-wait-launchpad-ready.path
-%{_unitdir_user}/ico-system-controller.service
-%TZ_SYS_RW_APP/org.tizen.ico.system-controller/bin
-%attr(644,app,app) /home/app/ico/defaultApps.info
-%attr(755,app,app) /home/app/ico
+# retain the system control configuration inside homescreen at least for now
+/usr/apps/org.tizen.ico.system-controller/res/config
%files system-controller-devel
%defattr(-,root,root,-)
%{_includedir}/ico-appfw/ico_syc_type.h
%{_includedir}/ico-appfw/ico_syc_userctl.h
%{_includedir}/ico-appfw/ico_syc_winctl.h
-%{_includedir}/ico-state-machine/CicoBlockParser.h
-%{_includedir}/ico-state-machine/CicoEvent.h
-%{_includedir}/ico-state-machine/CicoEventInfo.h
-%{_includedir}/ico-state-machine/CicoFinalState.h
-%{_includedir}/ico-state-machine/CicoHistoryState.h
-%{_includedir}/ico-state-machine/CicoState.h
-%{_includedir}/ico-state-machine/CicoStateAction.h
-%{_includedir}/ico-state-machine/CicoStateCore.h
-%{_includedir}/ico-state-machine/CicoStateMachine.h
-%{_includedir}/ico-state-machine/CicoStateMachineCreator.h
+
SUBDIRS= \
- syscond \
homescreen \
statusbar \
onscreen
mkdir -p $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/res/edj
mkdir -p $(INSTALL_ROOT)/usr/share/packages
mkdir -p $(INSTALL_ROOT)/usr/share/icons/default/small/
+ mkdir -p $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/res/config
install -m 0755 HomeScreen $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/bin
install -m 0644 home_screen_bg.edj $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/res/edj
install -m 0644 home_screen_touch.edj $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/res/edj
install -m 0644 $(top_srcdir)/res/org.tizen.ico.homescreen/res/config/* $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/res/config
install -m 0644 $(top_srcdir)/res/org.tizen.ico.homescreen/res/sound/* $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen/res/sound
install -m 0644 $(top_srcdir)/data/apps/org.tizen.ico.homescreen/res/icons/default/small/* $(INSTALL_ROOT)/usr/share/icons/default/small/
+ install -m 0644 $(top_srcdir)/res/org.tizen.ico.system-controller/res/config/* $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/res/config
uninstall:
rm -rf $(INSTALL_ROOT)/usr/apps/org.tizen.ico.homescreen
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSysConDaemon.cpp
- *
- * @brief This file is implimention of CicoSysConDaemon class
- */
-//==========================================================================
-
-#include <exception>
-#include <iostream>
-#include <string>
-
-#include "CicoSysConDaemon.h"
-#include "ico_syc_error.h"
-#include "CicoLog.h"
-#include "CicoSystemConfig.h"
-#include "CicoSCServer.h"
-#include "CicoSCWayland.h"
-#include "CicoSCWindowController.h"
-#include "CicoSCInputController.h"
-#include "CicoSCLifeCycleController.h"
-#include "CicoSCUser.h"
-#include "CicoSCUserManager.h"
-#include "CicoSCResourceManager.h"
-#include "Cico_aul_listen_app.h"
-#include "CicoSCVInfoManager.h"
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSysConDaemon::CicoSysConDaemon()
- : m_winctrl(NULL), m_inputctrl(NULL), m_resourcemgr(NULL)
-{
-// ICO_TRA("CicoSysConDaemon::CicoSysConDaemon Enter");
-// ICO_TRA("CicoSysConDaemon::CicoSysConDaemon Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on create
- *
- * @param [in] user_data The user data passed from the callback
- * registration function
- *
- * @return true on success, false on error
- */
-//--------------------------------------------------------------------------
-CicoSysConDaemon::~CicoSysConDaemon()
-{
-// ICO_TRA("CicoSysConDaemon::~CicoSysConDaemon Enter");
-// ICO_TRA("CicoSysConDaemon::~CicoSysConDaemon Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on terminate
- *
- * @param [in] user_data The user data passed from the callback
- * registration function
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConDaemon::onCreate(void *user_data)
-{
- ICO_TRA("CicoSysConDaemon::onCreate Enter");
-
- try {
- int ret = ICO_SYC_EOK;
- CicoSystemConfig::getInstance()->load("/usr/apps/org.tizen.ico.system-controller/res/config/system.xml");
-
- initAulListenXSignal();
-
- CicoSCVInfoManager::getInstance()->startup();
-
- CicoSCLifeCycleController *lifecycle =
- CicoSCLifeCycleController::getInstance();
- m_winctrl = new CicoSCWindowController();
- m_inputctrl = new CicoSCInputController();
-
- m_resourcemgr = new CicoSCResourceManager();
- m_resourcemgr->setWindowController(m_winctrl);
- m_resourcemgr->setInputController(m_inputctrl);
- ret = m_resourcemgr->initialize();
- if (ICO_SYC_EOK != ret) {
- return false;
- }
-
- m_winctrl->setResourceManager(m_resourcemgr);
-
- CicoSCUserManager *usermgr = CicoSCUserManager::getInstance();
- usermgr->load("/usr/apps/org.tizen.ico.system-controller/res/config/user.xml");
-
- CicoSCServer *server = CicoSCServer::getInstance();
- server->setWindowCtrl(m_winctrl);
- server->setInputCtrl(m_inputctrl);
- server->setUserMgr(usermgr);
- server->setResourceMgr(m_resourcemgr);
- server->setPolicyMgr(m_resourcemgr->getPolicyManager());
-
- server->startup(18081, (const char*)"ico_syc_protocol");
- ret = CicoSCWayland::getInstance()->initialize();
- if (ICO_SYC_EOK != ret) {
- return false;
- }
- CicoSCWayland::getInstance()->addEcoreMainWlFdHandler();
-
- usermgr->initialize();
- if (true == lifecycle->isAppResource()) {
- const CicoSCUser* user = usermgr->getLoginUser();
- if (NULL != user) {
- if (false == lifecycle->startAppResource(user->name)) {
- lifecycle->createAppResourceFile(user->name);
- }
- }
- }
- }
- catch (const std::exception& e) {
- std::cerr << e.what() << std::endl;
- ICO_ERR("catch exception %s", e.what());
- ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
- return false;
- }
- catch (const std::string& str) {
- std::cerr << str << std::endl;
- ICO_ERR("catch exception %s", str.c_str());
- ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
- return false;
- }
- catch (...) {
- ICO_ERR("catch exception unknown");
- ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
- return false;
- }
-
- ICO_TRA("CicoSysConDaemon::onCreate Leave(true)");
- ICO_PRF("SYS_STARTED Initialization is complete");
-
- return true;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on terminate
- *
- * @param [in] user_data The user data passed from the callback
- * registration function
- */
-//--------------------------------------------------------------------------
-void
-CicoSysConDaemon::onTerminate(void *user_data)
-{
- ICO_TRA("CicoSysConDaemon::onTerminate Enter");
- CicoSCUserManager *usermgr = CicoSCUserManager::getInstance();
- usermgr->cloaseUser();
- stop();
- CicoSCServer::getInstance()->teardown();
- CicoSCVInfoManager::getInstance()->teardown();
- ICO_TRA("CicoSysConDaemon::onTerminate Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on pause
- *
- * @param [in] user_data The user data passed from the callback
- * registration function
- */
-//--------------------------------------------------------------------------
-void
-CicoSysConDaemon::onPause(void *user_data)
-{
- ICO_TRA("CicoSysConDaemon::onPause Enter");
- ICO_TRA("CicoSysConDaemon::onPause Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on resume
- *
- * @param [in] user_data The user data passed from the callback
- * registration function
- */
-//--------------------------------------------------------------------------
-void
-CicoSysConDaemon::onResume(void *user_data)
-{
- ICO_TRA("CicoSysConDaemon::onResume Enter");
- ICO_TRA("CicoSysConDaemon::onResume Leave");
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief callback function on service
- *
- * @param [in] service The handle to the service
- * @param [in] user_data The user data passed from the callback
- * registration function
- */
-//--------------------------------------------------------------------------
-void
-CicoSysConDaemon::onService(service_h service, void *user_data)
-{
- ICO_TRA("CicoSysConDaemon::onService Enter");
- ICO_TRA("CicoSysConDaemon::onService Leave");
-}
-// vim: set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoSysConDaemon.h
- *
- * @brief This file is definition of CicoSysConDaemon class
- */
-//==========================================================================
-#ifndef __CICO_SYS_CON_DAEMON_H__
-#define __CICO_SYS_CON_DAEMON_H__
-
-#include <stdio.h>
-#include "CicoEFLApp.h"
-
-//==========================================================================
-// Forward declaration
-//==========================================================================
-class CicoSCWindowController;
-class CicoSCInputController;
-class CicoSCResourceManager;
-
-//==========================================================================
-/**
- * @brief ELF Application functions for SystemController
- */
-//==========================================================================
-class CicoSysConDaemon : public CicoEFLApp {
-public:
- // default constructor
- CicoSysConDaemon();
-
- // destructor
- virtual ~CicoSysConDaemon();
-
- // callback function on create
- virtual bool onCreate(void *user_data);
-
- // callback function on terminate
- virtual void onTerminate(void *user_data);
-
- // callback function on pause
- virtual void onPause(void *user_data);
-
- // callback function on resume
- virtual void onResume(void *user_data);
-
- // callback function on service
- virtual void onService(service_h service, void *user_data);
-
-protected:
- // assignment operator
- CicoSysConDaemon& operator=(const CicoSysConDaemon &object);
-
- // copy constructor
- CicoSysConDaemon(const CicoSysConDaemon &object);
-
-private:
- // CicoSCWindowController instance
- CicoSCWindowController* m_winctrl;
-
- // CicoSCInputController instance
- CicoSCInputController* m_inputctrl;
-
- // CicoSCResourceManager instance
- CicoSCResourceManager* m_resourcemgr;
-};
-#endif // __CICO_SYS_CON_DAEMON_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoSysConLogConfig.cpp
- *
- * @brief This file implementation of CicoSysConLogConfig class
- */
-/*========================================================================*/
-
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
-
-using namespace boost;
-using namespace boost::property_tree;
-
-#include "CicoSysConLogConfig.h"
-
-//==========================================================================
-// private static variable
-//==========================================================================
-CicoSysConLogConfig* CicoSysConLogConfig::ms_myInstance = NULL;
-
-//--------------------------------------------------------------------------
-/**
- * @brief default constructor
- */
-//--------------------------------------------------------------------------
-CicoSysConLogConfig::CicoSysConLogConfig()
- : m_confFile(""), m_name("IcoSysConDaemon"),
- m_levelPRF(false), m_levelTRA(false), m_levelDBG(false),
- m_levelINF(false), m_levelWRN(false), m_levelCRI(false),
- m_levelERR(false), m_flush(false), m_ecore(false)
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief destructor
- */
-//--------------------------------------------------------------------------
-CicoSysConLogConfig::~CicoSysConLogConfig()
-{
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get instance of CicoSysConLogConfig
- *
- * @return pointer of CicoSysConLogConfig object
- */
-//--------------------------------------------------------------------------
-CicoSysConLogConfig*
-CicoSysConLogConfig::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoSysConLogConfig();
- }
- return ms_myInstance;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief Get instance of CicoSysConLogConfig
- *
- * @param [in] confFile config file name
- * @return 0 on success, other on error
- */
-//--------------------------------------------------------------------------
-int
-CicoSysConLogConfig::load(const std::string & confFile)
-{
- // load xml config file
- ptree root;
- read_xml(confFile, root);
-
- //<log>
- if (root.not_found() != root.find("system-controller.log")) {
- printf("log element not found");
- return -1;
- }
-
- ptree log = root.get_child("system-controller.log");
-
- ptree child;
- optional<std::string> sValue;
- optional<bool> bValue;
-
- // read <performance eneble="xxx"/>
- sValue = log.get_optional<std::string>("name");
- if (true == sValue.is_initialized()) {
- m_name = sValue.get();
- }
-
- // read <performance eneble="xxx"/>
- child = log.get_child("level.performance");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelPRF = bValue.get();
- }
-
- // read <trace eneble="xxx"/>
- child = log.get_child("level.trace");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelTRA = bValue.get();
- }
-
- // read <debug eneble="xxx"/>
- child = log.get_child("level.debug");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelDBG = bValue.get();
- }
-
- // read <info eneble="xxx"/>
- child = log.get_child("level.info");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelINF = bValue.get();
- }
-
- // read <warning eneble="xxx"/>
- child = log.get_child("level.warning");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelWRN = bValue.get();
- }
-
- // read <critical eneble="xxx"/>
- child = log.get_child("level.critical");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelCRI = bValue.get();
- }
-
- // read <error eneble="xxx"/>
- child = log.get_child("level.error");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_levelERR = bValue.get();
- }
-
- // read <flush eneble="xxx"/>
- child = log.get_child("flush");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_flush = bValue.get();
- }
-
- // read <ecore eneble="xxx"/>
- child = log.get_child("ecore");
- bValue = child.get_optional<bool>("<xmlattr>.enable");
- if (true == bValue.is_initialized()) {
- m_ecore = bValue.get();
- }
-
- return 0;
-}
-
-
-//--------------------------------------------------------------------------
-/**
- * @brief get log name
- */
-//--------------------------------------------------------------------------
-std::string &
-CicoSysConLogConfig::getLogName(void)
-{
- return m_name;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get performance level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isPRF(void)
-{
- return m_levelPRF;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get trace level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isTRA(void)
-{
- return m_levelTRA;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get debug level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isDBG(void)
-{
- return m_levelDBG;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get info level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isINF(void)
-{
- return m_levelINF;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get warning level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isWRN(void)
-{
- return m_levelWRN;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get critical level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isCRI(void)
-{
- return m_levelCRI;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get error level enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isERR(void)
-{
- return m_levelERR;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get flush log enable state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isFlush(void)
-{
- return m_flush;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief get ecore log print enalbe state
- */
-//--------------------------------------------------------------------------
-bool
-CicoSysConLogConfig::isEcore(void)
-{
- return m_ecore;
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file CicoLogConfig.h
- *
- * @brief This file is definition of CicoSysConLogConfig class
- */
-//==========================================================================
-#ifndef __CICO_SYS_CON_LOG_CONFIG_H__
-#define __CICO_SYS_CON_LOG_CONFIG_H__
-
-#include <string>
-
-//==========================================================================
-/**
- * @brief This class has function of access to my appliction log
- * configuration information
- */
-//==========================================================================
-class CicoSysConLogConfig
-{
-public:
- // get my install
- static CicoSysConLogConfig* getInstance(void);
-
- // load configuration file
- int load(const std::string & confFile);
-
- // get log name
- std::string & getLogName(void);
-
- // get performance level enable state
- bool isPRF(void);
-
- // get trace level enable state
- bool isTRA(void);
-
- // get debug level enable state
- bool isDBG(void);
-
- // get info level enable state
- bool isINF(void);
-
- // get warning level enable state
- bool isWRN(void);
-
- // get critical level enable state
- bool isCRI(void);
-
- // get error level enable state
- bool isERR(void);
-
- // get flush log enable state
- bool isFlush(void);
-
- // get ecore log print enalbe state
- bool isEcore(void);
-
-private:
- // default constructor
- CicoSysConLogConfig();
-
- // destructor
- ~CicoSysConLogConfig();
-
- // assignment operator
- CicoSysConLogConfig& operator=(const CicoSysConLogConfig &object);
-
- // copy constructor
- CicoSysConLogConfig(const CicoSysConLogConfig &object);
-
-private:
- // this class instance
- static CicoSysConLogConfig* ms_myInstance;
-
- // log file path
- std::string m_confFile;
-
- // log name
- std::string m_name;
-
- // performance log enable
- bool m_levelPRF;
-
- // trace log enable
- bool m_levelTRA;
-
- // debug log enable
- bool m_levelDBG;
-
- // info log enable
- bool m_levelINF;
-
- // warning log enable
- bool m_levelWRN;
-
- // critical log enable
- bool m_levelCRI;
-
- // error log enable
- bool m_levelERR;
-
- // flush enable
- bool m_flush;
-
- // ecore log print eneble
- bool m_ecore;
-};
-#endif // __CICO_SYSysConON_LOG_CONFIG_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-AM_CPPFLAGS = $(GCC_CXXFLAGS)
-
-noinst_PROGRAMS = \
- IcoSysconDaemon
-
-check_PROGRAMS = \
- IcoSysconDaemon
-
-IcoSysconDaemon_SOURCES = \
- CicoSysConLogConfig.cpp \
- CicoSysConDaemon.cpp \
- main.cpp
-
-IcoSysconDaemon_CPPFLAGS = \
- @ECORE_CFLAGS@ \
- @EINA_CFLAGS@ \
- @GLIB_CFLAGS@ \
- @AIL_CFLAGS@ \
- @BUNDLE_CFLAGS@ \
- @AUL_CFLAGS@ \
- @PKGMGR_CFLAGS@ \
- @WAYLANDCLIENT_CFLAGS@ \
- @CAPIAPPFWAPPLICATION_CFLAGS@ \
- @JSONGLIB_CFLAGS@ \
- @MURPHYCOMMON_CFLAGS@ \
- @MURPHYDOMAINCONTROLLER_CFLAGS@ \
- @MURPHYECORE_CFLAGS@ \
- @MURPHYRESOURCE_CFLAGS@ \
- $(UWS_CFLAGS) \
- -I../../include \
- -I../../lib/system-controller \
- -I../../lib/common
-
-IcoSysconDaemon_LDADD = \
- ../../lib/system-controller/.libs/libico-system-controller.a \
- ../../lib/common/.libs/libico-common.a \
- ../../lib/misc/state-machine/.libs/libico-state-machine.a \
- @ECORE_LIBS@ \
- @EINA_LIBS@ \
- @GLIB_LIBS@ \
- @AIL_LIBS@ \
- @BUNDLE_LIBS@ \
- @AUL_LIBS@ \
- @PKGMGR_LIBS@ \
- @WAYLANDCLIENT_LIBS@ \
- @CAPIAPPFWAPPLICATION_LIBS@ \
- @JSONGLIB_LIBS@ \
- @MURPHYCOMMON_LIBS@ \
- @MURPHYDOMAINCONTROLLER_LIBS@ \
- @MURPHYECORE_LIBS@ \
- @MURPHYRESOURCE_LIBS@ \
- $(UWS_LIBS) \
- $(GENIVI_LIBS) \
- $(WESTONPLUGIN_LIBS)
-
-CLEANFILES = $(BUILT_SOURCES)
-
-install-exec-hook:
- mkdir -p $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/bin
- mkdir -p $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/res/config
- mkdir -p $(INSTALL_ROOT)/usr/share/packages
- mkdir -p $(INSTALL_ROOT)/usr/lib/systemd/user
- mkdir -p $(INSTALL_ROOT)/usr/lib/systemd/user/weston.target.wants
- mkdir -p $(INSTALL_ROOT)/home/app/ico
- install -m 0755 IcoSysconDaemon $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/bin
- install -m 0644 ../../data/share/packages/org.tizen.ico.system-controller.xml $(INSTALL_ROOT)/usr/share/packages
- install -m 0644 $(top_srcdir)/res/org.tizen.ico.system-controller/res/config/* $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller/res/config
- install -d -m 0755 app $(INSTALL_ROOT)/home/app/ico
- install -m 0644 $(top_srcdir)/res/org.tizen.ico.system-controller/res/ico/* $(INSTALL_ROOT)/home/app/ico
- chown -fHR app $(INSTALL_ROOT)/home/app; set $?=0
- chgrp -fHR app $(INSTALL_ROOT)/home/app; set $?=0
- install -m 0644 $(top_srcdir)/data/lib/systemd/user/ico-uxf-wait-launchpad-ready.path $(INSTALL_ROOT)/usr/lib/systemd/user
- install -m 0644 $(top_srcdir)/data/lib/systemd/user/ico-system-controller.service $(INSTALL_ROOT)/usr/lib/systemd/user
- ln -sf ../ico-uxf-wait-launchpad-ready.path $(INSTALL_ROOT)/usr/lib/systemd/user/weston.target.wants
-
-uninstall:
- rm -rf $(INSTALL_ROOT)/usr/apps/org.tizen.ico.system-controller
- rm -f $(INSTALL_ROOT)/usr/share/packages/org.tizen.ico.system-controller.xml
- rm -rf $(INSTALL_ROOT)/home/app/ico
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-//==========================================================================
-/**
- * @file main.cpp
- *
- * @brief This file is implimantion of system-controller
- * application main function
- */
-//==========================================================================
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <exception>
-#include <iostream>
-#include <string>
-
-#include "CicoEFLApp.h"
-#include "CicoSysConLogConfig.h"
-#include "CicoSysConDaemon.h"
-#include "CicoLog.h"
-#include <Eina.h>
-
-//--------------------------------------------------------------------------
-/**
- * @brief get log level
- *
- * @praram [in] logConf CicoSysConLogConfig instance
- */
-//--------------------------------------------------------------------------
-int
-getLogLevel(CicoSysConLogConfig* logConf)
-{
- int level = 0;
- if (true == logConf->isPRF()) {
- level |= ICO_LOG_LVL_PRF;
- }
- if (true == logConf->isTRA()) {
- level |= ICO_LOG_LVL_TRA;
- }
- if (true == logConf->isDBG()) {
- level |= ICO_LOG_LVL_DBG;
- }
- if (true == logConf->isINF()) {
- level |= ICO_LOG_LVL_INF;
- }
- if (true == logConf->isWRN()) {
- level |= ICO_LOG_LVL_WRN;
- }
- if (true == logConf->isCRI()) {
- level |= ICO_LOG_LVL_CRI;
- }
- if (true == logConf->isERR()) {
- level |= ICO_LOG_LVL_ERR;
- }
- if (true == logConf->isFlush()) {
- level |= ICO_LOG_FLUSH;
- }
- else {
- level |= ICO_LOG_NOFLUSH;
- }
-
- return level;
-}
-
-//--------------------------------------------------------------------------
-/**
- * @brief system-controller main
- *
- * @param [in] argc counts of argment
- * @param [in] argv argment
- * @return result
- * @retval 0 success
- * @retval -1 error
- */
-//--------------------------------------------------------------------------
-int
-main(int argc, char **argv)
-{
- int i;
-
- // check '--user' option
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "--user") == 0) {
- i ++;
- if (i < argc) {
- if (strcmp(argv[i], cuserid(NULL)) != 0) {
- printf("=== start IcoSysConDaemon main entry(user=%s)\n", argv[i]);
- printf("=== abort IcoSysConDaemon main exit(cannot run in a '%s')\n",
- cuserid(NULL));
- return 0;
- }
- }
- }
- }
-
- try {
- printf("=== start IcoSysConDaemon main entry(uid=%d)\n", getuid());
-
- CicoSysConLogConfig* logConf = CicoSysConLogConfig::getInstance();
- logConf->load("/usr/apps/org.tizen.ico.system-controller/res/config/system-controller.xml");
-
- // setup ecore log print
- if (logConf->isEcore()) {
- eina_init();
- eina_log_level_set(EINA_LOG_LEVEL_DBG);
- }
-
- // setup ico_log print
- ico_log_open(logConf->getLogName().c_str());
- ico_log_set_level(getLogLevel(logConf));
- ICO_INF("START_MODULE SystemController");
-
- int ret = 0;
- CicoSysConDaemon daemon;
-
- ret = daemon.start(argc, argv);
-
- ICO_DBG("ret = %d error=%s", ret, daemon.appfwErrorToString(ret));
-
- daemon.stop();
- }
- catch (const std::exception& e) {
- std::cerr << e.what() << std::endl;
- ICO_ERR("main: catch exception [%s]", e.what());
- return -1;
- }
- catch (const std::string& str) {
- std::cerr << str << std::endl;
- ICO_ERR("main: catch exception [%s]", str.c_str());
- return -1;
- }
- catch (...) {
- ICO_ERR("main: catch exception unknown");
- return -1;
- }
- ICO_INF("END_MODULE SystemController");
-
- return 0;
-}
-// vim: set expandtab ts=4 sw=4:
#SUBDIRS=\
# system-controller \
# homescreen
-
-SUBDIRS=\
- system-controller
+++ /dev/null
-SUBDIRS=\
- apps-framework
+++ /dev/null
-TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/apps-framework/run_test.sh
-
-export abs_builddir
-
-AM_CFLAGS = $(GCC_CFLAGS)
-AM_CPPFLAGS = $(GCC_CFLAGS)
-
-noinst_PROGRAMS = \
- tst_common \
- tst_appresctl \
- tst_appresctl_main \
- tst_inputctl \
- tst_userctl \
- tst_winctl \
- tst_server
-
-check_LTLIBRARIES = $(TESTS)
-check_PROGRAMS = tst_common tst_appresctl tst_appresctl_main tst_inputctl tst_userctl tst_winctl tst_server
-
-test_target_flag = -I../../../include $(AIL_CFLAGS) $(OPT_CFLAGS) \
- @ECORE_CFLAGS@ @EINA_CFLAGS@ \
- -I/usr/include/ico-uxf-weston-plugin \
- -I/usr/include/ico-util
-test_target_lib = ../../../lib/apps-framework/.libs/libico-appfw.so \
- @ECORE_LIBS@ @EINA_LIBS@ \
- $(UWS_LIBS) $(OPT_LIBS) $(AIL_LIBS)
-
-tst_common_SOURCES = tst_common.c
-tst_common_CFLAGS = $(test_target_flag)
-tst_common_LDADD = $(test_target_lib)
-
-tst_appresctl_main_SOURCES = tst_appresctl_main.c
-tst_appresctl_main_CFLAGS = $(AIL_CFLAGS)
-tst_appresctl_main_LDADD = $(AIL_LIBS)
-
-tst_appresctl_SOURCES = tst_appresctl.c
-tst_appresctl_CFLAGS = $(test_target_flag)
-tst_appresctl_LDADD = $(test_target_lib)
-
-tst_inputctl_SOURCES = tst_inputctl.c
-tst_inputctl_CFLAGS = $(test_target_flag)
-tst_inputctl_LDADD = $(test_target_lib)
-
-tst_userctl_SOURCES = tst_userctl.c
-tst_userctl_CFLAGS = $(test_target_flag)
-tst_userctl_LDADD = $(test_target_lib)
-
-tst_winctl_SOURCES = tst_winctl.c
-tst_winctl_CFLAGS = $(test_target_flag)
-tst_winctl_LDADD = $(test_target_lib)
-
-tst_server_SOURCES = tst_server.c
-tst_server_CFLAGS = $(test_target_flag)
-tst_server_LDADD = $(test_target_lib)
-
-EXTRA_DIST = run_test.sh
+++ /dev/null
-[Desktop Entry]
-Name=test.ico.res.app
-Type=Application
-Exec=/opt/usr/apps/test.ico.res.app/bin/tst_appresctl
-Icon=
-Categories=Test
-Version=1.0.0
-NoDisplay=true
-X-TIZEN-Removable=False
+++ /dev/null
-#!/bin/sh
-
-########################
-#
-# Setting value
-#
-########################
-# directory to put result
-log_dir="./result"
-# test log tag
-test_tag="TestCase"
-
-# log file name
-date_str=`date '+%Y%m%d'`
-time_str=`date '+%H%M'`
-file_str="${date_str}_${time_str}.txt"
-
-# sample app dir
-app_dir="/opt/usr/apps/test.ico.res.app"
-
-########################
-#
-# Initialize
-#
-########################
-cd ../../../
-curpath=`pwd`;
-export LD_LIBRARY_PATH=$curpath/lib/apps-framework/.libs:$LD_LIBRARY_PATH
-#/usr/bin/launchpad_preloading_preinitializing_daemon &
-cd ./tests/system-controller/apps-framework/
-
-# set library path & reboot launchpad
-pids=(`ps -ef | grep launchpad | grep -v grep | awk '{ print $2 }'`)
-for pid in ${pids[*]}
-do
- kill -9 ${pid}
-done
-
-# setting for appresctl test
-cp ./data/* /opt/share/applications
-if [ ! -e ${app_dir} ]; then
- mkdir ${app_dir}
- mkdir ${app_dir}/bin
-fi
-cp tst_appresctl ${app_dir}/bin/
-
-# make directory to put result
-if [ ! -e ${log_dir} ]; then
- mkdir ${log_dir}
-fi
-
-########################
-#
-# Function
-#
-########################
-print_result()
-{
- local l_test="$1"
- local l_log="$2"
-
- # count OK/NG
- l_cnt_ok=`grep ${test_tag} ${l_log} | grep " OK" | wc -l`
- l_cnt_ng=`grep ${test_tag} ${l_log} | grep " NG" | wc -l`
- echo "## ${l_test} OK: ${l_cnt_ok}, NG: ${l_cnt_ng}"
-}
-
-kill_server()
-{
- pids=(`ps -ef | grep tst_server | grep -v grep | awk '{ print $2 }'`)
- for pid in ${pids[*]}
- do
- kill -9 ${pid}
- done
- sleep 1
-}
-
-########################
-#
-# Test
-#
-########################
-# kill test server
-kill_server
-
-echo "===== System Controller API Test ====="
-log_server="${log_dir}/server_${file_str}"
-./tst_server >> ${log_server}&
-sleep 2
-
-log_common="${log_dir}/common_${file_str}"
-./tst_common 2>&1 | tee ${log_common}
-sleep 1
-
-log_winctl="${log_dir}/winctl_${file_str}"
-./tst_winctl 2>&1 | tee ${log_winctl}
-sleep 1
-
-log_inputctl="${log_dir}/inputctl_${file_str}"
-./tst_inputctl 2>&1 | tee ${log_inputctl}
-sleep 1
-
-log_userctl="${log_dir}/userctl_${file_str}"
-./tst_userctl 2>&1 | tee ${log_userctl}
-sleep 1
-
-log_appresctl="${log_dir}/appresctl_${file_str}"
-./tst_appresctl_main -add
-${app_dir}/bin/tst_appresctl 2>&1 | tee ${log_appresctl}
-./tst_appresctl_main -del
-sleep 2
-
-echo ""
-echo ""
-echo "<<Results of System Controller API Test>>"
-print_result "Common API" ${log_common}
-print_result "WindowControl API" ${log_winctl}
-print_result "InputControl API" ${log_inputctl}
-print_result "UserControl API" ${log_userctl}
-print_result "ResourceControl API" ${log_appresctl}
-echo ""
-echo ""
-
-# kill test server
-kill_server
-
-# remove test application
-rm -fr /opt/share/applications/test.ico.*
-rm -fr /opt/apps/test.ico.res.app
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for App Resource Control API
- *
- * @date Aug-6-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include "ico_syc_appresctl.h"
-#include "ico_syc_common.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Variable */
-/* ----------------------------------------------- */
-static struct ico_syc_res_context *res_context = NULL;
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static void _check_res_info(const char *ev_name, ico_syc_res_info_t *info);
-static void _check_input_region(const char *ev_name,
- ico_syc_input_region_t *region);
-static void _syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data);
-static void tst_acquire_res(const ico_syc_res_window_t *window,
- const ico_syc_res_sound_t *sound,
- const ico_syc_res_input_t *input,
- int type);
-static void tst_release_res(void);
-static void tst_set_input_region(const ico_syc_input_region_t *region, int attr);
-static void tst_unset_input_region(const ico_syc_input_region_t *region);
-static Eina_Bool ico_syc_appresctl_test(void *data);
-
-/* ----------------------------------------------- */
-/* Public API Test */
-/* ----------------------------------------------- */
-static void
-_check_res_info(const char *ev_name, ico_syc_res_info_t *info)
-{
- ico_syc_res_window_t *window = NULL;
- ico_syc_res_sound_t *sound = NULL;
- ico_syc_res_input_t *input = NULL;
- int check_flag = 0;
-
- printf("--- %s\n", ev_name);
-
- window = info->window;
- sound = info->sound;
- input = info->input;
- if (window != NULL) {
- ico_syc_res_window_t *w = window;
- printf("\t(window ECU[%s].display[%s].layer[%s].layout[%s].area[%s], app[%s], role[%s], resId[%d]",
- w->ECU, w->display, w->layer, w->layout, w->area,
- w->dispatchApp, w->role, w->resourceId);
-
- if ((0 != strcmp(w->ECU, TST_ECU)) ||
- (0 != strcmp(w->display, TST_display)) ||
- (0 != strcmp(w->layer, TST_layer)) ||
- (0 != strcmp(w->layout, TST_layout)) ||
- (0 != strcmp(w->area, TST_area)) ||
- (0 != strcmp(w->dispatchApp, TST_dispatchApp)) ||
- (0 != strcmp(w->role, TST_role)) ||
- (w->resourceId != TST_resourceId)) {
- check_flag = 1;
- }
- }
- if (sound != NULL) {
- printf("\t sound zone[%s], name[%s], id[%s], adjust[%d]\n",
- sound->zone, sound->name, sound->id, sound->adjust);
- if (strcmp(sound->zone, TST_ZONE_B) != 0
- || strcmp(sound->name, TST_NAME_B) != 0
- || strcmp(sound->id, TST_ID_B) != 0
- || sound->adjust != TST_ADJUST) {
- check_flag = 1;
- }
- }
- if (input != NULL) {
- printf("\t input name[%s], event[%d])\n", input->name, input->event);
- if (strcmp(input->name, TST_NAME_C) != 0
- || input->event != TST_INPUT_EV) {
- check_flag = 1;
- }
- }
-
- if (check_flag == 0) {
- print_ok("callback (%s)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_check_input_region(const char *ev_name, ico_syc_input_region_t *region)
-{
- printf("--- %s\n", ev_name);
- printf("\t(winname[%s], (x,y)[%d, %d], width[%d], height[%d], hot[%d,%d], "
- "cursor[%d.%d-%d,%d], attr[%d])\n",
- region->winname, region->pos_x, region->pos_y,
- region->width, region->height, region->hotspot_x, region->hotspot_y,
- region->cursor_x, region->cursor_y, region->cursor_width,
- region->cursor_height, region->attr);
-
- if ((strcmp(region->winname, TST_WIN_NAME) == 0)
- && region->pos_x == TST_POS_X && region->pos_y == TST_POS_Y
- && region->width == TST_REG_WIDTH && region->height == TST_REG_HEIGHT
- && region->hotspot_x == TST_REG_HOT_X && region->hotspot_y == TST_REG_HOT_Y
- && region->cursor_x == TST_REG_CUR_X && region->cursor_y == TST_REG_CUR_Y
- && region->cursor_width == TST_REG_CUR_WIDTH
- && region->cursor_height == TST_REG_CUR_HEIGHT
- && region->attr == TST_REG_ATTR) {
- print_ok("callback (%s)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data)
-{
- switch (event) {
- case ICO_SYC_EV_RES_ACQUIRE:
- _check_res_info("ICO_SYC_EV_RES_ACQUIRE", (ico_syc_res_info_t *)detail);
- break;
- case ICO_SYC_EV_RES_DEPRIVE:
- _check_res_info("ICO_SYC_EV_RES_DEPRIVE", (ico_syc_res_info_t *)detail);
- break;
- case ICO_SYC_EV_RES_WAITING:
- _check_res_info("ICO_SYC_EV_RES_WAITING", (ico_syc_res_info_t *)detail);
- break;
- case ICO_SYC_EV_RES_REVERT:
- _check_res_info("ICO_SYC_EV_RES_REVERT", (ico_syc_res_info_t *)detail);
- break;
- case ICO_SYC_EV_RES_RELEASE:
- _check_res_info("ICO_SYC_EV_RES_RELEASE", (ico_syc_res_info_t *)detail);
- break;
- case ICO_SYC_EV_INPUT_SET:
- _check_input_region("ICO_SYC_EV_INPUT_SET",
- (ico_syc_input_region_t *)detail);
- break;
- case ICO_SYC_EV_INPUT_UNSET:
- _check_input_region("ICO_SYC_EV_INPUT_UNSET",
- (ico_syc_input_region_t *)detail);
- break;
- default:
- break;
- }
-
- return;
-}
-
-/* test acquire resource */
-static void
-tst_acquire_res(const ico_syc_res_window_t *window,
- const ico_syc_res_sound_t *sound,
- const ico_syc_res_input_t *input,
- int type)
-{
- char *func = "ico_syc_acquire_res";
-
- res_context = ico_syc_acquire_res(window, sound, input, type);
- if (res_context == NULL) {
- print_ng("%s (context is NULL)", func);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test release resource */
-static void
-tst_release_res(void)
-{
- int ret;
- char *func = "ico_syc_release_res";
-
- ret = ico_syc_release_res(res_context);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test set input region */
-static void
-tst_set_input_region(const ico_syc_input_region_t *region, int attr)
-{
- int ret;
- char *func = "ico_syc_set_input_region";
-
- ret = ico_syc_set_input_region(region, attr);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test unset input region */
-static void
-tst_unset_input_region(const ico_syc_input_region_t *region)
-{
- int ret;
- char *func = "ico_syc_unset_input_region";
-
- ret = ico_syc_unset_input_region(region);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* ------------------------ */
-/* test main */
-/* ------------------------ */
-static
-Eina_Bool ico_syc_appresctl_test(void *data)
-{
- printf("\n");
- printf("##### ico_syc_appresctl API Test Start #####\n");
-
- /* window/sound resource */
- ico_syc_res_window_t window;
- ico_syc_res_sound_t sound;
- int type = ICO_SYC_RES_BASIC;
- /* input resource */
- ico_syc_res_input_t input;
- /* input region */
- ico_syc_input_region_t region;
- int attr = 1;
-
- /* set window resource info */
- window.ECU = "Center";
- window.display = "Center";
- window.layer = "OnScreen";
- window.layout = "Full";
- window.area = "Full";
- window.dispatchApp = "zzzzzzzz";
- window.role = "Message";
- window.resourceId = 8888;
- /* set sound resource info */
- sound.zone = "all";
- sound.name = "sound B";
- sound.id = "id B";
- sound.adjust = ICO_SYC_SOUND_MUTE;
- /* set sound resource info */
- input.name = "input C";
- input.event = 100;
- /* set input region info */
- strcpy(region.winname, TST_WIN_NAME);
- region.pos_x = 10;
- region.pos_y = 10;
- region.width = 200;
- region.height = 100;
- region.hotspot_x = 28;
- region.hotspot_y = 16;
- region.cursor_x = 35;
- region.cursor_y = 25;
- region.cursor_width = 150;
- region.cursor_height= 80;
- region.attr = 98765432;
-
- /* acquire window/sound/input */
- tst_acquire_res((const ico_syc_res_window_t *)&window,
- (const ico_syc_res_sound_t *)&sound,
- (const ico_syc_res_input_t *)&input,
- type);
- usleep(5000);
- /* set input region */
- tst_set_input_region(®ion, attr);
-
- sleep(2);
-
- /* release window/sound/input */
- tst_release_res();
- usleep(5000);
- /* unset input region */
- tst_unset_input_region(®ion);
-
- sleep(3);
-
- printf("##### ico_syc_appresctl API Test End #####\n");
- printf("\n");
-
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ------------------------ */
-/* quit test callback */
-/* ------------------------ */
-static Eina_Bool
-quit_test(void *data)
-{
- ico_syc_disconnect();
- ecore_main_loop_quit();
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-/* main */
-int
-main(int argc, char **argv)
-{
- ecore_init();
-
- ico_syc_connect(_syc_callback, NULL);
-
- ecore_timer_add(1, ico_syc_appresctl_test, NULL);
- ecore_timer_add(5, quit_test, NULL);
-
- ecore_main_loop_begin();
- ecore_shutdown();
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for App Resource Control API
- *
- * @date July-31-2013
- */
-
-#include<string.h>
-
-#include <ail.h>
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-int
-main(int argc, char **argv)
-{
- int id;
-
- for (id = 0; id < argc; id++) {
- if (strcmp(argv[id], "-add") == 0) {
- ail_desktop_add("test.ico.res.app");
- }
- else if (strcmp(argv[id], "-del") == 0) {
- ail_desktop_remove("test.ico.res.app");
- }
- }
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for Connect/Disconnect to System Controller API
- *
- * @date Aug-19-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <glib.h>
-
-#include "ico_syc_common.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Variable */
-/* ----------------------------------------------- */
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static void tst_connect(void);
-static void tst_disconnect(void);
-static int ico_syc_common_test(void);
-
-/* ----------------------------------------------- */
-/* Public API Test */
-/* ----------------------------------------------- */
-/* test connect */
-static void
-tst_connect(void)
-{
- int ret;
- char *func = "ico_syc_connect";
-
- ret = ico_syc_connect(NULL, NULL);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test disconnect */
-static void
-tst_disconnect(void)
-{
- (void)ico_syc_disconnect();
- print_ok("(void)ico_syc_disconnect");
-
- return;
-}
-
-/* test main */
-static int
-ico_syc_common_test()
-{
- tst_connect();
- sleep(1);
- tst_disconnect();
-
- sleep(3);
-
- return 1;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-static GMainLoop *g_mainloop = NULL;
-
-static gboolean
-exit_program(gpointer data)
-{
- g_main_loop_quit(g_mainloop);
-
- return FALSE;
-}
-
-/* main */
-int
-main(int argc, char **argv)
-{
- g_setenv("PKG_NAME", "org.test.ico.syc_common", 1);
- g_mainloop = g_main_loop_new(NULL, 0);
-
- printf("\n");
- printf("##### ico_syc_common API Test Start #####\n");
- ico_syc_common_test();
- printf("##### ico_syc_common API Test End #####\n");
- printf("\n");
-
- g_timeout_add_seconds(1, exit_program, NULL);
- g_main_loop_run(g_mainloop);
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#ifndef __TST_COMMON_H__
-#define __TST_COMMON_H__
-
-#include "ico_syc_type.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* log macro */
-#define print_ok(fmt, arg...) \
- do { \
- fprintf(stdout, \
- "[TestCase] " fmt " : OK\n", \
- ##arg); \
- } while (0)
-
-#define print_ng(fmt, arg...) \
- do { \
- fprintf(stdout, \
- "[TestCase] " fmt " : NG\n", \
- ##arg); \
- } while (0)
-
-
-/* test server uri */
-#define SRV_URI ":18081"
-
-/* return value */
-#define TST_APPID (char *)"org.test.syc.app"
-#define TST_WIN_NAME (char *)"surface A"
-
-#define TST_SURFACE 100
-#define TST_NODE 1
-#define TST_LAYER 2
-#define TST_POS_X 10
-#define TST_POS_Y 20
-#define TST_WIDTH 1024
-#define TST_HEIGHT 768
-#define TST_RAISE ICO_SYC_WIN_RAISE_RAISE
-#define TST_VISIBLE ICO_SYC_WIN_VISIBLE_SHOW
-#define TST_INVISIBLE ICO_SYC_WIN_VISIBLE_HIDE
-#define TST_ACTIVE ICO_SYC_WIN_ACTIVE_NONE
-#define TST_STRIDE 1
-#define TST_FORMAT ICO_SYC_THUMB_FORMAT_ARGB
-
-#define TST_ZONE_A (char *)"zone A"
-#define TST_ZONE_B (char *)"zone B"
-#define TST_NAME_A (char *)"name A"
-#define TST_NAME_B (char *)"name B"
-#define TST_NAME_C (char *)"name C"
-#define TST_ID_A (char *)"id A"
-#define TST_ID_B (char *)"id B"
-
-#define TST_ECU (char *)"ECU A"
-#define TST_display (char *)"display A"
-#define TST_layer (char *)"layer A"
-#define TST_layout (char *)"layout A"
-#define TST_area (char *)"area A"
-#define TST_dispatchApp (char *)"dispatchApp A"
-#define TST_role (char *)"role A"
-#define TST_resourceId 55555
-
-
-#define TST_ADJUST 1
-#define TST_INPUT_EV 2
-#define TST_RES_TYPE 0
-#define TST_REG_WIDTH 200
-#define TST_REG_HEIGHT 100
-#define TST_REG_HOT_X 120
-#define TST_REG_HOT_Y 80
-#define TST_REG_CUR_X 40
-#define TST_REG_CUR_Y 30
-#define TST_REG_CUR_WIDTH 160
-#define TST_REG_CUR_HEIGHT 100
-#define TST_REG_ATTR 12345678
-
-#define TST_USER_A (char *)"user A"
-#define TST_USER_B (char *)"User B"
-#define TST_USER_C (char *)"user c"
-
-#define TST_LASTINFO (char *)"{\"page\": \"last page\", \"time\": 5}"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TST_COMMON_H__ */
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for Input Control API
- *
- * @date July-31-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include "ico_syc_common.h"
-#include "ico_syc_inputctl.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Variable */
-/* ----------------------------------------------- */
-
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static void tst_add_input(const char *appid, const char *device,
- int input, int fix, int keycode);
-static void tst_delete_input(const char *appid, const char *device,
- int input);
-static void tst_send_input(const char *appid, int surface, int ev_type,
- int deviceno, int ev_time, int ev_code, int ev_value);
-static Eina_Bool ico_syc_inputctl_test(void *data);
-
-/* ----------------------------------------------- */
-/* Public API Test */
-/* ----------------------------------------------- */
-/* test add input */
-static void
-tst_add_input(const char *appid, const char *device,
- int input, int fix, int keycode)
-{
- int ret;
- char *func = "ico_syc_add_input";
-
- ret = ico_syc_add_input(appid, device, input, fix, keycode);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test delete input */
-static void
-tst_delete_input(const char *appid, const char *device, int input)
-{
- int ret;
- char *func = "ico_syc_delete_input";
-
- ret = ico_syc_delete_input(appid, device, input);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test send input */
-static void
-tst_send_input(const char *appid, int surface, int ev_type,
- int deviceno, int ev_time, int ev_code, int ev_value)
-{
-#if 0 /* SystemController 0.9.21(with GENIVI ivi-shell) not support send_input */
- int ret;
- char *func = "ico_syc_send_input";
-
- ret = ico_syc_send_input(appid, surface, ev_type, deviceno,
- ev_time, ev_code, ev_value);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-#endif
- return;
-}
-
-/* test main */
-static Eina_Bool
-ico_syc_inputctl_test(void *data)
-{
- const char *appid = "org.test.app.testapp";
- const char *device = "input.dev";
- int input = 100;
- int fix = ICO_SYC_INPUT_ALLOC_FIX;
- int keycode = 10;
- int surface = 12345;
- int ev_type = ICO_SYC_INPUT_TYPE_POINTER;
- int deviceno = 123;
- int ev_time = 2345;
- int ev_code = 1;
- int ev_value = 1;
-
- printf("\n");
- printf("##### ico_syc_inputctl API Test Start #####\n");
-
- tst_add_input(appid, device, input, fix, keycode);
- usleep(5000);
- tst_delete_input(appid, device, input);
- usleep(5000);
- tst_send_input(appid, surface, ev_type, deviceno, ev_time, ev_code, ev_value);
-
- printf("##### ico_syc_inputctl API Test End #####\n");
- printf("\n");
-
- return ECORE_CALLBACK_CANCEL;
-}
-/* ------------------------ */
-/* quit test callback */
-/* ------------------------ */
-static Eina_Bool
-quit_test(void *data)
-{
- ico_syc_disconnect();
- ecore_main_loop_quit();
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-/* main */
-int
-main(int argc, char **argv)
-{
- ecore_init();
-
- ico_syc_connect(NULL, NULL);
-
- ecore_timer_add(1, ico_syc_inputctl_test, NULL);
- ecore_timer_add(5, quit_test, NULL);
-
- ecore_main_loop_begin();
- ecore_shutdown();
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test server
- *
- * @date Aug-19-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <glib.h>
-#include <ico_uws.h>
-
-#include "ico_syc_msg_cmd_def.h"
-#include "ico_syc_msg.h"
-#include "ico_syc_private.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Define of static variable */
-/* ----------------------------------------------- */
-#define ZONE_EXIST 0
-#define ZONE_NO_EXIST 1
-
-static int num_close = 0;
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static int _get_command(const void *data, size_t len);
-static int _check_zone(const void *data, size_t len);
-static msg_t _create_winctl_msg(int cmd);
-static msg_t _create_winctl_attr_msg(int cmd, const char *type);
-static msg_t _create_winctl_move_msg(const void *data, size_t len);
-static msg_t _create_winctl_layer_msg(int cmd);
-static msg_t _create_userctl_msg(int cmd);
-static msg_t _create_resctl_msg(int cmd);
-static msg_t _create_resctl_region_msg(int cmd);
-static msg_t _create_msg(const void *data, size_t len);
-static void tst_uws_callback(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data);
-static int test_server(void);
-
-/* ----------------------------------------------- */
-/* Static function */
-/* ----------------------------------------------- */
-static int
-_get_command(const void *data, size_t len)
-{
- /* get command from receive data */
- JsonParser *parser = NULL;
- GError *error = NULL;
- gboolean gbool = FALSE;
- JsonNode *r_root = NULL;
- JsonObject *r_obj = NULL;
- int cmd = -1;
-
- /* get command */
- parser = json_parser_new();
- gbool = json_parser_load_from_data(parser, data, len, &error);
- if (gbool == FALSE) {
- g_object_unref(parser);
- return -1;
- }
- r_root = json_parser_get_root(parser);
- if (r_root == NULL) {
- g_object_unref(parser);
- return -1;
- }
- r_obj = json_node_get_object(r_root);
- cmd = json_object_get_int_member(r_obj, MSG_PRMKEY_CMD);
- g_object_unref(parser);
-
- return cmd;
-}
-
-static int
-_check_zone(const void *data, size_t len)
-{
- /* get command from receive data */
- JsonParser *parser = NULL;
- GError *error = NULL;
- gboolean gbool = FALSE;
- JsonNode *r_root = NULL;
- JsonObject *r_obj = NULL;
- JsonObject *arg_obj = NULL;
- int ret = -1;
-
- /* get command */
- parser = json_parser_new();
- gbool = json_parser_load_from_data(parser, data, len, &error);
- if (gbool == FALSE) {
- g_object_unref(parser);
- return -1;
- }
- r_root = json_parser_get_root(parser);
- if (r_root == NULL) {
- g_object_unref(parser);
- return -1;
- }
-
- r_obj = json_node_get_object(r_root);
- arg_obj = json_object_get_object_member(r_obj, MSG_PRMKEY_ARG);
- if (json_object_has_member(arg_obj, MSG_PRMKEY_ZONE) == TRUE) {
- ret = ZONE_EXIST;
- }
- else {
- ret = ZONE_NO_EXIST;
- }
- g_object_unref(parser);
-
- return ret;
-}
-
-static msg_t
-_create_winctl_msg(int cmd)
-{
- JsonObject *obj = NULL;
- JsonObject *argobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- argobj = json_object_new();
- if (obj == NULL || argobj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, cmd);
- json_object_set_string_member(argobj, MSG_PRMKEY_WINNAME, TST_WIN_NAME);
- json_object_set_int_member(argobj, MSG_PRMKEY_SURFACE, TST_SURFACE);
- json_object_set_int_member(argobj, MSG_PRMKEY_NODE, TST_NODE);
- json_object_set_int_member(argobj, MSG_PRMKEY_LAYER, TST_LAYER);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_X, TST_POS_X);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_Y, TST_POS_Y);
- json_object_set_int_member(argobj, MSG_PRMKEY_WIDTH, TST_WIDTH);
- json_object_set_int_member(argobj, MSG_PRMKEY_HEIGHT, TST_HEIGHT);
- json_object_set_int_member(argobj, MSG_PRMKEY_RAISE, TST_RAISE);
- json_object_set_int_member(argobj, MSG_PRMKEY_VISIBLE, TST_VISIBLE);
- json_object_set_int_member(argobj, MSG_PRMKEY_ACTIVE, TST_ACTIVE);
- json_object_set_int_member(argobj, MSG_PRMKEY_STRIDE, TST_STRIDE);
- json_object_set_int_member(argobj, MSG_PRMKEY_FORMAT, TST_FORMAT);
-
- json_object_set_object_member(obj, MSG_PRMKEY_ARG, argobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_winctl_attr_msg(int cmd, const char *type)
-{
- JsonObject *obj = NULL;
- JsonObject *argobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- argobj = json_object_new();
- if (obj == NULL || argobj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, cmd);
- json_object_set_string_member(argobj, MSG_PRMKEY_WINNAME, type);
- json_object_set_int_member(argobj, MSG_PRMKEY_SURFACE, TST_SURFACE);
- json_object_set_int_member(argobj, MSG_PRMKEY_NODE, TST_NODE);
- json_object_set_int_member(argobj, MSG_PRMKEY_LAYER, TST_LAYER);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_X, TST_POS_X);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_Y, TST_POS_Y);
- json_object_set_int_member(argobj, MSG_PRMKEY_WIDTH, TST_WIDTH);
- json_object_set_int_member(argobj, MSG_PRMKEY_HEIGHT, TST_HEIGHT);
- json_object_set_int_member(argobj, MSG_PRMKEY_RAISE, TST_RAISE);
- json_object_set_int_member(argobj, MSG_PRMKEY_VISIBLE, TST_VISIBLE);
- json_object_set_int_member(argobj, MSG_PRMKEY_ACTIVE, TST_ACTIVE);
- json_object_set_int_member(argobj, MSG_PRMKEY_STRIDE, TST_STRIDE);
- json_object_set_int_member(argobj, MSG_PRMKEY_FORMAT, TST_FORMAT);
-
- json_object_set_object_member(obj, MSG_PRMKEY_ARG, argobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_winctl_move_msg(const void *data, size_t len)
-{
- JsonObject *obj = NULL;
- JsonObject *argobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- argobj = json_object_new();
- if (obj == NULL || argobj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, MSG_CMD_CHANGE_ATTR);
- json_object_set_string_member(argobj, MSG_PRMKEY_WINNAME, "move");
- json_object_set_int_member(argobj, MSG_PRMKEY_SURFACE, TST_SURFACE);
- json_object_set_int_member(argobj, MSG_PRMKEY_NODE, TST_NODE);
- json_object_set_int_member(argobj, MSG_PRMKEY_LAYER, TST_LAYER);
- if (_check_zone(data, len) == ZONE_EXIST) {
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_X, 0);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_Y, 0);
- }
- else {
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_X, 10);
- json_object_set_int_member(argobj, MSG_PRMKEY_POS_Y, 10);
- }
- json_object_set_int_member(argobj, MSG_PRMKEY_WIDTH, TST_WIDTH);
- json_object_set_int_member(argobj, MSG_PRMKEY_HEIGHT, TST_HEIGHT);
- json_object_set_int_member(argobj, MSG_PRMKEY_RAISE, TST_RAISE);
- json_object_set_int_member(argobj, MSG_PRMKEY_VISIBLE, TST_VISIBLE);
- json_object_set_int_member(argobj, MSG_PRMKEY_ACTIVE, TST_ACTIVE);
- json_object_set_int_member(argobj, MSG_PRMKEY_STRIDE, TST_STRIDE);
- json_object_set_int_member(argobj, MSG_PRMKEY_FORMAT, TST_FORMAT);
-
- json_object_set_object_member(obj, MSG_PRMKEY_ARG, argobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_winctl_layer_msg(int cmd)
-{
- JsonObject *obj = NULL;
- JsonObject *argobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- argobj = json_object_new();
- if (obj == NULL || argobj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, MSG_CMD_CHANGE_LAYER_ATTR);
- json_object_set_int_member(argobj, MSG_PRMKEY_LAYER, TST_LAYER);
- if (cmd == MSG_CMD_SHOW_LAYER) {
- json_object_set_int_member(argobj, MSG_PRMKEY_VISIBLE, TST_VISIBLE);
- }
- else {
- json_object_set_int_member(argobj, MSG_PRMKEY_VISIBLE, TST_INVISIBLE);
- }
-
- json_object_set_object_member(obj, MSG_PRMKEY_ARG, argobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-
-static msg_t
-_create_userctl_msg(int cmd)
-{
- JsonObject *obj = NULL;
- JsonObject *argobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
- JsonArray *array = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- argobj = json_object_new();
- array = json_array_new();
- if (obj == NULL || argobj == NULL || array == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, cmd);
- json_object_set_int_member(argobj, MSG_PRMKEY_USER_NUM, 3);
-
- json_array_add_string_element(array, TST_USER_A);
- json_array_add_string_element(array, TST_USER_B);
- json_array_add_string_element(array, TST_USER_C);
- json_object_set_array_member(argobj, MSG_PRMKEY_USER_LIST, array);
-
- json_object_set_string_member(argobj, MSG_PRMKEY_USER_LOGIN, TST_USER_A);
- json_object_set_string_member(argobj, MSG_PRMKEY_LASTINFO, TST_LASTINFO);
-
- json_object_set_object_member(obj, MSG_PRMKEY_ARG, argobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_resctl_msg(int cmd)
-{
- JsonObject *obj = NULL;
- JsonObject *resobj = NULL;
- JsonObject *window_obj = NULL;
- JsonObject *sound_obj = NULL;
- JsonObject *input_obj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- resobj = json_object_new();
- window_obj = json_object_new();
- sound_obj = json_object_new();
- input_obj = json_object_new();
- if (obj == NULL || resobj == NULL || window_obj == NULL
- || sound_obj == NULL || input_obj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, cmd);
-
- /* window */
- json_object_set_string_member(window_obj, MSG_PRMKEY_RES_ZONE, TST_ZONE_A);
- json_object_set_string_member(window_obj, MSG_PRMKEY_RES_NAME, TST_NAME_A);
- json_object_set_string_member(window_obj, MSG_PRMKEY_RES_ID, TST_ID_A);
- /* sound */
- json_object_set_string_member(sound_obj, MSG_PRMKEY_RES_ZONE, TST_ZONE_B);
- json_object_set_string_member(sound_obj, MSG_PRMKEY_RES_NAME, TST_NAME_B);
- json_object_set_string_member(sound_obj, MSG_PRMKEY_RES_ID, TST_ID_B);
- json_object_set_int_member(sound_obj, MSG_PRMKEY_RES_ADJUST, TST_ADJUST);
- /* input */
- json_object_set_string_member(input_obj, MSG_PRMKEY_RES_NAME, TST_NAME_C);
- json_object_set_int_member(input_obj, MSG_PRMKEY_RES_EV, TST_INPUT_EV);
- /* type */
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_TYPE, TST_RES_TYPE);
-
- /* set object */
- json_object_set_object_member(resobj, MSG_PRMKEY_RES_WINDOW, window_obj);
- json_object_set_object_member(resobj, MSG_PRMKEY_RES_SOUND, sound_obj);
- json_object_set_object_member(resobj, MSG_PRMKEY_RES_INPUT, input_obj);
- json_object_set_object_member(obj, MSG_PRMKEY_RES, resobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_resctl_region_msg(int cmd)
-{
- JsonObject *obj = NULL;
- JsonObject *resobj = NULL;
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
-
- /* create json object and array */
- obj = json_object_new();
- resobj = json_object_new();
- if (obj == NULL || resobj == NULL) {
- return NULL;
- }
-
- /* set message */
- json_object_set_string_member(obj, MSG_PRMKEY_APPID, TST_APPID);
- json_object_set_int_member(obj, MSG_PRMKEY_CMD, cmd);
-
- /* region */
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_SURFACE, TST_SURFACE);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_POS_X, TST_POS_X);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_POS_Y, TST_POS_Y);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_WIDTH, TST_REG_WIDTH);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_HEIGHT, TST_REG_HEIGHT);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_HOT_X, TST_REG_HOT_X);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_HOT_Y, TST_REG_HOT_Y);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_CUR_X, TST_REG_CUR_X);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_CUR_Y, TST_REG_CUR_Y);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_CUR_WIDTH, TST_REG_CUR_WIDTH);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_CUR_HEIGHT, TST_REG_CUR_HEIGHT);
- json_object_set_int_member(resobj, MSG_PRMKEY_RES_ATTR, TST_REG_ATTR);
-
- /* set object */
- json_object_set_object_member(obj, MSG_PRMKEY_REGION, resobj);
-
- /* create root object */
- root = json_node_new(JSON_NODE_OBJECT);
- json_node_take_object(root, obj);
-
- /* create generator object */
- gen = json_generator_new();
- json_generator_set_root(gen, root);
-
- return gen;
-}
-
-static msg_t
-_create_msg(const void *data, size_t len)
-{
- int cmd = -1;
- JsonGenerator *gen = NULL;
-
- /* get command */
- cmd = _get_command(data, len);
- if (cmd < 0) {
- return NULL;
- }
-
- switch (cmd) {
- case MSG_CMD_CREATE:
- case MSG_CMD_DESTROY:
- case MSG_CMD_CHANGE_ACTIVE:
- gen = _create_winctl_msg(cmd);
- break;
- case MSG_CMD_SHOW:
- gen = _create_winctl_attr_msg(MSG_CMD_CHANGE_ATTR, "show");
- break;
- case MSG_CMD_HIDE:
- gen = _create_winctl_attr_msg(MSG_CMD_CHANGE_ATTR, "hide");
- break;
- case MSG_CMD_MOVE:
- gen = _create_winctl_move_msg(data, len);
- break;
- case MSG_CMD_CHANGE_LAYER:
- gen = _create_winctl_attr_msg(MSG_CMD_CHANGE_ATTR, "change layer");
- break;
- case MSG_CMD_MAP_THUMB:
- case MSG_CMD_UNMAP_THUMB:
- gen = _create_winctl_msg(cmd);
- break;
- case MSG_CMD_SHOW_LAYER:
- case MSG_CMD_HIDE_LAYER:
- gen = _create_winctl_layer_msg(cmd);
- break;
- case MSG_CMD_ADD_INPUT:
- case MSG_CMD_DEL_INPUT:
-#if 0 /* SystemController 0.9.21(with GENIVI ivi-shell) not support send_input */
- case MSG_CMD_SEND_INPUT:
-#endif
- gen = NULL;
- break;
- case MSG_CMD_CHANGE_USER:
- case MSG_CMD_GET_USERLIST:
- gen = _create_userctl_msg(cmd);
- break;
- case MSG_CMD_ACQUIRE_RES:
- case MSG_CMD_RELEASE_RES:
- case MSG_CMD_DEPRIVE_RES:
- case MSG_CMD_WAITING_RES:
- case MSG_CMD_REVERT_RES:
- gen = _create_resctl_msg(cmd);
- break;
- case MSG_CMD_SET_REGION:
- case MSG_CMD_UNSET_REGION:
- gen = _create_resctl_region_msg(cmd);
- break;
- default:
- gen = NULL;
- break;
- }
-
- return gen;
-}
-
-/* event callback */
-static void
-tst_uws_callback(const struct ico_uws_context *context,
- const ico_uws_evt_e event,
- const void *id,
- const ico_uws_detail *detail,
- void *user_data)
-{
- JsonNode *node = NULL;
- msg_t msg = NULL;
- msg_str_t data = NULL;
- size_t len = 0;
-
- switch (event) {
- case ICO_UWS_EVT_RECEIVE:
- msg = _create_msg((const void *)detail->_ico_uws_message.recv_data,
- detail->_ico_uws_message.recv_len);
- if (msg == NULL) break;
- data = json_generator_to_data(msg, &len);
- if (data == NULL) break;
-
- /* send return message */
- ico_uws_send((struct ico_uws_context *)context,
- (void *)id,
- (unsigned char *)data, len);
- printf("send: %s\n", (char *)data);
- /* free */
- g_free(data);
- node = json_generator_get_root(msg);
- json_object_unref(json_node_get_object(node));
- json_node_free(node);
- usleep(50);
- break;
- case ICO_UWS_EVT_CLOSE:
- num_close++;
- break;
- case ICO_UWS_EVT_OPEN:
- case ICO_UWS_EVT_ERROR:
- case ICO_UWS_EVT_ADD_FD:
- case ICO_UWS_EVT_DEL_FD:
- default:
- /* other event is not test */
- break;
- }
-
- return;
-}
-
-/* test main (server) */
-static int
-test_server(void)
-{
- struct ico_uws_context *context;
-
- /* create context */
- context = ico_uws_create_context(SRV_URI, ICO_SYC_PROTOCOL);
-
- if (context) {
- (void)ico_uws_set_event_cb(context, tst_uws_callback, NULL);
-
- /* service (loop) */
- while (num_close < 5) {
- ico_uws_service(context);
- usleep(50);
- }
-
- /* close */
- ico_uws_close(context);
- }
-
- return 1;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-static GMainLoop *g_mainloop = NULL;
-
-static gboolean
-exit_program(gpointer data)
-{
- g_main_loop_quit(g_mainloop);
-
- return FALSE;
-}
-
-/* main */
-int
-main(int argc, char **argv)
-{
- g_setenv("PKG_NAME", "org.test.ico.tst_server", 1);
- g_mainloop = g_main_loop_new(NULL, 0);
-
- test_server();
-
- g_timeout_add_seconds(2, exit_program, NULL);
- g_main_loop_run(g_mainloop);
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for User Control API
- *
- * @date Sep-5-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include "ico_syc_common.h"
-#include "ico_syc_userctl.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Variable */
-/* ----------------------------------------------- */
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static void _check_userlist(const char *ev_name, ico_syc_userlist_t *list);
-static void _syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data);
-static void tst_change_user(void);
-static void tst_get_userlist(void);
-static void tst_get_lastinfo(void);
-static void tst_set_lastinfo(void);
-static Eina_Bool ico_syc_userctl_test(void *data);
-
-/* ----------------------------------------------- */
-/* Public API Test */
-/* ----------------------------------------------- */
-static void
-_check_userlist(const char *ev_name, ico_syc_userlist_t *list)
-{
- int check_flag = 0;
- char *name;
- int id;
-
- printf("--- %s userlist[%d] (", ev_name, list->user_num);
- for (id = 0; id < list->user_num; id++) {
- if (id > 0) printf(", ");
- name = *(list->userlist);
- printf("%s", name);
- if (strcmp(name, TST_USER_A) != 0 && strcmp(name, TST_USER_B) != 0
- && strcmp(name, TST_USER_C) != 0) {
- check_flag++;
- }
- list->userlist++;
- }
- printf("), login[%s]\n", list->user_login);
-
- if (strcmp(list->user_login, TST_USER_A) != 0) {
- check_flag++;
- }
-
- if (check_flag == 0) {
- print_ok("callback (%s)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data)
-{
- switch (event) {
- case ICO_SYC_EV_USERLIST:
- _check_userlist("ICO_SYC_EV_USERLIST", (ico_syc_userlist_t *)detail);
- break;
- case ICO_SYC_EV_AUTH_FAIL:
- if (detail == NULL) {
- printf("--- ICO_SYC_EV_AUTH_FAIL (detail is NULL)\n");
- print_ok("callback (ICO_SYC_EV_AUTH_FAIL)");
- }
- else {
- printf("--- ICO_SYC_EV_AUTH_FAIL (detail is not NULL)\n");
- print_ng("callback (ICO_SYC_EV_AUTH_FAIL)");
- }
- break;
- case ICO_SYC_EV_LASTINFO:
- printf("--- lastinfo: %s\n", (char *)detail);
- if (strcmp((char *)detail, TST_LASTINFO) == 0) {
- print_ok("callback (ICO_SYC_EV_LASTINFO)");
- }
- else {
- print_ng("callback (ICO_SYC_EV_LASTINFO)");
- }
- break;
- default:
- break;
- }
-
- return;
-}
-
-/* test change user */
-static void
-tst_change_user(void)
-{
- (void)ico_syc_change_user("Alice", "");
- print_ok("(void)ico_syc_change_user");
-
- return;
-}
-
-/* test get userlist */
-static void
-tst_get_userlist(void)
-{
- (void)ico_syc_get_userlist();
- print_ok("(void)ico_syc_get_userlist");
-
- return;
-}
-
-/* test get lastinfo */
-static void
-tst_get_lastinfo(void)
-{
- (void)ico_syc_get_lastinfo();
- print_ok("(void)ico_syc_get_lastinfo");
-
- return;
-}
-
-/* test set lastinfo */
-static void
-tst_set_lastinfo(void)
-{
- (void)ico_syc_set_lastinfo(TST_LASTINFO);
- print_ok("(void)ico_syc_set_lastinfo");
-
- return;
-}
-
-/* test main */
-static Eina_Bool
-ico_syc_userctl_test(void *data)
-{
- printf("\n");
- printf("##### ico_syc_userctl API Test Start #####\n");
-
- tst_change_user();
- usleep(5000);
- tst_get_userlist();
- usleep(5000);
- tst_set_lastinfo();
- usleep(5000);
- tst_get_lastinfo();
-
- printf("##### ico_syc_userctl API Test End #####\n");
- printf("\n");
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ------------------------ */
-/* quit test callback */
-/* ------------------------ */
-static Eina_Bool
-quit_test(void *data)
-{
- ico_syc_disconnect();
- ecore_main_loop_quit();
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-/* main */
-int
-main(int argc, char **argv)
-{
- ecore_init();
-
- ico_syc_connect(_syc_callback, NULL);
-
- ecore_timer_add(1, ico_syc_userctl_test, NULL);
- ecore_timer_add(5, quit_test, NULL);
-
- ecore_main_loop_begin();
- ecore_shutdown();
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief test suite for Window Control API
- *
- * @date Aug-19-2013
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include "ico_syc_common.h"
-#include "ico_syc_winctl.h"
-
-#include "tst_common.h"
-
-/* ----------------------------------------------- */
-/* Variable */
-/* ----------------------------------------------- */
-
-
-/* ----------------------------------------------- */
-/* Define of static function */
-/* ----------------------------------------------- */
-static void _check_win_info(const char *ev_name, ico_syc_win_info_t *info);
-static void _check_win_attr(const char *ev_name, ico_syc_win_attr_t *attr);
-static void _check_thumb_info(const char *ev_name, ico_syc_thumb_info_t *info);
-static void _check_layer_attr(const char *ev_name, ico_syc_layer_attr_t *attr);
-/* callback */
-static void _syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data);
-/* window */
-static void tst_show(const char *appid, int surface,
- ico_syc_animation_t *animation);
-static void tst_hide(const char *appid, int surface,
- ico_syc_animation_t *animation);
-static void tst_move(const char *appid, int surface,
- ico_syc_win_move_t *move,
- ico_syc_animation_t *animation, const char *type);
-static void tst_change_active(const char *appid, int surface);
-static void tst_change_layer(const char *appid, int surface, int layer);
-/* thumbnail */
-static void tst_map_thumb(int surface, int framerate);
-static void tst_unmap_thumb(int surface);
-/* layer */
-static void tst_show_layer(int layer);
-static void tst_hide_layer(int layer);
-/* test main */
-static Eina_Bool ico_syc_winctl_test(void *data);
-
-/* ----------------------------------------------- */
-/* Public API Test */
-/* ----------------------------------------------- */
-static void
-_check_win_info(const char *ev_name, ico_syc_win_info_t *info)
-{
- printf("--- %s ", ev_name);
- printf("(appid[%s], name[%s], surface[%d])\n",
- info->appid, info->name, info->surface);
-
- if (strcmp(info->appid, TST_APPID) == 0
- && strcmp(info->name, TST_WIN_NAME) == 0
- && info->surface == TST_SURFACE) {
- print_ok("callback (%s)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_check_win_attr(const char *ev_name, ico_syc_win_attr_t *attr)
-{
- printf("--- %s\n", ev_name);
- printf("\t(appid[%s], name[%s], surface[%d], node[%d], layer[%d],\n",
- attr->appid, attr->name, attr->surface, attr->nodeid, attr->layer);
- printf("\t (x,y)[%d, %d], width[%d], height[%d], ",
- attr->pos_x, attr->pos_y, attr->width, attr->height);
- printf("raise[%d], visible[%d], active[%d])\n",
- attr->raise, attr->visible, attr->active);
-
- // move
- if (strcmp(attr->name, "move") == 0) {
- if ((attr->pos_x > 0) && (attr->pos_y > 0)) {
- print_ok("callback (%s move (pos))", ev_name);
- }
- else {
- print_ok("callback (%s move (zone))", ev_name);
- }
- return;
- }
-
- // not move
- if (strcmp(attr->appid, TST_APPID) == 0
- && attr->surface == TST_SURFACE && attr->nodeid == TST_NODE
- && attr->layer == TST_LAYER && attr->pos_x == TST_POS_X
- && attr->pos_y == TST_POS_Y && attr->width == TST_WIDTH
- && attr->height == TST_HEIGHT && attr->raise == TST_RAISE
- && attr->visible == TST_VISIBLE && attr->active == TST_ACTIVE) {
- print_ok("callback (%s %s)", ev_name, attr->name);
- }
- else {
- print_ng("callback (%s %s)", ev_name, attr->name);
- }
-
- return;
-}
-
-static void
-_check_thumb_info(const char *ev_name, ico_syc_thumb_info_t *info)
-{
- printf("--- %s ", ev_name);
- printf("\t(appid[%s], surface[%d], width[%d], height[%d], ",
- info->appid, info->surface, info->width, info->height);
- printf("stride[%d], format[%d])\n",
- info->stride, info->format);
-
- if (strcmp(info->appid, TST_APPID) == 0
- && info->surface == TST_SURFACE
- && info->width == TST_WIDTH && info->height == TST_HEIGHT
- && info->stride == TST_STRIDE && info->format == TST_FORMAT) {
- print_ok("callback (%s)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_check_layer_attr(const char *ev_name, ico_syc_layer_attr_t *attr)
-{
- printf("--- %s ", ev_name);
- printf("(layer[%d], visible[%d])\n",
- attr->layer, attr->visible);
-
- if (attr->layer == TST_LAYER && attr->visible == TST_VISIBLE) {
- print_ok("callback (%s show)", ev_name);
- }
- else if (attr->layer == TST_LAYER && attr->visible == TST_INVISIBLE) {
- print_ok("callback (%s hide)", ev_name);
- }
- else {
- print_ng("callback (%s)", ev_name);
- }
-
- return;
-}
-
-static void
-_syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data)
-{
-
- switch (event) {
- case ICO_SYC_EV_WIN_CREATE:
- _check_win_info("ICO_SYC_EV_WIN_CREATE", (ico_syc_win_info_t *)detail);
- break;
- case ICO_SYC_EV_WIN_DESTROY:
- _check_win_info("ICO_SYC_EV_WIN_DESTROY", (ico_syc_win_info_t *)detail);
- break;
- case ICO_SYC_EV_WIN_ACTIVE:
- _check_win_info("ICO_SYC_EV_WIN_ACTIVE", (ico_syc_win_info_t *)detail);
- break;
- case ICO_SYC_EV_WIN_ATTR_CHANGE:
- _check_win_attr("ICO_SYC_EV_WIN_ATTR_CHANGE",
- (ico_syc_win_attr_t *)detail);
- break;
- case ICO_SYC_EV_THUMB_ERROR:
- _check_thumb_info("ICO_SYC_EV_THUMB_ERROR",
- (ico_syc_thumb_info_t *)detail);
- break;
- case ICO_SYC_EV_THUMB_CHANGE:
- _check_thumb_info("ICO_SYC_EV_THUMB_CHANGE",
- (ico_syc_thumb_info_t *)detail);
- break;
- case ICO_SYC_EV_THUMB_UNMAP:
- _check_thumb_info("ICO_SYC_EV_THUMB_UNMAP",
- (ico_syc_thumb_info_t *)detail);
- break;
- case ICO_SYC_EV_LAYER_ATTR_CHANGE:
- _check_layer_attr("ICO_SYC_EV_LAYER_ATTR_CHANGE",
- (ico_syc_layer_attr_t *)detail);
- break;
- default:
- break;
- }
-
- return;
-}
-
-/* test show window */
-static void
-tst_show(const char *appid, int surface, ico_syc_animation_t *animation)
-{
- int ret;
- char *func = "ico_syc_show";
-
- ret = ico_syc_show(appid, surface, animation);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test hide window */
-static void
-tst_hide(const char *appid, int surface, ico_syc_animation_t *animation)
-{
- int ret;
- char *func = "ico_syc_hide";
-
- ret = ico_syc_hide(appid, surface, animation);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test move window */
-static void
-tst_move(const char *appid, int surface,
- ico_syc_win_move_t *move,
- ico_syc_animation_t *animation, const char *type)
-{
- int ret;
- char *func = "ico_syc_move";
-
- ret = ico_syc_move(appid, surface, move, animation);
- if (ret != 0) {
- print_ng("%s (%s) (ret: %d)", func, type, ret);
- return;
- }
- print_ok("%s (%s)", func, type);
-
- return;
-}
-
-/* test change active window */
-static void
-tst_change_active(const char *appid, int surface)
-{
- int ret;
- char *func = "ico_syc_change_active";
-
- ret = ico_syc_change_active(appid, surface);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test change window layer */
-static void
-tst_change_layer(const char *appid, int surface, int layer)
-{
- int ret;
- char *func = "ico_syc_change_layer";
-
- ret = ico_syc_change_layer(appid, surface, layer);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test map thumbnail */
-static void
-tst_map_thumb(int surface, int framerate)
-{
- int ret;
- char *func = "ico_syc_map_thumb";
-
- ret = ico_syc_map_thumb(surface, framerate, " ");
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test unmap thumbnail */
-static void
-tst_unmap_thumb(int surface)
-{
- int ret;
- char *func = "ico_syc_unmap_thumb";
-
- ret = ico_syc_unmap_thumb(surface);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test show layer */
-static void
-tst_show_layer(int layer)
-{
- int ret;
- char *func = "ico_syc_show_layer";
-
- ret = ico_syc_show_layer(layer);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* test hide layer */
-static void
-tst_hide_layer(int layer)
-{
- int ret;
- char *func = "ico_syc_hide_layer";
-
- ret = ico_syc_hide_layer(layer);
- if (ret != 0) {
- print_ng("%s (ret: %d)", func, ret);
- return;
- }
- print_ok("%s", func);
-
- return;
-}
-
-/* ------------------------------- */
-/* test main */
-/* ------------------------------- */
-static Eina_Bool
-ico_syc_winctl_test(void *data)
-{
- const char *appid = "org.test.app.testapp";
- int surface = 98765;
- int layer = 5;
- ico_syc_win_move_t move, move_pos;
- ico_syc_animation_t animation;
-
- printf("\n");
- printf("##### ico_syc_winctl API Test Start #####\n");
-
- /* set move info (zone) */
- move.zone = "center:bottom";
- move.width = ICO_SYC_WIN_NOCHANGE;
- move.height = 600;
- /* set move info (position) */
- move_pos.zone = NULL;
- move_pos.pos_x = 10;
- move_pos.pos_y = 20;
- move_pos.width = 1024;
- move_pos.height = ICO_SYC_WIN_NOCHANGE;
-
- /* set animation data */
- animation.name = "fade";
- animation.time = 200;
-
- /* window */
- tst_show(appid, surface, &animation);
- usleep(5000);
- tst_hide(appid, surface, NULL);
- usleep(5000);
- tst_move(appid, surface, &move, &animation, "zone");
- usleep(5000);
- tst_move(appid, surface, &move_pos, NULL, "pos");
- usleep(5000);
- tst_change_active(appid, surface);
- usleep(5000);
- tst_change_layer(appid, surface, layer);
-
- sleep(1);
-
- /* thumbnail */
- tst_map_thumb(surface, 200);
- usleep(5000);
- tst_unmap_thumb(surface);
-
- sleep(1);
-
- /* layer */
- tst_show_layer(layer);
- usleep(5000);
- tst_hide_layer(layer);
-
- printf("##### ico_syc_winctl API Test End #####\n");
- printf("\n");
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ------------------------ */
-/* quit test callback */
-/* ------------------------ */
-static Eina_Bool
-quit_test(void *data)
-{
- ico_syc_disconnect();
- ecore_main_loop_quit();
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/* ----------------------------------------------- */
-/* Main */
-/* ----------------------------------------------- */
-/* main */
-int
-main(int argc, char **argv)
-{
- ecore_init();
-
- ico_syc_connect(_syc_callback, NULL);
-
- ecore_timer_add(1, ico_syc_winctl_test, NULL);
- ecore_timer_add(5, quit_test, NULL);
-
- ecore_main_loop_begin();
- ecore_shutdown();
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoBackground.cpp
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <exception>
-#include <string>
-
-#include "CicoBackground.h"
-#include "CicoLog.h"
-
-/**
- * Default Constructor
- */
-CicoBackground::CicoBackground(const Evas *parent,
- const CicoGeometry &geometry,
- const CicoColor &color)
- : CicoEvasObject(parent, CicoEvasObject::OBJTYPE_RECTANGLE, geometry),
- _color(color)
-{
- ICO_DBG("CicoBackground::CicoBackground entry");
-
- /* setup attribute background object */
- /* set color */
- setColor(color);
-
- /* show object */
- show();
-
- ICO_DBG("CicoBackground::CicoBackground exit");
-}
-
-/**
- * Destructor
- */
-CicoBackground::~CicoBackground()
-{
- ICO_DBG("CicoBackground::~CicoBackground entry");
- ICO_DBG("CicoBackground::~CicoBackground exit");
-}
-
-/**
- * Set background color
- */
-void
-CicoBackground::setColor(const CicoColor &color)
-{
- ICO_DBG("CicoBackground::setColor entry");
- _color = color;
- ICO_DBG("color(R:%03d G:%03d B:%03d A:%03d)",
- _color._r, _color._g,
- _color._b, _color._a);
- evas_object_color_set(_object,
- _color._r, _color._g,
- _color._b, _color._a);
- ICO_DBG("CicoBackground::setColor exit");
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoBackground.h
- *
- * @brief
- */
-/*========================================================================*/
-
-#include "CicoEvasObject.h"
-#include "CicoColor.h"
-
-#ifndef __CICO_BACKGROUND_H__
-#define __CICO_BACKGROUND_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-class CicoBackground : public CicoEvasObject {
-public:
- /* Constructor */
- CicoBackground(const Evas *parent,
- const CicoGeometry &geometry,
- const CicoColor &color);
-
- /* Destructor */
- virtual ~CicoBackground();
-
- /* Get this object geometry */
- void setColor(const CicoColor &color);
-
-protected:
- /* Default Constructor */
- CicoBackground();
-
- /* Assignment Operator */
- CicoBackground& operator=(const CicoBackground &object);
-
- /* Copy Constructor */
- CicoBackground(const CicoBackground &object);
-
-private:
- /* color of background object */
- CicoColor _color;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_BACKGROUND_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoBaseWin.cpp
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <exception>
-#include <string>
-
-#include "CicoBaseWin.h"
-#include "CicoLog.h"
-//#include "Ecore_Wayland.h"
-//#include "Ecore.h"
-
-Ecore_Evas* CicoBaseWin::_window = NULL;
-
-static void
-_object_focus_in_cb(void *data,
- Evas *e,
- void *event_info)
-{
- int x, y, w, h;
- ICO_DBG("#####_object_focus_in_cb() called.");
- /* show window */
- ecore_evas_show(CicoBaseWin::_window);
-
- ecore_evas_geometry_get (CicoBaseWin::_window, &x, &y, &w, &h);
- ICO_DBG("#####_object_focus_in_cb(x=%d y=%d w=%d h=%d)", x, y, w, h);
-}
-
-static void
-_object_obj_focus_in_cb(void *data,
- Evas *e,
- void *event_info)
-{
- ICO_DBG("$$$$$_object_obj_focus_in_cb() called.");
-}
-
-/**
- * Default Constructor
- */
-CicoBaseWin::CicoBaseWin(const char *title,
- const CicoGeometry &geometry)
- : //_window(NULL),
- _geometry(geometry)
-{
- ICO_DBG("CicoBaseWin::CicoBaseWin entry");
-
- /* create window */
- _window = ecore_evas_new(NULL, _geometry._x, _geometry._y,
- _geometry._w, geometry._h, "frame=0");
- if (NULL == _window) {
- ICO_ERR("ecore_evas_new() failed.");
- throw std::string("ecore_evas_new() failed.");
- }
-
- /* get display screen size */
-// ecore_main_loop_iterate();
-// ecore_wl_screen_size_get(&_width, &_height);
-// _INFO("Display Screen Size(%dx%d)", _width, _height);
-
- /* set callback on destroy */
- ecore_evas_callback_destroy_set(_window, CicoBaseWin::onDestroy);
-
- /* setup attribute window */
- /* set title */
- ecore_evas_title_set(_window, title);
-
- /* enable alpha */
- ecore_evas_alpha_set(_window, EINA_TRUE);
-
- /* chanage window size */
- ecore_evas_resize(_window, _geometry._w, geometry._h);
-
- evas_event_callback_add(getEvas(), EVAS_CALLBACK_CANVAS_FOCUS_IN,
- _object_focus_in_cb, NULL);
- evas_event_callback_add(getEvas(), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
- _object_obj_focus_in_cb, NULL);
-
- /* show window */
- ecore_evas_show(_window);
-
- ICO_DBG("CicoBaseWin::CicoBaseWin exit");
-}
-
-/**
- * Destructor
- */
-CicoBaseWin::~CicoBaseWin()
-{
- ICO_DBG("CicoBaseWin::~CicoBaseWin entry");
- ICO_DBG("CicoBaseWin::~CicoBaseWin exit");
-}
-
-/**
- * Show
- */
-void
-CicoBaseWin::show()
-{
- ICO_DBG("CicoBaseWin::show entry");
- ecore_evas_show(_window);
- ICO_DBG("CicoBaseWin::show exit");
-}
-
-/**
- *
- */
-Ecore_Evas*
-CicoBaseWin::getEcoreEvas(void) const
-{
- return _window;
-}
-
-/**
- *
- */
-Evas*
-CicoBaseWin::getEvas(void) const
-{
- return ecore_evas_get(_window);
-}
-
-/**
- *
- */
-void CicoBaseWin::onDestroy(Ecore_Evas *window)
-{
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoBaseWin.h
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <stdio.h>
-#include <Ecore_Evas.h>
-
-#include "CicoGeometry.h"
-
-#ifndef __CICO_BASE_WIN_H__
-#define __CICO_BASE_WIN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-class CicoBaseWin {
-public:
- // Default Constructor
- CicoBaseWin(const char *title,
- const CicoGeometry &geometry);
-
- // Destructor
- virtual ~CicoBaseWin();
-
- // Show Window
- void show(void);
-
- // Get instance of ecore_evas
- Ecore_Evas* getEcoreEvas(void) const;
-
- // Get instance of evas
- Evas* getEvas(void) const;
-
-protected:
- // Default Constructor
- CicoBaseWin();
-
- // Assignment Operator
- CicoBaseWin& operator=(const CicoBaseWin &object);
-
- // Copy Constructor
- CicoBaseWin(const CicoBaseWin &object);
-
-private:
- static void onDestroy(Ecore_Evas *window);
-
-
-public:
- static Ecore_Evas *_window;
-private:
-
- CicoGeometry _geometry;
-
-// CicoBackground *_background;
-
-// CicoImage *_bgImage;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_BASE_WIN_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoColor.cpp
- *
- * @brief Color Implementaion
- */
-/*========================================================================*/
-
-#include "CicoColor.h"
-
-/**
- * Default Constructor
- */
-CicoColor::CicoColor(int r, int g, int b, int a)
- : _r(r), _g(g), _b(b), _a(a)
-{
-}
-
-/**
- * Copy Constructor
- */
-CicoColor::CicoColor(const CicoColor &object)
-{
- _r = object._r;
- _g = object._g;
- _b = object._b;
- _a = object._a;
-}
-
-
-/**
- * Destructor
- */
-CicoColor::~CicoColor()
-{
-}
-
-/**
- * Assignment Operator
- */
-CicoColor&
-CicoColor::operator=(const CicoColor& object)
-{
- _r = object._r;
- _g = object._g;
- _b = object._b;
- _a = object._a;
-
- return *this;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoColor.h
- *
- * @brief
- */
-/*========================================================================*/
-
-#ifndef __CICO_COLOR_H__
-#define __CICO_COLOR_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-class CicoColor {
-public:
- /**
- * Constructor
- */
- CicoColor(int r, int g, int b, int a);
-
- /**
- * Assignment Operator
- */
- CicoColor& operator=(const CicoColor &object);
-
- /**
- * Destructor
- */
- ~CicoColor();
-
- /**
- * Copy Constructor
- */
- CicoColor(const CicoColor &object);
-
-private:
- /**
- * Default Constructor
- */
- CicoColor();
-
-public:
- int _r;
- int _g;
- int _b;
- int _a;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_COLOR_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoEFLApp.cpp
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <exception>
-#include <string>
-#include "Ecore.h"
-#include "CicoEFLApp.h"
-#include "CicoLog.h"
-
-/*========================================================================*/
-app_event_callback_s CicoEFLApp::m_appEventCB = {
- .create = CicoEFLApp::app_create,
- .terminate = CicoEFLApp::app_terminate,
- .pause = CicoEFLApp::app_pause,
- .resume = CicoEFLApp::app_resume,
- .service = CicoEFLApp::app_service,
- .low_memory = CicoEFLApp::app_low_memory,
- .low_battery = CicoEFLApp::app_low_battery,
- .device_orientation = CicoEFLApp::app_device_orientation,
- .language_changed = CicoEFLApp::app_language_changed,
- .region_format_changed = CicoEFLApp::app_region_format_changed
-};
-
-/*========================================================================*/
-/**
- * Default Constructor
- */
-CicoEFLApp::CicoEFLApp()
-{
- ICO_DBG("CicoEFLApp::CicoEFLApp Enter");
- ICO_DBG("CicoEFLApp::CicoEFLApp Leave");
-}
-
-/**
- * Destructor
- */
-CicoEFLApp::~CicoEFLApp()
-{
- ICO_DBG("CicoEFLApp::~CicoEFLApp Enter");
- ICO_DBG("CicoEFLApp::~CicoEFLApp Leave");
-}
-
-/**
- * Start Main Loop
- */
-int
-CicoEFLApp::start(int argc, char **argv)
-{
- ICO_DBG("CicoEFLApp::start Enter");
-#if 0
- return app_efl_main(&argc, &argv, &m_appEventCB, this);
-#else
- /* init ecore*/
- if (0 == ecore_init()) {
- ICO_DBG("CIcoUIApp::start Leave");
- return 0;
- }
-
- if (false== onCreate(NULL)) {
- ICO_DBG("CicoEFLApp::start Leave");
- return 0;
- }
-
- ecore_main_loop_begin();
- ICO_DBG("CicoEFLApp::start Leave");
- return 0;
-#endif
- ICO_DBG("CicoEFLApp::start Leave");
-}
-
-/**
- * Stop Main Loop
- */
-int
-CicoEFLApp::stop(void)
-{
- return 0;
-}
-
-const char*
-CicoEFLApp::app_error_to_string(int error)
-{
- switch(error) {
- case APP_ERROR_NONE:
- return (const char*)"APP_ERROR_NONE";
- break;
- case APP_ERROR_INVALID_PARAMETER:
- return (const char*)"APP_ERROR_INVALID_PARAMETER";
- break;
- case APP_ERROR_OUT_OF_MEMORY:
- return (const char*)"APP_ERROR_OUT_OF_MEMORY";
- break;
- case APP_ERROR_INVALID_CONTEXT:
- return (const char*)"APP_ERROR_INVALID_CONTEXT";
- break;
- case APP_ERROR_NO_SUCH_FILE:
- return (const char*)"APP_ERROR_NO_SUCH_FILE";
- break;
- case APP_ERROR_ALREADY_RUNNING:
- return (const char*)"APP_ERROR_ALREADY_RUNNING";
- break;
- default:
- break;
- }
-
- return (const char*)"TIZEN_ERROR_UNKNOWN";
-}
-
-bool
-CicoEFLApp::onCreate(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onCreate called.");
- return false;
-}
-
-void
-CicoEFLApp::onTerminate(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onTerminate called.");
-}
-
-void
-CicoEFLApp::onPause(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onPause called.");
-}
-
-void
-CicoEFLApp::onResume(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onResume called.");
-}
-
-void
-CicoEFLApp::onService(service_h service, void *user_data)
-{
- ICO_WRN("CicoEFLApp::onService called.");
-}
-
-void
-CicoEFLApp::onLowMemory(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onLowMemory called.");
-}
-
-void
-CicoEFLApp::onLowBattery(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onLowBattery called.");
-}
-
-void
-CicoEFLApp::onDeviceOrientation(app_device_orientation_e orientation,
- void *user_data)
-{
- ICO_WRN("CicoEFLApp::onDeviceOrientation called.");
-}
-
-void
-CicoEFLApp::onLanguageChanged(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onLanguageChanged called.");
-}
-
-void
-CicoEFLApp::onRegionFormatChanged(void *user_data)
-{
- ICO_WRN("CicoEFLApp::onRegionFormatChanged called.");
-}
-
-bool
-CicoEFLApp::app_create(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_create Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_create Leave");
- return false;
- }
-
- int ret = static_cast<CicoEFLApp*>(user_data)->onCreate(user_data);
-
- ICO_DBG("CicoEFLApp::app_create Leave(%d)", ret);
-
- return ret;
-}
-
-void
-CicoEFLApp::app_terminate(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_terminate Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_terminate Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onTerminate(user_data);
-
- ICO_DBG("CicoEFLApp::app_terminate Leave");
-}
-
-void
-CicoEFLApp::app_pause(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_pause Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_pause Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onPause(user_data);
-
- ICO_DBG("CicoEFLApp::app_pause Leave");
-}
-
-void
-CicoEFLApp::app_resume(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_resume Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_resume Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onResume(user_data);
-
- ICO_DBG("CicoEFLApp::app_resume Leave");
-}
-
-void
-CicoEFLApp::app_service(service_h service, void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_service Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_service Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onService(service, user_data);
-
- ICO_DBG("CicoEFLApp::app_service Leave");
-}
-
-void
-CicoEFLApp::app_low_memory(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_low_memory Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_low_memory Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onLowMemory(user_data);
-
- ICO_DBG("CicoEFLApp::app_low_memory Leave");
-}
-
-void
-CicoEFLApp::app_low_battery(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_low_battery Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_low_battery Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onLowBattery(user_data);
-
- ICO_DBG("CicoEFLApp::app_low_battery Leave");
-}
-
-void
-CicoEFLApp::app_device_orientation(app_device_orientation_e orientation,
- void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_device_orientation Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_device_orientation Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onDeviceOrientation(orientation,
- user_data);
-
- ICO_DBG("CicoEFLApp::app_device_orientation Leave");
-}
-
-void
-CicoEFLApp::app_language_changed(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_language_changed Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_device_orientation Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onLanguageChanged(user_data);
-
- ICO_DBG("CicoEFLApp::app_language_changed Leave");
-}
-
-void
-CicoEFLApp::app_region_format_changed(void *user_data)
-{
- ICO_DBG("CicoEFLApp::app_region_format_changed Enter");
-
- if (NULL == user_data) {
- ICO_DBG("CicoEFLApp::app_device_orientation Leave");
- return;
- }
-
- static_cast<CicoEFLApp*>(user_data)->onRegionFormatChanged(user_data);
-
- ICO_DBG("CicoEFLApp::app_region_format_changed Leave");
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoEFLApp.h
- *
- * @brief
- */
-/*========================================================================*/
-#ifndef __CICO_EFL_APP_H__
-#define __CICO_EFL_APP_H__
-
-#include <app.h>
-
-class CicoEFLApp {
-public:
- // default constructor
- CicoEFLApp();
-
- /**
- * Destructor
- */
- virtual ~CicoEFLApp();
-
- /**
- * Start Main Loop
- */ int start(int argc, char **argv);
-
- /**
- * Stop Main Loop
- */
- int stop(void);
-
- /**
- * Convert application error to string
- */
- const char* app_error_to_string(int error);
-
- virtual bool onCreate(void *user_data);
- virtual void onTerminate(void *user_data);
- virtual void onPause(void *user_data);
- virtual void onResume(void *user_data);
- virtual void onService(service_h service, void *user_data);
- virtual void onLowMemory(void *user_data);
- virtual void onLowBattery(void *user_data);
- virtual void onDeviceOrientation(app_device_orientation_e orientation,
- void *user_data);
- virtual void onLanguageChanged(void *user_data);
- virtual void onRegionFormatChanged(void *user_data);
-
-protected:
- // assignment operator
- CicoEFLApp& operator=(const CicoEFLApp &object);
-
- // copy constructor
- CicoEFLApp(const CicoEFLApp &object);
-
-private:
- static bool app_create(void *user_data);
- static void app_terminate(void *user_data);
- static void app_pause(void *user_data);
- static void app_resume(void *user_data);
- static void app_service(service_h service, void *user_data);
- static void app_low_memory(void *user_data);
- static void app_low_battery(void *user_data);
- static void app_device_orientation(app_device_orientation_e orientation,
- void *user_data);
- static void app_language_changed(void *user_data);
- static void app_region_format_changed(void *user_data);
-
-private:
- // application callbacks
- static app_event_callback_s m_appEventCB;
-};
-#endif /* __CICO_EFL_APP_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoEvasObject.cpp
- *
- * @brief Class implemetation of EvasObject Object
- */
-/*========================================================================*/
-
-#include <exception>
-#include <string>
-
-#include "CicoEvasObject.h"
-#include "CicoLog.h"
-//#include "Ecore_Wayland.h"
-
-/*------------------------------------------------------------------------*/
-/**
- * @brief Constructor
- *
- * @param [IN] parent parent of this object
- * @param [IN] geometry geometry of this object
- */
-/*------------------------------------------------------------------------*/
-CicoEvasObject::CicoEvasObject(const Evas *parent,
- CicoEvasObject::ObjType type,
- const CicoGeometry &geometry)
- : _parent((Evas*)parent),
- _object(NULL),
- _geometry(geometry)
-{
- ICO_DBG("CicoEvasObject::CicoEvasObject Entry");
-
- if (NULL == _parent) {
- ICO_ERR("Invalid argument: _window is NULL");
- throw std::string("_parent is NULL.");
- }
-
- /* create object */
- switch (type) {
- case OBJTYPE_RECTANGLE:
- _object = evas_object_rectangle_add(_parent);
- break;
- case OBJTYPE_POLYGON:
- _object = evas_object_polygon_add(_parent);
- break;
- case OBJTYPE_LINE:
- _object = evas_object_line_add(_parent);
- break;
- case OBJTYPE_IMAGE:
- _object = evas_object_image_add(_parent);
- break;
- case OBJTYPE_FILLED_IMAGE:
- _object = evas_object_image_filled_add(_parent);
- break;
- case OBJTYPE_TEXT:
- _object = evas_object_text_add(_parent);
- break;
- case OBJTYPE_TEXTBLOCK:
- _object = evas_object_textblock_add(_parent);
- break;
- default:
- _object = NULL;
- break;
- }
-
- if (NULL == _object) {
- ICO_ERR("create evas object failed. objtype=%d", type);
- throw std::string("create evas object failed.");
- }
-
- /* setup attribute background object */
- /* set object position */
- move(geometry._x, geometry._y);
-
- /* set object size */
- resize(geometry._w, geometry._h);
-
- ICO_DBG("CicoEvasObject::CicoEvasObject exit");
-}
-
-/**
- * Destructor
- */
-CicoEvasObject::~CicoEvasObject()
-{
- ICO_DBG("CicoEvasObject::~CicoEvasObject entry");
- if (NULL != _object) {
- evas_object_del(_object);
- _object = NULL;
- }
- ICO_DBG("CicoEvasObject::~CicoEvasObject exit");
-}
-
-/**
- * Show
- */
-void
-CicoEvasObject::show()
-{
- ICO_DBG("CicoEvasObject::show entry");
- evas_object_show(_object);
- ICO_DBG("CicoEvasObject::show exit");
-}
-
-/**
- * Hide Background
- */
-void
-CicoEvasObject::hide()
-{
- ICO_DBG("CicoEvasObject::hide entry");
- evas_object_hide(_object);
- ICO_DBG("CicoEvasObject::hide exit");
-}
-
-
-/**
- * Get visible state
- */
-bool
-CicoEvasObject::isVisible(void)
-{
- return evas_object_visible_get(_object);
-}
-
-/**
- * Move Background
- */
-void
-CicoEvasObject::move(int x, int y)
-{
- ICO_DBG("CicoEvasObject::move entry");
- evas_object_move(_object, x, y);
- ICO_DBG("CicoEvasObject::move exit");
-}
-
-/**
- * Move Background
- */
-void
-CicoEvasObject::resize(int w, int h)
-{
- ICO_DBG("CicoEvasObject::resize entry");
- evas_object_resize(_object, w, h);
- ICO_DBG("CicoEvasObject::resize exit");
-}
-
-/**
- * Get geometry of this object
- */
-const CicoGeometry&
-CicoEvasObject::getGeometry(void)
-{
- ICO_DBG("CicoEvasObject::getGeometryentry entry");
- evas_object_geometry_get(_object,
- &_geometry._x, &_geometry._y,
- &_geometry._w, &_geometry._h);
- ICO_DBG("CicoEvasObject::getGeometryentry exit");
- return _geometry;
-}
-
-/* Get this evas object */
-Evas_Object*
-CicoEvasObject::getObject(void) const
-{
- return _object;
-}
-
-void
-CicoEvasObject::setClip(Evas_Object *clip)
-{
- ICO_DBG("CicoEvasObject::getGeometryentry entry");
- evas_object_clip_set(_object, clip);
- ICO_DBG("CicoEvasObject::getGeometryentry exit");
-}
-
-/* Set this evas object */
-void
-CicoEvasObject::event_cb(void *data, Evas *evas,
- Evas_Object *obj, void *event_info)
-{
- ICO_DBG("CicoEvasObject::event_cb entry");
- int *type = (int*)data;
- ICO_DBG("event_type = %d", *type);
- ICO_DBG("CicoEvasObject::event_cb exit");
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoEvasObject.h
- *
- * @brief Class definition of evas object
- */
-/*========================================================================*/
-
-#include <Ecore_Evas.h>
-
-#include "CicoGeometry.h"
-
-#ifndef __CICO_EVAS_OBJECT_H__
-#define __CICO_EVAS_OBJECT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*------------------------------------------------------------------------*/
-/*
- * Forward declaration
- */
-/*------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*/
-/**
- * @class CiconEvasObject
- *
- * @brief This class provide common funciton of evas object
- */
-/*------------------------------------------------------------------------*/
-class CicoEvasObject {
-public:
- typedef enum {
- OBJTYPE_UNKNOWN = 0,
- OBJTYPE_RECTANGLE = 1,
- OBJTYPE_POLYGON = 2,
- OBJTYPE_LINE = 3,
- OBJTYPE_IMAGE = 4,
- OBJTYPE_FILLED_IMAGE = 5,
- OBJTYPE_TEXT = 6,
- OBJTYPE_TEXTBLOCK = 7,
- } ObjType;
-
-public:
- /* Destructor */
- virtual ~CicoEvasObject();
-
- /* Show this object */
- void show(void);
-
- /* Hide this object */
- void hide(void);
-
- /* Is visible this object */
- bool isVisible(void);
-
- /* Move this object */
- void move(int x, int y);
-
- /* Resize this object */
- void resize(int w, int h);
-
- /* Get this object geometry */
- const CicoGeometry& getGeometry(void);
-
- /* Set this object layer */
- void setLayer(short l);
-
- /* Get this object layer */
- short getLayer(void) const;
-
- /* Get this evas object */
- Evas_Object* getObject(void) const;
-
- /* Set this evas object */
- void setClip(Evas_Object *clip);
-
- /* Set this evas object */
- static void event_cb(void *data,
- Evas *evas,
- Evas_Object *obj,
- void *event_info);
-
-protected:
- /* Default Constructor */
- CicoEvasObject();
-
- /* Constructor */
- CicoEvasObject(const Evas *parent,
- CicoEvasObject::ObjType type,
- const CicoGeometry &geometry);
-
- /* Assignment Operator */
- CicoEvasObject& operator=(const CicoEvasObject &object);
-
- /* Copy Constructor */
- CicoEvasObject(const CicoEvasObject &object);
-
-protected:
- /* parent object of this object */
- Evas *_parent;
-
- /* instance of this object */
- Evas_Object *_object;
-
- /* geometry of this object */
- CicoGeometry _geometry;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_EVAS_OBJECT_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoGeometry.cpp
- *
- * @brief Geometry Implementaion
- */
-/*========================================================================*/
-
-#include "CicoGeometry.h"
-
-/**
- * Default Constructor
- */
-CicoGeometry::CicoGeometry(int x, int y, int w, int h)
- : _x(x), _y(y), _w(w), _h(h)
-{
-}
-
-/**
- * Copy Constructor
- */
-CicoGeometry::CicoGeometry(const CicoGeometry& object)
-{
- _x = object._x;
- _y = object._y;
- _w = object._w;
- _h = object._h;
-}
-
-
-/**
- * Destructor
- */
-CicoGeometry::~CicoGeometry()
-{
-}
-
-/**
- * Assignment Operator
- */
-CicoGeometry&
-CicoGeometry::operator=(const CicoGeometry& object)
-{
- _x = object._x;
- _y = object._y;
- _w = object._w;
- _h = object._h;
-
- return *this;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoGeometry.h
- *
- * @brief
- */
-/*========================================================================*/
-
-#ifndef __CICO_GEOMETRY_H__
-#define __CICO_GEOMETRY_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-class CicoGeometry {
-public:
- /**
- * Constructor
- */
- CicoGeometry(int x, int y, int w, int h);
-
- /**
- * Assignment Operator
- */
- CicoGeometry& operator=(const CicoGeometry &object);
-
- /**
- * Destructor
- */
- ~CicoGeometry();
-
- /**
- * Copy Constructor
- */
- CicoGeometry(const CicoGeometry &object);
-
-private:
- /**
- * Default Constructor
- */
- CicoGeometry();
-
-public:
- int _x;
- int _y;
- int _w;
- int _h;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_GEOMETRY_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-/**
- * @brief Application Framework debug log function
- *
- * @date Feb-28-2013
- */
-
-#include <string>
-#include "CicoLog.h"
-
-CicoLog* CicoLog::ms_myInstance = NULL;
-int CicoLog::m_sTimeZone = 99*60*60;
-
-CicoLog::CicoLog()
- : m_logLevel(0x7fffffff), m_flushMode(true), m_initialized(false),
- m_sDbgFd(NULL), m_sDbgLines(0)
-{
- memset(&m_sDbgProg[0], 0, sizeof(m_sDbgProg));
-}
-
-CicoLog::~CicoLog()
-{
- closeLog();
-}
-
-CicoLog*
-CicoLog::getInstance(void)
-{
- if (NULL == ms_myInstance) {
- ms_myInstance = new CicoLog();
- }
- return ms_myInstance;
-}
-/*--------------------------------------------------------------------------*/
-/**
- * @brief ico_apf_log_print: printout log message
- *
- * @param[in] fmt message format(same as printf)
- * @param[in] ... arguments if need
- * @return nothing
- */
-/*--------------------------------------------------------------------------*/
-void
-CicoLog::printLog(int loglevel, const char *fmt, ...)
-{
- if (m_logLevel < loglevel) {
- return;
- }
- va_list list;
-
- if (! m_sDbgFd) {
- openLog(NULL);
- }
-#if ICO_APF_LOG_STDOUT == 0
- else if (m_sDbgLines >= (ICO_LOG_MAXLINES-2)) {
- if (m_sDbgLines >= ICO_LOG_MAXLINES) {
- closeLog();
- openLog(m_sDbgProg);
- }
- else {
- fflush(m_sDbgFd);
- }
- }
-#endif /*ICO_APF_LOG_STDOUT*/
- if (m_sDbgFd) {
- va_start(list, fmt);
- vfprintf(m_sDbgFd, fmt, list);
- va_end(list);
- if (m_flushMode) {
- fflush(m_sDbgFd);
- }
- }
- if (m_sDbgFd != stdout) {
- m_sDbgLines ++;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/**
- * @brief open: open log file
- *
- * @param[in] prog program name
- * @return nothing
- */
-/*--------------------------------------------------------------------------*/
-void
-CicoLog::openLog(const char *prog)
-{
-#if ICO_LOG_STDOUT == 0
- int idx;
- char sPath[128];
- char sPath2[128];
-#endif /*ICO_LOG_STDOUT*/
-
- if (m_sDbgFd) {
- fflush(m_sDbgFd);
- if (m_sDbgFd != stdout) {
- fclose(m_sDbgFd);
- }
- }
-
- m_sDbgLines = 0;
-
- if ((! prog) || (*prog == 0)) {
- m_sDbgFd = stdout;
- m_sDbgProg[0] = 0;
- return;
- }
- else {
- strncpy(m_sDbgProg, prog, sizeof(m_sDbgProg)-1);
- m_sDbgProg[sizeof(m_sDbgProg)-1] = 0;
- }
-#if ICO_LOG_STDOUT > 0
- m_sDbgFd = stdout;
-#else /*ICO_LOG_STDOUT*/
- snprintf(sPath, sizeof(sPath)-1, "%s/%s.log%d",
- ICO_LOG_DIR, m_sDbgProg, ICO_LOG_MAXFILES-1);
- (void) remove(sPath);
-
- for (idx = (ICO_LOG_MAXFILES-1); idx > 0; idx--) {
- strcpy(sPath2, sPath);
- if (idx > 1) {
- snprintf(sPath, sizeof(sPath)-1, "%s/%s.log%d",
- ICO_LOG_DIR, m_sDbgProg, idx-1);
- }
- else {
- snprintf(sPath, sizeof(sPath)-1, "%s/%s.log",
- ICO_LOG_DIR, m_sDbgProg);
- }
- (void) rename(sPath, sPath2);
- }
- m_sDbgFd = fopen(sPath, "w");
- if (! m_sDbgFd) {
- m_sDbgFd = stdout;
- }
- else if ((m_initialized == false) &&
- (m_sDbgFd != stdout) && (m_sDbgFd != stderr)) {
- m_initialized = true;
- //fflush(stdout);
- //fflush(stderr);
- //stdout = m_sDbgFd;
- //stderr = m_sDbgFd;
- }
-#endif /*ICO_LOG_STDOUT*/
-}
-
-/*--------------------------------------------------------------------------*/
-/**
- * @brief closeLog: close log file
- *
- * @param nothing
- * @return nothing
- */
-/*--------------------------------------------------------------------------*/
-void
-CicoLog::closeLog(void)
-{
-#if ICO_LOG_STDOUT == 0
- if (m_sDbgFd) {
- fflush(m_sDbgFd);
- if (m_sDbgFd != stdout) {
- fclose(m_sDbgFd);
- }
- m_sDbgFd = (FILE *)0;
- }
-#endif /*ICO_LOG_STDOUT*/
-}
-
-/*--------------------------------------------------------------------------*/
-/**
- * @brief flushLog: flush log file
- *
- * @param nothing
- * @return nothing
- */
-/*--------------------------------------------------------------------------*/
-void
-CicoLog::flushLog(void)
-{
- if ((m_sDbgFd != NULL) && (m_flushMode == 0)) {
- fflush(m_sDbgFd);
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/**
- * @brief getStrCurtime: create current time string
- *
- * @param[in] level log level string(header of log message)
- * @return current time string
- */
-/*--------------------------------------------------------------------------*/
-char *
-CicoLog::getStrCurTime(const char *level)
-{
- struct timeval NowTime;
- extern long timezone;
- static char sBuf[28];
-
- gettimeofday(&NowTime, (struct timezone *)0);
- if (m_sTimeZone > (24*60*60)) {
- tzset();
- m_sTimeZone = timezone;
- }
- NowTime.tv_sec -= m_sTimeZone;
-
- sprintf(sBuf, "%02d:%02d:%02d.%03d[%s]@%d",
- (int)((NowTime.tv_sec/3600) % 24),
- (int)((NowTime.tv_sec/60) % 60),
- (int)(NowTime.tv_sec % 60),
- (int)NowTime.tv_usec/1000, level, getpid());
-
- return sBuf;
-}
-
-/*--------------------------------------------------------------------------*/
-/**
- * @brief setLogLevel: set log output level
- *
- * @param[in] loglevel log output level
- * @return nothing
- */
-/*--------------------------------------------------------------------------*/
-void
-CicoLog::setLogLevel(const int loglevel)
-{
- m_logLevel = loglevel & (~(ICO_LOG_FLUSH|ICO_LOG_NOFLUSH));
-
- if (m_logLevel & (ICO_LOG_FLUSH|ICO_LOG_NOFLUSH)) {
- if (m_logLevel & ICO_LOG_FLUSH) {
- m_flushMode = true;
- }
- else {
- m_flushMode = false;
- }
- }
-}
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/**
- * @brief Application Framework debug log function
- *
- * @date Feb-28-2013
- */
-
-#ifndef __CICO_LOG_H__
-#define __CICO_LOG_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <time.h>
-
-#ifndef ICO_LOG_STDOUT
-#define ICO_LOG_STDOUT 0 /* Log output to stdout(=1) or file(=0) */
-#endif /*ICO_APF_LOG_STDOUT*/
-
-#define ICO_LOG_DIR "/var/log/ico"
- /* Directory name of Log destination */
-
-/* Maximum lines/files */
-#define ICO_LOG_MAXLINES 10000 /* Maximum output lines of one log file */
-#define ICO_LOG_MAXFILES 6 /* Maximum number of the log file */
-
-/* Log output level */
-#define ICO_LOG_DEBUG 128 /* Debug write */
-#define ICO_LOG_INFO 64 /* Information */
-#define ICO_LOG_WARNING 16 /* Warning */
-#define ICO_LOG_CRITICAL 8 /* Critical */
-#define ICO_LOG_ERROR 4 /* Error */
-
-/* Log output flush */
-#define ICO_LOG_FLUSH 0x4000 /* Log outout with log flush */
-#define ICO_LOG_NOFLUSH 0x2000 /* Log output without log flush */
-
-#define ICO_TRA(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_DEBUG, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("DBG"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-#define ICO_DBG(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_DEBUG, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("DBG"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-#define ICO_INF(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_INFO, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("INF"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-#define ICO_WRN(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_WARNING, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("WRN"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-#define ICO_CRI(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_CRITICAL, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("CRI"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-#define ICO_ERR(fmt,...) \
-{ \
- CicoLog::getInstance()->printLog(ICO_LOG_ERROR, \
- "%s> " fmt " (%s,%s:%d)\n", \
- CicoLog::getStrCurTime("ERR"), \
- ##__VA_ARGS__, \
- __func__, \
- __FILE__, \
- __LINE__); \
-}
-
-class CicoLog
-{
-public:
- CicoLog();
-
- ~CicoLog();
-
- static CicoLog* getInstance(void);
-
- void printLog(int loglevel, const char *fmt, ...);
-
- void openLog(const char *prog);
-
- void closeLog(void);
-
- void flushLog(void);
-
- void setLogLevel(const int loglevel);
-
- static char * getStrCurTime(const char *level);
-
-private:
- static CicoLog* ms_myInstance; //!< CicoLog Object
- static int m_sTimeZone; //!< local time difference(sec)
- int m_logLevel; //!< output level debug log
- bool m_flushMode; //!< flush mode flag
- bool m_initialized; //!< initialized flag
- FILE *m_sDbgFd; //!< file descriptor of output debug log
- int m_sDbgLines; //!< output lines
- char m_sDbgProg[32]; //!< name of output source module
-};
-#endif // __CICO_LOG_H__
-// vim:set expandtab ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoUISample.cpp
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <exception>
-#include <iostream>
-#include <string>
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "CicoUISample.h"
-#include "CicoBaseWin.h"
-#include "CicoGeometry.h"
-#include "CicoBackground.h"
-#include "CicoColor.h"
-#include "CicoLog.h"
-#include "ico_syc_common.h"
-#include "ico_syc_privilege.h"
-
-
-CicoBackground* _background = NULL;
-CicoBackground* _controlbar = NULL;
-bool backgroundShow = false;
-extern "C" {
-static void
-_syc_callback(const ico_syc_ev_e event,
- const void *detail, void *user_data)
-{
- switch (event) {
- case ICO_SYC_EV_WIN_CREATE:
- {
- ICO_DBG("--- ICO_SYC_EV_WIN_CREATE "
- "(appid[%s], name[%s], surface[%d])",
- ((ico_syc_win_info_t *)detail)->appid,
- ((ico_syc_win_info_t *)detail)->name,
- ((ico_syc_win_info_t *)detail)->surface);
-
- ico_syc_win_info_t *info = (ico_syc_win_info_t *)detail;
- if (0 == strcmp(info->name, "HSBackground")) {
- if (backgroundShow == true) {
- break;
- }
- ico_syc_change_layer(info->appid, info->surface, 0);
- ico_syc_animation_t animation = {"fade", 500};
- ico_syc_win_move_t win_move = {NULL, 0, 64, 300, 300};
- ico_syc_move(info->appid, info->surface, &win_move, &animation);
- ico_syc_show(info->appid, info->surface, &animation);
-
- ico_syc_map_thumb(info->surface, 0);
- backgroundShow = true;
- }
- if (0 == strcmp(info->name, "HSControllBar")) {
- ico_syc_change_layer(info->appid, info->surface, 1);
- ico_syc_show(info->appid, info->surface, NULL);
- ico_syc_win_move_t win_move = {NULL, 0, 1920-128, 1080, 128};
- ico_syc_move(info->appid, info->surface, &win_move, NULL);
-
- ico_syc_change_layer(info->appid, info->surface, 0);
- ico_syc_win_move_t win_move2 = {NULL, 0, 128, 1080, 512};
- ico_syc_move(info->appid, info->surface, &win_move2, NULL);
- }
-
- break;
- }
- case ICO_SYC_EV_WIN_DESTROY:
- printf("--- ICO_SYC_EV_WIN_DESTROY ");
- printf("(appid[%s], name[%s], surface[%d])\n",
- ((ico_syc_win_info_t *)detail)->appid,
- ((ico_syc_win_info_t *)detail)->name,
- ((ico_syc_win_info_t *)detail)->surface);
- break;
- case ICO_SYC_EV_WIN_ACTIVE:
- printf("--- ICO_SYC_EV_WIN_ACTIVE ");
- printf("(appid[%s], name[%s], surface[%d])\n",
- ((ico_syc_win_info_t *)detail)->appid,
- ((ico_syc_win_info_t *)detail)->name,
- ((ico_syc_win_info_t *)detail)->surface);
- break;
- case ICO_SYC_EV_WIN_ATTR_CHANGE:
- {
- ICO_DBG("--- ICO_SYC_EV_WIN_ATTR_CHANGE"
- "(appid[%s], name[%s], surface[%d], node[%d], layer[%d], "
- "(x,y)[%d, %d], width[%d], height[%d], raise[%d], visible[%d], active[%d])",
- ((ico_syc_win_attr_t *)detail)->appid,
- ((ico_syc_win_attr_t *)detail)->name,
- ((ico_syc_win_attr_t *)detail)->surface,
- ((ico_syc_win_attr_t *)detail)->nodeid,
- ((ico_syc_win_attr_t *)detail)->layer,
- ((ico_syc_win_attr_t *)detail)->pos_x,
- ((ico_syc_win_attr_t *)detail)->pos_y,
- ((ico_syc_win_attr_t *)detail)->width,
- ((ico_syc_win_attr_t *)detail)->height,
- ((ico_syc_win_attr_t *)detail)->raise,
- ((ico_syc_win_attr_t *)detail)->visible,
- ((ico_syc_win_attr_t *)detail)->active);
-
- ico_syc_win_attr_t *info = (ico_syc_win_attr_t *)detail;
- if (0 == strcmp(info->name, "HSBackground")) {
- if (backgroundShow == true) {
- break;
- }
- ico_syc_change_layer(info->appid, info->surface, 1);
- ico_syc_show_layer(1);
- ico_syc_animation_t animation = {"fade", 500};
- ico_syc_show(info->appid, info->surface, &animation);
- ico_syc_win_move_t win_move = {NULL, 100, 64, 300, 300};
- ico_syc_move(info->appid, info->surface, &win_move, &animation);
- ico_syc_hide(info->appid, info->surface, &animation);
- ico_syc_show(info->appid, info->surface, &animation);
- backgroundShow = true;
- }
- break;
- }
- case ICO_SYC_EV_THUMB_ERROR:
- printf("--- ICO_SYC_EV_THUMB_ERROR\n");
- printf("\t(appid[%s], surface[%d], error[%d]",
- ((ico_syc_thumb_info_t *)detail)->appid,
- ((ico_syc_thumb_info_t *)detail)->surface,
- ((ico_syc_thumb_info_t *)detail)->target);
- break;
- case ICO_SYC_EV_THUMB_CHANGE:
- printf("--- ICO_SYC_EV_THUMB_CHANGE\n");
- printf("\t(appid[%s], surface[%d], name[%d], width[%d], height[%d], ",
- ((ico_syc_thumb_info_t *)detail)->appid,
- ((ico_syc_thumb_info_t *)detail)->surface,
- ((ico_syc_thumb_info_t *)detail)->name,
- ((ico_syc_thumb_info_t *)detail)->width,
- ((ico_syc_thumb_info_t *)detail)->height);
- printf("stride[%d], format[%d])\n",
- ((ico_syc_thumb_info_t *)detail)->stride,
- ((ico_syc_thumb_info_t *)detail)->format);
- break;
- case ICO_SYC_EV_THUMB_UNMAP:
- printf("--- ICO_SYC_EV_THUMB_UNMAP\n");
- printf("\t(appid[%s], surface[%d], name[%d], width[%d], height[%d], ",
- ((ico_syc_thumb_info_t *)detail)->appid,
- ((ico_syc_thumb_info_t *)detail)->surface,
- ((ico_syc_thumb_info_t *)detail)->name,
- ((ico_syc_thumb_info_t *)detail)->width,
- ((ico_syc_thumb_info_t *)detail)->height);
- printf("stride[%d], format[%d])\n",
- ((ico_syc_thumb_info_t *)detail)->stride,
- ((ico_syc_thumb_info_t *)detail)->format);
- break;
- case ICO_SYC_EV_LAYER_ATTR_CHANGE:
- printf("--- ICO_SYC_EV_LAYER_ATTR_CHANGE ");
- printf("(layer[%d], visible[%d])\n",
- ((ico_syc_layer_attr_t *)detail)->layer,
- ((ico_syc_layer_attr_t *)detail)->visible);
- break;
- default:
- printf("--- UNKNOWN");
- break;
- }
-
- return;
-}
-}
-
-/**
- * Default Constructor
- */
-CicoUISample::CicoUISample()
-{
- ICO_DBG("CicoUISample::CicoUISample Enter");
- ICO_DBG("CicoUISample::CicoUISample Leave");
-}
-
-/**
- * Destructor
- */
-CicoUISample::~CicoUISample()
-{
- ICO_DBG("CicoUISample::~CicoUISample Enter");
- ICO_DBG("CicoUISample::~CicoUISample Leave");
-}
-
-bool
-CicoUISample::onCreate(void *user_data)
-{
- ICO_DBG("CicoUISample::onCreate Enter");
-
- try {
- ico_syc_connect(_syc_callback, NULL);
-
- ecore_evas_init();
- CicoBaseWin* _bgwin = new CicoBaseWin("HSBackground",
- CicoGeometry(0, 64, 300, 300));
- _background = new CicoBackground(_bgwin->getEvas(),
- CicoGeometry(0, 0, 300, 300),
- CicoColor(128, 0, 128, 255));
-
-// CicoBaseWin* _ctlwin = new CicoBaseWin("HSControllBar",
-// CicoGeometry(0, 0, 1080, 128));
-// _controlbar = new CicoBackground(_ctlwin->getEvas(),
-// CicoGeometry(0, 0, 1080, 128),
-// CicoColor(128, 128, 128, 255));
-
- }
- catch (const std::exception& e) {
- std::cerr << e.what() << std::endl;
- ICO_ERR("catch exception %s", e.what());
- ICO_DBG("CicoUISample::onCreate Leave(false)");
- return false;
- }
- catch (const std::string& str) {
- std::cerr << str << std::endl;
- ICO_ERR("catch exception %s", str.c_str());
- ICO_DBG("CicoUISample::onCreate Leave(false)");
- return false;
- }
- catch (...) {
- ICO_ERR("catch exception unknown");
- ICO_DBG("CicoUISample::onCreate Leave(false)");
- return false;
- }
-
- ICO_DBG("CicoUISample::onCreate Leave(true)");
-
- return true;
-}
-
-#if 0
-void
-CicoUISample::onTerminate(void *user_data)
-{
- _DBG("CicoUISample::onTerminate entry");
-}
-
-void
-CicoUISample::onPause(void *user_data)
-{
- _DBG("CicoUISample::onPause entry");
-}
-
-void
-CicoUISample::onResume(void *user_data)
-{
- _DBG("CicoUISample::onResume entry");
-}
-
-void
-CicoUISample::onService(service_h service, void *user_data)
-{
- _DBG("CicoUISample::onService entry");
-}
-#endif
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file CicoUISample.h
- *
- * @brief
- */
-/*========================================================================*/
-
-//#include <app.h>
-#include <stdio.h>
-#include "CicoEFLApp.h"
-
-#ifndef __CICO_UI_SAMPLE_APP_H__
-#define __CICO_UI_SAMPLE_APP_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-class CicoUISample : public CicoEFLApp {
-public:
- /**
- * Default Constructor
- */
- CicoUISample();
-
- /**
- * Destructor
- */
- virtual ~CicoUISample();
-
- /**
- *
- */
- virtual bool onCreate(void *user_data);
-#if 0
- void onTerminate(void *user_data);
- void onPause(void *user_data);
- void onResume(void *user_data);
- void onService(service_h service, void *user_data);
-#endif
-
-protected:
- /**
- * Assignment Operator
- */
- CicoUISample& operator=(const CicoUISample &object);
-
- /**
- * Copy Constructor
- */
- CicoUISample(const CicoUISample &object);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CICO_UI_SAMPLE_APP_H__ */
-/* vim:set expandtab ts=4 sw=4: */
+++ /dev/null
-AM_CFLAGS = $(GCC_CFLAGS)
-AM_CPPFLAGS = $(GCC_CXXFLAGS)
-
-COMMON_LIBS = -L/usr/local/lib -lm -lwebsockets -lico-uxf-weston-plugin
-
-noinst_PROGRAMS = \
- DummyHomeScreen
-
-DummyHomeScreen_SOURCES = \
- CicoLog.cpp \
- CicoBackground.cpp \
- CicoBaseWin.cpp \
- CicoGeometry.cpp \
- CicoColor.cpp \
- CicoEFLApp.cpp \
- CicoEvasObject.cpp \
- CicoUISample.cpp \
- main.cpp
-
-DummyHomeScreen_CXXFLAGS = \
- @ECORE_CFLAGS@ \
- @EINA_CFLAGS@ \
- @ECOREEVAS_CFLAGS@ \
- @EVAS_CFLAGS@ \
- @GLIB_CFLAGS@ \
- @AIL_CFLAGS@ \
- @BUNDLE_CFLAGS@ \
- @AUL_CFLAGS@ \
- @PKGMGR_CFLAGS@ \
- @WAYLANDCLIENT_CFLAGS@ \
- @CAPIAPPFWAPPLICATION_CFLAGS@ \
- -I/usr/include/ico-util \
- -I/usr/include/ico-uxf-weston-plugin \
- -I../../../include
-
-DummyHomeScreen_LDADD = \
- @ECORE_LIBS@ \
- @EINA_LIBS@ \
- @ECOREEVAS_LIBS@ \
- @EVAS_LIBS@ \
- @GLIB_LIBS@ \
- @AIL_LIBS@ \
- @BUNDLE_LIBS@ \
- @AUL_LIBS@ \
- @PKGMGR_LIBS@ \
- @WAYLANDCLIENT_LIBS@ \
- @CAPIAPPFWAPPLICATION_LIBS@ \
- -L/usr/lib \
- -lico-uxf-weston-plugin \
- -lico-util \
- ../../../lib/apps-framework/.libs/libico-appfw.so \
- -lreadline
-
-
-CLEANFILES = $(BUILT_SOURCES)
-
-#install-exec-hook:
-# mkdir -p $(INSTALL_ROOT)/usr/apps/org.tizen.ico.dummy-homescreen/bin
-# mkdir -p $(INSTALL_ROOT)/usr/share/packages
-# install -m 0755 DummyHomeScreen $(INSTALL_ROOT)/usr/apps/org.tizen.ico.dummy-homescreen/bin
-# install -m 0644 org.tizen.ico.dummy-homescreen.xml $(INSTALL_ROOT)/usr/share/packages
-#
-#uninstall:
-# rm -rf $(INSTALL_ROOT)/usr/apps/org.tizen.ico.dummy-homescreen
-# rm -f $(INSTALL_ROOT)/usr/share/packages/org.tizen.ico.dummy-homescreen.xml
-# rm -f $(INSTALL_ROOT)/usr/share/applications/org.tizen.ico.dummy-homescreen.desktop
-
-# vim:set ts=4 sw=4:
+++ /dev/null
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*========================================================================*/
-/**
- * @file main.cpp
- *
- * @brief
- */
-/*========================================================================*/
-
-#include <exception>
-#include <iostream>
-#include <string>
-
-#include "CicoUISample.h"
-#include "CicoLog.h"
-#include <Ecore.h>
-#include <Eina.h>
-#include <Ecore_Evas.h>
-
-#include <pthread.h>
-pthread_t thread;
-
-void *
-uiMain(void *args)
-{
- CicoUISample uiSample;
- uiSample.start(0, NULL);
-
- return NULL;
-}
-
-#include <readline/readline.h>
-#include <readline/history.h>
-#define MAX_HISTORY_NO 3
-void
-consoleMain(void)
-{
- char *prompt = (char*)"ico >";
- char *line = NULL;
- int history_no = 0;
- HIST_ENTRY *history = NULL;
-
- printf("consolMain Enter\n");
- while (1) {
- line = readline(prompt);
-
- if (strcmp(line, "exit") == 0) {
- break;
- }
-
- add_history(line);
- if (++history_no > MAX_HISTORY_NO) {
- history = remove_history(0);
- free(history);
- }
-
- free(line);
- }
-
- clear_history();
-}
-
-int
-main(int argc, char **argv)
-{
- //eina_init();
- //eina_log_level_set(EINA_LOG_LEVEL_DBG);
-
- try {
- CicoLog::getInstance()->openLog("DummyHomeScreen"/*TOOD*/);
-
-#if 1
- /* pthread start */
- int ret = pthread_create(&thread, NULL, uiMain, (void *)NULL);
- if (-1 == ret) {
- ICO_ERR("pthread_create failed(%d:%s)",
- errno, strerror(errno));
- return -1;
- }
-#endif
- consoleMain();
-
- ecore_main_loop_quit();
- ecore_evas_shutdown();
- pthread_join(thread, NULL);
-
- }
- catch (const std::exception& e) {
- std::cerr << e.what() << std::endl;
- ICO_ERR("main: catch exception [%s]", e.what());
- }
- catch (const std::string& str) {
- std::cerr << str << std::endl;
- ICO_ERR("main: catch exception [%s]", str.c_str());
- }
- catch (...) {
- ICO_ERR("main: catch exception unknown");
- }
-
- return 0;
-}
-/* vim: set expandtab ts=4 sw=4: */
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.ico.dummy-homescreen" version="0.1.0-0" install-location="internal-only">
- <label>dummy-homescreen</label>
- <author email="" href=""> </author>
- <description>ico dummy-homescreen</description>
- <ui-application appid="org.tizen.ico.dummy-homescreen" exec="/usr/apps/org.tizen.ico.dummy-homescreen/bin/DummyHomeScreen" nodisplay="true" multiple="false" type="capp" taskmanage="false">
- <label>dummy-homescreen</label>
- <icon> </icon>
- </ui-application>
-</manifest>