Changeset 22666 in vbox
- Timestamp:
- Sep 1, 2009 2:03:51 PM (15 years ago)
- Location:
- trunk/src/VBox/Main/webservice
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/webservice/vboxweb.cpp
r22266 r22666 3 3 * hand-coded parts of the webservice server. This is linked with the 4 4 * generated code in out/.../src/VBox/Main/webservice/methodmaps.cpp 5 * ( andstatic gSOAP server code) to implement the actual webservice5 * (plus static gSOAP server code) to implement the actual webservice 6 6 * server, to which clients can connect. 7 7 * … … 98 98 *g_pcszIVirtualBox; 99 99 100 // globals for vboxweb command-line arguments 100 101 #define DEFAULT_TIMEOUT_SECS 300 101 102 #define DEFAULT_TIMEOUT_SECS_STRING "300" 102 103 103 int g_iWatchdogTimeoutSecs = DEFAULT_TIMEOUT_SECS; 104 104 int g_iWatchdogCheckInterval = 5; 105 105 106 const char *g_pcszBindToHost = NULL; 106 const char *g_pcszBindToHost = NULL; // host; NULL = current machine 107 107 unsigned int g_uBindToPort = 18083; // port 108 108 unsigned int g_uBacklog = 100; // backlog = max queue size for requests … … 205 205 } 206 206 207 /** 208 * Implementation for WEBLOG macro defined in vboxweb.h; this prints a message 209 * to the console and optionally to the file that may have been given to the 210 * vboxwebsrv command line. 211 * @param pszFormat 212 */ 207 213 void WebLog(const char *pszFormat, ...) 208 214 { … … 223 229 } 224 230 231 /** 232 * Helper for printing SOAP error messages. 233 * @param soap 234 */ 225 235 void WebLogSoapError(struct soap *soap) 226 236 { … … 241 251 /** 242 252 * Start up the webservice server. This keeps running and waits 243 * for incoming SOAP connections. 253 * for incoming SOAP connections; for each request that comes in, 254 * it calls method implementation code, most of it in the generated 255 * code in methodmaps.cpp. 244 256 * 245 257 * @param argc … … 417 429 m); 418 430 419 for (u nsigned long longi = 1;431 for (uint64_t i = 1; 420 432 ; 421 433 i++) 422 434 { 435 // call gSOAP to handle incoming SOAP connection 423 436 s = soap_accept(&soap); 424 437 if (s < 0) … … 479 492 { 480 493 WEBDEBUG(("Watchdog: sleeping %d seconds\n", g_iWatchdogCheckInterval)); 481 RTThreadSleep(g_iWatchdogCheckInterval *1000);494 RTThreadSleep(g_iWatchdogCheckInterval * 1000); 482 495 483 496 time_t tNow; … … 570 583 ex->badObjectID = obj; 571 584 572 /* std::ostringstream ostr;573 ostr << std::hex << ex->badObjectID; */574 575 585 std::string str("VirtualBox error: "); 576 586 str += "Invalid managed object reference \"" + obj + "\""; -
trunk/src/VBox/Main/webservice/vboxweb.h
r21878 r22666 26 26 void WebLog(const char *pszFormat, ...); 27 27 28 // #ifdef DEBUG29 28 #define WEBDEBUG(a) if (g_fVerbose) { WebLog a; } 30 // #else31 // #define WEBDEBUG(a) do { } while(0)32 // #endif33 29 34 30 /**************************************************************************** … … 38 34 ****************************************************************************/ 39 35 40 extern ComPtr<IVirtualBox> G_pVirtualBox;36 extern ComPtr<IVirtualBox> g_pVirtualBox; 41 37 extern bool g_fVerbose; 42 38 … … 53 49 typedef std::string vbox__uuid; 54 50 55 // type used internally by our class56 // typedef WSDLT_ID ManagedObjectID;57 58 // #define VBOXWEB_ERROR_BASE 1000059 // #define VBOXWEB_INVALID_MANAGED_OBJECT (VBOXWEB_ERROR_BASE + 0)60 // #define VBOXWEB_INVALID_MANAGED_OBJECT_TYPE (VBOXWEB_ERROR_BASE + 1)61 62 51 /**************************************************************************** 63 52 * … … 90 79 91 80 /** 92 * 81 * An instance of this gets created for every client that logs onto the 82 * webservice (via the special IWebsessionManager::logon() SOAP API) and 83 * maintains the managed object references for that session. 93 84 */ 94 85 class WebServiceSession … … 98 89 private: 99 90 uint64_t _uSessionID; 100 WebServiceSessionPrivate *_pp; 91 WebServiceSessionPrivate *_pp; // opaque data struct (defined in vboxweb.cpp) 101 92 bool _fDestructing; 102 93 … … 228 219 if (fNullAllowed && pRef == NULL) 229 220 { 230 pComPtr.setNull();231 return 0;221 pComPtr.setNull(); 222 return 0; 232 223 } 233 224 234 225 // pRef->getComPtr returns a ComPtr<IUnknown>; by casting it to 235 // ComPtr<T>, we implicitly do a queryInterface() call226 // ComPtr<T>, we implicitly do a COM queryInterface() call 236 227 if (pComPtr = pRef->getComPtr()) 237 228 return 0; … … 266 257 } 267 258 268 WebServiceSession *pSession;259 WebServiceSession *pSession; 269 260 if ((pSession = WebServiceSession::findSessionFromRef(idParent))) 270 261 { -
trunk/src/VBox/Main/webservice/webtest.cpp
r18423 r22666 47 47 "Usage:\n" 48 48 " - IWebsessionManager:\n" 49 " - webtest logon <user> <pass>: IWebsessionManage::logon().\n" 50 " - webtest getsession <vboxref>: IWebsessionManage::getSessionObject().\n" 49 " - webtest logon <user> <pass>: IWebsessionManager::logon().\n" 50 " - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n" 51 " - webtest logoff <vboxref>: IWebsessionManager::logoff().\n" 51 52 " - IVirtualBox:\n" 52 53 " - webtest version <vboxref>: IVirtualBox::getVersion().\n" … … 84 85 req.username = argv[2]; 85 86 req.password = argv[3]; 86 std::cout << "logon: user = \"" << req.username << "\", pass = \"" << req.password << "\"\n";87 87 _vbox__IWebsessionManager_USCORElogonResponse resp; 88 88 … … 111 111 &resp))) 112 112 std::cout << "session: \"" << resp.returnval << "\"\n"; 113 } 114 } 115 else if (!strcmp(pcszMode, "logoff")) 116 { 117 if (argc < 3) 118 std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n"; 119 else 120 { 121 _vbox__IWebsessionManager_USCORElogoff req; 122 req.refIVirtualBox = argv[2]; 123 _vbox__IWebsessionManager_USCORElogoffResponse resp; 124 125 if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogoff(&soap, 126 pcszArgEndpoint, 127 NULL, 128 &req, 129 &resp))) 130 ; 113 131 } 114 132 }
Note:
See TracChangeset
for help on using the changeset viewer.