mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
use get_unique_id for bookmarks
This commit is contained in:
parent
2837c4054f
commit
034cf730cc
@ -37,9 +37,6 @@
|
||||
// and page size is at least 4KB
|
||||
#define READ_BUF_SIZE 4088
|
||||
|
||||
// for generating ids
|
||||
static int unique_id = 0;
|
||||
|
||||
struct curl_data_t
|
||||
{
|
||||
char *buffer;
|
||||
@ -400,10 +397,12 @@ xdg_get_data_home(void)
|
||||
char *
|
||||
get_unique_id(void)
|
||||
{
|
||||
static unsigned long unique_id;
|
||||
char *result = NULL;
|
||||
unique_id++;
|
||||
GString *result_str = g_string_new("");
|
||||
g_string_printf(result_str, "prof%d", unique_id);
|
||||
|
||||
unique_id++;
|
||||
g_string_printf(result_str, "prof%lu", unique_id);
|
||||
result = result_str->str;
|
||||
g_string_free(result_str, FALSE);
|
||||
|
||||
|
@ -18,21 +18,25 @@ static int _bookmark_handle_result(xmpp_conn_t * const conn,
|
||||
void
|
||||
bookmark_request(void)
|
||||
{
|
||||
int id;
|
||||
char id_str[10];
|
||||
char *id;
|
||||
xmpp_conn_t * const conn = connection_get_conn();
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *iq = stanza_create_storage_bookmarks(ctx);
|
||||
xmpp_stanza_t *iq;
|
||||
|
||||
id = jabber_get_id();
|
||||
snprintf(id_str, sizeof(id_str), "%u", id);
|
||||
id = get_unique_id();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: timed handler to remove this id_handler */
|
||||
xmpp_id_handler_add(conn, _bookmark_handle_result, id_str, ctx);
|
||||
xmpp_id_handler_add(conn, _bookmark_handle_result, id, ctx);
|
||||
|
||||
xmpp_stanza_set_id(iq, id_str);
|
||||
iq = stanza_create_storage_bookmarks(ctx);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
|
||||
g_free(id);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -232,19 +232,6 @@ jabber_set_autoping(const int seconds)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
jabber_get_id(void)
|
||||
{
|
||||
static int xmpp_id;
|
||||
|
||||
++xmpp_id;
|
||||
if (xmpp_id < 0) {
|
||||
xmpp_id = 1;
|
||||
}
|
||||
|
||||
return xmpp_id;
|
||||
}
|
||||
|
||||
GList *
|
||||
jabber_get_available_resources(void)
|
||||
{
|
||||
|
@ -31,7 +31,6 @@ xmpp_conn_t *connection_get_conn(void);
|
||||
xmpp_ctx_t *connection_get_ctx(void);
|
||||
int connection_error_handler(xmpp_conn_t * const conn,
|
||||
xmpp_stanza_t * const stanza, void * const userdata);
|
||||
int jabber_get_id(void);
|
||||
void connection_set_priority(int priority);
|
||||
void connection_set_presence_message(const char * const message);
|
||||
void connection_add_available_resource(Resource *resource);
|
||||
|
Loading…
Reference in New Issue
Block a user