Tizen 2.1 base
[platform/framework/web/download-provider.git] / src / include / download-provider.h
1 /*
2  * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 #ifndef DOWNLOAD_PROVIDER2_H
18 #define DOWNLOAD_PROVIDER2_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #define DP_IPC "/tmp/download-provider"
25
26 #define DP_MAX_STR_LEN_64 64
27 #define DP_MAX_STR_LEN 256
28 #define DP_MAX_PATH_LEN DP_MAX_STR_LEN
29 #define DP_MAX_URL_LEN 2048
30
31 #ifdef DP_SUPPORT_DBUS_ACTIVATION
32 #define DP_DBUS_ACTIVATION
33 #define DP_DBUS_SERVICE_DBUS            "org.download-provider"
34 #endif
35
36 #define DP_ECHO_TEST
37
38         typedef enum {
39                 DP_CMD_NONE = 0,
40                 DP_CMD_CREATE = DP_CMD_NONE + 1,
41                 DP_CMD_START = DP_CMD_NONE + 2,
42                 DP_CMD_PAUSE = DP_CMD_NONE + 3,
43                 DP_CMD_CANCEL = DP_CMD_NONE + 4,
44                 DP_CMD_DESTROY = DP_CMD_NONE + 9,
45                 DP_CMD_FREE = DP_CMD_NONE + 10,
46                 DP_CMD_ECHO = DP_CMD_NONE + 15,
47                 DP_CMD_SET_URL = DP_CMD_NONE + 21,
48                 DP_CMD_SET_DESTINATION = DP_CMD_NONE + 22,
49                 DP_CMD_SET_FILENAME = DP_CMD_NONE + 23,
50                 DP_CMD_SET_NOTIFICATION = DP_CMD_NONE + 24,
51                 DP_CMD_SET_STATE_CALLBACK = DP_CMD_NONE + 25,
52                 DP_CMD_SET_PROGRESS_CALLBACK = DP_CMD_NONE + 26,
53                 DP_CMD_SET_AUTO_DOWNLOAD = DP_CMD_NONE + 28,
54                 DP_CMD_SET_NETWORK_TYPE = DP_CMD_NONE + 29,
55                 DP_CMD_SET_HTTP_HEADER = DP_CMD_NONE + 30,
56                 DP_CMD_SET_EXTRA_PARAM = DP_CMD_NONE + 31,
57                 DP_CMD_DEL_HTTP_HEADER = DP_CMD_NONE + 35,
58                 DP_CMD_GET_URL = DP_CMD_NONE + 41,
59                 DP_CMD_GET_DESTINATION = DP_CMD_NONE + 42,
60                 DP_CMD_GET_FILENAME = DP_CMD_NONE + 43,
61                 DP_CMD_GET_NOTIFICATION = DP_CMD_NONE + 44,
62                 DP_CMD_GET_STATE_CALLBACK = DP_CMD_NONE + 45,
63                 DP_CMD_GET_PROGRESS_CALLBACK = DP_CMD_NONE + 46,
64                 DP_CMD_GET_HTTP_HEADERS = DP_CMD_NONE + 47,
65                 DP_CMD_GET_AUTO_DOWNLOAD = DP_CMD_NONE + 48,
66                 DP_CMD_GET_NETWORK_TYPE = DP_CMD_NONE + 49,
67                 DP_CMD_GET_SAVED_PATH = DP_CMD_NONE + 50,
68                 DP_CMD_GET_TEMP_SAVED_PATH = DP_CMD_NONE + 51,
69                 DP_CMD_GET_MIME_TYPE = DP_CMD_NONE + 52,
70                 DP_CMD_GET_HTTP_HEADER = DP_CMD_NONE + 53,
71                 DP_CMD_GET_EXTRA_PARAM = DP_CMD_NONE + 54,
72                 DP_CMD_GET_RECEIVED_SIZE = DP_CMD_NONE + 71,
73                 DP_CMD_GET_TOTAL_FILE_SIZE = DP_CMD_NONE + 72,
74                 DP_CMD_GET_CONTENT_NAME = DP_CMD_NONE + 73,
75                 DP_CMD_GET_HTTP_STATUS = DP_CMD_NONE + 74,
76                 DP_CMD_GET_ETAG = DP_CMD_NONE + 75,
77                 DP_CMD_GET_STATE = DP_CMD_NONE + 81,
78                 DP_CMD_GET_ERROR = DP_CMD_NONE + 91,
79                 DP_CMD_SET_COMMAND_SOCKET = DP_CMD_NONE + 100,
80                 DP_CMD_SET_EVENT_SOCKET = DP_CMD_NONE + 101
81         } dp_command_type;
82
83         typedef enum {
84                 DP_STATE_NONE = 0,
85                 DP_STATE_READY = DP_STATE_NONE + 5, // created id, set some info.
86                 DP_STATE_QUEUED = DP_STATE_NONE + 10, // request to start
87                 DP_STATE_CONNECTING = DP_STATE_NONE + 15, // try to connect to url
88                 DP_STATE_DOWNLOADING = DP_STATE_NONE + 20, // started
89                 DP_STATE_PAUSE_REQUESTED = DP_STATE_NONE + 25,
90                 DP_STATE_PAUSED = DP_STATE_NONE + 30, // paused actually
91                 DP_STATE_COMPLETED = DP_STATE_NONE + 40,
92                 DP_STATE_CANCELED = DP_STATE_NONE + 45, // stopped with error
93                 DP_STATE_FAILED = DP_STATE_NONE + 50 // failed with error
94         } dp_state_type;
95
96         typedef enum {
97                 DP_ERROR_NONE = 0,
98                 DP_ERROR_INVALID_PARAMETER = DP_ERROR_NONE + 1,
99                 DP_ERROR_OUT_OF_MEMORY = DP_ERROR_NONE + 2,
100                 DP_ERROR_IO_ERROR = DP_ERROR_NONE + 3,
101                 DP_ERROR_NETWORK_UNREACHABLE = DP_ERROR_NONE + 4,
102                 DP_ERROR_CONNECTION_TIMED_OUT = DP_ERROR_NONE + 5,
103                 DP_ERROR_NO_SPACE = DP_ERROR_NONE + 6,
104                 DP_ERROR_FIELD_NOT_FOUND = DP_ERROR_NONE + 7,
105                 DP_ERROR_INVALID_STATE = DP_ERROR_NONE + 8,
106                 DP_ERROR_CONNECTION_FAILED = DP_ERROR_NONE + 9,
107                 DP_ERROR_INVALID_URL = DP_ERROR_NONE + 10,
108                 DP_ERROR_INVALID_DESTINATION = DP_ERROR_NONE + 11,
109                 DP_ERROR_QUEUE_FULL = DP_ERROR_NONE + 12,
110                 DP_ERROR_ALREADY_COMPLETED = DP_ERROR_NONE + 13,
111                 DP_ERROR_FILE_ALREADY_EXISTS = DP_ERROR_NONE + 14,
112                 DP_ERROR_TOO_MANY_DOWNLOADS = DP_ERROR_NONE + 15,
113                 DP_ERROR_NO_DATA = DP_ERROR_NONE + 17,
114                 DP_ERROR_UNHANDLED_HTTP_CODE = DP_ERROR_NONE + 18,
115                 DP_ERROR_CANNOT_RESUME = DP_ERROR_NONE + 19,
116                 DP_ERROR_RESPONSE_TIMEOUT = DP_ERROR_NONE + 50,
117                 DP_ERROR_REQUEST_TIMEOUT = DP_ERROR_NONE + 55,
118                 DP_ERROR_SYSTEM_DOWN = DP_ERROR_NONE + 60,
119                 DP_ERROR_CLIENT_DOWN = DP_ERROR_NONE + 65,
120                 DP_ERROR_ID_NOT_FOUND = DP_ERROR_NONE + 90,
121                 DP_ERROR_UNKNOWN = DP_ERROR_NONE + 100
122         } dp_error_type;
123
124         typedef enum {
125                 DP_NETWORK_TYPE_OFF = -1,
126                 DP_NETWORK_TYPE_ALL = 0,
127                 DP_NETWORK_TYPE_WIFI = 1,
128                 DP_NETWORK_TYPE_DATA_NETWORK = 2,
129                 DP_NETWORK_TYPE_ETHERNET = 3,
130         } dp_network_type;
131
132         typedef struct {
133                 unsigned int length;
134                 char *str;
135         } dp_string;
136
137         typedef struct {
138                 int id;
139                 dp_state_type state;
140                 dp_error_type err;
141                 unsigned long long received_size;
142         } dp_event_info;
143
144         typedef struct {
145                 dp_command_type cmd;
146                 int id;
147         } dp_command;
148
149         // Usage IPC : send(dp_command);send(dp_string);
150
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif