about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c10
-rw-r--r--src/command/commands.c12
-rw-r--r--src/command/commands.h1
-rw-r--r--src/ui/core.c38
-rw-r--r--src/ui/ui.h4
-rw-r--r--src/ui/window.h3
-rw-r--r--src/ui/windows.c41
-rw-r--r--src/ui/windows.h2
8 files changed, 100 insertions, 11 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 5175a16b..3520535b 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -789,6 +789,14 @@ static struct cmd_t command_defs[] =
           "The default is 'all' for all windows.",
           NULL } } },
 
+    { "/xmlconsole",
+        cmd_xmlconsole, parse_args, 0, 0, NULL,
+        { "/xmlconsole", "Open the XML console",
+        { "/xmlconsole",
+          "-----------",
+          "Open the XML console to view incoming and outgoing XMPP traffic.",
+          NULL } } },
+
     { "/away",
         cmd_away, parse_args_with_freetext, 0, 1, NULL,
         { "/away [msg]", "Set status to away.",
@@ -1937,4 +1945,4 @@ _account_autocomplete(char *input, int *size)
 
     found = autocomplete_param_with_ac(input, size, "/account", account_ac);
     return found;
-}
\ No newline at end of file
+}
diff --git a/src/command/commands.c b/src/command/commands.c
index 1a05de4e..8e026b50 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2444,6 +2444,18 @@ cmd_vercheck(gchar **args, struct cmd_help_t help)
 }
 
 gboolean
+cmd_xmlconsole(gchar **args, struct cmd_help_t help)
+{
+    if (!ui_xmlconsole_exists()) {
+        ui_create_xmlconsole_win();
+    } else {
+        ui_open_xmlconsole_win();
+    }
+
+    return TRUE;
+}
+
+gboolean
 cmd_flash(gchar **args, struct cmd_help_t help)
 {
     return _cmd_set_boolean_preference(args[0], help,
diff --git a/src/command/commands.h b/src/command/commands.h
index fa1afbff..59fd8b27 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -110,5 +110,6 @@ gboolean cmd_win(gchar **args, struct cmd_help_t help);
 gboolean cmd_wins(gchar **args, struct cmd_help_t help);
 gboolean cmd_xa(gchar **args, struct cmd_help_t help);
 gboolean cmd_alias(gchar **args, struct cmd_help_t help);
+gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help);
 
 #endif
diff --git a/src/ui/core.c b/src/ui/core.c
index 48999319..f80c6ad2 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -219,18 +219,28 @@ _ui_duck_exists(void)
     return wins_duck_exists();
 }
 
+static gboolean
+_ui_xmlconsole_exists(void)
+{
+    return wins_xmlconsole_exists();
+}
+
 static void
 _ui_handle_stanza(const char * const msg)
 {
-    ProfWin *console = wins_get_console();
-    if (g_str_has_prefix(msg, "SENT:")) {
-        win_vprint_line(console, '!', COLOUR_ONLINE, "<- %s", &msg[6]);
-    } else if (g_str_has_prefix(msg, "RECV:")) {
-        win_vprint_line(console, '!', COLOUR_AWAY, "-> %s", &msg[6]);
-    }
-    win_update_virtual(console);
-    if (wins_is_current(console)) {
-        ui_current_page_off();
+    if (ui_xmlconsole_exists()) {
+        ProfWin *xmlconsole = wins_get_xmlconsole();
+	    
+        if (g_str_has_prefix(msg, "SENT:")) {
+	    win_vprint_line(xmlconsole, '!', COLOUR_ONLINE, "<- %s", &msg[6]);
+	} else if (g_str_has_prefix(msg, "RECV:")) {
+	    win_vprint_line(xmlconsole, '!', COLOUR_AWAY, "-> %s", &msg[6]);
+	}
+
+	win_update_virtual(xmlconsole);
+	if (wins_is_current(xmlconsole)) {
+	    ui_current_page_off();
+	}
     }
 }
 
@@ -1118,6 +1128,14 @@ _ui_create_duck_win(void)
 }
 
 static void
