From db4bcd3e6d6efa9bae1d85b327a9f0318177555f Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 1 Nov 2015 19:39:36 +0000 Subject: Added xmlwin module --- src/ui/core.c | 20 -------------------- src/ui/ui.h | 4 +++- src/ui/xmlwin.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 src/ui/xmlwin.c (limited to 'src/ui') diff --git a/src/ui/core.c b/src/ui/core.c index f8c8b7c6..d50f1c3d 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -222,26 +222,6 @@ ui_load_colours(void) } } -void -ui_handle_stanza(const char *const msg) -{ - ProfXMLWin *xmlwin = wins_get_xmlconsole(); - if (!xmlwin) { - return; - } - - ProfWin *window = (ProfWin*)xmlwin; - if (g_str_has_prefix(msg, "SENT:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "SENT:"); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); - } else if (g_str_has_prefix(msg, "RECV:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "RECV:"); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); - } -} - void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 9f7cf46a..6520358a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -85,7 +85,6 @@ int ui_win_unread(int index); char* ui_ask_password(void); char* ui_get_line(void); char* ui_ask_pgp_passphrase(const char *hint, int prev_fail); -void ui_handle_stanza(const char *const msg); void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); void ui_contact_typing(const char *const barejid, const char *const resource); void ui_incoming_private_msg(const char *const fulljid, const char *const message, GDateTime *timestamp); @@ -209,6 +208,9 @@ void chatwin_otr_untrust(ProfChatWin *chatwin); void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data); #endif +// xml console +void xmlwin_show(const char *const msg); + // Input window char* inp_readline(void); void inp_nonblocking(gboolean reset); diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c new file mode 100644 index 00000000..d793fd05 --- /dev/null +++ b/src/ui/xmlwin.c @@ -0,0 +1,56 @@ +/* + * xmlwin.c + * + * Copyright (C) 2012 - 2015 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +#include "ui/win_types.h" +#include "window_list.h" + +void +xmlwin_show(const char *const msg) +{ + ProfXMLWin *xmlwin = wins_get_xmlconsole(); + if (!xmlwin) { + return; + } + + ProfWin *window = (ProfWin*)xmlwin; + if (g_str_has_prefix(msg, "SENT:")) { + win_print(window, '-', 0, NULL, 0, 0, "", "SENT:"); + win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); + win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); + } else if (g_str_has_prefix(msg, "RECV:")) { + win_print(window, '-', 0, NULL, 0, 0, "", "RECV:"); + win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); + win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); + } +} -- cgit 1.4.1-2-gfad0