1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added xmlwin module

This commit is contained in:
James Booth 2015-11-01 19:39:36 +00:00
parent 7e386fbf00
commit db4bcd3e6d
6 changed files with 62 additions and 23 deletions

View File

@ -24,6 +24,7 @@ core_sources = \
src/ui/rosterwin.c src/ui/occupantswin.c \
src/ui/buffer.c src/ui/buffer.h \
src/ui/chatwin.c \
src/ui/xmlwin.c \
src/command/command.h src/command/command.c \
src/command/commands.h src/command/commands.c \
src/tools/parser.c \

View File

@ -521,7 +521,7 @@ sv_ev_roster_update(const char *const barejid, const char *const name,
void
sv_ev_xmpp_stanza(const char *const msg)
{
ui_handle_stanza(msg);
xmlwin_show(msg);
}
void

View File

@ -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)
{

View File

@ -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);

56
src/ui/xmlwin.c Normal file
View File

@ -0,0 +1,56 @@
/*
* xmlwin.c
*
* Copyright (C) 2012 - 2015 James Booth <boothj5@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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, "", "");
}
}

View File

@ -165,7 +165,7 @@ char *ui_get_line(void)
return NULL;
}
void ui_handle_stanza(const char * const msg) {}
void xmlwin_show(const char * const msg) {}
// ui events
void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity)