Skip to content

Commit

Permalink
Create a static library containing constants to be shared with extens…
Browse files Browse the repository at this point in the history
…ions"
  • Loading branch information
luc-guyot-infomaniak committed Dec 12, 2024
1 parent 2b8d8fc commit a50a853
Show file tree
Hide file tree
Showing 13 changed files with 15,934 additions and 53 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(libcommonserver_NAME "${APPLICATION_NAME}commonserver")
set(libcommongui_NAME "${APPLICATION_NAME}commongui")
set(libsyncengine_NAME "${APPLICATION_NAME}syncengine")
set(libparms_NAME "${APPLICATION_NAME}parms")
set(libcommonext_NAME "${APPLICATION_NAME}commonext")

# For PocoUtilConfig
set(ENABLE_XML TRUE)
Expand Down Expand Up @@ -179,6 +180,8 @@ endif()
file(GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
set(TRANSLATIONS ${TRANS_FILES})

add_subdirectory(libcommonext)

if (BUILD_CLIENT)
add_subdirectory(src)
if (NOT BUILD_LIBRARIES_ONLY)
Expand Down
15 changes: 12 additions & 3 deletions extensions/MacOSX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ add_custom_target(mac_loginitemagent ALL
"KD_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}"
"KD_APPLICATION_VERSION=${KDRIVE_VERSION}"
COMMENT building FinderSync Extension
VERBATIM)
VERBATIM
)

add_dependencies(mac_loginitemagent ${libcommonext_NAME})

set_property (TARGET mac_loginitemagent APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
add_dependencies(mac_loginitemagent ${APPLICATION_EXECUTABLE})

Expand All @@ -29,23 +33,28 @@ add_custom_target(mac_findersyncext ALL
COMMENT building FinderSync Extension
VERBATIM)
set_property (TARGET mac_findersyncext APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
add_dependencies(mac_findersyncext ${APPLICATION_EXECUTABLE})
add_dependencies(mac_findersyncext ${libcommonext_NAME} ${APPLICATION_EXECUTABLE})

INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/Extension.appex
DESTINATION ${KDRIVE_OSX_BUNDLE}/Contents/PlugIns
USE_SOURCE_PERMISSIONS)


# LiteSync Ext
add_custom_target(mac_litesyncext ALL
xcodebuild -project ${CMAKE_SOURCE_DIR}/extensions/MacOSX/kDriveLiteSync/kDriveLiteSync.xcodeproj
"HEADER_SEARCH_PATHS=${CMAKE_SOURCE_DIR}/libcommonext" "LIBRARY_SEARCH_PATHS=${LIBRARY_SEARCH_PATHS} ${CMAKE_BINARY_DIR}/libcommonext"
-target Extension -configuration ${CMAKE_BUILD_TYPE} "SYMROOT=${CMAKE_CURRENT_BINARY_DIR}"
"KD_APPLICATION_NAME=${APPLICATION_NAME}"
"KD_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}"
"KD_APPLICATION_VERSION=${KDRIVE_VERSION}"
COMMENT building LiteSync Extension
VERBATIM)

set_property (TARGET mac_litesyncext APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
add_dependencies(mac_litesyncext ${APPLICATION_EXECUTABLE})


add_dependencies(mac_litesyncext ${libcommonext_NAME} ${APPLICATION_EXECUTABLE})

INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${APPLICATION_REV_DOMAIN}.LiteSyncExt.systemextension
DESTINATION ${KDRIVE_OSX_BUNDLE}/Contents/Library/SystemExtensions
Expand Down
21 changes: 12 additions & 9 deletions extensions/MacOSX/kDriveLiteSync/Extension/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
*/

#include "xpcService.h"
#include "fileAttributes.h"

#import <Foundation/Foundation.h>
#import <EndpointSecurity/EndpointSecurity.h>
#import <Foundation/Foundation.h>
#import <bsm/libbsm.h>

#include "commonext.h"

#include <dispatch/queue.h>
#include <sys/xattr.h>

Expand Down Expand Up @@ -109,15 +110,16 @@ static BOOL processAuthOpen(const es_message_t *msg, BOOL *thumbnail)
msg->process->signing_id.data);*/

// Check file status
long bufferLength = getxattr([filePath UTF8String], [EXT_ATTR_STATUS UTF8String], NULL, 0, 0, 0);
long bufferLength = getxattr([filePath UTF8String], [@(extAttrsStatus) UTF8String], NULL, 0, 0, 0);
if (bufferLength >= 0) {
char status[bufferLength];
if (getxattr([filePath UTF8String], [EXT_ATTR_STATUS UTF8String], status, bufferLength, 0, 0) != bufferLength) {
if (getxattr([filePath UTF8String], [@(extAttrsStatus) UTF8String], status, bufferLength, 0, 0)
!= bufferLength) {
NSLog(@"[KD] ERROR: fgetxattr() failed for file %@: %d", filePath, errno);
return FALSE;
}

if (status[0] != EXT_ATTR_STATUS_ONLINE[0]) {
if (status[0] != extAttrsStatusOnline[0]) {
// The file is not dehydrated.
return FALSE;
}
Expand Down Expand Up @@ -194,15 +196,16 @@ static BOOL processAuthRename(const es_message_t *msg)
}

// Check file status
long bufferLength = getxattr([filePath UTF8String], [EXT_ATTR_STATUS UTF8String], NULL, 0, 0, 0);
long bufferLength = getxattr([filePath UTF8String], [@(extAttrsStatus) UTF8String], NULL, 0, 0, 0);
char status[bufferLength];
if (bufferLength >= 0) {
if (getxattr([filePath UTF8String], [EXT_ATTR_STATUS UTF8String], status, bufferLength, 0, 0) != bufferLength) {
if (getxattr([filePath UTF8String], [@(extAttrsStatus) UTF8String], status, bufferLength, 0, 0)
!= bufferLength) {
NSLog(@"[KD] ERROR: fgetxattr() failed for file %@: %d", filePath, errno);
return FALSE;
}
if (status[0] != EXT_ATTR_STATUS_ONLINE[0]) {

if (status[0] != extAttrsStatusOnline[0]) {
return FALSE;
}
}
Expand Down
Loading

0 comments on commit a50a853

Please sign in to comment.