55import org .cryptomator .integrations .common .Priority ;
66import org .cryptomator .integrations .update .UpdateFailedException ;
77import org .cryptomator .integrations .update .UpdateService ;
8+ import org .freedesktop .dbus .FileDescriptor ;
89import org .freedesktop .dbus .exceptions .DBusException ;
10+ import org .freedesktop .dbus .types .UInt32 ;
11+ import org .freedesktop .dbus .types .Variant ;
912import org .purejava .portal .Flatpak ;
1013import org .purejava .portal .UpdatePortal ;
14+ import org .purejava .portal .Util ;
1115import org .slf4j .Logger ;
1216import org .slf4j .LoggerFactory ;
1317
18+ import java .util .Collections ;
19+ import java .util .List ;
20+ import java .util .Map ;
21+
1422@ Priority (1000 )
1523@ CheckAvailability
1624@ OperatingSystem (OperatingSystem .Value .LINUX )
@@ -37,9 +45,16 @@ public String isUpdateAvailable(DistributionChannel channel) {
3745
3846 @ Override
3947 public void triggerUpdate () throws UpdateFailedException {
40- getUpdateMonitor ();
41- //var monitor = getUpdateMonitor();
42- //portal.updateApp("x11:0", monitor, UpdatePortal.OPTIONS_DUMMY);
48+ var cwdPath = Util .stringToByteList (System .getProperty ("user.dir" ));
49+ List <List <Byte >> argv = List .of (
50+ Util .stringToByteList ("org.cryptomator.Cryptomator" ));
51+ Map <UInt32 , FileDescriptor > fds = Collections .emptyMap ();
52+ Map <String , String > envs = Map .of ();
53+ var flags = new UInt32 (0 );
54+ Map <String , Variant <?>> options = UpdatePortal .OPTIONS_DUMMY ;
55+
56+ spawnApp (cwdPath , argv , fds , envs , flags , options );
57+
4358 }
4459
4560 @ Override
@@ -56,7 +71,7 @@ public String getDisplayName() {
5671 public void close () throws Exception {
5772 try {
5873 if (null != updateMonitor ) {
59- updateMonitor . Close ( );
74+ portal . cancelUpdateMonitor ( updateMonitor );
6075 }
6176 portal .close ();
6277 } catch (Exception e ) {
@@ -87,4 +102,14 @@ private synchronized Flatpak.UpdateMonitor getUpdateMonitor() {
87102 public void notifyOnUpdateAvailable (Flatpak .UpdateMonitor .UpdateAvailable signal ) {
88103 LOG .info ("Update available to remote-commit {}" , signal .update_info .get ("remote-commit" ).getValue ());
89104 }
105+
106+ private UInt32 spawnApp (List <Byte > cwdPath , List <List <Byte >> argv , Map <UInt32 , FileDescriptor > fds , Map <String , String > envs , UInt32 flags , Map <String , Variant <?>> options ) {
107+ var pid = portal .Spawn (cwdPath , argv , fds , envs , flags , options );
108+ if (null != pid ) {
109+ LOG .error ("Spawning new application failed" );
110+ } else {
111+ LOG .debug ("New application spawned with PID {}" , pid );
112+ }
113+ return pid ;
114+ }
90115}
0 commit comments