csync_owncloud.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CSYNC_OWNCLOUD_H
00022 #define CSYNC_OWNCLOUD_H
00023
00024 #include <errno.h>
00025 #include <stdio.h>
00026 #include <time.h>
00027 #include <limits.h>
00028 #include <stdlib.h>
00029
00030 #include <sys/types.h>
00031 #include <sys/stat.h>
00032 #include <fcntl.h>
00033
00034 #include "config.h"
00035 #ifdef NEON_WITH_LFS
00036 #define NE_LFS
00037 #endif
00038
00039 #include <neon/ne_basic.h>
00040 #include <neon/ne_socket.h>
00041 #include <neon/ne_session.h>
00042 #include <neon/ne_request.h>
00043 #include <neon/ne_props.h>
00044 #include <neon/ne_auth.h>
00045 #include <neon/ne_dates.h>
00046 #include <neon/ne_compress.h>
00047 #include <neon/ne_redirect.h>
00048
00049
00050 #include "c_rbtree.h"
00051
00052 #include "c_lib.h"
00053 #include "csync.h"
00054 #include "csync_misc.h"
00055 #include "csync_macros.h"
00056 #include "c_private.h"
00057 #include "httpbf.h"
00058
00059 #include "vio/csync_vio_module.h"
00060 #include "vio/csync_vio_file_stat.h"
00061 #include "vio/csync_vio.h"
00062
00063 #include "csync_log.h"
00064
00065
00066 #define DEBUG_WEBDAV(...) csync_log( dav_session.csync_ctx, 9, "oc_module", __VA_ARGS__);
00067
00068 enum resource_type {
00069 resr_normal = 0,
00070 resr_collection,
00071 resr_reference,
00072 resr_error
00073 };
00074
00075 #define DAV_STRTOL strtoll
00076
00077
00078
00079
00080
00081 typedef struct resource {
00082 char *uri;
00083 char *name;
00084
00085 enum resource_type type;
00086 int64_t size;
00087 time_t modtime;
00088 char* md5;
00089
00090 struct resource *next;
00091 } resource;
00092
00093
00094
00095
00096 struct listdir_context {
00097 struct resource *list;
00098 struct resource *currResource;
00099 char *target;
00100 unsigned int result_count;
00101 int ref;
00102 };
00103
00104
00105
00106 extern c_rbtree_t *propfind_recursive_cache;
00107
00108 struct propfind_recursive_element {
00109 struct resource *self;
00110 struct resource *children;
00111 };
00112 typedef struct propfind_recursive_element propfind_recursive_element_t;
00113 void clear_propfind_recursive_cache(void);
00114 struct listdir_context *get_listdir_context_from_cache(const char *curi);
00115 struct listdir_context *fetch_resource_list_recursive(const char *uri, const char *curi);
00116
00117
00118
00119
00120
00121
00122
00123 struct transfer_context {
00124 ne_request *req;
00125 int fd;
00126 const char *method;
00127 ne_decompress *decompress;
00128 char *url;
00129
00130
00131 struct timeval last_time;
00132 ne_off_t last_progress;
00133 int64_t get_size;
00134 };
00135
00136 typedef int (*csync_owncloud_redirect_callback_t)(CSYNC* ctx, const char* uri);
00137
00138
00139 struct dav_session_s {
00140 ne_session *ctx;
00141 char *user;
00142 char *pwd;
00143
00144 char *proxy_type;
00145 char *proxy_host;
00146 int proxy_port;
00147 char *proxy_user;
00148 char *proxy_pwd;
00149
00150 char *session_key;
00151
00152 char *error_string;
00153
00154 int read_timeout;
00155
00156 CSYNC *csync_ctx;
00157
00158 csync_hbf_info_t *chunk_info;
00159
00160 bool no_recursive_propfind;
00161 int64_t hbf_block_size;
00162 int64_t hbf_threshold;
00163
00164
00165 int bandwidth_limit_upload;
00166 int bandwidth_limit_download;
00167
00168 csync_overall_progress_t *overall_progress_data;
00169 csync_owncloud_redirect_callback_t redir_callback;
00170 };
00171 extern struct dav_session_s dav_session;
00172
00173
00174 static const ne_propname ls_props[] = {
00175 { "DAV:", "getlastmodified" },
00176 { "DAV:", "getcontentlength" },
00177 { "DAV:", "resourcetype" },
00178 { "DAV:", "getetag"},
00179 { NULL, NULL }
00180 };
00181
00182 void set_errno_from_http_errcode( int err );
00183 void set_error_message( const char *msg );
00184 void set_errno_from_neon_errcode( int neon_code );
00185 int http_result_code_from_session(void);
00186 void set_errno_from_session(void);
00187
00188 time_t oc_httpdate_parse( const char *date );
00189
00190 char *_cleanPath( const char* uri );
00191
00192 int _stat_perms( int type );
00193 csync_vio_file_stat_t *resourceToFileStat( struct resource *res );
00194
00195 void oc_notify_progress(const char *file, enum csync_notify_type_e kind, int64_t current_size, int64_t full_size);
00196
00197 #endif