- Timestamp:
- Apr 6, 2009 4:15:17 PM (16 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/tstXPCOMCCall.c
r18726 r18786 29 29 #include <string.h> 30 30 #include <stdlib.h> 31 #include <unistd.h> 31 32 32 33 static char *nsIDToString(nsID *guid); 33 34 static void listVMs(IVirtualBox *virtualBox, ISession *session); 34 35 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id); 36 37 int refcount = 0; 35 38 36 39 /** … … 57 60 } 58 61 62 static const char *GetStateName(PRUint32 machineState) 63 { 64 switch (machineState) 65 { 66 case MachineState_Null: return "<null>"; 67 case MachineState_PoweredOff: return "PoweredOff"; 68 case MachineState_Saved: return "Saved"; 69 case MachineState_Aborted: return "Aborted"; 70 case MachineState_Running: return "Running"; 71 case MachineState_Paused: return "Paused"; 72 case MachineState_Stuck: return "Stuck"; 73 case MachineState_Starting: return "Starting"; 74 case MachineState_Stopping: return "Stopping"; 75 case MachineState_Saving: return "Saving"; 76 case MachineState_Restoring: return "Restoring"; 77 case MachineState_Discarding: return "Discarding"; 78 case MachineState_SettingUp: return "SettingUp"; 79 default: return "no idea"; 80 } 81 } 82 83 nsresult OnMousePointerShapeChange( 84 IConsoleCallback *this_, 85 PRBool visible, 86 PRBool alpha, 87 PRUint32 xHot, 88 PRUint32 yHot, 89 PRUint32 width, 90 PRUint32 height, 91 PRUint8 * shape 92 ) { 93 printf("%d here\n",__LINE__); 94 return 0; 95 } 96 97 nsresult OnMouseCapabilityChange( 98 IConsoleCallback *this_, 99 PRBool supportsAbsolute, 100 PRBool needsHostCursor 101 ) { 102 printf("%d here\n",__LINE__); 103 return 0; 104 } 105 106 nsresult OnKeyboardLedsChange( 107 IConsoleCallback *this_, 108 PRBool numLock, 109 PRBool capsLock, 110 PRBool scrollLock 111 ) { 112 printf("%d here\n",__LINE__); 113 return 0; 114 } 115 116 nsresult OnStateChange( 117 IConsoleCallback *this_, 118 PRUint32 state 119 ) { 120 printf("%d here\n",__LINE__); 121 printf("OnStateChange: %s\n", GetStateName(state)); 122 fflush(stdout); 123 return 0; 124 } 125 126 nsresult OnAdditionsStateChange(IConsoleCallback *this_ ) 127 { 128 printf("%d here\n",__LINE__); 129 return 0; 130 } 131 132 nsresult OnDVDDriveChange(IConsoleCallback *this_ ) 133 { 134 printf("%d here\n",__LINE__); 135 return 0; 136 } 137 138 nsresult OnFloppyDriveChange(IConsoleCallback *this_ ) 139 { 140 printf("%d here\n",__LINE__); 141 return 0; 142 } 143 144 nsresult OnNetworkAdapterChange( 145 IConsoleCallback *this_, 146 INetworkAdapter * networkAdapter 147 ) { 148 printf("%d here\n",__LINE__); 149 return 0; 150 } 151 152 nsresult OnSerialPortChange( 153 IConsoleCallback *this_, 154 ISerialPort * serialPort 155 ) { 156 printf("%d here\n",__LINE__); 157 return 0; 158 } 159 160 nsresult OnParallelPortChange( 161 IConsoleCallback *this_, 162 IParallelPort * parallelPort 163 ) { 164 printf("%d here\n",__LINE__); 165 return 0; 166 } 167 168 nsresult OnStorageControllerChange(IConsoleCallback *this_ ) 169 { 170 printf("%d here\n",__LINE__); 171 return 0; 172 } 173 174 nsresult OnVRDPServerChange(IConsoleCallback *this_ ) 175 { 176 printf("%d here\n",__LINE__); 177 return 0; 178 } 179 180 nsresult OnUSBControllerChange(IConsoleCallback *this_ ) 181 { 182 printf("%d here\n",__LINE__); 183 return 0; 184 } 185 186 nsresult OnUSBDeviceStateChange( 187 IConsoleCallback *this_, 188 IUSBDevice * device, 189 PRBool attached, 190 IVirtualBoxErrorInfo * error 191 ) { 192 printf("%d here\n",__LINE__); 193 return 0; 194 } 195 196 nsresult OnSharedFolderChange( 197 IConsoleCallback *this_, 198 PRUint32 scope 199 ) { 200 printf("%d here\n",__LINE__); 201 return 0; 202 } 203 204 nsresult OnRuntimeError( 205 IConsoleCallback *this_, 206 PRBool fatal, 207 PRUnichar * id, 208 PRUnichar * message 209 ) { 210 printf("%d here\n",__LINE__); 211 return 0; 212 } 213 214 nsresult OnCanShowWindow( 215 IConsoleCallback *this_, 216 PRBool * canShow 217 ) { 218 printf("%d here\n",__LINE__); 219 return 0; 220 } 221 222 nsresult OnShowWindow( 223 IConsoleCallback *this_, 224 PRUint64 * winId 225 ) { 226 printf("%d here\n",__LINE__); 227 return 0; 228 } 229 230 231 nsresult AddRef(IConsoleCallback *this_) 232 { 233 printf("AddRef\n"); 234 refcount++; 235 return refcount; 236 } 237 238 nsresult Release(IConsoleCallback *this_) 239 { 240 printf("Release\n"); 241 refcount--; 242 return refcount; 243 } 244 245 nsresult QueryInterface(IConsoleCallback *this_, const nsID *iid, void **resultp) 246 { 247 printf("QueryInterface\n"); 248 refcount++; 249 *resultp = this_; 250 return 0; 251 } 252 253 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID *machineId) 254 { 255 IConsole *console = NULL; 256 nsresult rc; 257 258 rc = virtualBox->vtbl->OpenExistingSession(virtualBox, session, machineId); 259 session->vtbl->GetConsole(session, &console); 260 if (console) { 261 IConsoleCallback *consoleCallback = NULL; 262 263 consoleCallback = calloc(1, sizeof(IConsoleCallback)); 264 consoleCallback->vtbl = calloc(1, sizeof(struct IConsoleCallback_vtbl)); 265 266 if (consoleCallback && consoleCallback->vtbl) { 267 268 consoleCallback->vtbl->nsisupports.AddRef = &AddRef; 269 consoleCallback->vtbl->nsisupports.Release = &Release; 270 consoleCallback->vtbl->nsisupports.QueryInterface = &QueryInterface; 271 consoleCallback->vtbl->OnMousePointerShapeChange = &OnMousePointerShapeChange; 272 consoleCallback->vtbl->OnMouseCapabilityChange = &OnMouseCapabilityChange; 273 consoleCallback->vtbl->OnKeyboardLedsChange =&OnKeyboardLedsChange; 274 consoleCallback->vtbl->OnStateChange = &OnStateChange; 275 consoleCallback->vtbl->OnAdditionsStateChange = &OnAdditionsStateChange; 276 consoleCallback->vtbl->OnDVDDriveChange = &OnDVDDriveChange; 277 consoleCallback->vtbl->OnFloppyDriveChange = &OnFloppyDriveChange; 278 consoleCallback->vtbl->OnNetworkAdapterChange = &OnNetworkAdapterChange; 279 consoleCallback->vtbl->OnSerialPortChange = &OnSerialPortChange; 280 consoleCallback->vtbl->OnParallelPortChange = &OnParallelPortChange; 281 consoleCallback->vtbl->OnStorageControllerChange = &OnStorageControllerChange; 282 consoleCallback->vtbl->OnVRDPServerChange = &OnVRDPServerChange; 283 consoleCallback->vtbl->OnUSBControllerChange = &OnUSBControllerChange; 284 consoleCallback->vtbl->OnUSBDeviceStateChange = &OnUSBDeviceStateChange; 285 consoleCallback->vtbl->OnSharedFolderChange = &OnSharedFolderChange; 286 consoleCallback->vtbl->OnRuntimeError = &OnRuntimeError; 287 consoleCallback->vtbl->OnCanShowWindow = &OnCanShowWindow; 288 consoleCallback->vtbl->OnShowWindow = &OnShowWindow; 289 290 printf("%d here\n",__LINE__); 291 console->vtbl->RegisterCallback(console, consoleCallback); 292 printf("%d here\n",__LINE__); 293 294 int run = 10; 295 while (run-- > 0) { 296 sleep(1); 297 printf("waiting here:%d\n",run); 298 fflush(stdout); 299 } 300 console->vtbl->UnregisterCallback(console, consoleCallback); 301 } 302 //free(consoleCallback->vtbl); 303 //free(consoleCallback); 304 } 305 session->vtbl->Close((void *)session); 306 } 307 59 308 /** 60 309 * List the registered VMs. … … 198 447 199 448 machine->vtbl->GetId(machine, &iid); 200 startVM(virtualBox, session, iid); 449 //startVM(virtualBox, session, iid); 450 registerCallBack(virtualBox, session, iid); 201 451 202 452 g_pVBoxFuncs->pfnComUnallocMem(iid); … … 226 476 * @param id identifies the machine to start 227 477 */ 478 #if 0 228 479 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id) 229 480 { … … 298 549 machine->vtbl->nsisupports.Release((void *)machine); 299 550 } 551 #endif 300 552 301 553 /* Main - Start the ball rolling. */
Note:
See TracChangeset
for help on using the changeset viewer.