From 1af3b165c9377702ca62a64112bc089a6f575c30 Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Tue, 21 Oct 2014 22:48:19 -0400 Subject: Imported Upstream version 2.0~beta2 --- src/frontend/bookshelfmanager/btinstallmgr.cpp | 94 ++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/frontend/bookshelfmanager/btinstallmgr.cpp (limited to 'src/frontend/bookshelfmanager/btinstallmgr.cpp') diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp new file mode 100644 index 0000000..d0bc760 --- /dev/null +++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp @@ -0,0 +1,94 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2008 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + +//BibleTime includes +#include "btinstallmgr.h" + +#include "frontend/bookshelfmanager/instbackend.h" +#include "backend/managers/cswordbackend.h" + +//Qt includes +#include +#include +#include +#include + +#include + +//sword includes +#include +#include + +using namespace sword; + + +BtInstallMgr::BtInstallMgr() + : InstallMgr(instbackend::configPath().toLatin1(), this), + m_firstCallOfPreStatus(true) +{ //use this class also as status reporter + qDebug("BtInstallMgr::BtInstallMgr"); + this->setFTPPassive(true); +#ifdef SWORD_INTERNET_WARNING + // this was in 1.6RC1, removed in RC2. To be removed from here soon - uncomment this and comment out the isUserDisclaimerConfirmed if you need to use RC1. + //setUserDisclaimerConfirmed(true); +#endif +} + +BtInstallMgr::~BtInstallMgr() { + //doesn't really help because it only sets a flag + terminate(); //make sure to close the connection +} + +#ifdef SWORD_INTERNET_WARNING +bool BtInstallMgr::isUserDisclaimerConfirmed() const +{ + // TODO: Check from config if it's been confirmed with "don't show this anymore" checked. + // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default. + return true; +} +#endif + +void BtInstallMgr::statusUpdate(double dltotal, double dlnow) +{ + //qDebug("BtInstallMgr::statusUpdate"); + if (dlnow > dltotal) + dlnow = dltotal; + + int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0); + + if (totalPercent > 100) { + totalPercent = 100; + } + else if (totalPercent < 0) { + totalPercent = 0; + } + + int filePercent = (int)((float)(dlnow) / (float)(dltotal+1) * 100.0); + if (filePercent > 100) { + filePercent = 100; + } + else if (filePercent < 0) { + filePercent = 0; + } + //qApp->processEvents(); + //qDebug() << "status: total"< 0) ? totalBytes : 1; //avoid division by zero +} -- cgit v1.2.3