The download provider daemon is added newly.
[profile/ivi/download-provider.git] / src / agent / include / download-agent-file.h
1 /*
2  * Download Agent
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jungki Kwak <jungki.kwak@samsung.com>, Keunsoon Lee <keunsoon.lee@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  * @file                download-agent-file.h
21  * @brief
22  * @author              Keunsoon Lee(keunsoon.lee@samsung.com)
23  ***/
24
25 #ifndef _Download_Agent_File_H
26 #define _Download_Agent_File_H
27
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31
32 #include "download-agent-type.h"
33 #include "download-agent-dl-mgr.h"
34
35 #ifdef _TARGET
36 #define DA_DEFAULT_TMP_FILE_DIR_PATH    "/opt/media/.tmp_download"
37 #else
38 // FIXME Later : temporary code
39 #define DA_DEFAULT_TMP_FILE_DIR_PATH    "/tmp/.tmp_download"
40 #endif
41
42 da_bool_t is_file_exist(const char *file_path);
43 da_bool_t is_dir_exist(char *dir_path);
44
45 void get_file_size(char *file_path, int *out_file_size);
46
47 da_result_t clean_files_from_dir(char* dir_path);
48 da_result_t create_temp_saved_dir(void);
49
50 da_result_t  file_write_ongoing(stage_info *stage, char *body, int body_len);
51 da_result_t  file_write_complete(stage_info *stage);
52 da_result_t  start_file_writing(stage_info *stage);
53 da_result_t  start_file_writing_append(stage_info *stage);
54
55 da_result_t  get_mime_type(stage_info *stage, char **out_mime_type);
56 da_result_t  discard_download(stage_info *stage) ;
57 void clean_paused_file(stage_info *stage);
58 da_result_t  replace_content_file_in_stage(stage_info *stage, const char *dest_dd_file_path);
59 da_result_t  decide_final_file_path(stage_info *stage);
60 char *get_full_path_avoided_duplication(char *in_dir, char *in_candidate_file_name, char * in_extension);
61
62 da_result_t copy_file(const char *src, const char *dest);
63 da_result_t create_dir(const char *install_dir);
64
65 #endif