00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __RIOEXPLORER_H__
00019 #define __RIOEXPLORER_H__
00020
00021 #include <signal.h>
00022 #include <dirent.h>
00023 #include <string>
00024 #include <vector>
00025
00026 #include <ctime>
00027 #include <qdom.h>
00028 #include <qstring.h>
00029 #include <qfile.h>
00030 #include <qtextstream.h>
00031
00032 #define MD5SIZE 33
00033
00034 using namespace std;
00035
00036 #include "RioInterface.h"
00037 #include "ObjectInfo.h"
00038 #include "Parser.h"
00039 #include "common.h"
00040
00041 void CallBack( RioRequest* );
00042
00043 class SessionsInfo;
00044 class DuInfo;
00045 class DfInfo;
00046 class DisplayInfo;
00047 class RioMd5;
00048
00049 class RioExplorer
00050 {
00051 private:
00052 RioObjectSize rGetSize( vector<DuInfo> *, char*, CRioSession*, bool );
00053 bool getLocalObjectInfo( const char*, ObjectInfo* );
00054 bool getNextLocalFileName( DIR*, char*, ObjectInfo* );
00055 bool getNextRioFileName( CRioDirectory*, CRioSession*, char*,
00056 ObjectInfo*, bool );
00057 bool copyFile( CRioStream *stream_src, CRioStream *stream_dest,
00058 char *src, char *dst,
00059 bool askuser, bool *can_continue,
00060 RioObjectSize *current_file_completed,
00061 RioObjectSize *total_completed,
00062 RioMd5 *calculator );
00063
00064 bool strMatch( char *, char * );
00065 char *convertPath( const char * );
00066
00067
00068 RioResult RioError;
00069
00070
00071 int SystemError;
00072
00073 protected:
00074 CRioSession *session;
00075
00076
00077
00078 CRioStream *createNRTStream( CRioSession *cpsession );
00079 char HomeDir[ MAXNAMELEN ];
00080 char curDir[ MAXNAMELEN ];
00081 bool resolveRegExp( vector<ObjectInfo> *, CRioSession*,
00082 const char*, char* = NULL, int = 0 );
00083
00084 public:
00085 RioExplorer();
00086 virtual ~RioExplorer();
00087 CRioSession *createSession( char *, char *, char * );
00088 bool checkSession( void );
00089 bool checkSession( CRioSession *session );
00090
00091 bool display( DisplayInfo *, char*, int, int , bool);
00092 bool ls( ObjectInfo *, vector<ObjectInfo> *, CRioSession *, bool, bool,
00093 char * = NULL, int = 0 );
00094 bool mkdir( char*, CRioSession*, bool = true );
00095 bool rm( ObjectInfo*, CRioSession *, bool askuser, bool = false );
00096 bool cd( char*, CRioSession * );
00097 bool createObject( char*, unsigned int );
00098 bool df( vector<DfInfo> * );
00099 bool du( vector<DuInfo> *, char*, CRioSession*, bool );
00100 bool sessions( SessionsInfo * );
00101 bool measures( void );
00102 bool mv( char*, char*, CRioSession *, bool );
00103
00104 bool cp( CRioSession *session_src ,
00105 CRioSession *session_dest ,
00106 ObjectInfo *src ,
00107 char *dest ,
00108 bool askuser ,
00109 bool recursive ,
00110 bool *can_continue ,
00111 string *current_file = NULL,
00112 RioObjectSize *current_file_completed = NULL,
00113 RioObjectSize *current_file_size = NULL,
00114 RioObjectSize *total_completed = NULL,
00115 CRioStream *stream_src = NULL,
00116 CRioStream *stream_dest = NULL,
00117 RioMd5 *calculator = NULL );
00118
00119 bool sync( QString, CRioSession*, QString, CRioSession*,
00120 string *current_file = NULL,
00121 RioObjectSize *current_file_completed = NULL,
00122 RioObjectSize *current_file_size = NULL );
00123 bool getObjectMd5Sum( char*, CRioSession*, char*, bool = true );
00124 QString md5CacheFile();
00125
00126 bool getObjectInfo( const char*, CRioSession*, ObjectInfo*,
00127 bool = true );
00128 bool getBlockSize( unsigned int *, CRioSession* );
00129 bool getMonitorTable( CRioSession *, char *, vector<ClientData> *,
00130 vector<StorageData> * );
00131
00132 static string formatSize( RioObjectSize );
00133
00134
00135
00136
00137
00138
00139 void setSession( CRioSession* Session );
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 void getError( RioResult *RioStatus, int *SystemStatus );
00151
00152
00153 virtual bool showMessage( int, string, string = "" ) = 0;
00154 virtual void updateCopyProgress( void ) = 0;
00155 virtual void setMD5Calculation( char *, bool ) = 0;
00156 virtual void setSyncCheck( char *, bool ) = 0;
00157
00158
00159 static const int MaxRequests = 20;
00160 static const int INVALID = 0;
00161 static const int LOCAL = 1;
00162 static const int REMOTE = 2;
00163 static const int SERVER = 3;
00164 static const int BUFFERSIZE = 1024*1024;
00165
00166
00167 static const int ERROR_MSG = 0;
00168 static const int INFO_MSG = 1;
00169 static const int QUESTION_MSG = 2;
00170 static const int WARNING_MSG = 3;
00171
00172
00173 static const int _FILE = 0;
00174 static const int _DIRECTORY = 1;
00175 static const int _DOTDIRECTORY = 2;
00176 static const int _INVALID = 3;
00177
00178
00179 QString MD5CACHEFILE;
00180 };
00181
00182
00183 class SessionsInfo
00184 {
00185 public:
00186 unsigned int number_of_max_sessions;
00187 unsigned int number_of_active_sessions;
00188 };
00189
00190 class DuInfo
00191 {
00192 public:
00193 string object_name;
00194 unsigned int nBlocks;
00195 RioObjectSize size;
00196 };
00197
00198 class StorageDfInfo
00199 {
00200 public:
00201 string hostname;
00202 string diskname;
00203 RioObjectSize size;
00204 RioObjectSize used_size;
00205 RioObjectSize free_size;
00206 unsigned int total_blocks;
00207 unsigned int used_blocks;
00208 unsigned int free_blocks;
00209 };
00210
00211 class DfInfo
00212 {
00213 public:
00214 unsigned int free_blocks_of_all_disks;
00215 unsigned int total_blocks_of_all_disks;
00216 unsigned int used_blocks_of_all_disks;
00217 RioObjectSize used_size;
00218 RioObjectSize free_size;
00219 vector<StorageDfInfo> storage_df_info;
00220 };
00221
00222 class DisplayInfo
00223 {
00224 public:
00225 string data;
00226 };
00227
00228 class RioMd5
00229 {
00230 public:
00231 bool getMd5Sum( char *, char *, bool = false );
00232 bool updateCache();
00233 void copyCache( RioMd5 * );
00234 bool importData( QString, CRioSession * );
00235 RioMd5( RioExplorer *, CRioSession * );
00236 RioMd5( RioExplorer *, CRioSession *, char * );
00237 ~RioMd5();
00238 private:
00239 char *calculateMD5( const char *, char * );
00240 void loadCache( QString, vector<QDomElement> & );
00241 RioExplorer *parent;
00242 CRioSession *md5Session;
00243 QString srcDirectory;
00244 vector<QDomElement> md5Cache;
00245 QString MD5CACHEFILE;
00246 };
00247 #endif //__RIOEXPLORER_H__