3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 * @brief This file is the source file of implementation of functions for device information structure which is used in Service Adapter
24 #include <sync_agent.h>
26 #include "service-adapter/sa_devinf.h"
27 #include "service-adapter/sa_devinf_internal.h"
28 #include "service-adapter/sa_session_internal.h"
29 #include "common/common_define.h"
31 #ifndef OMADS_AGENT_LOG
33 #define LOG_TAG "OMA_DS_SA"
36 static sa_error_type_e _create_devinf_new(char *devid, devinf_devtyp_e devtyp, devinf_s ** devinf);
37 static sa_error_type_e _create_devinf_contenttype(char *cttype, char *verct, devinf_content_type_s ** devinf_content_type);
38 static sa_error_type_e _create_devinf_ctcap(devinf_content_type_s * devinf_content_type, devinf_ct_cap_s ** devinf_ctcap);
39 static sa_error_type_e _create_devinf_property(char *prop_name, devinf_property_s ** devinf_property);
40 static sa_error_type_e _create_devinf_datastore(char *datastore, devinf_datastore_s ** devinf_datastore);
42 static void _free_devinf_datastores(GList * devinf_datastores);
43 static void __free_devinf_datastore(devinf_datastore_s * devinf_datastore);
44 static void ___free_devinf_contenttype(devinf_content_type_s * devinf_content_type);
45 static void ___free_devinf_ctcaps(devinf_ct_cap_s * devinf_ctcap);
46 static void ___free_devinf_property(devinf_property_s * devinf_property);
47 static void ___free_devinf_propparam(devinf_prop_param_s * devinf_prop_param);
49 static void _set_devinf_version(devinf_s * devinf, devinf_version_e version);
50 static void _set_devinf_manufacturer(devinf_s * devinf, char *manufacturer);
51 static void _set_devinf_model(devinf_s * devinf, char *model);
52 static void _set_devinf_oem(devinf_s * devinf, char *oem);
53 static void _set_devinf_software_version(devinf_s * devinf, char *software_version);
54 static void _set_devinf_hardware_version(devinf_s * devinf, char *hardware_version);
55 static void _set_devinf_firmware_version(devinf_s * devinf, char *firmware_version);
56 static void _set_devinf_datastore(devinf_s * devinf, devinf_datastore_s * devinf_datastore);
57 static void _set_devinf_datastore_rxpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type);
58 static void _set_devinf_datastore_txpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type);
59 static void _set_devinf_datastore_ctcap(devinf_datastore_s * devinf_datastore, devinf_ct_cap_s * devinf_ctcap);
60 static void _set_devinf_datastore_sharedmem(devinf_datastore_s * devinf_datastore, int shared_mem);
61 static void _set_devinf_datastore_maxmem(devinf_datastore_s * devinf_datastore, unsigned int max_mem);
62 static void _set_devinf_datastore_maxid(devinf_datastore_s * devinf_datastore, unsigned int max_id);
63 static void _set_devinf_ctcap_property(devinf_ct_cap_s * devinf_ctcap, devinf_property_s * devinf_property);
64 static void _set_devinf_property_valenums(devinf_property_s * devinf_property, char *val_enum);
65 static devinf_devtyp_e _convert_devtyp(char *dev_typ);
71 static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **devinfPropParam);
72 static void set_DevInfDataStoreDisplayname(DevInfDataStore* devinf_datastore, char *displayname);
73 static void set_DevInfDataStoreRx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type);
74 static void set_DevInfDataStoreTx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type);
75 static void set_DevInfPropertyDataType(DevInfProperty *devinfProperty, char *dataType);
76 static void set_DevInfPropertyMaxOccur(DevInfProperty *devinfProperty, unsigned int maxOccur);
77 static void set_DevInfPropertyMaxSize(DevInfProperty *devinfProperty, unsigned int maxSize);
78 static void set_DevInfPropertyNoTruncate(DevInfProperty *devinfProperty, int noTruncate);
79 static void set_DevInfPropertyDisplayName(DevInfProperty *devinfProperty, char *displayName);
80 static void set_DevInfPropertyPropParam(DevInfProperty *devinfProperty, DevInfPropParam *devinfPropParam);
81 static void set_DevInfPropParamDataType(DevInfPropParam *devinfPropParam, char *dataType);
82 static void set_DevInfPropParamDisplayName(DevInfPropParam *devinfPropParam, char *displayName);
83 static void set_DevInfPropParamValEnums(DevInfPropParam *devinfPropParam, char *valEnum);
86 static sa_error_type_e _create_devinf_new(char *devid, devinf_devtyp_e devtyp, devinf_s ** devinf)
90 sa_error_type_e errorType = SA_INTERNAL_OK;
93 errorType = SA_INTERNAL_NOT_DEFINED;
98 errorType = SA_INTERNAL_NOT_DEFINED;
102 *devinf = (devinf_s *) calloc(1, sizeof(devinf_s));
103 if (*devinf == NULL) {
104 errorType = SA_INTERNAL_NO_MEMORY;
109 (*devinf)->dev_id = strdup(devid);
110 (*devinf)->devtyp = devtyp;
118 static sa_error_type_e _create_devinf_contenttype(char *cttype, char *verct, devinf_content_type_s ** devinf_content_type)
122 sa_error_type_e errorType = SA_INTERNAL_OK;
124 if (cttype == NULL) {
125 errorType = SA_INTERNAL_NOT_DEFINED;
130 errorType = SA_INTERNAL_NOT_DEFINED;
134 *devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
135 if (*devinf_content_type == NULL) {
136 errorType = SA_INTERNAL_NO_MEMORY;
140 (*devinf_content_type)->ct_type = strdup(cttype);
141 (*devinf_content_type)->verct = strdup(verct);
149 static sa_error_type_e _create_devinf_ctcap(devinf_content_type_s * devinf_content_type, devinf_ct_cap_s ** devinf_ctcap)
153 sa_error_type_e errorType = SA_INTERNAL_OK;
155 if (devinf_content_type == NULL) {
156 errorType = SA_INTERNAL_NOT_DEFINED;
160 *devinf_ctcap = (devinf_ct_cap_s *) calloc(1, sizeof(devinf_ct_cap_s));
161 if (*devinf_ctcap == NULL) {
162 errorType = SA_INTERNAL_NO_MEMORY;
166 (*devinf_ctcap)->ct = devinf_content_type;
175 static sa_error_type_e _create_devinf_property(char *prop_name, devinf_property_s ** devinf_property)
179 sa_error_type_e errorType = SA_INTERNAL_OK;
181 if (prop_name == NULL) {
182 errorType = SA_INTERNAL_NOT_DEFINED;
186 *devinf_property = (devinf_property_s *) calloc(1, sizeof(devinf_property_s));
187 if (*devinf_property == NULL) {
188 errorType = SA_INTERNAL_NO_MEMORY;
192 (*devinf_property)->prop_name = strdup(prop_name);
200 static sa_error_type_e _create_devinf_datastore(char *datastore, devinf_datastore_s ** devinf_datastore)
204 sa_error_type_e errorType = SA_INTERNAL_OK;
206 if (datastore == NULL) {
207 errorType = SA_INTERNAL_NOT_DEFINED;
211 *devinf_datastore = (devinf_datastore_s *) calloc(1, sizeof(devinf_datastore_s));
212 if (*devinf_datastore == NULL) {
213 errorType = SA_INTERNAL_NO_MEMORY;
217 (*devinf_datastore)->source_ref = strdup(datastore);
225 static void _free_devinf_datastores(GList * devinf_datastores)
229 retm_if(devinf_datastores == NULL, "List is NULL");
232 for (iter = devinf_datastores; iter != NULL; iter = g_list_next(iter))
233 __free_devinf_datastore(iter->data);
235 g_list_free(devinf_datastores);
240 static void __free_devinf_datastore(devinf_datastore_s * devinf_datastore)
244 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
246 if (devinf_datastore->source_ref != NULL) {
247 free(devinf_datastore->source_ref);
248 devinf_datastore->source_ref = NULL;
251 if (devinf_datastore->display_name != NULL) {
252 free(devinf_datastore->display_name);
253 devinf_datastore->display_name = NULL;
256 ___free_devinf_contenttype(devinf_datastore->rx_pref);
257 devinf_datastore->rx_pref = NULL;
259 ___free_devinf_contenttype(devinf_datastore->tx_pref);
260 devinf_datastore->tx_pref = NULL;
262 /*free_FilterRx(filter_rx); */
263 /*free_FilterCap(filterCap); */
266 for (iter = devinf_datastore->rx; iter != NULL; iter = g_list_next(iter))
267 ___free_devinf_contenttype(iter->data);
268 g_list_free(devinf_datastore->rx);
270 for (iter = devinf_datastore->tx; iter != NULL; iter = g_list_next(iter))
271 ___free_devinf_contenttype(iter->data);
272 g_list_free(devinf_datastore->tx);
274 for (iter = devinf_datastore->ct_caps; iter != NULL; iter = g_list_next(iter))
275 ___free_devinf_ctcaps(iter->data);
276 g_list_free(devinf_datastore->ct_caps);
278 free(devinf_datastore);
283 static void ___free_devinf_contenttype(devinf_content_type_s * devinf_content_type)
287 retm_if(devinf_content_type == NULL, "devinf_content_type is NULL");
289 if (devinf_content_type->ct_type != NULL) {
290 free(devinf_content_type->ct_type);
291 devinf_content_type->ct_type = NULL;
294 if (devinf_content_type->verct != NULL) {
295 free(devinf_content_type->verct);
296 devinf_content_type->verct = NULL;
299 free(devinf_content_type);
304 static void ___free_devinf_ctcaps(devinf_ct_cap_s * devinf_ctcap)
308 retm_if(devinf_ctcap == NULL, "devinf_ctcap is NULL");
310 ___free_devinf_contenttype(devinf_ctcap->ct);
311 devinf_ctcap->ct = NULL;
314 for (iter = devinf_ctcap->properties; iter != NULL; iter = g_list_next(iter))
315 ___free_devinf_property(iter->data);
317 g_list_free(devinf_ctcap->properties);
324 static void ___free_devinf_property(devinf_property_s * devinf_property)
328 retm_if(devinf_property == NULL, "devinf_property is NULL");
330 if (devinf_property->prop_name != NULL) {
331 free(devinf_property->prop_name);
332 devinf_property->prop_name = NULL;
335 if (devinf_property->data_type != NULL) {
336 free(devinf_property->data_type);
337 devinf_property->data_type = NULL;
340 if (devinf_property->display_name != NULL) {
341 free(devinf_property->display_name);
342 devinf_property->display_name = NULL;
346 for (iter = devinf_property->val_enums; iter != NULL; iter = g_list_next(iter))
349 g_list_free(devinf_property->val_enums);
351 for (iter = devinf_property->prop_params; iter != NULL; iter = g_list_next(iter))
352 ___free_devinf_propparam(iter->data);
354 g_list_free(devinf_property->prop_params);
356 free(devinf_property);
361 static void ___free_devinf_propparam(devinf_prop_param_s * devinf_prop_param)
365 retm_if(devinf_prop_param == NULL, "devinfPropParam is NULL");
367 if (devinf_prop_param->param_name != NULL) {
368 free(devinf_prop_param->param_name);
369 devinf_prop_param->param_name = NULL;
372 if (devinf_prop_param->data_type != NULL) {
373 free(devinf_prop_param->data_type);
374 devinf_prop_param->data_type = NULL;
377 if (devinf_prop_param->display_name != NULL) {
378 free(devinf_prop_param->display_name);
379 devinf_prop_param->display_name = NULL;
383 for (iter = devinf_prop_param->val_enums; iter != NULL; iter = g_list_next(iter))
386 g_list_free(devinf_prop_param->val_enums);
388 free(devinf_prop_param);
393 static void _set_devinf_version(devinf_s * devinf, devinf_version_e version)
397 retm_if(devinf == NULL, "devinf is NULL");
399 devinf->version = version;
404 static void _set_devinf_manufacturer(devinf_s * devinf, char *manufacturer)
408 retm_if(devinf == NULL, "devinf is NULL");
410 if (manufacturer != NULL)
411 devinf->manufacturer = strdup(manufacturer);
416 static void _set_devinf_model(devinf_s * devinf, char *model)
420 retm_if(devinf == NULL, "devinf is NULL");
423 devinf->model = strdup(model);
428 static void _set_devinf_oem(devinf_s * devinf, char *oem)
432 retm_if(devinf == NULL, "devinf is NULL");
435 devinf->oem = strdup(oem);
440 static void _set_devinf_software_version(devinf_s * devinf, char *software_version)
444 retm_if(devinf == NULL, "devinf is NULL");
446 if (software_version != NULL)
447 devinf->software_version = strdup(software_version);
452 static void _set_devinf_hardware_version(devinf_s * devinf, char *hardware_version)
456 retm_if(devinf == NULL, "devinf is NULL");
458 if (hardware_version != NULL)
459 devinf->hardware_version = strdup(hardware_version);
464 static void _set_devinf_firmware_version(devinf_s * devinf, char *firmware_version)
468 retm_if(devinf == NULL, "devinf is NULL");
470 if (firmware_version != NULL)
471 devinf->firmware_version = strdup(firmware_version);
476 static void _set_devinf_datastore(devinf_s * devinf, devinf_datastore_s * devinf_datastore)
480 retm_if(devinf == NULL, "devinf is NULL");
482 devinf->datastores = g_list_append(devinf->datastores, devinf_datastore);
487 static void _set_devinf_datastore_rxpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type)
491 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
493 devinf_datastore->rx_pref = devinf_content_type;
498 static void _set_devinf_datastore_txpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type)
502 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
504 devinf_datastore->tx_pref = devinf_content_type;
509 static void _set_devinf_datastore_ctcap(devinf_datastore_s * devinf_datastore, devinf_ct_cap_s * devinf_ctcap)
513 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
515 devinf_datastore->ct_caps = g_list_append(devinf_datastore->ct_caps, devinf_ctcap);
520 static void _set_devinf_datastore_sharedmem(devinf_datastore_s * devinf_datastore, int shared_mem)
524 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
526 devinf_datastore->shared_mem = shared_mem;
531 static void _set_devinf_datastore_maxmem(devinf_datastore_s * devinf_datastore, unsigned int max_mem)
535 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
537 devinf_datastore->max_mem = max_mem;
542 static void _set_devinf_datastore_maxid(devinf_datastore_s * devinf_datastore, unsigned int max_id)
546 retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
548 devinf_datastore->max_id = max_id;
553 static void _set_devinf_ctcap_property(devinf_ct_cap_s * devinf_ctcap, devinf_property_s * devinf_property)
557 retm_if(devinf_ctcap == NULL, "devinfCTCap is NULL");
559 devinf_ctcap->properties = g_list_append(devinf_ctcap->properties, devinf_property);
564 static void _set_devinf_property_valenums(devinf_property_s * devinf_property, char *val_enum)
568 retm_if(devinf_property == NULL, "devinfCTCap is NULL");
570 if (val_enum != NULL)
571 devinf_property->val_enums = g_list_append(devinf_property->val_enums, strdup(val_enum));
576 static devinf_devtyp_e _convert_devtyp(char *dev_typ)
580 devinf_devtyp_e devinfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
582 if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PAGER) == 0)
583 devinfDevTyp = DEVINF_DEVTYPE_PAGER;
584 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_HANDHELD) == 0)
585 devinfDevTyp = DEVINF_DEVTYPE_HANDHELD;
586 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PDA) == 0)
587 devinfDevTyp = DEVINF_DEVTYPE_PDA;
588 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PHONE) == 0)
589 devinfDevTyp = DEVINF_DEVTYPE_PHONE;
590 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_SMARTPHONE) == 0)
591 devinfDevTyp = DEVINF_DEVTYPE_SMARTPHONE;
592 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_SERVER) == 0)
593 devinfDevTyp = DEVINF_DEVTYPE_SERVER;
594 else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_WORKSTATION) == 0)
595 devinfDevTyp = DEVINF_DEVTYPE_WORKSTATION;
601 sa_error_type_e create_devinf(session_s * session, devinf_s ** devinf)
605 sa_error_type_e errorType = SA_INTERNAL_OK;
606 sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
617 devinf_s *temp_devinf = NULL;
618 devinf_datastore_s *devInfDataStore = NULL;
619 devinf_ct_cap_s *devInfCTCap = NULL;
620 devinf_property_s *devInfProperty = NULL;
622 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "DevID", &devID);
623 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
624 errorType = SA_INTERNAL_ERROR;
628 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "DevTyp", &devTyp);
629 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
630 errorType = SA_INTERNAL_ERROR;
634 devinf_devtyp_e devInfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
636 devInfDevTyp = _convert_devtyp(devTyp);
638 devinf_version_e devInfVersion = DEVINF_VERSION_UNKNOWN;
639 if (session->protocol_version == VERSION_10)
640 devInfVersion = DEVINF_VERSION_10;
641 else if (session->protocol_version == VERSION_11)
642 devInfVersion = DEVINF_VERSION_11;
643 else if (session->protocol_version == VERSION_12)
644 devInfVersion = DEVINF_VERSION_12;
646 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "Man", &man);
647 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
648 errorType = SA_INTERNAL_ERROR;
652 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "Mod", &model);
653 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
654 errorType = SA_INTERNAL_ERROR;
658 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "OEM", &oem);
659 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
660 errorType = SA_INTERNAL_ERROR;
664 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "SwV", &swv);
665 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
666 errorType = SA_INTERNAL_ERROR;
670 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "HwV", &hwv);
671 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
672 errorType = SA_INTERNAL_ERROR;
677 err = sync_agent_get_devinfo(DEFINE_PLATFORM, "FwV", &fwv);
678 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
679 errorType = ERROR_INTERNAL_ERROR;
684 _DEBUG_INFO("devID = %s", devID);
685 _DEBUG_INFO("devTyp = %s", devTyp);
686 _DEBUG_INFO("man = %s", man);
687 _DEBUG_INFO("model = %s", model);
688 _DEBUG_INFO("oem = %s", oem);
689 _DEBUG_INFO("swv = %s", swv);
690 _DEBUG_INFO("hwv = %s", hwv);
691 _DEBUG_INFO("fwv = %s", fwv);
693 errorType = _create_devinf_new(devID, devInfDevTyp, &temp_devinf);
694 if (errorType != SA_INTERNAL_OK) {
695 _DEBUG_ERROR("failed to create devInf New");
699 _set_devinf_version(temp_devinf, devInfVersion);
700 _set_devinf_manufacturer(temp_devinf, man);
701 _set_devinf_model(temp_devinf, model);
702 _set_devinf_oem(temp_devinf, oem);
703 _set_devinf_software_version(temp_devinf, swv);
704 _set_devinf_hardware_version(temp_devinf, hwv);
705 _set_devinf_firmware_version(temp_devinf, fwv);
707 temp_devinf->supports_large_objs = 1;
708 temp_devinf->supports_utc = 1;
709 temp_devinf->supports_number_of_changes = 1;
711 /*TODO Implements call log datastore's datastore for device info */
712 /* TYPE_CONTENT_COUNT -1 -> not include calllog datastore */
714 for (content_type = 0; content_type < TYPE_SERVICE_COUNT - 1; content_type++) {
716 if (datastoreinfo_per_content_type[content_type] != NULL) {
717 if (datastoreinfo_per_content_type[content_type]->source != NULL) {
718 errorType = _create_devinf_datastore(datastoreinfo_per_content_type[content_type]->source, &devInfDataStore);
719 if (errorType != SA_INTERNAL_OK) {
720 _DEBUG_ERROR("failed to create devInfDataStore");
724 sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(content_type);
726 _DEBUG_INFO("datastore->type = %s", datastore->type);
727 _DEBUG_INFO("datastore->version = %s", datastore->version);
728 _DEBUG_INFO("datastore->field_cnt = %d", datastore->field_cnt);
730 devinf_content_type_s *devInfContentTypeRxPref = NULL;
731 errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeRxPref);
732 if (errorType != SA_INTERNAL_OK) {
733 _DEBUG_ERROR("failed to create devInfContentType");
736 _set_devinf_datastore_rxpref(devInfDataStore, devInfContentTypeRxPref);
738 devinf_content_type_s *devInfContentTypeTxPref = NULL;
739 errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeTxPref);
740 if (errorType != SA_INTERNAL_OK) {
741 _DEBUG_ERROR("failed to create devInfContentType");
744 _set_devinf_datastore_txpref(devInfDataStore, devInfContentTypeTxPref);
746 devinf_content_type_s *devInfContentTypeCTCap = NULL;
747 errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeCTCap);
748 if (errorType != SA_INTERNAL_OK) {
749 _DEBUG_ERROR("failed to create devInfContentType");
753 errorType = _create_devinf_ctcap(devInfContentTypeCTCap, &devInfCTCap);
754 if (errorType != SA_INTERNAL_OK) {
755 _DEBUG_ERROR("failed to create devInfCTCap");
759 sync_agent_plugin_field_info_s field_list;
761 for (i = 0; i < datastore->field_cnt; i++) {
762 field_list = datastore->field_list[i];
763 errorType = _create_devinf_property(field_list.field_name, &devInfProperty);
764 if (errorType != SA_INTERNAL_OK) {
765 _DEBUG_ERROR("failed to create devInfProperty");
769 sync_agent_plugin_field_info_s children_field_list;
771 for (j = 0; j < field_list.field_child_cnt; j++) {
772 children_field_list = field_list.field_child_list[j];
773 _set_devinf_property_valenums(devInfProperty, children_field_list.field_name);
775 _set_devinf_ctcap_property(devInfCTCap, devInfProperty);
776 devInfProperty = NULL;
779 _set_devinf_datastore_ctcap(devInfDataStore, devInfCTCap);
782 /* TODO Get information about static memory for each datastore
783 * It will be used to fill DSMem and children element(SharedMem, MaxMem, MaxID) */
785 _set_devinf_datastore_sharedmem(devInfDataStore, 0);
787 _set_devinf_datastore_maxmem(devInfDataStore, 0);
789 _set_devinf_datastore_maxid(devInfDataStore, 0);
791 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY, 1);
792 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC, 1);
793 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT, 1);
794 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT, 1);
795 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER, 1);
796 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER, 1);
797 set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC, 1);
799 _set_devinf_datastore(temp_devinf, devInfDataStore);
800 devInfDataStore = NULL;
803 sync_agent_free_obj_info(content_type, datastore);
808 *devinf = temp_devinf;
813 if (temp_devinf != NULL)
816 __free_devinf_datastore(devInfDataStore);
817 ___free_devinf_ctcaps(devInfCTCap);
818 ___free_devinf_property(devInfProperty);
841 void free_devinf(devinf_s * devinf)
845 retm_if(devinf == NULL, "devinf is NULL");
847 if (devinf->manufacturer != NULL) {
848 free(devinf->manufacturer);
849 devinf->manufacturer = NULL;
852 if (devinf->model != NULL) {
854 devinf->model = NULL;
857 if (devinf->oem != NULL) {
862 if (devinf->software_version != NULL) {
863 free(devinf->software_version);
864 devinf->software_version = NULL;
867 if (devinf->hardware_version != NULL) {
868 free(devinf->hardware_version);
869 devinf->hardware_version = NULL;
872 if (devinf->firmware_version != NULL) {
873 free(devinf->firmware_version);
874 devinf->firmware_version = NULL;
877 if (devinf->dev_id != NULL) {
878 free(devinf->dev_id);
879 devinf->dev_id = NULL;
882 _free_devinf_datastores(devinf->datastores);
883 devinf->datastores = NULL;
890 void set_devinf_datastore_sync_cap(devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap, int supported)
895 devinf_datastore->sync_cap = devinf_datastore->sync_cap | cap;
897 devinf_datastore->sync_cap = devinf_datastore->sync_cap & ~cap;
902 int get_devinf_datastore_sync_cap(const devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap)
907 data = devinf_datastore->sync_cap & cap ? 1 : 0;
913 devinf_sync_cap_e convert_devinf_synccap(unsigned int id)
917 devinf_sync_cap_e result = DEVINF_SYNCTYPE_UNKNOWN;
920 case DEVINF_SYNCTYPE_TWO_WAY:
921 result = DEVINF_SYNCTYPE_TWO_WAY;
923 case DEVINF_SYNCTYPE_SLOW_SYNC:
924 result = DEVINF_SYNCTYPE_SLOW_SYNC;
926 case DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT:
927 result = DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT;
929 case DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT:
930 result = DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT;
932 case DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER:
933 result = DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER;
935 case DEVINF_SYNCTYPE_REFRESH_FROM_SERVER:
936 result = DEVINF_SYNCTYPE_REFRESH_FROM_SERVER;
938 case DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC:
939 result = DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC;
942 return DEVINF_SYNCTYPE_UNKNOWN;
951 static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **devinfPropParam)
955 ErrorType errorType = ERROR_INTERNAL_OK;
958 errorType = ERROR_INTERNAL_NOT_DEFINED;
962 *devinfPropParam = (DevInfPropParam *)calloc(1, sizeof(DevInfPropParam));
963 if (*devinfPropParam == NULL) {
964 errorType = ERROR_INTERNAL_NO_MEMORY;
968 (*devinfPropParam)->paramName = strdup(paramName);
976 static void set_DevInfDataStoreDisplayname(DevInfDataStore* devinf_datastore, char *displayname) {
978 if (!devinf_datastore)
981 devinf_datastore->displayname = strdup(displayname);
984 static void set_DevInfDataStoreRx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type) {
985 if (!devinf_datastore)
988 devinf_datastore->rx = g_list_append(devinf_datastore->rx, devinf_content_type);
991 static void set_DevInfDataStoreTx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type) {
992 if (!devinf_datastore)
995 devinf_datastore->tx = g_list_append(devinf_datastore->tx, devinf_content_type);
998 static void set_DevInfPropertyDataType(DevInfProperty *devinfProperty, char *dataType) {
1000 if (!devinfProperty)
1003 devinfProperty->dataType = strdup(dataType);
1006 static void set_DevInfPropertyMaxOccur(DevInfProperty *devinfProperty, unsigned int maxOccur) {
1008 if (!devinfProperty)
1011 devinfProperty->maxOccur = maxOccur;
1014 static void set_DevInfPropertyMaxSize(DevInfProperty *devinfProperty, unsigned int maxSize) {
1016 if (!devinfProperty)
1019 devinfProperty->maxSize = maxSize;
1022 static void set_DevInfPropertyNoTruncate(DevInfProperty *devinfProperty, int noTruncate) {
1024 if (!devinfProperty)
1027 devinfProperty->noTruncate = noTruncate;
1030 static void set_DevInfPropertyDisplayName(DevInfProperty *devinfProperty, char *displayName) {
1032 if (!devinfProperty)
1035 devinfProperty->displayName = strdup(displayName);
1038 static void set_DevInfPropertyPropParam(DevInfProperty *devinfProperty, DevInfPropParam *devinfPropParam) {
1040 if (!devinfProperty)
1043 devinfProperty->propParams = g_list_append(devinfProperty->propParams, devinfPropParam);
1046 static void set_DevInfPropParamDataType(DevInfPropParam *devinfPropParam, char *dataType) {
1048 if (!devinfPropParam)
1051 devinfPropParam->dataType = strdup(dataType);
1054 static void set_DevInfPropParamDisplayName(DevInfPropParam *devinfPropParam, char *displayName) {
1056 if (!devinfPropParam)
1059 devinfPropParam->displayName = strdup(displayName);
1062 static void set_DevInfPropParamValEnums(DevInfPropParam *devinfPropParam, char *valEnum) {
1064 if (!devinfPropParam)
1067 devinfPropParam->valEnums = g_list_append(devinfPropParam->valEnums, strdup(valEnum));