Changeset 55437 in vbox
- Timestamp:
- Apr 27, 2015 9:35:19 AM (9 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
-
Frontends/VBoxHeadless/VBoxHeadless.cpp (modified) (10 diffs)
-
Main/idl/VirtualBox.xidl (modified) (2 diffs)
-
Main/include/ConsoleImpl.h (modified) (2 diffs)
-
Main/include/MachineImpl.h (modified) (2 diffs)
-
Main/src-client/ConsoleImpl.cpp (modified) (9 diffs)
-
Main/src-server/MachineImpl.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r51618 r55437 5 5 6 6 /* 7 * Copyright (C) 2006-201 4Oracle Corporation7 * Copyright (C) 2006-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 128 128 129 129 /** 130 * Handler for globalevents.130 * Handler for machine events. 131 131 */ 132 class VirtualBoxEventListener132 class ConsoleEventListener 133 133 { 134 134 public: 135 VirtualBoxEventListener() 136 { 137 mfNoLoggedInUsers = true; 138 } 139 140 virtual ~VirtualBoxEventListener() 135 ConsoleEventListener() : 136 mLastVRDEPort(-1), 137 m_fIgnorePowerOffEvents(false), 138 m_fNoLoggedInUsers(true) 139 { 140 } 141 142 virtual ~ConsoleEventListener() 141 143 { 142 144 } … … 155 157 switch (aType) 156 158 { 159 case VBoxEventType_OnMouseCapabilityChanged: 160 { 161 162 ComPtr<IMouseCapabilityChangedEvent> mccev = aEvent; 163 Assert(!mccev.isNull()); 164 165 BOOL fSupportsAbsolute = false; 166 mccev->COMGETTER(SupportsAbsolute)(&fSupportsAbsolute); 167 168 /* Emit absolute mouse event to actually enable the host mouse cursor. */ 169 if (fSupportsAbsolute && gConsole) 170 { 171 ComPtr<IMouse> mouse; 172 gConsole->COMGETTER(Mouse)(mouse.asOutParam()); 173 if (mouse) 174 { 175 mouse->PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0); 176 } 177 } 178 break; 179 } 180 case VBoxEventType_OnStateChanged: 181 { 182 ComPtr<IStateChangedEvent> scev = aEvent; 183 Assert(scev); 184 185 MachineState_T machineState; 186 scev->COMGETTER(State)(&machineState); 187 188 /* Terminate any event wait operation if the machine has been 189 * PoweredDown/Saved/Aborted. */ 190 if (machineState < MachineState_Running && !m_fIgnorePowerOffEvents) 191 { 192 g_fTerminateFE = true; 193 gEventQ->interruptEventQueueProcessing(); 194 } 195 196 break; 197 } 198 case VBoxEventType_OnVRDEServerInfoChanged: 199 { 200 ComPtr<IVRDEServerInfoChangedEvent> rdicev = aEvent; 201 Assert(rdicev); 202 203 if (gConsole) 204 { 205 ComPtr<IVRDEServerInfo> info; 206 gConsole->COMGETTER(VRDEServerInfo)(info.asOutParam()); 207 if (info) 208 { 209 LONG port; 210 info->COMGETTER(Port)(&port); 211 if (port != mLastVRDEPort) 212 { 213 if (port == -1) 214 RTPrintf("VRDE server is inactive.\n"); 215 else if (port == 0) 216 RTPrintf("VRDE server failed to start.\n"); 217 else 218 RTPrintf("VRDE server is listening on port %d.\n", port); 219 220 mLastVRDEPort = port; 221 } 222 } 223 } 224 break; 225 } 226 case VBoxEventType_OnCanShowWindow: 227 { 228 ComPtr<ICanShowWindowEvent> cswev = aEvent; 229 Assert(cswev); 230 cswev->AddVeto(NULL); 231 break; 232 } 233 case VBoxEventType_OnShowWindow: 234 { 235 ComPtr<IShowWindowEvent> swev = aEvent; 236 Assert(swev); 237 swev->COMSETTER(WinId)(0); 238 break; 239 } 157 240 case VBoxEventType_OnGuestPropertyChanged: 158 241 { … … 166 249 { 167 250 hrc = gConsole->COMGETTER(Machine)(pMachine.asOutParam()); 168 if (SUCCEEDED(hrc) && pMachine) 169 { 170 Bstr gpMachineId, machineId; 171 hrc = pMachine->COMGETTER(Id)(gpMachineId.asOutParam()); 172 AssertComRC(hrc); 173 hrc = pChangedEvent->COMGETTER(MachineId)(machineId.asOutParam()); 174 AssertComRC(hrc); 175 if (gpMachineId != machineId) 176 hrc = VBOX_E_OBJECT_NOT_FOUND; 177 } 251 if (FAILED(hrc) || !pMachine) 252 hrc = VBOX_E_OBJECT_NOT_FOUND; 178 253 } 179 254 else … … 216 291 LogRelFlow(("VRDE: hrc=%Rhrc: Host %s disconnecting clients (current host state known: %s)\n", 217 292 hrc, fProcessDisconnectOnGuestLogout ? "will handle" : "does not handle", 218 m fNoLoggedInUsers ? "No users logged in" : "Users logged in"));293 m_fNoLoggedInUsers ? "No users logged in" : "Users logged in")); 219 294 220 295 if (fProcessDisconnectOnGuestLogout) 221 296 { 222 297 bool fDropConnection = false; 223 if (!m fNoLoggedInUsers) /* Only if the property really changes. */298 if (!m_fNoLoggedInUsers) /* Only if the property really changes. */ 224 299 { 225 300 if ( utf8Value == "true" … … 228 303 || utf8Value.isEmpty()) 229 304 { 230 m fNoLoggedInUsers = true;305 m_fNoLoggedInUsers = true; 231 306 fDropConnection = true; 232 307 } 233 308 } 234 309 else if (utf8Value == "false") 235 m fNoLoggedInUsers = false;310 m_fNoLoggedInUsers = false; 236 311 /* Guest property got deleted due to reset, 237 * take the shortcut without touching the m fNoLoggedInUsers312 * take the shortcut without touching the m_fNoLoggedInUsers 238 313 * state. */ 239 314 else if (utf8Value.isEmpty()) 240 315 fDropConnection = true; 241 316 242 LogRelFlow(("VRDE: szNoLoggedInUsers=%s, m fNoLoggedInUsers=%RTbool, fDropConnection=%RTbool\n",243 utf8Value.c_str(), m fNoLoggedInUsers, fDropConnection));317 LogRelFlow(("VRDE: szNoLoggedInUsers=%s, m_fNoLoggedInUsers=%RTbool, fDropConnection=%RTbool\n", 318 utf8Value.c_str(), m_fNoLoggedInUsers, fDropConnection)); 244 319 245 320 if (fDropConnection) … … 283 358 AssertFailed(); 284 359 } 285 286 return S_OK;287 }288 289 private:290 291 bool mfNoLoggedInUsers;292 };293 294 /**295 * Handler for machine events.296 */297 class ConsoleEventListener298 {299 public:300 ConsoleEventListener() :301 mLastVRDEPort(-1),302 m_fIgnorePowerOffEvents(false)303 {304 }305 306 virtual ~ConsoleEventListener()307 {308 }309 310 HRESULT init()311 {312 return S_OK;313 }314 315 void uninit()316 {317 }318 319 STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent)320 {321 switch (aType)322 {323 case VBoxEventType_OnMouseCapabilityChanged:324 {325 326 ComPtr<IMouseCapabilityChangedEvent> mccev = aEvent;327 Assert(!mccev.isNull());328 329 BOOL fSupportsAbsolute = false;330 mccev->COMGETTER(SupportsAbsolute)(&fSupportsAbsolute);331 332 /* Emit absolute mouse event to actually enable the host mouse cursor. */333 if (fSupportsAbsolute && gConsole)334 {335 ComPtr<IMouse> mouse;336 gConsole->COMGETTER(Mouse)(mouse.asOutParam());337 if (mouse)338 {339 mouse->PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);340 }341 }342 break;343 }344 case VBoxEventType_OnStateChanged:345 {346 ComPtr<IStateChangedEvent> scev = aEvent;347 Assert(scev);348 349 MachineState_T machineState;350 scev->COMGETTER(State)(&machineState);351 352 /* Terminate any event wait operation if the machine has been353 * PoweredDown/Saved/Aborted. */354 if (machineState < MachineState_Running && !m_fIgnorePowerOffEvents)355 {356 g_fTerminateFE = true;357 gEventQ->interruptEventQueueProcessing();358 }359 360 break;361 }362 case VBoxEventType_OnVRDEServerInfoChanged:363 {364 ComPtr<IVRDEServerInfoChangedEvent> rdicev = aEvent;365 Assert(rdicev);366 367 if (gConsole)368 {369 ComPtr<IVRDEServerInfo> info;370 gConsole->COMGETTER(VRDEServerInfo)(info.asOutParam());371 if (info)372 {373 LONG port;374 info->COMGETTER(Port)(&port);375 if (port != mLastVRDEPort)376 {377 if (port == -1)378 RTPrintf("VRDE server is inactive.\n");379 else if (port == 0)380 RTPrintf("VRDE server failed to start.\n");381 else382 RTPrintf("VRDE server is listening on port %d.\n", port);383 384 mLastVRDEPort = port;385 }386 }387 }388 break;389 }390 case VBoxEventType_OnCanShowWindow:391 {392 ComPtr<ICanShowWindowEvent> cswev = aEvent;393 Assert(cswev);394 cswev->AddVeto(NULL);395 break;396 }397 case VBoxEventType_OnShowWindow:398 {399 ComPtr<IShowWindowEvent> swev = aEvent;400 Assert(swev);401 swev->COMSETTER(WinId)(0);402 break;403 }404 default:405 AssertFailed();406 }407 360 return S_OK; 408 361 } … … 417 370 long mLastVRDEPort; 418 371 bool m_fIgnorePowerOffEvents; 372 bool m_fNoLoggedInUsers; 419 373 }; 420 374 421 375 typedef ListenerImpl<VirtualBoxClientEventListener> VirtualBoxClientEventListenerImpl; 422 typedef ListenerImpl<VirtualBoxEventListener> VirtualBoxEventListenerImpl;423 376 typedef ListenerImpl<ConsoleEventListener> ConsoleEventListenerImpl; 424 377 425 378 VBOX_LISTENER_DECLARE(VirtualBoxClientEventListenerImpl) 426 VBOX_LISTENER_DECLARE(VirtualBoxEventListenerImpl)427 379 VBOX_LISTENER_DECLARE(ConsoleEventListenerImpl) 428 380 … … 1057 1009 eventTypes.push_back(VBoxEventType_OnCanShowWindow); 1058 1010 eventTypes.push_back(VBoxEventType_OnShowWindow); 1011 eventTypes.push_back(VBoxEventType_OnGuestPropertyChanged); 1059 1012 CHECK_ERROR(es, RegisterListener(consoleListener, ComSafeArrayAsInParam(eventTypes), true)); 1060 1013 } … … 1207 1160 } 1208 1161 1209 /* VirtualBox events registration. */1210 {1211 ComPtr<IEventSource> es;1212 CHECK_ERROR(virtualBox, COMGETTER(EventSource)(es.asOutParam()));1213 ComObjPtr<VirtualBoxEventListenerImpl> listener;1214 listener.createObject();1215 listener->init(new VirtualBoxEventListener());1216 vboxListener = listener;1217 com::SafeArray<VBoxEventType_T> eventTypes;1218 eventTypes.push_back(VBoxEventType_OnGuestPropertyChanged);1219 1220 /**1221 * @todo Set the notification pattern to "/VirtualBox/GuestInfo/OS/ *Logged*"1222 * to not cause too much load. The current API is broken as1223 * IMachine::GuestPropertyNotificationPatterns() would change the1224 * filter for _all_ clients. This is not what we want!1225 */1226 CHECK_ERROR(es, RegisterListener(vboxListener, ComSafeArrayAsInParam(eventTypes), true));1227 }1228 1229 1162 #ifdef VBOX_WITH_SAVESTATE_ON_SIGNAL 1230 1163 signal(SIGINT, SaveState); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r55422 r55437 3592 3592 <interface 3593 3593 name="IInternalMachineControl" extends="$unknown" 3594 uuid=" f0b3bf6e-c609-4d5e-9fd7-77537a52c31b"3594 uuid="2cfec73b-4447-4ff8-bae5-e4306e6197e8" 3595 3595 internal="yes" 3596 3596 wsmap="suppress" … … 3817 3817 <desc> 3818 3818 The flags of the property. 3819 </desc> 3820 </param> 3821 <param name="notify" type="boolean" dir="return"> 3822 <desc> 3823 Returns if a guest property change notification event should be fired. 3819 3824 </desc> 3820 3825 </param> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r55214 r55437 146 146 147 147 const ComPtr<IMachine> &i_machine() const { return mMachine; } 148 const Bstr &i_getId() const { return mstrUuid; } 148 149 149 150 bool i_useHostClipboard() { return mfUseHostClipboard; } … … 975 976 MachineState_T mMachineState; 976 977 978 /** Machine uuid string. */ 979 Bstr mstrUuid; 980 977 981 /** Pointer to the progress object of a live cancelable task. 978 982 * -
trunk/src/VBox/Main/include/MachineImpl.h
r55214 r55437 1230 1230 const com::Utf8Str &aValue, 1231 1231 LONG64 aTimestamp, 1232 const com::Utf8Str &aFlags); 1232 const com::Utf8Str &aFlags, 1233 BOOL *aNotify); 1233 1234 HRESULT lockMedia(); 1234 1235 HRESULT unlockMedia(); … … 1378 1379 const com::Utf8Str &aValue, 1379 1380 LONG64 aTimestamp, 1380 const com::Utf8Str &aFlags); 1381 const com::Utf8Str &aFlags, 1382 BOOL *aNotify); 1381 1383 HRESULT lockMedia(); 1382 1384 HRESULT unlockMedia(); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r55382 r55437 266 266 } 267 267 268 STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)268 STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent) 269 269 { 270 270 switch(aType) … … 278 278 Assert(pNREv); 279 279 280 Bstr interestedId;281 rc = pMachine->COMGETTER(Id)(interestedId.asOutParam());282 AssertComRC(rc);283 280 rc = pNREv->COMGETTER(MachineId)(id.asOutParam()); 284 281 AssertComRC(rc); 285 if (id != interestedId)282 if (id != mConsole->i_getId()) 286 283 break; 287 284 /* now we can operate with redirects */ … … 342 339 AssertFailed(); 343 340 } 341 344 342 return S_OK; 345 343 } … … 478 476 AssertComRCReturnRC(rc); 479 477 478 rc = mMachine->COMGETTER(Id)(mstrUuid.asOutParam()); 479 AssertComRCReturnRC(rc); 480 480 481 #ifdef VBOX_WITH_EXTPACK 481 482 unconst(mptrExtPackManager).createObject(); … … 1065 1066 } 1066 1067 1067 Bstr id; 1068 HRESULT hrc = mMachine->COMGETTER(Id)(id.asOutParam()); 1069 Guid uuid = Guid(id); 1070 1071 AssertComRCReturn(hrc, VERR_ACCESS_DENIED); 1068 Guid uuid = Guid(i_getId()); 1072 1069 1073 1070 AuthType_T authType = AuthType_Null; 1074 hrc = mVRDEServer->COMGETTER(AuthType)(&authType);1071 HRESULT hrc = mVRDEServer->COMGETTER(AuthType)(&authType); 1075 1072 AssertComRCReturn(hrc, VERR_ACCESS_DENIED); 1076 1073 … … 1419 1416 } 1420 1417 1421 Bstr uuid;1422 HRESULT hrc = m Machine->COMGETTER(Id)(uuid.asOutParam());1418 AuthType_T authType = AuthType_Null; 1419 HRESULT hrc = mVRDEServer->COMGETTER(AuthType)(&authType); 1423 1420 AssertComRC(hrc); 1424 1421 1425 AuthType_T authType = AuthType_Null;1426 hrc = mVRDEServer->COMGETTER(AuthType)(&authType);1427 AssertComRC(hrc);1428 1429 1422 if (authType == AuthType_External) 1430 mConsoleVRDPServer->AuthDisconnect( uuid, u32ClientId);1423 mConsoleVRDPServer->AuthDisconnect(i_getId(), u32ClientId); 1431 1424 1432 1425 #ifdef VBOX_WITH_GUEST_PROPS … … 1762 1755 Bstr flags(pCBData->pcszFlags); 1763 1756 ComObjPtr<Console> pConsole = reinterpret_cast<Console *>(pvExtension); 1757 BOOL fNotify = FALSE; 1764 1758 HRESULT hrc = pConsole->mControl->PushGuestProperty(name.raw(), 1765 1759 value.raw(), 1766 1760 pCBData->u64Timestamp, 1767 flags.raw()); 1761 flags.raw(), 1762 &fNotify); 1768 1763 if (SUCCEEDED(hrc)) 1769 1764 rc = VINF_SUCCESS; … … 1774 1769 rc = Global::vboxStatusCodeFromCOM(hrc); 1775 1770 } 1771 if (fNotify) 1772 fireGuestPropertyChangedEvent(pConsole->mEventSource, pConsole->i_getId().raw(), name.raw(), value.raw(), flags.raw()); 1776 1773 return rc; 1777 1774 } … … 5670 5667 HRESULT hrc = S_OK; 5671 5668 Bstr idMachine(aMachineId); 5672 Bstr idSelf;5673 hrc = mMachine->COMGETTER(Id)(idSelf.asOutParam());5674 5669 if ( FAILED(hrc) 5675 || idMachine != i dSelf)5670 || idMachine != i_getId()) 5676 5671 return hrc; 5677 5672 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r55233 r55437 13371 13371 } 13372 13372 13373 HRESULT SessionMachine::pushGuestProperty(const com::Utf8Str &aName, 13374 const com::Utf8Str &aValue, 13375 LONG64 aTimestamp, 13376 const com::Utf8Str &aFlags) 13373 HRESULT SessionMachine::pushGuestProperty(const com::Utf8Str &aName, 13374 const com::Utf8Str &aValue, 13375 LONG64 aTimestamp, 13376 const com::Utf8Str &aFlags, 13377 BOOL *aNotify) 13377 13378 { 13378 13379 LogFlowThisFunc(("\n")); … … 13380 13381 #ifdef VBOX_WITH_GUEST_PROPS 13381 13382 using namespace guestProp; 13383 13384 *aNotify = FALSE; 13382 13385 13383 13386 try … … 13463 13466 Bstr(aValue).raw(), 13464 13467 Bstr(aFlags).raw()); 13468 *aNotify = TRUE; 13465 13469 } 13466 13470 } … … 14705 14709 const com::Utf8Str &aValue, 14706 14710 LONG64 aTimestamp, 14707 const com::Utf8Str &aFlags) 14711 const com::Utf8Str &aFlags, 14712 BOOL *aNotify) 14708 14713 { 14709 14714 NOREF(aName); … … 14711 14716 NOREF(aTimestamp); 14712 14717 NOREF(aFlags); 14718 NOREF(aNotify); 14713 14719 ReturnComNotImplemented(); 14714 14720 }
Note:
See TracChangeset
for help on using the changeset viewer.

