|
@@ -493,7 +493,11 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
ErrorCodeEnum tmpResult(Error_Succeed);
|
|
|
CSimpleStringA tmpMsg(true);
|
|
|
|
|
|
+ Dbg("ctx-req context: %d, %d, %d", ctx->Req.type, ctx->Req.reserved1, ctx->Req.reserved2);
|
|
|
+
|
|
|
bool sogouInstalled = false;
|
|
|
+ const bool doTryRestart = (ctx->Req.reserved1 != 1);
|
|
|
+
|
|
|
if (ctx->Req.type == 1) {//安装搜狗输入法
|
|
|
bool zipFind = false;
|
|
|
time_t newestWrite = 0;
|
|
@@ -511,32 +515,29 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
{
|
|
|
DIR* dp;
|
|
|
struct dirent* dirp;
|
|
|
-
|
|
|
if ((dp = opendir(strDownloadDirPath.GetData())) != NULL)
|
|
|
{
|
|
|
while ((dirp = readdir(dp)) != NULL)
|
|
|
{
|
|
|
CSimpleStringA tmpName(dirp->d_name);
|
|
|
- struct stat buf;
|
|
|
- int ret = 0;
|
|
|
- memset(&buf, 0x00, sizeof(buf));
|
|
|
- ret = stat(CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strDownloadDirPath.GetData(), dirp->d_name).GetData(), &buf);
|
|
|
-
|
|
|
- if ((tmpName.IsStartWith("sogou", true) || tmpName.IsStartWith("uos-sogou", true))
|
|
|
- && tmpName.IsEndWith(".zip", true) && buf.st_mtim.tv_sec > newestWrite)
|
|
|
- {
|
|
|
- if (ret != 0)
|
|
|
- {
|
|
|
- Dbg("获取文件[%s]状态信息出错。\n", tmpName.GetData());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ if ((tmpName.IsStartWith("sogou", true) || tmpName.IsStartWith("uos-sogou", true))
|
|
|
+ && tmpName.IsEndWith(".zip", true)) {
|
|
|
+
|
|
|
+ struct stat buf;
|
|
|
+ memset(&buf, 0x00, sizeof(buf));
|
|
|
+ const int ret = stat(CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strDownloadDirPath.GetData(), dirp->d_name).GetData(), &buf);
|
|
|
+ if (ret != 0) {
|
|
|
+ Dbg("获取文件[%s]状态信息出错。", tmpName.GetData());
|
|
|
+ } else if(buf.st_mtim.tv_sec > newestWrite){
|
|
|
newestWrite = buf.st_mtim.tv_sec;
|
|
|
newSogouPath = CSimpleStringA(tmpName.GetData());
|
|
|
zipFind = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ closedir(dp);
|
|
|
+
|
|
|
if(!zipFind)
|
|
|
{
|
|
|
tmpResult = Error_NotExist;
|
|
@@ -550,7 +551,7 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- CSimpleStringA strInstallPkgPath;
|
|
|
+ CSimpleStringA strInstallPkgPath(true);
|
|
|
if (zipFind)
|
|
|
{
|
|
|
if (UnzipPack(newSogouPath.GetData()) != Error_Succeed)
|
|
@@ -568,8 +569,8 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
else
|
|
|
{
|
|
|
tmpResult = GetSogouPkgDirPath(strInstallPkgPath);
|
|
|
- if (tmpResult != 0) {
|
|
|
- tmpMsg = tmpMsg + CSimpleStringA::Format(" 指定位置[%s]找不到输入法安装包", strInstallPkgPath.GetData());
|
|
|
+ if (tmpResult != Error_Succeed) {
|
|
|
+ tmpMsg =CSimpleStringA::Format(" 指定位置 [Ad] 找不到输入法安装包");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -581,8 +582,8 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
if (tmpResult != Error_Succeed) {
|
|
|
tmpMsg = CSimpleStringA::Format("%s 修改文件夹权限失败", strInstallPkgPath.GetData());
|
|
|
tmpResult = Error_NotExist;
|
|
|
- }
|
|
|
- else {
|
|
|
+
|
|
|
+ } else {
|
|
|
CSimpleStringA strRunIniFilePath = strInstallPkgPath + SPLIT_SLASH_STR + "Run.ini";
|
|
|
if (ExistsFileA(strRunIniFilePath)) {
|
|
|
char* p = inifile_read_str(strRunIniFilePath, "Action", "ToRun", "");
|
|
@@ -713,7 +714,9 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
ctx->Ans.reserverd1 = info.program.strVersion;
|
|
|
ctx->Ans.reserverd2 = info.state.GetInstallTime().ToTimeString();
|
|
|
|
|
|
- tmpMsg = tmpMsg + CSimpleStringA::Format(" 从[%s]安装搜狗输入法成功,设备即将重启。", strInstallPkgPath.GetData());
|
|
|
+ if (doTryRestart) {
|
|
|
+ tmpMsg = CSimpleStringA::Format(" 从[%s]安装搜狗输入法成功,设备即将重启。", strInstallPkgPath.GetData());
|
|
|
+ }
|
|
|
sogouInstalled = true;
|
|
|
}
|
|
|
}
|
|
@@ -791,7 +794,7 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
ctx->Ans.msg = tmpMsg;
|
|
|
ctx->Answer(result);
|
|
|
|
|
|
- if (sogouInstalled)
|
|
|
+ if (sogouInstalled && doTryRestart)
|
|
|
{
|
|
|
HealthManagerService_ClientBase* m_pRWClient = new HealthManagerService_ClientBase(this);
|
|
|
ErrorCodeEnum eErr = m_pRWClient->Connect();
|
|
@@ -810,13 +813,13 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
|
|
|
eErr = m_pRWClient->ControlTerminalLife(detReq, detAns, 3000);
|
|
|
if (eErr == Error_Succeed)
|
|
|
{
|
|
|
- // 系统重启事件
|
|
|
- LogWarn(Severity_Middle, Error_Succeed, Event_Req_OS_Restart, "搜狗安装成功, 设备即将重启。");
|
|
|
+ LogWarn(Severity_Middle, Error_Succeed, 0, "搜狗安装成功, 设备即将重启。");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, 0, "调用健康实体重启设备失败!");
|
|
|
}
|
|
|
+ m_pRWClient->GetFunction()->CloseSession();
|
|
|
}
|
|
|
}
|
|
|
|