diff --git a/src/common.c b/src/common.c index c8367592..5cce121a 100644 --- a/src/common.c +++ b/src/common.c @@ -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); diff --git a/src/common.h b/src/common.h index ad98aa2c..1559c12a 100644 --- a/src/common.h +++ b/src/common.h @@ -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); diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 542da2d0..cf42acac 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -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) {