void airport::Url::normalize_url (const char *url) { std::string turl (url); normalize_url (turl); }
void airport::Url::normalize_url_baseurl (const char *url, const char *baseurl) { std::string turl (url); std::string tbaseurl (baseurl); normalize_url_baseurl (turl, tbaseurl); }
void FtdApp::AddDownload(Json::Value& req, UnixClientSocket* sock) { struct stat st; // Validate input if(!(req.isMember("user") && req["user"].isString())) { syslog(LOG_ERR,"AddDownload: missing or invalid user"); this->SendFail(sock); return; } if(!(req.isMember("url") && req["url"].isString())) { syslog(LOG_ERR,"AddDownload: missing or invalid url"); this->SendFail(sock); return; } if(!(req.isMember("uuid") && req["uuid"].isString())) { syslog(LOG_ERR,"AddDownload: missing or invalid uuid"); this->SendFail(sock); return; } if(!(req.isMember("policy") && req["policy"].isIntegral())) { syslog(LOG_ERR,"AddDownload: missing or invalid policy"); this->SendFail(sock); return; } string user=req["user"].asString(); string uuid=req["uuid"].asString(); string url=req["url"].asString(); unsigned int policy= req["policy"].asUInt(); // Check for duplicate downloads doubleclicks etc if (this->FindByUUID(uuid,user)) { this->SendFail(sock); syslog(LOG_NOTICE,"Duplicate uuid"); return; } // Avoid duplicate concurrent downloads if(this->FindByURL(url)) { this->SendFail(sock); syslog(LOG_NOTICE,"Duplicate URL"); return; } string filename=url; filename=filename.substr(filename.rfind("/")+1); string path=this->GetDownloadDir(user); if (!stat( (path+filename).c_str(),&st)) { int i=0; stringstream oss; do { i++; oss.str(""); oss<<filename<<"("<<i<<")"; } while(!stat((path+oss.str()).c_str(),&st)); filename=oss.str(); } URL turl(url); Downloader* down=this->FindDownloader(turl); if(down!=NULL) { down->SetUrl(url); down->SetDestinationPath(path); down->SetDownloadName(filename); down->SetUUID(uuid); down->SetGroup(Group::GroupToGID("users")); down->SetUser(User::UserToUID(user)); down->SetPolicy(policy); if(policy && DLP_AUTOREMOVE) { down->SignalDone.connect(sigc::bind(sigc::mem_fun(this,&FtdApp::dlDone),down)); down->SignalFailed.connect(sigc::hide<0>(sigc::bind(sigc::mem_fun(this,&FtdApp::dlDone),down))); } this->RegisterDownload(user,down); this->SendOk(sock); down->StartDownload(); syslog(LOG_DEBUG, "User %s added download",user.c_str()); } else { this->SendFail(sock); syslog(LOG_ERR, "Failed to find suitable downloader"); } }
std::string airport::Uriparser::normalize(const char *url) { std::string turl(url); return normalize(turl); }