Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Fixes #2: Display tray icon with current status (#58)
Browse files Browse the repository at this point in the history
In addition there is a basic context menu with the following actions:
- Open Goobox Folder
- Quit Goobox
  • Loading branch information
kaloyan-raev authored Dec 11, 2017
1 parent 4773e1d commit 3999550
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>io.goobox</groupId>
<artifactId>goobox-sync-common</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>io.storj</groupId>
Expand All @@ -74,11 +74,6 @@
<artifactId>appdirs</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/io/goobox/sync/storj/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.util.concurrent.CountDownLatch;

import io.goobox.sync.common.Utils;
import io.goobox.sync.common.systemtray.ShutdownListener;
import io.goobox.sync.common.systemtray.SystemTrayHelper;
import io.storj.libstorj.Bucket;
import io.storj.libstorj.CreateBucketCallback;
import io.storj.libstorj.GetBucketsCallback;
import io.storj.libstorj.KeysNotFoundException;
import io.storj.libstorj.Storj;

public class App {
public class App implements ShutdownListener {

private static App instance;

Expand Down Expand Up @@ -63,6 +65,9 @@ public FileWatcher getFileWatcher() {
}

private void init() {
SystemTrayHelper.setIdle();
SystemTrayHelper.setShutdownListener(this);

Storj.setConfigDirectory(StorjUtil.getStorjConfigDir());
Storj.setDownloadDirectory(Utils.getSyncDir());

Expand All @@ -89,6 +94,12 @@ private void init() {
taskExecutor.start();
}

@Override
public void shutdown() {
// TODO graceful shutdown
System.exit(0);
}

private boolean checkAndCreateSyncDir() {
System.out.print("Checking if local Goobox sync folder exists... ");
return checkAndCreateFolder(Utils.getSyncDir());
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/goobox/sync/storj/CheckStateTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;

import io.goobox.sync.common.Utils;
import io.goobox.sync.common.systemtray.SystemTrayHelper;
import io.goobox.sync.storj.db.DB;
import io.goobox.sync.storj.db.SyncFile;
import io.goobox.sync.storj.db.SyncState;
Expand Down Expand Up @@ -54,6 +55,8 @@ public void run() {
}

System.out.println("Checking for changes...");
SystemTrayHelper.setSynchronizing();

Storj.getInstance().listFiles(gooboxBucket, new ListFilesCallback() {
@Override
public void onFilesReceived(File[] files) {
Expand All @@ -64,6 +67,7 @@ public void onFilesReceived(File[] files) {
if (tasks.isEmpty()) {
// Sleep some time to avoid overloading the bridge
tasks.add(new SleepTask());
SystemTrayHelper.setIdle();
}
// Add itself to the queueAdd itself to the queue
tasks.add(CheckStateTask.this);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- only one line, shut up logback ! -->
<configuration />

0 comments on commit 3999550

Please sign in to comment.