/*
 * Copyright (C) 2020 The Qt Company Ltd.
 * Copyright 2022 KylinSoft Co., Ltd.
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#ifndef APPMANAGERSERVICE_H
#define APPMANAGERSERVICE_H

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

/*
 * Adaptor class for interface com.kylin.AppManager
 */
class AppManagerService: public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.kylin.AppManager")
    Q_CLASSINFO("D-Bus Introspection", ""
"  <interface name=\"com.kylin.AppManager\">\n"
"    <method name=\"LaunchApp\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"ActiveProcessByWid\">\n"
"      <arg direction=\"in\" type=\"u\" name=\"wid\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"LaunchAppWithArguments\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"in\" type=\"as\" name=\"args\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"LaunchDefaultAppWithUrl\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"url\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"LaunchXdgFile\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"in\" type=\"s\" name=\"file\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"AppDesktopFileNameByPid\">\n"
"      <arg direction=\"in\" type=\"x\" name=\"pid\"/>\n"
"      <arg direction=\"out\" type=\"s\" name=\"desktopFileName\"/>\n"
"    </method>\n"
"    <method name=\"AppDesktopFileNameByWid\">\n"
"      <arg direction=\"in\" type=\"x\" name=\"wid\"/>\n"
"      <arg direction=\"out\" type=\"s\" name=\"desktopFileName\"/>\n"
"    </method>\n"
"    <method name=\"SetPowerSavingModeEnable\">\n"
"      <arg direction=\"in\" type=\"b\" name=\"enable\"/>\n"
"    </method>\n"
"    <method name=\"AddToWhiteList\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"in\" type=\"s\" name=\"option\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"RemoveFromWhiteList\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"in\" type=\"s\" name=\"option\"/>\n"
"      <arg direction=\"out\" type=\"b\" name=\"succeed\"/>\n"
"    </method>\n"
"    <method name=\"WhiteListsOfApp\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
"      <arg direction=\"out\" type=\"as\" name=\"whiteLists\"/>\n"
"    </method>\n"
"    <signal name=\"startSuccess\"/>\n"
"  </interface>\n"
        "")
public:
    AppManagerService(QObject *parent);
    virtual ~AppManagerService();

public: // PROPERTIES
public Q_SLOTS: // METHODS
    bool ActiveProcessByWid(uint wid);
    bool AddToWhiteList(const QString &desktopFile, const QString &option);
    QString AppDesktopFileNameByPid(qlonglong pid);
    QString AppDesktopFileNameByWid(qlonglong wid);
    bool LaunchApp(const QString &desktopFile);
    bool LaunchAppWithArguments(const QString &desktopFile, const QStringList &args);
    bool LaunchDefaultAppWithUrl(const QString &url);
    bool LaunchXdgFile(const QString &desktopFile, const QString &file);
    bool RemoveFromWhiteList(const QString &desktopFile, const QString &option);
    void SetPowerSavingModeEnable(bool enable);
    QStringList WhiteListsOfApp(const QString &desktopFile);
Q_SIGNALS: // SIGNALS
    void startSuccess();
};

#endif
