Ticket #5091: 5091.patch

File 5091.patch, 10.7 KB (added by David, 12 years ago)
  • docs/filezilla.man

     
    44.SH SYNOPSIS
    55.B filezilla
    66.br
    7 .B filezilla [\-l <logontype>] <FTP URL>
     7.B filezilla [-s] [\-l <logontype>] [<FTP URL>]... [fzsite://<SITE>]...
    88.br
    99.B filezilla \-h|\-s|\-v
    10 .br
    11 .B filezilla \-c <site>
    1210.SH DESCRIPTION
    1311FileZilla is a powerful client for plain FTP, FTP over SSL/TLS (FTPS) and the SSH File Transfer Protocol (SFTP).
    1412.SH OPTIONS
    1513
    1614.TP
    17 .B \-c <site>, \-\-site <site>
    18 Connect to the given site from the Site Manager.
     15.B <FTP URL>...
     16Connect to the given FTP URL(s).
     17
     18.TP
     19.B fzsite://<SITE>
     20Connect to the given site(s) from the Site Manager.
    1921Site has to be given as complete path, with a slash as separation character. Any slash or backslash that is part of a segment has to be escaped with a backslash. Path has to be prefixed with 0 for user defined entries or 1 for default entries. Site path may not contain double quotation marks.
    2022.IP
    21 Example: filezilla \-c 0/foo/bar/sl\\/ash connects to the user site sl/ash in the site directory foo/bar
    22 .IP
    23 May not be used together with
    24 .B \-s
    25 nor with URL parameter.
     23Example: filezilla fzsite://0/foo/bar/sl\\/ash connects to the user site sl/ash in the site directory foo/bar
    2624
    2725.TP
    2826.B \-h, \-\-help
     
    3028
    3129.TP
    3230.B \-l <logontype>, \-\-logontype <logontype>
    33 Set a special logontype, can only be used in combination with a FTP URL as argument.
     31Set a special logontype, will only be used in combination with FTP URL(s).
    3432
    3533Logontype has to be either
    3634.B ask
  • src/interface/cmdline.cpp

     
    55{
    66    m_parser.AddSwitch(_T("h"), _T("help"), _("Shows this help dialog"), wxCMD_LINE_OPTION_HELP);
    77    m_parser.AddSwitch(_T("s"), _T("site-manager"), _("Start with opened Site Manager"));
    8     m_parser.AddOption(_T("c"), _T("site"), _("Connect to specified Site Manager site"));
    98
    10     wxString desc = wxString::Format(_("Logontype, can only be used together with FTP URL. Argument has to be either '%s' or '%s'"), _T("ask"), _T("interactive"));
     9    wxString desc = wxString::Format(_("Logontype, will only be used together with FTP URL(s). Argument has to be either '%s' or '%s'"), _T("ask"), _T("interactive"));
    1110    m_parser.AddOption(_T("l"), _T("logontype"), desc);
    1211
    1312#ifdef __WXMSW__
     
    1514#endif
    1615    m_parser.AddSwitch(_T(""), _T("verbose"), _("Verbose log messages from wxWidgets"));
    1716    m_parser.AddSwitch(_T("v"), _T("version"), _("Print version information to stdout and exit"));
    18     wxString str = _T("<");
    19     str += _("FTP URL");
    20     str += _T(">");
    21     m_parser.AddParam(str, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
     17    m_parser.AddParam(_("FTP URL"), wxCMD_LINE_VAL_STRING, (wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE));
    2218
     19    wxString str = _T("fzsite://");
     20    str += _("SITE");
     21    m_parser.AddParam(str, wxCMD_LINE_VAL_STRING, (wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE));
     22
    2323    m_parser.SetCmdLine(argc, argv);
    2424
    2525    m_parser.SetSwitchChars(_T("-"));
     
    6363    if (res != 0)
    6464        return false;
    6565
    66     if (HasSwitch(sitemanager) && GetOption(site) != _T(""))
    67     {
    68         wxMessageBox(_("-s and -c cannot be present at the same time."), _("Syntax error in command line"));
    69         return false;
    70     }
    71 
    72     if (HasSwitch(sitemanager) && m_parser.GetParamCount())
    73     {
    74         wxMessageBox(_("-s cannot be used together with an FTP URL."), _("Syntax error in command line"));
    75         return false;
    76     }
    77 
    78     if (GetOption(site) != _T("") && m_parser.GetParamCount())
    79     {
    80         wxMessageBox(_("-c cannot be used together with an FTP URL."), _("Syntax error in command line"));
    81         return false;
    82     }
    83 
    8466    wxString type = GetOption(logontype);
    8567    if (type != _T(""))
    8668    {
     
    10890    m_parser.Usage();
    10991}
    11092
    111 wxString CCommandLine::GetParameter() const
     93void CCommandLine::GetParameters(std::vector<wxString> &params) const
    11294{
    113     if (!m_parser.GetParamCount())
    114         return _T("");
     95    size_t paramCount = m_parser.GetParamCount();
     96    params.clear();
     97    params.reserve(paramCount);
    11598
    116     return m_parser.GetParam();
     99    for(size_t i = 0; i < paramCount; i++)
     100    {
     101        params.push_back(m_parser.GetParam(i));
     102    }
    117103}
  • src/interface/cmdline.h

     
    2525
    2626    bool HasSwitch(enum t_switches s) const;
    2727    wxString GetOption(enum t_option option) const;
    28     wxString GetParameter() const;
     28    // Fetch all parameters
     29    void GetParameters(std::vector<wxString> &params) const;
    2930
    3031protected:
    3132    wxCmdLineParser m_parser;
  • src/interface/Mainfrm.cpp

     
    19631963    ShowDropdownMenu(pMenu, m_pToolBar, event);
    19641964}
    19651965
    1966 bool CMainFrame::ConnectToSite(CSiteManagerItemData_Site* const pData)
     1966bool CMainFrame::ConnectToSite(CSiteManagerItemData_Site* const pData, bool newtab /*=false*/)
    19671967{
    19681968    wxASSERT(pData);
    19691969
     
    19741974            return false;
    19751975    }
    19761976
    1977     if (!ConnectToServer(pData->m_server, pData->m_remoteDir))
     1977    if (!ConnectToServer(pData->m_server, pData->m_remoteDir, newtab))
    19781978        return false;
    19791979
    19801980    if (pData->m_localDir != _T(""))
     
    24252425    if (!pCommandLine)
    24262426        return;
    24272427
    2428     wxString site;
    2429     if (pCommandLine->HasSwitch(CCommandLine::sitemanager))
     2428    std::vector<wxString> params;
     2429    pCommandLine->GetParameters(params);
     2430    if (!params.empty())
    24302431    {
    2431         Show();
    2432         OpenSiteManager();
    2433     }
    2434     else if ((site = pCommandLine->GetOption(CCommandLine::site)) != _T(""))
    2435     {
    2436         CSiteManagerItemData_Site* pData = CSiteManager::GetSiteByPath(site);
    2437 
    2438         if (pData)
    2439         {
    2440             if (ConnectToSite(pData))
    2441             {
    2442                 SetBookmarksFromPath(site);
    2443                 if (m_pMenuBar)
    2444                     m_pMenuBar->UpdateBookmarkMenu();
    2445             }
    2446             delete pData;
    2447         }
    2448     }
    2449 
    2450     wxString param = pCommandLine->GetParameter();
    2451     if (param != _T(""))
    2452     {
    24532432        wxString error;
    2454 
    24552433        CServer server;
    24562434
    24572435        wxString logontype = pCommandLine->GetOption(CCommandLine::logontype);
     
    24602438        else if (logontype == _T("interactive"))
    24612439            server.SetLogonType(INTERACTIVE);
    24622440
    2463         CServerPath path;
    2464         if (!server.ParseUrl(param, 0, _T(""), _T(""), error, path))
     2441        // Iterate over available parameters
     2442        for(std::vector<wxString>::iterator iter = params.begin(); iter != params.end(); ++iter)
    24652443        {
    2466             wxString str = _("Parameter not a valid URL");
    2467             str += _T("\n") + error;
    2468             wxMessageBox(error, _("Syntax error in command line"));
    2469         }
     2444            wxString site;
    24702445
    2471         if (server.GetLogonType() == ASK ||
    2472             (server.GetLogonType() == INTERACTIVE && server.GetUser() == _T("")))
    2473         {
    2474             if (!CLoginManager::Get().GetPassword(server, false))
     2446            // Check if parameter is a site
     2447            if (iter->StartsWith(_T("fzsite://"), &site))
     2448            {
     2449                CSiteManagerItemData_Site* pData = CSiteManager::GetSiteByPath(site);
     2450
     2451                if (pData)
     2452                {
     2453                    if (ConnectToSite(pData, true))
     2454                    {
     2455                        SetBookmarksFromPath(site);
     2456                        if (m_pMenuBar)
     2457                            m_pMenuBar->UpdateBookmarkMenu();
     2458                    }
     2459                    delete pData;
     2460                }
     2461                continue;
     2462            }
     2463
     2464            // Not a site, try parsing as URL
     2465            CServerPath path;
     2466            if (!server.ParseUrl(*iter, 0, _T(""), _T(""), error, path))
     2467            {
     2468                wxString str = _("Parameter not a valid URL");
     2469                str += _T("\n") + error;
     2470                wxMessageBox(error, _("Syntax error in command line"));
     2471                continue;
     2472            }
     2473
     2474            if (server.GetLogonType() == ASK ||
     2475                (server.GetLogonType() == INTERACTIVE && server.GetUser() == _T("")))
     2476            {
     2477                if (!CLoginManager::Get().GetPassword(server, false))
     2478                    continue;
     2479            }
     2480
     2481            CState* pState = CContextManager::Get()->GetCurrentContext();
     2482            if (!pState)
    24752483                return;
     2484
     2485            ConnectToServer(server, path, true);
    24762486        }
    2477 
    2478         CState* pState = CContextManager::Get()->GetCurrentContext();
    2479         if (!pState)
    2480             return;
    2481 
    2482         ConnectToServer(server, path);
    24832487    }
     2488   
     2489    if (pCommandLine->HasSwitch(CCommandLine::sitemanager))
     2490    {
     2491        Show();
     2492        OpenSiteManager();
     2493    }
    24842494}
    24852495
    24862496void CMainFrame::OnFilterRightclicked(wxCommandEvent& event)
     
    26952705    }
    26962706}
    26972707
    2698 bool CMainFrame::ConnectToServer(const CServer &server, const CServerPath &path /*=CServerPath()*/)
     2708bool CMainFrame::ConnectToServer(const CServer &server, const CServerPath &path /*=CServerPath()*/, bool newtab /*=false*/)
    26992709{
    27002710    CState* pState = CContextManager::Get()->GetCurrentContext();
    27012711    if (!pState)
     
    27032713
    27042714    if (pState->IsRemoteConnected() || !pState->IsRemoteIdle())
    27052715    {
    2706         wxDialogEx dlg;
    2707         if (dlg.Load(this, _T("ID_ALREADYCONNECTED")))
     2716        if (newtab)
    27082717        {
    2709             if (COptions::Get()->GetOptionVal(OPTION_ALREADYCONNECTED_CHOICE) != 0)
    2710                 XRCCTRL(dlg, "ID_OLDTAB", wxRadioButton)->SetValue(true);
    2711             else
    2712                 XRCCTRL(dlg, "ID_NEWTAB", wxRadioButton)->SetValue(true);
     2718            m_pContextControl->CreateTab();
     2719            pState = CContextManager::Get()->GetCurrentContext();
     2720        }
     2721        else
     2722        {
     2723            wxDialogEx dlg;
     2724            if (dlg.Load(this, _T("ID_ALREADYCONNECTED")))
     2725            {
     2726                if (COptions::Get()->GetOptionVal(OPTION_ALREADYCONNECTED_CHOICE) != 0)
     2727                    XRCCTRL(dlg, "ID_OLDTAB", wxRadioButton)->SetValue(true);
     2728                else
     2729                    XRCCTRL(dlg, "ID_NEWTAB", wxRadioButton)->SetValue(true);
    27132730
    2714             if (dlg.ShowModal() != wxID_OK)
    2715                 return false;
     2731                if (dlg.ShowModal() != wxID_OK)
     2732                    return false;
    27162733
    2717             if (XRCCTRL(dlg, "ID_NEWTAB", wxRadioButton)->GetValue())
    2718             {
    2719                 m_pContextControl->CreateTab();
    2720                 pState = CContextManager::Get()->GetCurrentContext();
    2721                 COptions::Get()->SetOption(OPTION_ALREADYCONNECTED_CHOICE, 0);
     2734                if (XRCCTRL(dlg, "ID_NEWTAB", wxRadioButton)->GetValue())
     2735                {
     2736                    m_pContextControl->CreateTab();
     2737                    pState = CContextManager::Get()->GetCurrentContext();
     2738                    COptions::Get()->SetOption(OPTION_ALREADYCONNECTED_CHOICE, 0);
     2739                }
     2740                else
     2741                    COptions::Get()->SetOption(OPTION_ALREADYCONNECTED_CHOICE, 1);
    27222742            }
    2723             else
    2724                 COptions::Get()->SetOption(OPTION_ALREADYCONNECTED_CHOICE, 1);
    27252743        }
    27262744    }
    27272745
  • src/interface/Mainfrm.h

     
    5656
    5757    void PostInitialize();
    5858   
    59     bool ConnectToServer(const CServer& server, const CServerPath& path = CServerPath());
     59    bool ConnectToServer(const CServer& server, const CServerPath& path = CServerPath(), bool newtab = false);
    6060
    6161    CContextControl* GetContextControl() { return m_pContextControl; }
    6262
    63     bool ConnectToSite(CSiteManagerItemData_Site* const pData);
     63    bool ConnectToSite(CSiteManagerItemData_Site* const pData, bool newtab = false);
    6464
    6565protected:
    6666    bool CreateMenus();