|
libsax 7.2
|
00001 /************** 00002 FILE : extensions.cpp 00003 *************** 00004 PROJECT : SaX2 - library interface 00005 : 00006 AUTHOR : Marcus Schäfer <ms@suse.de> 00007 : 00008 BELONGS TO : SaX2 - SuSE advanced X11 configuration 00009 : 00010 : 00011 DESCRIPTION : native C++ class library to access SaX2 00012 : functionality. Easy to use interface for 00013 : //.../ 00014 : - importing/exporting X11 configurations 00015 : - modifying/creating X11 configurations 00016 : --- 00017 : 00018 : 00019 STATUS : Status: Development 00020 **************/ 00021 #include "extensions.h" 00022 00023 namespace SaX { 00024 //==================================== 00025 // Constructor... 00026 //------------------------------------ 00027 SaXManipulateExtensions::SaXManipulateExtensions (SaXImport* in) { 00028 // .../ 00031 // ---- 00032 if ( ! in ) { 00033 excNullPointerArgument (); 00034 qError (errorString(),EXC_NULLPOINTERARGUMENT); 00035 return; 00036 } 00037 if ( in->getSectionID() != SAX_EXTENSIONS ) { 00038 excExtensionsImportBindFailed ( in->getSectionID() ); 00039 qError (errorString(),EXC_EXTENSIONSIMPORTBINDFAILED); 00040 return; 00041 } 00042 mImport = in; 00043 mExtensions = 0; 00044 mImport -> setID ( mExtensions ); 00045 } 00046 00047 //==================================== 00048 // More to come for the extensions... 00049 //------------------------------------ 00050 // ... 00051 00052 //==================================== 00053 // Constructor... 00054 //------------------------------------ 00055 SaXManipulateVNC::SaXManipulateVNC ( 00056 SaXImport* card,SaXImport* pointer,SaXImport* kbd, 00057 SaXImport* layout,SaXImport* path,int id 00058 ) : SaXManipulateVNCIF (card,id) { 00059 // .../ 00062 // ---- 00063 mManipPointer = new SaXManipulateDevices (pointer,layout); 00064 mManipKeyboard = new SaXManipulateDevices (kbd,layout); 00065 mManipModules = new SaXManipulatePath (path); 00066 mVNCMouse = -1; 00067 mVNCKeyboard = -1; 00068 if ( layout->getSectionID() != SAX_LAYOUT ) { 00069 excLayoutImportBindFailed ( layout->getSectionID() ); 00070 qError (errorString(),EXC_LAYOUTIMPORTBINDFAILED); 00071 return; 00072 } 00073 mLayout = layout; 00074 mPointer = pointer; 00075 mKeyboard = kbd; 00076 } 00077 00078 //==================================== 00079 // enableVNC 00080 //------------------------------------ 00081 void SaXManipulateVNC::enableVNC (void) { 00082 // .../ 00086 // ---- 00087 removeCardOption ("usevnc"); 00088 mManipModules->removeLoadableModule ("vnc"); 00089 addCardOption ("usevnc","yes"); 00090 mManipModules->addLoadableModule ("vnc"); 00091 } 00092 00093 //==================================== 00094 // disableVNC 00095 //------------------------------------ 00096 void SaXManipulateVNC::disableVNC (void) { 00097 // .../ 00102 // ---- 00103 removeCardOption ("usevnc"); 00104 addCardOption ("usevnc","no"); 00105 mManipModules->removeLoadableModule ("vnc"); 00106 } 00107 00108 //==================================== 00109 // setPassword 00110 //------------------------------------ 00111 void SaXManipulateVNC::setPassword (const QString& pwd) { 00112 // .../ 00117 // ---- 00118 if (! setLock()) { 00119 return; 00120 } 00121 SaXProcessCall* proc = new SaXProcessCall (); 00122 proc -> addArgument ( SAX_CREATE_VNC_PWD ); 00123 proc -> addArgument ( pwd ); 00124 if ( ! proc -> start() ) { 00125 excProcessFailed(); 00126 qError (errorString(),EXC_PROCESSFAILED); 00127 unsetLock(); 00128 return; 00129 } 00130 unsetLock(); 00131 } 00132 00133 //==================================== 00134 // enablePasswordProtection 00135 //------------------------------------ 00136 void SaXManipulateVNC::enablePasswordProtection (const QString& pwd) { 00137 // .../ 00142 // ---- 00143 setPassword (pwd); 00144 disablePasswordProtection(); 00145 addCardOption ("rfbauth","/root/.vnc/passwd"); 00146 } 00147 00148 //==================================== 00149 // disablePasswordProtection 00150 //------------------------------------ 00151 void SaXManipulateVNC::disablePasswordProtection (void) { 00152 // .../ 00156 // ---- 00157 removeCardOption ("rfbauth"); 00158 } 00159 00160 //==================================== 00161 // enableHTTPAccess 00162 //------------------------------------ 00163 void SaXManipulateVNC::enableHTTPAccess (int port) { 00164 // .../ 00168 // ---- 00169 QString HTTPport; 00170 QTextOStream (&HTTPport) << port; 00171 disableHTTPAccess(); 00172 addCardOption ("httpdir","/usr/share/vnc/classes"); 00173 addCardOption ("httpport",HTTPport); 00174 } 00175 00176 //==================================== 00177 // disableHTTPAccess 00178 //------------------------------------ 00179 void SaXManipulateVNC::disableHTTPAccess (void) { 00180 // .../ 00183 // ---- 00184 removeCardOption ("httpdir"); 00185 removeCardOption ("httpport"); 00186 } 00187 00188 //==================================== 00189 // allowMultipleConnections 00190 //------------------------------------ 00191 void SaXManipulateVNC::allowMultipleConnections (bool allow) { 00192 // .../ 00195 // ---- 00196 if (allow) { 00197 removeCardOption ("alwaysshared"); 00198 addCardOption ("alwaysshared",0); 00199 } else { 00200 removeCardOption ("alwaysshared"); 00201 } 00202 } 00203 00204 //==================================== 00205 // addVNCKeyboard 00206 //------------------------------------ 00207 void SaXManipulateVNC::addVNCKeyboard (void) { 00208 // .../ 00211 // ---- 00212 if (! mLayout) { 00213 return; 00214 } 00215 if (mVNCKeyboard == -1) { 00216 QString extraLink; 00217 mVNCKeyboard = mManipKeyboard->addInputDevice (SAX_INPUT_VNC); 00218 QTextOStream (&extraLink) << mVNCMouse << " " << mVNCKeyboard; 00219 mLayout -> setItem ( "VNC", extraLink ); 00220 } 00221 } 00222 00223 //==================================== 00224 // addVNCMouse 00225 //------------------------------------ 00226 void SaXManipulateVNC::addVNCMouse (void) { 00227 // .../ 00229 // ---- 00230 if (! mLayout) { 00231 return; 00232 } 00233 if (mVNCMouse == -1) { 00234 QString extraLink; 00235 mVNCMouse = mManipPointer->addInputDevice (SAX_INPUT_VNC); 00236 QTextOStream (&extraLink) << mVNCMouse << " " << mVNCKeyboard; 00237 mLayout -> setItem ( "VNC", extraLink ); 00238 } 00239 } 00240 00241 //==================================== 00242 // removeVNCMouse 00243 //------------------------------------ 00244 void SaXManipulateVNC::removeVNCMouse (void) { 00245 // .../ 00247 // 00248 if (! mLayout) { 00249 return; 00250 } 00251 if (mVNCMouse == -1) { 00252 mVNCMouse = searchVNCDevice ( SAX_VNC_MOUSE ); 00253 } 00254 mManipPointer->removeInputDevice (mVNCMouse); 00255 mLayout -> setItem ("VNC",""); 00256 mVNCMouse = -1; 00257 } 00258 00259 //==================================== 00260 // removeVNCKeyboard 00261 //------------------------------------ 00262 void SaXManipulateVNC::removeVNCKeyboard (void) { 00263 // .../ 00265 // ---- 00266 if (! mLayout) { 00267 return; 00268 } 00269 if (mVNCKeyboard == -1) { 00270 mVNCKeyboard = searchVNCDevice ( SAX_VNC_KEYBOARD ); 00271 } 00272 mManipKeyboard->removeInputDevice (mVNCKeyboard); 00273 mLayout -> setItem ("VNC",""); 00274 mVNCKeyboard = -1; 00275 } 00276 00277 //==================================== 00278 // searchVNCDevice 00279 //------------------------------------ 00280 int SaXManipulateVNC::searchVNCDevice ( int flag ) { 00281 SaXManipulateMice mManipInput ( mPointer ); 00282 SaXManipulateKeyboard mManipKeyboard ( mKeyboard ); 00283 int input1Count = mPointer->getCount(); 00284 int input2Count = mKeyboard->getCount(); 00285 int pINPUT = mPointer->getCurrentID(); 00286 int pKBD = mKeyboard->getCurrentID(); 00287 int result = -1; 00288 if (flag == SAX_VNC_MOUSE) { 00289 for (int i=input1Count;i>=0;i--) { 00290 if (mManipInput.selectPointer (i)) { 00291 QString driver = mManipInput.getDriver(); 00292 if (driver == "rfbmouse") { 00293 result = i; break; 00294 } 00295 } 00296 } 00297 } 00298 if (flag == SAX_VNC_KEYBOARD) { 00299 for (int i=input2Count;i>=0;i--) { 00300 if (mManipKeyboard.selectKeyboard (i)) { 00301 QString driver = mManipKeyboard.getDriver(); 00302 if (driver == "rfbkeyb") { 00303 result = i; break; 00304 } 00305 } 00306 } 00307 } 00308 mManipInput.selectPointer ( pINPUT ); 00309 mManipKeyboard.selectKeyboard ( pKBD ); 00310 return result; 00311 } 00312 00313 //==================================== 00314 // VNCEnabled 00315 //------------------------------------ 00316 bool SaXManipulateVNC::isVNCEnabled (void) { 00317 // .../ 00319 // ---- 00320 Q3Dict<QString> options = getOptions(); 00321 if ((options["usevnc"]) && (*options["usevnc"] == "yes")) { 00322 return true; 00323 } 00324 return false; 00325 } 00326 00327 //==================================== 00328 // HTTPAccessEnabled 00329 //------------------------------------ 00330 bool SaXManipulateVNC::isHTTPAccessEnabled (void) { 00331 // .../ 00333 // ---- 00334 Q3Dict<QString> options = getOptions(); 00335 if (options["httpport"]) { 00336 return true; 00337 } 00338 return false; 00339 } 00340 00341 //==================================== 00342 // multiConnectEnabled 00343 //------------------------------------ 00344 bool SaXManipulateVNC::isMultiConnectEnabled (void) { 00345 // .../ 00348 // ---- 00349 Q3Dict<QString> options = getOptions(); 00350 if (options["alwaysshared"]) { 00351 return true; 00352 } 00353 return false; 00354 } 00355 00356 //==================================== 00357 // pwdProtectionEnabled 00358 //------------------------------------ 00359 bool SaXManipulateVNC::isPwdProtectionEnabled (void) { 00360 // .../ 00362 // ---- 00363 Q3Dict<QString> options = getOptions(); 00364 if (options["rfbauth"]) { 00365 return true; 00366 } 00367 return false; 00368 } 00369 00370 //==================================== 00371 // getHTTPPort 00372 //------------------------------------ 00373 int SaXManipulateVNC::getHTTPPort (void) { 00374 // .../ 00377 // ---- 00378 Q3Dict<QString> options = getOptions(); 00379 if (options["httpport"]) { 00380 return options["httpport"]->toInt(); 00381 } 00382 return 0; 00383 } 00384 } // end namespace
1.7.3