/*
 * Copyright (C) 2023 ~ 2023 Deepin Technology Co., Ltd.
 *
 * Author:     zhangyu <zhangyud@uniontech.com>
 *
 * Maintainer: zhangyu <zhangyud@uniontech.com>
 *
 * 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
 * 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/>.
 */
#include "screenmark.h"
#include "deepinwatermark.h"
#include "utils.h"

static DeepinWatermark *watermark = nullptr;

void LoadScreenMark()
{
    if (watermark == nullptr)
        watermark = new DeepinWatermark;
}

void FreeScreenMark()
{
    if (watermark) {
        watermark->clearConfig();
        delete watermark;
        watermark = nullptr;
    }
}

bool GetScreenMarkStatus()
{
    if (watermark)
        return watermark->watermarkStatus();
    return false;
}

void SetScreenWaterMark(const char *strPolicy)
{
    if (watermark)
        watermark->setScreenWatermark(strPolicy);
    else
        qWarning() << "Can't set screen water mark, watermark is null";
}

bool IsAccessible(int pid)
{
    if (watermark)
        return watermark->isAccessible(pid);
    return false;
}
