| 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 time_t t, |
55 time_t t, |
| |
56 gboolean show_date, |
| 56 gboolean force, |
57 gboolean force, |
| 57 const char *dates) |
58 const char *dates) |
| 58 { |
59 { |
| 59 struct tm *tm = localtime(&t); |
|
| 60 g_return_val_if_fail(conv != NULL, NULL); |
60 g_return_val_if_fail(conv != 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 (show_date || |
| 64 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
64 !strcmp(dates, "always") || |
| 65 !strcmp(dates, "chats")) || |
65 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) |
| 66 (time(NULL) > (mktime(tm) + 20*60))) |
|
| 67 { |
66 { |
| |
67 struct tm *tm = localtime(&t); |
| 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)); |
| 72 } |
72 } |
| 73 |
73 |
| 74 if (force) |
74 if (force) |
| |
75 { |
| |
76 struct tm *tm = localtime(&t); |
| 75 return g_strdup(gaim_utf8_strftime("%H:%M:%S", tm)); |
77 return g_strdup(gaim_utf8_strftime("%H:%M:%S", tm)); |
| |
78 } |
| 76 |
79 |
| 77 return NULL; |
80 return NULL; |
| 78 } |
81 } |
| 79 |
82 |
| 80 static char *conversation_timestamp_cb(GaimConversation *conv, |
83 static char *conversation_timestamp_cb(GaimConversation *conv, |
| 81 time_t t, gpointer data) |
84 time_t t, gboolean show_date, gpointer data) |
| 82 { |
85 { |
| 83 gboolean force = gaim_prefs_get_bool( |
86 gboolean force = gaim_prefs_get_bool( |
| 84 "/plugins/gtk/timestamp_format/force_24hr"); |
87 "/plugins/gtk/timestamp_format/force_24hr"); |
| 85 const char *dates = gaim_prefs_get_string( |
88 const char *dates = gaim_prefs_get_string( |
| 86 "/plugins/gtk/timestamp_format/use_dates/conversation"); |
89 "/plugins/gtk/timestamp_format/use_dates/conversation"); |
| 87 |
90 |
| 88 g_return_val_if_fail(conv != NULL, NULL); |
91 g_return_val_if_fail(conv != NULL, NULL); |
| 89 |
92 |
| 90 return timestamp_cb_common(conv, t, force, dates); |
93 return timestamp_cb_common(conv, t, show_date, force, dates); |
| 91 } |
94 } |
| 92 |
95 |
| 93 static char *log_timestamp_cb(GaimLog *log, time_t t, gpointer data) |
96 static char *log_timestamp_cb(GaimLog *log, time_t t, gboolean show_date, gpointer data) |
| 94 { |
97 { |
| 95 gboolean force = gaim_prefs_get_bool( |
98 gboolean force = gaim_prefs_get_bool( |
| 96 "/plugins/gtk/timestamp_format/force_24hr"); |
99 "/plugins/gtk/timestamp_format/force_24hr"); |
| 97 const char *dates = gaim_prefs_get_string( |
100 const char *dates = gaim_prefs_get_string( |
| 98 "/plugins/gtk/timestamp_format/use_dates/log"); |
101 "/plugins/gtk/timestamp_format/use_dates/log"); |
| 99 |
102 |
| 100 g_return_val_if_fail(log != NULL, NULL); |
103 g_return_val_if_fail(log != NULL, NULL); |
| 101 |
104 |
| 102 if (log->type == GAIM_LOG_SYSTEM) |
105 return timestamp_cb_common(log->conv, t, show_date, force, dates); |
| 103 { |
|
| 104 if (force) { |
|
| 105 struct tm *tm = localtime(&t); |
|
| 106 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); |
|
| 107 } else { |
|
| 108 return NULL; |
|
| 109 } |
|
| 110 } |
|
| 111 |
|
| 112 return timestamp_cb_common(log->conv, t, force, dates); |
|
| 113 } |
106 } |
| 114 |
107 |
| 115 static gboolean |
108 static gboolean |
| 116 plugin_load(GaimPlugin *plugin) |
109 plugin_load(GaimPlugin *plugin) |
| 117 { |
110 { |