diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Main/src-server/xpcom | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Main/src-server/xpcom')
-rw-r--r-- | src/VBox/Main/src-server/xpcom/server.cpp | 45 | ||||
-rw-r--r-- | src/VBox/Main/src-server/xpcom/server.h | 2 | ||||
-rw-r--r-- | src/VBox/Main/src-server/xpcom/server_module.cpp | 92 |
3 files changed, 69 insertions, 70 deletions
diff --git a/src/VBox/Main/src-server/xpcom/server.cpp b/src/VBox/Main/src-server/xpcom/server.cpp index 6c48fcba..24ff15a8 100644 --- a/src/VBox/Main/src-server/xpcom/server.cpp +++ b/src/VBox/Main/src-server/xpcom/server.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2004-2012 Oracle Corporation + * Copyright (C) 2004-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -20,10 +20,6 @@ #include <nsIComponentRegistrar.h> -#ifdef XPCOM_GLUE -# include <nsXPCOMGlue.h> -#endif - #include <nsEventQueueUtils.h> #include <nsGenericFactory.h> @@ -66,7 +62,7 @@ #include "AudioAdapterImpl.h" #include "BandwidthControlImpl.h" #include "BandwidthGroupImpl.h" -#include "DHCPServerRunner.h" +#include "NetworkServiceRunner.h" #include "DHCPServerImpl.h" #include "GuestOSTypeImpl.h" #include "HostImpl.h" @@ -77,7 +73,6 @@ #include "NATEngineImpl.h" #include "NetworkAdapterImpl.h" #include "ParallelPortImpl.h" -#include "ProgressCombinedImpl.h" #include "ProgressProxyImpl.h" #include "SerialPortImpl.h" #include "SharedFolderImpl.h" @@ -85,6 +80,7 @@ #include "StorageControllerImpl.h" #include "SystemPropertiesImpl.h" #include "USBControllerImpl.h" +#include "USBDeviceFiltersImpl.h" #include "VFSExplorerImpl.h" #include "VirtualBoxImpl.h" #include "VRDEServerImpl.h" @@ -96,6 +92,8 @@ #ifdef VBOX_WITH_EXTPACK # include "ExtPackManagerImpl.h" #endif +# include "NATNetworkImpl.h" + /* implement nsISupports parts of our objects with support for nsIClassInfo */ @@ -126,18 +124,12 @@ NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Snapshot, ISnapshot) NS_DECL_CLASSINFO(Medium) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Medium, IMedium) -NS_DECL_CLASSINFO(MediumFormat) -NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MediumFormat, IMediumFormat) - NS_DECL_CLASSINFO(MediumAttachment) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MediumAttachment, IMediumAttachment) NS_DECL_CLASSINFO(Progress) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress) -NS_DECL_CLASSINFO(CombinedProgress) -NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress) - NS_DECL_CLASSINFO(ProgressProxy) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ProgressProxy, IProgress) @@ -156,6 +148,9 @@ NS_IMPL_THREADSAFE_ISUPPORTS1_CI(HostNetworkInterface, IHostNetworkInterface) NS_DECL_CLASSINFO(DHCPServer) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(DHCPServer, IDHCPServer) +NS_DECL_CLASSINFO(NATNetwork) +NS_IMPL_THREADSAFE_ISUPPORTS1_CI(NATNetwork, INATNetwork) + NS_DECL_CLASSINFO(GuestOSType) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestOSType, IGuestOSType) @@ -175,6 +170,9 @@ NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ParallelPort, IParallelPort) NS_DECL_CLASSINFO(USBController) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBController, IUSBController) +NS_DECL_CLASSINFO(USBDeviceFilters) +NS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBDeviceFilters, IUSBDeviceFilters) + NS_DECL_CLASSINFO(StorageController) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(StorageController, IStorageController) @@ -881,23 +879,26 @@ int main(int argc, char **argv) nsresult rc; + /** @todo Merge this code with svcmain.cpp (use Logging.cpp?). */ + char szLogFile[RTPATH_MAX]; if (!pszLogFile) { - char szLogFile[RTPATH_MAX] = ""; vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile)); - if (vrc == VERR_ACCESS_DENIED) - return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open global settings directory '%s'", szLogFile); if (RT_SUCCESS(vrc)) vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log"); - if (RT_SUCCESS(vrc)) - pszLogFile = RTStrDup(szLogFile); - if (RT_FAILURE(vrc)) - return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to determine release log file (%Rrc)", vrc); } + else + { + if (!RTStrPrintf(szLogFile, sizeof(szLogFile), "%s", pszLogFile)) + vrc = VERR_NO_MEMORY; + } + if (RT_FAILURE(vrc)) + return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to create logging file name, rc=%Rrc", vrc); + char szError[RTPATH_MAX + 128]; - vrc = com::VBoxLogRelCreate("XPCOM Server", pszLogFile, + vrc = com::VBoxLogRelCreate("XPCOM Server", szLogFile, RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG, - "all", "VBOXSVC_RELEASE_LOG", + VBOXSVC_LOG_DEFAULT, "VBOXSVC_RELEASE_LOG", RTLOGDEST_FILE, UINT32_MAX /* cMaxEntriesPerGroup */, cHistory, uHistoryFileTime, uHistoryFileSize, szError, sizeof(szError)); diff --git a/src/VBox/Main/src-server/xpcom/server.h b/src/VBox/Main/src-server/xpcom/server.h index f14977af..4fbaa231 100644 --- a/src/VBox/Main/src-server/xpcom/server.h +++ b/src/VBox/Main/src-server/xpcom/server.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2010 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/Main/src-server/xpcom/server_module.cpp b/src/VBox/Main/src-server/xpcom/server_module.cpp index 0647016c..11cf239e 100644 --- a/src/VBox/Main/src-server/xpcom/server_module.cpp +++ b/src/VBox/Main/src-server/xpcom/server_module.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2014 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -53,10 +53,9 @@ #include <iprt/path.h> #include <iprt/process.h> #include <iprt/env.h> +#include <iprt/string.h> #include <iprt/thread.h> -#include <string.h> - #if defined(RT_OS_SOLARIS) # include <sys/systeminfo.h> #endif @@ -92,8 +91,8 @@ static bool IsVBoxSVCPathSet = false; * in sync with macros used for VirtualBox in server.cpp for the same purpose. */ -NS_DECL_CLASSINFO (VirtualBox) -NS_IMPL_CI_INTERFACE_GETTER1 (VirtualBox, IVirtualBox) +NS_DECL_CLASSINFO(VirtualBox) +NS_IMPL_CI_INTERFACE_GETTER1(VirtualBox, IVirtualBox) static nsresult vboxsvcSpawnDaemon(void) { @@ -137,7 +136,7 @@ static nsresult vboxsvcSpawnDaemon(void) writable = nsnull; char msg[10]; - memset(msg, '\0', sizeof(msg)); + RT_ZERO(msg); if ( PR_Read(readable, msg, sizeof(msg)-1) != 5 || strcmp(msg, "READY")) { @@ -168,8 +167,8 @@ end: * VirtualBox component defined on the server. */ static NS_IMETHODIMP -VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, - void **aResult) +VirtualBoxConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) { LogFlowFuncEnter(); @@ -189,25 +188,25 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, { /* Get the directory containing XPCOM components -- the VBoxSVC * executable is expected in the parent directory. */ - nsCOMPtr <nsIProperties> dirServ = do_GetService (NS_DIRECTORY_SERVICE_CONTRACTID, &rc); + nsCOMPtr<nsIProperties> dirServ = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rc); if (NS_SUCCEEDED(rc)) { - nsCOMPtr <nsIFile> componentDir; - rc = dirServ->Get (NS_XPCOM_COMPONENT_DIR, - NS_GET_IID (nsIFile), getter_AddRefs (componentDir)); + nsCOMPtr<nsIFile> componentDir; + rc = dirServ->Get(NS_XPCOM_COMPONENT_DIR, + NS_GET_IID(nsIFile), getter_AddRefs(componentDir)); if (NS_SUCCEEDED(rc)) { nsCAutoString path; - componentDir->GetNativePath (path); + componentDir->GetNativePath(path); - LogFlowFunc (("component directory = \"%s\"\n", path.get())); - AssertBreakStmt (path.Length() + strlen (VBoxSVC_exe) < RTPATH_MAX, - rc = NS_ERROR_FAILURE); + LogFlowFunc(("component directory = \"%s\"\n", path.get())); + AssertBreakStmt(path.Length() + strlen(VBoxSVC_exe) < RTPATH_MAX, + rc = NS_ERROR_FAILURE); #if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_HARDENING) char achKernArch[128]; - int cbKernArch = sysinfo (SI_ARCHITECTURE_K, achKernArch, sizeof(achKernArch)); + int cbKernArch = sysinfo(SI_ARCHITECTURE_K, achKernArch, sizeof(achKernArch)); if (cbKernArch > 0) { sprintf(VBoxSVCPath, "/opt/VirtualBox/%s%s", achKernArch, VBoxSVC_exe); @@ -216,9 +215,9 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, else rc = NS_ERROR_UNEXPECTED; #else - strcpy (VBoxSVCPath, path.get()); - RTPathStripFilename (VBoxSVCPath); - strcat (VBoxSVCPath, VBoxSVC_exe); + strcpy(VBoxSVCPath, path.get()); + RTPathStripFilename(VBoxSVCPath); + strcat(VBoxSVCPath, VBoxSVC_exe); IsVBoxSVCPathSet = true; #endif @@ -228,7 +227,7 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, break; } - nsCOMPtr <ipcIService> ipcServ = do_GetService (IPC_SERVICE_CONTRACTID, &rc); + nsCOMPtr<ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc); if (NS_FAILED(rc)) break; @@ -239,13 +238,13 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, do { - LogFlowFunc (("Resolving server name \"%s\"...\n", VBOXSVC_IPC_NAME)); + LogFlowFunc(("Resolving server name \"%s\"...\n", VBOXSVC_IPC_NAME)); PRUint32 serverID = 0; - rc = ipcServ->ResolveClientName (VBOXSVC_IPC_NAME, &serverID); + rc = ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); if (NS_FAILED(rc)) { - LogFlowFunc (("Starting server \"%s\"...\n", VBoxSVCPath)); + LogFlowFunc(("Starting server \"%s\"...\n", VBoxSVCPath)); startedOnce = true; @@ -256,8 +255,8 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, /* wait for the server process to establish a connection */ do { - RTThreadSleep (VBoxSVC_WaitSlice); - rc = ipcServ->ResolveClientName (VBOXSVC_IPC_NAME, &serverID); + RTThreadSleep(VBoxSVC_WaitSlice); + rc = ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); if (NS_SUCCEEDED(rc)) break; if (timeLeft <= VBoxSVC_WaitSlice) @@ -276,20 +275,20 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, } } - LogFlowFunc (("Connecting to server (ID=%d)...\n", serverID)); + LogFlowFunc(("Connecting to server (ID=%d)...\n", serverID)); - nsCOMPtr <ipcIDConnectService> dconServ = - do_GetService (IPC_DCONNECTSERVICE_CONTRACTID, &rc); + nsCOMPtr<ipcIDConnectService> dconServ = + do_GetService(IPC_DCONNECTSERVICE_CONTRACTID, &rc); if (NS_FAILED(rc)) break; - rc = dconServ->CreateInstance (serverID, - CLSID_VirtualBox, - aIID, aResult); + rc = dconServ->CreateInstance(serverID, + CLSID_VirtualBox, + aIID, aResult); if (NS_SUCCEEDED(rc)) break; - LogFlowFunc (("Failed to connect (rc=%Rhrc (%#08x))\n", rc, rc)); + LogFlowFunc(("Failed to connect (rc=%Rhrc (%#08x))\n", rc, rc)); /* It's possible that the server gets shut down after we * successfully resolve the server name but before it @@ -298,12 +297,11 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, if (!startedOnce) { nsresult rc2 = - ipcServ->ResolveClientName (VBOXSVC_IPC_NAME, &serverID); + ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); if (NS_SUCCEEDED(rc2)) break; - LogFlowFunc (("Server seems to have terminated before " - "receiving our request. Will try again.\n")); + LogFlowFunc(("Server seems to have terminated before receiving our request. Will try again.\n")); } else break; @@ -312,7 +310,7 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, } while (0); - LogFlowFunc (("rc=%Rhrc (%#08x), vrc=%Rrc\n", rc, rc, vrc)); + LogFlowFunc(("rc=%Rhrc (%#08x), vrc=%Rrc\n", rc, rc, vrc)); LogFlowFuncLeave(); return rc; @@ -331,19 +329,19 @@ VirtualBoxConstructor (nsISupports *aOuter, REFNSIID aIID, * @return */ static NS_IMETHODIMP -VirtualBoxRegistration (nsIComponentManager *aCompMgr, - nsIFile *aPath, - const char *aLoaderStr, - const char *aType, - const nsModuleComponentInfo *aInfo) +VirtualBoxRegistration(nsIComponentManager *aCompMgr, + nsIFile *aPath, + const char *aLoaderStr, + const char *aType, + const nsModuleComponentInfo *aInfo) { nsCAutoString modulePath; - aPath->GetNativePath (modulePath); + aPath->GetNativePath(modulePath); nsCAutoString moduleTarget; - aPath->GetNativeTarget (moduleTarget); + aPath->GetNativeTarget(moduleTarget); - LogFlowFunc (("aPath=%s, aTarget=%s, aLoaderStr=%s, aType=%s\n", - modulePath.get(), moduleTarget.get(), aLoaderStr, aType)); + LogFlowFunc(("aPath=%s, aTarget=%s, aLoaderStr=%s, aType=%s\n", + modulePath.get(), moduleTarget.get(), aLoaderStr, aType)); nsresult rc = NS_OK; @@ -372,4 +370,4 @@ static const nsModuleComponentInfo components[] = } }; -NS_IMPL_NSGETMODULE (VirtualBox_Server_Module, components) +NS_IMPL_NSGETMODULE(VirtualBox_Server_Module, components) |