int ServerPic::Install(int argc, char *argv[]) { string configUrl("http://192.168.89.1/Test/config.json"); // init error ErrorInfo::Init(); /* // check params count if (argc < 2) return INVALID_ARGV_NUMBERS; // load argv string configUrl(argv[1]); */ // init libcurl curl_global_init(CURL_GLOBAL_ALL); // init system config HttpRequest *configReq = new HttpRequestGet(configUrl); configReq->contentType = HttpContentType::Json; configReq->Connect(); if (configReq->text.empty()) return EMPTY_CONFIG_FILE; AppSetting *setting = AppSetting::Instance(); JsonObject *jsonObj = new JsonObject(); jsonObj->LoadFromText(configReq->text); setting->Load(jsonObj); // Release install memory safe_del(jsonObj); safe_del(configReq); return NO_ERROR; }
CThread::~CThread() { if (!IsOver()) Kill(); safe_del(_t); }
void CreateProc::_ResizeFiles() { AppSetting *setting = AppSetting::Instance(); JsonObject *projData = new JsonObject(); projData->Add("pid",_pid); JsonArray *pages = new JsonArray(); projData->AddObject("pages", pages); for (auto fileItor = _filesMapping->begin(); fileItor != _filesMapping->end(); ++fileItor) { JsonObject *singleFile = new JsonObject(); string srcFilename = FileSys::GetFilename(fileItor->first); string saveFilename = FileSys::GetFilename(fileItor->second); string fileExtension = FileSys::GetFileExtension(fileItor->first); singleFile->Add("filename", srcFilename); singleFile->Add("imagedir", fileItor->first); for (auto sizeItor = setting->pic_size->begin(); sizeItor != setting->pic_size->end(); ++sizeItor) { string optDir = FileSys::FormatDir(setting->file_save_dir + _zipRandName + "/" + sizeItor->first); FileSys::CreateDirectory(optDir); // Resize Picture, but need to rename saveFilename = Assist::GenerateRandomFilename(saveFilename) + fileExtension; OpencvEx::ResizePictureFile(fileItor->second, optDir + saveFilename, sizeItor->second->x, sizeItor->second->y); singleFile->Add("image" + sizeItor->first, optDir + saveFilename); } pages->AddObject(singleFile); safe_del(singleFile); } // push to server _PushJsonToServer(projData->ToString()); safe_del(pages); safe_del(projData); }
void CreateProc::_PushJsonToServer(string value) { AppSetting *setting = AppSetting::Instance(); // push to server HttpRequestPost *postJson = new HttpRequestPost(setting->push_json_url); postJson->contentType = HttpContentType::Json; postJson->AddParam(setting->push_json_url_key, value); postJson->Connect(); safe_del(postJson); }
void CreateProc::_RenameFiles() { list<string> *files = FileSys::GetAllFilename(_leveloffDir); for (list<string>::iterator itor = files->begin(); itor != files->end(); ++itor) { string oldName = _leveloffDir + (*itor); string newName = _leveloffDir + Assist::GenerateRandomFilename(*itor) + FileSys::GetFileExtension(*itor); rename(oldName.c_str(), newName.c_str()); _filesMapping->insert(make_pair(oldName, newName)); } files->clear(); safe_del(files); }
RtspClientSession::~RtspClientSession(){ safe_del(m_mediaSession); }
CreateProc::~CreateProc() { safe_del(_filesMapping); }
int ServerPic::Uninstall() { curl_global_cleanup(); safe_del(AppSetting::Instance()); }
mediaCtrl:: ~mediaCtrl(){ printf("~mediaCtrl\n"); safe_del(m_mediaSource); }