00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _FILESYS_H_
00036 #define _FILESYS_H_
00037
00038 #include <string>
00039
00040 #include "shared.h"
00041
00042 using namespace std;
00043
00044
00045
00046
00047
00048 #define FILESYS_NOT_PUBLISHED 1
00049
00050
00051
00052
00053 #define FILESYS_GOT_FILE 2
00054
00055
00056
00057
00058 #define FILESYS_GOT_SECURE_MSG 3
00059
00060
00061
00062
00063 #define FILESYS_GOT_INCOMPLETE 4
00064
00065
00066
00067
00068
00069 #define FILESYS_ALREADY_EXISTS 5
00070
00071
00072
00073
00074 #define FILESYS_REPLACED 6
00075
00076
00077
00078
00079
00080
00081
00082 enum e_file_type {
00083 ft_invalid=0,
00084 ft_file,
00085 ft_message
00086 };
00087
00088
00089
00090
00091
00092
00093
00094 struct s_access {
00095 bool all_users;
00096 string user_name;
00097 bool owner;
00098 bool read;
00099 bool del;
00100 bool notify_owner;
00101 bool notify_user;
00102 bool secure;
00103 string all_on_channel;
00104 bool also_unknown;
00105
00106 string notify_owner_message;
00107 string notify_user_message;
00108
00109
00110
00111
00112
00113
00114
00115 void clear()
00116 {
00117 all_users=false;
00118 user_name="";
00119 owner=false;
00120 read=false;
00121 del=false;
00122 notify_owner=false;
00123 notify_user=false;
00124 secure=false;
00125 notify_owner_message="";
00126 notify_user_message="";
00127 all_on_channel="";
00128 also_unknown=false;
00129 }
00130
00131 s_access()
00132 {
00133 clear();
00134 }
00135 };
00136
00137
00138
00139
00140
00141
00142
00143 struct s_event {
00144 bool has_read;
00145 bool owner_notified;
00146 bool user_notified;
00147 string user_name;
00148
00149 time_t first;
00150
00151
00152
00153
00154
00155
00156
00157 void clear()
00158 {
00159 has_read=false;
00160 owner_notified=false;
00161 user_notified=false;
00162 user_name="";
00163 first=0;
00164 }
00165
00166 s_event()
00167 {
00168 clear();
00169 }
00170 };
00171
00172
00173
00174
00175
00176
00177
00178 struct s_file {
00179 e_file_type file_type;
00180 bool published;
00181 bool complete;
00182 string sender_file_name;
00183 time_t ftime;
00184 string internal_name;
00185 string public_name;
00186 vector<s_access> access;
00187 vector<s_event> events;
00188
00189 time_t expiration;
00190 bool expired;
00191
00192
00193
00194
00195
00196
00197
00198 void clear()
00199 {
00200 file_type=ft_invalid;
00201 ftime=0;
00202 published=false;
00203 sender_file_name="";
00204 complete=false;
00205 internal_name="";
00206 public_name="";
00207 access.clear();
00208 events.clear();
00209 expiration=0;
00210 expired=false;
00211 }
00212
00213 s_file()
00214 {
00215 clear();
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 bool is_owner(string user)
00227 {
00228 vector<s_access>::iterator i1;
00229 for(i1=access.begin(); i1!=access.end(); i1++) {
00230 if((*i1).owner && ((*i1).all_users || !(*i1).user_name.compare(user)))
00231 return true;
00232 }
00233 return false;
00234 }
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 bool can_read(string user)
00245 {
00246 vector<s_access>::iterator i1;
00247 for(i1=access.begin(); i1!=access.end(); i1++) {
00248 if((*i1).read && ((*i1).all_users || !(*i1).user_name.compare(user)))
00249 return true;
00250 }
00251 return false;
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 bool can_delete(string user)
00263 {
00264 vector<s_access>::iterator i1;
00265 for(i1=access.begin(); i1!=access.end(); i1++) {
00266 if((*i1).del && ((*i1).all_users || !(*i1).user_name.compare(user)))
00267 return true;
00268 }
00269 return false;
00270 }
00271 };
00272
00273
00274
00275
00276
00277
00278
00279 struct s_dcc_notify {
00280 bool unpublished;
00281 bool incomplete;
00282 bool notify_user;
00283 bool notify_owner;
00284 bool secure_notify_user;
00285 bool secure_notify_owner;
00286 string name;
00287 string message;
00288
00289 s_dcc_notify()
00290 {
00291 unpublished=false;
00292 incomplete=false;
00293 notify_user=false;
00294 notify_owner=false;
00295 secure_notify_user=false;
00296 secure_notify_owner=false;
00297 name="";
00298 message="";
00299 }
00300 };
00301
00302 void filesys_add_file_raw(string internal_name, string original_name, string owner, bool complete, bool after_resume);
00303 bool filesys_dcc_check_for_notifies(string user, s_user& u, vector<s_channel>& chs, string channel, vector<s_dcc_notify>& notify, bool secured, string lang, string eol);
00304 bool filesys_dcc_filelist(string user, vector<s_file>& files_, bool must_be_owner);
00305 bool filesys_dcc_get_file(string user, string public_name, s_file& file);
00306 bool filesys_dcc_set_file_attrs(string user, s_file& file, bool& forced_secure);
00307 void filesys_dcc_drop_notifies(string user, bool only_non_secure);
00308 string filesys_dcc_add_message(string from, s_file& msg, string content, bool& force_secure);
00309 void filesys_set_file_was_read(string user, string public_name);
00310 bool filesys_dcc_set_file_attrs(s_file& file);
00311 bool filesys_dcc_check_for_resume(string user, string file_name, size_t& got_bytes);
00312 void filesys_dcc_get_resume_info(string user, string file_name, string& internal_name);
00313 int filesys_dcc_delete(string user, string file_name);
00314 int filesys_check_add_file_raw(string public_name, string user_name);
00315
00316 void filesys_flush();
00317
00318 string filesys_get_script(string script_type);
00319
00320 bool filesys_logic_get_file(string internal_name, s_file& file);
00321 bool filesys_logic_set_file(string internal_name, s_file& file);
00322
00323 #endif
00324