pidgin/pidgin

Parents 7f0cde300360
Children 54b2a95ac176
Fix building on glib < 2.58.0 as we have a minimum of 2.52.0

Add compatibility for G_SOURCE_FUNC and g_time_zone_new_offset that were added in 2.58.0

g_time_zone_new_offset is from 2.58.0 which might be buggy, the version of it
from glib git has some fixes it but it is much more involved so using the older
version is a calculated risk.

Testing Done:
Built on ubuntu:bionic.

Reviewed at https://reviews.imfreedom.org/r/573/
--- a/libpurple/glibcompat.h Sat Mar 13 05:39:22 2021 -0600
+++ b/libpurple/glibcompat.h Sat Mar 13 15:33:49 2021 -0600
@@ -49,6 +49,34 @@
# define g_stat purple_g_stat
#endif
+#if !GLIB_CHECK_VERSION(2, 58, 0)
+#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
+
+static inline GTimeZone *
+g_time_zone_new_offset(gint32 seconds) {
+ GTimeZone *tz = NULL;
+ gchar *identifier = NULL;
+
+ /* Seemingly, we should be using @seconds directly to set the
+ * #TransitionInfo.gmt_offset to avoid all this string building and
+ * parsing. However, we always need to set the #GTimeZone.name to a
+ * constructed string anyway, so we might as well reuse its code.
+ */
+ identifier = g_strdup_printf("%c%02u:%02u:%02u",
+ (seconds >= 0) ? '+' : '-',
+ (ABS (seconds) / 60) / 60,
+ (ABS (seconds) / 60) % 60,
+ ABS (seconds) % 60);
+ tz = g_time_zone_new(identifier);
+ g_free(identifier);
+
+ g_assert(g_time_zone_get_offset(tz, 0) == seconds);
+
+ return tz;
+}
+
+#endif /* !GLIB_CHECK_VERSION(2, 58, 0) */
+
#if !GLIB_CHECK_VERSION(2, 62, 0)
#define g_date_time_format_iso8601(dt) (purple_compat_date_time_format_iso8601((dt)))
gchar *purple_compat_date_time_format_iso8601(GDateTime *datetime);
--- a/libpurple/protocols/jabber/buddy.c Sat Mar 13 05:39:22 2021 -0600
+++ b/libpurple/protocols/jabber/buddy.c Sat Mar 13 15:33:49 2021 -0600
@@ -24,6 +24,8 @@
#include <purple.h>
+#include "glibcompat.h"
+
#include "buddy.h"
#include "chat.h"
#include "jabber.h"
--- a/libpurple/stun.c Sat Mar 13 05:39:22 2021 -0600
+++ b/libpurple/stun.c Sat Mar 13 15:33:49 2021 -0600
@@ -30,6 +30,8 @@
#include <gio/gio.h>
+#include "glibcompat.h"
+
#include "debug.h"
#include "account.h"
#include "network.h"
--- a/libpurple/upnp.c Sat Mar 13 05:39:22 2021 -0600
+++ b/libpurple/upnp.c Sat Mar 13 15:33:49 2021 -0600
@@ -25,6 +25,8 @@
#include "upnp.h"
+#include "glibcompat.h"
+
#include "debug.h"
#include "eventloop.h"
#include "network.h"