Host name and FQDN validators moved to wxExtend >> wxExtend API level incremented to 14

This commit is contained in:
Simon Rozman 2016-10-07 15:23:03 +02:00
parent 3d5ad3986b
commit 4719e99a60
14 changed files with 541 additions and 41 deletions

View File

@ -41,17 +41,17 @@ s$(MSIBUILD_LENGTH_ID) S38 s$(MSIBUILD_LENGTH_ID) i2 S255 S$(MSIBUILD_LENGTH_ID)
Component Component Component Component
!IFNDEF WXEXTEND_STATIC !IFNDEF WXEXTEND_STATIC
!IF "$(PLAT)" == "Win32" !IF "$(PLAT)" == "Win32"
compwxExtend.dll.Win32 {7645D753-4A8C-40C6-BD6F-6DDE54F2B8F8} $(WXEXTEND_BIN_DIR) 0 filewxExtend.dll.Win32 compwxExtend.dll.Win32 {37C6943E-B5D0-4C22-B039-29FEE015D0E8} $(WXEXTEND_BIN_DIR) 0 filewxExtend.dll.Win32
!ENDIF !ENDIF
!IF "$(PLAT)" == "x64" !IF "$(PLAT)" == "x64"
compwxExtend.dll.x64 {919135CB-B106-467E-A3DA-CBC463FBB7FF} $(WXEXTEND_BIN_DIR) 256 filewxExtend.dll.x64 compwxExtend.dll.x64 {F323428B-B329-4492-943C-0F2387C80DC9} $(WXEXTEND_BIN_DIR) 256 filewxExtend.dll.x64
!ENDIF !ENDIF
!ENDIF !ENDIF
!IF "$(LANG)" == "ru_RU" !IF "$(LANG)" == "ru_RU"
compwxExtend.mo.ru_RU {53ED87E7-83E9-44B2-8969-A6B7059466F5} WXEXTENDLOCRURUDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.ru_RU compwxExtend.mo.ru_RU {3B4C86C3-ABFF-4272-B8E4-2E9B59DC7867} WXEXTENDLOCRURUDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.ru_RU
!ENDIF !ENDIF
!IF "$(LANG)" == "sl_SI" !IF "$(LANG)" == "sl_SI"
compwxExtend.mo.sl_SI {08656BB6-0887-4605-B6D3-20B0444624BA} WXEXTENDLOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.sl_SI compwxExtend.mo.sl_SI {E970685D-7997-40C9-A95C-95F1204BD534} WXEXTENDLOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.sl_SI
!ENDIF !ENDIF
<<NOKEEP <<NOKEEP
@ -90,26 +90,26 @@ File File
!IFNDEF WXEXTEND_STATIC !IFNDEF WXEXTEND_STATIC
!IF "$(PLAT)" == "Win32" !IF "$(PLAT)" == "Win32"
!IF "$(CFG)" == "Release" !IF "$(CFG)" == "Release"
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~2.DLL|wxExtend13u_vc100.dll 0 0 1536 1 filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~2.DLL|wxExtend14u_vc100.dll 0 0 1536 1
!ENDIF !ENDIF
!IF "$(CFG)" == "Debug" !IF "$(CFG)" == "Debug"
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~4.DLL|wxExtend13ud_vc100.dll 0 0 1536 1 filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~4.DLL|wxExtend14ud_vc100.dll 0 0 1536 1
!ENDIF !ENDIF
!ENDIF !ENDIF
!IF "$(PLAT)" == "x64" !IF "$(PLAT)" == "x64"
!IF "$(CFG)" == "Release" !IF "$(CFG)" == "Release"
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~6.DLL|wxExtend13u_vc100_x64.dll 0 0 1536 1 filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~6.DLL|wxExtend14u_vc100_x64.dll 0 0 1536 1
!ENDIF !ENDIF
!IF "$(CFG)" == "Debug" !IF "$(CFG)" == "Debug"
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~8.DLL|wxExtend13ud_vc100_x64.dll 0 0 1536 1 filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~8.DLL|wxExtend14ud_vc100_x64.dll 0 0 1536 1
!ENDIF !ENDIF
!ENDIF !ENDIF
!ENDIF !ENDIF
!IF "$(LANG)" == "ru_RU" !IF "$(LANG)" == "ru_RU"
filewxExtend.mo.ru_RU compwxExtend.mo.ru_RU WXEXTE~1.MO|wxExtend13.mo 0 1060 0 1 filewxExtend.mo.ru_RU compwxExtend.mo.ru_RU WXEXTE~1.MO|wxExtend14.mo 0 1049 0 1
!ENDIF !ENDIF
!IF "$(LANG)" == "sl_SI" !IF "$(LANG)" == "sl_SI"
filewxExtend.mo.sl_SI compwxExtend.mo.sl_SI WXEXTE~1.MO|wxExtend13.mo 0 1060 0 1 filewxExtend.mo.sl_SI compwxExtend.mo.sl_SI WXEXTE~1.MO|wxExtend14.mo 0 1060 0 1
!ENDIF !ENDIF
<<NOKEEP <<NOKEEP

