Skip to content

Commit

Permalink
Merge branch icons into master [release]
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Oct 1, 2024
1 parent 19b341d commit dbea577
Show file tree
Hide file tree
Showing 5,425 changed files with 52,427 additions and 1,529 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 10 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ components from it when it is run in a development environment.
Note that in case the current master branch is ahead of the latest release, it might happen that there are some incompatibilities when loading data from your local XPipe installation.
You should therefore always check out the matching version tag for your local repository and local XPipe installation.
You can find the available version tags at https://github.com/xpipe-io/xpipe/tags.
So for example if you currently have XPipe `10.0` installed, you should run `git reset --hard 10.0` first to properly compile against it.
So for example if you currently have XPipe `11.3` installed, you should run `git reset --hard 11.3` first to properly compile against it.

You need to have JDK for Java 21 installed to compile the project.
If you are on Linux or macOS, you can easily accomplish that by running
```bash
curl -s "https://get.sdkman.io" | bash
. "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21.0.1-graalce
sdk default java 21.0.1-graalce
sdk install java 22.0.2-graalce
sdk default java 22.0.2-graalce
```
.
On Windows, you have to manually install a JDK, e.g. from [Adoptium](https://adoptium.net/temurin/releases/?version=21).
Expand Down Expand Up @@ -74,7 +74,7 @@ Especially when starting out, it might be a good idea to start with easy tasks f

### Interacting via the HTTP API

You can create clients they communicate with the XPipe daemon via its HTTP API.
You can create clients that communicate with the XPipe daemon via its HTTP API.
To get started, see the [OpenAPI spec](/openapi.yaml).

### Implementing support for a new editor
Expand All @@ -98,16 +98,20 @@ All actions that you can perform for certain connections in the connection overv

You can add custom script definitions [here](https://github.com/xpipe-io/xpipe/tree/master/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java) and [here](https://github.com/xpipe-io/xpipe/tree/master/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts).

### Adding more system icons for system autodetection

You can register new system types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/java/io/xpipe/app/resources/SystemIcons.java) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/img/system).

### Adding more file icons for specific types

