示例#1
0
void SFTPTreeView::OnOpenTerminal(wxAuiToolBarEvent& event)
{
    // Open terminal to the selected account
    if(event.IsDropDownClicked()) {
        SFTPTreeViewBase::ShowAuiToolMenu(event);

    } else {
        SFTPSettings settings;
        settings.Load();

        wxString accountName = m_choiceAccount->GetStringSelection();
        if(accountName.IsEmpty()) {
            ::wxMessageBox(_("Please select an account to connect to"), "CodeLite", wxICON_ERROR | wxOK);
            return;
        }

        SSHAccountInfo account;
        if(!settings.GetAccount(accountName, account)) {
            ::wxMessageBox(wxString() << _("Could not find account: ") << accountName, "CodeLite", wxICON_ERROR | wxOK);
            return;
        }

        wxString connectString;
        connectString << account.GetUsername() << "@" << account.GetHost();

        const wxString& sshClient = settings.GetSshClient();
        FileUtils::OpenSSHTerminal(sshClient, connectString, account.GetPassword(), account.GetPort());
    }
}
void SSHAccountManagerDlg::DoAddAccount(const SSHAccountInfo& account)
{
    wxVector<wxVariant> cols;
    cols.push_back( account.GetAccountName() );
    cols.push_back( account.GetUsername() );
    m_dvListCtrlAccounts->AppendItem( cols, (wxUIntPtr)(new SSHAccountInfo(account)));
}
示例#3
0
void SFTPSettings::FromJSON(const JSONElement& json)
{
    m_accounts.clear();
    m_sshClient = json.namedObject("sshClient").toString(m_sshClient);
    JSONElement arrAccounts = json.namedObject("accounts");
    int size = arrAccounts.arraySize();
    for(int i=0; i<size; ++i) {
        SSHAccountInfo account;
        account.FromJSON(arrAccounts.arrayItem(i));
        m_accounts.push_back( account );
    }
}
void SSHAccountManagerDlg::OnEditAccount(wxDataViewEvent& event)
{
    SSHAccountInfo *account = (SSHAccountInfo*)(m_dvListCtrlAccounts->GetItemData( event.GetItem() ));
    AddSSHAcountDlg dlg(this, *account);
    if ( dlg.ShowModal() == wxID_OK ) {
        // update the user info
        dlg.GetAccountInfo(*account);

        // update the UI
        m_dvListCtrlAccounts->GetStore()->SetValue(account->GetAccountName(), event.GetItem(), 0);
        m_dvListCtrlAccounts->GetStore()->SetValue(account->GetUsername(), event.GetItem(), 1);
        m_dvListCtrlAccounts->Refresh();
    }
}
void SSHAccountManagerDlg::DoEditAccount(const wxDataViewItem& item)
{
    SSHAccountInfo* account = (SSHAccountInfo*)(m_dvListCtrlAccounts->GetItemData(item));
    if(account) {
        AddSSHAcountDlg dlg(this, *account);
        if(dlg.ShowModal() == wxID_OK) {
            // update the user info
            dlg.GetAccountInfo(*account);

            // update the UI
            m_dvListCtrlAccounts->GetStore()->SetValue(account->GetAccountName(), item, 0);
            m_dvListCtrlAccounts->GetStore()->SetValue(account->GetHost(), item, 1);
            m_dvListCtrlAccounts->GetStore()->SetValue(account->GetUsername(), item, 2);
            m_dvListCtrlAccounts->Refresh();
        }
    }
}
示例#6
0
bool SFTPSettings::UpdateAccount(const SSHAccountInfo& account)
{
    for( size_t i=0; i<m_accounts.size(); ++i ) {
        SSHAccountInfo& currentAccount = m_accounts.at(i);
        if ( account.GetAccountName() == currentAccount.GetAccountName() ) {
            currentAccount = account;
            return true;
        }
    }
    return false;
}
示例#7
0
void SFTPTreeView::OnOpenTerminal(wxAuiToolBarEvent& event)
{
    // Open terminal to the selected account
    if(event.IsDropDownClicked()) {
        SFTPTreeViewBase::ShowAuiToolMenu(event);

    } else {
        SSHAccountInfo account;
        if(!GetAccountFromUser(account)) { return; }

        wxString connectString;
        connectString << account.GetUsername() << "@" << account.GetHost();

        SFTPSettings settings;
        settings.Load();

        const wxString& sshClient = settings.GetSshClient();
        FileUtils::OpenSSHTerminal(sshClient, connectString, account.GetPassword(), account.GetPort());
    }
}