View File

@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros"> <PropertyGroup Label="UserMacros">
<wxExtendVersion>13</wxExtendVersion> <wxExtendVersion>14</wxExtendVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutDir>..\..\..\output\$(Platform).$(Configuration)\</OutDir> <OutDir>..\..\..\output\$(Platform).$(Configuration)\</OutDir>

View File

@ -31,6 +31,7 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\src\url.cpp" /> <ClCompile Include="..\src\url.cpp" />
<ClCompile Include="..\src\valhex.cpp" /> <ClCompile Include="..\src\valhex.cpp" />
<ClCompile Include="..\src\valnet.cpp" />
<ClCompile Include="..\src\xml.cpp" /> <ClCompile Include="..\src\xml.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -43,6 +44,7 @@
<ClInclude Include="..\include\wxex\persist\dialog.h" /> <ClInclude Include="..\include\wxex\persist\dialog.h" />
<ClInclude Include="..\include\wxex\url.h" /> <ClInclude Include="..\include\wxex\url.h" />
<ClInclude Include="..\include\wxex\valhex.h" /> <ClInclude Include="..\include\wxex\valhex.h" />
<ClInclude Include="..\include\wxex\valnet.h" />
<ClInclude Include="..\include\wxex\xml.h" /> <ClInclude Include="..\include\wxex\xml.h" />
<ClInclude Include="..\src\stdafx.h" /> <ClInclude Include="..\src\stdafx.h" />
</ItemGroup> </ItemGroup>

View File

@ -46,6 +46,9 @@
<ClCompile Include="..\src\url.cpp"> <ClCompile Include="..\src\url.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\valnet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\stdafx.h"> <ClInclude Include="..\src\stdafx.h">
@ -81,6 +84,9 @@
<ClInclude Include="..\include\wxex\url.h"> <ClInclude Include="..\include\wxex\url.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\include\wxex\valnet.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\locale\wxExtend.pot"> <None Include="..\locale\wxExtend.pot">

View File

@ -31,6 +31,7 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\src\url.cpp" /> <ClCompile Include="..\src\url.cpp" />
<ClCompile Include="..\src\valhex.cpp" /> <ClCompile Include="..\src\valhex.cpp" />
<ClCompile Include="..\src\valnet.cpp" />
<ClCompile Include="..\src\xml.cpp" /> <ClCompile Include="..\src\xml.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -44,6 +45,7 @@
<ClInclude Include="..\include\wxex\persist\dialog.h" /> <ClInclude Include="..\include\wxex\persist\dialog.h" />
<ClInclude Include="..\include\wxex\url.h" /> <ClInclude Include="..\include\wxex\url.h" />
<ClInclude Include="..\include\wxex\valhex.h" /> <ClInclude Include="..\include\wxex\valhex.h" />
<ClInclude Include="..\include\wxex\valnet.h" />
<ClInclude Include="..\include\wxex\xml.h" /> <ClInclude Include="..\include\wxex\xml.h" />
<ClInclude Include="..\src\stdafx.h" /> <ClInclude Include="..\src\stdafx.h" />
</ItemGroup> </ItemGroup>

View File

@ -46,6 +46,9 @@
<ClCompile Include="..\src\url.cpp"> <ClCompile Include="..\src\url.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\valnet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\stdafx.h"> <ClInclude Include="..\src\stdafx.h">
@ -84,6 +87,9 @@
<ClInclude Include="..\include\wxex\object.h"> <ClInclude Include="..\include\wxex\object.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\include\wxex\valnet.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\locale\wxExtend.pot"> <None Include="..\locale\wxExtend.pot">

View File

@ -33,7 +33,7 @@
#define wxEXTEND_VERSION_STR "1.3" #define wxEXTEND_VERSION_STR "1.3"
#define wxEXTEND_BUILD_YEAR_STR "2016" #define wxEXTEND_BUILD_YEAR_STR "2016"
#define wxExtendVersion "13" #define wxExtendVersion "14"
#if !defined(RC_INVOKED) && !defined(MIDL_PASS) #if !defined(RC_INVOKED) && !defined(MIDL_PASS)

171
include/wxex/valnet.h Normal file
View File

@ -0,0 +1,171 @@
/*
Copyright 2015-2016 Amebis
This file is part of wxExtend.
wxExtend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
wxExtend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common.h"
#include <wx/arrstr.h>
#include <wx/textctrl.h>
#include <wx/validate.h>
#ifdef __VISUALC__
// non dll-interface class 'xxx' used as base for dll-interface class 'yyy'
#pragma warning (push)
#pragma warning (disable:4275)
#endif
///
/// Validator for host name
///
class WXEXTEND_API wxHostNameValidator : public wxValidator
{
public:
///
/// Construct the validator with a value to store data
///
wxHostNameValidator(wxString *val = NULL);
///
/// Copies this validator
///
virtual wxObject* Clone() const;
///
/// Validates the value
///
virtual bool Validate(wxWindow *parent);
///
/// Transfers the value to the window
///
virtual bool TransferToWindow();
///
/// Transfers the value from the window
///
virtual bool TransferFromWindow();
///
/// Parses FQDN value
///
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxString *val_out = NULL);
protected:
wxString *m_val; ///< Pointer to variable to receive control's parsed value
private:
wxDECLARE_DYNAMIC_CLASS(wxHostNameValidator);
wxDECLARE_NO_ASSIGN_CLASS(wxHostNameValidator);
};
///
/// Validator for FQDN
///
class WXEXTEND_API wxFQDNValidator : public wxValidator
{
public:
///
/// Construct the validator with a value to store data
///
wxFQDNValidator(wxString *val = NULL);
///
/// Copies this validator
///
virtual wxObject* Clone() const;
///
/// Validates the value
///
virtual bool Validate(wxWindow *parent);
///
/// Transfers the value to the window
///
virtual bool TransferToWindow();
///
/// Transfers the value from the window
///
virtual bool TransferFromWindow();
///
/// Parses FQDN value
///
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxString *val_out = NULL);
protected:
wxString *m_val; ///< Pointer to variable to receive control's parsed value
private:
wxDECLARE_DYNAMIC_CLASS(wxFQDNValidator);
wxDECLARE_NO_ASSIGN_CLASS(wxFQDNValidator);
};
///
/// Validator for FQDN lists
///
class WXEXTEND_API wxFQDNListValidator : public wxValidator
{
public:
///
/// Construct the validator with a value to store data
///
wxFQDNListValidator(wxArrayString *val = NULL);
///
/// Copies this validator
///
virtual wxObject* Clone() const;
///
/// Validates the value
///
virtual bool Validate(wxWindow *parent);
///
/// Transfers the value to the window
///
virtual bool TransferToWindow();
///
/// Transfers the value from the window
///
virtual bool TransferFromWindow();
///
/// Parses FQDN list value
///
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxArrayString *val_out = NULL);
protected:
wxArrayString *m_val; ///< Pointer to variable to receive control's parsed value
private:
wxDECLARE_DYNAMIC_CLASS(wxFQDNListValidator);
wxDECLARE_NO_ASSIGN_CLASS(wxFQDNListValidator);
};
#ifdef __VISUALC__
#pragma warning(pop)
#endif

View File

@ -1,19 +1,32 @@
#
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: wxExtend\n" "Project-Id-Version: wxExtend\n"
"POT-Creation-Date: 2016-10-05 08:39+0200\n" "POT-Creation-Date: 2016-10-07 12:59+0200\n"
"PO-Revision-Date: 2016-10-05 08:39+0200\n" "PO-Revision-Date: 2016-02-06 09:04+0100\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon@rozman.si>, 2016\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: German (https://www.transifex.com/eduroam_devel/teams/11799/de/)\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.9\n" "Language: de\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n" "X-Generator: Poedit 1.8.9\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPath-1: include\n"
"X-Poedit-SourceCharset: UTF-8\n"
#: src/valnet.cpp:99
#, c-format
msgid "Invalid character in host name found: %c"
msgstr "Ungültiger Buchstabe im Servernamen gefunden: %c"
#: src/valnet.cpp:99
msgid "Validation conflict"
msgstr "Fehler bei der Validierung"
#: include/wxex/appbar.h:981 #: include/wxex/appbar.h:981
msgid "" msgid ""

View File

@ -1,20 +1,32 @@
#
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: wxExtend\n" "Project-Id-Version: wxExtend\n"
"POT-Creation-Date: 2016-10-05 08:38+0200\n" "POT-Creation-Date: 2016-10-07 12:59+0200\n"
"PO-Revision-Date: 2016-10-05 08:38+0200\n" "PO-Revision-Date: 2016-02-06 09:04+0100\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon@rozman.si>, 2016\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Russian (Russia) (https://www.transifex.com/eduroam_devel/teams/11799/ru_RU/)\n"
"Language: ru_RU\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: ru_RU\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
"X-Generator: Poedit 1.8.9\n" "X-Generator: Poedit 1.8.9\n"
"X-Poedit-Basepath: .\n" "X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPath-1: include\n"
"X-Poedit-SourceCharset: UTF-8\n"
#: src/valnet.cpp:99
#, c-format
msgid "Invalid character in host name found: %c"
msgstr ""
#: src/valnet.cpp:99
msgid "Validation conflict"
msgstr ""
#: include/wxex/appbar.h:981 #: include/wxex/appbar.h:981
msgid "" msgid ""
@ -23,8 +35,7 @@ msgid ""
"Auto-hide feature is now off." "Auto-hide feature is now off."
msgstr "" msgstr ""
"На этом месте уже автоматически скрыта панель.\n" "На этом месте уже автоматически скрыта панель.\n"
"На каждом месте может находится только одна автоматически скрыта " "На каждом месте может находится только одна автоматически скрыта панель.\n"
"панель.\n"
"Автоматическое скрытие теперь выключен." "Автоматическое скрытие теперь выключен."
#: include/wxex/appbar.h:981 #: include/wxex/appbar.h:981

View File

@ -1,20 +1,32 @@
#
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: wxExtend\n" "Project-Id-Version: wxExtend\n"
"POT-Creation-Date: 2016-10-05 08:38+0200\n" "POT-Creation-Date: 2016-10-07 12:59+0200\n"
"PO-Revision-Date: 2016-10-05 08:38+0200\n" "PO-Revision-Date: 2016-02-06 09:04+0100\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon@rozman.si>, 2016\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Slovenian (Slovenia) (https://www.transifex.com/eduroam_devel/teams/11799/sl_SI/)\n"
"Language: sl_SI\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: sl_SI\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
"X-Generator: Poedit 1.8.9\n" "X-Generator: Poedit 1.8.9\n"
"X-Poedit-Basepath: .\n" "X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPath-1: include\n"
"X-Poedit-SourceCharset: UTF-8\n"
#: src/valnet.cpp:99
#, c-format
msgid "Invalid character in host name found: %c"
msgstr "Napačen znak v imenu gostitelja: %c"
#: src/valnet.cpp:99
msgid "Validation conflict"
msgstr "Nesoglasje pri preverjanju"
#: include/wxex/appbar.h:981 #: include/wxex/appbar.h:981
msgid "" msgid ""

View File

@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: wxExtend\n" "Project-Id-Version: wxExtend\n"
"POT-Creation-Date: 2016-09-19 11:19+0200\n" "POT-Creation-Date: 2016-10-07 12:59+0200\n"
"PO-Revision-Date: 2016-02-06 09:04+0100\n" "PO-Revision-Date: 2016-02-06 09:04+0100\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
@ -18,6 +18,15 @@ msgstr ""
"X-Poedit-SearchPath-0: src\n" "X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPath-1: include\n" "X-Poedit-SearchPath-1: include\n"
#: src/valnet.cpp:99
#, c-format
msgid "Invalid character in host name found: %c"
msgstr ""
#: src/valnet.cpp:99
msgid "Validation conflict"
msgstr ""
#: include/wxex/appbar.h:981 #: include/wxex/appbar.h:981
msgid "" msgid ""
"There is already an auto hidden bar on this edge.\n" "There is already an auto hidden bar on this edge.\n"

View File

@ -30,6 +30,7 @@
#include "../include/wxex/object.h" #include "../include/wxex/object.h"
#include "../include/wxex/url.h" #include "../include/wxex/url.h"
#include "../include/wxex/valhex.h" #include "../include/wxex/valhex.h"
#include "../include/wxex/valnet.h"
#include "../include/wxex/xml.h" #include "../include/wxex/xml.h"
#include "../include/wxex/common.h" #include "../include/wxex/common.h"

267
src/valnet.cpp Normal file
View File

@ -0,0 +1,267 @@
/*
Copyright 2015-2016 Amebis
This file is part of wxExtend.
wxExtend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
wxExtend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////
// wxHostNameValidator
//////////////////////////////////////////////////////////////////////
wxIMPLEMENT_DYNAMIC_CLASS(wxHostNameValidator, wxValidator);
wxHostNameValidator::wxHostNameValidator(wxString *val) :
m_val(val),
wxValidator()
{
}
wxObject* wxHostNameValidator::Clone() const
{
return new wxHostNameValidator(*this);
}
bool wxHostNameValidator::Validate(wxWindow *parent)
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
if (!ctrl->IsEnabled()) return true;
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, parent);
}
bool wxHostNameValidator::TransferToWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
if (m_val)
((wxTextCtrl*)GetWindow())->SetValue(*m_val);
return true;
}
bool wxHostNameValidator::TransferFromWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
}
bool wxHostNameValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxString *val_out)
{
const wxStringCharType *buf = val_in;
size_t i = i_start;
for (;;) {
if (i >= i_end) {
// End of host name found.
if (val_out) val_out->assign(val_in.c_str() + i_start, i - i_start);
return true;
} else if (buf[i] == _T('-') || buf[i] == _T('_') || buf[i] == _T('*') || _istalnum(buf[i])) {
// Valid character found.
i++;
} else {
// Invalid character found.
ctrl->SetFocus();
ctrl->SetSelection(i, i + 1);
wxMessageBox(wxString::Format(_("Invalid character in host name found: %c"), buf[i]), _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return false;
}
}
}
//////////////////////////////////////////////////////////////////////
// wxFQDNValidator
//////////////////////////////////////////////////////////////////////
wxIMPLEMENT_DYNAMIC_CLASS(wxFQDNValidator, wxValidator);
wxFQDNValidator::wxFQDNValidator(wxString *val) :
m_val(val),
wxValidator()
{
}
wxObject* wxFQDNValidator::Clone() const
{
return new wxFQDNValidator(*this);
}
bool wxFQDNValidator::Validate(wxWindow *parent)
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
if (!ctrl->IsEnabled()) return true;
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, parent);
}
bool wxFQDNValidator::TransferToWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
if (m_val)
((wxTextCtrl*)GetWindow())->SetValue(*m_val);
return true;
}
bool wxFQDNValidator::TransferFromWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
}
bool wxFQDNValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxString *val_out)
{
const wxStringCharType *buf = val_in;
size_t i = i_start;
for (;;) {
const wxStringCharType *buf_next;
if ((buf_next = wmemchr(buf + i, L'.', i_end - i)) != NULL) {
// FQDN separator found.
if (!wxHostNameValidator::Parse(val_in, i, buf_next - buf, ctrl, parent))
return false;
i = buf_next - buf + 1;
} else if (wxHostNameValidator::Parse(val_in, i, i_end, ctrl, parent)) {
// The rest of the FQDN parsed succesfully.
if (val_out) val_out->assign(val_in.c_str() + i_start, i_end - i_start);
return true;
} else
return false;
}
}
//////////////////////////////////////////////////////////////////////
// wxFQDNListValidator
//////////////////////////////////////////////////////////////////////
wxIMPLEMENT_DYNAMIC_CLASS(wxFQDNListValidator, wxValidator);
wxFQDNListValidator::wxFQDNListValidator(wxArrayString *val) :
m_val(val),
wxValidator()
{
}
wxObject* wxFQDNListValidator::Clone() const
{
return new wxFQDNListValidator(*this);
}
bool wxFQDNListValidator::Validate(wxWindow *parent)
{
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
if (!ctrl->IsEnabled()) return true;
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, parent);
}
bool wxFQDNListValidator::TransferToWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
if (m_val) {
wxString str;
for (wxArrayString::const_iterator name = m_val->begin(), name_end = m_val->end(); name != name_end; ++name) {
if (!str.IsEmpty()) str += wxT("; ");
str += *name;
}
((wxTextCtrl*)GetWindow())->SetValue(str);
}
return true;
}
bool wxFQDNListValidator::TransferFromWindow()
{
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
wxString val(ctrl->GetValue());
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
}
bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wxArrayString *val_out)
{
const wxStringCharType *buf = val_in;
wxString _fqdn, *fqdn = val_out ? &_fqdn : NULL;
wxArrayString _val_out;
size_t i = i_start;
for (;;) {
// Skip initial white-space.
for (; i < i_end && _istspace(buf[i]); i++);
const wxStringCharType *buf_next;
if ((buf_next = wmemchr(buf + i, L';', i_end - i)) != NULL) {
// FQDN list separator found.
// Skip trailing white-space.
size_t i_next = buf_next - buf;
for (; i < i_next && _istspace(buf[i_next - 1]); i_next--);
if (!wxFQDNValidator::Parse(val_in, i, i_next, ctrl, parent, fqdn))
return false;
if (fqdn && !fqdn->empty()) _val_out.push_back(std::move(*fqdn));
i = buf_next - buf + 1;
} else {
// Skip trailing white-space.
for (; i < i_end && _istspace(buf[i_end - 1]); i_end--);
if (wxFQDNValidator::Parse(val_in, i, i_end, ctrl, parent, fqdn)) {
// The rest of the FQDN list parsed succesfully.
if (fqdn && !fqdn->empty()) _val_out.push_back(std::move(*fqdn));
if (val_out) *val_out = std::move(_val_out);
return true;
} else
return false;
}
}
}