diff --git a/VS10Solution.sln b/VS10Solution.sln index c75600d..3f1a075 100644 --- a/VS10Solution.sln +++ b/VS10Solution.sln @@ -42,7 +42,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MsiUseFeature", "MsiUseFeat EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventMonitor", "EventMonitor\EventMonitor.vcxproj", "{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxExtendLib", "lib\wxExtend\build\wxExtendLib.vcxproj", "{D3E29951-D9F5-486D-A167-20AE8E90B1FA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxExtend", "lib\wxExtend\build\wxExtendLib.vcxproj", "{D3E29951-D9F5-486D-A167-20AE8E90B1FA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WLANManager", "WLANManager\WLANManager.vcxproj", "{BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -180,6 +182,14 @@ Global {D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Release|Win32.Build.0 = Release|Win32 {D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Release|x64.ActiveCfg = Release|x64 {D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Release|x64.Build.0 = Release|x64 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Debug|Win32.ActiveCfg = Debug|Win32 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Debug|Win32.Build.0 = Debug|Win32 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Debug|x64.ActiveCfg = Debug|x64 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Debug|x64.Build.0 = Debug|x64 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|Win32.ActiveCfg = Release|Win32 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|Win32.Build.0 = Release|Win32 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|x64.ActiveCfg = Release|x64 + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -201,5 +211,6 @@ Global {2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} {679D03C5-CD70-4FFA-93F8-A4AB3637509B} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} {E0D0725B-B2FC-4225-9481-CA9B1B6306F2} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} EndGlobalSection EndGlobal diff --git a/WLANManager/.gitignore b/WLANManager/.gitignore new file mode 100644 index 0000000..9c8716a --- /dev/null +++ b/WLANManager/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/WLANManager/MSIBuild/.gitignore b/WLANManager/MSIBuild/.gitignore new file mode 100644 index 0000000..80ea676 --- /dev/null +++ b/WLANManager/MSIBuild/.gitignore @@ -0,0 +1,9 @@ +/*-1.idt +/*-2.idt +/*-2.idtx +/*.Binary-1 +/*.Binary-2 +/*.Icon-1 +/*.Icon-2 +/*.lst +/*.msm diff --git a/WLANManager/MSIBuild/Makefile b/WLANManager/MSIBuild/Makefile new file mode 100644 index 0000000..8b81a7b Binary files /dev/null and b/WLANManager/MSIBuild/Makefile differ diff --git a/WLANManager/Main.cpp b/WLANManager/Main.cpp new file mode 100644 index 0000000..f410350 --- /dev/null +++ b/WLANManager/Main.cpp @@ -0,0 +1,136 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "StdAfx.h" + +#pragma comment(lib, "Wlanapi.lib") +#pragma comment(lib, "Wlanui.lib") + +using namespace std; +using namespace winstd; + +DWORD (WINAPI *pfnWlanReasonCodeToString)(__in DWORD dwReasonCode, __in DWORD dwBufferSize, __in_ecount(dwBufferSize) PWCHAR pStringBuffer, __reserved PVOID pReserved); + + +static int DisplayError(_In_z_ _Printf_format_string_ LPCTSTR format, ...) +{ + va_list arg; + va_start(arg, format); + tstring msg; + vsprintf(msg, format, arg); + va_end(arg); + + return MessageBox(NULL, msg.c_str(), _T("WLANManager"), MB_OK); +} + + +static int WLANManager() +{ + int nArgs; + unique_ptr > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs)); + if (pwcArglist == NULL) { + DisplayError(_T("%s function failed (error %u)."), _T("CommandLineToArgvW"), GetLastError()); + return 1; + } + + if (nArgs < 3) { + DisplayError(_T("Not enough parameters.")); + return -1; + } + + if (_wcsicmp(pwcArglist[1], L"profile") != 0) { + DisplayError(_T("Unknown command (%ls)."), pwcArglist[1]); + return -1; + } + + // Open WLAN handle. + DWORD dwNegotiatedVersion; + wlan_handle wlan; + if (!wlan.open(WLAN_API_MAKE_VERSION(2, 0), &dwNegotiatedVersion)) { + DisplayError(_T("%s function failed (error %u)."), _T("WlanOpenHandle"), GetLastError()); + return 2; + } else if (dwNegotiatedVersion < WLAN_API_MAKE_VERSION(2, 0)) { + DisplayError(_T("WlanOpenHandle negotiated unsupported version (expected: %u, negotiated: %u)."), WLAN_API_MAKE_VERSION(2, 0), dwNegotiatedVersion); + return 3; + } + + unique_ptr > interfaces; + { + // Get a list of WLAN interfaces. + WLAN_INTERFACE_INFO_LIST *pInterfaceList; + DWORD dwResult = WlanEnumInterfaces(wlan, NULL, &pInterfaceList); + if (dwResult != ERROR_SUCCESS) { + DisplayError(_T("%s function failed (error %u)."), _T("WlanEnumInterfaces"), dwResult); + return 4; + } + interfaces.reset(pInterfaceList); + } + + for (DWORD i = 0; i < interfaces->dwNumberOfItems; i++) { + if (interfaces->InterfaceInfo[i].isState == wlan_interface_state_not_ready) { + // This interface is not ready. + continue; + } + + // Launch WLAN profile config dialog. + // Note: When a debugger is attached to this process the WlanUIEditProfile() will raise an exception and fail. + WLAN_REASON_CODE wlrc; + DWORD dwResult = WlanUIEditProfile(WLAN_UI_API_VERSION, pwcArglist[2], &(interfaces->InterfaceInfo[i].InterfaceGuid), NULL, WLSecurityPage, NULL, &wlrc); + if (dwResult != ERROR_SUCCESS) { + DisplayError(_T("%s function failed (error %u)."), _T("WlanUIEditProfile"), dwResult); + return 5; + } + if (wlrc != WLAN_REASON_CODE_SUCCESS) { + tstring reason; + if (WlanReasonCodeToString(wlrc, reason, NULL) == ERROR_SUCCESS) + DisplayError(_T("%s function failed: %s"), _T("WlanUIEditProfile"), reason.c_str()); + else + DisplayError(_T("%s function failed (reason code: %u)."), _T("WlanUIEditProfile"), wlrc); + } + + break; + } + + return 0; +} + + +int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hInstance); + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + UNREFERENCED_PARAMETER(nCmdShow); + + { + // Initialize Windows XP visual styles + INITCOMMONCONTROLSEX icc; + icc.dwSize = sizeof(INITCOMMONCONTROLSEX); + icc.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_LINK_CLASS; + InitCommonControlsEx(&icc); + } + + pfnWlanReasonCodeToString = WlanReasonCodeToString; + + int res = WLANManager(); + + assert(!_CrtDumpMemoryLeaks()); + return res; +} diff --git a/WLANManager/README.md b/WLANManager/README.md new file mode 100644 index 0000000..1d74770 --- /dev/null +++ b/WLANManager/README.md @@ -0,0 +1,18 @@ +#WLANManager +Invokes standard Windows Wireless Network Properties dialog + +##Usage +``` +WLANManager profile +``` + +- `name` - The name of the network profile (not neccessarely the same as SSID) + +Return codes: +- -1 = Invalid parameters +- 0 = Success +- 1 = Error parsing command line +- 2 = WLAN handle could not be opened +- 3 = WLAN provider negotiated unsupported version +- 4 = Interface enumeration failed +- 5 = Edit profile UI failed diff --git a/WLANManager/StdAfx.cpp b/WLANManager/StdAfx.cpp new file mode 100644 index 0000000..4af5ec1 --- /dev/null +++ b/WLANManager/StdAfx.cpp @@ -0,0 +1,21 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "StdAfx.h" diff --git a/WLANManager/StdAfx.h b/WLANManager/StdAfx.h new file mode 100644 index 0000000..92aeb9e --- /dev/null +++ b/WLANManager/StdAfx.h @@ -0,0 +1,33 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#pragma once + +#include "../lib/EAPBase_UI/include/EAP_UI.h" + +#include +#include +#include + +#include +#include +#include + +#include diff --git a/WLANManager/WLANManager.props b/WLANManager/WLANManager.props new file mode 100644 index 0000000..2a3442e --- /dev/null +++ b/WLANManager/WLANManager.props @@ -0,0 +1,14 @@ + + + + + + ..\output\$(Platform).$(Configuration)\ + + + + ..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/WLANManager/WLANManager.rc b/WLANManager/WLANManager.rc new file mode 100644 index 0000000..8fdc5d6 Binary files /dev/null and b/WLANManager/WLANManager.rc differ diff --git a/WLANManager/WLANManager.vcxproj b/WLANManager/WLANManager.vcxproj new file mode 100644 index 0000000..7e90ef0 --- /dev/null +++ b/WLANManager/WLANManager.vcxproj @@ -0,0 +1,112 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC} + Win32Proj + WLANManager + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + {47399d91-7eb9-41de-b521-514ba5db0c43} + + + + + + + + + + \ No newline at end of file diff --git a/WLANManager/WLANManager.vcxproj.filters b/WLANManager/WLANManager.vcxproj.filters new file mode 100644 index 0000000..d5e15bf --- /dev/null +++ b/WLANManager/WLANManager.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + Source Files + + + + + Resource Files + + + + + + Resource Files + + + \ No newline at end of file diff --git a/WLANManager/locale/.gitignore b/WLANManager/locale/.gitignore new file mode 100644 index 0000000..85ebba8 --- /dev/null +++ b/WLANManager/locale/.gitignore @@ -0,0 +1 @@ +/*.mo diff --git a/WLANManager/locale/WLANManager.pot b/WLANManager/locale/WLANManager.pot new file mode 100644 index 0000000..6336ccd --- /dev/null +++ b/WLANManager/locale/WLANManager.pot @@ -0,0 +1,32 @@ +msgid "" +msgstr "" +"Project-Id-Version: WLANManager\n" +"POT-Creation-Date: 2016-08-28 12:03+0200\n" +"PO-Revision-Date: 2016-06-02 12:27+0200\n" +"Last-Translator: Simon Rozman \n" +"Language-Team: Amebis, d. o. o., Kamnik \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.8\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: en_US\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: _\n" +"X-Poedit-SearchPath-0: .\n" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:3 +#: MSIBuild/En.x64.Release.Feature-2.idtx:3 +msgid "1252" +msgstr "" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "Helper utility to support direct shortcuts to Wireless Network Properties" +msgstr "" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "WLAN Manager" +msgstr "" diff --git a/WLANManager/locale/sl_SI.po b/WLANManager/locale/sl_SI.po new file mode 100644 index 0000000..ae25856 --- /dev/null +++ b/WLANManager/locale/sl_SI.po @@ -0,0 +1,37 @@ +# Translators: +# Simon Rozman , 2016 +msgid "" +msgstr "" +"Project-Id-Version: WLANManager\n" +"POT-Creation-Date: 2016-08-28 12:03+0200\n" +"PO-Revision-Date: 2016-06-02 12:27+0200\n" +"Last-Translator: Simon Rozman , 2016\n" +"Language-Team: Slovenian (Slovenia) (https://www.transifex.com/eduroam_devel/teams/11799/sl_SI/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\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.8\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-KeywordsList: _\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SourceCharset: UTF-8\n" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:3 +#: MSIBuild/En.x64.Release.Feature-2.idtx:3 +msgid "1252" +msgstr "1250" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "" +"Helper utility to support direct shortcuts to Wireless Network Properties" +msgstr "" +"Orodje za pomoč, ki omogoča neposredne bližnjice do nastavitev brezžičnega " +"omrežja" + +#: MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "WLAN Manager" +msgstr "Upravitelj WLAN" diff --git a/WLANManager/res/WLANManager.ico b/WLANManager/res/WLANManager.ico new file mode 100644 index 0000000..43e3a99 Binary files /dev/null and b/WLANManager/res/WLANManager.ico differ diff --git a/include/MSIBuildCfg.mak b/include/MSIBuildCfg.mak index ecd3829..0e1176c 100644 Binary files a/include/MSIBuildCfg.mak and b/include/MSIBuildCfg.mak differ diff --git a/lib/WinStd b/lib/WinStd index ea9a08e..88a8b7d 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit ea9a08e02a6ecac5721feb4bb730a6fe453f3cf7 +Subproject commit 88a8b7d093f357390065283dd08dac6459685726