mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Remove inotify from cmake files.
This commit is contained in:
parent
890c0eb885
commit
aba1252e60
@ -78,16 +78,10 @@ endif()
|
||||
find_package(Neon REQUIRED)
|
||||
find_package(Csync REQUIRED)
|
||||
find_package(QtKeychain REQUIRED)
|
||||
if(UNIX)
|
||||
find_package(INotify REQUIRED)
|
||||
else()
|
||||
find_package(INotify)
|
||||
endif()
|
||||
find_package(Sphinx)
|
||||
find_package(PdfLatex)
|
||||
|
||||
set(WITH_QTKEYCHAIN ${QTKEYCHAIN_FOUND})
|
||||
set(USE_INOTIFY ${INOTIFY_FOUND})
|
||||
|
||||
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
# This module defines
|
||||
# INOTIFY_INCLUDE_DIR, where to find inotify.h, etc.
|
||||
# INOTIFY_FOUND, If false, do not try to use inotify.
|
||||
# also defined, but not for general use are
|
||||
# INOTIFY_LIBRARY, where to find the inotify library.
|
||||
|
||||
find_path(INOTIFY_INCLUDE_DIR sys/inotify.h
|
||||
HINTS /usr/include/${CMAKE_LIBRARY_ARCHITECTURE})
|
||||
mark_as_advanced(INOTIFY_INCLUDE_DIR)
|
||||
|
||||
# all listed variables are TRUE
|
||||
# handle the QUIETLY and REQUIRED arguments and set INOTIFY_FOUND to TRUE if
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(INOTIFY DEFAULT_MSG INOTIFY_INCLUDE_DIR)
|
||||
|
||||
IF(INOTIFY_FOUND)
|
||||
SET(INotify_INCLUDE_DIRS ${INOTIFY_INCLUDE_DIR})
|
||||
ENDIF(INOTIFY_FOUND)
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#cmakedefine USE_INOTIFY 1
|
||||
#cmakedefine WITH_QTKEYCHAIN 1
|
||||
|
||||
#cmakedefine GIT_SHA1 "@GIT_SHA1@"
|
||||
|
||||
@ -112,10 +112,8 @@ set(libsync_HEADERS
|
||||
3rdparty/qjson/json.h
|
||||
)
|
||||
|
||||
IF( INOTIFY_FOUND )
|
||||
set(libsync_SRCS ${libsync_SRCS} mirall/inotify.cpp)
|
||||
IF( NOT WIN32 AND NOT APPLE )
|
||||
set(libsync_SRCS ${libsync_SRCS} mirall/folderwatcher_qt.cpp)
|
||||
set(libsync_HEADERS ${libsync_HEADERS} mirall/inotify.h)
|
||||
set(libsync_HEADERS ${libsync_HEADERS} mirall/folderwatcher_qt.h)
|
||||
ENDIF()
|
||||
IF( WIN32 )
|
||||
@ -173,12 +171,6 @@ list(APPEND libsync_LINK_TARGETS
|
||||
${HTTPBF_LIBRARY}
|
||||
)
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
list(APPEND libsync_LINK_TARGETS
|
||||
inotify
|
||||
)
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
|
||||
if(QTKEYCHAIN_FOUND)
|
||||
list(APPEND libsync_LINK_TARGETS ${QTKEYCHAIN_LIBRARY})
|
||||
include_directories(${QTKEYCHAIN_INCLUDE_DIR})
|
||||
@ -295,12 +287,6 @@ set(mirall_HEADERS
|
||||
mirall/socketapi.h
|
||||
)
|
||||
|
||||
if( UNIX AND NOT APPLE)
|
||||
if(NOT DEFINED USE_INOTIFY)
|
||||
set(USE_INOTIFY ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# csync is required.
|
||||
include_directories(${CSYNC_INCLUDE_DIR}/csync ${CSYNC_INCLUDE_DIR} ${CSYNC_INCLUDE_DIR}/httpbf/src ${CSYNC_BUILD_PATH}/src)
|
||||
include_directories(${3rdparty_INC})
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/folder.h"
|
||||
#include "mirall/syncresult.h"
|
||||
#include "mirall/inotify.h"
|
||||
#include "mirall/theme.h"
|
||||
|
||||
#include <neon/ne_socket.h>
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
// event masks
|
||||
#include "mirall/folderwatcher.h"
|
||||
#include "mirall/folder.h"
|
||||
#include "mirall/inotify.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "mirall/folderwatcher_win.h"
|
||||
#elif defined(Q_OS_MAC)
|
||||
#include "mirall/folderwatcher_mac.h"
|
||||
#elif defined(USE_INOTIFY)
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#include "mirall/folderwatcher_qt.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class INotify;
|
||||
class FolderWatcher;
|
||||
|
||||
class FolderWatcherPrivate : public QObject {
|
||||
|
||||
@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
||||
*
|
||||
* Originally based on example copyright (c) Ashish Shukla
|
||||
* Ported to use QSocketNotifier later instead of a thread loop
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/inotify.h>
|
||||
|
||||
#include "inotify.h"
|
||||
#include "mirall/folder.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#include "inotify.h"
|
||||
|
||||
// Buffer Size for read() buffer
|
||||
#define DEFAULT_READ_BUFFERSIZE 2048
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
INotify::INotify(QObject *parent, int mask)
|
||||
: QObject(parent),
|
||||
_mask(mask)
|
||||
{
|
||||
_fd = inotify_init();
|
||||
if (_fd == -1)
|
||||
qDebug() << Q_FUNC_INFO << "notify_init() failed: " << strerror(errno);
|
||||
_notifier = new QSocketNotifier(_fd, QSocketNotifier::Read);
|
||||
connect(_notifier, SIGNAL(activated(int)), SLOT(slotActivated(int)));
|
||||
_buffer_size = DEFAULT_READ_BUFFERSIZE;
|
||||
_buffer = (char *) malloc(_buffer_size);
|
||||
}
|
||||
|
||||
void INotify::slotActivated(int /*fd*/)
|
||||
{
|
||||
int len;
|
||||
struct inotify_event* event;
|
||||
int i;
|
||||
int error;
|
||||
|
||||
do {
|
||||
len = read(_fd, _buffer, _buffer_size);
|
||||
error = errno;
|
||||
/**
|
||||
* From inotify documentation:
|
||||
*
|
||||
* The behavior when the buffer given to read(2) is too
|
||||
* small to return information about the next event
|
||||
* depends on the kernel version: in kernels before 2.6.21,
|
||||
* read(2) returns 0; since kernel 2.6.21, read(2) fails with
|
||||
* the error EINVAL.
|
||||
*/
|
||||
if (len < 0 && error == EINVAL)
|
||||
{
|
||||
// double the buffer size
|
||||
qWarning() << "buffer size too small";
|
||||
_buffer_size *= 2;
|
||||
_buffer = (char *) realloc(_buffer, _buffer_size);
|
||||
/* and try again ... */
|
||||
continue;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
/* TODO handle len == 0 */
|
||||
|
||||
// reset counter
|
||||
i = 0;
|
||||
// while there are enough events in the buffer
|
||||
while(i + sizeof(struct inotify_event) < static_cast<unsigned int>(len)) {
|
||||
// cast an inotify_event
|
||||
event = (struct inotify_event*)&_buffer[i];
|
||||
// with the help of watch descriptor, retrieve, corresponding INotify
|
||||
if (event == NULL) {
|
||||
qDebug() << "NULL event";
|
||||
i += sizeof(struct inotify_event);
|
||||
continue;
|
||||
}
|
||||
|
||||
// fire event
|
||||
if (event->len > 0) {
|
||||
QStringList paths(_wds.keys(event->wd));
|
||||
foreach (QString path, paths)
|
||||
emit notifyEvent(event->mask, event->cookie, path + "/" + QString::fromUtf8(event->name));
|
||||
}
|
||||
|
||||
// increment counter
|
||||
i += sizeof(struct inotify_event) + event->len;
|
||||
}
|
||||
}
|
||||
|
||||
INotify::~INotify()
|
||||
{
|
||||
// Remove all inotify watchs.
|
||||
QString key;
|
||||
foreach (key, _wds.keys())
|
||||
inotify_rm_watch(_fd, _wds.value(key));
|
||||
|
||||
close(_fd);
|
||||
free(_buffer);
|
||||
delete _notifier;
|
||||
}
|
||||
|
||||
bool INotify::addPath(const QString &path)
|
||||
{
|
||||
// Add an inotify watch.
|
||||
int wd = inotify_add_watch(_fd, path.toUtf8().constData(), _mask);
|
||||
if( wd > -1 ) {
|
||||
_wds[path] = wd;
|
||||
return true;
|
||||
} else {
|
||||
qDebug() << "WRN: Could not watch " << path << ':' << strerror(errno);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void INotify::removePath(const QString &path)
|
||||
{
|
||||
// Remove the inotify watch.
|
||||
inotify_rm_watch(_fd, _wds[path]);
|
||||
_wds.remove(path);
|
||||
}
|
||||
|
||||
QStringList INotify::directories() const
|
||||
{
|
||||
return _wds.keys();
|
||||
}
|
||||
|
||||
} // ns mirall
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
||||
*
|
||||
* Originally based on example copyright (c) Ashish Shukla
|
||||
*
|
||||
* Ported to use QSocketNotifier later instead of a thread loop
|
||||
*
|
||||
* 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 MIRALL_INOTIFY_H
|
||||
#define MIRALL_INOTIFY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
namespace Mirall
|
||||
{
|
||||
|
||||
class INotify : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
INotify(QObject *parent, int mask);
|
||||
~INotify();
|
||||
|
||||
bool addPath(const QString &name);
|
||||
void removePath(const QString &name);
|
||||
|
||||
QStringList directories() const;
|
||||
|
||||
protected slots:
|
||||
void slotActivated(int);
|
||||
|
||||
signals:
|
||||
void notifyEvent(int mask, int cookie, const QString &name);
|
||||
|
||||
private:
|
||||
int _fd;
|
||||
QSocketNotifier *_notifier;
|
||||
// the mask is shared for all paths
|
||||
int _mask;
|
||||
QMap<QString, int> _wds;
|
||||
|
||||
size_t _buffer_size;
|
||||
char *_buffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user