Move Utility to a new common static library

Now that csync builds as C++, this will avoid having to implement
functionalities needed by csync mandatorily in csync itself.

This library is built as part of libocsync and symbols exported
through it.
This requires a relicense of Utility as LGPL. All classes moved into
this library from src/libsync will need to be relicensed as well.
This commit is contained in:
Jocelyn Turcotte 2017-08-16 08:36:52 +02:00 committed by Roeland Jago Douma
parent 6d8c98f6b4
commit bfc7ea562d
No known key found for this signature in database
GPG Key ID: F941078878347C0C
76 changed files with 298 additions and 263 deletions

View File

@ -41,7 +41,13 @@ endif()
include(Warnings)
include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
# For config.h
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# Allows includes based on src/ like #include "common/utility.h" or #include "csync/csync.h"
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/src
)
# disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
@ -211,13 +217,8 @@ endif()
file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
set(TRANSLATIONS ${TRANS_FILES})
if(UNIT_TESTING)
# Make sure we set this before recursing into child folders.
set(WITH_TESTING ON)
include(CTest)
enable_testing()
add_subdirectory(test)
endif(UNIT_TESTING)
# Make sure we set this before recursing into child folders.
set(WITH_TESTING ${UNIT_TESTING})
add_subdirectory(src)
if(NOT BUILD_LIBRARIES_ONLY)
@ -227,7 +228,14 @@ add_subdirectory(doc/dev)
add_subdirectory(admin)
endif(NOT BUILD_LIBRARIES_ONLY)
if(UNIT_TESTING)
include(CTest)
enable_testing()
add_subdirectory(test)
endif(UNIT_TESTING)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
if(BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)

View File

@ -12,7 +12,7 @@
* for more details.
*/
#include "configfile.h"
#include "utility.h"
#include "common/utility.h"
#include "account.h"
#include "simplesslerrorhandler.h"

2
src/common/README Normal file
View File

@ -0,0 +1,2 @@
This folder contains code covered by the CLA being licensed as LGPL.
This allows it to be linked together with the rest of the LGPL code in csync.

6
src/common/common.cmake Normal file
View File

@ -0,0 +1,6 @@
# Just list files to build as part of the csync dynamic lib.
# Essentially they could be in the same directory but are separate to
# help keep track of the different code licenses.
set(common_SOURCES
${CMAKE_CURRENT_LIST_DIR}/utility.cpp
)

View File

@ -2,22 +2,24 @@
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "utility.h"
#include "common/utility.h"
#include "version.h"
#include "configfile.h"
// Note: This file must compile without QtGui
#include <QCoreApplication>
@ -384,51 +386,6 @@ bool Utility::hasDarkSystray()
}
bool Utility::isWindows()
{
#ifdef Q_OS_WIN
return true;
#else
return false;
#endif
}
bool Utility::isMac()
{
#ifdef Q_OS_MAC
return true;
#else
return false;
#endif
}
bool Utility::isUnix()
{
#ifdef Q_OS_UNIX
return true;
#else
return false;
#endif
}
bool Utility::isLinux()
{
#if defined(Q_OS_LINUX)
return true;
#else
return false;
#endif
}
bool Utility::isBSD()
{
#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD)
return true;
#else
return false;
#endif
}
QString Utility::platformName()
{
QString re("Windows");
@ -611,18 +568,4 @@ QUrl Utility::concatUrlPath(const QUrl &url, const QString &concatPath,
return tmpUrl;
}
Q_GLOBAL_STATIC(QString, g_configFileName)
std::unique_ptr<QSettings> Utility::settingsWithGroup(const QString &group, QObject *parent)
{
if (g_configFileName()->isEmpty()) {
// cache file name
ConfigFile cfg;
*g_configFileName() = cfg.configFile();
}
std::unique_ptr<QSettings> settings(new QSettings(*g_configFileName(), QSettings::IniFormat, parent));
settings->beginGroup(group);
return settings;
}
} // namespace OCC

View File

