int app_config_check(struct app_params *app) { check_mempools(app); check_links(app); check_rxqs(app); check_txqs(app); check_swqs(app); check_tms(app); check_sources(app); check_sinks(app); check_msgqs(app); check_pipelines(app); return 0; }
void save_file(QString text , int pageid , int revid , QString page_title) { if(!check_links(text)) // check the html to see if there are any dependencies that needs to be downloaded { QDir dir(data_path); // set path to application data location dir.cd("WTL_appdata"); // change to the application data location QString Folder_name = dir.absoluteFilePath(QString::number(pageid)); // Folder_name = Generic location of application data ( varies from OS to OS ) + filename(pageid) QString fname = QString::number(pageid); if(QDir(Folder_name).exists()) // checks if the file already exists or not { qDebug() << " already exist "; } else{ // save the file QDir dir(data_path); dir.cd("WTL_appdata"); dir.mkdir(Folder_name); QString filename = dir.absoluteFilePath(Folder_name+".html"); QFile file(filename); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\">" +text; text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"wikitolearnskin.css\">" + text; text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"bootstrap.css\">" + text; out << text; // optional, as QFile destructor will already do it: file.close(); // move html file to their respective folder QString temp_name = dir.absoluteFilePath(filename); QString new_name = temp_name.replace(".html",""); QString css_path = new_name; new_name = new_name + "/" + fname +".html"; file.rename(filename,new_name); css_path = css_path + "/main.css"; file.copy(dir.absoluteFilePath("main.css"),css_path); bool success = add_in_db(pageid,revid,page_title); if(success == true) { qDebug() <<"entry added to DB successfully "; } else { qDebug() <<" failed to add in DB "; } } } else { dbmanager d; // created object of dbmanager to access private variables and functions of dbmanager.h QDir dir(data_path); dir.cd("WTL_appdata"); // imageDownloadPath is going to be the same path as of it's html file d.imageDownloadPath = dir.absoluteFilePath(QString::number(pageid)); imgpath = d.imageDownloadPath; if(QDir(d.imageDownloadPath).exists()) // checks if the files are already saved { qDebug() << " already exist "; } else{ dir.mkdir(d.imageDownloadPath); QString filename = d.imageDownloadPath+".html"; QFile file(filename); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out << text; // optional, as QFile destructor will already do it: file.close(); // add entries to the database ( i.e. in Pages table ) bool success = add_in_db(pageid,revid,page_title); if(success == true) { qDebug() <<"entry added to DB successfully "; } else { qDebug() <<" failed to add in DB "; } // call save_images function save the images // filename is html filename which will be read to extract URLs from it // filename has the same name as of pageid success = save_images(filename,pageid); if(success == true) { qDebug() << "images downloaded successfully "; } else { qDebug() << "error in downloading images"; } } } }