diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index ad1dd7c..1416012 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1555,6 +1555,7 @@ public class MainWindowController { } else { props.setProperty("cloudService", getCloudService()); } + props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); @@ -1642,6 +1643,13 @@ public class MainWindowController { setCloudService(""); } + try { + main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); + } catch (Exception e) { + LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); + setCloudSync(false); + } + try { setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync"))); } catch (Exception e) { diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index 25b995b..3c37c94 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -202,4 +202,28 @@ public class CloudController { } } + public String getFolderID(String cloudService) { + String folderID = ""; + if (cloudService != null) { + if (cloudService.equals("GoogleDrive")) { + folderID = googleDriveController.getFolderID(); + } + if (cloudService.equals("Dropbox")) { + + } + } + return folderID; + } + + public void setFolderID(String folderID, String cloudService) { + if (cloudService != null) { + if (cloudService.equals("GoogleDrive")) { + googleDriveController.setFolderID(folderID); + } + if (cloudService.equals("Dropbox")) { + + } + } + } + } diff --git a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java index 622656c..485ceef 100644 --- a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java +++ b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java @@ -116,10 +116,13 @@ public class GoogleDriveController { .build(); } - - public void main(String cemuDirectory) throws IOException { - service = getDriveService(); - } + public void main(String cemuDirectory) throws IOException { + service = getDriveService(); + + if (getFolderID() == "" || getFolderID() == null) { + getSavegamesFolderID(); + } + } // create a folder in google drive public void creatFolder() throws IOException { @@ -203,4 +206,24 @@ public class GoogleDriveController { return outputFile; } + private void getSavegamesFolderID() throws IOException { + Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'"); + FileList files = request.execute(); + + try { + LOGGER.info("FolderID: " + files.getFiles().get(0).getId()); + setFolderID(files.getFiles().get(0).getId()); + } catch (Exception e) { + LOGGER.error("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!", e); + } +} + + public String getFolderID() { + return folderID; + } + + public void setFolderID(String folderID) { + this.folderID = folderID; +} + }