1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into plugins

This commit is contained in:
James Booth 2014-04-26 00:37:37 +01:00
commit 91e0fd8af1
31 changed files with 39 additions and 230 deletions

5
debian/changelog vendored
View File

@ -1,5 +0,0 @@
profanity (0.4.0) UNRELEASED; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Florent Peterschmitt <florent@peterschmitt.fr> Fri, 31 May 2013 10:07:08 +0200

1
debian/compat vendored
View File

@ -1 +0,0 @@
8

11
debian/control vendored
View File

@ -1,11 +0,0 @@
Source: profanity
Maintainer: Florent Peterschmitt <florent@peterschmitt.fr>
Section: misc
Priority: optional
Standards-Version: 3.9.2
Build-Depends: debhelper (>=8), libexpat1-dev, libexpat1, libssl-dev, libncursesw5-dev, libglib2.0-dev, libglib2.0-0, libcurl4-openssl-dev, libotr-dev
Package: profanity
Depends: ${shlibs:Depends}, ${misc:Depends}, libexpat1, libssl1.0.0, libncursesw5, libglib2.0-0, curl, libotr
Description: Console XMPP client
Architecture: all

8
debian/rules vendored
View File

@ -1,8 +0,0 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_install:
$(MAKE) DESTDIR=$$(pwd)/debian/profanity prefix=/usr install
override_dh_auto_test:

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -181,18 +181,6 @@ chat_session_is_inactive(const char * const recipient)
} }
} }
gboolean
chat_session_is_active(const char * const recipient)
{
ChatSession session = g_hash_table_lookup(sessions, recipient);
if (session == NULL) {
return FALSE;
} else {
return (session->state == CHAT_STATE_ACTIVE);
}
}
void void
chat_session_set_active(const char * const recipient) chat_session_set_active(const char * const recipient)
{ {

View File

@ -38,7 +38,6 @@ void chat_session_set_recipient_supports(const char * const recipient,
void chat_session_set_composing(const char * const recipient); void chat_session_set_composing(const char * const recipient);
void chat_session_no_activity(const char * const recipient); void chat_session_no_activity(const char * const recipient);
gboolean chat_session_is_inactive(const char * const recipient); gboolean chat_session_is_inactive(const char * const recipient);
gboolean chat_session_is_active(const char * const recipient);
void chat_session_set_active(const char * const recipient); void chat_session_set_active(const char * const recipient);
gboolean chat_session_is_paused(const char * const recipient); gboolean chat_session_is_paused(const char * const recipient);
gboolean chat_session_is_gone(const char * const recipient); gboolean chat_session_is_gone(const char * const recipient);

View File

@ -1198,12 +1198,11 @@ cmd_alias_remove(char *value)
void void
cmd_autocomplete(char *input, int *size) cmd_autocomplete(char *input, int *size)
{ {
// autocomplete command
if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, *size, ' '))) {
int i = 0; int i = 0;
char *found = NULL; char *found = NULL;
char inp_cpy[*size]; char inp_cpy[*size];
// autocomplete command
if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, *size, ' '))) {
for(i = 0; i < *size; i++) { for(i = 0; i < *size; i++) {
inp_cpy[i] = input[i]; inp_cpy[i] = input[i];
} }

View File

@ -1303,7 +1303,6 @@ gboolean
cmd_status(gchar **args, struct cmd_help_t help) cmd_status(gchar **args, struct cmd_help_t help)
{ {
char *usr = args[0]; char *usr = args[0];
char *usr_jid = NULL;
jabber_conn_status_t conn_status = jabber_get_connection_status(); jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type(); win_type_t win_type = ui_current_win_type();
@ -1338,7 +1337,7 @@ cmd_status(gchar **args, struct cmd_help_t help)
break; break;
case WIN_CONSOLE: case WIN_CONSOLE:
if (usr != NULL) { if (usr != NULL) {
usr_jid = roster_barejid_from_name(usr); char *usr_jid = roster_barejid_from_name(usr);
if (usr_jid == NULL) { if (usr_jid == NULL) {
usr_jid = usr; usr_jid = usr;
} }
@ -1358,7 +1357,6 @@ gboolean
cmd_info(gchar **args, struct cmd_help_t help) cmd_info(gchar **args, struct cmd_help_t help)
{ {
char *usr = args[0]; char *usr = args[0];
char *usr_jid = NULL;
jabber_conn_status_t conn_status = jabber_get_connection_status(); jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type(); win_type_t win_type = ui_current_win_type();
@ -1414,7 +1412,7 @@ cmd_info(gchar **args, struct cmd_help_t help)
break; break;
case WIN_CONSOLE: case WIN_CONSOLE:
if (usr != NULL) { if (usr != NULL) {
usr_jid = roster_barejid_from_name(usr); char *usr_jid = roster_barejid_from_name(usr);
if (usr_jid == NULL) { if (usr_jid == NULL) {
usr_jid = usr; usr_jid = usr;
} }

View File

@ -116,7 +116,6 @@ str_replace(const char *string, const char *substr,
{ {
char *tok = NULL; char *tok = NULL;
char *newstr = NULL; char *newstr = NULL;
char *oldstr = NULL;
char *head = NULL; char *head = NULL;
if (string == NULL) if (string == NULL)
@ -131,7 +130,7 @@ str_replace(const char *string, const char *substr,
head = newstr; head = newstr;
while ( (tok = strstr ( head, substr ))) { while ( (tok = strstr ( head, substr ))) {
oldstr = newstr; char *oldstr = newstr;
newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) + newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) +
strlen ( replacement ) + 1 ); strlen ( replacement ) + 1 );
@ -171,7 +170,6 @@ char *
prof_getline(FILE *stream) prof_getline(FILE *stream)
{ {
char *buf; char *buf;
size_t buf_size;
char *result; char *result;
char *s = NULL; char *s = NULL;
size_t s_size = 1; size_t s_size = 1;
@ -183,7 +181,7 @@ prof_getline(FILE *stream)
result = fgets(buf, READ_BUF_SIZE, stream); result = fgets(buf, READ_BUF_SIZE, stream);
if (result == NULL) if (result == NULL)
break; break;
buf_size = strlen(buf); size_t buf_size = strlen(buf);
if (buf[buf_size - 1] == '\n') { if (buf[buf_size - 1] == '\n') {
buf_size--; buf_size--;
buf[buf_size] = '\0'; buf[buf_size] = '\0';
@ -416,12 +414,12 @@ cmp_win_num(gconstpointer a, gconstpointer b)
int int
get_next_available_win_num(GList *used) get_next_available_win_num(GList *used)
{ {
int result = 0;
used = g_list_sort(used, cmp_win_num); used = g_list_sort(used, cmp_win_num);
// only console used // only console used
if (g_list_length(used) == 1) { if (g_list_length(used) == 1) {
return 2; return 2;
} else { } else {
int result = 0;
int last_num = 1; int last_num = 1;
GList *curr = used; GList *curr = used;
// skip console // skip console

View File

@ -138,7 +138,6 @@ account_free(ProfAccount *account)
free(account->muc_service); free(account->muc_service);
free(account->muc_nick); free(account->muc_nick);
free(account); free(account);
account = NULL;
} }
} }

View File

@ -209,13 +209,6 @@ prefs_get_priority(void)
return g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "priority", NULL); return g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "priority", NULL);
} }
void
prefs_set_priority(gint value)
{
g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "priority", value);
_save_prefs();
}
gint gint
prefs_get_reconnect(void) prefs_get_reconnect(void)
{ {

View File

@ -88,7 +88,6 @@ void prefs_set_notify_remind(gint period);
gint prefs_get_notify_remind(void); gint prefs_get_notify_remind(void);
void prefs_set_max_log_size(gint value); void prefs_set_max_log_size(gint value);
gint prefs_get_max_log_size(void); gint prefs_get_max_log_size(void);
void prefs_set_priority(gint value);
gint prefs_get_priority(void); gint prefs_get_priority(void);
void prefs_set_reconnect(gint value); void prefs_set_reconnect(gint value);
gint prefs_get_reconnect(void); gint prefs_get_reconnect(void);

View File

@ -124,36 +124,6 @@ jid_is_valid_room_form(Jid *jid)
return (jid->fulljid != NULL); return (jid->fulljid != NULL);
} }
/*
* Given a full room JID of the form
* room@server/nick
* Will create two new strings and point room and nick to them e.g.
* *room = "room@server", *nick = "nick"
* The strings must be freed by the caller
* Returns TRUE if the JID was parsed successfully, FALSE otherwise
*/
gboolean
parse_room_jid(const char * const full_room_jid, char **room, char **nick)
{
Jid *jid = jid_create(full_room_jid);
if (jid == NULL) {
return FALSE;
}
if (jid->resourcepart == NULL) {
jid_destroy(jid);
return FALSE;
}
*room = strdup(jid->barejid);
*nick = strdup(jid->resourcepart);
jid_destroy(jid);
return TRUE;
}
/* /*
* Given a barejid, and resourcepart, create and return a full JID of the form * Given a barejid, and resourcepart, create and return a full JID of the form
* barejid/resourcepart * barejid/resourcepart
@ -173,28 +143,6 @@ create_fulljid(const char * const barejid, const char * const resource)
return result; return result;
} }
/*
* Get the room name part of the full JID, e.g.
* Full JID = "test@conference.server/person"
* returns "test@conference.server"
*/
char *
get_room_from_full_jid(const char * const full_room_jid)
{
char **tokens = g_strsplit(full_room_jid, "/", 0);
char *room_part = NULL;
if (tokens != NULL) {
if (tokens[0] != NULL) {
room_part = strdup(tokens[0]);
}
g_strfreev(tokens);
}
return room_part;
}
/* /*
* Get the nickname part of the full JID, e.g. * Get the nickname part of the full JID, e.g.
* Full JID = "test@conference.server/person" * Full JID = "test@conference.server/person"

View File

@ -42,9 +42,6 @@ void jid_destroy(Jid *jid);
gboolean jid_is_valid_room_form(Jid *jid); gboolean jid_is_valid_room_form(Jid *jid);
char * create_fulljid(const char * const barejid, const char * const resource); char * create_fulljid(const char * const barejid, const char * const resource);
char * get_room_from_full_jid(const char * const full_room_jid);
char * get_nick_from_full_jid(const char * const full_room_jid); char * get_nick_from_full_jid(const char * const full_room_jid);
gboolean parse_room_jid(const char * const full_room_jid, char **room,
char **nick);
#endif #endif

View File

@ -158,7 +158,6 @@ void
log_msg(log_level_t level, const char * const area, const char * const msg) log_msg(log_level_t level, const char * const area, const char * const msg)
{ {
if (level >= level_filter && logp != NULL) { if (level >= level_filter && logp != NULL) {
long result;
dt = g_date_time_new_now(tz); dt = g_date_time_new_now(tz);
char *level_str = _log_string_from_level(level); char *level_str = _log_string_from_level(level);
@ -172,7 +171,7 @@ log_msg(log_level_t level, const char * const area, const char * const msg)
g_free(date_fmt); g_free(date_fmt);
if (prefs_get_boolean(PREF_LOG_ROTATE)) { if (prefs_get_boolean(PREF_LOG_ROTATE)) {
result = ftell(logp); long result = ftell(logp);
if (result != -1 && result >= prefs_get_max_log_size()) { if (result != -1 && result >= prefs_get_max_log_size()) {
_rotate_log_file(); _rotate_log_file();
} }
@ -348,7 +347,6 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
char *filename = _get_log_filename(recipient, login, log_date, FALSE); char *filename = _get_log_filename(recipient, login, log_date, FALSE);
FILE *logp = fopen(filename, "r"); FILE *logp = fopen(filename, "r");
char *line;
if (logp != NULL) { if (logp != NULL) {
GString *gs_header = g_string_new(""); GString *gs_header = g_string_new("");
g_string_append_printf(gs_header, "%d/%d/%d:", g_string_append_printf(gs_header, "%d/%d/%d:",
@ -359,6 +357,7 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
history = g_slist_append(history, header); history = g_slist_append(history, header);
g_string_free(gs_header, TRUE); g_string_free(gs_header, TRUE);
char *line;
while ((line = prof_getline(logp)) != NULL) { while ((line = prof_getline(logp)) != NULL) {
history = g_slist_append(history, line); history = g_slist_append(history, line);
} }

View File

@ -494,10 +494,8 @@ muc_complete_roster_nick_change(const char * const room,
if (chat_room != NULL) { if (chat_room != NULL) {
char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick); char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick);
char *old_nick_cpy;
if (old_nick != NULL) { if (old_nick != NULL) {
old_nick_cpy = strdup(old_nick); char *old_nick_cpy = strdup(old_nick);
g_hash_table_remove(chat_room->nick_changes, nick); g_hash_table_remove(chat_room->nick_changes, nick);
return old_nick_cpy; return old_nick_cpy;

View File

@ -436,13 +436,12 @@ _otr_decrypt_message(const char * const from, const char * const message, gboole
{ {
char *decrypted = NULL; char *decrypted = NULL;
OtrlTLV *tlvs = NULL; OtrlTLV *tlvs = NULL;
OtrlTLV *tlv = NULL;
int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &decrypted, &tlvs); int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &decrypted, &tlvs);
// internal libotr message // internal libotr message
if (result == 1) { if (result == 1) {
tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
if (tlv) { if (tlv) {
ConnContext *context = otrlib_context_find(user_state, from, jid); ConnContext *context = otrlib_context_find(user_state, from, jid);

View File

@ -184,21 +184,21 @@ char *
autocomplete_param_with_func(char *input, int *size, char *command, autocomplete_param_with_func(char *input, int *size, char *command,
autocomplete_func func) autocomplete_func func)
{ {
char *found = NULL;
GString *auto_msg = NULL; GString *auto_msg = NULL;
char *result = NULL; char *result = NULL;
char inp_cpy[*size];
int i;
char command_cpy[strlen(command) + 2]; char command_cpy[strlen(command) + 2];
sprintf(command_cpy, "%s ", command); sprintf(command_cpy, "%s ", command);
int len = strlen(command_cpy); int len = strlen(command_cpy);
if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) { if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) {
int i;
char inp_cpy[*size];
for(i = len; i < *size; i++) { for(i = len; i < *size; i++) {
inp_cpy[i-len] = input[i]; inp_cpy[i-len] = input[i];
} }
inp_cpy[(*size) - len] = '\0'; inp_cpy[(*size) - len] = '\0';
found = func(inp_cpy);
char *found = func(inp_cpy);
if (found != NULL) { if (found != NULL) {
auto_msg = g_string_new(command_cpy); auto_msg = g_string_new(command_cpy);
g_string_append(auto_msg, found); g_string_append(auto_msg, found);
@ -215,20 +215,20 @@ char *
autocomplete_param_with_ac(char *input, int *size, char *command, autocomplete_param_with_ac(char *input, int *size, char *command,
Autocomplete ac) Autocomplete ac)
{ {
char *found = NULL;
GString *auto_msg = NULL; GString *auto_msg = NULL;
char *result = NULL; char *result = NULL;
char inp_cpy[*size];
int i;
char *command_cpy = malloc(strlen(command) + 2); char *command_cpy = malloc(strlen(command) + 2);
sprintf(command_cpy, "%s ", command); sprintf(command_cpy, "%s ", command);
int len = strlen(command_cpy); int len = strlen(command_cpy);
if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) { if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) {
int i;
char inp_cpy[*size];
for(i = len; i < *size; i++) { for(i = len; i < *size; i++) {
inp_cpy[i-len] = input[i]; inp_cpy[i-len] = input[i];
} }
inp_cpy[(*size) - len] = '\0'; inp_cpy[(*size) - len] = '\0';
found = autocomplete_complete(ac, inp_cpy);
char *found = autocomplete_complete(ac, inp_cpy);
if (found != NULL) { if (found != NULL) {
auto_msg = g_string_new(command_cpy); auto_msg = g_string_new(command_cpy);
g_string_append(auto_msg, found); g_string_append(auto_msg, found);
@ -246,10 +246,8 @@ char *
autocomplete_param_no_with_func(char *input, int *size, char *command, autocomplete_param_no_with_func(char *input, int *size, char *command,
int arg_number, autocomplete_func func) int arg_number, autocomplete_func func)
{ {
char *result = NULL;
if (strncmp(input, command, strlen(command)) == 0 && (*size > strlen(command))) { if (strncmp(input, command, strlen(command)) == 0 && (*size > strlen(command))) {
int i = 0; int i = 0;
char *found = NULL;
GString *result_str = NULL; GString *result_str = NULL;
// copy and null terminate input // copy and null terminate input
@ -270,12 +268,12 @@ autocomplete_param_no_with_func(char *input, int *size, char *command,
// autocomplete param // autocomplete param
if (comp_str != NULL) { if (comp_str != NULL) {
found = func(comp_str); char *found = func(comp_str);
if (found != NULL) { if (found != NULL) {
result_str = g_string_new(""); result_str = g_string_new("");
g_string_append(result_str, start_str); g_string_append(result_str, start_str);
g_string_append(result_str, found); g_string_append(result_str, found);
result = result_str->str; char *result = result_str->str;
g_string_free(result_str, FALSE); g_string_free(result_str, FALSE);
return result; return result;
} }

View File

@ -437,6 +437,5 @@ options_destroy(GHashTable *options)
{ {
if (options != NULL) { if (options != NULL) {
g_hash_table_destroy(options); g_hash_table_destroy(options);
options = NULL;
} }
} }

View File

@ -643,7 +643,6 @@ static void
_cons_show_bookmarks(const GList *list) _cons_show_bookmarks(const GList *list)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
Bookmark *item;
if (list == NULL) { if (list == NULL) {
cons_show(""); cons_show("");
@ -654,7 +653,7 @@ _cons_show_bookmarks(const GList *list)
/* TODO: show status (connected or not) and window number */ /* TODO: show status (connected or not) and window number */
while (list != NULL) { while (list != NULL) {
item = list->data; Bookmark *item = list->data;
win_print_time(console, '-'); win_print_time(console, '-');
wprintw(console->win, " %s", item->jid); wprintw(console->win, " %s", item->jid);

View File

@ -1053,8 +1053,6 @@ _ui_current_page_off(void)
static void static void
_ui_print_system_msg_from_recipient(const char * const from, const char *message) _ui_print_system_msg_from_recipient(const char * const from, const char *message)
{ {
int num = 0;
if (from == NULL || message == NULL) if (from == NULL || message == NULL)
return; return;
@ -1062,6 +1060,7 @@ _ui_print_system_msg_from_recipient(const char * const from, const char *message
ProfWin *window = wins_get_by_recipient(jid->barejid); ProfWin *window = wins_get_by_recipient(jid->barejid);
if (window == NULL) { if (window == NULL) {
int num = 0;
window = wins_new(jid->barejid, WIN_CHAT); window = wins_new(jid->barejid, WIN_CHAT);
if (window != NULL) { if (window != NULL) {
num = wins_get_num(window); num = wins_get_num(window);

View File

@ -109,8 +109,6 @@ inp_block(void)
wint_t wint_t
inp_get_char(char *input, int *size) inp_get_char(char *input, int *size)
{ {
int inp_x = 0;
int i;
wint_t ch; wint_t ch;
int display_size = 0; int display_size = 0;
@ -148,7 +146,7 @@ inp_get_char(char *input, int *size)
return ERR; return ERR;
} }
inp_x = getcurx(inp_win); int inp_x = getcurx(inp_win);
// handle insert if not at end of input // handle insert if not at end of input
if (inp_x < display_size) { if (inp_x < display_size) {
@ -160,6 +158,7 @@ inp_get_char(char *input, int *size)
for (offset = &input[*size - 1]; offset >= next_ch; offset--) { for (offset = &input[*size - 1]; offset >= next_ch; offset--) {
*(offset + utf_len) = *offset; *(offset + utf_len) = *offset;
} }
int i;
for (i = 0; i < utf_len; i++) { for (i = 0; i < utf_len; i++) {
*(next_ch + i) = bytes[i]; *(next_ch + i) = bytes[i];
} }
@ -181,6 +180,7 @@ inp_get_char(char *input, int *size)
// wcrtomb can return (size_t) -1 // wcrtomb can return (size_t) -1
if (utf_len < MB_CUR_MAX) { if (utf_len < MB_CUR_MAX) {
int i;
for (i = 0 ; i < utf_len; i++) { for (i = 0 ; i < utf_len; i++) {
input[(*size)++] = bytes[i]; input[(*size)++] = bytes[i];
} }

View File

@ -64,7 +64,6 @@ win_free(ProfWin* window)
delwin(window->win); delwin(window->win);
free(window->from); free(window->from);
free(window); free(window);
window = NULL;
} }
void void

View File

@ -210,7 +210,6 @@ static void
_jabber_process_events(void) _jabber_process_events(void)
{ {
int reconnect_sec; int reconnect_sec;
int elapsed_sec;
switch (jabber_conn.conn_status) switch (jabber_conn.conn_status)
{ {
@ -222,7 +221,7 @@ _jabber_process_events(void)
case JABBER_DISCONNECTED: case JABBER_DISCONNECTED:
reconnect_sec = prefs_get_reconnect(); reconnect_sec = prefs_get_reconnect();
if ((reconnect_sec != 0) && (reconnect_timer != NULL)) { if ((reconnect_sec != 0) && (reconnect_timer != NULL)) {
elapsed_sec = g_timer_elapsed(reconnect_timer, NULL); int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
if (elapsed_sec > reconnect_sec) { if (elapsed_sec > reconnect_sec) {
_jabber_reconnect(); _jabber_reconnect();
} }

View File

@ -439,13 +439,13 @@ _disco_info_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
if (g_strcmp0(id, "discoinforeq") == 0) { if (g_strcmp0(id, "discoinforeq") == 0) {
GSList *identities = NULL;
GSList *features = NULL;
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query != NULL) { if (query != NULL) {
xmpp_stanza_t *child = xmpp_stanza_get_children(query); xmpp_stanza_t *child = xmpp_stanza_get_children(query);
GSList *identities = NULL;
GSList *features = NULL;
while (child != NULL) { while (child != NULL) {
const char *stanza_name = xmpp_stanza_get_name(child); const char *stanza_name = xmpp_stanza_get_name(child);
if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) { if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
@ -606,9 +606,6 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
log_debug("Recieved diso#items response"); log_debug("Recieved diso#items response");
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
const char *stanza_name = NULL;
const char *item_jid = NULL;
const char *item_name = NULL;
GSList *items = NULL; GSList *items = NULL;
if ((g_strcmp0(id, "confreq") == 0) || (g_strcmp0(id, "discoitemsreq") == 0)) { if ((g_strcmp0(id, "confreq") == 0) || (g_strcmp0(id, "discoitemsreq") == 0)) {
@ -618,13 +615,13 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
if (query != NULL) { if (query != NULL) {
xmpp_stanza_t *child = xmpp_stanza_get_children(query); xmpp_stanza_t *child = xmpp_stanza_get_children(query);
while (child != NULL) { while (child != NULL) {
stanza_name = xmpp_stanza_get_name(child); const char *stanza_name = xmpp_stanza_get_name(child);
if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) { if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
if (item_jid != NULL) { if (item_jid != NULL) {
DiscoItem *item = malloc(sizeof(struct disco_item_t)); DiscoItem *item = malloc(sizeof(struct disco_item_t));
item->jid = strdup(item_jid); item->jid = strdup(item_jid);
item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
if (item_name != NULL) { if (item_name != NULL) {
item->name = strdup(item_name); item->name = strdup(item_name);
} else { } else {

View File

@ -237,8 +237,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
char *invitor = NULL;
char *reason = NULL;
if (room == NULL) { if (room == NULL) {
log_warning("Message received with no from attribute, ignoring"); log_warning("Message received with no from attribute, ignoring");
@ -258,8 +256,9 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
if (jidp == NULL) { if (jidp == NULL) {
return 1; return 1;
} }
invitor = jidp->barejid; char *invitor = jidp->barejid;
char *reason = NULL;
xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON); xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);
if (reason_st != NULL) { if (reason_st != NULL) {
reason = xmpp_stanza_get_text(reason_st); reason = xmpp_stanza_get_text(reason_st);

View File

@ -139,12 +139,6 @@ _presence_sub_request_count(void)
return autocomplete_length(sub_requests_ac); return autocomplete_length(sub_requests_ac);
} }
void
presence_free_sub_requests(void)
{
autocomplete_free(sub_requests_ac);
}
void void
presence_clear_sub_requests(void) presence_clear_sub_requests(void)
{ {
@ -625,7 +619,7 @@ _get_caps_key(xmpp_stanza_t * const stanza)
if ((hash_type != NULL) && (strcmp(hash_type, "sha-1") == 0)) { if ((hash_type != NULL) && (strcmp(hash_type, "sha-1") == 0)) {
log_debug("Hash type %s supported.", hash_type); log_debug("Hash type %s supported.", hash_type);
caps_key = strdup(node); caps_key = strdup(node);
char *id = generate_unique_id("caps"); id = generate_unique_id("caps");
_send_caps_request(node, caps_key, id, from); _send_caps_request(node, caps_key, id, from);

View File

@ -25,7 +25,6 @@
void presence_sub_requests_init(void); void presence_sub_requests_init(void);
void presence_add_handlers(void); void presence_add_handlers(void);
void presence_free_sub_requests(void);
void presence_clear_sub_requests(void); void presence_clear_sub_requests(void);
#endif #endif

View File

@ -830,62 +830,6 @@ stanza_contains_caps(xmpp_stanza_t * const stanza)
return TRUE; return TRUE;
} }
gboolean
stanza_is_version_request(xmpp_stanza_t * const stanza)
{
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
if (g_strcmp0(type, STANZA_TYPE_GET) != 0) {
return FALSE;
}
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query == NULL) {
return FALSE;
}
char *ns = xmpp_stanza_get_ns(query);
if (ns == NULL) {
return FALSE;
}
if (strcmp(ns, STANZA_NS_VERSION) != 0) {
return FALSE;
}
return TRUE;
}
gboolean
stanza_is_caps_request(xmpp_stanza_t * const stanza)
{
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
if (g_strcmp0(type, STANZA_TYPE_GET) != 0) {
return FALSE;
}
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query == NULL) {
return FALSE;
}
char *ns = xmpp_stanza_get_ns(query);
if (ns == NULL) {
return FALSE;
}
if (strcmp(ns, XMPP_NS_DISCO_INFO) != 0) {
return FALSE;
}
return TRUE;
}
char * char *
stanza_caps_get_hash(xmpp_stanza_t * const stanza) stanza_caps_get_hash(xmpp_stanza_t * const stanza)
{ {
@ -957,8 +901,6 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
// otherwise check each defined-condition RFC-6120 8.3.3 // otherwise check each defined-condition RFC-6120 8.3.3
} else { } else {
xmpp_stanza_t *cond_stanza = NULL;
gchar *defined_conditions[] = { gchar *defined_conditions[] = {
STANZA_NAME_BAD_REQUEST, STANZA_NAME_BAD_REQUEST,
STANZA_NAME_CONFLICT, STANZA_NAME_CONFLICT,
@ -985,7 +927,7 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
int i; int i;
for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) { for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]); xmpp_stanza_t *cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
if (cond_stanza != NULL) { if (cond_stanza != NULL) {
char *result = strdup(xmpp_stanza_get_name(cond_stanza)); char *result = strdup(xmpp_stanza_get_name(cond_stanza));
return result; return result;

View File

@ -192,9 +192,6 @@ int stanza_get_idle_time(xmpp_stanza_t * const stanza);
char * stanza_get_caps_str(xmpp_stanza_t * const stanza); char * stanza_get_caps_str(xmpp_stanza_t * const stanza);
gboolean stanza_contains_caps(xmpp_stanza_t * const stanza); gboolean stanza_contains_caps(xmpp_stanza_t * const stanza);
char * stanza_caps_get_hash(xmpp_stanza_t * const stanza); char * stanza_caps_get_hash(xmpp_stanza_t * const stanza);
gboolean stanza_is_caps_request(xmpp_stanza_t * const stanza);
gboolean stanza_is_version_request(xmpp_stanza_t * const stanza);
DataForm * stanza_create_form(xmpp_stanza_t * const stanza); DataForm * stanza_create_form(xmpp_stanza_t * const stanza);
void stanza_destroy_form(DataForm *form); void stanza_destroy_form(DataForm *form);