Store password with room

This commit is contained in:
James Booth
2014-04-20 22:02:55 +01:00
parent e830e2a06a
commit 9a55d8ad19
6 changed files with 15 additions and 8 deletions

View File

@@ -32,6 +32,7 @@
typedef struct _muc_room_t { typedef struct _muc_room_t {
char *room; // e.g. test@conference.server char *room; // e.g. test@conference.server
char *nick; // e.g. Some User char *nick; // e.g. Some User
char *password;
char *subject; char *subject;
gboolean pending_nick_change; gboolean pending_nick_change;
GHashTable *roster; GHashTable *roster;
@@ -125,7 +126,7 @@ muc_clear_invites(void)
* Join the chat room with the specified nickname * Join the chat room with the specified nickname
*/ */
void 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) { if (rooms == NULL) {
rooms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, 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)); ChatRoom *new_room = malloc(sizeof(ChatRoom));
new_room->room = strdup(room); new_room->room = strdup(room);
new_room->nick = strdup(nick); new_room->nick = strdup(nick);
if (password != NULL) {
new_room->password = strdup(password);
} else {
new_room->password = NULL;
}
new_room->subject = NULL; new_room->subject = NULL;
new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)p_contact_free); (GDestroyNotify)p_contact_free);
@@ -469,6 +475,7 @@ _free_room(ChatRoom *room)
free(room->room); free(room->room);
free(room->nick); free(room->nick);
free(room->subject); free(room->subject);
free(room->password);
if (room->roster != NULL) { if (room->roster != NULL) {
g_hash_table_remove_all(room->roster); g_hash_table_remove_all(room->roster);
} }

View File

@@ -31,7 +31,7 @@
void muc_init(void); void muc_init(void);
void muc_close(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); void muc_leave_room(const char * const room);
gboolean muc_room_is_active(const char * const room); gboolean muc_room_is_active(const char * const room);
GList* muc_get_active_room_list(void); GList* muc_get_active_room_list(void);

View File

@@ -283,7 +283,7 @@ _presence_join_room(char *room, char *nick, char * passwd)
xmpp_send(conn, presence); xmpp_send(conn, presence);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
muc_join_room(jid->barejid, jid->resourcepart); muc_join_room(jid->barejid, jid->resourcepart, passwd);
jid_destroy(jid); jid_destroy(jid);
} }

View File

@@ -248,7 +248,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details(void **state)
gchar *args[] = { "add", NULL }; gchar *args[] = { "add", NULL };
muc_init(); muc_init();
muc_join_room(jid, nick); muc_join_room(jid, nick, NULL);
mock_connection_status(JABBER_CONNECTED); mock_connection_status(JABBER_CONNECTED);
mock_current_win_type(WIN_MUC); 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 }; gchar *args[] = { "add", "autojoin", NULL };
muc_init(); muc_init();
muc_join_room(jid, nick); muc_join_room(jid, nick, NULL);
mock_connection_status(JABBER_CONNECTED); mock_connection_status(JABBER_CONNECTED);
mock_current_win_type(WIN_MUC); mock_current_win_type(WIN_MUC);

View File

@@ -70,7 +70,7 @@ void test_muc_room_is_active(void **state)
{ {
char *room = "room@server.org"; char *room = "room@server.org";
char *nick = "bob"; char *nick = "bob";
muc_join_room(room, nick); muc_join_room(room, nick, NULL);
gboolean room_is_active = muc_room_is_active(room); gboolean room_is_active = muc_room_is_active(room);

View File

@@ -192,7 +192,7 @@ void handle_presence_error_when_nick_conflict_shows_recipient_error(void **state
char *type = NULL; char *type = NULL;
muc_init(); muc_init();
muc_join_room(barejid, nick); muc_join_room(barejid, nick, NULL);
expect_ui_handle_recipient_error(barejid, err_msg); 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(); stub_ui_handle_recipient_error();
muc_init(); muc_init();
muc_join_room(barejid, nick); muc_join_room(barejid, nick, NULL);
handle_presence_error(from, type, err_msg); handle_presence_error(from, type, err_msg);