about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-05 20:52:45 +0000
committerJames Booth <boothj5@gmail.com>2014-01-05 20:52:45 +0000
commit87cdbe015a8dfe20067b2933322a7c9ca17745f2 (patch)
tree6710efa4bc120e5cea4c0906b1a7d537beda41ce /src
parent4a8d6c2153a9ca4a3fb6f0ddc20e1d6c6e2107e6 (diff)
downloadprofani-tty-87cdbe015a8dfe20067b2933322a7c9ca17745f2.tar.gz
Added server_events.c
Diffstat (limited to 'src')
-rw-r--r--src/profanity.c15
-rw-r--r--src/server_events.c40
-rw-r--r--src/server_events.h28
-rw-r--r--src/xmpp/connection.c5
4 files changed, 71 insertions, 17 deletions
diff --git a/src/profanity.c b/src/profanity.c
index 7b156cd3..736e43ab 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -197,21 +197,6 @@ prof_handle_group_remove(const char * const contact,
 }
 
 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)
 {
     switch (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 <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/>.
+ *
+ */
+
+#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 <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/>.
+ *
+ */
+
+#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 <error/> [RFC6120, 8.3.2]
             }