pidgin/gtkconv.c

branch
soc.2013.gobjectification.plugins
changeset 37148
50f361d39a1e
parent 37147
6037d5c3a06c
parent 36099
a4eb488f88ae
child 37153
c0eccc6696da
equal deleted inserted replaced
37147:6037d5c3a06c 37148:50f361d39a1e
386 386
387 tmp = g_string_free(str, FALSE); 387 tmp = g_string_free(str, FALSE);
388 } else if (!g_ascii_strcasecmp(args[0], "unsafe")) { 388 } else if (!g_ascii_strcasecmp(args[0], "unsafe")) {
389 if (purple_debug_is_unsafe()) { 389 if (purple_debug_is_unsafe()) {
390 purple_debug_set_unsafe(FALSE); 390 purple_debug_set_unsafe(FALSE);
391 purple_conversation_write(conv, NULL, _("Unsafe debugging is now disabled."), 391 purple_conversation_write_system_message(conv,
392 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_SYSTEM, time(NULL)); 392 _("Unsafe debugging is now disabled."),
393 PURPLE_MESSAGE_NO_LOG);
393 } else { 394 } else {
394 purple_debug_set_unsafe(TRUE); 395 purple_debug_set_unsafe(TRUE);
395 purple_conversation_write(conv, NULL, _("Unsafe debugging is now enabled."), 396 purple_conversation_write_system_message(conv,
396 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_SYSTEM, time(NULL)); 397 _("Unsafe debugging is now enabled."),
398 PURPLE_MESSAGE_NO_LOG);
397 } 399 }
398 400
399 return PURPLE_CMD_RET_OK; 401 return PURPLE_CMD_RET_OK;
400 } else if (!g_ascii_strcasecmp(args[0], "verbose")) { 402 } else if (!g_ascii_strcasecmp(args[0], "verbose")) {
401 if (purple_debug_is_verbose()) { 403 if (purple_debug_is_verbose()) {
402 purple_debug_set_verbose(FALSE); 404 purple_debug_set_verbose(FALSE);
403 purple_conversation_write(conv, NULL, _("Verbose debugging is now disabled."), 405 purple_conversation_write_system_message(conv,
404 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_SYSTEM, time(NULL)); 406 _("Verbose debugging is now disabled."),
407 PURPLE_MESSAGE_NO_LOG);
405 } else { 408 } else {
406 purple_debug_set_verbose(TRUE); 409 purple_debug_set_verbose(TRUE);
407 purple_conversation_write(conv, NULL, _("Verbose debugging is now enabled."), 410 purple_conversation_write_system_message(conv,
408 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_SYSTEM, time(NULL)); 411 _("Verbose debugging is now enabled."),
412 PURPLE_MESSAGE_NO_LOG);
409 } 413 }
410 414
411 return PURPLE_CMD_RET_OK; 415 return PURPLE_CMD_RET_OK;
412 } else { 416 } else {
413 purple_conversation_write(conv, NULL, _("Supported debug options are: plugins version unsafe verbose"), 417 purple_conversation_write_system_message(conv,
414 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); 418 _("Supported debug options are: plugins version unsafe verbose"),
419 PURPLE_MESSAGE_NO_LOG);
415 return PURPLE_CMD_RET_OK; 420 return PURPLE_CMD_RET_OK;
416 } 421 }
417 422
418 markup = g_markup_escape_text(tmp, -1); 423 markup = g_markup_escape_text(tmp, -1);
419 purple_conversation_send(conv, markup); 424 purple_conversation_send(conv, markup);
484 else 489 else
485 g_string_append_printf(s, "%s.", (char *)l->data); 490 g_string_append_printf(s, "%s.", (char *)l->data);
486 g_list_free(text); 491 g_list_free(text);
487 } 492 }
488 493
489 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); 494 purple_conversation_write_system_message(conv, s->str, PURPLE_MESSAGE_NO_LOG);
490 g_string_free(s, TRUE); 495 g_string_free(s, TRUE);
491 496
492 return PURPLE_CMD_RET_OK; 497 return PURPLE_CMD_RET_OK;
493 } 498 }
494 499
525 g_free(send_history); 530 g_free(send_history);
526 531
527 cmdline = cmd + strlen(prefix); 532 cmdline = cmd + strlen(prefix);
528 533
529 if (strcmp(cmdline, "xyzzy") == 0) { 534 if (strcmp(cmdline, "xyzzy") == 0) {
530 purple_conversation_write(conv, "", "Nothing happens", 535 purple_conversation_write_system_message(conv,
531 PURPLE_MESSAGE_NO_LOG, time(NULL)); 536 "Nothing happens", PURPLE_MESSAGE_NO_LOG);
532 g_free(cmd); 537 g_free(cmd);
533 return TRUE; 538 return TRUE;
534 } 539 }
535 540
536 /* TODO WebKit: Cut out prefix for markup... */ 541 /* TODO WebKit: Cut out prefix for markup... */
558 spaceslash = cmdline; 563 spaceslash = cmdline;
559 while (*spaceslash && *spaceslash != ' ' && *spaceslash != '/') 564 while (*spaceslash && *spaceslash != ' ' && *spaceslash != '/')
560 spaceslash++; 565 spaceslash++;
561 566
562 if (*spaceslash != '/') { 567 if (*spaceslash != '/') {
563 purple_conversation_write(conv, "", _("Unknown command."), PURPLE_MESSAGE_NO_LOG, time(NULL)); 568 purple_conversation_write_system_message(conv,
569 _("Unknown command."), PURPLE_MESSAGE_NO_LOG);
564 retval = TRUE; 570 retval = TRUE;
565 } 571 }
566 } 572 }
567 break; 573 break;
568 } 574 }
569 case PURPLE_CMD_STATUS_WRONG_ARGS: 575 case PURPLE_CMD_STATUS_WRONG_ARGS:
570 purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " 576 purple_conversation_write_system_message(conv,
571 "to that command."), 577 _("Syntax Error: You typed the wrong "
572 PURPLE_MESSAGE_NO_LOG, time(NULL)); 578 "number of arguments to that command."),
579 PURPLE_MESSAGE_NO_LOG);
573 retval = TRUE; 580 retval = TRUE;
574 break; 581 break;
575 case PURPLE_CMD_STATUS_FAILED: 582 case PURPLE_CMD_STATUS_FAILED:
576 purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), 583 purple_conversation_write_system_message(conv,
577 PURPLE_MESSAGE_NO_LOG, time(NULL)); 584 error ? error : _("Your command failed for an unknown reason."),
585 PURPLE_MESSAGE_NO_LOG);
578 g_free(error); 586 g_free(error);
579 retval = TRUE; 587 retval = TRUE;
580 break; 588 break;
581 case PURPLE_CMD_STATUS_WRONG_TYPE: 589 case PURPLE_CMD_STATUS_WRONG_TYPE:
582 if(PURPLE_IS_IM_CONVERSATION(conv)) 590 if(PURPLE_IS_IM_CONVERSATION(conv))
583 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), 591 purple_conversation_write_system_message(conv,
584 PURPLE_MESSAGE_NO_LOG, time(NULL)); 592 _("That command only works in chats, not IMs."),
593 PURPLE_MESSAGE_NO_LOG);
585 else 594 else
586 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), 595 purple_conversation_write_system_message(conv,
587 PURPLE_MESSAGE_NO_LOG, time(NULL)); 596 _("That command only works in IMs, not chats."),
597 PURPLE_MESSAGE_NO_LOG);
588 retval = TRUE; 598 retval = TRUE;
589 break; 599 break;
590 case PURPLE_CMD_STATUS_WRONG_PROTOCOL: 600 case PURPLE_CMD_STATUS_WRONG_PROTOCOL:
591 purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), 601 purple_conversation_write_system_message(conv,
592 PURPLE_MESSAGE_NO_LOG, time(NULL)); 602 _("That command doesn't work on this protocol."),
603 PURPLE_MESSAGE_NO_LOG);
593 retval = TRUE; 604 retval = TRUE;
594 break; 605 break;
595 } 606 }
596 } 607 }
597 608
1404 if (logging) 1415 if (logging)
1405 { 1416 {
1406 /* Enable logging first so the message below can be logged. */ 1417 /* Enable logging first so the message below can be logged. */
1407 purple_conversation_set_logging(conv, TRUE); 1418 purple_conversation_set_logging(conv, TRUE);
1408 1419
1409 purple_conversation_write(conv, NULL, 1420 purple_conversation_write_system_message(conv,
1410 _("Logging started. Future messages in this conversation will be logged."), 1421 _("Logging started. Future messages in this conversation will be logged."), 0);
1411 PURPLE_MESSAGE_SYSTEM,
1412 time(NULL));
1413 } 1422 }
1414 else 1423 else
1415 { 1424 {
1416 purple_conversation_write(conv, NULL, 1425 purple_conversation_write_system_message(conv,
1417 _("Logging stopped. Future messages in this conversation will not be logged."), 1426 _("Logging stopped. Future messages in this conversation will not be logged."), 0);
1418 PURPLE_MESSAGE_SYSTEM,
1419 time(NULL));
1420 1427
1421 /* Disable the logging second, so that the above message can be logged. */ 1428 /* Disable the logging second, so that the above message can be logged. */
1422 purple_conversation_set_logging(conv, FALSE); 1429 purple_conversation_set_logging(conv, FALSE);
1423 } 1430 }
1424 1431
4613 g_free(tmp); 4620 g_free(tmp);
4614 g_free(matches->data); 4621 g_free(matches->data);
4615 matches = g_list_remove(matches, matches->data); 4622 matches = g_list_remove(matches, matches->data);
4616 } 4623 }
4617 4624
4618 purple_conversation_write(conv, NULL, addthis, PURPLE_MESSAGE_NO_LOG, 4625 purple_conversation_write_system_message(conv, addthis, PURPLE_MESSAGE_NO_LOG);
4619 time(NULL));
4620 4626
4621 modified = g_strdup_printf("%s%s%s", sub1, partial, sub2); 4627 modified = g_strdup_printf("%s%s%s", sub1, partial, sub2);
4622 webkit_dom_node_set_node_value(container, modified, NULL); 4628 webkit_dom_node_set_node_value(container, modified, NULL);
4623 pidgin_webview_set_caret(PIDGIN_WEBVIEW(gtkconv->entry), container, 4629 pidgin_webview_set_caret(PIDGIN_WEBVIEW(gtkconv->entry), container,
4624 word_start + g_utf8_strlen(partial, -1) + colon); 4630 word_start + g_utf8_strlen(partial, -1) + colon);
6194 g_object_unref(gtkconv->theme); 6200 g_object_unref(gtkconv->theme);
6195 6201
6196 g_free(gtkconv); 6202 g_free(gtkconv);
6197 } 6203 }
6198 6204
6199
6200 static void
6201 pidgin_conv_write_im(PurpleIMConversation *im, const char *who,
6202 const char *message, PurpleMessageFlags flags,
6203 time_t mtime)
6204 {
6205 PidginConversation *gtkconv;
6206 PurpleConversation *conv = PURPLE_CONVERSATION(im);
6207
6208 gtkconv = PIDGIN_CONVERSATION(conv);
6209
6210 if (conv != gtkconv->active_conv &&
6211 flags & PURPLE_MESSAGE_ACTIVE_ONLY)
6212 {
6213 /* Plugins that want these messages suppressed should be
6214 * calling purple_im_conversation_write_message(), so they get suppressed here,
6215 * before being written to the log. */
6216 purple_debug_info("gtkconv",
6217 "Suppressing message for an inactive conversation in pidgin_conv_write_im()\n");
6218 return;
6219 }
6220
6221 purple_conversation_write(conv, who, message, flags, mtime);
6222 }
6223
6224 #if 0 6205 #if 0
6225 static const char * 6206 static const char *
6226 get_text_tag_color(GtkTextTag *tag) 6207 get_text_tag_color(GtkTextTag *tag)
6227 { 6208 {
6228 GdkColor *color = NULL; 6209 GdkColor *color = NULL;
6897 /* Enforce direction on alias */ 6878 /* Enforce direction on alias */
6898 if (is_rtl_message) 6879 if (is_rtl_message)
6899 str_embed_direction_chars(&alias_escaped); 6880 str_embed_direction_chars(&alias_escaped);
6900 6881
6901 str = g_malloc(1024); 6882 str = g_malloc(1024);
6902 if (flags & PURPLE_MESSAGE_WHISPER) { 6883 if (TRUE) { /* XXX: reduce numer of indentations */
6903 /* If we're whispering, it's not an autoresponse. */
6904 if (purple_message_meify(new_message, -1 )) {
6905 g_snprintf(str, 1024, "***%s", alias_escaped);
6906 tag_start_offset += 3;
6907 tagname = "whisper-action-name";
6908 }
6909 else {
6910 g_snprintf(str, 1024, "*%s*:", alias_escaped);
6911 tag_start_offset += 1;
6912 #if 0
6913 tag_end_offset = 2;
6914 #endif
6915 tagname = "whisper-name";
6916 }
6917 } else {
6918 if (purple_message_meify(new_message, -1)) { 6884 if (purple_message_meify(new_message, -1)) {
6919 if (flags & PURPLE_MESSAGE_AUTO_RESP) { 6885 if (flags & PURPLE_MESSAGE_AUTO_RESP) {
6920 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped); 6886 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped);
6921 tag_start_offset += strlen(AUTO_RESPONSE) - 6 + 4; 6887 tag_start_offset += strlen(AUTO_RESPONSE) - 6 + 4;
6922 } else { 6888 } else {
7752 static PurpleConversationUiOps conversation_ui_ops = 7718 static PurpleConversationUiOps conversation_ui_ops =
7753 { 7719 {
7754 pidgin_conv_new, 7720 pidgin_conv_new,
7755 pidgin_conv_destroy, /* destroy_conversation */ 7721 pidgin_conv_destroy, /* destroy_conversation */
7756 NULL, /* write_chat */ 7722 NULL, /* write_chat */
7757 pidgin_conv_write_im, /* write_im */ 7723 NULL, /* write_im */
7758 pidgin_conv_write_conv, /* write_conv */ 7724 pidgin_conv_write_conv, /* write_conv */
7759 pidgin_conv_chat_add_users, /* chat_add_users */ 7725 pidgin_conv_chat_add_users, /* chat_add_users */
7760 pidgin_conv_chat_rename_user, /* chat_rename_user */ 7726 pidgin_conv_chat_rename_user, /* chat_rename_user */
7761 pidgin_conv_chat_remove_users, /* chat_remove_users */ 7727 pidgin_conv_chat_remove_users, /* chat_remove_users */
7762 pidgin_conv_chat_update_user, /* chat_update_user */ 7728 pidgin_conv_chat_update_user, /* chat_update_user */
8373 while (list) { 8339 while (list) {
8374 PurpleConversation *conv = list->data; 8340 PurpleConversation *conv = list->data;
8375 if (!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) && 8341 if (!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) &&
8376 purple_conversation_get_account(conv) == account) { 8342 purple_conversation_get_account(conv) == account) {
8377 g_object_set_data(G_OBJECT(conv), "want-to-rejoin", GINT_TO_POINTER(TRUE)); 8343 g_object_set_data(G_OBJECT(conv), "want-to-rejoin", GINT_TO_POINTER(TRUE));
8378 purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " 8344 purple_conversation_write_system_message(conv,
8379 "longer in this chat. You will automatically rejoin the chat when " 8345 _("The account has disconnected and you are no "
8380 "the account reconnects."), 8346 "longer in this chat. You will automatically "
8381 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); 8347 "rejoin the chat when the account reconnects."),
8348 PURPLE_MESSAGE_NO_LOG);
8382 } 8349 }
8383 list = list->next; 8350 list = list->next;
8384 } 8351 }
8385 } 8352 }
8386 8353

mercurial