From 8c0bdc5bda6bb05f1ae27e2e27a2da235b1ced32 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Tue, 27 Mar 2007 17:42:45 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=12272 --- checkin_notes | 24 +++ clientgui/DlgAdvPreferences.cpp | 145 ++++++++++++++---- clientgui/DlgAdvPreferences.h | 3 + clientgui/Makefile.am | 6 +- clientgui/WizardAttachProject.cpp | 15 +- clientgui/stdwx.h | 1 + lib/boinc_win.h | 1 - lib/browser.C | 52 +++++++ .../AuthenticatorDetection.h => lib/browser.h | 20 ++- lib/browser_firefox.C | 40 +++++ .../browser_ie.C | 62 ++++---- lib/prefs.C | 29 +++- win_build/boinc_dll.vcproj | 8 - win_build/boinc_dll_2003.vcproj | 6 - win_build/boincmgr_curl.vcproj | 20 +++ win_build/boincmgr_curl_2003.vcproj | 12 ++ 16 files changed, 350 insertions(+), 94 deletions(-) create mode 100644 lib/browser.C rename clientlib/win/AuthenticatorDetection.h => lib/browser.h (61%) create mode 100644 lib/browser_firefox.C rename clientlib/win/AuthenticatorDetection.cpp => lib/browser_ie.C (56%) diff --git a/checkin_notes b/checkin_notes index 6dacfd814f..6819daa280 100755 --- a/checkin_notes +++ b/checkin_notes @@ -2823,3 +2823,27 @@ David 24 Mar 2007 html/ops/ index.php manage_user.php + +Rom 27 Mar 2007 + - MGR: Extend browser cookie detection framework so that additional + browsers can be used. + - MGR: Checkin Frank's latest changes to the Advanced Preferences + dialog. + + clientgui/ + DlgAdvPreferences.cpp, .h + Makefile.am + stdwx.h + WizardAttachProject.cpp + clientlib/win/ + AuthenticatorDetection.cpp, .h (Removed) + lib/ + boinc_win.h + browser.C, .h (Added) + browser_firefox.C (Added) + browser_ie.C (Added - Windows Only) + win_build/ + boinc_dll.vcproj + boinc_dll_2003.vcproj + boincmgr_curl.vcproj + boincmgr_curl_2003.vcproj diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 962f91fb6b..dbf5712c5a 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -145,7 +145,7 @@ bool CDlgAdvPreferences::SaveState() { bool CDlgAdvPreferences::RestoreState() { wxString strBaseConfigLocation = wxString(wxT("/DlgAdvPreferences/")); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); - int iTemp,iTemp1; + int p,w,h; wxASSERT(pConfig); @@ -153,15 +153,32 @@ bool CDlgAdvPreferences::RestoreState() { pConfig->SetPath(strBaseConfigLocation); - pConfig->Read(wxT("CurrentPage"), &iTemp,0); - m_Notebook->SetSelection(iTemp); - pConfig->Read(wxT("Width"), &iTemp,-1); - pConfig->Read(wxT("Height"), &iTemp1,-1); - this->SetSize(iTemp,iTemp1); + pConfig->Read(wxT("CurrentPage"), &p,0); + m_Notebook->SetSelection(p); + pConfig->Read(wxT("Width"), &w,-1); + pConfig->Read(wxT("Height"), &h,-1); + this->SetSize(w,h); return true; } +// convert a Timestring HH:MM into a double +double CDlgAdvPreferences::TimeStringToDouble(wxString timeStr) { + double hour; + double minutes; + timeStr.SubString(0,timeStr.First(':')).ToDouble(&hour); + timeStr.SubString(timeStr.First(':')+1,timeStr.Length()).ToDouble(&minutes); + minutes = minutes/60.0; + return hour + minutes; +} + +// convert a double into a timestring HH:MM +wxString CDlgAdvPreferences::DoubleToTimeString(double dt) { + int hour = (int)dt; + int minutes = (int)(60.0 * (dt - hour)); + return wxString::Format(wxT("%02d:%02d"),hour,minutes); +} + /* read preferences from core client and initialize control values */ void CDlgAdvPreferences::ReadPreferenceSettings() { m_bInInit=true;//prevent dialog handlers from doing anything @@ -180,11 +197,30 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { // ######### proc usage page // do work between - m_rbtProcEveryDay->SetValue(true); - buffer.Printf(wxT("%02d:00"),(int)prefs.time_prefs.start_hour); - *m_txtProcEveryDayStart << buffer; - buffer.Printf(wxT("%02d:00"),(int)prefs.time_prefs.end_hour); - *m_txtProcEveryDayStop << buffer; + m_rbtProcEveryDay->SetValue(true); + + *m_txtProcEveryDayStart << DoubleToTimeString(prefs.time_prefs.start_hour); + *m_txtProcEveryDayStop << DoubleToTimeString(prefs.time_prefs.end_hour); + //special day times + if(prefs.week_prefs.present) { + bool isRestricted=false; + wxCheckBox* aChks[] = {m_chkProcSunday,m_chkProcMonday,m_chkProcTuesday,m_chkProcWednesday,m_chkProcThursday,m_chkProcFriday,m_chkProcSaturday}; + wxTextCtrl* aTxts[] = {m_txtProcSunday,m_txtProcMonday,m_txtProcTuesday,m_txtProcWednesday,m_txtProcThursday,m_txtProcFriday,m_txtProcSaturday}; + for(int i=0; i< 7;i++) { + if(prefs.week_prefs.days[i].present && + prefs.week_prefs.days[i].time_prefs.start_hour != prefs.week_prefs.days[i].time_prefs.end_hour) { + aChks[prefs.week_prefs.days[i].day_of_week]->SetValue(true); + wxString timeStr = DoubleToTimeString(prefs.week_prefs.days[i].time_prefs.start_hour) + + wxT("-") + DoubleToTimeString(prefs.week_prefs.days[i].time_prefs.end_hour); + aTxts[i]->SetValue(timeStr); + isRestricted=true; + } + } + if(isRestricted) { + m_rbtProcSpecialTimes->SetValue(true); + } + } + // on batteries m_chkProcOnBatteries->SetValue(prefs.run_on_batteries); // in use @@ -205,10 +241,27 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { // ######### net usage page // use network between m_rbtNetEveryDay->SetValue(true); - buffer.Printf(wxT("%02d:00"),(int)prefs.time_prefs.net_start_hour); - *m_txtNetEveryDayStart << buffer; - buffer.Printf(wxT("%02d:00"),(int)prefs.time_prefs.net_end_hour); - *m_txtNetEveryDayStop << buffer; + *m_txtNetEveryDayStart << DoubleToTimeString(prefs.time_prefs.net_start_hour); + *m_txtNetEveryDayStop << DoubleToTimeString(prefs.time_prefs.net_end_hour); + //special day times + if(prefs.week_prefs.present) { + bool isRestricted = false; + wxCheckBox* aChks[] = {m_chkNetSunday,m_chkNetMonday,m_chkNetTuesday,m_chkNetWednesday,m_chkNetThursday,m_chkNetFriday,m_chkNetSaturday}; + wxTextCtrl* aTxts[] = {m_txtNetSunday,m_txtNetMonday,m_txtNetTuesday,m_txtNetWednesday,m_txtNetThursday,m_txtNetFriday,m_txtNetSaturday}; + for(int i=0; i< 7;i++) { + if(prefs.week_prefs.days[i].present && + prefs.week_prefs.days[i].time_prefs.net_start_hour != prefs.week_prefs.days[i].time_prefs.net_end_hour) { + aChks[prefs.week_prefs.days[i].day_of_week]->SetValue(true); + wxString timeStr = DoubleToTimeString(prefs.week_prefs.days[i].time_prefs.net_start_hour) + + wxT("-") + DoubleToTimeString(prefs.week_prefs.days[i].time_prefs.net_end_hour); + aTxts[i]->SetValue(timeStr); + isRestricted = true; + } + } + if(isRestricted) { + m_rbtNetSpecialTimes->SetValue(true); + } + } // connection interval buffer.Printf(wxT("%01.4f"),prefs.work_buf_min_days); *m_txtNetConnectInterval << buffer; @@ -260,6 +313,12 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { long tl; mask.clear(); + //clear special times settings + prefs.week_prefs.present=false; + for(int i=0; i< 7;i++) { + prefs.week_prefs.days[i].present=false; + prefs.week_prefs.days[i].time_prefs.clear(); + } //proc page prefs.run_on_batteries=m_chkProcOnBatteries->GetValue(); mask.run_on_batteries=true; @@ -273,18 +332,32 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.idle_time_to_run=true; } // - if(m_txtProcEveryDayStart->IsEnabled()) { - m_txtProcEveryDayStart->GetValue().ToLong(&tl); - prefs.time_prefs.start_hour=tl; + if(m_txtProcEveryDayStart->IsEnabled()) { + prefs.time_prefs.start_hour=TimeStringToDouble(m_txtProcEveryDayStart->GetValue()); mask.start_hour = true; } // if(m_txtProcEveryDayStop->IsEnabled()) { - m_txtProcEveryDayStop->GetValue().ToLong(&tl); - prefs.time_prefs.end_hour=tl; + prefs.time_prefs.end_hour=TimeStringToDouble(m_txtProcEveryDayStop->GetValue()); mask.end_hour = true; } // + if(m_rbtProcSpecialTimes->GetValue()) { + prefs.week_prefs.present=true; + wxCheckBox* aChks[] = {m_chkProcSunday,m_chkProcMonday,m_chkProcTuesday,m_chkProcWednesday,m_chkProcThursday,m_chkProcFriday,m_chkProcSaturday}; + wxTextCtrl* aTxts[] = {m_txtProcSunday,m_txtProcMonday,m_txtProcTuesday,m_txtProcWednesday,m_txtProcThursday,m_txtProcFriday,m_txtProcSaturday}; + for(int i=0; i< 7;i++) { + if(aChks[i]->GetValue()) { + prefs.week_prefs.days[i].day_of_week =i; + prefs.week_prefs.days[i].present =true; + wxString timeStr = aTxts[i]->GetValue(); + wxString startStr = timeStr.SubString(0,timeStr.First('-')); + wxString endStr = timeStr.SubString(timeStr.First('-')+1,timeStr.Length()); + prefs.week_prefs.days[i].time_prefs.start_hour = TimeStringToDouble(startStr); + prefs.week_prefs.days[i].time_prefs.end_hour = TimeStringToDouble(endStr); + } + } + } m_txtProcSwitchEvery->GetValue().ToDouble(&td); prefs.cpu_scheduling_period_minutes=td; mask.cpu_scheduling_period_minutes=true; @@ -321,16 +394,30 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.hangup_if_dialed=true; // if(m_txtNetEveryDayStart->IsEnabled()) { - m_txtNetEveryDayStart->GetValue().ToLong(&tl); - prefs.time_prefs.net_start_hour=tl; + prefs.time_prefs.net_start_hour=TimeStringToDouble(m_txtNetEveryDayStart->GetValue()); mask.net_start_hour = true; } // - if(m_txtNetEveryDayStop->IsEnabled()) { - m_txtNetEveryDayStop->GetValue().ToLong(&tl); - prefs.time_prefs.net_end_hour=tl; + if(m_txtNetEveryDayStop->IsEnabled()) { + prefs.time_prefs.net_end_hour=TimeStringToDouble(m_txtNetEveryDayStop->GetValue()); mask.net_end_hour = true; } + if(m_rbtNetSpecialTimes->GetValue()) { + prefs.week_prefs.present=true; + wxCheckBox* aChks[] = {m_chkNetSunday,m_chkNetMonday,m_chkNetTuesday,m_chkNetWednesday,m_chkNetThursday,m_chkNetFriday,m_chkNetSaturday}; + wxTextCtrl* aTxts[] = {m_txtNetSunday,m_txtNetMonday,m_txtNetTuesday,m_txtNetWednesday,m_txtNetThursday,m_txtNetFriday,m_txtNetSaturday}; + for(int i=0; i< 7;i++) { + if(aChks[i]->GetValue()) { + prefs.week_prefs.days[i].day_of_week =i; + prefs.week_prefs.days[i].present =true; + wxString timeStr = aTxts[i]->GetValue(); + wxString startStr = timeStr.SubString(0,timeStr.First('-')); + wxString endStr = timeStr.SubString(timeStr.First('-')+1,timeStr.Length()); + prefs.week_prefs.days[i].time_prefs.net_start_hour = TimeStringToDouble(startStr); + prefs.week_prefs.days[i].time_prefs.net_end_hour = TimeStringToDouble(endStr); + } + } + } //disk usage m_txtDiskMaxSpace->GetValue().ToDouble(&td); prefs.disk_max_used_gb=td; @@ -593,9 +680,10 @@ bool CDlgAdvPreferences::IsValidTimeIntervalValue(const wxString& value) { wxDateTime dtStart,dtStop; dtStart.ParseFormat(start,wxT("%H:%M")); dtStop.ParseFormat(stop,wxT("%H:%M")); - if(dtStart>=dtStop) { + // + /*if(dtStart>=dtStop) { return false; - } + }*/ return true; } @@ -657,4 +745,5 @@ bool CDlgAdvPreferences::ConfirmClear() { _("Confirmation"),wxCENTER | wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,this); return res==wxYES; -} \ No newline at end of file +} + diff --git a/clientgui/DlgAdvPreferences.h b/clientgui/DlgAdvPreferences.h index 21287fc02b..24e1f302e1 100644 --- a/clientgui/DlgAdvPreferences.h +++ b/clientgui/DlgAdvPreferences.h @@ -51,6 +51,8 @@ class CDlgAdvPreferences : public CDlgAdvPreferencesBase { void ShowErrorMessage(wxTextCtrl* errorCtrl); bool EnsureTabPageVisible(wxTextCtrl* txtCtrl); bool ConfirmClear(); + wxString DoubleToTimeString(double dt); + double TimeStringToDouble(wxString timeStr); public: CDlgAdvPreferences(wxWindow* parent=NULL);//to act as standard constructor set a default value virtual ~CDlgAdvPreferences(); @@ -69,3 +71,4 @@ private: }; #endif // _DLGADVPREFERENCES_H_ + diff --git a/clientgui/Makefile.am b/clientgui/Makefile.am index 77e505eeac..e4d1dfa5ef 100644 --- a/clientgui/Makefile.am +++ b/clientgui/Makefile.am @@ -97,6 +97,8 @@ boinc_gui_SOURCES = \ WizardAccountManager.cpp \ WizardAttachProject.cpp \ wizardex.cpp \ + ../lib/browser.C \ + ../lib/browser_firefox.C \ $(mac_sources) EXTRA_DIST = *.h \ @@ -105,8 +107,8 @@ EXTRA_DIST = *.h \ ../lib/error_numbers.h \ locale $(mac_headers) -boinc_gui_CPPFLAGS = $(AM_CPPFLAGS) $(WX_CPPFLAGS) $(CLIENTGUIFLAGS) -I../wizards -boinc_gui_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CXXFLAGS) $(CLIENTGUIFLAGS) -I../wizards +boinc_gui_CPPFLAGS = $(AM_CPPFLAGS) $(WX_CPPFLAGS) $(CLIENTGUIFLAGS) +boinc_gui_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CXXFLAGS) $(CLIENTGUIFLAGS) boinc_gui_LDADD = -L../lib -lboinc $(CLIENTGUILIBS) all-local: client_gui-bin diff --git a/clientgui/WizardAttachProject.cpp b/clientgui/WizardAttachProject.cpp index 6344d9379d..7e8bedc81a 100644 --- a/clientgui/WizardAttachProject.cpp +++ b/clientgui/WizardAttachProject.cpp @@ -31,6 +31,7 @@ #include "wizardex.h" #include "error_numbers.h" #include "hyperlink.h" +#include "browser.h" #include "BOINCGUIApp.h" #include "SkinManager.h" #include "MainDocument.h" @@ -277,27 +278,21 @@ bool CWizardAttachProject::Run( wxString& WXUNUSED(strName), wxString& strURL, b m_bCredentialsCached = bCredentialsCached; } -#ifdef __WXMSW__ - // If credentials are not cached, then we should try one last place to look up the // authenticator. Some projects will set a "Setup" cookie off of their URL with a // pretty short timeout. Lets take a crack at detecting it. // - // Only Internet Explorer is supported at this time. - // if (!bCredentialsCached) { - TCHAR szAuthenticator[512]; - DWORD dwSize = sizeof(szAuthenticator)/sizeof(TCHAR); + std::string url = strURL.mb_str(); + std::string authenticator; - if (DetectSetupAuthenticator(strURL.mbc_str(), szAuthenticator, &dwSize)) { + if (detect_setup_authenticator(url, authenticator)) { m_bCredentialsDetected = true; close_when_completed = true; - m_AccountKeyPage->m_strAccountKey = szAuthenticator; + m_AccountKeyPage->m_strAccountKey = wxString(authenticator.c_str(), wxConvUTF8); } } -#endif - if ( strURL.Length() && (bCredentialsCached || m_bCredentialsDetected) && m_ProjectProcessingPage) { return RunWizard(m_ProjectProcessingPage); } else if (strURL.Length() && !bCredentialsCached && m_ProjectPropertiesPage) { diff --git a/clientgui/stdwx.h b/clientgui/stdwx.h index fb79e83940..ddc9ce86cf 100644 --- a/clientgui/stdwx.h +++ b/clientgui/stdwx.h @@ -134,6 +134,7 @@ #include #include #include +#include #if wxUSE_ACCESSIBILITY #include diff --git a/lib/boinc_win.h b/lib/boinc_win.h index b0c1c0a15a..7d9a78ad46 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -105,7 +105,6 @@ #include #include -//#include #include #include diff --git a/lib/browser.C b/lib/browser.C new file mode 100644 index 0000000000..25ff310924 --- /dev/null +++ b/lib/browser.C @@ -0,0 +1,52 @@ +// Berkeley Open Infrastructure for Network Computing +// http://boinc.berkeley.edu +// Copyright (C) 2005 University of California +// +// This is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// either version 2.1 of the License, or (at your option) any later version. +// +// This software is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// To view the GNU Lesser General Public License visit +// http://www.gnu.org/copyleft/lesser.html +// or write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) +#include "boinc_win.h" +#endif + +#ifndef _WIN32 +#include +#endif + +#include "browser.h" + +// +// Some projects perfer to use there web sites as the primary means of setting up +// there user accounts, so walk through the various browsers looking up the +// project cookies until the projects 'Setup' cookie is found. +// +// Give preference to the default platform specific browers first before going +// to the platform independant browsers since most people don't switch from +// the default. +// +bool detect_setup_authenticator(std::string& project_url, std::string& authenticator) { +#ifdef _WIN32 + if (detect_setup_authenticator_ie(project_url, authenticator)) { + return true; + } +#endif + if (detect_setup_authenticator_firefox(project_url, authenticator)) { + return true; + } + + return false; +} + diff --git a/clientlib/win/AuthenticatorDetection.h b/lib/browser.h similarity index 61% rename from clientlib/win/AuthenticatorDetection.h rename to lib/browser.h index 6ba8ebd32b..75962282e6 100644 --- a/clientlib/win/AuthenticatorDetection.h +++ b/lib/browser.h @@ -17,6 +17,22 @@ // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -#pragma once +#ifndef _BROWSER_ +#define _BROWSER_ -EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectURL, LPTSTR szAuthenticator, LPDWORD lpdwSize); +// +// The BOINC client now supports the ability to lookup a users +// authenticator during automatic attachments via a browser +// cookie. +// + +bool detect_setup_authenticator(std::string& project_url, std::string& authenticator); + +// These functions are browser specific functions +// +#ifdef _WIN32 +bool detect_setup_authenticator_ie(std::string& project_url, std::string& authenticator); +#endif +bool detect_setup_authenticator_firefox(std::string& project_url, std::string& authenticator); + +#endif \ No newline at end of file diff --git a/lib/browser_firefox.C b/lib/browser_firefox.C new file mode 100644 index 0000000000..d19932c383 --- /dev/null +++ b/lib/browser_firefox.C @@ -0,0 +1,40 @@ +// Berkeley Open Infrastructure for Network Computing +// http://boinc.berkeley.edu +// Copyright (C) 2005 University of California +// +// This is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// either version 2.1 of the License, or (at your option) any later version. +// +// This software is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// To view the GNU Lesser General Public License visit +// http://www.gnu.org/copyleft/lesser.html +// or write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) +#include "boinc_win.h" +#endif + +#include "browser.h" + + +/** + * Detect what authenticator to use from the current users cookie cache. + * + * A project will assign an authenticator from some web based signup system as part + * of their HTTP cookie, from there we can query Internet Explorer and get the + * authenticator and use it during the attach to project wizard execution. + * + * Internet Explorer is the only browser supported at present. + **/ +bool detect_setup_authenticator_firefox(std::string& project_url, std::string& authenticator) { + return false; +} + diff --git a/clientlib/win/AuthenticatorDetection.cpp b/lib/browser_ie.C similarity index 56% rename from clientlib/win/AuthenticatorDetection.cpp rename to lib/browser_ie.C index 0948ccfd27..69378826d6 100644 --- a/clientlib/win/AuthenticatorDetection.cpp +++ b/lib/browser_ie.C @@ -18,49 +18,48 @@ // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -#include "stdafx.h" -#include "win_util.h" +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) +#include "boinc_win.h" +#endif + +#include "browser.h" -/** - * Detect what authenticator to use from the current users cookie cache. - * - * A project will assign an authenticator from some web based signup system as part - * of their HTTP cookie, from there we can query Internet Explorer and get the - * authenticator and use it during the attach to project wizard execution. - * - * Internet Explorer is the only browser supported at present. - **/ -EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectURL, LPTSTR szAuthenticator, LPDWORD lpdwSize) +// +// Detect the 'Setup' cookie in Internet Explorer by using the InternetGetCookie API. +// +// This is a Windows only browser. +// +bool detect_setup_authenticator_ie(std::string& project_url, std::string& authenticator) { - BOOL bReturnValue = FALSE; + bool bReturnValue = FALSE; BOOL bValidates = TRUE; - TCHAR szCookieBuffer[2048]; - LPTSTR pszCookieFragment = NULL; - DWORD dwSize = sizeof(szCookieBuffer)/sizeof(TCHAR); - tstring strCookieFragment; - tstring strCookieName; - tstring strCookieValue; + char szCookieBuffer[2048]; + char* pszCookieFragment = NULL; + DWORD dwSize = sizeof(szCookieBuffer)/sizeof(char); + std::string strCookieFragment; + std::string strCookieName; + std::string strCookieValue; size_t uiDelimeterLocation; - bReturnValue = InternetGetCookie(szProjectURL, NULL, szCookieBuffer, &dwSize); + bReturnValue = InternetGetCookie(project_url.c_str(), NULL, szCookieBuffer, &dwSize) == TRUE; if (bReturnValue) { // Format of cookie buffer: // 'cookie1=value1; cookie2=value2; cookie3=value3; // - pszCookieFragment = _tcstok(szCookieBuffer, _T("; ")); + pszCookieFragment = strtok(szCookieBuffer, "; "); while(pszCookieFragment) { // Convert to a std::string so we can go to town strCookieFragment = pszCookieFragment; // Extract the name & value - uiDelimeterLocation = strCookieFragment.find(_T("="), 0); + uiDelimeterLocation = strCookieFragment.find("=", 0); strCookieName = strCookieFragment.substr(0, uiDelimeterLocation); strCookieValue = strCookieFragment.substr(uiDelimeterLocation + 1); - if (tstring(_T("Setup")) == strCookieName) + if (std::string("Setup") == strCookieName) { // Perform some basic validation of the suspect authenticator // @@ -71,7 +70,7 @@ EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectUR } // If the string contains non alpha numeric characters it is invalid. - tstring::iterator it = strCookieValue.begin(); + std::string::iterator it = strCookieValue.begin(); while (it != strCookieValue.end()) { if (!_istalpha(*it) && !_istdigit(*it)) { bValidates = FALSE; @@ -79,25 +78,18 @@ EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectUR it++; } - // If validation failed, null out the Authenticator field just in case + // If validation failed, null out the authenticator just in case // somebody tries to use it, otherwise copy in the real deal. if (!bValidates) { - _tcsncpy(szAuthenticator, _T(""), *lpdwSize); - *lpdwSize = 0; + authenticator = ""; } else { - _tcsncpy(szAuthenticator, strCookieValue.c_str(), *lpdwSize); - *lpdwSize = (DWORD)_tcslen(szAuthenticator); + authenticator = strCookieValue; } } - pszCookieFragment = _tcstok(NULL, _T("; ")); + pszCookieFragment = strtok(NULL, "; "); } } - else - { - fprintf(stderr, _T("DetectSetupAuthenticator() - InternetGetCookieEx Failed. GetLastError = '%d'"), GetLastError()); - } - return bReturnValue; } diff --git a/lib/prefs.C b/lib/prefs.C index 3e5ea81905..cef401232a 100644 --- a/lib/prefs.C +++ b/lib/prefs.C @@ -120,7 +120,9 @@ void GLOBAL_PREFS::defaults() { max_bytes_sec_down = 0; cpu_usage_limit = 100; week_prefs.present = false; - + for(int i=0;i<7;i++) { + week_prefs.days[i].time_prefs.clear(); + } // don't initialize source_project, source_scheduler, // mod_time, host_specific here // since they are outside of elements, @@ -208,7 +210,7 @@ int DAY_PREFS::parse(XML_PARSER& xp) { while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) continue; if (!strcmp(tag, "/day_prefs")) { - if (day_of_week < 0 || day_of_week) return ERR_XML_PARSE; + if (day_of_week < 0 || day_of_week > 6) return ERR_XML_PARSE; return 0; } else if (xp.parse_int(tag, "day_of_week", day_of_week)) { } else if (xp.parse_double(tag, "start_hour", time_prefs.start_hour)) { @@ -558,9 +560,32 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) { if (mask.cpu_usage_limit) { f.printf(" %f\n", cpu_usage_limit); } + if (week_prefs.present) { + for(int i=0; i< 7;i++) { + DAY_PREFS dp = week_prefs.days[i]; + //write only when needed + if(dp.present && + (dp.time_prefs.start_hour != dp.time_prefs.end_hour || + dp.time_prefs.net_start_hour != dp.time_prefs.net_end_hour)) { + + f.printf(" \n"); + f.printf(" %d\n",dp.day_of_week); + if(dp.time_prefs.start_hour != dp.time_prefs.end_hour) { + f.printf(" %.02f\n",dp.time_prefs.start_hour); + f.printf(" %.02f\n",dp.time_prefs.end_hour); + } + if(dp.time_prefs.net_start_hour != dp.time_prefs.net_end_hour) { + f.printf(" %.02f\n",dp.time_prefs.net_start_hour); + f.printf(" %.02f\n",dp.time_prefs.net_end_hour); + } + f.printf(" \n"); + } + } + } f.printf("\n"); return 0; } const char *BOINC_RCSID_3fb442bb02 = "$Id$"; + diff --git a/win_build/boinc_dll.vcproj b/win_build/boinc_dll.vcproj index 1e473921fc..69f9e952b5 100644 --- a/win_build/boinc_dll.vcproj +++ b/win_build/boinc_dll.vcproj @@ -222,10 +222,6 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - @@ -292,10 +288,6 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > - - diff --git a/win_build/boinc_dll_2003.vcproj b/win_build/boinc_dll_2003.vcproj index 59f420a5a6..050ce6786e 100644 --- a/win_build/boinc_dll_2003.vcproj +++ b/win_build/boinc_dll_2003.vcproj @@ -157,9 +157,6 @@ Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> - - @@ -210,9 +207,6 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> - - diff --git a/win_build/boincmgr_curl.vcproj b/win_build/boincmgr_curl.vcproj index 516d165efb..3378f2191c 100644 --- a/win_build/boincmgr_curl.vcproj +++ b/win_build/boincmgr_curl.vcproj @@ -656,6 +656,22 @@ RelativePath="..\lib\app_ipc.h" > + + + + + + + + @@ -868,6 +884,10 @@ RelativePath="..\lib\str_util.C" > + + diff --git a/win_build/boincmgr_curl_2003.vcproj b/win_build/boincmgr_curl_2003.vcproj index 8b0289b5db..70d59c3b7b 100644 --- a/win_build/boincmgr_curl_2003.vcproj +++ b/win_build/boincmgr_curl_2003.vcproj @@ -505,6 +505,18 @@ + + + + + + + +