mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-07 03:17:13 +08:00
Add option to build websockets (#2693)
* Revert "Disable notification on linux (#2659)"
This reverts commit 20d5947916
.
* Add option to build websockets
* Set enable-ws default to no
* Add build option COMPILE_LINUX_WS
* Modify APPLE macro
---------
Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
parent
ed64098bf2
commit
5b44209bf6
16
configure.ac
16
configure.ac
@ -159,6 +159,7 @@ JANSSON_REQUIRED=2.2.1
|
||||
CURL_REQUIRED=7.17
|
||||
ZLIB_REQUIRED=1.2.0
|
||||
GNUTLS_REQUIRED=3.3.0
|
||||
WS_REQUIRED=4.0.20
|
||||
|
||||
PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= $GLIB_REQUIRED])
|
||||
AC_SUBST(GLIB2_CFLAGS)
|
||||
@ -188,6 +189,15 @@ PKG_CHECK_MODULES(CURL, [libcurl >= $CURL_REQUIRED])
|
||||
AC_SUBST(CURL_CFLAGS)
|
||||
AC_SUBST(CURL_LIBS)
|
||||
|
||||
AC_ARG_ENABLE(ws, AC_HELP_STRING([--enable-ws], [enable build websockets]),
|
||||
[compile_linux_ws=$enableval],[compile_linux_ws="yes"])
|
||||
AM_CONDITIONAL([COMPILE_LINUX_WS], [test "${compile_linux_ws}" = "yes"])
|
||||
if test "${compile_linux_ws}" = "yes"; then
|
||||
PKG_CHECK_MODULES(WS, [libwebsockets >= $WS_REQUIRED])
|
||||
AC_SUBST(WS_CFLAGS)
|
||||
AC_SUBST(WS_LIBS)
|
||||
fi
|
||||
|
||||
if test "$bwin32" != true; then
|
||||
# do not check libevent_pthreads in win32
|
||||
PKG_CHECK_MODULES(LIBEVENT_PTHREADS, [libevent_pthreads >= $LIBEVENT_PTHREADS_REQUIRED])
|
||||
@ -195,12 +205,6 @@ AC_SUBST(LIBEVENT_PTHREADS_CFLAGS)
|
||||
AC_SUBST(LIBEVENT_PTHREADS_LIBS)
|
||||
fi
|
||||
|
||||
if test "$blinux" != true; then
|
||||
PKG_CHECK_MODULES(WS, [libwebsockets])
|
||||
AC_SUBST(WS_CFLAGS)
|
||||
AC_SUBST(WS_LIBS)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([python3], [AS_HELP_STRING([--with-python3], [use python3])],
|
||||
[with_python3="yes"],[])
|
||||
|
||||
|
@ -54,6 +54,14 @@ if MACOS
|
||||
wt_monitor_src = wt-monitor.c wt-monitor-macos.c wt-monitor-structs.c
|
||||
endif
|
||||
|
||||
if MACOS
|
||||
ws_src = notif-mgr.c
|
||||
else
|
||||
if COMPILE_LINUX_WS
|
||||
ws_src = notif-mgr.c
|
||||
endif
|
||||
endif
|
||||
|
||||
common_src = \
|
||||
job-mgr.c timer.c cevent.c \
|
||||
http-tx-mgr.c \
|
||||
@ -79,7 +87,7 @@ common_src = \
|
||||
filelock-mgr.c \
|
||||
set-perm.c \
|
||||
change-set.c \
|
||||
notif-mgr.c
|
||||
$(ws_src)
|
||||
|
||||
|
||||
seaf_daemon_SOURCES = seaf-daemon.c $(common_src)
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
|
||||
#include "common.h"
|
||||
#include <libwebsockets.h>
|
||||
@ -623,7 +622,7 @@ handle_folder_perm (json_t *content)
|
||||
perm);
|
||||
else if (g_strcmp0 (change_event, "del") == 0)
|
||||
seaf_repo_manager_delete_folder_perm (seaf->repo_mgr, repo_id,
|
||||
FOLDER_PERM_TYPE_USER,
|
||||
FOLDER_PERM_TYPE_GROUP,
|
||||
perm);
|
||||
}
|
||||
g_free (perm);
|
||||
@ -731,7 +730,7 @@ out:
|
||||
|
||||
static const struct lws_protocols protocols[] = {
|
||||
{ "notification.seafile.com", event_callback, 0, 0, 0, NULL, 0 },
|
||||
LWS_PROTOCOL_LIST_TERM
|
||||
{NULL, NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static struct lws_context *
|
||||
@ -974,5 +973,3 @@ out:
|
||||
notif_server_unref (server);
|
||||
return subscribed;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
|
||||
#ifndef NOTIF_MGR_H
|
||||
#define NOTIF_MGR_H
|
||||
@ -31,5 +30,3 @@ gboolean
|
||||
seaf_notif_manager_is_repo_subscribed (SeafNotifManager *mgr, SeafRepo *repo);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6662,7 +6662,7 @@ seaf_repo_manager_del_repo (SeafRepoManager *mgr,
|
||||
|
||||
pthread_rwlock_unlock (&mgr->priv->lock);
|
||||
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
seaf_notif_manager_unsubscribe_repo (seaf->notif_mgr, repo);
|
||||
#endif
|
||||
|
||||
|
@ -236,7 +236,7 @@ seafile_session_new(const char *seafile_dir,
|
||||
if (!session->mq_mgr)
|
||||
goto onerror;
|
||||
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
session->notif_mgr = seaf_notif_manager_new (session);
|
||||
#endif
|
||||
|
||||
|
@ -72,9 +72,7 @@ struct _SeafileSession {
|
||||
|
||||
SeafFilelockManager *filelock_mgr;
|
||||
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
SeafNotifManager *notif_mgr;
|
||||
#endif
|
||||
|
||||
/* Set after all components are up and running. */
|
||||
gboolean started;
|
||||
|
@ -1777,6 +1777,7 @@ http_notification_url (const char *url)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
// Returns TRUE if notification server is alive; otherwise FALSE.
|
||||
// We only check notification server once.
|
||||
static gboolean
|
||||
@ -1820,6 +1821,7 @@ check_notif_server (SeafSyncManager *mgr, SeafRepo *repo)
|
||||
g_free (notif_url);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
gint
|
||||
cmp_repos_by_sync_time (gconstpointer a, gconstpointer b, gpointer user_data)
|
||||
@ -2110,7 +2112,7 @@ check_folder_permissions_one_server_immediately (SeafSyncManager *mgr,
|
||||
for (ptr = repos; ptr; ptr = ptr->next) {
|
||||
repo = ptr->data;
|
||||
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
if (!force && seaf_notif_manager_is_repo_subscribed (seaf->notif_mgr, repo))
|
||||
continue;
|
||||
#endif
|
||||
@ -2254,7 +2256,7 @@ check_locked_files_one_server_immediately (SeafSyncManager *mgr,
|
||||
for (ptr = repos; ptr; ptr = ptr->next) {
|
||||
repo = ptr->data;
|
||||
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
if (!force && seaf_notif_manager_is_repo_subscribed (seaf->notif_mgr, repo))
|
||||
continue;
|
||||
#endif
|
||||
@ -2439,10 +2441,10 @@ periodic_sync_due (SeafRepo *repo)
|
||||
return (now > (repo->last_sync_time + repo->sync_interval));
|
||||
}
|
||||
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
static int
|
||||
check_and_subscribe_repo (SeafSyncManager *mgr, SeafRepo *repo)
|
||||
{
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
char *url = NULL;
|
||||
HttpServerState *state = g_hash_table_lookup (mgr->http_server_states,
|
||||
repo->server_url);
|
||||
@ -2483,10 +2485,10 @@ check_and_subscribe_repo (SeafSyncManager *mgr, SeafRepo *repo)
|
||||
if (repo->jwt_token)
|
||||
seaf_notif_manager_subscribe_repo (seaf->notif_mgr, repo);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
auto_sync_pulse (void *vmanager)
|
||||
@ -2597,7 +2599,7 @@ auto_sync_pulse (void *vmanager)
|
||||
if (repo->version > 0) {
|
||||
/* For repo version > 0, only use http sync. */
|
||||
if (check_http_protocol (manager, repo)) {
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
if (check_notif_server (manager, repo)) {
|
||||
seaf_notif_manager_connect_server (seaf->notif_mgr, repo->server_url, repo->use_fileserver_port);
|
||||
}
|
||||
@ -2605,11 +2607,15 @@ auto_sync_pulse (void *vmanager)
|
||||
|
||||
if (repo->sync_interval == 0) {
|
||||
sync_repo_v2 (manager, repo, FALSE);
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
check_and_subscribe_repo (manager, repo);
|
||||
#endif
|
||||
}
|
||||
else if (periodic_sync_due (repo)) {
|
||||
sync_repo_v2 (manager, repo, TRUE);
|
||||
#if defined WIN32 || defined __APPLE__ || defined COMPILE_LINUX_WS
|
||||
check_and_subscribe_repo (manager, repo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user