feat: 修改自启动应用启动方式

*修改自启动应用启动方式, 采用loader进程先校验应用信息,再拉起应用的方式
*修复launcher模块部分接口导出失败的问题
*增加launcher、dock、loader模块代码注释

Log: 修改自启动应用启动方式
Task: https://pms.uniontech.com/task-view-131611.html
Influence: 应用启动方式不同
Change-Id: Ie88027602d1395c6bbad69e610f3639ecc7dfbc1
This commit is contained in:
weizhixiang
2022-05-19 13:13:55 +08:00
parent 68f52fe831
commit 5997b3a2a1
53 changed files with 1618 additions and 693 deletions

View File

@ -48,7 +48,7 @@ std::string BaseDir::userDataDir()
if (!xdgDataHomePtr)
return defaultDir;
if (!DFile::isAbs(xdgDataHomePtr))
if (!DFile::isDir(xdgDataHomePtr))
return defaultDir;
return std::string(xdgDataHomePtr) + "/";
@ -80,7 +80,7 @@ std::string BaseDir::userConfigDir()
return defaultDir;
std::string xdgConfigHome(xdgConfigHomePtr);
if (!DFile::isAbs(xdgConfigHome))
if (!DFile::isDir(xdgConfigHome))
return defaultDir;
return xdgConfigHome + "/";
@ -112,7 +112,7 @@ std::string BaseDir::userCacheDir()
return defaultDir;
std::string xdgCacheHome(xdgCacheHomePtr);
if (!DFile::isAbs(xdgCacheHome))
if (!DFile::isDir(xdgCacheHome))
return defaultDir;
return xdgCacheHome + "/";
@ -158,7 +158,7 @@ std::string BaseDir::userAutoStartDir()
void BaseDir::filterNotAbs(std::vector<std::string> &dirs)
{
for (auto iter = dirs.begin(); iter != dirs.end();) { // erase element in vector
if (!DFile::isAbs(*iter))
if (!DFile::isDir(*iter))
iter = dirs.erase(iter);
else
iter++;

View File

@ -43,7 +43,7 @@ DesktopInfo::DesktopInfo(const std::string &_fileName)
m_fileName = fileNameWithSuffix;
if (!DFile::isAbs(m_fileName)) {
if (DFile::dir(m_fileName).empty()) {
// fileName是文件名增加目录
bool isExisted = false;
for (const auto &dir : BaseDir::appDirs()) {

View File

@ -21,7 +21,9 @@
#include "dfile.h"
#include "macro.h"
#include "dstring.h"
#include<sys/stat.h>
#include <unistd.h>
#include <cstring>
@ -30,14 +32,39 @@ DFile::DFile()
}
bool DFile::isAbs(std::string file)
// 符号连接
bool DFile::isLink(std::string file)
{
char resolved_path[MAX_FILEPATH_LEN];
if (realpath(file.c_str(), resolved_path)) {
std::string filePath(resolved_path);
if (filePath == file)
return true;
}
if (file.empty())
return false;
struct stat fileStat;
if (!stat(file.c_str(), &fileStat))
return S_ISLNK(fileStat.st_mode);
return false;
}
bool DFile::isRegularFile(std::string file)
{
if (file.empty())
return false;
struct stat fileStat;
if (!stat(file.c_str(), &fileStat))
return S_ISREG(fileStat.st_mode);
return true;
}
bool DFile::isDir(std::string dir)
{
if (dir.empty())
return false;
struct stat fileStat;
if (!stat(dir.c_str(), &fileStat))
return S_ISDIR(fileStat.st_mode);
return false;
}
@ -47,13 +74,15 @@ bool DFile::isExisted(std::string file)
return !access(file.c_str(), F_OK);
}
std::string DFile::dir(std::string file)
std::string DFile::dir(std::string path)
{
std::string ret;
if (isAbs(file)) {
size_t pos = file.find_last_of("/");
if (isDir(path)) {
ret = path;
} else {
size_t pos = path.find_last_of("/");
if (pos != std::string::npos) {
ret.assign(file, 0, pos + 1); // 包含结尾斜杠/
ret.assign(path, 0, pos + 1); // 包含结尾斜杠/
}
}

View File

@ -28,9 +28,11 @@ class DFile
{
public:
explicit DFile();
static bool isAbs(std::string file);
static bool isLink(std::string file);
static bool isRegularFile(std::string file);
static bool isDir(std::string dir);
static bool isExisted(std::string file);
static std::string dir(std::string file);
static std::string dir(std::string path);
static std::string base(std::string file);
};

View File

@ -25,7 +25,11 @@
#define _likely_(x) (__builtin_expect(!!(x), 1))
#define _unlikely_(x) (__builtin_expect(!!(x), 0))
#define MAX(x, y) (x) > (y) ? (x) : (y)
#define MIN(x, y) (x) < (y) ? (x) : (y)
#define MAX_FILEPATH_LEN 256
#define MAX_LINE_LEN 256
#endif // MACRO_H