pidgin/pidgin

Remove purple_date_format_full

19 months ago, Elliott Sales de Andrade
4a51008d3f64
Parents 5c21747ff7dc
Children 5d2bc2736da2
Remove purple_date_format_full

And inline it instead. Somehow with all these uses, it's still more delete than insert.

Testing Done:
Compiled.

Reviewed at https://reviews.imfreedom.org/r/1869/
--- a/ChangeLog.API Thu Sep 29 23:43:08 2022 -0500
+++ b/ChangeLog.API Fri Sep 30 03:09:55 2022 -0500
@@ -450,6 +450,7 @@
or whatever is appropriate for your UI.
* purple_core_migrate
* Removed the general Purple DBus interface
+ * purple_date_format_full, use g_date_time_format instead.
* purple_date_format_long, use g_date_time_format instead.
* purple_date_format_short, use g_date_time_format instead.
* PurpleDebugUiOps
--- a/finch/gntdebug.c Thu Sep 29 23:43:08 2022 -0500
+++ b/finch/gntdebug.c Fri Sep 30 03:09:55 2022 -0500
@@ -230,16 +230,24 @@
file_save(GntFileSel *fs, const char *path, const char *file, GntTextView *tv)
{
FILE *fp;
+ GDateTime *date = NULL;
+ gchar *date_str = NULL;
if ((fp = g_fopen(path, "w+")) == NULL) {
purple_notify_error(NULL, NULL, _("Unable to open file."), NULL, NULL);
return;
}
- fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(NULL));
+ date = g_date_time_new_now_local();
+ date_str = g_date_time_format(date, "%c");
+
+ fprintf(fp, "Finch Debug Log : %s\n", date_str);
fprintf(fp, "%s", gnt_text_view_get_text(tv));
fclose(fp);
gnt_widget_destroy(GNT_WIDGET(fs));
+
+ g_free(date_str);
+ g_date_time_unref(date);
}
static void
--- a/libpurple/protocols/gg/chat.c Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/protocols/gg/chat.c Fri Sep 30 03:09:55 2022 -0500
@@ -586,21 +586,21 @@
PurpleRoomlistRoom *room;
ggp_chat_local_info *chat = &sdata->chats[i];
const gchar *name;
- time_t date;
+ GDateTime *date = NULL;
const gchar *status;
int count = chat->participants_count;
- date = (uint32_t)(chat->id >> 32);
+ date = g_date_time_new_from_unix_local((uint32_t)(chat->id >> 32));
- if (chat->conv)
+ if (chat->conv) {
status = _("Joined");
- else if (chat->left)
+ } else if (chat->left) {
/* Translators: For Gadu-Gadu, this is one possible status for a
chat room. It means you had previously joined the chat room but
you have since left it. You cannot rejoin without another
invitation. */
status = _("Chat left");
- else {
+ } else {
status = _("Can join chat");
count--;
}
@@ -610,10 +610,11 @@
purple_roomlist_room_set_user_count(room, (guint)count);
purple_roomlist_room_add_field(room, "id", g_strdup(name));
purple_roomlist_room_add_field(room, "date",
- g_strdup(purple_date_format_full(localtime(&date))));
+ g_date_time_format(date, "%c"));
purple_roomlist_room_add_field(room, "status", g_strdup(status));
purple_roomlist_room_add(roomlist, room);
g_object_unref(room);
+ g_date_time_unref(date);
}
/* TODO
--- a/libpurple/protocols/gg/multilogon.c Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/protocols/gg/multilogon.c Fri Sep 30 03:09:55 2022 -0500
@@ -41,7 +41,7 @@
uint64_t id;
uint32_t remote_addr;
gchar *name;
- time_t logon_time;
+ GDateTime *logon_time;
} ggp_multilogon_session_info;
struct _ggp_multilogon_session_data
@@ -82,8 +82,10 @@
ggp_multilogon_session_data *mldata = ggp_multilogon_get_mldata(gc);
int i;
- for (i = 0; i < mldata->session_count; i++)
+ for (i = 0; i < mldata->session_count; i++) {
g_free(mldata->sessions[i].name);
+ g_clear_pointer(&mldata->sessions[i].logon_time, g_date_time_unref);
+ }
g_free(mldata->sessions);
mldata->sessions = NULL;
@@ -137,16 +139,19 @@
for (i = 0; i < mldata->session_count; i++) {
ggp_multilogon_session_info *sess = &mldata->sessions[i];
PurpleRequestDatasheetRecord *rec;
+ gchar *tmp = NULL;
rec = purple_request_datasheet_record_add(sheet,
ggp_keymapper_to_key(km, sess->id));
purple_request_datasheet_record_set_string_data(rec, 0,
ggp_ipv4_to_str(sess->remote_addr));
- purple_request_datasheet_record_set_string_data(rec, 1,
- purple_date_format_full(localtime(&sess->logon_time)));
- purple_request_datasheet_record_set_string_data(rec, 2,
- sess->name);
+
+ tmp = g_date_time_format(sess->logon_time, "%c");
+ purple_request_datasheet_record_set_string_data(rec, 1, tmp);
+ g_free(tmp);
+
+ purple_request_datasheet_record_set_string_data(rec, 2, sess->name);
}
purple_request_datasheet_record_remove_marked(sheet);
@@ -171,7 +176,7 @@
psess->id = ggp_multilogon_sid_from_libgadu(lsess->id);
psess->remote_addr = lsess->remote_addr;
psess->name = g_strdup(lsess->name);
- psess->logon_time = lsess->logon_time;
+ psess->logon_time = g_date_time_new_from_unix_local(lsess->logon_time);
}
mldata->session_count = info->count;
--- a/libpurple/protocols/irc/msgs.c Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/protocols/irc/msgs.c Fri Sep 30 03:09:55 2022 -0500
@@ -450,11 +450,19 @@
g_string_free(irc->whois.channels, TRUE);
}
if (irc->whois.idle) {
- gchar *timex = purple_str_seconds_to_string(irc->whois.idle);
- purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"), timex);
- g_free(timex);
+ GDateTime *signon = NULL;
+
+ tmp = purple_str_seconds_to_string(irc->whois.idle);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"),
+ tmp);
+ g_free(tmp);
+
+ signon = g_date_time_new_from_unix_local(irc->whois.signon);
+ tmp = g_date_time_format(signon, "%c");
purple_notify_user_info_add_pair_plaintext(user_info,
- _("Online since"), purple_date_format_full(localtime(&irc->whois.signon)));
+ _("Online since"), tmp);
+ g_free(tmp);
+ g_date_time_unref(signon);
}
if (purple_strequal(irc->whois.nick, "elb")) {
purple_notify_user_info_add_pair_plaintext(user_info,
--- a/libpurple/protocols/novell/novell.c Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/protocols/novell/novell.c Fri Sep 30 03:09:55 2022 -0500
@@ -1914,7 +1914,8 @@
const char *secondary = NULL;
const char *name = NULL;
char *primary = NULL;
- time_t gmt;
+ GDateTime *gmt = NULL;
+ gchar *gmt_str = NULL;
ur = nm_find_user_record(user, nm_event_get_source(event));
if (ur)
@@ -1923,10 +1924,11 @@
if (name == NULL)
name = nm_event_get_source(event);
- gmt = nm_event_get_gmt(event);
+ gmt = g_date_time_new_from_unix_local(nm_event_get_gmt(event));
+ gmt_str = g_date_time_format(gmt, "%c");
title = _("Invitation to Conversation");
primary = g_strdup_printf(_("Invitation from: %s\n\nSent: %s"),
- name, purple_date_format_full(localtime(&gmt)));
+ name, gmt_str);
secondary = _("Would you like to join the conversation?");
/* Set up params list for the callbacks
@@ -1947,6 +1949,8 @@
_("Yes"), G_CALLBACK(_join_conference_cb),
_("No"), G_CALLBACK(_reject_conference_cb));
+ g_free(gmt_str);
+ g_date_time_unref(gmt);
g_free(primary);
}
--- a/libpurple/util.c Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/util.c Fri Sep 30 03:09:55 2022 -0500
@@ -48,39 +48,6 @@
}
/**************************************************************************
- * Date/Time Functions
- **************************************************************************/
-const char *
-purple_date_format_full(const struct tm *tm)
-{
- static char buf[128];
- GDateTime *dt;
- char *utf8;
-
- if (tm == NULL)
- {
- dt = g_date_time_new_now_local();
- } else {
- dt = g_date_time_new_local(tm->tm_year + 1900, tm->tm_mon + 1,
- tm->tm_mday, tm->tm_hour,
- tm->tm_min, tm->tm_sec);
- }
-
- utf8 = g_date_time_format(dt, "%c");
- g_date_time_unref(dt);
-
- if (utf8 == NULL) {
- purple_debug_error("util",
- "purple_date_format_full(): Formatting failed\n");
- return "";
- }
-
- g_strlcpy(buf, utf8, sizeof(buf));
- g_free(utf8);
- return buf;
-}
-
-/**************************************************************************
* Path/Filename Functions
**************************************************************************/
static gboolean
--- a/libpurple/util.h Thu Sep 29 23:43:08 2022 -0500
+++ b/libpurple/util.h Fri Sep 30 03:09:55 2022 -0500
@@ -87,20 +87,6 @@
/**************************************************************************/
/**
- * purple_date_format_full:
- * @tm: The time to format, or %NULL to use the current local time
- *
- * Formats a time into the user's preferred full date and time format.
- *
- * The returned string is stored in a static buffer, so the result
- * should be g_strdup()'d if it's going to be kept.
- *
- * Returns: The date and time, formatted as per the user's settings. In the
- * USA this is something like "Mon Feb 18 15:26:44 2013"
- */
-const char *purple_date_format_full(const struct tm *tm);
-
-/**
* PURPLE_NO_TZ_OFF:
*
* Used by purple_str_to_time to indicate no timezone offset was
--- a/pidgin/pidgindebug.c Thu Sep 29 23:43:08 2022 -0500
+++ b/pidgin/pidgindebug.c Fri Sep 30 03:09:55 2022 -0500
@@ -114,6 +114,8 @@
GFile *file = NULL;
GFileOutputStream *output = NULL;
GtkTextIter start, end;
+ GDateTime *date = NULL;
+ gchar *date_str = NULL;
gchar *tmp = NULL;
GError *error = NULL;
@@ -131,10 +133,14 @@
return;
}
- tmp = g_strdup_printf("Pidgin Debug Log : %s\n", purple_date_format_full(NULL));
+ date = g_date_time_new_now_local();
+ date_str = g_date_time_format(date, "%c");
+
+ tmp = g_strdup_printf("Pidgin Debug Log : %s\n", date_str);
g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
NULL, NULL, &error);
g_free(tmp);
+ g_free(date_str);
if(error != NULL) {
purple_debug_error("debug", "Unable to save debug log: %s",