aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/manager.vala
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/omemo/src/manager.vala
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'plugins/omemo/src/manager.vala')
-rw-r--r--plugins/omemo/src/manager.vala46
1 files changed, 23 insertions, 23 deletions
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) {