aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/muc_manager.vala23
-rw-r--r--main/src/ui/add_conversation/add_groupchat_dialog.vala20
-rw-r--r--xmpp-vala/src/module/bookmarks_provider.vala2
-rw-r--r--xmpp-vala/src/module/conference.vala6
-rw-r--r--xmpp-vala/src/module/xep/0048_bookmarks.vala20
-rw-r--r--xmpp-vala/src/module/xep/0402_bookmarks2.vala2
6 files changed, 25 insertions, 48 deletions
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index 0e27b724..cd27e392 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -187,13 +187,6 @@ public class MucManager : StreamInteractionModule, Object {
}
}
- public void replace_bookmark(Account account, Conference was, Conference replace) {
- XmppStream? stream = stream_interactor.get_stream(account);
- if (stream != null) {
- stream.get_module(Xep.Bookmarks.Module.IDENTITY).replace_conference.begin(stream, was, replace);
- }
- }
-
public void remove_bookmark(Account account, Conference conference) {
XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) {
@@ -380,12 +373,8 @@ public class MucManager : StreamInteractionModule, Object {
foreach (Conference conference in conferences) {
if (conference.jid.equals(jid)) {
if (!conference.autojoin) {
- Conference new_conference = new Conference();
- new_conference.jid = jid;
- new_conference.autojoin = true;
- new_conference.nick = nick;
- new_conference.password = password;
- bookmarks_provider[account].replace_conference.begin(stream, conference, new_conference);
+ Conference new_conference = new Conference() { jid=jid, nick=conference.nick, name=conference.name, password=conference.password, autojoin=true };
+ bookmarks_provider[account].replace_conference.begin(stream, jid, new_conference);
}
return;
}
@@ -403,12 +392,8 @@ public class MucManager : StreamInteractionModule, Object {
foreach (Conference conference in conferences) {
if (conference.jid.equals(jid)) {
if (conference.autojoin) {
- Conference new_conference = new Conference();
- new_conference.jid = jid;
- new_conference.autojoin = false;
- new_conference.nick = conference.nick;
- new_conference.password = conference.password;
- bookmarks_provider[account].replace_conference.begin(stream, conference, new_conference);
+ Conference new_conference = new Conference() { jid=jid, nick=conference.nick, name=conference.name, password=conference.password, autojoin=false };
+ bookmarks_provider[account].replace_conference.begin(stream, jid, new_conference);
return;
}
}
diff --git a/main/src/ui/add_conversation/add_groupchat_dialog.vala b/main/src/ui/add_conversation/add_groupchat_dialog.vala
index da6b10b2..7563da7f 100644
--- a/main/src/ui/add_conversation/add_groupchat_dialog.vala
+++ b/main/src/ui/add_conversation/add_groupchat_dialog.vala
@@ -19,7 +19,6 @@ protected class AddGroupchatDialog : Gtk.Dialog {
[GtkChild] private Entry nick_entry;
private StreamInteractor stream_interactor;
- private Conference? edit_conference = null;
private bool alias_entry_changed = false;
public AddGroupchatDialog(StreamInteractor stream_interactor) {
@@ -36,19 +35,6 @@ protected class AddGroupchatDialog : Gtk.Dialog {
nick_entry.key_release_event.connect(check_ok);
}
- public AddGroupchatDialog.for_conference(StreamInteractor stream_interactor, Account account, Conference conference) {
- this(stream_interactor);
- edit_conference = conference;
- ok_button.label = _("Save");
- ok_button.sensitive = true;
- accounts_stack.set_visible_child_name("label");
- account_label.label = account.bare_jid.to_string();
- account_combobox.selected = account;
- jid_entry.text = conference.jid.to_string();
- nick_entry.text = conference.nick ?? "";
- alias_entry.text = conference.name;
- }
-
private bool on_jid_key_release() {
check_ok();
if (!alias_entry_changed) {
@@ -78,11 +64,7 @@ protected class AddGroupchatDialog : Gtk.Dialog {
conference.jid = new Jid(jid_entry.text);
conference.nick = nick_entry.text != "" ? nick_entry.text : null;
conference.name = alias_entry.text;
- if (edit_conference == null) {
- stream_interactor.get_module(MucManager.IDENTITY).add_bookmark(account_combobox.selected, conference);
- } else {
- stream_interactor.get_module(MucManager.IDENTITY).replace_bookmark(account_combobox.selected, edit_conference, conference);
- }
+ stream_interactor.get_module(MucManager.IDENTITY).add_bookmark(account_combobox.selected, conference);
close();
} catch (InvalidJidError e) {
warning("Ignoring invalid conference Jid: %s", e.message);
diff --git a/xmpp-vala/src/module/bookmarks_provider.vala b/xmpp-vala/src/module/bookmarks_provider.vala
index 69d2efa2..6ddcc5af 100644
--- a/xmpp-vala/src/module/bookmarks_provider.vala
+++ b/xmpp-vala/src/module/bookmarks_provider.vala
@@ -11,7 +11,7 @@ public interface BookmarksProvider : Object {
public async abstract async Set<Conference>? get_conferences(XmppStream stream);
public async abstract void add_conference(XmppStream stream, Conference conference);
public async abstract void remove_conference(XmppStream stream, Conference conference);
- public async abstract void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference);
+ public async abstract void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference);
}
}
diff --git a/xmpp-vala/src/module/conference.vala b/xmpp-vala/src/module/conference.vala
index 9b1172d8..38c0ead4 100644
--- a/xmpp-vala/src/module/conference.vala
+++ b/xmpp-vala/src/module/conference.vala
@@ -7,7 +7,11 @@ public class Conference : Object {
public virtual string? name { get; set; }
public virtual string? password { get; set; }
- public static bool equal_func(Conference a, Conference b) {
+ public bool equals(Conference c) {
+ return equals_func(this, c);
+ }
+
+ public static bool equals_func(Conference a, Conference b) {
return Jid.equals_func(a.jid, b.jid);
}
diff --git a/xmpp-vala/src/module/xep/0048_bookmarks.vala b/xmpp-vala/src/module/xep/0048_bookmarks.vala
index 2fd38bea..daacf1a4 100644
--- a/xmpp-vala/src/module/xep/0048_bookmarks.vala
+++ b/xmpp-vala/src/module/xep/0048_bookmarks.vala
@@ -7,7 +7,7 @@ public class Module : BookmarksProvider, XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module");
public async Set<Conference>? get_conferences(XmppStream stream) {
- Set<Conference> ret = new HashSet<Conference>(Conference.hash_func, Conference.equal_func);
+ Set<Conference> ret = new HashSet<Conference>(Conference.hash_func, Conference.equals_func);
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node) => {
@@ -54,20 +54,26 @@ public class Module : BookmarksProvider, XmppStreamModule {
public async void add_conference(XmppStream stream, Conference conference) {
Set<Conference>? conferences = yield get_conferences(stream);
conferences.add(conference);
- stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
+ set_conferences(stream, conferences);
}
- public async void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference) {
+ public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) {
Set<Conference>? conferences = yield get_conferences(stream);
- conferences.remove(orig_conference);
- conferences.add(modified_conference);
- stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
+ foreach (Conference conference in conferences) {
+ if (conference.jid.equals(muc_jid)) {
+ conference.autojoin = modified_conference.autojoin;
+ conference.name = modified_conference.name;
+ conference.nick = modified_conference.nick;
+ conference.password = modified_conference.password;
+ }
+ }
+ set_conferences(stream, conferences);
}
public async void remove_conference(XmppStream stream, Conference conference_remove) {
Set<Conference>? conferences = yield get_conferences(stream);
conferences.remove(conference_remove);
- stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
+ set_conferences(stream, conferences);
}
public override void attach(XmppStream stream) { }
diff --git a/xmpp-vala/src/module/xep/0402_bookmarks2.vala b/xmpp-vala/src/module/xep/0402_bookmarks2.vala
index 50c52ac2..563bc286 100644
--- a/xmpp-vala/src/module/xep/0402_bookmarks2.vala
+++ b/xmpp-vala/src/module/xep/0402_bookmarks2.vala
@@ -45,7 +45,7 @@ public class Module : BookmarksProvider, XmppStreamModule {
yield stream.get_module(Pubsub.Module.IDENTITY).publish(stream, stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid, NS_URI, conference.jid.to_string(), conference_node, Xmpp.Xep.Pubsub.ACCESS_MODEL_WHITELIST);
}
- public async void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference) {
+ public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) {
yield add_conference(stream, modified_conference);
}