You can register file types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/resources/io/xpipe/app/resources/file_list.txt) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/browser_icons).
You can register file types [here](https://github.com/xpipe-io/xpipe/blob/master/app/src/main/resources/io/xpipe/app/resources/file_list.txt) and add the respective icons [here](https://github.com/xpipe-io/xpipe/tree/master/app/src/main/resources/io/xpipe/app/resources/img/browser).

The existing file list and icons are taken from the [vscode-icons](https://github.com/vscode-icons/vscode-icons) project. Due to limitations in the file definition list compatibility, some file types might not be listed by their proper extension and are therefore not being applied correctly even though the images and definitions exist already.

### Implementing something else

if you want to work on something that was not listed here, you can still do so of course. You can reach out on the [Discord server](https://discord.gg/8y89vS8cRb) to discuss any development plans and get you started.

### Translations
### Adding translations

See the [translation guide](/lang) for details.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ It currently supports:
- [Docker](https://www.docker.com/), [Podman](https://podman.io/), and [LXD](https://linuxcontainers.org/lxd/introduction/) container instances located on any host
- [Windows Subsystem for Linux](https://ubuntu.com/wsl), [Cygwin](https://www.cygwin.com/), and [MSYS2](https://www.msys2.org/) instances
- [Proxmox PVE](https://www.proxmox.com/en/proxmox-virtual-environment/overview) virtual machines and containers
- [Hyper-V](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/) and [VMware Player/Workstation/Fusion](https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion) virtual machines
- [Kubernetes](https://kubernetes.io/) clusters, pods, and containers
- [Powershell Remote Sessions](https://learn.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.3)
- Built-in VNC connections and RDP launchers
- Any other custom remote connection methods that work through the command-line

## Connection hub
Expand Down Expand Up @@ -50,6 +52,8 @@ It currently supports:
- Works with all command shells such as bash, zsh, cmd, PowerShell, and more, locally and remote
- Connects to a system while the terminal is still starting up, allowing for faster connections than otherwise possible

![Terminal](https://github.com/xpipe-io/.github/raw/main/img/terminal_shadow.png)

<br>
<p align="center">
<img src="https://github.com/xpipe-io/.github/raw/main/img/terminal.gif" alt="Terminal launcher"/>
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ dependencies {
api files("$rootDir/gradle/gradle_scripts/vernacular-1.16.jar")
api 'org.bouncycastle:bcprov-jdk18on:1.78.1'
api 'info.picocli:picocli:4.7.6'
api ('org.kohsuke:github-api:1.324') {
api ('org.kohsuke:github-api:1.326') {
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
api 'org.apache.commons:commons-lang3:3.16.0'
api 'org.apache.commons:commons-lang3:3.17.0'
api 'io.sentry:sentry:7.14.0'
api 'commons-io:commons-io:2.16.1'
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.17.2"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.xpipe.app.beacon;

import io.xpipe.app.core.AppResources;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.util.MarkdownHelper;
import io.xpipe.beacon.BeaconConfig;
import io.xpipe.beacon.BeaconInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void handle(HttpExchange exchange) {
}
}

if (beaconInterface.requiresEnabledApi() && !AppPrefs.get().enableHttpApi().get()) {
if (beaconInterface.requiresEnabledApi()
&& !AppPrefs.get().enableHttpApi().get()) {
var ex = new BeaconServerException("HTTP API is not enabled in the settings menu");
writeError(exchange, ex, 403);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public Object handle(HttpExchange exchange, Request msg) throws Throwable {
.getStoreEntryIfPresent(msg.getConnection())
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection()));
if (e.getStore() instanceof FixedHierarchyStore) {
DataStorage.get().refreshChildren(e, true);
DataStorage.get().refreshChildren(e, null, true);
} else {
e.validateOrThrow();
e.validateOrThrowAndClose(null);
}
return Response.builder().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public Object handle(HttpExchange exchange, Request msg) {
var out = exchange.getResponseBody()) {
fileIn.transferTo(out);
}
return Response.builder().build();
} else {
byte[] bytes;
try (var in = fs.openInput(msg.getPath().toString())) {
Expand All @@ -55,7 +54,7 @@ public Object handle(HttpExchange exchange, Request msg) {
try (var out = exchange.getResponseBody()) {
out.write(bytes);
}
return Response.builder().build();
}
return Response.builder().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package io.xpipe.app.beacon.impl;

import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.beacon.BeaconShellSession;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.ShellStartExchange;
import io.xpipe.core.store.ShellStore;

import com.sun.net.httpserver.HttpExchange;
import lombok.SneakyThrows;

public class ShellStartExchangeImpl extends ShellStartExchange {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.xpipe.app.beacon.impl;

import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.api.SshLaunchExchange;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellDialects;

import com.sun.net.httpserver.HttpExchange;

import java.util.List;

public class SshLaunchExchangeImpl extends SshLaunchExchange {
Expand All @@ -27,7 +28,7 @@ public Object handle(HttpExchange exchange, Request msg) throws Exception {

// There are sometimes multiple requests by a terminal client (e.g. Termius)
// This might fail sometimes, but it is expected
var r = TerminalLauncherManager.waitForNextLaunch();
var r = TerminalLauncherManager.sshLaunchExchange();
var c = ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getOpenScriptCommand(r.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class TerminalLaunchExchangeImpl extends TerminalLaunchExchange {
@Override
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException {
var r = TerminalLauncherManager.performLaunch(msg.getRequest());
var r = TerminalLauncherManager.launchExchange(msg.getRequest());
return Response.builder().targetFile(r).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class TerminalWaitExchangeImpl extends TerminalWaitExchange {
@Override
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException, BeaconServerException {
TerminalLauncherManager.waitForCompletion(msg.getRequest());
TerminalLauncherManager.waitExchange(msg.getRequest());
return Response.builder().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.browser.file.BrowserFileTransferMode;
import io.xpipe.app.browser.file.LocalFileSystem;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.util.FailableRunnable;

Expand Down
68 changes: 60 additions & 8 deletions app/src/main/java/io/xpipe/app/browser/BrowserFileOpener.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,76 @@
package io.xpipe.app.browser;

import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.FileBridge;
import io.xpipe.app.util.FileOpener;
import io.xpipe.core.process.ElevationFunction;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ConnectionFileSystem;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileInfo;
import io.xpipe.core.store.FileNames;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;

public class BrowserFileOpener {

private static OutputStream openFileOutput(OpenFileSystemModel model, FileEntry file, long totalBytes)
throws Exception {
var fileSystem = model.getFileSystem();
if (model.isClosed() || fileSystem.getShell().isEmpty()) {
return OutputStream.nullOutputStream();
}

var sc = fileSystem.getShell().get();
if (sc.getOsType() == OsType.WINDOWS) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}

var info = (FileInfo.Unix) file.getInfo();
var zero = Integer.valueOf(0);
var otherWrite = info.getPermissions().charAt(7) == 'w';
var requiresRoot = zero.equals(info.getUid()) && zero.equals(info.getGid()) && !otherWrite;
if (!requiresRoot || model.getCache().isRoot()) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}

var elevate = AppWindowHelper.showConfirmationAlert(
"app.fileWriteSudoTitle", "app.fileWriteSudoHeader", "app.fileWriteSudoContent");
if (!elevate) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}

var rootSc = sc.identicalSubShell()
.elevated(ElevationFunction.elevated("sudo"))
.start();
var rootFs = new ConnectionFileSystem(rootSc);
try {
return new FilterOutputStream(rootFs.openOutput(file.getPath(), totalBytes)) {
@Override
public void close() throws IOException {
super.close();
rootFs.close();
}
};
} catch (Exception ex) {
rootFs.close();
throw ex;
}
}

private static int calculateKey(FileEntry entry) {
return Objects.hash(entry.getPath(), entry.getFileSystem(), entry.getKind(), entry.getInfo());
}

public static void openWithAnyApplication(OpenFileSystemModel model, FileEntry entry) {
var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
Expand All @@ -35,7 +91,7 @@ public static void openWithAnyApplication(OpenFileSystemModel model, FileEntry e

public static void openInDefaultApplication(OpenFileSystemModel model, FileEntry entry) {
var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
Expand All @@ -61,7 +117,7 @@ public static void openInTextEditor(OpenFileSystemModel model, FileEntry entry)
}

var file = entry.getPath();
var key = entry.getPath().hashCode() + entry.getFileSystem().hashCode();
var key = calculateKey(entry);
FileBridge.get()
.openIO(
FileNames.getFileName(file),
Expand All @@ -71,11 +127,7 @@ public static void openInTextEditor(OpenFileSystemModel model, FileEntry entry)
return entry.getFileSystem().openInput(file);
},
(size) -> {
if (model.isClosed()) {
return OutputStream.nullOutputStream();
}

return entry.getFileSystem().openOutput(file, size);
return openFileOutput(model, entry, size);
},
FileOpener::openInTextEditor);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/browser/BrowserNavBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Structure createBase() {
var graphic = Bindings.createStringBinding(
() -> {
return model.getCurrentDirectory() != null
? FileIconManager.getFileIcon(model.getCurrentDirectory(), false)
? FileIconManager.getFileIcon(model.getCurrentDirectory())
: null;
},
model.getCurrentPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected Region createSimple() {

private Comp<?> createProgressEstimateStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
var expected = p.expectedTimeRemaining();
Expand All @@ -74,7 +74,7 @@ private Comp<?> createProgressEstimateStatus() {

private Comp<?> createProgressStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
var transferred = HumanReadableFormat.progressByteCount(p.getTransferred());
Expand All @@ -91,7 +91,7 @@ private Comp<?> createProgressStatus() {

private Comp<?> createProgressNameStatus() {
var text = BindingsHelper.map(model.getProgress(), p -> {
if (p == null || p.done()) {
if (p == null) {
return null;
} else {
return p.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.ShellTemp;
import io.xpipe.app.util.ThreadHelper;

import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import lombok.Value;
import org.apache.commons.io.FileUtils;

Expand Down Expand Up @@ -133,6 +135,12 @@ public void downloadSingle(Item item) {
BrowserFileTransferMode.COPY,
false,
progress -> {
// Don't update item progress to keep it as finished
if (progress == null) {
item.getOpenFileSystemModel().getProgress().setValue(null);
return;
}

synchronized (item.getProgress()) {
item.getProgress().setValue(progress);
}
Expand Down Expand Up @@ -170,7 +178,7 @@ public void transferToDownloads() throws Exception {
if (Files.isDirectory(file)) {
FileUtils.moveDirectory(file.toFile(), target.toFile());
} else {
FileUtils.moveFile(file.toFile(), target.toFile(), StandardCopyOption.REPLACE_EXISTING);
Files.move(file, target, StandardCopyOption.REPLACE_EXISTING);
}
}
DesktopHelper.browseFileInDirectory(downloads.resolve(files.getFirst().getFileName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class BrowserTransferProgress {
long total;
Instant start;

public static BrowserTransferProgress empty() {
return new BrowserTransferProgress(null, 0, 0, Instant.now());
}

static BrowserTransferProgress empty(String name, long size) {
return new BrowserTransferProgress(name, 0, size, Instant.now());
}

public static BrowserTransferProgress finished(String name, long size) {
return new BrowserTransferProgress(name, size, size, Instant.now());
}
Expand Down
Loading

0 comments on commit dbea577

Please sign in to comment.