// Generated with hyprwire-scanner 0.3.1. Made with vaxry's keyboard and ❤️.
// hyprlauncher_core

/*
 This protocol's authors' copyright notice is:


    BSD 3-Clause License

    Copyright (c) 2025, Hypr Development

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this
        list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright notice,
        this list of conditions and the following disclaimer in the documentation
        and/or other materials provided with the distribution.

    3. Neither the name of the copyright holder nor the names of its
        contributors may be used to endorse or promote products derived from
        this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
*/


#define private public
#include "hyprlauncher_core-client.hpp"
#undef private

using namespace Hyprutils::Memory;
#define SP CSharedPointer
    
CCHyprlauncherCoreManagerObject::CCHyprlauncherCoreManagerObject(Hyprutils::Memory::CSharedPointer<Hyprwire::IObject>&& object) : m_object(std::move(object)) {
    m_object->setData(this);
            
}

CCHyprlauncherCoreManagerObject::~CCHyprlauncherCoreManagerObject() {
    ; // TODO: call destructor if present
}
void CCHyprlauncherCoreManagerObject::sendSetOpenState(uint32_t state) {
    m_object->call(0, state);
}

void CCHyprlauncherCoreManagerObject::sendOpenWithOptions(const std::vector<const char*>& options) {
    m_object->call(1, options.data(), (uint32_t)options.size());
}


SP<Hyprwire::IObject> CCHyprlauncherCoreManagerObject::sendGetInfoObject() {
    auto _seq = m_object->call(2);
    return m_object->clientSock()->objectForSeq(_seq);
}

void CCHyprlauncherCoreManagerObject::sendDestroy() {
    m_object->call(3);
}

static void hyprlauncherCoreInfo_method0(Hyprwire::IObject* r, uint32_t state) {
    auto& fn = rc<CCHyprlauncherCoreInfoObject*>(r->getData())->m_listeners.open_state;
    if (fn)
        fn(state);
}

static void hyprlauncherCoreInfo_method1(Hyprwire::IObject* r, const char* selected) {
    auto& fn = rc<CCHyprlauncherCoreInfoObject*>(r->getData())->m_listeners.selection_made;
    if (fn)
        fn(selected);
}

CCHyprlauncherCoreInfoObject::CCHyprlauncherCoreInfoObject(Hyprutils::Memory::CSharedPointer<Hyprwire::IObject>&& object) : m_object(std::move(object)) {
    m_object->setData(this);
            
    m_object->listen(0, rc<void*>(::hyprlauncherCoreInfo_method0));
    m_object->listen(1, rc<void*>(::hyprlauncherCoreInfo_method1));
}

CCHyprlauncherCoreInfoObject::~CCHyprlauncherCoreInfoObject() {
    ; // TODO: call destructor if present
}
void CCHyprlauncherCoreInfoObject::sendDestroy() {
    m_object->call(0);
}

void CCHyprlauncherCoreInfoObject::setOpenState(std::function<void(uint32_t)>&& fn) {
    m_listeners.open_state = std::move(fn);
}

void CCHyprlauncherCoreInfoObject::setSelectionMade(std::function<void(const char*)>&& fn) {
    m_listeners.selection_made = std::move(fn);
}

CCHyprlauncherCoreImpl::CCHyprlauncherCoreImpl(uint32_t ver) : m_version(ver) {
    ;
}

static auto hyprlauncherCoreSpec = makeShared<CHyprlauncherCoreProtocolSpec>();

SP<Hyprwire::IProtocolSpec> CCHyprlauncherCoreImpl::protocol() {
    return hyprlauncherCoreSpec;
}

std::vector<SP<Hyprwire::SClientObjectImplementation>> CCHyprlauncherCoreImpl::implementation() {
    return {

            makeShared<Hyprwire::SClientObjectImplementation>(Hyprwire::SClientObjectImplementation{
                .objectName = "hyprlauncher_core_manager",
                .version    = m_version,
            }),

            makeShared<Hyprwire::SClientObjectImplementation>(Hyprwire::SClientObjectImplementation{
                .objectName = "hyprlauncher_core_info",
                .version    = m_version,
            }),
};
}
