diff --git a/src/handler/eventHandler.cpp b/src/handler/eventHandler.cpp index 7aaf01f..d3d02ab 100644 --- a/src/handler/eventHandler.cpp +++ b/src/handler/eventHandler.cpp @@ -162,11 +162,20 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2) _nextcloud.getItems()->at(itemID).open(); break; case 2: + //TODO implement upload if local file + if (_nextcloud.isWorkOffline()) + { + int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "You are in offline modus. Go back online?", "Yes", "No", "Cancel"); + if (dialogResult == 2 || dialogResult == 3) + return 0; + _nextcloud.switchWorkOffline(); + } OpenProgressbar(1, "Downloading...", "Check network connection", 0, EventHandler::DialogHandlerStatic); _nextcloud.downloadItem(itemID); CloseProgressbar(); break; case 3: + if (!_nextcloud.getItems()->at(itemID).removeFile()) Message(ICON_WARNING, "Warning", "Could not delete the file, please try again.", 1200); break; diff --git a/src/ui/loginView.cpp b/src/ui/loginView.cpp index 71d5eae..14a7ea6 100644 --- a/src/ui/loginView.cpp +++ b/src/ui/loginView.cpp @@ -91,7 +91,6 @@ void LoginView::keyboardHandler(char *text) int LoginView::logginClicked(int x, int y) { _charBuffer = (char *)malloc(_bufferSize); - //_charBuffer = "test"; if (IsInRect(x, y, &_urlButton)) { diff --git a/src/util/item.cpp b/src/util/item.cpp index 86d9543..e727791 100644 --- a/src/util/item.cpp +++ b/src/util/item.cpp @@ -88,10 +88,20 @@ void Item::open() const } } -void Item::removeFile() +bool Item::removeFile() { - remove(_localPath.c_str()); - _downloaded = false; + + if (remove(_localPath.c_str()) != 0) + return false; + if (_state == FileState::ISYNCED) + { + _state = FileState::ICLOUD; + } + else + { + Message(ICON_INFORMATION, "Warning", "The file will be shown until next folder update.", 1200); + } + return true; } void Item::setSize(double tempSize) diff --git a/src/util/item.h b/src/util/item.h index b0584b0..4d73857 100644 --- a/src/util/item.h +++ b/src/util/item.h @@ -50,7 +50,7 @@ public: void open() const; - void removeFile(); + bool removeFile(); private: string _path; diff --git a/src/util/nextcloud.cpp b/src/util/nextcloud.cpp index 2a06cc2..860f803 100644 --- a/src/util/nextcloud.cpp +++ b/src/util/nextcloud.cpp @@ -108,7 +108,6 @@ void Nextcloud::logout(bool deleteFiles) string cmd = "rm -rf " + NEXTCLOUD_FILE_PATH + "/" + getUsername() + "/"; system(cmd.c_str()); } - remove(NEXTCLOUD_CONFIG_PATH.c_str()); remove((NEXTCLOUD_CONFIG_PATH + ".back.").c_str()); @@ -122,14 +121,6 @@ void Nextcloud::downloadItem(int itemID) { Log::writeLog("started download of " + _items->at(itemID).getPath() + " to " + _items->at(itemID).getLocalPath()); - if (_workOffline) - { - int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "You are in offline modus. Go back online?", "Yes", "No", "Cancel"); - if (dialogResult == 2 || dialogResult == 3) - return; - _workOffline = false; - } - if (!Util::connectToNetwork()) { Message(ICON_WARNING, "Warning", "Can not connect to the Internet. Switching to offline modus.", 1200); @@ -188,14 +179,6 @@ void Nextcloud::downloadItem(int itemID) } } -bool Nextcloud::removeFile(int itemID) -{ - if (remove(_items->at(itemID).getLocalPath().c_str()) != 0) - return false; - _items->at(itemID).setDownloaded(false); - return true; -} - bool Nextcloud::getDataStructure(string &pathUrl) { return getDataStructure(pathUrl, this->getUsername(), this->getPassword()); diff --git a/src/util/nextcloud.h b/src/util/nextcloud.h index 902a92e..47adbd6 100644 --- a/src/util/nextcloud.h +++ b/src/util/nextcloud.h @@ -47,8 +47,6 @@ public: void downloadItem(int itemID); - bool removeFile(int itemID); - /** * gets the dataStructure of the given URL and writes its WEBDAV items to the items vector, reads Userdata from configfile *