Changeset 17712 in vbox
- Timestamp:
- Mar 11, 2009 5:13:57 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 44224
- Location:
- trunk/src/VBox/Main/cbinding
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp
r17304 r17712 40 40 static nsIComponentManager *manager; 41 41 42 VBOXXPCOMC_DECL(int) 42 void VBoxComUninitialize(void); 43 44 int 43 45 VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString) 44 46 { … … 46 48 } 47 49 48 VBOXXPCOMC_DECL(int) 50 int 49 51 VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString) 50 52 { … … 52 54 } 53 55 54 VBOXXPCOMC_DECL(void) 56 void 55 57 VBoxUtf16Free(PRUnichar *pwszString) 56 58 { … … 58 60 } 59 61 60 VBOXXPCOMC_DECL(void) 62 void 61 63 VBoxUtf8Free(char *pszString) 62 64 { … … 64 66 } 65 67 66 VBOXXPCOMC_DECL(void) 68 void 67 69 VBoxComUnallocMem(void *ptr) 68 70 { … … 73 75 } 74 76 75 VBOXXPCOMC_DECL(int) 77 int 76 78 VBoxSetEnv(const char *pszVar, const char *pszValue) 77 79 { … … 79 81 } 80 82 81 VBOXXPCOMC_DECL(const char *) 83 const char * 82 84 VBoxGetEnv(const char *pszVar) 83 85 { … … 85 87 } 86 88 87 VBOXXPCOMC_DECL(void) 89 void 88 90 VBoxComInitialize(IVirtualBox **virtualBox, ISession **session) 89 91 { … … 139 141 } 140 142 141 VBOXXPCOMC_DECL(void) 143 void 142 144 VBoxComUninitialize(void) 143 145 { -
trunk/src/VBox/Main/cbinding/tstLinuxC.c
r17304 r17712 27 27 #include <sys/stat.h> 28 28 #include "VirtualBox_CXPCOM.h" 29 30 PCVBOXXPCOM g_pVBoxFuncs = NULL; 29 31 30 32 static char *nsIDToString(nsID *guid); … … 114 116 115 117 machine->vtbl->GetName(machine, &machineNameUtf16); 116 VBoxUtf16ToUtf8(machineNameUtf16,&machineName);118 g_pVBoxFuncs->pfnUtf16ToUtf8(machineNameUtf16,&machineName); 117 119 printf("\tName: %s\n", machineName); 118 120 119 VBoxUtf8Free(machineName);120 VBoxComUnallocMem(machineNameUtf16);121 g_pVBoxFuncs->pfnUtf8Free(machineName); 122 g_pVBoxFuncs->pfnComUnallocMem(machineNameUtf16); 121 123 } 122 124 else … … 135 137 136 138 free(uuidString); 137 VBoxComUnallocMem(iid);139 g_pVBoxFuncs->pfnComUnallocMem(iid); 138 140 } 139 141 … … 145 147 146 148 machine->vtbl->GetSettingsFilePath(machine, &configFile); 147 VBoxUtf16ToUtf8(configFile, &configFile1);149 g_pVBoxFuncs->pfnUtf16ToUtf8(configFile, &configFile1); 148 150 printf("\tConfig file: %s\n", configFile1); 149 151 150 152 free(configFile1); 151 VBoxComUnallocMem(configFile);153 g_pVBoxFuncs->pfnComUnallocMem(configFile); 152 154 } 153 155 … … 168 170 virtualBox->vtbl->GetGuestOSType(virtualBox, typeId, &osType); 169 171 osType->vtbl->GetDescription(osType, &osNameUtf16); 170 VBoxUtf16ToUtf8(osNameUtf16,&osName);172 g_pVBoxFuncs->pfnUtf16ToUtf8(osNameUtf16,&osName); 171 173 printf("\tGuest OS: %s\n\n", osName); 172 174 173 175 osType->vtbl->nsisupports.Release((void *)osType); 174 VBoxUtf8Free(osName);175 VBoxComUnallocMem(osNameUtf16);176 VBoxComUnallocMem(typeId);176 g_pVBoxFuncs->pfnUtf8Free(osName); 177 g_pVBoxFuncs->pfnComUnallocMem(osNameUtf16); 178 g_pVBoxFuncs->pfnComUnallocMem(typeId); 177 179 } 178 180 } … … 198 200 startVM(virtualBox, session, iid); 199 201 200 VBoxComUnallocMem(iid);202 g_pVBoxFuncs->pfnComUnallocMem(iid); 201 203 } 202 204 } … … 240 242 } 241 243 242 VBoxUtf8ToUtf16("gui", &sessionType);244 g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType); 243 245 244 246 rc = virtualBox->vtbl->OpenRemoteSession( … … 251 253 ); 252 254 253 VBoxUtf16Free(sessionType);255 g_pVBoxFuncs->pfnUtf16Free(sessionType); 254 256 255 257 if (NS_FAILED(rc)) … … 280 282 progress->vtbl->GetErrorInfo(progress, &errorInfo); 281 283 errorInfo->vtbl->GetText(errorInfo, &textUtf16); 282 VBoxUtf16ToUtf8(textUtf16, &text);284 g_pVBoxFuncs->pfnUtf16ToUtf8(textUtf16, &text); 283 285 printf("Error: %s\n", text); 284 286 285 VBoxComUnallocMem(textUtf16);286 VBoxUtf8Free(text);287 g_pVBoxFuncs->pfnComUnallocMem(textUtf16); 288 g_pVBoxFuncs->pfnUtf8Free(text); 287 289 } 288 290 else … … 309 311 nsresult rc; /* Result code of various function (method) calls. */ 310 312 311 /* 312 * Guess where VirtualBox is installed not mentioned in the environment. 313 * (This will be moved to VBoxComInitialize later.) 314 */ 315 316 if (!VBoxGetEnv("VBOX_APP_HOME")) 313 if (!getenv("VBOX_APP_HOME")) 317 314 { 318 315 if (stat("/opt/VirtualBox/VBoxXPCOMC.so", &stIgnored) == 0) 319 316 { 320 VBoxSetEnv("VBOX_APP_HOME","/opt/VirtualBox/");317 setenv("VBOX_APP_HOME","/opt/VirtualBox/", 0 /* no need to overwrite */); 321 318 } 322 319 if (stat("/usr/lib/virtualbox/VBoxXPCOMC.so", &stIgnored) == 0) 323 320 { 324 VBoxSetEnv("VBOX_APP_HOME","/usr/lib/virtualbox/");321 setenv("VBOX_APP_HOME","/usr/lib/virtualbox/", 0 /* no need to overwrite */); 325 322 } 326 323 } … … 329 326 330 327 /* 331 * VBoxComInitialize does all the necessary startup action and 332 * provides us with pointers to vbox and session handles. 333 * It should be matched by a call to VBoxComUninitialize(vbox) 328 * VBoxGetXPCOMCFunctions() is the only function exported by 329 * VBoxXPCOMC.so. This functions gives you the pointer to the 330 * function table (g_pVBoxFuncs). 331 * 332 * g_pVBoxFuncs->pfnComInitialize does all the necessary startup 333 * action and provides us with pointers to vbox and session handles. 334 * It should be matched by a call to g_pVBoxFuncs->pfnComUninitialize() 334 335 * when done. 335 336 */ 336 337 337 VBoxComInitialize(&vbox, &session); 338 g_pVBoxFuncs = VBoxGetXPCOMCFunctions(VBOX_XPCOMC_VERSION); 339 g_pVBoxFuncs->pfnComInitialize(&vbox, &session); 338 340 339 341 if (vbox == NULL) … … 375 377 { 376 378 char *version = NULL; 377 VBoxUtf16ToUtf8(versionUtf16, &version);379 g_pVBoxFuncs->pfnUtf16ToUtf8(versionUtf16, &version); 378 380 printf("\tVersion: %s\n", version); 379 VBoxUtf8Free(version);380 VBoxComUnallocMem(versionUtf16);381 g_pVBoxFuncs->pfnUtf8Free(version); 382 g_pVBoxFuncs->pfnComUnallocMem(versionUtf16); 381 383 } 382 384 else … … 392 394 { 393 395 char *homefolder = NULL; 394 VBoxUtf16ToUtf8(homefolderUtf16, &homefolder);396 g_pVBoxFuncs->pfnUtf16ToUtf8(homefolderUtf16, &homefolder); 395 397 printf("\tHomeFolder: %s\n", homefolder); 396 VBoxUtf8Free(homefolder);397 VBoxComUnallocMem(homefolderUtf16);398 g_pVBoxFuncs->pfnUtf8Free(homefolder); 399 g_pVBoxFuncs->pfnComUnallocMem(homefolderUtf16); 398 400 } 399 401 else … … 412 414 */ 413 415 414 VBoxComUninitialize();416 g_pVBoxFuncs->pfnComUninitialize(); 415 417 printf("Finished Main\n"); 416 418 -
trunk/src/VBox/Main/cbinding/xpcidl.xsl
r17570 r17712 546 546 extern "C" { 547 547 #endif 548 549 /* Initialize/Uninitialize XPCOM. */550 VBOXXPCOMC_DECL(void) VBoxComInitialize(IVirtualBox **virtualBox, ISession **session);551 VBOXXPCOMC_DECL(void) VBoxComUninitialize(void);552 553 /* Deallocation functions. */554 VBOXXPCOMC_DECL(void) VBoxComUnallocMem(void *ptr);555 VBOXXPCOMC_DECL(void) VBoxUtf16Free(PRUnichar *pwszString);556 VBOXXPCOMC_DECL(void) VBoxUtf8Free(char *pszString);557 558 /* Converting to and from UTF-8 and UTF-16. */559 VBOXXPCOMC_DECL(int) VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString);560 VBOXXPCOMC_DECL(int) VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString);561 562 /* Getting and setting the environment variables. */563 VBOXXPCOMC_DECL(const char *) VBoxGetEnv(const char *pszVar);564 VBOXXPCOMC_DECL(int) VBoxSetEnv(const char *pszVar, const char *pszValue);565 548 566 549
Note:
See TracChangeset
for help on using the changeset viewer.