00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "fsDldFilter.h"
00009 #include "ShedulerWnd.h"
00010
00011 #ifdef _DEBUG
00012 #undef THIS_FILE
00013 static char THIS_FILE[]=__FILE__;
00014 #define new DEBUG_NEW
00015 #endif
00016
00017 extern CShedulerWnd *_pwndScheduler;
00018
00019 fsDldFilter::fsDldFilter()
00020 {
00021
00022 }
00023
00024 fsDldFilter::~fsDldFilter()
00025 {
00026
00027 }
00028
00029 BOOL fsDldFilter::IsSatisfies(vmsDownloadSmartPtr )
00030 {
00031 return TRUE;
00032 }
00033
00034 fsDldGroupFilter::fsDldGroupFilter()
00035 {
00036
00037 }
00038
00039 fsDldGroupFilter::~fsDldGroupFilter()
00040 {
00041
00042 }
00043
00044 void fsDldGroupFilter::SetGroup(vmsDownloadsGroupSmartPtr pGroup)
00045 {
00046 m_pGrp = pGroup;
00047 }
00048
00049 BOOL fsDldGroupFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00050 {
00051 return m_pGrp->nId == dld->pGroup->nId;
00052 }
00053
00054 fsDldRunningFilter::fsDldRunningFilter()
00055 {
00056
00057 }
00058
00059 fsDldRunningFilter::~fsDldRunningFilter()
00060 {
00061
00062 }
00063
00064 BOOL fsDldRunningFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00065 {
00066 return dld->pMgr->IsRunning ();
00067 }
00068
00069 fsDldDoneFilter::fsDldDoneFilter()
00070 {
00071
00072 }
00073
00074 fsDldDoneFilter::~fsDldDoneFilter()
00075 {
00076
00077 }
00078
00079 BOOL fsDldDoneFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00080 {
00081 return dld->pMgr->IsDone ();
00082 }
00083
00084 fsDldTasksFilter::fsDldTasksFilter()
00085 {
00086
00087 }
00088
00089 fsDldTasksFilter::~fsDldTasksFilter()
00090 {
00091
00092 }
00093
00094 BOOL fsDldTasksFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00095 {
00096 BOOL bDone = dld->pMgr->IsDone ();
00097 BOOL b = bDone == FALSE ||
00098 CompareFileTime (&_timeAppHasStarted, &dld->dateAdded) != 1;
00099 if (b == FALSE && bDone)
00100 {
00101
00102 SYSTEMTIME st1, st2;
00103 FileTimeToSystemTime (&_timeAppHasStarted, &st1);
00104 FileTimeToSystemTime (&dld->dateAdded, &st2);
00105 b = st1.wDay == st2.wDay;
00106 }
00107 return b;
00108 }
00109
00110 fsDldStoppedFilter::fsDldStoppedFilter()
00111 {
00112
00113 }
00114
00115 fsDldStoppedFilter::~fsDldStoppedFilter()
00116 {
00117
00118 }
00119
00120 BOOL fsDldStoppedFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00121 {
00122 return dld->pMgr->IsRunning () == FALSE && dld->pMgr->IsDone () == FALSE;
00123 }
00124
00125 fsDldScheduledFilter::fsDldScheduledFilter()
00126 {
00127
00128 }
00129
00130 fsDldScheduledFilter::~fsDldScheduledFilter()
00131 {
00132
00133 }
00134
00135 BOOL fsDldScheduledFilter::IsSatisfies(vmsDownloadSmartPtr dld)
00136 {
00137 return _pwndScheduler->GetMgr ()->IsDownloadScheduled (dld);
00138 }
00139
00140 fsDldFilterType fsDldFilter::GetType()
00141 {
00142 return DFT_NONE;
00143 }
00144
00145 vmsDownloadsGroupSmartPtr fsDldGroupFilter::GetGroup()
00146 {
00147 return m_pGrp;
00148 }
00149
00150 fsDldFilterType fsDldGroupFilter::GetType()
00151 {
00152 return DFT_GROUP;
00153 }
00154
00155 fsDldHistRecFilter::fsDldHistRecFilter()
00156 {
00157
00158 }
00159
00160 fsDldHistRecFilter::~fsDldHistRecFilter()
00161 {
00162
00163 }
00164
00165 BOOL fsDldHistRecFilter::IsSatisfies(fsDLHistoryRecord* )
00166 {
00167 return TRUE;
00168 }
00169
00170 fsDldHistRecFilter_DuringPeriod::fsDldHistRecFilter_DuringPeriod()
00171 {
00172 SetPeriod (0);
00173 }
00174
00175 fsDldHistRecFilter_DuringPeriod::~fsDldHistRecFilter_DuringPeriod()
00176 {
00177
00178 }
00179
00180 fsDldHistRecFilter_Today::fsDldHistRecFilter_Today()
00181 {
00182
00183 }
00184
00185 fsDldHistRecFilter_Today::~fsDldHistRecFilter_Today()
00186 {
00187
00188 }
00189
00190 fsDldHistRecFilter_Yesterday::fsDldHistRecFilter_Yesterday()
00191 {
00192
00193 }
00194
00195 fsDldHistRecFilter_Yesterday::~fsDldHistRecFilter_Yesterday()
00196 {
00197
00198 }
00199
00200 fsDldHistRecFilter_Custom::fsDldHistRecFilter_Custom()
00201 {
00202
00203 }
00204
00205 fsDldHistRecFilter_Custom::~fsDldHistRecFilter_Custom()
00206 {
00207
00208 }
00209
00210 BOOL fsDldHistRecFilter_Custom::IsSatisfies(fsDLHistoryRecord* rec)
00211 {
00212 if (CompareFileTime (&m_tFrom, &rec->dateAdded) == 1)
00213 return FALSE;
00214
00215 if (CompareFileTime (&rec->dateAdded, &m_tTo) == 1)
00216 return FALSE;
00217
00218 return TRUE;
00219 }
00220
00221 BOOL fsDldHistRecFilter_DuringPeriod::IsSatisfies(fsDLHistoryRecord * rec)
00222 {
00223 SYSTEMTIME s;
00224 FILETIME f;
00225
00226 GetLocalTime (&s);
00227 SystemTimeToFileTime (&s, &f);
00228
00229 return fsGetFTimeDaysDelta (f, rec->dateRecordAdded) <= m_lastDays;
00230 }
00231
00232 BOOL fsDldHistRecFilter_Today::IsSatisfies(fsDLHistoryRecord* rec)
00233 {
00234 SYSTEMTIME s1, s2;
00235
00236 GetLocalTime (&s1);
00237 FileTimeToSystemTime (&rec->dateAdded, &s2);
00238
00239 return s1.wDay == s2.wDay && s1.wMonth == s2.wMonth && s1.wYear == s2.wYear;
00240 }
00241
00242 BOOL fsDldHistRecFilter_Yesterday::IsSatisfies(fsDLHistoryRecord* rec)
00243 {
00244 SYSTEMTIME s1, s2;
00245
00246 GetLocalTime (&s1);
00247 FileTimeToSystemTime (&rec->dateAdded, &s2);
00248
00249 if (s1.wDay == 0)
00250 {
00251 if ((s1.wMonth % 2) || s1.wMonth == 8)
00252 {
00253 s1.wDay = 31;
00254 }
00255 else
00256 {
00257 if (s1.wMonth == 2)
00258 {
00259 if (s1.wYear % 4)
00260 s1.wDay = 28;
00261 else
00262 s1.wDay = 29;
00263 }
00264 else
00265 {
00266 s1.wDay = 30;
00267 }
00268 }
00269
00270 s1.wMonth--;
00271 }
00272 else
00273 s1.wDay--;
00274
00275 return s1.wDay == s2.wDay && s1.wMonth == s2.wMonth && s1.wYear == s2.wYear;
00276 }
00277
00278 void fsDldHistRecFilter_DuringPeriod::SetPeriod(int cDays)
00279 {
00280 m_lastDays = cDays;
00281 }
00282
00283 void fsDldHistRecFilter_Custom::SetTimeRange(FILETIME tFrom, FILETIME tTo)
00284 {
00285 m_tFrom = tFrom;
00286 m_tTo = tTo;
00287 }