=================== Session_PromptKey_f =================== */
| 249 | =================== |
| 250 | */ |
| 251 | static void Session_PromptKey_f( const idCmdArgs &args ) { |
| 252 | const char *retkey; |
| 253 | bool valid[ 2 ]; |
| 254 | static bool recursed = false; |
| 255 | |
| 256 | if ( recursed ) { |
| 257 | common->Warning( "promptKey recursed - aborted" ); |
| 258 | return; |
| 259 | } |
| 260 | recursed = true; |
| 261 | |
| 262 | do { |
| 263 | // in case we're already waiting for an auth to come back to us ( may happen exceptionally ) |
| 264 | if ( sessLocal.MaybeWaitOnCDKey() ) { |
| 265 | if ( sessLocal.CDKeysAreValid( true ) ) { |
| 266 | recursed = false; |
| 267 | return; |
| 268 | } |
| 269 | } |
| 270 | // the auth server may have replied and set an error message, otherwise use a default |
| 271 | const char *prompt_msg = sessLocal.GetAuthMsg(); |
| 272 | if ( prompt_msg[ 0 ] == '\0' ) { |
| 273 | prompt_msg = common->GetLanguageDict()->GetString( "#str_04308" ); |
| 274 | } |
| 275 | retkey = sessLocal.MessageBox( MSG_CDKEY, prompt_msg, common->GetLanguageDict()->GetString( "#str_04305" ), true, NULL, NULL, true ); |
| 276 | if ( retkey ) { |
| 277 | if ( sessLocal.CheckKey( retkey, false, valid ) ) { |
| 278 | // if all went right, then we may have sent an auth request to the master ( unless the prompt is used during a net connect ) |
| 279 | bool canExit = true; |
| 280 | if ( sessLocal.MaybeWaitOnCDKey() ) { |
| 281 | // wait on auth reply, and got denied, prompt again |
| 282 | if ( !sessLocal.CDKeysAreValid( true ) ) { |
| 283 | // server says key is invalid - MaybeWaitOnCDKey was interrupted by a CDKeysAuthReply call, which has set the right error message |
| 284 | // the invalid keys have also been cleared in the process |
| 285 | sessLocal.MessageBox( MSG_OK, sessLocal.GetAuthMsg(), common->GetLanguageDict()->GetString( "#str_04310" ), true, NULL, NULL, true ); |
| 286 | canExit = false; |
| 287 | } |
| 288 | } |
| 289 | if ( canExit ) { |
| 290 | // make sure that's saved on file |
| 291 | sessLocal.WriteCDKey(); |
| 292 | sessLocal.MessageBox( MSG_OK, common->GetLanguageDict()->GetString( "#str_04307" ), common->GetLanguageDict()->GetString( "#str_04305" ), true, NULL, NULL, true ); |
| 293 | break; |
| 294 | } |
| 295 | } else { |
| 296 | // offline check sees key invalid |
| 297 | // build a message about keys being wrong. do not attempt to change the current key state though |
| 298 | // ( the keys may be valid, but user would have clicked on the dialog anyway, that kind of thing ) |
| 299 | idStr msg; |
| 300 | idAsyncNetwork::BuildInvalidKeyMsg( msg, valid ); |
| 301 | sessLocal.MessageBox( MSG_OK, msg, common->GetLanguageDict()->GetString( "#str_04310" ), true, NULL, NULL, true ); |
| 302 | } |
| 303 | } else if ( args.Argc() == 2 && idStr::Icmp( args.Argv(1), "force" ) == 0 ) { |
| 304 | // cancelled in force mode |
| 305 | cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "quit\n" ); |
| 306 | cmdSystem->ExecuteCommandBuffer(); |
| 307 | } |
| 308 | } while ( retkey ); |
nothing calls this directly
no test coverage detected