コード例 #1
0
ChatMenu::ChatMenu(ChatClient &client)
  : Utilities::CLIMenu("Chatting as "+client.username()),
    mClient(client)
{
  addChoice("Send Message", Utilities::ObjectCallback0<ChatMenu>(this, &ChatMenu::sendChat));
  setExitString("Disconnect");
}
コード例 #2
0
int SshProcess::exec(const char *password, int check)
{
    if(check)
        setTerminal(true);

    KStringList args;
    args += "-l";
    args += m_User;
    args += "-o";
    args += "StrictHostKeyChecking=no";
    args += m_Host;
    args += m_Stub;

    if(StubProcess::exec("ssh", args) < 0)
    {
        return check ? SshNotFound : -1;
    }

    int ret = ConverseSsh(password, check);
    if(ret < 0)
    {
        if(!check)
            kdError(900) << k_lineinfo << "Conversation with ssh failed\n";
        return ret;
    }
    if(check == 2)
    {
        if(ret == 1)
        {
            kill(m_Pid, SIGTERM);
            waitForChild();
        }
        return ret;
    }

    if(m_bErase && password)
    {
        char *ptr = const_cast< char * >(password);
        const uint plen = strlen(password);
        for(unsigned i = 0; i < plen; i++)
            ptr[i] = '\000';
    }

    ret = ConverseStub(check);
    if(ret < 0)
    {
        if(!check)
            kdError(900) << k_lineinfo << "Converstation with kdesu_stub failed\n";
        return ret;
    }
    else if(ret == 1)
    {
        kill(m_Pid, SIGTERM);
        waitForChild();
        ret = SshIncorrectPassword;
    }

    if(check == 1)
    {
        waitForChild();
        return 0;
    }

    setExitString("Waiting for forwarded connections to terminate");
    ret = waitForChild();
    return ret;
}