mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Add qtkeychain to cmake - WIP read password from keychain.
Conflicts: CMakeLists.txt
This commit is contained in:
parent
bf2181f111
commit
2b2eb853fc
@ -37,13 +37,16 @@ else()
|
||||
endif()
|
||||
#####
|
||||
|
||||
#### find libs
|
||||
find_package(Qt4 4.6.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest REQUIRED )
|
||||
find_package(Csync)
|
||||
find_package(INotify)
|
||||
find_package(Sphinx)
|
||||
find_package(PdfLatex)
|
||||
find_package(QtKeychain)
|
||||
|
||||
set(WITH_CSYNC CSYNC_FOUND)
|
||||
set(WITH_QTKEYCHAIN QTKEYCHAIN_FOUND)
|
||||
set(USE_INOTIFY ${INOTIFY_FOUND})
|
||||
|
||||
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
21
cmake/modules/FindQtKeychain.cmake
Normal file
21
cmake/modules/FindQtKeychain.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
# - Try to find QtKeyChain
|
||||
# Once done this will define
|
||||
# QTKEYCHAIN_FOUND - System has QtKeyChain
|
||||
# QTKEYCHAIN_INCLUDE_DIRS - The QtKeyChain include directories
|
||||
# QTKEYCHAIN_LIBRARIES - The libraries needed to use QtKeyChain
|
||||
# QTKEYCHAIN_DEFINITIONS - Compiler switches required for using LibXml2
|
||||
|
||||
find_path(QTKEYCHAIN_INCLUDE_DIR qtkeychain/keychain.h)
|
||||
|
||||
find_library(QTKEYCHAIN_LIBRARY NAMES libqtkeychain qtkeychain)
|
||||
|
||||
set(QTKEYCHAIN_LIBRARIES ${QTKEYCHAIN_LIBRARY} )
|
||||
set(QTKEYCHAIN_INCLUDE_DIRS ${QTKEYCHAIN_INCLUDE_DIR} )
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set QTKEYCHAIN_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(QtKeyChain DEFAULT_MSG
|
||||
QTKEYCHAIN_LIBRARY QTKEYCHAIN_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(QTKEYCHAIN_INCLUDE_DIR QTKEYCHAIN_LIBRARY )
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#cmakedefine USE_INOTIFY 1
|
||||
#cmakedefine WITH_CSYNC 1
|
||||
#cmakedefine WITH_QTKEYCHAIN 1
|
||||
|
||||
#cmakedefine THEME_CLASS @THEME_CLASS@
|
||||
#endif
|
||||
|
||||
@ -91,11 +91,22 @@ ENDIF()
|
||||
|
||||
qt4_wrap_cpp(syncMoc ${libsync_HEADERS})
|
||||
|
||||
list(APPEND libsync_LINK_TARGETS
|
||||
${QT_LIBRARIES}
|
||||
${CSYNC_LIBRARY}
|
||||
)
|
||||
|
||||
if(QTKEYCHAIN_FOUND)
|
||||
list(APPEND libsync_LINK_TARGETS ${QTKEYCHAIN_LIBRARY})
|
||||
include_directories(${QTKEYCHAIN_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
add_library(mirallsync SHARED ${libsync_SRCS} ${syncMoc})
|
||||
add_library(owncloudsync SHARED ${libsync_SRCS} ${syncMoc})
|
||||
set_target_properties( owncloudsync PROPERTIES COMPILE_DEFINITIONS OWNCLOUD_CLIENT)
|
||||
target_link_libraries(mirallsync ${QT_LIBRARIES} ${CSYNC_LIBRARY} )
|
||||
target_link_libraries(owncloudsync ${QT_LIBRARIES} ${CSYNC_LIBRARY} )
|
||||
|
||||
target_link_libraries(mirallsync ${libsync_LINK_TARGETS} )
|
||||
target_link_libraries(owncloudsync ${libsync_LINK_TARGETS} )
|
||||
|
||||
if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
|
||||
install(TARGETS mirallsync owncloudsync
|
||||
|
||||
@ -13,10 +13,14 @@
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "mirall/credentialstore.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/theme.h"
|
||||
|
||||
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
CredentialStore *CredentialStore::_instance=0;
|
||||
@ -90,14 +94,14 @@ void CredentialStore::fetchCredentials()
|
||||
}
|
||||
case MirallConfigFile::KeyChain: {
|
||||
/* Qt Keychain is not yet implemented. */
|
||||
#ifdef HAVE_QTKEYCHAIN
|
||||
#ifdef WITH_QTKEYCHAIN
|
||||
if( !_user.isEmpty() ) {
|
||||
ReadPasswordJoei b job( QLatin1String(Theme::instance()->appName()) );
|
||||
ReadPasswordJob job(Theme::instance()->appName());
|
||||
job.setAutoDelete( false );
|
||||
job.setKey( _user );
|
||||
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), this,
|
||||
SLOT(slotKeyChainFinished(QKeyChain::Job*)));
|
||||
SLOT(slotKeyChainFinished(QKeychain::Job*)));
|
||||
job.start();
|
||||
}
|
||||
#else
|
||||
@ -121,14 +125,15 @@ void CredentialStore::fetchCredentials()
|
||||
emit( fetchCredentialsFinished(ok) );
|
||||
}
|
||||
|
||||
#ifdef HAVE_QTKEYCHAIN
|
||||
void CredentialsStore::slotKeyChainFinished(QKeyChain::Job* job)
|
||||
#ifdef WITH_QTKEYCHAIN
|
||||
void CredentialStore::slotKeyChainFinished(QKeychain::Job* job)
|
||||
{
|
||||
if( job ) {
|
||||
if( job->error() ) {
|
||||
qDebug() << "Error mit keychain: " << job->errorString();
|
||||
ReadPasswordJob *pwdJob = static_cast<ReadPasswordJob*>(job);
|
||||
if( pwdJob ) {
|
||||
if( pwdJob->error() ) {
|
||||
qDebug() << "Error mit keychain: " << pwdJob->errorString();
|
||||
} else {
|
||||
_passwd = job.textData();
|
||||
_passwd = pwdJob->textData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,8 +14,16 @@
|
||||
#ifndef CREDENTIALSTORE_H
|
||||
#define CREDENTIALSTORE_H
|
||||
|
||||
#include "config.h"
|
||||
#include <QObject>
|
||||
|
||||
#ifdef WITH_QTKEYCHAIN
|
||||
#include "qtkeychain/keychain.h"
|
||||
|
||||
using namespace QKeychain;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
/*
|
||||
@ -94,8 +102,8 @@ signals:
|
||||
void fetchCredentialsFinished(bool);
|
||||
|
||||
private slots:
|
||||
#ifdef HAVE_QTKEYCHAIN
|
||||
void slotKeyChainFinished(QKeyChain::Job* job);
|
||||
#ifdef WITH_QTKEYCHAIN
|
||||
void slotKeyChainFinished(QKeychain::Job* job);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user