BOOL AboutDialog::OnInitDialog() { rich_edit_.Attach(GetDlgItem(IDC_RICHEDIT_ABOUT)); rich_edit_.SendMessage(EM_AUTOURLDETECT, TRUE /* AURL_ENABLEURL */); rich_edit_.SetEventMask(ENM_LINK); std::wstring text = L"{\\rtf1\\ansi\\deff0" L"{\\fonttbl" L"{\\f0 Segoe UI;}" L"}" L"\\deflang1024\\fs18" L"\\b " TAIGA_APP_NAME L"\\b0\\line " L"version " + std::wstring(Taiga.version) + L"\\line\\line " L"\\b Author:\\b0\\line " L"Eren 'erengy' Okka\\line\\line " L"\\b Committers and other contributors:\\b0\\line " L"saka, Diablofan, slevir, LordGravewish, cassist, rr-\\line\\line " L"\\b Third party stuff that is used by Taiga:\\b0\\line " L"- Fugue Icons 3.4.5, Copyright (c) 2012, Yusuke Kamiyamane\\line " L"- JsonCpp 0.6.0, Copyright (c) 2007-2010, Baptiste Lepilleur\\line " L"- libcurl 7.38.0, Copyright (c) 1996-2014, Daniel Stenberg\\line " L"- pugixml 1.4, Copyright (c) 2006-2014, Arseny Kapoulkine\\line " L"- zlib 1.2.8, Copyright (c) 1995-2013, Jean-loup Gailly and Mark Adler\\line\\line " L"\\b Links:\\b0\\line " L"- Home page {\\field{\\*\\fldinst HYPERLINK \"http://taiga.erengy.com\"}{\\fldrslt http://taiga.erengy.com}}\\line " L"- GitHub repository {\\field{\\*\\fldinst HYPERLINK \"https://github.com/erengy/taiga\"}{\\fldrslt https://github.com/erengy/taiga}}\\line " L"- Hummingbird thread {\\field{\\*\\fldinst HYPERLINK \"http://forums.hummingbird.me/t/taiga/10565\"}{\\fldrslt http://forums.hummingbird.me/t/taiga/10565}}\\line " L"- MyAnimeList club {\\field{\\*\\fldinst HYPERLINK \"http://myanimelist.net/clubs.php?cid=21400\"}{\\fldrslt http://myanimelist.net/clubs.php?cid=21400}}\\line " L"- Twitter account {\\field{\\*\\fldinst HYPERLINK \"https://twitter.com/taigaapp\"}{\\fldrslt https://twitter.com/taigaapp}}\\line " L"- IRC channel {\\field{\\*\\fldinst HYPERLINK \"irc://irc.rizon.net/taiga\"}{\\fldrslt irc://irc.rizon.net/taiga}}" L"}"; rich_edit_.SetTextEx(WstrToStr(text)); return TRUE; }
bool Service::ParseResponseBody(Response& response, HttpResponse& http_response, Json::Value& root) { Json::Reader reader; if (reader.parse(WstrToStr(http_response.body), root)) return true; switch (response.type) { case kGetLibraryEntries: response.data[L"error"] = L"Could not parse the list"; break; case kGetMetadataById: case kGetMetadataByIdV2: response.data[L"error"] = L"Could not parse the anime object"; break; case kSearchTitle: response.data[L"error"] = L"Could not parse search results"; break; case kUpdateLibraryEntry: response.data[L"error"] = L"Could not parse library entry"; break; } return false; }
std::wstring Base64Encode(const std::wstring& str, bool for_filename) { std::wstring output = StrToWstr(Base64Encode(WstrToStr(str))); if (for_filename) ReplaceChar(output, '/', '-'); return output; }
std::wstring CalculateCrcFromString(const std::wstring& str) { std::string text = WstrToStr(str); ULONG crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, reinterpret_cast<const Bytef*>(text.data()), text.size()); return ConvertCrcValueToString(crc); }
bool ReadFromFile(const std::wstring& path, std::string& output) { std::ifstream is; is.open(WstrToStr(path).c_str(), std::ios::binary); is.seekg(0, std::ios::end); size_t len = static_cast<size_t>(is.tellg()); if (len != -1) { output.resize(len); is.seekg(0, std::ios::beg); is.read((char*)output.data(), output.size()); } is.close(); return len != -1; }
bool Service::RequestSucceeded(Response& response, const HttpResponse& http_response) { switch (http_response.code) { // OK case 200: case 201: return true; // Error default: { Json::Value root; Json::Reader reader; bool parsed = reader.parse(WstrToStr(http_response.body), root); response.data[L"error"] = name() + L" returned an error: "; if (parsed) { response.data[L"error"] += StrToWstr(root["error"].asString()); } else { response.data[L"error"] += L"Unknown error (" + ToWstr(static_cast<int>(http_response.code)) + L")"; } return false; } } }
bool operator==(const wstring& iwstr, const string& istr) { return WstrToStr(iwstr) == istr; }