Add licenses

This commit is contained in:
Michael Theall 2020-04-25 17:47:55 -05:00
parent d237b04b3b
commit b78f626f2b
7 changed files with 328 additions and 11 deletions

View File

@ -52,7 +52,7 @@ RSF_FILE := meta/ftpd-classic-cia.rsf
endif
APP_DESCRIPTION := v$(VERSION)
APP_AUTHOR := mtheall
APP_AUTHOR := (c) 2014-2020 Michael Theall, Dave Murphy, TuxSH
ICON := meta/icon.png
BNR_IMAGE := meta/banner.png

View File

@ -35,7 +35,7 @@ NITRO :=
# These set the information text in the nds file
GAME_TITLE := ftpd classic
GAME_SUBTITLE1 := v$(VERSION)
GAME_SUBTITLE2 := (c) mtheall
GAME_SUBTITLE2 := (c) 2014-2020 mtheall
#---------------------------------------------------------------------------------
# options for code generation

View File

@ -37,7 +37,7 @@ include $(DEVKITPRO)/libnx/switch_rules
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
APP_AUTHOR := mtheall, TuxSH, WinterMute
APP_AUTHOR := (c) 2014-2020 Michael Theall, Dave Murphy, TuxSH
ICON := meta/ftpd.jpg
APP_VERSION := $(VERSION)

View File

@ -70,6 +70,12 @@ private:
/// \brief Show menu in the current window
void showMenu ();
/// \brief Show settings menu
void showSettings ();
/// \brief Show about window
void showAbout ();
/// \brief Server loop
void loop ();
@ -102,6 +108,8 @@ private:
#ifndef CLASSIC
/// \brief Whether to show settings menu
bool m_showSettings = false;
/// \brief Whether to show about window
bool m_showAbout = false;
/// \brief User name setting
std::string m_userSetting;

53
include/licenses.h Normal file
View File

@ -0,0 +1,53 @@
// ftpd is a server implementation based on the following:
// - RFC 959 (https://tools.ietf.org/html/rfc959)
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
//
// This program 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.
//
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include "platform.h"
extern char const *const g_dearImGuiVersion;
extern char const *const g_dearImGuiCopyright;
extern char const *const g_mitLicense;
#ifdef _3DS
extern char const *const g_libctruVersion;
extern char const *const g_citro3dVersion;
extern char const *const g_citro3dCopyright;
#endif
#ifdef __SWITCH__
extern char const *const g_libnxVersion;
extern char const *const g_deko3dVersion;
extern char const *const g_zstdVersion;
extern char const *const g_libnxCopyright;
extern char const *const g_deko3dCopyright;
extern char const *const g_zstdCopyright;
extern char const *const g_libnxLicense;
extern char const *const g_bsdLicense;
#endif
#if !defined(NDS)
extern char const *const g_zlibLicense;
#endif
#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__)
extern char const *const g_glfwVersion;
extern char const *const g_glfwCopyright;
#endif

View File

