bool CServerList::Init() { // auto update the list by using an url if (thePrefs.GetAutoUpdateServerList()) { if(theApp.IsSplash()) theApp.DestroySplash(); //Xman new slpash-screen arrangement AutoUpdate(); } //Xman // Load Metfile CString strPath; strPath.Format(_T("%s") SERVER_MET_FILENAME, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); bool bRes = AddServerMetToList(strPath, false); if (thePrefs.GetAutoUpdateServerList()) { strPath.Format(_T("%sserver_met.download"), thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); bool bRes2 = AddServerMetToList(strPath, true); if (!bRes && bRes2) bRes = true; } // insert static servers from textfile strPath.Format(_T("%sstaticservers.dat"), thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); AddServersFromTextFile(strPath); //Xman auto update IPFilter if(thePrefs.AutoUpdateIPFilter()) { bool update=false; if (thePrefs.m_last_ipfilter_check!=0) { CTime last(thePrefs.m_last_ipfilter_check); struct tm tmTemp; time_t tLast=safe_mktime(last.GetLocalTm(&tmTemp)); time_t tNow=safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp)); if ( (difftime(tNow,tLast) / 86400)>=thePrefs.GetUpdateDays() ) { update=true; } } else update=true; if(update) { if(theApp.IsSplash()) theApp.DestroySplash(); //Xman new slpash-screen arrangement theApp.ipfilter->UpdateIPFilterURL(); } } //Xman end //X-Ray :: Fincan Hash Detection :: Start if(thePrefs.GetAntiLeecherFincan()) theApp.dlp->LoadFincanHashes(thePrefs.m_antileecherFincanURL, true); //X-Ray :: Fincan Hash Detection :: End theApp.serverlist->GiveServersForTraceRoute(); return bRes; }
/* MORPH START leuk_he: Remove 2nd apply in scheduler void CPPgScheduler::OnBnClickedApply() { int index=m_list.GetSelectionMark(); */ BOOL CPPgScheduler::OnApply(){ int index=miActiveSelection ; // MORPH END leuk_he: Remove 2nd apply in scheduler if (index>-1) { Schedule_Struct* schedule=theApp.scheduler->GetSchedule(index); //title GetDlgItem(IDC_S_TITLE)->GetWindowText(schedule->title); //time CTime myTime; DWORD result=m_time.GetTime(myTime); if (result == GDT_VALID){ struct tm tmTemp; schedule->time=safe_mktime(myTime.GetLocalTm(&tmTemp)); } CTime myTime2; DWORD result2=m_timeTo.GetTime(myTime2); if (result2 == GDT_VALID){ struct tm tmTemp; schedule->time2=safe_mktime(myTime2.GetLocalTm(&tmTemp)); } if (IsDlgButtonChecked(IDC_CHECKNOENDTIME)) schedule->time2=0; //time kindof (days) schedule->day=m_timesel.GetCurSel(); schedule->enabled=IsDlgButtonChecked(IDC_S_ENABLE)!=0; schedule->ResetActions(); for (uint8 i=0;i<m_actions.GetItemCount();i++) { schedule->actions[i]=m_actions.GetItemData(i); //MORPH START - Changed by Stulle, Show cat name for scheduler cat actions if(schedule->actions[i]==ACTION_CATSTOP || schedule->actions[i]==ACTION_CATRESUME) { CString strCat = m_actions.GetItemText(i,1); schedule->values[i]=strCat.Left(strCat.Find(L"(")-1); } else //MORPH END - Changed by Stulle, Show cat name for scheduler cat actions schedule->values[i]=m_actions.GetItemText(i,1); } m_list.SetItemText(index, 0, schedule->title); m_list.SetItemText(index, 1, GetDayLabel(schedule->day)); CTime time(theApp.scheduler->GetSchedule(index)->time); CString timeS; timeS.Format(_T("%s"),time.Format(_T("%H:%M"))); m_list.SetItemText(index, 2, timeS); } RecheckSchedules(); // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(false); return CPropertyPage::OnApply(); // MORPH END leuk_he: Remove 2nd apply in scheduler }
void CPPgScheduler::OnBnClickedApply() { int index=m_list.GetSelectionMark(); if (index>-1) { Schedule_Struct* schedule=theApp.scheduler->GetSchedule(index); //title GetDlgItem(IDC_S_TITLE)->GetWindowText(schedule->title); //time CTime myTime; DWORD result=m_time.GetTime(myTime); if (result == GDT_VALID){ struct tm tmTemp; schedule->time=safe_mktime(myTime.GetLocalTm(&tmTemp)); } CTime myTime2; DWORD result2=m_timeTo.GetTime(myTime2); if (result2 == GDT_VALID){ struct tm tmTemp; schedule->time2=safe_mktime(myTime2.GetLocalTm(&tmTemp)); } if (IsDlgButtonChecked(IDC_CHECKNOENDTIME)) schedule->time2=0; //time kindof (days) schedule->day=m_timesel.GetCurSel(); schedule->enabled=IsDlgButtonChecked(IDC_S_ENABLE)!=0; schedule->ResetActions(); for (uint8 i=0;i<m_actions.GetItemCount();i++) { schedule->actions[i]=m_actions.GetItemData(i); schedule->values[i]=m_actions.GetItemText(i,1); } m_list.SetItemText(index, 0, schedule->title); m_list.SetItemText(index, 1, GetDayLabel(schedule->day)); CTime time(theApp.scheduler->GetSchedule(index)->time); CString timeS; timeS.Format(_T("%s"),time.Format(_T("%H:%M"))); m_list.SetItemText(index, 2, timeS); } RecheckSchedules(); }
void CScheduler::SetWeekly(int action,bool activate) { bool Currentactivated = HasWeekly(action); if ( Currentactivated == activate) return; // nothing to do. if ( ( Currentactivated == false )&& (activate == true)) { // must we insert a new? Schedule_Struct* newschedule=new Schedule_Struct(); struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); newschedule->day=tNow.GetDayOfWeek(); newschedule->enabled=true; newschedule->time=time(NULL); newschedule->time2=time(NULL); newschedule->title=GetResString(IDS_SCHEDTEXT); newschedule->ResetActions(); newschedule->actions[0]=action; newschedule->values[0]=L"update"; AddSchedule(newschedule); thePrefs.scheduler=true; // enable scheduler } if ((Currentactivated == true )&& (activate == false)) { // we must delete Schedule_Struct* curschedule; for (uint8 si=0;si< GetCount();si++) { curschedule= GetSchedule(si); if (curschedule->actions[0]==0 || !curschedule->enabled) continue; if (curschedule->day!=DAY_DAYLY) { // not daily, so must be weekly ( or montly, good also) for (int ai=0;ai<16;ai++) { if (curschedule->actions[ai]==action) { RemoveSchedule(si); return ; } } } } // not found? then schedule does not exist. ASSERT()?; return ; } };
void CFileDetailDialogInfo::RefreshData() { CString str; if (m_paFiles->GetSize() == 1) { CPartFile* file = STATIC_DOWNCAST(CPartFile, (*m_paFiles)[0]); // if file is completed, we output the 'file path' and not the 'part.met file path' if (file->GetStatus(true) == PS_COMPLETE) GetDlgItem(IDC_FD_X2)->SetWindowText(GetResString(IDS_DL_FILENAME)); SetDlgItemText(IDC_FNAME, file->GetFileName()); SetDlgItemText(IDC_METFILE, file->GetFullName()); SetDlgItemText(IDC_FHASH, md4str(file->GetFileHash())); if (file->GetTransferringSrcCount() > 0) str.Format(GetResString(IDS_PARTINFOS2), file->GetTransferringSrcCount()); else str = file->getPartfileStatus(); SetDlgItemText(IDC_PFSTATUS, str); str.Format(_T("%u; %s: %u (%.1f%%)"), file->GetPartCount(), GetResString(IDS_AVAILABLE) , file->GetAvailablePartCount(), (float)((file->GetAvailablePartCount()*100)/file->GetPartCount())); SetDlgItemText(IDC_PARTCOUNT, str); // date created if (file->GetCrFileDate() != 0) { str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->GetCrCFileDate().Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(time(NULL) - file->GetCrFileDate())); } else str = GetResString(IDS_UNKNOWN); SetDlgItemText(IDC_FILECREATED, str); // active download time time_t nDlActiveTime = file->GetDlActiveTime(); //vs2005 if (nDlActiveTime) str = CastSecondsToLngHM(nDlActiveTime); else str = GetResString(IDS_UNKNOWN); SetDlgItemText(IDC_DL_ACTIVE_TIME, str); // last seen complete struct tm tmTemp; struct tm* ptimLastSeenComplete = file->lastseencomplete.GetLocalTm(&tmTemp); if (file->lastseencomplete == NULL || ptimLastSeenComplete == NULL) str.Format(GetResString(IDS_NEVER)); else { str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->lastseencomplete.Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(time(NULL) - safe_mktime(ptimLastSeenComplete))); } SetDlgItemText(IDC_LASTSEENCOMPL, str); // last receive if (file->GetFileDate() != 0 && file->GetRealFileSize() > (uint64)0) { // 'Last Modified' sometimes is up to 2 seconds greater than the current time ??? // If it's related to the FAT32 seconds time resolution the max. failure should still be only 1 sec. // Happens at least on FAT32 with very high download speed. uint32 tLastModified = file->GetFileDate(); time_t tNow = time(NULL); //vs2005 uint32 tAgo; if (tNow >= tLastModified) tAgo = tNow - tLastModified; else{ TRACE("tNow = %s\n", CTime(tNow).Format("%X")); TRACE("tLMd = %s, +%u\n", CTime(tLastModified).Format("%X"), tLastModified - tNow); TRACE("\n"); tAgo = 0; } str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->GetCFileDate().Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(tAgo)); } else str = GetResString(IDS_NEVER); SetDlgItemText(IDC_LASTRECEIVED, str); // AICH Hash switch (file->GetAICHRecoveryHashSet()->GetStatus()) { case AICH_TRUSTED: case AICH_VERIFIED: case AICH_HASHSETCOMPLETE: if (file->GetAICHRecoveryHashSet()->HasValidMasterHash()) { SetDlgItemText(IDC_FD_AICHHASH, file->GetAICHRecoveryHashSet()->GetMasterHash().GetString()); break; } default: SetDlgItemText(IDC_FD_AICHHASH, GetResString(IDS_UNKNOWN)); } // file type CString ext; bool showwarning = false; int pos = file->GetFileName().ReverseFind(_T('.')); if (file->GetFileName().ReverseFind(_T('\\')) < pos) { ext = file->GetFileName().Mid(pos + 1); ext.MakeUpper(); } EFileType bycontent = GetFileTypeEx((CKnownFile *)file, false, true); if (bycontent != FILETYPE_UNKNOWN) { str = GetFileTypeName(bycontent) + _T(" ("); str.Append(GetResString(IDS_VERIFIED) + _T(')')); int extLevel = IsExtensionTypeOf(bycontent, ext); if (extLevel == -1) { showwarning = true; str.Append(_T(" - ")); str.Append(GetResString(IDS_INVALIDFILEEXT) + _T(": ")); str.Append(ext); } else if (extLevel == 0) { str.Append(_T(" - ")); str.Append(GetResString(IDS_UNKNOWNFILEEXT) + _T(": ")); str.Append(ext); } } else { // not verified if (pos != -1) { str =file->GetFileName().Mid(pos + 1); str.MakeUpper(); str.Append(_T(" (") ); str.Append( GetResString(IDS_UNVERIFIED) + _T(')')); } else str = GetResString(IDS_UNKNOWN); } m_bShowFileTypeWarning = showwarning; SetDlgItemText(IDC_FD_X11,str); } else { SetDlgItemText(IDC_FNAME, sm_pszNotAvail); SetDlgItemText(IDC_METFILE, sm_pszNotAvail); SetDlgItemText(IDC_FHASH, sm_pszNotAvail); SetDlgItemText(IDC_PFSTATUS, sm_pszNotAvail); SetDlgItemText(IDC_PARTCOUNT, sm_pszNotAvail); SetDlgItemText(IDC_FD_X11, sm_pszNotAvail); SetDlgItemText(IDC_FILECREATED, sm_pszNotAvail); SetDlgItemText(IDC_DL_ACTIVE_TIME, sm_pszNotAvail); SetDlgItemText(IDC_LASTSEENCOMPL, sm_pszNotAvail); SetDlgItemText(IDC_LASTRECEIVED, sm_pszNotAvail); SetDlgItemText(IDC_FD_AICHHASH, sm_pszNotAvail); } uint64 uFileSize = 0; uint64 uRealFileSize = 0; uint64 uTransferred = 0; uint64 uCorrupted = 0; uint32 uRecoveredParts = 0; uint64 uCompression = 0; uint64 uCompleted = 0; int iMD4HashsetAvailable = 0; int iAICHHashsetAvailable = 0; uint32 uDataRate = 0; UINT uSources = 0; UINT uValidSources = 0; UINT uNNPSources = 0; UINT uA4AFSources = 0; for (int i = 0; i < m_paFiles->GetSize(); i++) { CPartFile* file = STATIC_DOWNCAST(CPartFile, (*m_paFiles)[i]); uFileSize += (uint64)file->GetFileSize(); uRealFileSize += (uint64)file->GetRealFileSize(); uTransferred += (uint64)file->GetTransferred(); uCorrupted += file->GetCorruptionLoss(); uRecoveredParts += file->GetRecoveredPartsByICH(); uCompression += file->GetCompressionGain(); uDataRate += file->GetDatarate(); uCompleted += (uint64)file->GetCompletedSize(); iMD4HashsetAvailable += (file->GetFileIdentifier().HasExpectedMD4HashCount()) ? 1 : 0; iAICHHashsetAvailable += (file->GetFileIdentifier().HasExpectedAICHHashCount()) ? 1 : 0; if (file->IsPartFile()) { uSources += file->GetSourceCount(); uValidSources += file->GetValidSourcesCount(); uNNPSources += file->GetSrcStatisticsValue(DS_NONEEDEDPARTS); uA4AFSources += file->GetSrcA4AFCount(); } } str.Format(_T("%s (%s %s); %s %s"), CastItoXBytes(uFileSize, false, false), GetFormatedUInt64(uFileSize), GetResString(IDS_BYTES), GetResString(IDS_ONDISK), CastItoXBytes(uRealFileSize, false, false)); SetDlgItemText(IDC_FSIZE, str); if (m_paFiles->GetSize() == 1) { if (iAICHHashsetAvailable == 0 && iMD4HashsetAvailable == 0) SetDlgItemText(IDC_HASHSET, GetResString(IDS_NO)); else if (iAICHHashsetAvailable == 1 && iMD4HashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (eD2K + AICH)")); else if (iAICHHashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (AICH)")); else if (iMD4HashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (eD2K)")); } else { if (iAICHHashsetAvailable == 0 && iMD4HashsetAvailable == 0) SetDlgItemText(IDC_HASHSET, GetResString(IDS_NO)); else if (iMD4HashsetAvailable == m_paFiles->GetSize() && iAICHHashsetAvailable == m_paFiles->GetSize()) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + + _T(" (eD2K + AICH)")); else SetDlgItemText(IDC_HASHSET, _T("")); } str.Format(GetResString(IDS_SOURCESINFO), uSources, uValidSources, uNNPSources, uA4AFSources); SetDlgItemText(IDC_SOURCECOUNT, str); SetDlgItemText(IDC_DATARATE, CastItoXBytes(uDataRate, false, true)); SetDlgItemText(IDC_TRANSFERRED, CastItoXBytes(uTransferred, false, false)); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCompleted, false, false), uFileSize!=0 ? (uCompleted * 100.0 / uFileSize) : 0.0); SetDlgItemText(IDC_COMPLSIZE, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCorrupted, false, false), uTransferred!=0 ? (uCorrupted * 100.0 / uTransferred) : 0.0); SetDlgItemText(IDC_CORRUPTED, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uFileSize - uCompleted, false, false), uFileSize!=0 ? ((uFileSize - uCompleted) * 100.0 / uFileSize) : 0.0); SetDlgItemText(IDC_REMAINING, str); str.Format(_T("%u %s"), uRecoveredParts, GetResString(IDS_FD_PARTS)); SetDlgItemText(IDC_RECOVERED, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCompression, false, false), uTransferred!=0 ? (uCompression * 100.0 / uTransferred) : 0.0); SetDlgItemText(IDC_COMPRESSION, str); }
int CScheduler::Check(bool forcecheck){ if (!thePrefs.IsSchedulerEnabled() || theApp.scheduler->GetCount()==0 || !theApp.emuledlg->IsRunning()) return -1; Schedule_Struct* schedule; struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); if (!forcecheck && tNow.GetMinute()==m_iLastCheckedMinute) return -1; m_iLastCheckedMinute=tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); for (uint8 si=0;si<theApp.scheduler->GetCount();si++) { schedule=theApp.scheduler->GetSchedule(si); if (schedule->actions[0]==0 || !schedule->enabled) continue; // check day of week if (schedule->day!=DAY_DAYLY) { int dow=tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO : if (dow!=2) continue; break; case DAY_DI : if (dow!=3) continue; break; case DAY_MI : if (dow!=4) continue; break; case DAY_DO : if (dow!=5) continue; break; case DAY_FR : if (dow!=6) continue; break; case DAY_SA : if (dow!=7) continue; break; case DAY_SO : if (dow!=1) continue; break; case DAY_MO_FR : if (dow==7 || dow==1 ) continue; break; case DAY_MO_SA : if (dow==1) continue; break; case DAY_SA_SO : if (dow>=2 && dow<=6) continue; } } //check time UINT h1,h2,m1,m2; CTime t1=CTime(schedule->time); CTime t2=CTime(schedule->time2); h1=t1.GetHour(); h2=t2.GetHour(); m1=t1.GetMinute(); m2=t2.GetMinute(); int it1,it2, itn; it1=h1*60 + m1; it2=h2*60 + m2; itn=tNow.GetHour()*60 + tNow.GetMinute(); if (it1<=it2) { // normal timespan if ( !(itn>=it1 && itn<it2) ) continue; } else { // reversed timespan (23:30 to 5:10) now 10 if ( !(itn>=it1 || itn<it2)) continue; } // ok, lets do the actions of this schedule ActivateSchedule(si,schedule->time2==0); } return -1; }
int CScheduler::Check(bool forcecheck){ if (!thePrefs.IsSchedulerEnabled() || theApp.scheduler->GetCount()==0 || !theApp.emuledlg->IsRunning()) return -1; Schedule_Struct* schedule; struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); if (!forcecheck && tNow.GetMinute()==m_iLastCheckedMinute) return -1; m_iLastCheckedMinute=tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); for (uint8 si=0;si<theApp.scheduler->GetCount();si++) { schedule=theApp.scheduler->GetSchedule(si); if (schedule->actions[0]==0 || !schedule->enabled) continue; // check day of week if (schedule->day!=DAY_DAYLY) { int dow=tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO : if (dow!=2) continue; break; case DAY_DI : if (dow!=3) continue; break; case DAY_MI : if (dow!=4) continue; break; case DAY_DO : if (dow!=5) continue; break; case DAY_FR : if (dow!=6) continue; break; case DAY_SA : if (dow!=7) continue; break; case DAY_SO : if (dow!=1) continue; break; case DAY_MO_FR : if (dow==7 || dow==1 ) continue; break; case DAY_MO_SA : if (dow==1) continue; break; case DAY_SA_SO : if (dow>=2 && dow<=6) continue; } } //check time UINT h1,h2,m1,m2; CTime t1=CTime(schedule->time); CTime t2=CTime(schedule->time2); h1=t1.GetHour(); h2=t2.GetHour(); m1=t1.GetMinute(); m2=t2.GetMinute(); int it1,it2, itn; it1=h1*60 + m1; it2=h2*60 + m2; // ==> handling of one-time-events [Mighty Knife] - Stulle // if start-time=end-time, this is an event that should // occur once in that minute. In that case we add 1 to it2 to make sure // it happens (because of the timespan-comparison below, which happens // once per minute, too...) if (it2==it1) it2++; // <== handling of one-time-events [Mighty Knife] - Stulle itn=tNow.GetHour()*60 + tNow.GetMinute(); if (it1<=it2) { // normal timespan if ( !(itn>=it1 && itn<it2) ) continue; } else { // reversed timespan (23:30 to 5:10) now 10 if ( !(itn>=it1 || itn<it2)) continue; } // ok, lets do the actions of this schedule ActivateSchedule(si,schedule->time2==0); } return -1; }