aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /plugins
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'plugins')
-rw-r--r--plugins/http-files/src/file_provider.vala1
-rw-r--r--plugins/http-files/src/manager.vala6
-rw-r--r--plugins/http-files/src/upload_stream_module.vala10
-rw-r--r--plugins/omemo/src/bundle.vala2
-rw-r--r--plugins/omemo/src/manager.vala46
-rw-r--r--plugins/omemo/src/message_flag.vala4
-rw-r--r--plugins/omemo/src/stream_module.vala111
-rw-r--r--plugins/openpgp/src/database.vala1
-rw-r--r--plugins/openpgp/src/encryption_list_entry.vala1
-rw-r--r--plugins/openpgp/src/manager.vala8
-rw-r--r--plugins/openpgp/src/plugin.vala2
-rw-r--r--plugins/openpgp/src/stream_flag.vala8
-rw-r--r--plugins/openpgp/src/stream_module.vala21
13 files changed, 111 insertions, 110 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 9a9db072..493aaa61 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -2,6 +2,7 @@ using Gee;
using Gtk;
using Dino.Entities;
+using Xmpp;
namespace Dino.Plugins.HttpFiles {
diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala
index 83836989..db7a3f8f 100644
--- a/plugins/http-files/src/manager.vala
+++ b/plugins/http-files/src/manager.vala
@@ -30,7 +30,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
public void send_file(Conversation conversation, FileTransfer file_transfer) {
- Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(file_transfer.account);
+ Xmpp.XmppStream? stream = stream_interactor.get_stream(file_transfer.account);
if (stream != null) {
stream_interactor.module_manager.get_module(file_transfer.account, UploadStreamModule.IDENTITY).upload(stream, file_transfer.input_stream, file_transfer.server_file_name, file_transfer.size, file_transfer.mime_type,
(stream, url_down) => {
@@ -60,7 +60,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
}
- private void on_stream_negotiated(Account account, Core.XmppStream stream) {
+ private void on_stream_negotiated(Account account, XmppStream stream) {
stream_interactor.module_manager.get_module(account, UploadStreamModule.IDENTITY).feature_available.connect((stream, max_file_size) => {
lock (max_file_sizes) {
max_file_sizes[account] = max_file_size;
@@ -69,7 +69,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
});
}
- private void check_add_oob(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ private void check_add_oob(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
if (message_is_file(db, message)) {
Xep.OutOfBandData.add_url_to_message(message_stanza, message_stanza.body);
}
diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala
index 08e6105f..f4a4a428 100644
--- a/plugins/http-files/src/upload_stream_module.vala
+++ b/plugins/http-files/src/upload_stream_module.vala
@@ -1,5 +1,5 @@
using Xmpp;
-using Xmpp.Core;
+using Xmpp;
using Xmpp.Xep;
namespace Dino.Plugins.HttpFiles {
@@ -8,7 +8,7 @@ private const string NS_URI = "urn:xmpp:http:upload";
private const string NS_URI_0 = "urn:xmpp:http:upload:0";
public class UploadStreamModule : XmppStreamModule {
- public static Core.ModuleIdentity<UploadStreamModule> IDENTITY = new Core.ModuleIdentity<UploadStreamModule>(NS_URI, "0363_http_file_upload");
+ public static Xmpp.ModuleIdentity<UploadStreamModule> IDENTITY = new Xmpp.ModuleIdentity<UploadStreamModule>(NS_URI, "0363_http_file_upload");
public signal void feature_available(XmppStream stream, long max_file_size);
@@ -116,7 +116,7 @@ public class UploadStreamModule : XmppStreamModule {
});
}
- private bool check_ns_in_info(XmppStream stream, string jid, Xep.ServiceDiscovery.InfoResult info_result) {
+ private bool check_ns_in_info(XmppStream stream, Jid jid, Xep.ServiceDiscovery.InfoResult info_result) {
bool ver_available = false;
bool ver_0_available = false;
foreach (string feature in info_result.features) {
@@ -162,11 +162,11 @@ public class UploadStreamModule : XmppStreamModule {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
- public string file_store_jid;
+ public Jid file_store_jid;
public string ns_ver;
public int? max_file_size;
- public Flag(string file_store_jid, string ns_ver) {
+ public Flag(Jid file_store_jid, string ns_ver) {
this.file_store_jid = file_store_jid;
this.ns_ver = ns_ver;
}
diff --git a/plugins/omemo/src/bundle.vala b/plugins/omemo/src/bundle.vala
index 688f6192..9b01f299 100644
--- a/plugins/omemo/src/bundle.vala
+++ b/plugins/omemo/src/bundle.vala
@@ -1,6 +1,6 @@
using Gee;
using Signal;
-using Xmpp.Core;
+using Xmpp;
namespace Dino.Plugins.Omemo {
diff --git a/plugins/omemo/src/manager.vala b/plugins/omemo/src/manager.vala
index 5a7cb9ef..6c8ce4ef 100644
--- a/plugins/omemo/src/manager.vala
+++ b/plugins/omemo/src/manager.vala
@@ -69,16 +69,16 @@ public class Manager : StreamInteractionModule, Object {
stream_interactor.get_module(MessageProcessor.IDENTITY).pre_message_send.connect(on_pre_message_send);
}
- private void on_pre_message_received(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ private void on_pre_message_received(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
MessageFlag? flag = MessageFlag.get_flag(message_stanza);
if (flag != null && ((!)flag).decrypted) {
message.encryption = Encryption.OMEMO;
}
}
- private void on_pre_message_send(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ private void on_pre_message_send(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
if (message.encryption == Encryption.OMEMO) {
- Core.XmppStream? stream = stream_interactor.get_stream(conversation.account);
+ XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream == null) {
message.marked = Entities.Message.Marked.UNSENT;
return;
@@ -89,7 +89,7 @@ public class Manager : StreamInteractionModule, Object {
return;
}
StreamModule module = (!)module_;
- EncryptState enc_state = module.encrypt(message_stanza, conversation.account.bare_jid.to_string());
+ EncryptState enc_state = module.encrypt(message_stanza, conversation.account.bare_jid);
MessageState state;
lock (message_states) {
if (message_states.has_key(message)) {
@@ -111,13 +111,13 @@ public class Manager : StreamInteractionModule, Object {
if (Plugin.DEBUG) print(@"OMEMO: message will be delayed: $state\n");
if (state.waiting_own_sessions > 0) {
- module.start_sessions_with((!)stream, conversation.account.bare_jid.to_string());
+ module.start_sessions_with((!)stream, conversation.account.bare_jid);
}
if (state.waiting_other_sessions > 0 && message.counterpart != null) {
- module.start_sessions_with((!)stream, ((!)message.counterpart).bare_jid.to_string());
+ module.start_sessions_with((!)stream, ((!)message.counterpart).bare_jid);
}
if (state.waiting_other_devicelist && message.counterpart != null) {
- module.request_user_devicelist((!)stream, ((!)message.counterpart).bare_jid.to_string());
+ module.request_user_devicelist((!)stream, ((!)message.counterpart).bare_jid);
}
}
}
@@ -132,20 +132,20 @@ public class Manager : StreamInteractionModule, Object {
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).session_start_failed.connect((jid, device_id) => on_session_started(account, jid, true));
}
- private void on_stream_negotiated(Account account, Core.XmppStream stream) {
- stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, account.bare_jid.to_string());
+ private void on_stream_negotiated(Account account, XmppStream stream) {
+ stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, account.bare_jid);
}
- private void on_session_started(Account account, string jid, bool failed) {
+ private void on_session_started(Account account, Jid jid, bool failed) {
if (Plugin.DEBUG) print(@"OMEMO: session start between $(account.bare_jid) and $jid $(failed ? "failed" : "successful")\n");
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
lock (message_states) {
foreach (Entities.Message msg in message_states.keys) {
if (!msg.account.equals(account)) continue;
MessageState state = message_states[msg];
- if (account.bare_jid.to_string() == jid) {
+ if (account.bare_jid.equals(jid)) {
state.waiting_own_sessions--;
- } else if (msg.counterpart != null && ((!)msg.counterpart).bare_jid.to_string() == jid) {
+ } else if (msg.counterpart != null && msg.counterpart.equals_bare(jid)) {
state.waiting_other_sessions--;
}
if (state.should_retry_now()) {
@@ -162,16 +162,16 @@ public class Manager : StreamInteractionModule, Object {
}
}
- private void on_device_list_loaded(Account account, string jid) {
+ private void on_device_list_loaded(Account account, Jid jid) {
if (Plugin.DEBUG) print(@"OMEMO: received device list for $(account.bare_jid) from $jid\n");
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
lock (message_states) {
foreach (Entities.Message msg in message_states.keys) {
if (!msg.account.equals(account)) continue;
MessageState state = message_states[msg];
- if (account.bare_jid.to_string() == jid) {
+ if (account.bare_jid.equals(jid)) {
state.waiting_own_devicelist = false;
- } else if (msg.counterpart != null && ((!)msg.counterpart).bare_jid.to_string() == jid) {
+ } else if (msg.counterpart != null && msg.counterpart.equals_bare(jid)) {
state.waiting_other_devicelist = false;
}
if (state.should_retry_now()) {
@@ -188,7 +188,7 @@ public class Manager : StreamInteractionModule, Object {
}
// Update meta database
- Core.XmppStream? stream = stream_interactor.get_stream(account);
+ XmppStream? stream = stream_interactor.get_stream(account);
if (stream == null) {
return;
}
@@ -197,10 +197,10 @@ public class Manager : StreamInteractionModule, Object {
return;
}
ArrayList<int32> device_list = module.get_device_list(jid);
- db.identity_meta.insert_device_list(jid, device_list);
+ db.identity_meta.insert_device_list(jid.bare_jid.to_string(), device_list);
int inc = 0;
- foreach (Row row in db.identity_meta.with_address(jid).with_null(db.identity_meta.identity_key_public_base64)) {
- module.fetch_bundle(stream, row[db.identity_meta.address_name], row[db.identity_meta.device_id]);
+ foreach (Row row in db.identity_meta.with_address(jid.bare_jid.to_string()).with_null(db.identity_meta.identity_key_public_base64)) {
+ module.fetch_bundle(stream, Jid.parse(row[db.identity_meta.address_name]), row[db.identity_meta.device_id]);
inc++;
}
if (inc > 0) {
@@ -208,8 +208,8 @@ public class Manager : StreamInteractionModule, Object {
}
}
- public void on_bundle_fetched(Account account, string jid, int32 device_id, Bundle bundle) {
- db.identity_meta.insert_device_bundle(jid, device_id, bundle);
+ public void on_bundle_fetched(Account account, Jid jid, int32 device_id, Bundle bundle) {
+ db.identity_meta.insert_device_bundle(jid.bare_jid.to_string(), device_id, bundle);
}
private void on_store_created(Account account, Store store) {
@@ -252,11 +252,11 @@ public class Manager : StreamInteractionModule, Object {
public bool can_encrypt(Entities.Conversation conversation) {
- Core.XmppStream? stream = stream_interactor.get_stream(conversation.account);
+ XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream == null) return false;
StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY);
if (module == null) return false;
- return ((!)module).is_known_address(conversation.counterpart.bare_jid.to_string());
+ return ((!)module).is_known_address(conversation.counterpart.bare_jid);
}
public static void start(StreamInteractor stream_interactor, Database db) {
diff --git a/plugins/omemo/src/message_flag.vala b/plugins/omemo/src/message_flag.vala
index cea1e9b2..ba9ea16e 100644
--- a/plugins/omemo/src/message_flag.vala
+++ b/plugins/omemo/src/message_flag.vala
@@ -2,12 +2,12 @@ using Xmpp;
namespace Dino.Plugins.Omemo {
-public class MessageFlag : Message.MessageFlag {
+public class MessageFlag : Xmpp.MessageFlag {
public const string id = "omemo";
public bool decrypted = false;
- public static MessageFlag? get_flag(Message.Stanza message) {
+ public static MessageFlag? get_flag(MessageStanza message) {
return (MessageFlag) message.get_flag(NS_URI, id);
}
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 1aa92801..0b5f4ea9 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -1,6 +1,6 @@
using Gee;
using Xmpp;
-using Xmpp.Core;
+using Xmpp;
using Xmpp.Xep;
using Signal;
@@ -14,33 +14,32 @@ private const string NODE_VERIFICATION = NS_URI + ".verification";
private const int NUM_KEYS_TO_PUBLISH = 100;
public class StreamModule : XmppStreamModule {
- public static Core.ModuleIdentity<StreamModule> IDENTITY = new Core.ModuleIdentity<StreamModule>(NS_URI, "omemo_module");
+ public static Xmpp.ModuleIdentity<StreamModule> IDENTITY = new Xmpp.ModuleIdentity<StreamModule>(NS_URI, "omemo_module");
private Store store;
private ConcurrentSet<string> active_bundle_requests = new ConcurrentSet<string>();
- private ConcurrentSet<string> active_devicelist_requests = new ConcurrentSet<string>();
- private Map<string, ArrayList<int32>> device_lists = new HashMap<string, ArrayList<int32>>();
- private Map<string, ArrayList<int32>> ignored_devices = new HashMap<string, ArrayList<int32>>();
+ private ConcurrentSet<Jid> active_devicelist_requests = new ConcurrentSet<Jid>();
+ private Map<Jid, ArrayList<int32>> device_lists = new HashMap<Jid, ArrayList<int32>>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private Map<Jid, ArrayList<int32>> ignored_devices = new HashMap<Jid, ArrayList<int32>>(Jid.hash_bare_func, Jid.equals_bare_func);
private ReceivedPipelineListener received_pipeline_listener;
public signal void store_created(Store store);
- public signal void device_list_loaded(string jid);
- public signal void bundle_fetched(string jid, int device_id, Bundle bundle);
- public signal void session_started(string jid, int device_id);
- public signal void session_start_failed(string jid, int device_id);
+ public signal void device_list_loaded(Jid jid);
+ public signal void bundle_fetched(Jid jid, int device_id, Bundle bundle);
+ public signal void session_started(Jid jid, int device_id);
+ public signal void session_start_failed(Jid jid, int device_id);
- public EncryptState encrypt(Message.Stanza message, string self_bare_jid) {
+ public EncryptState encrypt(MessageStanza message, Jid self_jid) {
EncryptState status = new EncryptState();
if (!Plugin.ensure_context()) return status;
if (message.to == null) return status;
try {
- string name = get_bare_jid((!)message.to);
- if (!device_lists.has_key(self_bare_jid)) return status;
+ if (!device_lists.has_key(self_jid)) return status;
status.own_list = true;
- status.own_devices = device_lists.get(self_bare_jid).size;
- if (!device_lists.has_key(name)) return status;
+ status.own_devices = device_lists.get(self_jid).size;
+ if (!device_lists.has_key(message.to)) return status;
status.other_list = true;
- status.other_devices = device_lists.get(name).size;
+ status.other_devices = device_lists.get(message.to).size;
if (status.own_devices == 0 || status.other_devices == 0) return status;
uint8[] key = new uint8[16];
@@ -59,9 +58,9 @@ public class StreamModule : XmppStreamModule {
.put_node(new StanzaNode.build("payload", NS_URI)
.put_node(new StanzaNode.text(Base64.encode(ciphertext))));
- Address address = new Address(name, 0);
- foreach(int32 device_id in device_lists[name]) {
- if (is_ignored_device(name, device_id)) {
+ Address address = new Address(message.to.bare_jid.to_string(), 0);
+ foreach(int32 device_id in device_lists[message.to]) {
+ if (is_ignored_device(message.to, device_id)) {
status.other_lost++;
continue;
}
@@ -75,9 +74,9 @@ public class StreamModule : XmppStreamModule {
else status.other_failure++;
}
}
- address.name = self_bare_jid;
- foreach(int32 device_id in device_lists[self_bare_jid]) {
- if (is_ignored_device(self_bare_jid, device_id)) {
+ address.name = self_jid.bare_jid.to_string();
+ foreach(int32 device_id in device_lists[self_jid]) {
+ if (is_ignored_device(self_jid, device_id)) {
status.own_lost++;
continue;
}
@@ -119,26 +118,26 @@ public class StreamModule : XmppStreamModule {
this.store = Plugin.get_context().create_store();
store_created(store);
received_pipeline_listener = new ReceivedPipelineListener(store);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.connect(received_pipeline_listener);
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node));
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
}
- public void request_user_devicelist(XmppStream stream, string jid) {
+ public void request_user_devicelist(XmppStream stream, Jid jid) {
if (active_devicelist_requests.add(jid)) {
if (Plugin.DEBUG) print(@"OMEMO: requesting device list for $jid\n");
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node));
}
}
- public void on_devicelist(XmppStream stream, string jid, string? id, StanzaNode? node_) {
+ public void on_devicelist(XmppStream stream, Jid jid, string? id, StanzaNode? node_) {
StanzaNode node = node_ ?? new StanzaNode.build("list", NS_URI).add_self_xmlns();
- string? my_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid;
+ Jid? my_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid;
if (my_jid == null) return;
- if (jid == get_bare_jid((!)my_jid) && store.local_registration_id != 0) {
+ if (jid.equals_bare(my_jid) && store.local_registration_id != 0) {
bool am_on_devicelist = false;
foreach (StanzaNode device_node in node.get_subnodes("device")) {
int device_id = device_node.get_attribute_int("id");
@@ -164,17 +163,17 @@ public class StreamModule : XmppStreamModule {
device_list_loaded(jid);
}
- public void start_sessions_with(XmppStream stream, string bare_jid) {
- if (!device_lists.has_key(bare_jid)) {
+ public void start_sessions_with(XmppStream stream, Jid jid) {
+ if (!device_lists.has_key(jid)) {
return;
}
- Address address = new Address(bare_jid, 0);
- foreach(int32 device_id in device_lists[bare_jid]) {
- if (!is_ignored_device(bare_jid, device_id)) {
+ Address address = new Address(jid.bare_jid.to_string(), 0);
+ foreach(int32 device_id in device_lists[jid]) {
+ if (!is_ignored_device(jid, device_id)) {
address.device_id = device_id;
try {
if (!store.contains_session(address)) {
- start_session_with(stream, bare_jid, device_id);
+ start_session_with(stream, jid, device_id);
}
} catch (Error e) {
// Ignore
@@ -184,25 +183,25 @@ public class StreamModule : XmppStreamModule {
address.device_id = 0;
}
- public void start_session_with(XmppStream stream, string bare_jid, int device_id) {
- if (active_bundle_requests.add(bare_jid + @":$device_id")) {
- if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $bare_jid:$device_id\n");
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
+ public void start_session_with(XmppStream stream, Jid jid, int device_id) {
+ if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
+ if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
on_other_bundle_result(stream, jid, device_id, id, node);
});
}
}
- public void fetch_bundle(XmppStream stream, string bare_jid, int device_id) {
- if (active_bundle_requests.add(bare_jid + @":$device_id")) {
- if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $bare_jid:$device_id\n");
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
+ public void fetch_bundle(XmppStream stream, Jid jid, int device_id) {
+ if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
+ if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
bundle_fetched(jid, device_id, new Bundle(node));
});
}
}
- public ArrayList<int32> get_device_list(string jid) {
+ public ArrayList<int32> get_device_list(Jid jid) {
if (is_known_address(jid)) {
return device_lists[jid];
} else {
@@ -210,11 +209,11 @@ public class StreamModule : XmppStreamModule {
}
}
- public bool is_known_address(string name) {
- return device_lists.has_key(name);
+ public bool is_known_address(Jid jid) {
+ return device_lists.has_key(jid);
}
- public void ignore_device(string jid, int32 device_id) {
+ public void ignore_device(Jid jid, int32 device_id) {
if (device_id <= 0) return;
lock (ignored_devices) {
if (!ignored_devices.has_key(jid)) {
@@ -225,14 +224,14 @@ public class StreamModule : XmppStreamModule {
session_start_failed(jid, device_id);
}
- public bool is_ignored_device(string jid, int32 device_id) {
+ public bool is_ignored_device(Jid jid, int32 device_id) {
if (device_id <= 0) return true;
lock (ignored_devices) {
return ignored_devices.has_key(jid) && ignored_devices[jid].contains(device_id);
}
}
- private void on_other_bundle_result(XmppStream stream, string jid, int device_id, string? id, StanzaNode? node) {
+ private void on_other_bundle_result(XmppStream stream, Jid jid, int device_id, string? id, StanzaNode? node) {
bool fail = false;
if (node == null) {
// Device not registered, shouldn't exist
@@ -255,7 +254,7 @@ public class StreamModule : XmppStreamModule {
if (pre_key_id < 0 || pre_key == null) {
fail = true;
} else {
- Address address = new Address(jid, device_id);
+ Address address = new Address(jid.bare_jid.to_string(), device_id);
try {
if (store.contains_session(address)) {
return;
@@ -273,16 +272,16 @@ public class StreamModule : XmppStreamModule {
if (fail) {
stream.get_module(IDENTITY).ignore_device(jid, device_id);
}
- stream.get_module(IDENTITY).active_bundle_requests.remove(jid + @":$device_id");
+ stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$device_id");
}
- public void publish_bundles_if_needed(XmppStream stream, string jid) {
- if (active_bundle_requests.add(jid + @":$(store.local_registration_id)")) {
+ public void publish_bundles_if_needed(XmppStream stream, Jid jid) {
+ if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$(store.local_registration_id)")) {
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, @"$NODE_BUNDLES:$(store.local_registration_id)", on_self_bundle_result);
}
}
- private void on_self_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node) {
+ private void on_self_bundle_result(XmppStream stream, Jid jid, string? id, StanzaNode? node) {
if (!Plugin.ensure_context()) return;
Map<int, ECPublicKey> keys = new HashMap<int, ECPublicKey>();
ECPublicKey? identity_key = null;
@@ -350,7 +349,7 @@ public class StreamModule : XmppStreamModule {
} catch (Error e) {
if (Plugin.DEBUG) print(@"Unexpected error while publishing bundle: $(e.message)\n");
}
- stream.get_module(IDENTITY).active_bundle_requests.remove(jid + @":$(store.local_registration_id)");
+ stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$(store.local_registration_id)");
}
public static void publish_bundles(XmppStream stream, SignedPreKeyRecord signed_pre_key_record, IdentityKeyPair identity_key_pair, Set<PreKeyRecord> pre_key_records, int32 device_id) throws Error {
@@ -385,7 +384,7 @@ public class StreamModule : XmppStreamModule {
}
-public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
+public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {"EXTRACT_MESSAGE_2"};
@@ -398,7 +397,7 @@ public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
this.store = store;
}
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
StanzaNode? _encrypted = message.stanza.get_subnode("encrypted", NS_URI);
if (_encrypted == null || MessageFlag.get_flag(message) != null || message.from == null) return;
StanzaNode encrypted = (!)_encrypted;
@@ -419,7 +418,7 @@ public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
uint8[] key;
uint8[] ciphertext = Base64.decode((!)payload);
uint8[] iv = Base64.decode((!)iv_node);
- Address address = new Address(get_bare_jid((!)message.from), header.get_attribute_int("sid"));
+ Address address = new Address(message.from.bare_jid.to_string(), header.get_attribute_int("sid"));
if (key_node.get_attribute_bool("prekey")) {
PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(Base64.decode((!)key_node_content));
SessionCipher cipher = store.create_session_cipher(address);
diff --git a/plugins/openpgp/src/database.vala b/plugins/openpgp/src/database.vala
index 0e4bf74c..52005651 100644
--- a/plugins/openpgp/src/database.vala
+++ b/plugins/openpgp/src/database.vala
@@ -1,6 +1,7 @@
using Qlite;
using Dino.Entities;
+using Xmpp;
namespace Dino.Plugins.OpenPgp {
diff --git a/plugins/openpgp/src/encryption_list_entry.vala b/plugins/openpgp/src/encryption_list_entry.vala
index d2cbd13f..7ccd9f73 100644
--- a/plugins/openpgp/src/encryption_list_entry.vala
+++ b/plugins/openpgp/src/encryption_list_entry.vala
@@ -1,6 +1,7 @@
using Gee;
using Dino.Entities;
+using Xmpp;
namespace Dino.Plugins.OpenPgp {
diff --git a/plugins/openpgp/src/manager.vala b/plugins/openpgp/src/manager.vala
index 3f0fe3dd..79e832ff 100644
--- a/plugins/openpgp/src/manager.vala
+++ b/plugins/openpgp/src/manager.vala
@@ -63,17 +63,17 @@ public class Manager : StreamInteractionModule, Object {
return gpgkeys;
}
- private void on_pre_message_received(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ private void on_pre_message_received(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
if (MessageFlag.get_flag(message_stanza) != null && MessageFlag.get_flag(message_stanza).decrypted) {
message.encryption = Encryption.PGP;
}
}
- private void check_encypt(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ private void check_encypt(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
try {
if (message.encryption == Encryption.PGP) {
GPG.Key[] keys = get_key_fprs(conversation);
- Core.XmppStream? stream = stream_interactor.get_stream(conversation.account);
+ XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream != null) {
bool encrypted = stream.get_module(Module.IDENTITY).encrypt(message_stanza, keys);
if (!encrypted) message.marked = Entities.Message.Marked.WONTSEND;
@@ -91,7 +91,7 @@ public class Manager : StreamInteractionModule, Object {
private void on_account_added(Account account) {
stream_interactor.module_manager.get_module(account, Module.IDENTITY).received_jid_key_id.connect((stream, jid, key_id) => {
- on_jid_key_received(account, new Jid(jid), key_id);
+ on_jid_key_received(account, jid, key_id);
});
}
diff --git a/plugins/openpgp/src/plugin.vala b/plugins/openpgp/src/plugin.vala
index 7ec6c357..adf2ecc7 100644
--- a/plugins/openpgp/src/plugin.vala
+++ b/plugins/openpgp/src/plugin.vala
@@ -37,7 +37,7 @@ public class Plugin : Plugins.RootInterface, Object {
public void shutdown() { }
- private void on_initialize_account_modules(Account account, ArrayList<Xmpp.Core.XmppStreamModule> modules) {
+ private void on_initialize_account_modules(Account account, ArrayList<Xmpp.XmppStreamModule> modules) {
Module module = new Module(db.get_account_key(account));
this.modules[account] = module;
modules.add(module);
diff --git a/plugins/openpgp/src/stream_flag.vala b/plugins/openpgp/src/stream_flag.vala
index 165327b9..8593fa9d 100644
--- a/plugins/openpgp/src/stream_flag.vala
+++ b/plugins/openpgp/src/stream_flag.vala
@@ -1,18 +1,18 @@
using Gee;
using Xmpp;
-using Xmpp.Core;
+using Xmpp;
namespace Dino.Plugins.OpenPgp {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "pgp");
- public HashMap<string, string> key_ids = new HashMap<string, string>();
+ public HashMap<Jid, string> key_ids = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
- public string? get_key_id(string jid) { return key_ids[get_bare_jid(jid)]; }
+ public string? get_key_id(Jid jid) { return key_ids[jid]; }
- public void set_key_id(string jid, string key) { key_ids[get_bare_jid(jid)] = key; }
+ public void set_key_id(Jid jid, string key) { key_ids[jid] = key; }
public override string get_ns() { return NS_URI; }
diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala
index a2b48dd9..a8b821de 100644
--- a/plugins/openpgp/src/stream_module.vala
+++ b/plugins/openpgp/src/stream_module.vala
@@ -1,7 +1,6 @@
using GPG;
using Xmpp;
-using Xmpp.Core;
namespace Dino.Plugins.OpenPgp {
private const string NS_URI = "jabber:x";
@@ -9,9 +8,9 @@ namespace Dino.Plugins.OpenPgp {
private const string NS_URI_SIGNED = NS_URI + ":signed";
public class Module : XmppStreamModule {
- public static Core.ModuleIdentity<Module> IDENTITY = new Core.ModuleIdentity<Module>(NS_URI, "0027_current_pgp_usage");
+ public static Xmpp.ModuleIdentity<Module> IDENTITY = new Xmpp.ModuleIdentity<Module>(NS_URI, "0027_current_pgp_usage");
- public signal void received_jid_key_id(XmppStream stream, string jid, string key_id);
+ public signal void received_jid_key_id(XmppStream stream, Jid jid, string key_id);
private string? signed_status = null;
private Key? own_key = null;
@@ -33,7 +32,7 @@ namespace Dino.Plugins.OpenPgp {
}
}
- public bool encrypt(Message.Stanza message, GPG.Key[] keys) {
+ public bool encrypt(MessageStanza message, GPG.Key[] keys) {
string? enc_body = gpg_encrypt(message.body, keys);
if (enc_body != null) {
message.stanza.put_node(new StanzaNode.build("x", NS_URI_ENCRYPTED).add_self_xmlns().put_node(new StanzaNode.text(enc_body)));
@@ -46,14 +45,14 @@ namespace Dino.Plugins.OpenPgp {
public override void attach(XmppStream stream) {
stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_decrypt_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.connect(received_pipeline_decrypt_listener);
stream.add_flag(new Flag());
}
public override void detach(XmppStream stream) {
stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_decrypt_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.disconnect(received_pipeline_decrypt_listener);
}
public static void require(XmppStream stream) {
@@ -121,12 +120,12 @@ namespace Dino.Plugins.OpenPgp {
}
}
- public class MessageFlag : Message.MessageFlag {
+ public class MessageFlag : Xmpp.MessageFlag {
public const string id = "pgp";
public bool decrypted = false;
- public static MessageFlag? get_flag(Message.Stanza message) {
+ public static MessageFlag? get_flag(MessageStanza message) {
return (MessageFlag) message.get_flag(NS_URI, id);
}
@@ -134,14 +133,14 @@ namespace Dino.Plugins.OpenPgp {
public override string get_id() { return id; }
}
-public class ReceivedPipelineDecryptListener : StanzaListener<Message.Stanza> {
+public class ReceivedPipelineDecryptListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {"MODIFY_BODY"};
public override string action_group { get { return "ENCRYPT_BODY"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
string? encrypted = get_cyphertext(message);
if (encrypted != null) {
MessageFlag flag = new MessageFlag();
@@ -171,7 +170,7 @@ public class ReceivedPipelineDecryptListener : StanzaListener<Message.Stanza> {
return res;
}
- private string? get_cyphertext(Message.Stanza message) {
+ private string? get_cyphertext(MessageStanza message) {
StanzaNode? x_node = message.stanza.get_subnode("x", NS_URI_ENCRYPTED);
return x_node == null ? null : x_node.get_string_content();
}