readusers.cpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: Readusers.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 /*********************************************************************** 00045 * Video Session Migration System, 2004 * 00046 * Author: Klaus Schoeffmann * 00047 ************************************************************************/ 00048 00049 00050 #include "readusers.hpp" 00051 00052 /***********************************************************************/ 00053 void createUserSelection() 00054 { 00055 //first read all users 00056 UserList *ul = new UserList(); 00057 ul->readUsersFromFile(Globals::getConfigFilePath()); 00058 00059 //then create selection box 00060 cout << "<select style=\"width:100%\" size=\"3\" name=\"userid\" "; 00061 cout << " onChange=\"doLogon();\">" << endl; 00062 //output all usernames 00063 vector<User*> users = ul->getUsers(); 00064 vector<User*>::const_iterator iter = users.begin(); 00065 for (; iter != users.end(); iter++) 00066 { 00067 User *user = *iter; 00068 cout << "<option value=\"" << user->getUserId() << "\">"; 00069 cout << user->getUsername() << "</option>" << endl; 00070 } 00071 cout << "</select>" << endl; 00072 00073 delete ul; 00074 } 00075 00076 /***********************************************************************/ 00077 int main (int argc, char *argv[]) 00078 { 00079 00080 bool foundMovieList = false; 00081 00082 string formdata; 00083 cin >> formdata; 00084 CGIParser cgiparser (formdata); 00085 uint pageSize = atoi(cgiparser.getFieldValue("pagesize").c_str()); 00086 if (pageSize == 0) pageSize = 1; 00087 00088 //create header and menu 00089 cout << html::getHTMLHeader(); 00090 cout << html::getMenu("readusers.cgi", pageSize); 00091 html::createPageSizeForm(cgiparser.createOpenForm("frmPageSize", "readusers.cgi", "post", ""), pageSize); 00092 00093 Globals::sdebug << "\nreadusers: request movielist"; 00094 00095 //first try to request movielist from mediaserver 00096 MovieListRequest *mlr = new MovieListRequest(); 00097 if (mlr->requestMovieList(Globals::getMediaserverHttpHost(),Globals::getMediaserverHttpPort())) 00098 { 00099 foundMovieList = true; 00100 } 00101 else 00102 { 00103 //cannot request movielist 00104 //try to use an older version 00105 ifstream testoldfile (Globals::getMoviesFileName()); 00106 if (testoldfile) 00107 { 00108 cout << html::warning("movielist-request failed!<br>Using cached version!") << endl; 00109 foundMovieList = true; 00110 } 00111 else 00112 { 00113 cout << html::error("Cannot request movielist from mediaserver!") << endl; 00114 exit(1); 00115 } 00116 } 00117 delete mlr; 00118 00119 //if movielist were received/found, output all users 00120 if (foundMovieList) 00121 { 00122 00123 //create form and selection-box 00124 cout << "<form name=\"logon\" action=\"" << Globals::getCGIPath() << "readprofiles.cgi\" method=\"post\">"; 00125 cout << "<input type=\"hidden\" id=\"pagesize\" name=\"pagesize\" value=\"" << pageSize << "\">"; 00126 00127 cout << "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; 00128 cout << "<tr><td width=\"50%\" align=\"left\">Choose user:</td>" << endl; 00129 cout << "<td with=\"50%\" align=\"center\" rowspan=\"2\">" << endl; 00130 cout << "<input name=\"logon\" id=\"logon\" type=\"submit\" value=\"Go\"></td></tr>" << endl; 00131 cout << "<tr><td align=\"left\">" << endl; 00132 00133 createUserSelection(); 00134 00135 cout << "</td></tr></table>" << endl; 00136 cout << "<br><input type=\"checkbox\" id=\"proxysupported\" name=\"proxysupported\"" 00137 << " checked onChange=\"checkProxyFields();\" onClick=\"checkProxyFields();\">" 00138 << "Client supports RTSP proxy" << endl; 00139 cout << "<span id=\"proxyconf\">" << endl; 00140 cout << "<br>SeMiProxy<br>Address:<input type=\"text\" id=\"sphost\" name=\"sphost\"" 00141 << " value=\"" << semifunc::getHostname() << "\" size=\"15\">" << endl; 00142 cout << "<br>Port:<input type=\"text\" id=\"spport\" name=\"spport\"" 00143 << "value=\"6554\" size=\"6\">" << endl; 00144 cout << "</span>" << endl; 00145 cout << "</form>" << endl; 00146 00147 cout << "<script language=\"javascript\">" << endl; 00148 cout << "function doLogon() {" << endl; 00149 cout << " document.forms['logon'].submit();" << endl; 00150 cout << " document.getElementById('logon').disabled = true;" << endl; 00151 cout << "}" << endl; 00152 cout << "function checkProxyFields() {" << endl; 00153 cout << " if (document.getElementById('proxysupported').checked) {" << endl; 00154 cout << " document.getElementById('proxyconf').style.display = \"none\";" << endl; 00155 cout << " } else {" << endl; 00156 cout << " document.getElementById('proxyconf').style.display = \"inline\";" << endl; 00157 cout << " }" << endl; 00158 cout << "}" << endl; 00159 cout << "document.getElementById('proxyconf').style.display = \"none\";" << endl; 00160 cout << "</script>" << endl; 00161 00162 } 00163 00164 00165 cout << html::getHTMLFooter(cgiparser.createRefreshForm("readusers.cgi", "post")); 00166 00167 return 0; 00168 }