MEGA Desktop

repository·master·Indexed 23 days ago

https://github.com/meganz/megasync

An automated synchronization and backup tool that maintains bidirectional replication between local folders and the MEGA Cloud Drive. Supported on Windows 10+, macOS Catalina 10.15+, and various Debian- and RedHat-based Linux distributions. The project utilizes the MEGA C++ SDK for server communication and employs VCPKG for dependency management, with build support via CMake and Qt Creator.

Tokens
8.8K
Snippets
23
Records
54
Agent score
84%

What's inside megasync

  1. Overview of MEGA Desktop Application

    master
    MEGA Desktop is an automated syncing and backup application that replicates folders between your local computer and your MEGA Cloud Drive. It performs bidirectional synchronization: changes made on your device (including renaming, moving, and deleting) are reflected in the MEGA Cloud Drive, and changes made in the Cloud Drive are reflected in your local synced folders.
  2. Use the MEGA C++ SDK for server access

    master

    MEGAsync relies on the MEGA C++ SDK to handle all functionality requiring communication with MEGA servers. The SDK provides the core capabilities of MEGA's client applications, including end-to-end encryption (User Controlled Encryption) and secure data transfers. If you are building custom tools or analyzing the security of MEGA products, you should use the SDK directly rather than attempting to replicate the protocol.

    SDK Repository: https://github.com/meganz/sdk
    License: Simplified (2-clause) BSD License.

  3. Understand the Qt patch directory structure

    master

    The contrib/build_qt/patches directory contains patches applied to Qt submodules before building. Patches are organized by Qt version, then by submodule, and finally by a filename convention that determines application order and target platform.

    Patch Filename Convention

    To control when and how a patch is applied, use the following naming pattern: <order>.<os>.<name>

    • <order>: A 2-digit, zero-padded numerical value (e.g., 00, 01). Patches are applied in ascending order.
    • <os>: Specifies the target platform:
      • all: Applied to all platforms.
      • win: Applied only to Windows builds.
      • macx: Applied only to macOS builds.
    • <name>: The descriptive name of the patch including its extension (e.g., .diff or .patch).
    <Qt Version>
        ├───<qt submodule>
        │       <order>.<os>.<name>
        │       <order>.<os>.<name>
        │       [...]
        │
        ├───<qt submodule>
        │       <order>.<os>.<name>
        │       <order>.<os>.<name>
        │       [...]
        [...]
  4. Understand the testing framework used in MEGAsync

    master

    MEGAsync uses two primary frameworks for its automated testing and unit testing suites:

    1. Catch2: A modern, C++-native framework used for running automated tests on MEGAsync modules.
    2. Trompeloeil: A thread-safe header-only mocking framework used for mocking in automated tests.
  5. Build the MEGAsync Desktop App

    master

    Once configured, use CMake to build the MEGAsync target. You can specify either Debug or Release configurations.

    Example (Debug build):

    cmake --build 'c:\mega\build-x64' --config Debug --target MEGAsync

    The resulting executable will be located in .\src\MEGASync\<Configuration>\ (e.g., .\src\MEGASync\Debug\).

  6. Configure MEGAsync in Qt Creator

    master

    For IDE-based development, you can use Qt Creator. After opening the root CMakeLists.txt, you must manually add the VCPKG_ROOT variable to the CMake configuration:

    1. Open the CMakeLists.txt in Qt Creator.
    2. In the "Initial Configuration" tab, add a new key: VCPKG_ROOT.
    3. Set the value to your VCPKG root directory (e.g., ~/mega/vcpkg).
    4. Click "Re-configure with Initial Parameters".
  7. Install development tools for Windows

    master

    To develop the MEGA Desktop App on Windows, you need to install the following tools:

    • Visual Studio 2019: Install the Community or Professional Edition via the Visual Studio Installer. You must include the Desktop Development with C++ workload.
    • CMake: Download the Windows x64 Installer from cmake.org. It is recommended to add CMake to the system PATH during installation.
    • Git: Download Git for Windows. During installation, select Checkout as-is, commit as-is to prevent line ending conversions and add Git tools to the user environment PATH.
    • Windows Terminal: Use Windows Terminal with PowerShell for command-line builds.
  8. Configure the project with CMake

    master

    Use CMake to configure the build. You must provide the path to your VCPKG installation using the -DVCPKG_ROOT flag. It is recommended to build in a separate directory outside of the source tree.

    Required CMake arguments:

    • -DVCPKG_ROOT: The absolute path to your VCPKG installation.
    • -S: The path to the desktop application source repository.
    • -B: The path to the directory where the build files will be generated.
    • -DCMAKE_BUILD_TYPE: Set to Debug or Release.
    cd ~/mega
    cmake -DVCPKG_ROOT='~/mega/vcpkg' -S '~/mega/desktop' -B '~/mega/build_dir' -DCMAKE_BUILD_TYPE=Debug
  9. Install and setup VCPKG

    master

    MEGA uses Microsoft's VCPKG C++ Library Manager to manage third-party dependencies. You must clone the VCPKG repository to a local directory (e.g., c:\mega\) before building the project.

    mkdir c:\mega\
    cd c:\mega\
    git clone https://github.com/microsoft/vcpkg
  10. Set up VCPKG for dependency management

    master

    MEGAsync uses Microsoft's VCPKG C++ Library Manager to handle third-party dependencies (including Qt). You must clone the VCPKG repository to a local directory before building the project.

    mkdir ~/mega
    cd ~/mega
    git clone https://github.com/microsoft/vcpkg
  11. Develop using Qt Creator

    master

    To use Qt Creator for development:

    1. Open the CMakeLists.txt file located at the root of the repository.
    2. Select your desired configuration and set the build path.
    3. Configure VCPKG: In the "Initial Configuration" tab, add a new VCPKG_ROOT key for each configuration and set its value to your VCPKG root directory (e.g., ~/mega/vcpkg).
    4. Click "Re-configure with Initial Parameters" and wait for the process to complete.