TSS_RESULT read_conf_line(char *buf, int line_num, struct tcsd_config *conf) { char *ptr = buf, *tmp_ptr = NULL, *arg, *comma; int option, tmp_int; TSS_RESULT result; if (ptr == NULL || *ptr == '\0' || *ptr == '#' || *ptr == '\n') return TSS_SUCCESS; /* read through whitespace */ while (*ptr == ' ' || *ptr == '\t') ptr++; /* ignore comments */ if (*ptr == '#') return TSS_SUCCESS; option = get_config_option(ptr, &arg); switch (option) { case opt_port: tmp_int = atoi(arg); if (tmp_int < 0 || tmp_int > 65535) { LogError("Config option \"port\" out of range. %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); return TCSERR(TSS_E_INTERNAL_ERROR); } else { conf->port = tmp_int; conf->unset &= ~TCSD_OPTION_PORT; } break; case opt_max_threads: tmp_int = atoi(arg); if (tmp_int <= 0) { LogError("Config option \"num_threads\" out of range. %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); return TCSERR(TSS_E_INTERNAL_ERROR); } else { conf->num_threads = tmp_int; conf->unset &= ~TCSD_OPTION_MAX_THREADS; } break; case opt_firmware_pcrs: conf->unset &= ~TCSD_OPTION_FIRMWARE_PCRS; while (1) { comma = rindex(arg, ','); if (comma == NULL) { if (!isdigit((unsigned char)*arg)) break; comma = arg; tmp_int = atoi(comma); if (tmp_int >= 0 && tmp_int < TCSD_MAX_PCRS) conf->firmware_pcrs |= (1 << tmp_int); else LogError("Config option \"firmware_pcrs\" is out of range." "%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); break; } *comma++ = '\0'; tmp_int = atoi(comma); if (tmp_int >= 0 && tmp_int < TCSD_MAX_PCRS) conf->firmware_pcrs |= (1 << tmp_int); else LogError("Config option \"firmware_pcrs\" is out of range. " "%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); } break; case opt_kernel_pcrs: conf->unset &= ~TCSD_OPTION_KERNEL_PCRS; while (1) { comma = rindex(arg, ','); if (comma == NULL) { if (!isdigit((unsigned char)*arg)) break; comma = arg; tmp_int = atoi(comma); if (tmp_int >= 0 && tmp_int < TCSD_MAX_PCRS) conf->kernel_pcrs |= (1 << tmp_int); else LogError("Config option \"kernel_pcrs\" is out of range. " "%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); break; } *comma++ = '\0'; tmp_int = atoi(comma); if (tmp_int >= 0 && tmp_int < TCSD_MAX_PCRS) conf->kernel_pcrs |= (1 << tmp_int); else LogError("Config option \"kernel_pcrs\" is out of range. " "%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); } break; case opt_system_ps_file: if (*arg != '/') { LogError("Config option \"system_ps_dir\" must be an absolute path name. " "%s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { char *dir_ptr; int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"system_ps_file\" is invalid." " %s:%d: \"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"system_ps_file\" is invalid. %s:%d:" " \"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->system_ps_file) free(conf->system_ps_file); if (conf->system_ps_dir) free(conf->system_ps_dir); /* break out the system ps directory from the file path */ dir_ptr = rindex(tmp_ptr, '/'); *dir_ptr = '\0'; if (strlen(tmp_ptr) == 0) conf->system_ps_dir = strdup("/"); else conf->system_ps_dir = strdup(tmp_ptr); if (conf->system_ps_dir == NULL) { LogError("malloc failed."); free(tmp_ptr); return TCSERR(TSS_E_OUTOFMEMORY); } *dir_ptr = '/'; conf->system_ps_file = tmp_ptr; conf->unset &= ~TCSD_OPTION_SYSTEM_PSFILE; } break; case opt_kernel_log: if (*arg != '/') { LogError("Config option \"kernel_log\" must be an absolute path name." " %s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"kernel_log\" is invalid. %s:%d: \"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"kernel_log\" is invalid. %s:%d: \"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->kernel_log_file) free(conf->kernel_log_file); conf->kernel_log_file = tmp_ptr; conf->unset &= ~TCSD_OPTION_KERNEL_LOGFILE; } break; case opt_firmware_log: if (*arg != '/') { LogError("Config option \"firmware_log\" must be an absolute path name." " %s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"firmware_log\" is invalid. %s:%d: \"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"firmware_log\" is invalid. %s:%d: \"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->firmware_log_file) free(conf->firmware_log_file); conf->firmware_log_file = tmp_ptr; conf->unset &= ~TCSD_OPTION_FIRMWARE_LOGFILE; } break; case opt_platform_cred: if (*arg != '/') { LogError("Config option \"platform_cred\" must be an absolute path name. " "%s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"platform_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"platform_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->platform_cred) free(conf->platform_cred); conf->platform_cred = tmp_ptr; conf->unset &= ~TCSD_OPTION_PLATFORM_CRED; } break; case opt_conformance_cred: if (*arg != '/') { LogError("Config option \"conformance_cred\" must be an absolute path name." " %s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"conformance_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"conformance_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->conformance_cred) free(conf->conformance_cred); conf->conformance_cred = tmp_ptr; conf->unset &= ~TCSD_OPTION_CONFORMANCE_CRED; } break; case opt_endorsement_cred: if (*arg != '/') { LogError("Config option \"endorsement_cred\" must be an absolute path name." " %s:%d: \"%s\"", tcsd_config_file, line_num, arg); } else { int rc; if ((rc = get_file_path(arg, &tmp_ptr)) < 0) { LogError("Config option \"endorsement_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } else if (rc > 0) { LogError("Config option \"endorsement_cred\" is invalid. %s:%d: " "\"%s\"", tcsd_config_file, line_num, tmp_ptr); return TCSERR(TSS_E_INTERNAL_ERROR); } if (tmp_ptr == NULL) return TCSERR(TSS_E_OUTOFMEMORY); if (conf->endorsement_cred) free(conf->endorsement_cred); conf->endorsement_cred = tmp_ptr; conf->unset &= ~TCSD_OPTION_ENDORSEMENT_CRED; } break; case opt_remote_ops: conf->unset &= ~TCSD_OPTION_REMOTE_OPS; comma = rindex(arg, '\n'); *comma = '\0'; while (1) { comma = rindex(arg, ','); if (comma == NULL) { comma = arg; if (comma != NULL) { if (tcsd_set_remote_op(conf, comma)) { LogError("Config option \"remote_ops\" is invalid. " "%s:%d: \"%s\"", tcsd_config_file, line_num, comma); } } break; } *comma++ = '\0'; if (tcsd_set_remote_op(conf, comma)) { LogError("Config option \"remote_ops\" is invalid. " "%s:%d: \"%s\"", tcsd_config_file, line_num, comma); } } break; case opt_exclusive_transport: tmp_int = atoi(arg); if (tmp_int < 0 || tmp_int > 1) { LogError("Config option \"enforce_exclusive_transport\" out of range." " %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int); return TCSERR(TSS_E_INTERNAL_ERROR); } else { conf->exclusive_transport = tmp_int; conf->unset &= ~TCSD_OPTION_EXCLUSIVE_TRANSPORT; } break; case opt_host_platform_class: /* append the host class on the list */ conf->unset &= ~TCSD_OPTION_HOST_PLATFORM_CLASS; comma = rindex(arg,'\n'); *comma = '\0'; comma = rindex(arg,','); /* At least one comma: error - more than one host class defined */ if (comma != NULL) { LogError("Config option \"host_platform_class\" error: more than one " "defined. %s:%d: \"%s\"", tcsd_config_file, line_num, comma); return TCSERR(TSS_E_INTERNAL_ERROR); } else { comma = arg; /* Add the platform class on the list */ if ((result = platform_class_list_append(conf, comma, TRUE))){ LogError("Config option \"host_platform_class\" invalid. " "%s:%d: \"%s\"", tcsd_config_file, line_num, comma); return result; } } break; case opt_all_platform_classes: /* append each of the comma separated values on the list */ comma = rindex(arg, '\n'); *comma = '\0'; while (1) { comma = rindex(arg, ','); if (comma == NULL) { comma = arg; if (comma != NULL) { /* Add the platform class on the list */ if ((result = platform_class_list_append(conf, comma, FALSE))) { LogError("Config option \"all_platform_class\" " "invalid. %s:%d: \"%s\"", tcsd_config_file, line_num, comma); return result; } } break; } *comma++ = '\0'; /* Add the platform class on the list */ if ((result = platform_class_list_append(conf, comma, FALSE))) { LogError("Config option \"all_platform_class\" invalid. " "%s:%d: \"%s\"", tcsd_config_file, line_num, comma); return result; } } break; default: /* bail out on any unknown option */ LogError("Unknown config option %s:%d \"%s\"!", tcsd_config_file, line_num, arg); return TCSERR(TSS_E_INTERNAL_ERROR); } return TSS_SUCCESS; }
SV *get_native_property(pTHX_ const char *property) { static const char *native_byteorder = #if ARCH_NATIVE_BYTEORDER == ARCH_BYTEORDER_BIG_ENDIAN "BigEndian" #elif ARCH_NATIVE_BYTEORDER == ARCH_BYTEORDER_LITTLE_ENDIAN "LittleEndian" #else #error "unknown native byte order" #endif ; #if defined(__STDC_VERSION__) # define STD_C_NATIVE newSViv(__STDC_VERSION__) #else # define STD_C_NATIVE &PL_sv_undef #endif #ifdef __STDC_HOSTED__ # define HOSTED_C_NATIVE newSViv(__STDC_HOSTED__) #else # define HOSTED_C_NATIVE &PL_sv_undef #endif if (property == NULL) { HV *h = newHV(); HV_STORE_CONST(h, "PointerSize", newSViv(CTLIB_POINTER_SIZE)); HV_STORE_CONST(h, "IntSize", newSViv(CTLIB_int_SIZE)); HV_STORE_CONST(h, "CharSize", newSViv(CTLIB_char_SIZE)); HV_STORE_CONST(h, "ShortSize", newSViv(CTLIB_short_SIZE)); HV_STORE_CONST(h, "LongSize", newSViv(CTLIB_long_SIZE)); HV_STORE_CONST(h, "LongLongSize", newSViv(CTLIB_long_long_SIZE)); HV_STORE_CONST(h, "FloatSize", newSViv(CTLIB_float_SIZE)); HV_STORE_CONST(h, "DoubleSize", newSViv(CTLIB_double_SIZE)); HV_STORE_CONST(h, "LongDoubleSize", newSViv(CTLIB_long_double_SIZE)); HV_STORE_CONST(h, "Alignment", newSViv(CTLIB_ALIGNMENT)); HV_STORE_CONST(h, "CompoundAlignment", newSViv(CTLIB_COMPOUND_ALIGNMENT)); HV_STORE_CONST(h, "EnumSize", newSViv(get_native_enum_size())); HV_STORE_CONST(h, "ByteOrder", newSVpv(native_byteorder, 0)); HV_STORE_CONST(h, "UnsignedChars", newSViv(get_native_unsigned_chars())); HV_STORE_CONST(h, "UnsignedBitfields", newSViv(get_native_unsigned_bitfields())); HV_STORE_CONST(h, "StdCVersion", STD_C_NATIVE); HV_STORE_CONST(h, "HostedC", HOSTED_C_NATIVE); return newRV_noinc((SV *)h); } switch (get_config_option(property)) { case OPTION_PointerSize: return newSViv(CTLIB_POINTER_SIZE); case OPTION_IntSize: return newSViv(CTLIB_int_SIZE); case OPTION_CharSize: return newSViv(CTLIB_char_SIZE); case OPTION_ShortSize: return newSViv(CTLIB_short_SIZE); case OPTION_LongSize: return newSViv(CTLIB_long_SIZE); case OPTION_LongLongSize: return newSViv(CTLIB_long_long_SIZE); case OPTION_FloatSize: return newSViv(CTLIB_float_SIZE); case OPTION_DoubleSize: return newSViv(CTLIB_double_SIZE); case OPTION_LongDoubleSize: return newSViv(CTLIB_long_double_SIZE); case OPTION_Alignment: return newSViv(CTLIB_ALIGNMENT); case OPTION_CompoundAlignment: return newSViv(CTLIB_COMPOUND_ALIGNMENT); case OPTION_EnumSize: return newSViv(get_native_enum_size()); case OPTION_ByteOrder: return newSVpv(native_byteorder, 0); case OPTION_UnsignedChars: return newSViv(get_native_unsigned_chars()); case OPTION_UnsignedBitfields: return newSViv(get_native_unsigned_bitfields()); case OPTION_StdCVersion: return STD_C_NATIVE; case OPTION_HostedC: return HOSTED_C_NATIVE; default: return NULL; } }
ActivityConfigScreensaverView::ActivityConfigScreensaverView(Evas *_e, Evas_Object *_parent): ActivityView(_e, _parent, "calaos/page/config/screensaver") { EdjeObject *slider; setPartText("tab1.text", _("Configure Touch Screen")); setPartText("tab1.text.detail", _("Resume : <light_blue>Touch Screen</light_blue><br><small>Configure your Touch Screen !</small>")); setPartText("tab2.text", _("About")); setPartText("tab2.text.detail", _("About : <light_blue>Calaos products</light_blue><br><small>Touchscreen solutions.</small>")); setPartText("module_screen", _("Configure power management settings")); setPartText("module_screen_desc", _("Enable if you want to activate automatic screen blanking and the delay after wich the screen will be turned off. You can also ask for a password when the screen is turned on again.")); setPartText("tab1.title_icon", _("TouchScreen")); setPartText("tab1.subtitle_icon", _("TouchScreen configuration.")); setPartText("tab2.web.label", _("Web Site : ")); setPartText("tab2.web", CALAOS_WEBSITE_URL); setPartText("tab2.mail.label", _("Email : ")); setPartText("tab2.mail", CALAOS_CONTACT_EMAIL); setPartText("tab2.copyright", CALAOS_COPYRIGHT_TEXT); setPartText("module_screen_time_desc", _("Time before screensaver activation : ")); setPartText("module_screen suspend_desc", _("Enable screen saver : ")); // Create a new slider for the DPMS standby option slider = new EdjeObject(ApplicationMain::getTheme(), evas); slider->setAutoDelete(true); double slider_val; string option_val; option_val = get_config_option("dpms_standby"); from_string(option_val, slider_val); setPartText("module_screen_time_value", to_string((int)(slider_val / 60.0)) + _(" minutes")); slider->addCallback("object", "*", [=](void *data, Evas_Object *edje_object, string emission, string source) { // Change value on screen when slider move if (emission == "slider,move") { double x; string val; slider->getDragValue("slider", &x, NULL); val = to_string((int)(x * DPMS_STANDBY_MAX_VALUE)) + _(" minutes"); setPartText("module_screen_time_value", val); } // Set new value in local_config.xml when slider,changed is received else if (emission == "slider,changed") { double x; slider->getDragValue("slider", &x, NULL); // Value is store in seconds set_config_option("dpms_standby", to_string((int)(x * 60.0 * DPMS_STANDBY_MAX_VALUE))); } } ); slider->LoadEdje("calaos/slider/horizontal/default"); slider->Show(); slider->setDragValue("slider", slider_val / 60.0 / DPMS_STANDBY_MAX_VALUE, slider_val / 60.0 / DPMS_STANDBY_MAX_VALUE); Swallow(slider, "dpms_standby_slider.swallow", true); addCallback("object", "*", [=](void *data, Evas_Object *edje_object, string emission, string source) { printf("Emission : %s | Source : %s\n", emission.c_str(), source.c_str()); }); }
void TimeRange::computeSunSetRise(int year, int month, int day, int &rise_hour, int &rise_min, int &set_hour, int &set_min) { if (year == cyear && month == cmonth && day == cday && (sunrise_hour_cache != 0 || sunrise_min_cache != 0 || sunset_hour_cache != 0 || sunset_min_cache != 0)) { rise_hour = sunrise_hour_cache; rise_min = sunrise_min_cache; set_hour = sunset_hour_cache; set_min = sunset_min_cache; return; } double longitude; double latitude; Params opt; get_config_options(opt); if (!opt.Exists("longitude") || !opt.Exists("latitude")) { longitude = 2.548828; latitude = 46.422713; cError() << "Horaire: To use sunset/sunrise, you have to set your longitude/latitude in configuration!"; cError() << "Horaire: Please go to the webpage of the server to set these parameters."; } else { from_string(get_config_option("longitude"), longitude); from_string(get_config_option("latitude"), latitude); } double rise, set; int res; cInfo() << "Horaire: Computing sunrise/sunset for date " << day << "/" << month << "/" << year; res = sun_rise_set(year, month, day, longitude, latitude, &rise, &set); if (res != 0) { rise_hour = 0; rise_min = 0; set_hour = 0; set_min = 0; cError() << "Horaire: Error in sunset/sunrise calculation!"; return; } long tzOffset = getTimezoneOffset(); rise_min = minutes(rise + minutes((double)tzOffset / 3600.0)); rise_hour = hours(rise + (double)tzOffset / 3600.0); set_min = minutes(set + minutes((double)tzOffset / 3600.0)); set_hour = hours(set + (double)tzOffset / 3600.0); std::stringstream streamrise, streamset; streamrise << std::setfill('0') << std::setw(2) << rise_hour << ":" << rise_min; streamset << std::setfill('0') << std::setw(2) << set_hour << ":" << set_min; cInfo() << "Horaire: sunrise is at " << streamrise.str() << " and sunset is at " << streamset.str(); sunrise_hour_cache = rise_hour; sunrise_min_cache = rise_min; sunset_hour_cache = set_hour; sunset_min_cache = set_min; cyear = year; cmonth = month; cday = day; }
ApplicationController::ApplicationController(Evas *_e, Evas_Object *_l): evas(_e), layout(_l), mouseCursor(NULL), menu_hidden(false), homeController(NULL), mediaController(NULL), scenariosController(NULL), configController(NULL), keyboardController(NULL), webController(NULL), editScController(NULL), scheduleScController(NULL) { if (Utils::get_config_option("show_cursor") == "true") { mouseCursor = new EdjeObject(ApplicationMain::getTheme(), evas); try { mouseCursor->LoadEdje("calaos/cursor"); } catch(exception const& e) { Utils::logger("root") << Priority::CRIT << "ApplicationController: Can't load mouse cursor" << log4cpp::eol; throw; } int w, h; edje_object_size_min_get(mouseCursor->getEvasObject(), &w, &h); mouseCursor->Resize(w, h); mouseCursor->Show(); ecore_evas_object_cursor_set(ecore_evas_ecore_evas_get(evas), mouseCursor->getEvasObject(), EVAS_LAYER_MAX - 32, w / 2, h / 2); } else { Evas_Object *cursor = evas_object_rectangle_add(evas); evas_object_color_set(cursor, 0, 0, 0, 0); evas_object_resize(cursor, 1, 1); evas_object_show(cursor); ecore_evas_object_cursor_set(ecore_evas_ecore_evas_get(evas), cursor, EVAS_LAYER_MAX - 32, 0, 0); } menuView = new MainMenuView(evas, layout); menuView->setVersionString(get_config_option("fw_version")); menuView->on_home_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuHomeClick)); menuView->on_media_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuMediaClick)); menuView->on_scenario_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuScenarioClick)); menuView->on_config_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuConfigClick)); menuView->on_reboot_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuRebootClick)); menuView->on_suspend_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuSuspendClick)); menuView->on_widget_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuWidgetClick)); //Start the model instance CalaosModel::Instance().home_loaded.connect(sigc::mem_fun(*this, &ApplicationController::home_loaded)); CalaosModel::Instance().login_failed.connect(sigc::mem_fun(*this, &ApplicationController::login_failed)); contentView = new MainContentView(evas, layout); elm_object_part_content_set(layout, "calaos.main.content", contentView->getSmartObject()); widgetsController = new ActivityWidgetsController(evas, layout); contentView->addView(widgetsController->getView()); menuView->on_menu_open.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::dimView)); menuView->on_menu_close.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::resetView)); menuView->on_widget_valid_click.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::validEdit)); menuView->on_widget_cancel_click.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::cancelEdit)); }