diff --git a/README.md b/README.md index 1c8bb82..fdade9a 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,11 @@ You'll need some dependencies to build: And you'll need these to actually run [magic-wormhole](https://github.com/warner/magic-wormhole): * build-essential -* python-pip -* python-dev * libffi-dev * libssl-dev +* python-pip +* python-dev +* zip Run these commands to configure the build environment: diff --git a/data/com.github.bleakgrey.transporter.appdata.xml.in b/data/com.github.bleakgrey.transporter.appdata.xml.in index 8cfb40e..7771c23 100644 --- a/data/com.github.bleakgrey.transporter.appdata.xml.in +++ b/data/com.github.bleakgrey.transporter.appdata.xml.in @@ -28,9 +28,24 @@ https://raw.githubusercontent.com/bleakgrey/transporter/master/data/screenshot.png + + https://raw.githubusercontent.com/bleakgrey/transporter/master/data/screenshot2.png + + + https://raw.githubusercontent.com/bleakgrey/transporter/master/data/screenshot3.png + + + ​ + ​
    +
  • Folders and multiple files support
  • +
  • Improved UI
  • +
  • Updated locales
  • +
+ ​
+ ​
    diff --git a/data/screenshot.png b/data/screenshot.png index 95d07d4..eecf872 100644 Binary files a/data/screenshot.png and b/data/screenshot.png differ diff --git a/data/screenshot2.png b/data/screenshot2.png new file mode 100644 index 0000000..0000a6a Binary files /dev/null and b/data/screenshot2.png differ diff --git a/data/screenshot3.png b/data/screenshot3.png new file mode 100644 index 0000000..b2beda8 Binary files /dev/null and b/data/screenshot3.png differ diff --git a/debian/changelog b/debian/changelog index 8bf5704..e9e1c54 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ -transporter (1.1.1) xenial; urgency=low +transporter (1.2.0) xenial; urgency=low * Minor UI tweaks * Corrected typos - -- Glushchenko Artyom Tue, 27 Feb 2018 10:00:00 -0500 \ No newline at end of file + -- bleak_grey Tue, 27 Feb 2018 10:00:00 -0500 \ No newline at end of file diff --git a/debian/control b/debian/control index c8f28de..6fb10d1 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: com.github.bleakgrey.transporter Section: x11 Priority: extra -Maintainer: Glushchenko Artyom +Maintainer: bleak_grey Build-Depends: meson, libgranite-dev, debhelper (>= 9), @@ -12,6 +12,6 @@ Standards-Version: 3.9.3 Package: com.github.bleakgrey.transporter Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends}, python-pip, build-essential, python-dev, libffi-dev, libssl-dev +Depends: ${misc:Depends}, ${shlibs:Depends}, python-pip, build-essential, python-dev, libffi-dev, libssl-dev, zip Description: Simple file transfer A magic-wormhole client that makes file transfer between computers a breeze. diff --git a/debian/copyright b/debian/copyright index f667107..0f47082 100644 --- a/debian/copyright +++ b/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: transporter Source: https://github.com/bleakgrey/transporter Files: * -Copyright: 2013 elementary LLC. +Copyright: 2018 bleak_grey License: GPL-3.0+ License: GPL-3.0+ diff --git a/meson.build b/meson.build index f32b998..09e4383 100644 --- a/meson.build +++ b/meson.build @@ -13,11 +13,13 @@ executable( 'src/Transporter.vala', 'src/TransporterWindow.vala', 'src/Settings.vala', + 'src/Utils.vala', 'src/WormholeInterface.vala', 'src/View/InstallView.vala', + 'src/View/WelcomeView.vala', 'src/View/ReceiveView.vala', 'src/View/SendView.vala', - 'src/View/WelcomeView.vala', + 'src/View/DropView.vala', 'src/View/SettingsView.vala', dependencies: [ dependency('gtk+-3.0'), diff --git a/po/POTFILES b/po/POTFILES index a9d7eb3..4fa61a6 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -5,4 +5,5 @@ src/View/InstallView.vala src/View/ReceiveView.vala src/View/SendView.vala src/View/WelcomeView.vala -src/View/SettingsView.vala \ No newline at end of file +src/View/SettingsView.vala +src/View/DropView.vala \ No newline at end of file diff --git a/po/com.github.bleakgrey.transporter.pot b/po/com.github.bleakgrey.transporter.pot index acd7897..0c26a4c 100644 --- a/po/com.github.bleakgrey.transporter.pot +++ b/po/com.github.bleakgrey.transporter.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: com.github.bleakgrey.transporter\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-11 15:05+0300\n" +"POT-Creation-Date: 2018-03-14 16:26+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,103 +17,102 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/TransporterWindow.vala:52 +#: src/TransporterWindow.vala:51 msgid "Back" msgstr "" -#: src/TransporterWindow.vala:57 +#: src/TransporterWindow.vala:56 msgid "Settings" msgstr "" -#: src/TransporterWindow.vala:91 +#: src/TransporterWindow.vala:90 msgid "Are you sure you want to cancel transaction?" msgstr "" -#: src/TransporterWindow.vala:135 -msgid "Select files or a folder to send" -msgstr "" - -#: src/TransporterWindow.vala:138 -msgid "_Cancel" -msgstr "" - -#: src/TransporterWindow.vala:140 -msgid "_Open" -msgstr "" - #: src/WormholeInterface.vala:8 msgid "Error" msgstr "" -#: src/WormholeInterface.vala:64 src/WormholeInterface.vala:71 +#: src/WormholeInterface.vala:66 src/WormholeInterface.vala:73 msgid "Installation Error" msgstr "" -#: src/WormholeInterface.vala:71 +#: src/WormholeInterface.vala:73 msgid "Couldn't install magic-wormhole automatically." msgstr "" -#: src/WormholeInterface.vala:193 +#: src/WormholeInterface.vala:195 msgid "Please verify your ID and try again." msgstr "" -#: src/WormholeInterface.vala:193 +#: src/WormholeInterface.vala:195 msgid "Invalid ID" msgstr "" -#: src/WormholeInterface.vala:198 +#: src/WormholeInterface.vala:200 msgid "Server is crowded at the moment. " msgstr "" -#: src/WormholeInterface.vala:198 src/WormholeInterface.vala:213 +#: src/WormholeInterface.vala:200 src/WormholeInterface.vala:215 msgid "Server Error" msgstr "" -#: src/WormholeInterface.vala:203 src/WormholeInterface.vala:208 +#: src/WormholeInterface.vala:205 src/WormholeInterface.vala:210 msgid "Received file already exists in Downloads folder." msgstr "" -#: src/WormholeInterface.vala:203 src/WormholeInterface.vala:208 -msgid "File Conflict" +#: src/WormholeInterface.vala:205 src/WormholeInterface.vala:210 +#: src/WormholeInterface.vala:220 src/WormholeInterface.vala:225 +msgid "I/O Error" msgstr "" -#: src/WormholeInterface.vala:213 +#: src/WormholeInterface.vala:215 msgid "Relay server unresponsive." msgstr "" -#: src/View/InstallView.vala:11 +#: src/WormholeInterface.vala:220 +msgid "" +"Please make sure selected files do not contain special characters in their " +"paths and names." +msgstr "" + +#: src/WormholeInterface.vala:225 +msgid "Archive creation failed, perhaps your disk is running out of space." +msgstr "" + +#: src/View/InstallView.vala:8 msgid "Preparing Transporter" msgstr "" -#: src/View/InstallView.vala:12 +#: src/View/InstallView.vala:9 msgid "Installing magic-wormhole" msgstr "" -#: src/View/ReceiveView.vala:11 +#: src/View/ReceiveView.vala:13 msgid "Enter Transfer ID" msgstr "" -#: src/View/ReceiveView.vala:16 +#: src/View/ReceiveView.vala:18 msgid "Ask the sender to share it" msgstr "" -#: src/View/ReceiveView.vala:74 src/View/SendView.vala:33 +#: src/View/ReceiveView.vala:77 src/View/SendView.vala:33 msgid "Transfer Complete" msgstr "" -#: src/View/ReceiveView.vala:75 +#: src/View/ReceiveView.vala:78 msgid "Saved in your Downloads folder" msgstr "" -#: src/View/ReceiveView.vala:81 +#: src/View/ReceiveView.vala:84 msgid "Connection closed unexpectedly." msgstr "" -#: src/View/ReceiveView.vala:84 +#: src/View/ReceiveView.vala:87 msgid "Transferring: " msgstr "" -#: src/View/ReceiveView.vala:85 +#: src/View/ReceiveView.vala:88 msgid "Please wait a moment" msgstr "" @@ -137,58 +136,70 @@ msgstr "" msgid "Connection has been closed" msgstr "" -#: src/View/WelcomeView.vala:6 +#: src/View/WelcomeView.vala:7 msgid "Welcome to Transporter" msgstr "" -#: src/View/WelcomeView.vala:6 +#: src/View/WelcomeView.vala:7 msgid "What would you like to do?" msgstr "" -#: src/View/WelcomeView.vala:7 +#: src/View/WelcomeView.vala:8 msgid "Send Files" msgstr "" -#: src/View/WelcomeView.vala:7 +#: src/View/WelcomeView.vala:8 msgid "Upload data to another computer" msgstr "" -#: src/View/WelcomeView.vala:8 +#: src/View/WelcomeView.vala:9 msgid "Receive Files" msgstr "" -#: src/View/WelcomeView.vala:8 +#: src/View/WelcomeView.vala:9 msgid "Download data from another computer" msgstr "" -#: src/View/WelcomeView.vala:9 +#: src/View/WelcomeView.vala:10 msgid "Show Downloads" msgstr "" -#: src/View/WelcomeView.vala:9 +#: src/View/WelcomeView.vala:10 msgid "Open your Downloads folder" msgstr "" -#: src/View/SettingsView.vala:10 +#: src/View/SettingsView.vala:9 msgid "Servers" msgstr "" -#: src/View/SettingsView.vala:11 -msgid "Relay Server:" +#: src/View/SettingsView.vala:10 +msgid "Relay:" msgstr "" -#: src/View/SettingsView.vala:13 -msgid "Transit Server:" +#: src/View/SettingsView.vala:12 +msgid "Transit:" msgstr "" -#: src/View/SettingsView.vala:16 +#: src/View/SettingsView.vala:15 msgid "Miscellaneous" msgstr "" -#: src/View/SettingsView.vala:17 -msgid "ID Word Length:" +#: src/View/SettingsView.vala:16 +msgid "ID Length:" +msgstr "" + +#: src/View/SettingsView.vala:20 +msgid "Sounds:" +msgstr "" + +#: src/View/DropView.vala:16 +msgid "Drag files and folders here" +msgstr "" + +#: src/View/DropView.vala:17 +msgid "Drop to send" msgstr "" -#: src/View/SettingsView.vala:21 -msgid "Play Sounds:" +#: src/View/DropView.vala:93 +msgid "Internal Error" msgstr "" diff --git a/po/ru.po b/po/ru.po index a007757..d5fff1e 100644 --- a/po/ru.po +++ b/po/ru.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: com.github.bleakgrey.transporter\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-11 15:05+0300\n" +"POT-Creation-Date: 2018-03-14 16:26+0300\n" "PO-Revision-Date: 2018-02-28 15:36+0300\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -18,106 +18,108 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -#: src/TransporterWindow.vala:52 +#: src/TransporterWindow.vala:51 msgid "Back" msgstr "Назад" -#: src/TransporterWindow.vala:57 +#: src/TransporterWindow.vala:56 msgid "Settings" msgstr "Настройки" -#: src/TransporterWindow.vala:91 +#: src/TransporterWindow.vala:90 msgid "Are you sure you want to cancel transaction?" msgstr "Вы уверены, что хотите отменить передачу?" -#: src/TransporterWindow.vala:135 -msgid "Select files or a folder to send" -msgstr "Выберите файлы или папку для отправки" - -#: src/TransporterWindow.vala:138 -msgid "_Cancel" -msgstr "_Отменить" - -#: src/TransporterWindow.vala:140 -msgid "_Open" -msgstr "_Выбрать" - #: src/WormholeInterface.vala:8 msgid "Error" msgstr "Ошибка" -#: src/WormholeInterface.vala:64 src/WormholeInterface.vala:71 +#: src/WormholeInterface.vala:66 src/WormholeInterface.vala:73 msgid "Installation Error" msgstr "Ошибка Установки" -#: src/WormholeInterface.vala:71 +#: src/WormholeInterface.vala:73 #, fuzzy msgid "Couldn't install magic-wormhole automatically." msgstr "Установить magic-wormhole автоматически не получилось." -#: src/WormholeInterface.vala:193 +#: src/WormholeInterface.vala:195 msgid "Please verify your ID and try again." msgstr "Пожалуйста, проверьте написание ID и попробуйте снова." -#: src/WormholeInterface.vala:193 +#: src/WormholeInterface.vala:195 msgid "Invalid ID" msgstr "Неправильный ID" -#: src/WormholeInterface.vala:198 +#: src/WormholeInterface.vala:200 msgid "Server is crowded at the moment. " msgstr "Сервер на данный момент перегружен." -#: src/WormholeInterface.vala:198 src/WormholeInterface.vala:213 +#: src/WormholeInterface.vala:200 src/WormholeInterface.vala:215 msgid "Server Error" msgstr "Ошибка Сервера" -#: src/WormholeInterface.vala:203 src/WormholeInterface.vala:208 +#: src/WormholeInterface.vala:205 src/WormholeInterface.vala:210 #, fuzzy msgid "Received file already exists in Downloads folder." msgstr "Сохранена в вашей папке Загрузок" -#: src/WormholeInterface.vala:203 src/WormholeInterface.vala:208 -msgid "File Conflict" -msgstr "Конфликт Файлов" +#: src/WormholeInterface.vala:205 src/WormholeInterface.vala:210 +#: src/WormholeInterface.vala:220 src/WormholeInterface.vala:225 +#, fuzzy +msgid "I/O Error" +msgstr "Файловая Ошибка" -#: src/WormholeInterface.vala:213 +#: src/WormholeInterface.vala:215 msgid "Relay server unresponsive." msgstr "Сервер-ретранслятор не отвечает." -#: src/View/InstallView.vala:11 +#: src/WormholeInterface.vala:220 +msgid "" +"Please make sure selected files do not contain special characters in their " +"paths and names." +msgstr "Пожалуйста, убедитесь, что имена файлов не содержат запрещённые знаки." + +#: src/WormholeInterface.vala:225 +msgid "Archive creation failed, perhaps your disk is running out of space." +msgstr "" +"Не получилось упаковать файлы. Возможно, у вас кончается свободное место на " +"диске." + +#: src/View/InstallView.vala:8 msgid "Preparing Transporter" msgstr "Подготовка Transporter" -#: src/View/InstallView.vala:12 +#: src/View/InstallView.vala:9 msgid "Installing magic-wormhole" msgstr "Установка magic-wormhole" -#: src/View/ReceiveView.vala:11 +#: src/View/ReceiveView.vala:13 msgid "Enter Transfer ID" msgstr "Введите ID Передачи" -#: src/View/ReceiveView.vala:16 +#: src/View/ReceiveView.vala:18 msgid "Ask the sender to share it" msgstr "Спросите его у отправителя" -#: src/View/ReceiveView.vala:74 src/View/SendView.vala:33 +#: src/View/ReceiveView.vala:77 src/View/SendView.vala:33 msgid "Transfer Complete" msgstr "Передача Завершена" -#: src/View/ReceiveView.vala:75 +#: src/View/ReceiveView.vala:78 msgid "Saved in your Downloads folder" msgstr "Сохранена в вашей папке Загрузок" -#: src/View/ReceiveView.vala:81 +#: src/View/ReceiveView.vala:84 #, fuzzy msgid "Connection closed unexpectedly." msgstr "Соединение неожиданно разорвано." -#: src/View/ReceiveView.vala:84 +#: src/View/ReceiveView.vala:87 msgid "Transferring: " msgstr "Передача: " -#: src/View/ReceiveView.vala:85 +#: src/View/ReceiveView.vala:88 msgid "Please wait a moment" msgstr "Пожалуйста, подождите" @@ -141,60 +143,76 @@ msgstr "Поделитесь им с получателем" msgid "Connection has been closed" msgstr "Соединение было закрыто" -#: src/View/WelcomeView.vala:6 +#: src/View/WelcomeView.vala:7 msgid "Welcome to Transporter" msgstr "Добро пожаловать в Transporter" -#: src/View/WelcomeView.vala:6 +#: src/View/WelcomeView.vala:7 msgid "What would you like to do?" msgstr "Что вы хотите сделать?" -#: src/View/WelcomeView.vala:7 +#: src/View/WelcomeView.vala:8 msgid "Send Files" -msgstr "Отправить файлы" +msgstr "Отправить Файлы" -#: src/View/WelcomeView.vala:7 +#: src/View/WelcomeView.vala:8 msgid "Upload data to another computer" msgstr "Загрузить данные на другой компьютер" -#: src/View/WelcomeView.vala:8 +#: src/View/WelcomeView.vala:9 msgid "Receive Files" -msgstr "Получить файлы" +msgstr "Получить Файлы" -#: src/View/WelcomeView.vala:8 +#: src/View/WelcomeView.vala:9 msgid "Download data from another computer" msgstr "Скачать данные с другого компьютера" -#: src/View/WelcomeView.vala:9 +#: src/View/WelcomeView.vala:10 msgid "Show Downloads" msgstr "Показать Загрузки" -#: src/View/WelcomeView.vala:9 +#: src/View/WelcomeView.vala:10 msgid "Open your Downloads folder" msgstr "Открыть вашу папку Загрузок" -#: src/View/SettingsView.vala:10 +#: src/View/SettingsView.vala:9 #, fuzzy msgid "Servers" msgstr "Серверы" -#: src/View/SettingsView.vala:11 -msgid "Relay Server:" -msgstr "Сервер-ретранслятор:" +#: src/View/SettingsView.vala:10 +#, fuzzy +msgid "Relay:" +msgstr "Ретранслятор:" -#: src/View/SettingsView.vala:13 +#: src/View/SettingsView.vala:12 #, fuzzy -msgid "Transit Server:" -msgstr "Сервер-передатчик:" +msgid "Transit:" +msgstr "Передатчик:" -#: src/View/SettingsView.vala:16 +#: src/View/SettingsView.vala:15 msgid "Miscellaneous" msgstr "Разное" -#: src/View/SettingsView.vala:17 -msgid "ID Word Length:" -msgstr "Кол-во слов в ID:" +#: src/View/SettingsView.vala:16 +#, fuzzy +msgid "ID Length:" +msgstr "Слов в ID:" + +#: src/View/SettingsView.vala:20 +#, fuzzy +msgid "Sounds:" +msgstr "Звуки:" -#: src/View/SettingsView.vala:21 -msgid "Play Sounds:" -msgstr "Проигрывать звуки:" +#: src/View/DropView.vala:16 +msgid "Drag files and folders here" +msgstr "Перетащите сюда файлы и папки" + +#: src/View/DropView.vala:17 +msgid "Drop to send" +msgstr "Отпустите для отправки" + +#: src/View/DropView.vala:93 +#, fuzzy +msgid "Internal Error" +msgstr "Ошибка" diff --git a/src/Transporter.vala b/src/Transporter.vala index 8237a85..7a67c65 100644 --- a/src/Transporter.vala +++ b/src/Transporter.vala @@ -10,7 +10,7 @@ public class Transporter : Granite.Application { application_id = "com.github.bleakgrey.transporter"; flags = ApplicationFlags.FLAGS_NONE; program_name = "Transporter"; - build_version = "1.1.1"; + build_version = "1.2.0"; } public static int main (string[] args) { diff --git a/src/TransporterWindow.vala b/src/TransporterWindow.vala index 2a882fe..ec0fcb9 100644 --- a/src/TransporterWindow.vala +++ b/src/TransporterWindow.vala @@ -7,7 +7,7 @@ public class TransporterWindow: Gtk.Dialog { Button settings_button; Spinner spinner; - Widget currScreen; + Widget current_screen; Widget[] screens; public WormholeInterface wormhole; @@ -16,11 +16,9 @@ public class TransporterWindow: Gtk.Dialog { Object (application: application, icon_name: "com.github.bleakgrey.transporter", title: "Transporter", - resizable: false, - width_request: 470, - height_request: 470 + resizable: false ); - this.wormhole = new WormholeInterface(); + this.wormhole = new WormholeInterface (); this.window_position = WindowPosition.CENTER; this.set_titlebar (headerbar); @@ -38,13 +36,14 @@ public class TransporterWindow: Gtk.Dialog { }); if(wormhole.bin_present ()) - addScreen(new WelcomeView (this)); + addScreen (new WelcomeView (this)); else - addScreen(new InstallView (this, wormhole)); + addScreen (new InstallView (this)); } construct{ get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + get_content_area ().set_size_request (400, 400); spinner = new Gtk.Spinner (); spinner.active = true; @@ -67,22 +66,22 @@ public class TransporterWindow: Gtk.Dialog { headerbar.show (); } - private void updateWindow(){ - back_button.visible = !(currScreen is WelcomeView) && screens.length > 1; - settings_button.visible = currScreen is WelcomeView; + private void update_header(){ + back_button.visible = !(current_screen is WelcomeView) && screens.length > 1; + settings_button.visible = current_screen is WelcomeView; } public void addScreen(Widget screen){ var box = get_content_area () as Gtk.Box; - if(screens.length > 0 && currScreen != null) - box.remove (currScreen); + if(screens.length > 0 && current_screen != null) + box.remove (current_screen); screens += screen; - currScreen = screen; - box.add (currScreen); - currScreen.show (); - updateWindow (); + current_screen = screen; + box.add (current_screen); + current_screen.show (); + update_header (); } public void prevScreen(){ @@ -113,33 +112,22 @@ public class TransporterWindow: Gtk.Dialog { return; var box = get_content_area () as Gtk.Box; - box.remove (currScreen); + box.remove (current_screen); screens.resize (screens.length - 1); - currScreen = screens[screens.length - 1]; - box.add (currScreen); - currScreen.show (); - updateWindow (); + current_screen.destroy(); + current_screen = screens[screens.length - 1]; + box.add (current_screen); + current_screen.show (); + update_header (); } public void replaceScreen(Widget screen){ var box = get_content_area () as Gtk.Box; - box.remove (currScreen); - currScreen = null; + box.remove (current_screen); + current_screen = null; screens = {}; addScreen (screen); } - public Gtk.FileChooserDialog getFileChooser(){ - return new Gtk.FileChooserDialog ( - _("Select files or a folder to send"), - this, - Gtk.FileChooserAction.OPEN, - _("_Cancel"), - Gtk.ResponseType.CANCEL, - _("_Open"), - Gtk.ResponseType.ACCEPT - ); - } - } \ No newline at end of file diff --git a/src/Utils.vala b/src/Utils.vala new file mode 100644 index 0000000..e96e775 --- /dev/null +++ b/src/Utils.vala @@ -0,0 +1,97 @@ +public class Utils{ + + private const string dir = "/tmp/Transporter"; + private static string zip = null; + + public static string get_send_path(string[] uris){ + int files = 0; + int dirs = 0; + string[] paths = {}; + + foreach (string uri in uris) { + var path = GLib.Filename.from_uri(uri); + paths += path; + + if(is_directory (path)) + dirs++; + else + files++; + } + + info("Sending %d files and %d directories".printf(files, dirs)); + + if(uris.length == 1 && files == 1) + return paths[0]; + else if(uris.length == 1 && dirs == 1) + return paths[0]; + else + return get_archive_path(paths); + } + + public static bool is_directory(string path){ + string stdout = ""; + Process.spawn_sync ( + "/", + {"file", "-b", "--mime-type", path}, + Environ.get (), + SpawnFlags.SEARCH_PATH, + null, + out stdout, + null, + null); + + return "directory" in stdout; + } + + // magic-wormhole doesn't support multiple file sending or + // when directory contains symlinks to other directories. + // + // That's why we have to create an archive. + private static string get_archive_path(string[] paths){ + info ("Preparing zip file at: "+dir); + clean_temp(); + + //Create temp folder + zip = "Transfer-" + new GLib.DateTime.now_local ().to_unix ().to_string (); + var zip_path = "%s/%s".printf(dir, zip); + try{ + Process.spawn_command_line_sync ("mkdir " + dir); + } + catch(GLib.SpawnError e){ + warning(e.message); + } + + //Create symlinks for each file + foreach (string path in paths) { + info ("Linking: " + path); + Process.spawn_sync ( + dir, {"ln", "-s", path}, + Environ.get (), + SpawnFlags.SEARCH_PATH, null, null, null, null); + } + + //Zip them up + Process.spawn_sync ( + dir, + {"zip", "-r", zip+".zip", "."}, + Environ.get (), + SpawnFlags.SEARCH_PATH, + null, + null, + null, + null); + + return zip_path+".zip"; + } + + public static void clean_temp(){ + info("Cleaning up temporary files"); + try{ + Process.spawn_command_line_sync ("rm -rf "+dir); + } + catch(GLib.SpawnError e){ + warning(e.message); + } + } + +} \ No newline at end of file diff --git a/src/View/DropView.vala b/src/View/DropView.vala new file mode 100644 index 0000000..c576fbf --- /dev/null +++ b/src/View/DropView.vala @@ -0,0 +1,97 @@ +using Gtk; +using Gdk; + +public class DropView : Gtk.Box { + + private const string STYLE = """ + .drop{ + border: 2px dashed rgba(0,0,0,.25); + border-radius: 5px; + padding: 32px; + } + """; + private const Gtk.TargetEntry[] targets = { + {"text/uri-list",0,0} + }; + private const string DRAG_TEXT = _("Drag files and folders here"); + private const string DROP_TEXT = _("Drop to send"); + + private Gtk.Label title; + + protected TransporterWindow window; + protected WormholeInterface wormhole; + + construct { + Granite.Widgets.Utils.set_theming_for_screen ( + get_screen(), + STYLE, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + border_width = 10; + + var drop = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + drop.hexpand = true; + drop.vexpand = true; + drop.get_style_context().add_class("drop"); + + title = new Gtk.Label (DRAG_TEXT); + title.get_style_context ().add_class ("h2"); + title.hexpand = true; + title.vexpand = true; + drop.add (title); + + add (drop); + show_all (); + + Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY); + drag_motion.connect (this.on_drag_motion); + drag_leave.connect (this.on_drag_leave); + drag_data_received.connect (this.on_drag_data_received); + } + + public DropView(TransporterWindow window){ + this.window = window; + this.wormhole = window.wormhole; + + wormhole.closed.connect(() => title.label = DRAG_TEXT); + } + + private bool on_drag_motion (DragContext context, int x, int y, uint time){ + title.label = DROP_TEXT; + return false; + } + + private void on_drag_leave (DragContext context, uint time) { + title.label = DRAG_TEXT; + } + + private void on_drag_data_received (Gdk.DragContext drag_context, int x, int y, Gtk.SelectionData data, uint info, uint time){ + Gtk.drag_finish (drag_context, true, false, time); + + var display = window.get_display (); + var clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD); + window.prevScreen(); + window.addScreen (new SendView (window, clipboard)); + + var uris = data.get_uris (); + try{ + if(Thread.supported ()){ + new Thread.try ("PackThread", () => { + var path = Utils.get_send_path (uris); + wormhole.send (path); + return false; + }); + } + else{ + var path = Utils.get_send_path (uris); + wormhole.send (path); + } + } + catch(Error e){ + warning(e.message); + wormhole.errored(e.message, _("Internal Error"), true); + } + } + +} \ No newline at end of file diff --git a/src/View/InstallView.vala b/src/View/InstallView.vala index ef66ca2..a42730e 100644 --- a/src/View/InstallView.vala +++ b/src/View/InstallView.vala @@ -1,10 +1,7 @@ public class InstallView : ReceiveView { - private TransporterWindow window; - - public InstallView(TransporterWindow window, WormholeInterface wormhole){ - base (wormhole); - this.window = window; + public InstallView(TransporterWindow window){ + base (window); } protected override void setup(){ @@ -17,7 +14,7 @@ public class InstallView : ReceiveView { }); if(Thread.supported ()){ - var thread = new Thread.try ("InstallThread", () => { + new Thread.try ("InstallThread", () => { wormhole.install (); return false; }); diff --git a/src/View/ReceiveView.vala b/src/View/ReceiveView.vala index e28a70e..8d507d9 100644 --- a/src/View/ReceiveView.vala +++ b/src/View/ReceiveView.vala @@ -1,6 +1,8 @@ public class ReceiveView : Gtk.EventBox { protected bool is_finished = false; + + protected TransporterWindow window; protected WormholeInterface wormhole; protected Gtk.Label title_label; @@ -46,8 +48,9 @@ public class ReceiveView : Gtk.EventBox { show_all (); } - public ReceiveView(WormholeInterface wormhole){ - this.wormhole = wormhole; + public ReceiveView(TransporterWindow window){ + this.window = window; + this.wormhole = window.wormhole; this.setup (); } diff --git a/src/View/SendView.vala b/src/View/SendView.vala index f85d07c..76bad7c 100644 --- a/src/View/SendView.vala +++ b/src/View/SendView.vala @@ -2,8 +2,8 @@ public class SendView : ReceiveView { protected Gtk.Clipboard clipboard; - public SendView(WormholeInterface wormhole, Gtk.Clipboard clipboard){ - base (wormhole); + public SendView(TransporterWindow window, Gtk.Clipboard clipboard){ + base (window); this.clipboard = clipboard; } @@ -33,6 +33,7 @@ public class SendView : ReceiveView { title_label.set_text (_("Transfer Complete")); subtitle_label.set_text (_("Connection has been closed")); wormhole.ding(); + Utils.clean_temp(); }); } diff --git a/src/View/SettingsView.vala b/src/View/SettingsView.vala index 91ec6bb..dc9d758 100644 --- a/src/View/SettingsView.vala +++ b/src/View/SettingsView.vala @@ -5,20 +5,19 @@ public class SettingsView : Gtk.Grid { column_spacing = 12; row_spacing = 6; margin = 6; - width_request = 400; attach (new Granite.HeaderLabel (_("Servers")), 0, 0, 2, 1); - attach (new SettingsLabel (_("Relay Server:")), 0, 1, 1, 1); + attach (new SettingsLabel (_("Relay:")), 0, 1, 1, 1); attach (new SettingsEntry ("server-relay"), 1, 1, 1, 1); - attach (new SettingsLabel (_("Transit Server:")), 0, 3, 1, 1); + attach (new SettingsLabel (_("Transit:")), 0, 3, 1, 1); attach (new SettingsEntry ("server-transit"), 1, 3, 1, 1); attach (new Granite.HeaderLabel (_("Miscellaneous")), 0, 4, 2, 1); - attach (new SettingsLabel (_("ID Word Length:")), 0, 5, 1, 1); + attach (new SettingsLabel (_("ID Length:")), 0, 5, 1, 1); var words = new Gtk.SpinButton.with_range (2, 5, 1); settings.schema.bind ("words", words, "value", SettingsBindFlags.DEFAULT); attach (words, 1, 5, 1, 1); - attach (new SettingsLabel (_("Play Sounds:")), 0, 6, 1, 1); + attach (new SettingsLabel (_("Sounds:")), 0, 6, 1, 1); attach (new SettingsSwitch ("ding"), 1, 6, 1, 1); show_all (); diff --git a/src/View/WelcomeView.vala b/src/View/WelcomeView.vala index 562b6a2..839d2ec 100644 --- a/src/View/WelcomeView.vala +++ b/src/View/WelcomeView.vala @@ -1,6 +1,7 @@ public class WelcomeView : Gtk.Grid { - TransporterWindow window; + protected TransporterWindow window; + protected WormholeInterface wormhole; construct { var welcome = new Granite.Widgets.Welcome (_("Welcome to Transporter"), _("What would you like to do?")); @@ -10,23 +11,14 @@ public class WelcomeView : Gtk.Grid { welcome.activated.connect ((index) => { switch (index) { case 0: - var chooser = window.getFileChooser (); - if (chooser.run () == Gtk.ResponseType.ACCEPT) { - var file = chooser.get_filename (); - var display = window.get_display (); - var clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD); - - window.addScreen (new SendView (window.wormhole, clipboard)); - window.wormhole.send (file); - } - chooser.close (); + window.addScreen (new DropView (window)); break; case 1: - window.addScreen (new ReceiveView (window.wormhole)); + window.addScreen (new ReceiveView (window)); break; case 2: try{ - AppInfo.launch_default_for_uri ("file://" + window.wormhole.downloads_path, null); + AppInfo.launch_default_for_uri ("file://" + wormhole.downloads_path, null); } catch(GLib.Error e){ warning(e.message); @@ -43,6 +35,7 @@ public class WelcomeView : Gtk.Grid { public WelcomeView(TransporterWindow window){ this.window = window; + this.wormhole = window.wormhole; } } \ No newline at end of file diff --git a/src/WormholeInterface.vala b/src/WormholeInterface.vala index 2da4ec5..c5c0c9e 100644 --- a/src/WormholeInterface.vala +++ b/src/WormholeInterface.vala @@ -20,11 +20,13 @@ public class WormholeInterface : Object { public const string ERR_INVALID_ID = "reenter the key"; public const string ERR_CROWDED = "crowded"; public const string ERR_REJECTED = "transfer rejected"; + public const string ERR_NOT_FOUND = "no file/directory"; public const string ERR_ALREADY_EXISTS = "overwrite existing"; public const string ERR_MISMATCHED_ID = "confirmation failed"; public const string ERR_RELAY_UNRESPONSIVE = "We had a problem connecting to the relay"; + public const string ERR_UNREADABLE = "file you wanted to send couldn't be read"; public const string ID_GENERATED = "wormhole receive"; - public const string FINISH_RECEIVE = "Received file written"; + public const string FINISH_RECEIVE = "written"; public const string PERCENT_RECEIVE = "%|"; construct{ @@ -200,12 +202,12 @@ public class WormholeInterface : Object { return false; } if(ERR_ALREADY_EXISTS in line){ - errored (_("Received file already exists in Downloads folder."), _("File Conflict")); + errored (_("Received file already exists in Downloads folder."), _("I/O Error")); close (); return false; } if(ERR_ALREADY_EXISTS in line){ - errored (_("Received file already exists in Downloads folder."), _("File Conflict")); + errored (_("Received file already exists in Downloads folder."), _("I/O Error")); close (); return false; } @@ -214,6 +216,16 @@ public class WormholeInterface : Object { close (); return false; } + if(ERR_UNREADABLE in line){ + errored (_("Please make sure selected files do not contain special characters in their paths and names."), _("I/O Error")); + close (); + return false; + } + if(ERR_NOT_FOUND in line){ + errored (_("Archive creation failed, perhaps your disk is running out of space."), _("I/O Error")); + close (); + return false; + } if(PERCENT_RECEIVE in line){ var percent = line.split ("%", 2) [0];