Skip to content

Commit

Permalink
Fix review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: allexzander <blackslayer4@gmail.com>
  • Loading branch information
allexzander committed Jul 29, 2022
1 parent 570f478 commit b99a208
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/common/shellextensionutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Protocol {
return QJsonDocument::fromVariant((messageCopy)).toJson(QJsonDocument::Compact);
}

bool validatProtocolVersion(const QVariantMap &message)
bool validateProtocolVersion(const QVariantMap &message)
{
const auto valid = message.value(QStringLiteral("version")) == Version;
if (!valid) {
Expand Down
4 changes: 2 additions & 2 deletions src/common/shellextensionutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ QString serverNameForApplicationNameDefault();
namespace Protocol {
static constexpr auto ThumbnailProviderRequestKey = "thumbnailProviderRequest";
static constexpr auto ThumbnailProviderRequestFilePathKey = "filePath";
static constexpr auto ThumbnailProviderRequestFileSizeKey = "size";
static constexpr auto ThumbnailProviderRequestFileSizeKey = "fileSize";
static constexpr auto ThumnailProviderDataKey = "thumbnailData";
static constexpr auto Version = "1.0";

QByteArray createJsonMessage(const QVariantMap &message);
bool validatProtocolVersion(const QVariantMap &message);
bool validateProtocolVersion(const QVariantMap &message);
}
}
4 changes: 1 addition & 3 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ set(client_SRCS
profilepagewidget.cpp
sharee.h
sharee.cpp
shellextensionsserver.cpp
sslbutton.h
sslbutton.cpp
sslerrordialog.h
Expand Down Expand Up @@ -183,7 +182,6 @@ set(client_SRCS
iconutils.cpp
remotewipe.h
remotewipe.cpp
${CMAKE_SOURCE_DIR}/src/common/shellextensionutils.cpp
userstatusselectormodel.h
userstatusselectormodel.cpp
emojimodel.h
Expand Down Expand Up @@ -293,7 +291,7 @@ IF( NOT WIN32 AND NOT APPLE )
set(client_SRCS ${client_SRCS} folderwatcher_linux.cpp)
ENDIF()
IF( WIN32 )
set(client_SRCS ${client_SRCS} folderwatcher_win.cpp)
set(client_SRCS ${client_SRCS} folderwatcher_win.cpp shellextensionsserver.cpp ${CMAKE_SOURCE_DIR}/src/common/shellextensionutils.cpp)
ENDIF()
IF( APPLE )
list(APPEND client_SRCS folderwatcher_mac.cpp)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ Application::Application(int &argc, char **argv)
qCInfo(lcApplication) << "VFS suffix plugin is available";

_folderManager.reset(new FolderMan);
#ifdef Q_OS_WIN
_shellExtensionsServer.reset(new ShellExtensionsServer);
#endif

connect(this, &SharedTools::QtSingleApplication::messageReceived, this, &Application::slotParseMessage);

Expand Down
2 changes: 2 additions & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ protected slots:
QScopedPointer<CrashReporter::Handler> _crashHandler;
#endif
QScopedPointer<FolderMan> _folderManager;
#ifdef Q_OS_WIN
QScopedPointer<ShellExtensionsServer> _shellExtensionsServer;
#endif
};

} // namespace OCC
Expand Down
2 changes: 1 addition & 1 deletion src/gui/shellextensionsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void ShellExtensionsServer::slotNewConnection()
socket->waitForReadyRead();
const auto message = QJsonDocument::fromJson(socket->readAll()).toVariant().toMap();

if (!VfsShellExtensions::Protocol::validatProtocolVersion(message)) {
if (!VfsShellExtensions::Protocol::validateProtocolVersion(message)) {
sendEmptyDataAndCloseSession(socket);
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/libsync/vfs/cfapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ if (WIN32)
)

target_include_directories("nextcloudsync_vfs_cfapi" BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR} INTERFACE ${CMAKE_BINARY_DIR})
add_dependencies(nextcloudsync_vfs_cfapi ${CFAPI_SHELL_EXTENSIONS_LIB_NAME})

set(vfs_installdir "${PLUGINDIR}")

Expand Down
16 changes: 10 additions & 6 deletions src/libsync/vfs/cfapi/shellext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(${CFAPI_SHELL_EXTENSIONS_LIB_NAME} MODULE
add_library(CfApiShellExtensions MODULE
dllmain.cpp
cfapishellintegrationclassfactory.cpp
thumbnailprovider.cpp
Expand All @@ -7,21 +7,25 @@ add_library(${CFAPI_SHELL_EXTENSIONS_LIB_NAME} MODULE
CfApiShellIntegration.def
)

target_link_libraries(${CFAPI_SHELL_EXTENSIONS_LIB_NAME} shlwapi Gdiplus Nextcloud::csync Qt5::Core Qt5::Network)
target_link_libraries(CfApiShellExtensions shlwapi Gdiplus Nextcloud::csync Qt5::Core Qt5::Network)

target_include_directories(${CFAPI_SHELL_EXTENSIONS_LIB_NAME} PRIVATE ${GeneratedFilesPath})
target_include_directories(CfApiShellExtensions PRIVATE ${GeneratedFilesPath})

target_include_directories(${CFAPI_SHELL_EXTENSIONS_LIB_NAME} PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(CfApiShellExtensions PRIVATE ${CMAKE_SOURCE_DIR})

set_target_properties(${CFAPI_SHELL_EXTENSIONS_LIB_NAME}
set_target_properties(CfApiShellExtensions
PROPERTIES
LIBRARY_OUTPUT_NAME
${CFAPI_SHELL_EXTENSIONS_LIB_NAME}
RUNTIME_OUTPUT_NAME
${CFAPI_SHELL_EXTENSIONS_LIB_NAME}
LIBRARY_OUTPUT_DIRECTORY
${BIN_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY
${BIN_OUTPUT_DIRECTORY}
)

install(TARGETS ${CFAPI_SHELL_EXTENSIONS_LIB_NAME}
install(TARGETS CfApiShellExtensions
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
)
2 changes: 1 addition & 1 deletion src/libsync/vfs/cfapi/shellext/thumbnailprovideripc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ QByteArray ThumbnailProviderIpc::fetchThumbnailForFile(const QString &filePath,

// #3 Read the thumbnail data (read all as the thumbnail size is usually less than 1MB)
const auto message = QJsonDocument::fromJson(_localSocket->readAll()).toVariant().toMap();
if (!VfsShellExtensions::Protocol::validatProtocolVersion(message)) {
if (!VfsShellExtensions::Protocol::validateProtocolVersion(message)) {
return result;
}
result = QByteArray::fromBase64(message.value(VfsShellExtensions::Protocol::ThumnailProviderDataKey).toByteArray());
Expand Down

0 comments on commit b99a208

Please sign in to comment.