Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to LibSoup-3 #84

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false

container:
image: ghcr.io/elementary/flatpak-platform/runtime:7.1-${{ matrix.arch }}
image: ghcr.io/elementary/flatpak-platform/runtime:8-${{ matrix.arch }}
options: --privileged

steps:
Expand Down
2 changes: 1 addition & 1 deletion com.github.alecaddd.taxi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app-id: com.github.alecaddd.taxi

runtime: io.elementary.Platform
runtime-version: '7.1'
runtime-version: '8'
sdk: io.elementary.Sdk

command: com.github.alecaddd.taxi
Expand Down
8 changes: 4 additions & 4 deletions src/API/IFileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Taxi {
* @return true if successful at connecting
*/
public async abstract bool connect_to_device (
Soup.URI uri,
GLib.Uri uri,
Gtk.Window window
);

Expand All @@ -38,11 +38,11 @@ namespace Taxi {
*/
public async abstract List<FileInfo> get_file_list ();

public abstract Soup.URI get_uri ();
public abstract GLib.Uri get_uri ();

public abstract void goto_dir (Soup.URI uri);
public abstract void goto_dir (GLib.Uri uri);

public abstract void open_file (Soup.URI uri);
public abstract void open_file (GLib.Uri uri);

public abstract File get_current_file ();
}
Expand Down
14 changes: 7 additions & 7 deletions src/Backend/FileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Taxi {
protected virtual IFileOperations file_operation { get; set; }

public abstract async bool connect_to_device (
Soup.URI uri,
GLib.Uri uri,
Gtk.Window window
);

Expand All @@ -35,21 +35,21 @@ namespace Taxi {
}
}

public virtual Soup.URI get_uri () {
public virtual GLib.Uri get_uri () {
var uri = file_handle.get_uri ();
if (!uri.has_suffix ("/")) {
uri += "/";
}
return new Soup.URI (uri);
return GLib.Uri.parse (uri, PARSE_RELAXED);
}

public virtual void goto_dir (Soup.URI uri) {
var uri_string = uri.to_string (false);
public virtual void goto_dir (GLib.Uri uri) {
var uri_string = uri.to_string ();
file_handle = File.new_for_uri (uri_string);
}

public virtual void open_file (Soup.URI uri) {
var uri_string = uri.to_string (false);
public virtual void open_file (GLib.Uri uri) {
var uri_string = uri.to_string ();
try {
AppInfo.launch_default_for_uri (uri_string, null);
} catch (Error e) {
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/LocalFileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Taxi {
}

public async override bool connect_to_device (
Soup.URI uri,
GLib.Uri uri,
Gtk.Window window
) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/Backend/RemoteFileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ namespace Taxi {

class RemoteFileAccess : FileAccess {

private Soup.URI uri;
private GLib.Uri uri;
private Gtk.Window window;

public RemoteFileAccess () {
file_operation = new FileOperations ();
}

public async override bool connect_to_device (
Soup.URI uri,
GLib.Uri uri,
Gtk.Window window
) {
this.window = window;
var mount = mount_operation_from_uri (uri);
this.uri = uri;
file_handle = File.new_for_uri (uri.to_string (false));
file_handle = File.new_for_uri (uri.to_string ());
try {
return yield file_handle.mount_enclosing_volume (
MountMountFlags.NONE,
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace Taxi {
file_handle = file_handle.resolve_relative_path ("/" + path);
}*/

private Gtk.MountOperation mount_operation_from_uri (Soup.URI uri) {
private Gtk.MountOperation mount_operation_from_uri (GLib.Uri uri) {
var mount = new Gtk.MountOperation (window);
mount.set_domain (uri.get_host ());
return mount;
Expand Down
30 changes: 15 additions & 15 deletions src/Frontend/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
private Granite.Widgets.Welcome welcome;
private FilePane local_pane;
private FilePane remote_pane;
private Soup.URI conn_uri;
private GLib.Uri conn_uri;
private GLib.Settings saved_state;

public MainWindow (
Expand Down Expand Up @@ -166,7 +166,7 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
popover.operations_finished.connect (hide_spinner);
}

private void on_connect_initiated (Soup.URI uri) {
private void on_connect_initiated (GLib.Uri uri) {
show_spinner ();
remote_access.connect_to_device.begin (uri, this, (obj, res) => {
if (remote_access.connect_to_device.end (res)) {
Expand All @@ -177,12 +177,12 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
update_pane (Location.LOCAL);
update_pane (Location.REMOTE);
connect_box.show_favorite_icon (
conn_saver.is_bookmarked (remote_access.get_uri ().to_string (false))
conn_saver.is_bookmarked (remote_access.get_uri ().to_string ())
);
conn_uri = uri;
} else {
alert_stack.visible_child = welcome;
welcome.title = _("Could not connect to '%s'").printf (uri.to_string (false));
welcome.title = _("Could not connect to '%s'").printf (uri.to_string ());
}
hide_spinner ();
});
Expand All @@ -197,7 +197,7 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
}

private void bookmark () {
var uri_string = conn_uri.to_string (false);
var uri_string = conn_uri.to_string ();
if (conn_saver.is_bookmarked (uri_string)) {
conn_saver.remove (uri_string);
} else {
Expand Down Expand Up @@ -233,19 +233,19 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
}
}

private void on_local_navigate (Soup.URI uri) {
private void on_local_navigate (GLib.Uri uri) {
navigate (uri, local_access, Location.LOCAL);
}

private void on_local_open (Soup.URI uri) {
private void on_local_open (GLib.Uri uri) {
local_access.open_file (uri);
}

private void on_remote_navigate (Soup.URI uri) {
private void on_remote_navigate (GLib.Uri uri) {
navigate (uri, remote_access, Location.REMOTE);
}

private void on_remote_open (Soup.URI uri) {
private void on_remote_open (GLib.Uri uri) {
remote_access.open_file (uri);
}

Expand All @@ -257,15 +257,15 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
file_dragged (uri, Location.LOCAL, local_access);
}

private void on_local_file_delete (Soup.URI uri) {
private void on_local_file_delete (GLib.Uri uri) {
file_delete (uri, Location.LOCAL);
}

private void on_remote_file_delete (Soup.URI uri) {
private void on_remote_file_delete (GLib.Uri uri) {
file_delete (uri, Location.REMOTE);
}

private void navigate (Soup.URI uri, IFileAccess file_access, Location pane) {
private void navigate (GLib.Uri uri, IFileAccess file_access, Location pane) {
file_access.goto_dir (uri);
update_pane (pane);
}
Expand Down Expand Up @@ -294,8 +294,8 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
);
}

private void file_delete (Soup.URI uri, Location pane) {
var file = File.new_for_uri (uri.to_string (false));
private void file_delete (GLib.Uri uri, Location pane) {
var file = File.new_for_uri (uri.to_string ());
file_operation.delete_recursive.begin (
file,
new Cancellable (),
Expand Down Expand Up @@ -335,7 +335,7 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
});
}

private Soup.URI on_ask_hostname () {
private GLib.Uri on_ask_hostname () {
return conn_uri;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Frontend/Widgets/ConnectBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace Taxi {
private bool show_fav_icon = false;
private bool added = false;

public signal void connect_initiated (Soup.URI uri);
public signal void connect_initiated (GLib.Uri uri);
public signal void bookmarked ();
public signal Soup.URI ask_hostname ();
public signal GLib.Uri ask_hostname ();

construct {
string[] entries = {"FTP", "SFTP", "DAV", "AFP"};
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace Taxi {
private void submit_form () {
var protocol = ((Protocol) protocol_combobox.get_active ()).to_plain_text ();
var path = path_entry.get_text ();
var uri = new Soup.URI (protocol + "://" + path);
var uri = Uri.parse (protocol + "://" + path, PARSE_RELAXED);
connect_initiated (uri);
}

Expand Down Expand Up @@ -83,7 +83,7 @@ namespace Taxi {
var uri_reply = ask_hostname ();
// TODO: Handle text changes in a less lazy way
path_entry.changed.disconnect (this.on_changed);
path_entry.set_text (uri_reply.to_string (false));
path_entry.set_text (uri_reply.to_string ());
path_entry.changed.connect (this.on_changed);
}
return false;
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace Taxi {

path_entry.text = split[1];

connect_initiated (new Soup.URI (uri));
connect_initiated (GLib.Uri.parse (uri, PARSE_RELAXED));
}

public void show_favorite_icon (bool added = false) {
Expand Down
32 changes: 17 additions & 15 deletions src/Frontend/Widgets/FilePane.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ namespace Taxi {
};

class FilePane : Gtk.Grid {
private Soup.URI current_uri;
private GLib.Uri current_uri;
private PathBar path_bar;
private Gtk.ListBox list_box;
private Gtk.Stack stack;

public signal void file_dragged (string uri);
public signal void transfer (string uri);
public signal void navigate (Soup.URI uri);
public signal void @delete (Soup.URI uri);
public signal void rename (Soup.URI uri);
public signal void open (Soup.URI uri);
public signal void edit (Soup.URI uri);
public signal void navigate (GLib.Uri uri);
public signal void @delete (GLib.Uri uri);
public signal void rename (GLib.Uri uri);
public signal void open (GLib.Uri uri);
public signal void edit (GLib.Uri uri);

delegate void ActivateFunc (Soup.URI uri);
delegate void ActivateFunc (GLib.Uri uri);

construct {
path_bar = new PathBar ();
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace Taxi {
list_box.drag_drop.connect (on_drag_drop);
list_box.drag_data_received.connect (on_drag_data_received);
list_box.row_activated.connect ((row) => {
var uri = row.get_data<Soup.URI> ("uri");
var uri = row.get_data<GLib.Uri> ("uri");
var type = row.get_data<FileType> ("type");
if (type == FileType.DIRECTORY) {
navigate (uri);
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace Taxi {
var uri_list = new Gee.ArrayList<string> ();
foreach (Gtk.Widget row in list_box.get_children ()) {
if (row.get_data<Gtk.CheckButton> ("checkbutton").get_active ()) {
uri_list.add (current_uri.to_string (false) + "/" + row.get_data<string> ("name"));
uri_list.add (current_uri.to_string () + "/" + row.get_data<string> ("name"));
}
}
return uri_list;
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace Taxi {
row.add (size);
}

var uri = new Soup.URI.with_base (current_uri, file_info.get_name ());
var uri = GLib.Uri.parse_relative (current_uri, file_info.get_name (), PARSE_RELAXED);

var ebrow = new Gtk.EventBox ();
ebrow.add (row);
Expand Down Expand Up @@ -241,10 +241,12 @@ namespace Taxi {


private bool on_ebr_popup_menu (Gtk.EventBox event_box) {
var uri = new Soup.URI.with_base (
var uri = GLib.Uri.parse_relative (
current_uri,
event_box.get_data<string> ("name")
event_box.get_data<string> ("name"),
PARSE_RELAXED
);

var type = event_box.get_data<FileType> ("type");
var menu = new Gtk.Menu ();
if (type == FileType.DIRECTORY) {
Expand All @@ -266,14 +268,14 @@ namespace Taxi {
private Gtk.MenuItem new_menu_item (
string label,
ActivateFunc activate_fn,
Soup.URI uri
GLib.Uri uri
) {
var menu_item = new Gtk.MenuItem.with_label (label);
menu_item.activate.connect (() => activate_fn (uri));
return menu_item;
}

public void update_pathbar (Soup.URI uri) {
public void update_pathbar (GLib.Uri uri) {
current_uri = uri;
path_bar.set_path (uri);
path_bar.show_all ();
Expand Down Expand Up @@ -335,7 +337,7 @@ namespace Taxi {
uint time
) {
string file_name = widget.get_data ("name");
string file_uri = current_uri.to_string (false) + "/" + file_name;
string file_uri = current_uri.to_string () + "/" + file_name;
switch (target_type) {
case Target.URI_LIST:
selection_data.set_uris ({ file_uri });
Expand Down
10 changes: 5 additions & 5 deletions src/Frontend/Widgets/PathBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ namespace Taxi {
class PathBar : Gtk.Grid {
public bool transfer_button_sensitive { get; set; }

private Soup.URI current_uri;
private GLib.Uri current_uri;

public signal void navigate (Soup.URI uri);
public signal void navigate (GLib.Uri uri);
public signal void transfer ();

public PathBar.from_uri (Soup.URI uri) {
public PathBar.from_uri (GLib.Uri uri) {
set_path (uri);
}

Expand Down Expand Up @@ -64,13 +64,13 @@ namespace Taxi {
button_style_context.add_class ("path-button");

button.clicked.connect (() => {
current_uri.set_path (path);
current_uri.parse (current_uri.get_scheme () + path, PARSE_RELAXED);
navigate (current_uri);
});
add (button);
}

public void set_path (Soup.URI uri) {
public void set_path (GLib.Uri uri) {
clear_path ();
current_uri = uri;
string transfer_icon_name;
Expand Down
Loading