aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-12 23:14:50 +0200
committerfiaxh <git@mx.ax.lt>2017-08-14 22:38:12 +0200
commita59f728bdd7b81964a460b96b6c56da0d9dfda01 (patch)
tree21f1e2bd3a83a296f87f1a0307f258f0732dff24 /libdino/src
parent6904bda756321c67bea0108342fa9ba859dd66e9 (diff)
downloaddino-a59f728bdd7b81964a460b96b6c56da0d9dfda01.tar.gz
dino-a59f728bdd7b81964a460b96b6c56da0d9dfda01.zip
Stream Management
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/entity/jid.vala8
-rw-r--r--libdino/src/service/connection_manager.vala2
-rw-r--r--libdino/src/service/module_manager.vala14
-rw-r--r--libdino/src/service/stream_interactor.vala3
4 files changed, 19 insertions, 8 deletions
diff --git a/libdino/src/entity/jid.vala b/libdino/src/entity/jid.vala
index 2283b466..42218fb2 100644
--- a/libdino/src/entity/jid.vala
+++ b/libdino/src/entity/jid.vala
@@ -63,12 +63,12 @@ public class Dino.Entities.Jid : Object {
return jid;
}
- public bool equals_bare(Jid jid) {
- return equals_bare_func(this, jid);
+ public bool equals_bare(Jid? jid) {
+ return jid != null && equals_bare_func(this, jid);
}
- public bool equals(Jid jid) {
- return equals_func(this, jid);
+ public bool equals(Jid? jid) {
+ return jid != null && equals_func(this, jid);
}
public static new bool equals_bare_func(Jid jid1, Jid jid2) {
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 509964b3..d932d1cc 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -126,7 +126,7 @@ public class ConnectionManager {
Connection connection = new Connection(stream, new DateTime.now_local());
connections[account] = connection;
change_connection_state(account, ConnectionState.CONNECTING);
- stream.stream_negotiated.connect((stream) => {
+ stream.attached_modules.connect((stream) => {
change_connection_state(account, ConnectionState.CONNECTED);
});
stream.get_module(PlainSasl.Module.IDENTITY).received_auth_failure.connect((stream, node) => {
diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala
index b10765f1..437ecaf0 100644
--- a/libdino/src/service/module_manager.vala
+++ b/libdino/src/service/module_manager.vala
@@ -33,20 +33,30 @@ public class ModuleManager {
public ArrayList<Core.XmppStreamModule> get_modules(Account account, string? resource = null) {
ArrayList<Core.XmppStreamModule> modules = new ArrayList<Core.XmppStreamModule>();
- modules.add(new Bind.Module(resource == null ? account.resourcepart : resource));
- modules.add(new PlainSasl.Module(account.bare_jid.to_string(), account.password));
lock (module_map) {
if (!module_map.has_key(account)) initialize(account);
foreach (Core.XmppStreamModule module in module_map[account]) modules.add(module);
}
+
+ foreach (Core.XmppStreamModule module in module_map[account]) {
+ if (module.get_id() == Bind.Module.IDENTITY.id) {
+ (module as Bind.Module).requested_resource == null ? account.resourcepart : resource;
+ } else if (module.get_id() == PlainSasl.Module.IDENTITY.id) {
+ (module as PlainSasl.Module).password = account.password;
+ }
+ }
return modules;
}
public void initialize(Account account) {
lock(module_map) {
module_map[account] = new ArrayList<Core.XmppStreamModule>();
+ module_map[account].add(new Iq.Module());
module_map[account].add(new Tls.Module());
module_map[account].add(new Xep.SrvRecordsTls.Module());
+ module_map[account].add(new PlainSasl.Module(account.bare_jid.to_string(), account.password));
+ module_map[account].add(new Xep.StreamManagement.Module());
+ module_map[account].add(new Bind.Module(account.resourcepart));
module_map[account].add(new Session.Module());
module_map[account].add(new Roster.Module());
module_map[account].add(new Xep.ServiceDiscovery.Module.with_identity("client", "pc"));
diff --git a/libdino/src/service/stream_interactor.vala b/libdino/src/service/stream_interactor.vala
index 028d031b..f97eb482 100644
--- a/libdino/src/service/stream_interactor.vala
+++ b/libdino/src/service/stream_interactor.vala
@@ -10,6 +10,7 @@ public class StreamInteractor {
public signal void account_added(Account account);
public signal void account_removed(Account account);
public signal void stream_negotiated(Account account, Core.XmppStream stream);
+ public signal void attached_modules(Account account, Core.XmppStream stream);
public ModuleManager module_manager;
public ConnectionManager connection_manager;
@@ -84,4 +85,4 @@ public interface StreamInteractionModule : Object {
public abstract string id { get; }
}
-} \ No newline at end of file
+}