228 |
228 |
229 // ------------------------------------------------------------------------------------------------- |
229 // ------------------------------------------------------------------------------------------------- |
230 // |
230 // |
231 void Interface::safeDisconnect(std::function<void(bool)> afterwards) |
231 void Interface::safeDisconnect(std::function<void(bool)> afterwards) |
232 { |
232 { |
233 if (m_session.is_active()) |
233 if (m_session.isActive()) |
234 { |
234 { |
235 m_disconnectCallback = afterwards; |
235 m_disconnectCallback = afterwards; |
236 setInputState(INPUTSTATE_CONFIRM_DISCONNECTION); |
236 setInputState(INPUTSTATE_CONFIRM_DISCONNECTION); |
237 } |
237 } |
238 else |
238 else |
493 |
493 |
494 case RCON_CONNECTED: |
494 case RCON_CONNECTED: |
495 { |
495 { |
496 String adminText; |
496 String adminText; |
497 |
497 |
498 if (m_session.num_admins() == 0) |
498 if (m_session.getAdminCount() == 0) |
499 { |
499 { |
500 adminText = "No other admins"; |
500 adminText = "No other admins"; |
501 } |
501 } |
502 else |
502 else |
503 { |
503 { |
504 adminText.sprintf("%d other admin%s", m_session.num_admins(), |
504 adminText.sprintf("%d other admin%s", m_session.getAdminCount(), |
505 m_session.num_admins() != 1 ? "s" : ""); |
505 m_session.getAdminCount() != 1 ? "s" : ""); |
506 } |
506 } |
507 |
507 |
508 text.sprintf("%s | %s | %s", |
508 text.sprintf("%s | %s | %s", |
509 m_session.address().to_string(IPAddress::WITH_PORT).chars(), |
509 m_session.address().to_string(IPAddress::WITH_PORT).chars(), |
510 m_session.level().chars(), |
510 m_session.getLevel().chars(), |
511 adminText.chars()); |
511 adminText.chars()); |
512 } |
512 } |
513 break; |
513 break; |
514 } |
514 } |
515 |
515 |
516 if (not text.isEmpty()) |
516 if (not text.isEmpty()) |
517 text += " | "; |
517 text += " | "; |
518 |
518 |
519 text += "Ctrl+N to connect, Ctrl+Q to "; |
519 text += "Ctrl+N to connect, Ctrl+Q to "; |
520 text +=(m_session.state() == RCON_DISCONNECTED) ? "quit" : "disconnect"; |
520 text +=(m_session.getState() == RCON_DISCONNECTED) ? "quit" : "disconnect"; |
521 |
521 |
522 if (text != m_statusBarText) |
522 if (text != m_statusBarText) |
523 { |
523 { |
524 m_statusBarText = text; |
524 m_statusBarText = text; |
525 m_needStatusBarRender = true; |
525 m_needStatusBarRender = true; |
773 if (m_inputState == INPUTSTATE_NORMAL |
773 if (m_inputState == INPUTSTATE_NORMAL |
774 and m_cursorPosition > 0 |
774 and m_cursorPosition > 0 |
775 and(space == -1 or space >= m_cursorPosition)) |
775 and(space == -1 or space >= m_cursorPosition)) |
776 { |
776 { |
777 String start = getCurrentInput().mid(0, m_cursorPosition); |
777 String start = getCurrentInput().mid(0, m_cursorPosition); |
778 m_session.request_tab_complete(start); |
778 m_session.requestTabCompletion(start); |
779 } |
779 } |
780 } |
780 } |
781 break; |
781 break; |
782 |
782 |
783 case '\n': |
783 case '\n': |
807 |
807 |
808 case INPUTSTATE_PASSWORD: |
808 case INPUTSTATE_PASSWORD: |
809 if (m_inputState == INPUTSTATE_PASSWORD and not getCurrentInput().isEmpty()) |
809 if (m_inputState == INPUTSTATE_PASSWORD and not getCurrentInput().isEmpty()) |
810 { |
810 { |
811 m_session.disconnect(); |
811 m_session.disconnect(); |
812 m_session.set_password(getCurrentInput()); |
812 m_session.setPassword(getCurrentInput()); |
813 m_session.connect(m_remoteAddress); |
813 m_session.connect(m_remoteAddress); |
814 setInputState(INPUTSTATE_NORMAL); |
814 setInputState(INPUTSTATE_NORMAL); |
815 } |
815 } |
816 break; |
816 break; |
817 |
817 |
1005 |
1005 |
1006 if (m_remoteAddress.port == 0) |
1006 if (m_remoteAddress.port == 0) |
1007 m_remoteAddress.port = 10666; |
1007 m_remoteAddress.port = 10666; |
1008 |
1008 |
1009 m_session.disconnect(); |
1009 m_session.disconnect(); |
1010 m_session.set_password(password); |
1010 m_session.setPassword(password); |
1011 m_session.connect(m_remoteAddress); |
1011 m_session.connect(m_remoteAddress); |
1012 } |
1012 } |
1013 |
1013 |
1014 // ------------------------------------------------------------------------------------------------- |
1014 // ------------------------------------------------------------------------------------------------- |
1015 // |
1015 // |
1077 } |
1077 } |
1078 |
1078 |
1079 if (address.port == 0) |
1079 if (address.port == 0) |
1080 address.port = 10666; |
1080 address.port = 10666; |
1081 |
1081 |
1082 m_session.set_password(args[1]); |
1082 m_session.setPassword(args[1]); |
1083 m_session.disconnect(); |
1083 m_session.disconnect(); |
1084 m_session.connect(m_remoteAddress = address); |
1084 m_session.connect(m_remoteAddress = address); |
1085 } |
1085 } |
1086 } |
1086 } |
1087 else if (command == "disconnect") |
1087 else if (command == "disconnect") |