diff options
Diffstat (limited to 'libdino')
-rw-r--r-- | libdino/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libdino/src/service/module_manager.vala | 1 | ||||
-rw-r--r-- | libdino/src/service/muc_manager.vala | 2 | ||||
-rw-r--r-- | libdino/src/service/registration.vala | 42 |
4 files changed, 45 insertions, 1 deletions
diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index 054e2bab..f45d08f5 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -41,6 +41,7 @@ SOURCES src/service/muc_manager.vala src/service/notification_events.vala src/service/presence_manager.vala + src/service/registration.vala src/service/roster_manager.vala src/service/search_processor.vala src/service/stream_interactor.vala diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala index 78819bb3..dac5aef2 100644 --- a/libdino/src/service/module_manager.vala +++ b/libdino/src/service/module_manager.vala @@ -76,6 +76,7 @@ public class ModuleManager { module_map[account].add(new Xep.Ping.Module()); module_map[account].add(new Xep.DelayedDelivery.Module()); module_map[account].add(new StreamError.Module()); + module_map[account].add(new Xep.InBandRegistration.Module()); initialize_account_modules(account, module_map[account]); } } diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index b69d71f2..a0f7fe70 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -125,7 +125,7 @@ public class MucManager : StreamInteractionModule, Object { } public bool is_groupchat_occupant(Jid jid, Account account) { - return is_groupchat(jid.bare_jid, account) && jid.is_full(); + return is_groupchat(jid.bare_jid, account) && jid.resourcepart != null; } public void get_bookmarks(Account account, owned Xep.Bookmarks.Module.OnResult listener) { diff --git a/libdino/src/service/registration.vala b/libdino/src/service/registration.vala new file mode 100644 index 00000000..32d8b04b --- /dev/null +++ b/libdino/src/service/registration.vala @@ -0,0 +1,42 @@ +using Gee; + +using Xmpp; +using Dino.Entities; + +namespace Dino { + +public class Register { + + public static async Xep.InBandRegistration.Form get_registration_form(Jid jid) { + XmppStream stream = new XmppStream(); + stream.add_module(new Tls.Module()); + stream.add_module(new Iq.Module()); + stream.add_module(new Xep.InBandRegistration.Module()); + stream.connect.begin(jid.bare_jid.to_string()); + + Xep.InBandRegistration.Form? form = null; + SourceFunc callback = get_registration_form.callback; + stream.stream_negotiated.connect(() => { + if (callback != null) { + Idle.add((owned)callback); + } + }); + Timeout.add_seconds(5, () => { + if (callback != null) { + Idle.add((owned)callback); + } + return false; + }); + yield; + if (stream.negotiation_complete) { + form = yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).get_from_server(stream, jid); + } + return form; + } + + public static async string submit_form(Jid jid, Xep.InBandRegistration.Form form) { + return yield form.stream.get_module(Xep.InBandRegistration.Module.IDENTITY).submit_to_server(form.stream, jid, form); + } +} + +} |