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_Utils_H
18 #define _Download_Agent_Utils_H
21 #include "download-agent-defs.h"
22 #include "download-agent-interface.h"
23 #include "download-agent-dl-mgr.h"
25 /* Todo : move these to mime-util.c */
26 #define MIME_DRM_MESSAGE "application/vnd.oma.drm.message"
27 #define MIME_ODF "application/vnd.oasis.opendocument.formula"
28 #define MIME_OMA_DD "application/vnd.oma.dd+xml"
29 #define MIME_MIDP_JAR "application/vnd.sun.j2me.java-archive"
30 #define MIME_MULTIPART_MESSAGE "multipart/related"
31 #define MIME_TEXT_PLAIN "text/plain"
33 #define SAVE_FILE_BUFFERING_SIZE_50KB (50*1024)
34 #define SAVE_FILE_BUFFERING_SIZE_5MB (5*1024*1024)
39 struct timespec interval,remainder; \
40 interval.tv_sec = (unsigned int)((x)/1000); \
41 interval.tv_nsec = (((x)-(interval.tv_sec*1000))*1000000); \
42 nanosleep(&interval,&remainder); \
46 DA_STORAGE_PHONE, /*To Store in Phone memory*/
47 DA_STORAGE_MMC, /*To Store in MMC */
48 DA_STORAGE_SYSTEM /*To Store in both Phone and MMC*/
51 typedef struct _da_storage_size_t {
52 unsigned long b_available;
58 DA_MIME_TYPE_DRM1_MESSATE,
62 void get_random_number(int *out_num);
63 da_result_t get_available_dd_id(int *available_id);
64 da_result_t get_extension_from_mime_type(char *mime_type, char **extension);
65 da_mime_type_id_t get_mime_type_id(char *content_type);
66 da_result_t get_available_memory(da_storage_type_t storage_type, da_storage_size_t *avail_memory);
67 da_bool_t is_valid_url(const char *url, da_result_t *err_code);
69 int read_data_from_file(char *file, char**out_buffer);
70 da_result_t move_file(const char *from_path, const char *to_path);
71 void remove_file(const char *file_path);
72 char *_stristr(const char *long_str, const char *find_str);