Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 89290 | Differences between
and this patch

Collapse All | Expand All

(-)filezilla-3.0.0-beta4_2/src/engine/server.cpp (+57 lines)
Lines 1-5 Link Here
1
#include "FileZilla.h"
1
#include "FileZilla.h"
2
2
3
struct t_protocolInfo
4
{
5
	const bool translateable;
6
	const enum ServerProtocol protocol;
7
	const wxChar* const name;
8
};
9
10
static const t_protocolInfo protocolInfos[] = {
11
	false, FTP, _T("FTP - File Transfer Protocol"),
12
	false, SFTP, _T("SFTP - SSH File Transfer Protocol"),
13
	true, FTPS, wxTRANSLATE("FTPS - FTP over implicit TLS/SSL"),
14
	true, FTPES, wxTRANSLATE("FTPES - FTP over explicit TLS/SSL"),
15
	true, SFTP, _T("SSH File Transfer Protocol (SFTP)"),
16
	false, UNKNOWN, _T("")
17
};
18
3
CServer::CServer()
19
CServer::CServer()
4
{
20
{
5
	Initialize();
21
	Initialize();
Lines 553-555 Link Here
553
		return FTP;
569
		return FTP;
554
	}
570
	}
555
}
571
}
572
573
wxString CServer::GetProtocolName(enum ServerProtocol protocol)
574
{
575
	const t_protocolInfo *protocolInfo = protocolInfos;
576
	while (protocolInfo->protocol != UNKNOWN)
577
	{
578
		if (protocolInfo->protocol != protocol)
579
		{
580
			protocolInfo++;
581
			continue;
582
		}
583
584
		if (protocolInfo->translateable)
585
			return wxGetTranslation(protocolInfo->name);
586
		else
587
			return protocolInfo->name;
588
	}
589
590
	return _T("");
591
}
592
593
enum ServerProtocol CServer::GetProtocolFromName(const wxString& name)
594
{
595
	const t_protocolInfo *protocolInfo = protocolInfos;
596
	while (protocolInfo->protocol != UNKNOWN)
597
	{
598
		if (protocolInfo->translateable)
599
		{
600
			if (wxGetTranslation(protocolInfo->name) == name)
601
				return protocolInfo->protocol;
602
		}
603
		else
604
		{
605
			if (protocolInfo->name == name)
606
				return protocolInfo->protocol;
607
		}
608
		protocolInfo++;
609
	}
610
611
	return UNKNOWN;
612
}
(-)filezilla-3.0.0-beta4_2/src/include/server.h (+3 lines)
Lines 101-106 Link Here
101
	static unsigned int GetDefaultPort(enum ServerProtocol protocol);
101
	static unsigned int GetDefaultPort(enum ServerProtocol protocol);
102
	static enum ServerProtocol GetProtocolFromPort(unsigned int port);
102
	static enum ServerProtocol GetProtocolFromPort(unsigned int port);
103
103
104
	static wxString GetProtocolName(enum ServerProtocol protocol);
105
	static enum ServerProtocol GetProtocolFromName(const wxString& name);
106
104
protected:
107
protected:
105
	void Initialize();
108
	void Initialize();
106
109
(-)filezilla-3.0.0-beta4_2/src/interface/resources/dialogs.xrc (-4 lines)
Lines 719-728 Link Here
719
                            </object>
719
                            </object>
720
                            <object class="sizeritem">
720
                            <object class="sizeritem">
721
                              <object class="wxChoice" name="ID_PROTOCOL">
721
                              <object class="wxChoice" name="ID_PROTOCOL">
722
                                <content>
723
                                  <item>FTP</item>
724
                                  <item>SFTP</item>
725
                                </content>
726
                                <selection>0</selection>
722
                                <selection>0</selection>
727
                              </object>
723
                              </object>
728
                              <flag>wxGROW</flag>
724
                              <flag>wxGROW</flag>
(-)filezilla-3.0.0-beta4_2/src/interface/sitemanager.cpp (-31 / +24 lines)
Lines 85-90 Link Here
85
{	
85
{	
86
	wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_SITEMANAGER"));
86
	wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_SITEMANAGER"));
87
87
88
	wxChoice *pProtocol = XRCCTRL(*this, "ID_PROTOCOL", wxChoice);
89
	pProtocol->Append(CServer::GetProtocolName(FTP));
90
	pProtocol->Append(CServer::GetProtocolName(SFTP));
91
	pProtocol->Append(CServer::GetProtocolName(FTPS));
92
	pProtocol->Append(CServer::GetProtocolName(FTPES));
93
88
	wxChoice *pChoice = XRCCTRL(*this, "ID_SERVERTYPE", wxChoice);
94
	wxChoice *pChoice = XRCCTRL(*this, "ID_SERVERTYPE", wxChoice);
89
	wxASSERT(pChoice);
95
	wxASSERT(pChoice);
90
	pChoice->Append(_T("Unix"));
96
	pChoice->Append(_T("Unix"));
Lines 414-421 Link Here
414
		return false;
420
		return false;
415
	}
421
	}
416
422
417
	const wxString& protocol = XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->GetStringSelection();
