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
00032
00033 #ifndef __AUTOSCAN_H__
00034 #define __AUTOSCAN_H__
00035
00036 #include "zmmf/zmmf.h"
00037 #include "sync.h"
00038 #include "timer.h"
00039
00040 #define INVALID_SCAN_ID -1
00041
00043 enum scan_level_t
00044 {
00045 BasicScanLevel,
00046 FullScanLevel
00047 };
00048
00050 enum scan_mode_t
00051 {
00052 TimedScanMode,
00053 InotifyScanMode
00054 };
00055
00056 class AutoscanDirectory;
00057
00058 class AutoscanList : public zmm::Object
00059 {
00060 public:
00061 AutoscanList();
00062
00070 int add(zmm::Ref<AutoscanDirectory> dir);
00071
00072 void addList(zmm::Ref<AutoscanList> list);
00073
00074 zmm::Ref<AutoscanDirectory> get(int id);
00075
00076 zmm::Ref<AutoscanDirectory> get(zmm::String location);
00077
00078 zmm::Ref<AutoscanDirectory> getByObjectID(int objectID);
00079
00080 int size() { return list->size(); }
00081
00083 void remove(int id);
00084
00085 int removeByObjectID(int objectID);
00086
00090 int remove(zmm::String location);
00091
00096 zmm::Ref<AutoscanList> removeIfSubdir(zmm::String parent, bool persistent = false);
00097
00098
00101
00102
00103
00107 void notifyAll(zmm::Ref<TimerSubscriberSingleton<Object> > obj);
00108
00109
00113
00114
00115
00117 void updateLMinDB();
00118
00120 zmm::Ref<zmm::Array<AutoscanDirectory> > getArrayCopy();
00121
00122
00123
00124
00125
00126 protected:
00127 zmm::Ref<Mutex> mutex;
00128 zmm::Ref<zmm::Array<AutoscanDirectory> > list;
00129 int _add(zmm::Ref<AutoscanDirectory> dir);
00130 };
00131
00133 class AutoscanDirectory : public zmm::Object
00134 {
00135 public:
00136 AutoscanDirectory();
00137
00146 AutoscanDirectory(zmm::String location, scan_mode_t mode,
00147 scan_level_t level, bool recursive,
00148 bool persistent,
00149 int id = INVALID_SCAN_ID, unsigned int interval = 0, bool hidden = false);
00150
00151 void setStorageID(int storageID) { this->storageID = storageID; }
00152
00153 int getStorageID() { return storageID; }
00154
00156 void setLocation(zmm::String location);
00157
00158 zmm::String getLocation() { return location; }
00159
00160 scan_mode_t getScanMode() { return mode; }
00161
00162 void setScanMode(scan_mode_t mode) { this->mode = mode; }
00163
00164 scan_level_t getScanLevel() { return level; }
00165
00166 void setScanLevel(scan_level_t level) { this->level = level; }
00167
00168 bool getRecursive() { return recursive; }
00169
00170 void setHidden(bool hidden) { this->hidden = hidden; }
00171
00172 bool getHidden() { return hidden; }
00173
00174 void setRecursive(bool recursive) { this->recursive = recursive; }
00175
00176 unsigned int getInterval() { return interval; }
00177
00178 void setInterval(unsigned int interval) { this->interval = interval; }
00179
00188 void incTaskCount() { taskCount++; }
00189
00190 void decTaskCount() { taskCount--; }
00191
00192 int getTaskCount() { return taskCount; }
00193
00194 void setTaskCount(int taskCount) { this->taskCount = taskCount; }
00195
00201 void setScanID(int id);
00202
00203 int getScanID() { return scanID; }
00204
00205 void setObjectID(int id) { objectID = id; }
00206
00207 int getObjectID() { return objectID; }
00208
00209 bool persistent() { return persistent_flag; }
00210
00219 void setCurrentLMT(time_t lmt);
00220
00221 time_t getPreviousLMT() { return last_mod_previous_scan; }
00222
00223 void updateLMT() { last_mod_previous_scan = last_mod_current_scan; }
00224
00225 void resetLMT() { last_mod_previous_scan = 0; last_mod_current_scan = 0; }
00226
00228 void copyTo(zmm::Ref<AutoscanDirectory> copy);
00229
00232
00233
00235 zmm::Ref<zmm::Object> getTimerParameter();
00236
00237
00238
00239
00240 static zmm::String mapScanmode(scan_mode_t scanmode);
00241 static scan_mode_t remapScanmode(zmm::String scanmode);
00242 static zmm::String mapScanlevel(scan_level_t scanlevel);
00243 static scan_level_t remapScanlevel(zmm::String scanlevel);
00244
00245 protected:
00246 zmm::String location;
00247 scan_mode_t mode;
00248 scan_level_t level;
00249 bool recursive;
00250 bool hidden;
00251 bool persistent_flag;
00252 unsigned int interval;
00253 int taskCount;
00254 int scanID;
00255 int objectID;
00256 int storageID;
00257 time_t last_mod_previous_scan;
00258 time_t last_mod_current_scan;
00259 zmm::Ref<zmm::Object> timer_parameter;
00260 };
00261
00262 #endif