796da239900e74e312b3c6f2a4f972a41fa68c2d
[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 TcorePlugin*  tcore_pending_ref_plugin(TcorePending *pending);
53 CoreObject*   tcore_pending_ref_core_object(TcorePending *pending);
54 TReturn       tcore_pending_set_priority(TcorePending *pending,
55                   enum tcore_pending_priority priority);
56 TReturn       tcore_pending_get_priority(TcorePending *pending,
57                   enum tcore_pending_priority *result_priority);
58 TReturn       tcore_pending_get_send_status(TcorePending *pending,
59                   gboolean *result_status);
60 TReturn       tcore_pending_link_user_request(TcorePending *pending,
61                   UserRequest *ur);
62 UserRequest*  tcore_pending_ref_user_request(TcorePending *pending);
63
64 TReturn       tcore_pending_set_send_callback(TcorePending *pending,
65                   TcorePendingSendCallback func, void *user_data);
66 TReturn       tcore_pending_emit_send_callback(TcorePending *pending, int bytes);
67
68 TReturn       tcore_pending_set_timeout_callback(TcorePending *pending,
69                   TcorePendingTimeoutCallback func, void *user_data);
70 TReturn       tcore_pending_emit_timeout_callback(TcorePending *pending);
71
72 TReturn       tcore_pending_set_response_callback(TcorePending *pending,
73                   TcorePendingResponseCallback func, void *user_data);
74 TReturn       tcore_pending_emit_response_callback(TcorePending *pending,
75                   int data_len, const void *data);
76
77
78 TcoreQueue*   tcore_queue_new(TcoreHal *hal);
79 void          tcore_queue_free(TcoreQueue *qeueu);
80
81 TReturn       tcore_queue_push(TcoreQueue *queue, TcorePending *pending);
82 TcorePending* tcore_queue_pop(TcoreQueue *queue);
83 TcorePending* tcore_queue_pop_by_pending(TcoreQueue *queue, TcorePending *pending);
84 TcorePending* tcore_queue_pop_timeout_pending(TcoreQueue *queue);
85 TcorePending* tcore_queue_ref_head(TcoreQueue *queue);
86 TcorePending* tcore_queue_ref_tail(TcoreQueue *queue);
87 TcorePending* tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id);
88 TcorePending* tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id);
89 TcorePending* tcore_queue_ref_next_pending(TcoreQueue *queue);
90 unsigned int  tcore_queue_get_length(TcoreQueue *queue);
91 TcoreHal*     tcore_queue_ref_hal(TcoreQueue *queue);
92 TReturn       tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command);
93 TcorePending* tcore_queue_search_by_command(TcoreQueue *queue, enum tcore_request_command command, gboolean flag_sent);
94
95 __END_DECLS
96
97 #endif