Backup:AppManager module.
This commit is contained in:
parent
6021af6acd
commit
d4f57d78cd
|
@ -31,6 +31,37 @@ enum class UploadCommand
|
|||
UPGRADE_CPU = 0,
|
||||
END
|
||||
};
|
||||
enum class ChargeStatus
|
||||
{
|
||||
UNCHARGED = 0,
|
||||
CHARGING,
|
||||
END
|
||||
};
|
||||
enum class SdCardStatus
|
||||
{
|
||||
NORMAL = 0,
|
||||
UNFORMATTED = 1,
|
||||
NOT_INSERTED = 2,
|
||||
CARD_DAMAGED = 3,
|
||||
CARD_LOCKED = 10,
|
||||
SLOW_CARD = 11,
|
||||
FORMAT_REQUIRED = 12,
|
||||
FORMATTING = 13,
|
||||
END = 99
|
||||
};
|
||||
enum class LockVideoStatus
|
||||
{
|
||||
UNLOCK = 0,
|
||||
LOCK,
|
||||
END
|
||||
};
|
||||
enum class StorageType
|
||||
{
|
||||
EMMC = 0,
|
||||
SD_CARD_1,
|
||||
SD_CARD_2,
|
||||
END
|
||||
};
|
||||
typedef struct app_get_product_info
|
||||
{
|
||||
app_get_product_info() {}
|
||||
|
@ -59,18 +90,6 @@ typedef struct app_get_media_info
|
|||
std::string mTransport;
|
||||
int mPort;
|
||||
} AppGetMeidaInfo;
|
||||
enum class SdCardStatus
|
||||
{
|
||||
NORMAL = 0,
|
||||
UNFORMATTED = 1,
|
||||
NOT_INSERTED = 2,
|
||||
CARD_DAMAGED = 3,
|
||||
CARD_LOCKED = 10,
|
||||
SLOW_CARD = 11,
|
||||
FORMAT_REQUIRED = 12,
|
||||
FORMATTING = 13,
|
||||
END = 99
|
||||
};
|
||||
typedef struct app_get_sd_card_info
|
||||
{
|
||||
app_get_sd_card_info()
|
||||
|
@ -83,12 +102,6 @@ typedef struct app_get_sd_card_info
|
|||
int mFree;
|
||||
int mTotal;
|
||||
} AppGetSdCardInfo;
|
||||
enum class ChargeStatus
|
||||
{
|
||||
UNCHARGED = 0,
|
||||
CHARGING,
|
||||
END
|
||||
};
|
||||
typedef struct app_get_battery_info
|
||||
{
|
||||
app_get_battery_info()
|
||||
|
@ -99,6 +112,47 @@ typedef struct app_get_battery_info
|
|||
int mCapacity;
|
||||
ChargeStatus mChargeStatus;
|
||||
} AppGetBatteryInfo;
|
||||
typedef struct app_get_param_value
|
||||
{
|
||||
app_get_param_value()
|
||||
{
|
||||
mCapacity = 0;
|
||||
mChargeStatus = ChargeStatus::END;
|
||||
}
|
||||
int mCapacity;
|
||||
ChargeStatus mChargeStatus;
|
||||
} AppGetParamValue;
|
||||
typedef struct app_get_capability
|
||||
{
|
||||
app_get_capability()
|
||||
{
|
||||
mCapacity = 0;
|
||||
mChargeStatus = ChargeStatus::END;
|
||||
}
|
||||
int mCapacity;
|
||||
ChargeStatus mChargeStatus;
|
||||
} AppGetCapability;
|
||||
typedef struct app_get_storage_info
|
||||
{
|
||||
app_get_storage_info()
|
||||
{
|
||||
mIndex = -1;
|
||||
mType = StorageType::END;
|
||||
mFree = 0;
|
||||
mTotal = 0;
|
||||
}
|
||||
int mIndex;
|
||||
StorageType mType;
|
||||
std::string mName;
|
||||
int mFree;
|
||||
int mTotal;
|
||||
} AppGetStorageInfo;
|
||||
typedef struct app_set_param_value
|
||||
{
|
||||
app_set_param_value() { mValue = -1; }
|
||||
std::string mName;
|
||||
int mValue;
|
||||
} AppSetParamValue;
|
||||
typedef struct app_set_date_time
|
||||
{
|
||||
app_set_date_time(const unsigned int year, const unsigned int month, const unsigned int day,
|
||||
|
@ -133,8 +187,14 @@ public:
|
|||
virtual StatusCode GetMediaInfo(AppGetMeidaInfo ¶m);
|
||||
virtual StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m);
|
||||
virtual StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m);
|
||||
virtual StatusCode GetParamValue(AppGetParamValue ¶m);
|
||||
virtual StatusCode GetCapability(AppGetCapability ¶m);
|
||||
virtual StatusCode GetLockVideoStatus(LockVideoStatus ¶m);
|
||||
virtual StatusCode GetStorageInfo(std::vector<AppGetStorageInfo> ¶m);
|
||||
virtual StatusCode SetDateTime(AppSetDateTime ¶m);
|
||||
virtual StatusCode SetTimeZone(const unsigned int &zone);
|
||||
virtual StatusCode SetParamValue(AppSetParamValue ¶m);
|
||||
virtual StatusCode EnterRecorder(void);
|
||||
virtual StatusCode UploadFile(AppUploadFile ¶m);
|
||||
};
|
||||
typedef struct app_param
|
||||
|
|
|
@ -31,8 +31,29 @@ StatusCode VAppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetParamValue(AppGetParamValue ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetCapability(AppGetCapability ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetLockVideoStatus(LockVideoStatus ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetStorageInfo(std::vector<AppGetStorageInfo> ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::SetDateTime(AppSetDateTime ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::SetTimeZone(const unsigned int &zone) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::SetParamValue(AppSetParamValue ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::EnterRecorder(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::UploadFile(AppUploadFile ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
std::shared_ptr<IAppManager> &IAppManager::GetInstance(std::shared_ptr<IAppManager> *impl)
|
||||
{
|
||||
|
|
|
@ -26,8 +26,14 @@ const char *APP_GET_DEVICE_ATTR = "/app/getdeviceattr";
|
|||
const char *APP_GET_MEDIA_INFO = "/app/getmediainfo";
|
||||
const char *APP_GET_SD_CARD_INFO = "/app/getsdinfo";
|
||||
const char *APP_GET_BATTERY_INFO = "/app/getbatteryinfo";
|
||||
const char *APP_GET_PARAM_VALUE = "/app/getparamvalue";
|
||||
const char *APP_GET_CAPABILITY = "/app/capability";
|
||||
const char *APP_GET_LOCK_VIDEO_STATUS = "/app/getlockvideostatus";
|
||||
const char *APP_GET_STORAGE_INFO = "/app/getstorageinfo";
|
||||
const char *APP_SET_DATE_TIME = "/app/setsystime";
|
||||
const char *APP_SET_TIME_ZONE = "/app/settimezone";
|
||||
const char *APP_SET_PARAM_VALUE = "/app/setparamvalue";
|
||||
const char *APP_ENTER_RECORDER = "/app/enterrecorder";
|
||||
const char *APP_UPLOAD_FILE = "/upload";
|
||||
constexpr bool SET_REQUEST_RESPONSE = true;
|
||||
SixFrameHandle::SixFrameHandle()
|
||||
|
@ -38,8 +44,13 @@ SixFrameHandle::SixFrameHandle()
|
|||
mResquesHandleFunc[APP_GET_MEDIA_INFO] = std::bind(&SixFrameHandle::RequestGetMediaInfo, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_GET_SD_CARD_INFO] = std::bind(&SixFrameHandle::RequestGetSdCardInfo, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_GET_BATTERY_INFO] = std::bind(&SixFrameHandle::RequestGetBatteryInfo, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_GET_PARAM_VALUE] = std::bind(&SixFrameHandle::RequestGetParamValue, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_GET_CAPABILITY] = std::bind(&SixFrameHandle::RequestGetCapability, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_GET_LOCK_VIDEO_STATUS] =
|
||||
std::bind(&SixFrameHandle::RequestGetLockVideoStatus, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_SET_DATE_TIME] = std::bind(&SixFrameHandle::RequestSetDateTime, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_SET_TIME_ZONE] = std::bind(&SixFrameHandle::RequestSetTimeZone, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_ENTER_RECORDER] = std::bind(&SixFrameHandle::RequestEnterRecorder, this, _1, _2, _3);
|
||||
mResquesHandleFunc[APP_UPLOAD_FILE] = std::bind(&SixFrameHandle::RequestUpload, this, _1, _2, _3);
|
||||
// mResquesHandleFunc["favicon.ico"] = std::bind(&SixFrameHandle::DoNothing, this, _1, _2, _);
|
||||
}
|
||||
|
@ -98,6 +109,11 @@ void SixFrameHandle::DoNothing(const std::string &url, ResponseHandle responseHa
|
|||
// responseHandle("Unknown command.", context);
|
||||
char *resultStr = nullptr;
|
||||
cJSON *result = MakeResponseResult(ResposeResult::FAILED);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
|
@ -110,6 +126,11 @@ void SixFrameHandle::RequestGetProductInfo(const std::string &url, ResponseHandl
|
|||
AppGetProductInfo param;
|
||||
mAppMonitor->GetProductInfo(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetProductInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -132,6 +153,11 @@ void SixFrameHandle::RequestGetDeviceAttr(const std::string &url, ResponseHandle
|
|||
AppGetDeviceAttr param;
|
||||
mAppMonitor->GetDeviceAttr(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetDeviceAttr(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -159,6 +185,11 @@ void SixFrameHandle::RequestGetMediaInfo(const std::string &url, ResponseHandle
|
|||
AppGetMeidaInfo param;
|
||||
mAppMonitor->GetMediaInfo(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetMediaInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -181,6 +212,11 @@ void SixFrameHandle::RequestGetSdCardInfo(const std::string &url, ResponseHandle
|
|||
AppGetSdCardInfo param;
|
||||
mAppMonitor->GetSdCardInfo(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetSdCardInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -202,6 +238,11 @@ void SixFrameHandle::RequestGetBatteryInfo(const std::string &url, ResponseHandl
|
|||
AppGetBatteryInfo param;
|
||||
mAppMonitor->GetBatteryInfo(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetBatteryInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -215,6 +256,119 @@ void inline SixFrameHandle::ResponseGetBatteryInfo(cJSON *result, const AppGetBa
|
|||
cJSON_AddNumberToObject(info, "charge", static_cast<int>(param.mChargeStatus));
|
||||
cJSON_AddNumberToObject(info, "capacity", param.mCapacity);
|
||||
}
|
||||
void SixFrameHandle::RequestGetParamValue(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetParamValue.\n");
|
||||
char *resultStr = nullptr;
|
||||
AppGetParamValue param;
|
||||
mAppMonitor->GetParamValue(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetParamValue(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void inline SixFrameHandle::ResponseGetParamValue(cJSON *result, const AppGetParamValue ¶m)
|
||||
{
|
||||
cJSON *info = nullptr;
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
||||
cJSON_AddNumberToObject(info, "charge", static_cast<int>(param.mChargeStatus));
|
||||
cJSON_AddNumberToObject(info, "capacity", param.mCapacity);
|
||||
}
|
||||
void SixFrameHandle::RequestGetCapability(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetCapability.\n");
|
||||
char *resultStr = nullptr;
|
||||
AppGetCapability param;
|
||||
mAppMonitor->GetCapability(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetCapability(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void inline SixFrameHandle::ResponseGetCapability(cJSON *result, const AppGetCapability ¶m)
|
||||
{
|
||||
cJSON *info = nullptr;
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
||||
cJSON_AddNumberToObject(info, "charge", static_cast<int>(param.mChargeStatus));
|
||||
cJSON_AddNumberToObject(info, "capacity", param.mCapacity);
|
||||
}
|
||||
void SixFrameHandle::RequestGetLockVideoStatus(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetLockVideoStatus.\n");
|
||||
char *resultStr = nullptr;
|
||||
LockVideoStatus param;
|
||||
mAppMonitor->GetLockVideoStatus(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetLockVideoStatus(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void inline SixFrameHandle::ResponseGetLockVideoStatus(cJSON *result, const LockVideoStatus ¶m)
|
||||
{
|
||||
cJSON *info = nullptr;
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
||||
cJSON_AddNumberToObject(info, "status", static_cast<int>(param));
|
||||
}
|
||||
void SixFrameHandle::RequestGetStorageInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetStorageInfo.\n");
|
||||
char *resultStr = nullptr;
|
||||
std::vector<AppGetStorageInfo> param;
|
||||
mAppMonitor->GetStorageInfo(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetStorageInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void inline SixFrameHandle::ResponseGetStorageInfo(cJSON *result, const std::vector<AppGetStorageInfo> ¶m)
|
||||
{
|
||||
cJSON *info = cJSON_CreateArray();
|
||||
if (nullptr == info) {
|
||||
LogError("cJSON_CreateArray failed.\n");
|
||||
return;
|
||||
}
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info);
|
||||
for (const auto &storageInfo : param) {
|
||||
cJSON *storage = nullptr;
|
||||
storage = cJSON_CreateObject();
|
||||
if (nullptr != storage) {
|
||||
cJSON_AddItemToArray(info, storage);
|
||||
cJSON_AddNumberToObject(storage, "index", static_cast<int>(storageInfo.mIndex));
|
||||
cJSON_AddStringToObject(storage, "name", storageInfo.mName.c_str());
|
||||
cJSON_AddNumberToObject(storage, "type", static_cast<int>(storageInfo.mType));
|
||||
cJSON_AddNumberToObject(storage, "free", storageInfo.mFree);
|
||||
cJSON_AddNumberToObject(storage, "total", storageInfo.mTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
AppSetDateTime inline SixFrameHandle::RequestSetDateTimeParse(const std::string &url)
|
||||
{
|
||||
auto parseFunc = [](const std::string &key, const std::string &value, std::shared_ptr<VParseUrl> &parse) {
|
||||
|
@ -251,6 +405,11 @@ void SixFrameHandle::RequestSetDateTime(const std::string &url, ResponseHandle r
|
|||
AppSetDateTime param = RequestSetDateTimeParse(url);
|
||||
mAppMonitor->SetDateTime(param);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL, SET_REQUEST_RESPONSE);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
// ResponseGetBatteryInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
|
@ -277,17 +436,81 @@ int inline SixFrameHandle::RequestSetTimeZoneParse(const std::string &url)
|
|||
}
|
||||
void SixFrameHandle::RequestSetTimeZone(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetDeviceAttr.\n");
|
||||
LogInfo("RequestSetTimeZone.\n");
|
||||
char *resultStr = nullptr;
|
||||
int zone = RequestSetTimeZoneParse(url);
|
||||
mAppMonitor->SetTimeZone(zone);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL, SET_REQUEST_RESPONSE);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
// ResponseGetBatteryInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
AppSetParamValue inline SixFrameHandle::RequestSetParamValueParse(const std::string &url)
|
||||
{
|
||||
auto parseFunc = [](const std::string &key, const std::string &value, std::shared_ptr<VParseUrl> &parse) {
|
||||
std::shared_ptr<ParseUrl<AppSetParamValue>> parseyImpl =
|
||||
std::dynamic_pointer_cast<ParseUrl<AppSetParamValue>>(parse);
|
||||
if ("switchcam" == key) {
|
||||
parseyImpl->mData.mName = "switchcam";
|
||||
parseyImpl->mData.mValue = std::stoi(value);
|
||||
}
|
||||
if ("rec" == key) {
|
||||
parseyImpl->mData.mName = "rec";
|
||||
parseyImpl->mData.mValue = std::stoi(value);
|
||||
}
|
||||
if ("mic" == key) {
|
||||
parseyImpl->mData.mName = "mic";
|
||||
parseyImpl->mData.mValue = std::stoi(value);
|
||||
}
|
||||
};
|
||||
AppSetParamValue value;
|
||||
std::shared_ptr<VParseUrl> parse = std::make_shared<ParseUrl<AppSetParamValue>>();
|
||||
ExtractParamsFromUrl(url, parseFunc, parse);
|
||||
std::shared_ptr<ParseUrl<AppSetParamValue>> parseyImpl =
|
||||
std::dynamic_pointer_cast<ParseUrl<AppSetParamValue>>(parse);
|
||||
return parseyImpl->mData;
|
||||
}
|
||||
void SixFrameHandle::RequestSetParamValue(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestSetParamValue.\n");
|
||||
char *resultStr = nullptr;
|
||||
AppSetParamValue value = RequestSetParamValueParse(url);
|
||||
mAppMonitor->SetParamValue(value);
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL, SET_REQUEST_RESPONSE);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
// ResponseGetBatteryInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void SixFrameHandle::RequestEnterRecorder(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestEnterRecorder.\n");
|
||||
char *resultStr = nullptr;
|
||||
mAppMonitor->EnterRecorder();
|
||||
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void SixFrameHandle::RequestUpload(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestUpload.\n");
|
||||
|
@ -295,6 +518,11 @@ void SixFrameHandle::RequestUpload(const std::string &url, ResponseHandle respon
|
|||
AppUploadFile info("path", UploadCommand::UPGRADE_CPU);
|
||||
mAppMonitor->UploadFile(info);
|
||||
cJSON *result = MakeResponseResult(info.mResult);
|
||||
if (nullptr == result) {
|
||||
LogError("MakeResponseResult failed.\n");
|
||||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
|
@ -304,9 +532,13 @@ cJSON *SixFrameHandle::MakeResponseResult(const ResposeResult result, const bool
|
|||
{
|
||||
const char *RESPONSE_RESULT = "result";
|
||||
cJSON *resultCJSON = cJSON_CreateObject();
|
||||
if (nullptr == resultCJSON) {
|
||||
LogError("cJSON_CreateObject failed.\n");
|
||||
goto END;
|
||||
}
|
||||
cJSON_AddNumberToObject(resultCJSON, RESPONSE_RESULT, static_cast<int>(result));
|
||||
if (false == requestSet) {
|
||||
return resultCJSON;
|
||||
goto END;
|
||||
}
|
||||
if (ResposeResult::SUCCESSFUL == result) {
|
||||
cJSON_AddStringToObject(resultCJSON, CJSON_INFO_STRING, "set success.");
|
||||
|
@ -314,6 +546,7 @@ cJSON *SixFrameHandle::MakeResponseResult(const ResposeResult result, const bool
|
|||
else {
|
||||
cJSON_AddStringToObject(resultCJSON, CJSON_INFO_STRING, "set failed."); // TODO: what the failed string is?
|
||||
}
|
||||
END:
|
||||
return resultCJSON;
|
||||
}
|
||||
void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
VParseUrl() = default;
|
||||
virtual ~VParseUrl() = default;
|
||||
};
|
||||
using ParseUrlResultFunc = void(const std::string &, const std::string &, std::shared_ptr<VParseUrl> &);
|
||||
template <typename T>
|
||||
class ParseUrl : public VParseUrl
|
||||
{
|
||||
|
@ -41,7 +42,6 @@ public:
|
|||
public:
|
||||
T mData;
|
||||
};
|
||||
using ParseUrlResultFunc = void(const std::string &, const std::string &, std::shared_ptr<VParseUrl> &);
|
||||
class SixFrameHandle : public IAppProtocolHandle
|
||||
{
|
||||
public:
|
||||
|
@ -68,10 +68,21 @@ private:
|
|||
void ResponseGetSdCardInfo(cJSON *result, const AppGetSdCardInfo ¶m);
|
||||
void RequestGetBatteryInfo(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetBatteryInfo(cJSON *result, const AppGetBatteryInfo ¶m);
|
||||
void RequestGetParamValue(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetParamValue(cJSON *result, const AppGetParamValue ¶m);
|
||||
void RequestGetCapability(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetCapability(cJSON *result, const AppGetCapability ¶m);
|
||||
void RequestGetLockVideoStatus(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetLockVideoStatus(cJSON *result, const LockVideoStatus ¶m);
|
||||
void RequestGetStorageInfo(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetStorageInfo(cJSON *result, const std::vector<AppGetStorageInfo> ¶m);
|
||||
AppSetDateTime RequestSetDateTimeParse(const std::string &url);
|
||||
void RequestSetDateTime(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
int RequestSetTimeZoneParse(const std::string &url);
|
||||
void RequestSetTimeZone(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
AppSetParamValue RequestSetParamValueParse(const std::string &url);
|
||||
void RequestSetParamValue(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void RequestEnterRecorder(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void RequestUpload(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user