2014-03-08 20:18:19 -05:00
|
|
|
/*
|
|
|
|
* bookmark.c
|
|
|
|
*
|
2019-01-22 05:31:45 -05:00
|
|
|
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
2014-03-08 20:18:19 -05:00
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-07-23 20:14:49 -04:00
|
|
|
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
2014-03-08 20:18:19 -05:00
|
|
|
*
|
2014-08-24 15:57:39 -04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link the code of portions of this program with the OpenSSL library under
|
|
|
|
* certain conditions as described in each individual source file, and
|
|
|
|
* distribute linked combinations including the two.
|
|
|
|
*
|
|
|
|
* You must obey the GNU General Public License in all respects for all of the
|
|
|
|
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
|
|
* may extend this exception to your version of the file(s), but you are not
|
|
|
|
* obligated to do so. If you do not wish to do so, delete this exception
|
|
|
|
* statement from your version. If you delete this exception statement from all
|
|
|
|
* source files in the program, then also delete it here.
|
|
|
|
*
|
2014-03-08 20:18:19 -05:00
|
|
|
*/
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2016-03-31 16:05:02 -04:00
|
|
|
#include "config.h"
|
2015-09-21 16:40:04 -04:00
|
|
|
|
2013-07-14 10:05:46 -04:00
|
|
|
#include <assert.h>
|
2013-06-30 11:59:38 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
2015-09-21 16:40:04 -04:00
|
|
|
|
2016-03-31 16:05:02 -04:00
|
|
|
#ifdef HAVE_LIBMESODE
|
2015-09-21 16:40:04 -04:00
|
|
|
#include <mesode.h>
|
|
|
|
#endif
|
2016-07-24 10:43:51 -04:00
|
|
|
|
2016-03-31 16:05:02 -04:00
|
|
|
#ifdef HAVE_LIBSTROPHE
|
2013-06-30 11:59:38 -04:00
|
|
|
#include <strophe.h>
|
2015-09-21 16:40:04 -04:00
|
|
|
#endif
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2014-02-01 21:39:36 -05:00
|
|
|
#include "common.h"
|
2013-06-30 11:59:38 -04:00
|
|
|
#include "log.h"
|
2015-04-19 11:54:16 -04:00
|
|
|
#include "event/server_events.h"
|
2016-07-24 10:43:51 -04:00
|
|
|
#include "plugins/plugins.h"
|
|
|
|
#include "ui/ui.h"
|
2016-05-05 19:53:03 -04:00
|
|
|
#include "xmpp/connection.h"
|
2016-05-03 20:19:51 -04:00
|
|
|
#include "xmpp/iq.h"
|
2013-06-30 11:59:38 -04:00
|
|
|
#include "xmpp/stanza.h"
|
|
|
|
#include "xmpp/xmpp.h"
|
2013-07-14 16:58:02 -04:00
|
|
|
#include "xmpp/bookmark.h"
|
2016-07-24 10:43:51 -04:00
|
|
|
#include "xmpp/muc.h"
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2013-07-14 10:05:46 -04:00
|
|
|
#define BOOKMARK_TIMEOUT 5000
|
|
|
|
|
2013-07-14 16:58:02 -04:00
|
|
|
static Autocomplete bookmark_ac;
|
2016-08-21 10:25:49 -04:00
|
|
|
static GHashTable *bookmarks;
|
2013-07-14 16:58:02 -04:00
|
|
|
|
2016-03-27 16:36:29 -04:00
|
|
|
// id handlers
|
2016-03-27 20:25:48 -04:00
|
|
|
static int _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
|
2016-03-27 16:36:29 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
static void _bookmark_destroy(Bookmark *bookmark);
|
2014-04-12 20:39:54 -04:00
|
|
|
static void _send_bookmarks(void);
|
2013-06-30 11:59:38 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
bookmark_request(void)
|
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
if (bookmarks) {
|
|
|
|
g_hash_table_destroy(bookmarks);
|
|
|
|
}
|
|
|
|
bookmarks = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_bookmark_destroy);
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2014-09-25 19:48:48 -04:00
|
|
|
autocomplete_free(bookmark_ac);
|
2013-07-14 16:58:02 -04:00
|
|
|
bookmark_ac = autocomplete_new();
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
char *id = "bookmark_init_request";
|
|
|
|
iq_id_handler_add(id, _bookmark_result_id_handler, free, NULL);
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
xmpp_ctx_t *ctx = connection_get_ctx();
|
|
|
|
xmpp_stanza_t *iq = stanza_create_bookmarks_storage_request(ctx);
|
2013-07-14 06:49:50 -04:00
|
|
|
xmpp_stanza_set_id(iq, id);
|
2016-08-21 10:25:49 -04:00
|
|
|
|
2016-05-03 20:19:51 -04:00
|
|
|
iq_send_stanza(iq);
|
2013-06-30 11:59:38 -04:00
|
|
|
xmpp_stanza_release(iq);
|
|
|
|
}
|
|
|
|
|
2014-12-22 17:13:42 -05:00
|
|
|
gboolean
|
|
|
|
bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
assert(jid != NULL);
|
|
|
|
|
2018-02-05 16:40:32 -05:00
|
|
|
Jid *jidp = jid_create(jid);
|
|
|
|
if (jidp->domainpart) {
|
|
|
|
muc_confserver_add(jidp->domainpart);
|
|
|
|
}
|
|
|
|
jid_destroy(jidp);
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
if (g_hash_table_contains(bookmarks, jid)) {
|
2014-05-09 19:50:43 -04:00
|
|
|
return FALSE;
|
2016-08-21 10:25:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Bookmark *bookmark = malloc(sizeof(Bookmark));
|
2016-08-28 17:12:50 -04:00
|
|
|
bookmark->barejid = strdup(jid);
|
2016-08-21 10:25:49 -04:00
|
|
|
if (nick) {
|
|
|
|
bookmark->nick = strdup(nick);
|
2014-05-09 19:50:43 -04:00
|
|
|
} else {
|
2016-08-21 10:25:49 -04:00
|
|
|
bookmark->nick = NULL;
|
|
|
|
}
|
|
|
|
if (password) {
|
|
|
|
bookmark->password = strdup(password);
|
|
|
|
} else {
|
|
|
|
bookmark->password = NULL;
|
|
|
|
}
|
2014-05-09 19:50:43 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
if (g_strcmp0(autojoin_str, "on") == 0) {
|
|
|
|
bookmark->autojoin = TRUE;
|
|
|
|
} else {
|
|
|
|
bookmark->autojoin = FALSE;
|
|
|
|
}
|
2014-05-09 19:50:43 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
g_hash_table_insert(bookmarks, strdup(jid), bookmark);
|
|
|
|
autocomplete_add(bookmark_ac, jid);
|
2014-05-09 19:50:43 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
_send_bookmarks();
|
|
|
|
|
|
|
|
return TRUE;
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
2014-02-01 21:39:36 -05:00
|
|
|
|
2014-12-22 17:13:42 -05:00
|
|
|
gboolean
|
|
|
|
bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
2014-05-09 19:50:43 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
assert(jid != NULL);
|
|
|
|
|
|
|
|
Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
|
|
|
|
if (!bookmark) {
|
2014-05-09 19:50:43 -04:00
|
|
|
return FALSE;
|
2016-08-21 10:25:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nick) {
|
|
|
|
free(bookmark->nick);
|
|
|
|
bookmark->nick = strdup(nick);
|
|
|
|
}
|
|
|
|
if (password) {
|
|
|
|
free(bookmark->password);
|
|
|
|
bookmark->password = strdup(password);
|
|
|
|
}
|
|
|
|
if (autojoin_str) {
|
|
|
|
if (g_strcmp0(autojoin_str, "on") == 0) {
|
|
|
|
bookmark->autojoin = TRUE;
|
|
|
|
} else if (g_strcmp0(autojoin_str, "off") == 0) {
|
|
|
|
bookmark->autojoin = FALSE;
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
2014-04-12 20:01:53 -04:00
|
|
|
}
|
2016-08-21 10:25:49 -04:00
|
|
|
|
|
|
|
_send_bookmarks();
|
|
|
|
return TRUE;
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
2014-02-01 21:39:36 -05:00
|
|
|
|
2014-12-22 17:13:42 -05:00
|
|
|
gboolean
|
|
|
|
bookmark_join(const char *jid)
|
2014-05-09 19:50:43 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
assert(jid != NULL);
|
|
|
|
|
|
|
|
Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
|
|
|
|
if (!bookmark) {
|
2014-05-09 19:50:43 -04:00
|
|
|
return FALSE;
|
2016-08-21 10:25:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
char *account_name = session_get_account_name();
|
|
|
|
ProfAccount *account = accounts_get_account(account_name);
|
2016-08-28 17:12:50 -04:00
|
|
|
if (!muc_active(bookmark->barejid)) {
|
2016-08-21 10:25:49 -04:00
|
|
|
char *nick = bookmark->nick;
|
|
|
|
if (!nick) {
|
|
|
|
nick = account->muc_nick;
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
2016-08-28 17:12:50 -04:00
|
|
|
presence_join_room(bookmark->barejid, nick, bookmark->password);
|
|
|
|
muc_join(bookmark->barejid, nick, bookmark->password, FALSE);
|
2016-08-21 10:25:49 -04:00
|
|
|
account_free(account);
|
2016-08-28 17:12:50 -04:00
|
|
|
} else if (muc_roster_complete(bookmark->barejid)) {
|
|
|
|
ui_room_join(bookmark->barejid, TRUE);
|
2016-08-21 10:25:49 -04:00
|
|
|
account_free(account);
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
2016-08-21 10:25:49 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
|
|
|
|
2014-12-22 17:13:42 -05:00
|
|
|
gboolean
|
|
|
|
bookmark_remove(const char *jid)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
assert(jid != NULL);
|
|
|
|
|
|
|
|
Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
|
|
|
|
if (!bookmark) {
|
2014-05-09 19:50:43 -04:00
|
|
|
return FALSE;
|
2014-04-12 21:05:12 -04:00
|
|
|
}
|
2016-08-21 10:25:49 -04:00
|
|
|
|
|
|
|
g_hash_table_remove(bookmarks, jid);
|
|
|
|
autocomplete_remove(bookmark_ac, jid);
|
|
|
|
|
|
|
|
_send_bookmarks();
|
|
|
|
|
|
|
|
return TRUE;
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
GList*
|
2014-12-22 17:13:42 -05:00
|
|
|
bookmark_get_list(void)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
return g_hash_table_get_values(bookmarks);
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
|
|
|
|
2015-10-25 20:14:23 -04:00
|
|
|
char*
|
2017-03-31 19:27:11 -04:00
|
|
|
bookmark_find(const char *const search_str, gboolean previous)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2017-03-31 19:27:11 -04:00
|
|
|
return autocomplete_complete(bookmark_ac, search_str, TRUE, previous);
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
|
|
|
|
2014-12-22 17:13:42 -05:00
|
|
|
void
|
|
|
|
bookmark_autocomplete_reset(void)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2015-05-04 18:14:18 -04:00
|
|
|
if (bookmark_ac) {
|
2013-07-14 16:58:02 -04:00
|
|
|
autocomplete_reset(bookmark_ac);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 18:53:44 -04:00
|
|
|
gboolean
|
|
|
|
bookmark_exists(const char *const room)
|
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
return g_hash_table_contains(bookmarks, room);
|
2016-05-23 18:53:44 -04:00
|
|
|
}
|
|
|
|
|
2013-06-30 11:59:38 -04:00
|
|
|
static int
|
2016-03-27 20:25:48 -04:00
|
|
|
_bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
2013-06-30 11:59:38 -04:00
|
|
|
{
|
2016-08-21 10:25:49 -04:00
|
|
|
const char *name = xmpp_stanza_get_name(stanza);
|
2013-06-30 11:59:38 -04:00
|
|
|
if (!name || strcmp(name, STANZA_NAME_IQ) != 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
|
|
|
if (!query) {
|
2013-06-30 11:59:38 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-08-21 10:25:49 -04:00
|
|
|
xmpp_stanza_t *storage = xmpp_stanza_get_child_by_name(query, STANZA_NAME_STORAGE);
|
|
|
|
if (!storage) {
|
2013-06-30 11:59:38 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-14 16:58:02 -04:00
|
|
|
if (bookmark_ac == NULL) {
|
|
|
|
bookmark_ac = autocomplete_new();
|
|
|
|
}
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
xmpp_stanza_t *child = xmpp_stanza_get_children(storage);
|
|
|
|
while (child) {
|
|
|
|
name = xmpp_stanza_get_name(child);
|
2013-07-14 19:52:47 -04:00
|
|
|
if (!name || strcmp(name, STANZA_NAME_CONFERENCE) != 0) {
|
2016-08-21 10:25:49 -04:00
|
|
|
child = xmpp_stanza_get_next(child);
|
2013-06-30 11:59:38 -04:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-28 17:12:50 -04:00
|
|
|
const char *barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
|
|
|
if (!barejid) {
|
2016-08-21 10:25:49 -04:00
|
|
|
child = xmpp_stanza_get_next(child);
|
2013-06-30 11:59:38 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-08-28 17:12:50 -04:00
|
|
|
log_debug("Handle bookmark for %s", barejid);
|
2013-06-30 11:59:38 -04:00
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
char *nick = NULL;
|
|
|
|
xmpp_stanza_t *nick_st = xmpp_stanza_get_child_by_name(child, "nick");
|
2016-04-27 06:31:28 -04:00
|
|
|
if (nick_st) {
|
2016-08-21 10:25:49 -04:00
|
|
|
nick = stanza_text_strdup(nick_st);
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
char *password = NULL;
|
|
|
|
xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(child, "password");
|
2014-05-09 19:50:43 -04:00
|
|
|
if (password_st) {
|
2016-08-21 10:25:49 -04:00
|
|
|
password = stanza_text_strdup(password_st);
|
2014-05-09 19:50:43 -04:00
|
|
|
}
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
const char *autojoin = xmpp_stanza_get_attribute(child, "autojoin");
|
|
|
|
gboolean autojoin_val = FALSE;;
|
2013-07-14 19:52:47 -04:00
|
|
|
if (autojoin && (strcmp(autojoin, "1") == 0 || strcmp(autojoin, "true") == 0)) {
|
2013-07-14 16:58:02 -04:00
|
|
|
autojoin_val = TRUE;
|
|
|
|
}
|
|
|
|
|
2016-08-28 17:12:50 -04:00
|
|
|
autocomplete_add(bookmark_ac, barejid);
|
2016-08-21 10:25:49 -04:00
|
|
|
Bookmark *bookmark = malloc(sizeof(Bookmark));
|
2016-08-28 17:12:50 -04:00
|
|
|
bookmark->barejid = strdup(barejid);
|
2016-08-21 10:25:49 -04:00
|
|
|
bookmark->nick = nick;
|
|
|
|
bookmark->password = password;
|
|
|
|
bookmark->autojoin = autojoin_val;
|
2016-08-28 17:12:50 -04:00
|
|
|
g_hash_table_insert(bookmarks, strdup(barejid), bookmark);
|
2013-07-14 16:58:02 -04:00
|
|
|
|
|
|
|
if (autojoin_val) {
|
2016-08-28 17:42:09 -04:00
|
|
|
sv_ev_bookmark_autojoin(bookmark);
|
2013-06-30 11:59:38 -04:00
|
|
|
}
|
|
|
|
|
2018-02-05 16:40:32 -05:00
|
|
|
Jid *jidp = jid_create(barejid);
|
|
|
|
if (jidp->domainpart) {
|
|
|
|
muc_confserver_add(jidp->domainpart);
|
|
|
|
}
|
|
|
|
jid_destroy(jidp);
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
child = xmpp_stanza_get_next(child);
|
2013-06-30 11:59:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-14 10:05:46 -04:00
|
|
|
|
2013-07-14 16:58:02 -04:00
|
|
|
static void
|
2016-08-21 10:25:49 -04:00
|
|
|
_bookmark_destroy(Bookmark *bookmark)
|
2013-07-14 16:58:02 -04:00
|
|
|
{
|
2019-06-19 18:14:05 -04:00
|
|
|
if (bookmark) {
|
|
|
|
free(bookmark->barejid);
|
|
|
|
free(bookmark->nick);
|
|
|
|
free(bookmark->password);
|
|
|
|
free(bookmark);
|
2013-07-14 16:58:02 -04:00
|
|
|
}
|
2014-04-12 20:39:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_send_bookmarks(void)
|
|
|
|
{
|
|
|
|
xmpp_ctx_t *ctx = connection_get_ctx();
|
|
|
|
|
2018-08-30 05:01:28 -04:00
|
|
|
char *id = connection_create_stanza_id("bookmarks_update");
|
2016-08-20 15:20:38 -04:00
|
|
|
xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
2014-06-15 15:56:24 -04:00
|
|
|
free(id);
|
2014-04-12 20:39:54 -04:00
|
|
|
|
|
|
|
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
|
|
|
|
xmpp_stanza_set_ns(query, "jabber:iq:private");
|
|
|
|
|
|
|
|
xmpp_stanza_t *storage = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_name(storage, STANZA_NAME_STORAGE);
|
|
|
|
xmpp_stanza_set_ns(storage, "storage:bookmarks");
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
GList *bookmark_list = g_hash_table_get_values(bookmarks);
|
2014-04-12 20:39:54 -04:00
|
|
|
GList *curr = bookmark_list;
|
2015-05-04 18:14:18 -04:00
|
|
|
while (curr) {
|
2014-04-12 20:39:54 -04:00
|
|
|
Bookmark *bookmark = curr->data;
|
|
|
|
xmpp_stanza_t *conference = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_name(conference, STANZA_NAME_CONFERENCE);
|
2016-08-28 17:12:50 -04:00
|
|
|
xmpp_stanza_set_attribute(conference, STANZA_ATTR_JID, bookmark->barejid);
|
2014-04-12 20:39:54 -04:00
|
|
|
|
2016-08-28 17:12:50 -04:00
|
|
|
Jid *jidp = jid_create(bookmark->barejid);
|
2015-05-04 18:14:18 -04:00
|
|
|
if (jidp->localpart) {
|
2014-08-17 16:22:12 -04:00
|
|
|
xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, jidp->localpart);
|
|
|
|
}
|
2014-04-12 20:39:54 -04:00
|
|
|
jid_destroy(jidp);
|
|
|
|
|
|
|
|
if (bookmark->autojoin) {
|
|
|
|
xmpp_stanza_set_attribute(conference, STANZA_ATTR_AUTOJOIN, "true");
|
|
|
|
} else {
|
|
|
|
xmpp_stanza_set_attribute(conference, STANZA_ATTR_AUTOJOIN, "false");
|
|
|
|
}
|
|
|
|
|
2015-05-04 18:14:18 -04:00
|
|
|
if (bookmark->nick) {
|
2014-04-12 20:39:54 -04:00
|
|
|
xmpp_stanza_t *nick_st = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_name(nick_st, STANZA_NAME_NICK);
|
|
|
|
xmpp_stanza_t *nick_text = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_text(nick_text, bookmark->nick);
|
|
|
|
xmpp_stanza_add_child(nick_st, nick_text);
|
|
|
|
xmpp_stanza_add_child(conference, nick_st);
|
|
|
|
|
|
|
|
xmpp_stanza_release(nick_text);
|
|
|
|
xmpp_stanza_release(nick_st);
|
|
|
|
}
|
|
|
|
|
2015-05-04 18:14:18 -04:00
|
|
|
if (bookmark->password) {
|
2014-05-09 19:50:43 -04:00
|
|
|
xmpp_stanza_t *password_st = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD);
|
|
|
|
xmpp_stanza_t *password_text = xmpp_stanza_new(ctx);
|
|
|
|
xmpp_stanza_set_text(password_text, bookmark->password);
|
|
|
|
xmpp_stanza_add_child(password_st, password_text);
|
|
|
|
xmpp_stanza_add_child(conference, password_st);
|
|
|
|
|
|
|
|
xmpp_stanza_release(password_text);
|
|
|
|
xmpp_stanza_release(password_st);
|
|
|
|
}
|
|
|
|
|
2014-04-12 20:39:54 -04:00
|
|
|
xmpp_stanza_add_child(storage, conference);
|
|
|
|
xmpp_stanza_release(conference);
|
|
|
|
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
|
2016-08-21 10:25:49 -04:00
|
|
|
g_list_free(bookmark_list);
|
|
|
|
|
2014-04-12 20:39:54 -04:00
|
|
|
xmpp_stanza_add_child(query, storage);
|
|
|
|
xmpp_stanza_add_child(iq, query);
|
|
|
|
xmpp_stanza_release(storage);
|
|
|
|
xmpp_stanza_release(query);
|
|
|
|
|
2016-05-03 20:19:51 -04:00
|
|
|
iq_send_stanza(iq);
|
2014-04-12 20:39:54 -04:00
|
|
|
xmpp_stanza_release(iq);
|
2015-09-21 16:40:04 -04:00
|
|
|
}
|