Author: toad
Date: 2005-11-09 15:03:58 +0000 (Wed, 09 Nov 2005)
New Revision: 7501

Modified:
   trunk/contrib/wininstall/Sources/NodeConfig/ConfigFile.cpp
   trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.cpp
   trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.h
   trunk/contrib/wininstall/Sources/NodeConfig/PropNormal.cpp
Log:
Apply Bob's patch to wininstaller, since rapidsvn wasn't working for him.

Modified: trunk/contrib/wininstall/Sources/NodeConfig/ConfigFile.cpp
===================================================================
--- trunk/contrib/wininstall/Sources/NodeConfig/ConfigFile.cpp  2005-11-08 
16:02:24 UTC (rev 7500)
+++ trunk/contrib/wininstall/Sources/NodeConfig/ConfigFile.cpp  2005-11-09 
15:03:58 UTC (rev 7501)
@@ -725,11 +725,12 @@
                        case 'E':       v *= 1073741824;        v *= 1024;      
break;
                        case 'k':       v /= 1000;                              
                break;
                        //
-                       // N.B : If the below cases fail to compile with 
+                       // Bob H note : If the below cases fail to compile with 
                        // "error C2520: conversion from unsigned __int64 to 
double not implemented, use signed __int64"
                        // in VS6 then you need VS service pack 5 (NOT 6!) and 
the 'Processor Pack'.
-                       // 
http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/sp5_en.aspx
-                       // 
http://msdn.microsoft.com/vstudio/downloads/tools/ppack/download.aspx           
             
+                       // 
http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.aspx
+                       // 
http://msdn.microsoft.com/vstudio/downloads/tools/ppack/
+
                        case 'm':       v =  (DWORDLONG)(float(v)*0.9765625);   
break;
                        case 'g':       v =  (DWORDLONG)(float(v)*976.5625);    
break;
                        case 't':       v =  (DWORDLONG)(float(v)*976562.5);    
break;

Modified: trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.cpp
===================================================================
--- trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.cpp  2005-11-08 
16:02:24 UTC (rev 7500)
+++ trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.cpp  2005-11-09 
15:03:58 UTC (rev 7501)
@@ -82,63 +82,114 @@
        DWORD written;


+
        // DCH 26 Sep 2002: now uses run-time linking to WinInet instead of 
load-time linking
        // Solves NodeConfig program not running on base-level Win95 boxes.
+
        typedef BOOL (WINAPI *fnINTERNETGETCONNECTEDSTATE)(LPDWORD lpdwFlags, 
DWORD dwReserved);
+
        typedef BOOL (WINAPI *fnINTERNETAUTODIAL)(DWORD dwFlags, DWORD 
dwReserved);
+
        typedef BOOL (WINAPI *fnINTERNETAUTODIALHANGUP)(DWORD dwReserved);
+
        typedef HINTERNET (WINAPI *fnINTERNETOPEN)(LPCSTR lpszAgent, DWORD 
dwAccessType, LPCSTR lpszProxyName, LPCSTR lpszProxyBypass, DWORD dwFlags);
+
        typedef HINTERNET (WINAPI *fnINTERNETOPENURL)(HINTERNET 
hInternetSession, LPCSTR lpszUrl, LPCSTR lpszHeaders, DWORD dwHeadersLength, 
DWORD dwFlags, DWORD dwContext);
+
        typedef BOOL (WINAPI *fnHTTPQUERYINFO)(HINTERNET hHttpRequest, DWORD 
dwInfoLevel, LPVOID lpvBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex);
+
        typedef BOOL (WINAPI *fnINTERNETREADFILE)(HINTERNET hFile, LPVOID 
lpBuffer, DWORD dwNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead);
+
        typedef BOOL (WINAPI *fnINTERNETCLOSEHANDLE)(HINTERNET hInet);

+
+
        HINSTANCE hWinInet = LoadLibrary("WinInet.DLL");
+
        if (hWinInet==NULL)
+
        {
+
                str.LoadString(IDS_ERR_NOWININET);
+
                MessageBox(str,NULL,MB_OK|MB_ICONERROR);
+
                return;
+
 //             return FALSE;
+
        }

+
+
        fnINTERNETGETCONNECTEDSTATE pInternetGetConnectedState = 
