[Gpredict-svn] SF.net SVN: gpredict:[199] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2009-03-16 20:33:19
|
Revision: 199 http://gpredict.svn.sourceforge.net/gpredict/?rev=199&view=rev Author: csete Date: 2009-03-16 20:32:52 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Applied patch 2688135: Gio port of TLE updater (thanks Bruce Cowan). Modified Paths: -------------- trunk/ChangeLog trunk/NEWS trunk/README trunk/configure.ac trunk/src/about.c trunk/src/menubar.c trunk/src/tle-update.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/ChangeLog 2009-03-16 20:32:52 UTC (rev 199) @@ -1,3 +1,20 @@ +2009-03-16 Bruce Cowan <bc...@fa...> + + * src/menubar.c: + * src/tle-update.c: + Port TLE download to GIO. + + * configure.ac: + * README: + Remove references to libcurl, add GIO dependency, and bump GLib + requirement. + + * src/about.c: + Updated credits. + + * NEWS: + Updated. + 2009-03-01; Alexandru Csete <oz...@gm...> * configure.ac: Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/NEWS 2009-03-16 20:32:52 UTC (rev 199) @@ -17,6 +17,7 @@ - Fixed bug 2139102: rigctld port. - Fixed bug 2130912: Crash when no rig or no rotator are defined. - Fixed bug 2170642: Small error in user manual. +- Applied patch 2688135: Use GIO instead of libcurl for TLE download. x Windows: New installer instead of ZIP distribution. - Updated PDF user manual. - French translation. Modified: trunk/README =================================================================== --- trunk/README 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/README 2009-03-16 20:32:52 UTC (rev 199) @@ -49,7 +49,6 @@ for successful compilation of Gpredict: - Gtk+ 2.12 or later -- Curl and libcurl (optional but highly recommended) - Hamlib (runtime only, not required for build) If you compile Gpredict from source you will also need the development parts Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/configure.ac 2009-03-16 20:32:52 UTC (rev 199) @@ -21,24 +21,11 @@ fi dnl check for glib, gtk, and goocanvas libraries -pkg_modules="gtk+-2.0 >= 2.12.0 glib-2.0 >= 2.14.0 gthread-2.0 >= 2.14.0 goocanvas >= 0.9" +pkg_modules="gtk+-2.0 >= 2.12.0 glib-2.0 >= 2.16.0 gio-2.0 >= 2.16.0 gthread-2.0 >= 2.14.0 goocanvas >= 0.9" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) - -dnl check for libcurl -PKG_CHECK_MODULES(LIBCURL, libcurl, [ - CFLAGS="$CFLAGS $LIBCURL_CFLAGS"; - LIBS="$LIBS $LIBCURL_LIBS"; - havecurl=true; - AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) - ], [ - havecurl=false; - AC_DEFINE(HAVE_LIBCURL, 0, [Define if libcurl is unvailable]) - -]) - dnl Hamlib not needed if we go for the TCP based I/F dnl check for hamlib dnl PKG_CHECK_MODULES(HAMLIB, hamlib, [ @@ -73,14 +60,12 @@ GLIB_V=`pkg-config --modversion glib-2.0` +GIO_V=`pkg-config --modversion gio-2.0` GTHR_V=`pkg-config --modversion gthread-2.0` GDK_V=`pkg-config --modversion gdk-2.0` GTK_V=`pkg-config --modversion gtk+-2.0` GOOC_V=`pkg-config --modversion goocanvas` dnl SQL_V=`pkg-config --modversion sqlite3` -if test "$havecurl" = true ; then - CURL_V=`pkg-config --modversion libcurl` -fi dnl if test "$havehamlib" = true ; then dnl HAML_V=`pkg-config --modversion hamlib` dnl fi @@ -110,16 +95,12 @@ echo echo Gpredict version... : $VERSION echo Glib version....... : $GLIB_V +echo Gio version........ : $GIO_V echo Gthread version.... : $GTHR_V echo Gdk version........ : $GDK_V echo Gtk+ version....... : $GTK_V echo GooCanvas version.. : $GOOC_V dnl echo SQLite version..... : $SQL_V -if test "$havecurl" = true ; then -echo Curl version....... : $CURL_V -else -echo Curl version....... : none -fi dnl if test "$havehamlib" = true ; then dnl echo Hamlib version..... : $HAML_V dnl else Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/src/about.c 2009-03-16 20:32:52 UTC (rev 199) @@ -36,20 +36,21 @@ const gchar *authors[] = { - "Alexandru Csete, OZ9AEC (design and development)", - "", - "Contributors:", - "Damon Chaplin (GooCanvas)", - "Dr. T.S. Kelso (SGP4/SDP4 algorithms)", - "John A. Magliacane, KD2BD (prediction code)", - "Neoklis Kyriazis, 5B4AZ (SGP4/SDP4 in C)", - "William J Beksi, KC2EXL (GtkSatMap)", - "Stephane Fillod (locator.c)", - "Nate Bargmann (locator.c)", - "Dave Hines (locator.c)", - "Mirko Caserta (locator.c)", - "S. R. Sampson (locator.c)", - NULL + "Alexandru Csete, OZ9AEC (design and development)", + "", + "Contributors:", + "Bruce Cowan (Gio port of TLE updater)", + "Damon Chaplin (GooCanvas)", + "Dr. T.S. Kelso (SGP4/SDP4 algorithms)", + "John A. Magliacane, KD2BD (prediction code)", + "Neoklis Kyriazis, 5B4AZ (SGP4/SDP4 in C)", + "William J Beksi, KC2EXL (GtkSatMap)", + "Stephane Fillod (locator.c)", + "Nate Bargmann (locator.c)", + "Dave Hines (locator.c)", + "Mirko Caserta (locator.c)", + "S. R. Sampson (locator.c)", + NULL }; Modified: trunk/src/menubar.c =================================================================== --- trunk/src/menubar.c 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/src/menubar.c 2009-03-16 20:32:52 UTC (rev 199) @@ -436,7 +436,6 @@ menubar_tle_net_cb (GtkWidget *widget, gpointer data) { GtkWidget *dialog; /* dialog window */ -#if HAVE_LIBCURL GtkWidget *label; /* misc labels */ GtkWidget *progress; /* progress indicator */ GtkWidget *label1,*label2; /* activitity and stats labels */ @@ -514,24 +513,6 @@ /* reload satellites */ mod_mgr_reload_sats (); - -#else - - dialog = gtk_message_dialog_new (GTK_WINDOW (app), - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("This version of gpredict has been compiled "\ - "without network support. Therefore, TLE update "\ - "from network is not available.\n\n"\ - "Consult the user manual for details.")); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - -#endif - } Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-03-01 11:09:38 UTC (rev 198) +++ trunk/src/tle-update.c 2009-03-16 20:32:52 UTC (rev 199) @@ -32,9 +32,7 @@ #ifdef HAVE_CONFIG_H # include <build-config.h> #endif -#if HAVE_LIBCURL -# include <curl/curl.h> -#endif +#include <gio/gio.h> #include "sgpsdp/sgp4sdp4.h" #include "sat-log.h" #include "sat-cfg.h" @@ -58,7 +56,6 @@ static gchar *tle_to_gchar (tle_type_t type, tle_t *tle); #endif -static size_t my_write_func (void *ptr, size_t size, size_t nmemb, FILE *stream); static gint read_fresh_tle (const gchar *dir, const gchar *fnam, GHashTable *data); static void update_tle_in_file (const gchar *ldname, @@ -414,20 +411,16 @@ GtkWidget *label1, GtkWidget *label2) { - -#if HAVE_LIBCURL gchar *server; - gchar *proxy = NULL; gchar *files_tmp; gchar **files; guint numfiles,i; gchar *curfile; gchar *locfile; - CURL *curl; - CURLcode res; + GFile *file; gboolean error = FALSE; gdouble fraction,start=0; - FILE *outfile; + GFile *outfile; GDir *dir; gchar *cache; const gchar *fname; @@ -443,9 +436,8 @@ tle_in_progress = TRUE; - /* get server, proxy, and list of files */ + /* get server and list of files */ server = sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER); - proxy = sat_cfg_get_str (SAT_CFG_STR_TLE_PROXY); files_tmp = sat_cfg_get_str (SAT_CFG_STR_TLE_FILES); files = g_strsplit (files_tmp, ";", 0); numfiles = g_strv_length (files); @@ -467,20 +459,13 @@ if (!silent && (progress != NULL)) start = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress)); - /* initialise curl */ - curl = curl_easy_init(); - if (proxy != NULL) - curl_easy_setopt (curl, CURLOPT_PROXY, proxy); - curl_easy_setopt (curl, CURLOPT_USERAGENT, "gpredict/curl"); - curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 10); - /* get files */ for (i = 0; i < numfiles; i++) { /* set URL */ curfile = g_strconcat (server, files[i], NULL); - curl_easy_setopt (curl, CURLOPT_URL, curfile); + file = g_file_new_for_uri (curfile); /* set activity message */ if (!silent && (label1 != NULL)) { @@ -502,18 +487,15 @@ "tle", G_DIR_SEPARATOR_S, "cache", G_DIR_SEPARATOR_S, files[i], NULL); - outfile = g_fopen (locfile, "wb"); - curl_easy_setopt (curl, CURLOPT_WRITEDATA, outfile); - curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, my_write_func); + outfile = g_file_new_for_path (locfile); - /* get file */ - res = curl_easy_perform (curl); + g_file_copy (file, outfile, G_FILE_COPY_NONE, NULL, NULL, NULL, &err); - if (res != CURLE_OK) { + if (error) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%s)"), - __FUNCTION__, curfile, curl_easy_strerror (res)); - error = TRUE; + __FUNCTION__, curfile, err->message); + g_clear_error (&err); } else { sat_log_log (SAT_LOG_LEVEL_MSG, @@ -539,11 +521,8 @@ g_free (curfile); g_free (locfile); - fclose (outfile); } - curl_easy_cleanup (curl); - /* continue update if we have fetched at least one file */ if (success > 0) { /* call update_from_files */ @@ -561,8 +540,6 @@ g_free (server); g_strfreev (files); g_free (files_tmp); - if (proxy != NULL) - g_free (proxy); /* open cache */ cache = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, @@ -596,36 +573,9 @@ /* clear busy flag */ tle_in_progress = FALSE; - -#else - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: This version of gpredict has been compiled without network support.\n" - "To update TLE data, download NASA 2-line files manually, then run Update from files."), - __FUNCTION__); -#endif - } -/** \brief Write TLE data block to file. - * \param ptr Pointer to the data block to be written. - * \param size Size of data block. - * \param nmemb Size multiplier? - * \param stream Pointer to the file handle. - * \return The number of bytes actually written. - * - * This function writes the received data to the file pointed to by stream. - * It is used as write callback by to curl exec function. - */ -static size_t -my_write_func (void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - /*** FIXME: TBC whether this works in wintendo */ - return fwrite (ptr, size, nmemb, stream); -} - - - /** \brief Read fresh TLE data into hash table. * \param dir The directory to read from. * \param fnam The name of the file to read from. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |