diff options
author | James Booth <boothj5@gmail.com> | 2014-04-20 22:02:55 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-04-20 22:02:55 +0100 |
commit | 9a55d8ad193e79c38d59c9448330132f1c874bca (patch) | |
tree | 05dde8cae2a038c6887f8c78f0f845d3d90e3a9a | |
parent | e830e2a06a43b03377c9bb862b1843aec91cb366 (diff) | |
download | profani-tty-9a55d8ad193e79c38d59c9448330132f1c874bca.tar.gz |
Store password with room
-rw-r--r-- | src/muc.c | 9 | ||||
-rw-r--r-- | src/muc.h | 2 | ||||
-rw-r--r-- | src/xmpp/presence.c | 2 | ||||
-rw-r--r-- | tests/test_cmd_bookmark.c | 4 | ||||
-rw-r--r-- | tests/test_muc.c | 2 | ||||
-rw-r--r-- | tests/test_server_events.c | 4 |
6 files changed, 15 insertions, 8 deletions
diff --git a/src/muc.c b/src/muc.c index 9ee94755..11a707a4 100644 --- a/src/muc.c +++ b/src/muc.c @@ -32,6 +32,7 @@ typedef struct _muc_room_t { char *room; // e.g. test@conference.server char *nick; // e.g. Some User + char *password; char *subject; gboolean pending_nick_change; GHashTable *roster; @@ -125,7 +126,7 @@ muc_clear_invites(void) * Join the chat room with the specified nickname */ void -muc_join_room(const char * const room, const char * const nick) +muc_join_room(const char * const room, const char * const nick, const char * const password) { if (rooms == NULL) { rooms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, @@ -135,6 +136,11 @@ muc_join_room(const char * const room, const char * const nick) ChatRoom *new_room = malloc(sizeof(ChatRoom)); new_room->room = strdup(room); new_room->nick = strdup(nick); + if (password != NULL) { + new_room->password = strdup(password); + } else { + new_room->password = NULL; + } new_room->subject = NULL; new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)p_contact_free); @@ -469,6 +475,7 @@ _free_room(ChatRoom *room) free(room->room); free(room->nick); free(room->subject); + free(room->password); if (room->roster != NULL) { g_hash_table_remove_all(room->roster); } diff --git a/src/muc.h b/src/muc.h index e28e048a..fc8c4668 100644 --- a/src/muc.h +++ b/src/muc.h @@ -31,7 +31,7 @@ void muc_init(void); void muc_close(void); -void muc_join_room(const char * const room, const char * const nick); +void muc_join_room(const char * const room, const char * const nick, const char * const password); void muc_leave_room(const char * const room); gboolean muc_room_is_active(const char * const room); GList* muc_get_active_room_list(void); diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 46467b2e..433c05f3 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -283,7 +283,7 @@ _presence_join_room(char *room, char *nick, char * passwd) xmpp_send(conn, presence); xmpp_stanza_release(presence); - muc_join_room(jid->barejid, jid->resourcepart); + muc_join_room(jid->barejid, jid->resourcepart, passwd); jid_destroy(jid); } diff --git a/tests/test_cmd_bookmark.c b/tests/test_cmd_bookmark.c index 4dc12217..e154413e 100644 --- a/tests/test_cmd_bookmark.c +++ b/tests/test_cmd_bookmark.c @@ -248,7 +248,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details(void **state) gchar *args[] = { "add", NULL }; muc_init(); - muc_join_room(jid, nick); + muc_join_room(jid, nick, NULL); mock_connection_status(JABBER_CONNECTED); mock_current_win_type(WIN_MUC); @@ -275,7 +275,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details_autojoin(void **state) gchar *args[] = { "add", "autojoin", NULL }; muc_init(); - muc_join_room(jid, nick); + muc_join_room(jid, nick, NULL); mock_connection_status(JABBER_CONNECTED); mock_current_win_type(WIN_MUC); diff --git a/tests/test_muc.c b/tests/test_muc.c index 3cfb38b4..b1f55a53 100644 --- a/tests/test_muc.c +++ b/tests/test_muc.c @@ -70,7 +70,7 @@ void test_muc_room_is_active(void **state) { char *room = "room@server.org"; char *nick = "bob"; - muc_join_room(room, nick); + muc_join_room(room, nick, NULL); gboolean room_is_active = muc_room_is_active(room); diff --git a/tests/test_server_events.c b/tests/test_server_events.c index af8f8d1a..e660ae7e 100644 --- a/tests/test_server_events.c +++ b/tests/test_server_events.c @@ -192,7 +192,7 @@ void handle_presence_error_when_nick_conflict_shows_recipient_error(void **state char *type = NULL; muc_init(); - muc_join_room(barejid, nick); + muc_join_room(barejid, nick, NULL); expect_ui_handle_recipient_error(barejid, err_msg); @@ -212,7 +212,7 @@ void handle_presence_error_when_nick_conflict_does_not_join_room(void **state) stub_ui_handle_recipient_error(); muc_init(); - muc_join_room(barejid, nick); + muc_join_room(barejid, nick, NULL); handle_presence_error(from, type, err_msg); |