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_Http_Queue_H
18 #define _Download_Agent_Http_Queue_H
21 #include "download-agent-type.h"
22 #include "download-agent-http-msg-handler.h"
27 #define MAX_QUEUE_SIZE 1024*64
31 Q_EVENT_TYPE_DATA_HTTP,
32 Q_EVENT_TYPE_DATA_DRM,
38 Q_EVENT_TYPE_CONTROL_CANCEL,
39 Q_EVENT_TYPE_CONTROL_SUSPEND,
40 Q_EVENT_TYPE_CONTROL_RESUME,
41 Q_EVENT_TYPE_CONTROL_NET_DISCONNECTED,
42 Q_EVENT_TYPE_CONTROL_ABORT,
43 // [090205][jungki]not used yet.
44 // Q_EVENT_TYPE_CONTROL_USER_CONFIRM_RESULT,
45 // Q_EVENT_TYPE_CONTROL_INSTALL_RESULT,
46 }q_event_type_control;
50 Q_EVENT_TYPE_DATA_PACKET,
51 Q_EVENT_TYPE_DATA_FINAL,
52 Q_EVENT_TYPE_DATA_ABORT,
55 typedef struct _q_event_data_http_t
57 q_event_type_data data_type;
61 http_msg_response_t* http_response_msg;
66 da_result_t error_type;
69 typedef struct _q_event_control_t
71 q_event_type_control control_type;
74 typedef struct _q_event_t q_event_t;
78 q_event_type event_type;
81 q_event_data_http_t q_event_data_http;
82 q_event_control_t q_event_control;
88 typedef struct _queue_t
90 da_bool_t having_data;
92 q_event_t *control_head;
95 pthread_mutex_t mutex_queue;
96 pthread_cond_t cond_queue;
101 void Q_init_queue(queue_t *queue);
102 void Q_destroy_queue(queue_t *queue);
104 void Q_init_q_event(q_event_t *q_event);
105 void Q_destroy_q_event(q_event_t **q_event);
107 da_result_t Q_make_control_event(q_event_type_control control_type, q_event_t **out_event);
109 da_result_t Q_make_http_data_event(q_event_type_data data_type, q_event_t **out_event);
110 da_result_t Q_set_status_code_on_http_data_event(q_event_t *q_event, int status_code);
111 da_result_t Q_set_http_body_on_http_data_event(q_event_t *q_event, int body_len, char *body_data);
112 da_result_t Q_set_error_type_on_http_data_event(q_event_t *q_event, int error_type);
115 da_bool_t Q_push_event(const queue_t *in_queue, const q_event_t *in_event);
116 da_bool_t Q_push_event_without_lock(const queue_t *in_queue, const q_event_t *in_event);
117 void Q_pop_event(const queue_t *in_queue, q_event_t **out_event);
119 #define GET_IS_Q_HAVING_DATA(QUEUE) (QUEUE->having_data)
121 void Q_goto_sleep(const queue_t *in_queue);
122 void Q_wake_up(const queue_t *in_queue);