aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src/contact_titlebar_entry.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/contact_titlebar_entry.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/contact_titlebar_entry.vala')
-rw-r--r--plugins/http-files/src/contact_titlebar_entry.vala72
1 files changed, 0 insertions, 72 deletions
diff --git a/plugins/http-files/src/contact_titlebar_entry.vala b/plugins/http-files/src/contact_titlebar_entry.vala
deleted file mode 100644
index e5b82abe..00000000
--- a/plugins/http-files/src/contact_titlebar_entry.vala
+++ /dev/null
@@ -1,72 +0,0 @@
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Plugins.HttpFiles {
-
-public class ConversationsTitlebarEntry : Plugins.ConversationTitlebarEntry, Object {
- public string id { get { return "send_files"; } }
-
- StreamInteractor stream_interactor;
-
- public ConversationsTitlebarEntry(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
- }
-
- public double order { get { return 4; } }
- public Plugins.ConversationTitlebarWidget get_widget(WidgetType type) {
- if (type == WidgetType.GTK) {
- return new ConversationTitlebarWidget(stream_interactor) { visible=true };
- }
- return null;
- }
-}
-
-public class ConversationTitlebarWidget : Button, Plugins.ConversationTitlebarWidget {
-
- private Conversation? conversation;
- private StreamInteractor stream_interactor;
-
- public ConversationTitlebarWidget(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
- image = new Image.from_icon_name("mail-attachment-symbolic", IconSize.MENU);
- clicked.connect(on_clicked);
- stream_interactor.get_module(Manager.IDENTITY).upload_available.connect(on_upload_available);
- }
-
- public void on_clicked() {
- FileChooserNative chooser = new FileChooserNative (
- "Select file", get_toplevel() as Window, FileChooserAction.OPEN,
- "Select", "Cancel");
- 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);
- FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
- return file_info.get_size() <= max_file_size;
- });
- chooser.set_filter(filter);
- }
- if (chooser.run() == Gtk.ResponseType.ACCEPT) {
- string uri = chooser.get_filename();
- stream_interactor.get_module(Manager.IDENTITY).send(conversation, uri);
- }
- }
-
- public void on_upload_available(Account account) {
- Idle.add(() => {
- if (conversation != null && conversation.account.equals(account)) {
- visible = true;
- }
- return false;
- });
- }
-
- public new void set_conversation(Conversation conversation) {
- this.conversation = conversation;
- visible = stream_interactor.get_module(Manager.IDENTITY).is_upload_available(conversation.account);
- }
-}
-
-}