summaryrefslogtreecommitdiff
path: root/src/agent/service-adapter/network-binder/na_binder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/service-adapter/network-binder/na_binder.c')
-rwxr-xr-xsrc/agent/service-adapter/network-binder/na_binder.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/agent/service-adapter/network-binder/na_binder.c b/src/agent/service-adapter/network-binder/na_binder.c
new file mode 100755
index 0000000..4c9ff49
--- /dev/null
+++ b/src/agent/service-adapter/network-binder/na_binder.c
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+
+/**
+ * @NA_Binder.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of header binder function for Network Adapter
+ */
+
+#include <sync_agent.h>
+
+#include "service-adapter/network-binder/na_binder.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_SA"
+#endif
+
+int na_http_header_binder(char *acc_type, char *loc_uri, bool is_xml, char *jsession_id, GList ** list)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(acc_type == NULL, 0, "[NA Header Binder] accType is NULL");
+ retvm_if(loc_uri == NULL, 0, "[NA Header Binder] loc_uri is NULL");
+
+ if (!strcmp(acc_type, "OMA_DS")) {
+ sync_agent_na_common_header_info_s *method = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(method == NULL, 0, "[NA Header Binder] 'method' malloc fail !!");
+
+ memset(method, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ method->key = "method";
+ method->value = "post";
+ *list = g_list_append(*list, method);
+
+ sync_agent_na_common_header_info_s *uri = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(uri == NULL, 0, "[NA Header Binder] 'uri' malloc fail !!");
+
+ memset(uri, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ uri->key = "uri";
+ uri->value = loc_uri;
+ *list = g_list_append(*list, uri);
+
+ sync_agent_na_common_header_info_s *cache_control = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(cache_control == NULL, 0, "[NA Header Binder] 'cache_control' malloc fail !!");
+
+ memset(cache_control, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ cache_control->key = "Cache-Control";
+ cache_control->value = "no-store, private";
+ *list = g_list_append(*list, cache_control);
+
+ sync_agent_na_common_header_info_s *connection = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(connection == NULL, 0, "[NA Header Binder] 'connection' malloc fail !!");
+
+ memset(connection, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ connection->key = "Connection";
+ connection->value = "Keep-Alive";
+ *list = g_list_append(*list, connection);
+
+ sync_agent_na_common_header_info_s *accept = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept == NULL, 0, "[NA Header Binder] 'accept' malloc fail !!");
+
+ memset(accept, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept->key = "Accept";
+ if (is_xml == true)
+ accept->value = "application/vnd.syncml+xml";
+ else
+ accept->value = "application/vnd.syncml+wbxml";
+ *list = g_list_append(*list, accept);
+
+ sync_agent_na_common_header_info_s *accept_language = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept_language == NULL, 0, "[NA Header Binder] 'accept_language' malloc fail !!");
+
+ memset(accept_language, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept_language->key = "Accept-Language";
+ accept_language->value = "en-US";
+ *list = g_list_append(*list, accept_language);
+
+ sync_agent_na_common_header_info_s *accept_charset = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept_charset == NULL, 0, "[NA Header Binder] 'accept_charset' malloc fail !!");
+
+ memset(accept_charset, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept_charset->key = "Accept-Charset";
+ accept_charset->value = "UTF-8";
+ *list = g_list_append(*list, accept_charset);
+
+ sync_agent_na_common_header_info_s *content_type = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(content_type == NULL, 0, "[NA Header Binder] 'content_type' malloc fail !!");
+
+ memset(content_type, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ content_type->key = "Content-Type";
+ if (is_xml == true)
+ content_type->value = "application/vnd.syncml+xml";
+ else
+ content_type->value = "application/vnd.syncml+wbxml";
+ *list = g_list_append(*list, content_type);
+
+ if (jsession_id != NULL) {
+ _DEBUG_INFO(" jsessionid : %s\n", jsession_id);
+ sync_agent_na_common_header_info_s *cookie = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(cookie == NULL, 0, "[NA Header Binder] 'cookie' malloc fail !!");
+
+ memset(cookie, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ cookie->key = "cookie";
+ cookie->value = jsession_id;
+ *list = g_list_append(*list, cookie);
+ _DEBUG_INFO(" cookie : %s\n", cookie->value);
+ }
+ }
+
+ GList *iter = NULL;
+ for (iter = *list; iter != NULL; iter = g_list_next(iter)) {
+ _DEBUG_INFO("[NA_Header_Binder] key : %s, value : %s", ((sync_agent_na_common_header_info_s *) (iter->data))->key, ((sync_agent_na_common_header_info_s *) (iter->data))->value);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+void free_header_info(sync_agent_na_common_header_info_s * common_header_info)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(common_header_info == NULL, "pCommon_header_info is NULL");
+
+ free(common_header_info);
+
+ _EXTERN_FUNC_EXIT;
+}