feat: AM 默认程序迁移
默认程序迁移到AM中 Log: 默认程序迁移到AM Task: https://pms.uniontech.com/task-view-140029.html Influence: 默认程序 Change-Id: I0824c503b6ab844f09b3bf3cf740565b1e4215e5
This commit is contained in:
48
src/modules/methods/process_status.hpp
Normal file
48
src/modules/methods/process_status.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef PROCESS_STATUS_H_
|
||||
#define PROCESS_STATUS_H_
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Methods {
|
||||
struct ProcessStatus {
|
||||
QString data;
|
||||
QString type;
|
||||
QString id;
|
||||
int code;
|
||||
};
|
||||
|
||||
inline void toJson(QByteArray& array, const ProcessStatus& processStatus)
|
||||
{
|
||||
QJsonObject obj {
|
||||
{ "type", processStatus.type },
|
||||
{ "data", processStatus.data },
|
||||
{ "id", processStatus.id },
|
||||
{ "code", processStatus.code }
|
||||
};
|
||||
|
||||
array = QJsonDocument(obj).toJson();
|
||||
}
|
||||
inline void fromJson(const QByteArray& array, ProcessStatus& quit)
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
if (!doc.isObject()) {
|
||||
qWarning() << "fromJson quit failed";
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject obj = doc.object();
|
||||
if (!obj.contains("id") || !obj.contains("data") || !obj.contains("code")) {
|
||||
qWarning() << "id data code not exist in quit array";
|
||||
return;
|
||||
}
|
||||
|
||||
quit.id = obj.value("id").toString();
|
||||
quit.data = obj.value("data").toString();
|
||||
quit.code = obj.value("code").toInt();
|
||||
quit.type = obj.value("type").toString();
|
||||
}
|
||||
} // namespace Methods
|
||||
|
||||
#endif // PROCESS_STATUS_H_
|
70
src/modules/methods/use_default_app_info.h
Normal file
70
src/modules/methods/use_default_app_info.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef USE_DEFAULT_APP_INFO_H
|
||||
#define USE_DEFAULT_APP_INFO_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <vector>
|
||||
|
||||
namespace Methods {
|
||||
struct DefaultUserAppInfo {
|
||||
QVariantList appId;
|
||||
std::string appType;
|
||||
QVariantList supportedType;
|
||||
};
|
||||
|
||||
struct DefaultUserAppInfos {
|
||||
std::vector<DefaultUserAppInfo> appInfos;
|
||||
};
|
||||
|
||||
inline void toJson(QJsonObject& j, const DefaultUserAppInfo& userAppInfo)
|
||||
{
|
||||
j = QJsonObject{ { "appId", QJsonArray::fromVariantList(userAppInfo.appId) }, { "appType", userAppInfo.appType.c_str() }, { "supportedType", QJsonArray::fromVariantList(userAppInfo.supportedType) }};
|
||||
}
|
||||
|
||||
inline void fromJson(const QJsonObject& j, DefaultUserAppInfo& userAppInfo)
|
||||
{
|
||||
|
||||
if (j.contains("appId")) {
|
||||
userAppInfo.appId = j.value("appId").toArray().toVariantList();
|
||||
}
|
||||
|
||||
if (j.contains("appType")) {
|
||||
userAppInfo.appType = j.value("appType").toString().toStdString();
|
||||
}
|
||||
|
||||
if (j.contains("supportedType")) {
|
||||
userAppInfo.supportedType = j.value("supportedType").toArray().toVariantList();
|
||||
}
|
||||
}
|
||||
|
||||
inline void toJson(QJsonObject& j, const DefaultUserAppInfos& userAppInfos)
|
||||
{
|
||||
QJsonObject tmpObj;
|
||||
QJsonArray appInfoArray;
|
||||
|
||||
for (auto appInfo : userAppInfos.appInfos) {
|
||||
toJson(tmpObj, appInfo);
|
||||
appInfoArray.append(tmpObj);
|
||||
}
|
||||
|
||||
j = QJsonObject {
|
||||
{"appInfos", appInfoArray}
|
||||
};
|
||||
}
|
||||
|
||||
inline void fromJson(const QJsonObject& j, DefaultUserAppInfos& userAppInfos)
|
||||
{
|
||||
QJsonObject tmpObj = j;
|
||||
|
||||
if (j.contains("appInfos")) {
|
||||
DefaultUserAppInfo userAppInfo;
|
||||
for (auto appInfo : tmpObj.take("appInfos").toArray()) {
|
||||
fromJson(appInfo.toObject(), userAppInfo);
|
||||
userAppInfos.appInfos.push_back(userAppInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Methods
|
||||
|
||||
#endif // USE_DEFAULT_APP_INFO_H
|
59
src/modules/methods/use_mime_app_info.h
Normal file
59
src/modules/methods/use_mime_app_info.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef USE_MIME_APP_INFO_H
|
||||
#define USE_MIME_APP_INFO_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <vector>
|
||||
|
||||
namespace Methods {
|
||||
struct UserAppInfo {
|
||||
std::string deskopid;
|
||||
QVariantList supportedMime;
|
||||
};
|
||||
|
||||
struct UserAppInfos {
|
||||
std::vector<UserAppInfo> appInfos;
|
||||
};
|
||||
|
||||
inline void toJson(QJsonObject& j, const UserAppInfo& userAppInfo)
|
||||
{
|
||||
j = QJsonObject{ { "DesktopId", userAppInfo.deskopid.c_str() }, { "SupportedMime", QJsonArray::fromVariantList(userAppInfo.supportedMime) } };
|
||||
}
|
||||
|
||||
inline void fromJson(const QJsonObject& j, UserAppInfo& userAppInfo)
|
||||
{
|
||||
if (j.contains("DesktopId")) {
|
||||
userAppInfo.deskopid = j.value("DesktopId").toString().toStdString();
|
||||
}
|
||||
|
||||
if (j.contains("SupportedMime")) {
|
||||
userAppInfo.supportedMime = j.value("SupportedMime").toArray().toVariantList();
|
||||
}
|
||||
}
|
||||
inline void toJson(QJsonArray& j, const UserAppInfos& userAppInfos)
|
||||
{
|
||||
QJsonObject tmpObj;
|
||||
QJsonArray appInfoArray;
|
||||
|
||||
for (auto appInfo : userAppInfos.appInfos) {
|
||||
toJson(tmpObj, appInfo);
|
||||
appInfoArray.append(tmpObj);
|
||||
}
|
||||
|
||||
j = appInfoArray;
|
||||
}
|
||||
|
||||
inline void fromJson(const QJsonArray& j, UserAppInfos& userAppInfos)
|
||||
{
|
||||
QJsonArray tmpObj = j;
|
||||
|
||||
for (auto iter : tmpObj) {
|
||||
UserAppInfo userAppInfo;
|
||||
fromJson(iter.toObject(), userAppInfo);
|
||||
userAppInfos.appInfos.push_back(userAppInfo);
|
||||
}
|
||||
}
|
||||
} // namespace Methods
|
||||
|
||||
#endif // USE_MIME_APP_INFO_H
|
426
src/modules/mimeapp/mime_app.cpp
Normal file
426
src/modules/mimeapp/mime_app.cpp
Normal file
@ -0,0 +1,426 @@
|
||||
#include "mime_app.h"
|
||||
#include "utils.h"
|
||||
#include "../methods/use_mime_app_info.h"
|
||||
#include "../methods/use_default_app_info.h"
|
||||
#include "appinfo.h"
|
||||
#include "terminalinfo.h"
|
||||
#include "appinfocommon.h"
|
||||
|
||||
#include <qmutex.h>
|
||||
#include <QSettings>
|
||||
#include <QVector>
|
||||
#include <QFileInfo>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <QJsonParseError>
|
||||
#include <QDebug>
|
||||
|
||||
class MimeAppPrivate : public QObject
|
||||
{
|
||||
MimeApp *q_ptr = nullptr;
|
||||
Q_DECLARE_PUBLIC(MimeApp)
|
||||
|
||||
private:
|
||||
Methods::UserAppInfos userAppInfos;
|
||||
std::string filename;
|
||||
QMutex mutex;
|
||||
public:
|
||||
MimeAppPrivate(MimeApp *parent) : QObject(parent), q_ptr(parent)
|
||||
{
|
||||
std::string homeDir = getUserHomeDir();
|
||||
if (!homeDir.empty()) {
|
||||
homeDir += "/.config/deepin/dde-daemon/user_mime.json";
|
||||
filename = homeDir;
|
||||
}
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
QFile file(filename.c_str());
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonParseError *error = new QJsonParseError;
|
||||
QJsonDocument jdc = QJsonDocument::fromJson(file.readAll(), error);
|
||||
|
||||
Methods::fromJson(jdc.array(), userAppInfos);
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void Write()
|
||||
{
|
||||
QFile file(filename.c_str());
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonArray jsonArr;
|
||||
Methods::toJson(jsonArr, userAppInfos);
|
||||
|
||||
QJsonDocument jdc;
|
||||
jdc.setArray(jsonArr);
|
||||
file.write(jdc.toJson(QJsonDocument::Compact)); //Indented:表示自动添加/n回车符
|
||||
file.close();
|
||||
}
|
||||
|
||||
bool Add(const std::string &desktopId, QStringList mimeTypes)
|
||||
{
|
||||
bool bAdd = false;
|
||||
|
||||
std::vector<Methods::UserAppInfo>::iterator iter = userAppInfos.appInfos.begin();
|
||||
while (iter != userAppInfos.appInfos.end()) {
|
||||
if (iter->deskopid == desktopId) {
|
||||
for (auto mimeType : mimeTypes) {
|
||||
if (std::find(iter->supportedMime.begin(), iter->supportedMime.end(), mimeType) != iter->supportedMime.end()) {
|
||||
bAdd = true;
|
||||
iter->supportedMime.push_back(mimeType);
|
||||
}
|
||||
}
|
||||
return bAdd;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
bAdd = true;
|
||||
Methods::UserAppInfo appInfo;
|
||||
for (auto mimeType : mimeTypes) {
|
||||
|
||||
appInfo.supportedMime.push_back(mimeType);
|
||||
}
|
||||
|
||||
userAppInfos.appInfos.push_back(appInfo);
|
||||
|
||||
return bAdd;
|
||||
}
|
||||
|
||||
bool Delete(const std::string &desktopId)
|
||||
{
|
||||
std::vector<Methods::UserAppInfo>::iterator iter = userAppInfos.appInfos.begin();
|
||||
|
||||
while (iter != userAppInfos.appInfos.end()) {
|
||||
if (iter->deskopid == desktopId) {
|
||||
iter = userAppInfos.appInfos.erase(iter);
|
||||
return true;
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeleteMimeTypes(const std::string &desktopId, QStringList mimeTypes)
|
||||
{
|
||||
bool bDelete = false;
|
||||
std::vector<Methods::UserAppInfo>::iterator iter = userAppInfos.appInfos.begin();
|
||||
|
||||
while (iter != userAppInfos.appInfos.end()) {
|
||||
if (iter->deskopid == desktopId) {
|
||||
for (auto mimeType : mimeTypes) {
|
||||
if (std::find(iter->supportedMime.begin(), iter->supportedMime.end(), mimeType) == iter->supportedMime.end()) {
|
||||
bDelete = true;
|
||||
iter->supportedMime.push_back(mimeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
return bDelete;
|
||||
}
|
||||
|
||||
std::vector<Methods::UserAppInfo> GetUserAppInfosByMimeType(std::string mimeType)
|
||||
{
|
||||
std::vector<Methods::UserAppInfo> retVector;
|
||||
|
||||
for (auto iter : userAppInfos.appInfos) {
|
||||
if (std::find(iter.supportedMime.begin(), iter.supportedMime.end(), mimeType.c_str()) != iter.supportedMime.end()) {
|
||||
retVector.push_back(iter);
|
||||
}
|
||||
}
|
||||
|
||||
return retVector;
|
||||
}
|
||||
~MimeAppPrivate() {}
|
||||
|
||||
};
|
||||
|
||||
MimeApp::MimeApp(QObject *parent) : QObject(parent), dd_ptr(new MimeAppPrivate(this))
|
||||
{
|
||||
Q_D(MimeApp);
|
||||
d->Init();
|
||||
initConfigData();
|
||||
}
|
||||
|
||||
MimeApp::~MimeApp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MimeApp::deleteMimeAssociation(std::string mimeType, std::string desktopId)
|
||||
{
|
||||
Q_D(MimeApp);
|
||||
|
||||
KeyFile keyFile;
|
||||
keyFile.loadFile(d->filename);
|
||||
|
||||
std::vector<std::string> sessions{AppinfoCommon::SectionDefaultApps, AppinfoCommon::SectionAddedAssociations};
|
||||
|
||||
for (auto iter : sessions) {
|
||||
std::vector<std::string> apps = keyFile.getStrList(iter, mimeType);
|
||||
std::vector<std::string>::iterator app = apps.begin();
|
||||
while (app != apps.end()) {
|
||||
if ((*app) == desktopId) {
|
||||
app = apps.erase(app);
|
||||
} else {
|
||||
app++;
|
||||
}
|
||||
}
|
||||
if (apps.empty()) {
|
||||
//keyFile.DeleteKey(section, mimeType);
|
||||
} else {
|
||||
//keyFile.SetStringList(iter,mimeType,apps);
|
||||
}
|
||||
}
|
||||
|
||||
keyFile.saveToFile(d->filename);
|
||||
}
|
||||
|
||||
void MimeApp::initConfigData()
|
||||
{
|
||||
std::string filename = findFilePath("/dde-daemon/mime/data.json");
|
||||
|
||||
QFile file(filename.c_str());
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonParseError *error = new QJsonParseError;
|
||||
QJsonDocument jdc = QJsonDocument::fromJson(file.readAll(), error);
|
||||
|
||||
Methods::DefaultUserAppInfos defaultAppInfos;
|
||||
Methods::fromJson(jdc.object(), defaultAppInfos);
|
||||
|
||||
file.close();
|
||||
|
||||
for (auto defaultApp : defaultAppInfos.appInfos) {
|
||||
std::string validAppId;
|
||||
|
||||
for (auto type : defaultApp.supportedType) {
|
||||
if (!validAppId.empty()) {
|
||||
if (setDefaultApp(type.toString().toStdString(), validAppId)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto appId : defaultApp.appId) {
|
||||
if (setDefaultApp(type.toString().toStdString(), appId.toString().toStdString())) {
|
||||
validAppId = appId.toString().toStdString();
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string MimeApp::findFilePath(std::string fileName)
|
||||
{
|
||||
std::string homeDir = getUserHomeDir();
|
||||
std::string path = homeDir + "/.local/share" + fileName;
|
||||
|
||||
QFileInfo file(path.c_str());
|
||||
if (file.isFile()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
path = "/usr/local/share" + fileName;
|
||||
|
||||
file.setFile(path.c_str());
|
||||
if (file.isFile()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
return "/usr/share" + fileName;
|
||||
}
|
||||
|
||||
void MimeApp::AddUserApp(QStringList mimeTypes, const QString &desktopId)
|
||||
{
|
||||
qInfo() << "AddUserApp mimeTypes: " << mimeTypes << ", desktopId: " << desktopId;
|
||||
Q_D(MimeApp);
|
||||
|
||||
std::shared_ptr<AppInfoManger> appInfo = AppInfoManger::loadByDesktopId(desktopId.toStdString());
|
||||
if (!appInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool bAdd = d->Add(desktopId.toStdString(), mimeTypes);
|
||||
|
||||
if (bAdd) {
|
||||
d->Write();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool MimeApp::setDefaultApp(const std::string &mimeType, const std::string &desktopId)
|
||||
{
|
||||
qInfo() << "setDefaultApp mimeType: " << mimeType.c_str() << ", desktopId: " << desktopId.c_str();
|
||||
Q_D(MimeApp);
|
||||
|
||||
KeyFile keyFile;
|
||||
keyFile.loadFile(d->filename);
|
||||
|
||||
std::string curDeskTopId = keyFile.getStr(AppinfoCommon::SectionDefaultApps, mimeType);
|
||||
if (curDeskTopId == desktopId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return AppInfoManger::getDefaultApp(mimeType, desktopId);
|
||||
}
|
||||
|
||||
void MimeApp::DeleteApp(QStringList mimeTypes, const QString &desktopId)
|
||||
{
|
||||
qInfo() << "DeleteApp mimeTypes: " << mimeTypes << ", desktopId: " << desktopId;
|
||||
Q_D(MimeApp);
|
||||
|
||||
if (d->DeleteMimeTypes(desktopId.toStdString(), mimeTypes)) {
|
||||
d->Write();
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AppInfoManger> appInfo = AppInfoManger::loadByDesktopId(desktopId.toStdString());
|
||||
if (!appInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> originMimeTypes = appInfo->getStringList(AppinfoCommon::MainSection, AppinfoCommon::KeyMimeType);
|
||||
|
||||
for (auto iter : mimeTypes) {
|
||||
if (std::find(originMimeTypes.begin(), originMimeTypes.end(), iter.toStdString()) == originMimeTypes.end()) {
|
||||
deleteMimeAssociation(iter.toStdString(), desktopId.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MimeApp::DeleteUserApp(const QString &desktopId)
|
||||
{
|
||||
qInfo() << "DeleteUserApp desktopId: " << desktopId;
|
||||
Q_D(MimeApp);
|
||||
|
||||
bool bDelete = d->Delete(desktopId.toStdString());
|
||||
|
||||
if (bDelete) {
|
||||
d->Write();
|
||||
}
|
||||
}
|
||||
|
||||
QString MimeApp::GetDefaultApp(const QString &mimeType)
|
||||
{
|
||||
qInfo() << "GetDefaultApp mimeType: " << mimeType;
|
||||
std::shared_ptr<AppInfoManger> appInfo;
|
||||
|
||||
if (mimeType.toStdString().compare(AppinfoCommon::AppMimeTerminal) == 0) {
|
||||
appInfo = TerminalInfo::getInstanceTerminal().getDefaultTerminal();
|
||||
} else {
|
||||
std::string appId = AppInfoManger::getDefaultApp(mimeType.toStdString(), false);
|
||||
appInfo = AppInfoManger::loadByDesktopId(appId);
|
||||
}
|
||||
|
||||
if (!appInfo) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return appInfo->toJson().c_str();
|
||||
}
|
||||
|
||||
QString MimeApp::ListApps(const QString &mimeType)
|
||||
{
|
||||
qInfo() << "ListApps mimeType: " << mimeType;
|
||||
std::vector<std::shared_ptr<AppInfoManger>> appInfos;
|
||||
|
||||
if (mimeType.toStdString().compare(AppinfoCommon::AppMimeTerminal) == 0) {
|
||||
appInfos = TerminalInfo::getInstanceTerminal().getTerminalInfos();
|
||||
} else {
|
||||
std::vector<std::string> appList = AppInfoManger::getAppList(mimeType.toStdString());
|
||||
|
||||
for (auto iter : appList) {
|
||||
std::shared_ptr<AppInfoManger> appInfo = AppInfoManger::loadByDesktopId(iter);
|
||||
if (appInfo) {
|
||||
appInfos.push_back(appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string userAppDir = getUserDataDir() + "/applications";
|
||||
std::vector<std::shared_ptr<AppInfoManger>>::iterator iter = appInfos.begin();
|
||||
|
||||
while (iter != appInfos.end()) {
|
||||
QDir dir((*iter)->getFileName().c_str());
|
||||
|
||||
if (dir.path().toStdString() == userAppDir && hasBeginWith(dir.path().toStdString(), "deepin-custom-")) {
|
||||
iter = appInfos.erase(iter);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
return AppInfoManger::toJson(appInfos).c_str();
|
||||
}
|
||||
|
||||
QString MimeApp::ListUserApps(const QString &mimeType)
|
||||
{
|
||||
qInfo() << "ListUserApps mimeType: " << mimeType;
|
||||
Q_D(MimeApp);
|
||||
|
||||
std::vector<std::shared_ptr<AppInfoManger>> retAppInfos;
|
||||
|
||||
std::vector<Methods::UserAppInfo> userAppInfos = d->GetUserAppInfosByMimeType(mimeType.toStdString());
|
||||
std::vector<Methods::UserAppInfo>::iterator iter = userAppInfos.begin();
|
||||
|
||||
while (iter != userAppInfos.end()) {
|
||||
std::shared_ptr<AppInfoManger> appInfo = AppInfoManger::loadByDesktopId(iter->deskopid);
|
||||
if (appInfo) {
|
||||
appInfo->setCanDelete(true);
|
||||
retAppInfos.push_back(appInfo);
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
return AppInfoManger::toJson(retAppInfos).c_str();
|
||||
}
|
||||
|
||||
void MimeApp::SetDefaultApp(const QStringList &mimeTypes, const QString &desktopId)
|
||||
{
|
||||
qInfo() << "SetDefaultApp mimeTypes: " << mimeTypes << ", desktopId: " << desktopId;
|
||||
|
||||
bool bSuccess = false;
|
||||
for (auto mime : mimeTypes) {
|
||||
if (mime.toStdString().compare(AppinfoCommon::AppMimeTerminal) == 0) {
|
||||
bSuccess = TerminalInfo::getInstanceTerminal().setDefaultTerminal(desktopId.toStdString());
|
||||
} else {
|
||||
bSuccess = AppInfoManger::getDefaultApp(mime.toStdString(), desktopId.toStdString());
|
||||
}
|
||||
|
||||
if (!bSuccess) {
|
||||
qWarning() << "SetDefaultApp faile";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
40
src/modules/mimeapp/mime_app.h
Normal file
40
src/modules/mimeapp/mime_app.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef MIME_APP_H
|
||||
#define MIME_APP_H
|
||||
|
||||
#include "../../lib/dfile.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class MimeAppPrivate;
|
||||
class MimeApp : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QScopedPointer<MimeAppPrivate> dd_ptr;
|
||||
Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), MimeApp)
|
||||
public:
|
||||
explicit MimeApp(QObject *parent = nullptr);
|
||||
void deleteMimeAssociation(std::string mimeType, std::string desktopId);
|
||||
void initConfigData();
|
||||
bool setDefaultApp(const std::string &mimeType, const std::string &desktopId);
|
||||
std::string findFilePath(std::string fileName);
|
||||
~MimeApp() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
// Standard Notifications dbus implementation
|
||||
void Change();
|
||||
public: // PROPERTIES
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
void AddUserApp(QStringList mimeTypes, const QString &desktopId);
|
||||
void DeleteApp(QStringList mimeTypes, const QString &desktopId);
|
||||
void DeleteUserApp(const QString &desktopId);
|
||||
QString GetDefaultApp(const QString &mimeType);
|
||||
QString ListApps(const QString &mimeType);
|
||||
QString ListUserApps(const QString &mimeType);
|
||||
void SetDefaultApp(const QStringList &mimeTypes, const QString &desktopId);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // MIME_APP_H
|
@ -62,7 +62,7 @@ void ServerPrivate::work()
|
||||
}
|
||||
|
||||
if (buffer[readBytes - 1] == '\0') {
|
||||
emit q_ptr->onReadyRead(socket, data);
|
||||
Q_EMIT q_ptr->onReadyRead(socket, data);
|
||||
data.clear();
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ bool Server::listen(const std::string &host)
|
||||
d_ptr->workThread = new QThread;
|
||||
d_ptr->moveToThread(d_ptr->workThread);
|
||||
d_ptr->workThread->start();
|
||||
emit d_ptr->requestStart();
|
||||
Q_EMIT d_ptr->requestStart();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
};
|
||||
|
||||
#endif // STARTMANAGERDBUSHANDLER_H
|
||||
|
Reference in New Issue
Block a user