about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-02-14 22:28:55 +0000
committerJames Booth <boothj5@gmail.com>2016-02-14 22:28:55 +0000
commit41fe8c22b1f8c1cf666d42052cd73d59e40a2ed2 (patch)
tree3b53c1fbc2e5dc8c6daccf7fe7bb9f27d1c9d05a /src/xmpp
parentf887a35c0cd550a3c635630da2bd83bb7400b957 (diff)
downloadprofani-tty-41fe8c22b1f8c1cf666d42052cd73d59e40a2ed2.tar.gz
Added C plugin code from plugins branch
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/bookmark.c6
-rw-r--r--src/xmpp/capabilities.c14
-rw-r--r--src/xmpp/capabilities.h6
-rw-r--r--src/xmpp/connection.c23
-rw-r--r--src/xmpp/connection.h6
-rw-r--r--src/xmpp/form.c6
-rw-r--r--src/xmpp/iq.c14
-rw-r--r--src/xmpp/message.c8
-rw-r--r--src/xmpp/presence.c6
-rw-r--r--src/xmpp/roster.c7
-rw-r--r--src/xmpp/stanza.c6
-rw-r--r--src/xmpp/stanza.h6
-rw-r--r--src/xmpp/xmpp.h8
13 files changed, 62 insertions, 54 deletions
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index 682aa2b2..99fd5293 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -32,7 +32,7 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <assert.h>
 #include <stdio.h>
@@ -40,10 +40,10 @@
 #include <string.h>
 #include <glib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index b425c6f1..b2f36ae5 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -32,9 +32,9 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_GIT_VERSION
+#ifdef PROF_HAVE_GIT_VERSION
 #include "gitversion.h"
 #endif
 
@@ -44,10 +44,10 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
@@ -565,9 +565,9 @@ caps_create_query_response_stanza(xmpp_ctx_t *const ctx)
     xmpp_stanza_set_attribute(identity, "type", "console");
 
     GString *name_str = g_string_new("Profanity ");
