Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDESKTOP-394 Fix path in error widget #12

Merged
merged 11 commits into from
Mar 25, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ install/
*.user
*.sln.docstates
.drone-secrets.env
*.vscode

# Build results
[Dd]ebug/
Expand Down
27 changes: 15 additions & 12 deletions infomaniak-build-tools/linux/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
- [CPPUnit](#cppunit)
- [Sentry](#sentry)
- [xxHash](#xxhash)
- [Build in Debug mode](#build-in-debug-mode)
- [Configuration](#configuration)
- [Debugging](#debugging)
- [Build in Release mode](#build-in-release-mode)
- [Build in Debug](#build-in-debug)
- [Qt Creator](#using-qt-creator)
- [Configuration](#configuration)
- [Debugging](#debugging)
- [Build in Release](#build-in-release)
- [Podman Image](#podman-image)
- [Building](#building)

Expand All @@ -25,7 +26,7 @@ If you wish to have the sources elsewhere, feel free to use the path you want.
```bash
cd ~/Projects
git clone https://github.com/Infomaniak/desktop-kDrive.git
cd kdrive && git submodule update --init --recursive
cd desktop-kDrive && git submodule update --init --recursive
```

# Installation Requirements
Expand Down Expand Up @@ -152,9 +153,11 @@ cmake ..
sudo cmake --build . --target install
```

# Build in Debug mode
# Build in Debug

## Configuration
## Using Qt Creator

### Configuration

Open the kDrive project in your IDE
In the project build settings, paste the following lines in the Initial Configuration Batch Edit (replace `<user>`)
Expand All @@ -167,19 +170,19 @@ In the project build settings, paste the following lines in the Initial Configur
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
-DAPPLICATION_CLIENT_EXECUTABLE=kdrive_client
-DKDRIVE_THEME_DIR=/home/<user>/Projects/kdrive/infomaniak
-DCMAKE_INSTALL_PREFIX=/home/<user>/Projects/build-kdrive-Desktop_Qt_6_2_3_GCC_64bit-Debug/bin
-DAPPLICATION_CLIENT_EXECUTABLE=kdrive
-DKDRIVE_THEME_DIR=/home/<user>/Projects/desktop-kDrive/infomaniak
-DCMAKE_INSTALL_PREFIX=/home/<user>/Projects/build-desktop-kDrive-Desktop_Qt_6_2_3_GCC_64bit-Debug/bin
-DBUILD_TESTING=OFF
-DWITH_CRASHREPORTER=OFF
```

## Debugging
### Debugging

The configuration and database files are stored in the `~/.config/kDrive` directory.
The log files will be generated in the `/tmp/kDrive-logdir` directory.

# Build in Release mode
# Build in Release

Currently, the release appImage file is generated in a podman container.
For this part, please replace `[arch]` by either `amd64` or `arm64` depending on your architecture.
Expand Down
25 changes: 15 additions & 10 deletions infomaniak-build-tools/macos/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
- [Sparkle](#sparkle)
- [Packages](#packages)
- [Notarytool](#notarytool)
- [Debug building in Qt](#debug-building-in-qt)
- [Qt Configuration](#qt-configuration)
- [Build in Debug](#build-in-debug)
- [Qt Creator](#using-qt-creator)
- [Qt Configuration](#qt-configuration)
- [Build in Release](#build-in-release)
- [Requirements](#requirements)
- [Build](#build)
Expand All @@ -29,7 +30,7 @@ If you wish to have the sources elsewhere, feel free to use the path you want.
```bash
cd ~/Projects
git clone https://github.com/Infomaniak/desktop-kDrive.git
cd kdrive && git submodule update --init --recursive
cd desktop-kDrive && git submodule update --init --recursive
```

# Installation Requirements
Expand Down Expand Up @@ -205,9 +206,11 @@ Copy the previously generated password to use in the command below :
xcrun notarytool store-credentials "notarytool" --apple-id <email address> --team-id [team-id] --password <password>
```

# Debug building in Qt
# Build in Debug

## Qt Configuration
## Using Qt Creator

### Qt Configuration

Open the kDrive project in Qt Creator
In the project build settings, paste the following lines in the Initial Configuration Batch Edit (replace `<user>`)
Expand All @@ -220,9 +223,10 @@ In the project build settings, paste the following lines in the Initial Configur
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
-DAPPLICATION_CLIENT_EXECUTABLE=kdrive_client
-DKDRIVE_THEME_DIR=/Users/<user>/Projects/kdrive/infomaniak
-DCMAKE_INSTALL_PREFIX=/Users/<user>/Projects/build-kdrive-Qt_6_2_3_for_macOS-Debug/bin
-DAPPLICATION_CLIENT_EXECUTABLE=kdrive
-DSOCKETAPI_TEAM_IDENTIFIER_PREFIX=<team id>
-DKDRIVE_THEME_DIR=/Users/<user>/Projects/desktop-kDrive/infomaniak
-DCMAKE_INSTALL_PREFIX=/Users/<user>/Projects/build-desktop-kDrive-Qt_6_2_3_for_macOS-Debug/bin
-DBUILD_TESTING=OFF
-DWITH_CRASHREPORTER=OFF
%{CMAKE_OSX_ARCHITECTURES:DefaultFlag}
Expand All @@ -233,7 +237,7 @@ Build - Build Steps - Build :

Build - Build Steps - Custom Process Step 1 :
`Command : %{Qt:QT_INSTALL_BINS}/macdeployqt`
`Arguments : %{buildDir}/bin/kDrive.app -no-strip`
`Arguments : %{buildDir}/bin/kDrive.app -no-strip -executable=%{buildDir}/bin/kDrive.app/Contents/MacOS/kDrive_client`

Build - Build Steps - Custom Process Step 2 :
`Command : /Users/<user name>/Projects/kdrive/admin/osx/sign_app_debug.sh`
Expand All @@ -257,7 +261,7 @@ pip3 install bs4 lxml
In a terminal :

```bash
cd ~/Projects/kdrive
cd ~/Projects/desktop-kDrive
```
For a simple unsigned build :

Expand All @@ -266,6 +270,7 @@ infomaniak-build-tools/macos/build-drive.sh
```

# Disabling SIP in VMWare Fusion

To Debug the application, the SIP needs to be disabled, this is because the extension is not signed and notarized in Debug mode.
If you are debugging on a Mac device, you can follow the [official Apple documentation](https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection) to disable it.
If you want to debug on a MacOS VM, disabling the SIP depends on the tool you are using, here is one way to disable it on VMWare Fusion :
Expand Down
32 changes: 19 additions & 13 deletions infomaniak-build-tools/windows/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
- [7za](#7za)
- [IcoTool](#icotool)
- [Certificate Configuration](#certificate-configuration)
- [Build in Debug mode](#build-in-debug-mode)
- [Additionnal Requirements](#additionnal-requirements)
- [CMake Parameters](#cmake-parameters)
- [Build in Debug](#build-in-debug)
- [Qt Creator](#using-qt-creator)
- [Additionnal Requirements](#additionnal-requirements)
- [CMake Parameters](#cmake-parameters)
- [Testing the extension](#testing-the-extension)
- [Build in Release mode](#build-in-release-mode)
- [Build in Release](#build-in-release)
- [Build and Packaging](#build-and-packaging)
- [Possible build errors](#possible-build-errors)

Expand All @@ -32,7 +33,7 @@ If you wish to have the sources elsewhere, feel free to use the path you want.
F:
cd Projects
git clone https://github.com/Infomaniak/desktop-kDrive.git
cd kdrive && git submodule update --init --recursive
cd desktop-kDrive && git submodule update --init --recursive
```

# Installation Requirements
Expand Down Expand Up @@ -66,11 +67,14 @@ In Qt 6.2.3 Additional Libraries, select :
- Qt Positioning
- Qt WebChannel
- Qt WebView
- Qt Debug Information Files (only if you want to use a debugger)

In Developer and Designer Tools (should be selected by default):
- CMake
- Ninja



Add an environment variable named `QTDIR`, with the path of your Qt msvc folder (by default `C:\Qt\6.2.3\msvc2019_64`)
Add to your PATH (replace the path to Qt if needed):
- C:\Qt\6.2.3\msvc2019_64\bin
Expand Down Expand Up @@ -240,18 +244,20 @@ Once installed, open kDriveExt.sln (in `extensions/windows/cfapi`) then :
- Repeat the same steps using the USB certificate, in an environment variable named `KDC_PHYSICAL_AUMID`
- Update the REGVALUE_AUMID define in `Vfs/cloudproviderregistrar.cpp` file if needed

# Build in Debug mode
# Build in Debug

To build in Debug, you will need to build and deploy the Windows extension first.

## Using Qt Creator
You can disable QML debugger from the settings to avoid some error pop-ups.

## Additionnal Requirements
### Additionnal Requirements

To be able to properly debug, you will need to install `Qt Debug Information Files` from the Qt 6.2.3 section
If you cannot see it, you need to tick the **Archive** box and filter again


## CMake Parameters
### CMake Parameters

Open the kDrive project in Qt Creator
Copy the following list in "Initial CMake Parameters" :
Expand All @@ -265,13 +271,13 @@ Copy the following list in "Initial CMake Parameters" :
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
-DAPPLICATION_UPDATE_URL:STRING=https://www.infomaniak.com/drive/update/desktopclient
-DAPPLICATION_VIRTUALFILE_SUFFIX:STRING=kdrive
-DBIN_INSTALL_DIR:PATH=F:/projects/kdrive
-DVFS_DIRECTORY:PATH=F:/Projects/kdrive/extensions/windows/cfapi/x64/Debug
-DBIN_INSTALL_DIR:PATH=F:/projects/desktop-kDrive
-DVFS_DIRECTORY:PATH=F:/Projects/desktop-kDrive/extensions/windows/cfapi/x64/Debug
-DCMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
-DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
-DCMAKE_INSTALL_PREFIX:PATH=%{ActiveProject:RunConfig:Executable:Path}
-DCRASHREPORTER_SUBMIT_URL:STRING=https://www.infomaniak.com/report/drive/crash
-DKDRIVE_THEME_DIR:STRING=F:/projects/kdrive/infomaniak
-DKDRIVE_THEME_DIR:STRING=F:/projects/desktop-kDrive/infomaniak
-DPLUGINDIR:STRING=C:/Program Files (x86)/kDrive/lib/kDrive/plugins
-DZLIB_INCLUDE_DIR:PATH=C:/Program Files (x86)/zlib-1.2.11/include
-DZLIB_LIBRARY_RELEASE:FILEPATH=C:/Program Files (x86)/zlib-1.2.11/lib/zlib.lib
Expand Down Expand Up @@ -303,7 +309,7 @@ And restart the File Explorer :
start explorer.exe
```

# Build in Release mode
# Build in Release

## Build and Packaging

Expand All @@ -325,4 +331,4 @@ When building in Debug mode, the following error may occur when `CMAKE_INSTALL_P
![sentry_init Debug Error](./doc-images/Qt_Debug_Error.png)

The `INSTALL_PREFIX` must not end with `bin`, and if so you will need to adjust its value
For example, `F:/Projects/build-kdrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug/bin ` must be changed to `F:/Projects/build-kdrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug`
For example, `F:/Projects/build-desktop-kDrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug/bin ` must be changed to `F:/Projects/build-desktop-kDrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug`
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ project(gui)

find_package(Qt6 REQUIRED COMPONENTS Network Sql Widgets SvgWidgets WebEngineWidgets)
find_package(Qt6LinguistTools)
find_package(Poco 1.12.5 REQUIRED Foundation Net)

add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)
Expand Down Expand Up @@ -254,6 +255,7 @@ endif()
target_link_libraries(${APPLICATION_CLIENT_EXECUTABLE}
Qt6::Network Qt6::Sql Qt6::SvgWidgets Qt6::WebEngineWidgets
sentry::sentry
Poco::Foundation Poco::Net
${libcommon_NAME}
${libcommongui_NAME})

Expand Down
5 changes: 2 additions & 3 deletions src/gui/abstractfileitemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ AbstractFileItemWidget::AbstractFileItemWidget(QWidget *parent /*= nullptr*/) :
effect->setOffset(0);
setGraphicsEffect(effect);

// Generic error icon by defaul
// Generic error icon by default
setFileTypeIcon(":/client/resources/icons/statuts/error-sync.svg");

setMinimumHeight(80);
Expand Down Expand Up @@ -185,8 +185,7 @@ void AbstractFileItemWidget::setPath(const QString &path) {
_driveIconLabel->setPixmap(
KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/icon-folder-empty.svg").pixmap(iconSize));

QFileInfo fileInfo(path);
QString printablePath = fileInfo.dir().path();
QString printablePath = "/" + path;
ClementKunz marked this conversation as resolved.
Show resolved Hide resolved
if (printablePath.size() > filePathMaxSize) {
printablePath = printablePath.left(filePathMaxSize) + "...";
}
Expand Down
47 changes: 28 additions & 19 deletions src/gui/genericerroritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "guiutility.h"
#include "clientgui.h"
#include "libcommon/utility/utility.h"
#include "custommessagebox.h"

#include <QDir>
#include <QFileInfo>
Expand Down Expand Up @@ -80,29 +81,37 @@ void GenericErrorItemWidget::init() {
}

void GenericErrorItemWidget::openFolder(const QString &path) {
if (_errorInfo.inconsistencyType() == InconsistencyTypePathLength ||
_errorInfo.inconsistencyType() == InconsistencyTypeCase ||
_errorInfo.inconsistencyType() == InconsistencyTypeForbiddenChar ||
_errorInfo.inconsistencyType() == InconsistencyTypeReservedName ||
_errorInfo.inconsistencyType() == InconsistencyTypeNameLength ||
_errorInfo.inconsistencyType() == InconsistencyTypeNotYetSupportedChar ||
_errorInfo.cancelType() == CancelTypeAlreadyExistLocal ||
(_errorInfo.conflictType() == ConflictTypeEditDelete && !_errorInfo.remoteNodeId().isEmpty())) {
const auto syncInfoMapIt = _gui->syncInfoMap().find(_errorInfo.syncDbId());
if (syncInfoMapIt == _gui->syncInfoMap().end()) {
CustomMessageBox msgBox(QMessageBox::Warning, tr("Unable to open folder path %1.").arg(path), QMessageBox::Ok, this);
msgBox.exec();
return;
}

if (openInWebview()) {
// Open in webview instead
const auto &syncInfoMapIt = _gui->syncInfoMap().find(_errorInfo.syncDbId());
if (syncInfoMapIt != _gui->syncInfoMap().end()) {
const auto &driveInfoMapIt = _gui->driveInfoMap().find(syncInfoMapIt->second.driveDbId());
if (driveInfoMapIt == _gui->driveInfoMap().end()) {
// qCDebug(lcGenericErrorItemWidget()) << "Drive not found in drive map for driveDbId=" <<
// syncInfoMapIt->second.driveDbId();
} else {
_gui->onOpenWebviewItem(syncInfoMapIt->second.driveDbId(), _errorInfo.remoteNodeId());
return;
}
const auto &driveInfoMapIt = _gui->driveInfoMap().find(syncInfoMapIt->second.driveDbId());
if (driveInfoMapIt != _gui->driveInfoMap().end()) {
_gui->onOpenWebviewItem(syncInfoMapIt->second.driveDbId(), _errorInfo.remoteNodeId());
return;
}
}

AbstractFileItemWidget::openFolder(path);
// Open on local filesystem
QString fullPath = syncInfoMapIt->second.localPath() + "/" + path;
AbstractFileItemWidget::openFolder(fullPath);
}

bool GenericErrorItemWidget::openInWebview() const {
return _errorInfo.inconsistencyType() == InconsistencyTypePathLength
|| _errorInfo.inconsistencyType() == InconsistencyTypeCase
|| _errorInfo.inconsistencyType() == InconsistencyTypeForbiddenChar
|| _errorInfo.inconsistencyType() == InconsistencyTypeReservedName
|| _errorInfo.inconsistencyType() == InconsistencyTypeNameLength
|| _errorInfo.inconsistencyType() == InconsistencyTypeNotYetSupportedChar
|| _errorInfo.cancelType() == CancelTypeAlreadyExistLocal
|| (_errorInfo.conflictType() == ConflictTypeEditDelete && !_errorInfo.remoteNodeId().isEmpty())
|| (_errorInfo.exitCode() == ExitCodeBackError && _errorInfo.exitCause() == ExitCauseNotFound);
}

} // namespace KDC
2 changes: 2 additions & 0 deletions src/gui/genericerroritemwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class GenericErrorItemWidget : public AbstractFileItemWidget {
virtual void openFolder(const QString &path) override;

private:
bool openInWebview() const;

std::shared_ptr<ClientGui> _gui;
ErrorInfo _errorInfo;
const QString _errorMsg;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/guiutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,14 @@ bool GuiUtility::openFolder(const QString &dirPath) {
if (!dirPath.isEmpty()) {
QFileInfo fileInfo(dirPath);
if (fileInfo.exists()) {
QUrl url = getUrlFromLocalPath(fileInfo.filePath());
const QUrl url = getUrlFromLocalPath(fileInfo.path());
if (url.isValid()) {
if (!QDesktopServices::openUrl(url)) {
return false;
}
}
} else if (fileInfo.dir().exists()) {
QUrl url = getUrlFromLocalPath(fileInfo.dir().path());
const QUrl url = getUrlFromLocalPath(fileInfo.dir().path());
if (url.isValid()) {
if (!QDesktopServices::openUrl(url)) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/gui/parametersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,7 @@ QString ParametersDialog::getErrorMessage(ErrorInfo &errorInfo) {
"The file/directory has been temporarily blacklisted.")
.arg(errorInfo.path());
} else if (errorInfo.exitCause() == ExitCauseFileTooBig) {
return tr("Impossible to upload a file bigger than 100GB.<br>"
"The file \"%1\" has been temporarily blacklisted")
return tr("The file \"%1\" is too large to be uploaded. It has been temporarily blacklisted.")
.arg(errorInfo.path());
} else if (errorInfo.exitCause() == ExitCauseNotFound) {
return tr("Impossible to download file \"%1\"").arg(errorInfo.path());
Expand Down
4 changes: 2 additions & 2 deletions src/libcommonserver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(libcommonserver)

find_package(SQLite3 3.8.0 REQUIRED)
find_package(Poco 1.12.5 REQUIRED Foundation JSON Util)
find_package(Poco 1.12.5 REQUIRED Foundation Net JSON Util)
find_package(OpenSSL 3.1.0 REQUIRED SSL Crypto)
find_package(log4cplus 2.1.0 REQUIRED)
find_package(xxHash 0.8.1 REQUIRED)
Expand Down Expand Up @@ -84,7 +84,7 @@ endif()
target_link_libraries(${libcommonserver_NAME}
${libcommon_NAME}
${SQLITE3_LIBRARIES}
Poco::Foundation Poco::JSON Poco::Util
Poco::Foundation Poco::Net Poco::JSON Poco::Util
OpenSSL::SSL OpenSSL::Crypto)

if (WIN32)
Expand Down
Loading
Loading