diff --git a/Makefile.am b/Makefile.am index 70738515..e8f92ba1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,7 @@ core_sources = \ src/xmpp/capabilities.h src/xmpp/connection.h \ src/xmpp/roster.c src/xmpp/roster.h \ src/xmpp/bookmark.c src/xmpp/bookmark.h \ + src/server_events.c src/server_events.h \ src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \ src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ src/ui/console.c src/ui/notifier.c \ diff --git a/src/profanity.c b/src/profanity.c index 7b156cd3..736e43ab 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -196,21 +196,6 @@ prof_handle_group_remove(const char * const contact, ui_current_page_off(); } -void -prof_handle_error_message(const char *from, const char *err_msg) -{ - ui_handle_error_message(from, err_msg); - - if (g_strcmp0(err_msg, "conflict") == 0) { - // remove the room from muc - Jid *room_jid = jid_create(from); - if (!muc_get_roster_received(room_jid->barejid)) { - muc_leave_room(room_jid->barejid); - } - jid_destroy(room_jid); - } -} - void prof_handle_subscription(const char *from, jabber_subscr_t type) { diff --git a/src/server_events.c b/src/server_events.c new file mode 100644 index 00000000..58c62488 --- /dev/null +++ b/src/server_events.c @@ -0,0 +1,40 @@ +/* + * server_events.c + * + * Copyright (C) 2012, 2013 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 . + * + */ + +#include "ui/ui.h" +#include "muc.h" + +void +handle_error_message(const char *from, const char *err_msg) +{ + ui_handle_error_message(from, err_msg); + + if (g_strcmp0(err_msg, "conflict") == 0) { + // remove the room from muc + Jid *room_jid = jid_create(from); + if (!muc_get_roster_received(room_jid->barejid)) { + muc_leave_room(room_jid->barejid); + } + jid_destroy(room_jid); + } +} + diff --git a/src/server_events.h b/src/server_events.h new file mode 100644 index 00000000..ae313275 --- /dev/null +++ b/src/server_events.h @@ -0,0 +1,28 @@ +/* + * server_events.h + * + * Copyright (C) 2012, 2013 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 . + * + */ + +#ifndef SERVER_EVENTS_H +#define SERVER_EVENTS_H + +void handle_error_message(const char *from, const char *err_msg); + +#endif diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index f38da800..d2c2c6f7 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -33,6 +33,7 @@ #include "log.h" #include "muc.h" #include "profanity.h" +#include "server_events.h" #include "xmpp/bookmark.h" #include "xmpp/capabilities.h" #include "xmpp/connection.h" @@ -349,7 +350,7 @@ connection_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (text_stanza != NULL) { err_msg = xmpp_stanza_get_text(text_stanza); if (err_msg != NULL) { - prof_handle_error_message(from, err_msg); + handle_error_message(from, err_msg); xmpp_free(ctx, err_msg); } @@ -364,7 +365,7 @@ connection_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } else { err_msg = xmpp_stanza_get_name(err_cond); - prof_handle_error_message(from, err_msg); + handle_error_message(from, err_msg); // TODO : process 'type' attribute from [RFC6120, 8.3.2] }