Sun, 16 Aug 2020 03:28:38 -0500
Fix some easy compiler warnings
make ggp_date_from_iso8601 use a GDateTime instead of GTimeVal and have it return a gint64
Wrap a signal callback in a G_CALLBACK like it should be
Remove some unused variables
Only include sysctl.h on platforms where we need it. It's deprecated under gcc now.
Testing Done:
Compiled on freebsd 12.0, netbsd 9.0, openbsd 6.7, mac, and linux without issues.
Reviewed at https://reviews.imfreedom.org/r/69/
--- a/finch/gntconv.c Sat Aug 15 23:33:09 2020 -0500 +++ b/finch/gntconv.c Sun Aug 16 03:28:38 2020 -0500 @@ -742,7 +742,6 @@ char *title; PurpleConversation *cc; PurpleAccount *account; - PurpleBlistNode *convnode = NULL; if (ggc) { gnt_window_present(ggc->window);
--- a/libpurple/accounts.c Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/accounts.c Sun Aug 16 03:28:38 2020 -0500 @@ -997,7 +997,7 @@ g_signal_connect(G_OBJECT(g_network_monitor_get_default()), "network-changed", - purple_accounts_network_changed_cb, NULL); + G_CALLBACK(purple_accounts_network_changed_cb), NULL); } void
--- a/libpurple/nat-pmp.c Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/nat-pmp.c Sun Aug 16 03:28:38 2020 -0500 @@ -32,23 +32,20 @@ #include "signals.h" #include "network.h" -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif +#include <sys/types.h> #ifdef HAVE_SYS_SYSCTL_H -#include <sys/sysctl.h> +# include <sys/sysctl.h> #endif #ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> +# include <sys/socket.h> #endif /* We will need sysctl() and NET_RT_DUMP, both of which are not present * on all platforms, to continue. */ #if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_DUMP) -#include <sys/types.h> #include <net/route.h> #define PMP_DEBUG 1
--- a/libpurple/protocols/gg/pubdir-prpl.c Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/protocols/gg/pubdir-prpl.c Sun Aug 16 03:28:38 2020 -0500 @@ -116,6 +116,7 @@ g_free(records[i].first_name); g_free(records[i].last_name); g_free(records[i].city); + g_date_time_unref(records[i].birth); } g_free(records); } @@ -214,6 +215,7 @@ record->nickname = ggp_free_if_equal(record->nickname, ""); record->first_name = ggp_free_if_equal(record->first_name, ""); record->last_name = ggp_free_if_equal(record->last_name, ""); + g_clear_pointer(&record->birth, g_date_time_unref); if (record->label) {} else if (record->nickname) @@ -246,7 +248,7 @@ record->city = NULL; } - record->birth = ggp_date_from_iso8601(birth_s); + record->birth = g_date_time_new_from_iso8601(birth_s, NULL); /*TODO: calculate age from birth */ if (purple_debug_is_verbose()) { @@ -256,7 +258,7 @@ "[birth:%lu]\n", record->uin, record->label, record->nickname, record->first_name, record->last_name, record->city, record->gender, - record->age, record->birth); + record->age, g_date_time_to_unix(record->birth)); } g_free(city); @@ -386,8 +388,11 @@ record->city); } if (record->birth) { - purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), - ggp_date_strftime("%Y-%m-%d", record->birth)); + gchar *bday = g_date_time_format(record->birth, "%Y-%m-%d"); + + purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), bday); + + g_free(bday); } else if (record->age) { gchar *age_s = g_strdup_printf("%d", record->age); purple_notify_user_info_add_pair_plaintext(info, _("Age"), @@ -778,6 +783,7 @@ gchar *url; gchar *request_data; gchar *name, *surname, *city; + gchar *bday; uin_t uin = record->uin; PURPLE_ASSERT_CONNECTION_IS_VALID(gc); @@ -794,6 +800,8 @@ surname = g_uri_escape_string(record->last_name, NULL, FALSE); city = g_uri_escape_string(record->city, NULL, FALSE); + bday = g_date_time_format(record->birth, "%Y-%m-%d"); + request_data = g_strdup_printf( "name=%s&" "surname=%s&" @@ -804,11 +812,13 @@ "city=%s&" "province=%d", name, surname, - ggp_date_strftime("%Y-%m-%d", record->birth), + bday, record->gender, city, record->province); + g_free(bday); + if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { purple_debug_misc("gg", "ggp_pubdir_set_info_got_token: " "query [%s]\n", request_data); @@ -851,10 +861,10 @@ birth_s = g_strdup_printf( "%sT10:00:00+00:00", purple_request_fields_get_string(fields, "birth_date")); - record->birth = ggp_date_from_iso8601(birth_s); + record->birth = g_date_time_new_from_iso8601(birth_s, NULL); g_free(birth_s); purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]", - record->birth, + g_date_time_to_unix(record->birth), purple_request_fields_get_string(fields, "birth_date")); url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin); @@ -870,6 +880,7 @@ PurpleRequestFields *fields; PurpleRequestFieldGroup *group; PurpleRequestField *field; + gchar *bday = NULL; gsize i; const ggp_pubdir_record *record; @@ -903,12 +914,14 @@ GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE)); purple_request_field_group_add_field(group, field); + if(record != NULL && record->birth != NULL) { + bday = g_date_time_format(record->birth, "%Y-%m-%d"); + } + field = purple_request_field_string_new( - "birth_date", _("Birth Day"), - (record && record->birth) - ? ggp_date_strftime("%Y-%m-%d", record->birth) - : NULL, + "birth_date", _("Birth Day"), bday, FALSE); + g_free(bday); purple_request_field_set_required(field, TRUE); purple_request_field_group_add_field(group, field);
--- a/libpurple/protocols/gg/pubdir-prpl.h Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/protocols/gg/pubdir-prpl.h Sun Aug 16 03:28:38 2020 -0500 @@ -50,7 +50,7 @@ ggp_pubdir_gender gender; gchar *city; unsigned int province; - time_t birth; + GDateTime *birth; unsigned int age; } ggp_pubdir_record;
--- a/libpurple/protocols/gg/utils.c Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/protocols/gg/utils.c Sun Aug 16 03:28:38 2020 -0500 @@ -219,28 +219,6 @@ return str; } -const gchar * ggp_date_strftime(const gchar *format, time_t date) -{ - GDate g_date; - static gchar buff[30]; - - g_date_set_time_t(&g_date, date); - if (0 == g_date_strftime(buff, sizeof(buff), format, &g_date)) - return NULL; - return buff; -} - -time_t ggp_date_from_iso8601(const gchar *str) -{ - GTimeVal g_timeval; - - if (!str) - return 0; - if (!g_time_val_from_iso8601(str, &g_timeval)) - return 0; - return g_timeval.tv_sec; -} - uint64_t * ggp_uint64dup(uint64_t val) { uint64_t *ptr = g_new(uint64_t, 1);
--- a/libpurple/protocols/gg/utils.h Sat Aug 15 23:33:09 2020 -0500 +++ b/libpurple/protocols/gg/utils.h Sun Aug 16 03:28:38 2020 -0500 @@ -99,10 +99,6 @@ gchar * ggp_free_if_equal(gchar *str, const gchar *pattern); -const gchar * ggp_date_strftime(const gchar *format, time_t date); - -time_t ggp_date_from_iso8601(const gchar *str); - uint64_t * ggp_uint64dup(uint64_t val); gint ggp_int64_compare(gconstpointer a, gconstpointer b);
--- a/meson.build Sat Aug 15 23:33:09 2020 -0500 +++ b/meson.build Sun Aug 16 03:28:38 2020 -0500 @@ -738,22 +738,19 @@ compiler.has_header(header)) endforeach -# sys/sysctl.h on OpenBSD 4.2 requires sys/param.h -# sys/sysctl.h on FreeBSD requires sys/types.h -have_sys_param_h = compiler.has_header('sys/param.h') -conf.set('HAVE_SYS_PARAM_H', have_sys_param_h) -prefix = ''' +# OpenBSD 6.7 and FreeBSD 12 require including sys/types.h before sys/sysctl.h. +# NetBSD 9.0 doesn't care. +if target_machine.system() in ['freebsd', 'openbsd'] + prefix = ''' #include <sys/types.h> ''' -if have_sys_param_h - prefix += ''' -#include <sys/param.h> -''' + + conf.set('HAVE_SYS_SYSCTL_H', + compiler.has_header('sys/sysctl.h', prefix : prefix)) + conf.set('HAVE_SYS_SOCKET_H', + compiler.has_header('sys/socket.h')) endif -conf.set('HAVE_SYS_SYSCTL_H', - compiler.has_header('sys/sysctl.h', prefix : prefix)) -conf.set('HAVE_SYS_SOCKET_H', - compiler.has_header('sys/socket.h')) + #AC_VAR_TIMEZONE_EXTERNALS #######################################################################