summaryrefslogtreecommitdiff
path: root/src/agent/service-adapter/sa_devinf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/service-adapter/sa_devinf.c')
-rwxr-xr-xsrc/agent/service-adapter/sa_devinf.c1069
1 files changed, 1069 insertions, 0 deletions
diff --git a/src/agent/service-adapter/sa_devinf.c b/src/agent/service-adapter/sa_devinf.c
new file mode 100755
index 0000000..d65bad5
--- /dev/null
+++ b/src/agent/service-adapter/sa_devinf.c
@@ -0,0 +1,1069 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+/**
+ * @SA_DevInf.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of functions for device information structure which is used in Service Adapter
+ */
+
+#include <sync_agent.h>
+
+#include "service-adapter/sa_devinf.h"
+#include "service-adapter/sa_devinf_internal.h"
+#include "service-adapter/sa_session_internal.h"
+#include "common/common_define.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_SA"
+#endif
+
+static sa_error_type_e _create_devinf_new(char *devid, devinf_devtyp_e devtyp, devinf_s ** devinf);
+static sa_error_type_e _create_devinf_contenttype(char *cttype, char *verct, devinf_content_type_s ** devinf_content_type);
+static sa_error_type_e _create_devinf_ctcap(devinf_content_type_s * devinf_content_type, devinf_ct_cap_s ** devinf_ctcap);
+static sa_error_type_e _create_devinf_property(char *prop_name, devinf_property_s ** devinf_property);
+static sa_error_type_e _create_devinf_datastore(char *datastore, devinf_datastore_s ** devinf_datastore);
+
+static void _free_devinf_datastores(GList * devinf_datastores);
+static void __free_devinf_datastore(devinf_datastore_s * devinf_datastore);
+static void ___free_devinf_contenttype(devinf_content_type_s * devinf_content_type);
+static void ___free_devinf_ctcaps(devinf_ct_cap_s * devinf_ctcap);
+static void ___free_devinf_property(devinf_property_s * devinf_property);
+static void ___free_devinf_propparam(devinf_prop_param_s * devinf_prop_param);
+
+static void _set_devinf_version(devinf_s * devinf, devinf_version_e version);
+static void _set_devinf_manufacturer(devinf_s * devinf, char *manufacturer);
+static void _set_devinf_model(devinf_s * devinf, char *model);
+static void _set_devinf_oem(devinf_s * devinf, char *oem);
+static void _set_devinf_software_version(devinf_s * devinf, char *software_version);
+static void _set_devinf_hardware_version(devinf_s * devinf, char *hardware_version);
+static void _set_devinf_firmware_version(devinf_s * devinf, char *firmware_version);
+static void _set_devinf_datastore(devinf_s * devinf, devinf_datastore_s * devinf_datastore);
+static void _set_devinf_datastore_rxpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type);
+static void _set_devinf_datastore_txpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type);
+static void _set_devinf_datastore_ctcap(devinf_datastore_s * devinf_datastore, devinf_ct_cap_s * devinf_ctcap);
+static void _set_devinf_datastore_sharedmem(devinf_datastore_s * devinf_datastore, int shared_mem);
+static void _set_devinf_datastore_maxmem(devinf_datastore_s * devinf_datastore, unsigned int max_mem);
+static void _set_devinf_datastore_maxid(devinf_datastore_s * devinf_datastore, unsigned int max_id);
+static void _set_devinf_ctcap_property(devinf_ct_cap_s * devinf_ctcap, devinf_property_s * devinf_property);
+static void _set_devinf_property_valenums(devinf_property_s * devinf_property, char *val_enum);
+static devinf_devtyp_e _convert_devtyp(char *dev_typ);
+
+/* unused function
+ * keep for in case
+ */
+/*
+static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **devinfPropParam);
+static void set_DevInfDataStoreDisplayname(DevInfDataStore* devinf_datastore, char *displayname);
+static void set_DevInfDataStoreRx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type);
+static void set_DevInfDataStoreTx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type);
+static void set_DevInfPropertyDataType(DevInfProperty *devinfProperty, char *dataType);
+static void set_DevInfPropertyMaxOccur(DevInfProperty *devinfProperty, unsigned int maxOccur);
+static void set_DevInfPropertyMaxSize(DevInfProperty *devinfProperty, unsigned int maxSize);
+static void set_DevInfPropertyNoTruncate(DevInfProperty *devinfProperty, int noTruncate);
+static void set_DevInfPropertyDisplayName(DevInfProperty *devinfProperty, char *displayName);
+static void set_DevInfPropertyPropParam(DevInfProperty *devinfProperty, DevInfPropParam *devinfPropParam);
+static void set_DevInfPropParamDataType(DevInfPropParam *devinfPropParam, char *dataType);
+static void set_DevInfPropParamDisplayName(DevInfPropParam *devinfPropParam, char *displayName);
+static void set_DevInfPropParamValEnums(DevInfPropParam *devinfPropParam, char *valEnum);
+*/
+
+static sa_error_type_e _create_devinf_new(char *devid, devinf_devtyp_e devtyp, devinf_s ** devinf)
+{
+ _INNER_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+
+ if (devid == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (!devtyp) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinf = (devinf_s *) calloc(1, sizeof(devinf_s));
+ if (*devinf == NULL) {
+ errorType = SA_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ if (devid != NULL)
+ (*devinf)->dev_id = strdup(devid);
+ (*devinf)->devtyp = devtyp;
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return errorType;
+}
+
+static sa_error_type_e _create_devinf_contenttype(char *cttype, char *verct, devinf_content_type_s ** devinf_content_type)
+{
+ _INNER_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+
+ if (cttype == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (verct == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (*devinf_content_type == NULL) {
+ errorType = SA_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*devinf_content_type)->ct_type = strdup(cttype);
+ (*devinf_content_type)->verct = strdup(verct);
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return errorType;
+}
+
+static sa_error_type_e _create_devinf_ctcap(devinf_content_type_s * devinf_content_type, devinf_ct_cap_s ** devinf_ctcap)
+{
+ _INNER_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+
+ if (devinf_content_type == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinf_ctcap = (devinf_ct_cap_s *) calloc(1, sizeof(devinf_ct_cap_s));
+ if (*devinf_ctcap == NULL) {
+ errorType = SA_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*devinf_ctcap)->ct = devinf_content_type;
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return errorType;
+
+}
+
+static sa_error_type_e _create_devinf_property(char *prop_name, devinf_property_s ** devinf_property)
+{
+ _INNER_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+
+ if (prop_name == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinf_property = (devinf_property_s *) calloc(1, sizeof(devinf_property_s));
+ if (*devinf_property == NULL) {
+ errorType = SA_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*devinf_property)->prop_name = strdup(prop_name);
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return errorType;
+}
+
+static sa_error_type_e _create_devinf_datastore(char *datastore, devinf_datastore_s ** devinf_datastore)
+{
+ _INNER_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+
+ if (datastore == NULL) {
+ errorType = SA_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinf_datastore = (devinf_datastore_s *) calloc(1, sizeof(devinf_datastore_s));
+ if (*devinf_datastore == NULL) {
+ errorType = SA_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*devinf_datastore)->source_ref = strdup(datastore);
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return errorType;
+}
+
+static void _free_devinf_datastores(GList * devinf_datastores)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastores == NULL, "List is NULL");
+
+ GList *iter = NULL;
+ for (iter = devinf_datastores; iter != NULL; iter = g_list_next(iter))
+ __free_devinf_datastore(iter->data);
+
+ g_list_free(devinf_datastores);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void __free_devinf_datastore(devinf_datastore_s * devinf_datastore)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ if (devinf_datastore->source_ref != NULL) {
+ free(devinf_datastore->source_ref);
+ devinf_datastore->source_ref = NULL;
+ }
+
+ if (devinf_datastore->display_name != NULL) {
+ free(devinf_datastore->display_name);
+ devinf_datastore->display_name = NULL;
+ }
+
+ ___free_devinf_contenttype(devinf_datastore->rx_pref);
+ devinf_datastore->rx_pref = NULL;
+
+ ___free_devinf_contenttype(devinf_datastore->tx_pref);
+ devinf_datastore->tx_pref = NULL;
+
+ /*free_FilterRx(filter_rx); */
+ /*free_FilterCap(filterCap); */
+
+ GList *iter = NULL;
+ for (iter = devinf_datastore->rx; iter != NULL; iter = g_list_next(iter))
+ ___free_devinf_contenttype(iter->data);
+ g_list_free(devinf_datastore->rx);
+
+ for (iter = devinf_datastore->tx; iter != NULL; iter = g_list_next(iter))
+ ___free_devinf_contenttype(iter->data);
+ g_list_free(devinf_datastore->tx);
+
+ for (iter = devinf_datastore->ct_caps; iter != NULL; iter = g_list_next(iter))
+ ___free_devinf_ctcaps(iter->data);
+ g_list_free(devinf_datastore->ct_caps);
+
+ free(devinf_datastore);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void ___free_devinf_contenttype(devinf_content_type_s * devinf_content_type)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_content_type == NULL, "devinf_content_type is NULL");
+
+ if (devinf_content_type->ct_type != NULL) {
+ free(devinf_content_type->ct_type);
+ devinf_content_type->ct_type = NULL;
+ }
+
+ if (devinf_content_type->verct != NULL) {
+ free(devinf_content_type->verct);
+ devinf_content_type->verct = NULL;
+ }
+
+ free(devinf_content_type);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void ___free_devinf_ctcaps(devinf_ct_cap_s * devinf_ctcap)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_ctcap == NULL, "devinf_ctcap is NULL");
+
+ ___free_devinf_contenttype(devinf_ctcap->ct);
+ devinf_ctcap->ct = NULL;
+
+ GList *iter = NULL;
+ for (iter = devinf_ctcap->properties; iter != NULL; iter = g_list_next(iter))
+ ___free_devinf_property(iter->data);
+
+ g_list_free(devinf_ctcap->properties);
+
+ free(devinf_ctcap);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void ___free_devinf_property(devinf_property_s * devinf_property)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_property == NULL, "devinf_property is NULL");
+
+ if (devinf_property->prop_name != NULL) {
+ free(devinf_property->prop_name);
+ devinf_property->prop_name = NULL;
+ }
+
+ if (devinf_property->data_type != NULL) {
+ free(devinf_property->data_type);
+ devinf_property->data_type = NULL;
+ }
+
+ if (devinf_property->display_name != NULL) {
+ free(devinf_property->display_name);
+ devinf_property->display_name = NULL;
+ }
+
+ GList *iter = NULL;
+ for (iter = devinf_property->val_enums; iter != NULL; iter = g_list_next(iter))
+ free(iter->data);
+
+ g_list_free(devinf_property->val_enums);
+
+ for (iter = devinf_property->prop_params; iter != NULL; iter = g_list_next(iter))
+ ___free_devinf_propparam(iter->data);
+
+ g_list_free(devinf_property->prop_params);
+
+ free(devinf_property);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void ___free_devinf_propparam(devinf_prop_param_s * devinf_prop_param)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_prop_param == NULL, "devinfPropParam is NULL");
+
+ if (devinf_prop_param->param_name != NULL) {
+ free(devinf_prop_param->param_name);
+ devinf_prop_param->param_name = NULL;
+ }
+
+ if (devinf_prop_param->data_type != NULL) {
+ free(devinf_prop_param->data_type);
+ devinf_prop_param->data_type = NULL;
+ }
+
+ if (devinf_prop_param->display_name != NULL) {
+ free(devinf_prop_param->display_name);
+ devinf_prop_param->display_name = NULL;
+ }
+
+ GList *iter = NULL;
+ for (iter = devinf_prop_param->val_enums; iter != NULL; iter = g_list_next(iter))
+ free(iter->data);
+
+ g_list_free(devinf_prop_param->val_enums);
+
+ free(devinf_prop_param);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_version(devinf_s * devinf, devinf_version_e version)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ devinf->version = version;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_manufacturer(devinf_s * devinf, char *manufacturer)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (manufacturer != NULL)
+ devinf->manufacturer = strdup(manufacturer);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_model(devinf_s * devinf, char *model)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (model != NULL)
+ devinf->model = strdup(model);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_oem(devinf_s * devinf, char *oem)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (oem != NULL)
+ devinf->oem = strdup(oem);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_software_version(devinf_s * devinf, char *software_version)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (software_version != NULL)
+ devinf->software_version = strdup(software_version);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_hardware_version(devinf_s * devinf, char *hardware_version)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (hardware_version != NULL)
+ devinf->hardware_version = strdup(hardware_version);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_firmware_version(devinf_s * devinf, char *firmware_version)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (firmware_version != NULL)
+ devinf->firmware_version = strdup(firmware_version);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore(devinf_s * devinf, devinf_datastore_s * devinf_datastore)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ devinf->datastores = g_list_append(devinf->datastores, devinf_datastore);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_rxpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->rx_pref = devinf_content_type;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_txpref(devinf_datastore_s * devinf_datastore, devinf_content_type_s * devinf_content_type)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->tx_pref = devinf_content_type;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_ctcap(devinf_datastore_s * devinf_datastore, devinf_ct_cap_s * devinf_ctcap)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->ct_caps = g_list_append(devinf_datastore->ct_caps, devinf_ctcap);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_sharedmem(devinf_datastore_s * devinf_datastore, int shared_mem)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->shared_mem = shared_mem;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_maxmem(devinf_datastore_s * devinf_datastore, unsigned int max_mem)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->max_mem = max_mem;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_datastore_maxid(devinf_datastore_s * devinf_datastore, unsigned int max_id)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_datastore == NULL, "devinf_datastore is NULL");
+
+ devinf_datastore->max_id = max_id;
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_ctcap_property(devinf_ct_cap_s * devinf_ctcap, devinf_property_s * devinf_property)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_ctcap == NULL, "devinfCTCap is NULL");
+
+ devinf_ctcap->properties = g_list_append(devinf_ctcap->properties, devinf_property);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _set_devinf_property_valenums(devinf_property_s * devinf_property, char *val_enum)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if(devinf_property == NULL, "devinfCTCap is NULL");
+
+ if (val_enum != NULL)
+ devinf_property->val_enums = g_list_append(devinf_property->val_enums, strdup(val_enum));
+
+ _INNER_FUNC_EXIT;
+}
+
+static devinf_devtyp_e _convert_devtyp(char *dev_typ)
+{
+ _INNER_FUNC_ENTER;
+
+ devinf_devtyp_e devinfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
+
+ if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PAGER) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_PAGER;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_HANDHELD) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_HANDHELD;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PDA) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_PDA;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_PHONE) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_PHONE;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_SMARTPHONE) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_SMARTPHONE;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_SERVER) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_SERVER;
+ else if (strcmp(dev_typ, DEFINE_DEVICE_TYPE_WORKSTATION) == 0)
+ devinfDevTyp = DEVINF_DEVTYPE_WORKSTATION;
+
+ _INNER_FUNC_EXIT;
+ return devinfDevTyp;
+}
+
+sa_error_type_e create_devinf(session_s * session, devinf_s ** devinf)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sa_error_type_e errorType = SA_INTERNAL_OK;
+ sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ char *devID = NULL;
+ char *devTyp = NULL;
+ char *man = NULL;
+ char *model = NULL;
+ char *oem = NULL;
+ char *swv = NULL;
+ char *hwv = NULL;
+ char *fwv = "1.0";
+
+ devinf_s *temp_devinf = NULL;
+ devinf_datastore_s *devInfDataStore = NULL;
+ devinf_ct_cap_s *devInfCTCap = NULL;
+ devinf_property_s *devInfProperty = NULL;
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "DevID", &devID);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "DevTyp", &devTyp);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ devinf_devtyp_e devInfDevTyp = DEVINF_DEVTYPE_UNKNOWN;
+ if (devTyp != NULL)
+ devInfDevTyp = _convert_devtyp(devTyp);
+
+ devinf_version_e devInfVersion = DEVINF_VERSION_UNKNOWN;
+ if (session->protocol_version == VERSION_10)
+ devInfVersion = DEVINF_VERSION_10;
+ else if (session->protocol_version == VERSION_11)
+ devInfVersion = DEVINF_VERSION_11;
+ else if (session->protocol_version == VERSION_12)
+ devInfVersion = DEVINF_VERSION_12;
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "Man", &man);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "Mod", &model);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "OEM", &oem);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "SwV", &swv);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "HwV", &hwv);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = SA_INTERNAL_ERROR;
+ goto error;
+ }
+
+ /*
+ err = sync_agent_get_devinfo(DEFINE_PLATFORM, "FwV", &fwv);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ errorType = ERROR_INTERNAL_ERROR;
+ goto error;
+ }
+ */
+
+ _DEBUG_INFO("devID = %s", devID);
+ _DEBUG_INFO("devTyp = %s", devTyp);
+ _DEBUG_INFO("man = %s", man);
+ _DEBUG_INFO("model = %s", model);
+ _DEBUG_INFO("oem = %s", oem);
+ _DEBUG_INFO("swv = %s", swv);
+ _DEBUG_INFO("hwv = %s", hwv);
+ _DEBUG_INFO("fwv = %s", fwv);
+
+ errorType = _create_devinf_new(devID, devInfDevTyp, &temp_devinf);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInf New");
+ goto error;
+ }
+
+ _set_devinf_version(temp_devinf, devInfVersion);
+ _set_devinf_manufacturer(temp_devinf, man);
+ _set_devinf_model(temp_devinf, model);
+ _set_devinf_oem(temp_devinf, oem);
+ _set_devinf_software_version(temp_devinf, swv);
+ _set_devinf_hardware_version(temp_devinf, hwv);
+ _set_devinf_firmware_version(temp_devinf, fwv);
+
+ temp_devinf->supports_large_objs = 1;
+ temp_devinf->supports_utc = 1;
+ temp_devinf->supports_number_of_changes = 1;
+
+ /*TODO Implements call log datastore's datastore for device info */
+ /* TYPE_CONTENT_COUNT -1 -> not include calllog datastore */
+ int content_type;
+ for (content_type = 0; content_type < TYPE_SERVICE_COUNT - 1; content_type++) {
+
+ if (datastoreinfo_per_content_type[content_type] != NULL) {
+ if (datastoreinfo_per_content_type[content_type]->source != NULL) {
+ errorType = _create_devinf_datastore(datastoreinfo_per_content_type[content_type]->source, &devInfDataStore);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfDataStore");
+ goto error;
+ }
+
+ sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(content_type);
+
+ _DEBUG_INFO("datastore->type = %s", datastore->type);
+ _DEBUG_INFO("datastore->version = %s", datastore->version);
+ _DEBUG_INFO("datastore->field_cnt = %d", datastore->field_cnt);
+
+ devinf_content_type_s *devInfContentTypeRxPref = NULL;
+ errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeRxPref);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfContentType");
+ goto error;
+ }
+ _set_devinf_datastore_rxpref(devInfDataStore, devInfContentTypeRxPref);
+
+ devinf_content_type_s *devInfContentTypeTxPref = NULL;
+ errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeTxPref);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfContentType");
+ goto error;
+ }
+ _set_devinf_datastore_txpref(devInfDataStore, devInfContentTypeTxPref);
+
+ devinf_content_type_s *devInfContentTypeCTCap = NULL;
+ errorType = _create_devinf_contenttype(datastore->type, datastore->version, &devInfContentTypeCTCap);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfContentType");
+ goto error;
+ }
+
+ errorType = _create_devinf_ctcap(devInfContentTypeCTCap, &devInfCTCap);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfCTCap");
+ goto error;
+ }
+
+ sync_agent_plugin_field_info_s field_list;
+ int i;
+ for (i = 0; i < datastore->field_cnt; i++) {
+ field_list = datastore->field_list[i];
+ errorType = _create_devinf_property(field_list.field_name, &devInfProperty);
+ if (errorType != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("failed to create devInfProperty");
+ goto error;
+ }
+
+ sync_agent_plugin_field_info_s children_field_list;
+ int j;
+ for (j = 0; j < field_list.field_child_cnt; j++) {
+ children_field_list = field_list.field_child_list[j];
+ _set_devinf_property_valenums(devInfProperty, children_field_list.field_name);
+ }
+ _set_devinf_ctcap_property(devInfCTCap, devInfProperty);
+ devInfProperty = NULL;
+ }
+
+ _set_devinf_datastore_ctcap(devInfDataStore, devInfCTCap);
+ devInfCTCap = NULL;
+
+ /* TODO Get information about static memory for each datastore
+ * It will be used to fill DSMem and children element(SharedMem, MaxMem, MaxID) */
+ /* Set SharedMem */
+ _set_devinf_datastore_sharedmem(devInfDataStore, 0);
+ /* Set MaxMem */
+ _set_devinf_datastore_maxmem(devInfDataStore, 0);
+ /* Set MaxID */
+ _set_devinf_datastore_maxid(devInfDataStore, 0);
+
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER, 1);
+ set_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC, 1);
+
+ _set_devinf_datastore(temp_devinf, devInfDataStore);
+ devInfDataStore = NULL;
+
+ /*free datastore */
+ sync_agent_free_obj_info(content_type, datastore);
+ }
+ }
+ }
+
+ *devinf = temp_devinf;
+ temp_devinf = NULL;
+
+ error:
+
+ if (temp_devinf != NULL)
+ free(temp_devinf);
+
+ __free_devinf_datastore(devInfDataStore);
+ ___free_devinf_ctcaps(devInfCTCap);
+ ___free_devinf_property(devInfProperty);
+
+ if (devID != NULL)
+ free(devID);
+ if (devTyp != NULL)
+ free(devTyp);
+ if (man != NULL)
+ free(man);
+ if (model != NULL)
+ free(model);
+ if (oem != NULL)
+ free(oem);
+ if (swv != NULL)
+ free(swv);
+ if (hwv != NULL)
+ free(hwv);
+/* if (fwv != NULL)
+ free(fwv);*/
+
+ _EXTERN_FUNC_EXIT;
+ return errorType;
+}
+
+void free_devinf(devinf_s * devinf)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(devinf == NULL, "devinf is NULL");
+
+ if (devinf->manufacturer != NULL) {
+ free(devinf->manufacturer);
+ devinf->manufacturer = NULL;
+ }
+
+ if (devinf->model != NULL) {
+ free(devinf->model);
+ devinf->model = NULL;
+ }
+
+ if (devinf->oem != NULL) {
+ free(devinf->oem);
+ devinf->oem = NULL;
+ }
+
+ if (devinf->software_version != NULL) {
+ free(devinf->software_version);
+ devinf->software_version = NULL;
+ }
+
+ if (devinf->hardware_version != NULL) {
+ free(devinf->hardware_version);
+ devinf->hardware_version = NULL;
+ }
+
+ if (devinf->firmware_version != NULL) {
+ free(devinf->firmware_version);
+ devinf->firmware_version = NULL;
+ }
+
+ if (devinf->dev_id != NULL) {
+ free(devinf->dev_id);
+ devinf->dev_id = NULL;
+ }
+
+ _free_devinf_datastores(devinf->datastores);
+ devinf->datastores = NULL;
+
+ free(devinf);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_devinf_datastore_sync_cap(devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap, int supported)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (supported)
+ devinf_datastore->sync_cap = devinf_datastore->sync_cap | cap;
+ else
+ devinf_datastore->sync_cap = devinf_datastore->sync_cap & ~cap;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int get_devinf_datastore_sync_cap(const devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int data;
+ data = devinf_datastore->sync_cap & cap ? 1 : 0;
+
+ _EXTERN_FUNC_EXIT;
+ return data;
+}
+
+devinf_sync_cap_e convert_devinf_synccap(unsigned int id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ devinf_sync_cap_e result = DEVINF_SYNCTYPE_UNKNOWN;
+
+ switch (id) {
+ case DEVINF_SYNCTYPE_TWO_WAY:
+ result = DEVINF_SYNCTYPE_TWO_WAY;
+ break;
+ case DEVINF_SYNCTYPE_SLOW_SYNC:
+ result = DEVINF_SYNCTYPE_SLOW_SYNC;
+ break;
+ case DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT:
+ result = DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT;
+ break;
+ case DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT:
+ result = DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT;
+ break;
+ case DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER:
+ result = DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER;
+ break;
+ case DEVINF_SYNCTYPE_REFRESH_FROM_SERVER:
+ result = DEVINF_SYNCTYPE_REFRESH_FROM_SERVER;
+ break;
+ case DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC:
+ result = DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC;
+ break;
+ default:
+ return DEVINF_SYNCTYPE_UNKNOWN;
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return result;
+}
+
+/*
+static ErrorType create_DevInfPropParam(char *paramName, DevInfPropParam **devinfPropParam)
+{
+ _EXTERN_FUNC_ENTER;
+
+ ErrorType errorType = ERROR_INTERNAL_OK;
+
+ if (!paramName) {
+ errorType = ERROR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *devinfPropParam = (DevInfPropParam *)calloc(1, sizeof(DevInfPropParam));
+ if (*devinfPropParam == NULL) {
+ errorType = ERROR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*devinfPropParam)->paramName = strdup(paramName);
+
+error:
+
+ _EXTERN_FUNC_EXIT;
+ return errorType;
+}
+
+static void set_DevInfDataStoreDisplayname(DevInfDataStore* devinf_datastore, char *displayname) {
+
+ if (!devinf_datastore)
+ return;
+
+ devinf_datastore->displayname = strdup(displayname);
+}
+
+static void set_DevInfDataStoreRx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type) {
+ if (!devinf_datastore)
+ return;
+
+ devinf_datastore->rx = g_list_append(devinf_datastore->rx, devinf_content_type);
+}
+
+static void set_DevInfDataStoreTx(DevInfDataStore *devinf_datastore, DevInfContentType *devinf_content_type) {
+ if (!devinf_datastore)
+ return;
+
+ devinf_datastore->tx = g_list_append(devinf_datastore->tx, devinf_content_type);
+}
+
+static void set_DevInfPropertyDataType(DevInfProperty *devinfProperty, char *dataType) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->dataType = strdup(dataType);
+}
+
+static void set_DevInfPropertyMaxOccur(DevInfProperty *devinfProperty, unsigned int maxOccur) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->maxOccur = maxOccur;
+}
+
+static void set_DevInfPropertyMaxSize(DevInfProperty *devinfProperty, unsigned int maxSize) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->maxSize = maxSize;
+}
+
+static void set_DevInfPropertyNoTruncate(DevInfProperty *devinfProperty, int noTruncate) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->noTruncate = noTruncate;
+}
+
+static void set_DevInfPropertyDisplayName(DevInfProperty *devinfProperty, char *displayName) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->displayName = strdup(displayName);
+}
+
+static void set_DevInfPropertyPropParam(DevInfProperty *devinfProperty, DevInfPropParam *devinfPropParam) {
+
+ if (!devinfProperty)
+ return;
+
+ devinfProperty->propParams = g_list_append(devinfProperty->propParams, devinfPropParam);
+}
+
+static void set_DevInfPropParamDataType(DevInfPropParam *devinfPropParam, char *dataType) {
+
+ if (!devinfPropParam)
+ return;
+
+ devinfPropParam->dataType = strdup(dataType);
+}
+
+static void set_DevInfPropParamDisplayName(DevInfPropParam *devinfPropParam, char *displayName) {
+
+ if (!devinfPropParam)
+ return;
+
+ devinfPropParam->displayName = strdup(displayName);
+}
+
+static void set_DevInfPropParamValEnums(DevInfPropParam *devinfPropParam, char *valEnum) {
+
+ if (!devinfPropParam)
+ return;
+
+ devinfPropParam->valEnums = g_list_append(devinfPropParam->valEnums, strdup(valEnum));
+ }
+*/