(fnINTERNETGETCONNECTEDSTATE)GetProcAddress(hWinInet, 
"InternetGetConnectedState");
+
        if (pInternetGetConnectedState==NULL) pInternetGetConnectedState = 
(fnINTERNETGETCONNECTEDSTATE)GetProcAddress(hWinInet, 
"InternetGetConnectedStateA");
+
        fnINTERNETAUTODIAL pInternetAutodial = 
(fnINTERNETAUTODIAL)GetProcAddress(hWinInet, "InternetAutodial");
+
        if (pInternetAutodial==NULL) pInternetAutodial = 
(fnINTERNETAUTODIAL)GetProcAddress(hWinInet, "InternetAutodialA");
+
        fnINTERNETAUTODIALHANGUP pInternetAutodialHangup = 
(fnINTERNETAUTODIALHANGUP)GetProcAddress(hWinInet, "InternetAutodialHangup");
+
        if (pInternetAutodialHangup==NULL) pInternetAutodialHangup = 
(fnINTERNETAUTODIALHANGUP)GetProcAddress(hWinInet, "InternetAutodialHangupA");
+
        fnINTERNETOPEN pInternetOpen = (fnINTERNETOPEN)GetProcAddress(hWinInet, 
"InternetOpen");
+
        if (pInternetOpen==NULL) pInternetOpen = 
(fnINTERNETOPEN)GetProcAddress(hWinInet, "InternetOpenA");
+
        fnINTERNETOPENURL pInternetOpenUrl = 
(fnINTERNETOPENURL)GetProcAddress(hWinInet, "InternetOpenUrl");
+
        if (pInternetOpenUrl==NULL) pInternetOpenUrl = 
(fnINTERNETOPENURL)GetProcAddress(hWinInet, "InternetOpenUrlA");
+
        fnHTTPQUERYINFO pHttpQueryInfo = 
(fnHTTPQUERYINFO)GetProcAddress(hWinInet, "HttpQueryInfo");
+
        if (pHttpQueryInfo==NULL) pHttpQueryInfo = 
(fnHTTPQUERYINFO)GetProcAddress(hWinInet, "HttpQueryInfoA");
+
        fnINTERNETREADFILE pInternetReadFile = 
(fnINTERNETREADFILE)GetProcAddress(hWinInet, "InternetReadFile");
+
        if (pInternetReadFile==NULL) pInternetReadFile = 
(fnINTERNETREADFILE)GetProcAddress(hWinInet, "InternetReadFileA");
+
        fnINTERNETCLOSEHANDLE pInternetCloseHandle = 
(fnINTERNETCLOSEHANDLE)GetProcAddress(hWinInet, "InternetCloseHandle");
+
        if (pInternetCloseHandle==NULL) pInternetCloseHandle = 
(fnINTERNETCLOSEHANDLE)GetProcAddress(hWinInet, "InternetCloseHandleA");

+
+
        if (pInternetOpen==NULL || pInternetOpenUrl==NULL || 
pHttpQueryInfo==NULL || pInternetReadFile==NULL || pInternetCloseHandle==NULL)
+
        {
+
                // exit if the 'vital' APIs aren't available.
+
                str.LoadString(IDS_ERR_NOWININET);
+
                MessageBox(str,NULL,MB_OK|MB_ICONERROR);
+
                FreeLibrary(hWinInet);
+
                hWinInet=NULL;
+
                return;
+
 //             return FALSE;
+
        }


+
+
        //InternetGetConnectedState returns FALSE if there is no Internet 
