Changeset 44074 in vbox
- Timestamp:
- Dec 10, 2012 11:45:04 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxHeadless
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/VBox-3.0/src/VBox/Frontends/VBoxHeadless 58652,70973 /branches/VBox-3.2/src/VBox/Frontends/VBoxHeadless 66309,66318 /branches/VBox-4.0/src/VBox/Frontends/VBoxHeadless 70873 /branches/VBox-4.1/src/VBox/Frontends/VBoxHeadless 74233,78414,78691,81841,82127,82454,82579 /branches/VBox-4.1/src/VBox/Frontends/VBoxHeadless/VBoxHeadless 82454 /branches/andy/guestctrl20/src/VBox/Frontends/VBoxHeadless 78916,78930 /branches/dsen/gui/src/VBox/Frontends/VBoxHeadless 79076-79078,79089,79109-79110,79112-79113,79127-79130,79134,79141,79151,79155,79157-79159,79193,79197 /branches/dsen/gui2/src/VBox/Frontends/VBoxHeadless 79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644 /branches/dsen/gui3/src/VBox/Frontends/VBoxHeadless 79645-79692
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r43927 r44074 165 165 case VBoxEventType_OnGuestPropertyChanged: 166 166 { 167 ComPtr<IGuestPropertyChangedEvent> gpcev = aEvent; 168 Assert(gpcev); 169 170 Bstr strKey; 171 gpcev->COMGETTER(Name)(strKey.asOutParam()); 172 173 Utf8Str utf8Key = strKey; 174 LogRelFlow(("Guest property \"%s\" has been changed\n", utf8Key.c_str())); 175 176 if (utf8Key.equals("/VirtualBox/GuestInfo/OS/NoLoggedInUsers")) 167 ComPtr<IGuestPropertyChangedEvent> pChangedEvent = aEvent; 168 Assert(pChangedEvent); 169 170 HRESULT hrc; 171 172 ComPtr <IMachine> pMachine; 173 if (gConsole) 177 174 { 178 LogRelFlow(("Guest indicates that there %s logged in users (anymore)\n", 179 utf8Key.equals("true") ? "are no" : "are")); 180 181 /* Check if this is our machine and the "disconnect on logout feature" is enabled. */ 182 BOOL fProcessDisconnectOnGuestLogout = FALSE; 183 ComPtr <IMachine> machine; 184 HRESULT hrc = S_OK; 185 186 if (gConsole) 175 hrc = gConsole->COMGETTER(Machine)(pMachine.asOutParam()); 176 if (SUCCEEDED(hrc) && pMachine) 187 177 { 188 hrc = gConsole->COMGETTER(Machine)(machine.asOutParam()); 189 if (SUCCEEDED(hrc) && machine) 178 Bstr gpMachineId, machineId; 179 hrc = pMachine->COMGETTER(Id)(gpMachineId.asOutParam()); 180 AssertComRC(hrc); 181 hrc = pChangedEvent->COMGETTER(MachineId)(machineId.asOutParam()); 182 AssertComRC(hrc); 183 if (gpMachineId != machineId) 184 hrc = VBOX_E_OBJECT_NOT_FOUND; 185 } 186 } 187 else 188 hrc = VBOX_E_INVALID_VM_STATE; 189 190 if (SUCCEEDED(hrc)) 191 { 192 Bstr strKey; 193 hrc = pChangedEvent->COMGETTER(Name)(strKey.asOutParam()); 194 AssertComRC(hrc); 195 196 Utf8Str utf8Key = strKey; 197 LogRelFlow(("Guest property \"%s\" has been changed\n", utf8Key.c_str())); 198 199 if (utf8Key.equals("/VirtualBox/GuestInfo/OS/NoLoggedInUsers")) 200 { 201 Bstr strValue; 202 pChangedEvent->COMGETTER(Value)(strValue.asOutParam()); 203 Utf8Str utf8Value = strValue; 204 205 LogRelFlow(("Guest indicates that there %s logged in users\n", 206 utf8Value.equals("true") ? "are no" : "are")); 207 208 /* Check if this is our machine and the "disconnect on logout feature" is enabled. */ 209 BOOL fProcessDisconnectOnGuestLogout = FALSE; 210 211 /* Does the machine handle VRDP disconnects? */ 212 Bstr strDiscon; 213 hrc = pMachine->GetExtraData(Bstr("VRDP/DisconnectOnGuestLogout").raw(), 214 strDiscon.asOutParam()); 215 if (SUCCEEDED(hrc)) 190 216 { 191 Bstr id, machineId; 192 hrc = machine->COMGETTER(Id)(id.asOutParam()); 193 gpcev->COMGETTER(MachineId)(machineId.asOutParam()); 194 if (id == machineId) 217 Utf8Str utf8Discon = strDiscon; 218 fProcessDisconnectOnGuestLogout = utf8Discon.equals("1") 219 ? TRUE : FALSE; 220 } 221 222 LogRelFlow(("VRDE: hrc=%Rhrc: Host %s disconnecting clients (current host state known: %s)\n", 223 hrc, fProcessDisconnectOnGuestLogout ? "will handle" : "does not handle", 224 mfNoLoggedInUsers ? "No users logged in" : "Users logged in")); 225 226 if (fProcessDisconnectOnGuestLogout) 227 { 228 bool fDropConnection = false; 229 if (!mfNoLoggedInUsers) /* Only if the property really changes. */ 195 230 { 196 Bstr strDiscon;197 hrc = machine->GetExtraData(Bstr("VRDP/DisconnectOnGuestLogout").raw(),198 strDiscon.asOutParam());199 if (SUCCEEDED(hrc))231 if ( utf8Value == "true" 232 /* Guest property got deleted due to reset, 233 * so it has no value anymore. */ 234 || utf8Value.isEmpty()) 200 235 { 201 Utf8Str utf8Discon = strDiscon; 202 fProcessDisconnectOnGuestLogout = utf8Discon.equals("1") 203 ? TRUE : FALSE; 204 205 LogRelFlow(("VRDE: ExtraData VRDP/DisconnectOnGuestLogout=%s\n", 206 utf8Discon.c_str())); 236 mfNoLoggedInUsers = true; 237 fDropConnection = true; 207 238 } 208 239 } 209 } 210 } 211 else 212 LogRel(("VRDE: No console available, skipping disconnect on guest logout check\n")); 213 214 LogRelFlow(("VRDE: hrc=%Rhrc: Host %s disconnecting clients (current host state known: %s)\n", 215 hrc, fProcessDisconnectOnGuestLogout ? "will handle" : "does not handle", 216 mfNoLoggedInUsers ? "No users logged in" : "Users logged in")); 217 218 if (fProcessDisconnectOnGuestLogout) 219 { 220 bool fDropConnection = false; 221 222 Bstr value; 223 gpcev->COMGETTER(Value)(value.asOutParam()); 224 Utf8Str utf8Value = value; 225 226 if (!mfNoLoggedInUsers) /* Only if the property really changes. */ 227 { 228 if ( utf8Value == "true" 229 /* Guest property got deleted due to reset, 230 * so it has no value anymore. */ 231 || utf8Value.isEmpty()) 240 else if (utf8Value == "false") 241 mfNoLoggedInUsers = false; 242 /* Guest property got deleted due to reset, 243 * take the shortcut without touching the mfNoLoggedInUsers 244 * state. */ 245 else if (utf8Value.isEmpty()) 246 fDropConnection = true; 247 248 LogRelFlow(("VRDE: szNoLoggedInUsers=%s, mfNoLoggedInUsers=%RTbool, fDropConnection=%RTbool\n", 249 utf8Value.c_str(), mfNoLoggedInUsers, fDropConnection)); 250 251 if (fDropConnection) 232 252 { 233 mfNoLoggedInUsers = true; 234 fDropConnection = true; 235 } 236 } 237 else if (utf8Value == "false") 238 mfNoLoggedInUsers = false; 239 /* Guest property got deleted due to reset, 240 * take the shortcut without touching the mfNoLoggedInUsers 241 * state. */ 242 else if (utf8Value.isEmpty()) 243 fDropConnection = true; 244 245 LogRelFlow(("VRDE: szNoLoggedInUsers=%s, mfNoLoggedInUsers=%RTbool, fDropConnection=%RTbool\n", 246 utf8Value.c_str(), mfNoLoggedInUsers, fDropConnection)); 247 248 if (fDropConnection) 249 { 250 /* If there is a connection, drop it. */ 251 ComPtr<IVRDEServerInfo> info; 252 hrc = gConsole->COMGETTER(VRDEServerInfo)(info.asOutParam()); 253 if (SUCCEEDED(hrc) && info) 254 { 255 ULONG cClients = 0; 256 hrc = info->COMGETTER(NumberOfClients)(&cClients); 257 258 LogRelFlow(("VRDE: connected clients=%RU32\n", cClients)); 259 if (SUCCEEDED(hrc) && cClients > 0) 253 /* If there is a connection, drop it. */ 254 ComPtr<IVRDEServerInfo> info; 255 hrc = gConsole->COMGETTER(VRDEServerInfo)(info.asOutParam()); 256 if (SUCCEEDED(hrc) && info) 260 257 { 261 ComPtr <IVRDEServer> vrdeServer; 262 hrc = machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam()); 263 if (SUCCEEDED(hrc) && vrdeServer) 258 ULONG cClients = 0; 259 hrc = info->COMGETTER(NumberOfClients)(&cClients); 260 261 LogRelFlow(("VRDE: connected clients=%RU32\n", cClients)); 262 if (SUCCEEDED(hrc) && cClients > 0) 264 263 { 265 LogRel(("VRDE: the guest user has logged out, disconnecting remote clients.\n")); 266 vrdeServer->COMSETTER(Enabled)(FALSE); 267 vrdeServer->COMSETTER(Enabled)(TRUE); 264 ComPtr <IVRDEServer> vrdeServer; 265 hrc = pMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam()); 266 if (SUCCEEDED(hrc) && vrdeServer) 267 { 268 LogRel(("VRDE: the guest user has logged out, disconnecting remote clients.\n")); 269 hrc = vrdeServer->COMSETTER(Enabled)(FALSE); 270 AssertComRC(hrc); 271 HRESULT hrc2 = vrdeServer->COMSETTER(Enabled)(TRUE); 272 if (SUCCEEDED(hrc)) 273 hrc = hrc2; 274 } 268 275 } 269 276 } … … 272 279 } 273 280 274 LogRelFlow(("VRDE: returned with=%Rhrc\n", hrc)); 281 if (FAILED(hrc)) 282 LogRelFlow(("VRDE: returned error=%Rhrc\n", hrc)); 275 283 } 276 break; 277 } 284 285 break; 286 } 287 278 288 default: 279 289 AssertFailed(); … … 284 294 285 295 private: 296 286 297 bool mfNoLoggedInUsers; 287 298 };
Note:
See TracChangeset
for help on using the changeset viewer.