#include "Sources.hpp" #include "Commands.hpp" #include #include #include using namespace std; using namespace net::lliurex::apt; using namespace net::lliurex::apt::command; Match::Match(Sources * sources,FindLineStatus status) { this->sources=sources; this->status=status; } void net::lliurex::apt::command::Init() { Glib::init(); Gio::init(); } vector net::lliurex::apt::command::LoadConf() { vector conf; Glib::RefPtr file = Gio::File::create_for_path(CONF_PATH); Glib::RefPtr dir = file->enumerate_children("*"); Glib::RefPtr info = dir->next_file(); while(info) { Sources src(CONF_PATH+info->get_name()); conf.push_back(src); info=dir->next_file(); } return conf; } void net::lliurex::apt::command::Show() { Sources src(SOURCES_LIST); src.Print(); } void net::lliurex::apt::command::List(vector & conf) { for(int n=0;n net::lliurex::apt::command::Check(Sources & src,vector & conf) { vector status; for(int n=0;n0 && f==cf.lines.size()) { status.push_back(Match(&conf[n],FindLineStatus::Found)); } else { if(f>0 || p>0) { status.push_back(Match(&conf[n],FindLineStatus::Partial)); } else { status.push_back(Match(&conf[n],FindLineStatus::NotFound)); } } } return status; } Sources net::lliurex::apt::command::Set(Sources & isrc,vector & conf,vector & targets,bool reset) { //there can only be one! Sources * mandatory=nullptr; vector optional; /* check if exists, test for valid combinations and fill target Sources */ for(string target : targets) { //cout<<"* ["< refactor; for(int n=0;nuri<<" "<dist<