Commit dc138512 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser() now returns empty string on abort.

GITHUB_PLUGIN uses redirected URL to remove one HTTP hit time.
parent 5821d4bc
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -503,11 +503,12 @@ public:
                                   wxDC*           aDC = NULL );
                                   wxDC*           aDC = NULL );


    /**
    /**
     * SelectFootprintFromLibBrowser
     * Function SelectFootprintFromLibBrowser
     * Launch the footprint viewer to select the name of a footprint to load.
     * launches the footprint viewer to select the name of a footprint to load.
     * @return the selected footprint name
     *
     * @return the selected footprint name or an empty string if no selection was made.
     */
     */
    wxString SelectFootprintFromLibBrowser( void );
    wxString SelectFootprintFromLibBrowser();


    /**
    /**
     * Function GetFootprintLibraryTable
     * Function GetFootprintLibraryTable
+22 −7
Original line number Original line Diff line number Diff line
@@ -36,8 +36,10 @@
    remote pretty libraries.  If you want to support writing to the repo, then you
    remote pretty libraries.  If you want to support writing to the repo, then you
    could use the above API.
    could use the above API.


@todo:  Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
@todo:

    Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
    Support local footprints if they are present in an optional directory.
    Possibly cache the zip file locally.  Use HTTP's "have changed" or whatever it is called.
*/
*/


#ifdef WIN32
#ifdef WIN32
@@ -53,7 +55,6 @@
#include <wx/zipstrm.h>
#include <wx/zipstrm.h>
#include <wx/mstream.h>
#include <wx/mstream.h>
#include <wx/uri.h>
#include <wx/uri.h>
//#include <wx/strconv.h>


#include <fctsys.h>
#include <fctsys.h>
// Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h
// Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h
@@ -247,10 +248,24 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
        // goal: "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
        // goal: "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
        wxString    zip_url( wxT( "https://" ) );
        wxString    zip_url( wxT( "https://" ) );


#if 0   // Github issues a redirect for this "master.zip".  i.e.
        //  "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
        // would be redirected to:
        //  "https://codeload.github.com/liftoff-sr/pretty_footprints/zip/master"

        // The alternate code path below uses the redirected URL on first attempt
        // to save one HTTP GET hit.  avhttp does the redirect behind the scenes normally.

        zip_url += repo.GetServer();
        zip_url += repo.GetServer();
        zip_url += repo.GetPath();
        zip_url += repo.GetPath();
        zip_url += wxT( '/' );
        zip_url += wxT( '/' );
        zip_url += wxT( "archive/master.zip" );
        zip_url += wxT( "archive/master.zip" );
#else
        zip_url += wxT( "codeload.github.com" );
        zip_url += repo.GetPath();
        zip_url += wxT( '/' );
        zip_url += wxT( "zip/master" );
#endif


        *aZipURL = zip_url.utf8_str();
        *aZipURL = zip_url.utf8_str();
        return true;
        return true;
+14 −10
Original line number Original line Diff line number Diff line
@@ -110,13 +110,12 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
    return true;
    return true;
}
}


/*

 * Launch the footprint viewer to select the name of a footprint to load.
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
 * return the selected footprint name
 */
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
{
{
    wxString    fpname;
    wxString    fpname;
    wxString    fpid;

    wxSemaphore semaphore( 0, 1 );
    wxSemaphore semaphore( 0, 1 );


    // Close the current Lib browser, if opened, and open a new one, in "modal" mode:
    // Close the current Lib browser, if opened, and open a new one, in "modal" mode:
@@ -135,17 +134,22 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
        wxMilliSleep( 50 );
        wxMilliSleep( 50 );
    }
    }


    fpname = viewer->GetSelectedFootprint();

    if( !!fpname )
    {
#if !defined( USE_FP_LIB_TABLE )
#if !defined( USE_FP_LIB_TABLE )
    // Returns the full fp name, i.e. the lib name and th fp name,
        // Returns the full fp name, i.e. the lib name and the fp name,
        // separated by a '/' (/ is now an illegal char in fp names)
        // separated by a '/' (/ is now an illegal char in fp names)
    fpname = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + viewer->GetSelectedFootprint();
        fpid = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + fpname;
#else
#else
    fpname = viewer->GetSelectedLibrary() + wxT( ":" ) + viewer->GetSelectedFootprint();
        fpid = viewer->GetSelectedLibrary() + wxT( ":" ) + fpname;
#endif
#endif
    }


    viewer->Destroy();
    viewer->Destroy();


    return fpname;
    return fpid;
}
}