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

Bind jabber functions in main.c

This commit is contained in:
James Booth 2013-12-22 23:07:41 +00:00
parent 5a5b1340aa
commit 581f58e47f
4 changed files with 29 additions and 14 deletions

View File

@ -29,11 +29,19 @@
#include "profanity.h" #include "profanity.h"
#include "xmpp/xmpp.h"
static gboolean disable_tls = FALSE; static gboolean disable_tls = FALSE;
static gboolean version = FALSE; static gboolean version = FALSE;
static char *log = "INFO"; static char *log = "INFO";
static char *account_name = NULL; static char *account_name = NULL;
static void
_init_modules(void)
{
jabber_init_module();
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -79,6 +87,7 @@ main(int argc, char **argv)
return 0; return 0;
} }
_init_modules();
prof_run(disable_tls, log, account_name); prof_run(disable_tls, log, account_name);
return 0; return 0;

View File

@ -125,6 +125,7 @@ _ui_get_idle_time(void)
unsigned long ms_elapsed = seconds_elapsed * 1000.0; unsigned long ms_elapsed = seconds_elapsed * 1000.0;
return ms_elapsed; return ms_elapsed;
} }
//unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time;
unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time; unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time;
static void static void

View File

@ -107,7 +107,6 @@ _jabber_init(const int disable_tls)
(GDestroyNotify)resource_destroy); (GDestroyNotify)resource_destroy);
xmpp_initialize(); xmpp_initialize();
} }
void (*jabber_init)(const int) = _jabber_init;
static jabber_conn_status_t static jabber_conn_status_t
_jabber_connect_with_account(const ProfAccount * const account) _jabber_connect_with_account(const ProfAccount * const account)
@ -128,7 +127,6 @@ _jabber_connect_with_account(const ProfAccount * const account)
return result; return result;
} }
jabber_conn_status_t (*jabber_connect_with_account)(const ProfAccount * const) = _jabber_connect_with_account;
static jabber_conn_status_t static jabber_conn_status_t
_jabber_connect_with_details(const char * const jid, _jabber_connect_with_details(const char * const jid,
@ -161,8 +159,6 @@ _jabber_connect_with_details(const char * const jid,
log_info("Connecting without account, JID: %s", saved_details.jid); log_info("Connecting without account, JID: %s", saved_details.jid);
return _jabber_connect(saved_details.jid, passwd, saved_details.altdomain); return _jabber_connect(saved_details.jid, passwd, saved_details.altdomain);
} }
jabber_conn_status_t (*jabber_connect_with_details)(const char * const,
const char * const, const char * const) = _jabber_connect_with_details;
static void static void
_jabber_disconnect(void) _jabber_disconnect(void)
@ -193,14 +189,12 @@ _jabber_disconnect(void)
FREE_SET_NULL(jabber_conn.presence_message); FREE_SET_NULL(jabber_conn.presence_message);
FREE_SET_NULL(jabber_conn.domain); FREE_SET_NULL(jabber_conn.domain);
} }
void (*jabber_disconnect)(void) = _jabber_disconnect;
static void static void
_jabber_shutdown(void) _jabber_shutdown(void)
{ {
xmpp_shutdown(); xmpp_shutdown();
} }
void (*jabber_shutdown)(void) = _jabber_shutdown;
static void static void
_jabber_process_events(void) _jabber_process_events(void)
@ -222,7 +216,6 @@ _jabber_process_events(void)
} }
} }
void (*jabber_process_events)(void) = _jabber_process_events;
static void static void
_jabber_set_autoping(const int seconds) _jabber_set_autoping(const int seconds)
@ -237,21 +230,18 @@ _jabber_set_autoping(const int seconds)
} }
} }
} }
void (*jabber_set_autoping)(const int) = _jabber_set_autoping;
static GList * static GList *
_jabber_get_available_resources(void) _jabber_get_available_resources(void)
{ {
return g_hash_table_get_values(available_resources); return g_hash_table_get_values(available_resources);
} }
GList * (*jabber_get_available_resources)(void) = _jabber_get_available_resources;
static jabber_conn_status_t static jabber_conn_status_t
_jabber_get_connection_status(void) _jabber_get_connection_status(void)
{ {
return (jabber_conn.conn_status); return (jabber_conn.conn_status);
} }
jabber_conn_status_t (*jabber_get_connection_status)(void) = _jabber_get_connection_status;
xmpp_conn_t * xmpp_conn_t *
connection_get_conn(void) connection_get_conn(void)
@ -270,28 +260,24 @@ _jabber_get_fulljid(void)
{ {
return xmpp_conn_get_jid(jabber_conn.conn); return xmpp_conn_get_jid(jabber_conn.conn);
} }
const char * (*jabber_get_fulljid)(void) = _jabber_get_fulljid;
static const char * static const char *
_jabber_get_domain(void) _jabber_get_domain(void)
{ {
return jabber_conn.domain; return jabber_conn.domain;
} }
const char * (*jabber_get_domain)(void) = _jabber_get_domain;
static char * static char *
_jabber_get_presence_message(void) _jabber_get_presence_message(void)
{ {
return jabber_conn.presence_message; return jabber_conn.presence_message;
} }
char * (*jabber_get_presence_message)(void) = _jabber_get_presence_message;
static char * static char *
_jabber_get_account_name(void) _jabber_get_account_name(void)
{ {
return saved_account.name; return saved_account.name;
} }
char * (*jabber_get_account_name)(void) = _jabber_get_account_name;
void void
connection_set_presence_message(const char * const message) connection_set_presence_message(const char * const message)
@ -629,3 +615,20 @@ _xmpp_get_file_logger()
return file_log; return file_log;
} }
void
jabber_init_module(void)
{
jabber_init = _jabber_init;
jabber_connect_with_account = _jabber_connect_with_account;
jabber_connect_with_details = _jabber_connect_with_details;
jabber_disconnect = _jabber_disconnect;
jabber_shutdown = _jabber_shutdown;
jabber_process_events = _jabber_process_events;
jabber_set_autoping = _jabber_set_autoping;
jabber_get_available_resources = _jabber_get_available_resources;
jabber_get_connection_status = _jabber_get_connection_status;
jabber_get_fulljid = _jabber_get_fulljid;
jabber_get_domain = _jabber_get_domain;
jabber_get_presence_message = _jabber_get_presence_message;
jabber_get_account_name = _jabber_get_account_name;
}

View File

@ -74,6 +74,8 @@ typedef struct disco_identity_t {
char *category; char *category;
} DiscoIdentity; } DiscoIdentity;
void jabber_init_module(void);
// connection functions // connection functions
void (*jabber_init)(const int disable_tls); void (*jabber_init)(const int disable_tls);
jabber_conn_status_t (*jabber_connect_with_details)(const char * const jid, jabber_conn_status_t (*jabber_connect_with_details)(const char * const jid,