# This file is part of the Flowee project
# Copyright (C) 2020-2026 Tom Zander <tom@flowee.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

project(flowee_lib)

set (PAY_SOURCES
    AccountConfig.cpp
    AccountInfo.cpp
    AddressInfo.cpp
    BitcoinValue.cpp
    ElectronXClient.cpp
    FloweePay.cpp
    ImportHandler.cpp
    IndexerServices.cpp
    MenuModel.cpp
    MetadataRepository.cpp
    NetDataProvider.cpp
    NewIndicatorProvider.cpp
    NewWalletConfig.cpp
    NFCTagData.cpp
    NotificationManager.cpp
    PaymentBackend.cpp
    Payment.cpp
    PaymentDetailComment.cpp
    PaymentDetailInputs.cpp
    PaymentDetailOutput.cpp
    PaymentProtocol.cpp
    PaymentRequest.cpp
    PortfolioDataProvider.cpp
    PriceDataProvider.cpp
    PriceHistoryDataProvider.cpp
    QMLClipboardHelper.cpp
    QMLImportHelper.cpp
    QRScanner.cpp
    RepeatPaymentDetails.cpp
    RepeatPaymentsModel.cpp
    SavedPaymentsHandler.cpp
    SeedsBackup.cpp
    SeedsBackup.cpp
    TransactionInfo.cpp
    TokenTabLayoutProvider.cpp
    TokensManager.cpp
    TxInfoObject.cpp
    UserIntent.cpp
    WalletCoinsModel.cpp
    Wallet.cpp
    Wallet_encryption.cpp
    WalletEnums.cpp
    WalletHistoryModel.cpp
    WalletKeyView.cpp
    WalletSecretsModel.cpp
    Wallet_spending.cpp
    Wallet_support.cpp


    # Modules support
    ModuleInfo.cpp
    ModuleManager.cpp
    ModuleSection.cpp
)
if (ANDROID)
    list(APPEND PAY_SOURCES
        main_utils_android.cpp
        NotificationManager_p_android.h NotificationManager_android.cpp
        FloweePay_android.cpp
    )
    if (AndroidLogBridge)
        list(APPEND PAY_SOURCES LogChannel_android.cpp)
    endif ()
elseif (${Qt6DBus_FOUND})
    list(APPEND PAY_SOURCES
        NotificationManager_p_dbus.h NotificationManager_dbus.cpp
        FloweePay_basic.cpp
        main_utils.cpp
    )
else ()
    list(APPEND PAY_SOURCES
        NotificationManager_dummy.cpp
        FloweePay_basic.cpp
        main_utils.cpp
    )
endif ()

if (ZXing_VERSION_MAJOR EQUAL 2)
    message(STATUS "Using ZXing 2.x")
    list(APPEND PAY_SOURCES QRCreator_zxing2.cpp)
elseif (ZXing_VERSION_MAJOR EQUAL 3)
    message(STATUS "Using ZXing 3.x")
    list(APPEND PAY_SOURCES QRCreator.cpp)
else ()
    message(FATAL_ERROR "Unsupported ZXing version: ${ZXing_VERSION}")
endif ()

if (${Qt6Multimedia_FOUND})
    if (ZXing_VERSION_MAJOR EQUAL 2)
        list(APPEND PAY_SOURCES CameraController_zxing2.cpp)
    else ()
        list(APPEND PAY_SOURCES CameraController.cpp)
    endif ()
    list(APPEND PayLib_PRIVATE_LIBS Qt6::Multimedia)
endif ()

if (NetworkLogClient)
    list(APPEND PAY_SOURCES NetworkLogClient.cpp)
endif ()

add_library(pay_lib STATIC ${PAY_SOURCES})

target_link_libraries(pay_lib
    flowee_apputils
    flowee_utils
    flowee_p2p
    OpenSSL::SSL
    ${Boost_LIBRARIES}
    Qt6::Core Qt6::Quick ${Qt6DBus_LIBRARIES} ${PayLib_PRIVATE_LIBS} ZXing::ZXing )
