├── .vs ├── ProjectSettings.json ├── slnx.sqlite └── VSWorkspaceState.json ├── src ├── discord-RPC │ ├── discord_rpc.cpp │ ├── bin │ │ └── discord-rpc.dll │ ├── lib │ │ └── discord-rpc.lib │ ├── include │ │ ├── discord_register.h │ │ └── discord_rpc.h │ ├── discord_rpc_functions.h │ └── discord_rpc_functions.cpp ├── base │ ├── format.h │ ├── html.h │ ├── gzip.h │ ├── process.h │ ├── base64.h │ ├── json.h │ ├── map.h │ ├── foreach.h │ ├── crypto.h │ ├── optional.h │ ├── types.h │ ├── comparable.h │ ├── log.h │ ├── url.h │ ├── base64.cpp │ ├── json.cpp │ ├── gfx.h │ ├── timer.h │ ├── xml.h │ ├── oauth.h │ ├── settings.h │ ├── process.cpp │ ├── gzip.cpp │ ├── xml.cpp │ ├── timer.cpp │ └── file_monitor.h ├── main.cpp ├── compat │ ├── crypto.h │ └── crypto.cpp ├── sync │ ├── anilist_types.h │ ├── kitsu_types.h │ ├── myanimelist_types.h │ ├── myanimelist.h │ ├── anilist_util.h │ ├── myanimelist_util.h │ ├── manager.h │ ├── sync.h │ ├── kitsu_util.h │ ├── service.cpp │ ├── anilist.h │ └── kitsu.h ├── library │ ├── metadata.cpp │ ├── anime.cpp │ ├── anime_filter.h │ ├── resource.h │ ├── anime_season.h │ ├── metadata.h │ ├── discover.h │ ├── anime_db.h │ ├── anime_util_time.cpp │ ├── anime_filter.cpp │ ├── anime.h │ ├── history.h │ └── anime_episode.h ├── taiga │ ├── version.rc │ ├── debug.h │ ├── dummy.h │ ├── orange.h │ ├── version.h │ ├── path.h │ ├── script.h │ ├── timer.h │ ├── taiga.h │ ├── stats.h │ ├── update.h │ ├── dummy.cpp │ ├── debug.cpp │ ├── orange.cpp │ ├── path.cpp │ └── http.h ├── ui │ ├── dlg │ │ ├── dlg_update_new.h │ │ ├── dlg_update.h │ │ ├── dlg_about.h │ │ ├── dlg_stats.h │ │ ├── dlg_format.h │ │ ├── dlg_history.h │ │ ├── dlg_input.h │ │ ├── dlg_feed_condition.h │ │ ├── dlg_search.h │ │ ├── dlg_torrent.h │ │ ├── dlg_anime_info_page.h │ │ ├── dlg_settings_page.h │ │ ├── dlg_season.h │ │ ├── dlg_settings.h │ │ ├── dlg_input.cpp │ │ ├── dlg_feed_filter.h │ │ ├── dlg_update_new.cpp │ │ ├── dlg_update.cpp │ │ └── dlg_anime_info.h │ ├── dialog.h │ ├── menu.h │ └── list.h └── track │ ├── monitor.h │ ├── search.h │ └── media.h ├── res ├── Taiga.ico └── Taiga.manifest ├── setup └── bitmap │ ├── header.bmp │ └── wizard.bmp ├── data └── theme │ └── Default │ ├── 16px │ ├── feed.png │ ├── film.png │ ├── gear.png │ ├── home.png │ ├── plus.png │ ├── chart.png │ ├── clock.png │ ├── cross.png │ ├── minus.png │ ├── arrow-090.png │ ├── arrow-270.png │ ├── category.png │ ├── funnel-plus.png │ ├── funnel-tick.png │ ├── balloon-left.png │ ├── calendar-month.png │ ├── funnel-cross.png │ ├── funnel-pencil.png │ ├── funnel-small.png │ ├── magnifier-left.png │ ├── arrow-circle-315.png │ ├── document-export.png │ ├── document-import.png │ ├── square-small-red.png │ ├── application-small.png │ ├── document-attribute.png │ ├── square-small-blue.png │ ├── square-small-gray.png │ ├── square-small-green.png │ ├── navigation-270-button.png │ ├── ui-scroll-pane-detail.png │ ├── application-small-blue.png │ ├── folder-small-horizontal.png │ └── sort-quantity-descending.png │ ├── 24px │ ├── feed.png │ ├── gear.png │ ├── globe.png │ ├── taiga.png │ ├── megaphone.png │ ├── folder-open.png │ ├── inbox-document.png │ ├── application-export.png │ ├── document-question.png │ ├── application-sidebar-list.png │ └── arrow-circle-double-135.png │ └── Theme.xml ├── .editorconfig ├── .gitignore ├── project └── vs2017 │ └── Taiga.sln ├── README.md ├── .gitmodules └── deps ├── src └── base64 │ └── base64.h └── build.bat /.vs/ProjectSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "CurrentProjectSetting": "x86-Debug" 3 | } -------------------------------------------------------------------------------- /src/discord-RPC/discord_rpc.cpp: -------------------------------------------------------------------------------- 1 | #include "discord-RPC/include/discord_rpc.h" -------------------------------------------------------------------------------- /res/Taiga.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/res/Taiga.ico -------------------------------------------------------------------------------- /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/.vs/slnx.sqlite -------------------------------------------------------------------------------- /setup/bitmap/header.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/setup/bitmap/header.bmp -------------------------------------------------------------------------------- /setup/bitmap/wizard.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/setup/bitmap/wizard.bmp -------------------------------------------------------------------------------- /data/theme/Default/16px/feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/feed.png -------------------------------------------------------------------------------- /data/theme/Default/16px/film.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/film.png -------------------------------------------------------------------------------- /data/theme/Default/16px/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/gear.png -------------------------------------------------------------------------------- /data/theme/Default/16px/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/home.png -------------------------------------------------------------------------------- /data/theme/Default/16px/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/plus.png -------------------------------------------------------------------------------- /data/theme/Default/24px/feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/feed.png -------------------------------------------------------------------------------- /data/theme/Default/24px/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/gear.png -------------------------------------------------------------------------------- /data/theme/Default/16px/chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/chart.png -------------------------------------------------------------------------------- /data/theme/Default/16px/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/clock.png -------------------------------------------------------------------------------- /data/theme/Default/16px/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/cross.png -------------------------------------------------------------------------------- /data/theme/Default/16px/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/minus.png -------------------------------------------------------------------------------- /data/theme/Default/24px/globe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/globe.png -------------------------------------------------------------------------------- /data/theme/Default/24px/taiga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/taiga.png -------------------------------------------------------------------------------- /data/theme/Default/16px/arrow-090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/arrow-090.png -------------------------------------------------------------------------------- /data/theme/Default/16px/arrow-270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/arrow-270.png -------------------------------------------------------------------------------- /data/theme/Default/16px/category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/category.png -------------------------------------------------------------------------------- /data/theme/Default/24px/megaphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/megaphone.png -------------------------------------------------------------------------------- /src/discord-RPC/bin/discord-rpc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/src/discord-RPC/bin/discord-rpc.dll -------------------------------------------------------------------------------- /src/discord-RPC/lib/discord-rpc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/src/discord-RPC/lib/discord-rpc.lib -------------------------------------------------------------------------------- /data/theme/Default/16px/funnel-plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/funnel-plus.png -------------------------------------------------------------------------------- /data/theme/Default/16px/funnel-tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/funnel-tick.png -------------------------------------------------------------------------------- /data/theme/Default/24px/folder-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/folder-open.png -------------------------------------------------------------------------------- /data/theme/Default/16px/balloon-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/balloon-left.png -------------------------------------------------------------------------------- /data/theme/Default/16px/calendar-month.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/calendar-month.png -------------------------------------------------------------------------------- /data/theme/Default/16px/funnel-cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/funnel-cross.png -------------------------------------------------------------------------------- /data/theme/Default/16px/funnel-pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/funnel-pencil.png -------------------------------------------------------------------------------- /data/theme/Default/16px/funnel-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/funnel-small.png -------------------------------------------------------------------------------- /data/theme/Default/16px/magnifier-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/magnifier-left.png -------------------------------------------------------------------------------- /data/theme/Default/24px/inbox-document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/inbox-document.png -------------------------------------------------------------------------------- /data/theme/Default/16px/arrow-circle-315.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/arrow-circle-315.png -------------------------------------------------------------------------------- /data/theme/Default/16px/document-export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/document-export.png -------------------------------------------------------------------------------- /data/theme/Default/16px/document-import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/document-import.png -------------------------------------------------------------------------------- /data/theme/Default/16px/square-small-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/square-small-red.png -------------------------------------------------------------------------------- /data/theme/Default/16px/application-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/application-small.png -------------------------------------------------------------------------------- /data/theme/Default/16px/document-attribute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/document-attribute.png -------------------------------------------------------------------------------- /data/theme/Default/16px/square-small-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/square-small-blue.png -------------------------------------------------------------------------------- /data/theme/Default/16px/square-small-gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/square-small-gray.png -------------------------------------------------------------------------------- /data/theme/Default/16px/square-small-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/square-small-green.png -------------------------------------------------------------------------------- /data/theme/Default/24px/application-export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/application-export.png -------------------------------------------------------------------------------- /data/theme/Default/24px/document-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/document-question.png -------------------------------------------------------------------------------- /data/theme/Default/16px/navigation-270-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/navigation-270-button.png -------------------------------------------------------------------------------- /data/theme/Default/16px/ui-scroll-pane-detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/ui-scroll-pane-detail.png -------------------------------------------------------------------------------- /data/theme/Default/16px/application-small-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/application-small-blue.png -------------------------------------------------------------------------------- /data/theme/Default/16px/folder-small-horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/folder-small-horizontal.png -------------------------------------------------------------------------------- /data/theme/Default/16px/sort-quantity-descending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/16px/sort-quantity-descending.png -------------------------------------------------------------------------------- /data/theme/Default/24px/application-sidebar-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/application-sidebar-list.png -------------------------------------------------------------------------------- /data/theme/Default/24px/arrow-circle-double-135.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyvorld/taiga/develop/data/theme/Default/24px/arrow-circle-double-135.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{cpp,h}] 4 | charset = latin1 5 | end_of_line = crlf 6 | indent_size = 2 7 | indent_style = space 8 | trim_trailing_whitespace = true 9 | -------------------------------------------------------------------------------- /.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "", 4 | "\\data", 5 | "\\data\\theme", 6 | "\\data\\theme\\Default" 7 | ], 8 | "PreviewInSolutionExplorer": false 9 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | build/* 3 | deps/lib/* 4 | 5 | project/vs*/.vs 6 | project/vs*/ipch 7 | project/vs*/*.db 8 | project/vs*/*.opendb 9 | project/vs*/*.opensdf 10 | project/vs*/*.sdf 11 | project/vs*/*.suo 12 | project/vs*/*.user 13 | -------------------------------------------------------------------------------- /src/discord-RPC/include/discord_register.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(DISCORD_DYNAMIC_LIB) 4 | # if defined(_WIN32) 5 | # if defined(DISCORD_BUILDING_SDK) 6 | # define DISCORD_EXPORT __declspec(dllexport) 7 | # else 8 | # define DISCORD_EXPORT __declspec(dllimport) 9 | # endif 10 | # else 11 | # define DISCORD_EXPORT __attribute__((visibility("default"))) 12 | # endif 13 | #else 14 | # define DISCORD_EXPORT 15 | #endif 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); 22 | DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /src/discord-RPC/discord_rpc_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "discord-RPC/include/discord_rpc.h" 3 | #include 4 | 5 | namespace discord 6 | { 7 | inline const char* APPLICATION_ID = "419764858976993280"; 8 | 9 | void discordInit(); 10 | void discordShutDown(); 11 | void updateDiscordPresence(bool idling = true, const std::wstring& animeName = L""); 12 | static void handleDiscordReady(void); 13 | static void handleDiscordDisconnected(int errcode, const char* message); 14 | static void handleDiscordError(int errcode, const char* message); 15 | static void handleDiscordJoin(const char* secret); 16 | static void handleDiscordSpectate(const char* secret); 17 | static void handleDiscordJoinRequest(const DiscordJoinRequest* request); 18 | } // namespace discord -------------------------------------------------------------------------------- /src/base/format.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | using namespace fmt::literals; 24 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #include "taiga/taiga.h" 20 | 21 | int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { 22 | return Taiga.Run(); 23 | } -------------------------------------------------------------------------------- /src/base/html.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | void DecodeHtmlEntities(std::wstring& str); 24 | void StripHtmlTags(std::wstring& str); 25 | -------------------------------------------------------------------------------- /src/compat/crypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace compat { 24 | 25 | std::wstring SimpleEncrypt(std::wstring str); 26 | std::wstring SimpleDecrypt(std::wstring str); 27 | 28 | } // namespace compat 29 | -------------------------------------------------------------------------------- /src/base/gzip.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | bool UncompressGzippedString(const std::string& input, std::string& output); 24 | 25 | bool DeflateString(const std::string& input, std::string& output); 26 | bool InflateString(const std::string& input, std::string& output, size_t output_length); 27 | -------------------------------------------------------------------------------- /src/base/process.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | bool CheckInstance(LPCWSTR mutex_name, LPCWSTR class_name); 25 | void ActivateWindow(HWND hwnd); 26 | std::wstring GetWindowClass(HWND hwnd); 27 | std::wstring GetWindowTitle(HWND hwnd); 28 | bool IsFullscreen(HWND hwnd); 29 | -------------------------------------------------------------------------------- /src/base/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | std::string Base64Decode(const std::string& str); 24 | std::string Base64Encode(const std::string& str); 25 | 26 | std::wstring Base64Decode(const std::wstring& str, bool for_filename = false); 27 | std::wstring Base64Encode(const std::wstring& str, bool for_filename = false); 28 | -------------------------------------------------------------------------------- /src/sync/anilist_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace sync { 22 | namespace anilist { 23 | 24 | enum class RatingSystem { 25 | Point_100, 26 | Point_10_Decimal, 27 | Point_10, 28 | Point_5, 29 | Point_3, 30 | }; 31 | 32 | constexpr auto kDefaultRatingSystem = RatingSystem::Point_10; 33 | 34 | } // namespace anilist 35 | } // namespace sync 36 | -------------------------------------------------------------------------------- /project/vs2017/Taiga.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2036 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Taiga", "Taiga.vcxproj", "{50BAD968-CEBF-46CA-A18A-FE3E8D625F94}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {50BAD968-CEBF-46CA-A18A-FE3E8D625F94}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {50BAD968-CEBF-46CA-A18A-FE3E8D625F94}.Debug|Win32.Build.0 = Debug|Win32 16 | {50BAD968-CEBF-46CA-A18A-FE3E8D625F94}.Release|Win32.ActiveCfg = Release|Win32 17 | {50BAD968-CEBF-46CA-A18A-FE3E8D625F94}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F8095055-DF1D-4030-9F21-8D5FDCDCBEB3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/library/metadata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #include "metadata.h" 20 | 21 | namespace library { 22 | 23 | Title::Title() 24 | : type(TitleType::Synonym) { 25 | } 26 | 27 | Title::Title(TitleType type, const string_t& value) 28 | : type(type), value(value) { 29 | } 30 | 31 | Metadata::Metadata() 32 | : audience(0), 33 | modified(0), 34 | source(0), 35 | status(0), 36 | type(0) { 37 | } 38 | 39 | } // namespace library -------------------------------------------------------------------------------- /src/taiga/version.rc: -------------------------------------------------------------------------------- 1 | // Generated by ResEdit 1.5.10 2 | // Copyright (C) 2006-2012 3 | // http://www.resedit.net 4 | 5 | #include 6 | #include 7 | #include 8 | #include "version.h" 9 | 10 | 11 | 12 | 13 | // 14 | // Version Information resources 15 | // 16 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 17 | 1 VERSIONINFO 18 | FILEVERSION VERSION_VALUE_DIGITAL 19 | PRODUCTVERSION VERSION_VALUE_DIGITAL 20 | FILEOS VOS_NT_WINDOWS32 21 | FILETYPE VFT_APP 22 | FILESUBTYPE VFT2_UNKNOWN 23 | FILEFLAGSMASK 0x00000000 24 | FILEFLAGS 0x00000000 25 | { 26 | BLOCK "StringFileInfo" 27 | { 28 | BLOCK "0409FDE9" 29 | { 30 | VALUE "CompanyName", "erengy" 31 | VALUE "FileDescription", "Taiga" 32 | VALUE "FileVersion", VERSION_VALUE_STRING 33 | VALUE "InternalName", "Taiga" 34 | VALUE "OriginalFilename", "Taiga.exe" 35 | VALUE "ProductName", "Taiga" 36 | VALUE "ProductVersion", VERSION_VALUE_STRING 37 | } 38 | } 39 | BLOCK "VarFileInfo" 40 | { 41 | VALUE "Translation", 0x0409, 0xFDE9 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_update_new.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace ui { 24 | 25 | class NewUpdateDialog : public win::Dialog { 26 | public: 27 | NewUpdateDialog() {} 28 | ~NewUpdateDialog() {} 29 | 30 | BOOL OnInitDialog(); 31 | void OnOK(); 32 | void OnCancel(); 33 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 34 | }; 35 | 36 | extern NewUpdateDialog DlgUpdateNew; 37 | 38 | } // namespace ui 39 | -------------------------------------------------------------------------------- /src/taiga/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace debug { 25 | 26 | class Tester { 27 | public: 28 | using clock_t = std::chrono::steady_clock; 29 | 30 | Tester(); 31 | 32 | void Start(); 33 | void Stop(std::wstring str, bool display_result); 34 | 35 | private: 36 | clock_t::time_point t0_; 37 | }; 38 | 39 | void Print(std::wstring text); 40 | void Test(); 41 | 42 | } // namespace debug 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Taiga 2 | 3 | Taiga is an open-source desktop application for Windows. It automatically detects the anime videos you're watching on your computer and synchronizes your progress with online services such as [AniList](https://anilist.co), [Kitsu](https://kitsu.io) and [MyAnimeList](https://myanimelist.net). It helps you manage your anime library, discover new series, share watched episodes and download new ones. 4 | 5 | Visit our [home page](http://taiga.moe) for more information. See the [guidelines](https://github.com/erengy/taiga/wiki/Guidelines) if you'd like to contribute. Here's [how to compile](https://github.com/erengy/taiga/wiki/How-to-Compile). 6 | 7 | ## Related projects 8 | 9 | - [Anime relations](https://github.com/erengy/anime-relations): Episode redirections 10 | - [Anime seasons](https://github.com/erengy/anime-seasons): Anime season data 11 | - [Anisthesia](https://github.com/erengy/anisthesia): Media detection library 12 | - [Anitomy](https://github.com/erengy/anitomy): Anime video filename parser 13 | - [taiga.moe](https://github.com/erengy/taiga-moe): Home page of Taiga 14 | 15 | ## License 16 | 17 | Taiga is licensed under [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.html). 18 | -------------------------------------------------------------------------------- /src/taiga/dummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "library/anime_episode.h" 22 | #include "library/anime_item.h" 23 | 24 | namespace taiga { 25 | 26 | class DummyAnime : public anime::Item { 27 | public: 28 | void Initialize(); 29 | }; 30 | 31 | class DummyEpisode : public anime::Episode { 32 | public: 33 | void Initialize(); 34 | }; 35 | 36 | extern class DummyAnime DummyAnime; 37 | extern class DummyEpisode DummyEpisode; 38 | 39 | } // namespace taiga 40 | -------------------------------------------------------------------------------- /src/taiga/orange.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace taiga { 24 | 25 | class Orange : public win::Thread { 26 | public: 27 | Orange(); 28 | ~Orange(); 29 | 30 | void Start(); 31 | void Stop(); 32 | 33 | DWORD ThreadProc(); 34 | 35 | private: 36 | float NoteToFrequency(int n); 37 | 38 | static int note_list_[][2]; 39 | bool play_; 40 | }; 41 | 42 | extern Orange orange; 43 | 44 | } // namespace taiga 45 | -------------------------------------------------------------------------------- /src/library/anime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #include "anime.h" 20 | 21 | namespace anime { 22 | 23 | MyInformation::MyInformation() 24 | : watched_episodes(0), 25 | score(0), 26 | status(kNotInList), 27 | rewatched_times(0), 28 | rewatching(FALSE), 29 | rewatching_ep(0) { 30 | } 31 | 32 | LocalInformation::LocalInformation() 33 | : last_aired_episode(0), 34 | playing(false), 35 | use_alternative(false) { 36 | } 37 | 38 | } // namespace anime -------------------------------------------------------------------------------- /src/track/monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/file_monitor.h" 22 | 23 | class FolderMonitor : public DirectoryMonitor { 24 | public: 25 | void Enable(bool enabled = true); 26 | void HandleChangeNotification(const DirectoryChangeNotification& notification) const; 27 | 28 | private: 29 | void OnDirectory(const DirectoryChangeNotification& notification) const; 30 | void OnFile(const DirectoryChangeNotification& notification) const; 31 | }; 32 | 33 | extern class FolderMonitor FolderMonitor; 34 | -------------------------------------------------------------------------------- /src/sync/kitsu_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace sync { 22 | namespace kitsu { 23 | 24 | enum MyPrivacy { 25 | kPrivate = 1, 26 | kPublic 27 | }; 28 | 29 | enum MyStatus { 30 | kCurrentlyWatching = 1, 31 | kPlanToWatch, 32 | kCompleted, 33 | kOnHold, 34 | kDropped 35 | }; 36 | 37 | enum class RatingSystem { 38 | Simple, 39 | Regular, 40 | Advanced, 41 | }; 42 | 43 | constexpr auto kDefaultRatingSystem = RatingSystem::Regular; 44 | 45 | } // namespace kitsu 46 | } // namespace sync 47 | -------------------------------------------------------------------------------- /src/sync/myanimelist_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace sync { 22 | namespace myanimelist { 23 | 24 | enum SeriesStatus { 25 | kUnknownStatus, 26 | kAiring, 27 | kFinishedAiring, 28 | kNotYetAired 29 | }; 30 | 31 | enum SeriesType { 32 | kUnknownType, 33 | kTv, 34 | kOva, 35 | kMovie, 36 | kSpecial, 37 | kOna, 38 | kMusic 39 | }; 40 | 41 | enum MyStatus { 42 | kWatching = 1, 43 | kCompleted, 44 | kOnHold, 45 | kDropped, 46 | kPlanToWatch = 6 47 | }; 48 | 49 | } // namespace myanimelist 50 | } // namespace sync 51 | -------------------------------------------------------------------------------- /src/base/json.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | 25 | using Json = nlohmann::json; 26 | 27 | bool JsonParseString(const std::string& str, Json& output); 28 | bool JsonParseString(const std::wstring& str, Json& output); 29 | 30 | bool JsonReadBool(const Json& json, const std::string& key); 31 | double JsonReadDouble(const Json& json, const std::string& key); 32 | int JsonReadInt(const Json& json, const std::string& key); 33 | std::string JsonReadStr(const Json& json, const std::string& key); 34 | -------------------------------------------------------------------------------- /src/taiga/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #define XSTRINGIFY(s) STRINGIFY(s) 22 | #define STRINGIFY(s) #s 23 | 24 | #define TAIGA_VERSION_MAJOR 1 25 | #define TAIGA_VERSION_MINOR 3 26 | #define TAIGA_VERSION_PATCH 0 27 | #define TAIGA_VERSION_PRE "beta.2-Discord.3" 28 | #define TAIGA_VERSION_BUILD 0 29 | 30 | #define VERSION_VALUE_DIGITAL TAIGA_VERSION_MAJOR, TAIGA_VERSION_MINOR, TAIGA_VERSION_PATCH, TAIGA_VERSION_BUILD 31 | #define VERSION_VALUE_STRING XSTRINGIFY(TAIGA_VERSION_MAJOR) "." XSTRINGIFY(TAIGA_VERSION_MINOR) "." XSTRINGIFY(TAIGA_VERSION_PATCH) "\0" 32 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_update.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace ui { 25 | 26 | class UpdateDialog : public win::Dialog { 27 | public: 28 | UpdateDialog(); 29 | ~UpdateDialog() {} 30 | 31 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 32 | BOOL OnDestroy(); 33 | BOOL OnInitDialog(); 34 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 35 | 36 | win::ProgressBar progressbar; 37 | }; 38 | 39 | extern UpdateDialog DlgUpdate; 40 | 41 | } // namespace ui 42 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_about.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace ui { 25 | 26 | class AboutDialog : public win::Dialog { 27 | public: 28 | AboutDialog(); 29 | ~AboutDialog() {} 30 | 31 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 32 | BOOL OnDestroy(); 33 | BOOL OnInitDialog(); 34 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 35 | 36 | private: 37 | win::RichEdit rich_edit_; 38 | }; 39 | 40 | extern AboutDialog DlgAbout; 41 | 42 | } // namespace ui 43 | -------------------------------------------------------------------------------- /src/ui/dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace ui { 24 | 25 | enum class Dialog { 26 | None, 27 | About, 28 | AnimeInformation, 29 | Main, 30 | Settings, 31 | Torrents, 32 | Update, 33 | }; 34 | 35 | void EndDialog(Dialog dialog); 36 | void EnableDialogInput(Dialog dialog, bool enable); 37 | HWND GetWindowHandle(Dialog dialog); 38 | void ShowDialog(Dialog dialog); 39 | 40 | void ShowDlgAnimeEdit(int anime_id); 41 | void ShowDlgAnimeInfo(int anime_id); 42 | void ShowDlgSettings(int section, int page); 43 | 44 | } // namespace ui 45 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_stats.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace ui { 25 | 26 | class StatsDialog : public win::Dialog, public win::Resizable { 27 | public: 28 | StatsDialog(); 29 | ~StatsDialog() {} 30 | 31 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 32 | BOOL OnInitDialog(); 33 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 34 | void OnSize(UINT uMsg, UINT nType, SIZE size); 35 | 36 | void Refresh(); 37 | }; 38 | 39 | extern StatsDialog DlgStats; 40 | 41 | } // namespace ui 42 | -------------------------------------------------------------------------------- /src/library/anime_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace anime { 26 | 27 | class Item; 28 | 29 | class Filters { 30 | public: 31 | Filters(); 32 | virtual ~Filters() {} 33 | 34 | bool CheckItem(const Item& item, int text_index) const; 35 | void Reset(); 36 | 37 | std::vector my_status; 38 | std::vector status; 39 | std::vector type; 40 | std::map text; 41 | 42 | private: 43 | bool FilterText(const Item& item, int text_index) const; 44 | }; 45 | 46 | } // namespace anime 47 | -------------------------------------------------------------------------------- /src/base/map.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace base { 24 | 25 | // A multimap implementation that allows accessing the first value that is 26 | // mapped to a given key. 27 | 28 | template 29 | class multimap : public std::multimap { 30 | public: 31 | mapped_type& operator[] (const key_type& key) { 32 | auto it = this->find(key); 33 | if (it == this->end()) 34 | it = this->insert(std::pair(key, mapped_type())); 35 | return it->second; 36 | } 37 | }; 38 | 39 | } // namespace base 40 | -------------------------------------------------------------------------------- /src/base/foreach.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | // iterator 22 | #define foreach_(item, container) \ 23 | for (auto item = (container).begin(); item != (container).end(); ++item) 24 | 25 | // reverse iterator 26 | #define foreach_r_(item, container) \ 27 | for (auto item = (container).rbegin(); item != (container).rend(); ++item) 28 | 29 | // const iterator 30 | #define foreach_c_(item, container) \ 31 | for (auto item = (container).cbegin(); item != (container).cend(); ++item) 32 | 33 | // const reverse iterator 34 | #define foreach_cr_(item, container) \ 35 | for (auto item = (container).crbegin(); item != (container).crend(); ++item) 36 | -------------------------------------------------------------------------------- /src/base/crypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | class StringCoder { 24 | public: 25 | StringCoder(); 26 | 27 | bool Encode(const std::wstring& metadata, const std::wstring& data, std::wstring& output); 28 | bool Decode(const std::wstring& input, std::wstring& metadata, std::wstring& data); 29 | 30 | private: 31 | std::string ConvertSizeToString(unsigned short value); 32 | unsigned short ReadSize(const std::string& str, size_t pos); 33 | 34 | const std::string magic_string_; 35 | const size_t min_length_; 36 | const unsigned char version_; 37 | }; 38 | 39 | std::string HmacSha1(const std::string& key_bytes, const std::string& data); 40 | -------------------------------------------------------------------------------- /src/taiga/path.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace sync { 24 | enum ServiceId; 25 | } 26 | 27 | namespace taiga { 28 | 29 | enum class Path { 30 | Data, 31 | Database, 32 | DatabaseAnime, 33 | DatabaseAnimeRelations, 34 | DatabaseImage, 35 | DatabaseSeason, 36 | Feed, 37 | FeedHistory, 38 | Media, 39 | Settings, 40 | Test, 41 | TestRecognition, 42 | Theme, 43 | ThemeCurrent, 44 | User, 45 | UserHistory, 46 | UserLibrary 47 | }; 48 | 49 | std::wstring GetUserDirectoryName(const sync::ServiceId service_id); 50 | std::wstring GetUserDirectoryName(); 51 | std::wstring GetPath(Path path); 52 | 53 | } // namespace taiga 54 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_format.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace ui { 25 | 26 | enum class FormatDialogMode { 27 | Http, 28 | Mirc, 29 | Skype, 30 | Twitter, 31 | Balloon, 32 | }; 33 | 34 | class FormatDialog : public win::Dialog { 35 | public: 36 | FormatDialog(); 37 | ~FormatDialog() {} 38 | 39 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 40 | BOOL OnInitDialog(); 41 | void OnOK(); 42 | 43 | void ColorizeText(); 44 | void RefreshPreviewText(); 45 | 46 | FormatDialogMode mode; 47 | 48 | private: 49 | win::RichEdit rich_edit_; 50 | }; 51 | 52 | extern FormatDialog DlgFormat; 53 | 54 | } // namespace ui 55 | -------------------------------------------------------------------------------- /src/base/optional.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | template 22 | class Optional { 23 | public: 24 | Optional() : initialized_(false) {} 25 | Optional(const T& value) : initialized_(true), value_(value) {} 26 | virtual ~Optional() {} 27 | 28 | void Reset() { 29 | initialized_ = false; 30 | } 31 | 32 | operator bool() const { 33 | return initialized_; 34 | } 35 | 36 | const T& operator *() const { 37 | return value_; 38 | } 39 | 40 | const T* operator ->() const { 41 | return &value_; 42 | } 43 | 44 | T& operator =(const T& value) { 45 | value_ = value; 46 | initialized_ = true; 47 | return value_; 48 | } 49 | 50 | private: 51 | bool initialized_; 52 | T value_; 53 | }; 54 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_history.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace ui { 25 | 26 | class HistoryDialog : public win::Dialog { 27 | public: 28 | HistoryDialog() {} 29 | ~HistoryDialog() {} 30 | 31 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 32 | void OnContextMenu(HWND hwnd, POINT pt); 33 | BOOL OnInitDialog(); 34 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 35 | void OnSize(UINT uMsg, UINT nType, SIZE size); 36 | BOOL PreTranslateMessage(MSG* pMsg); 37 | 38 | void RefreshList(); 39 | bool RemoveSelectedItems(); 40 | 41 | private: 42 | win::ListView list_; 43 | }; 44 | 45 | extern HistoryDialog DlgHistory; 46 | 47 | } // namespace ui 48 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "anime-relations"] 2 | path = deps/data/anime-relations 3 | url = https://github.com/erengy/anime-relations.git 4 | 5 | [submodule "anime-seasons"] 6 | path = deps/data/anime-seasons 7 | url = https://github.com/erengy/anime-seasons.git 8 | 9 | [submodule "anisthesia"] 10 | path = deps/src/anisthesia 11 | url = https://github.com/erengy/anisthesia.git 12 | 13 | [submodule "anitomy"] 14 | path = deps/src/anitomy 15 | url = https://github.com/erengy/anitomy.git 16 | 17 | [submodule "curl"] 18 | path = deps/src/curl 19 | url = https://github.com/curl/curl.git 20 | 21 | [submodule "date"] 22 | path = deps/src/date 23 | url = https://github.com/HowardHinnant/date.git 24 | 25 | [submodule "fmt"] 26 | path = deps/src/fmt 27 | url = https://github.com/fmtlib/fmt.git 28 | 29 | [submodule "json"] 30 | path = deps/src/json 31 | url = https://github.com/nlohmann/json.git 32 | 33 | [submodule "monolog"] 34 | path = deps/src/monolog 35 | url = https://github.com/erengy/monolog.git 36 | 37 | [submodule "pugixml"] 38 | path = deps/src/pugixml 39 | url = https://github.com/zeux/pugixml.git 40 | 41 | [submodule "semaver"] 42 | path = deps/src/semaver 43 | url = https://github.com/erengy/semaver.git 44 | 45 | [submodule "utf8proc"] 46 | path = deps/src/utf8proc 47 | url = https://github.com/erengy/utf8proc.git 48 | 49 | [submodule "windows"] 50 | path = deps/src/windows 51 | url = https://github.com/erengy/windows.git 52 | 53 | [submodule "zlib"] 54 | path = deps/src/zlib 55 | url = https://github.com/madler/zlib.git 56 | -------------------------------------------------------------------------------- /src/library/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include "base/gfx.h" 24 | 25 | namespace anime { 26 | 27 | class ImageDatabase { 28 | public: 29 | ImageDatabase() {} 30 | virtual ~ImageDatabase() {} 31 | 32 | // Loads a picture into memory, downloads a new file if requested. 33 | bool Load(int anime_id, bool load, bool download); 34 | 35 | bool Reload(int anime_id); 36 | 37 | // Releases image data from memory if an image is not in sight. 38 | void FreeMemory(); 39 | void Clear(); 40 | 41 | // Returns a pointer to requested image if available. 42 | base::Image* GetImage(int anime_id); 43 | 44 | private: 45 | std::map items_; 46 | }; 47 | 48 | } // namespace anime 49 | 50 | extern anime::ImageDatabase ImageDatabase; 51 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace ui { 27 | 28 | class InputDialog : public win::Dialog { 29 | public: 30 | InputDialog(); 31 | ~InputDialog() {} 32 | 33 | void OnCancel(); 34 | BOOL OnInitDialog(); 35 | void OnOK(); 36 | 37 | void SetNumbers(bool enabled, int min_value, int max_value, int current_value); 38 | void SetPassword(bool enabled); 39 | void Show(HWND parent = nullptr); 40 | 41 | INT_PTR result; 42 | std::wstring info, title, text; 43 | 44 | private: 45 | int current_value_, min_value_, max_value_; 46 | bool numbers_only_, password_; 47 | win::Edit edit_; 48 | win::Spin spin_; 49 | }; 50 | 51 | } // namespace ui 52 | -------------------------------------------------------------------------------- /res/Taiga.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_feed_condition.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "track/feed.h" 22 | #include 23 | #include 24 | 25 | namespace ui { 26 | 27 | class FeedConditionDialog : public win::Dialog { 28 | public: 29 | FeedConditionDialog(); 30 | ~FeedConditionDialog() {} 31 | 32 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 33 | void OnCancel(); 34 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 35 | BOOL OnInitDialog(); 36 | void OnOK(); 37 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 38 | 39 | void ChooseElement(int index); 40 | 41 | FeedFilterCondition condition; 42 | 43 | private: 44 | win::ComboBox element_combo_, operator_combo_, value_combo_; 45 | }; 46 | 47 | extern FeedConditionDialog DlgFeedCondition; 48 | 49 | } // namespace ui 50 | -------------------------------------------------------------------------------- /src/taiga/script.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace anime { 24 | class Episode; 25 | } 26 | 27 | void ExecuteAction(std::wstring action, WPARAM wParam = 0, LPARAM lParam = 0); 28 | 29 | std::wstring EvaluateFunction(const std::wstring& func_name, const std::wstring& func_body); 30 | 31 | bool IsScriptFunction(const std::wstring& str); 32 | bool IsScriptVariable(const std::wstring& str); 33 | 34 | std::wstring ReplaceVariables(std::wstring str, 35 | const anime::Episode& episode, 36 | bool url_encode = false, 37 | bool is_manual = false, 38 | bool is_preview = false); 39 | 40 | std::wstring EscapeScriptEntities(const std::wstring& str); 41 | std::wstring UnescapeScriptEntities(const std::wstring& str); 42 | -------------------------------------------------------------------------------- /src/base/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace base { 27 | namespace http { 28 | class Request; 29 | class Response; 30 | } 31 | } 32 | 33 | namespace base { 34 | 35 | // Unique ID type 36 | typedef std::wstring uid_t; 37 | 38 | } // namespace base 39 | 40 | // Default enumeration type 41 | typedef unsigned char enum_t; 42 | 43 | // Default string type 44 | typedef std::wstring string_t; 45 | 46 | // Dictionary types 47 | typedef std::map dictionary_t; 48 | typedef std::map> multidictionary_t; 49 | 50 | // HTTP request and response 51 | typedef base::http::Request HttpRequest; 52 | typedef base::http::Response HttpResponse; 53 | 54 | // 64-bit integral data type (quadword) 55 | typedef unsigned __int64 QWORD, *LPQWORD; 56 | -------------------------------------------------------------------------------- /deps/src/base64/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** base64.h: interface for the Base64Coder class. 3 | ** http://support.microsoft.com/kb/191239 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | // ============================================================================= 12 | 13 | class Base64Coder { 14 | class TempBucket { 15 | public: 16 | BYTE nData[4]; 17 | BYTE nSize; 18 | void Clear() { ::ZeroMemory(nData, 4); nSize = 0; }; 19 | }; 20 | 21 | PBYTE m_pDBuffer; 22 | PBYTE m_pEBuffer; 23 | DWORD m_nDBufLen; 24 | DWORD m_nEBufLen; 25 | DWORD m_nDDataLen; 26 | DWORD m_nEDataLen; 27 | 28 | public: 29 | Base64Coder(); 30 | virtual ~Base64Coder(); 31 | 32 | virtual void Encode(const PBYTE, DWORD); 33 | virtual void Decode(const PBYTE, DWORD); 34 | virtual void Encode(LPCSTR sMessage); 35 | virtual void Decode(LPCSTR sMessage); 36 | 37 | virtual std::string DecodedMessage() const; 38 | virtual std::string EncodedMessage() const; 39 | 40 | virtual void AllocEncode(DWORD); 41 | virtual void AllocDecode(DWORD); 42 | virtual void SetEncodeBuffer(const PBYTE pBuffer, DWORD nBufLen); 43 | virtual void SetDecodeBuffer(const PBYTE pBuffer, DWORD nBufLen); 44 | 45 | protected: 46 | virtual void _EncodeToBuffer(const TempBucket& Decode, PBYTE pBuffer); 47 | virtual ULONG _DecodeToBuffer(const TempBucket& Decode, PBYTE pBuffer); 48 | virtual void _EncodeRaw(TempBucket&, const TempBucket&); 49 | virtual void _DecodeRaw(TempBucket&, const TempBucket&); 50 | virtual BOOL _IsBadMimeChar(BYTE); 51 | 52 | static char m_DecodeTable[256]; 53 | static BOOL m_Init; 54 | void _Init(); 55 | }; 56 | -------------------------------------------------------------------------------- /src/base/comparable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace base { 22 | 23 | enum CompareResult { 24 | kLessThan = -1, 25 | kEqualTo = 0, 26 | kGreaterThan = 1, 27 | }; 28 | 29 | template 30 | class Comparable { 31 | public: 32 | bool operator==(const T& rhs) const { 33 | return Compare(rhs) == kEqualTo; 34 | } 35 | bool operator!=(const T& rhs) const { 36 | return !operator==(rhs); 37 | } 38 | bool operator<(const T& rhs) const { 39 | return Compare(rhs) == kLessThan; 40 | } 41 | bool operator<=(const T& rhs) const { 42 | return !operator>(rhs); 43 | } 44 | bool operator>(const T& rhs) const { 45 | return Compare(rhs) == kGreaterThan; 46 | } 47 | bool operator>=(const T& rhs) const { 48 | return !operator<(rhs); 49 | } 50 | 51 | private: 52 | virtual CompareResult Compare(const T& rhs) const = 0; 53 | }; 54 | 55 | } // namespace base 56 | -------------------------------------------------------------------------------- /src/base/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace base { 25 | 26 | template 27 | void Log(const monolog::Level level, const monolog::Source& source, 28 | const std::wstring& str, const Args&... args) { 29 | const monolog::Record record{sizeof...(Args) ? fmt::format(str, args...) : str}; 30 | monolog::log.Write(level, record, source); 31 | } 32 | 33 | } // namespace base 34 | 35 | #define TAIGA_LOG(level, text, ...) \ 36 | base::Log(level, monolog::Source{__FILE__, __FUNCTION__, __LINE__}, text, __VA_ARGS__) 37 | 38 | #define LOGD(text, ...) TAIGA_LOG(monolog::Level::Debug, text, __VA_ARGS__) 39 | #define LOGI(text, ...) TAIGA_LOG(monolog::Level::Informational, text, __VA_ARGS__) 40 | #define LOGW(text, ...) TAIGA_LOG(monolog::Level::Warning, text, __VA_ARGS__) 41 | #define LOGE(text, ...) TAIGA_LOG(monolog::Level::Error, text, __VA_ARGS__) 42 | -------------------------------------------------------------------------------- /src/taiga/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/timer.h" 22 | 23 | namespace taiga { 24 | 25 | enum TimerIds { 26 | kTimerAnimeList = 1, 27 | kTimerDetection, 28 | kTimerHistory, 29 | kTimerLibrary, 30 | kTimerMedia, 31 | kTimerMemory, 32 | kTimerStats, 33 | kTimerTorrents 34 | }; 35 | 36 | class Timer : public base::Timer { 37 | public: 38 | Timer(unsigned int id, int interval = 1 /*second*/, bool repeat = true); 39 | ~Timer() {} 40 | 41 | protected: 42 | void OnTimeout(); 43 | }; 44 | 45 | class TimerManager : public base::TimerManager { 46 | public: 47 | void Initialize(); 48 | 49 | void UpdateEnabledState(); 50 | void UpdateIntervalsFromSettings(); 51 | void UpdateUi(); 52 | 53 | protected: 54 | void OnTick(); 55 | 56 | private: 57 | static void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); 58 | }; 59 | 60 | extern TimerManager timers; 61 | 62 | } // namespace taiga 63 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace ui { 28 | 29 | class SearchDialog : public win::Dialog { 30 | public: 31 | SearchDialog() {}; 32 | ~SearchDialog() {}; 33 | 34 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 35 | void OnContextMenu(HWND hwnd, POINT pt); 36 | BOOL OnInitDialog(); 37 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 38 | void OnSize(UINT uMsg, UINT nType, SIZE size); 39 | 40 | void AddAnimeToList(int anime_id); 41 | void ParseResults(const std::vector& ids); 42 | void RefreshList(); 43 | void Search(const std::wstring& title, bool local = false); 44 | 45 | std::wstring search_text; 46 | 47 | private: 48 | std::vector anime_ids_; 49 | win::ListView list_; 50 | }; 51 | 52 | extern SearchDialog DlgSearch; 53 | 54 | } // namespace ui 55 | -------------------------------------------------------------------------------- /src/base/url.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include "map.h" 24 | 25 | typedef base::multimap query_t; 26 | 27 | namespace base { 28 | namespace http { 29 | enum class Protocol { 30 | Http, 31 | Https, 32 | Relative, 33 | }; 34 | } 35 | } 36 | 37 | class Url { 38 | public: 39 | Url(); 40 | Url(const std::wstring& url); 41 | ~Url() {} 42 | 43 | void Clear(); 44 | std::wstring Build() const; 45 | void Crack(std::wstring url); 46 | 47 | Url& operator=(const Url& url); 48 | void operator=(const std::wstring& url); 49 | 50 | base::http::Protocol protocol; 51 | std::wstring host; 52 | unsigned short port; 53 | std::wstring path; 54 | query_t query; 55 | std::wstring fragment; 56 | }; 57 | 58 | std::wstring BuildUrlParameters(const query_t& parameters); 59 | std::wstring DecodeUrl(const std::wstring& input); 60 | std::wstring EncodeUrl(const std::wstring& input, bool encode_unreserved = false); 61 | -------------------------------------------------------------------------------- /src/library/anime_season.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include "base/comparable.h" 24 | 25 | class Date; 26 | 27 | namespace anime { 28 | 29 | class Season : public base::Comparable { 30 | public: 31 | enum Name { 32 | kUnknown, 33 | kWinter, 34 | kSpring, 35 | kSummer, 36 | kFall 37 | }; 38 | 39 | Season(); 40 | Season(Name name, unsigned short year); 41 | Season(const Date& date); 42 | Season(const std::wstring& str); 43 | ~Season() {} 44 | 45 | Season& operator = (const Season& season); 46 | Season& operator ++ (); 47 | Season& operator -- (); 48 | 49 | operator bool() const; 50 | 51 | void GetInterval(Date& date_start, Date& date_end) const; 52 | std::wstring GetName() const; 53 | std::wstring GetString() const; 54 | 55 | Name name; 56 | unsigned short year; 57 | 58 | private: 59 | base::CompareResult Compare(const Season& season) const; 60 | }; 61 | 62 | } // namespace anime 63 | -------------------------------------------------------------------------------- /src/taiga/taiga.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #include "taiga/update.h" 25 | 26 | #define TAIGA_APP_NAME L"Taiga" 27 | #define TAIGA_APP_TITLE L"Taiga" 28 | 29 | #define TAIGA_PORTABLE 30 | 31 | namespace taiga { 32 | 33 | class App : public win::App { 34 | public: 35 | App(); 36 | ~App(); 37 | 38 | BOOL InitInstance(); 39 | void Uninitialize(); 40 | 41 | void LoadData(); 42 | 43 | bool allow_multiple_instances; 44 | bool debug_mode; 45 | semaver::Version version; 46 | 47 | class Updater : public UpdateHelper { 48 | public: 49 | void OnCheck(); 50 | void OnCRCCheck(const std::wstring& path, std::wstring& crc); 51 | void OnDone(); 52 | void OnProgress(int file_index); 53 | bool OnRestartApp(); 54 | void OnRunActions(); 55 | } Updater; 56 | 57 | private: 58 | void ParseCommandLineArguments(); 59 | }; 60 | 61 | } // namespace taiga 62 | 63 | extern taiga::App Taiga; 64 | -------------------------------------------------------------------------------- /src/sync/myanimelist.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/types.h" 22 | #include "sync/service.h" 23 | 24 | namespace sync { 25 | namespace myanimelist { 26 | 27 | // API documentation: 28 | // https://myanimelist.net/modules.php?go=api 29 | 30 | class Service : public sync::Service { 31 | public: 32 | Service(); 33 | ~Service() {} 34 | 35 | void BuildRequest(Request& request, HttpRequest& http_request); 36 | void HandleResponse(Response& response, HttpResponse& http_response); 37 | bool RequestNeedsAuthentication(RequestType request_type) const; 38 | 39 | private: 40 | REQUEST_AND_RESPONSE(AddLibraryEntry); 41 | REQUEST_AND_RESPONSE(AuthenticateUser); 42 | REQUEST_AND_RESPONSE(DeleteLibraryEntry); 43 | REQUEST_AND_RESPONSE(GetLibraryEntries); 44 | REQUEST_AND_RESPONSE(GetMetadataById); 45 | REQUEST_AND_RESPONSE(SearchTitle); 46 | REQUEST_AND_RESPONSE(UpdateLibraryEntry); 47 | 48 | bool RequestSucceeded(Response& response, const HttpResponse& http_response); 49 | }; 50 | 51 | } // namespace myanimelist 52 | } // namespace sync 53 | -------------------------------------------------------------------------------- /src/library/metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/time.h" 22 | #include "base/types.h" 23 | 24 | namespace library { 25 | 26 | enum class TitleType { 27 | Unknown, 28 | Synonym, 29 | LangEnglish, 30 | LangJapanese, 31 | }; 32 | 33 | struct Title { 34 | Title(); 35 | Title(TitleType type, const string_t& value); 36 | ~Title() {} 37 | 38 | TitleType type; 39 | string_t value; 40 | }; 41 | 42 | // A generic metadata structure for all kinds of media 43 | struct Metadata { 44 | Metadata(); 45 | ~Metadata() {} 46 | 47 | std::vector uid; 48 | enum_t source; 49 | time_t modified; 50 | 51 | string_t title; 52 | std::vector alternative; 53 | 54 | enum_t type; 55 | enum_t status; 56 | enum_t audience; 57 | 58 | std::vector<unsigned short> extent; 59 | std::vector<Date> date; 60 | 61 | std::vector<string_t> subject; 62 | std::vector<string_t> creator; 63 | std::vector<string_t> resource; 64 | std::vector<string_t> community; 65 | 66 | string_t description; 67 | }; 68 | 69 | } // namespace library 70 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_torrent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include <windows/win/common_controls.h> 24 | #include <windows/win/dialog.h> 25 | 26 | namespace ui { 27 | 28 | class TorrentDialog : public win::Dialog { 29 | public: 30 | TorrentDialog() {}; 31 | ~TorrentDialog() {}; 32 | 33 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 34 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 35 | void OnContextMenu(HWND hwnd, POINT pt); 36 | BOOL OnInitDialog(); 37 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 38 | void OnSize(UINT uMsg, UINT nType, SIZE size); 39 | 40 | void EnableInput(bool enable = true); 41 | void RefreshList(); 42 | void Search(std::wstring url, int anime_id); 43 | void Search(std::wstring url, std::wstring title); 44 | void SetTimer(int ticks); 45 | 46 | private: 47 | class ListView : public win::ListView { 48 | public: 49 | int last_checked_item; 50 | } list_; 51 | win::Rebar rebar_; 52 | win::Toolbar toolbar_; 53 | }; 54 | 55 | extern TorrentDialog DlgTorrent; 56 | 57 | } // namespace ui 58 | -------------------------------------------------------------------------------- /src/track/search.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include "base/file.h" 24 | #include "library/anime_episode.h" 25 | 26 | class TaigaFileSearchHelper : public FileSearchHelper { 27 | public: 28 | TaigaFileSearchHelper(); 29 | ~TaigaFileSearchHelper() {} 30 | 31 | bool OnDirectory(const std::wstring& root, const std::wstring& name, const WIN32_FIND_DATA& data); 32 | bool OnFile(const std::wstring& root, const std::wstring& name, const WIN32_FIND_DATA& data); 33 | 34 | const std::wstring& path_found() const; 35 | 36 | void set_anime_id(int anime_id); 37 | void set_episode_number(int episode_number); 38 | void set_path_found(const std::wstring& path_found); 39 | 40 | private: 41 | int anime_id_; 42 | anime::Episode episode_; 43 | int episode_number_; 44 | std::wstring path_found_; 45 | }; 46 | 47 | extern TaigaFileSearchHelper file_search_helper; 48 | 49 | void ScanAvailableEpisodes(bool silent); 50 | void ScanAvailableEpisodes(bool silent, int anime_id, int episode_number); 51 | void ScanAvailableEpisodesQuick(); 52 | void ScanAvailableEpisodesQuick(int anime_id); 53 | -------------------------------------------------------------------------------- /src/ui/menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include <windows/win/menu.h> 24 | 25 | namespace anime { 26 | class Item; 27 | } 28 | class FeedItem; 29 | 30 | namespace ui { 31 | 32 | class MenuList { 33 | public: 34 | void Load(); 35 | 36 | std::wstring Show(HWND hwnd, int x, int y, LPCWSTR lpName); 37 | 38 | void UpdateAll(const anime::Item* anime_item = nullptr); 39 | void UpdateAnime(const anime::Item* anime_item); 40 | void UpdateAnimeListHeaders(); 41 | void UpdateAnnounce(); 42 | void UpdateExternalLinks(); 43 | void UpdateFolders(); 44 | void UpdateHistoryList(bool enabled = false); 45 | void UpdateScore(const anime::Item* anime_item); 46 | void UpdateSearchList(bool enabled = false); 47 | void UpdateSeasonList(bool enabled = false); 48 | void UpdateTorrentsList(const FeedItem& feed_item); 49 | void UpdateSeason(); 50 | void UpdateServices(bool enabled = true); 51 | void UpdateTools(); 52 | void UpdateTray(); 53 | void UpdateView(); 54 | 55 | private: 56 | win::MenuList menu_list_; 57 | }; 58 | 59 | extern MenuList Menus; 60 | 61 | } // namespace ui 62 | -------------------------------------------------------------------------------- /src/base/base64.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <string> 20 | 21 | #include <base64/base64.h> 22 | 23 | #include "base64.h" 24 | #include "string.h" 25 | 26 | std::string Base64Decode(const std::string& str) { 27 | if (str.empty()) 28 | return str; 29 | 30 | Base64Coder coder; 31 | coder.Decode((BYTE*)str.c_str(), str.size()); 32 | 33 | return coder.DecodedMessage(); 34 | } 35 | 36 | std::string Base64Encode(const std::string& str) { 37 | if (str.empty()) 38 | return str; 39 | 40 | Base64Coder coder; 41 | coder.Encode((BYTE*)str.c_str(), str.size()); 42 | 43 | return coder.EncodedMessage(); 44 | } 45 | 46 | //////////////////////////////////////////////////////////////////////////////// 47 | 48 | std::wstring Base64Decode(const std::wstring& str, bool for_filename) { 49 | std::wstring output = StrToWstr(Base64Decode(WstrToStr(str))); 50 | 51 | if (for_filename) 52 | ReplaceChar(output, '-', '/'); 53 | 54 | return output; 55 | } 56 | 57 | std::wstring Base64Encode(const std::wstring& str, bool for_filename) { 58 | std::wstring output = StrToWstr(Base64Encode(WstrToStr(str))); 59 | 60 | if (for_filename) 61 | ReplaceChar(output, '/', '-'); 62 | 63 | return output; 64 | } -------------------------------------------------------------------------------- /src/taiga/stats.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <vector> 23 | 24 | namespace taiga { 25 | 26 | class Statistics { 27 | public: 28 | Statistics(); 29 | ~Statistics() {} 30 | 31 | void CalculateAll(); 32 | int CalculateAnimeCount(); 33 | int CalculateEpisodeCount(); 34 | const std::wstring& CalculateLifePlannedToWatch(); 35 | const std::wstring& CalculateLifeSpentWatching(); 36 | void CalculateLocalData(); 37 | float CalculateMeanScore(); 38 | float CalculateScoreDeviation(); 39 | const std::vector<float>& CalculateScoreDistribution(); 40 | 41 | public: 42 | int anime_count; 43 | int connections_failed; 44 | int connections_succeeded; 45 | int episode_count; 46 | unsigned int image_count; 47 | unsigned long long image_size; 48 | std::wstring life_planned_to_watch; 49 | std::wstring life_spent_watching; 50 | float score_mean; 51 | float score_deviation; 52 | std::vector<int> score_count; 53 | std::vector<float> score_distribution; 54 | int tigers_harmed; 55 | unsigned int torrent_count; 56 | unsigned long long torrent_size; 57 | int uptime; 58 | }; 59 | 60 | } // namespace taiga 61 | 62 | extern taiga::Statistics Stats; 63 | -------------------------------------------------------------------------------- /deps/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set vc=%1 4 | if "%vc%"=="15" ( 5 | set vcvarsall="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat" 6 | goto :initialize_environment 7 | ) 8 | if "%vc%"=="14" ( 9 | set vcvarsall="%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" 10 | goto :initialize_environment 11 | ) 12 | 13 | set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 14 | if exist %vswhere% ( 15 | for /f "usebackq delims=" %%i in (`%vswhere% -latest -property installationPath`) do ( 16 | set vcvarsall="%%i\VC\Auxiliary\Build\vcvars32.bat" 17 | ) 18 | for /f "usebackq delims=." %%i in (`%vswhere% -latest -property installationVersion`) do ( 19 | set vc=%%i 20 | ) 21 | goto :initialize_environment 22 | ) 23 | 24 | echo Error in script usage. The correct usage is: %~nx0 [version] 25 | echo [version] can be "15" ^(VS2017^) or "14" ^(VS2015^) 26 | echo Example: %~nx0 15 27 | exit /B 1 28 | 29 | :initialize_environment 30 | echo Initializing environment... 31 | call %vcvarsall% || ( 32 | echo Please edit the build script according to your system configuration. 33 | exit /B 1 34 | ) 35 | 36 | :build_libcurl 37 | echo Configuring libcurl... 38 | 39 | set currentdir=%cd% 40 | cd /D %~dp0 41 | 42 | call src\curl\buildconf.bat 43 | 44 | if exist src\curl\builds ( 45 | echo Clearing previous libcurl builds... 46 | rmdir /s /q src\curl\builds 47 | ) 48 | 49 | cd src\curl\winbuild\ 50 | 51 | echo Building libcurl for Debug configuration... 52 | nmake /f Makefile.vc mode=static RTLIBCFG=static VC=%vc% MACHINE=x86 DEBUG=yes 53 | xcopy /s ..\builds\libcurl-vc%vc%-x86-debug-static-ipv6-sspi-winssl\lib ..\..\..\lib\ 54 | 55 | echo Building libcurl for Release configuration... 56 | nmake /f Makefile.vc mode=static RTLIBCFG=static VC=%vc% MACHINE=x86 57 | xcopy /s ..\builds\libcurl-vc%vc%-x86-release-static-ipv6-sspi-winssl\lib ..\..\..\lib\ 58 | 59 | cd /D %currentdir% 60 | 61 | echo Done! 62 | pause 63 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_anime_info_page.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows/win/dialog.h> 22 | 23 | namespace ui { 24 | 25 | enum class AnimePageType { 26 | None, 27 | SeriesInfo, 28 | MyInfo, 29 | NotRecognized, 30 | }; 31 | 32 | class AnimeDialog; 33 | 34 | class PageBaseInfo : public win::Dialog { 35 | public: 36 | PageBaseInfo(); 37 | virtual ~PageBaseInfo() {} 38 | 39 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 40 | BOOL OnClose(); 41 | BOOL OnInitDialog(); 42 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 43 | void OnSize(UINT uMsg, UINT nType, SIZE size); 44 | 45 | ui::AnimeDialog* parent; 46 | 47 | protected: 48 | int anime_id_; 49 | }; 50 | 51 | class PageSeriesInfo : public PageBaseInfo { 52 | public: 53 | void OnSize(UINT uMsg, UINT nType, SIZE size); 54 | 55 | void Refresh(int anime_id, bool connect); 56 | }; 57 | 58 | class PageMyInfo : public PageBaseInfo { 59 | public: 60 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 61 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 62 | bool Save(); 63 | 64 | void Refresh(int anime_id); 65 | void RefreshFansubPreference(); 66 | 67 | private: 68 | bool start_date_changed_; 69 | bool finish_date_changed_; 70 | }; 71 | 72 | } // namespace ui 73 | -------------------------------------------------------------------------------- /src/sync/anilist_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include "base/json.h" 24 | #include "base/time.h" 25 | #include "sync/anilist_types.h" 26 | #include "sync/service.h" 27 | 28 | namespace anime { 29 | class Item; 30 | } 31 | 32 | namespace sync { 33 | namespace anilist { 34 | 35 | std::wstring DecodeDescription(std::string text); 36 | 37 | RatingSystem GetRatingSystem(); 38 | std::vector<Rating> GetMyRatings(RatingSystem rating_system); 39 | 40 | Date TranslateFuzzyDateFrom(const Json& json); 41 | Json TranslateFuzzyDateTo(const Date& date); 42 | std::string TranslateSeasonTo(const std::wstring& value); 43 | double TranslateSeriesRatingFrom(int value); 44 | double TranslateSeriesRatingTo(double value); 45 | int TranslateSeriesTypeFrom(const std::string& value); 46 | std::wstring TranslateMyRating(int value, RatingSystem rating_system); 47 | int TranslateMyStatusFrom(const std::string& value); 48 | std::string TranslateMyStatusTo(int value); 49 | RatingSystem TranslateRatingSystemFrom(const std::string& value); 50 | 51 | std::wstring GetAnimePage(const anime::Item& anime_item); 52 | void RequestToken(); 53 | void ViewAnimePage(int anime_id); 54 | void ViewProfile(); 55 | void ViewStats(); 56 | 57 | } // namespace anilist 58 | } // namespace sync 59 | -------------------------------------------------------------------------------- /src/sync/myanimelist_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <vector> 23 | 24 | #include "sync/service.h" 25 | 26 | namespace anime { 27 | class Item; 28 | } 29 | 30 | namespace sync { 31 | namespace myanimelist { 32 | 33 | std::wstring DecodeText(std::wstring text); 34 | std::wstring EraseBbcode(std::wstring& str); 35 | 36 | std::vector<Rating> GetMyRatings(); 37 | 38 | int TranslateSeriesStatusFrom(int value); 39 | int TranslateSeriesStatusFrom(const std::wstring& value); 40 | int TranslateSeriesTypeFrom(int value); 41 | int TranslateSeriesTypeFrom(const std::wstring& value); 42 | std::wstring TranslateMyDateTo(const std::wstring& value); 43 | std::wstring TranslateMyRating(int value, bool full); 44 | int TranslateMyRatingFrom(int value); 45 | int TranslateMyRatingTo(int value); 46 | int TranslateMyStatusFrom(int value); 47 | int TranslateMyStatusTo(int value); 48 | std::wstring TranslateKeyTo(const std::wstring& key); 49 | 50 | std::wstring GetAnimePage(const anime::Item& anime_item); 51 | void ViewAnimePage(int anime_id); 52 | void ViewAnimeSearch(const std::wstring& title); 53 | void ViewHistory(); 54 | void ViewLogin(); 55 | void ViewPanel(); 56 | void ViewProfile(); 57 | void ViewUpcomingAnime(); 58 | 59 | } // namespace myanimelist 60 | } // namespace sync 61 | -------------------------------------------------------------------------------- /src/sync/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | #include <memory> 23 | #include <string> 24 | 25 | #include <windows/win/thread.h> 26 | 27 | #include "service.h" 28 | #include "base/types.h" 29 | #include "taiga/http.h" 30 | 31 | namespace sync { 32 | 33 | // The service manager handles all the communication between services and the 34 | // application. 35 | 36 | class Manager { 37 | public: 38 | Manager(); 39 | ~Manager(); 40 | 41 | void MakeRequest(Request& request); 42 | void HandleHttpError(HttpResponse& http_response, string_t error); 43 | void HandleHttpResponse(HttpResponse& http_response); 44 | 45 | Service* service(ServiceId service_id) const; 46 | Service* service(const string_t& canonical_name) const; 47 | 48 | ServiceId GetServiceIdByName(const string_t& canonical_name) const; 49 | string_t GetServiceNameById(ServiceId service_id) const; 50 | 51 | private: 52 | void HandleError(Response& response, HttpResponse& http_response); 53 | void HandleResponse(Response& response, HttpResponse& http_response); 54 | 55 | win::CriticalSection critical_section_; 56 | std::map<std::wstring, Request> requests_; 57 | std::map<ServiceId, std::unique_ptr<Service>> services_; 58 | }; 59 | 60 | } // namespace sync 61 | 62 | extern sync::Manager ServiceManager; 63 | -------------------------------------------------------------------------------- /src/base/json.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "json.h" 20 | #include "string.h" 21 | 22 | bool JsonParseString(const std::string& str, Json& output) { 23 | try { 24 | output = Json::parse(str.begin(), str.end()); 25 | return true; 26 | } catch (const std::exception&) { 27 | return false; 28 | } 29 | } 30 | 31 | bool JsonParseString(const std::wstring& str, Json& output) { 32 | return JsonParseString(WstrToStr(str), output); 33 | } 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | 37 | bool JsonReadBool(const Json& json, const std::string& key) { 38 | const auto it = json.find(key); 39 | return it != json.end() && it->is_boolean() ? it->get<bool>() : false; 40 | } 41 | 42 | double JsonReadDouble(const Json& json, const std::string& key) { 43 | const auto it = json.find(key); 44 | return it != json.end() && it->is_number_float() ? it->get<double>() : 0.0; 45 | } 46 | 47 | int JsonReadInt(const Json& json, const std::string& key) { 48 | const auto it = json.find(key); 49 | return it != json.end() && it->is_number_integer() ? it->get<int>() : 0; 50 | } 51 | 52 | std::string JsonReadStr(const Json& json, const std::string& key) { 53 | const auto it = json.find(key); 54 | return it != json.end() && it->is_string() ? it->get<std::string>() : std::string(); 55 | } 56 | -------------------------------------------------------------------------------- /src/library/discover.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include "library/anime_season.h" 24 | 25 | namespace library { 26 | 27 | class SeasonDatabase { 28 | public: 29 | SeasonDatabase(); 30 | 31 | // Loads season data from db\season\<seasonname>.xml, returns false if no such 32 | // file exists. 33 | bool LoadSeason(const anime::Season& season); 34 | bool LoadFile(const std::wstring& filename); 35 | bool LoadString(const std::wstring& data); 36 | 37 | bool LoadSeasonFromMemory(const anime::Season& season); 38 | 39 | // Checkes if a significant portion of season data is empty and requires 40 | // refreshing. 41 | bool IsRefreshRequired(); 42 | 43 | void Reset(); 44 | 45 | // Improves season data by excluding invalid items (i.e. postpones series) and 46 | // adding missing ones from the anime database. 47 | void Review(bool hide_nsfw = true); 48 | 49 | // Only IDs are stored here, actual info is kept in anime::Database. 50 | std::vector<int> items; 51 | 52 | // Current season (e.g. "Spring 2012") 53 | anime::Season current_season; 54 | 55 | // Available seasons 56 | std::pair<anime::Season, anime::Season> available_seasons; 57 | std::wstring remote_location; 58 | }; 59 | 60 | } // namespace library 61 | 62 | extern library::SeasonDatabase SeasonDatabase; 63 | -------------------------------------------------------------------------------- /src/ui/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <vector> 22 | #include <windows.h> 23 | 24 | namespace win { 25 | class ListView; 26 | } 27 | 28 | namespace ui { 29 | 30 | enum ListSortType { 31 | kListSortDefault, 32 | kListSortFileSize, 33 | kListSortNumber, 34 | kListSortDateStart, 35 | kListSortEpisodeCount, 36 | kListSortEpisodeRange, 37 | kListSortLastUpdated, 38 | kListSortPopularity, 39 | kListSortProgress, 40 | kListSortRfc822DateTime, 41 | kListSortMyScore, 42 | kListSortScore, 43 | kListSortSeason, 44 | kListSortStatus, 45 | kListSortTitle 46 | }; 47 | 48 | int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, 49 | LPARAM lParamSort); 50 | 51 | int CALLBACK AnimeListCompareProc(LPARAM lParam1, LPARAM lParam2, 52 | LPARAM lParamSort); 53 | 54 | int GetAnimeIdFromSelectedListItem(win::ListView& listview); 55 | std::vector<int> GetAnimeIdsFromSelectedListItems(win::ListView& listview); 56 | LPARAM GetParamFromSelectedListItem(win::ListView& listview); 57 | std::vector<LPARAM> GetParamsFromSelectedListItems(win::ListView& listview); 58 | 59 | void GetPopupMenuPositionForSelectedListItem(win::ListView& listview, POINT& pt); 60 | bool HitTestListHeader(win::ListView& listview, POINT pt); 61 | 62 | } // namespace ui 63 | -------------------------------------------------------------------------------- /src/sync/sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "service.h" 22 | #include "base/types.h" 23 | #include "library/history.h" 24 | #include "taiga/http.h" 25 | 26 | namespace anime { 27 | class Season; 28 | } 29 | 30 | namespace sync { 31 | 32 | bool AuthenticateUser(); 33 | void GetUser(); 34 | void GetLibraryEntries(const int offset = 0); 35 | void GetMetadataById(int id); 36 | void GetSeason(const anime::Season season, const int offset); 37 | void SearchTitle(string_t title, int id); 38 | void Synchronize(); 39 | void UpdateLibraryEntry(AnimeValues& anime_values, int id, 40 | taiga::HttpClientMode http_client_mode); 41 | 42 | void DownloadImage(int id, const std::wstring& image_url); 43 | 44 | bool AddAuthenticationToRequest(Request& request); 45 | void AddPageOffsetToRequest(const int offset, Request& request); 46 | bool AddServiceDataToRequest(Request& request, int id); 47 | bool RequestNeedsAuthentication(RequestType request_type, ServiceId service_id); 48 | void SetActiveServiceForRequest(Request& request); 49 | bool UserAuthenticated(); 50 | void InvalidateUserAuthentication(); 51 | 52 | bool ServiceSupportsRequestType(RequestType request_type); 53 | RequestType ClientModeToRequestType(taiga::HttpClientMode client_mode); 54 | taiga::HttpClientMode RequestTypeToClientMode(RequestType request_type); 55 | 56 | } // namespace sync 57 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_settings_page.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows/win/dialog.h> 22 | 23 | namespace ui { 24 | 25 | enum SettingsPages { 26 | kSettingsPageAdvanced = 1, 27 | kSettingsPageAppGeneral, 28 | kSettingsPageAppList, 29 | kSettingsPageLibraryCache, 30 | kSettingsPageLibraryFolders, 31 | kSettingsPageRecognitionGeneral, 32 | kSettingsPageRecognitionMedia, 33 | kSettingsPageRecognitionStream, 34 | kSettingsPageServicesAniList, 35 | kSettingsPageServicesKitsu, 36 | kSettingsPageServicesMain, 37 | kSettingsPageServicesMal, 38 | kSettingsPageSharingHttp, 39 | kSettingsPageSharingMirc, 40 | kSettingsPageSharingSkype, 41 | kSettingsPageSharingTwitter, 42 | kSettingsPageTorrentsDiscovery, 43 | kSettingsPageTorrentsDownloads, 44 | kSettingsPageTorrentsFilters, 45 | kSettingsPageCount 46 | }; 47 | 48 | class SettingsDialog; 49 | 50 | class SettingsPage : public win::Dialog { 51 | public: 52 | SettingsPage(); 53 | virtual ~SettingsPage() {} 54 | 55 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 56 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 57 | void OnDropFiles(HDROP hDropInfo); 58 | BOOL OnInitDialog(); 59 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 60 | 61 | void Create(); 62 | 63 | int index; 64 | SettingsDialog* parent; 65 | }; 66 | 67 | } // namespace ui 68 | -------------------------------------------------------------------------------- /src/base/gfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows/win/gdi.h> 22 | #include <windows/win/gdi_plus.h> 23 | 24 | extern class win::GdiPlus GdiPlus; 25 | 26 | namespace base { 27 | 28 | class Image { 29 | public: 30 | Image(); 31 | virtual ~Image() {} 32 | 33 | bool Load(const std::wstring& file); 34 | 35 | win::Dc dc; 36 | win::Rect rect; 37 | LPARAM data; 38 | }; 39 | 40 | } // namespace base 41 | 42 | HFONT ChangeDCFont(HDC hdc, LPCWSTR lpFaceName, INT iSize, BOOL bBold, BOOL bItalic, BOOL bUnderline); 43 | int GetTextHeight(HDC hdc); 44 | int GetTextWidth(HDC hdc, const std::wstring& text); 45 | BOOL GradientRect(HDC hdc, const LPRECT lpRect, DWORD dwColor1, DWORD dwColor2, bool bVertical); 46 | BOOL DrawIconResource(int icon_id, HDC hdc, win::Rect& rect, bool center_x, bool center_y); 47 | BOOL DrawProgressBar(HDC hdc, const LPRECT lpRect, DWORD dwColor1, DWORD dwColor2, DWORD dwColor3); 48 | 49 | COLORREF HexToARGB(const std::wstring& text); 50 | win::Rect ResizeRect(const win::Rect& rect_dest, int src_width, int src_height, bool stretch, bool center_x, bool center_y); 51 | int ScaleX(int value); 52 | int ScaleY(int value); 53 | void RgbToHsv(float r, float g, float b, float& h, float& s, float& v); 54 | void HsvToRgb(float& r, float& g, float& b, float h, float s, float v); 55 | COLORREF ChangeColorBrightness(COLORREF color, float modifier); 56 | -------------------------------------------------------------------------------- /src/base/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | #include <windows.h> 23 | 24 | namespace base { 25 | 26 | class Timer { 27 | public: 28 | Timer(unsigned int id, int interval, bool repeat); 29 | virtual ~Timer() {} 30 | 31 | bool enabled() const; 32 | unsigned int id() const; 33 | int interval() const; 34 | bool repeat() const; 35 | int ticks() const; 36 | 37 | void set_enabled(bool enabled); 38 | void set_id(unsigned int id); 39 | void set_interval(int interval); 40 | void set_repeat(bool repeat); 41 | void set_ticks(int ticks); 42 | 43 | // Resets ticks to interval 44 | void Reset(); 45 | 46 | // Counts down from the interval 47 | void Tick(); 48 | 49 | protected: 50 | // What to do when timer reaches zero 51 | virtual void OnTimeout() = 0; 52 | 53 | private: 54 | bool enabled_; 55 | unsigned int id_; 56 | int interval_; 57 | bool repeat_; 58 | int ticks_; 59 | }; 60 | 61 | class TimerManager { 62 | public: 63 | TimerManager(); 64 | virtual ~TimerManager(); 65 | 66 | Timer* timer(unsigned int id); 67 | 68 | virtual bool Initialize(HWND hwnd, TIMERPROC proc); 69 | virtual void InsertTimer(const Timer* timer); 70 | 71 | virtual void OnTick() = 0; 72 | 73 | protected: 74 | HWND hwnd_; 75 | UINT_PTR id_; 76 | std::map<unsigned int, Timer*> timers_; 77 | }; 78 | 79 | } // namespace base 80 | -------------------------------------------------------------------------------- /src/taiga/update.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <memory> 22 | #include <string> 23 | #include <vector> 24 | 25 | #include "track/feed.h" 26 | 27 | namespace taiga { 28 | 29 | class UpdateHelper { 30 | public: 31 | UpdateHelper(); 32 | virtual ~UpdateHelper() {} 33 | 34 | void Cancel(); 35 | void Check(); 36 | void CheckAnimeRelations(); 37 | bool Download(); 38 | bool IsAnimeRelationsAvailable() const; 39 | bool IsNewSeasonAvailable() const; 40 | bool IsRestartRequired() const; 41 | bool IsUpdateAvailable() const; 42 | bool ParseData(std::wstring data); 43 | bool RunInstaller(); 44 | 45 | std::wstring GetCurrentAnimeRelationsModified() const; 46 | std::wstring GetDownloadPath() const; 47 | void SetDownloadPath(const std::wstring& path); 48 | 49 | class Item : public GenericFeedItem { 50 | public: 51 | std::wstring taiga_anime_relations_location; 52 | std::wstring taiga_anime_relations_modified; 53 | std::wstring taiga_anime_season_location; 54 | std::wstring taiga_anime_season_max; 55 | }; 56 | std::vector<Item> items; 57 | 58 | private: 59 | std::wstring download_path_; 60 | std::unique_ptr<Item> current_item_; 61 | std::unique_ptr<Item> latest_item_; 62 | bool new_season_available_; 63 | bool restart_required_; 64 | bool update_available_; 65 | std::wstring client_uid_; 66 | }; 67 | 68 | } // namespace taiga 69 | -------------------------------------------------------------------------------- /src/sync/kitsu_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <vector> 23 | 24 | #include "sync/kitsu_types.h" 25 | #include "sync/service.h" 26 | 27 | namespace anime { 28 | class Item; 29 | } 30 | 31 | namespace sync { 32 | namespace kitsu { 33 | 34 | std::wstring DecodeSynopsis(std::string text); 35 | 36 | RatingSystem GetRatingSystem(); 37 | std::vector<Rating> GetMyRatings(RatingSystem rating_system); 38 | 39 | int TranslateAgeRatingFrom(const std::string& value); 40 | double TranslateSeriesRatingFrom(const std::string& value); 41 | double TranslateSeriesRatingTo(double value); 42 | int TranslateSeriesTypeFrom(const std::string& value); 43 | std::wstring TranslateMyDateFrom(const std::string& value); 44 | std::string TranslateMyDateTo(const std::wstring& value); 45 | std::wstring TranslateMyLastUpdatedFrom(const std::string& value); 46 | std::wstring TranslateMyRating(int value, RatingSystem rating_system); 47 | int TranslateMyRatingFrom(int value); 48 | int TranslateMyRatingTo(int value); 49 | int TranslateMyStatusFrom(const std::string& value); 50 | std::string TranslateMyStatusTo(int value); 51 | RatingSystem TranslateRatingSystemFrom(const std::string& value); 52 | 53 | std::wstring GetAnimePage(const anime::Item& anime_item); 54 | void ViewAnimePage(int anime_id); 55 | void ViewFeed(); 56 | void ViewLibrary(); 57 | void ViewProfile(); 58 | 59 | } // namespace kitsu 60 | } // namespace sync 61 | -------------------------------------------------------------------------------- /src/base/xml.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <vector> 23 | 24 | #include <pugixml/src/pugixml.hpp> 25 | 26 | using pugi::xml_document; 27 | using pugi::xml_node; 28 | using pugi::xml_parse_result; 29 | 30 | #define foreach_xmlnode_(node, parent, name) \ 31 | for (pugi::xml_node node = parent.child(name); node; \ 32 | node = node.next_sibling(name)) 33 | 34 | std::wstring XmlGetNodeAsString(pugi::xml_node node); 35 | 36 | int XmlReadIntValue(pugi::xml_node& node, const wchar_t* name); 37 | std::wstring XmlReadStrValue(pugi::xml_node& node, const wchar_t* name); 38 | 39 | void XmlReadChildNodes(pugi::xml_node& parent_node, 40 | std::vector<std::wstring>& output, 41 | const wchar_t* name); 42 | void XmlWriteChildNodes(pugi::xml_node& parent_node, 43 | const std::vector<std::wstring>& input, 44 | const wchar_t* name, 45 | pugi::xml_node_type node_type = pugi::node_pcdata); 46 | 47 | void XmlWriteIntValue(pugi::xml_node& node, const wchar_t* name, int value); 48 | void XmlWriteStrValue(pugi::xml_node& node, const wchar_t* name, 49 | const wchar_t* value, 50 | pugi::xml_node_type node_type = pugi::node_pcdata); 51 | 52 | bool XmlWriteDocumentToFile(const pugi::xml_document& document, 53 | const std::wstring& path); 54 | -------------------------------------------------------------------------------- /src/base/oauth.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | #include <string> 23 | 24 | #include "url.h" 25 | 26 | typedef std::map<std::wstring, std::wstring> oauth_parameter_t; 27 | 28 | class OAuth { 29 | public: 30 | OAuth() {} 31 | ~OAuth() {} 32 | 33 | std::wstring BuildAuthorizationHeader( 34 | const std::wstring& url, 35 | const std::wstring& http_method, 36 | const oauth_parameter_t* post_parameters = nullptr, 37 | const std::wstring& oauth_token = L"", 38 | const std::wstring& oauth_token_secret = L"", 39 | const std::wstring& pin = L""); 40 | oauth_parameter_t ParseQueryString(const std::wstring& url); 41 | 42 | std::wstring consumer_key; 43 | std::wstring consumer_secret; 44 | 45 | private: 46 | oauth_parameter_t BuildSignedParameters( 47 | const oauth_parameter_t& get_parameters, 48 | const std::wstring& url, 49 | const std::wstring& http_method, 50 | const oauth_parameter_t* post_parameters, 51 | const std::wstring& oauth_token, 52 | const std::wstring& oauth_token_secret, 53 | const std::wstring& pin); 54 | 55 | std::wstring CreateNonce(); 56 | std::wstring CreateSignature(const std::wstring& signature_base, const std::wstring& oauth_token_secret); 57 | std::wstring CreateTimestamp(); 58 | 59 | std::wstring NormalizeUrl(const std::wstring& url); 60 | oauth_parameter_t ParseQuery(const query_t& query); 61 | std::wstring SortParameters(const oauth_parameter_t& parameters); 62 | }; 63 | -------------------------------------------------------------------------------- /src/discord-RPC/discord_rpc_functions.cpp: -------------------------------------------------------------------------------- 1 | #include "discord-RPC/discord_rpc_functions.h" 2 | #include <string> 3 | #include <ctime> 4 | 5 | namespace discord 6 | { 7 | void discordInit() 8 | { 9 | DiscordEventHandlers handlers; 10 | memset(&handlers, 0, sizeof(handlers)); 11 | handlers.ready = handleDiscordReady; 12 | handlers.disconnected = handleDiscordDisconnected; 13 | handlers.errored = handleDiscordError; 14 | handlers.joinGame = handleDiscordJoin; 15 | handlers.spectateGame = handleDiscordSpectate; 16 | handlers.joinRequest = handleDiscordJoinRequest; 17 | Discord_Initialize(APPLICATION_ID, &handlers, 1, NULL); 18 | } 19 | 20 | void discordShutDown() 21 | { 22 | Discord_ClearPresence(); 23 | Discord_Shutdown(); 24 | } 25 | 26 | 27 | void updateDiscordPresence(bool idling, const std::wstring& anime_name) 28 | { 29 | DiscordRichPresence discordPresence; 30 | memset(&discordPresence, 0, sizeof(discordPresence)); 31 | 32 | if (idling) 33 | { 34 | discordPresence.details = "Idling"; 35 | } 36 | else 37 | { 38 | discordPresence.details = "Watching Anime"; 39 | char* tmpString = new char[255]; 40 | sprintf_s(tmpString, sizeof(char) * 255, "%ls", anime_name.c_str()); 41 | discordPresence.state = tmpString; 42 | discordPresence.startTimestamp = time(0); 43 | } 44 | 45 | Discord_UpdatePresence(&discordPresence); 46 | 47 | #ifdef DISCORD_DISABLE_IO_THREAD 48 | Discord_UpdateConnection(); 49 | #endif 50 | Discord_RunCallbacks(); 51 | } 52 | 53 | static void handleDiscordReady(void) 54 | { 55 | // Stub event 56 | } 57 | 58 | static void handleDiscordDisconnected(int errcode, const char* message) 59 | { 60 | // Stub event 61 | } 62 | 63 | static void handleDiscordError(int errcode, const char* message) 64 | { 65 | // Stub event 66 | } 67 | 68 | static void handleDiscordJoin(const char* secret) 69 | { 70 | // Stub event 71 | } 72 | 73 | static void handleDiscordSpectate(const char* secret) 74 | { 75 | // Stub event 76 | } 77 | 78 | static void handleDiscordJoinRequest(const DiscordJoinRequest* request) 79 | { 80 | // Stub event 81 | } 82 | } // namespace discord -------------------------------------------------------------------------------- /src/taiga/dummy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "sync/service.h" 20 | #include "taiga/dummy.h" 21 | #include "track/recognition.h" 22 | 23 | namespace taiga { 24 | 25 | class DummyAnime DummyAnime; 26 | class DummyEpisode DummyEpisode; 27 | 28 | void DummyAnime::Initialize() { 29 | SetSource(sync::kMyAnimeList); 30 | SetId(L"4224", sync::kTaiga); 31 | SetId(L"4224", sync::kMyAnimeList); 32 | SetId(L"3532", sync::kKitsu); 33 | SetId(L"4224", sync::kAniList); 34 | SetSlug(L"toradora"); 35 | SetTitle(L"Toradora!"); 36 | SetSynonyms(L"Tiger X Dragon"); 37 | SetType(anime::kTv); 38 | SetEpisodeCount(25); 39 | SetEpisodeLength(24); 40 | SetAiringStatus(anime::kFinishedAiring); 41 | SetDateStart(Date(2008, 10, 01)); 42 | SetDateEnd(Date(2009, 03, 25)); 43 | SetImageUrl(L"https://myanimelist.cdn-dena.com/images/anime/13/22128.jpg"); 44 | AddtoUserList(); 45 | SetMyLastWatchedEpisode(25); 46 | SetMyScore(anime::kUserScoreMax); 47 | SetMyStatus(anime::kCompleted); 48 | SetMyTags(L"comedy, romance, drama"); 49 | SetMyNotes(L"Best series ever!"); 50 | } 51 | 52 | void DummyEpisode::Initialize() { 53 | anime_id = 74164; 54 | 55 | track::recognition::ParseOptions parse_options; 56 | parse_options.parse_path = true; 57 | parse_options.streaming_media = false; 58 | 59 | Meow.Parse(L"D:\\Anime\\Toradora!\\" 60 | L"[TaigaSubs]_Toradora!_-_01v2_-_Tiger_and_Dragon_[DVD][1280x720_H264_AAC][ABCD1234].mkv", 61 | parse_options, *this); 62 | } 63 | 64 | } // namespace taiga -------------------------------------------------------------------------------- /src/taiga/debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/string.h" 20 | #include "library/anime_db.h" 21 | #include "taiga/debug.h" 22 | #include "ui/dlg/dlg_main.h" 23 | #include "ui/dialog.h" 24 | 25 | namespace debug { 26 | 27 | Tester::Tester() 28 | : t0_(clock_t::duration::zero()) { 29 | } 30 | 31 | void Tester::Start() { 32 | t0_ = clock_t::now(); 33 | } 34 | 35 | void Tester::Stop(std::wstring str, bool display_result) { 36 | using duration_t = 37 | std::chrono::duration<float, std::chrono::milliseconds::period>; 38 | 39 | const auto now = clock_t::now(); 40 | const auto duration = std::chrono::duration_cast<duration_t>(now - t0_); 41 | t0_ = now; 42 | 43 | if (display_result) { 44 | str = ToWstr(duration.count(), 2) + L"ms | Text: [" + str + L"]"; 45 | ui::DlgMain.SetText(str); 46 | } 47 | } 48 | 49 | //////////////////////////////////////////////////////////////////////////////// 50 | 51 | void Print(std::wstring text) { 52 | #ifdef _DEBUG 53 | ::OutputDebugString(text.c_str()); 54 | #else 55 | UNREFERENCED_PARAMETER(text); 56 | #endif 57 | } 58 | 59 | void Test() { 60 | // Define variables 61 | std::wstring str; 62 | 63 | // Start ticking 64 | Tester test; 65 | test.Start(); 66 | 67 | for (int i = 0; i < 10000; i++) { 68 | // Do some tests here 69 | // ___ 70 | // {o,o} 71 | // |)__) 72 | // --"-"-- 73 | // O RLY? 74 | } 75 | 76 | // Show result 77 | test.Stop(str, true); 78 | } 79 | 80 | } // namespace debug 81 | -------------------------------------------------------------------------------- /src/base/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | #include <string> 23 | 24 | #include "types.h" 25 | 26 | namespace pugi { 27 | class xml_node; 28 | } 29 | 30 | namespace base { 31 | 32 | class Setting { 33 | public: 34 | Setting() {} 35 | Setting(bool attribute, const std::wstring& path); 36 | Setting(bool attribute, const std::wstring& default_value, const std::wstring& path); 37 | ~Setting() {} 38 | 39 | bool attribute; 40 | std::wstring default_value; 41 | std::wstring path; 42 | std::wstring value; 43 | }; 44 | 45 | class Settings { 46 | public: 47 | const std::wstring& operator[](enum_t name) const; 48 | 49 | bool GetBool(enum_t name) const; 50 | int GetInt(enum_t name) const; 51 | const std::wstring& GetWstr(enum_t name) const; 52 | 53 | void Set(enum_t name, bool value); 54 | void Set(enum_t name, int value); 55 | void Set(enum_t name, const std::wstring& value); 56 | bool Toggle(enum_t name); 57 | 58 | protected: 59 | void InitializeKey(enum_t name, const wchar_t* default_value, const std::wstring& path); 60 | std::wstring ReadValue(const pugi::xml_node& node_parent, const std::wstring& path, 61 | const bool attribute, const std::wstring& default_value); 62 | void ReadValue(const pugi::xml_node& node_parent, enum_t name); 63 | void WriteValue(const pugi::xml_node& node_parent, enum_t name); 64 | 65 | virtual void InitializeMap() = 0; 66 | 67 | std::map<enum_t, Setting> map_; 68 | }; 69 | 70 | } // namespace base 71 | -------------------------------------------------------------------------------- /src/library/anime_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | 23 | #include "library/anime_item.h" 24 | 25 | class HistoryItem; 26 | namespace pugi { 27 | class xml_document; 28 | class xml_node; 29 | } 30 | 31 | namespace anime { 32 | 33 | class Database { 34 | public: 35 | bool LoadDatabase(); 36 | bool SaveDatabase(); 37 | 38 | Item* FindItem(int id, bool log_error = true); 39 | Item* FindItem(const std::wstring& id, enum_t service, bool log_error = true); 40 | 41 | void ClearInvalidItems(); 42 | bool DeleteItem(int id); 43 | int UpdateItem(const Item& item); 44 | 45 | public: 46 | bool LoadList(); 47 | bool SaveList(bool include_database = false); 48 | 49 | int GetItemCount(int status, bool check_history = true); 50 | 51 | void AddToList(int anime_id, int status); 52 | void ClearUserData(); 53 | bool DeleteListItem(int anime_id); 54 | void UpdateItem(const HistoryItem& history_item); 55 | 56 | public: 57 | std::map<int, Item> items; 58 | 59 | private: 60 | void ReadDatabaseNode(pugi::xml_node& database_node); 61 | void WriteDatabaseNode(pugi::xml_node& database_node); 62 | 63 | bool CheckOldUserDirectory(); 64 | void HandleCompatibility(const std::wstring& meta_version); 65 | void HandleListCompatibility(const std::wstring& meta_version); 66 | void ReadDatabaseInCompatibilityMode(pugi::xml_document& document); 67 | void ReadListInCompatibilityMode(pugi::xml_document& document); 68 | }; 69 | 70 | } // namespace anime 71 | 72 | extern anime::Database AnimeDatabase; 73 | -------------------------------------------------------------------------------- /src/base/process.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <windows.h> 20 | 21 | #include "process.h" 22 | 23 | bool CheckInstance(LPCWSTR mutex_name, LPCWSTR class_name) { 24 | if (CreateMutex(NULL, FALSE, mutex_name) == NULL || 25 | GetLastError() == ERROR_ALREADY_EXISTS || 26 | GetLastError() == ERROR_ACCESS_DENIED) { 27 | HWND hwnd = FindWindow(class_name, NULL); 28 | 29 | if (IsWindow(hwnd)) { 30 | ActivateWindow(hwnd); 31 | FlashWindow(hwnd, TRUE); 32 | } 33 | 34 | return true; 35 | } 36 | 37 | return false; 38 | } 39 | 40 | void ActivateWindow(HWND hwnd) { 41 | if (IsIconic(hwnd)) 42 | ::ShowWindow(hwnd, SW_RESTORE); 43 | 44 | if (!IsWindowVisible(hwnd)) { 45 | WINDOWPLACEMENT wp = {0}; 46 | wp.length = sizeof(WINDOWPLACEMENT); 47 | ::GetWindowPlacement(hwnd, &wp); 48 | ::ShowWindow(hwnd, wp.showCmd); 49 | } 50 | 51 | ::SetForegroundWindow(hwnd); 52 | ::BringWindowToTop(hwnd); 53 | } 54 | 55 | std::wstring GetWindowClass(HWND hwnd) { 56 | WCHAR buff[MAX_PATH]; 57 | GetClassName(hwnd, buff, MAX_PATH); 58 | return buff; 59 | } 60 | 61 | std::wstring GetWindowTitle(HWND hwnd) { 62 | WCHAR buff[MAX_PATH]; 63 | GetWindowText(hwnd, buff, MAX_PATH); 64 | return buff; 65 | } 66 | 67 | bool IsFullscreen(HWND hwnd) { 68 | LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); 69 | 70 | if (style & WS_EX_TOPMOST) { 71 | RECT rect; 72 | GetClientRect(hwnd, &rect); 73 | 74 | if (rect.right >= GetSystemMetrics(SM_CXSCREEN) && 75 | rect.bottom >= GetSystemMetrics(SM_CYSCREEN)) 76 | return true; 77 | } 78 | 79 | return false; 80 | } 81 | -------------------------------------------------------------------------------- /src/library/anime_util_time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <map> 20 | 21 | #include "base/string.h" 22 | #include "base/time.h" 23 | #include "library/anime_season.h" 24 | #include "library/anime_util.h" 25 | 26 | namespace anime { 27 | 28 | bool IsValidDate(const Date& date) { 29 | return date.year() > 0; 30 | } 31 | 32 | std::wstring TranslateDate(const Date& date) { 33 | if (!IsValidDate(date)) 34 | return L"?"; 35 | 36 | std::wstring result; 37 | 38 | if (date.month() > 0 && date.month() <= 12) { 39 | const wchar_t* months[] = { 40 | L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", 41 | L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" 42 | }; 43 | result += months[date.month() - 1]; 44 | result += L" "; 45 | } 46 | if (date.day() > 0) 47 | result += ToWstr(date.day()) + L", "; 48 | result += ToWstr(date.year()); 49 | 50 | return result; 51 | } 52 | 53 | std::wstring TranslateDateToSeasonString(const Date& date) { 54 | if (!IsValidDate(date)) 55 | return L"Unknown"; 56 | 57 | return Season(date).GetString(); 58 | } 59 | 60 | std::wstring TranslateSeasonToMonths(const Season& season) { 61 | const wchar_t* months[] = { 62 | L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", 63 | L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" 64 | }; 65 | 66 | Date date_start, date_end; 67 | season.GetInterval(date_start, date_end); 68 | 69 | std::wstring result = months[date_start.month() - 1]; 70 | result += L" " + ToWstr(date_start.year()) + L" to "; 71 | result += months[date_end.month() - 1]; 72 | result += L" " + ToWstr(date_end.year()); 73 | 74 | return result; 75 | } 76 | 77 | } // namespace anime -------------------------------------------------------------------------------- /src/ui/dlg/dlg_season.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows/win/common_controls.h> 22 | #include <windows/win/dialog.h> 23 | 24 | namespace ui { 25 | 26 | enum SeasonGroupBy { 27 | kSeasonGroupByAiringStatus, 28 | kSeasonGroupByListStatus, 29 | kSeasonGroupByType 30 | }; 31 | 32 | enum SeasonSortBy { 33 | kSeasonSortByAiringDate, 34 | kSeasonSortByEpisodes, 35 | kSeasonSortByPopularity, 36 | kSeasonSortByScore, 37 | kSeasonSortByTitle 38 | }; 39 | 40 | enum SeasonViewAs { 41 | kSeasonViewAsImages, 42 | kSeasonViewAsTiles 43 | }; 44 | 45 | class SeasonDialog : public win::Dialog { 46 | public: 47 | SeasonDialog(); 48 | ~SeasonDialog() {} 49 | 50 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 51 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 52 | void OnContextMenu(HWND hwnd, POINT pt); 53 | BOOL OnDestroy(); 54 | BOOL OnInitDialog(); 55 | LRESULT OnListCustomDraw(LPARAM lParam); 56 | LRESULT OnListNotify(LPARAM lParam); 57 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 58 | void OnSize(UINT uMsg, UINT nType, SIZE size); 59 | LRESULT OnToolbarNotify(LPARAM lParam); 60 | 61 | void EnableInput(bool enable = true); 62 | void GetData(); 63 | void RefreshData(int anime_id = 0); 64 | void RefreshList(bool redraw_only = false); 65 | void RefreshStatus(); 66 | void RefreshToolbar(); 67 | void SetViewMode(int mode); 68 | 69 | private: 70 | int GetLineCount() const; 71 | 72 | win::Window cancel_button_; 73 | win::ListView list_; 74 | win::Rebar rebar_; 75 | win::Toolbar toolbar_; 76 | win::Tooltip tooltips_; 77 | 78 | int hot_item_; 79 | }; 80 | 81 | extern SeasonDialog DlgSeason; 82 | 83 | } // namespace ui 84 | -------------------------------------------------------------------------------- /src/sync/service.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/format.h" 20 | #include "base/http.h" 21 | #include "sync/service.h" 22 | 23 | namespace sync { 24 | 25 | Request::Request() 26 | : service_id(kAllServices), type(kGenericRequest) { 27 | } 28 | 29 | Request::Request(RequestType type) 30 | : service_id(kAllServices), type(type) { 31 | } 32 | 33 | Response::Response() 34 | : service_id(kAllServices), type(kGenericRequest) { 35 | } 36 | 37 | //////////////////////////////////////////////////////////////////////////////// 38 | 39 | Service::Service() 40 | : id_(0) { 41 | } 42 | 43 | bool Service::RequestNeedsAuthentication(RequestType request_type) const { 44 | return false; 45 | } 46 | 47 | const string_t& Service::host() const { 48 | return host_; 49 | } 50 | 51 | enum_t Service::id() const { 52 | return id_; 53 | } 54 | 55 | const string_t& Service::canonical_name() const { 56 | return canonical_name_; 57 | } 58 | 59 | const string_t& Service::name() const { 60 | return name_; 61 | } 62 | 63 | User& Service::user() { 64 | return user_; 65 | } 66 | 67 | const User& Service::user() const { 68 | return user_; 69 | } 70 | 71 | //////////////////////////////////////////////////////////////////////////////// 72 | 73 | void Service::HandleError(const HttpResponse& http_response, 74 | Response& response) const { 75 | auto& error = response.data[L"error"]; 76 | 77 | if (!error.empty()) { 78 | error = L"{} returned an error: {}"_format(name(), error); 79 | } else { 80 | error = L"{} returned an unknown error. " 81 | L"Request type: {} - HTTP status code: {}"_format( 82 | name(), response.type, http_response.code); 83 | } 84 | } 85 | 86 | } // namespace sync 87 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <map> 22 | #include <vector> 23 | 24 | #include "track/feed.h" 25 | #include <windows/win/common_controls.h> 26 | #include <windows/win/dialog.h> 27 | #include "ui/dlg/dlg_settings_page.h" 28 | 29 | namespace ui { 30 | 31 | enum SettingsSections { 32 | kSettingsSectionServices = 1, 33 | kSettingsSectionLibrary, 34 | kSettingsSectionApplication, 35 | kSettingsSectionRecognition, 36 | kSettingsSectionSharing, 37 | kSettingsSectionTorrents, 38 | kSettingsSectionAdvanced, 39 | }; 40 | 41 | class SettingsDialog : public win::Dialog { 42 | public: 43 | SettingsDialog(); 44 | ~SettingsDialog() {} 45 | 46 | friend class SettingsPage; 47 | 48 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 49 | BOOL OnInitDialog(); 50 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 51 | void OnOK(); 52 | 53 | void SetCurrentSection(SettingsSections section); 54 | void SetCurrentPage(SettingsPages page); 55 | 56 | int AddTorrentFilterToList(HWND hwnd_list, const FeedFilter& filter); 57 | void RefreshCache(); 58 | void RefreshTorrentFilterList(HWND hwnd_list); 59 | void RefreshTwitterLink(); 60 | 61 | private: 62 | class TreeView : public win::TreeView { 63 | public: 64 | LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 65 | std::map<int, HTREEITEM> items; 66 | } tree_; 67 | win::Tab tab_; 68 | 69 | private: 70 | std::map<int, std::pair<std::wstring, std::wstring>> advanced_settings_; 71 | SettingsSections current_section_; 72 | SettingsPages current_page_; 73 | std::vector<FeedFilter> feed_filters_; 74 | std::vector<SettingsPage> pages; 75 | }; 76 | 77 | extern SettingsDialog DlgSettings; 78 | 79 | } // namespace ui 80 | -------------------------------------------------------------------------------- /src/compat/crypto.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/string.h" 20 | #include "compat/crypto.h" 21 | 22 | namespace compat { 23 | 24 | static const wchar_t encryption_char = L'?'; 25 | static const wchar_t* encryption_key = L"Tenori Taiga"; 26 | static const size_t encryption_length_min = 16; 27 | 28 | static std::wstring Xor(std::wstring str, const std::wstring& key) { 29 | for (size_t i = 0; i < str.size(); i++) 30 | str[i] = str[i] ^ key[i % key.length()]; 31 | 32 | return str; 33 | } 34 | 35 | std::wstring SimpleEncrypt(std::wstring str) { 36 | // Set minimum length 37 | if (str.length() > 0 && str.length() < encryption_length_min) 38 | str.append(encryption_length_min - str.length(), 39 | encryption_char); 40 | 41 | // Encrypt 42 | str = Xor(str, encryption_key); 43 | 44 | // Convert to hexadecimal string 45 | std::wstring buffer; 46 | for (size_t i = 0; i < str.size(); i++) { 47 | wchar_t c[32] = {'\0'}; 48 | _itow_s(str[i], c, 32, 16); 49 | if (wcslen(c) == 1) 50 | buffer.push_back('0'); 51 | buffer += c; 52 | } 53 | ToUpper(buffer); 54 | 55 | return buffer; 56 | } 57 | 58 | std::wstring SimpleDecrypt(std::wstring str) { 59 | // Convert from hexadecimal string 60 | std::wstring buffer; 61 | for (size_t i = 0; i < str.size(); i = i + 2) { 62 | wchar_t c = static_cast<wchar_t>(wcstoul(str.substr(i, 2).c_str(), 63 | nullptr, 16)); 64 | buffer.push_back(c); 65 | } 66 | 67 | // Decrypt 68 | buffer = Xor(buffer, encryption_key); 69 | 70 | // Trim characters appended to match the minimum length 71 | if (buffer.size() >= encryption_length_min) 72 | TrimRight(buffer, std::wstring(1, encryption_char).c_str()); 73 | 74 | return buffer; 75 | } 76 | 77 | } // namespace compat 78 | -------------------------------------------------------------------------------- /data/theme/Default/Theme.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | <theme> 3 | <!-- Icons --> 4 | <!-- Fugue Icons by Yusuke Kamiyamane - http://p.yusukekamiyamane.com --> 5 | <icons> 6 | <set_16px> 7 | <icon name="square-small-green"/> 8 | <icon name="square-small-blue"/> 9 | <icon name="square-small-red"/> 10 | <icon name="square-small-gray"/> 11 | <icon name="film"/> 12 | <icon name="magnifier-left"/> 13 | <icon name="folder-small-horizontal"/> 14 | <icon name="application-small-blue"/> 15 | <icon name="application-small"/> 16 | <icon name="arrow-circle-315"/> 17 | <icon name="navigation-270-button"/> 18 | <icon name="gear"/> 19 | <icon name="cross"/> 20 | <icon name="plus"/> 21 | <icon name="minus"/> 22 | <icon name="arrow-090"/> 23 | <icon name="arrow-270"/> 24 | <icon name="funnel-small"/> 25 | <icon name="funnel-cross"/> 26 | <icon name="funnel-tick"/> 27 | <icon name="funnel-plus"/> 28 | <icon name="funnel-pencil"/> 29 | <icon name="calendar-month"/> 30 | <icon name="category"/> 31 | <icon name="sort-quantity-descending"/> 32 | <icon name="balloon-left"/> 33 | <icon name="clock"/> 34 | <icon name="home"/> 35 | <icon name="document-attribute"/> 36 | <icon name="chart"/> 37 | <icon name="feed"/> 38 | <icon name="ui-scroll-pane-detail"/> 39 | <icon name="document-import"/> 40 | <icon name="document-export"/> 41 | </set_16px> 42 | <set_24px> 43 | <icon name="arrow-circle-double-135"/> 44 | <icon name="folder-open"/> 45 | <icon name="application-export"/> 46 | <icon name="gear"/> 47 | <icon name="taiga"/> 48 | <icon name="globe"/> 49 | <icon name="inbox-document"/> 50 | <icon name="application-sidebar-list"/> 51 | <icon name="document-question"/> 52 | <icon name="megaphone"/> 53 | <icon name="feed"/> 54 | </set_24px> 55 | </icons> 56 | 57 | <!-- List --> 58 | <list> 59 | <progress> 60 | <border type="solid" value_1="E0E0E0"/> 61 | <background type="solid" value_1="F0F0F0"/> 62 | <button type="solid" value_1="646464"/> 63 | <separator type="solid" value_1="E0E0E0"/> 64 | <watching type="solid" value_1="60C653"/> 65 | <completed type="solid" value_1="60C653"/> 66 | <onhold type="solid" value_1="60C653"/> 67 | <dropped type="solid" value_1="60C653"/> 68 | <plantowatch type="solid" value_1="60C653"/> 69 | <available type="solid" value_1="4B9940"/> 70 | <aired type="solid" value_1="D8D8D8"/> 71 | </progress> 72 | </list> 73 | </theme> -------------------------------------------------------------------------------- /src/sync/anilist.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/json.h" 22 | #include "base/types.h" 23 | #include "sync/service.h" 24 | 25 | namespace anime { 26 | class Item; 27 | } 28 | 29 | namespace sync { 30 | namespace anilist { 31 | 32 | // API documentation: 33 | // https://anilist.gitbooks.io/anilist-apiv2-docs/ 34 | // https://anilist.github.io/ApiV2-GraphQL-Docs/ 35 | 36 | class Service : public sync::Service { 37 | public: 38 | Service(); 39 | ~Service() {} 40 | 41 | void BuildRequest(Request& request, HttpRequest& http_request); 42 | void HandleResponse(Response& response, HttpResponse& http_response); 43 | bool RequestNeedsAuthentication(RequestType request_type) const; 44 | 45 | private: 46 | REQUEST_AND_RESPONSE(AddLibraryEntry); 47 | REQUEST_AND_RESPONSE(AuthenticateUser); 48 | REQUEST_AND_RESPONSE(DeleteLibraryEntry); 49 | REQUEST_AND_RESPONSE(GetLibraryEntries); 50 | REQUEST_AND_RESPONSE(GetMetadataById); 51 | REQUEST_AND_RESPONSE(GetSeason); 52 | REQUEST_AND_RESPONSE(SearchTitle); 53 | REQUEST_AND_RESPONSE(UpdateLibraryEntry); 54 | 55 | bool RequestSucceeded(Response& response, const HttpResponse& http_response); 56 | 57 | std::wstring BuildLibraryObject(Request& request) const; 58 | std::wstring BuildRequestBody(const std::string& query, const Json& variables) const; 59 | 60 | int ParseMediaObject(const Json& json) const; 61 | int ParseMediaListObject(const Json& json) const; 62 | void ParseMediaTitleObject(const Json& json, anime::Item& anime_item) const; 63 | void ParseUserObject(const Json& json); 64 | 65 | bool ParseResponseBody(const std::wstring& body, Response& response, Json& json); 66 | 67 | std::string ExpandQuery(const std::string& query) const; 68 | std::wstring GetMediaFields() const; 69 | std::wstring GetMediaListFields() const; 70 | }; 71 | 72 | } // namespace anilist 73 | } // namespace sync 74 | -------------------------------------------------------------------------------- /src/sync/kitsu.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "base/json.h" 22 | #include "base/types.h" 23 | #include "sync/service.h" 24 | 25 | namespace sync { 26 | namespace kitsu { 27 | 28 | // API documentation: 29 | // https://kitsu.docs.apiary.io 30 | 31 | class Service : public sync::Service { 32 | public: 33 | Service(); 34 | ~Service() {} 35 | 36 | void BuildRequest(Request& request, HttpRequest& http_request); 37 | void HandleResponse(Response& response, HttpResponse& http_response); 38 | bool RequestNeedsAuthentication(RequestType request_type) const; 39 | 40 | private: 41 | REQUEST_AND_RESPONSE(AddLibraryEntry); 42 | REQUEST_AND_RESPONSE(AuthenticateUser); 43 | REQUEST_AND_RESPONSE(GetUser); 44 | REQUEST_AND_RESPONSE(DeleteLibraryEntry); 45 | REQUEST_AND_RESPONSE(GetLibraryEntries); 46 | REQUEST_AND_RESPONSE(GetMetadataById); 47 | REQUEST_AND_RESPONSE(GetSeason); 48 | REQUEST_AND_RESPONSE(SearchTitle); 49 | REQUEST_AND_RESPONSE(UpdateLibraryEntry); 50 | 51 | bool RequestSucceeded(Response& response, const HttpResponse& http_response); 52 | 53 | std::wstring BuildLibraryObject(Request& request) const; 54 | void UseSparseFieldsetsForAnime(HttpRequest& http_request, bool minimal = false) const; 55 | void UseSparseFieldsetsForLibraryEntries(HttpRequest& http_request) const; 56 | void UseSparseFieldsetsForUser(HttpRequest& http_request) const; 57 | 58 | void ParseObject(const Json& json) const; 59 | int ParseAnimeObject(const Json& json) const; 60 | void ParseCategories(const Json& json, const int anime_id) const; 61 | void ParseProducers(const Json& json, const int anime_id) const; 62 | int ParseLibraryObject(const Json& json) const; 63 | void ParseLinks(const Json& json, Response& response) const; 64 | 65 | bool ParseResponseBody(const std::wstring& body, Response& response, Json& json); 66 | 67 | bool IsPartialLibraryRequest() const; 68 | }; 69 | 70 | } // namespace kitsu 71 | } // namespace sync 72 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_input.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "taiga/resource.h" 20 | #include "ui/dlg/dlg_input.h" 21 | 22 | namespace ui { 23 | 24 | InputDialog::InputDialog() 25 | : current_value_(0), min_value_(0), max_value_(0), 26 | numbers_only_(false), password_(false), result(0) { 27 | info = L"Set new value:"; 28 | title = L"Input"; 29 | }; 30 | 31 | void InputDialog::SetNumbers(bool enabled, int min_value, int max_value, 32 | int current_value) { 33 | numbers_only_ = enabled; 34 | min_value_ = min_value; 35 | max_value_ = max_value; 36 | current_value_ = current_value; 37 | } 38 | 39 | void InputDialog::SetPassword(bool enabled) { 40 | password_ = enabled; 41 | } 42 | 43 | void InputDialog::Show(HWND parent) { 44 | result = Create(IDD_INPUT, parent, true); 45 | } 46 | 47 | //////////////////////////////////////////////////////////////////////////////// 48 | 49 | BOOL InputDialog::OnInitDialog() { 50 | // Set dialog title 51 | SetWindowText(GetWindowHandle(), title.c_str()); 52 | 53 | // Set information text 54 | SetDlgItemText(IDC_STATIC_INPUTINFO, info.c_str()); 55 | 56 | // Set text style and properties 57 | edit_.Attach(GetDlgItem(IDC_EDIT_INPUT)); 58 | spin_.Attach(GetDlgItem(IDC_SPIN_INPUT)); 59 | if (numbers_only_) { 60 | edit_.SetStyle(ES_NUMBER, 0); 61 | spin_.SetBuddy(edit_.GetWindowHandle()); 62 | spin_.SetRange32(min_value_, max_value_ > 0 ? max_value_ : 9999); 63 | spin_.SetPos32(current_value_); 64 | } else { 65 | edit_.SetStyle(0, ES_NUMBER); 66 | edit_.SetText(text.c_str()); 67 | spin_.Enable(FALSE); 68 | spin_.Hide(); 69 | } 70 | edit_.SetPasswordChar(password_ ? L'\u25cf' : 0); // black circle 71 | edit_.SetSel(0, -1); 72 | 73 | return TRUE; 74 | } 75 | 76 | void InputDialog::OnCancel() { 77 | EndDialog(IDCANCEL); 78 | } 79 | 80 | void InputDialog::OnOK() { 81 | edit_.GetText(text); 82 | EndDialog(IDOK); 83 | } 84 | 85 | } // namespace ui -------------------------------------------------------------------------------- /src/library/anime_filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/string.h" 20 | #include "library/anime_filter.h" 21 | #include "library/anime_item.h" 22 | #include "library/anime_util.h" 23 | 24 | namespace anime { 25 | 26 | Filters::Filters() { 27 | Reset(); 28 | } 29 | 30 | bool Filters::CheckItem(const Item& item, int text_index) const { 31 | // Filter my status 32 | for (size_t i = 0; i < my_status.size(); i++) 33 | if (!my_status.at(i) && item.GetMyStatus() == i) 34 | return false; 35 | 36 | // Filter airing status 37 | for (size_t i = 0; i < status.size(); i++) 38 | if (!status.at(i) && item.GetAiringStatus() == i + 1) 39 | return false; 40 | 41 | // Filter type 42 | for (size_t i = 0; i < type.size(); i++) 43 | if (!type.at(i) && item.GetType() == i + 1) 44 | return false; 45 | 46 | // Filter text 47 | if (!FilterText(item, text_index)) 48 | return false; 49 | 50 | // Item passed all filters 51 | return true; 52 | } 53 | 54 | bool Filters::FilterText(const Item& item, int text_index) const { 55 | std::vector<std::wstring> words; 56 | auto it = text.find(text_index); 57 | auto filter_text = it != text.end() ? it->second : std::wstring(); 58 | Split(filter_text, L" ", words); 59 | RemoveEmptyStrings(words); 60 | 61 | std::vector<std::wstring> titles; 62 | GetAllTitles(item.GetId(), titles); 63 | 64 | const auto& genres = item.GetGenres(); 65 | 66 | for (const auto& word : words) { 67 | auto check_strings = [&word](const std::vector<std::wstring>& v) { 68 | for (const auto& str : v) { 69 | if (InStr(str, word, 0, true) > -1) 70 | return true; 71 | } 72 | return false; 73 | }; 74 | if (!check_strings(titles) && 75 | !check_strings(genres) && 76 | InStr(item.GetMyTags(), word, 0, true) == -1) 77 | return false; 78 | } 79 | 80 | return true; 81 | } 82 | 83 | void Filters::Reset() { 84 | my_status.clear(); 85 | status.clear(); 86 | type.clear(); 87 | 88 | my_status.resize(7, true); 89 | status.resize(3, true); 90 | type.resize(6, true); 91 | 92 | text.clear(); 93 | } 94 | 95 | } // namespace anime -------------------------------------------------------------------------------- /src/taiga/orange.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <cmath> 20 | 21 | #include "taiga/orange.h" 22 | 23 | namespace taiga { 24 | 25 | Orange orange; 26 | 27 | int Orange::note_list_[][2] = { 28 | {84, 1}, // 1/2 29 | {84, 2}, // 1/4 30 | {86, 4}, // 1/8 31 | {84, 2}, // 1/4 32 | {82, 2}, // 1/4 33 | {81, 2}, // 1/4 34 | {77, 4}, // 1/8 35 | {79, 4}, // 1/8 36 | {72, 4}, // 1/8 37 | {77, 1}, // 1/2 38 | {76, 4}, // 1/8 39 | {77, 4}, // 1/8 40 | {79, 4}, // 1/8 41 | {81, 2}, // 1/4 42 | {79, 2}, // 1/4 43 | {77, 2}, // 1/4 44 | {79, 2}, // 1/4 45 | {81, 4}, // 1/8 46 | {84, 1}, // 1/2 47 | {84, 2}, // 1/2 48 | {86, 4}, // 1/8 49 | {84, 2}, // 1/4 50 | {82, 2}, // 1/4 51 | {81, 2}, // 1/4 52 | {77, 4}, // 1/8 53 | {79, 4}, // 1/8 54 | {72, 4}, // 1/8 55 | {77, 1}, // 1/2 56 | {76, 4}, // 1/8 57 | {77, 4}, // 1/8 58 | {76, 4}, // 1/8 59 | {74, 1} // 1/1 60 | }; 61 | 62 | Orange::Orange() 63 | : play_(false) { 64 | } 65 | 66 | Orange::~Orange() { 67 | Stop(); 68 | } 69 | 70 | void Orange::Start() { 71 | Stop(); 72 | play_ = true; 73 | 74 | if (!GetThreadHandle()) 75 | CreateThread(nullptr, 0, 0); 76 | } 77 | 78 | void Orange::Stop() { 79 | play_ = false; 80 | 81 | if (GetThreadHandle()) { 82 | WaitForSingleObject(GetThreadHandle(), INFINITE); 83 | CloseThreadHandle(); 84 | } 85 | } 86 | 87 | DWORD Orange::ThreadProc() { 88 | size_t note_count = 32; 89 | size_t note_index = 0; 90 | 91 | while (play_ && note_index < note_count) { 92 | int note = note_list_[note_index][0]; 93 | 94 | DWORD frequency = static_cast<DWORD>(NoteToFrequency(note)); 95 | DWORD duration = 800 / note_list_[note_index][1]; 96 | 97 | Beep(frequency, duration); 98 | 99 | note_index++; 100 | }; 101 | 102 | return 0; 103 | } 104 | 105 | float Orange::NoteToFrequency(int n) { 106 | if (n < 0 || n > 119) 107 | return -1.0f; 108 | 109 | return 440.0f * std::pow(2.0f, static_cast<float>(n - 57) / 12.0f); 110 | } 111 | 112 | } // namespace taiga -------------------------------------------------------------------------------- /src/ui/dlg/dlg_feed_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "track/feed.h" 22 | #include <windows/win/common_controls.h> 23 | #include <windows/win/dialog.h> 24 | 25 | namespace ui { 26 | 27 | class FeedFilterDialog : public win::Dialog { 28 | public: 29 | FeedFilterDialog(); 30 | ~FeedFilterDialog(); 31 | 32 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 33 | void OnCancel(); 34 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 35 | BOOL OnInitDialog(); 36 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 37 | 38 | void ChoosePage(int index); 39 | 40 | FeedFilter filter; 41 | 42 | private: 43 | int current_page_; 44 | HICON icon_; 45 | win::Window main_instructions_label_; 46 | 47 | // Page 48 | class DialogPage : public win::Dialog { 49 | public: 50 | void Create(UINT uResourceID, FeedFilterDialog* parent, const RECT& rect); 51 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 52 | public: 53 | FeedFilterDialog* parent; 54 | }; 55 | 56 | // Page #0 57 | class DialogPage0 : public DialogPage { 58 | public: 59 | BOOL OnInitDialog(); 60 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 61 | bool BuildFilter(FeedFilter& filter); 62 | public: 63 | win::ListView preset_list; 64 | } page_0_; 65 | 66 | // Page #1 67 | class DialogPage1 : public DialogPage { 68 | public: 69 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 70 | BOOL OnInitDialog(); 71 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 72 | bool BuildFilter(FeedFilter& filter); 73 | void AddConditionToList(const FeedFilterCondition& condition, int index = -1); 74 | void RefreshConditionList(); 75 | void ChangeAction(); 76 | public: 77 | win::ComboBox action_combo, match_combo, option_combo; 78 | win::Edit name_text; 79 | win::ListView condition_list; 80 | win::Toolbar condition_toolbar; 81 | } page_1_; 82 | 83 | // Page #2 84 | class DialogPage2 : public DialogPage { 85 | public: 86 | BOOL OnInitDialog(); 87 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 88 | bool BuildFilter(FeedFilter& filter); 89 | public: 90 | win::ListView anime_list; 91 | } page_2_; 92 | }; 93 | 94 | extern FeedFilterDialog DlgFeedFilter; 95 | 96 | } // namespace ui 97 | -------------------------------------------------------------------------------- /src/base/gzip.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <windows.h> 20 | 21 | #include <zlib/zlib.h> 22 | 23 | #include "gzip.h" 24 | 25 | bool UncompressGzippedString(const std::string& input, std::string& output) { 26 | z_stream stream; 27 | stream.zalloc = Z_NULL; 28 | stream.zfree = Z_NULL; 29 | stream.opaque = NULL; 30 | stream.total_out = 0; 31 | stream.next_in = (BYTE*)&input[0]; 32 | stream.avail_in = input.length(); 33 | 34 | if (inflateInit2(&stream, MAX_WBITS + 32) != Z_OK) 35 | return false; 36 | 37 | size_t buffer_length = input.length() * 2; 38 | char* buffer = (char*)GlobalAlloc(GMEM_ZEROINIT, buffer_length); 39 | 40 | size_t total_length = 0; 41 | int status = Z_OK; 42 | 43 | do { 44 | stream.next_out = (BYTE*)buffer; 45 | stream.avail_out = buffer_length; 46 | status = inflate(&stream, Z_SYNC_FLUSH); 47 | if (status == Z_OK || status == Z_STREAM_END) { 48 | output.append(buffer, stream.total_out - total_length); 49 | total_length = stream.total_out; 50 | } 51 | } while (status == Z_OK); 52 | 53 | GlobalFree(buffer); 54 | inflateEnd(&stream); 55 | 56 | return status == Z_STREAM_END; 57 | } 58 | 59 | //////////////////////////////////////////////////////////////////////////////// 60 | 61 | bool DeflateString(const std::string& input, std::string& output) { 62 | uLong source_length = input.length(); 63 | uLong destination_length = compressBound(source_length); 64 | 65 | output.resize(destination_length); 66 | 67 | int result = compress((Bytef*)output.data(), &destination_length, 68 | (Bytef*)input.data(), source_length); 69 | 70 | if (output.length() != destination_length) 71 | output.resize(destination_length); 72 | 73 | return result == Z_OK; 74 | } 75 | 76 | bool InflateString(const std::string& input, std::string& output, 77 | size_t output_length) { 78 | uLong source_length = input.length(); 79 | uLong destination_length = output_length; 80 | 81 | output.resize(destination_length); 82 | 83 | int result = uncompress((Bytef*)output.data(), &destination_length, 84 | (Bytef*)input.data(), source_length); 85 | 86 | if (output.length() != destination_length) 87 | output.resize(destination_length); 88 | 89 | return result == Z_OK; 90 | } -------------------------------------------------------------------------------- /src/base/xml.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "file.h" 20 | #include "string.h" 21 | #include "xml.h" 22 | 23 | struct xml_string_writer: pugi::xml_writer { 24 | std::string result; 25 | 26 | virtual void write(const void* data, size_t size) { 27 | result += std::string(static_cast<const char*>(data), size); 28 | } 29 | }; 30 | 31 | std::wstring XmlGetNodeAsString(pugi::xml_node node) { 32 | xml_string_writer writer; 33 | node.print(writer); 34 | 35 | return StrToWstr(writer.result); 36 | } 37 | 38 | int XmlReadIntValue(pugi::xml_node& node, const wchar_t* name) { 39 | return _wtoi(node.child_value(name)); 40 | } 41 | 42 | std::wstring XmlReadStrValue(pugi::xml_node& node, const wchar_t* name) { 43 | return node.child_value(name); 44 | } 45 | 46 | void XmlReadChildNodes(pugi::xml_node& parent_node, 47 | std::vector<std::wstring>& output, 48 | const wchar_t* name) { 49 | foreach_xmlnode_(child_node, parent_node, name) { 50 | output.push_back(child_node.child_value()); 51 | } 52 | } 53 | 54 | void XmlWriteChildNodes(pugi::xml_node& parent_node, 55 | const std::vector<std::wstring>& input, 56 | const wchar_t* name, 57 | pugi::xml_node_type node_type) { 58 | for (const auto& value : input) { 59 | xml_node child_node = parent_node.append_child(name); 60 | child_node.append_child(node_type).set_value(value.c_str()); 61 | } 62 | } 63 | 64 | void XmlWriteIntValue(pugi::xml_node& node, const wchar_t* name, int value) { 65 | xml_node child = node.append_child(name); 66 | child.append_child(pugi::node_pcdata).set_value(ToWstr(value).c_str()); 67 | } 68 | 69 | void XmlWriteStrValue(pugi::xml_node& node, const wchar_t* name, 70 | const wchar_t* value, pugi::xml_node_type node_type) { 71 | xml_node child = node.append_child(name); 72 | child.append_child(node_type).set_value(value); 73 | } 74 | 75 | bool XmlWriteDocumentToFile(const pugi::xml_document& document, 76 | const std::wstring& path) { 77 | CreateFolder(GetPathOnly(path)); 78 | 79 | const pugi::char_t* indent = L"\x09"; // horizontal tab 80 | unsigned int flags = pugi::format_default | pugi::format_write_bom; 81 | return document.save_file(path.c_str(), indent, flags); 82 | } -------------------------------------------------------------------------------- /src/library/anime.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <vector> 23 | 24 | #include "base/time.h" 25 | 26 | namespace anime { 27 | 28 | // ID_NOTINLIST 29 | // Used in Episode data to denote the item is not in user's list. 30 | // Item may or may not be in the database. 31 | // 32 | // ID_UNKNOWN 33 | // There's no item in the database with this ID. 34 | // This is the default ID for all anime items. 35 | // 36 | enum AnimeId { 37 | ID_NOTINLIST = -1, 38 | ID_UNKNOWN = 0 39 | }; 40 | 41 | enum SeriesStatus { 42 | kUnknownStatus, 43 | kFinishedAiring, 44 | kAiring, 45 | kNotYetAired 46 | }; 47 | 48 | enum SeriesType { 49 | kUnknownType, 50 | kTv, 51 | kOva, 52 | kMovie, 53 | kSpecial, 54 | kOna, 55 | kMusic 56 | }; 57 | 58 | const int kUnknownEpisodeCount = -1; 59 | const int kUnknownEpisodeLength = -1; 60 | const double kUnknownScore = 0.0; 61 | const int kUserScoreMax = 100; 62 | 63 | enum MyStatus { 64 | kMyStatusFirst = 1, 65 | kNotInList = 0, 66 | kWatching, 67 | kCompleted, 68 | kOnHold, 69 | kDropped, 70 | kPlanToWatch, 71 | kMyStatusLast 72 | }; 73 | 74 | enum AgeRating { 75 | kUnknownAgeRating, 76 | kAgeRatingG, 77 | kAgeRatingPG, 78 | kAgeRatingPG13, 79 | kAgeRatingR17, 80 | kAgeRatingR18 81 | }; 82 | 83 | // Invalid for anime items that are not in user's list 84 | class MyInformation { 85 | public: 86 | MyInformation(); 87 | virtual ~MyInformation() {} 88 | 89 | std::wstring id; 90 | int watched_episodes; 91 | int score; 92 | int status; 93 | int rewatched_times; 94 | int rewatching; 95 | int rewatching_ep; 96 | Date date_start; 97 | Date date_finish; 98 | std::wstring last_updated; 99 | std::wstring tags; 100 | std::wstring notes; 101 | }; 102 | 103 | // For all kinds of other temporary information 104 | class LocalInformation { 105 | public: 106 | LocalInformation(); 107 | virtual ~LocalInformation() {} 108 | 109 | int last_aired_episode; 110 | std::vector<bool> available_episodes; 111 | std::wstring next_episode_path; 112 | std::wstring folder; 113 | std::vector<std::wstring> synonyms; 114 | bool playing; 115 | bool use_alternative; 116 | }; 117 | 118 | } // namespace anime 119 | -------------------------------------------------------------------------------- /src/discord-RPC/include/discord_rpc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include <stdint.h> 3 | #include <string> 4 | 5 | // clang-format off 6 | namespace discord{ 7 | #if defined(DISCORD_DYNAMIC_LIB) 8 | # if defined(_WIN32) 9 | # if defined(DISCORD_BUILDING_SDK) 10 | # define DISCORD_EXPORT __declspec(dllexport) 11 | # else 12 | # define DISCORD_EXPORT __declspec(dllimport) 13 | # endif 14 | # else 15 | # define DISCORD_EXPORT __attribute__((visibility("default"))) 16 | # endif 17 | #else 18 | # define DISCORD_EXPORT 19 | #endif 20 | 21 | // clang-format on 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct DiscordRichPresence { 28 | const char* state; /* max 128 bytes */ 29 | const char* details; /* max 128 bytes */ 30 | int64_t startTimestamp; 31 | int64_t endTimestamp; 32 | const char* largeImageKey; /* max 32 bytes */ 33 | const char* largeImageText; /* max 128 bytes */ 34 | const char* smallImageKey; /* max 32 bytes */ 35 | const char* smallImageText; /* max 128 bytes */ 36 | const char* partyId; /* max 128 bytes */ 37 | int partySize; 38 | int partyMax; 39 | const char* matchSecret; /* max 128 bytes */ 40 | const char* joinSecret; /* max 128 bytes */ 41 | const char* spectateSecret; /* max 128 bytes */ 42 | int8_t instance; 43 | } DiscordRichPresence; 44 | 45 | typedef struct DiscordJoinRequest { 46 | const char* userId; 47 | const char* username; 48 | const char* discriminator; 49 | const char* avatar; 50 | } DiscordJoinRequest; 51 | 52 | typedef struct DiscordEventHandlers { 53 | void(*ready)(void); 54 | void(*disconnected)(int errorCode, const char* message); 55 | void(*errored)(int errorCode, const char* message); 56 | void(*joinGame)(const char* joinSecret); 57 | void(*spectateGame)(const char* spectateSecret); 58 | void(*joinRequest)(const DiscordJoinRequest* request); 59 | } DiscordEventHandlers; 60 | 61 | #define DISCORD_REPLY_NO 0 62 | #define DISCORD_REPLY_YES 1 63 | #define DISCORD_REPLY_IGNORE 2 64 | 65 | DISCORD_EXPORT void Discord_Initialize(const char* applicationId, 66 | DiscordEventHandlers* handlers, 67 | int autoRegister, 68 | const char* optionalSteamId); 69 | DISCORD_EXPORT void Discord_Shutdown(void); 70 | 71 | /* checks for incoming messages, dispatches callbacks */ 72 | DISCORD_EXPORT void Discord_RunCallbacks(void); 73 | 74 | /* If you disable the lib starting its own io thread, you'll need to call this from your own */ 75 | #ifdef DISCORD_DISABLE_IO_THREAD 76 | DISCORD_EXPORT void Discord_UpdateConnection(void); 77 | #endif 78 | 79 | DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); 80 | DISCORD_EXPORT void Discord_ClearPresence(void); 81 | 82 | DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply); 83 | 84 | #ifdef __cplusplus 85 | } /* extern "C" */ 86 | #endif 87 | } // namespace discord -------------------------------------------------------------------------------- /src/ui/dlg/dlg_update_new.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/gfx.h" 20 | #include "base/string.h" 21 | #include "taiga/resource.h" 22 | #include "taiga/taiga.h" 23 | #include "ui/dlg/dlg_update.h" 24 | #include "ui/dlg/dlg_update_new.h" 25 | #include "ui/theme.h" 26 | 27 | namespace ui { 28 | 29 | NewUpdateDialog DlgUpdateNew; 30 | 31 | BOOL NewUpdateDialog::OnInitDialog() { 32 | // Set icon 33 | SetIconLarge(IDI_MAIN); 34 | SetIconSmall(IDI_MAIN); 35 | 36 | // Set main text 37 | SendDlgItemMessage(IDC_STATIC_UPDATE_TITLE, WM_SETFONT, 38 | reinterpret_cast<WPARAM>(Theme.GetHeaderFont()), TRUE); 39 | SetDlgItemText(IDC_STATIC_UPDATE_TITLE, 40 | L"A new version of " TAIGA_APP_NAME L" is available!"); 41 | 42 | // Set details text 43 | std::wstring text = L"Current version: " + StrToWstr(Taiga.version.to_string()); 44 | SetDlgItemText(IDC_STATIC_UPDATE_DETAILS, text.c_str()); 45 | 46 | // Set changelog text 47 | std::wstring changelog = 48 | L"{\\rtf1\\ansi\\deff0" 49 | L"{\\fonttbl" 50 | L"{\\f0 Segoe UI;}" 51 | L"}" 52 | L"\\deflang1024\\fs18"; 53 | for (const auto& item : Taiga.Updater.items) { 54 | semaver::Version item_version(WstrToStr(item.guid)); 55 | if (item_version > Taiga.version) { 56 | changelog += L"\\b Version " + item.guid + L"\\b0\\line "; 57 | std::wstring description = item.description; 58 | ReplaceString(description, L"\n", L"\\line "); 59 | changelog += description + L"\\line\\line "; 60 | } 61 | } 62 | changelog += L"}"; 63 | win::RichEdit rich_edit(GetDlgItem(IDC_RICHEDIT_UPDATE)); 64 | rich_edit.SetTextEx(WstrToStr(changelog)); 65 | rich_edit.SetWindowHandle(nullptr); 66 | 67 | return TRUE; 68 | } 69 | 70 | void NewUpdateDialog::OnOK() { 71 | EndDialog(IDOK); 72 | 73 | if (!Taiga.Updater.Download()) 74 | DlgUpdate.PostMessage(WM_CLOSE); 75 | } 76 | 77 | void NewUpdateDialog::OnCancel() { 78 | EndDialog(IDCANCEL); 79 | 80 | DlgUpdate.PostMessage(WM_CLOSE); 81 | } 82 | 83 | void NewUpdateDialog::OnPaint(HDC hdc, LPPAINTSTRUCT lpps) { 84 | win::Dc dc = hdc; 85 | 86 | // Paint application icon 87 | win::Rect rect; 88 | win::Window label = GetDlgItem(IDC_STATIC_APP_ICON); 89 | label.GetWindowRect(GetWindowHandle(), &rect); 90 | label.SetWindowHandle(nullptr); 91 | DrawIconResource(IDI_MAIN, dc.Get(), rect, true, false); 92 | } 93 | 94 | } // namespace ui -------------------------------------------------------------------------------- /src/track/media.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <memory> 22 | #include <regex> 23 | #include <string> 24 | #include <vector> 25 | 26 | #include <anisthesia/src/player.h> 27 | #include <anisthesia/src/win/platform.h> 28 | 29 | namespace track { 30 | namespace recognition { 31 | 32 | enum class PlayStatus { 33 | Stopped, 34 | Playing, 35 | Updated, 36 | }; 37 | 38 | class MediaPlayer : public anisthesia::Player { 39 | public: 40 | MediaPlayer(const anisthesia::Player& player) 41 | : anisthesia::Player(player) {} 42 | 43 | bool enabled = true; 44 | }; 45 | 46 | class MediaPlayers { 47 | public: 48 | bool Load(); 49 | 50 | bool IsPlayerActive() const; 51 | 52 | std::string current_player_name() const; 53 | std::wstring current_title() const; 54 | 55 | bool player_running() const; 56 | void set_player_running(bool player_running); 57 | 58 | bool title_changed() const; 59 | void set_title_changed(bool title_changed); 60 | 61 | bool CheckRunningPlayers(); 62 | MediaPlayer* GetRunningPlayer(); 63 | 64 | public: 65 | std::vector<MediaPlayer> items; 66 | PlayStatus play_status = PlayStatus::Stopped; 67 | 68 | private: 69 | std::unique_ptr<anisthesia::win::Result> current_result_; 70 | std::wstring current_title_; 71 | std::wstring current_page_title_; 72 | bool player_running_ = false; 73 | bool title_changed_ = false; 74 | }; 75 | 76 | enum class Stream { 77 | Unknown, 78 | Animelab, 79 | Ann, 80 | Crunchyroll, 81 | Hidive, 82 | Plex, 83 | Veoh, 84 | Viz, 85 | Vrv, 86 | Wakanim, 87 | Youtube, 88 | }; 89 | 90 | struct StreamData { 91 | Stream id; 92 | enum_t option_id; 93 | std::wstring name; 94 | std::wstring url; 95 | std::regex url_pattern; 96 | std::regex title_pattern; 97 | }; 98 | 99 | const std::vector<StreamData>& GetStreamData(); 100 | 101 | bool GetTitleFromStreamingMediaProvider(const std::wstring& url, std::wstring& title); 102 | void NormalizeWebBrowserTitle(const std::wstring& url, std::wstring& title); 103 | 104 | } // namespace recognition 105 | } // namespace track 106 | 107 | using track::recognition::MediaPlayer; 108 | 109 | void ProcessMediaPlayerStatus(const MediaPlayer* media_player); 110 | void ProcessMediaPlayerTitle(const MediaPlayer& media_player); 111 | 112 | extern track::recognition::MediaPlayers MediaPlayers; 113 | -------------------------------------------------------------------------------- /src/ui/dlg/dlg_update.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "base/gfx.h" 20 | #include "taiga/resource.h" 21 | #include "taiga/taiga.h" 22 | #include "ui/dlg/dlg_main.h" 23 | #include "ui/dlg/dlg_update.h" 24 | #include "ui/dialog.h" 25 | #include "ui/theme.h" 26 | 27 | namespace ui { 28 | 29 | UpdateDialog DlgUpdate; 30 | 31 | UpdateDialog::UpdateDialog() { 32 | RegisterDlgClass(L"TaigaUpdateW"); 33 | } 34 | 35 | BOOL UpdateDialog::OnInitDialog() { 36 | // Set icon 37 | SetIconLarge(IDI_MAIN); 38 | SetIconSmall(IDI_MAIN); 39 | 40 | // Create default fonts 41 | Theme.CreateFonts(GetDC()); 42 | 43 | // Set title 44 | SetText(TAIGA_APP_TITLE); 45 | 46 | // Set progress text 47 | SetDlgItemText(IDC_STATIC_UPDATE_PROGRESS, L"Checking updates..."); 48 | // Set progress bar 49 | progressbar.Attach(GetDlgItem(IDC_PROGRESS_UPDATE)); 50 | progressbar.SetMarquee(true); 51 | 52 | // Check updates 53 | Taiga.Updater.Check(); 54 | 55 | return TRUE; 56 | } 57 | 58 | INT_PTR UpdateDialog::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 59 | switch (uMsg) { 60 | case WM_CTLCOLORSTATIC: { 61 | win::Dc dc = reinterpret_cast<HDC>(wParam); 62 | dc.SetBkMode(TRANSPARENT); 63 | dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); 64 | dc.DetachDc(); 65 | return reinterpret_cast<INT_PTR>(::GetSysColorBrush(COLOR_WINDOW)); 66 | } 67 | } 68 | 69 | return DialogProcDefault(hwnd, uMsg, wParam, lParam); 70 | } 71 | 72 | BOOL UpdateDialog::OnDestroy() { 73 | // Clean up 74 | Taiga.Updater.Cancel(); 75 | 76 | if (Taiga.Updater.IsRestartRequired()) { 77 | if (DlgMain.IsWindow()) { 78 | DlgMain.PostMessage(WM_DESTROY); 79 | } else { 80 | Taiga.Uninitialize(); 81 | } 82 | } else { 83 | // Create/activate main window 84 | ShowDialog(ui::Dialog::Main); 85 | } 86 | 87 | return TRUE; 88 | } 89 | 90 | void UpdateDialog::OnPaint(HDC hdc, LPPAINTSTRUCT lpps) { 91 | // Paint background 92 | win::Dc dc = hdc; 93 | dc.FillRect(lpps->rcPaint, ::GetSysColor(COLOR_WINDOW)); 94 | 95 | // Paint application icon 96 | win::Rect rect; 97 | win::Window label = GetDlgItem(IDC_STATIC_APP_ICON); 98 | label.GetWindowRect(GetWindowHandle(), &rect); 99 | label.SetWindowHandle(nullptr); 100 | DrawIconResource(IDI_MAIN, dc.Get(), rect, true, true); 101 | } 102 | 103 | } // namespace ui 104 | -------------------------------------------------------------------------------- /src/base/timer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include "timer.h" 20 | 21 | namespace base { 22 | 23 | Timer::Timer(unsigned int id, int interval, bool repeat) 24 | : enabled_(true), 25 | id_(id), 26 | interval_(interval), 27 | repeat_(repeat), 28 | ticks_(interval) { 29 | } 30 | 31 | bool Timer::enabled() const { 32 | return enabled_; 33 | } 34 | 35 | unsigned int Timer::id() const { 36 | return id_; 37 | } 38 | 39 | int Timer::interval() const { 40 | return interval_; 41 | } 42 | 43 | bool Timer::repeat() const { 44 | return repeat_; 45 | } 46 | 47 | int Timer::ticks() const { 48 | return ticks_; 49 | } 50 | 51 | void Timer::set_enabled(bool enabled) { 52 | enabled_ = enabled; 53 | } 54 | 55 | void Timer::set_id(unsigned int id) { 56 | id_ = id; 57 | } 58 | 59 | void Timer::set_interval(int interval) { 60 | int interval_difference = interval - interval_; 61 | interval_ = interval; 62 | ticks_ += interval_difference; 63 | 64 | if (ticks_ < 1) 65 | ticks_ = 1; // So that it reaches 0 on next tick 66 | } 67 | 68 | void Timer::set_repeat(bool repeat) { 69 | repeat_ = repeat; 70 | } 71 | 72 | void Timer::set_ticks(int ticks) { 73 | ticks_ = ticks; 74 | 75 | if (ticks_ > interval_) 76 | ticks_ = interval_; 77 | } 78 | 79 | void Timer::Reset() { 80 | ticks_ = interval_; 81 | enabled_ = true; 82 | } 83 | 84 | void Timer::Tick() { 85 | if (!enabled_) 86 | return; 87 | 88 | if (interval_ > 0 && ticks_ > 0) 89 | ticks_ -= 1; 90 | 91 | if (ticks_ == 0) { 92 | OnTimeout(); 93 | 94 | if (repeat_) { 95 | Reset(); 96 | } else { 97 | enabled_ = false; 98 | } 99 | } 100 | } 101 | 102 | //////////////////////////////////////////////////////////////////////////////// 103 | 104 | TimerManager::TimerManager() 105 | : hwnd_(nullptr), id_(0) { 106 | } 107 | 108 | TimerManager::~TimerManager() { 109 | if (id_ != 0) 110 | ::KillTimer(hwnd_, id_); 111 | } 112 | 113 | Timer* TimerManager::timer(unsigned int id) { 114 | if (timers_.find(id) != timers_.end()) 115 | return timers_[id]; 116 | 117 | return nullptr; 118 | } 119 | 120 | bool TimerManager::Initialize(HWND hwnd, TIMERPROC proc) { 121 | hwnd_ = hwnd; 122 | id_ = ::SetTimer(hwnd, 0, 1000 /*milliseconds*/, proc); 123 | 124 | return id_ != 0; 125 | } 126 | 127 | void TimerManager::InsertTimer(const Timer* timer) { 128 | timers_.insert(std::make_pair(timer->id(), const_cast<Timer*>(timer))); 129 | } 130 | 131 | } // namespace base -------------------------------------------------------------------------------- /src/taiga/path.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #include <map> 20 | 21 | #include "base/file.h" 22 | #include "base/string.h" 23 | #include "sync/manager.h" 24 | #include "taiga/path.h" 25 | #include "taiga/settings.h" 26 | #include "taiga/taiga.h" 27 | 28 | namespace taiga { 29 | 30 | std::wstring GetDataPath() { 31 | std::wstring path; 32 | 33 | #ifdef TAIGA_PORTABLE 34 | // Return current path in portable mode 35 | path = GetPathOnly(Taiga.GetModulePath()); 36 | #else 37 | // Return %AppData% folder 38 | path = GetKnownFolderPath(FOLDERID_RoamingAppData); 39 | AddTrailingSlash(path); 40 | path += TAIGA_APP_NAME; 41 | #endif 42 | 43 | AddTrailingSlash(path); 44 | return path + L"data\\"; 45 | } 46 | 47 | std::wstring GetUserDirectoryName(const sync::ServiceId service_id) { 48 | return GetCurrentUsername() + L"@" + 49 | ServiceManager.service(service_id)->canonical_name(); 50 | } 51 | 52 | std::wstring GetUserDirectoryName() { 53 | return GetUserDirectoryName(GetCurrentServiceId()); 54 | } 55 | 56 | std::wstring GetPath(Path path) { 57 | static const std::wstring data_path = GetDataPath(); 58 | 59 | switch (path) { 60 | default: 61 | case Path::Data: 62 | return data_path; 63 | case Path::Database: 64 | return data_path + L"db\\"; 65 | case Path::DatabaseAnime: 66 | return data_path + L"db\\anime.xml"; 67 | case Path::DatabaseAnimeRelations: 68 | return data_path + L"db\\anime-relations.txt"; 69 | case Path::DatabaseImage: 70 | return data_path + L"db\\image\\"; 71 | case Path::DatabaseSeason: 72 | return data_path + L"db\\season\\"; 73 | case Path::Feed: 74 | return data_path + L"feed\\"; 75 | case Path::FeedHistory: 76 | return data_path + L"feed\\history.xml"; 77 | case Path::Media: 78 | return data_path + L"players.anisthesia"; 79 | case Path::Settings: 80 | return data_path + L"settings.xml"; 81 | case Path::Test: 82 | return data_path + L"test\\"; 83 | case Path::TestRecognition: 84 | return data_path + L"test\\recognition.xml"; 85 | case Path::Theme: 86 | return data_path + L"theme\\"; 87 | case Path::ThemeCurrent: 88 | return data_path + L"theme\\" + Settings[kApp_Interface_Theme] + L"\\theme.xml"; 89 | case Path::User: 90 | return data_path + L"user\\"; 91 | case Path::UserHistory: 92 | return data_path + L"user\\" + GetUserDirectoryName() + L"\\history.xml"; 93 | case Path::UserLibrary: 94 | return data_path + L"user\\" + GetUserDirectoryName() + L"\\anime.xml"; 95 | } 96 | } 97 | 98 | } // namespace taiga -------------------------------------------------------------------------------- /src/ui/dlg/dlg_anime_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows/win/common_controls.h> 22 | #include <windows/win/dialog.h> 23 | 24 | #include "base/gfx.h" 25 | #include "ui/dlg/dlg_anime_info_page.h" 26 | 27 | namespace ui { 28 | 29 | enum class AnimeDialogMode { 30 | AnimeInformation, 31 | NowPlaying, 32 | }; 33 | 34 | class AnimeDialog : public win::Dialog { 35 | public: 36 | AnimeDialog(); 37 | virtual ~AnimeDialog() {} 38 | 39 | typedef std::vector<std::pair<int, double>> sorted_scores_t; 40 | 41 | INT_PTR DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 42 | void OnCancel(); 43 | BOOL OnCommand(WPARAM wParam, LPARAM lParam); 44 | BOOL OnInitDialog(); 45 | LRESULT OnNotify(int idCtrl, LPNMHDR pnmh); 46 | void OnOK(); 47 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 48 | void OnSize(UINT uMsg, UINT nType, SIZE size); 49 | BOOL PreTranslateMessage(MSG* pMsg); 50 | 51 | bool IsTabVisible() const; 52 | void GoToPreviousTab(); 53 | void GoToNextTab(); 54 | AnimeDialogMode GetMode() const; 55 | int GetCurrentId() const; 56 | void SetCurrentId(int anime_id); 57 | void SetCurrentPage(AnimePageType index); 58 | void SetScores(const sorted_scores_t& scores); 59 | void Refresh(bool image = true, 60 | bool series_info = true, 61 | bool my_info = true, 62 | bool connect = true); 63 | void UpdateControlPositions(const SIZE* size = nullptr); 64 | void UpdateTitle(bool refreshing = false); 65 | 66 | public: 67 | PageSeriesInfo page_series_info; 68 | PageMyInfo page_my_info; 69 | 70 | protected: 71 | int anime_id_; 72 | AnimePageType current_page_; 73 | AnimeDialogMode mode_; 74 | sorted_scores_t scores_; 75 | 76 | class ImageLabel : public win::Window { 77 | public: 78 | LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 79 | AnimeDialog* parent; 80 | } image_label_; 81 | 82 | class EditTitle : public win::Edit { 83 | public: 84 | LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 85 | } edit_title_; 86 | 87 | win::SysLink sys_link_; 88 | 89 | class Tab : public win::Tab { 90 | public: 91 | LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 92 | void OnPaint(HDC hdc, LPPAINTSTRUCT lpps); 93 | } tab_; 94 | }; 95 | 96 | class NowPlayingDialog : public AnimeDialog { 97 | public: 98 | NowPlayingDialog(); 99 | ~NowPlayingDialog() {} 100 | }; 101 | 102 | extern AnimeDialog DlgAnime; 103 | extern NowPlayingDialog DlgNowPlaying; 104 | 105 | } // namespace ui 106 | -------------------------------------------------------------------------------- /src/base/file_monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <windows.h> 22 | #include <string> 23 | #include <vector> 24 | 25 | #include <windows/win/thread.h> 26 | 27 | #define WM_MONITORCALLBACK (WM_APP + 0x32) 28 | 29 | class DirectoryChangeNotification { 30 | public: 31 | enum class Type { 32 | Directory, 33 | File, 34 | Unknown, 35 | }; 36 | 37 | DirectoryChangeNotification(DWORD action, 38 | const std::wstring& filename, 39 | const std::wstring& path); 40 | 41 | DWORD action; 42 | std::pair<std::wstring, std::wstring> filename; 43 | std::wstring path; 44 | Type type; 45 | }; 46 | 47 | class DirectoryChangeEntry { 48 | public: 49 | friend class DirectoryMonitor; 50 | 51 | enum class State { 52 | Stopped, 53 | Active, 54 | }; 55 | 56 | DirectoryChangeEntry(HANDLE directory_handle, const std::wstring& path); 57 | 58 | std::vector<DirectoryChangeNotification> notifications; 59 | std::wstring path; 60 | State state; 61 | 62 | private: 63 | std::vector<BYTE> buffer_; 64 | DWORD bytes_returned_; 65 | HANDLE directory_handle_; 66 | OVERLAPPED overlapped_; 67 | }; 68 | 69 | //////////////////////////////////////////////////////////////////////////////// 70 | // Monitors the contents of a directory and its subdirectories by using change 71 | // notifications. 72 | class DirectoryMonitor { 73 | public: 74 | DirectoryMonitor(); 75 | virtual ~DirectoryMonitor(); 76 | 77 | // The window must handle WM_MONITORCALLBACK message and call the callback 78 | // function. lParam of the message is a pointer to a DirectoryChangeEntry. 79 | void Callback(DirectoryChangeEntry& entry); 80 | void SetWindowHandle(HWND hwnd); 81 | 82 | // Override this function to handle notifications 83 | virtual void HandleChangeNotification( 84 | const DirectoryChangeNotification& notification) const = 0; 85 | 86 | protected: 87 | bool Add(const std::wstring& path); 88 | void Clear(); 89 | 90 | bool Start(); 91 | void Stop(); 92 | 93 | private: 94 | bool ReadDirectoryChanges(DirectoryChangeEntry& entry); 95 | void MonitorProc(); 96 | void HandleStoppedState(DirectoryChangeEntry& entry); 97 | void HandleActiveState(DirectoryChangeEntry& entry); 98 | 99 | class Thread : public win::Thread { 100 | public: 101 | DWORD ThreadProc(); 102 | DirectoryMonitor* parent; 103 | } thread_; 104 | 105 | std::vector<DirectoryChangeEntry> entries_; 106 | win::CriticalSection critical_section_; 107 | HANDLE completion_port_; 108 | HWND window_handle_; 109 | }; 110 | -------------------------------------------------------------------------------- /src/taiga/http.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <list> 22 | #include <map> 23 | 24 | #include <windows/win/thread.h> 25 | 26 | #include "base/http.h" 27 | #include "base/types.h" 28 | 29 | namespace taiga { 30 | 31 | enum HttpClientMode { 32 | kHttpSilent, 33 | // Service 34 | kHttpServiceAuthenticateUser, 35 | kHttpServiceGetUser, 36 | kHttpServiceGetMetadataById, 37 | kHttpServiceGetSeason, 38 | kHttpServiceSearchTitle, 39 | kHttpServiceAddLibraryEntry, 40 | kHttpServiceDeleteLibraryEntry, 41 | kHttpServiceGetLibraryEntries, 42 | kHttpServiceUpdateLibraryEntry, 43 | // Library 44 | kHttpGetLibraryEntryImage, 45 | // Feed 46 | kHttpFeedCheck, 47 | kHttpFeedCheckAuto, 48 | kHttpFeedDownload, 49 | // Seasons 50 | kHttpSeasonsGet, 51 | // Twitter 52 | kHttpTwitterRequest, 53 | kHttpTwitterAuth, 54 | kHttpTwitterPost, 55 | // Taiga 56 | kHttpTaigaUpdateCheck, 57 | kHttpTaigaUpdateDownload, 58 | kHttpTaigaUpdateRelations, 59 | }; 60 | 61 | class HttpClient : public base::http::Client { 62 | public: 63 | friend class HttpManager; 64 | 65 | HttpClient(const HttpRequest& request); 66 | virtual ~HttpClient() {} 67 | 68 | HttpClientMode mode() const; 69 | void set_mode(HttpClientMode mode); 70 | 71 | protected: 72 | void OnError(CURLcode error_code); 73 | bool OnHeadersAvailable(); 74 | bool OnProgress(); 75 | void OnReadComplete(); 76 | bool OnRedirect(const std::wstring& address, bool refresh); 77 | 78 | private: 79 | HttpClientMode mode_; 80 | }; 81 | 82 | class HttpManager { 83 | public: 84 | HttpManager(); 85 | 86 | void CancelRequest(base::uid_t uid); 87 | void MakeRequest(HttpRequest& request, HttpClientMode mode); 88 | 89 | void HandleError(HttpResponse& response, const string_t& error); 90 | void HandleRedirect(const std::wstring& current_host, const std::wstring& next_host); 91 | void HandleResponse(HttpResponse& response); 92 | 93 | void FreeMemory(); 94 | void Shutdown(); 95 | 96 | private: 97 | HttpClient* FindClient(base::uid_t uid); 98 | HttpClient& GetClient(const HttpRequest& request); 99 | 100 | void AddToQueue(HttpRequest& request, HttpClientMode mode); 101 | void ProcessQueue(); 102 | void AddConnection(const string_t& hostname); 103 | void FreeConnection(const string_t& hostname); 104 | 105 | std::list<HttpClient> clients_; 106 | std::map<std::wstring, unsigned int> connections_; 107 | win::CriticalSection critical_section_; 108 | std::vector<std::pair<HttpRequest, HttpClientMode>> requests_; 109 | bool shutdown_; 110 | }; 111 | 112 | } // namespace taiga 113 | 114 | extern taiga::HttpManager ConnectionManager; 115 | -------------------------------------------------------------------------------- /src/library/history.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | #include <queue> 23 | #include <vector> 24 | 25 | #include "base/optional.h" 26 | #include "base/time.h" 27 | #include "base/xml.h" 28 | #include "library/anime_episode.h" 29 | 30 | enum class QueueSearch { 31 | DateStart, 32 | DateEnd, 33 | Episode, 34 | Notes, 35 | RewatchedTimes, 36 | Rewatching, 37 | Score, 38 | Status, 39 | Tags, 40 | }; 41 | 42 | class AnimeValues { 43 | public: 44 | Optional<int> episode; 45 | Optional<int> status; 46 | Optional<int> score; 47 | Optional<Date> date_start; 48 | Optional<Date> date_finish; 49 | Optional<int> enable_rewatching; 50 | Optional<int> rewatched_times; 51 | Optional<std::wstring> tags; 52 | Optional<std::wstring> notes; 53 | }; 54 | 55 | class HistoryItem : public AnimeValues { 56 | public: 57 | HistoryItem(); 58 | virtual ~HistoryItem() {} 59 | 60 | bool enabled; 61 | int anime_id; 62 | int mode; 63 | std::wstring reason; 64 | std::wstring time; 65 | }; 66 | 67 | class History; 68 | 69 | class HistoryQueue { 70 | public: 71 | HistoryQueue(); 72 | ~HistoryQueue() {} 73 | 74 | void Add(HistoryItem& item, bool save = true); 75 | void Check(bool automatic = true); 76 | void Clear(bool save = true); 77 | HistoryItem* FindItem(int anime_id, QueueSearch search_mode); 78 | HistoryItem* GetCurrentItem(); 79 | int GetItemCount(); 80 | void Remove(int index = -1, bool save = true, bool refresh = true, bool to_history = true); 81 | void RemoveDisabled(bool save = true, bool refresh = true); 82 | 83 | size_t index; 84 | std::vector<HistoryItem> items; 85 | History* history; 86 | bool updating; 87 | }; 88 | 89 | class History { 90 | public: 91 | History(); 92 | ~History() {} 93 | 94 | void Clear(bool save = true); 95 | bool Load(); 96 | bool Save(); 97 | 98 | void HandleCompatibility(const std::wstring& meta_version); 99 | 100 | std::vector<HistoryItem> items; 101 | HistoryQueue queue; 102 | int limit; 103 | 104 | private: 105 | void ReadQueue(const pugi::xml_document& document); 106 | void ReadQueueInCompatibilityMode(const pugi::xml_document& document); 107 | 108 | int TranslateModeFromString(const std::wstring& mode); 109 | std::wstring TranslateModeToString(int mode); 110 | }; 111 | 112 | class ConfirmationQueue { 113 | public: 114 | ConfirmationQueue(); 115 | virtual ~ConfirmationQueue() {} 116 | 117 | void Add(const anime::Episode& episode); 118 | void Process(); 119 | 120 | private: 121 | bool in_process_; 122 | std::queue<anime::Episode> queue_; 123 | }; 124 | 125 | extern class History History; 126 | extern class ConfirmationQueue ConfirmationQueue; 127 | -------------------------------------------------------------------------------- /src/library/anime_episode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Taiga 3 | ** Copyright (C) 2010-2018, Eren Okka 4 | ** 5 | ** This program is free software: you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation, either version 3 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include <string> 22 | 23 | #include <anitomy/anitomy/element.h> 24 | 25 | namespace anime { 26 | 27 | typedef std::pair<int, int> number_range_t; 28 | 29 | class Episode { 30 | public: 31 | Episode(); 32 | virtual ~Episode() {} 33 | 34 | void Clear(); 35 | void Set(int anime_id); 36 | 37 | anitomy::Elements& elements(); 38 | const anitomy::Elements& elements() const; 39 | 40 | int anime_season() const; 41 | const std::wstring& anime_title() const; 42 | const std::wstring& anime_type() const; 43 | int anime_year() const; 44 | std::wstring audio_terms() const; 45 | int episode_number() const; 46 | number_range_t episode_number_range() const; 47 | const std::wstring& episode_title() const; 48 | const std::wstring& file_checksum() const; 49 | const std::wstring& file_extension() const; 50 | const std::wstring& file_name() const; 51 | std::wstring file_name_with_extension() const; 52 | const std::wstring& release_group() const; 53 | int release_version() const; 54 | const std::wstring& video_resolution() const; 55 | std::wstring video_terms() const; 56 | int volume_number() const; 57 | number_range_t volume_number_range() const; 58 | 59 | void set_anime_season(int value); 60 | void set_anime_title(const std::wstring& str); 61 | void set_anime_type(const std::wstring& str); 62 | void set_anime_year(int value); 63 | void set_audio_terms(const std::wstring& str); 64 | void set_elements(const anitomy::Elements& elements); 65 | void set_episode_number(int value); 66 | void set_episode_number_range(std::pair<int, int> range); 67 | void set_episode_title(const std::wstring& str); 68 | void set_file_checksum(const std::wstring& str); 69 | void set_file_extension(const std::wstring& str); 70 | void set_file_name(const std::wstring& str); 71 | void set_release_group(const std::wstring& str); 72 | void set_release_version(int value); 73 | void set_video_resolution(const std::wstring& str); 74 | void set_video_terms(const std::wstring& str); 75 | void set_volume_number(int value); 76 | 77 | int GetElementAsInt(anitomy::ElementCategory category, int default_value = 0) const; 78 | const std::wstring& GetElementAsString(anitomy::ElementCategory category) const; 79 | number_range_t GetElementAsRange(anitomy::ElementCategory category) const; 80 | std::wstring GetElementsAsString(anitomy::ElementCategory category) const; 81 | 82 | void SetElementValue(anitomy::ElementCategory category, int value); 83 | void SetElementValue(anitomy::ElementCategory category, const std::wstring& str); 84 | 85 | int anime_id; 86 | std::wstring folder; 87 | bool processed; 88 | 89 | private: 90 | anitomy::Elements elements_; 91 | }; 92 | 93 | } // namespace anime 94 | 95 | extern anime::Episode CurrentEpisode; 96 | --------------------------------------------------------------------------------