4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHak Park <juhaki.park@samsung.com>,
7 * JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8 * SunBong Ha <sunbong.ha@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
28 * For any sort of issue you concern as to this software,
29 * you may use following point of contact.
30 * All resources contributed on this software
31 * are orinigally written by S-Core Inc., a member of Samsung Group.
33 * SeongWon Shim <seongwon.shim@samsung.com>
39 * @brief This file is the source file of implementation of functions for device information structure which is used in Service Adapter
42 #include "agent-framework/Utility/fw_log.h"
43 #include "agent-framework/Device/EXT_DCI_DevInfo.h"
44 #include "agent-framework/DACI/EXT_DACI_Converter.h"
45 #include "ServiceAdapter/SA_DevInf.h"
46 #include "ServiceAdapter/SA_DevInf_Internal.h"
47 #include "ServiceAdapter/SA_Session_Internal.h"
48 #include "Common/Common_Define.h"
50 #define LOG_TAG "OMA_DS_SA"
52 static SA_ErrorType __create_devinf_new(char *devid, DevInfDevTyp devtyp, DevInf **pDevInf);
53 static SA_ErrorType __create_devinf_contenttype(char *cttype, char *verct, DevInfContentType **pDevInfContentType);
54 static SA_ErrorType __create_devinf_ctcap(DevInfContentType *devInfContentType, DevInfCTCap **pDevInfCTCap);
55 static SA_ErrorType __create_devinf_property(char *propName, DevInfProperty **pDevInfProperty);
57 static SA_ErrorType create_devinf_datastore(char *dataStore, DevInfDataStore **pDevInfDataStore);
58 static void __free_devinf_datastores(GList *devInfDatastores);
59 static void __free_devinf_datastore(DevInfDataStore *pDevInfDataStore);
60 static void __free_devinf_contenttype(DevInfContentType *pDevInfContentType);
61 static void __free_devinf_ctcaps(DevInfCTCap *pDevInfCTCap);
62 static void __free_devinf_property(DevInfProperty *pDevInfProperty);
63 static void __free_devinf_propparam(DevInfPropParam *pDevInfPropParam);
64 static void __set_devinf_version(DevInf *devInf, DevInfVersion version);
65 static void __set_devinf_manufacturer(DevInf *devInf, char *manufacturer);
66 static void __set_devinf_model(DevInf *devInf, char *model);
67 static void __set_devinf_oem(DevInf *devInf, char *oem);
68 static void __set_devinf_software_version(DevInf *devInf, char *softwareVersion);
69 static void __set_devinf_hardware_version(DevInf *devInf, char *hardwareVersion);
70 static void __set_devinf_firmware_version(DevInf *devInf, char *firmwareVersion);
71 static void __set_devinf_datastore(DevInf *devInf, DevInfDataStore *devInfDataStore);
72 static void __set_devinf_datastore_rxpref(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType);
73 static void __set_devinf_datastore_txpref(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType);
74 static void __set_devinf_datastore_ctcap(DevInfDataStore *devInfDataStore, DevInfCTCap *devInfCTCap);
75 static void __set_devinf_ctcap_property(DevInfCTCap *devInfCTCap, DevInfProperty *devInfProperty);
76 static void __set_devInf_property_valenums(DevInfProperty *devInfProperty, char*valEnum);
77 static DevInfDevTyp __convert_devtyp(char *devTyp);
83 static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **pDevInfPropParam);
84 static void set_DevInfDataStoreDisplayname(DevInfDataStore* devInfDataStore, char *displayname);
85 static void set_DevInfDataStoreRx(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType);
86 static void set_DevInfDataStoreTx(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType);
87 static void set_DevInfPropertyDataType(DevInfProperty *devInfProperty, char *dataType);
88 static void set_DevInfPropertyMaxOccur(DevInfProperty *devInfProperty, unsigned int maxOccur);
89 static void set_DevInfPropertyMaxSize(DevInfProperty *devInfProperty, unsigned int maxSize);
90 static void set_DevInfPropertyNoTruncate(DevInfProperty *devInfProperty, int noTruncate);
91 static void set_DevInfPropertyDisplayName(DevInfProperty *devInfProperty, char *displayName);
92 static void set_DevInfPropertyPropParam(DevInfProperty *devInfProperty, DevInfPropParam *devInfPropParam);
93 static void set_DevInfPropParamDataType(DevInfPropParam *devInfPropParam, char *dataType);
94 static void set_DevInfPropParamDisplayName(DevInfPropParam *devInfPropParam, char *displayName);
95 static void set_DevInfPropParamValEnums(DevInfPropParam *devInfPropParam, char *valEnum);
98 static SA_ErrorType __create_devinf_new(char *devid, DevInfDevTyp devtyp, DevInf **pDevInf)
102 SA_ErrorType errorType = SA_INTERNAL_OK;
105 errorType = SA_INTERNAL_NOT_DEFINED;
110 errorType = SA_INTERNAL_NOT_DEFINED;
114 *pDevInf = (DevInf *)calloc(1, sizeof(DevInf));
115 if (*pDevInf == NULL) {
116 errorType = SA_INTERNAL_NO_MEMORY;
121 (*pDevInf)->devid = strdup(devid);
122 (*pDevInf)->devtyp = devtyp;
129 FW_LOGE("error : %d", errorType);
133 static SA_ErrorType __create_devinf_contenttype(char *cttype, char *verct, DevInfContentType **pDevInfContentType)
137 SA_ErrorType errorType = SA_INTERNAL_OK;
140 errorType = SA_INTERNAL_NOT_DEFINED;
145 errorType = SA_INTERNAL_NOT_DEFINED;
149 *pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
150 if (*pDevInfContentType == NULL) {
151 errorType = SA_INTERNAL_NO_MEMORY;
155 (*pDevInfContentType)->cttype = strdup(cttype);
156 (*pDevInfContentType)->verct = strdup(verct);
163 FW_LOGE("error : %d", errorType);
167 static SA_ErrorType __create_devinf_ctcap(DevInfContentType *devInfContentType, DevInfCTCap **pDevInfCTCap)
171 SA_ErrorType errorType = SA_INTERNAL_OK;
173 if (!devInfContentType) {
174 errorType = SA_INTERNAL_NOT_DEFINED;
178 *pDevInfCTCap = (DevInfCTCap *)calloc(1, sizeof(DevInfCTCap));
179 if (*pDevInfCTCap == NULL) {
180 errorType = SA_INTERNAL_NO_MEMORY;
184 (*pDevInfCTCap)->ct = devInfContentType;
191 FW_LOGE("error : %d", errorType);
196 static SA_ErrorType __create_devinf_property(char *propName, DevInfProperty **pDevInfProperty)
200 SA_ErrorType errorType = SA_INTERNAL_OK;
203 errorType = SA_INTERNAL_NOT_DEFINED;
207 *pDevInfProperty = (DevInfProperty *)calloc(1, sizeof(DevInfProperty));
208 if (*pDevInfProperty == NULL) {
209 errorType = SA_INTERNAL_NO_MEMORY;
213 (*pDevInfProperty)->propName = strdup(propName);
220 FW_LOGE("error : %d", errorType);
224 static SA_ErrorType create_devinf_datastore(char *dataStore, DevInfDataStore **pDevInfDataStore)
228 SA_ErrorType errorType = SA_INTERNAL_OK;
231 errorType = SA_INTERNAL_NOT_DEFINED;
235 *pDevInfDataStore = (DevInfDataStore *)calloc(1, sizeof(DevInfDataStore));
236 if (*pDevInfDataStore == NULL) {
237 errorType = SA_INTERNAL_NO_MEMORY;
241 (*pDevInfDataStore)->sourceref = strdup(dataStore);
248 FW_LOGE("error : %d", errorType);
252 static void __free_devinf_datastores(GList *devInfDatastores)
256 if (!devInfDatastores)
260 for (iter = devInfDatastores; iter != NULL; iter = g_list_next(iter))
261 __free_devinf_datastore(iter->data);
263 g_list_free(devInfDatastores);
268 static void __free_devinf_datastore(DevInfDataStore *pDevInfDataStore)
272 if (!pDevInfDataStore)
275 if (pDevInfDataStore->sourceref) {
276 free(pDevInfDataStore->sourceref);
277 pDevInfDataStore->sourceref = NULL;
280 if (pDevInfDataStore->displayname) {
281 free(pDevInfDataStore->displayname);
282 pDevInfDataStore->displayname = NULL;
285 __free_devinf_contenttype(pDevInfDataStore->rxPref);
286 pDevInfDataStore->rxPref = NULL;
288 __free_devinf_contenttype(pDevInfDataStore->txPref);
289 pDevInfDataStore->txPref = NULL;
291 /*free_FilterRx(filter_rx);*/
292 /*free_FilterCap(filterCap);*/
295 for (iter = pDevInfDataStore->rx; iter != NULL; iter = g_list_next(iter))
296 __free_devinf_contenttype(iter->data);
297 g_list_free(pDevInfDataStore->rx);
299 for (iter = pDevInfDataStore->tx; iter != NULL; iter = g_list_next(iter))
300 __free_devinf_contenttype(iter->data);
301 g_list_free(pDevInfDataStore->tx);
303 for (iter = pDevInfDataStore->ctcaps; iter != NULL; iter = g_list_next(iter))
304 __free_devinf_ctcaps(iter->data);
305 g_list_free(pDevInfDataStore->ctcaps);
307 free(pDevInfDataStore);
313 static void __free_devinf_contenttype(DevInfContentType *pDevInfContentType)
317 if (!pDevInfContentType)
320 if (pDevInfContentType->cttype) {
321 free(pDevInfContentType->cttype);
322 pDevInfContentType->cttype = NULL;
325 if (pDevInfContentType->verct) {
326 free(pDevInfContentType->verct);
327 pDevInfContentType->verct = NULL;
330 free(pDevInfContentType);
335 static void __free_devinf_ctcaps(DevInfCTCap *pDevInfCTCap)
342 __free_devinf_contenttype(pDevInfCTCap->ct);
343 pDevInfCTCap->ct = NULL;
346 for (iter = pDevInfCTCap->properties; iter != NULL; iter = g_list_next(iter))
347 __free_devinf_property(iter->data);
349 g_list_free(pDevInfCTCap->properties);
357 static void __free_devinf_property(DevInfProperty *pDevInfProperty)
361 if (!pDevInfProperty)
364 if (pDevInfProperty->propName) {
365 free(pDevInfProperty->propName);
366 pDevInfProperty->propName = NULL;
369 if (pDevInfProperty->dataType) {
370 free(pDevInfProperty->dataType);
371 pDevInfProperty->dataType = NULL;
374 if (pDevInfProperty->displayName) {
375 free(pDevInfProperty->displayName);
376 pDevInfProperty->displayName = NULL;
380 for (iter = pDevInfProperty->valEnums; iter != NULL; iter = g_list_next(iter))
383 g_list_free(pDevInfProperty->valEnums);
386 for (iter = pDevInfProperty->propParams; iter != NULL; iter = g_list_next(iter))
387 __free_devinf_propparam(iter->data);
389 g_list_free(pDevInfProperty->propParams);
391 free(pDevInfProperty);
396 static void __free_devinf_propparam(DevInfPropParam *pDevInfPropParam)
400 if (!pDevInfPropParam)
403 if (pDevInfPropParam->paramName) {
404 free(pDevInfPropParam->paramName);
405 pDevInfPropParam->paramName = NULL;
408 if (pDevInfPropParam->dataType) {
409 free(pDevInfPropParam->dataType);
410 pDevInfPropParam->dataType = NULL;
413 if (pDevInfPropParam->displayName) {
414 free(pDevInfPropParam->displayName);
415 pDevInfPropParam->displayName = NULL;
419 for (iter = pDevInfPropParam->valEnums; iter != NULL; iter = g_list_next(iter))
422 g_list_free(pDevInfPropParam->valEnums);
424 free(pDevInfPropParam);
430 static void __set_devinf_version(DevInf *devInf, DevInfVersion version)
435 devInf->version = version;
438 static void __set_devinf_manufacturer(DevInf *devInf, char *manufacturer)
443 if (manufacturer != NULL)
444 devInf->manufacturer = strdup(manufacturer);
447 static void __set_devinf_model(DevInf *devInf, char *model)
453 devInf->model = strdup(model);
456 static void __set_devinf_oem(DevInf *devInf, char *oem)
462 devInf->oem = strdup(oem);
465 static void __set_devinf_software_version(DevInf *devInf, char *softwareVersion)
470 if (softwareVersion != NULL)
471 devInf->softwareVersion = strdup(softwareVersion);
474 static void __set_devinf_hardware_version(DevInf *devInf, char *hardwareVersion)
479 if (hardwareVersion != NULL)
480 devInf->hardwareVersion = strdup(hardwareVersion);
483 static void __set_devinf_firmware_version(DevInf *devInf, char *firmwareVersion)
488 if (firmwareVersion != NULL)
489 devInf->firmwareVersion = strdup(firmwareVersion);
492 static void __set_devinf_datastore(DevInf *devInf, DevInfDataStore *devInfDataStore)
497 devInf->datastores = g_list_append(devInf->datastores, devInfDataStore);
500 static void __set_devinf_datastore_rxpref(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType)
502 if (!devInfDataStore)
505 devInfDataStore->rxPref = devInfContentType;
508 static void __set_devinf_datastore_txpref(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType)
510 if (!devInfDataStore)
513 devInfDataStore->txPref = devInfContentType;
516 static void __set_devinf_datastore_ctcap(DevInfDataStore *devInfDataStore, DevInfCTCap *devInfCTCap)
518 if (!devInfDataStore)
521 devInfDataStore->ctcaps = g_list_append(devInfDataStore->ctcaps, devInfCTCap);
524 static void __set_devinf_ctcap_property(DevInfCTCap *devInfCTCap, DevInfProperty *devInfProperty)
529 devInfCTCap->properties = g_list_append(devInfCTCap->properties, devInfProperty);
532 static void __set_devInf_property_valenums(DevInfProperty *devInfProperty, char*valEnum)
538 devInfProperty->valEnums = g_list_append(devInfProperty->valEnums, strdup(valEnum));
541 static DevInfDevTyp __convert_devtyp(char *devTyp)
543 DevInfDevTyp devInfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
545 if (strcmp(devTyp, DEFINE_DEVICE_TYPE_PAGER) == 0)
546 devInfDevTyp = DEVINF_DEVTYPE_PAGER;
547 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_HANDHELD) == 0)
548 devInfDevTyp = DEVINF_DEVTYPE_HANDHELD;
549 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_PDA) == 0)
550 devInfDevTyp = DEVINF_DEVTYPE_PDA;
551 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_PHONE) == 0)
552 devInfDevTyp = DEVINF_DEVTYPE_PHONE;
553 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_SMARTPHONE) == 0)
554 devInfDevTyp = DEVINF_DEVTYPE_SMARTPHONE;
555 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_SERVER) == 0)
556 devInfDevTyp = DEVINF_DEVTYPE_SERVER;
557 else if (strcmp(devTyp, DEFINE_DEVICE_TYPE_WORKSTATION) == 0)
558 devInfDevTyp = DEVINF_DEVTYPE_WORKSTATION;
563 SA_ErrorType create_devinf(Session *session, DevInf **pDevInf)
567 SA_ErrorType errorType = SA_INTERNAL_OK;
568 DCI_RETURN err = DCI_SUCCESS;
571 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "DevID", &devID);
572 if (err != DCI_SUCCESS) {
573 errorType = SA_INTERNAL_ERROR;
578 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "DevTyp", &devTyp);
579 if (err != DCI_SUCCESS) {
580 errorType = SA_INTERNAL_ERROR;
584 DevInfDevTyp devInfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
586 devInfDevTyp = __convert_devtyp(devTyp);
588 DevInfVersion devInfVersion = DEVINF_VERSION_UNKNOWN;
589 if (session->protocolVersion == VERSION_10)
590 devInfVersion = DEVINF_VERSION_10;
591 else if (session->protocolVersion == VERSION_11)
592 devInfVersion = DEVINF_VERSION_11;
593 else if (session->protocolVersion == VERSION_12)
594 devInfVersion = DEVINF_VERSION_12;
597 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "Man", &man);
598 if (err != DCI_SUCCESS) {
599 errorType = SA_INTERNAL_ERROR;
604 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "Mod", &model);
605 if (err != DCI_SUCCESS) {
606 errorType = SA_INTERNAL_ERROR;
611 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "OEM", &oem);
612 if (err != DCI_SUCCESS) {
613 errorType = SA_INTERNAL_ERROR;
618 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "SwV", &swv);
619 if (err != DCI_SUCCESS) {
620 errorType = SA_INTERNAL_ERROR;
625 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "HwV", &hwv);
626 if (err != DCI_SUCCESS) {
627 errorType = SA_INTERNAL_ERROR;
633 err = DCI_Get_DevInfo(DEFINE_PLATFORM, "FwV", &fwv);
634 if (err != DCI_SUCCESS) {
635 errorType = ERROR_INTERNAL_ERROR;
640 FW_LOGV("devID = %s", devID);
641 FW_LOGV("devTyp = %s", devTyp);
642 FW_LOGV("man = %s", man);
643 FW_LOGV("model = %s", model);
644 FW_LOGV("oem = %s", oem);
645 FW_LOGV("swv = %s", swv);
646 FW_LOGV("hwv = %s", hwv);
647 FW_LOGV("fwv = %s", fwv);
649 DevInf *pTempDevInf = NULL;
650 errorType = __create_devinf_new(devID, devInfDevTyp, &pTempDevInf);
651 if (errorType != SA_INTERNAL_OK) {
652 FW_LOGE("failed to create devInf New");
656 __set_devinf_version(pTempDevInf, devInfVersion);
657 __set_devinf_manufacturer(pTempDevInf, man);
658 __set_devinf_model(pTempDevInf, model);
659 __set_devinf_oem(pTempDevInf, oem);
660 __set_devinf_software_version(pTempDevInf, swv);
661 __set_devinf_hardware_version(pTempDevInf, hwv);
662 __set_devinf_firmware_version(pTempDevInf, fwv);
664 pTempDevInf->supportsLargeObjs = 1;
665 pTempDevInf->supportsUTC = 1;
666 pTempDevInf->supportsNumberOfChanges = 1;
668 /*TODO Implements call log datastore's datastore for device info */
669 /* TYPE_CONTENT_COUNT -1 -> not include calllog datastore */
671 for (content_type = 0; content_type < TYPE_CONTENT_COUNT - 1; content_type++) {
673 if (datastoreinfo_per_content_type[content_type]->source != NULL) {
674 DevInfDataStore *devInfDataStore = NULL;
675 errorType = create_devinf_datastore(datastoreinfo_per_content_type[content_type]->source, &devInfDataStore);
676 if (errorType != SA_INTERNAL_OK) {
677 FW_LOGE("failed to create devInfDataStore");
681 Object_Info *datastore = T_DACI_Get_Obj_Info(content_type);
683 FW_LOGV("datastore->type = %s", datastore->type);
684 FW_LOGV("datastore->version = %s", datastore->version);
685 FW_LOGV("datastore->field_cnt = %d", datastore->field_cnt);
687 DevInfContentType *devInfContentTypeRxPref = NULL;
688 errorType = __create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeRxPref);
689 if (errorType != SA_INTERNAL_OK) {
690 FW_LOGE("failed to create devInfContentType");
693 __set_devinf_datastore_rxpref(devInfDataStore, devInfContentTypeRxPref);
695 DevInfContentType *devInfContentTypeTxPref = NULL;
696 errorType = __create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeTxPref);
697 if (errorType != SA_INTERNAL_OK) {
698 FW_LOGE("failed to create devInfContentType");
701 __set_devinf_datastore_txpref(devInfDataStore, devInfContentTypeTxPref);
703 DevInfContentType *devInfContentTypeCTCap = NULL;
704 errorType = __create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeCTCap);
705 if (errorType != SA_INTERNAL_OK) {
706 FW_LOGE("failed to create devInfContentType");
710 DevInfCTCap *devInfCTCap = NULL;
711 errorType = __create_devinf_ctcap(devInfContentTypeCTCap , &devInfCTCap);
712 if (errorType != SA_INTERNAL_OK) {
713 FW_LOGE("failed to create devInfCTCap");
717 DevInfProperty *devInfProperty = NULL;
718 Field_Info field_list;
720 for (i = 0; i < datastore->field_cnt; i++) {
721 field_list = datastore->field_list[i];
722 errorType = __create_devinf_property(field_list.field_name, &devInfProperty);
723 if (errorType != SA_INTERNAL_OK) {
724 FW_LOGE("failed to create devInfProperty");
728 Field_Info children_field_list;
730 for (j = 0; j < field_list.field_child_cnt; j++) {
731 children_field_list = field_list.field_child_list[j];
732 __set_devInf_property_valenums(devInfProperty, children_field_list.field_name);
734 __set_devinf_ctcap_property(devInfCTCap, devInfProperty);
737 __set_devinf_datastore_ctcap(devInfDataStore, devInfCTCap);
739 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY, 1);
740 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC, 1);
741 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT, 1);
742 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT, 1);
743 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER, 1);
744 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER, 1);
745 set_devInf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC, 1);
747 __set_devinf_datastore(pTempDevInf, devInfDataStore);
750 T_DACI_Free_Obj_Info(content_type, datastore);
771 *pDevInf = pTempDevInf;
795 FW_LOGE("error : %d", errorType);
799 void free_devinf(DevInf *devInf)
805 if (devInf->manufacturer) {
806 free(devInf->manufacturer);
807 devInf->manufacturer = NULL;
812 devInf->model = NULL;
821 if (devInf->softwareVersion) {
822 free(devInf->softwareVersion);
823 devInf->softwareVersion = NULL;
827 if (devInf->hardwareVersion) {
828 free(devInf->hardwareVersion);
829 devInf->hardwareVersion = NULL;
833 if (devInf->firmwareVersion) {
834 free(devInf->firmwareVersion);
835 devInf->firmwareVersion = NULL;
841 devInf->devid = NULL;
844 __free_devinf_datastores(devInf->datastores);
845 devInf->datastores = NULL;
852 void set_devInf_datastore_synccap(DevInfDataStore *devInfDataStore, DevInfSyncCap cap, int supported)
855 devInfDataStore->synccap = devInfDataStore->synccap | cap;
857 devInfDataStore->synccap = devInfDataStore->synccap & ~cap;
860 int get_devinf_datastore_synccap(const DevInfDataStore *devInfDataStore, DevInfSyncCap cap)
862 return devInfDataStore->synccap & cap ? 1 : 0;
865 DevInfSyncCap convert_devinf_synccap(unsigned int id)
867 DevInfSyncCap result = DEVINF_SYNCTYPE_UNKNOWN;
870 case DEVINF_SYNCTYPE_TWO_WAY:
871 result = DEVINF_SYNCTYPE_TWO_WAY;
873 case DEVINF_SYNCTYPE_SLOW_SYNC:
874 result = DEVINF_SYNCTYPE_SLOW_SYNC;
876 case DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT:
877 result = DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT;
879 case DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT:
880 result = DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT;
882 case DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER:
883 result = DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER;
885 case DEVINF_SYNCTYPE_REFRESH_FROM_SERVER:
886 result = DEVINF_SYNCTYPE_REFRESH_FROM_SERVER;
888 case DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC:
889 result = DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC;
892 return DEVINF_SYNCTYPE_UNKNOWN;
900 static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **pDevInfPropParam)
904 ErrorType errorType = ERROR_INTERNAL_OK;
907 errorType = ERROR_INTERNAL_NOT_DEFINED;
911 *pDevInfPropParam = (DevInfPropParam *)calloc(1, sizeof(DevInfPropParam));
912 if (*pDevInfPropParam == NULL) {
913 errorType = ERROR_INTERNAL_NO_MEMORY;
917 (*pDevInfPropParam)->paramName = strdup(paramName);
924 FW_LOGE("error : %d", errorType);
929 static void set_DevInfDataStoreDisplayname(DevInfDataStore* devInfDataStore, char *displayname) {
931 if (!devInfDataStore)
934 devInfDataStore->displayname = strdup(displayname);
937 static void set_DevInfDataStoreRx(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType) {
938 if (!devInfDataStore)
941 devInfDataStore->rx = g_list_append(devInfDataStore->rx, devInfContentType);
944 static void set_DevInfDataStoreTx(DevInfDataStore *devInfDataStore, DevInfContentType *devInfContentType) {
945 if (!devInfDataStore)
948 devInfDataStore->tx = g_list_append(devInfDataStore->tx, devInfContentType);
952 static void set_DevInfPropertyDataType(DevInfProperty *devInfProperty, char *dataType) {
957 devInfProperty->dataType = strdup(dataType);
960 static void set_DevInfPropertyMaxOccur(DevInfProperty *devInfProperty, unsigned int maxOccur) {
965 devInfProperty->maxOccur = maxOccur;
968 static void set_DevInfPropertyMaxSize(DevInfProperty *devInfProperty, unsigned int maxSize) {
973 devInfProperty->maxSize = maxSize;
976 static void set_DevInfPropertyNoTruncate(DevInfProperty *devInfProperty, int noTruncate) {
981 devInfProperty->noTruncate = noTruncate;
984 static void set_DevInfPropertyDisplayName(DevInfProperty *devInfProperty, char *displayName) {
989 devInfProperty->displayName = strdup(displayName);
992 static void set_DevInfPropertyPropParam(DevInfProperty *devInfProperty, DevInfPropParam *devInfPropParam) {
997 devInfProperty->propParams = g_list_append(devInfProperty->propParams, devInfPropParam);
1000 static void set_DevInfPropParamDataType(DevInfPropParam *devInfPropParam, char *dataType) {
1002 if (!devInfPropParam)
1005 devInfPropParam->dataType = strdup(dataType);
1008 static void set_DevInfPropParamDisplayName(DevInfPropParam *devInfPropParam, char *displayName) {
1010 if (!devInfPropParam)
1013 devInfPropParam->displayName = strdup(displayName);
1016 static void set_DevInfPropParamValEnums(DevInfPropParam *devInfPropParam, char *valEnum) {
1018 if (!devInfPropParam)
1021 devInfPropParam->valEnums = g_list_append(devInfPropParam->valEnums, strdup(valEnum));