Changeset 19375 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 5, 2009 1:28:56 PM (16 years ago)
- Location:
- trunk/src/VBox/Main/cbinding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/tstXPCOMCCall.c
r19085 r19375 31 31 #include <unistd.h> 32 32 33 static char *nsIDToString(nsID *guid);34 33 static void listVMs(IVirtualBox *virtualBox, ISession *session, nsIEventQueue *queue); 35 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID*machineId, nsIEventQueue *queue);36 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID*id, nsIEventQueue *queue);34 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, PRUnichar *machineId, nsIEventQueue *queue); 35 static void startVM(IVirtualBox *virtualBox, ISession *session, PRUnichar *id, nsIEventQueue *queue); 37 36 38 37 int volatile g_refcount = 0; 39 40 /**41 * Helper function to convert an nsID into a human readable string.42 *43 * @returns result string, allocated. Has to be freed using free()44 * @param guid Pointer to nsID that will be converted.45 */46 static char *nsIDToString(nsID *guid)47 {48 /* Avoid magic number 39. Yes, sizeof "literal" includes the NUL byte. */49 char *res = malloc(sizeof "{12345678-1234-1234-1234-123456789012}");50 51 if (res != NULL)52 {53 sprintf(res, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",54 (unsigned)guid->m0, (unsigned)guid->m1, (unsigned)guid->m2,55 (unsigned)guid->m3[0], (unsigned)guid->m3[1],56 (unsigned)guid->m3[2], (unsigned)guid->m3[3],57 (unsigned)guid->m3[4], (unsigned)guid->m3[5],58 (unsigned)guid->m3[6], (unsigned)guid->m3[7]);59 }60 return res;61 }62 38 63 39 /** … … 275 251 * @param queue handle to the event queue 276 252 */ 277 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID*machineId, nsIEventQueue *queue)253 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, PRUnichar *machineId, nsIEventQueue *queue) 278 254 { 279 255 IConsole *console = NULL; … … 402 378 } 403 379 404 405 { 406 nsID *iid = NULL; 407 char *uuidString; 408 409 machine->vtbl->GetId(machine, &iid); 410 uuidString = nsIDToString(iid); 411 printf("\tUUID: %s\n", uuidString); 412 413 free(uuidString); 414 g_pVBoxFuncs->pfnComUnallocMem(iid); 380 { 381 PRUnichar *uuidUtf16 = NULL; 382 char *uuidUtf8 = NULL; 383 384 machine->vtbl->GetId(machine, &uuidUtf16); 385 g_pVBoxFuncs->pfnUtf16ToUtf8(uuidUtf16, &uuidUtf8); 386 printf("\tUUID: %s\n", uuidUtf8); 387 388 g_pVBoxFuncs->pfnUtf8Free(uuidUtf8); 389 g_pVBoxFuncs->pfnUtf16Free(uuidUtf16); 415 390 } 416 391 … … 470 445 if (machine) 471 446 { 472 nsID *iid= NULL;473 474 machine->vtbl->GetId(machine, & iid);475 startVM(virtualBox, session, iid, queue);476 477 g_pVBoxFuncs->pfn ComUnallocMem(iid);447 PRUnichar *uuidUtf16 = NULL; 448 449 machine->vtbl->GetId(machine, &uuidUtf16); 450 startVM(virtualBox, session, uuidUtf16, queue); 451 452 g_pVBoxFuncs->pfnUtf16Free(uuidUtf16); 478 453 } 479 454 } … … 503 478 */ 504 479 505 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID*id, nsIEventQueue *queue)480 static void startVM(IVirtualBox *virtualBox, ISession *session, PRUnichar *id, nsIEventQueue *queue) 506 481 { 507 482 nsresult rc; … … 539 514 { 540 515 PRBool completed; 541 nsresultresultCode;516 PRInt32 resultCode; 542 517 543 518 printf("Waiting for the remote session to open...\n"); -
trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c
r19081 r19375 30 30 #include <stdlib.h> 31 31 32 static char *nsIDToString(nsID *guid);33 32 static void listVMs(IVirtualBox *virtualBox, ISession *session); 34 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id); 35 36 /** 37 * Helper function to convert an nsID into a human readable string. 38 * 39 * @returns result string, allocated. Has to be freed using free() 40 * @param guid Pointer to nsID that will be converted. 41 */ 42 static char *nsIDToString(nsID *guid) 43 { 44 /* Avoid magic number 39. Yes, sizeof "literal" includes the NUL byte. */ 45 char *res = malloc(sizeof "{12345678-1234-1234-1234-123456789012}"); 46 47 if (res != NULL) 48 { 49 sprintf(res, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", 50 (unsigned)guid->m0, (unsigned)guid->m1, (unsigned)guid->m2, 51 (unsigned)guid->m3[0], (unsigned)guid->m3[1], 52 (unsigned)guid->m3[2], (unsigned)guid->m3[3], 53 (unsigned)guid->m3[4], (unsigned)guid->m3[5], 54 (unsigned)guid->m3[6], (unsigned)guid->m3[7]); 55 } 56 return res; 57 } 33 static void startVM(IVirtualBox *virtualBox, ISession *session, PRUnichar *id); 58 34 59 35 /** … … 129 105 130 106 { 131 nsID *iid= NULL;132 char *uuidString;133 134 machine->vtbl->GetId(machine, & iid);135 uuidString = nsIDToString(iid);136 printf("\tUUID: %s\n", uuid String);137 138 free(uuidString);139 g_pVBoxFuncs->pfn ComUnallocMem(iid);107 PRUnichar *uuidUtf16 = NULL; 108 char *uuidUtf8 = NULL; 109 110 machine->vtbl->GetId(machine, &uuidUtf16); 111 g_pVBoxFuncs->pfnUtf16ToUtf8(uuidUtf16, &uuidUtf8); 112 printf("\tUUID: %s\n", uuidUtf8); 113 114 g_pVBoxFuncs->pfnUtf8Free(uuidUtf8); 115 g_pVBoxFuncs->pfnUtf16Free(uuidUtf16); 140 116 } 141 117 … … 195 171 if (machine) 196 172 { 197 nsID *iid= NULL;198 199 machine->vtbl->GetId(machine, & iid);200 startVM(virtualBox, session, iid);201 202 g_pVBoxFuncs->pfn ComUnallocMem(iid);173 PRUnichar *uuidUtf16 = NULL; 174 175 machine->vtbl->GetId(machine, &uuidUtf16); 176 startVM(virtualBox, session, uuidUtf16); 177 178 g_pVBoxFuncs->pfnUtf16Free(uuidUtf16); 203 179 } 204 180 } … … 226 202 * @param id identifies the machine to start 227 203 */ 228 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID*id)204 static void startVM(IVirtualBox *virtualBox, ISession *session, PRUnichar *id) 229 205 { 230 206 nsresult rc; … … 262 238 { 263 239 PRBool completed; 264 nsresultresultCode;240 PRInt32 resultCode; 265 241 266 242 printf("Waiting for the remote session to open...\n");
Note:
See TracChangeset
for help on using the changeset viewer.