Compare commits

..

1 Commits

Author SHA1 Message Date
rra
3080d1479f quick sketch of how it could work in a single window 2020-10-13 17:44:06 +02:00
9 changed files with 692 additions and 656 deletions

View File

@ -1,8 +1,8 @@
# Dropship # Dropship
> Drag it, drop it, ship it. > Get Things From One Computer To Another, Safely
Dropship is a graphical interface for [Magic-wormhole](https://magic-wormhole.readthedocs.io/en/latest). It allows you to securely send files from one computer to another. Dropship doesn't require any accounts or logging in. Simply select which files you want to send, drop them on the interface and share the resulting password with the receiver. Similarly, to receive a file just enter the received password in Dropship to start receiving a file. [Magic-wormhole](https://magic-wormhole.readthedocs.io/en/latest) with a nice graphical interface.
![Screen cast of dropship interface](https://vvvvvvaria.org/~r/dropship0.1.gif) ![Screen cast of dropship interface](https://vvvvvvaria.org/~r/dropship0.1.gif)
@ -10,12 +10,7 @@ _(click for video)_
## Features ## Features
- Drag and drop interface - ???
- Manage multiple transfers simultaneously, wheter you are receiving or sending
## Technical
Dropship is built using Python and GTK3.
## Supported Languages ## Supported Languages
@ -25,7 +20,7 @@ Dropship is built using Python and GTK3.
Dropship should work on the following distributions: Dropship should work on the following distributions:
- Debian Bullseye - Debian Stretch (9.0)
Other Linux distributions may work as well. We currently do not support MacOS or Windows. Other Linux distributions may work as well. We currently do not support MacOS or Windows.
@ -41,9 +36,9 @@ Dropship requires the following system dependencies:
[![PyPI version](https://badge.fury.io/py/dropship.svg)](https://badge.fury.io/py/dropship) [![PyPI version](https://badge.fury.io/py/dropship.svg)](https://badge.fury.io/py/dropship)
[![Build Status](https://travis-ci.org/decentral1se/dropship.svg?branch=main)](https://travis-ci.org/decentral1se/dropship) [![Build Status](https://travis-ci.org/decentral1se/dropship.svg?branch=main)](https://travis-ci.org/decentral1se/dropship)
<details><summary>Debian Bullseye</summary> <details><summary>Debian Stretch</summary>
<pre> <pre>
$ sudo apt install -y python3-gi python3-cairo-dev python3-gi-cairo gir1.2-gtk-3.0 libglib2.0-dev libgirepository1.0-dev libcairo2-dev $ sudo apt install -y python3-gi python3-gi-cairo gir1.2-gtk-3.0
$ python3 -m venv .venv $ python3 -m venv .venv
$ source .venv/bin/activate $ source .venv/bin/activate
$ pip install dropship $ pip install dropship

View File

@ -1,11 +1,13 @@
from logging import basicConfig, getLogger
from os import environ
from trio import open_nursery, sleep_forever from trio import open_nursery, sleep_forever
from trio_gtk import run from trio_gtk import run
from dropship.dropship import DropShip
def main(): def main():
"""Trio main entrypoint.""" """Trio main entrypoint."""
from dropship.dropship import DropShip
async def _main(): async def _main():
async with open_nursery() as nursery: async with open_nursery() as nursery:
@ -15,5 +17,5 @@ def main():
run(_main) run(_main)
if __name__ == "__main__": basicConfig(level=environ.get("LOGLEVEL", "INFO"))
main() log = getLogger("dropship")

View File

@ -1,13 +1,17 @@
from os.path import basename
from pathlib import Path
from gi import require_version from gi import require_version
from trio import CancelScope, open_process, run_process from trio import CancelScope, open_process, run_process
from dropship.logger import log from dropship import log
require_version("Gtk", "3.0") require_version("Gtk", "3.0")
require_version("Gdk", "3.0") require_version("Gdk", "3.0")
from gi.repository import Gdk, GLib, Gtk from gi.repository import Gdk, GLib, Gtk
from dropship import log
from dropship.constant import UI_DIR from dropship.constant import UI_DIR
from dropship.transfer import PendingTransfer from dropship.transfer import PendingTransfer
from dropship.ui_templates import PendingTransferRow from dropship.ui_templates import PendingTransferRow
@ -19,7 +23,7 @@ class DropShip:
def __init__(self, nursery): def __init__(self, nursery):
"""Object initialisation.""" """Object initialisation."""
self.GLADE_FILE = f"{UI_DIR}/dropship.ui" self.GLADE_FILE = f"{UI_DIR}/dropship_tabless.ui"
self.CSS_FILE = f"{UI_DIR}/dropship.css" self.CSS_FILE = f"{UI_DIR}/dropship.css"
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
@ -76,6 +80,16 @@ class DropShip:
"Cancel", Gtk.ResponseType.CANCEL, "Add", Gtk.ResponseType.OK "Cancel", Gtk.ResponseType.CANCEL, "Add", Gtk.ResponseType.OK
) )
#sendReceiveStack
self.sendReceiveStack = self.builder.get_object("sendReceiveStack")
#drag and drop in pending view
self.pendingdrop_box = self.builder.get_object("pendingDragDrop")
self.pendingdrop_box.drag_dest_set(
Gtk.DestDefaults.ALL, [self.enforce_target], Gdk.DragAction.COPY
)
self.pendingdrop_box.connect("drag-data-received", self.on_drop)
# Receive UI # Receive UI
# Code entry box # Code entry box
self.recv_box = self.builder.get_object("receiveBoxCodeEntry") self.recv_box = self.builder.get_object("receiveBoxCodeEntry")
@ -143,6 +157,8 @@ class DropShip:
self._create_pending_transfer(fpath, code, scope) self._create_pending_transfer(fpath, code, scope)
self.clipboard.set_text(code, -1) self.clipboard.set_text(code, -1)
self._send_spinner_off(code) self._send_spinner_off(code)
pending_view = self.sendReceiveStack.get_child_by_name('Pending')
self.sendReceiveStack.set_visible_child(pending_view)
log.info(f"send: successfully initiated transfer send ({code})") log.info(f"send: successfully initiated transfer send ({code})")
async def receive(self, code): async def receive(self, code):

View File

@ -1,5 +0,0 @@
from logging import basicConfig, getLogger
from os import environ
basicConfig(level=environ.get("LOGLEVEL", "INFO"))
log = getLogger("dropship")

View File

@ -0,0 +1,261 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow" id="mainWindow">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="default_width">250</property>
<property name="default_height">250</property>
<child>
<object class="GtkStack" id="sendReceiveStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<child>
<object class="GtkEventBox" id="dropBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="button-press-event" handler="add_files" swapped="no"/>
<child>
<object class="GtkBox" id="dragActionContainer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_start">16</property>
<property name="margin_end">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="dropLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Drag a file
drop it here
..and ship it </property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="dropSpinner">
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="drop"/>
</style>
</object>
</child>
</object>
<packing>
<property name="name">dragAndDrop</property>
<property name="title" translatable="yes">Send</property>
</packing>
</child>
<child>
<object class="GtkBox" id="receiveBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkEntry" id="receiveBoxCodeEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="primary_icon_stock">gtk-paste</property>
<property name="placeholder_text" translatable="yes">Transfer Code</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">receiveView</property>
<property name="title" translatable="yes">Receive</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="pendingDragDrop">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="pendingBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">16</property>
<property name="margin_end">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<child>
<object class="GtkLabel" id="dropLabel1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Drag a file to send</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEntry" id="receiveBoxCodeEntry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_stock">gtk-paste</property>
<property name="placeholder_text" translatable="yes">Transfer Code</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
<property name="margin_bottom">6</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="pendingTransfersList">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="drop"/>
</style>
</object>
</child>
</object>
<packing>
<property name="name">Pending</property>
<property name="title" translatable="yes">Pending</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkFileChooserDialog" id="filePicker">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Choose files to ship</property>
<property name="type_hint">dialog</property>
<property name="transient_for">mainWindow</property>
<property name="has_resize_grip">True</property>
<property name="select_multiple">True</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>

View File

@ -1,43 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 --> <!-- Generated with glade 3.36.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <requires lib="gtk+" version="3.20"/>
<template class="pendingTransferRow" parent="GtkListBoxRow"> <object class="GtkImage" id="image1">
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can_focus">False</property>
<property name="stock">gtk-no</property>
<property name="icon_size">3</property>
</object>
<template class="pendingTransferRow" parent="GtkListBoxRow">
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">False</property> <property name="activatable">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="name">pendingTransmission</property> <property name="name">pendingTransmission</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="margin-bottom">2</property> <property name="margin_bottom">2</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<child> <child>
<object class="GtkStack" id="transferStatusStack"> <object class="GtkStack" id="transferStatusStack">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="margin-left">6</property> <property name="margin_left">6</property>
<property name="margin-right">12</property> <property name="margin_right">12</property>
<property name="margin-start">6</property> <property name="margin_start">6</property>
<property name="margin-end">12</property> <property name="margin_end">12</property>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">
<property name="width-request">30</property> <property name="width_request">30</property>
<property name="height-request">30</property> <property name="height_request">30</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="icon-name">sync-synchronizing</property> <property name="icon_name">network-transmit</property>
<property name="icon_size">5</property> <property name="icon_size">5</property>
</object> </object>
<packing> <packing>
@ -48,8 +54,8 @@
<child> <child>
<object class="GtkImage"> <object class="GtkImage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="icon-name">folder</property> <property name="icon_name">dialog-ok</property>
<property name="icon_size">5</property> <property name="icon_size">5</property>
</object> </object>
<packing> <packing>
@ -68,27 +74,25 @@
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="margin-top">6</property> <property name="margin_top">6</property>
<property name="margin-bottom">6</property> <property name="margin_bottom">6</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="halign">center</property>
<property name="hexpand">True</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="GtkLabel" id="fileNameLabel"> <object class="GtkLabel" id="fileNameLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">screenshot_lkashdflasjdjasödjlkasjdlaskdlkashd01-292.jpg</property> <property name="label" translatable="yes">screenshot_lkashdflasjdjasödjlkasjdlaskdlkashd01-292.jpg</property>
<property name="ellipsize">middle</property> <property name="ellipsize">middle</property>
<property name="max-width-chars">20</property> <property name="max_width_chars">20</property>
<property name="track-visited-links">False</property> <property name="track_visited_links">False</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
@ -102,7 +106,7 @@
<child> <child>
<object class="GtkLabel" id="fileNameMetadata"> <object class="GtkLabel" id="fileNameMetadata">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">336 KB</property> <property name="label" translatable="yes">336 KB</property>
</object> </object>
@ -114,8 +118,8 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
@ -123,10 +127,10 @@
<object class="GtkButton" id="transferCodeButton"> <object class="GtkButton" id="transferCodeButton">
<property name="label" translatable="yes">5-courier-happening</property> <property name="label" translatable="yes">5-courier-happening</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can_focus">True</property>
<property name="receives-default">True</property> <property name="receives_default">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="margin-top">6</property> <property name="margin_top">6</property>
<signal name="clicked" handler="copy_transfer_code" swapped="no"/> <signal name="clicked" handler="copy_transfer_code" swapped="no"/>
</object> </object>
<packing> <packing>
@ -145,24 +149,23 @@
<child> <child>
<object class="GtkStack" id="statusButtonsStack"> <object class="GtkStack" id="statusButtonsStack">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
<property name="margin-left">12</property> <property name="margin_left">12</property>
<property name="margin-right">6</property> <property name="margin_right">6</property>
<property name="margin-start">12</property> <property name="margin_start">12</property>
<property name="margin-end">6</property> <property name="margin_end">6</property>
<property name="hhomogeneous">False</property> <property name="hhomogeneous">False</property>
<property name="transition-type">crossfade</property> <property name="transition_type">crossfade</property>
<child> <child>
<object class="GtkButton" id="cancelTransfer"> <object class="GtkButton" id="cancelTransfer">
<property name="label">gtk-cancel</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can_focus">True</property>
<property name="receives-default">True</property> <property name="receives_default">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="margin-top">16</property> <property name="margin_top">16</property>
<property name="margin-bottom">16</property> <property name="margin_bottom">16</property>
<property name="use-stock">True</property> <property name="image">image1</property>
<signal name="clicked" handler="cancel_transfer" swapped="no"/> <signal name="clicked" handler="cancel_transfer" swapped="no"/>
<style> <style>
<class name="circular"/> <class name="circular"/>
@ -177,12 +180,12 @@
<object class="GtkButton"> <object class="GtkButton">
<property name="label" translatable="yes">button</property> <property name="label" translatable="yes">button</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can_focus">True</property>
<property name="receives-default">True</property> <property name="receives_default">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="margin-top">16</property> <property name="margin_top">16</property>
<property name="margin-bottom">16</property> <property name="margin_bottom">16</property>
</object> </object>
<packing> <packing>
<property name="name">page1</property> <property name="name">page1</property>
@ -207,7 +210,7 @@
<child> <child>
<object class="GtkSeparator"> <object class="GtkSeparator">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can_focus">False</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>

View File

@ -1,11 +1,13 @@
from pathlib import Path
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gdk, GLib, Gtk from gi.repository import Gdk, GLib, Gtk
from dropship import log
from dropship.constant import DEFAULT_DROP_LABEL, UI_DIR from dropship.constant import DEFAULT_DROP_LABEL, UI_DIR
from dropship.logger import log
@Gtk.Template.from_file(f"{UI_DIR}/pendingTransferRow.ui") @Gtk.Template.from_file(f"{UI_DIR}/pendingTransferRow.ui")

View File

@ -2,21 +2,15 @@ from subprocess import PIPE
from trio import TASK_STATUS_IGNORED, CancelScope, open_process, run_process from trio import TASK_STATUS_IGNORED, CancelScope, open_process, run_process
from dropship.logger import log from dropship import log
async def wormhole_send(fpath, parent, task_status=TASK_STATUS_IGNORED): async def wormhole_send(fpath, parent, task_status=TASK_STATUS_IGNORED):
"""Run `wormhole send` on a local file path.""" """Run `wormhole send` on a local file path."""
with CancelScope() as scope: with CancelScope() as scope:
command = ["wormhole", "send", fpath] command = ["wormhole", "send", fpath]
process = await open_process(command, stderr=PIPE, stdout=PIPE) process = await open_process(command, stderr=PIPE)
output = await process.stderr.receive_some() output = await process.stderr.receive_some()
#this is some nasty hacky shit
async for i in process.stderr:
if b"On the other computer" in i:
output = i
break
code = output.decode().split()[-1] code = output.decode().split()[-1]
task_status.started((code, scope,)) task_status.started((code, scope,))
log.info(f"wormhole_send: now waiting for other side ({code})") log.info(f"wormhole_send: now waiting for other side ({code})")

916
poetry.lock generated

File diff suppressed because it is too large Load Diff