@ -21,6 +21,7 @@
#include "ftpServer.h"
#include "fs.h"
#include "licenses.h"
#include "log.h"
#include "platform.h"
#include "socket.h"
@ -317,6 +318,7 @@ void FtpServer::showMenu ()
{
#ifndef CLASSIC
auto const prevShowSettings = m_showSettings;
auto const prevShowAbout = m_showAbout;
if (ImGui::BeginMenuBar ())
{
@ -329,28 +331,48 @@ void FtpServer::showMenu ()
if (ImGui::MenuItem ("Settings"))
m_showSettings = true;
if (ImGui::MenuItem ("About"))
m_showAbout = true;
ImGui::EndMenu ();
}
ImGui::EndMenuBar ();
}
if (!prevShowSettings && m_showSettings)
if (m_showSettings)
{
m_userSetting = m_config->user ();
m_userSetting.resize (32);
if (!prevShowSettings)
{
m_userSetting = m_config->user ();
m_userSetting.resize (32);
m_passSetting = m_config->pass ();
m_passSetting.resize (32);
m_passSetting = m_config->pass ();
m_passSetting.resize (32);
m_portSetting = m_config->port ();
m_portSetting = m_config->port ();
#ifdef _3DS
m_getMTimeSetting = m_config->getMTime ();
m_getMTimeSetting = m_config->getMTime ();
#endif
ImGui::OpenPopup ("Settings");
ImGui::OpenPopup ("Settings");
}
showSettings ();
}
if (m_showAbout)
{
if (!prevShowAbout)
ImGui::OpenPopup ("About");
showAbout ();
}
}
void FtpServer::showSettings ()
{
#ifndef CLASSIC
#ifdef _3DS
auto const &io = ImGui::GetIO ();
auto const width = io.DisplaySize.x;
@ -420,6 +442,103 @@ void FtpServer::showMenu ()
ImGui::EndPopup ();
}
#endif
#endif
}
void FtpServer::showAbout ()
{
#ifndef CLASSIC
auto const &io = ImGui::GetIO ();
auto const width = io.DisplaySize.x;
auto const height = io.DisplaySize.y;
#ifdef _3DS
ImGui::SetNextWindowSize (ImVec2 (width * 0.8f, height * 0.5f));
ImGui::SetNextWindowPos (ImVec2 (width * 0.1f, height * 0.5f));
#else
ImGui::SetNextWindowSize (ImVec2 (width * 0.8f, height * 0.8f));
ImGui::SetNextWindowPos (ImVec2 (width * 0.1f, height * 0.1f));
#endif
if (ImGui::BeginPopupModal ("About",
nullptr,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextUnformatted (STATUS_STRING);
ImGui::TextWrapped ("Copyright © 2014-2020 Michael Theall, Dave Murphy, TuxSH");
ImGui::Separator ();
ImGui::Text ("Platform: %s", io.BackendPlatformName);
ImGui::Text ("Renderer: %s", io.BackendRendererName);
if (ImGui::Button ("OK", ImVec2 (100, 0)))
{
m_showAbout = false;
ImGui::CloseCurrentPopup ();
}
ImGui::Separator ();
if (ImGui::TreeNode (g_dearImGuiVersion))
{
ImGui::TextWrapped (g_dearImGuiCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_mitLicense);
ImGui::TreePop ();
}
#if defined(NDS)
#elif defined(_3DS)
if (ImGui::TreeNode (g_libctruVersion))
{
ImGui::TextWrapped (g_zlibLicense);
ImGui::Separator ();
ImGui::TextWrapped (g_zlibLicense);
ImGui::TreePop ();
}
if (ImGui::TreeNode (g_citro3dVersion))
{
ImGui::TextWrapped (g_citro3dCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_zlibLicense);
ImGui::TreePop ();
}
#elif defined(__SWITCH__)
if (ImGui::TreeNode (g_libnxVersion))
{
ImGui::TextWrapped (g_libnxCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_libnxLicense);
ImGui::TreePop ();
}
if (ImGui::TreeNode (g_deko3dVersion))
{
ImGui::TextWrapped (g_deko3dCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_zlibLicense);
ImGui::TreePop ();
}
if (ImGui::TreeNode (g_zstdVersion))
{
ImGui::TextWrapped (g_zstdCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_bsdLicense);
ImGui::TreePop ();
}
#else
if (ImGui::TreeNode (g_glfwVersion))
{
ImGui::TextWrapped (g_glfwCopyright);
ImGui::Separator ();
ImGui::TextWrapped (g_zlibLicense);
ImGui::TreePop ();
}
#endif
ImGui::EndPopup ();
}
#endif
}
void FtpServer::loop ()

137
source/licenses.cpp Normal file
View File

@ -0,0 +1,137 @@
// ftpd is a server implementation based on the following:
// - RFC 959 (https://tools.ietf.org/html/rfc959)
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
//
// This program 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.
//
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#include "licenses.h"
#include "imgui.h"
#ifdef __SWITCH__
#include <zstd.h>
#endif
#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__)
#include <GLFW/glfw3.h>
#endif
char const *const g_dearImGuiVersion = "Dear ImGui " IMGUI_VERSION;
char const *const g_dearImGuiCopyright = "Copyright (c) 2014-2020 Omar Cornut";
char const *const g_mitLicense =
"The MIT License (MIT)\n"
"\n"
"Permission is hereby granted, free of charge, to any person obtaining a copy of this software "
"and associated documentation files (the \"Software\"), to deal in the Software without "
"restriction, including without limitation the rights to use, copy, modify, merge, publish, "
"distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the "
"Software is furnished to do so, subject to the following conditions:\n"
"\n"
"The above copyright notice and this permission notice shall be included in all copies or "
"substantial portions of the Software.\n"
"\n"
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "
"INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
"PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR "
"ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, "
"ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE "
"SOFTWARE.";
#ifdef _3DS
char const *const g_libctruVersion = "libctru";
char const *const g_citro3dVersion = "citro3d";
char const *const g_citro3dCopyright = "Copyright (C) 2014-2018 fincs";
#endif
#ifdef __SWITCH__
char const *const g_libnxVersion = "libnx";
char const *const g_deko3dVersion = "deko3d";
char const *const g_zstdVersion = "zStandard " ZSTD_VERSION_STRING;
char const *const g_libnxCopyright = "Copyright 2017-2018 libnx Authors";
char const *const g_deko3dCopyright = "Copyright (C) 2018-2020 fincs\n";
char const *const g_zstdCopyright =
"Copyright (c) 2016-present, Facebook, Inc. All rights reserved.";
char const *const g_libnxLicense =
"Permission to use, copy, modify, and/or distribute this software for any purpose with or "
"without fee is hereby granted, provided that the above copyright notice and this permission "
"notice appear in all copies.\n"
"\n"
"THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO "
"THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT "
"SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY "
"DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF "
"CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE "
"OR PERFORMANCE OF THIS SOFTWARE.";
char const *const g_bsdLicense =
"BSD License\n"
"\n"
"Redistribution and use in source and binary forms, with or without modification, are "
"permitted provided that the following conditions are met:\n"
"\n"
"* Redistributions of source code must retain the above copyright notice, this list of "
"conditions and the following disclaimer.\n"
"\n"
"* Redistributions in binary form must reproduce the above copyright notice, this list of "
"conditions and the following disclaimer in the documentation and/or other materials provided "
"with the distribution.\n"
"\n"
"* Neither the name Facebook nor the names of its contributors may be used to endorse or "
"promote products derived from this software without specific prior written permission.\n"
"\n"
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS "
"OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF "
"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE "
"COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, "
"EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE "
"GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED "
"AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED "
"OF THE POSSIBILITY OF SUCH DAMAGE.";
#endif
#if !defined(NDS)
char const *const g_zlibLicense =
"This software is provided 'as-is', without any express or implied warranty. In no event will "
"the authors be held liable for any damages arising from the use of this software.\n"
"\n"
"Permission is granted to anyone to use this software for any purpose, including commercial "
"applications, and to alter it and redistribute it freely, subject to the following "
"restrictions:\n"
"\n"
"1. The origin of this software must not be misrepresented; you must not claim that you wrote "
"the original software. If you use this software in a product, an acknowledgment in the "
"product documentation would be appreciated but is not required.\n"
"2. Altered source versions must be plainly marked as such, and must not be misrepresented as "
"being the original software.\n"
"3. This notice may not be removed or altered from any source distribution.";
#endif
#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__)
#define STR(x) #x
#define XSTR(x) STR (x)
#define GLFW_VERSION_STRING \
XSTR (GLFW_VERSION_MAJOR) "." XSTR (GLFW_VERSION_MINOR) "." XSTR (GLFW_VERSION_REVISION)
char const *const g_glfwVersion = "glfw " GLFW_VERSION_STRING;
char const *const g_glfwCopyright = "Copyright (c) 2002-2006 Marcus Geelnard\n"
"Copyright (c) 2006-2019 Camilla Löwy";
#endif