+_ui_create_xmlconsole_win(void)
+{
+    ProfWin *window = wins_new("XML Console", WIN_XML);
+    int num = wins_get_num(window);
+    ui_switch_win(num);
+}
+
+static void
 _ui_open_duck_win(void)
 {
     ProfWin *window = wins_get_by_recipient("DuckDuckGo search");
@@ -1939,4 +1957,6 @@ ui_init_module(void)
     ui_replace_input = _ui_replace_input;
     ui_invalid_command_usage = _ui_invalid_command_usage;
     ui_handle_stanza = _ui_handle_stanza;
+    ui_create_xmlconsole_win = _ui_create_xmlconsole_win;
+    ui_xmlconsole_exists = _ui_xmlconsole_exists;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 43f2d5ed..a93cc3d0 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -163,6 +163,10 @@ void (*ui_replace_input)(char *input, const char * const new_input, int *size);
 
 void (*ui_invalid_command_usage)(const char * const usage, void (**setting_func)(void));
 
+void (*ui_create_xmlconsole_win)(void);
+gboolean (*ui_xmlconsole_exists)(void);
+void (*ui_open_xmlconsole_win)(void);
+
 // console window actions
 void (*cons_show)(const char * const msg, ...);
 void (*cons_about)(void);
diff --git a/src/ui/window.h b/src/ui/window.h
index 4bd37447..874e6307 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -41,7 +41,8 @@ typedef enum {
     WIN_CHAT,
     WIN_MUC,
     WIN_PRIVATE,
-    WIN_DUCK
+    WIN_DUCK,
+    WIN_XML
 } win_type_t;
 
 typedef struct prof_win_t {
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 75691f0d..82659be5 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -297,6 +297,38 @@ wins_duck_exists(void)
     return FALSE;
 }
 
+gboolean
+wins_xmlconsole_exists(void)
+{
+    GList *values = g_hash_table_get_values(windows);
+    GList *curr = values;
+
+    while (curr != NULL) {
+        ProfWin *window = curr->data;
+        if (window->type == WIN_XML)
+            return TRUE;
+        curr = g_list_next(curr);
+    }
+
+    return FALSE;
+}
+
+ProfWin *
+wins_get_xmlconsole(void)
+{
+    GList *values = g_hash_table_get_values(windows);
+    GList *curr = values;
+
+    while (curr != NULL) {
+        ProfWin *window = curr->data;
+        if (window->type == WIN_XML)
+            return window;
+        curr = g_list_next(curr);
+    }
+
+    return NULL;
+}
+
 GSList *
 wins_get_chat_recipients(void)
 {
@@ -428,6 +460,7 @@ wins_create_summary(void)
         GString *priv_string;
         GString *muc_string;
         GString *duck_string;
+        GString *xml_string;
 
         switch (window->type)
         {
@@ -501,6 +534,14 @@ wins_create_summary(void)
 
                 break;
 
+            case WIN_XML:
+                xml_string = g_string_new("");
+                g_string_printf(xml_string, "%d: XML console", ui_index);
+                result = g_slist_append(result, strdup(xml_string->str));
+                g_string_free(xml_string, TRUE);
+
+                break;
+
             default:
                 break;
         }
diff --git a/src/ui/windows.h b/src/ui/windows.h
index f8dec429..cbe219df 100644
--- a/src/ui/windows.h
+++ b/src/ui/windows.h
@@ -48,5 +48,7 @@ gboolean wins_tidy(void);
 GSList * wins_create_summary(void);
 void wins_destroy(void);
 GList * wins_get_nums(void);
+gboolean wins_xmlconsole_exists(void);
+ProfWin * wins_get_xmlconsole(void);
 
 #endif
545' href='#n545'>545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010