423
	wxString protocolName = XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->GetStringSelection();
418
	if (protocol == _("SFTP") &&
424
	enum ServerProtocol protocol = CServer::GetProtocolFromName(protocolName);
425
	if (protocol == SFTP &&
419
		XRCCTRL(*this, "ID_LOGONTYPE", wxChoice)->GetStringSelection() == _("Account"))
426
		XRCCTRL(*this, "ID_LOGONTYPE", wxChoice)->GetStringSelection() == _("Account"))
420
	{
427
	{
421
		XRCCTRL(*this, "ID_LOGONTYPE", wxChoice)->SetFocus();
428
		XRCCTRL(*this, "ID_LOGONTYPE", wxChoice)->SetFocus();
Lines 424-433 Link Here
424
	}
431
	}
425
432
426
	CServer server;
433
	CServer server;
427
	if (protocol == _("FTP"))
434
	if (protocol != UNKNOWN)
428
		server.SetProtocol(FTP);
435
		server.SetProtocol(protocol);
429
	else if (protocol == _("SFTP"))
430
		server.SetProtocol(SFTP);
431
436
432
	unsigned long port;
437
	unsigned long port;
433
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->GetValue().ToULong(&port);
438
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->GetValue().ToULong(&port);
Lines 443-458 Link Here
443
	XRCCTRL(*this, "ID_HOST", wxTextCtrl)->SetValue(server.GetHost());
448
	XRCCTRL(*this, "ID_HOST", wxTextCtrl)->SetValue(server.GetHost());
444
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->SetValue(wxString::Format(_T("%d"), server.GetPort()));
449
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->SetValue(wxString::Format(_T("%d"), server.GetPort()));
445
450
446
	switch (server.GetProtocol())
451
	protocolName = CServer::GetProtocolName(server.GetProtocol());
447
	{
452
	if (protocolName == _T(""))
448
	case SFTP:
453
		CServer::GetProtocolName(FTP);
449
		XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(_("SFTP"));
454
	XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(protocolName);
450
		break;
451
	case FTP:
452
	default:
453
		XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(_("FTP"));
454
		break;
455
	}
456
455
457
	if (XRCCTRL(*this, "ID_CHARSET_CUSTOM", wxRadioButton)->GetValue())
456
	if (XRCCTRL(*this, "ID_CHARSET_CUSTOM", wxRadioButton)->GetValue())
458
	{
457
	{
Lines 664-674 Link Here
664
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->GetValue().ToULong(&port);
663
	XRCCTRL(*this, "ID_PORT", wxTextCtrl)->GetValue().ToULong(&port);
665
	data->m_server.SetHost(XRCCTRL(*this, "ID_HOST", wxTextCtrl)->GetValue(), port);
664
	data->m_server.SetHost(XRCCTRL(*this, "ID_HOST", wxTextCtrl)->GetValue(), port);
666
665
667
	wxString protocol = XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->GetStringSelection();
666
	const wxString& protocolName = XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->GetStringSelection();
668
	if (protocol == _("FTP"))
667
	const enum ServerProtocol protocol = CServer::GetProtocolFromName(protocolName);
669
		data->m_server.SetProtocol(FTP);
668
	if (protocol != UNKNOWN)
670
	else if (protocol == _("SFTP"))
669
		data->m_server.SetProtocol(protocol);
671
		data->m_server.SetProtocol(SFTP);
672
	else
670
	else
673
		data->m_server.SetProtocol(FTP);
671
		data->m_server.SetProtocol(FTP);
674
672
Lines 863-878 Link Here
863
		else
861
		else
864
			XRCCTRL(*this, "ID_PORT", wxTextCtrl)->SetValue(_T(""));
862
			XRCCTRL(*this, "ID_PORT", wxTextCtrl)->SetValue(_T(""));
865
863
866
		switch (data->m_server.GetProtocol())
864
		const wxString& protocolName = CServer::GetProtocolName(data->m_server.GetProtocol());
867
		{
865
		if (protocolName != _T(""))
868
		case SFTP:
866
			XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(protocolName);
869
			XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(_("SFTP"));
867
		else
870
			break;
868
			XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(CServer::GetProtocolName(FTP));
871
		case FTP:
872
		default:
873
			XRCCTRL(*this, "ID_PROTOCOL", wxChoice)->SetStringSelection(_("FTP"));
874
			break;
875
		}
876
869
877
		XRCCTRL(*this, "ID_USER", wxTextCtrl)->Enable(data->m_server.GetLogonType() != ANONYMOUS);
870
		XRCCTRL(*this, "ID_USER", wxTextCtrl)->Enable(data->m_server.GetLogonType() != ANONYMOUS);
878
		XRCCTRL(*this, "ID_PASS", wxTextCtrl)->Enable(data->m_server.GetLogonType() == NORMAL || data->m_server.GetLogonType() == ACCOUNT);
871
		XRCCTRL(*this, "ID_PASS", wxTextCtrl)->Enable(data->m_server.GetLogonType() == NORMAL || data->m_server.GetLogonType() == ACCOUNT);

Return to bug 89290