Fixed:app protocol bug.
This commit is contained in:
parent
a476c4fc82
commit
59f6b7ec8b
|
@ -125,6 +125,7 @@ StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::v
|
|||
}
|
||||
IFilesManager::GetInstance()->GetFiles(types, info);
|
||||
}
|
||||
const std::string webServerDocumentRoot = IAppManager::GetInstance()->GetFilesSavingRootPath();
|
||||
LogInfo("GetStorageFileList: file size = %d, event = %s.\n",
|
||||
info.size(),
|
||||
IAppManager::GetInstance()->StorageFileEventToString(fileInfo.mEvent));
|
||||
|
@ -132,7 +133,7 @@ StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::v
|
|||
AppGetFileList file;
|
||||
file.mCreateTime_s = oneFileInfo.mCreateTime_s;
|
||||
file.mDuration = oneFileInfo.mFileDuration;
|
||||
file.mName = oneFileInfo.mFileName;
|
||||
file.mName = RemovePrefix(oneFileInfo.mFileName, webServerDocumentRoot);
|
||||
file.mSize = oneFileInfo.mFileSize;
|
||||
file.mType = StorageFileType::VIDEO;
|
||||
param.push_back(file);
|
||||
|
@ -184,4 +185,12 @@ SdCardStatus AppMonitor::SdCardStatusConvert(const StorageEvent &event)
|
|||
default:
|
||||
return SdCardStatus::END;
|
||||
}
|
||||
}
|
||||
std::string AppMonitor::RemovePrefix(const std::string &originalStr, const std::string &prefix)
|
||||
{
|
||||
if (originalStr.compare(0, prefix.length(), prefix) == 0) {
|
||||
return originalStr.substr(prefix.length());
|
||||
}
|
||||
LogWarning("Something wrong happened, prefix is %s.\n", prefix.c_str());
|
||||
return originalStr;
|
||||
}
|
|
@ -41,6 +41,7 @@ public:
|
|||
|
||||
private:
|
||||
SdCardStatus SdCardStatusConvert(const StorageEvent &event);
|
||||
std::string RemovePrefix(const std::string &originalStr, const std::string &prefix);
|
||||
|
||||
private:
|
||||
SwitchStatus mMicStatus; // TODO: improve delete.
|
||||
|
|
|
@ -48,7 +48,7 @@ set(LOG_SUPPORT "true")
|
|||
# ------------ build log end ------------ #
|
||||
|
||||
# ------------ build GoAhead ------------ #
|
||||
set(GOAHEAD_DOCUMENTS_PATH "web")
|
||||
set(GOAHEAD_DOCUMENTS_PATH "./sdcard") # web服务器配置文件的根目录,可以访问文件,例如:mp4,jpg,html等
|
||||
set(GOAHEAD_UPLOAD_TMP_PATH "./goahead")
|
||||
set(GOAHEAD_UPLOAD_PATH "${GOAHEAD_UPLOAD_TMP_PATH}")
|
||||
set(GOAHEAD_LIMIT_POST "335544320") # If not defined means using default setting. See goahead-linux-static-fancy.mk
|
||||
|
|
|
@ -344,5 +344,11 @@ public:
|
|||
virtual const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor);
|
||||
virtual StatusCode SetSdCardStatus(const SdCardStatus &status);
|
||||
virtual const char *StorageFileEventToString(const StorageFileEvent &event);
|
||||
/**
|
||||
* @brief Get the document root directory configured by the web server of the APP management module. The mobile APP
|
||||
* can access the files in the directory through the network.
|
||||
* @return std::string Path of the document root directory.
|
||||
*/
|
||||
virtual std::string GetFilesSavingRootPath(void);
|
||||
};
|
||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||
#include "TcpModule.h"
|
||||
#include "WebServer.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
AppManager::AppManager() : mTcpServer(nullptr), mInitRuning(false)
|
||||
{
|
||||
|
@ -97,6 +98,11 @@ const char *AppManager::StorageFileEventToString(const StorageFileEvent &event)
|
|||
break;
|
||||
}
|
||||
}
|
||||
std::string AppManager::GetFilesSavingRootPath(void)
|
||||
{
|
||||
std::string rootPath = GetWebServerDocumentRoot();
|
||||
return rootPath;
|
||||
}
|
||||
void AppManager::AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle,
|
||||
void *context)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
|
||||
StatusCode SetSdCardStatus(const SdCardStatus &status) override;
|
||||
const char *StorageFileEventToString(const StorageFileEvent &event) override;
|
||||
std::string GetFilesSavingRootPath(void) override;
|
||||
void AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle, void *context);
|
||||
void AppRequestHandleTcp(const char *data, const unsigned int dataLength, ResponseHandle responseHandle,
|
||||
void *context);
|
||||
|
|
|
@ -249,4 +249,10 @@ StatusCode IAppManager::SetSdCardStatus(const SdCardStatus &status)
|
|||
const char *IAppManager::StorageFileEventToString(const StorageFileEvent &event)
|
||||
{
|
||||
return "STATUS_CODE_VIRTUAL_FUNCTION";
|
||||
}
|
||||
std::string IAppManager::GetFilesSavingRootPath(void)
|
||||
{
|
||||
LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n");
|
||||
const std::string path = "unknwon";
|
||||
return path;
|
||||
}
|
|
@ -29,6 +29,12 @@ typedef struct web_server_param
|
|||
StatusCode WebServerInit(const WebServerParam webParam);
|
||||
StatusCode WebServerExit(void);
|
||||
StatusCode WebServerUnInit(void);
|
||||
/**
|
||||
* @brief The document root directory configured by the web server. Files under the directory can be accessed over the
|
||||
* network.
|
||||
* @return const char*
|
||||
*/
|
||||
const char *GetWebServerDocumentRoot(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -237,4 +237,8 @@ StatusCode WebServerUnInit(void)
|
|||
{
|
||||
LogInfo("WebServerUnInit.\n");
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
const char *GetWebServerDocumentRoot(void)
|
||||
{
|
||||
return GOAHEAD_DOCUMENTS_PATH;
|
||||
}
|
Loading…
Reference in New Issue
Block a user