comparison finch/gntconv.c @ 28269:7686397d2282

merge of '21bc6a005e10217fb89ff6fe326c1f4174fadf73' and 'e6bbde6f4d46cd78557b9d95f583b3668415e256'
author John Bailey <rekkanoryo@rekkanoryo.org>
date Wed, 16 Sep 2009 15:36:24 +0000
parents f15b14df260d
children 71dc3b5edbe7
comparison
equal deleted inserted replaced
28258:4eca423c63e1 28269:7686397d2282
27 27
28 #include "finch.h" 28 #include "finch.h"
29 #include <internal.h> 29 #include <internal.h>
30 30
31 #include <cmds.h> 31 #include <cmds.h>
32 #include <core.h>
32 #include <idle.h> 33 #include <idle.h>
33 #include <prefs.h> 34 #include <prefs.h>
34 #include <util.h> 35 #include <util.h>
35 36
36 #include "gntaccount.h" 37 #include "gntaccount.h"
1179 static PurpleCmdRet 1180 static PurpleCmdRet
1180 debug_command_cb(PurpleConversation *conv, 1181 debug_command_cb(PurpleConversation *conv,
1181 const char *cmd, char **args, char **error, void *data) 1182 const char *cmd, char **args, char **error, void *data)
1182 { 1183 {
1183 char *tmp, *markup; 1184 char *tmp, *markup;
1184 PurpleCmdStatus status;
1185 1185
1186 if (!g_ascii_strcasecmp(args[0], "version")) { 1186 if (!g_ascii_strcasecmp(args[0], "version")) {
1187 tmp = g_strdup_printf("me is using Finch v%s.", DISPLAY_VERSION); 1187 tmp = g_strdup_printf("Using Finch v%s with libpurple v%s.",
1188 markup = g_markup_escape_text(tmp, -1); 1188 DISPLAY_VERSION, purple_core_get_version());
1189 1189 } else if (!g_ascii_strcasecmp(args[0], "plugins")) {
1190 status = purple_cmd_do_command(conv, tmp, markup, error); 1190 /* Show all the loaded plugins, including the protocol plugins and plugin loaders.
1191 1191 * This is intentional, since third party prpls are often sources of bugs, and some
1192 g_free(tmp); 1192 * plugin loaders (e.g. mono) can also be buggy.
1193 g_free(markup); 1193 */
1194 return status; 1194 GString *str = g_string_new("Loaded Plugins: ");
1195 const GList *plugins = purple_plugins_get_loaded();
1196 if (plugins) {
1197 for (; plugins; plugins = plugins->next) {
1198 str = g_string_append(str, purple_plugin_get_name(plugins->data));
1199 if (plugins->next)
1200 str = g_string_append(str, ", ");
1201 }
1202 } else {
1203 str = g_string_append(str, "(none)");
1204 }
1205
1206 tmp = g_string_free(str, FALSE);
1195 } else { 1207 } else {
1196 purple_conversation_write(conv, NULL, _("Supported debug options are: version"), 1208 purple_conversation_write(conv, NULL, _("Supported debug options are: plugins version"),
1197 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); 1209 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL));
1198 return PURPLE_CMD_STATUS_OK; 1210 return PURPLE_CMD_RET_OK;
1199 } 1211 }
1212
1213 markup = g_markup_escape_text(tmp, -1);
1214 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
1215 purple_conv_im_send(PURPLE_CONV_IM(conv), markup);
1216 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
1217 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), markup);
1218
1219 g_free(tmp);
1220 g_free(markup);
1221 return PURPLE_CMD_RET_OK;
1200 } 1222 }
1201 1223
1202 /* Xerox */ 1224 /* Xerox */
1203 static PurpleCmdRet 1225 static PurpleCmdRet
1204 clear_command_cb(PurpleConversation *conv, 1226 clear_command_cb(PurpleConversation *conv,
1205 const char *cmd, char **args, char **error, void *data) 1227 const char *cmd, char **args, char **error, void *data)
1206 { 1228 {
1207 FinchConv *ggconv = FINCH_GET_DATA(conv); 1229 FinchConv *ggconv = FINCH_GET_DATA(conv);
1208 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); 1230 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv));
1209 purple_conversation_clear_message_history(conv); 1231 purple_conversation_clear_message_history(conv);
1210 return PURPLE_CMD_STATUS_OK; 1232 return PURPLE_CMD_RET_OK;
1211 } 1233 }
1212 1234
1213 /* Xerox */ 1235 /* Xerox */
1214 static PurpleCmdRet 1236 static PurpleCmdRet
1215 help_command_cb(PurpleConversation *conv, 1237 help_command_cb(PurpleConversation *conv,
1245 } 1267 }
1246 1268
1247 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); 1269 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL));
1248 g_string_free(s, TRUE); 1270 g_string_free(s, TRUE);
1249 1271
1250 return PURPLE_CMD_STATUS_OK; 1272 return PURPLE_CMD_RET_OK;
1251 } 1273 }
1252 1274
1253 static PurpleCmdRet 1275 static PurpleCmdRet
1254 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) 1276 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
1255 { 1277 {
1256 void (*callback)(void) = data; 1278 void (*callback)(void) = data;
1257 callback(); 1279 callback();
1258 return PURPLE_CMD_STATUS_OK; 1280 return PURPLE_CMD_RET_OK;
1259 } 1281 }
1260 1282
1261 #if GLIB_CHECK_VERSION(2,6,0) 1283 #if GLIB_CHECK_VERSION(2,6,0)
1262 static PurpleCmdRet 1284 static PurpleCmdRet
1263 cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) 1285 cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
1276 else if (strcmp(args[0], "timestamp") == 0) 1298 else if (strcmp(args[0], "timestamp") == 0)
1277 msgclass = &color_timestamp; 1299 msgclass = &color_timestamp;
1278 else { 1300 else {
1279 if (error) 1301 if (error)
1280 *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]); 1302 *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]);
1281 return PURPLE_CMD_STATUS_FAILED; 1303 return PURPLE_CMD_RET_FAILED;
1282 } 1304 }
1283 1305
1284 fg = gnt_colors_get_color(args[1]); 1306 fg = gnt_colors_get_color(args[1]);
1285 if (fg == -EINVAL) { 1307 if (fg == -EINVAL) {
1286 if (error) 1308 if (error)
1287 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]); 1309 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]);
1288 return PURPLE_CMD_STATUS_FAILED; 1310 return PURPLE_CMD_RET_FAILED;
1289 } 1311 }
1290 1312
1291 bg = gnt_colors_get_color(args[2]); 1313 bg = gnt_colors_get_color(args[2]);
1292 if (bg == -EINVAL) { 1314 if (bg == -EINVAL) {
1293 if (error) 1315 if (error)
1294 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]); 1316 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]);
1295 return PURPLE_CMD_STATUS_FAILED; 1317 return PURPLE_CMD_RET_FAILED;
1296 } 1318 }
1297 1319
1298 init_pair(*msgclass, fg, bg); 1320 init_pair(*msgclass, fg, bg);
1299 1321
1300 return PURPLE_CMD_STATUS_OK; 1322 return PURPLE_CMD_RET_OK;
1301 } 1323 }
1302 #endif 1324 #endif
1303 1325
1304 static PurpleCmdRet 1326 static PurpleCmdRet
1305 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) 1327 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
1306 { 1328 {
1307 FinchConv *fc = FINCH_GET_DATA(conv); 1329 FinchConv *fc = FINCH_GET_DATA(conv);
1308 FinchConvChat *ch; 1330 FinchConvChat *ch;
1309 if (!fc) 1331 if (!fc)
1310 return PURPLE_CMD_STATUS_FAILED; 1332 return PURPLE_CMD_RET_FAILED;
1311 1333
1312 ch = fc->u.chat; 1334 ch = fc->u.chat;
1313 gnt_widget_set_visible(ch->userlist, 1335 gnt_widget_set_visible(ch->userlist,
1314 (GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE))); 1336 (GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE)));
1315 gnt_box_readjust(GNT_BOX(fc->window)); 1337 gnt_box_readjust(GNT_BOX(fc->window));
1316 gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry); 1338 gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry);
1317 purple_prefs_set_bool(PREF_USERLIST, !(GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE))); 1339 purple_prefs_set_bool(PREF_USERLIST, !(GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE)));
1318 return PURPLE_CMD_STATUS_OK; 1340 return PURPLE_CMD_RET_OK;
1319 } 1341 }
1320 1342
1321 void finch_conversation_init() 1343 void finch_conversation_init()
1322 { 1344 {
1323 color_message_send = gnt_style_get_color(NULL, "color-message-sent"); 1345 color_message_send = gnt_style_get_color(NULL, "color-message-sent");