void SshConnectionPrivate::handleUserAuthSuccessPacket() { m_state = ConnectionEstablished; m_timeoutTimer.stop(); emit connected(); m_lastInvalidMsgSeqNr = InvalidSeqNr; connect(&m_keepAliveTimer, SIGNAL(timeout()), SLOT(sendKeepAlivePacket())); m_keepAliveTimer.start(); }
bool handleInput(int sock, struct addrinfo * p) { int charRead; while(true) { if(timeForKeepAlive) { sendKeepAlivePacket(sock, p); timeForKeepAlive = false; } handleNetwork(sock, p); charRead = wgetch(inputWnd); if(charRead == 127 && nchars > 0) { int cy, cx; getyx(inputWnd, cy, cx); mvwaddch(inputWnd, cy, cx-1, ' '); wmove(inputWnd, cy, cx-1); line[nchars] = '\0'; --nchars; return true; } else if(charRead >= 32 && charRead <= 126 && nchars < MAXLINE) { wechochar(inputWnd, charRead); line[nchars] = charRead; refreshAll(); ++nchars; return true; } else if(charRead == '\n') { if(strncmp(line, "/exit", std::max(nchars, MAXLINE+1)) == 0) { return false; } else if(strncmp(line, "/join ", 6) == 0) { sendJoinPacket(sock, p, &(line[6])); memset(curChannel, '\0', CHANNEL_MAX+1); strncpy(curChannel, &(line[6]), CHANNEL_MAX); channelsJoined.insert(curChannel); } else if(strncmp(line, "/switch ", 8) == 0) { char chanName[CHANNEL_MAX+1]; memset(chanName, '\0', CHANNEL_MAX+1); strncpy(chanName, &(line[8]), CHANNEL_MAX); if(channelsJoined.count(chanName) > 0) { strncpy(curChannel, chanName, CHANNEL_MAX); } else { char err[256]; snprintf(err, 256, "you have not subscribed to channel %.32s", chanName); printErrorMsg(err); } } else if(strncmp(line, "/leave ", 7) == 0) { sendLeavePacket(sock, p, &(line[7])); memset(curChannel, '\0', CHANNEL_MAX+1); strncpy(curChannel, &(line[7]), CHANNEL_MAX); channelsJoined.erase(curChannel); memset(curChannel, '\0', CHANNEL_MAX); } else if(strncmp(line, "/list", 5) == 0) { sendListPacket(sock, p); } else if(strncmp(line, "/who ", 5) == 0) { sendWhoPacket(sock, p, &(line[5])); } else if(line[0] == '/') { printErrorMsg("unrecognized command"); } else if(curChannel[0] != '\0'){ sendSayPacket(sock, p, curChannel, line); } //wprintw(wnd, "%s\n", line); memset(line, '\0', MAXLINE+1); clearInput(); return true; } }; }