@ -2,21 +2,25 @@
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef UTILITY_H
#define UTILITY_H
#include "owncloudlib.h"
#include "ocsynclib.h"
#include <QString>
#include <QByteArray>
#include <QDateTime>
@ -36,22 +40,22 @@ Q_DECLARE_LOGGING_CATEGORY(lcUtility)
* @{
*/
namespace Utility {
OWNCLOUDSYNC_EXPORT void sleep(int sec);
OWNCLOUDSYNC_EXPORT void usleep(int usec);
OWNCLOUDSYNC_EXPORT QString formatFingerprint(const QByteArray &, bool colonSeparated = true);
OWNCLOUDSYNC_EXPORT void setupFavLink(const QString &folder);
OWNCLOUDSYNC_EXPORT bool writeRandomFile(const QString &fname, int size = -1);
OWNCLOUDSYNC_EXPORT QString octetsToString(qint64 octets);
OWNCLOUDSYNC_EXPORT QByteArray userAgentString();
OWNCLOUDSYNC_EXPORT bool hasLaunchOnStartup(const QString &appName);
OWNCLOUDSYNC_EXPORT void setLaunchOnStartup(const QString &appName, const QString &guiName, bool launch);
OCSYNC_EXPORT void sleep(int sec);
OCSYNC_EXPORT void usleep(int usec);
OCSYNC_EXPORT QString formatFingerprint(const QByteArray &, bool colonSeparated = true);
OCSYNC_EXPORT void setupFavLink(const QString &folder);
OCSYNC_EXPORT bool writeRandomFile(const QString &fname, int size = -1);
OCSYNC_EXPORT QString octetsToString(qint64 octets);
OCSYNC_EXPORT QByteArray userAgentString();
OCSYNC_EXPORT bool hasLaunchOnStartup(const QString &appName);
OCSYNC_EXPORT void setLaunchOnStartup(const QString &appName, const QString &guiName, bool launch);
/**
* Return the amount of free space available.
*
* \a path must point to a directory
*/
OWNCLOUDSYNC_EXPORT qint64 freeDiskSpace(const QString &path);
OCSYNC_EXPORT qint64 freeDiskSpace(const QString &path);
/**
* @brief compactFormatDouble - formats a double value human readable.
@ -61,14 +65,14 @@ namespace Utility {
* @param unit an optional unit that is appended if present.
* @return the formatted string.
*/
OWNCLOUDSYNC_EXPORT QString compactFormatDouble(double value, int prec, const QString &unit = QString::null);
OCSYNC_EXPORT QString compactFormatDouble(double value, int prec, const QString &unit = QString::null);
// porting methods
OWNCLOUDSYNC_EXPORT QString escape(const QString &);
OCSYNC_EXPORT QString escape(const QString &);
// conversion function QDateTime <-> time_t (because the ones builtin work on only unsigned 32bit)
OWNCLOUDSYNC_EXPORT QDateTime qDateTimeFromTime_t(qint64 t);
OWNCLOUDSYNC_EXPORT qint64 qDateTimeToTime_t(const QDateTime &t);
OCSYNC_EXPORT QDateTime qDateTimeFromTime_t(qint64 t);
OCSYNC_EXPORT qint64 qDateTimeToTime_t(const QDateTime &t);
/**
* @brief Convert milliseconds duration to human readable string.
@ -81,8 +85,8 @@ namespace Utility {
* durationToDescriptiveString2 uses two units where possible, so
* "5 minutes 43 seconds" or "1 month 3 days".
*/
OWNCLOUDSYNC_EXPORT QString durationToDescriptiveString1(quint64 msecs);
OWNCLOUDSYNC_EXPORT QString durationToDescriptiveString2(quint64 msecs);
OCSYNC_EXPORT QString durationToDescriptiveString1(quint64 msecs);
OCSYNC_EXPORT QString durationToDescriptiveString2(quint64 msecs);
/**
* @brief hasDarkSystray - determines whether the systray is dark or light.
@ -94,38 +98,38 @@ namespace Utility {
*
* @return bool which is true for systems with dark systray.
*/
OWNCLOUDSYNC_EXPORT bool hasDarkSystray();
OCSYNC_EXPORT bool hasDarkSystray();
// convenience OS detection methods
OWNCLOUDSYNC_EXPORT bool isWindows();
OWNCLOUDSYNC_EXPORT bool isMac();
OWNCLOUDSYNC_EXPORT bool isUnix();
OWNCLOUDSYNC_EXPORT bool isLinux(); // use with care
OWNCLOUDSYNC_EXPORT bool isBSD(); // use with care, does not match OS X
inline bool isWindows();
inline bool isMac();
inline bool isUnix();
inline bool isLinux(); // use with care
inline bool isBSD(); // use with care, does not match OS X
OWNCLOUDSYNC_EXPORT QString platformName();
OCSYNC_EXPORT QString platformName();
// crash helper for --debug
OWNCLOUDSYNC_EXPORT void crash();
OCSYNC_EXPORT void crash();
// Case preserving file system underneath?
// if this function returns true, the file system is case preserving,
// that means "test" means the same as "TEST" for filenames.
// if false, the two cases are two different files.
OWNCLOUDSYNC_EXPORT bool fsCasePreserving();
OCSYNC_EXPORT bool fsCasePreserving();
// Check if two pathes that MUST exist are equal. This function
// uses QDir::canonicalPath() to judge and cares for the systems
// case sensitivity.
OWNCLOUDSYNC_EXPORT bool fileNamesEqual(const QString &fn1, const QString &fn2);
OCSYNC_EXPORT bool fileNamesEqual(const QString &fn1, const QString &fn2);
// Call the given command with the switch --version and rerun the first line
// of the output.
// If command is empty, the function calls the running application which, on
// Linux, might have changed while this one is running.
// For Mac and Windows, it returns QString()
OWNCLOUDSYNC_EXPORT QByteArray versionOfInstalledBinary(const QString &command = QString());
OCSYNC_EXPORT QByteArray versionOfInstalledBinary(const QString &command = QString());
OWNCLOUDSYNC_EXPORT QString fileNameForGuiUse(const QString &fName);
OCSYNC_EXPORT QString fileNameForGuiUse(const QString &fName);
/**
* @brief timeAgoInWords - human readable time span
@ -135,9 +139,9 @@ namespace Utility {
*
* If the second parameter is ommitted, the current time is used.
*/
OWNCLOUDSYNC_EXPORT QString timeAgoInWords(const QDateTime &dt, const QDateTime &from = QDateTime());
OCSYNC_EXPORT QString timeAgoInWords(const QDateTime &dt, const QDateTime &from = QDateTime());
class OWNCLOUDSYNC_EXPORT StopWatch
class OCSYNC_EXPORT StopWatch
{
private:
QMap<QString, quint64> _lapTimes;
@ -159,17 +163,63 @@ namespace Utility {
/**
* @brief Sort a QStringList in a way that's appropriate for filenames
*/
OWNCLOUDSYNC_EXPORT void sortFilenames(QStringList &fileNames);
OCSYNC_EXPORT void sortFilenames(QStringList &fileNames);
/** Appends concatPath and queryItems to the url */
OWNCLOUDSYNC_EXPORT QUrl concatUrlPath(
OCSYNC_EXPORT QUrl concatUrlPath(
const QUrl &url, const QString &concatPath,
const QList<QPair<QString, QString>> &queryItems = (QList<QPair<QString, QString>>()));
/** Returns a new settings pre-set in a specific group. The Settings will be created
with the given parent. If no parent is specified, the caller must destroy the settings */
OWNCLOUDSYNC_EXPORT std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = 0);
OCSYNC_EXPORT std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = 0);
}
/** @} */ // \addtogroup
inline bool Utility::isWindows()
{
#ifdef Q_OS_WIN
return true;
#else
return false;
#endif
}
inline bool Utility::isMac()
{
#ifdef Q_OS_MAC
return true;
#else
return false;
#endif
}
inline bool Utility::isUnix()
{
#ifdef Q_OS_UNIX
return true;
#else
return false;
#endif
}
inline bool Utility::isLinux()
{
#if defined(Q_OS_LINUX)
return true;
#else
return false;
#endif
}
inline bool Utility::isBSD()
{
#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD)
return true;
#else
return false;
#endif
}
}
#endif // UTILITY_H

View File

@ -1,15 +1,19 @@
/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <CoreServices/CoreServices.h>

View File

@ -2,15 +2,19 @@
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)

