diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/bookmark.c | 42 | ||||
-rw-r--r-- | src/xmpp/capabilities.c | 25 | ||||
-rw-r--r-- | src/xmpp/connection.c | 67 | ||||
-rw-r--r-- | src/xmpp/form.c | 87 | ||||
-rw-r--r-- | src/xmpp/iq.c | 105 | ||||
-rw-r--r-- | src/xmpp/message.c | 101 | ||||
-rw-r--r-- | src/xmpp/presence.c | 57 | ||||
-rw-r--r-- | src/xmpp/roster.c | 33 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 186 |
9 files changed, 277 insertions, 426 deletions
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index 00dcbaa4..ddc6e300 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -88,8 +88,8 @@ bookmark_request(void) xmpp_stanza_release(iq); } -static gboolean -_bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str) +gboolean +bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str) { if (autocomplete_contains(bookmark_ac, jid)) { return FALSE; @@ -121,8 +121,8 @@ _bookmark_add(const char *jid, const char *nick, const char *password, const cha } } -static gboolean -_bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str) +gboolean +bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str) { Bookmark *item = malloc(sizeof(*item)); item->jid = strdup(jid); @@ -156,8 +156,8 @@ _bookmark_update(const char *jid, const char *nick, const char *password, const } } -static gboolean -_bookmark_join(const char *jid) +gboolean +bookmark_join(const char *jid) { Bookmark *item = malloc(sizeof(*item)); item->jid = strdup(jid); @@ -188,8 +188,8 @@ _bookmark_join(const char *jid) } } -static gboolean -_bookmark_remove(const char *jid) +gboolean +bookmark_remove(const char *jid) { Bookmark *item = malloc(sizeof(*item)); item->jid = strdup(jid); @@ -213,20 +213,20 @@ _bookmark_remove(const char *jid) } } -static const GList * -_bookmark_get_list(void) +const GList * +bookmark_get_list(void) { return bookmark_list; } -static char * -_bookmark_find(char *search_str) +char * +bookmark_find(char *search_str) { return autocomplete_complete(bookmark_ac, search_str, TRUE); } -static void -_bookmark_autocomplete_reset(void) +void +bookmark_autocomplete_reset(void) { if (bookmark_ac != NULL) { autocomplete_reset(bookmark_ac); @@ -468,16 +468,4 @@ _send_bookmarks(void) xmpp_send(conn, iq); xmpp_stanza_release(iq); -} - -void -bookmark_init_module(void) -{ - bookmark_add = _bookmark_add; - bookmark_update = _bookmark_update; - bookmark_remove = _bookmark_remove; - bookmark_join = _bookmark_join; - bookmark_get_list = _bookmark_get_list; - bookmark_find = _bookmark_find; - bookmark_autocomplete_reset = _bookmark_autocomplete_reset; -} +} \ No newline at end of file diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index cbacae9b..164313e1 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -60,7 +60,6 @@ static GHashTable *jid_to_caps; static char *my_sha1; -static void _caps_destroy(Capabilities *caps); static gchar* _get_cache_file(void); static void _save_cache(void); static Capabilities * _caps_by_ver(const char * const ver); @@ -82,7 +81,7 @@ caps_init(void) NULL); jid_to_ver = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - jid_to_caps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_caps_destroy); + jid_to_caps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)caps_destroy); my_sha1 = NULL; } @@ -227,8 +226,8 @@ _caps_by_jid(const char * const jid) return g_hash_table_lookup(jid_to_caps, jid); } -static Capabilities * -_caps_lookup(const char * const jid) +Capabilities * +caps_lookup(const char * const jid) { char *ver = g_hash_table_lookup(jid_to_ver, jid); if (ver) { @@ -624,8 +623,8 @@ caps_create_query_response_stanza(xmpp_ctx_t * const ctx) return query; } -static void -_caps_close(void) +void +caps_close(void) { g_key_file_free(cache); cache = NULL; @@ -633,8 +632,8 @@ _caps_close(void) g_hash_table_destroy(jid_to_caps); } -static void -_caps_destroy(Capabilities *caps) +void +caps_destroy(Capabilities *caps) { if (caps != NULL) { free(caps->category); @@ -672,12 +671,4 @@ _save_cache(void) g_file_set_contents(cache_loc, g_cache_data, g_data_size, NULL); g_chmod(cache_loc, S_IRUSR | S_IWUSR); g_free(g_cache_data); -} - -void -capabilities_init_module(void) -{ - caps_lookup = _caps_lookup; - caps_close = _caps_close; - caps_destroy = _caps_destroy; -} +} \ No newline at end of file diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 266dd574..915525e4 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -104,8 +104,8 @@ void _connection_free_saved_account(void); void _connection_free_saved_details(void); void _connection_free_session_data(void); -static void -_jabber_init(const int disable_tls) +void +jabber_init(const int disable_tls) { log_info("Initialising XMPP"); jabber_conn.conn_status = JABBER_STARTED; @@ -121,8 +121,8 @@ _jabber_init(const int disable_tls) xmpp_initialize(); } -static jabber_conn_status_t -_jabber_connect_with_account(const ProfAccount * const account) +jabber_conn_status_t +jabber_connect_with_account(const ProfAccount * const account) { assert(account != NULL); @@ -147,8 +147,8 @@ _jabber_connect_with_account(const ProfAccount * const account) return result; } -static jabber_conn_status_t -_jabber_connect_with_details(const char * const jid, +jabber_conn_status_t +jabber_connect_with_details(const char * const jid, const char * const passwd, const char * const altdomain, const int port) { assert(jid != NULL); @@ -184,8 +184,8 @@ _jabber_connect_with_details(const char * const jid, return _jabber_connect(saved_details.jid, passwd, saved_details.altdomain, saved_details.port); } -static void -_jabber_disconnect(void) +void +jabber_disconnect(void) { // if connected, send end stream and wait for response if (jabber_conn.conn_status == JABBER_CONNECTED) { @@ -214,8 +214,8 @@ _jabber_disconnect(void) FREE_SET_NULL(jabber_conn.domain); } -static void -_jabber_shutdown(void) +void +jabber_shutdown(void) { _connection_free_saved_account(); _connection_free_saved_details(); @@ -224,8 +224,8 @@ _jabber_shutdown(void) free(jabber_conn.log); } -static void -_jabber_process_events(void) +void +jabber_process_events(void) { int reconnect_sec; @@ -250,14 +250,14 @@ _jabber_process_events(void) } } -static GList * -_jabber_get_available_resources(void) +GList * +jabber_get_available_resources(void) { return g_hash_table_get_values(available_resources); } -static jabber_conn_status_t -_jabber_get_connection_status(void) +jabber_conn_status_t +jabber_get_connection_status(void) { return (jabber_conn.conn_status); } @@ -274,26 +274,26 @@ connection_get_ctx(void) return jabber_conn.ctx; } -static const char * -_jabber_get_fulljid(void) +const char * +jabber_get_fulljid(void) { return xmpp_conn_get_jid(jabber_conn.conn); } -static const char * -_jabber_get_domain(void) +const char * +jabber_get_domain(void) { return jabber_conn.domain; } -static char * -_jabber_get_presence_message(void) +char * +jabber_get_presence_message(void) { return jabber_conn.presence_message; } -static char * -_jabber_get_account_name(void) +char * +jabber_get_account_name(void) { return saved_account.name; } @@ -572,21 +572,4 @@ _xmpp_get_file_logger() file_log->userdata = &level; 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_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; -} +} \ No newline at end of file diff --git a/src/xmpp/form.c b/src/xmpp/form.c index 9d26b28f..1facc754 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -379,8 +379,8 @@ _free_field(FormField *field) } } -static void -_form_destroy(DataForm *form) +void +form_destroy(DataForm *form) { if (form) { free(form->type); @@ -400,8 +400,8 @@ _field_compare_by_var(FormField *a, FormField *b) return g_strcmp0(a->var, b->var); } -static GSList * -_form_get_non_form_type_fields_sorted(DataForm *form) +GSList * +form_get_non_form_type_fields_sorted(DataForm *form) { GSList *sorted = NULL; GSList *curr = form->fields; @@ -416,8 +416,8 @@ _form_get_non_form_type_fields_sorted(DataForm *form) return sorted; } -static GSList * -_form_get_field_values_sorted(FormField *field) +GSList * +form_get_field_values_sorted(FormField *field) { GSList *sorted = NULL; GSList *curr = field->values; @@ -432,8 +432,8 @@ _form_get_field_values_sorted(FormField *field) return sorted; } -static char * -_form_get_form_type_field(DataForm *form) +char * +form_get_form_type_field(DataForm *form) { GSList *curr = form->fields; while (curr) { @@ -447,8 +447,8 @@ _form_get_form_type_field(DataForm *form) return NULL; } -static gboolean -_form_tag_exists(DataForm *form, const char * const tag) +gboolean +form_tag_exists(DataForm *form, const char * const tag) { GList *tags = g_hash_table_get_keys(form->tag_to_var); GList *curr = tags; @@ -463,8 +463,8 @@ _form_tag_exists(DataForm *form, const char * const tag) return FALSE; } -static form_field_type_t -_form_get_field_type(DataForm *form, const char * const tag) +form_field_type_t +form_get_field_type(DataForm *form, const char * const tag) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -480,8 +480,8 @@ _form_get_field_type(DataForm *form, const char * const tag) return FIELD_UNKNOWN; } -static void -_form_set_value(DataForm *form, const char * const tag, char *value) +void +form_set_value(DataForm *form, const char * const tag, char *value) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -505,8 +505,8 @@ _form_set_value(DataForm *form, const char * const tag, char *value) } } -static void -_form_add_value(DataForm *form, const char * const tag, char *value) +void +form_add_value(DataForm *form, const char * const tag, char *value) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -530,8 +530,8 @@ _form_add_value(DataForm *form, const char * const tag, char *value) } } -static gboolean -_form_add_unique_value(DataForm *form, const char * const tag, char *value) +gboolean +form_add_unique_value(DataForm *form, const char * const tag, char *value) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -561,8 +561,8 @@ _form_add_unique_value(DataForm *form, const char * const tag, char *value) return FALSE; } -static gboolean -_form_remove_value(DataForm *form, const char * const tag, char *value) +gboolean +form_remove_value(DataForm *form, const char * const tag, char *value) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -591,8 +591,8 @@ _form_remove_value(DataForm *form, const char * const tag, char *value) return FALSE; } -static gboolean -_form_remove_text_multi_value(DataForm *form, const char * const tag, int index) +gboolean +form_remove_text_multi_value(DataForm *form, const char * const tag, int index) { index--; char *var = g_hash_table_lookup(form->tag_to_var, tag); @@ -623,8 +623,8 @@ _form_remove_text_multi_value(DataForm *form, const char * const tag, int index) return FALSE; } -static int -_form_get_value_count(DataForm *form, const char * const tag) +int +form_get_value_count(DataForm *form, const char * const tag) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -645,8 +645,8 @@ _form_get_value_count(DataForm *form, const char * const tag) return 0; } -static gboolean -_form_field_contains_option(DataForm *form, const char * const tag, char *value) +gboolean +form_field_contains_option(DataForm *form, const char * const tag, char *value) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -670,8 +670,8 @@ _form_field_contains_option(DataForm *form, const char * const tag, char *value) return FALSE; } -static FormField * -_form_get_field_by_tag(DataForm *form, const char * const tag) +FormField * +form_get_field_by_tag(DataForm *form, const char * const tag) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -687,8 +687,8 @@ _form_get_field_by_tag(DataForm *form, const char * const tag) return NULL; } -static Autocomplete -_form_get_value_ac(DataForm *form, const char * const tag) +Autocomplete +form_get_value_ac(DataForm *form, const char * const tag) { char *var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { @@ -704,8 +704,8 @@ _form_get_value_ac(DataForm *form, const char * const tag) return NULL; } -static void -_form_reset_autocompleters(DataForm *form) +void +form_reset_autocompleters(DataForm *form) { autocomplete_reset(form->tag_ac); GSList *curr_field = form->fields; @@ -714,25 +714,4 @@ _form_reset_autocompleters(DataForm *form) autocomplete_reset(field->value_ac); curr_field = g_slist_next(curr_field); } -} - -void -form_init_module(void) -{ - form_destroy = _form_destroy; - form_get_form_type_field = _form_get_form_type_field; - form_get_field_type = _form_get_field_type; - form_set_value = _form_set_value; - form_add_unique_value = _form_add_unique_value; - form_add_value = _form_add_value; - form_remove_value = _form_remove_value; - form_remove_text_multi_value = _form_remove_text_multi_value; - form_field_contains_option = _form_field_contains_option; - form_tag_exists = _form_tag_exists; - form_get_value_count = _form_get_value_count; - form_get_value_ac = _form_get_value_ac; - form_get_field_by_tag = _form_get_field_by_tag; - form_reset_autocompleters = _form_reset_autocompleters; - form_get_non_form_type_fields_sorted = _form_get_non_form_type_fields_sorted; - form_get_field_values_sorted = _form_get_field_values_sorted; -} +} \ No newline at end of file diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 2292e9c4..7fedf0ed 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -125,8 +125,8 @@ iq_add_handlers(void) } } -static void -_iq_set_autoping(const int seconds) +void +iq_set_autoping(const int seconds) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -142,8 +142,8 @@ _iq_set_autoping(const int seconds) } } -static void -_iq_room_list_request(gchar *conferencejid) +void +iq_room_list_request(gchar *conferencejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -152,8 +152,8 @@ _iq_room_list_request(gchar *conferencejid) xmpp_stanza_release(iq); } -static void -_iq_disco_info_request(gchar *jid) +void +iq_disco_info_request(gchar *jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -168,8 +168,8 @@ _iq_disco_info_request(gchar *jid) xmpp_stanza_release(iq); } -static void -_iq_room_info_request(gchar *room) +void +iq_room_info_request(gchar *room) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -184,8 +184,8 @@ _iq_room_info_request(gchar *room) xmpp_stanza_release(iq); } -static void -_iq_send_caps_request_for_jid(const char * const to, const char * const id, +void +iq_send_caps_request_for_jid(const char * const to, const char * const id, const char * const node, const char * const ver) { xmpp_conn_t * const conn = connection_get_conn(); @@ -211,8 +211,8 @@ _iq_send_caps_request_for_jid(const char * const to, const char * const id, xmpp_stanza_release(iq); } -static void -_iq_send_caps_request(const char * const to, const char * const id, +void +iq_send_caps_request(const char * const to, const char * const id, const char * const node, const char * const ver) { xmpp_conn_t * const conn = connection_get_conn(); @@ -238,8 +238,8 @@ _iq_send_caps_request(const char * const to, const char * const id, xmpp_stanza_release(iq); } -static void -_iq_send_caps_request_legacy(const char * const to, const char * const id, +void +iq_send_caps_request_legacy(const char * const to, const char * const id, const char * const node, const char * const ver) { xmpp_conn_t * const conn = connection_get_conn(); @@ -265,8 +265,8 @@ _iq_send_caps_request_legacy(const char * const to, const char * const id, xmpp_stanza_release(iq); } -static void -_iq_disco_items_request(gchar *jid) +void +iq_disco_items_request(gchar *jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -275,8 +275,8 @@ _iq_disco_items_request(gchar *jid) xmpp_stanza_release(iq); } -static void -_iq_send_software_version(const char * const fulljid) +void +iq_send_software_version(const char * const fulljid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -285,8 +285,8 @@ _iq_send_software_version(const char * const fulljid) xmpp_stanza_release(iq); } -static void -_iq_confirm_instant_room(const char * const room_jid) +void +iq_confirm_instant_room(const char * const room_jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -295,8 +295,8 @@ _iq_confirm_instant_room(const char * const room_jid) xmpp_stanza_release(iq); } -static void -_iq_destroy_room(const char * const room_jid) +void +iq_destroy_room(const char * const room_jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -309,8 +309,8 @@ _iq_destroy_room(const char * const room_jid) xmpp_stanza_release(iq); } -static void -_iq_request_room_config_form(const char * const room_jid) +void +iq_request_room_config_form(const char * const room_jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -323,8 +323,8 @@ _iq_request_room_config_form(const char * const room_jid) xmpp_stanza_release(iq); } -static void -_iq_submit_room_config(const char * const room, DataForm *form) +void +iq_submit_room_config(const char * const room, DataForm *form) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -337,8 +337,8 @@ _iq_submit_room_config(const char * const room, DataForm *form) xmpp_stanza_release(iq); } -static void -_iq_room_config_cancel(const char * const room_jid) +void +iq_room_config_cancel(const char * const room_jid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -347,8 +347,8 @@ _iq_room_config_cancel(const char * const room_jid) xmpp_stanza_release(iq); } -static void -_iq_room_affiliation_list(const char * const room, char *affiliation) +void +iq_room_affiliation_list(const char * const room, char *affiliation) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -361,8 +361,8 @@ _iq_room_affiliation_list(const char * const room, char *affiliation) xmpp_stanza_release(iq); } -static void -_iq_room_kick_occupant(const char * const room, const char * const nick, const char * const reason) +void +iq_room_kick_occupant(const char * const room, const char * const nick, const char * const reason) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -380,8 +380,8 @@ struct privilege_set_t { char *privilege; }; -static void -_iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation, +void +iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation, const char * const reason) { xmpp_conn_t * const conn = connection_get_conn(); @@ -400,8 +400,8 @@ _iq_room_affiliation_set(const char * const room, const char * const jid, char * xmpp_stanza_release(iq); } -static void -_iq_room_role_set(const char * const room, const char * const nick, char *role, +void +iq_room_role_set(const char * const room, const char * const nick, char *role, const char * const reason) { xmpp_conn_t * const conn = connection_get_conn(); @@ -420,8 +420,8 @@ _iq_room_role_set(const char * const room, const char * const nick, char *role, xmpp_stanza_release(iq); } -static void -_iq_room_role_list(const char * const room, char *role) +void +iq_room_role_list(const char * const room, char *role) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -434,8 +434,8 @@ _iq_room_role_list(const char * const room, char *role) xmpp_stanza_release(iq); } -static void -_iq_send_ping(const char * const target) +void +iq_send_ping(const char * const target) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -1422,29 +1422,4 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan g_slist_free_full(items, (GDestroyNotify)_item_destroy); return 1; -} - -void -iq_init_module(void) -{ - iq_room_list_request = _iq_room_list_request; - iq_disco_info_request = _iq_disco_info_request; - iq_disco_items_request = _iq_disco_items_request; - iq_send_software_version = _iq_send_software_version; - iq_set_autoping = _iq_set_autoping; - iq_confirm_instant_room = _iq_confirm_instant_room; - iq_destroy_room = _iq_destroy_room; - iq_send_ping = _iq_send_ping; - iq_request_room_config_form = _iq_request_room_config_form; - iq_room_config_cancel = _iq_room_config_cancel; - iq_submit_room_config = _iq_submit_room_config; - iq_send_caps_request = _iq_send_caps_request; - iq_send_caps_request_for_jid = _iq_send_caps_request_for_jid; - iq_send_caps_request_legacy = _iq_send_caps_request_legacy; - iq_room_info_request = _iq_room_info_request; - iq_room_affiliation_set = _iq_room_affiliation_set; - iq_room_affiliation_list = _iq_room_affiliation_list; - iq_room_role_set = _iq_room_role_set; - iq_room_kick_occupant = _iq_room_kick_occupant; - iq_room_role_list = _iq_room_role_list; } \ No newline at end of file diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 84769213..c1c1ac14 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -79,41 +79,32 @@ message_add_handlers(void) HANDLE(STANZA_NS_CAPTCHA, NULL, _captcha_handler); } -static void -_message_send_chat(const char * const barejid, const char * const msg) +void +message_send_chat(const char * const barejid, const char * const resource, const char * const msg, gboolean send_state) { - const char * jid = NULL; - - if (roster_barejid_from_name(barejid) != NULL) { - jid = roster_barejid_from_name(barejid); - } else { - jid = barejid; - } - - if (prefs_get_boolean(PREF_STATES)) { - if (!chat_session_exists(jid)) { - chat_session_start(jid, TRUE); - } - } - xmpp_stanza_t *message; xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); - if (prefs_get_boolean(PREF_STATES) && chat_session_get_recipient_supports(jid)) { - chat_session_set_active(jid); - message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT, - msg, STANZA_NAME_ACTIVE); + + GString *jid = g_string_new(barejid); + if (resource) { + g_string_append(jid, "/"); + g_string_append(jid, resource); + } + + if (send_state) { + message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, STANZA_NAME_ACTIVE); } else { - message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT, - msg, NULL); + message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, NULL); } xmpp_send(conn, message); xmpp_stanza_release(message); + g_string_free(jid, TRUE); } -static void -_message_send_private(const char * const fulljid, const char * const msg) +void +message_send_private(const char * const fulljid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -123,8 +114,8 @@ _message_send_private(const char * const fulljid, const char * const msg) xmpp_stanza_release(message); } -static void -_message_send_groupchat(const char * const roomjid, const char * const msg) +void +message_send_groupchat(const char * const roomjid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -134,8 +125,8 @@ _message_send_groupchat(const char * const roomjid, const char * const msg) xmpp_stanza_release(message); } -static void -_message_send_groupchat_subject(const char * const roomjid, const char * const subject) +void +message_send_groupchat_subject(const char * const roomjid, const char * const subject) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -145,8 +136,8 @@ _message_send_groupchat_subject(const char * const roomjid, const char * const s xmpp_stanza_release(message); } -static void -_message_send_invite(const char * const roomjid, const char * const contact, +void +message_send_invite(const char * const roomjid, const char * const contact, const char * const reason) { xmpp_conn_t * const conn = connection_get_conn(); @@ -157,8 +148,8 @@ _message_send_invite(const char * const roomjid, const char * const contact, xmpp_stanza_release(stanza); } -static void -_message_send_composing(const char * const barejid) +void +message_send_composing(const char * const barejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -167,11 +158,10 @@ _message_send_composing(const char * const barejid) xmpp_send(conn, stanza); xmpp_stanza_release(stanza); - chat_session_set_sent(barejid); } -static void -_message_send_paused(const char * const barejid) +void +message_send_paused(const char * const barejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -180,11 +170,10 @@ _message_send_paused(const char * const barejid) xmpp_send(conn, stanza); xmpp_stanza_release(stanza); - chat_session_set_sent(barejid); } -static void -_message_send_inactive(const char * const barejid) +void +message_send_inactive(const char * const barejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -193,11 +182,10 @@ _message_send_inactive(const char * const barejid) xmpp_send(conn, stanza); xmpp_stanza_release(stanza); - chat_session_set_sent(barejid); } -static void -_message_send_gone(const char * const barejid) +void +message_send_gone(const char * const barejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -206,7 +194,6 @@ _message_send_gone(const char * const barejid) xmpp_send(conn, stanza); xmpp_stanza_release(stanza); - chat_session_set_sent(barejid); } static int @@ -214,7 +201,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { char *id = xmpp_stanza_get_id(stanza); - char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + char *jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); char *type = NULL; if (error_stanza != NULL) { @@ -229,9 +216,9 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_append(log_msg, " id="); g_string_append(log_msg, id); } - if (from != NULL) { + if (jid != NULL) { g_string_append(log_msg, " from="); - g_string_append(log_msg, from); + g_string_append(log_msg, jid); } if (type != NULL) { g_string_append(log_msg, " type="); @@ -244,7 +231,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_free(log_msg, TRUE); - handle_message_error(from, type, err_msg); + handle_message_error(jid, type, err_msg); free(err_msg); @@ -468,11 +455,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } // create or update chat session - if (!chat_session_exists(jid->barejid)) { - chat_session_start(jid->barejid, recipient_supports); - } else { - chat_session_set_recipient_supports(jid->barejid, recipient_supports); - } + chat_session_on_incoming_message(jid->barejid, recipient_supports); // determine if the notifications happened whilst offline GTimeVal tv_stamp; @@ -510,18 +493,4 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, jid_destroy(jid); return 1; } -} - -void -message_init_module(void) -{ - message_send_chat = _message_send_chat; - message_send_private = _message_send_private; - message_send_groupchat = _message_send_groupchat; - message_send_invite = _message_send_invite; - message_send_composing = _message_send_composing; - message_send_paused = _message_send_paused; - message_send_inactive = _message_send_inactive; - message_send_gone = _message_send_gone; - message_send_groupchat_subject = _message_send_groupchat_subject; -} +} \ No newline at end of file diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 9e24c7ac..1b3e7fc7 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -94,8 +94,8 @@ presence_add_handlers(void) HANDLE(NULL, NULL, _available_handler); } -static void -_presence_subscription(const char * const jid, const jabber_subscr_t action) +void +presence_subscription(const char * const jid, const jabber_subscr_t action) { assert(jid != NULL); @@ -139,14 +139,14 @@ _presence_subscription(const char * const jid, const jabber_subscr_t action) free(id); } -static GSList * -_presence_get_subscription_requests(void) +GSList * +presence_get_subscription_requests(void) { return autocomplete_create_list(sub_requests_ac); } -static gint -_presence_sub_request_count(void) +gint +presence_sub_request_count(void) { return autocomplete_length(sub_requests_ac); } @@ -157,14 +157,14 @@ presence_clear_sub_requests(void) autocomplete_clear(sub_requests_ac); } -static char * -_presence_sub_request_find(char * search_str) +char * +presence_sub_request_find(char * search_str) { return autocomplete_complete(sub_requests_ac, search_str, TRUE); } -static gboolean -_presence_sub_request_exists(const char * const bare_jid) +gboolean +presence_sub_request_exists(const char * const bare_jid) { gboolean result = FALSE; GSList *requests_p = autocomplete_create_list(sub_requests_ac); @@ -185,14 +185,14 @@ _presence_sub_request_exists(const char * const bare_jid) return result; } -static void -_presence_reset_sub_request_search(void) +void +presence_reset_sub_request_search(void) { autocomplete_reset(sub_requests_ac); } -static void -_presence_update(const resource_presence_t presence_type, const char * const msg, +void +presence_update(const resource_presence_t presence_type, const char * const msg, const int idle) { if (jabber_get_connection_status() != JABBER_CONNECTED) { @@ -266,8 +266,8 @@ _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence) } } -static void -_presence_join_room(char *room, char *nick, char * passwd) +void +presence_join_room(char *room, char *nick, char * passwd) { Jid *jid = jid_create_from_bare_and_resource(room, nick); @@ -293,8 +293,8 @@ _presence_join_room(char *room, char *nick, char * passwd) jid_destroy(jid); } -static void -_presence_change_room_nick(const char * const room, const char * const nick) +void +presence_change_room_nick(const char * const room, const char * const nick) { assert(room != NULL); assert(nick != NULL); @@ -323,8 +323,8 @@ _presence_change_room_nick(const char * const room, const char * const nick) free(full_room_jid); } -static void -_presence_leave_chat_room(const char * const room_jid) +void +presence_leave_chat_room(const char * const room_jid) { assert(room_jid != NULL); @@ -774,19 +774,4 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * jid_destroy(from_jid); return 1; -} - -void -presence_init_module(void) -{ - presence_subscription = _presence_subscription; - presence_get_subscription_requests = _presence_get_subscription_requests; - presence_sub_request_count = _presence_sub_request_count; - presence_sub_request_find = _presence_sub_request_find; - presence_sub_request_exists = _presence_sub_request_exists; - presence_reset_sub_request_search = _presence_reset_sub_request_search; - presence_update = _presence_update; - presence_join_room = _presence_join_room; - presence_change_room_nick = _presence_change_room_nick; - presence_leave_chat_room = _presence_leave_chat_room; -} +} \ No newline at end of file diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index f5439c46..3449c8d5 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -95,8 +95,8 @@ roster_request(void) xmpp_stanza_release(iq); } -static void -_roster_send_add_new(const char * const barejid, const char * const name) +void +roster_send_add_new(const char * const barejid, const char * const name) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -105,8 +105,8 @@ _roster_send_add_new(const char * const barejid, const char * const name) xmpp_stanza_release(iq); } -static void -_roster_send_remove(const char * const barejid) +void +roster_send_remove(const char * const barejid) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -115,8 +115,8 @@ _roster_send_remove(const char * const barejid) xmpp_stanza_release(iq); } -static void -_roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) +void +roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); @@ -126,8 +126,8 @@ _roster_send_name_change(const char * const barejid, const char * const new_name xmpp_stanza_release(iq); } -static void -_roster_send_add_to_group(const char * const group, PContact contact) +void +roster_send_add_to_group(const char * const group, PContact contact) { GSList *groups = p_contact_groups(contact); GSList *new_groups = NULL; @@ -171,8 +171,8 @@ _group_add_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, return 0; } -static void -_roster_send_remove_from_group(const char * const group, PContact contact) +void +roster_send_remove_from_group(const char * const group, PContact contact) { GSList *groups = p_contact_groups(contact); GSList *new_groups = NULL; @@ -351,15 +351,4 @@ _get_groups_from_item(xmpp_stanza_t *item) } return groups; -} - -void -roster_init_module(void) -{ - roster_send_add_new = _roster_send_add_new; - roster_send_remove = _roster_send_remove; - roster_send_name_change = _roster_send_name_change; - roster_send_add_to_group = _roster_send_add_to_group; - roster_send_remove_from_group = _roster_send_remove_from_group; - -} +} \ No newline at end of file diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index e893747e..2499d008 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -129,119 +129,111 @@ typedef struct data_form_t { gboolean modified; } DataForm; -void jabber_init_module(void); -void bookmark_init_module(void); -void capabilities_init_module(void); -void iq_init_module(void); -void message_init_module(void); -void presence_init_module(void); -void roster_init_module(void); -void form_init_module(void); - // connection functions -void (*jabber_init)(const int disable_tls); -jabber_conn_status_t (*jabber_connect_with_details)(const char * const jid, +void jabber_init(const int disable_tls); +jabber_conn_status_t jabber_connect_with_details(const char * const jid, const char * const passwd, const char * const altdomain, const int port); -jabber_conn_status_t (*jabber_connect_with_account)(const ProfAccount * const account); -void (*jabber_disconnect)(void); -void (*jabber_shutdown)(void); -void (*jabber_process_events)(void); -const char * (*jabber_get_fulljid)(void); -const char * (*jabber_get_domain)(void); -jabber_conn_status_t (*jabber_get_connection_status)(void); -char * (*jabber_get_presence_message)(void); -char* (*jabber_get_account_name)(void); -GList * (*jabber_get_available_resources)(void); +jabber_conn_status_t jabber_connect_with_account(const ProfAccount * const account); +void jabber_disconnect(void); +void jabber_shutdown(void); +void jabber_process_events(void); +const char * jabber_get_fulljid(void); +const char * jabber_get_domain(void); +jabber_conn_status_t jabber_get_connection_status(void); +char * jabber_get_presence_message(void); +char* jabber_get_account_name(void); +GList * jabber_get_available_resources(void); // message functions -void (*message_send_chat)(const char * const barejid, const char * const msg); -void (*message_send_private)(const char * const fulljid, const char * const msg); -void (*message_send_groupchat)(const char * const roomjid, const char * const msg); -void (*message_send_groupchat_subject)(const char * const roomjid, const char * const subject); - -void (*message_send_inactive)(const char * const barejid); -void (*message_send_composing)(const char * const barejid); -void (*message_send_paused)(const char * const barejid); -void (*message_send_gone)(const char * const barejid); - -void (*message_send_invite)(const char * const room, const char * const contact, +void message_send_chat(const char * const barejid, const char * const resource, const char * const msg, + gboolean send_state); +void message_send_private(const char * const fulljid, const char * const msg); +void message_send_groupchat(const char * const roomjid, const char * const msg); +void message_send_groupchat_subject(const char * const roomjid, const char * const subject); + +void message_send_inactive(const char * const barejid); +void message_send_composing(const char * const barejid); +void message_send_paused(const char * const barejid); +void message_send_gone(const char * const barejid); + +void message_send_invite(const char * const room, const char * const contact, const char * const reason); // presence functions -void (*presence_subscription)(const char * const jid, const jabber_subscr_t action); -GSList* (*presence_get_subscription_requests)(void); -gint (*presence_sub_request_count)(void); -void (*presence_reset_sub_request_search)(void); -char * (*presence_sub_request_find)(char * search_str); -void (*presence_join_room)(char *room, char *nick, char * passwd); -void (*presence_change_room_nick)(const char * const room, const char * const nick); -void (*presence_leave_chat_room)(const char * const room_jid); -void (*presence_update)(resource_presence_t status, const char * const msg, +void presence_subscription(const char * const jid, const jabber_subscr_t action); +GSList* presence_get_subscription_requests(void); +gint presence_sub_request_count(void); +void presence_reset_sub_request_search(void); +char * presence_sub_request_find(char * search_str); +void presence_join_room(char *room, char *nick, char * passwd); +void presence_change_room_nick(const char * const room, const char * const nick); +void presence_leave_chat_room(const char * const room_jid); +void presence_update(resource_presence_t status, const char * const msg, int idle); -gboolean (*presence_sub_request_exists)(const char * const bare_jid); +gboolean presence_sub_request_exists(const char * const bare_jid); // iq functions -void (*iq_send_software_version)(const char * const fulljid); -void (*iq_room_list_request)(gchar *conferencejid); -void (*iq_disco_info_request)(gchar *jid); -void (*iq_disco_items_request)(gchar *jid); -void (*iq_set_autoping)(int seconds); -void (*iq_confirm_instant_room)(const char * const room_jid); -void (*iq_destroy_room)(const char * const room_jid); -void (*iq_request_room_config_form)(const char * const room_jid); -void (*iq_submit_room_config)(const char * const room, DataForm *form); -void (*iq_room_config_cancel)(const char * const room_jid); -void (*iq_send_ping)(const char * const target); -void (*iq_send_caps_request)(const char * const to, const char * const id, +void iq_send_software_version(const char * const fulljid); +void iq_room_list_request(gchar *conferencejid); +void iq_disco_info_request(gchar *jid); +void iq_disco_items_request(gchar *jid); +void iq_set_autoping(int seconds); +void iq_confirm_instant_room(const char * const room_jid); +void iq_destroy_room(const char * const room_jid); +void iq_request_room_config_form(const char * const room_jid); +void iq_submit_room_config(const char * const room, DataForm *form); +void iq_room_config_cancel(const char * const room_jid); +void iq_send_ping(const char * const target); +void iq_send_caps_request(const char * const to, const char * const id, const char * const node, const char * const ver); -void (*iq_send_caps_request_for_jid)(const char * const to, const char * const id, +void iq_send_caps_request_for_jid(const char * const to, const char * const id, const char * const node, const char * const ver); -void (*iq_send_caps_request_legacy)(const char * const to, const char * const id, +void iq_send_caps_request_legacy(const char * const to, const char * const id, const char * const node, const char * const ver); -void (*iq_room_info_request)(gchar *room); -void (*iq_room_affiliation_list)(const char * const room, char *affiliation); -void (*iq_room_affiliation_set)(const char * const room, const char * const jid, char *affiliation, +void iq_room_info_request(gchar *room); +void iq_room_affiliation_list(const char * const room, char *affiliation); +void iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation, const char * const reason); -void (*iq_room_kick_occupant)(const char * const room, const char * const nick, const char * const reason); -void (*iq_room_role_set)(const char * const room, const char * const nick, char *role, +void iq_room_kick_occupant(const char * const room, const char * const nick, const char * const reason); +void iq_room_role_set(const char * const room, const char * const nick, char *role, const char * const reason); -void (*iq_room_role_list)(const char * const room, char *role); +void iq_room_role_list(const char * const room, char *role); // caps functions -Capabilities* (*caps_lookup)(const char * const jid); -void (*caps_close)(void); -void (*caps_destroy)(Capabilities *caps); - -gboolean (*bookmark_add)(const char *jid, const char *nick, const char *password, const char *autojoin_str); -gboolean (*bookmark_update)(const char *jid, const char *nick, const char *password, const char *autojoin_str); -gboolean (*bookmark_remove)(const char *jid); -gboolean (*bookmark_join)(const char *jid); -const GList * (*bookmark_get_list)(void); -char * (*bookmark_find)(char *search_str); -void (*bookmark_autocomplete_reset)(void); - -void (*roster_send_name_change)(const char * const barejid, const char * const new_name, GSList *groups); -void (*roster_send_add_to_group)(const char * const group, PContact contact); -void (*roster_send_remove_from_group)(const char * const group, PContact contact); -void (*roster_send_add_new)(const char * const barejid, const char * const name); -void (*roster_send_remove)(const char * const barejid); - -void (*form_destroy)(DataForm *form); -char * (*form_get_form_type_field)(DataForm *form); -void (*form_set_value)(DataForm *form, const char * const tag, char *value); -gboolean (*form_add_unique_value)(DataForm *form, const char * const tag, char *value); -void (*form_add_value)(DataForm *form, const char * const tag, char *value); -gboolean (*form_remove_value)(DataForm *form, const char * const tag, char *value); -gboolean (*form_remove_text_multi_value)(DataForm *form, const char * const tag, int index); -gboolean (*form_tag_exists)(DataForm *form, const char * const tag); -form_field_type_t (*form_get_field_type)(DataForm *form, const char * const tag); -gboolean (*form_field_contains_option)(DataForm *form, const char * const tag, char *value); -int (*form_get_value_count)(DataForm *form, const char * const tag); -FormField* (*form_get_field_by_tag)(DataForm *form, const char * const tag); -Autocomplete (*form_get_value_ac)(DataForm *form, const char * const tag); -void (*form_reset_autocompleters)(DataForm *form); - -GSList * (*form_get_non_form_type_fields_sorted)(DataForm *form); -GSList * (*form_get_field_values_sorted)(FormField *field); +Capabilities* caps_lookup(const char * const jid); +void caps_close(void); +void caps_destroy(Capabilities *caps); + +gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str); +gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str); +gboolean bookmark_remove(const char *jid); +gboolean bookmark_join(const char *jid); +const GList * bookmark_get_list(void); +char * bookmark_find(char *search_str); +void bookmark_autocomplete_reset(void); + +void roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups); +void roster_send_add_to_group(const char * const group, PContact contact); +void roster_send_remove_from_group(const char * const group, PContact contact); +void roster_send_add_new(const char * const barejid, const char * const name); +void roster_send_remove(const char * const barejid); + +void form_destroy(DataForm *form); +char * form_get_form_type_field(DataForm *form); +void form_set_value(DataForm *form, const char * const tag, char *value); +gboolean form_add_unique_value(DataForm *form, const char * const tag, char *value); +void form_add_value(DataForm *form, const char * const tag, char *value); +gboolean form_remove_value(DataForm *form, const char * const tag, char *value); +gboolean form_remove_text_multi_value(DataForm *form, const char * const tag, int index); +gboolean form_tag_exists(DataForm *form, const char * const tag); +form_field_type_t form_get_field_type(DataForm *form, const char * const tag); +gboolean form_field_contains_option(DataForm *form, const char * const tag, char *value); +int form_get_value_count(DataForm *form, const char * const tag); +FormField* form_get_field_by_tag(DataForm *form, const char * const tag); +Autocomplete form_get_value_ac(DataForm *form, const char * const tag); +void form_reset_autocompleters(DataForm *form); + +GSList * form_get_non_form_type_fields_sorted(DataForm *form); +GSList * form_get_field_values_sorted(FormField *field); #endif |