-    g_string_append(name_str, PACKAGE_VERSION);
-    if (strcmp(PACKAGE_STATUS, "development") == 0) {
-#ifdef HAVE_GIT_VERSION
+    g_string_append(name_str, PROF_PACKAGE_VERSION);
+    if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
+#ifdef PROF_HAVE_GIT_VERSION
         g_string_append(name_str, "dev.");
         g_string_append(name_str, PROF_GIT_BRANCH);
         g_string_append(name_str, ".");
diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h
index 812a7eb1..2d251b00 100644
--- a/src/xmpp/capabilities.h
+++ b/src/xmpp/capabilities.h
@@ -35,12 +35,12 @@
 #ifndef XMPP_CAPABILITIES_H
 #define XMPP_CAPABILITIES_H
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index d72d10ca..667dfda6 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -32,16 +32,16 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
@@ -51,6 +51,7 @@
 #include "jid.h"
 #include "log.h"
 #include "muc.h"
+#include "plugins/plugins.h"
 #include "profanity.h"
 #include "event/server_events.h"
 #include "xmpp/bookmark.h"
@@ -93,12 +94,12 @@ static struct {
 static GTimer *reconnect_timer;
 
 static log_level_t _get_log_level(xmpp_log_level_t xmpp_level);
-static xmpp_log_level_t _get_xmpp_log_level();
+static xmpp_log_level_t _get_xmpp_log_level(void);
 
 static void _xmpp_file_logger(void *const userdata, const xmpp_log_level_t level, const char *const area,
     const char *const msg);
 
-static xmpp_log_t* _xmpp_get_file_logger();
+static xmpp_log_t* _xmpp_get_file_logger(void);
 
 static jabber_conn_status_t _jabber_connect(const char *const fulljid, const char *const passwd,
     const char *const altdomain, int port, const char *const tls_policy);
@@ -235,6 +236,9 @@ jabber_disconnect(void)
 {
     // if connected, send end stream and wait for response
     if (jabber_conn.conn_status == JABBER_CONNECTED) {
+        char *account_name = jabber_get_account_name();
+        const char *fulljid = jabber_get_fulljid();
+        plugins_on_disconnect(account_name, fulljid);
         log_info("Closing connection");
         accounts_set_last_activity(jabber_get_account_name());
         jabber_conn.conn_status = JABBER_DISCONNECTING;
@@ -418,7 +422,7 @@ _connection_free_session_data(void)
     presence_clear_sub_requests();
 }
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 static int
 _connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg)
 {
@@ -526,7 +530,7 @@ _jabber_connect(const char *const fulljid, const char *const passwd, const char
         xmpp_conn_set_flags(jabber_conn.conn, XMPP_CONN_FLAG_DISABLE_TLS);
     }
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
     char *cert_path = prefs_get_string(PREF_TLS_CERTPATH);
     if (cert_path) {
         xmpp_conn_tlscert_path(jabber_conn.conn, cert_path);
@@ -534,7 +538,7 @@ _jabber_connect(const char *const fulljid, const char *const passwd, const char
     prefs_free_string(cert_path);
 #endif
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
     int connect_status = xmpp_connect_client(
         jabber_conn.conn,
         altdomain,
@@ -580,6 +584,9 @@ _jabber_reconnect(void)
 static void
 _jabber_lost_connection(void)
 {
+    char *account_name = jabber_get_account_name();
+    const char *fulljid = jabber_get_fulljid();
+    plugins_on_disconnect(account_name, fulljid);
     sv_ev_lost_connection();
     if (prefs_get_reconnect() != 0) {
         assert(reconnect_timer == NULL);
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index 0f9407f9..04c11ab1 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -35,12 +35,12 @@
 #ifndef XMPP_CONNECTION_H
 #define XMPP_CONNECTION_H
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index 9631e8b6..670e3bd8 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -32,15 +32,15 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 4cf3313e..cfe0f1c6 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -32,9 +32,9 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_GIT_VERSION
+#ifdef PROF_HAVE_GIT_VERSION
 #include "gitversion.h"
 #endif
 
@@ -43,10 +43,10 @@
 #include <stdio.h>
 #include <glib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
@@ -1081,9 +1081,9 @@ _version_get_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
         xmpp_stanza_t *version = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(version, "version");
         xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx);
-        GString *version_str = g_string_new(PACKAGE_VERSION);
-        if (strcmp(PACKAGE_STATUS, "development") == 0) {
-#ifdef HAVE_GIT_VERSION
+        GString *version_str = g_string_new(PROF_PACKAGE_VERSION);
+        if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
+#ifdef PROF_HAVE_GIT_VERSION
             g_string_append(version_str, "dev.");
             g_string_append(version_str, PROF_GIT_BRANCH);
             g_string_append(version_str, ".");
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 810cb6e1..fceae729 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -32,15 +32,15 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
@@ -156,7 +156,7 @@ message_send_chat_pgp(const char *const barejid, const char *const msg)
     char *id = create_unique_id("msg");
 
     xmpp_stanza_t *message = NULL;
-#ifdef HAVE_LIBGPGME
+#ifdef PROF_HAVE_LIBGPGME
     char *account_name = jabber_get_account_name();
     ProfAccount *account = accounts_get_account(account_name);
     if (account->pgp_keyid) {
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 0743cbe2..8207c8bb 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -32,7 +32,7 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -41,10 +41,10 @@
 #include <glib.h>
 #include <glib/gprintf.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 8b646efa..f90fc748 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -32,7 +32,7 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -40,14 +40,15 @@
 
 #include <glib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
 #include "log.h"
+#include "plugins/plugins.h"
 #include "profanity.h"
 #include "ui/ui.h"
 #include "event/server_events.h"
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 7679e6c3..b2d36461 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -32,17 +32,17 @@
  *
  */
 
-#include "config.h"
+#include "prof_config.h"
 
 #include <stdlib.h>
 #include <string.h>
 
 #include <glib.h>
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 7170e204..69cd4267 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -35,12 +35,12 @@
 #ifndef XMPP_STANZA_H
 #define XMPP_STANZA_H
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 7e5e430e..0827cc46 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -35,12 +35,12 @@
 #ifndef XMPP_XMPP_H
 #define XMPP_XMPP_H
 
-#include "config.h"
+#include "prof_config.h"
 
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 #include <mesode.h>
 #endif
-#ifdef HAVE_LIBSTROPHE
+#ifdef PROF_HAVE_LIBSTROPHE
 #include <strophe.h>
 #endif
 
@@ -155,7 +155,7 @@ char* jabber_get_account_name(void);
 GList* jabber_get_available_resources(void);
 char* jabber_create_uuid(void);
 void jabber_free_uuid(char *uuid);
-#ifdef HAVE_LIBMESODE
+#ifdef PROF_HAVE_LIBMESODE
 TLSCertificate* jabber_get_tls_peer_cert(void);
 #endif
 gboolean jabber_conn_is_secured(void);