Skip to content
Open
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
*.iml
*node_modules
*target
.project
.settings
.classpath
*.log
web-ui/javascript/build
web-ui/javascript/report.*.json

**/.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class FsStoryPackWriter {

public Path write(StoryPack pack, Path outputFolder) throws Exception {
// Create pack folder: last 8 digits of uuid
File packFolder = new File(outputFolder.toFile(), transformUuid(UUID.fromString(pack.getUuid())));
// File packFolder = new File(outputFolder.toFile(), transformUuid(UUID.fromString(pack.getUuid())));
File packFolder = outputFolder.toFile();
packFolder.mkdirs();

// Write night mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ public static void initializeLibUsb(DeviceVersion deviceVersion, DeviceHotplugEv
}
}
LOGGER.info("Exiting libusb...");
LibUsb.exit(context);

try {
LibUsb.exit(context);
} catch(IllegalStateException e) {
}
})
);
}
Expand Down
103 changes: 56 additions & 47 deletions driver/src/main/java/studio/driver/fs/FsStoryTellerAsyncDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,63 +51,72 @@ public class FsStoryTellerAsyncDriver {
private List<DeviceHotplugEventListener> listeners = new ArrayList<>();


public FsStoryTellerAsyncDriver() {
// Initialize libusb, handle and propagate hotplug events
LOGGER.fine("Registering hotplug listener");
LibUsbDetectionHelper.initializeLibUsb(DeviceVersion.DEVICE_VERSION_2, new DeviceHotplugEventListener() {
@Override
public void onDevicePlugged(Device device) {
// Wait for a partition to be mounted which contains the .md file
LOGGER.fine("Waiting for device partition...");
for (int i = 0; i < FS_MOUNTPOINT_RETRY && partitionMountPoint==null; i++) {
try {
Thread.sleep(FS_MOUNTPOINT_POLL_DELAY);
DeviceUtils.listMountPoints().forEach(path -> {
LOGGER.finest("Looking for .md file on mount point / drive: " + path);
File mdFile = new File(path, DEVICE_METADATA_FILENAME);
if (mdFile.exists()) {
partitionMountPoint = path;
LOGGER.info("FS device partition located: " + partitionMountPoint);
}
});
} catch (InterruptedException e) {
LOGGER.log(Level.SEVERE, "Failed to locate device partition", e);
}
private boolean simulating = false;
public FsStoryTellerAsyncDriver(boolean simulating) {
this();
this.simulating = simulating;
}


private DeviceHotplugEventListener defaultListener = new DeviceHotplugEventListener() {
@Override
public void onDevicePlugged(Device device) {
// Wait for a partition to be mounted which contains the .md file
LOGGER.fine("Waiting for device partition...");
for (int i = 0; i < FS_MOUNTPOINT_RETRY && partitionMountPoint==null; i++) {
try {
Thread.sleep(FS_MOUNTPOINT_POLL_DELAY);
DeviceUtils.listMountPoints().forEach(path -> {
LOGGER.finest("Looking for .md file on mount point / drive: " + path);
File mdFile = new File(path, DEVICE_METADATA_FILENAME);
if (mdFile.exists()) {
partitionMountPoint = path;
LOGGER.info("FS device partition located: " + partitionMountPoint);
}
});
} catch (InterruptedException e) {
LOGGER.log(Level.SEVERE, "Failed to locate device partition", e);
}
}

if (partitionMountPoint == null) {
throw new StoryTellerException("Could not locate device partition");
}
if (partitionMountPoint == null) {
throw new StoryTellerException("Could not locate device partition");
}

// Update device reference
FsStoryTellerAsyncDriver.this.device = device;
// Notify listeners
FsStoryTellerAsyncDriver.this.listeners.forEach(listener -> listener.onDevicePlugged(device));
}
// Update device reference
FsStoryTellerAsyncDriver.this.device = device;
// Notify listeners
FsStoryTellerAsyncDriver.this.listeners.forEach(listener -> listener.onDevicePlugged(device));
}

@Override
public void onDeviceUnplugged(Device device) {
// Update device reference
FsStoryTellerAsyncDriver.this.device = null;
FsStoryTellerAsyncDriver.this.partitionMountPoint = null;
// Notify listeners
FsStoryTellerAsyncDriver.this.listeners.forEach(listener -> listener.onDeviceUnplugged(device));
}
}
);
@Override
public void onDeviceUnplugged(Device device) {
// Update device reference
FsStoryTellerAsyncDriver.this.device = null;
FsStoryTellerAsyncDriver.this.partitionMountPoint = null;
// Notify listeners
FsStoryTellerAsyncDriver.this.listeners.forEach(listener -> listener.onDeviceUnplugged(device));
}
};

public FsStoryTellerAsyncDriver() {
// Initialize libusb, handle and propagate hotplug events
LOGGER.fine("Registering hotplug listener");
LibUsbDetectionHelper.initializeLibUsb(DeviceVersion.DEVICE_VERSION_2, defaultListener);
}


public void registerDeviceListener(DeviceHotplugEventListener listener) {
this.listeners.add(listener);
if (this.device != null) {
if (this.device != null || this.simulating) {
this.defaultListener.onDevicePlugged(null);
listener.onDevicePlugged(this.device);
}
}


public CompletableFuture<FsDeviceInfos> getDeviceInfos() {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}
FsDeviceInfos infos = new FsDeviceInfos();
Expand Down Expand Up @@ -235,7 +244,7 @@ private long readAsciiToLong(FileInputStream fis, int numberBytes) throws IOExce


public CompletableFuture<List<FsStoryPackInfos>> getPacksList() {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}

Expand Down Expand Up @@ -308,7 +317,7 @@ private CompletableFuture<List<UUID>> readPackIndex() {


public CompletableFuture<Boolean> reorderPacks(List<String> uuids) {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}

Expand All @@ -331,7 +340,7 @@ public CompletableFuture<Boolean> reorderPacks(List<String> uuids) {
}

public CompletableFuture<Boolean> deletePack(String uuid) {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}

Expand Down Expand Up @@ -397,7 +406,7 @@ private CompletableFuture<Boolean> writePackIndex(List<UUID> packUUIDs) {


public CompletableFuture<TransferStatus> downloadPack(String uuid, String outputPath, TransferProgressListener listener) {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}

Expand Down Expand Up @@ -433,7 +442,7 @@ public CompletableFuture<TransferStatus> downloadPack(String uuid, String output
}

public CompletableFuture<TransferStatus> uploadPack(String uuid, String inputPath, TransferProgressListener listener) {
if (this.device == null || this.partitionMountPoint == null) {
if (!simulating && (this.device == null || this.partitionMountPoint == null)) {
return CompletableFuture.failedFuture(new StoryTellerException("No device plugged"));
}

Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<module>core</module>
<module>driver</module>
<module>metadata</module>
<module>web-ui</module>
<!--<module>web-ui</module>-->
<module>studio-desktop</module>
</modules>

<build>
Expand Down Expand Up @@ -49,7 +50,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand Down
26 changes: 26 additions & 0 deletions studio-desktop/Lunii-Transfert.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Lunii Transfert</string>

<key>CFBundleExecutable</key>
<string>studio.sh</string>

<key>CFBundleIconFile</key>
<string>lunii.png</string>

<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleSignature</key>
<string>????</string>

<key>CFBundleIdentifier</key>
<string>studio.GUI</string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions studio-desktop/build_macos_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash


cp -r Lunii-Transfert.app target/
cp target/studio.sh target/Lunii-Transfert.app/Contents/MacOS
cp target/lunii.png target/Lunii-Transfert.app/Contents/Resources
cp -r target/lib/ target/Lunii-Transfert.app/Contents/Resources/Java/lib
cp libusb4java-1.3.0-darwin-aarch64.jar target/Lunii-Transfert.app/Contents/Resources/Java/lib/
cp target/$1.jar target/Lunii-Transfert.app/Contents/Resources/Java

rm -rf /tmp/buildlunii
mkdir -p /tmp/buildlunii
cp -r target/Lunii-Transfert.app /tmp/buildlunii
ln -s /Applications/ /tmp/buildlunii/Applications

hdiutil create -fs HFS+ -srcfolder "/tmp/buildlunii" -volname Lunii-Transfert target/Lunii-Transfert.dmg

rm -rf /tmp/buildlunii
Binary file not shown.
Loading