source: filezilla/trunk/fuentes/src/engine/servercapabilities.cpp @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 3 years ago

First release to xenial

File size: 2.9 KB
Line 
1#include <filezilla.h>
2#include "servercapabilities.h"
3
4std::map<CServer, CCapabilities> CServerCapabilities::m_serverMap;
5
6enum capabilities CCapabilities::GetCapability(enum capabilityNames name, wxString* pOption /*=0*/) const
7{
8        const std::map<enum capabilityNames, struct CCapabilities::t_cap>::const_iterator iter = m_capabilityMap.find(name);
9        if (iter == m_capabilityMap.end())
10                return unknown;
11
12        if (iter->second.cap == yes && pOption)
13                *pOption = iter->second.option;
14        return iter->second.cap;
15}
16
17enum capabilities CCapabilities::GetCapability(enum capabilityNames name, int* pOption) const
18{
19        const std::map<enum capabilityNames, struct CCapabilities::t_cap>::const_iterator iter = m_capabilityMap.find(name);
20        if (iter == m_capabilityMap.end())
21                return unknown;
22
23        if (iter->second.cap == yes && pOption)
24                *pOption = iter->second.number;
25        return iter->second.cap;
26}
27
28void CCapabilities::SetCapability(enum capabilityNames name, enum capabilities cap, const wxString& option)
29{
30        wxASSERT(cap == yes || option.empty());
31        struct CCapabilities::t_cap tcap;
32        tcap.cap = cap;
33        tcap.option = option;
34        tcap.number = 0;
35
36        m_capabilityMap[name] = tcap;
37}
38
39void CCapabilities::SetCapability(enum capabilityNames name, enum capabilities cap, int option)
40{
41        wxASSERT(cap == yes || option == 0);
42        struct CCapabilities::t_cap tcap;
43        tcap.cap = cap;
44        tcap.number = option;
45
46        m_capabilityMap[name] = tcap;
47}
48
49enum capabilities CServerCapabilities::GetCapability(const CServer& server, enum capabilityNames name, wxString* pOption /*=0*/)
50{
51        const std::map<CServer, CCapabilities>::const_iterator iter = m_serverMap.find(server);
52        if (iter == m_serverMap.end())
53                return unknown;
54
55        return iter->second.GetCapability(name, pOption);
56}
57
58enum capabilities CServerCapabilities::GetCapability(const CServer& server, enum capabilityNames name, int* pOption)
59{
60        const std::map<CServer, CCapabilities>::const_iterator iter = m_serverMap.find(server);
61        if (iter == m_serverMap.end())
62                return unknown;
63
64        return iter->second.GetCapability(name, pOption);
65}
66
67void CServerCapabilities::SetCapability(const CServer& server, enum capabilityNames name, enum capabilities cap, const wxString& option /*=_T("")*/)
68{
69        const std::map<CServer, CCapabilities>::iterator iter = m_serverMap.find(server);
70        if (iter == m_serverMap.end())
71        {
72                CCapabilities capabilities;
73                capabilities.SetCapability(name, cap, option);
74                m_serverMap[server] = capabilities;
75                return;
76        }
77
78        iter->second.SetCapability(name, cap, option);
79}
80
81void CServerCapabilities::SetCapability(const CServer& server, enum capabilityNames name, enum capabilities cap, int option)
82{
83        const std::map<CServer, CCapabilities>::iterator iter = m_serverMap.find(server);
84        if (iter == m_serverMap.end())
85        {
86                CCapabilities capabilities;
87                capabilities.SetCapability(name, cap, option);
88                m_serverMap[server] = capabilities;
89                return;
90        }
91
92        iter->second.SetCapability(name, cap, option);
93}
Note: See TracBrowser for help on using the repository browser.