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 header binder function for Network Adapter
42 #include "agent-framework/Utility/fw_log.h"
43 #include "ServiceAdapter/NetworkBinder/NA_Binder.h"
45 #define LOG_TAG "OMA_DS_SA"
47 int NA_http_header_binder(char *accType, char *loc_uri, bool isXML, GList **list)
49 FW_LOGV("[NA Header Binder] start!!");
51 if (!strcmp(accType, "OMA_DS")) {
52 common_header_info *method = (common_header_info *)malloc(sizeof(common_header_info));
54 FW_LOGE("[NA Header Binder] 'method' malloc fail !!");
57 memset(method, 0x00, sizeof(common_header_info));
58 method->key = "method";
59 method->value = "post";
60 *list = g_list_append(*list, method);
62 common_header_info *uri = (common_header_info *)malloc(sizeof(common_header_info));
64 FW_LOGE("[NA Header Binder] 'uri' malloc fail !!");
67 memset(uri, 0x00, sizeof(common_header_info));
70 *list = g_list_append(*list, uri);
72 common_header_info *cache_control = (common_header_info *)malloc(sizeof(common_header_info));
73 if (cache_control == 0x00) {
74 FW_LOGE("[NA Header Binder] 'cache_control' malloc fail !!");
77 memset(cache_control, 0x00, sizeof(common_header_info));
78 cache_control->key = "Cache-Control";
79 cache_control->value = "no-store, private";
80 *list = g_list_append(*list, cache_control);
82 common_header_info *connection = (common_header_info *)malloc(sizeof(common_header_info));
83 if (connection == 0x00) {
84 FW_LOGE("[NA Header Binder] 'connection' malloc fail !!");
87 memset(connection, 0x00, sizeof(common_header_info));
88 connection->key = "Connection";
89 connection->value = "Keep-Alive";
90 *list = g_list_append(*list, connection);
92 common_header_info *accept = (common_header_info *)malloc(sizeof(common_header_info));
94 FW_LOGE("[NA Header Binder] 'accept' malloc fail !!");
97 memset(accept, 0x00, sizeof(common_header_info));
98 accept->key = "Accept";
100 accept->value = "application/vnd.syncml+xml";
102 accept->value = "application/vnd.syncml+wbxml";
103 *list = g_list_append(*list, accept);
105 common_header_info *accept_language = (common_header_info *)malloc(sizeof(common_header_info));
106 if (accept_language == 0x00) {
107 FW_LOGE("[NA Header Binder] 'accept_language' malloc fail !!");
110 memset(accept_language, 0x00, sizeof(common_header_info));
111 accept_language->key = "Accept-Language";
112 accept_language->value = "en-US";
113 *list = g_list_append(*list, accept_language);
115 common_header_info *accept_charset = (common_header_info *)malloc(sizeof(common_header_info));
116 if (accept_charset == 0x00) {
117 FW_LOGE("[NA Header Binder] 'accept_charset' malloc fail !!");
120 memset(accept_charset, 0x00, sizeof(common_header_info));
121 accept_charset->key = "Accept-Charset";
122 accept_charset->value = "UTF-8";
123 *list = g_list_append(*list, accept_charset);
125 common_header_info *content_type = (common_header_info *)malloc(sizeof(common_header_info));
126 if (content_type == 0x00) {
127 FW_LOGE("[NA Header Binder] 'content_type' malloc fail !!");
130 memset(content_type, 0x00, sizeof(common_header_info));
131 content_type->key = "Content-Type";
133 content_type->value = "application/vnd.syncml+xml";
135 content_type->value = "application/vnd.syncml+wbxml";
136 *list = g_list_append(*list, content_type);
141 for (iter = *list; iter != NULL; iter = g_list_next(iter)) {
142 FW_LOGV("[NA_Header_Binder] key : %s, value : %s", ((common_header_info *)(iter->data))->key, ((common_header_info *)(iter->data))->value);
150 void free_header_info(common_header_info *pCommon_header_info)
152 if (pCommon_header_info == NULL)
155 free(pCommon_header_info);