From 79bf710fbcbc6d2d64b6c4008238b04306cbadff Mon Sep 17 00:00:00 2001 From: csete Date: Tue, 14 Apr 2009 21:06:51 +0000 Subject: [PATCH] Reverted TLE updater to libcurl instead of GIO (was patch 2688135, see reason in comments). git-svn-id: https://gpredict.svn.sourceforge.net/svnroot/gpredict/trunk@268 ab6734ba-2843-0410-b83b-99c217ef6c0f --- ChangeLog | 11 + NEWS | 2 - README | 2 +- configure.ac | 5 +- src/sat-cfg.c | 926 ++++++++++++++++++------------------ src/sat-cfg.h | 184 ++++---- src/sat-pref-tle.c | 369 ++++++++------- src/tle-update.c | 1122 +++++++++++++++++++++++--------------------- 8 files changed, 1348 insertions(+), 1273 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb65463..aeceb3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-04-14 Alexandru Csete + + * configure.ac: + Require libcur 7.16.0 or later as mandatory dependency. + + * src/tle-update.c: + * src/sat-cfg.[ch]: + * src/sat-pref-tle.c: + Reverted TLE update to libcurl version. + + 2009-04-13 Alexandru Csete * src/predict-tools.c: diff --git a/NEWS b/NEWS index 17a6753..c98b88a 100644 --- a/NEWS +++ b/NEWS @@ -20,8 +20,6 @@ Changes in version 1.0 beta 2 (TBD Apr 2009): - Fixed bug 2130914: Gpredict doesn't handle PTT. - Fixed bug 2170642: Small error in user manual. - Fixed bug 2750119: Unable to set the time correctly in Time Controller. -- Applied patch 2688135: Use GIO instead of libcurl for TLE download. - Note: This removes proxy management from gpredict. - Updated PDF user manual. - French translation. diff --git a/README b/README index fdeef70..a66737c 100644 --- a/README +++ b/README @@ -45,7 +45,7 @@ for successful compilation of Gpredict: - Gtk+ 2.12 or later - GLib 2.16 or later -- Gio 2.16 or later (including gvfs) +- Libcurl 7.16.0 or later - GooCanvas 0.9 or later - Hamlib (runtime only, not required for build) diff --git a/configure.ac b/configure.ac index 0e70248..bbecedc 100644 --- a/configure.ac +++ b/configure.ac @@ -21,11 +21,12 @@ if test "${ac_cv_c_compiler_gnu}" = "yes"; then fi dnl check for glib, gtk, and goocanvas libraries -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_modules="gtk+-2.0 >= 2.12.0 glib-2.0 >= 2.16.0 gthread-2.0 >= 2.14.0 goocanvas >= 0.9 libcurl >= 7.16.0" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) + dnl Hamlib not needed if we go for the TCP based I/F dnl check for hamlib dnl PKG_CHECK_MODULES(HAMLIB, hamlib, [ @@ -65,6 +66,7 @@ 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` +CURL_V=`pkg-config --modversion libcurl` dnl SQL_V=`pkg-config --modversion sqlite3` dnl if test "$havehamlib" = true ; then dnl HAML_V=`pkg-config --modversion hamlib` @@ -100,6 +102,7 @@ echo Gthread version.... : $GTHR_V echo Gdk version........ : $GDK_V echo Gtk+ version....... : $GTK_V echo GooCanvas version.. : $GOOC_V +echo Liburl version..... : $CURL_V dnl echo SQLite version..... : $SQL_V dnl if test "$havehamlib" = true ; then dnl echo Hamlib version..... : $HAML_V diff --git a/src/sat-cfg.c b/src/sat-cfg.c index 6d95bd2..a357f2f 100644 --- a/src/sat-cfg.c +++ b/src/sat-cfg.c @@ -47,176 +47,178 @@ #define LIST_COLUMNS_DEFAULTS (SAT_LIST_FLAG_NAME |\ - SAT_LIST_FLAG_AZ |\ - SAT_LIST_FLAG_EL |\ - SAT_LIST_FLAG_RANGE |\ - SAT_LIST_FLAG_DIR |\ - SAT_LIST_FLAG_NEXT_EVENT |\ - SAT_LIST_FLAG_ALT |\ - SAT_LIST_FLAG_ORBIT) + SAT_LIST_FLAG_AZ |\ + SAT_LIST_FLAG_EL |\ + SAT_LIST_FLAG_RANGE |\ + SAT_LIST_FLAG_DIR |\ + SAT_LIST_FLAG_NEXT_EVENT |\ + SAT_LIST_FLAG_ALT |\ + SAT_LIST_FLAG_ORBIT) #define SINGLE_PASS_COL_DEFAULTS (SINGLE_PASS_FLAG_TIME |\ - SINGLE_PASS_FLAG_AZ |\ - SINGLE_PASS_FLAG_EL |\ - SINGLE_PASS_FLAG_RANGE |\ - SINGLE_PASS_FLAG_FOOTPRINT) + SINGLE_PASS_FLAG_AZ |\ + SINGLE_PASS_FLAG_EL |\ + SINGLE_PASS_FLAG_RANGE |\ + SINGLE_PASS_FLAG_FOOTPRINT) #define MULTI_PASS_COL_DEFAULTS (MULTI_PASS_FLAG_AOS_TIME |\ - MULTI_PASS_FLAG_LOS_TIME |\ - MULTI_PASS_FLAG_DURATION |\ - MULTI_PASS_FLAG_AOS_AZ |\ - MULTI_PASS_FLAG_MAX_EL |\ - MULTI_PASS_FLAG_LOS_AZ) + MULTI_PASS_FLAG_LOS_TIME |\ + MULTI_PASS_FLAG_DURATION |\ + MULTI_PASS_FLAG_AOS_AZ |\ + MULTI_PASS_FLAG_MAX_EL |\ + MULTI_PASS_FLAG_LOS_AZ) #define SINGLE_SAT_FIELD_DEF (SINGLE_SAT_FLAG_AZ |\ SINGLE_SAT_FLAG_EL |\ - SINGLE_SAT_FLAG_RANGE |\ - SINGLE_SAT_FLAG_RANGE_RATE |\ - SINGLE_SAT_FLAG_NEXT_EVENT |\ - SINGLE_SAT_FLAG_SSP |\ - SINGLE_SAT_FLAG_FOOTPRINT |\ - SINGLE_SAT_FLAG_ALT |\ - SINGLE_SAT_FLAG_VEL |\ - SINGLE_SAT_FLAG_DOPPLER |\ - SINGLE_SAT_FLAG_LOSS |\ - SINGLE_SAT_FLAG_DELAY |\ - SINGLE_SAT_FLAG_MA |\ - SINGLE_SAT_FLAG_PHASE |\ - SINGLE_SAT_FLAG_ORBIT |\ - SINGLE_SAT_FLAG_VISIBILITY) + SINGLE_SAT_FLAG_RANGE |\ + SINGLE_SAT_FLAG_RANGE_RATE |\ + SINGLE_SAT_FLAG_NEXT_EVENT |\ + SINGLE_SAT_FLAG_SSP |\ + SINGLE_SAT_FLAG_FOOTPRINT |\ + SINGLE_SAT_FLAG_ALT |\ + SINGLE_SAT_FLAG_VEL |\ + SINGLE_SAT_FLAG_DOPPLER |\ + SINGLE_SAT_FLAG_LOSS |\ + SINGLE_SAT_FLAG_DELAY |\ + SINGLE_SAT_FLAG_MA |\ + SINGLE_SAT_FLAG_PHASE |\ + SINGLE_SAT_FLAG_ORBIT |\ + SINGLE_SAT_FLAG_VISIBILITY) /** \brief Structure representing a boolean value */ typedef struct { - gchar *group; /*!< The configration group */ - gchar *key; /*!< The configuration key */ - gboolean defval; /*!< The default value */ + gchar *group; /*!< The configration group */ + gchar *key; /*!< The configuration key */ + gboolean defval; /*!< The default value */ } sat_cfg_bool_t; /** \brief Structure representing an integer value */ typedef struct { - gchar *group; /*!< The configration group */ - gchar *key; /*!< The configuration key */ - gint defval; /*!< The default value */ + gchar *group; /*!< The configration group */ + gchar *key; /*!< The configuration key */ + gint defval; /*!< The default value */ } sat_cfg_int_t; /** \brief Structure representing a string value */ typedef struct { - gchar *group; /*!< The configration group */ - gchar *key; /*!< The configuration key */ - gchar *defval; /*!< The default value */ + gchar *group; /*!< The configration group */ + gchar *key; /*!< The configuration key */ + gchar *defval; /*!< The default value */ } sat_cfg_str_t; /** \brief Array containing the boolean configuration values */ sat_cfg_bool_t sat_cfg_bool[SAT_CFG_BOOL_NUM] = { - { "GLOBAL", "USE_LOCAL_TIME", FALSE}, - { "GLOBAL", "USE_NSEW", FALSE}, - { "GLOBAL", "USE_IMPERIAL", FALSE}, - { "GLOBAL", "MAIN_WIN_POS", FALSE}, - { "GLOBAL", "MOD_WIN_POS", FALSE}, + { "GLOBAL", "USE_LOCAL_TIME", FALSE}, + { "GLOBAL", "USE_NSEW", FALSE}, + { "GLOBAL", "USE_IMPERIAL", FALSE}, + { "GLOBAL", "MAIN_WIN_POS", FALSE}, + { "GLOBAL", "MOD_WIN_POS", FALSE}, { "GLOBAL", "MOD_STATE", FALSE}, - { "MODULES", "RULES_HINT", TRUE}, - { "MODULES", "MAP_QTH_INFO", TRUE}, - { "MODULES", "MAP_NEXT_EVENT", TRUE}, - { "MODULES", "MAP_CURSOR_TRACK", FALSE}, - { "MODULES", "MAP_SHOW_GRID", FALSE}, - { "MODULES", "MAP_KEEP_RATIO", FALSE}, - { "MODULES", "POLAR_QTH_INFO", TRUE}, - { "MODULES", "POLAR_NEXT_EVENT", TRUE}, - { "MODULES", "POLAR_CURSOR_TRACK", TRUE}, + { "MODULES", "RULES_HINT", TRUE}, + { "MODULES", "MAP_QTH_INFO", TRUE}, + { "MODULES", "MAP_NEXT_EVENT", TRUE}, + { "MODULES", "MAP_CURSOR_TRACK", FALSE}, + { "MODULES", "MAP_SHOW_GRID", FALSE}, + { "MODULES", "MAP_KEEP_RATIO", FALSE}, + { "MODULES", "POLAR_QTH_INFO", TRUE}, + { "MODULES", "POLAR_NEXT_EVENT", TRUE}, + { "MODULES", "POLAR_CURSOR_TRACK", TRUE}, { "MODULES", "POLAR_EXTRA_AZ_TICKS", FALSE}, { "TLE", "SERVER_AUTH", FALSE}, + { "TLE", "PROXY_AUTH", FALSE}, { "TLE", "ADD_NEW_SATS", TRUE}, - { "LOG", "KEEP_LOG_FILES", FALSE}, + { "LOG", "KEEP_LOG_FILES", FALSE}, { "PREDICT", "USE_REAL_T0", FALSE} }; /** \brief Array containing the integer configuration parameters */ sat_cfg_int_t sat_cfg_int[SAT_CFG_INT_NUM] = { - { "MODULES", "DATA_TIMEOUT", 300}, - { "MODULES", "LAYOUT", GTK_SAT_MOD_LAYOUT_3}, - { "MODULES", "VIEW_1", GTK_SAT_MOD_VIEW_MAP}, - { "MODULES", "VIEW_2", GTK_SAT_MOD_VIEW_POLAR}, - { "MODULES", "VIEW_3", GTK_SAT_MOD_VIEW_SINGLE}, - { "GLOBAL", "WARP", 1}, - { "MODULES", "LIST_REFRESH", 1}, - { "MODULES", "LIST_COLUMNS", LIST_COLUMNS_DEFAULTS}, - { "MODULES", "MAP_REFRESH", 10}, - { "MODULES", "MAP_INFO_COLOUR", 0x00FF00FF}, - { "MODULES", "MAP_INFO_BGD_COLOUR", 0x000000FF}, - { "MODULES", "MAP_QTH_COLOUR", 0x00FFFFFF}, - { "MODULES", "MAP_SAT_COLOUR", 0xF0F000FF}, - { "MODULES", "MAP_SELECTED_SAT_COLOUR", 0xFFFFFFFF}, - { "MODULES", "MAP_COV_AREA_COLOUR", 0xFFFFFF1F}, - { "MODULES", "MAP_GRID_COLOUR", 0x7F7F7F7F}, - { "MODULES", "MAP_TICK_COLOUR", 0x7F7F7F7F}, - { "MODULES", "MAP_TRACK_COLOUR", 0x00FFFFFF}, - { "MODULES", "MAP_TRACK_NUM", 1}, - { "MODULES", "POLAR_REFRESH", 3}, - { "MODULES", "POLAR_CHART_ORIENT", POLAR_VIEW_NESW}, - { "MODULES", "POLAR_BGD_COLOUR", 0xFFFFFFFF}, - { "MODULES", "POLAR_AXIS_COLOUR", 0x0F0F0F7F}, - { "MODULES", "POLAR_TICK_COLOUR", 0x007F00FF}, - { "MODULES", "POLAR_SAT_COLOUR", 0x8F0000FF}, - { "MODULES", "POLAR_SELECTED_SAT_COL", 0xFF0D0BFF}, - { "MODULES", "POLAR_TRACK_COLOUR", 0x0000FFFF}, - { "MODULES", "POLAR_INFO_COLOUR", 0x00007FFF}, - { "MODULES", "SINGLE_SAT_REFRESH", 1}, - { "MODULES", "SINGLE_SAT_FIELDS", SINGLE_SAT_FIELD_DEF}, - { "PREDICT", "MINIMUM_ELEV", 5}, - { "PREDICT", "NUMBER_OF_PASSES", 10}, - { "PREDICT", "LOOK_AHEAD", 3}, - { "PREDICT", "TIME_RESOLUTION", 10}, - { "PREDICT", "NUMBER_OF_ENTRIES", 20}, - { "PREDICT", "SINGLE_PASS_COL", SINGLE_PASS_COL_DEFAULTS}, - { "PREDICT", "MULTI_PASS_COL", MULTI_PASS_COL_DEFAULTS}, - { "PREDICT", "SAVE_FORMAT", 0}, - { "PREDICT", "SAVE_CONTENTS", 0}, + { "MODULES", "DATA_TIMEOUT", 300}, + { "MODULES", "LAYOUT", GTK_SAT_MOD_LAYOUT_3}, + { "MODULES", "VIEW_1", GTK_SAT_MOD_VIEW_MAP}, + { "MODULES", "VIEW_2", GTK_SAT_MOD_VIEW_POLAR}, + { "MODULES", "VIEW_3", GTK_SAT_MOD_VIEW_SINGLE}, + { "GLOBAL", "WARP", 1}, + { "MODULES", "LIST_REFRESH", 1}, + { "MODULES", "LIST_COLUMNS", LIST_COLUMNS_DEFAULTS}, + { "MODULES", "MAP_REFRESH", 10}, + { "MODULES", "MAP_INFO_COLOUR", 0x00FF00FF}, + { "MODULES", "MAP_INFO_BGD_COLOUR", 0x000000FF}, + { "MODULES", "MAP_QTH_COLOUR", 0x00FFFFFF}, + { "MODULES", "MAP_SAT_COLOUR", 0xF0F000FF}, + { "MODULES", "MAP_SELECTED_SAT_COLOUR", 0xFFFFFFFF}, + { "MODULES", "MAP_COV_AREA_COLOUR", 0xFFFFFF1F}, + { "MODULES", "MAP_GRID_COLOUR", 0x7F7F7F7F}, + { "MODULES", "MAP_TICK_COLOUR", 0x7F7F7F7F}, + { "MODULES", "MAP_TRACK_COLOUR", 0x00FFFFFF}, + { "MODULES", "MAP_TRACK_NUM", 1}, + { "MODULES", "POLAR_REFRESH", 3}, + { "MODULES", "POLAR_CHART_ORIENT", POLAR_VIEW_NESW}, + { "MODULES", "POLAR_BGD_COLOUR", 0xFFFFFFFF}, + { "MODULES", "POLAR_AXIS_COLOUR", 0x0F0F0F7F}, + { "MODULES", "POLAR_TICK_COLOUR", 0x007F00FF}, + { "MODULES", "POLAR_SAT_COLOUR", 0x8F0000FF}, + { "MODULES", "POLAR_SELECTED_SAT_COL", 0xFF0D0BFF}, + { "MODULES", "POLAR_TRACK_COLOUR", 0x0000FFFF}, + { "MODULES", "POLAR_INFO_COLOUR", 0x00007FFF}, + { "MODULES", "SINGLE_SAT_REFRESH", 1}, + { "MODULES", "SINGLE_SAT_FIELDS", SINGLE_SAT_FIELD_DEF}, + { "PREDICT", "MINIMUM_ELEV", 5}, + { "PREDICT", "NUMBER_OF_PASSES", 10}, + { "PREDICT", "LOOK_AHEAD", 3}, + { "PREDICT", "TIME_RESOLUTION", 10}, + { "PREDICT", "NUMBER_OF_ENTRIES", 20}, + { "PREDICT", "SINGLE_PASS_COL", SINGLE_PASS_COL_DEFAULTS}, + { "PREDICT", "MULTI_PASS_COL", MULTI_PASS_COL_DEFAULTS}, + { "PREDICT", "SAVE_FORMAT", 0}, + { "PREDICT", "SAVE_CONTENTS", 0}, { "PREDICT", "TWILIGHT_THRESHOLD", -6}, - { "SKY_AT_GLANCE", "TIME_SPAN_HOURS", 8}, - { "SKY_AT_GLANCE", "COLOUR_01", 0x3c46c8}, - { "SKY_AT_GLANCE", "COLOUR_02", 0x00500a}, - { "SKY_AT_GLANCE", "COLOUR_03", 0xd5472b}, - { "SKY_AT_GLANCE", "COLOUR_04", 0xd06b38}, - { "SKY_AT_GLANCE", "COLOUR_05", 0xcf477a}, - { "SKY_AT_GLANCE", "COLOUR_06", 0xbf041f}, - { "SKY_AT_GLANCE", "COLOUR_07", 0x04bf20}, - { "SKY_AT_GLANCE", "COLOUR_08", 0x0420bf}, - { "SKY_AT_GLANCE", "COLOUR_09", 0xa304bf}, - { "SKY_AT_GLANCE", "COLOUR_10", 0x04bdbf}, - { "GLOBAL", "WINDOW_POS_X", 0}, - { "GLOBAL", "WINDOW_POS_Y", 0}, - { "GLOBAL", "WINDOW_WIDTH", 700}, - { "GLOBAL", "WINDOW_HEIGHT", 700}, - { "GLOBAL", "HTML_BROWSER_TYPE", 0}, - { "TLE", "AUTO_UPDATE_FREQ", 2}, - { "TLE", "AUTO_UPDATE_ACTION", 1}, - { "TLE", "LAST_UPDATE", 0}, - { "LOG", "CLEAN_AGE", 0}, /* 0 = Never clean */ - { "LOG", "LEVEL", 4} + { "SKY_AT_GLANCE", "TIME_SPAN_HOURS", 8}, + { "SKY_AT_GLANCE", "COLOUR_01", 0x3c46c8}, + { "SKY_AT_GLANCE", "COLOUR_02", 0x00500a}, + { "SKY_AT_GLANCE", "COLOUR_03", 0xd5472b}, + { "SKY_AT_GLANCE", "COLOUR_04", 0xd06b38}, + { "SKY_AT_GLANCE", "COLOUR_05", 0xcf477a}, + { "SKY_AT_GLANCE", "COLOUR_06", 0xbf041f}, + { "SKY_AT_GLANCE", "COLOUR_07", 0x04bf20}, + { "SKY_AT_GLANCE", "COLOUR_08", 0x0420bf}, + { "SKY_AT_GLANCE", "COLOUR_09", 0xa304bf}, + { "SKY_AT_GLANCE", "COLOUR_10", 0x04bdbf}, + { "GLOBAL", "WINDOW_POS_X", 0}, + { "GLOBAL", "WINDOW_POS_Y", 0}, + { "GLOBAL", "WINDOW_WIDTH", 700}, + { "GLOBAL", "WINDOW_HEIGHT", 700}, + { "GLOBAL", "HTML_BROWSER_TYPE", 0}, + { "TLE", "AUTO_UPDATE_FREQ", 2}, + { "TLE", "AUTO_UPDATE_ACTION", 1}, + { "TLE", "LAST_UPDATE", 0}, + { "LOG", "CLEAN_AGE", 0}, /* 0 = Never clean */ + { "LOG", "LEVEL", 4} }; /** \brief Array containing the string configuration values */ sat_cfg_str_t sat_cfg_str[SAT_CFG_STR_NUM] = { - { "GLOBAL", "TIME_FORMAT", "%Y/%m/%d %H:%M:%S"}, - { "GLOBAL", "DEFAULT_QTH", "sample.qth"}, - { "GLOBAL", "OPEN_MODULES", "Amateur"}, - { "GLOBAL", "HTML_BROWSER", NULL}, - { "MODULES", "MAP_FILE", "nasa-topo_800.png"}, - { "MODULES", "MAP_FONT", "Sans 10"}, - { "MODULES", "POLAR_FONT", "Sans 10"}, - { "TLE", "SERVER", "http://www.celestrak.com/NORAD/elements/"}, - { "TLE", "FILES", "amateur.txt;cubesat.txt;galileo.txt;geo.txt;gps-ops.txt;"\ - "iridium.txt;military.txt;radar.txt;science.txt;weather.txt"}, - { "TLE", "FILE_DIR", NULL}, - { "TLE", "EXTENSION", "*.*"}, - { "PREDICT", "SAVE_DIR", NULL} + { "GLOBAL", "TIME_FORMAT", "%Y/%m/%d %H:%M:%S"}, + { "GLOBAL", "DEFAULT_QTH", "sample.qth"}, + { "GLOBAL", "OPEN_MODULES", "Amateur"}, + { "GLOBAL", "HTML_BROWSER", NULL}, + { "MODULES", "MAP_FILE", "nasa-topo_800.png"}, + { "MODULES", "MAP_FONT", "Sans 10"}, + { "MODULES", "POLAR_FONT", "Sans 10"}, + { "TLE", "SERVER", "http://www.celestrak.com/NORAD/elements/"}, + { "TLE", "FILES", "amateur.txt;cubesat.txt;galileo.txt;geo.txt;gps-ops.txt;"\ + "iridium.txt;military.txt;radar.txt;science.txt;weather.txt"}, + { "TLE", "PROXY", NULL}, + { "TLE", "FILE_DIR", NULL}, + { "TLE", "EXTENSION", "*.*"}, + { "PREDICT", "SAVE_DIR", NULL} }; @@ -239,42 +241,42 @@ static GKeyFile *config = NULL; guint sat_cfg_load () { - gchar *keyfile; - GError *error = NULL; + gchar *keyfile; + GError *error = NULL; - if (config != NULL) - sat_cfg_close (); + if (config != NULL) + sat_cfg_close (); - /* load the configuration file */ - config = g_key_file_new (); - keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "gpredict.cfg", NULL); + /* load the configuration file */ + config = g_key_file_new (); + keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "gpredict.cfg", NULL); - g_key_file_load_from_file (config, keyfile, G_KEY_FILE_KEEP_COMMENTS, &error); + g_key_file_load_from_file (config, keyfile, G_KEY_FILE_KEEP_COMMENTS, &error); - g_free (keyfile); + g_free (keyfile); - if (error != NULL) { + if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Error reading config file (%s)"), - __FUNCTION__, error->message); + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s: Error reading config file (%s)"), + __FUNCTION__, error->message); - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Using built-in defaults"), - __FUNCTION__); + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s: Using built-in defaults"), + __FUNCTION__); - g_clear_error (&error); + g_clear_error (&error); - return 1; - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Everything OK."), __FUNCTION__); - } - - return 0; + return 1; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Everything OK."), __FUNCTION__); + } + + return 0; } @@ -287,84 +289,84 @@ sat_cfg_load () guint sat_cfg_save () { - gsize length; - gsize written; - GError *error = NULL; - gchar *cfgstr; - gchar *keyfile; - GIOChannel *cfgfile; - guint err = 0; + gsize length; + gsize written; + GError *error = NULL; + gchar *cfgstr; + gchar *keyfile; + GIOChannel *cfgfile; + guint err = 0; - /* convert configuration data struct to charachter string */ - cfgstr = g_key_file_to_data (config, &length, &error); + /* convert configuration data struct to charachter string */ + cfgstr = g_key_file_to_data (config, &length, &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create config data (%s)."), - __FUNCTION__, error->message); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not create config data (%s)."), + __FUNCTION__, error->message); - g_clear_error (&error); + g_clear_error (&error); - err = 1; - } - else { + err = 1; + } + else { - /* create and open a file for writing */ - keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "gpredict.cfg", NULL); - cfgfile = g_io_channel_new_file (keyfile, "w", &error); - g_free (keyfile); + /* create and open a file for writing */ + keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "gpredict.cfg", NULL); + cfgfile = g_io_channel_new_file (keyfile, "w", &error); + g_free (keyfile); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create config file (%s)."), - __FUNCTION__, error->message); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not create config file (%s)."), + __FUNCTION__, error->message); - g_clear_error (&error); + g_clear_error (&error); - err = 1; - } - else { - g_io_channel_write_chars (cfgfile, - cfgstr, - length, - &written, - &error); + err = 1; + } + else { + g_io_channel_write_chars (cfgfile, + cfgstr, + length, + &written, + &error); - g_io_channel_shutdown (cfgfile, TRUE, NULL); - g_io_channel_unref (cfgfile); + g_io_channel_shutdown (cfgfile, TRUE, NULL); + g_io_channel_unref (cfgfile); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error writing config data (%s)."), - __FUNCTION__, error->message); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error writing config data (%s)."), + __FUNCTION__, error->message); - g_clear_error (&error); + g_clear_error (&error); - err = 1; - } - else if (length != written) { - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Wrote only %d out of %d chars."), - __FUNCTION__, written, length); + err = 1; + } + else if (length != written) { + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s: Wrote only %d out of %d chars."), + __FUNCTION__, written, length); - err = 1; - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Configuration saved."), - __FUNCTION__); + err = 1; + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Configuration saved."), + __FUNCTION__); - err = 0; - } - } + err = 0; + } + } - g_free (cfgstr); - } + g_free (cfgstr); + } - return err; + return err; } @@ -379,10 +381,10 @@ sat_cfg_save () void sat_cfg_close () { - if (config != NULL) { - g_key_file_free (config); - config = NULL; - } + if (config != NULL) { + g_key_file_free (config); + config = NULL; + } } @@ -390,60 +392,59 @@ sat_cfg_close () gboolean sat_cfg_get_bool (sat_cfg_bool_e param) { - gboolean value = FALSE; - GError *error = NULL; + gboolean value = FALSE; + GError *error = NULL; - if (param < SAT_CFG_BOOL_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + if (param < SAT_CFG_BOOL_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); - /* return default value */ - value = sat_cfg_bool[param].defval; - } - else { - /* fetch value */ - value = g_key_file_get_boolean (config, - sat_cfg_bool[param].group, - sat_cfg_bool[param].key, - &error); + /* return default value */ + value = sat_cfg_bool[param].defval; + } + else { + /* fetch value */ + value = g_key_file_get_boolean (config, + sat_cfg_bool[param].group, + sat_cfg_bool[param].key, + &error); - if (error != NULL) { - g_clear_error (&error); + if (error != NULL) { + g_clear_error (&error); - value = sat_cfg_bool[param].defval; - } - } + value = sat_cfg_bool[param].defval; + } + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); + } - return value; + return value; } /** \brief Get default value of boolean parameter */ gboolean sat_cfg_get_bool_def (sat_cfg_bool_e param) { - gboolean value = FALSE; + gboolean value = FALSE; - if (param < SAT_CFG_BOOL_NUM) { - value = sat_cfg_bool[param].defval; - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); - } + if (param < SAT_CFG_BOOL_NUM) { + value = sat_cfg_bool[param].defval; + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); + } - - return value; + return value; } /** \brief Store a boolean configuration value. @@ -457,52 +458,52 @@ void sat_cfg_set_bool (sat_cfg_bool_e param, gboolean value) { - if (param < SAT_CFG_BOOL_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - g_key_file_set_boolean (config, - sat_cfg_bool[param].group, - sat_cfg_bool[param].key, - value); - } + if (param < SAT_CFG_BOOL_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + g_key_file_set_boolean (config, + sat_cfg_bool[param].group, + sat_cfg_bool[param].key, + value); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); + } } void sat_cfg_reset_bool (sat_cfg_bool_e param) { - if (param < SAT_CFG_BOOL_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - g_key_file_remove_key (config, - sat_cfg_bool[param].group, - sat_cfg_bool[param].key, - NULL); - } + if (param < SAT_CFG_BOOL_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + g_key_file_remove_key (config, + sat_cfg_bool[param].group, + sat_cfg_bool[param].key, + NULL); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); + } } @@ -513,43 +514,43 @@ sat_cfg_reset_bool (sat_cfg_bool_e param) gchar * sat_cfg_get_str (sat_cfg_str_e param) { - gchar *value; - GError *error = NULL; + gchar *value; + GError *error = NULL; - if (param < SAT_CFG_STR_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + if (param < SAT_CFG_STR_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); - /* return default value */ - value = g_strdup (sat_cfg_str[param].defval); - } - else { - /* fetch value */ - value = g_key_file_get_string (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - &error); + /* return default value */ + value = g_strdup (sat_cfg_str[param].defval); + } + else { + /* fetch value */ + value = g_key_file_get_string (config, + sat_cfg_str[param].group, + sat_cfg_str[param].key, + &error); - if (error != NULL) { - g_clear_error (&error); + if (error != NULL) { + g_clear_error (&error); - value = g_strdup (sat_cfg_str[param].defval); - } - } + value = g_strdup (sat_cfg_str[param].defval); + } + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); - value = g_strdup ("ERROR"); - } + value = g_strdup ("ERROR"); + } - return value; + return value; } /** \brief Get default value of string parameter @@ -559,21 +560,20 @@ sat_cfg_get_str (sat_cfg_str_e param) gchar * sat_cfg_get_str_def (sat_cfg_str_e param) { - gchar *value; + gchar *value; - if (param < SAT_CFG_STR_NUM) { - value = g_strdup (sat_cfg_str[param].defval); - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + if (param < SAT_CFG_STR_NUM) { + value = g_strdup (sat_cfg_str[param].defval); + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); - value = g_strdup ("ERROR"); - } + value = g_strdup ("ERROR"); + } - - return value; + return value; } /** \brief Store a str configuration value. @@ -582,35 +582,35 @@ void sat_cfg_set_str (sat_cfg_str_e param, const gchar *value) { - if (param < SAT_CFG_STR_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - if (value) { - g_key_file_set_string (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - value); - } - else { - /* remove key from config */ - g_key_file_remove_key (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - NULL); - } - } + if (param < SAT_CFG_STR_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + if (value) { + g_key_file_set_string (config, + sat_cfg_str[param].group, + sat_cfg_str[param].key, + value); + } + else { + /* remove key from config */ + g_key_file_remove_key (config, + sat_cfg_str[param].group, + sat_cfg_str[param].key, + NULL); + } + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); + } } @@ -618,136 +618,136 @@ void sat_cfg_reset_str (sat_cfg_str_e param) { - if (param < SAT_CFG_STR_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - g_key_file_remove_key (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - NULL); - } + if (param < SAT_CFG_STR_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + g_key_file_remove_key (config, + sat_cfg_str[param].group, + sat_cfg_str[param].key, + NULL); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); + } } gint sat_cfg_get_int (sat_cfg_int_e param) { - gint value = 0; - GError *error = NULL; + gint value = 0; + GError *error = NULL; - if (param < SAT_CFG_INT_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + if (param < SAT_CFG_INT_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); - /* return default value */ - value = sat_cfg_int[param].defval; - } - else { - /* fetch value */ - value = g_key_file_get_integer (config, - sat_cfg_int[param].group, - sat_cfg_int[param].key, - &error); + /* return default value */ + value = sat_cfg_int[param].defval; + } + else { + /* fetch value */ + value = g_key_file_get_integer (config, + sat_cfg_int[param].group, + sat_cfg_int[param].key, + &error); - if (error != NULL) { - g_clear_error (&error); + if (error != NULL) { + g_clear_error (&error); - value = sat_cfg_int[param].defval; - } - } + value = sat_cfg_int[param].defval; + } + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); + } - return value; + return value; } gint sat_cfg_get_int_def (sat_cfg_int_e param) { - gint value = 0; + gint value = 0; - if (param < SAT_CFG_INT_NUM) { - value = sat_cfg_int[param].defval; - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); - } + if (param < SAT_CFG_INT_NUM) { + value = sat_cfg_int[param].defval; + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); + } - return value; + return value; } void sat_cfg_set_int (sat_cfg_int_e param, gint value) { - if (param < SAT_CFG_INT_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - g_key_file_set_integer (config, - sat_cfg_int[param].group, - sat_cfg_int[param].key, - value); - } + if (param < SAT_CFG_INT_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + g_key_file_set_integer (config, + sat_cfg_int[param].group, + sat_cfg_int[param].key, + value); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); + } } void sat_cfg_reset_int (sat_cfg_int_e param) { - if (param < SAT_CFG_INT_NUM) { - - if (config == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); - } - else { - g_key_file_remove_key (config, - sat_cfg_int[param].group, - sat_cfg_int[param].key, - NULL); - } + if (param < SAT_CFG_INT_NUM) { + + if (config == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Module not initialised\n"), + __FUNCTION__); + } + else { + g_key_file_remove_key (config, + sat_cfg_int[param].group, + sat_cfg_int[param].key, + NULL); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); - } + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); + } } diff --git a/src/sat-cfg.h b/src/sat-cfg.h index c766cb5..5d7516d 100644 --- a/src/sat-cfg.h +++ b/src/sat-cfg.h @@ -35,113 +35,115 @@ /** \brief Symbolic references for boolean config values. */ typedef enum { - SAT_CFG_BOOL_USE_LOCAL_TIME = 0, /*!< Display local time instead of UTC. */ - SAT_CFG_BOOL_USE_NSEW, /*!< Use N, S, E and W instead of sign */ - SAT_CFG_BOOL_USE_IMPERIAL, /*!< Use Imperial units instead of Metric */ - SAT_CFG_BOOL_MAIN_WIN_POS, /*!< Restore position of main window */ - SAT_CFG_BOOL_MOD_WIN_POS, /*!< Restore size and position of module windows */ + SAT_CFG_BOOL_USE_LOCAL_TIME = 0, /*!< Display local time instead of UTC. */ + SAT_CFG_BOOL_USE_NSEW, /*!< Use N, S, E and W instead of sign */ + SAT_CFG_BOOL_USE_IMPERIAL, /*!< Use Imperial units instead of Metric */ + SAT_CFG_BOOL_MAIN_WIN_POS, /*!< Restore position of main window */ + SAT_CFG_BOOL_MOD_WIN_POS, /*!< Restore size and position of module windows */ SAT_CFG_BOOL_MOD_STATE, /*!< Restore module state */ - SAT_CFG_BOOL_RULES_HINT, /*!< Enable rules hint in GtkSatList. */ - SAT_CFG_BOOL_MAP_SHOW_QTH_INFO, /*!< Show QTH info on map */ - SAT_CFG_BOOL_MAP_SHOW_NEXT_EV, /*!< Show next event on map */ - SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK, /*!< Track mouse cursor on map. */ - SAT_CFG_BOOL_MAP_SHOW_GRID, /*!< Show grid on map. */ - SAT_CFG_BOOL_MAP_KEEP_RATIO, /*!< Keep original aspect ratio */ - SAT_CFG_BOOL_POL_SHOW_QTH_INFO, /*!< Show QTH info on polar plot */ - SAT_CFG_BOOL_POL_SHOW_NEXT_EV, /*!< Show next event on polar plot */ - SAT_CFG_BOOL_POL_SHOW_CURS_TRACK, /*!< Track mouse cursor on polar plot. */ - SAT_CFG_BOOL_POL_SHOW_EXTRA_AZ_TICKS, /*!< Extra Az ticks at every 30 deg. */ - SAT_CFG_BOOL_TLE_SERVER_AUTH, /*!< TLE server requires authentication. */ + SAT_CFG_BOOL_RULES_HINT, /*!< Enable rules hint in GtkSatList. */ + SAT_CFG_BOOL_MAP_SHOW_QTH_INFO, /*!< Show QTH info on map */ + SAT_CFG_BOOL_MAP_SHOW_NEXT_EV, /*!< Show next event on map */ + SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK, /*!< Track mouse cursor on map. */ + SAT_CFG_BOOL_MAP_SHOW_GRID, /*!< Show grid on map. */ + SAT_CFG_BOOL_MAP_KEEP_RATIO, /*!< Keep original aspect ratio */ + SAT_CFG_BOOL_POL_SHOW_QTH_INFO, /*!< Show QTH info on polar plot */ + SAT_CFG_BOOL_POL_SHOW_NEXT_EV, /*!< Show next event on polar plot */ + SAT_CFG_BOOL_POL_SHOW_CURS_TRACK, /*!< Track mouse cursor on polar plot. */ + SAT_CFG_BOOL_POL_SHOW_EXTRA_AZ_TICKS, /*!< Extra Az ticks at every 30 deg. */ + SAT_CFG_BOOL_TLE_SERVER_AUTH, /*!< TLE server requires authentication. */ + SAT_CFG_BOOL_TLE_PROXY_AUTH, /*!< Proxy requires authentication. */ SAT_CFG_BOOL_TLE_ADD_NEW, /*!< Add new satellites to database. */ SAT_CFG_BOOL_KEEP_LOG_FILES, /*!< Whether to keep old log files */ SAT_CFG_BOOL_PRED_USE_REAL_T0, /*!< Whether to use current time as T0 fro predictions */ - SAT_CFG_BOOL_NUM /*!< Number of boolean parameters */ + SAT_CFG_BOOL_NUM /*!< Number of boolean parameters */ } sat_cfg_bool_e; /** \brief Symbolic references for integer config values. */ typedef enum { - SAT_CFG_INT_MODULE_TIMEOUT = 0, /*!< Module refresh rate */ - SAT_CFG_INT_MODULE_LAYOUT, /*!< Module layout */ - SAT_CFG_INT_MODULE_VIEW_1, /*!< Type of view 1 */ - SAT_CFG_INT_MODULE_VIEW_2, /*!< Type of view 2 */ - SAT_CFG_INT_MODULE_VIEW_3, /*!< Type of view 3 */ - SAT_CFG_INT_WARP_FACTOR, /*!< Time compression factor. */ - SAT_CFG_INT_LIST_REFRESH, /*!< List refresh rate (cycle). */ - SAT_CFG_INT_LIST_COLUMNS, /*!< List column visibility. */ - SAT_CFG_INT_MAP_REFRESH, /*!< Map refresh rate (cycle). */ - SAT_CFG_INT_MAP_INFO_COL, /*!< Info text colour on maps. */ - SAT_CFG_INT_MAP_INFO_BGD_COL, /*!< Info text bgd colour on maps. */ - SAT_CFG_INT_MAP_QTH_COL, /*!< QTH mark colour on map. */ - SAT_CFG_INT_MAP_SAT_COL, /*!< Satellite colour on maps */ - SAT_CFG_INT_MAP_SAT_SEL_COL, /*!< Selected satellite colour */ - SAT_CFG_INT_MAP_SAT_COV_COL, /*!< Map coverage area colour */ - SAT_CFG_INT_MAP_GRID_COL, /*!< Grid colour. */ - SAT_CFG_INT_MAP_TICK_COL, /*!< Tick labels colour. */ - SAT_CFG_INT_MAP_TRACK_COL, /*!< Ground Track colour. */ - SAT_CFG_INT_MAP_TRACK_NUM, /*!< Number of orbits to show ground track for */ - SAT_CFG_INT_POLAR_REFRESH, /*!< Polar refresh rate (cycle). */ - SAT_CFG_INT_POLAR_ORIENTATION, /*!< Orientation of the polar charts. */ - SAT_CFG_INT_POLAR_BGD_COL, /*!< Polar view, background colour. */ - SAT_CFG_INT_POLAR_AXIS_COL, /*!< Polar view, axis colour. */ - SAT_CFG_INT_POLAR_TICK_COL, /*!< Tick label colour, e.g. N/W/S/E */ - SAT_CFG_INT_POLAR_SAT_COL, /*!< Satellite colour. */ - SAT_CFG_INT_POLAR_SAT_SEL_COL, /*!< Selected satellite colour. */ - SAT_CFG_INT_POLAR_TRACK_COL, /*!< Track colour. */ - SAT_CFG_INT_POLAR_INFO_COL, /*!< Info colour. */ - SAT_CFG_INT_SINGLE_SAT_REFRESH, /*!< Single-sat refresh rate (cycle). */ - SAT_CFG_INT_SINGLE_SAT_FIELDS, /*!< Single-sat fields. */ - SAT_CFG_INT_PRED_MIN_EL, /*!< Minimum elevation for passes. */ - SAT_CFG_INT_PRED_NUM_PASS, /*!< Number of passes to predict. */ - SAT_CFG_INT_PRED_LOOK_AHEAD, /*!< Look-ahead time limit in days. */ - SAT_CFG_INT_PRED_RESOLUTION, /*!< Time resolution in seconds */ - SAT_CFG_INT_PRED_NUM_ENTRIES, /*!< Number of entries in single pass. */ - SAT_CFG_INT_PRED_SINGLE_COL, /*!< Visible columns in single-pass dialog */ - SAT_CFG_INT_PRED_MULTI_COL, /*!< Visible columns in multi-pass dialog */ - SAT_CFG_INT_PRED_SAVE_FORMAT, /*!< Last used save format for predictions */ - SAT_CFG_INT_PRED_SAVE_CONTENTS, /*!< Last selection for save file contents */ + SAT_CFG_INT_MODULE_TIMEOUT = 0, /*!< Module refresh rate */ + SAT_CFG_INT_MODULE_LAYOUT, /*!< Module layout */ + SAT_CFG_INT_MODULE_VIEW_1, /*!< Type of view 1 */ + SAT_CFG_INT_MODULE_VIEW_2, /*!< Type of view 2 */ + SAT_CFG_INT_MODULE_VIEW_3, /*!< Type of view 3 */ + SAT_CFG_INT_WARP_FACTOR, /*!< Time compression factor. */ + SAT_CFG_INT_LIST_REFRESH, /*!< List refresh rate (cycle). */ + SAT_CFG_INT_LIST_COLUMNS, /*!< List column visibility. */ + SAT_CFG_INT_MAP_REFRESH, /*!< Map refresh rate (cycle). */ + SAT_CFG_INT_MAP_INFO_COL, /*!< Info text colour on maps. */ + SAT_CFG_INT_MAP_INFO_BGD_COL, /*!< Info text bgd colour on maps. */ + SAT_CFG_INT_MAP_QTH_COL, /*!< QTH mark colour on map. */ + SAT_CFG_INT_MAP_SAT_COL, /*!< Satellite colour on maps */ + SAT_CFG_INT_MAP_SAT_SEL_COL, /*!< Selected satellite colour */ + SAT_CFG_INT_MAP_SAT_COV_COL, /*!< Map coverage area colour */ + SAT_CFG_INT_MAP_GRID_COL, /*!< Grid colour. */ + SAT_CFG_INT_MAP_TICK_COL, /*!< Tick labels colour. */ + SAT_CFG_INT_MAP_TRACK_COL, /*!< Ground Track colour. */ + SAT_CFG_INT_MAP_TRACK_NUM, /*!< Number of orbits to show ground track for */ + SAT_CFG_INT_POLAR_REFRESH, /*!< Polar refresh rate (cycle). */ + SAT_CFG_INT_POLAR_ORIENTATION, /*!< Orientation of the polar charts. */ + SAT_CFG_INT_POLAR_BGD_COL, /*!< Polar view, background colour. */ + SAT_CFG_INT_POLAR_AXIS_COL, /*!< Polar view, axis colour. */ + SAT_CFG_INT_POLAR_TICK_COL, /*!< Tick label colour, e.g. N/W/S/E */ + SAT_CFG_INT_POLAR_SAT_COL, /*!< Satellite colour. */ + SAT_CFG_INT_POLAR_SAT_SEL_COL, /*!< Selected satellite colour. */ + SAT_CFG_INT_POLAR_TRACK_COL, /*!< Track colour. */ + SAT_CFG_INT_POLAR_INFO_COL, /*!< Info colour. */ + SAT_CFG_INT_SINGLE_SAT_REFRESH, /*!< Single-sat refresh rate (cycle). */ + SAT_CFG_INT_SINGLE_SAT_FIELDS, /*!< Single-sat fields. */ + SAT_CFG_INT_PRED_MIN_EL, /*!< Minimum elevation for passes. */ + SAT_CFG_INT_PRED_NUM_PASS, /*!< Number of passes to predict. */ + SAT_CFG_INT_PRED_LOOK_AHEAD, /*!< Look-ahead time limit in days. */ + SAT_CFG_INT_PRED_RESOLUTION, /*!< Time resolution in seconds */ + SAT_CFG_INT_PRED_NUM_ENTRIES, /*!< Number of entries in single pass. */ + SAT_CFG_INT_PRED_SINGLE_COL, /*!< Visible columns in single-pass dialog */ + SAT_CFG_INT_PRED_MULTI_COL, /*!< Visible columns in multi-pass dialog */ + SAT_CFG_INT_PRED_SAVE_FORMAT, /*!< Last used save format for predictions */ + SAT_CFG_INT_PRED_SAVE_CONTENTS, /*!< Last selection for save file contents */ SAT_CFG_INT_PRED_TWILIGHT_THLD, /*!< Twilight zone threshold */ - SAT_CFG_INT_SKYATGL_TIME, /*!< Time span for sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_01, /*!< Colour 1 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_02, /*!< Colour 2 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_03, /*!< Colour 3 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_04, /*!< Colour 4 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_05, /*!< Colour 5 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_06, /*!< Colour 6 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_07, /*!< Colour 7 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_08, /*!< Colour 8 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_09, /*!< Colour 9 in sky at a glance predictions */ - SAT_CFG_INT_SKYATGL_COL_10, /*!< Colour 10 in sky at a glance predictions */ - SAT_CFG_INT_WINDOW_POS_X, /*!< Main window X during last session */ - SAT_CFG_INT_WINDOW_POS_Y, /*!< Main window Y during last session */ - SAT_CFG_INT_WINDOW_WIDTH, /*!< Main window width during last session */ - SAT_CFG_INT_WINDOW_HEIGHT, /*!< Main window height during last session */ - SAT_CFG_INT_WEB_BROWSER_TYPE, /*!< Web browser type, see browser_type_t */ - SAT_CFG_INT_TLE_AUTO_UPD_FREQ, /*!< TLE auto-update frequency. */ - SAT_CFG_INT_TLE_AUTO_UPD_ACTION, /*!< TLE auto-update action. */ - SAT_CFG_INT_TLE_LAST_UPDATE, /*!< Date and time of last update, Unix seconds. */ - SAT_CFG_INT_LOG_CLEAN_AGE, /*!< Age of log file to delete (seconds) */ - SAT_CFG_INT_LOG_LEVEL, /*!< Logging level */ - SAT_CFG_INT_NUM /*!< Number of integer parameters. */ + SAT_CFG_INT_SKYATGL_TIME, /*!< Time span for sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_01, /*!< Colour 1 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_02, /*!< Colour 2 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_03, /*!< Colour 3 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_04, /*!< Colour 4 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_05, /*!< Colour 5 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_06, /*!< Colour 6 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_07, /*!< Colour 7 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_08, /*!< Colour 8 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_09, /*!< Colour 9 in sky at a glance predictions */ + SAT_CFG_INT_SKYATGL_COL_10, /*!< Colour 10 in sky at a glance predictions */ + SAT_CFG_INT_WINDOW_POS_X, /*!< Main window X during last session */ + SAT_CFG_INT_WINDOW_POS_Y, /*!< Main window Y during last session */ + SAT_CFG_INT_WINDOW_WIDTH, /*!< Main window width during last session */ + SAT_CFG_INT_WINDOW_HEIGHT, /*!< Main window height during last session */ + SAT_CFG_INT_WEB_BROWSER_TYPE, /*!< Web browser type, see browser_type_t */ + SAT_CFG_INT_TLE_AUTO_UPD_FREQ, /*!< TLE auto-update frequency. */ + SAT_CFG_INT_TLE_AUTO_UPD_ACTION, /*!< TLE auto-update action. */ + SAT_CFG_INT_TLE_LAST_UPDATE, /*!< Date and time of last update, Unix seconds. */ + SAT_CFG_INT_LOG_CLEAN_AGE, /*!< Age of log file to delete (seconds) */ + SAT_CFG_INT_LOG_LEVEL, /*!< Logging level */ + SAT_CFG_INT_NUM /*!< Number of integer parameters. */ } sat_cfg_int_e; /** \brief Symbolic references for string config values. */ typedef enum { - SAT_CFG_STR_TIME_FORMAT = 0,/*!< Time format. */ - SAT_CFG_STR_DEF_QTH, /*!< Default QTH file. */ - SAT_CFG_STR_OPEN_MODULES, /*!< Open modules. */ - SAT_CFG_STR_WEB_BROWSER, /*!< Web browser string. */ - SAT_CFG_STR_MAP_FILE, /*!< Map file (abs or rel). */ - SAT_CFG_STR_MAP_FONT, /*!< Map font. */ - SAT_CFG_STR_POL_FONT, /*!< Polar view font. */ - SAT_CFG_STR_TLE_SERVER, /*!< Server for TLE updates. */ - SAT_CFG_STR_TLE_FILES, /*!< ; separated list of files on server. */ - SAT_CFG_STR_TLE_FILE_DIR, /*!< Local directory from which tle were last updated. */ - SAT_CFG_STR_TLE_FILE_EXT, /*!< File extensions. */ - SAT_CFG_STR_PRED_SAVE_DIR, /*!< Last used save directory for pass predictions */ - SAT_CFG_STR_NUM /*!< Number of string parameters */ + SAT_CFG_STR_TIME_FORMAT = 0,/*!< Time format. */ + SAT_CFG_STR_DEF_QTH, /*!< Default QTH file. */ + SAT_CFG_STR_OPEN_MODULES, /*!< Open modules. */ + SAT_CFG_STR_WEB_BROWSER, /*!< Web browser string. */ + SAT_CFG_STR_MAP_FILE, /*!< Map file (abs or rel). */ + SAT_CFG_STR_MAP_FONT, /*!< Map font. */ + SAT_CFG_STR_POL_FONT, /*!< Polar view font. */ + SAT_CFG_STR_TLE_SERVER, /*!< Server for TLE updates. */ + SAT_CFG_STR_TLE_FILES, /*!< ; separated list of files on server. */ + SAT_CFG_STR_TLE_PROXY, /*!< Proxy server. */ + SAT_CFG_STR_TLE_FILE_DIR, /*!< Local directory from which tle were last updated. */ + SAT_CFG_STR_TLE_FILE_EXT, /*!< File extensions. */ + SAT_CFG_STR_PRED_SAVE_DIR, /*!< Last used save directory for pass predictions */ + SAT_CFG_STR_NUM /*!< Number of string parameters */ } sat_cfg_str_e; diff --git a/src/sat-pref-tle.c b/src/sat-pref-tle.c index c6a88b9..0d5920b 100644 --- a/src/sat-pref-tle.c +++ b/src/sat-pref-tle.c @@ -42,7 +42,7 @@ static GtkWidget *freq; static GtkWidget *warn,*autom; /* internet updates */ -static GtkWidget *server,*files; +static GtkWidget *server,*proxy,*files; /* add new sats */ static GtkWidget *addnew; @@ -76,28 +76,27 @@ static void value_changed_cb (GtkWidget *widget, gpointer data); GtkWidget *sat_pref_tle_create () { - GtkWidget *vbox; + GtkWidget *vbox; - - /* vertical box */ - vbox = gtk_vbox_new (FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 20); + /* vertical box */ + vbox = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 20); - /* add contents */ - create_auto_update (vbox); - gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0); - create_network (vbox); - gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0); + /* add contents */ + create_auto_update (vbox); + gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0); + create_network (vbox); + gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0); create_misc (vbox); #if 0 create_local (vbox); #endif - /* create RESET button */ - create_reset_button (GTK_BOX (vbox)); + /* create RESET button */ + create_reset_button (GTK_BOX (vbox)); - return vbox; + return vbox; } @@ -106,8 +105,8 @@ GtkWidget *sat_pref_tle_create () void sat_pref_tle_cancel () { - dirty = FALSE; - reset = FALSE; + dirty = FALSE; + reset = FALSE; } @@ -116,45 +115,50 @@ sat_pref_tle_cancel () void sat_pref_tle_ok () { - if (dirty) { - - /* save settings */ + if (dirty) { + + /* save settings */ - /* update frequency */ - sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ, - gtk_combo_box_get_active (GTK_COMBO_BOX (freq))); + /* update frequency */ + sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ, + gtk_combo_box_get_active (GTK_COMBO_BOX (freq))); - /* action to take */ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (autom))) - sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION, TLE_AUTO_UPDATE_GOAHEAD); - else - sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION, TLE_AUTO_UPDATE_NOTIFY); + /* action to take */ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (autom))) + sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION, TLE_AUTO_UPDATE_GOAHEAD); + else + sat_cfg_set_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION, TLE_AUTO_UPDATE_NOTIFY); - /* server */ - sat_cfg_set_str (SAT_CFG_STR_TLE_SERVER, - gtk_entry_get_text (GTK_ENTRY (server))); + /* server */ + sat_cfg_set_str (SAT_CFG_STR_TLE_SERVER, + gtk_entry_get_text (GTK_ENTRY (server))); - /* files */ - sat_cfg_set_str (SAT_CFG_STR_TLE_FILES, - gtk_entry_get_text (GTK_ENTRY (files))); + /* proxy */ + sat_cfg_set_str (SAT_CFG_STR_TLE_PROXY, + gtk_entry_get_text (GTK_ENTRY (proxy))); + + /* files */ + sat_cfg_set_str (SAT_CFG_STR_TLE_FILES, + gtk_entry_get_text (GTK_ENTRY (files))); /* add new sats */ sat_cfg_set_bool (SAT_CFG_BOOL_TLE_ADD_NEW, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (addnew))); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (addnew))); - dirty = FALSE; - } - else if (reset) { + dirty = FALSE; + } + else if (reset) { - /* use sat_cfg_reset */ - sat_cfg_reset_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ); - sat_cfg_reset_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION); - sat_cfg_reset_str (SAT_CFG_STR_TLE_SERVER); - sat_cfg_reset_str (SAT_CFG_STR_TLE_FILES); + /* use sat_cfg_reset */ + sat_cfg_reset_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ); + sat_cfg_reset_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION); + sat_cfg_reset_str (SAT_CFG_STR_TLE_SERVER); + sat_cfg_reset_str (SAT_CFG_STR_TLE_PROXY); + sat_cfg_reset_str (SAT_CFG_STR_TLE_FILES); sat_cfg_reset_bool (SAT_CFG_BOOL_TLE_ADD_NEW); - reset = FALSE; - } + reset = FALSE; + } } @@ -162,53 +166,53 @@ sat_pref_tle_ok () static void create_auto_update (GtkWidget *vbox) { - GtkWidget *label; - GtkWidget *box; - guint i; + GtkWidget *label; + GtkWidget *box; + guint i; - /* auto update */ - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), _("Auto-Update:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); + /* auto update */ + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), _("Auto-Update:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - /* frequency */ - freq = gtk_combo_box_new_text (); - for (i = 0; i < TLE_AUTO_UPDATE_NUM; i++) { - gtk_combo_box_append_text (GTK_COMBO_BOX (freq), - tle_update_freq_to_str (i)); - } - gtk_combo_box_set_active (GTK_COMBO_BOX (freq), - sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)); - g_signal_connect (freq, "changed", G_CALLBACK (value_changed_cb), NULL); + /* frequency */ + freq = gtk_combo_box_new_text (); + for (i = 0; i < TLE_AUTO_UPDATE_NUM; i++) { + gtk_combo_box_append_text (GTK_COMBO_BOX (freq), + tle_update_freq_to_str (i)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (freq), + sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)); + g_signal_connect (freq, "changed", G_CALLBACK (value_changed_cb), NULL); - label = gtk_label_new (_("Check the age of TLE data:")); + label = gtk_label_new (_("Check the age of TLE data:")); - box = gtk_hbox_new (FALSE, 5); - gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), freq, FALSE, FALSE, 0); + box = gtk_hbox_new (FALSE, 5); + gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), freq, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0); - /* radio buttons selecting action */ - label = gtk_label_new (_("If TLEs are too old:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - warn = gtk_radio_button_new_with_label (NULL, - _("Notify me")); - gtk_box_pack_start (GTK_BOX (vbox), warn, FALSE, TRUE, 0); - autom = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (warn), - _("Perform automatic update in the background")); - gtk_box_pack_start (GTK_BOX (vbox), autom, FALSE, TRUE, 0); + /* radio buttons selecting action */ + label = gtk_label_new (_("If TLEs are too old:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); + warn = gtk_radio_button_new_with_label (NULL, + _("Notify me")); + gtk_box_pack_start (GTK_BOX (vbox), warn, FALSE, TRUE, 0); + autom = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (warn), + _("Perform automatic update in the background")); + gtk_box_pack_start (GTK_BOX (vbox), autom, FALSE, TRUE, 0); - /* warn is selected automatically by default */ - if (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autom), TRUE); - } - + /* warn is selected automatically by default */ + if (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autom), TRUE); + } - g_signal_connect (warn, "toggled", G_CALLBACK (value_changed_cb), NULL); - g_signal_connect (autom, "toggled", G_CALLBACK (value_changed_cb), NULL); + + g_signal_connect (warn, "toggled", G_CALLBACK (value_changed_cb), NULL); + g_signal_connect (autom, "toggled", G_CALLBACK (value_changed_cb), NULL); } @@ -218,58 +222,75 @@ create_auto_update (GtkWidget *vbox) static void create_network (GtkWidget *vbox) { - GtkWidget *label; - GtkWidget *table; - GtkTooltips *tips; + GtkWidget *label; + GtkWidget *table; + GtkTooltips *tips; - /* auto update */ - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), _("Update from the Internet:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); + /* auto update */ + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), _("Update from the Internet:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - /* create table */ - table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 5); - gtk_table_set_col_spacings (GTK_TABLE (table), 5); + /* create table */ + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); + gtk_table_set_col_spacings (GTK_TABLE (table), 5); - /* server */ - label = gtk_label_new (_("Remote server:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - - server = gtk_entry_new (); - if (sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER)) - gtk_entry_set_text (GTK_ENTRY (server), sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER)); - tips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tips, server, - _("Enter URL for remote server including directory, i.e.\n"\ - "protocol://servername/directory\n"\ - "Protocol can be both http and ftp."), - NULL); - g_signal_connect (server, "changed", G_CALLBACK (value_changed_cb), NULL); - gtk_table_attach (GTK_TABLE (table), server, 1, 2, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - /* Files */ - label = gtk_label_new (_("Files to fetch:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - - files = gtk_entry_new (); - if (sat_cfg_get_str (SAT_CFG_STR_TLE_FILES)) - gtk_entry_set_text (GTK_ENTRY (files), sat_cfg_get_str (SAT_CFG_STR_TLE_FILES)); - tips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tips, files, - _("Enter list of files to fetch from remote server.\n"\ - "The files should be separated with ; (semicolon)"), - NULL); - g_signal_connect (files, "changed", G_CALLBACK (value_changed_cb), NULL); - gtk_table_attach (GTK_TABLE (table), files, 1, 2, 2, 3, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + /* server */ + label = gtk_label_new (_("Remote server:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - /* put table into vbox */ - gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0); + server = gtk_entry_new (); + if (sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER)) + gtk_entry_set_text (GTK_ENTRY (server), sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER)); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, server, + _("Enter URL for remote server including directory, i.e.\n"\ + "protocol://servername/directory\n"\ + "Protocol can be both http and ftp."), + NULL); + g_signal_connect (server, "changed", G_CALLBACK (value_changed_cb), NULL); + gtk_table_attach (GTK_TABLE (table), server, 1, 2, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + /* proxy */ + label = gtk_label_new (_("Proxy server:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + + proxy = gtk_entry_new (); + if (sat_cfg_get_str (SAT_CFG_STR_TLE_PROXY)) + gtk_entry_set_text (GTK_ENTRY (proxy), sat_cfg_get_str (SAT_CFG_STR_TLE_PROXY)); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, proxy, + _("Enter URL for local proxy server. e.g.\n"\ + "http://my.proxy.com"), + NULL); + g_signal_connect (proxy, "changed", G_CALLBACK (value_changed_cb), NULL); + gtk_table_attach (GTK_TABLE (table), proxy, 1, 2, 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + /* Files */ + label = gtk_label_new (_("Files to fetch:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); + + files = gtk_entry_new (); + if (sat_cfg_get_str (SAT_CFG_STR_TLE_FILES)) + gtk_entry_set_text (GTK_ENTRY (files), sat_cfg_get_str (SAT_CFG_STR_TLE_FILES)); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, files, + _("Enter list of files to fetch from remote server.\n"\ + "The files should be separated with ; (semicolon)"), + NULL); + g_signal_connect (files, "changed", G_CALLBACK (value_changed_cb), NULL); + gtk_table_attach (GTK_TABLE (table), files, 1, 2, 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + /* put table into vbox */ + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0); } @@ -299,14 +320,13 @@ create_misc (GtkWidget *vbox) static void create_local (GtkWidget *vbox) { - GtkWidget *label; - - /* auto update */ - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), _("Update from Local Files:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); + GtkWidget *label; + /* auto update */ + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), _("Update from Local Files:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); } #endif @@ -320,25 +340,25 @@ create_local (GtkWidget *vbox) static void create_reset_button (GtkBox *vbox) { - GtkWidget *button; - GtkWidget *butbox; - GtkTooltips *tips; + GtkWidget *button; + GtkWidget *butbox; + GtkTooltips *tips; - button = gtk_button_new_with_label (_("Reset")); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (reset_cb), NULL); + button = gtk_button_new_with_label (_("Reset")); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (reset_cb), NULL); - tips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tips, button, - _("Reset settings to the default values."), - NULL); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, button, + _("Reset settings to the default values."), + NULL); - butbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (butbox), GTK_BUTTONBOX_END); - gtk_box_pack_end (GTK_BOX (butbox), button, FALSE, TRUE, 10); + butbox = gtk_hbutton_box_new (); + gtk_button_box_set_layout (GTK_BUTTON_BOX (butbox), GTK_BUTTONBOX_END); + gtk_box_pack_end (GTK_BOX (butbox), button, FALSE, TRUE, 10); - gtk_box_pack_end (vbox, butbox, FALSE, TRUE, 0); + gtk_box_pack_end (vbox, butbox, FALSE, TRUE, 0); } @@ -357,35 +377,38 @@ static void reset_cb (GtkWidget *button, gpointer data) { - /* get defaults */ + /* get defaults */ - /* update frequency */ - gtk_combo_box_set_active (GTK_COMBO_BOX (freq), - sat_cfg_get_int_def (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)); + /* update frequency */ + gtk_combo_box_set_active (GTK_COMBO_BOX (freq), + sat_cfg_get_int_def (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)); - /* action */ - if (sat_cfg_get_int_def (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autom), TRUE); - } - else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (warn), TRUE); - } + /* action */ + if (sat_cfg_get_int_def (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autom), TRUE); + } + else { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (warn), TRUE); + } - /* server */ - gtk_entry_set_text (GTK_ENTRY (server), sat_cfg_get_str_def (SAT_CFG_STR_TLE_SERVER)); + /* server */ + gtk_entry_set_text (GTK_ENTRY (server), sat_cfg_get_str_def (SAT_CFG_STR_TLE_SERVER)); - /* files */ - gtk_entry_set_text (GTK_ENTRY (files), sat_cfg_get_str_def (SAT_CFG_STR_TLE_FILES)); + /* proxy */ + gtk_entry_set_text (GTK_ENTRY (proxy), ""); + + /* files */ + gtk_entry_set_text (GTK_ENTRY (files), sat_cfg_get_str_def (SAT_CFG_STR_TLE_FILES)); /* add new sats */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (addnew), - sat_cfg_get_bool_def (SAT_CFG_BOOL_TLE_ADD_NEW)); + sat_cfg_get_bool_def (SAT_CFG_BOOL_TLE_ADD_NEW)); - - /* reset flags */ - reset = TRUE; - dirty = FALSE; + + /* reset flags */ + reset = TRUE; + dirty = FALSE; } @@ -400,6 +423,6 @@ reset_cb (GtkWidget *button, gpointer data) static void value_changed_cb (GtkWidget *widget, gpointer data) { - dirty = TRUE; + dirty = TRUE; } diff --git a/src/tle-update.c b/src/tle-update.c index 93f006a..1fb0a0a 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -32,7 +32,7 @@ #ifdef HAVE_CONFIG_H # include #endif -#include +#include #include "sgpsdp/sgp4sdp4.h" #include "sat-log.h" #include "sat-cfg.h" @@ -56,15 +56,16 @@ static tle_t *gchar_to_tle (tle_type_t type, const gchar *lines); 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, - const gchar *fname, - GHashTable *data, - guint *sat_upd, - guint *sat_ski, - guint *sat_nod, - guint *sat_tot); + const gchar *fname, + GHashTable *data, + guint *sat_upd, + guint *sat_ski, + guint *sat_nod, + guint *sat_tot); static guint add_new_sats (GHashTable *data); @@ -73,14 +74,14 @@ static guint add_new_sats (GHashTable *data); /** \bief Free a new_tle_t structure. */ static void free_new_tle (gpointer data) { - new_tle_t *tle; + new_tle_t *tle; - tle = (new_tle_t *) data; + tle = (new_tle_t *) data; - g_free (tle->satname); - g_free (tle->line1); - g_free (tle->line2); - g_free (tle); + g_free (tle->satname); + g_free (tle->line1); + g_free (tle->line2); + g_free (tle); } @@ -104,209 +105,209 @@ static void free_new_tle (gpointer data) */ void tle_update_from_files (const gchar *dir, const gchar *filter, - gboolean silent, GtkWidget *progress, - GtkWidget *label1, GtkWidget *label2) + gboolean silent, GtkWidget *progress, + GtkWidget *label1, GtkWidget *label2) { - GHashTable *data; /* hash table with fresh TLE data */ - GDir *cache_dir; /* directory to scan fresh TLE */ - GDir *loc_dir; /* directory for gpredict TLE files */ - GError *err = NULL; - gchar *text; - gchar *ldname; - const gchar *fnam; - guint num = 0; - guint updated,updated_tmp; - guint skipped,skipped_tmp; - guint nodata,nodata_tmp; + GHashTable *data; /* hash table with fresh TLE data */ + GDir *cache_dir; /* directory to scan fresh TLE */ + GDir *loc_dir; /* directory for gpredict TLE files */ + GError *err = NULL; + gchar *text; + gchar *ldname; + const gchar *fnam; + guint num = 0; + guint updated,updated_tmp; + guint skipped,skipped_tmp; + guint nodata,nodata_tmp; guint newsats = 0; - guint total,total_tmp; - gdouble fraction = 0.0; - gdouble start = 0.0; + guint total,total_tmp; + gdouble fraction = 0.0; + gdouble start = 0.0; - /* create hash table */ - data = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, free_new_tle); + /* create hash table */ + data = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, free_new_tle); - /* open directory and read files one by one */ - cache_dir = g_dir_open (dir, 0, &err); + /* open directory and read files one by one */ + cache_dir = g_dir_open (dir, 0, &err); - if (err != NULL) { + if (err != NULL) { - /* send an error message */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error opening directory %s (%s)"), - __FUNCTION__, dir, err->message); + /* send an error message */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error opening directory %s (%s)"), + __FUNCTION__, dir, err->message); - /* insert error message into the status string, too */ - if (!silent && (label1 != NULL)) { - text = g_strdup_printf (_("ERROR opening directory %s\n%s"), - dir, err->message); - - gtk_label_set_markup (GTK_LABEL (label1), text); - g_free (text); + /* insert error message into the status string, too */ + if (!silent && (label1 != NULL)) { + text = g_strdup_printf (_("ERROR opening directory %s\n%s"), + dir, err->message); + + gtk_label_set_markup (GTK_LABEL (label1), text); + g_free (text); - } + } - g_clear_error (&err); - err = NULL; - } - else { + g_clear_error (&err); + err = NULL; + } + else { - /* read fresh tle files into memory */ - while ((fnam = g_dir_read_name (cache_dir)) != NULL) { + /* read fresh tle files into memory */ + while ((fnam = g_dir_read_name (cache_dir)) != NULL) { - /* status message */ - if (!silent && (label1 != NULL)) { - text = g_strdup_printf (_("Reading data from %s"), fnam); - gtk_label_set_text (GTK_LABEL (label1), text); - g_free (text); - + /* status message */ + if (!silent && (label1 != NULL)) { + text = g_strdup_printf (_("Reading data from %s"), fnam); + gtk_label_set_text (GTK_LABEL (label1), text); + g_free (text); + - /* Force the drawing queue to be processed otherwise there will - not be any visual feedback, ie. frozen GUI - - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 - */ - while (g_main_context_iteration (NULL, FALSE)); - - /* give user a chance to follow progress */ - g_usleep (G_USEC_PER_SEC / 10); - } + /* Force the drawing queue to be processed otherwise there will + not be any visual feedback, ie. frozen GUI + - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 + */ + while (g_main_context_iteration (NULL, FALSE)); + + /* give user a chance to follow progress */ + g_usleep (G_USEC_PER_SEC / 10); + } - /* now, do read the fresh data */ - num = read_fresh_tle (dir, fnam, data); - - if (num < 1) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: No valid TLE data found in %s"), - __FUNCTION__, fnam); - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Read %d sats from %s into memory"), - __FUNCTION__, num, fnam); - } - } + /* now, do read the fresh data */ + num = read_fresh_tle (dir, fnam, data); + + if (num < 1) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: No valid TLE data found in %s"), + __FUNCTION__, fnam); + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Read %d sats from %s into memory"), + __FUNCTION__, num, fnam); + } + } - /* close directory since we don't need it anymore */ - g_dir_close (cache_dir); + /* close directory since we don't need it anymore */ + g_dir_close (cache_dir); - /* store number of available sats */ - num = tle_lookup_count (); + /* store number of available sats */ + num = tle_lookup_count (); - /* now it is time to read gpredict-tle into memory, too */ - ldname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", NULL); + /* now it is time to read gpredict-tle into memory, too */ + ldname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", NULL); - /* open directory and read files one by one */ - loc_dir = g_dir_open (ldname, 0, &err); + /* open directory and read files one by one */ + loc_dir = g_dir_open (ldname, 0, &err); - if (err != NULL) { + if (err != NULL) { - /* send an error message */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error opening directory %s (%s)"), - __FUNCTION__, dir, err->message); + /* send an error message */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error opening directory %s (%s)"), + __FUNCTION__, dir, err->message); - /* insert error message into the status string, too */ - if (!silent && (label1 != NULL)) { - text = g_strdup_printf (_("ERROR opening directory %s\n%s"), - dir, err->message); - - gtk_label_set_markup (GTK_LABEL (label1), text); - g_free (text); - } + /* insert error message into the status string, too */ + if (!silent && (label1 != NULL)) { + text = g_strdup_printf (_("ERROR opening directory %s\n%s"), + dir, err->message); + + gtk_label_set_markup (GTK_LABEL (label1), text); + g_free (text); + } - g_clear_error (&err); - err = NULL; - } - else { - /* clear statistics */ - updated = 0; - skipped = 0; - nodata = 0; - total = 0; + g_clear_error (&err); + err = NULL; + } + else { + /* clear statistics */ + updated = 0; + skipped = 0; + nodata = 0; + total = 0; - /* get initial value of progress indicator */ - if (progress != NULL) - start = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress)); + /* get initial value of progress indicator */ + if (progress != NULL) + start = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress)); - /* update TLE files one by one */ - while ((fnam = g_dir_read_name (loc_dir)) != NULL) { + /* update TLE files one by one */ + while ((fnam = g_dir_read_name (loc_dir)) != NULL) { - /* skip 'cache' directory */ - if (g_ascii_strcasecmp (fnam, "cache")) { + /* skip 'cache' directory */ + if (g_ascii_strcasecmp (fnam, "cache")) { - /* clear stat bufs */ - updated_tmp = 0; - skipped_tmp = 0; - nodata_tmp = 0; - total_tmp = 0; - + /* clear stat bufs */ + updated_tmp = 0; + skipped_tmp = 0; + nodata_tmp = 0; + total_tmp = 0; + - /* update TLE data in this file */ - update_tle_in_file (ldname, fnam, data, - &updated_tmp, - &skipped_tmp, - &nodata_tmp, - &total_tmp); + /* update TLE data in this file */ + update_tle_in_file (ldname, fnam, data, + &updated_tmp, + &skipped_tmp, + &nodata_tmp, + &total_tmp); - /* update statistics */ - updated += updated_tmp; - skipped += skipped_tmp; - nodata += nodata_tmp; - total += total_tmp; + /* update statistics */ + updated += updated_tmp; + skipped += skipped_tmp; + nodata += nodata_tmp; + total += total_tmp; - if (!silent) { + if (!silent) { - if (label1 != NULL) { - gtk_label_set_text (GTK_LABEL (label1), - _("Updating data...")); - } + if (label1 != NULL) { + gtk_label_set_text (GTK_LABEL (label1), + _("Updating data...")); + } - if (label2 != NULL) { - text = g_strdup_printf (_("Satellites updated:\t %d\n"\ - "Satellites skipped:\t %d\n"\ - "Missing Satellites:\t %d\n"), - updated, skipped, nodata); - gtk_label_set_text (GTK_LABEL (label2), text); - g_free (text); - } + if (label2 != NULL) { + text = g_strdup_printf (_("Satellites updated:\t %d\n"\ + "Satellites skipped:\t %d\n"\ + "Missing Satellites:\t %d\n"), + updated, skipped, nodata); + gtk_label_set_text (GTK_LABEL (label2), text); + g_free (text); + } - if (progress != NULL) { + if (progress != NULL) { - /* calculate and saturate fraction - (number of sats in TLE files is greater - than the number of sats in link table) - */ - fraction = start + (1.0-start) * ((gdouble) total) / ((gdouble) num); - if (fraction >= 0.95) - fraction = 0.98; - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), - fraction); + /* calculate and saturate fraction + (number of sats in TLE files is greater + than the number of sats in link table) + */ + fraction = start + (1.0-start) * ((gdouble) total) / ((gdouble) num); + if (fraction >= 0.95) + fraction = 0.98; + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), + fraction); - } + } - /* Force the drawing queue to be processed otherwise there will - not be any visual feedback, ie. frozen GUI - - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 - */ - while (g_main_context_iteration (NULL, FALSE)); + /* Force the drawing queue to be processed otherwise there will + not be any visual feedback, ie. frozen GUI + - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 + */ + while (g_main_context_iteration (NULL, FALSE)); - /* give user a chance to follow progress */ - g_usleep (G_USEC_PER_SEC / 10); - } - } - - } + /* give user a chance to follow progress */ + g_usleep (G_USEC_PER_SEC / 10); + } + } + + } - /* close directory handle */ - g_dir_close (loc_dir); + /* close directory handle */ + g_dir_close (loc_dir); /* see if we have any new sats that need to be added */ if (sat_cfg_get_bool (SAT_CFG_BOOL_TLE_ADD_NEW)) { @@ -329,25 +330,25 @@ tle_update_from_files (const gchar *dir, const gchar *filter, __FUNCTION__, newsats); } - /* store time of update if we have updated something */ - if ((updated > 0) || (newsats > 0)) { - GTimeVal tval; - - g_get_current_time (&tval); - sat_cfg_set_int (SAT_CFG_INT_TLE_LAST_UPDATE, tval.tv_sec); - } + /* store time of update if we have updated something */ + if ((updated > 0) || (newsats > 0)) { + GTimeVal tval; + + g_get_current_time (&tval); + sat_cfg_set_int (SAT_CFG_INT_TLE_LAST_UPDATE, tval.tv_sec); + } - } + } - g_free (ldname); + g_free (ldname); - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: TLE elements updated."), - __FUNCTION__); - } + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: TLE elements updated."), + __FUNCTION__); + } - /* destroy hash tables */ - g_hash_table_destroy (data); + /* destroy hash tables */ + g_hash_table_destroy (data); } @@ -407,176 +408,213 @@ static guint add_new_sats (GHashTable *data) */ void tle_update_from_network (gboolean silent, - GtkWidget *progress, - GtkWidget *label1, - GtkWidget *label2) -{ - gchar *server; - gchar *files_tmp; - gchar **files; - guint numfiles,i; - gchar *curfile; - gchar *locfile; - GFile *file; - gdouble fraction,start=0; - GFile *outfile; - GDir *dir; - gchar *cache; - const gchar *fname; - gchar *text; - GError *err = NULL; - guint success = 0; /* no. of successfull downloads */ + GtkWidget *progress, + GtkWidget *label1, + GtkWidget *label2) + { + gchar *server; + gchar *proxy = NULL; + gchar *files_tmp; + gchar **files; + guint numfiles,i; + gchar *curfile; + gchar *locfile; + CURL *curl; + CURLcode res; + gboolean error = FALSE; + gdouble fraction,start=0; + FILE *outfile; + GDir *dir; + gchar *cache; + const gchar *fname; + gchar *text; + GError *err = NULL; + guint success = 0; /* no. of successfull downloads */ - /* bail out if we are already in an update process */ - if (tle_in_progress) - return; + /* bail out if we are already in an update process */ + if (tle_in_progress) + return; - tle_in_progress = TRUE; + tle_in_progress = TRUE; - /* get server and list of files */ - server = sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER); - files_tmp = sat_cfg_get_str (SAT_CFG_STR_TLE_FILES); - files = g_strsplit (files_tmp, ";", 0); - numfiles = g_strv_length (files); + /* get server, proxy, 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); - if (numfiles < 1) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: No files to fetch from network."), - __FUNCTION__); + if (numfiles < 1) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: No files to fetch from network."), + __FUNCTION__); - /* set activity string, so user knows why nothing happens */ - if (!silent && (label1 != NULL)) { - gtk_label_set_text (GTK_LABEL (label1), - _("No files to fetch from network")); - } - } - else { + /* set activity string, so user knows why nothing happens */ + if (!silent && (label1 != NULL)) { + gtk_label_set_text (GTK_LABEL (label1), + _("No files to fetch from network")); + } + } + else { - /* initialise progress bar */ - if (!silent && (progress != NULL)) - start = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress)); + /* initialise progress bar */ + 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); - /* get files */ - for (i = 0; i < numfiles; i++) { + curl_easy_setopt (curl, CURLOPT_USERAGENT, "gpredict/curl"); + curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 10); - /* set URL */ - curfile = g_strconcat (server, files[i], NULL); - file = g_file_new_for_uri (curfile); + /* get files */ + for (i = 0; i < numfiles; i++) { - /* set activity message */ - if (!silent && (label1 != NULL)) { + /* set URL */ + curfile = g_strconcat (server, files[i], NULL); + curl_easy_setopt (curl, CURLOPT_URL, curfile); - text = g_strdup_printf (_("Fetching %s"), files[i]); - gtk_label_set_text (GTK_LABEL (label1), text); - g_free (text); + /* set activity message */ + if (!silent && (label1 != NULL)) { - /* Force the drawing queue to be processed otherwise there will - not be any visual feedback, ie. frozen GUI - - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 - */ - while (g_main_context_iteration (NULL, FALSE)); - } + text = g_strdup_printf (_("Fetching %s"), files[i]); + gtk_label_set_text (GTK_LABEL (label1), text); + g_free (text); - /* create local file */ - locfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", G_DIR_SEPARATOR_S, - "cache", G_DIR_SEPARATOR_S, - files[i], NULL); - outfile = g_file_new_for_path (locfile); + /* Force the drawing queue to be processed otherwise there will + not be any visual feedback, ie. frozen GUI + - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 + */ + while (g_main_context_iteration (NULL, FALSE)); + } - g_file_copy (file, outfile, G_FILE_COPY_NONE, NULL, NULL, NULL, &err); + /* create local file */ + locfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "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); - if (err != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error fetching %s (%s)"), - __FUNCTION__, curfile, err->message); - g_clear_error (&err); - err = NULL; - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Successfully fetched %s"), - __FUNCTION__, curfile); - success++; - } + /* get file */ + res = curl_easy_perform (curl); - /* update progress indicator */ - if (!silent && (progress != NULL)) { + if (res != CURLE_OK) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error fetching %s (%s)"), + __FUNCTION__, curfile, curl_easy_strerror (res)); + error = TRUE; + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Successfully fetched %s"), + __FUNCTION__, curfile); + success++; + } - /* complete download corresponds to 50% */ - fraction = start + (0.5-start) * i / (2.0 * numfiles); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), fraction); + /* update progress indicator */ + if (!silent && (progress != NULL)) { - /* Force the drawing queue to be processed otherwise there will - not be any visual feedback, ie. frozen GUI - - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 - */ - while (g_main_context_iteration (NULL, FALSE)); + /* complete download corresponds to 50% */ + fraction = start + (0.5-start) * i / (2.0 * numfiles); + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), fraction); - } + /* Force the drawing queue to be processed otherwise there will + not be any visual feedback, ie. frozen GUI + - see Gtk+ FAQ http://www.gtk.org/faq/#AEN602 + */ + while (g_main_context_iteration (NULL, FALSE)); - g_free (curfile); - g_free (locfile); - } + } - /* continue update if we have fetched at least one file */ - if (success > 0) { - /* call update_from_files */ - cache = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", G_DIR_SEPARATOR_S, - "cache", NULL); - tle_update_from_files (cache, NULL, silent, progress, label1, label2); - g_free (cache); - } - - } + g_free (curfile); + g_free (locfile); + fclose (outfile); + } - /* clear cache and memory */ - g_free (server); - g_strfreev (files); - g_free (files_tmp); + curl_easy_cleanup (curl); - /* open cache */ - cache = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", G_DIR_SEPARATOR_S, - "cache", NULL); - dir = g_dir_open (cache, 0, &err); + /* continue update if we have fetched at least one file */ + if (success > 0) { + /* call update_from_files */ + cache = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", G_DIR_SEPARATOR_S, + "cache", NULL); + tle_update_from_files (cache, NULL, silent, progress, label1, label2); + g_free (cache); + } + + } - if (err != NULL) { - /* send an error message */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error opening %s (%s)"), - __FUNCTION__, cache, err->message); - g_clear_error (&err); - err = NULL; - } - else { - /* delete files in cache one by one */ - while ((fname = g_dir_read_name (dir)) != NULL) { + /* clear cache and memory */ + g_free (server); + g_strfreev (files); + g_free (files_tmp); + if (proxy != NULL) + g_free (proxy); - locfile = g_strconcat (cache, G_DIR_SEPARATOR_S, - fname, NULL); + /* open cache */ + cache = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", G_DIR_SEPARATOR_S, + "cache", NULL); + dir = g_dir_open (cache, 0, &err); - g_remove (locfile); - g_free (locfile); - } - /* close cache */ - g_dir_close (dir); - } + if (err != NULL) { + /* send an error message */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error opening %s (%s)"), + __FUNCTION__, dir, err->message); + g_clear_error (&err); + } + else { + /* delete files in cache one by one */ + while ((fname = g_dir_read_name (dir)) != NULL) { - g_free (cache); + locfile = g_strconcat (cache, G_DIR_SEPARATOR_S, + fname, NULL); + + g_remove (locfile); + g_free (locfile); + } + /* close cache */ + g_dir_close (dir); + } + + g_free (cache); + + /* clear busy flag */ + tle_in_progress = FALSE; - /* clear busy flag */ - tle_in_progress = FALSE; } +/** \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. @@ -586,91 +624,91 @@ tle_update_from_network (gboolean silent, static gint read_fresh_tle (const gchar *dir, const gchar *fnam, GHashTable *data) { - new_tle_t *ntle; - tle_t tle; - gchar *path; - gchar tle_str[3][80]; - gchar catstr[6]; - FILE *fp; - gint retcode = 0; - guint catnr,i; - guint *key = NULL; - - - path = g_strconcat (dir, G_DIR_SEPARATOR_S, fnam, NULL); - - fp = g_fopen (path, "r"); - - if (fp != NULL) { - - /* read 3 lines at a time */ - while (fgets (tle_str[0], 80, fp)) { - /* read second and third lines */ - fgets (tle_str[1], 80, fp); - fgets (tle_str[2], 80, fp); - - /* copy catnum and convert to integer */ - for (i = 2; i < 7; i++) { - catstr[i-2] = tle_str[1][i]; - } - catstr[5] = '\0'; - catnr = (guint) g_ascii_strtod (catstr, NULL); + new_tle_t *ntle; + tle_t tle; + gchar *path; + gchar tle_str[3][80]; + gchar catstr[6]; + FILE *fp; + gint retcode = 0; + guint catnr,i; + guint *key = NULL; - if (Get_Next_Tle_Set (tle_str, &tle) != 1) { - /* TLE data not good */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Invalid data for %d"), - __FILE__, __FUNCTION__, catnr); - } - else { - /* DATA OK, phew... */ -/* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ -/* _("%s: Good data for %d"), */ -/* __FUNCTION__, */ -/* catnr); */ + path = g_strconcat (dir, G_DIR_SEPARATOR_S, fnam, NULL); - /* add data to hash table */ - key = g_try_new0 (guint, 1); - *key = catnr; + fp = g_fopen (path, "r"); + + if (fp != NULL) { + + /* read 3 lines at a time */ + while (fgets (tle_str[0], 80, fp)) { + /* read second and third lines */ + fgets (tle_str[1], 80, fp); + fgets (tle_str[2], 80, fp); + + /* copy catnum and convert to integer */ + for (i = 2; i < 7; i++) { + catstr[i-2] = tle_str[1][i]; + } + catstr[5] = '\0'; + catnr = (guint) g_ascii_strtod (catstr, NULL); - if (g_hash_table_lookup (data, key) == NULL) { + if (Get_Next_Tle_Set (tle_str, &tle) != 1) { + /* TLE data not good */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Invalid data for %d"), + __FILE__, __FUNCTION__, catnr); + } + else { + /* DATA OK, phew... */ + /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ + /* _("%s: Good data for %d"), */ + /* __FUNCTION__, */ + /* catnr); */ - /* create new_tle structure */ - ntle = g_try_new (new_tle_t, 1); - ntle->epoch = tle.epoch; - ntle->satname = g_strdup (tle_str[0]); - ntle->line1 = g_strdup (tle_str[1]); - ntle->line2 = g_strdup (tle_str[2]); + /* add data to hash table */ + key = g_try_new0 (guint, 1); + *key = catnr; + + + if (g_hash_table_lookup (data, key) == NULL) { + + /* create new_tle structure */ + ntle = g_try_new (new_tle_t, 1); + ntle->epoch = tle.epoch; + ntle->satname = g_strdup (tle_str[0]); + ntle->line1 = g_strdup (tle_str[1]); + ntle->line2 = g_strdup (tle_str[2]); ntle->isnew = TRUE; /* flag will be reset when using data */ - g_hash_table_insert (data, key, ntle); - retcode++; - } - else { - g_free (key); - } - } + g_hash_table_insert (data, key, ntle); + retcode++; + } + else { + g_free (key); + } + } - } + } - /* close input TLE file */ - fclose (fp); + /* close input TLE file */ + fclose (fp); - } + } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Failed to open %s"), - __FILE__, __FUNCTION__, path); - } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Failed to open %s"), + __FILE__, __FUNCTION__, path); + } - g_free (path); + g_free (path); - return retcode; + return retcode; } @@ -693,184 +731,184 @@ read_fresh_tle (const gchar *dir, const gchar *fnam, GHashTable *data) */ static void update_tle_in_file (const gchar *ldname, - const gchar *fname, - GHashTable *data, - guint *sat_upd, - guint *sat_ski, - guint *sat_nod, - guint *sat_tot) + const gchar *fname, + GHashTable *data, + guint *sat_upd, + guint *sat_ski, + guint *sat_nod, + guint *sat_tot) { - gchar *path; - gchar *tmp_path; - guint updated = 0; /* number of updated sats */ - guint nodata = 0; /* no sats for which no fresh data available */ - guint skipped = 0; /* no. sats where fresh data is older */ - guint total = 0; /* total no. of sats in gpredict tle file */ - gchar tle_str[3][80]; - gchar catstr[6]; - FILE *fp; - FILE *tmp; - guint catnr,i; - guint *key = NULL; - tle_t tle; - new_tle_t *ntle; - gint retcode = 0; + gchar *path; + gchar *tmp_path; + guint updated = 0; /* number of updated sats */ + guint nodata = 0; /* no sats for which no fresh data available */ + guint skipped = 0; /* no. sats where fresh data is older */ + guint total = 0; /* total no. of sats in gpredict tle file */ + gchar tle_str[3][80]; + gchar catstr[6]; + FILE *fp; + FILE *tmp; + guint catnr,i; + guint *key = NULL; + tle_t tle; + new_tle_t *ntle; + gint retcode = 0; - /* open input file (file containing old tle) */ - path = g_strconcat (ldname, G_DIR_SEPARATOR_S, fname, NULL); - fp = g_fopen (path, "r"); + /* open input file (file containing old tle) */ + path = g_strconcat (ldname, G_DIR_SEPARATOR_S, fname, NULL); + fp = g_fopen (path, "r"); - if (fp != NULL) { + if (fp != NULL) { - /* open output temp file */ - tmp_path = g_strconcat (ldname, G_DIR_SEPARATOR_S, "TLEUPDATE.tmp", NULL); - tmp = g_fopen (tmp_path, "w"); + /* open output temp file */ + tmp_path = g_strconcat (ldname, G_DIR_SEPARATOR_S, "TLEUPDATE.tmp", NULL); + tmp = g_fopen (tmp_path, "w"); - if (tmp != NULL) { + if (tmp != NULL) { - /* read 3 lines at a time */ - while (fgets (tle_str[0], 80, fp)) { - /* read second and third lines */ - fgets (tle_str[1], 80, fp); - fgets (tle_str[2], 80, fp); + /* read 3 lines at a time */ + while (fgets (tle_str[0], 80, fp)) { + /* read second and third lines */ + fgets (tle_str[1], 80, fp); + fgets (tle_str[2], 80, fp); - /* stats */ - total++; + /* stats */ + total++; - /* copy catnum and convert to integer */ - for (i = 2; i < 7; i++) { - catstr[i-2] = tle_str[1][i]; - } - catstr[5] = '\0'; - catnr = (guint) g_ascii_strtod (catstr, NULL); + /* copy catnum and convert to integer */ + for (i = 2; i < 7; i++) { + catstr[i-2] = tle_str[1][i]; + } + catstr[5] = '\0'; + catnr = (guint) g_ascii_strtod (catstr, NULL); - if (Get_Next_Tle_Set (tle_str, &tle) != 1) { - /* TLE data not good */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Original data for %d seems to be bad"), - __FILE__, __FUNCTION__, catnr); - } - - /* get data from hash table */ - key = g_try_new0 (guint, 1); - *key = catnr; - ntle = (new_tle_t *) g_hash_table_lookup (data, key); - g_free (key); + if (Get_Next_Tle_Set (tle_str, &tle) != 1) { + /* TLE data not good */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Original data for %d seems to be bad"), + __FILE__, __FUNCTION__, catnr); + } + + /* get data from hash table */ + key = g_try_new0 (guint, 1); + *key = catnr; + ntle = (new_tle_t *) g_hash_table_lookup (data, key); + g_free (key); - if (ntle == NULL) { + if (ntle == NULL) { - /* no new data found for this sat => obsolete */ - nodata++; + /* no new data found for this sat => obsolete */ + nodata++; /* check if obsolete sats should be deleted */ /**** FIXME: This is dangereous, so we omit it */ - } - else { + } + else { - /* new data is available for this sat */ - if (tle.epoch < ntle->epoch) { - /* fresh data is newer than original - => update - */ - updated++; + /* new data is available for this sat */ + if (tle.epoch < ntle->epoch) { + /* fresh data is newer than original + => update + */ + updated++; - /* write new data to file */ - fputs (ntle->satname, tmp); - fputs (ntle->line1, tmp); - fputs (ntle->line2, tmp); + /* write new data to file */ + fputs (ntle->satname, tmp); + fputs (ntle->line1, tmp); + fputs (ntle->line2, tmp); - } - else { - /* fresh data is older than original - => don't update - */ - skipped++; + } + else { + /* fresh data is older than original + => don't update + */ + skipped++; - /* write current data back to tle file */ - fputs (tle_str[0], tmp); - fputs (tle_str[1], tmp); - fputs (tle_str[2], tmp); - } + /* write current data back to tle file */ + fputs (tle_str[0], tmp); + fputs (tle_str[1], tmp); + fputs (tle_str[2], tmp); + } /* clear isnew flag */ ntle->isnew = FALSE; - } + } - } + } - fclose (tmp); - fclose (fp); + fclose (tmp); + fclose (fp); - /* if there is at least one updated sat */ - if (updated > 0) { + /* if there is at least one updated sat */ + if (updated > 0) { - /* remove old tle file fp */ - retcode = g_remove (path); + /* remove old tle file fp */ + retcode = g_remove (path); - if (retcode != 0) { - /* could not remove file */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not remove %s (file open?)"), - __FUNCTION__, path); - } + if (retcode != 0) { + /* could not remove file */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not remove %s (file open?)"), + __FUNCTION__, path); + } - /* rename temp file tmp to old tle file */ - retcode = g_rename (tmp_path, path); + /* rename temp file tmp to old tle file */ + retcode = g_rename (tmp_path, path); - if (retcode != 0) { - /* could not rename file */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not rename %s to %s"), - __FUNCTION__, tmp_path, path); - } + if (retcode != 0) { + /* could not rename file */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not rename %s to %s"), + __FUNCTION__, tmp_path, path); + } - } - else { - /* we have to remove the temp file */ - g_remove (tmp_path); - } + } + else { + /* we have to remove the temp file */ + g_remove (tmp_path); + } - } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to open temp file %s"), - __FUNCTION__, tmp_path); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to open temp file %s"), + __FUNCTION__, tmp_path); - /* close input TLE file */ - fclose (fp); - } + /* close input TLE file */ + fclose (fp); + } - /* close input TLE file */ - //fclose (fp); + /* close input TLE file */ + //fclose (fp); - /* free path to tmp file */ - g_free (tmp_path); + /* free path to tmp file */ + g_free (tmp_path); - /* print stats */ - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Update statistics for %s (U/O/N/T): %d/%d/%d/%d"), - __FUNCTION__, fname, - updated, skipped, nodata, total); + /* print stats */ + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Update statistics for %s (U/O/N/T): %d/%d/%d/%d"), + __FUNCTION__, fname, + updated, skipped, nodata, total); - } + } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to open %s"), - __FUNCTION__, path); - } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to open %s"), + __FUNCTION__, path); + } - g_free (path); + g_free (path); - /* update out parameters */ - *sat_upd = updated; - *sat_ski = skipped; - *sat_nod = nodata; - *sat_tot = total; + /* update out parameters */ + *sat_upd = updated; + *sat_ski = skipped; + *sat_nod = nodata; + *sat_tot = total; } @@ -946,7 +984,7 @@ gchar_to_tle (tle_type_t type, const gchar *lines) static gchar * tle_to_gchar (tle_type_t type, tle_t *tle) { - return NULL; + return NULL; } #endif @@ -955,21 +993,21 @@ tle_to_gchar (tle_type_t type, tle_t *tle) const gchar *freq_to_str[TLE_AUTO_UPDATE_NUM] = { - N_("Never"), - N_("Monthly"), - N_("Weekly"), - N_("Daily") + N_("Never"), + N_("Monthly"), + N_("Weekly"), + N_("Daily") }; const gchar * tle_update_freq_to_str (tle_auto_upd_freq_t freq) { - if ((freq < TLE_AUTO_UPDATE_NEVER) || - (freq >= TLE_AUTO_UPDATE_NUM)) { + if ((freq < TLE_AUTO_UPDATE_NEVER) || + (freq >= TLE_AUTO_UPDATE_NUM)) { - freq = TLE_AUTO_UPDATE_NEVER; + freq = TLE_AUTO_UPDATE_NEVER; - } + } - return _(freq_to_str[freq]); + return freq_to_str[freq]; }