connection
        if ((pInternetGetConnectedState == NULL) || 
(pInternetGetConnectedState(&dwFlags,0)==FALSE) )
        {
                str.LoadString(IDS_NOTCONNECTED);
                if (MessageBox(str,NULL,MB_OKCANCEL) == IDCANCEL)
                {
+
                        //abort the download and quit the function
+
                        FreeLibrary(hWinInet);
+
                        hWinInet=NULL;
                        return;
 //                     return FALSE;
@@ -146,43 +197,91 @@
                doDialUp = TRUE;
        }

+
        UpdateData(TRUE);
        hInternet = pInternetOpen(AfxGetApp()->m_pszAppName, 
INTERNET_OPEN_TYPE_PRECONFIG , NULL, NULL, NULL /*dwFlags*/); // returns NULL 
on failure
+
        if (hInternet) hhttpFile = pInternetOpenUrl(hInternet, m_seedURL, NULL, 
NULL, INTERNET_FLAG_NO_UI|INTERNET_FLAG_NO_COOKIES, NULL); //return FAIL on 
error
        if (hhttpFile)
+
        {
+
                success = 
pHttpQueryInfo(hhttpFile,HTTP_QUERY_CONTENT_LENGTH|HTTP_QUERY_FLAG_NUMBER,(LPVOID)&filesize,&fsize_bufsize,NULL);
                if (success && filesize)
                {       //Set progress bar control step size
                        m_dloadprogressbar.SetStep((int)(100*512/filesize));
                }
                success = ((hfile = CreateFile(m_seedfile, GENERIC_WRITE, 0, 0, 
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) && success;
+
                while (success)
+
                {
                        success = pInternetReadFile(hhttpFile, buf, 512, &read) 
&& success;
+
                        if (success && read==0) break;
                        success = WriteFile(hfile, buf, read, &written, 0) && 
success;
                        success = (written == read) && success;
                        if (filesize && written && success) 
m_dloadprogressbar.StepIt();
+
                };
+
        }

+
        // Cleanup now
        if (hhttpFile) pInternetCloseHandle(hhttpFile); // close the remote 
http file
        if (hInternet) pInternetCloseHandle(hInternet); // close the Internet 
handle
+
        if (doDialUp && pInternetAutodialHangup) {pInternetAutodialHangup(0);}

+
+
        if (hfile) CloseHandle(hfile);
+
 //     FreeLibrary(hWinInet);  // Microsoft bug - calling FreeLibrary on 
WinInet.DLL causes application to hang!
+
        hWinInet=NULL;

+
        if (success)
                EndDialog(1);
        else
        {
                DeleteFile(m_seedfile);
-               str.LoadString(IDS_ERR_GETSEED);
-               MessageBox(str,NULL,MB_OK|MB_ICONERROR);
+               //      str.LoadString(IDS_ERR_GETSEED);
+               //      MessageBox(str,NULL,MB_OK|MB_ICONERROR);
+
+               // Seednode mirror sites
+               CString strSFSeednodesMirror = 
"http://freenetproject.org/snapshots/seednodes.ref";;
+               CString strEmuSeednodesMirror = 
"http://emu.freenetproject.org/downloads/seednodes/seednodes.ref";;
+               
+               // Bob H : Download has failed for some reason.
+               // If not using SourceForge mirror, offer to retry with it
+               if( m_seedURL.Find( strEmuSeednodesMirror ) > -1 )
+               {
+                       CString strPrompt = "Downloading seednodes from site #1 
failed.\n";
+                       strPrompt += "Would you like to try switching to a 
mirror site?\n";
+                       if( IDYES == AfxMessageBox( strPrompt, 
MB_YESNO|MB_ICONQUESTION ) )
+                       {
+                               m_seedURL = strSFSeednodesMirror;
+                               UpdateData( false );
+                               AfxMessageBox("Switched to mirror site 
#2.\nPress \"Download References\" to start.");
+                       }
+               }
+
+               // Converse (SourceForge --> Emu) ... obviously this logic only 
works for 2 mirror sites
+               else if( m_seedURL.Find( strSFSeednodesMirror ) > -1 )
+               {
+                       CString strPrompt = "Downloading seednodes from site #2 
failed.\n";
+                       strPrompt += "Would you like to try switching to a 
mirror site?\n";
+                       if( IDYES == AfxMessageBox( strPrompt, 
MB_YESNO|MB_ICONQUESTION ) )
+                       {
+                               m_seedURL = strEmuSeednodesMirror;
+                               UpdateData( false );
+                               AfxMessageBox("Switched to mirror site 
#1.\nPress \"Download References\" to start.");
+                       }
+               }
+
        }
        return;
 //     return success;

Modified: trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.h
===================================================================
--- trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.h    2005-11-08 
16:02:24 UTC (rev 7500)
+++ trunk/contrib/wininstall/Sources/NodeConfig/GetSeedDlg.h    2005-11-09 
15:03:58 UTC (rev 7501)
@@ -8,7 +8,9 @@
 #pragma once
 #endif // _MSC_VER > 1000

-#define DEFSEEDURL "http://freenetproject.org/snapshots/seednodes.ref";
+//#define DEFSEEDURL "http://freenetproject.org/snapshots/seednodes.ref";
+// Bob H : GetSeed is rarely used now, so use Emu mirror with fallback to 
SourceForge since Emu is faster / reliable
+#define DEFSEEDURL 
"http://emu.freenetproject.org/downloads/seednodes/seednodes.ref";
 #define DEFSEEDFILE "seednodes.ref"

 /////////////////////////////////////////////////////////////////////////////

Modified: trunk/contrib/wininstall/Sources/NodeConfig/PropNormal.cpp
===================================================================
--- trunk/contrib/wininstall/Sources/NodeConfig/PropNormal.cpp  2005-11-08 
16:02:24 UTC (rev 7500)
+++ trunk/contrib/wininstall/Sources/NodeConfig/PropNormal.cpp  2005-11-09 
15:03:58 UTC (rev 7501)
@@ -18,6 +18,7 @@
 static char THIS_FILE[] = __FILE__;
 #endif

+
 //extern CDlgWarnPerm          *pWarnPerm;
 extern CPropAdvanced   *pAdvanced;

@@ -183,9 +184,39 @@
 {
        if (m_useDefaultNodeRefs)
        {
-               CGetSeedDlg Getseeddlg(TRUE);
+               // Bob H : We get here if NodeConfig can't find a seednodes.ref 
.
+               // Used to be Getseeddlg(TRUE) which put Getseeddlg in "silent 
mode", where it automatically downloads seednodes.
+               // At least on win2k and XP this doesn't work correctly, the 
dialog never inits properly and is invisible,
+               // so I changed it to FALSE; user now has to press the download 
button. Also, it didn't use to prompt if they wanted
+               // to download. This caused a long-standing "hanging" problem 
during install after OK'ing the initial NodeConfig,
+               // because NodeConfig.exe was initially in a different 
directory to where the installer downloaded the seednodes
+               // and therefore always invisibly downloaded them AGAIN itself! 
(I fixed this in the wininstaller.)
+               // This happened even when the user chose NOT to download 
seednodes because they already had some e.g. from a friend,
+               // not a good thing (hi freenet-china.) For extra fun recently 
SourceForge has been randomly throttling big 
+               // freenetproject.org downloads to 0.2Kb/s - 0.3Kb/s, making 
the invisible download hang the installer for HOURS.
+
+               CString prompt = "The Freenet node configuration utility 
couldn't find \"seednodes.ref\".";
+               prompt += "\nThis file is needed for freenet to work\n(it 
provides it with addresses";
+               prompt += " of other nodes to connect to initially.)\n\n";
+               prompt += "** If you chose NOT to download seednodes.ref, this 
is normal! **\n";
+               prompt += "Please answer NO to this, place your seednodes.ref 
in the directory\n";
+               prompt += "where freenet is installed (e.g. c:\\Program 
Files\\Freenet)";
+               prompt += "\nand then run Freenet.\n\n";  // because compressed 
so it should be faster, even though dl jars too
+               prompt += "We recommend you try \"Update Snapshot\" (once 
Freenet is\n";
+               prompt += "installed) to fix this.\n";
+               prompt += "Answer NO, then do Start->Programs->Freenet->Update 
Snapshot.\n\n";
+               prompt += "If that doesn't work, I can try to download the 
seednodes myself.\n";
+               prompt += "Do you want me to try to download them myself now?";
+
+               if( IDYES == AfxMessageBox( prompt, MB_YESNO|MB_ICONQUESTION ) )
+               {
+                       // Cheesey I know ... presumably some way to trigger 
download that works properly
+                       AfxMessageBox("Please press \"Download References\" on 
the next screen.\nThe download may take a while.",
+                                                                               
                MB_OK|MB_ICONINFORMATION );
+                       CGetSeedDlg Getseeddlg(FALSE);
                Getseeddlg.DoModal();
        }
+       }

        if (m_pGeek)
        {


Reply via email to