diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 1c8df9d3e..de492fb3a 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -5,12 +5,23 @@ #include // C #include +#include #include + // C++ #include #include #include // system +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include // tuxbox @@ -194,6 +205,9 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]= {"get_logo", &CControlAPI::logoCGI, "text/plain"}, // settings {"config", &CControlAPI::ConfigCGI, "text/plain"}, + // filehandling + {"file", &CControlAPI::FileCGI, "+xml"}, + }; //----------------------------------------------------------------------------- @@ -1033,6 +1047,7 @@ void CControlAPI::channelEPGAsXML(CyhookHandler *hh, int bouquetnr, t_channel_id void CControlAPI::EpgCGI(CyhookHandler *hh) { //hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); + NeutrinoAPI->eList.clear(); if (hh->ParamList.empty()) { hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); @@ -1695,16 +1710,32 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh) hh->printf("\t\t\t%s\n",title.c_str()); // audio - if( timer->apids != TIMERD_APIDS_CONF){ + if(timer->apids != TIMERD_APIDS_CONF){ hh->WriteLn("\t\t\t\n"); } + else { + hh->WriteLn("\t\t\t\n"); + } + hh->printf("\t\t\t%s\n",timer->recordingDir); hh->printf("\t\t\t%d\n",(int)timer->epgID); @@ -2362,3 +2393,84 @@ void CControlAPI::ConfigCGI(CyhookHandler *hh) delete Config; } +//----------------------------------------------------------------------------- +// File handling +// action=list|new_folder|delete|read_file|write_file|set_properties +// path= +// TODO: development in progress! +//----------------------------------------------------------------------------- +void CControlAPI::FileCGI(CyhookHandler *hh) +{ + + // directory list: action=list&path= + if (hh->ParamList["action"] == "list"){ + DIR *dirp; + struct dirent *entry; + struct stat statbuf; + struct passwd *pwd; + struct group *grp; + struct tm *tm; + char datestring[256]; + + hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); + hh->WriteLn(""); + std::string path = hh->ParamList["path"]; + if((dirp = opendir( path.c_str() ))) + { + while((entry = readdir(dirp))){ + hh->WriteLn("\t"); + hh->printf("\t\t%s\n", entry->d_name); + std::string ftype; + if(entry->d_type == DT_DIR) + ftype="dir"; + else if(entry->d_type == DT_LNK) + ftype="lnk"; + else if(entry->d_type == 8) + ftype="file"; + + hh->printf("\t\t%s", ftype.c_str() ); + hh->printf("\t\t%d", (int)entry->d_type); + if(path[path.length() - 1] != '/') + path+="/"; + std::string fullname = path + entry->d_name; + hh->printf("\t\t%s", fullname.c_str()); +//entry->d_name + if(stat(fullname.c_str(), &statbuf)!=-1){ + hh->printf("\t\t%xld", (long)statbuf.st_mode); + /* Print out type, permissions, and number of links. */ +// hh->printf("\t\t%10.10s\n", sperm (statbuf.st_mode)); + hh->printf("\t\t%d\n", statbuf.st_nlink); + /* Print out owner's name if it is found using getpwuid(). */ + if ((pwd = getpwuid(statbuf.st_uid)) != NULL) + hh->printf("\t\t%s\n", pwd->pw_name); + else + hh->printf("\t\t%d\n", statbuf.st_uid); + /* Print out group name if it is found using getgrgid(). */ + if ((grp = getgrgid(statbuf.st_gid)) != NULL) + hh->printf("\t\t%s\n", grp->gr_name); + else + hh->printf("\t\t%d\n", statbuf.st_gid); + /* Print size of file. */ + hh->printf("\t\t%jd\n", (intmax_t)statbuf.st_size); + tm = localtime(&statbuf.st_mtime); + /* Get localized date string. */ + strftime(datestring, sizeof(datestring), nl_langinfo(D_T_FMT), tm); + hh->printf("\t\t\n", datestring); + hh->printf("\t\t%ld\n", (long)statbuf.st_mtime); + } + hh->WriteLn("\t"); + } + closedir(dirp); + } + hh->WriteLn(""); + } + // create new folder + else if (hh->ParamList["action"] == "new_folder"){ + hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); + //TODO + } + else if (hh->ParamList["action"] == "delete"){ + hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); + //TODO + } +} diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.h b/src/nhttpd/tuxboxapi/coolstream/controlapi.h index ceee5bcd9..a1c0bf6d7 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.h +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.h @@ -101,6 +101,7 @@ private: void build_live_url(CyhookHandler *hh); void logoCGI(CyhookHandler *hh); void ConfigCGI(CyhookHandler *hh); + void FileCGI(CyhookHandler *hh); protected: static const unsigned int PLUGIN_DIR_COUNT = 7; diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 1cec30b34..42da676f7 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -25,7 +25,7 @@ //----------------------------------------------------------------------------- // General central Definitions //----------------------------------------------------------------------------- -#define HTTPD_VERSION "3.3.1" // Webserver version (can be overloaded) +#define HTTPD_VERSION "3.3.2" // Webserver version (can be overloaded) #define YHTTPD_VERSION "1.3.1" // Webserver version (Version of yhttpd-core!) #define IADDR_LOCAL "127.0.0.1" // local IP #define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)