comparison plugins/timestamp_format.c @ 13987:f94309c7c480

[gaim-migrate @ 16559] Change the log-timestamp and conversation-timestamp signals to pass around a time_t instead of a struct tm. Most of this changeset is Ethan's work. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 24 Jul 2006 05:08:30 +0000
parents c73c7dd0721f
children
comparison
equal deleted inserted replaced
13986:8a8b4f7f7d99 13987:f94309c7c480
50 50
51 return frame; 51 return frame;
52 } 52 }
53 53
54 static char *timestamp_cb_common(GaimConversation *conv, 54 static char *timestamp_cb_common(GaimConversation *conv,
55 const struct tm *tm, 55 time_t t,
56 gboolean force, 56 gboolean force,
57 const char *dates) 57 const char *dates)
58 { 58 {
59 struct tm *tm = localtime(&t);
59 g_return_val_if_fail(conv != NULL, NULL); 60 g_return_val_if_fail(conv != NULL, NULL);
60 g_return_val_if_fail(tm != NULL, NULL);
61 g_return_val_if_fail(dates != NULL, NULL); 61 g_return_val_if_fail(dates != NULL, NULL);
62 62
63 if (!strcmp(dates, "always") || 63 if (!strcmp(dates, "always") ||
64 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && 64 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT &&
65 !strcmp(dates, "chats")) || 65 !strcmp(dates, "chats")) ||
66 (time(NULL) > (mktime((struct tm *)tm) + 20*60))) 66 (time(NULL) > (mktime(tm) + 20*60)))
67 { 67 {
68 if (force) 68 if (force)
69 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); 69 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm));
70 else 70 else
71 return g_strdup(gaim_date_format_long(tm)); 71 return g_strdup(gaim_date_format_long(tm));
76 76
77 return NULL; 77 return NULL;
78 } 78 }
79 79
80 static char *conversation_timestamp_cb(GaimConversation *conv, 80 static char *conversation_timestamp_cb(GaimConversation *conv,
81 const struct tm *tm, gpointer data) 81 time_t t, gpointer data)
82 { 82 {
83 gboolean force = gaim_prefs_get_bool( 83 gboolean force = gaim_prefs_get_bool(
84 "/plugins/gtk/timestamp_format/force_24hr"); 84 "/plugins/gtk/timestamp_format/force_24hr");
85 const char *dates = gaim_prefs_get_string( 85 const char *dates = gaim_prefs_get_string(
86 "/plugins/gtk/timestamp_format/use_dates/conversation"); 86 "/plugins/gtk/timestamp_format/use_dates/conversation");
87 87
88 g_return_val_if_fail(conv != NULL, NULL); 88 g_return_val_if_fail(conv != NULL, NULL);
89 g_return_val_if_fail(tm != NULL, NULL);
90 89
91 return timestamp_cb_common(conv, tm, force, dates); 90 return timestamp_cb_common(conv, t, force, dates);
92 } 91 }
93 92
94 static char *log_timestamp_cb(GaimLog *log, 93 static char *log_timestamp_cb(GaimLog *log, time_t t, gpointer data)
95 const struct tm *tm, gpointer data)
96 { 94 {
97 gboolean force = gaim_prefs_get_bool( 95 gboolean force = gaim_prefs_get_bool(
98 "/plugins/gtk/timestamp_format/force_24hr"); 96 "/plugins/gtk/timestamp_format/force_24hr");
99 const char *dates = gaim_prefs_get_string( 97 const char *dates = gaim_prefs_get_string(
100 "/plugins/gtk/timestamp_format/use_dates/log"); 98 "/plugins/gtk/timestamp_format/use_dates/log");
101 99
102 g_return_val_if_fail(log != NULL, NULL); 100 g_return_val_if_fail(log != NULL, NULL);
103 g_return_val_if_fail(tm != NULL, NULL);
104 101
105 if (log->type == GAIM_LOG_SYSTEM) 102 if (log->type == GAIM_LOG_SYSTEM)
106 { 103 {
107 if (force) 104 if (force) {
105 struct tm *tm = localtime(&t);
108 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); 106 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm));
109 else 107 } else {
110 return NULL; 108 return NULL;
109 }
111 } 110 }
112 111
113 return timestamp_cb_common(log->conv, tm, force, dates); 112 return timestamp_cb_common(log->conv, t, force, dates);
114 } 113 }
115 114
116 static gboolean 115 static gboolean
117 plugin_load(GaimPlugin *plugin) 116 plugin_load(GaimPlugin *plugin)
118 { 117 {