4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHyun Kim <jh8212.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
38 #include <cobject_type.h>
45 #include <cipc_worker.h>
48 #include <sf_common.h>
51 #include <csensor_module.h>
52 #include <csensor_catalog.h>
54 #include <resource_str.h>
61 csensor_catalog::csensor_catalog()
67 csensor_catalog::~csensor_catalog()
73 bool csensor_catalog::create(char *file)
80 if (ccatalog::load(file) == false) {
81 if ( ccatalog::is_loaded() ) {
82 DBG("The catalog is already loaded , so first unload it");
85 ERR("Failed to load a catalog file\n");
89 handle = ccatalog::iterate_init();
91 name = ccatalog::iterate_get_name(handle);
92 handle = ccatalog::iterate_next(handle);
94 ERR("Name is null\n");
98 value = ccatalog::value(name, (char*)STR_DISABLE);
99 if (value && !strcasecmp(value, STR_YES)) {
100 ERR("%s is disabled\n", name);
104 value = ccatalog::value(name, (char*)STR_PATH);
106 ERR("Module path is not defined\n");
110 module = csensor_module::register_module(value, NULL, NULL);
112 ERR("Failed to register a module %s\n", name);
116 value = ccatalog::value(name, (char*)STR_OVERRIDE);
117 if (value && !strcasecmp(value, STR_YES)) {
118 DBG("Let's override module description [%s]\n", name);
120 if (module->update_name(name) == false) {
121 ERR("Failed to update module name\n");
124 value = ccatalog::value(name, (char*)STR_ID);
126 if (module->update_id(atoi(value)) == false) {
127 ERR("Failed to update ID\n");
131 value = ccatalog::value(name, (char*)STR_VERSION);
133 if (module->update_version(atoi(value)) == false) {
134 ERR("Failed to update version\n");
138 value = ccatalog::value(name, (char*)STR_POLL);
140 csensor_module *sensor;
141 sensor = (csensor_module*)module;
142 if (sensor->update_polling_interval(atoi(value)) == false) {
143 ERR("Failed to update polling interval\n");
149 DBG("Finished registeration , unload sensor.conf ");
157 void csensor_catalog::destroy(void)
159 if ( ccatalog::is_loaded() ) {