Moved some functions for better experience
parent
778d222e2f
commit
62c2dae3dd
|
@ -162,11 +162,20 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
_nextcloud.getItems()->at(itemID).open();
|
_nextcloud.getItems()->at(itemID).open();
|
||||||
break;
|
break;
|
||||||
case 2:
|
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);
|
OpenProgressbar(1, "Downloading...", "Check network connection", 0, EventHandler::DialogHandlerStatic);
|
||||||
_nextcloud.downloadItem(itemID);
|
_nextcloud.downloadItem(itemID);
|
||||||
CloseProgressbar();
|
CloseProgressbar();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
if (!_nextcloud.getItems()->at(itemID).removeFile())
|
||||||
Message(ICON_WARNING, "Warning", "Could not delete the file, please try again.", 1200);
|
Message(ICON_WARNING, "Warning", "Could not delete the file, please try again.", 1200);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,6 @@ void LoginView::keyboardHandler(char *text)
|
||||||
int LoginView::logginClicked(int x, int y)
|
int LoginView::logginClicked(int x, int y)
|
||||||
{
|
{
|
||||||
_charBuffer = (char *)malloc(_bufferSize);
|
_charBuffer = (char *)malloc(_bufferSize);
|
||||||
//_charBuffer = "test";
|
|
||||||
|
|
||||||
if (IsInRect(x, y, &_urlButton))
|
if (IsInRect(x, y, &_urlButton))
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
void Item::setSize(double tempSize)
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
void open() const;
|
void open() const;
|
||||||
|
|
||||||
void removeFile();
|
bool removeFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string _path;
|
string _path;
|
||||||
|
|
|
@ -108,7 +108,6 @@ void Nextcloud::logout(bool deleteFiles)
|
||||||
string cmd = "rm -rf " + NEXTCLOUD_FILE_PATH + "/" + getUsername() + "/";
|
string cmd = "rm -rf " + NEXTCLOUD_FILE_PATH + "/" + getUsername() + "/";
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(NEXTCLOUD_CONFIG_PATH.c_str());
|
remove(NEXTCLOUD_CONFIG_PATH.c_str());
|
||||||
remove((NEXTCLOUD_CONFIG_PATH + ".back.").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());
|
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())
|
if (!Util::connectToNetwork())
|
||||||
{
|
{
|
||||||
Message(ICON_WARNING, "Warning", "Can not connect to the Internet. Switching to offline modus.", 1200);
|
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)
|
bool Nextcloud::getDataStructure(string &pathUrl)
|
||||||
{
|
{
|
||||||
return getDataStructure(pathUrl, this->getUsername(), this->getPassword());
|
return getDataStructure(pathUrl, this->getUsername(), this->getPassword());
|
||||||
|
|
|
@ -47,8 +47,6 @@ public:
|
||||||
|
|
||||||
void downloadItem(int itemID);
|
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
|
* gets the dataStructure of the given URL and writes its WEBDAV items to the items vector, reads Userdata from configfile
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue