merge with master
[platform/framework/web/download-provider.git] / agent / include / download-agent-file.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_Agent_File_H
18 #define _Download_Agent_File_H
19
20 #include <stdio.h>
21 #include <sys/types.h>
22 #include <sys/stat.h>
23
24 #include "download-agent-type.h"
25 #include "download-agent-dl-mgr.h"
26
27 #define DA_DEFAULT_FILE_DIR_PATH        "/opt/usr/media/.tmp_download"
28 #define DA_DEFAULT_INSTALL_PATH_FOR_PHONE "/opt/usr/media/Downloads"
29 #define DA_DEFAULT_INSTALL_PATH_FOR_MMC "/opt/storage/sdcard/Downloads"
30
31 da_bool_t is_file_exist(const char *file_path);
32 da_bool_t is_dir_exist(const char *dir_path);
33
34 void get_file_size(char *file_path, unsigned long long *out_file_size);
35
36 da_result_t clean_files_from_dir(char *dir_path);
37 da_result_t create_saved_dir(void);
38
39 da_result_t file_write_ongoing(stage_info *stage, char *body, int body_len);
40 da_result_t file_write_complete(stage_info *stage);
41 da_result_t start_file_writing(stage_info *stage);
42 da_result_t start_file_writing_append(stage_info *stage);
43 da_result_t start_file_writing_append_with_new_download(stage_info *stage);
44
45 da_result_t  get_mime_type(stage_info *stage, char **out_mime_type);
46 da_result_t  discard_download(stage_info *stage) ;
47 void clean_paused_file(stage_info *stage);
48 da_result_t  replace_content_file_in_stage(stage_info *stage, const char *dest_dd_file_path);
49 da_result_t  decide_tmp_file_path(stage_info *stage);
50 char *get_full_path_avoided_duplication(char *in_dir, char *in_candidate_file_name, char *in_extension);
51
52 da_result_t copy_file(const char *src, const char *dest);
53 da_result_t create_dir(const char *install_dir);
54 da_result_t get_default_dir(char **out_path);
55 da_result_t get_default_install_dir(char **out_path);
56
57 #endif