Added C plugin code from plugins branch

This commit is contained in:
James Booth
2016-02-14 22:28:55 +00:00
parent f887a35c0c
commit 41fe8c22b1
70 changed files with 2668 additions and 287 deletions

View File

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

View File

@@ -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, ".");

View File

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

View File

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

View File

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

View File

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

View File

@@ -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, ".");

View File

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

View File

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

View File

@@ -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"

View File

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

View File

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

View File

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