initial tizen_2.0_beta
[apps/core/preloaded/music-player.git] / src / core / include / mp-http-mgr.h
1 /*
2  * Copyright 2012         Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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
7  *
8  *  http://www.tizenopensource.org/license
9  *
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.
15  */
16
17
18 #ifndef __MP_HTTP_MGR_H__
19 #define __MP_HTTP_MGR_H__
20
21 #include "mp-define.h"
22
23 #define HTTP_ADDR_LEN_MAX               64
24 typedef enum
25 {
26         MP_HTTP_SVC_DEFAULT,
27         MP_HTTP_SVC_SHAZAM,
28         MP_HTTP_SVC_STREAMING,
29         MP_HTTP_SVC_MAX,
30 } mp_http_svc_type;
31
32 typedef enum
33 {
34         MP_HTTP_RESPONSE_NORMAL,
35         MP_HTTP_RESPONSE_DISCONNECT,
36 } mp_http_response_type;
37
38 typedef enum
39 {
40         MP_HTTP_RESP_FAIL,
41         MP_HTTP_RESP_SUCCESS,
42 } MpHttpRespResultType_t;
43
44 typedef void (*MpHttpRespCb) (gpointer user_data, int type, char *id, MpHttpRespResultType_t res, int view_id);
45 typedef void (*MpHttpOpenCb) (gpointer user_data);
46 typedef bool (*MpHttpRespExcuteCb)(gpointer user_data, mp_http_response_type response_type);
47 typedef bool(*MpHttpOpenExcuteCb) (gpointer user_data);
48
49 typedef enum
50 {
51         MP_HTTP_STATE_NONE = 0,
52         MP_HTTP_STATE_OFF = 0,
53         MP_HTTP_STATE_CELLULAR,
54         MP_HTTP_STATE_WIFI,
55 } MpHttpState_t;
56
57 typedef struct mp_http_mgr_t
58 {
59         struct appdata *ad;
60         MpHttpState_t http_state;               //the state of the http
61         char ip[HTTP_ADDR_LEN_MAX];
62         char proxy[HTTP_ADDR_LEN_MAX];
63
64         bool svc_state[MP_HTTP_SVC_MAX];
65         void *cb_data[MP_HTTP_SVC_MAX];
66         MpHttpOpenExcuteCb http_open_cb[MP_HTTP_SVC_MAX];
67         MpHttpRespExcuteCb http_resp_cb[MP_HTTP_SVC_MAX];
68 } mp_http_mgr_t;
69
70 typedef struct mp_http_data_t
71 {
72         struct appdata *ad;
73         int req_type;
74         char *req_id;
75         MpHttpRespCb user_callback;
76         int view_id;
77         void *user_data;
78 } mp_http_data_t;
79
80 bool mp_http_mgr_create(void *data);
81 bool mp_http_mgr_destory(void *data);
82 MpHttpState_t mp_http_mgr_get_state(void *data);
83 char* mp_http_mgr_get_user_agent(); /* return value should be freed */
84
85 const char* mp_http_mgr_get_ip(void *data);
86 const char* mp_http_mgr_get_proxy(void *data);
87 bool mp_http_mgr_get_svc_state(void *data, mp_http_svc_type svc_type);
88 bool mp_http_mgr_start_svc(void *data, mp_http_svc_type svc_type, MpHttpOpenExcuteCb open_cb, MpHttpRespExcuteCb rsp_cb, gpointer cb_data);
89 bool mp_http_mgr_stop_svc(void *data, mp_http_svc_type svc_type, mp_http_response_type response_type);
90
91 #define TOKEN "025B58C0"
92 #endif //__MP_HTTP_MGR_H__