mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 05:55:59 +03:00
Some restructuring that allows proper compilation on Windows systems.
Still not stable on Windows. Need to resolve sqlite3 issues.
This commit is contained in:
parent
efee4de678
commit
309760ab36
7 changed files with 51 additions and 29 deletions
|
@ -37,9 +37,10 @@
|
|||
#include <QComboBox>
|
||||
|
||||
OwnCloudSync::OwnCloudSync(QString name, OwnPasswordManager *passwordManager,
|
||||
QSet<QString> *globalFilters)
|
||||
QSet<QString> *globalFilters,
|
||||
QString configDir)
|
||||
: mAccountName(name),mPasswordManager(passwordManager),
|
||||
mGlobalFilters(globalFilters)
|
||||
mGlobalFilters(globalFilters),mConfigDirectory(configDir)
|
||||
{
|
||||
mBusy = false;
|
||||
mIsPaused = false;
|
||||
|
@ -87,21 +88,11 @@ OwnCloudSync::OwnCloudSync(QString name, OwnPasswordManager *passwordManager,
|
|||
|
||||
// Initialize the Database
|
||||
mDB = QSqlDatabase::addDatabase("QSQLITE",mAccountName);
|
||||
#ifdef Q_OS_LINUX
|
||||
// In linux, we will store all databases in
|
||||
// $HOME/.local/share/data/owncloud_sync
|
||||
mHomeDirectory = QDir::home().path();
|
||||
mConfigDirectory = mHomeDirectory+"/.local/share/data/owncloud_sync";
|
||||
QDir configDir(mConfigDirectory);
|
||||
configDir.mkpath(mConfigDirectory);
|
||||
QDir logsDir(mConfigDirectory+"/logs");
|
||||
logsDir.mkpath(mConfigDirectory+"/logs");
|
||||
//mDB.setDatabaseName(mConfigDirectory+"/owncloud_sync.db");
|
||||
mDB.setDatabaseName(":memory:"); // Use memory for now
|
||||
mDBFileName = mConfigDirectory+"/"+mAccountName+".db";
|
||||
#endif
|
||||
mDBFileName = QDir::toNativeSeparators(mConfigDirectory+"/")+mAccountName+".db";
|
||||
|
||||
// Find out if the database exists.
|
||||
QFile dbFile(mConfigDirectory+"/"+mAccountName+".db");
|
||||
QFile dbFile(mDBFileName);
|
||||
if( dbFile.exists() ) {
|
||||
if(!mDB.open()) {
|
||||
syncDebug() << "Cannot open database!";
|
||||
|
@ -1163,7 +1154,7 @@ void OwnCloudSync::localDirectoryChanged(QString name)
|
|||
{
|
||||
// Maybe this was caused by us renaming a file, just wait it out
|
||||
while (mFileAccessBusy ) {
|
||||
sleep(1);
|
||||
//sleep(1);
|
||||
}
|
||||
// If it was caused by one directory being deleted, then delete it now
|
||||
// and don't scan it!
|
||||
|
@ -1576,7 +1567,7 @@ void OwnCloudSync::deleteAccount()
|
|||
|
||||
// Delete the database
|
||||
mDB.close();
|
||||
QFile dbFile(mConfigDirectory+"/"+mAccountName+".db");
|
||||
QFile dbFile(mDBFileName);
|
||||
dbFile.remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class OwnCloudSync : public QObject
|
|||
|
||||
public:
|
||||
explicit OwnCloudSync(QString name, OwnPasswordManager *passwordManager,
|
||||
QSet<QString> *globalFilters);
|
||||
QSet<QString> *globalFilters,QString configDir);
|
||||
~OwnCloudSync();
|
||||
void initialize(QString host, QString user, QString pass, QString remote,
|
||||
QString local, qint64 time);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
OwnPasswordManager::OwnPasswordManager(QObject *parent, WId winID )
|
||||
: QObject(parent)
|
||||
{
|
||||
mIsReady = false;
|
||||
#ifdef Q_OS_LINUX
|
||||
QProcess p;
|
||||
QStringList args;
|
||||
|
@ -32,9 +33,18 @@ OwnPasswordManager::OwnPasswordManager(QObject *parent, WId winID )
|
|||
}
|
||||
#endif // OCS_USE_KWALLET
|
||||
if(mPasswordManagerLinux != KWALLET ) {
|
||||
mIsReady = true;
|
||||
emit managerReady();
|
||||
}
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
#ifdef Q_OS_MAC_OS_X
|
||||
mIsReady = true;
|
||||
#endif // Q_OS_MAC_OS_X
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
mIsReady = true;
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
bool OwnPasswordManager::savePassword(QString name, QString pass)
|
||||
|
@ -45,8 +55,10 @@ bool OwnPasswordManager::savePassword(QString name, QString pass)
|
|||
if(mPasswordManagerLinux == KWALLET) {
|
||||
QMap<QString,QString> map;
|
||||
map[name] = pass;
|
||||
if( mKWallet )
|
||||
if( mKWallet ) {
|
||||
mKWallet->writeMap(name,map);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -107,6 +119,7 @@ void OwnPasswordManager::kwalletOpened(bool ok)
|
|||
if( ok && (mKWallet->hasFolder("owncloud_sync")
|
||||
|| mKWallet->createFolder("owncloud_sync"))
|
||||
&& mKWallet->setFolder("owncloud_sync") ){
|
||||
mIsReady = true;
|
||||
emit managerReady();
|
||||
//emit toLog("Wallet opened!");
|
||||
syncDebug() << "Wallet opened!";
|
||||
|
|
|
@ -31,8 +31,10 @@ public:
|
|||
OwnPasswordManager(QObject *parent = 0, WId winId = 0);
|
||||
bool savePassword(QString name, QString pass);
|
||||
QString getPassword(QString name);
|
||||
bool isReady() { return mIsReady; }
|
||||
|
||||
private:
|
||||
bool mIsReady;
|
||||
#ifdef Q_OS_LINUX
|
||||
enum PasswordManagerLinux {
|
||||
NONE,
|
||||
|
|
|
@ -53,6 +53,7 @@ SyncWindow::SyncWindow(QWidget *parent) :
|
|||
ui(new Ui::SyncWindow)
|
||||
{
|
||||
hide();
|
||||
mProcessedPasswordManager = false;
|
||||
mSharedFilters = new QSet<QString>();
|
||||
mIncludedFilters = g_GetIncludedFilterList();
|
||||
mQuitAction = false;
|
||||
|
@ -99,16 +100,20 @@ SyncWindow::SyncWindow(QWidget *parent) :
|
|||
connect(mAccountsSignalMapper, SIGNAL(mapped(int)), this,
|
||||
SLOT(slotAccountsSignalMapper(int)));
|
||||
|
||||
mConfigDirectory = QDir::toNativeSeparators(QDir::homePath());
|
||||
#ifdef Q_OS_LINUX
|
||||
// In linux, we will store all databases in
|
||||
// $HOME/.local/share/data/owncloud_sync
|
||||
mConfigDirectory = QDir::home().path()+"/.local/share/data/owncloud_sync";
|
||||
mConfigDirectory += QDir::toNativeSeparators("/.local/share/data/)";
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
mConfigDirectory += QDir::toNativeSeparators("/AppData/Local/");
|
||||
#endif
|
||||
mConfigDirectory += "owncloud_sync";
|
||||
QDir configDir(mConfigDirectory);
|
||||
configDir.mkpath(mConfigDirectory);
|
||||
QDir logsDir(mConfigDirectory+"/logs");
|
||||
logsDir.mkpath(mConfigDirectory+"/logs");
|
||||
#endif
|
||||
|
||||
QDir logsDir(QDir::toNativeSeparators(mConfigDirectory+"/logs"));
|
||||
logsDir.mkpath(QDir::toNativeSeparators(mConfigDirectory+"/logs"));
|
||||
importGlobalFilters(true);
|
||||
updateSharedFilterList();
|
||||
|
||||
|
@ -116,19 +121,25 @@ SyncWindow::SyncWindow(QWidget *parent) :
|
|||
mPasswordManager = new OwnPasswordManager(this,winId());
|
||||
connect(mPasswordManager,SIGNAL(managerReady()),
|
||||
this,SLOT(passwordManagerReady()));
|
||||
|
||||
// Check if the passwordManager is already ready
|
||||
if(mPasswordManager->isReady() && !mProcessedPasswordManager) {
|
||||
passwordManagerReady();
|
||||
}
|
||||
}
|
||||
|
||||
void SyncWindow::passwordManagerReady()
|
||||
{
|
||||
mProcessedPasswordManager = true;
|
||||
// Look for accounts that already exist
|
||||
QDir configDir(mConfigDirectory);
|
||||
configDir.mkpath(mConfigDirectory);
|
||||
QStringList filters;
|
||||
filters << "*.db";
|
||||
QStringList files = configDir.entryList(filters);
|
||||
for( int i = 0; i < files.size(); i++ ) {
|
||||
QString name = files[i].replace(".db","");
|
||||
addAccount(name);
|
||||
syncDebug() << "Found account: " << name;
|
||||
}
|
||||
if( files.size() == 0 ) {
|
||||
on_buttonNewAccount_clicked();
|
||||
|
@ -187,10 +198,12 @@ SyncWindow::~SyncWindow()
|
|||
void SyncWindow::saveLogs()
|
||||
{
|
||||
QString name =
|
||||
QDateTime::currentDateTime().toString("yyyyMMdd:hh:mm:ss.log");
|
||||
QFile file(mConfigDirectory+"/logs/"+name);
|
||||
QDateTime::currentDateTime().toString("yyyyMMdd_hh_mm_ss.log");
|
||||
QFile file(QDir::toNativeSeparators(mConfigDirectory+"/logs/"+name));
|
||||
if( !file.open(QIODevice::WriteOnly)) {
|
||||
syncDebug() << "Could not open log file for writting!\n";
|
||||
syncDebug() << "Could not open log file for writting!"
|
||||
<< QDir::toNativeSeparators(mConfigDirectory+"/logs/"+name)
|
||||
<< file.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -236,7 +249,7 @@ void SyncWindow::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
|
|||
OwnCloudSync* SyncWindow::addAccount(QString name)
|
||||
{
|
||||
OwnCloudSync *account = new OwnCloudSync(name,mPasswordManager,
|
||||
mSharedFilters);
|
||||
mSharedFilters,mConfigDirectory);
|
||||
mAccounts.append(account);
|
||||
mAccountNames.append(name);
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
bool mHideOnClose;
|
||||
qint64 mSaveLogCounter;
|
||||
qint64 mSaveDBTime;
|
||||
bool mProcessedPasswordManager;
|
||||
|
||||
QIcon mDefaultIcon;
|
||||
QIcon mSyncIcon;
|
||||
|
|
|
@ -70,6 +70,8 @@ unix:!macx:!symbian: LIBS += -L/usr/lib/ -lsqlite3
|
|||
unix:!macx:!symbian: LIBS += -L/usr/lib/kde4/devel -lkparts -lkdeui -lkdecore
|
||||
}
|
||||
|
||||
win32: LIBS += -lsqlite3
|
||||
|
||||
#linux-g++ {
|
||||
#message(On Linux)
|
||||
#}
|
||||
|
|
Loading…
Reference in a new issue