aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src/file_provider.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-14 19:34:30 +0200
committerfiaxh <git@mx.ax.lt>2017-10-21 23:31:05 +0200
commit8b43df8ec3f92477f857280668a9f29f0b9d6229 (patch)
treebb7d1411e0c3f486d3977e2edad2b701702c2362 /plugins/http-files/src/file_provider.vala
parent9d8e1e88ec61403659a8cc410d5c4414e3bd3a96 (diff)
downloaddino-8b43df8ec3f92477f857280668a9f29f0b9d6229.tar.gz
dino-8b43df8ec3f92477f857280668a9f29f0b9d6229.zip
Handle file uploading in libdino & main, have http upload as provider
Diffstat (limited to 'plugins/http-files/src/file_provider.vala')
-rw-r--r--plugins/http-files/src/file_provider.vala36
1 files changed, 1 insertions, 35 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 69ae9218..d327ec5f 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -5,7 +5,7 @@ using Dino.Entities;
namespace Dino.Plugins.HttpFiles {
-public class FileProvider : Plugins.FileProvider, Object {
+public class FileProvider : Dino.FileProvider, Object {
public string id { get { return "http"; } }
private StreamInteractor stream_interactor;
@@ -19,15 +19,8 @@ public class FileProvider : Plugins.FileProvider, Object {
this.url_regex = new Regex("""^(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$""");
this.file_ext_regex = new Regex("""\.(png|jpg|jpeg|svg|gif)""");
- Application app = GLib.Application.get_default() as Application;
- app.plugin_registry.register_message_display(new FileMessageFilterDisplay(dino_db));
-
stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(check_message);
stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(check_message);
- stream_interactor.get_module(Manager.IDENTITY).uploading.connect((file_transfer) => {
- file_transfer.provider = 0;
- file_incoming(file_transfer);
- });
stream_interactor.get_module(Manager.IDENTITY).uploaded.connect((file_transfer, url) => {
file_transfer.info = url;
ignore_once.add(url);
@@ -77,31 +70,4 @@ public class FileProvider : Plugins.FileProvider, Object {
}
}
-public class FileMessageFilterDisplay : Plugins.MessageDisplayProvider, Object {
- public string id { get; set; default="file_message_filter"; }
- public double priority { get; set; default=10; }
-
- public Database db;
-
- public FileMessageFilterDisplay(Dino.Database db) {
- this.db = db;
- }
-
- public bool can_display(Entities.Message? message) {
- return message_is_file(message);
- }
-
- public Plugins.MetaConversationItem? get_item(Entities.Message message, Conversation conversation) {
- return null;
- }
-
- private bool message_is_file(Entities.Message message) {
- Qlite.QueryBuilder builder = db.file_transfer.select()
- .with(db.file_transfer.info, "=", message.body)
- .with(db.file_transfer.account_id, "=", message.account.id)
- .with(db.file_transfer.counterpart_id, "=", db.get_jid_id(message.counterpart));
- return builder.count() > 0;
- }
-}
-
}