- Timestamp:
- May 22, 2007 2:19:37 AM (18 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r2587 r2754 231 231 VBoxSVCM_LIBS = \ 232 232 $(PATH_BIN)/VBoxXPCOM$(VBOX_SUFF_DLL) 233 VBoxSVCM_LDFLAGS.darwin = -install_name @executable_path/components/VBoxSVCM.dylib 233 VBoxSVCM_LDFLAGS.darwin = \ 234 -install_name @executable_path/components/VBoxSVCM.dylib \ 235 -exported_symbols_list $(PATH_TARGET)/VBoxSVCM.def 236 ifeq ($(BUILD_TARGET),darwin) 237 VBoxSVCM_ORDERDEPS += $(PATH_TARGET)/VBoxSVCM.def 238 VBoxSVCM_CLEAN += $(PATH_TARGET)/VBoxSVCM.def 239 $(PATH_TARGET)/VBoxSVCM.def: 240 $(RM) -f $@ 241 $(APPEND) $@ _NSGetModule 242 endif 234 243 235 244 endif # VBOX_WITH_XPCOM … … 270 279 VBoxC_INCS.win := \ 271 280 $(PATH_SUB_CURRENT) 272 VBoxC_LDFLAGS.darwin = -install_name @executable_path/components/VBoxC.dylib 281 VBoxC_LDFLAGS.darwin = \ 282 -install_name @executable_path/components/VBoxSVCM.dylib \ 283 -exported_symbols_list $(PATH_TARGET)/VBoxC.def 273 284 ifdef VBOX_USE_VCC80 274 285 VBoxC_LDFLAGS.win = /MANIFEST … … 277 288 VBoxC_LIBS = \ 278 289 $(TARGET_VBoxXPCOM) \ 279 $(PATH_BIN)/VBoxXPCOM$(VBOX_SUFF_DLL) \ 280 $(PATH_LIB)/VBoxXPCOMGlue$(VBOX_SUFF_LIB) 290 $(PATH_BIN)/VBoxXPCOM$(VBOX_SUFF_DLL) 291 ifneq ($(BUILD_TARGET),darwin) # Why is a XPCOM component linking with the glue? Because of the old com.cpp? 292 VBoxC_LIBS += $(PATH_LIB)/VBoxXPCOMGlue$(VBOX_SUFF_LIB) 293 endif 281 294 else 282 295 VBoxC_LIBS = \ … … 328 341 endif 329 342 343 ifeq ($(BUILD_TARGET),darwin) 344 VBoxC_ORDERDEPS += $(PATH_TARGET)/VBoxC.def 345 VBoxC_CLEAN += $(PATH_TARGET)/VBoxC.def 346 $(PATH_TARGET)/VBoxC.def: $(MAKEFILE_CURRENT) 347 $(RM) -f $@ 348 $(APPEND) $@ _NSGetModule 349 $(APPEND) $@ _VBoxDriversRegister 350 endif 330 351 331 352 # … … 387 408 VBoxCOM_COMMON_SOURCES = \ 388 409 glue/com.cpp \ 410 glue/initterm.cpp \ 389 411 glue/string.cpp \ 390 412 glue/EventQueue.cpp \ … … 487 509 VBoxXPCOMIPCC$(SUFF_DLL)=>../VBoxXPCOMIPCC$(SUFF_DLL) 488 510 endif 489 490 511 491 512 # generate -
trunk/src/VBox/Main/glue/com.cpp
r2672 r2754 1 1 /** @file 2 *3 2 * MS COM / XPCOM Abstraction Layer 4 3 */ … … 49 48 namespace com 50 49 { 51 52 HRESULT Initialize()53 {54 HRESULT rc = E_FAIL;55 56 #if !defined (VBOX_WITH_XPCOM)57 58 rc = CoInitializeEx (NULL, COINIT_MULTITHREADED |59 COINIT_DISABLE_OLE1DDE |60 COINIT_SPEED_OVER_MEMORY);61 62 #else63 64 /* Set VBOX_XPCOM_HOME if not present */65 if (!getenv("VBOX_XPCOM_HOME"))66 {67 /* get the executable path */68 char szPathProgram[1024];69 int rcVBox = RTPathProgram(szPathProgram, sizeof(szPathProgram));70 if (VBOX_SUCCESS(rcVBox))71 {72 setenv("VBOX_XPCOM_HOME", szPathProgram, 1);73 }74 }75 76 nsCOMPtr <nsIEventQueue> eventQ;77 rc = NS_GetMainEventQ (getter_AddRefs (eventQ));78 if (rc == NS_ERROR_NOT_INITIALIZED)79 {80 XPCOMGlueStartup (nsnull);81 nsCOMPtr <nsIServiceManager> serviceManager;82 rc = NS_InitXPCOM2 (getter_AddRefs (serviceManager), nsnull, nsnull);83 if (NS_SUCCEEDED (rc))84 {85 nsCOMPtr <nsIComponentRegistrar> registrar =86 do_QueryInterface (serviceManager, &rc);87 if (NS_SUCCEEDED (rc))88 registrar->AutoRegister (nsnull);89 }90 }91 92 #endif93 94 AssertComRC (rc);95 96 return rc;97 }98 99 void Shutdown()100 {101 #if !defined (VBOX_WITH_XPCOM)102 103 CoUninitialize();104 105 #else106 107 nsCOMPtr <nsIEventQueue> eventQ;108 nsresult rc = NS_GetMainEventQ (getter_AddRefs (eventQ));109 if (NS_SUCCEEDED (rc))110 {111 BOOL isOnMainThread = FALSE;112 eventQ->IsOnCurrentThread (&isOnMainThread);113 eventQ = nsnull; /* early release */114 if (isOnMainThread)115 {116 /* only the main thread needs to uninitialize XPCOM */117 NS_ShutdownXPCOM (nsnull);118 XPCOMGlueShutdown();119 }120 }121 122 #endif123 }124 50 125 51 void GetInterfaceNameByIID (const GUID &aIID, BSTR *aName) -
trunk/src/VBox/Main/glue/initterm.cpp
r2751 r2754 1 1 /** @file 2 * 3 * MS COM / XPCOM Abstraction Layer 2 * MS COM / XPCOM Abstraction Layer - Initialization and Termination. 4 3 */ 5 4 … … 123 122 } 124 123 125 void GetInterfaceNameByIID (const GUID &aIID, BSTR *aName)126 {127 Assert (aName);128 if (!aName)129 return;130 131 *aName = NULL;132 133 #if !defined (VBOX_WITH_XPCOM)134 135 LONG rc;136 LPOLESTR iidStr = NULL;137 if (StringFromIID (aIID, &iidStr) == S_OK)138 {139 HKEY ifaceKey;140 rc = RegOpenKeyExW (HKEY_CLASSES_ROOT, L"Interface",141 0, KEY_QUERY_VALUE, &ifaceKey);142 if (rc == ERROR_SUCCESS)143 {144 HKEY iidKey;145 rc = RegOpenKeyExW (ifaceKey, iidStr, 0, KEY_QUERY_VALUE, &iidKey);146 if (rc == ERROR_SUCCESS)147 {148 /* determine the size and type */149 DWORD sz, type;150 rc = RegQueryValueExW (iidKey, NULL, NULL, &type, NULL, &sz);151 if (rc == ERROR_SUCCESS && type == REG_SZ)152 {153 /* query the value to BSTR */154 *aName = SysAllocStringLen (NULL, (sz + 1) /155 sizeof (TCHAR) + 1);156 rc = RegQueryValueExW (iidKey, NULL, NULL, NULL,157 (LPBYTE) *aName, &sz);158 if (rc != ERROR_SUCCESS)159 {160 SysFreeString (*aName);161 aName = NULL;162 }163 }164 RegCloseKey (iidKey);165 }166 RegCloseKey (ifaceKey);167 }168 CoTaskMemFree (iidStr);169 }170 171 #else172 173 nsresult rv;174 nsCOMPtr <nsIInterfaceInfoManager> iim =175 do_GetService (NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID, &rv);176 if (NS_SUCCEEDED (rv))177 {178 nsCOMPtr <nsIInterfaceInfo> iinfo;179 rv = iim->GetInfoForIID (&aIID, getter_AddRefs (iinfo));180 if (NS_SUCCEEDED (rv))181 {182 const char *iname = NULL;183 iinfo->GetNameShared (&iname);184 char *utf8IName = NULL;185 if (VBOX_SUCCESS (RTStrCurrentCPToUtf8 (&utf8IName, iname)))186 {187 PRTUCS2 ucs2IName = NULL;188 if (VBOX_SUCCESS (RTStrUtf8ToUcs2 (&ucs2IName, utf8IName)))189 {190 *aName = SysAllocString ((OLECHAR *) ucs2IName);191 RTStrUcs2Free (ucs2IName);192 }193 RTStrFree (utf8IName);194 }195 }196 }197 198 #endif199 }200 201 124 }; // namespace com
Note:
See TracChangeset
for help on using the changeset viewer.