From 528695ce8ee34e09575176120a24fd30970426d7 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Tue, 5 Dec 2017 20:35:41 +0000 Subject: [PATCH 01/11] First win32 build of 2.0 --- src/gtk-sat-module-popup.c | 3 ++- src/main.c | 3 ++- src/tle-update.c | 6 +++++- src/trsp-update.c | 11 +++++++++-- win32/Makefile | 37 +++++++++++++++++++++---------------- win32/README | 20 ++++++++++++++++++++ win32/build-config.h | 2 +- win32/config.mk | 27 +++++++++++++-------------- win32/gdk.pc | 11 +++++++++++ win32/gpredict.exe.manifest | 2 +- win32/gpredict.rc | 8 ++++---- win32/gtk+-3.0.pc | 13 +++++++++++++ 12 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 win32/README create mode 100644 win32/gdk.pc create mode 100644 win32/gtk+-3.0.pc diff --git a/src/gtk-sat-module-popup.c b/src/gtk-sat-module-popup.c index 769789fd8..6d999b363 100644 --- a/src/gtk-sat-module-popup.c +++ b/src/gtk-sat-module-popup.c @@ -1261,10 +1261,11 @@ gboolean module_window_config_cb(GtkWidget * widget, GdkEventConfigure * event, #ifdef G_OS_WIN32 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired when the window is being maximized */ + /* PAA: going to assume this is fixed in GTK-3... if (gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_MAXIMIZED) { return FALSE; - } + } */ #endif /* don't save off-screen positioning */ diff --git a/src/main.c b/src/main.c index 664c383a1..0c174526e 100644 --- a/src/main.c +++ b/src/main.c @@ -403,10 +403,11 @@ gpredict_app_config(GtkWidget * widget, GdkEventConfigure * event, #ifdef G_OS_WIN32 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired when the window is being maximized */ + /* PAA: going to assume this is fixed in GTK-3 if (gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_MAXIMIZED) { return FALSE; - } + } */ #endif /* don't save off-screen positioning */ diff --git a/src/tle-update.c b/src/tle-update.c index 3ebfc2a9e..787b6cd17 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -23,7 +23,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ -#include #include #include #include @@ -32,6 +31,9 @@ #ifdef HAVE_CONFIG_H #include #endif +#ifdef HAVE_CURL +#include +#endif #include "compat.h" #include "gpredict-utils.h" @@ -464,6 +466,7 @@ void tle_update_from_network(gboolean silent, GtkWidget * progress, GtkWidget * label1, GtkWidget * label2) { +#ifdef HAVE_CURL static GMutex tle_in_progress; gchar *proxy = NULL; @@ -663,6 +666,7 @@ void tle_update_from_network(gboolean silent, g_free(cache); g_mutex_unlock(&tle_in_progress); +#endif } /** diff --git a/src/trsp-update.c b/src/trsp-update.c index a88a6951b..a3d231509 100644 --- a/src/trsp-update.c +++ b/src/trsp-update.c @@ -29,7 +29,6 @@ * Downloads Frequency list from SATNOGS db and exports json transponder * information into satellite files identified by catalog id */ -#include #include #include #include @@ -39,14 +38,18 @@ #include "compat.h" #include "trsp-update.h" #include "gpredict-utils.h" -#include "nxjson/nxjson.h" #include "sat-cfg.h" #include "sat-log.h" +#include "nxjson/nxjson.h" #ifdef HAVE_CONFIG_H #include #endif +#ifdef HAVE_CURL +#include +#endif + /* TRSP auto update frequency. */ typedef enum { TRSP_AUTO_UPDATE_NEVER = 0, /* No auto-update, just warn after one week. */ @@ -369,6 +372,7 @@ void trsp_update_files(gchar * input_file) /** Update MODES files from network. */ void modes_update_from_network() { +#ifdef HAVE_CURL gchar *server; gchar *proxy = NULL; gchar *modes_file; @@ -461,6 +465,7 @@ void modes_update_from_network() _("%s: Could not fetch frequency files from network"), __func__); } +#endif } /** @@ -475,6 +480,7 @@ void trsp_update_from_network(gboolean silent, GtkWidget * progress, GtkWidget * label1, GtkWidget * label2) { +#ifdef HAVE_CURL static GMutex trsp_in_progress; gchar *server; @@ -621,6 +627,7 @@ void trsp_update_from_network(gboolean silent, } g_mutex_unlock(&trsp_in_progress); +#endif } /** diff --git a/win32/Makefile b/win32/Makefile index a4fc9fb94..9e6d4e028 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -1,19 +1,20 @@ # Makefile for cross-compiling gpredict for win32 on Linux, # using mingw compiler +# configure pkg-config include config.mk +# cross-compiler prefix +MGW_PREFIX=i686-w64-mingw32- + # directories topsrc = .. -glibdir = c:/mingw/include/glib-2.0 -gcincdir = c:/mingw/include/goocanvas-1.0/ -gcsrcdir = $(topsrc)/goocanvas-0.15/src - gpreddir = $(topsrc)/src sgpsdpdir = $(gpreddir)/sgpsdp +nxjsondir = $(gpreddir)/nxjson # tools -CC = $(MGW_PREFIX)gcc -Wall -O2 -mms-bitfields -DWIN32 -Wl,-subsystem,windows +CC = $(MGW_PREFIX)gcc -Wall -O2 -mms-bitfields -DWIN32 -m32 AS = $(MGW_PREFIX)as DLLWRAP = $(MGW_PREFIX)dllwrap DLLWRAP_FLAGS = --as=$(AS) --export-all --driver-name $(CC) -s @@ -22,23 +23,24 @@ RCFLAGS = --define __WIN32__ --define __WIN95__ --define MSRC \ --define __GNUWIN32__ # libraries -GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-win32-2.0) +GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-3.0) GLIBLIB := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs glib-2.0 gthread-2.0) -GUI_LIBS = $(GTKLIBS) $(GLIBLIB) -lgoocanvas libsgpsdp.lib -lcurldll -lwinmm -lws2_32 +GOOLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs goocanvas) +GUI_LIBS = $(GTKLIBS) $(GLIBLIB) $(GOOLIBS) libsgpsdp.lib -lwinmm -lws2_32 LIBS = -lm # flags/defines -CFLAGS = -DHAVE_CONFIG_H -DHAVE_LIBCURL -DPACKAGE_LOCALE_DIR=\"/\" \ - -I. -I.. -I$(glibdir) -I$(gpreddir) -I$(gcincdir) -I$(gcsrcdir) -I$(CROSSDIR)/include -GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-win32-2.0) +GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-3.0) +GOO_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags goocanvas) +CFLAGS = -DHAVE_CONFIG_H -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) # source paths -vpath %.c $(gcsrcdir) vpath %.c $(sgpsdpdir) vpath %.c $(gpreddir) vpath %.h $(gpreddir) vpath %.h $(sgpsdpdir) -vpath %.h $(gcsrcdir) +vpath %.c $(nxjsondir) +vpath %.h $(nxjsondir) vpath %.rc $(topsrc)/win32 #### End of system configuration section. #### @@ -53,6 +55,10 @@ SGPSDPSRC = \ SGPSDPOBJ = $(SGPSDPSRC:.c=.o) +NXJSONSRC = \ + nxjson.c + +NXJSONOBJ = $(NXJSONSRC:.c=.o) GOOCANVSRC = \ goocanvasatk.c \ @@ -84,7 +90,6 @@ GPREDICTSRC = \ compat.c \ first-time.c \ gpredict-help.c \ - gpredict-url-hook.c \ gpredict-utils.c \ gtk-azel-plot.c \ gtk-event-list.c \ @@ -130,7 +135,6 @@ GPREDICTSRC = \ radio-conf.c \ rotor-conf.c \ sat-cfg.c \ - sat-debugger.c \ sat-info.c \ sat-log.c \ sat-log-browser.c \ @@ -141,9 +145,9 @@ GPREDICTSRC = \ sat-pref-debug.c \ sat-pref-formats.c \ sat-pref-general.c \ - sat-pref-help.c \ sat-pref-interfaces.c \ sat-pref-layout.c \ + sat-pref-layout-utils.c \ sat-pref-list-view.c \ sat-pref-map-view.c \ sat-pref-modules.c \ @@ -168,10 +172,11 @@ GPREDICTSRC = \ tle-tools.c \ tle-update.c \ trsp-conf.c \ + trsp-update.c GPREDICTOBJ = $(GPREDICTSRC:.c=.o) -OBJS = $(SGPSDPOBJ) $(GPREDICTOBJ) +OBJS = $(SGPSDPOBJ) $(NXJSONOBJ) $(GPREDICTOBJ) %.o: %.c $(CC) -c $(CFLAGS) $(GTK_CFLAGS) $< diff --git a/win32/README b/win32/README new file mode 100644 index 000000000..9b404dafb --- /dev/null +++ b/win32/README @@ -0,0 +1,20 @@ +### Win32 build notes ### + +# Phil Ashby, Dec 2017 + +Check config.mk for dependant packages. I recommend use of inline sed +to fix up pkg-config file prefix settings once unpacked, then fix up and +copy in gtk+-3.0.pc and gdk.pc if required. + +Compile tested on Debian 9 (stretch) using standard mingw-w64 toolchain. + +Sorry, no installer package as yet, you will need to copy out all the +binary DLLs from dependant packages along with gpredict.exe to your +target system. Then create /share/gpredict and recursively copy +in these folders: ../data ../pixmaps + +Configured to build the console version, as this usefully logs errors +to stdout, see -mconsole option in Makefile for building GUI only exe. + +Good luck! +Phlash. diff --git a/win32/build-config.h b/win32/build-config.h index b62fd1fec..6f258700a 100644 --- a/win32/build-config.h +++ b/win32/build-config.h @@ -86,7 +86,7 @@ #undef STDC_HEADERS /* Version number of package */ -#define VERSION "1.3.99" +#define VERSION "2.0.0" #define GETTEXT_PACKAGE "gpredict" diff --git a/win32/config.mk b/win32/config.mk index 2bd806b54..d05bea8fc 100644 --- a/win32/config.mk +++ b/win32/config.mk @@ -1,16 +1,15 @@ # Configuration variables governing the build of grig for win32 -# directory containing the cross tools -CROSSDIR = /mingw - -# prefix for mingw tools (e.g. i586-mingw32msvc-gcc) -#MGW_PREFIX = i586-mingw32msvc- - -# mingw include dir -MGW_INC = $(CROSSDIR)/include - -# msgfmt command for producing win32 messages file - - -# pkgconfig path -PKG_CONFIG_PATH = $(CROSSDIR)/lib/pkgconfig +# pkgconfig path, assumes goocanvas-2.0.2 and gtk+-3.10.4 win32 packages +# unpacked and paths adjusted (pkg-config files) at the same folder level +# as gpredict. Downloads used: +# +# http://ftp.gnome.org/pub/GNOME/binaries/win32/goocanvas/2.0/ +# download both: goocanvas-2.0.2-win32.zip, goocanvas-dev-2.0.2-win32.zip +# +# http://win32builder.gnome.org/gtk+-bundle_3.10.4-20131202_win32.zip +# NB: I had to create new .pc files for both gtk+-3.0.pc and gdk.pc +# (thanks GNOME for missing crucial bits out of builds). My versions +# are in this folder, and will need unpack paths inserting. + +PKG_CONFIG_PATH = $(abspath ../../goocanvas-2.0.2/lib/pkgconfig):$(abspath ../../gtk+-3.10.4/lib/pkgconfig) diff --git a/win32/gdk.pc b/win32/gdk.pc new file mode 100644 index 000000000..ff6cc62ba --- /dev/null +++ b/win32/gdk.pc @@ -0,0 +1,11 @@ +prefix=/gtk+-3.10.4 +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: Gdk +Description: Graphics Drawing Kit +Version: 3.10.4 +Requires: +Libs: -L${libdir} -lgdk-3 +Cflags: -I${includedir}/gdk-3 diff --git a/win32/gpredict.exe.manifest b/win32/gpredict.exe.manifest index 15b114e62..38ec57638 100644 --- a/win32/gpredict.exe.manifest +++ b/win32/gpredict.exe.manifest @@ -1,6 +1,6 @@ - + Gpredict: Real-time satellite tracking and orbit prediction program diff --git a/win32/gpredict.rc b/win32/gpredict.rc index 090843849..888aeaef9 100644 --- a/win32/gpredict.rc +++ b/win32/gpredict.rc @@ -7,8 +7,8 @@ A ICON "icons/gpredict-icon.ico" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 1 VERSIONINFO - FILEVERSION 1,3,99,0 - PRODUCTVERSION 1,3,99,0 + FILEVERSION 2,0,0,0 + PRODUCTVERSION 2,0,0,0 FILEOS VOS__WINDOWS32 FILETYPE VFT_APP FILESUBTYPE VFT2_UNKNOWN @@ -21,11 +21,11 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL { VALUE "CompanyName", "Alexandru Csete, OZ9AEC" VALUE "FileDescription", "Gpredict: Real-time satellite tracking and orbit prediction program" - VALUE "FileVersion", "1.3.99.0" + VALUE "FileVersion", "2.0.0.0" VALUE "InternalName", "GPredict" VALUE "LegalCopyright", "Copyright (C) 2001-2013 Alexandru Csete, OZ9AEC" VALUE "ProductName", "GPredict" - VALUE "ProductVersion", "1.3.99" + VALUE "ProductVersion", "2.0.0" } } BLOCK "VarFileInfo" diff --git a/win32/gtk+-3.0.pc b/win32/gtk+-3.0.pc new file mode 100644 index 000000000..0162690af --- /dev/null +++ b/win32/gtk+-3.0.pc @@ -0,0 +1,13 @@ +prefix=/gtk+-3.10.4 +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +gtk_binary_version=3.0.0 + +Name: GTK+ +Description: GTK+ Graphical UI Library +Version: 3.10.4 +Requires: atk cairo cairo-gobject gdk gdk-pixbuf-2.0 gio-2.0 pangocairo +Libs: -L${libdir} -lgtk-3 +Cflags: -I${includedir}/gtk-3.0 From f265a11bca681d94c7b25590c80f0116d5ed6892 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Thu, 7 Dec 2017 00:16:36 +0000 Subject: [PATCH 02/11] Autoversioning from git describe --- win32/Makefile | 22 +++++++++++++++------- win32/build-config.h | 8 +++++++- win32/config.mk | 10 ++++++++++ win32/gpredict.exe.manifest | 2 +- win32/gpredict.rc | 27 +++++++++++++++++++++------ 5 files changed, 54 insertions(+), 15 deletions(-) diff --git a/win32/Makefile b/win32/Makefile index 9e6d4e028..445529e9a 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -1,9 +1,13 @@ # Makefile for cross-compiling gpredict for win32 on Linux, # using mingw compiler -# configure pkg-config +# configure pkg-config, version from git include config.mk +# version string in C code +VERSION_SHORT = $(GITMAJ).$(GITMIN).$(GITBLD) +VERSION_LONG = $(GITMAJ).$(GITMIN).0.$(GITBLD) + # cross-compiler prefix MGW_PREFIX=i686-w64-mingw32- @@ -19,8 +23,9 @@ AS = $(MGW_PREFIX)as DLLWRAP = $(MGW_PREFIX)dllwrap DLLWRAP_FLAGS = --as=$(AS) --export-all --driver-name $(CC) -s RC = $(MGW_PREFIX)windres -RCFLAGS = --define __WIN32__ --define __WIN95__ --define MSRC \ - --define __GNUWIN32__ +# NB: .rc file create various version formats from the numbers +RCFLAGS = --define __WIN32__ --define __WIN95__ --define MSRC --define __GNUWIN32__ \ + --define VERMAJ=$(GITMAJ) --define VERMIN=$(GITMIN) --define VERBLD=$(GITBLD) # libraries GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-3.0) @@ -32,7 +37,7 @@ LIBS = -lm # flags/defines GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-3.0) GOO_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags goocanvas) -CFLAGS = -DHAVE_CONFIG_H -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) +CFLAGS = -DVERSION_SHORT=$(VERSION_SHORT) -DHAVE_CONFIG_H -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) # source paths vpath %.c $(sgpsdpdir) @@ -193,8 +198,11 @@ all: libsgpsdp.dll gpredict.exe gpredict.exe: $(OBJS) gpredict_res.o $(CC) -mconsole -mthreads -o $@ $^ $(CFLAGS) $(GTK_CFLAGS) $(LIBS) $(GUI_LIBS) -lmingwex -s -gpredict_res.o: gpredict.rc - $(RC) $(RCFLAGS) $< $@ +gpredict_res.o: gpredict.rc gpredict.exp.manifest + $(RC) $(RCFLAGS) gpredict.rc $@ + +gpredict.exp.manifest: gpredict.exe.manifest + sed -e 's/VERSION_STRL/$(VERSION_LONG)/' < $< > $@ libgoocanvas.dll: $(GOOCANVOBJ) $(CC) -shared $(CFLAGS) $(GTK_CFLAGS) $(GOOCANVOBJ) $(GTKLIBS) -lm -lmingwex \ @@ -205,7 +213,7 @@ libsgpsdp.dll: $(SGPSDPOBJ) -Wl,--enable-auto-image-base -Wl,--out-implib,libsgpsdp.lib -o libsgpsdp.dll clean: - rm -f *.o *.d *.def *.a *.lib *.dll *.exe + rm -f *.o *.d *.def *.a *.lib *.dll *.exe *.exp.manifest diff --git a/win32/build-config.h b/win32/build-config.h index 6f258700a..4408fe853 100644 --- a/win32/build-config.h +++ b/win32/build-config.h @@ -86,7 +86,13 @@ #undef STDC_HEADERS /* Version number of package */ -#define VERSION "2.0.0" +#ifdef VERSION_SHORT +#define stringify_(x) #x +#define str_(x) stringify_(x) +#define VERSION str_(VERSION_SHORT) +#else +#define VERSION "1.9.xx" +#endif #define GETTEXT_PACKAGE "gpredict" diff --git a/win32/config.mk b/win32/config.mk index d05bea8fc..3754a5bd7 100644 --- a/win32/config.mk +++ b/win32/config.mk @@ -13,3 +13,13 @@ # are in this folder, and will need unpack paths inserting. PKG_CONFIG_PATH = $(abspath ../../goocanvas-2.0.2/lib/pkgconfig):$(abspath ../../gtk+-3.10.4/lib/pkgconfig) + +# Autoversioning from nearest git tag, assumes v. tag format. + +GITVER := $(shell git describe) +GITSEP := $(subst -, ,$(GITVER)) +GITTAG := $(word 1,$(GITSEP)) +GITBLD := $(word 2,$(GITSEP)) +GITCOM := $(word 3,$(GITSEP)) +GITMAJ := $(subst v,,$(word 1,$(subst ., ,$(GITTAG)))) +GITMIN := $(word 2,$(subst ., ,$(GITTAG))) diff --git a/win32/gpredict.exe.manifest b/win32/gpredict.exe.manifest index 38ec57638..af08ea3ba 100644 --- a/win32/gpredict.exe.manifest +++ b/win32/gpredict.exe.manifest @@ -1,6 +1,6 @@ - + Gpredict: Real-time satellite tracking and orbit prediction program diff --git a/win32/gpredict.rc b/win32/gpredict.rc index 888aeaef9..b942ed4e3 100644 --- a/win32/gpredict.rc +++ b/win32/gpredict.rc @@ -3,12 +3,27 @@ #include #include "resource.h" +#if defined(VERMAJ) && defined(VERMIN) && defined(VERBLD) +// awesome, we have version info +#else +// fake it! +#define VERMAJ 1 +#define VERMIN 9 +#define VERBLD 0 +#endif + +#define stringify_(x) #x +#define str_(x) stringify_(x) +#define VERSION_RSRC VERMAJ,VERMIN,0,VERBLD +#define VERSION_STRS str_(VERMAJ) "." str_(VERMIN) "." str_(VERBLD) +#define VERSION_STRL str_(VERMAJ) "." str_(VERMIN) ".0." str_(VERBLD) + A ICON "icons/gpredict-icon.ico" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 1 VERSIONINFO - FILEVERSION 2,0,0,0 - PRODUCTVERSION 2,0,0,0 + FILEVERSION VERSION_RSRC + PRODUCTVERSION VERSION_RSRC FILEOS VOS__WINDOWS32 FILETYPE VFT_APP FILESUBTYPE VFT2_UNKNOWN @@ -21,11 +36,11 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL { VALUE "CompanyName", "Alexandru Csete, OZ9AEC" VALUE "FileDescription", "Gpredict: Real-time satellite tracking and orbit prediction program" - VALUE "FileVersion", "2.0.0.0" + VALUE "FileVersion", VERSION_STRL VALUE "InternalName", "GPredict" - VALUE "LegalCopyright", "Copyright (C) 2001-2013 Alexandru Csete, OZ9AEC" + VALUE "LegalCopyright", "Copyright (C) 2001-2017 Alexandru Csete, OZ9AEC" VALUE "ProductName", "GPredict" - VALUE "ProductVersion", "2.0.0" + VALUE "ProductVersion", VERSION_STRS } } BLOCK "VarFileInfo" @@ -35,4 +50,4 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL } LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -2 RT_MANIFEST "gpredict.exe.manifest" +2 RT_MANIFEST "gpredict.exp.manifest" From c95346a71798bac70d4d9abe645bcdf11a5a61a7 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sun, 17 Dec 2017 22:30:42 +0000 Subject: [PATCH 03/11] Removed gtk-sat-list-col-sel.c from source list --- win32/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/win32/Makefile b/win32/Makefile index 445529e9a..31b22d16b 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -109,7 +109,6 @@ GPREDICTSRC = \ gtk-sat-data.c \ gtk-sat-list.c \ gtk-sat-list-popup.c \ - gtk-sat-list-col-sel.c \ gtk-sat-map.c \ gtk-sat-map-ground-track.c \ gtk-sat-map-popup.c \ From 7722a62ed6b8602ad0c592d8d67bedbf56a3f8e1 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sat, 23 Dec 2017 22:07:01 +0000 Subject: [PATCH 04/11] Network functionality restored --- src/tle-update.c | 38 ++++++++++++++++++++++++++-- src/trsp-update.c | 61 ++++++++++++++++++++++++++++++++++++++++++--- win32/Makefile | 24 ++++++++++-------- win32/win32-fetch.c | 39 +++++++++++++++++++++++++++++ win32/win32-fetch.h | 4 +++ 5 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 win32/win32-fetch.c create mode 100644 win32/win32-fetch.h diff --git a/src/tle-update.c b/src/tle-update.c index 787b6cd17..74f78997d 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -34,6 +34,9 @@ #ifdef HAVE_CURL #include #endif +#ifdef USE_WIN32_FETCH +#include "win32-fetch.h" +#endif #include "compat.h" #include "gpredict-utils.h" @@ -44,8 +47,10 @@ /* private function prototypes */ +#ifdef HAVE_CURL static size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE * stream); +#endif static gint read_fresh_tle(const gchar * dir, const gchar * fnam, GHashTable * data); static gboolean is_tle_file(const gchar * dir, const gchar * fnam); @@ -466,7 +471,6 @@ void tle_update_from_network(gboolean silent, GtkWidget * progress, GtkWidget * label1, GtkWidget * label2) { -#ifdef HAVE_CURL static GMutex tle_in_progress; gchar *proxy = NULL; @@ -476,8 +480,13 @@ void tle_update_from_network(gboolean silent, gchar *curfile; gchar *locfile; gchar *userconfdir; +#ifdef HAVE_CURL CURL *curl; CURLcode res; +#endif +#ifdef USE_WIN32_FETCH + int res; +#endif gdouble fraction, start = 0; FILE *outfile; GDir *dir; @@ -521,6 +530,7 @@ void tle_update_from_network(gboolean silent, if (!silent && (progress != NULL)) start = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progress)); +#ifdef HAVE_CURL /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -528,13 +538,16 @@ void tle_update_from_network(gboolean silent, curl_easy_setopt(curl, CURLOPT_USERAGENT, "gpredict/curl"); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); +#endif /* get files */ for (i = 0; i < numfiles; i++) { /* set URL */ curfile = g_strdup(files[i]); +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_URL, curfile); +#endif /* set activity message */ if (!silent && (label1 != NULL)) @@ -559,6 +572,7 @@ void tle_update_from_network(gboolean silent, outfile = g_fopen(locfile, "wb"); if (outfile != NULL) { +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); @@ -578,6 +592,23 @@ void tle_update_from_network(gboolean silent, __func__, curfile); success++; } +#endif +#ifdef USE_WIN32_FETCH + res = win32_fetch(curfile, outfile, proxy, "gpredict/win32"); + if (res != 0) + { + sat_log_log(SAT_LOG_LEVEL_ERROR, + _("%s: Error fetching %s (%x)"), + __func__, curfile, res); + } + else + { + sat_log_log(SAT_LOG_LEVEL_INFO, + _("%s: Successfully fetched %s"), + __func__, curfile); + success++; + } +#endif fclose(outfile); } else @@ -607,7 +638,9 @@ void tle_update_from_network(gboolean silent, g_free(locfile); } +#ifdef HAVE_CURL curl_easy_cleanup(curl); +#endif /* continue update if we have fetched at least one file */ if (success > 0) @@ -666,9 +699,9 @@ void tle_update_from_network(gboolean silent, g_free(cache); g_mutex_unlock(&tle_in_progress); -#endif } +#ifdef HAVE_CURL /** * Write TLE data block to file. * @@ -687,6 +720,7 @@ static size_t my_write_func(void *ptr, size_t size, size_t nmemb, /*** FIXME: TBC whether this works in wintendo */ return fwrite(ptr, size, nmemb, stream); } +#endif /** * Check whether file is TLE file. diff --git a/src/trsp-update.c b/src/trsp-update.c index a3d231509..f6cfc9a0c 100644 --- a/src/trsp-update.c +++ b/src/trsp-update.c @@ -49,6 +49,9 @@ #ifdef HAVE_CURL #include #endif +#ifdef USE_WIN32_FETCH +#include "win32-fetch.h" +#endif /* TRSP auto update frequency. */ typedef enum { @@ -372,15 +375,19 @@ void trsp_update_files(gchar * input_file) /** Update MODES files from network. */ void modes_update_from_network() { -#ifdef HAVE_CURL gchar *server; gchar *proxy = NULL; gchar *modes_file; gchar *file_url; gchar *locfile; gchar *userconfdir; +#ifdef HAVE_CURL CURL *curl; CURLcode res; +#endif +#ifdef USE_WIN32_FETCH + int res; +#endif FILE *outfile; guint success = 0; /* no. of successfull downloads */ @@ -388,6 +395,7 @@ void modes_update_from_network() proxy = sat_cfg_get_str(SAT_CFG_STR_TRSP_PROXY); modes_file = sat_cfg_get_str(SAT_CFG_STR_TRSP_MODE_FILE); +#ifdef HAVE_CURL /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -395,14 +403,17 @@ void modes_update_from_network() curl_easy_setopt(curl, CURLOPT_USERAGENT, "gpredict/curl"); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); +#endif /* get files */ /* set URL */ file_url = g_strconcat(server, modes_file, NULL); +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_URL, file_url); sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Ready to fetch modes list from %s"), __func__, file_url); +#endif /* create local cache file */ userconfdir = get_user_conf_dir(); @@ -414,6 +425,7 @@ void modes_update_from_network() outfile = g_fopen(locfile, "wb"); if (outfile != NULL) { +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); @@ -431,6 +443,21 @@ void modes_update_from_network() __func__, file_url); success++; } +#endif +#ifdef USE_WIN32_FETCH + res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); + if (res != 0) + { + sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), + __func__, file_url, res); + } + else + { + sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), + __func__, file_url); + success++; + } +#endif fclose(outfile); } @@ -447,7 +474,9 @@ void modes_update_from_network() g_free(proxy); g_free(modes_file); +#ifdef HAVE_CURL curl_easy_cleanup(curl); +#endif /* continue update if we have fetched at least one file */ if (success > 0) @@ -465,7 +494,6 @@ void modes_update_from_network() _("%s: Could not fetch frequency files from network"), __func__); } -#endif } /** @@ -480,7 +508,6 @@ void trsp_update_from_network(gboolean silent, GtkWidget * progress, GtkWidget * label1, GtkWidget * label2) { -#ifdef HAVE_CURL static GMutex trsp_in_progress; gchar *server; @@ -489,8 +516,13 @@ void trsp_update_from_network(gboolean silent, gchar *file_url; gchar *locfile_trsp; gchar *userconfdir; +#ifdef HAVE_CURL CURL *curl; CURLcode res; +#endif +#ifdef USE_WIN32_FETCH + int res; +#endif gdouble fraction; FILE *outfile; gchar *cache; @@ -516,6 +548,7 @@ void trsp_update_from_network(gboolean silent, proxy = sat_cfg_get_str(SAT_CFG_STR_TRSP_PROXY); freq_file = sat_cfg_get_str(SAT_CFG_STR_TRSP_FREQ_FILE); +#ifdef HAVE_CURL /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -523,14 +556,17 @@ void trsp_update_from_network(gboolean silent, curl_easy_setopt(curl, CURLOPT_USERAGENT, "gpredict/curl"); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); +#endif /* get files */ /* set URL */ file_url = g_strconcat(server, freq_file, NULL); +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_URL, file_url); sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Ready to fetch transponder list from %s"), __func__, file_url); +#endif /* set activity message */ if (!silent && (label1 != NULL)) @@ -558,6 +594,7 @@ void trsp_update_from_network(gboolean silent, outfile = g_fopen(locfile_trsp, "wb"); if (outfile != NULL) { +#ifdef HAVE_CURL curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); @@ -575,6 +612,21 @@ void trsp_update_from_network(gboolean silent, __func__, file_url); success++; } +#endif +#ifdef USE_WIN32_FETCH + res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); + if (res != 0) + { + sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), + __func__, file_url, res); + } + else + { + sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), + __func__, file_url); + success++; + } +#endif fclose(outfile); } @@ -606,7 +658,9 @@ void trsp_update_from_network(gboolean silent, g_free(freq_file); g_free(proxy); +#ifdef HAVE_CURL curl_easy_cleanup(curl); +#endif /* continue update if we have fetched at least one file */ if (success > 0) @@ -627,7 +681,6 @@ void trsp_update_from_network(gboolean silent, } g_mutex_unlock(&trsp_in_progress); -#endif } /** diff --git a/win32/Makefile b/win32/Makefile index 31b22d16b..30bc083fc 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -31,13 +31,13 @@ RCFLAGS = --define __WIN32__ --define __WIN95__ --define MSRC --define __GNUWIN3 GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-3.0) GLIBLIB := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs glib-2.0 gthread-2.0) GOOLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs goocanvas) -GUI_LIBS = $(GTKLIBS) $(GLIBLIB) $(GOOLIBS) libsgpsdp.lib -lwinmm -lws2_32 +GUI_LIBS = $(GTKLIBS) $(GLIBLIB) $(GOOLIBS) libsgpsdp.lib -lwinmm -lwininet -lws2_32 LIBS = -lm # flags/defines GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-3.0) GOO_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags goocanvas) -CFLAGS = -DVERSION_SHORT=$(VERSION_SHORT) -DHAVE_CONFIG_H -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) +CFLAGS = -DVERSION_SHORT=$(VERSION_SHORT) -DHAVE_CONFIG_H -DUSE_WIN32_FETCH -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) # source paths vpath %.c $(sgpsdpdir) @@ -47,6 +47,7 @@ vpath %.h $(sgpsdpdir) vpath %.c $(nxjsondir) vpath %.h $(nxjsondir) vpath %.rc $(topsrc)/win32 +vpath %.c . #### End of system configuration section. #### @@ -97,8 +98,8 @@ GPREDICTSRC = \ gpredict-help.c \ gpredict-utils.c \ gtk-azel-plot.c \ - gtk-event-list.c \ - gtk-event-list-popup.c \ + gtk-event-list.c \ + gtk-event-list-popup.c \ gtk-freq-knob.c \ gtk-polar-plot.c \ gtk-polar-view.c \ @@ -176,7 +177,8 @@ GPREDICTSRC = \ tle-tools.c \ tle-update.c \ trsp-conf.c \ - trsp-update.c + trsp-update.c \ + win32-fetch.c GPREDICTOBJ = $(GPREDICTSRC:.c=.o) @@ -189,13 +191,15 @@ OBJS = $(SGPSDPOBJ) $(NXJSONOBJ) $(GPREDICTOBJ) # targets begin -all: libsgpsdp.dll gpredict.exe - +all: libsgpsdp.dll gpredict.exe gpredict-con.exe # Use -mconsole to always open a console window when gpredicxt is started -# Use -mwindows for no copnsole -gpredict.exe: $(OBJS) gpredict_res.o - $(CC) -mconsole -mthreads -o $@ $^ $(CFLAGS) $(GTK_CFLAGS) $(LIBS) $(GUI_LIBS) -lmingwex -s +# Use -mwindows for no console +gpredict.exe: TARGET:=-mwindows +gpredict-con.exe: TARGET:=-mconsole + +gpredict.exe gpredict-con.exe: $(OBJS) gpredict_res.o + $(CC) $(TARGET) -mthreads -o $@ $^ $(CFLAGS) $(GTK_CFLAGS) $(LIBS) $(GUI_LIBS) -lmingwex -s gpredict_res.o: gpredict.rc gpredict.exp.manifest $(RC) $(RCFLAGS) gpredict.rc $@ diff --git a/win32/win32-fetch.c b/win32/win32-fetch.c new file mode 100644 index 000000000..b8da6a067 --- /dev/null +++ b/win32/win32-fetch.c @@ -0,0 +1,39 @@ +// Fetch URL content to a specified handle using Wininet as no libcurl +// dev libs available for Win32/64. +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "win32-fetch.h" + +int win32_fetch(char *url, FILE *file, char *proxy, char *ua) +{ + HINTERNET hInt; + if (proxy != NULL) + hInt = InternetOpen(ua, INTERNET_OPEN_TYPE_PROXY, proxy, "", 0); + else + hInt = InternetOpen(ua, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + if (NULL == hInt) + return 0x80000000 | (int)GetLastError(); + + HINTERNET hUrl = InternetOpenUrl(hInt, url, NULL, 0, INTERNET_FLAG_RELOAD, 0); + if (NULL == hUrl) + { + InternetCloseHandle(hInt); + return 0x40000000 | (int)GetLastError(); + } + + char buf[8192]; + DWORD nRead; + while (InternetReadFile(hUrl, buf, 8192, &nRead)) + { + if (nRead > 0) + fwrite(buf, nRead, 1, file); + else + break; + } + InternetCloseHandle(hUrl); + InternetCloseHandle(hInt); + return 0; +} + diff --git a/win32/win32-fetch.h b/win32/win32-fetch.h new file mode 100644 index 000000000..9087fc952 --- /dev/null +++ b/win32/win32-fetch.h @@ -0,0 +1,4 @@ +// @see win32_fetch.c + +extern int win32_fetch(char *url, FILE *file, char *proxy, char *ua); + From 3622709746f96c75df5011cdb470691db6a87730 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sun, 24 Dec 2017 17:57:00 +0000 Subject: [PATCH 05/11] C-89 compatible variables --- win32/win32-fetch.c | 40 ++++++++++++++++++++++++++++++++++------ win32/win32-fetch.h | 26 +++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/win32/win32-fetch.c b/win32/win32-fetch.c index b8da6a067..2351b1474 100644 --- a/win32/win32-fetch.c +++ b/win32/win32-fetch.c @@ -1,5 +1,32 @@ -// Fetch URL content to a specified handle using Wininet as no libcurl -// dev libs available for Win32/64. +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2017 Alexandru Csete, OZ9AEC. + Copyright (C) 2017 Phil Ashby, 2E0IPX. + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ + + + Fetch URL content to a specified handle using Wininet as no libcurl + dev libs available for Win32/64. +*/ #define WIN32_LEAN_AND_MEAN #include #include @@ -8,7 +35,10 @@ int win32_fetch(char *url, FILE *file, char *proxy, char *ua) { - HINTERNET hInt; + HINTERNET hInt, hUrl; + char buf[8192]; + DWORD nRead; + if (proxy != NULL) hInt = InternetOpen(ua, INTERNET_OPEN_TYPE_PROXY, proxy, "", 0); else @@ -16,15 +46,13 @@ int win32_fetch(char *url, FILE *file, char *proxy, char *ua) if (NULL == hInt) return 0x80000000 | (int)GetLastError(); - HINTERNET hUrl = InternetOpenUrl(hInt, url, NULL, 0, INTERNET_FLAG_RELOAD, 0); + hUrl = InternetOpenUrl(hInt, url, NULL, 0, INTERNET_FLAG_RELOAD, 0); if (NULL == hUrl) { InternetCloseHandle(hInt); return 0x40000000 | (int)GetLastError(); } - char buf[8192]; - DWORD nRead; while (InternetReadFile(hUrl, buf, 8192, &nRead)) { if (nRead > 0) diff --git a/win32/win32-fetch.h b/win32/win32-fetch.h index 9087fc952..2e8d5ea30 100644 --- a/win32/win32-fetch.h +++ b/win32/win32-fetch.h @@ -1,4 +1,28 @@ -// @see win32_fetch.c +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2017 Alexandru Csete, OZ9AEC. + Copyright (C) 2017 Phil Ashby, 2E0IPX. + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ extern int win32_fetch(char *url, FILE *file, char *proxy, char *ua); From 6fc34251d35bcbdfe6ea1bd45b3fd38f45746d8b Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sun, 24 Dec 2017 17:57:42 +0000 Subject: [PATCH 06/11] New build target to create deployable ZIP archive: dist --- win32/Makefile | 16 +++++++++++++--- win32/config.mk | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/win32/Makefile b/win32/Makefile index 30bc083fc..db80a761e 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -193,6 +193,17 @@ OBJS = $(SGPSDPOBJ) $(NXJSONOBJ) $(GPREDICTOBJ) all: libsgpsdp.dll gpredict.exe gpredict-con.exe +dist: gpredict-$(GITMAJ).$(GITMIN).$(GITBLD).zip + +gpredict-$(GITMAJ).$(GITMIN).$(GITBLD).zip: all + mkdir -p gpredict/share/gpredict + cp -p libsgpsdp.dll gpredict.exe gpredict-con.exe $(BINDEPS) gpredict + cp -rp ../data gpredict/share/gpredict + cp -rp ../pixmaps gpredict/share/gpredict + cp -rp ../po gpredict/share/gpredict + zip -r $@ gpredict + rm -rf gpredict + # Use -mconsole to always open a console window when gpredicxt is started # Use -mwindows for no console gpredict.exe: TARGET:=-mwindows @@ -216,7 +227,6 @@ libsgpsdp.dll: $(SGPSDPOBJ) -Wl,--enable-auto-image-base -Wl,--out-implib,libsgpsdp.lib -o libsgpsdp.dll clean: - rm -f *.o *.d *.def *.a *.lib *.dll *.exe *.exp.manifest - - + rm -f *.o *.d *.def *.a *.lib *.dll *.exe *.exp.manifest *.zip + rm -rf gpredict diff --git a/win32/config.mk b/win32/config.mk index 3754a5bd7..f73510bcf 100644 --- a/win32/config.mk +++ b/win32/config.mk @@ -1,4 +1,4 @@ -# Configuration variables governing the build of grig for win32 +# Configuration variables governing the build of gpredict for win32 # pkgconfig path, assumes goocanvas-2.0.2 and gtk+-3.10.4 win32 packages # unpacked and paths adjusted (pkg-config files) at the same folder level @@ -14,6 +14,9 @@ PKG_CONFIG_PATH = $(abspath ../../goocanvas-2.0.2/lib/pkgconfig):$(abspath ../../gtk+-3.10.4/lib/pkgconfig) +# binary dependencies to be deployed with gpredict.exe +BINDEPS = $(wildcard ../../goocanvas-2.0.2/bin/*.dll) $(wildcard ../../gtk+-3.10.4/bin/*.dll) + # Autoversioning from nearest git tag, assumes v. tag format. GITVER := $(shell git describe) From 1af211ec19bef7c50e5acb8ed2701428ab4691af Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sun, 24 Dec 2017 18:01:01 +0000 Subject: [PATCH 07/11] Fix up README --- win32/README | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/win32/README b/win32/README index 9b404dafb..d7184f1f4 100644 --- a/win32/README +++ b/win32/README @@ -8,13 +8,9 @@ copy in gtk+-3.0.pc and gdk.pc if required. Compile tested on Debian 9 (stretch) using standard mingw-w64 toolchain. -Sorry, no installer package as yet, you will need to copy out all the -binary DLLs from dependant packages along with gpredict.exe to your -target system. Then create /share/gpredict and recursively copy -in these folders: ../data ../pixmaps - -Configured to build the console version, as this usefully logs errors -to stdout, see -mconsole option in Makefile for building GUI only exe. +To build a deployable ZIP archive, use 'make dist', which packages all +binary DLLs from dependant packages along with gpredict[-con].exe into +a versioned ZIP. Good luck! Phlash. From 72258fa2b73fc026c8064a7b906474a043400c28 Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Sun, 24 Dec 2017 23:51:23 +0000 Subject: [PATCH 08/11] Either win32-fetch or curl, not both --- src/tle-update.c | 45 +++++++++++----------- src/trsp-update.c | 91 +++++++++++++++++++++------------------------ win32/Makefile | 2 +- win32/win32-fetch.c | 6 ++- 4 files changed, 69 insertions(+), 75 deletions(-) diff --git a/src/tle-update.c b/src/tle-update.c index 74f78997d..7cdaeb96e 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -31,11 +31,10 @@ #ifdef HAVE_CONFIG_H #include #endif -#ifdef HAVE_CURL -#include -#endif -#ifdef USE_WIN32_FETCH +#ifdef WIN32 #include "win32-fetch.h" +#else +#include #endif #include "compat.h" @@ -480,12 +479,11 @@ void tle_update_from_network(gboolean silent, gchar *curfile; gchar *locfile; gchar *userconfdir; -#ifdef HAVE_CURL +#ifdef WIN32 + int res; +#else CURL *curl; CURLcode res; -#endif -#ifdef USE_WIN32_FETCH - int res; #endif gdouble fraction, start = 0; FILE *outfile; @@ -572,18 +570,13 @@ void tle_update_from_network(gboolean silent, outfile = g_fopen(locfile, "wb"); if (outfile != NULL) { -#ifdef HAVE_CURL - curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); - - /* get file */ - res = curl_easy_perform(curl); - - if (res != CURLE_OK) +#ifdef WIN32 + res = win32_fetch(curfile, outfile, proxy, "gpredict/win32"); + if (res != 0) { sat_log_log(SAT_LOG_LEVEL_ERROR, - _("%s: Error fetching %s (%s)"), - __func__, curfile, curl_easy_strerror(res)); + _("%s: Error fetching %s (%x)"), + __func__, curfile, res); } else { @@ -592,14 +585,18 @@ void tle_update_from_network(gboolean silent, __func__, curfile); success++; } -#endif -#ifdef USE_WIN32_FETCH - res = win32_fetch(curfile, outfile, proxy, "gpredict/win32"); - if (res != 0) +#else + curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); + + /* get file */ + res = curl_easy_perform(curl); + + if (res != CURLE_OK) { sat_log_log(SAT_LOG_LEVEL_ERROR, - _("%s: Error fetching %s (%x)"), - __func__, curfile, res); + _("%s: Error fetching %s (%s)"), + __func__, curfile, curl_easy_strerror(res)); } else { diff --git a/src/trsp-update.c b/src/trsp-update.c index 24177614e..d329ecc32 100644 --- a/src/trsp-update.c +++ b/src/trsp-update.c @@ -46,11 +46,10 @@ #include #endif -#ifdef HAVE_CURL -#include -#endif -#ifdef USE_WIN32_FETCH +#ifdef WIN32 #include "win32-fetch.h" +#else +#include #endif /* TRSP auto update frequency. */ @@ -393,12 +392,11 @@ void modes_update_from_network() gchar *file_url; gchar *locfile; gchar *userconfdir; -#ifdef HAVE_CURL +#ifdef WIN32 + int res; +#else CURL *curl; CURLcode res; -#endif -#ifdef USE_WIN32_FETCH - int res; #endif FILE *outfile; guint success = 0; /* no. of successfull downloads */ @@ -407,7 +405,7 @@ void modes_update_from_network() proxy = sat_cfg_get_str(SAT_CFG_STR_TRSP_PROXY); modes_file = sat_cfg_get_str(SAT_CFG_STR_TRSP_MODE_FILE); -#ifdef HAVE_CURL +#ifndef WIN32 /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -420,7 +418,7 @@ void modes_update_from_network() /* get files */ /* set URL */ file_url = g_strconcat(server, modes_file, NULL); -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_setopt(curl, CURLOPT_URL, file_url); sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Ready to fetch modes list from %s"), @@ -437,7 +435,20 @@ void modes_update_from_network() outfile = g_fopen(locfile, "wb"); if (outfile != NULL) { -#ifdef HAVE_CURL +#ifdef WIN32 + res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); + if (res != 0) + { + sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), + __func__, file_url, res); + } + else + { + sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), + __func__, file_url); + success++; + } +#else curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); @@ -455,20 +466,6 @@ void modes_update_from_network() __func__, file_url); success++; } -#endif -#ifdef USE_WIN32_FETCH - res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); - if (res != 0) - { - sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), - __func__, file_url, res); - } - else - { - sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), - __func__, file_url); - success++; - } #endif fclose(outfile); @@ -486,7 +483,7 @@ void modes_update_from_network() g_free(proxy); g_free(modes_file); -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_cleanup(curl); #endif @@ -528,12 +525,11 @@ void trsp_update_from_network(gboolean silent, gchar *file_url; gchar *locfile_trsp; gchar *userconfdir; -#ifdef HAVE_CURL +#ifdef WIN32 + int res; +#else CURL *curl; CURLcode res; -#endif -#ifdef USE_WIN32_FETCH - int res; #endif gdouble fraction; FILE *outfile; @@ -562,7 +558,7 @@ void trsp_update_from_network(gboolean silent, proxy = sat_cfg_get_str(SAT_CFG_STR_TRSP_PROXY); freq_file = sat_cfg_get_str(SAT_CFG_STR_TRSP_FREQ_FILE); -#ifdef HAVE_CURL +#ifndef WIN32 /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -575,7 +571,7 @@ void trsp_update_from_network(gboolean silent, /* get files */ /* set URL */ file_url = g_strconcat(server, freq_file, NULL); -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_setopt(curl, CURLOPT_URL, file_url); sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Ready to fetch transponder list from %s"), @@ -608,7 +604,20 @@ void trsp_update_from_network(gboolean silent, outfile = g_fopen(locfile_trsp, "wb"); if (outfile != NULL) { -#ifdef HAVE_CURL +#ifdef WIN32 + res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); + if (res != 0) + { + sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), + __func__, file_url, res); + } + else + { + sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), + __func__, file_url); + success++; + } +#else curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); @@ -626,20 +635,6 @@ void trsp_update_from_network(gboolean silent, __func__, file_url); success++; } -#endif -#ifdef USE_WIN32_FETCH - res = win32_fetch(file_url, outfile, proxy, "gpredict/win32"); - if (res != 0) - { - sat_log_log(SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%x)"), - __func__, file_url, res); - } - else - { - sat_log_log(SAT_LOG_LEVEL_INFO, _("%s: Successfully fetched %s"), - __func__, file_url); - success++; - } #endif fclose(outfile); @@ -672,7 +667,7 @@ void trsp_update_from_network(gboolean silent, g_free(freq_file); g_free(proxy); -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_cleanup(curl); #endif diff --git a/win32/Makefile b/win32/Makefile index db80a761e..97ac61957 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -37,7 +37,7 @@ LIBS = -lm # flags/defines GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-3.0) GOO_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags goocanvas) -CFLAGS = -DVERSION_SHORT=$(VERSION_SHORT) -DHAVE_CONFIG_H -DUSE_WIN32_FETCH -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) +CFLAGS = -DVERSION_SHORT=$(VERSION_SHORT) -DHAVE_CONFIG_H -DPACKAGE_LOCALE_DIR=\"/\" -I. -I.. -I$(gpreddir) $(GOO_CFLAGS) # source paths vpath %.c $(sgpsdpdir) diff --git a/win32/win32-fetch.c b/win32/win32-fetch.c index 2351b1474..a03bd4bb6 100644 --- a/win32/win32-fetch.c +++ b/win32/win32-fetch.c @@ -33,10 +33,12 @@ #include #include "win32-fetch.h" +#define BUFLEN 8192 + int win32_fetch(char *url, FILE *file, char *proxy, char *ua) { HINTERNET hInt, hUrl; - char buf[8192]; + char buf[BUFLEN]; DWORD nRead; if (proxy != NULL) @@ -53,7 +55,7 @@ int win32_fetch(char *url, FILE *file, char *proxy, char *ua) return 0x40000000 | (int)GetLastError(); } - while (InternetReadFile(hUrl, buf, 8192, &nRead)) + while (InternetReadFile(hUrl, buf, BUFLEN, &nRead)) { if (nRead > 0) fwrite(buf, nRead, 1, file); From 7154ff6bd46f9ab0bdbc7b2a421a7075a138c71f Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Mon, 25 Dec 2017 00:03:43 +0000 Subject: [PATCH 09/11] build fix: missed some HAVE_CURL bits --- src/tle-update.c | 10 +++++----- src/trsp-update.c | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tle-update.c b/src/tle-update.c index 7cdaeb96e..652eda28e 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -46,7 +46,7 @@ /* private function prototypes */ -#ifdef HAVE_CURL +#ifndef WIN32 static size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE * stream); #endif @@ -528,7 +528,7 @@ void tle_update_from_network(gboolean silent, if (!silent && (progress != NULL)) start = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progress)); -#ifdef HAVE_CURL +#ifndef WIN32 /* initialise curl */ curl = curl_easy_init(); if (proxy != NULL) @@ -543,7 +543,7 @@ void tle_update_from_network(gboolean silent, { /* set URL */ curfile = g_strdup(files[i]); -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_setopt(curl, CURLOPT_URL, curfile); #endif @@ -635,7 +635,7 @@ void tle_update_from_network(gboolean silent, g_free(locfile); } -#ifdef HAVE_CURL +#ifndef WIN32 curl_easy_cleanup(curl); #endif @@ -698,7 +698,7 @@ void tle_update_from_network(gboolean silent, g_mutex_unlock(&tle_in_progress); } -#ifdef HAVE_CURL +#ifndef WIN32 /** * Write TLE data block to file. * diff --git a/src/trsp-update.c b/src/trsp-update.c index d329ecc32..117332b67 100644 --- a/src/trsp-update.c +++ b/src/trsp-update.c @@ -94,9 +94,11 @@ typedef struct { guint numtrsp; /* Number of transponders. */ } new_trsp_t; +#ifndef WIN32 /* private function prototypes */ static size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE * stream); +#endif //int getMODElist_intoHashMap(); @@ -692,6 +694,7 @@ void trsp_update_from_network(gboolean silent, g_mutex_unlock(&trsp_in_progress); } +#ifndef WIN32 /** * Write TRSP data block to file. * @@ -710,6 +713,7 @@ static size_t my_write_func(void *ptr, size_t size, size_t nmemb, /*** FIXME: TBC whether this works in wintendo */ return fwrite(ptr, size, nmemb, stream); } +#endif const gchar *freq_to_str2[TRSP_AUTO_UPDATE_NUM] = { N_("Never"), From 4b3d661f2faa73d013c452a6e38275da6763fa8e Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Thu, 28 Dec 2017 21:07:25 +0000 Subject: [PATCH 10/11] Remove sat-pref-layout-utils.c from build --- win32/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/win32/Makefile b/win32/Makefile index 97ac61957..674e74e02 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -152,7 +152,6 @@ GPREDICTSRC = \ sat-pref-general.c \ sat-pref-interfaces.c \ sat-pref-layout.c \ - sat-pref-layout-utils.c \ sat-pref-list-view.c \ sat-pref-map-view.c \ sat-pref-modules.c \ From 01449679e3d101c4e3eefabead0a87b015ba99aa Mon Sep 17 00:00:00 2001 From: Phil Ashby Date: Fri, 29 Dec 2017 00:56:54 +0000 Subject: [PATCH 11/11] Additional runtime files --- win32/Makefile | 5 +++++ win32/config.mk | 12 +++++++++++- win32/loaders.cache | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 win32/loaders.cache diff --git a/win32/Makefile b/win32/Makefile index 674e74e02..845c8843c 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -200,6 +200,11 @@ gpredict-$(GITMAJ).$(GITMIN).$(GITBLD).zip: all cp -rp ../data gpredict/share/gpredict cp -rp ../pixmaps gpredict/share/gpredict cp -rp ../po gpredict/share/gpredict + mkdir -p gpredict/$(LOADERS) + cp -p loaders.cache gpredict/$(LOADERS) + cp -rp $(GTKETC) gpredict + mkdir -p gpredict/share/glib-2.0 + cp -rp $(SCHEMAS) gpredict/share/glib-2.0 zip -r $@ gpredict rm -rf gpredict diff --git a/win32/config.mk b/win32/config.mk index f73510bcf..d47e02bfd 100644 --- a/win32/config.mk +++ b/win32/config.mk @@ -15,7 +15,17 @@ PKG_CONFIG_PATH = $(abspath ../../goocanvas-2.0.2/lib/pkgconfig):$(abspath ../../gtk+-3.10.4/lib/pkgconfig) # binary dependencies to be deployed with gpredict.exe -BINDEPS = $(wildcard ../../goocanvas-2.0.2/bin/*.dll) $(wildcard ../../gtk+-3.10.4/bin/*.dll) +BINDEPS = \ + $(wildcard ../../goocanvas-2.0.2/bin/*.dll) \ + $(wildcard ../../gtk+-3.10.4/bin/*.dll) \ + ../../gtk+-3.10.4/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.dll + +# where to put the loaders.cache file +LOADERS = lib/gdk-pixbuf-2.0/2.10.0 + +# other miscellaneous folders to deploy with the binary +GTKETC = ../../gtk+-3.10.4/etc +SCHEMAS = ../../gtk+-3.10.4/share/glib-2.0/schemas # Autoversioning from nearest git tag, assumes v. tag format. diff --git a/win32/loaders.cache b/win32/loaders.cache new file mode 100644 index 000000000..80c0b05b2 --- /dev/null +++ b/win32/loaders.cache @@ -0,0 +1,14 @@ +# GdkPixbuf Image Loader Modules file +# Automatically generated file, do not edit +# Created by gdk-pixbuf-query-loaders.exe from gdk-pixbuf-2.30.1 +# +# LoaderDir = Z:\srv\win32builder\fixed_3104\build\win32/lib/gdk-pixbuf-2.0/2.10.0/loaders +# +"libpixbufloader-svg.dll" +"svg" 2 "gdk-pixbuf" "Scalable Vector Graphics" "LGPL" +"image/svg+xml" "image/svg" "image/svg-xml" "image/vnd.adobe.svg+xml" "text/xml-svg" "image/svg+xml-compressed" "" +"svg" "svgz" "svg.gz" "" +"