tizen 2.3.1 release
[framework/telephony/libtcore.git] / include / queue.h
1 /*
2  * libtcore
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #ifndef __TCORE_QUEUE_H__
22 #define __TCORE_QUEUE_H__
23
24 __BEGIN_DECLS
25
26 typedef void(*TcorePendingSendCallback)(TcorePending *p, gboolean result,
27     void *user_data);
28 typedef void(*TcorePendingTimeoutCallback)(TcorePending *p, void *user_data);
29 typedef void(*TcorePendingResponseCallback)(TcorePending *p, int data_len,
30     const void *data, void *user_data);
31
32 enum tcore_pending_priority {
33         TCORE_PENDING_PRIORITY_IMMEDIATELY = 0,
34         TCORE_PENDING_PRIORITY_HIGH = 100,
35         TCORE_PENDING_PRIORITY_DEFAULT = 200,
36         TCORE_PENDING_PRIORITY_LOW = 300,
37 };
38
39 TcorePending* tcore_pending_new(CoreObject *co, unsigned int id);
40 void          tcore_pending_free(TcorePending *pending);
41
42 unsigned int  tcore_pending_get_id(TcorePending *pending);
43 TReturn       tcore_pending_set_auto_free_status_after_sent(TcorePending *pending,
44                   gboolean flag);
45 gboolean      tcore_pending_get_auto_free_status_after_sent(TcorePending *pending);
46 TReturn       tcore_pending_set_request_data(TcorePending *pending,
47                   unsigned int data_len, void *data);
48 void*         tcore_pending_ref_request_data(TcorePending *pending,
49                   unsigned int *data_len);
50 TReturn       tcore_pending_set_timeout(TcorePending *pending,
51                   unsigned int timeout);
52 unsigned int  tcore_pending_get_timeout(TcorePending *pending);
53 TcorePlugin*  tcore_pending_ref_plugin(TcorePending *pending);
54 CoreObject*   tcore_pending_ref_core_object(TcorePending *pending);
55 TReturn       tcore_pending_set_priority(TcorePending *pending,
56                   enum tcore_pending_priority priority);
57 TReturn       tcore_pending_get_priority(TcorePending *pending,
58                   enum tcore_pending_priority *result_priority);
59 TReturn       tcore_pending_get_send_status(TcorePending *pending,
60                   gboolean *result_status);
61 TReturn       tcore_pending_link_user_request(TcorePending *pending,
62                   UserRequest *ur);
63 UserRequest*  tcore_pending_ref_user_request(TcorePending *pending);
64
65 TReturn tcore_pending_start_timer(TcorePending *pending);
66
67 TReturn       tcore_pending_set_send_callback(TcorePending *pending,
68                   TcorePendingSendCallback func, void *user_data);
69 TReturn       tcore_pending_emit_send_callback(TcorePending *pending, int bytes);
70
71 TReturn       tcore_pending_set_timeout_callback(TcorePending *pending,
72                   TcorePendingTimeoutCallback func, void *user_data);
73 TReturn       tcore_pending_emit_timeout_callback(TcorePending *pending);
74
75 TReturn       tcore_pending_set_response_callback(TcorePending *pending,
76                   TcorePendingResponseCallback func, void *user_data);
77 TReturn       tcore_pending_emit_response_callback(TcorePending *pending,
78                   int data_len, const void *data);
79
80
81 TcoreQueue*   tcore_queue_new(TcoreHal *hal);
82 void          tcore_queue_free(TcoreQueue *qeueu);
83
84 TReturn       tcore_queue_push(TcoreQueue *queue, TcorePending *pending);
85 TcorePending* tcore_queue_pop(TcoreQueue *queue);
86 TcorePending* tcore_queue_pop_by_pending(TcoreQueue *queue, TcorePending *pending);
87 TcorePending* tcore_queue_pop_timeout_pending(TcoreQueue *queue);
88 TcorePending* tcore_queue_ref_head(TcoreQueue *queue);
89 TcorePending* tcore_queue_ref_tail(TcoreQueue *queue);
90 TcorePending* tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id);
91 TcorePending* tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id);
92 TcorePending* tcore_queue_ref_next_pending(TcoreQueue *queue);
93 unsigned int  tcore_queue_get_length(TcoreQueue *queue);
94 unsigned int  tcore_queue_get_normal_length(TcoreQueue *queue);
95 TcoreHal*     tcore_queue_ref_hal(TcoreQueue *queue);
96 TReturn       tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command);
97 TcorePending* tcore_queue_search_by_command(TcoreQueue *queue, enum tcore_request_command command, gboolean flag_sent);
98
99 __END_DECLS
100
101 #endif