2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _Download_Agent_Plugin_Libsoup_H
18 #define _Download_Agent_Plugin_Libsoup_H
21 #include <libsoup/soup.h>
23 #include "download-agent-http-queue.h"
24 #include "download-agent-pthread.h"
25 #include "download-agent-plugin-http-interface.h"
27 typedef struct _pi_session_table_t {
32 pthread_mutex_t mutex;
37 extern pi_session_table_t pi_session_table[];
39 #define MAX_SESSION_COUNT DA_MAX_DOWNLOAD_REQ_AT_ONCE
40 #define MAX_TIMEOUT 60 // second
42 #define IS_VALID_SESSION_TABLE_ENTRY(ENTRY) ((((ENTRY) < 0) || ((ENTRY) > MAX_SESSION_COUNT-1)) ? 0 : 1)
45 #define GET_SESSION_FROM_TABLE_ENTRY(ENTRY) (pi_session_table[ENTRY].session)
46 #define GET_MSG_FROM_TABLE_ENTRY(ENTRY) (pi_session_table[ENTRY].msg)
47 #define GET_QUEUE_FROM_TABLE_ENTRY(ENTRY) (pi_session_table[ENTRY].queue)
50 da_bool_t _pi_http_is_valid_input_for_tranx(const input_for_tranx_t *input_for_tranx);
52 void _pi_http_init_session_table_entry(const int in_session_table_entry);
53 void _pi_http_destroy_session_table_entry(const int in_session_table_entry);
54 int _pi_http_get_avaiable_session_table_entry(void);
56 da_bool_t _pi_http_register_queue_to_session_table(const int session_table_entry, const queue_t *in_queue);
57 da_bool_t _pi_http_register_session_to_session_table(const int in_session_table_entry, SoupSession *session);
58 da_bool_t _pi_http_register_msg_to_session_table(const int in_session_table_entry, SoupMessage *msg);
60 queue_t *_pi_http_get_queue_from_session_table_entry(const int in_session_table_entry);
61 int _pi_http_get_session_table_entry_from_message(SoupMessage *msg);
63 void _pi_http_store_read_data_to_queue(SoupMessage *msg, const char *body_data, int received_body_len);
64 void _pi_http_store_read_header_to_queue(SoupMessage *msg, const char *sniffedType);
65 void _pi_http_store_neterr_to_queue(SoupMessage *msg);
68 void _pi_http_finished_cb(SoupSession *session, SoupMessage *msg, gpointer data);
69 void _pi_http_restarted_cb(SoupMessage *msg, gpointer data);
70 void _pi_http_gotheaders_cb(SoupMessage *msg, gpointer data);
71 void _pi_http_contentsniffed_cb(SoupMessage *msg, const char *sniffedType, GHashTable *params, gpointer data);
72 void _pi_http_gotchunk_cb(SoupMessage *msg, SoupBuffer *chunk, gpointer data);