summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-07-24 18:00:40 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-07-24 18:00:40 +0200
commit713f55a1f9958222f85238bde40482b566cf040e (patch)
tree7ca0800a14cec6f9cbe6794a3bdcea9b42001db7 /modules
parent0a987e0a95b3473f8bc5e70455c92232d9990114 (diff)
contact: make contacts re-entrant
Diffstat (limited to 'modules')
-rw-r--r--modules/contact/contact.c19
-rw-r--r--modules/gtk/gtk_mod.c3
-rw-r--r--modules/gtk/uri_entry.c3
-rw-r--r--modules/presence/subscriber.c3
4 files changed, 20 insertions, 8 deletions
diff --git a/modules/contact/contact.c b/modules/contact/contact.c
index 42ff614..2a566eb 100644
--- a/modules/contact/contact.c
+++ b/modules/contact/contact.c
@@ -24,13 +24,14 @@ static char cmd_desc[128] = "Send MESSAGE to peer";
static int confline_handler(const struct pl *addr)
{
- return contact_add(NULL, addr);
+ return contact_add(baresip_contacts(), NULL, addr);
}
static int cmd_contact(struct re_printf *pf, void *arg)
{
const struct cmd_arg *carg = arg;
+ struct contacts *contacts = baresip_contacts();
struct contact *cnt = NULL;
struct pl dname, user, pl;
struct le *le;
@@ -42,7 +43,7 @@ static int cmd_contact(struct re_printf *pf, void *arg)
err |= re_hprintf(pf, "\n");
- for (le = list_head(contact_list()); le; le = le->next) {
+ for (le = list_head(contact_list(contacts)); le; le = le->next) {
struct contact *c = le->data;
@@ -101,6 +102,13 @@ static int cmd_contact(struct re_printf *pf, void *arg)
}
+static int print_contacts(struct re_printf *pf, void *unused)
+{
+ (void)unused;
+ return contacts_print(pf, baresip_contacts());
+}
+
+
static int cmd_message(struct re_printf *pf, void *arg)
{
const struct cmd_arg *carg = arg;
@@ -120,7 +128,7 @@ static int cmd_message(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
{'/', CMD_IPRM, "Dial from contacts", cmd_contact },
{'=', CMD_IPRM, "Select chat peer", cmd_contact },
- {'C', 0, "List contacts", contacts_print },
+ {'C', 0, "List contacts", print_contacts },
{'-', CMD_PRM, cmd_desc, cmd_message },
};
@@ -201,7 +209,8 @@ static int module_init(void)
if (err)
return err;
- info("Populated %u contacts\n", list_count(contact_list()));
+ info("Populated %u contacts\n",
+ list_count(contact_list(baresip_contacts())));
return err;
}
@@ -210,7 +219,7 @@ static int module_init(void)
static int module_close(void)
{
cmd_unregister(cmdv);
- list_flush(contact_list());
+ list_flush(contact_list(baresip_contacts()));
return 0;
}
diff --git a/modules/gtk/gtk_mod.c b/modules/gtk/gtk_mod.c
index 5e01882..55559d8 100644
--- a/modules/gtk/gtk_mod.c
+++ b/modules/gtk/gtk_mod.c
@@ -142,12 +142,13 @@ static void menu_on_dial_contact(GtkMenuItem *menuItem, gpointer arg)
static void init_contacts_menu(struct gtk_mod *mod)
{
+ struct contacts *contacts = baresip_contacts();
struct le *le;
GtkWidget *item;
GtkMenuShell *contacts_menu = GTK_MENU_SHELL(mod->contacts_menu);
/* Add contacts to submenu */
- for (le = list_head(contact_list()); le; le = le->next) {
+ for (le = list_head(contact_list(contacts)); le; le = le->next) {
struct contact *c = le->data;
item = gtk_menu_item_new_with_label(contact_str(c));
gtk_menu_shell_append(contacts_menu, item);
diff --git a/modules/gtk/uri_entry.c b/modules/gtk/uri_entry.c
index 601bf83..0ca1a3d 100644
--- a/modules/gtk/uri_entry.c
+++ b/modules/gtk/uri_entry.c
@@ -18,6 +18,7 @@
*/
GtkWidget *uri_combo_box_new(void)
{
+ struct contacts *contacts = baresip_contacts();
struct le *le;
GtkEntry *uri_entry;
GtkWidget *uri_combobox;
@@ -26,7 +27,7 @@ GtkWidget *uri_combo_box_new(void)
uri_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(uri_combobox)));
gtk_entry_set_activates_default(uri_entry, TRUE);
- for (le = list_head(contact_list()); le; le = le->next) {
+ for (le = list_head(contact_list(contacts)); le; le = le->next) {
struct contact *c = le->data;
gtk_combo_box_text_append_text(
GTK_COMBO_BOX_TEXT(uri_combobox),
diff --git a/modules/presence/subscriber.c b/modules/presence/subscriber.c
index baf0b0c..b61e454 100644
--- a/modules/presence/subscriber.c
+++ b/modules/presence/subscriber.c
@@ -282,10 +282,11 @@ static int presence_alloc(struct contact *contact)
int subscriber_init(void)
{
+ struct contacts *contacts = baresip_contacts();
struct le *le;
int err = 0;
- for (le = list_head(contact_list()); le; le = le->next) {
+ for (le = list_head(contact_list(contacts)); le; le = le->next) {
struct contact *c = le->data;
struct sip_addr *addr = contact_addr(c);