Structure get methods for WebDAVItems
parent
010ee9264a
commit
061355c3ed
|
@ -31,37 +31,20 @@ EventHandler::EventHandler()
|
||||||
|
|
||||||
_loginView = nullptr;
|
_loginView = nullptr;
|
||||||
_webDAVView = nullptr;
|
_webDAVView = nullptr;
|
||||||
vector<WebDAVItem> fromDB;
|
|
||||||
std::vector<WebDAVItem> currentWebDAVItems;
|
std::vector<WebDAVItem> currentWebDAVItems;
|
||||||
|
string path = NEXTCLOUD_ROOT_PATH + Util::accessConfig(CONFIG_PATH, Action::IReadString,"UUID") + '/';
|
||||||
|
|
||||||
if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0)
|
if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0)
|
||||||
{
|
currentWebDAVItems = _webDAV.getDataStructure(path);
|
||||||
//menubar
|
|
||||||
//explanation on first login?
|
|
||||||
//TODO here mark folders that are unsynced?
|
|
||||||
//compare both datasets, if fromDB etag is different, mark as unsycned
|
|
||||||
string tempPath = NEXTCLOUD_ROOT_PATH + Util::accessConfig(CONFIG_PATH, Action::IReadString,"UUID");
|
|
||||||
currentWebDAVItems = _webDAV.getDataStructure(tempPath);
|
|
||||||
fromDB = _sqllite.getItemsChildren(tempPath);
|
|
||||||
}
|
|
||||||
//TODO here or father below?
|
|
||||||
_menu = std::unique_ptr<MainMenu>(new MainMenu("Nextcloud"));
|
_menu = std::unique_ptr<MainMenu>(new MainMenu("Nextcloud"));
|
||||||
|
|
||||||
if(currentWebDAVItems.empty())
|
if(currentWebDAVItems.empty())
|
||||||
{
|
currentWebDAVItems = _sqllite.getItemsChildren(path);
|
||||||
//use from DB
|
else
|
||||||
//this one is always required --> if does not work -> say to the user that it did not work, to sync use
|
updateItems(currentWebDAVItems);
|
||||||
/*
|
|
||||||
vector<Item> Nextcloud::getOfflineStructure(const string &pathUrl)
|
if(currentWebDAVItems.empty())
|
||||||
{
|
|
||||||
if (pathUrl.compare(NEXTCLOUD_ROOT_PATH + getUUID() + "/") == 0)
|
|
||||||
{
|
|
||||||
Message(ICON_ERROR, "Error", "The root structure is not available offline. Please try again to login.", 2000);
|
|
||||||
logout();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Message(ICON_ERROR, "Error", "Could not login, please try again.", 1200);
|
|
||||||
if(fromDB.empty())
|
|
||||||
{
|
{
|
||||||
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Could not login and there is no DB available to restore information. What would you like to do?", "Logout", "Close App", NULL);
|
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Could not login and there is no DB available to restore information. What would you like to do?", "Logout", "Close App", NULL);
|
||||||
switch (dialogResult)
|
switch (dialogResult)
|
||||||
|
@ -69,8 +52,7 @@ EventHandler::EventHandler()
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
_webDAV.logout();
|
_webDAV.logout();
|
||||||
_loginView = std::unique_ptr<LoginView>(new LoginView(_menu->getContentRect()));
|
_loginView = std::make_unique<LoginView>(LoginView(_menu->getContentRect()));
|
||||||
FullUpdate();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -79,13 +61,11 @@ EventHandler::EventHandler()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_webDAVView = std::unique_ptr<WebDAVView>(new WebDAVView(_menu->getContentRect(), _currentWebDAVItems,1));
|
drawWebDAVItems(currentWebDAVItems);
|
||||||
_sqllite.saveItemsChildren(_currentWebDAVItems);
|
|
||||||
FullUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventHandler::eventDistributor(const int type, const int par1, const int par2)
|
int EventHandler::eventDistributor(const int type, const int par1, const int par2)
|
||||||
|
@ -236,7 +216,6 @@ std::unique_ptr<ContextMenu> _contextMenu;
|
||||||
|
|
||||||
void EventHandler::contextMenuHandler(const int index)
|
void EventHandler::contextMenuHandler(const int index)
|
||||||
{
|
{
|
||||||
//invert color
|
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
//Open
|
//Open
|
||||||
|
@ -364,97 +343,57 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::updatePBLibrary()
|
|
||||||
{
|
|
||||||
if (_webDAVView->getCurrentEntry().type == Itemtype::IFOLDER)
|
|
||||||
{
|
|
||||||
Util::updatePBLibrary(15);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if (_nextcloud.getItems().at(_tempItemID).isBook())
|
|
||||||
/*
|
|
||||||
* is needed twice!
|
|
||||||
if (_fileType.find("application/epub+zip") != string::npos ||
|
|
||||||
_fileType.find("application/pdf") != string::npos ||
|
|
||||||
_fileType.find("application/octet-stream") != string::npos ||
|
|
||||||
_fileType.find("text/plain") != string::npos ||
|
|
||||||
_fileType.find("text/html") != string::npos ||
|
|
||||||
_fileType.find("text/rtf") != string::npos ||
|
|
||||||
_fileType.find("application/msword") != string::npos ||
|
|
||||||
_fileType.find("application/x-mobipocket-ebook") != string::npos ||
|
|
||||||
_fileType.find("application/vnd.openxmlformats-officedocument.wordprocessingml.document") != string::npos ||
|
|
||||||
_fileType.find("application/x-fictionbook+xml") != string::npos)
|
|
||||||
Util::updatePBLibrary(5);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventHandler::startDownload()
|
|
||||||
{
|
|
||||||
OpenProgressbar(1, "Downloading...", "Checking network connection", 0, NULL);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//_nextcloud.download(_tempItemID);
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
Log::writeErrorLog(e.what());
|
|
||||||
Message(ICON_ERROR, "Error", "Something has gone wrong. Please check the logs. (/system/config/nextcloud/)", 1200);
|
|
||||||
}
|
|
||||||
updatePBLibrary();
|
|
||||||
|
|
||||||
CloseProgressbar();
|
|
||||||
_webDAVView->reDrawCurrentEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventHandler::openItem()
|
void EventHandler::openItem()
|
||||||
{
|
{
|
||||||
_webDAVView->invertCurrentEntryColor();
|
_webDAVView->invertCurrentEntryColor();
|
||||||
/*
|
if (_webDAVView->getCurrentEntry().state == FileState::ICLOUD)
|
||||||
if (_state == FileState::ICLOUD)
|
|
||||||
{
|
{
|
||||||
Message(ICON_ERROR, "File not found.", "Could not find file.", 1000);
|
Message(ICON_ERROR, "File not found.", "Could not find file.", 1000);
|
||||||
}
|
}
|
||||||
else if(isBook())
|
else if(_webDAVView->getCurrentEntry().fileType.find("application/epub+zip") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/pdf") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/octet-stream") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("text/plain") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("text/html") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("text/rtf") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/msword") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/x-mobipocket-ebook") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/vnd.openxmlformats-officedocument.wordprocessingml.document") != string::npos ||
|
||||||
|
_webDAVView->getCurrentEntry().fileType.find("application/x-fictionbook+xml") != string::npos)
|
||||||
{
|
{
|
||||||
|
OpenBook(_webDAVView->getCurrentEntry().localPath.c_str(), "", 0);
|
||||||
OpenBook(_localPath.c_str(), "", 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message(ICON_INFORMATION, "Warning", "The filetype is currently not supported.", 1200);
|
Message(ICON_INFORMATION, "Warning", "The filetype is currently not supported.", 1200);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//webDAVView->getCurrentEntry
|
|
||||||
//_nextcloud.getItems().at(_tempItemID).open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::openFolder()
|
void EventHandler::openFolder()
|
||||||
{
|
{
|
||||||
ShowHourglassForce();
|
ShowHourglassForce();
|
||||||
//_nextcloud.setItems(_nextcloud.getDataStructure(_tempPath));
|
|
||||||
//TODO if folder is unsynced sync
|
std::vector<WebDAVItem> currentWebDAVItems;
|
||||||
std::vector<WebDAVItem> currentWebDAVItems = _webDAV.getDataStructure(_webDAVView->getCurrentEntry().path);
|
|
||||||
|
if(_webDAVView->getCurrentEntry().state == FileState::IOUTSYNCED || _webDAVView->getCurrentEntry().state == FileState::ICLOUD)
|
||||||
|
currentWebDAVItems = _webDAV.getDataStructure(_webDAVView->getCurrentEntry().path);
|
||||||
|
|
||||||
|
if(currentWebDAVItems.empty())
|
||||||
|
currentWebDAVItems = _sqllite.getItemsChildren(_webDAVView->getCurrentEntry().path);
|
||||||
|
else
|
||||||
|
updateItems(currentWebDAVItems);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(currentWebDAVItems.empty())
|
if(currentWebDAVItems.empty())
|
||||||
{
|
{
|
||||||
Log::writeErrorLog("items empty");
|
Message(ICON_ERROR, "Error", "Could not sync the items and there is no offline copy available.", 1200);
|
||||||
HideHourglass();
|
HideHourglass();
|
||||||
_webDAVView->invertCurrentEntryColor();
|
_webDAVView->invertCurrentEntryColor();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::writeInfoLog("got new items");
|
drawWebDAVItems(currentWebDAVItems);
|
||||||
_sqllite.saveItemsChildren(currentWebDAVItems);
|
|
||||||
|
|
||||||
//if folder is synced, get only from DB
|
|
||||||
//vector<WebDAVItem> fromDB = _sqllite.getItemsChildren(_tempPath);
|
|
||||||
//get etags from DB, if etag for path is unchanged, stays the same, same for foldersjj
|
|
||||||
FillAreaRect(&_menu->getContentRect(), WHITE);
|
|
||||||
_webDAVView.release();
|
|
||||||
_webDAVView = std::unique_ptr<WebDAVView>(new WebDAVView(_menu->getContentRect(), _currentWebDAVItems,1));
|
|
||||||
//_sqllite.saveItemsChildren(_nextcloud.getItems());
|
|
||||||
PartialUpdate(_menu->getContentRect().x, _menu->getContentRect().y, _menu->getContentRect().w, _menu->getContentRect().h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue