diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | libdino/src/service/connection_manager.vala | 2 | ||||
-rw-r--r-- | plugins/http-files/src/contact_titlebar_entry.vala | 4 | ||||
-rw-r--r-- | plugins/http-files/src/file_provider.vala | 9 | ||||
-rw-r--r-- | plugins/http-files/src/manager.vala | 4 | ||||
-rw-r--r-- | plugins/http-files/src/upload_stream_module.vala | 10 | ||||
-rw-r--r-- | xmpp-vala/src/core/xmpp_stream.vala | 2 | ||||
-rw-r--r-- | xmpp-vala/src/module/iq/module.vala | 5 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 6 |
9 files changed, 26 insertions, 18 deletions
@@ -1,7 +1,7 @@ ![Dino](https://cdn.rawgit.com/fiaxh/3cb1391c5a94443098d004b4bf7c712c/raw/62f6a5e7de8402a0a89ffc73e8d1ed170054051c/dino-writing.svg) ======= -![screenshots](https://i.imgur.com/xIKPEFF.png) +![screenshots](https://i.imgur.com/1KqLqDV.png) Build ----- diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala index 2be16a21..f9dbb0e1 100644 --- a/libdino/src/service/connection_manager.vala +++ b/libdino/src/service/connection_manager.vala @@ -145,7 +145,7 @@ public class ConnectionManager { private Core.XmppStream? connect_(Account account, string? resource = null) { if (!connection_mutexes[account].trylock()) return null; - if (connections.has_key(account)) connections[account].stream.remove_modules(); + if (connections.has_key(account)) connections[account].stream.detach_modules(); connection_errors.unset(account); if (resource == null) resource = account.resourcepart; diff --git a/plugins/http-files/src/contact_titlebar_entry.vala b/plugins/http-files/src/contact_titlebar_entry.vala index 3fd8ee39..e5b82abe 100644 --- a/plugins/http-files/src/contact_titlebar_entry.vala +++ b/plugins/http-files/src/contact_titlebar_entry.vala @@ -38,8 +38,8 @@ public class ConversationTitlebarWidget : Button, Plugins.ConversationTitlebarWi FileChooserNative chooser = new FileChooserNative ( "Select file", get_toplevel() as Window, FileChooserAction.OPEN, "Select", "Cancel"); - int? max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account); - if (max_file_size != null) { + long max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account); + if (max_file_size != -1) { FileFilter filter = new FileFilter(); filter.add_custom(FileFilterFlags.URI, (filter_info) => { File file = File.new_for_uri(filter_info.uri); diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index b4a69ddb..69ae9218 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -36,7 +36,8 @@ public class FileProvider : Plugins.FileProvider, Object { public void check_message(Message message, Conversation conversation) { if (ignore_once.remove(message.body)) return; - bool in_roster = stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(conversation.account, conversation.counterpart) != null; + Jid relevant_jid = stream_interactor.get_module(MucManager.IDENTITY).get_real_jid(message.from, conversation.account) ?? conversation.counterpart; + bool in_roster = stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(conversation.account, relevant_jid) != null; if (message.direction == Message.DIRECTION_RECEIVED && !in_roster) return; if (message.body.length < 5) return; if (!url_regex.match(message.body)) return; @@ -57,11 +58,11 @@ public class FileProvider : Plugins.FileProvider, Object { Soup.Request request = session.request (message.body); FileTransfer file_transfer = new FileTransfer(); file_transfer.account = conversation.account; - file_transfer.counterpart = conversation.counterpart; + file_transfer.counterpart = message.counterpart; file_transfer.ourpart = message.ourpart; file_transfer.encryption = Encryption.NONE; - file_transfer.time = new DateTime.now_utc(); - file_transfer.local_time = new DateTime.now_utc(); + file_transfer.time = message.time; + file_transfer.local_time = message.local_time; file_transfer.direction = message.direction; file_transfer.input_stream = request.send(); file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1); diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala index 14c190af..b1b7296c 100644 --- a/plugins/http-files/src/manager.vala +++ b/plugins/http-files/src/manager.vala @@ -13,7 +13,7 @@ public class Manager : StreamInteractionModule, Object { public signal void uploaded(FileTransfer file_transfer, string url); private StreamInteractor stream_interactor; - private HashMap<Account, int?> max_file_sizes = new HashMap<Account, int?>(Account.hash_func, Account.equals_func); + private HashMap<Account, long> max_file_sizes = new HashMap<Account, long>(Account.hash_func, Account.equals_func); private Manager(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; @@ -60,7 +60,7 @@ public class Manager : StreamInteractionModule, Object { } } - public int? get_max_file_size(Account account) { + public long get_max_file_size(Account account) { lock (max_file_sizes) { return max_file_sizes[account]; } diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala index db2e655b..c4fa3d2f 100644 --- a/plugins/http-files/src/upload_stream_module.vala +++ b/plugins/http-files/src/upload_stream_module.vala @@ -10,7 +10,7 @@ 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 signal void feature_available(XmppStream stream, int? max_file_size); + public signal void feature_available(XmppStream stream, long max_file_size); public delegate void OnUploadOk(XmppStream stream, string url_down); public delegate void OnError(XmppStream stream, string error); @@ -122,7 +122,7 @@ public class UploadStreamModule : XmppStreamModule { } if (ver_available || ver_0_available) { - int? max_file_size = extract_max_file_size(info_result); + long max_file_size = extract_max_file_size(info_result); if (ver_0_available) { stream.add_flag(new Flag(jid, NS_URI_0)); } else if (ver_available) { @@ -135,7 +135,7 @@ public class UploadStreamModule : XmppStreamModule { return false; } - private int? extract_max_file_size(Xep.ServiceDiscovery.InfoResult info_result) { + private long extract_max_file_size(Xep.ServiceDiscovery.InfoResult info_result) { string? max_file_size_str = null; StanzaNode x_node = info_result.iq.stanza.get_deep_subnode("http://jabber.org/protocol/disco#info:query", "jabber:x:data:x"); Gee.List<StanzaNode> field_nodes = x_node.get_subnodes("field", "jabber:x:data"); @@ -147,8 +147,8 @@ public class UploadStreamModule : XmppStreamModule { break; } } - if (max_file_size_str != null) return int.parse(max_file_size_str); - return null; + if (max_file_size_str != null) return long.parse(max_file_size_str); + return -1; } } diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala index 6bb66445..9d700b4d 100644 --- a/xmpp-vala/src/core/xmpp_stream.vala +++ b/xmpp-vala/src/core/xmpp_stream.vala @@ -149,7 +149,7 @@ public class XmppStream { return this; } - public void remove_modules() { + public void detach_modules() { foreach (XmppStreamModule module in modules) module.detach(this); } diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala index 088519ff..c19cc2e5 100644 --- a/xmpp-vala/src/module/iq/module.vala +++ b/xmpp-vala/src/module/iq/module.vala @@ -30,6 +30,11 @@ namespace Xmpp.Iq { namespaceRegistrants[namespace].add(module); } + public void unregister_from_namespace(string namespace, Handler module) { + ArrayList<Handler>? handlers = namespaceRegistrants[namespace]; + if (handlers != null) handlers.remove(module); + } + public override void attach(XmppStream stream) { stream.received_iq_stanza.connect(on_received_iq_stanza); } diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala index 4d7a3245..011a1f36 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -71,12 +71,14 @@ public class Module : XmppStreamModule, Iq.Handler { public void on_iq_set(XmppStream stream, Iq.Stanza iq) { } public override void attach(XmppStream stream) { - stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this); stream.add_flag(new Flag()); + stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this); add_feature(stream, NS_URI_INFO); } - public override void detach(XmppStream stream) { } + public override void detach(XmppStream stream) { + stream.get_module(Iq.Module.IDENTITY).unregister_from_namespace(NS_URI_INFO, this); + } public static void require(XmppStream stream) { if (stream.get_module(IDENTITY) == null) stream.add_module(new ServiceDiscovery.Module()); |