void CalaosCameraView::play() { if (ecurl) ecore_con_url_free(ecurl); ecurl = ecore_con_url_new(cameraUrl.c_str()); if (!ecurl) { cErrorDom("camera") << "Failed to create ecore_con_url!"; return; } ecore_con_url_data_set(ecurl, this); ecore_con_url_ssl_verify_peer_set(ecurl, false); single_frame = false; buffer.clear(); formatDetected = false; format_error = false; nextContentLength = -1; if (!ecore_con_url_get(ecurl)) { cErrorDom("camera") << "Could not realize request!"; ecore_con_url_free(ecurl); ecurl = nullptr; } cDebugDom("camera") << "Request started to " << cameraUrl; }
bool FileDownloader::Start() { Utils::logger("downloader") << Priority::DEBUG << "FileDownloader: Start download (" << url << ")" << log4cpp::eol; if (url_con) { Utils::logger("downloader") << Priority::WARN << "A download is already in progress..." << log4cpp::eol; return false; } url_con = ecore_con_url_new(url.c_str()); if (!url_con) { string err = "Failed to create Ecore_Con_Url"; IPC::Instance().SendEvent("downloader::" + Utils::to_string(this), "failed", IPCData(new string(err), new DeletorT<string *>()), true); cb_signal.emit("failed", &err); cb_signal_user.emit("failed", &err, user_data); Utils::logger("downloader") << Priority::ERROR << "Download failed: " << err << log4cpp::eol; return false; } if (dest.empty()) { //Create a temporary file for download int cpt = 0; //Get a temporary filename do { tmpFile = "/tmp/calaos" + Utils::to_string(getpid()) + "_download_tmp_"; tmpFile += Utils::to_string(cpt); cpt++; } while (ecore_file_exists(tmpFile.c_str())); dl_file = fopen(tmpFile.c_str(), "wb"); } else { dl_file = fopen(dest.c_str(), "wb"); } if (!dl_file) { string err = "Failed to open file"; IPC::Instance().SendEvent("downloader::" + Utils::to_string(this), "failed", IPCData(new string(err), new DeletorT<string *>()), true); cb_signal.emit("failed", &err); cb_signal_user.emit("failed", &err, user_data); Utils::logger("downloader") << Priority::ERROR << "Download failed: " << err << log4cpp::eol; ecore_con_url_free(url_con); url_con = NULL; return false; } ecore_con_url_fd_set(url_con, fileno(dl_file)); ecore_con_url_data_set(url_con, this); ecore_con_url_ssl_verify_peer_set(url_con, false); bool ret = false; if (postData.empty()) { ret = ecore_con_url_get(url_con); } else { ret = ecore_con_url_post(url_con, postData.c_str(), postData.length(), postContentType.c_str()); } if (!ret) { string err = "Failed to call GET/POST"; IPC::Instance().SendEvent("downloader::" + Utils::to_string(this), "failed", IPCData(new string(err), new DeletorT<string *>()), true); cb_signal.emit("failed", &err); cb_signal_user.emit("failed", &err, user_data); Utils::logger("downloader") << Priority::ERROR << "Download failed: " << err << log4cpp::eol; ecore_con_url_free(url_con); url_con = NULL; fclose(dl_file); if (dest.empty()) ecore_file_unlink(tmpFile.c_str()); return false; } return true; }