View File

@ -1,15 +1,19 @@
/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _WIN32_WINNT 0x0600

View File

@ -20,6 +20,7 @@ include(MacroCopyFile)
find_package(SQLite3 3.8.0 REQUIRED)
include(ConfigureChecks.cmake)
include(../common/common.cmake)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@ -117,11 +118,10 @@ include_directories(
${CSYNC_PRIVATE_INCLUDE_DIRS}
)
add_library(${CSYNC_LIBRARY} SHARED ${csync_SRCS})
add_library(${CSYNC_LIBRARY} SHARED ${common_SOURCES} ${csync_SRCS})
#add_library(${CSYNC_LIBRARY}_static STATIC ${csync_SRCS})
generate_export_header( ${CSYNC_LIBRARY}
BASE_NAME ${CSYNC_LIBRARY}
EXPORT_MACRO_NAME OCSYNC_EXPORT
EXPORT_FILE_NAME ocsynclib.h
)
@ -129,6 +129,16 @@ generate_export_header( ${CSYNC_LIBRARY}
target_link_libraries(${CSYNC_LIBRARY} ${CSYNC_LINK_LIBRARIES})
#target_link_libraries(${CSYNC_LIBRARY}_static ${CSYNC_LINK_LIBRARIES})
find_package(Qt5Core REQUIRED)
qt5_use_modules(${CSYNC_LIBRARY} Core)
# For src/common/utility_mac.cpp
if (APPLE)
find_library(FOUNDATION_LIBRARY NAMES Foundation)
find_library(CORESERVICES_LIBRARY NAMES CoreServices)
target_link_libraries(${CSYNC_LIBRARY} ${FOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY})
endif()
set_target_properties(
${CSYNC_LIBRARY}
PROPERTIES

View File

@ -36,9 +36,5 @@ include_directories(
add_library(${CSTDLIB_LIBRARY} STATIC ${cstdlib_SRCS})
if(NOT WIN32)
add_definitions( -fPIC )
qt5_use_modules(${CSTDLIB_LIBRARY} Core)
endif()
if(NOT HAVE_FNMATCH AND WIN32)
# needed for PathMatchSpec for our fnmatch replacement
target_link_libraries(${CSTDLIB_LIBRARY} ${SHLWAPI_LIBRARY})
endif()
qt5_use_modules(${CSTDLIB_LIBRARY} Core)

View File

@ -13,6 +13,7 @@
*/
#include "accountmanager.h"
#include "configfile.h"
#include "sslerrordialog.h"
#include "proxyauthhandler.h"
#include <theme.h>
@ -47,7 +48,7 @@ AccountManager *AccountManager::instance()
bool AccountManager::restore()
{
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
if (settings->status() != QSettings::NoError) {
qCWarning(lcAccountManager) << "Could not read settings from" << settings->fileName()
<< settings->status();
@ -81,7 +82,7 @@ bool AccountManager::restoreFromLegacySettings()
<< Theme::instance()->appName();
// try to open the correctly themed settings
auto settings = Utility::settingsWithGroup(Theme::instance()->appName());
auto settings = ConfigFile::settingsWithGroup(Theme::instance()->appName());
// if the settings file could not be opened, the childKeys list is empty
// then try to load settings from a very old place
@ -134,7 +135,7 @@ bool AccountManager::restoreFromLegacySettings()
void AccountManager::save(bool saveCredentials)
{
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->setValue(QLatin1String(versionC), 2);
foreach (const auto &acc, _accounts) {
settings->beginGroup(acc->account()->id());
@ -150,7 +151,7 @@ void AccountManager::save(bool saveCredentials)
void AccountManager::saveAccount(Account *a)
{
qCInfo(lcAccountManager) << "Saving account" << a->url().toString();
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->beginGroup(a->id());
saveAccountHelper(a, *settings, false); // don't save credentials they might not have been loaded yet
settings->endGroup();
@ -162,7 +163,7 @@ void AccountManager::saveAccount(Account *a)
void AccountManager::saveAccountState(AccountState *a)
{
qCInfo(lcAccountManager) << "Saving account state" << a->account()->url().toString();
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->beginGroup(a->account()->id());
a->writeToSettings(*settings);
settings->endGroup();
@ -308,7 +309,7 @@ void AccountManager::deleteAccount(AccountState *account)
account->account()->credentials()->forgetSensitiveData();
QFile::remove(account->account()->cookieJarPath());
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->remove(account->account()->id());
emit accountRemoved(account);

View File

@ -21,7 +21,7 @@
#include "folderwizard.h"
#include "folderstatusmodel.h"
#include "folderstatusdelegate.h"
#include "utility.h"
#include "common/utility.h"
#include "application.h"
#include "configfile.h"
#include "account.h"

View File

@ -356,7 +356,7 @@ void AccountState::slotCredentialsAsked(AbstractCredentials *credentials)
std::unique_ptr<QSettings> AccountState::settings()
{
auto s = Utility::settingsWithGroup(QLatin1String("Accounts"));
auto s = ConfigFile::settingsWithGroup(QLatin1String("Accounts"));
s->beginGroup(_account->id());
return s;
}

View File

@ -17,8 +17,8 @@
#define ACCOUNTINFO_H
#include <QByteArray>
#include <QElapsedTimer>
#include <QPointer>
#include "utility.h"
#include "connectionvalidator.h"
#include "creds/abstractcredentials.h"
#include <memory>

View File

@ -18,7 +18,6 @@
#include "folderstatusmodel.h"
#include "folderman.h"
#include "accountstate.h"
#include "utility.h"
#include <theme.h>
#include <account.h>

View File

@ -21,7 +21,6 @@
#include "activitywidget.h"
#include "syncresult.h"
#include "logger.h"
#include "utility.h"
#include "theme.h"
#include "folderman.h"
#include "syncfileitem.h"

View File

@ -30,7 +30,6 @@
#include "socketapi.h"
#include "sslerrordialog.h"
#include "theme.h"
#include "utility.h"
#include "clientproxy.h"
#include "sharedialog.h"
#include "accountmanager.h"

View File

@ -26,6 +26,7 @@
#include "accessmanager.h"
#include "account.h"
#include "configfile.h"
#include "theme.h"
#include "cookiejar.h"
#include "owncloudgui.h"
@ -131,7 +132,7 @@ void ShibbolethCredentials::fetchFromKeychain()
} else {
_url = _account->url();
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setSettings(ConfigFile::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setInsecureFallback(false);
job->setKey(keychainKey(_account->url().toString(), user()));
connect(job, SIGNAL(finished(QKeychain::Job *)), SLOT(slotReadJobDone(QKeychain::Job *)));
@ -250,7 +251,7 @@ void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job)
addToCookieJar(_shibCookie);
}
// access
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setSettings(ConfigFile::settingsWithGroup(Theme::instance()->appName(), job).release());
_ready = true;
_stillValid = true;
@ -309,7 +310,7 @@ QByteArray ShibbolethCredentials::shibCookieName()
void ShibbolethCredentials::storeShibCookie(const QNetworkCookie &cookie)
{
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setSettings(ConfigFile::settingsWithGroup(Theme::instance()->appName(), job).release());
// we don't really care if it works...
//connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotWriteJobDone(QKeychain::Job*)));
job->setKey(keychainKey(_account->url().toString(), user()));
@ -320,7 +321,7 @@ void ShibbolethCredentials::storeShibCookie(const QNetworkCookie &cookie)
void ShibbolethCredentials::removeShibCookie()
{
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setSettings(ConfigFile::settingsWithGroup(Theme::instance()->appName(), job).release());
job->setKey(keychainKey(_account->url().toString(), user()));
job->start();
}

View File

@ -24,7 +24,6 @@
#include "networkjobs.h"
#include "syncjournalfilerecord.h"
#include "syncresult.h"
#include "utility.h"
#include "clientproxy.h"
#include "syncengine.h"
#include "syncrunfilelog.h"

View File

@ -199,7 +199,7 @@ int FolderMan::setupFolders()
{
unloadAndDeleteAllFolders();
auto settings = Utility::settingsWithGroup(QLatin1String("Accounts"));
auto settings = ConfigFile::settingsWithGroup(QLatin1String("Accounts"));
const auto accountsWithSettings = settings->childGroups();
if (accountsWithSettings.isEmpty()) {
int r = setupFoldersMigration();

View File

@ -18,7 +18,6 @@
#include "folderstatusmodel.h"
#include "folderman.h"
#include "accountstate.h"
#include "utility.h"
#include <theme.h>
#include <account.h>

View File

@ -15,7 +15,6 @@
#include "folderstatusmodel.h"
#include "folderman.h"
#include "accountstate.h"
#include "utility.h"
#include "asserts.h"
#include <theme.h>
#include <account.h>

View File

@ -18,7 +18,6 @@
#include "theme.h"
#include "configfile.h"
#include "application.h"
#include "utility.h"
#include "configfile.h"
#include "owncloudsetupwizard.h"
#include "accountmanager.h"

View File

@ -21,7 +21,6 @@
#include "configfile.h"
#include "syncresult.h"
#include "logger.h"
#include "utility.h"
#include "theme.h"
#include "folderman.h"
#include "syncfileitem.h"

View File

@ -23,7 +23,7 @@
#include "application.h"
#include "theme.h"
#include "utility.h"
#include "common/utility.h"
#include "cocoainitializer.h"
#include "updater/updater.h"

View File

@ -18,7 +18,6 @@
#include "theme.h"
#include "configfile.h"
#include "application.h"
#include "utility.h"
#include "configfile.h"
#include "folderman.h"

View File

@ -14,7 +14,7 @@
#include "notificationwidget.h"
#include "QProgressIndicator.h"
#include "utility.h"
#include "common/utility.h"
#include "asserts.h"
#include <QPushButton>

View File

@ -14,7 +14,7 @@
*/
#include "openfilemanager.h"
#include "utility.h"
#include "common/utility.h"
#include <QProcess>
#include <QSettings>
#include <QDir>

View File

@ -17,7 +17,6 @@
#include "theme.h"
#include "folderman.h"
#include "configfile.h"
#include "utility.h"
#include "progressdispatcher.h"
#include "owncloudsetupwizard.h"
#include "sharedialog.h"

View File

@ -24,7 +24,6 @@
#include "owncloudsetupwizard.h"
#include "configfile.h"
#include "folderman.h"
#include "utility.h"
#include "accessmanager.h"
#include "account.h"
#include "networkjobs.h"

View File

@ -21,7 +21,6 @@
#include "configfile.h"
#include "syncresult.h"
#include "logger.h"
#include "utility.h"
#include "theme.h"
#include "folderman.h"
#include "syncfileitem.h"

View File

@ -20,7 +20,6 @@
#include "configfile.h"
#include "folderman.h"
#include "folder.h"
#include "utility.h"
#include "theme.h"
#include "syncjournalfilerecord.h"
#include "syncengine.h"

View File

@ -15,7 +15,6 @@
#include "sslbutton.h"
#include "account.h"
#include "accountstate.h"
#include "utility.h"
#include "theme.h"
#include <QMenu>

View File

@ -12,7 +12,6 @@
* for more details.
*/
#include "configfile.h"
#include "utility.h"
#include "sslerrordialog.h"
#include <QtGui>

View File

@ -15,7 +15,7 @@
#include <QRegExp>
#include "syncrunfilelog.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include <qfileinfo.h>

View File

@ -14,7 +14,7 @@
#include "theme.h"
#include "configfile.h"
#include "utility.h"
#include "common/utility.h"
#include "accessmanager.h"
#include "updater/ocupdater.h"

View File

@ -20,8 +20,6 @@
#include "updater/sparkleupdater.h"
#include "utility.h"
// Does not work yet
@interface DelegateObject : NSObject <SUUpdaterDelegate>
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle;

View File

@ -19,9 +19,9 @@
#include "updater/sparkleupdater.h"
#include "updater/ocupdater.h"
#include "version.h"
#include "theme.h"
#include "utility.h"
#include "common/utility.h"
#include "version.h"
#include "config.h"

View File

@ -14,7 +14,6 @@
*/
#include "wizard/owncloudconnectionmethoddialog.h"
#include "utility.h"
#include <QUrl>
namespace OCC {

View File

@ -1,8 +1,6 @@
project(libsync)
set(CMAKE_AUTOMOC TRUE)
configure_file( version.h.in "${CMAKE_CURRENT_BINARY_DIR}/version.h" )
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
# csync is required.
include_directories(${CMAKE_SOURCE_DIR}/src/csync
@ -59,7 +57,6 @@ set(libsync_SRCS
syncjournalfilerecord.cpp
syncresult.cpp
theme.cpp
utility.cpp
ownsql.cpp
checksums.cpp
excludedfiles.cpp

View File

@ -25,7 +25,7 @@
#include "cookiejar.h"
#include "accessmanager.h"
#include "utility.h"
#include "common/utility.h"
namespace OCC {

View File

@ -28,7 +28,7 @@
#include <QSharedPointer>
#include <QPixmap>
#include "utility.h"
#include "common/utility.h"
#include <memory>
#include "capabilities.h"

View File

@ -16,7 +16,7 @@
#include "propagatedownload.h"
#include "propagateupload.h"
#include "propagatorjobs.h"
#include "utility.h"
#include "common/utility.h"
#ifdef Q_OS_WIN
#include <windef.h>

View File

@ -21,7 +21,8 @@
#include <QUrl>
#include <csync.h>
#include "utility.h"
#include "common/utility.h"
#include "owncloudlib.h"
namespace OCC {

View File

@ -16,7 +16,7 @@
#include "configfile.h"
#include "theme.h"
#include "utility.h"
#include "common/utility.h"
#include "asserts.h"
#include "creds/abstractcredentials.h"
@ -703,4 +703,19 @@ void ConfigFile::setCertificatePasswd(const QString &cPasswd)
settings.setValue(QLatin1String(certPasswd), cPasswd);
settings.sync();
}
Q_GLOBAL_STATIC(QString, g_configFileName)
std::unique_ptr<QSettings> ConfigFile::settingsWithGroup(const QString &group, QObject *parent)
{
if (g_configFileName()->isEmpty()) {
// cache file name
ConfigFile cfg;
*g_configFileName() = cfg.configFile();
}
std::unique_ptr<QSettings> settings(new QSettings(*g_configFileName(), QSettings::IniFormat, parent));
settings->beginGroup(group);
return settings;
}
}

View File

@ -16,7 +16,9 @@
#define CONFIGFILE_H
#include "owncloudlib.h"
#include <memory>
#include <QSharedPointer>
#include <QSettings>
#include <QString>
#include <QVariant>
@ -137,6 +139,10 @@ public:
QString certificatePasswd() const;
void setCertificatePasswd(const QString &cPasswd);
/** Returns a new settings pre-set in a specific group. The Settings will be created
with the given parent. If no parent is specified, the caller must destroy the settings */
static std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = 0);
protected:
QVariant getPolicySetting(const QString &policy, const QVariant &defaultValue = QVariant()) const;
void storeData(const QString &group, const QString &key, const QVariant &value);

View File

@ -21,7 +21,7 @@
#include "creds/credentialscommon.h"
#include "utility.h"
#include "common/utility.h"
#include "account.h"
#include "syncengine.h"

View File

@ -25,7 +25,7 @@
#include "account.h"
#include "accessmanager.h"
#include "utility.h"
#include "configfile.h"
#include "theme.h"
#include "syncengine.h"
#include "creds/credentialscommon.h"
@ -94,7 +94,7 @@ private:
static void addSettingsToJob(Account *account, QKeychain::Job *job)
{
Q_UNUSED(account);
auto settings = Utility::settingsWithGroup(Theme::instance()->appName());
auto settings = ConfigFile::settingsWithGroup(Theme::instance()->appName());
settings->setParent(job); // make the job parent to make setting deleted properly
job->setSettings(settings.release());
}

View File

@ -21,7 +21,7 @@
#include "account.h"
#include "accessmanager.h"
#include "utility.h"
#include "common/utility.h"
#include "theme.h"
#include "creds/credentialscommon.h"
#include "creds/tokencredentials.h"

View File

@ -14,7 +14,7 @@
#include "config.h"
#include "excludedfiles.h"
#include "utility.h"
#include "common/utility.h"
#include <QFileInfo>

View File

@ -14,7 +14,7 @@
#include "filesystem.h"
#include "utility.h"
#include "common/utility.h"
#include <QFile>
#include <QFileInfo>
#include <QLoggingCategory>

View File

@ -22,7 +22,9 @@
#include <QTextStream>
#include <qmutex.h>
#include "utility.h"
#include "common/utility.h"
#include "logger.h"
#include "owncloudlib.h"
namespace OCC {

View File

@ -23,7 +23,7 @@
#include "propagateremotemkdir.h"
#include "propagatorjobs.h"
#include "configfile.h"
#include "utility.h"
#include "common/utility.h"
#include "account.h"
#include "asserts.h"

View File

@ -24,9 +24,9 @@
#endif
#include <QCoreApplication>
#include "version.h"
#include "config.h"
#include "utility.h"
#include "common/utility.h"
#include "version.h"
namespace OCC {

View File

@ -21,7 +21,7 @@
#include <QDir>
#include "ownsql.h"
#include "utility.h"
#include "common/utility.h"
#include "asserts.h"
#define SQLITE_SLEEP_TIME_USEC 100000

View File

@ -19,7 +19,7 @@
#include "account.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include "propagatorjobs.h"
#include "checksums.h"

View File

@ -19,7 +19,7 @@
#include "account.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include "propagatorjobs.h"
#include "checksums.h"

View File

@ -19,7 +19,7 @@
#include "account.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include "propagatorjobs.h"
#include "syncengine.h"

View File

@ -19,7 +19,7 @@
#include "account.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include "propagatorjobs.h"
#include "checksums.h"

View File

@ -16,7 +16,7 @@
#include "propagatorjobs.h"
#include "owncloudpropagator_p.h"
#include "propagateremotemove.h"
#include "utility.h"
#include "common/utility.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "filesystem.h"

View File

@ -34,7 +34,7 @@
#include "excludedfiles.h"
#include "syncfileitem.h"
#include "progressdispatcher.h"
#include "utility.h"
#include "common/utility.h"
#include "syncfilestatustracker.h"
#include "accountfwd.h"
#include "discoveryphase.h"

View File

@ -23,7 +23,7 @@
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
#include "utility.h"
#include "common/utility.h"
#include "version.h"
#include "filesystem.h"
#include "asserts.h"

View File

@ -20,7 +20,7 @@
#include <QDateTime>
#include <QHash>
#include "utility.h"
#include "common/utility.h"
#include "ownsql.h"
#include "syncjournalfilerecord.h"

View File

@ -14,7 +14,7 @@
#include "syncjournalfilerecord.h"
#include "syncfileitem.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include <QLoggingCategory>

View File

@ -13,9 +13,9 @@
*/
#include "theme.h"
#include "version.h"
#include "config.h"
#include "utility.h"
#include "common/utility.h"
#include "version.h"
#include <QtCore>
#ifndef TOKEN_AUTH_ONLY

View File

@ -1,34 +0,0 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef VERSION_H
#define VERSION_H
#cmakedefine GIT_SHA1 "@GIT_SHA1@"
#define MIRALL_STRINGIFY(s) MIRALL_TOSTRING(s)
#define MIRALL_TOSTRING(s) #s
/* MIRALL version */
#define MIRALL_VERSION_MAJOR @MIRALL_VERSION_MAJOR@
#define MIRALL_VERSION_MINOR @MIRALL_VERSION_MINOR@
#define MIRALL_VERSION_PATCH @MIRALL_VERSION_PATCH@
#define MIRALL_VERSION_BUILD @MIRALL_VERSION_BUILD@
#define MIRALL_VERSION @MIRALL_VERSION@
#define MIRALL_VERSION_FULL @MIRALL_VERSION_FULL@
#define MIRALL_VERSION_STRING "@MIRALL_VERSION_STRING@"
#endif // VERSION_H

View File

@ -17,10 +17,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "torture.h"
#include "csync_misc.h"
#include <stdlib.h>
#include "torture.h"
static void check_csync_normalize_etag(void **state)
{

View File

@ -11,7 +11,7 @@
#include "checksums.h"
#include "networkjobs.h"
#include "utility.h"
#include "common/utility.h"
#include "filesystem.h"
#include "propagatorjobs.h"

View File

@ -8,7 +8,7 @@
#include <QDebug>
#include "filesystem.h"
#include "utility.h"
#include "common/utility.h"
using namespace OCC::Utility;
using namespace OCC::FileSystem;

View File

@ -7,7 +7,7 @@
#include <QtTest>
#include "utility.h"
#include "common/utility.h"
#include "folder.h"
using namespace OCC;

View File

@ -11,7 +11,7 @@
#endif
#include <QtTest>
#include "utility.h"
#include "common/utility.h"
#include "folderman.h"
#include "account.h"
#include "accountstate.h"

View File

@ -8,7 +8,7 @@
#include <QtTest>
#include "folderwatcher.h"
#include "utility.h"
#include "common/utility.h"
void touch(const QString &file)
{

View File

@ -7,7 +7,7 @@
#include <QtTest>
#include "folderwatcher_linux.h"
#include "utility.h"
#include "common/utility.h"
using namespace OCC;

View File

@ -9,7 +9,7 @@
#include <QTemporaryDir>
#endif
#include "utility.h"
#include "common/utility.h"
using namespace OCC::Utility;

38
version.h.in Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef VERSION_H
#define VERSION_H
#cmakedefine GIT_SHA1 "@GIT_SHA1@"
#define MIRALL_STRINGIFY(s) MIRALL_TOSTRING(s)
#define MIRALL_TOSTRING(s) #s
/* MIRALL version */
#define MIRALL_VERSION_MAJOR @MIRALL_VERSION_MAJOR@
#define MIRALL_VERSION_MINOR @MIRALL_VERSION_MINOR@
#define MIRALL_VERSION_PATCH @MIRALL_VERSION_PATCH@
#define MIRALL_VERSION_BUILD @MIRALL_VERSION_BUILD@
#define MIRALL_VERSION @MIRALL_VERSION@
#define MIRALL_VERSION_FULL @MIRALL_VERSION_FULL@
#define MIRALL_VERSION_STRING "@MIRALL_VERSION_STRING@"
#endif // VERSION_H