mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
generate_unique_id allows prefix
This commit is contained in:
parent
e1aca3b1f6
commit
fbdecdad0c
@ -372,14 +372,18 @@ xdg_get_data_home(void)
|
||||
}
|
||||
|
||||
char *
|
||||
get_unique_id(void)
|
||||
generate_unique_id(char *prefix)
|
||||
{
|
||||
static unsigned long unique_id;
|
||||
char *result = NULL;
|
||||
GString *result_str = g_string_new("");
|
||||
|
||||
unique_id++;
|
||||
g_string_printf(result_str, "prof%lu", unique_id);
|
||||
if (prefix != NULL) {
|
||||
g_string_printf(result_str, "prof_%s_%lu", prefix, unique_id);
|
||||
} else {
|
||||
g_string_printf(result_str, "prof_%lu", unique_id);
|
||||
}
|
||||
result = result_str->str;
|
||||
g_string_free(result_str, FALSE);
|
||||
|
||||
|
@ -88,7 +88,7 @@ const char * string_from_resource_presence(resource_presence_t presence);
|
||||
resource_presence_t resource_presence_from_string(const char * const str);
|
||||
contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence);
|
||||
|
||||
char * get_unique_id(void);
|
||||
char * generate_unique_id(char *prefix);
|
||||
|
||||
int cmp_win_num(gconstpointer a, gconstpointer b);
|
||||
int get_next_available_win_num(GList *used);
|
||||
|
@ -126,7 +126,7 @@ _roster_send_add_to_group(const char * const group, PContact contact)
|
||||
|
||||
new_groups = g_slist_append(new_groups, strdup(group));
|
||||
// add an id handler to handle the response
|
||||
char *unique_id = get_unique_id();
|
||||
char *unique_id = generate_unique_id(NULL);
|
||||
GroupData *data = malloc(sizeof(GroupData));
|
||||
data->group = strdup(group);
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
@ -175,7 +175,7 @@ _roster_send_remove_from_group(const char * const group, PContact contact)
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
|
||||
// add an id handler to handle the response
|
||||
char *unique_id = get_unique_id();
|
||||
char *unique_id = generate_unique_id(NULL);
|
||||
GroupData *data = malloc(sizeof(GroupData));
|
||||
data->group = strdup(group);
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user