* Began refactoring http_get. Still a few cases to handle, but it works. * Introduced error enum; handle error 406; handle a misbehaving server; redirect_url leaked memory (L888) * Allowed calls to http_get to pass NULL as acceptable_mime_types * Removed status_code from header struct; eventually planning to move most of parse_header's logic back to http_get, so this makes sense * Moved some more logic back into http_get Note: currently behaves weirdly with some QR codes, including but probably not limited to ones pointing to TinyURL. * Handle redirects correctly; other rearrangements * Formatting * Handle HTTP 303 See Other correctly * Removed "Download failed" error in camera.c due to all related failures being handled in http_get * Fixed missing loading bar; started working on unchunked download * Added unchunked download * Reintroduced the download progress bar, rolled back to always doing chunked download * URL length caps at 2083 chars * Slightly more efficient * Correctly handle incorrect filesize header TODO: reorder clauses to remove the goto? * Fixed illegal characters, removed unnecessary logic (technically a regression, as we always have to realloc now) * Finally finished up status code handling. Fixed a memory leak when the server fails conneg.
58 lines
2.4 KiB
C
58 lines
2.4 KiB
C
/*
|
|
* This file is part of Anemone3DS
|
|
* Copyright (C) 2016-2018 Contributors in CONTRIBUTORS.md
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
|
* * Requiring preservation of specified reasonable legal notices or
|
|
* author attributions in that material or in the Appropriate Legal
|
|
* Notices displayed by works containing it.
|
|
* * Prohibiting misrepresentation of the origin of that material,
|
|
* or requiring that modified versions of such material be marked in
|
|
* reasonable ways as different from the original version.
|
|
*/
|
|
|
|
#ifndef REMOTE_H
|
|
#define REMOTE_H
|
|
|
|
#include "common.h"
|
|
#include "draw.h"
|
|
#include <ctype.h>
|
|
|
|
#define THEMEPLAZA_BASE_URL "https://themeplaza.eu"
|
|
#define THEMEPLAZA_API_URL "/api/anemone/v1"
|
|
#define THEMEPLAZA_BASE_API_URL THEMEPLAZA_BASE_URL THEMEPLAZA_API_URL
|
|
|
|
#define THEMEPLAZA_PAGE_FORMAT THEMEPLAZA_BASE_API_URL "/list?page=%" JSON_INTEGER_FORMAT "&category=%i&query=%s"
|
|
#define THEMEPLAZA_JSON_PAGE_COUNT "pages"
|
|
#define THEMEPLAZA_JSON_PAGE_IDS "items"
|
|
|
|
#define THEMEPLAZA_JSON_ERROR_MESSAGE "message"
|
|
#define THEMEPLAZA_JSON_ERROR_MESSAGE_NOT_FOUND "No items found"
|
|
|
|
|
|
#define THEMEPLAZA_DOWNLOAD_FORMAT THEMEPLAZA_BASE_URL "/download/%" JSON_INTEGER_FORMAT
|
|
#define THEMEPLAZA_PREVIEW_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/preview"
|
|
#define THEMEPLAZA_BGM_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/bgm"
|
|
#define THEMEPLAZA_ICON_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/preview/icon"
|
|
#define THEMEPLAZA_SMDH_FORMAT THEMEPLAZA_DOWNLOAD_FORMAT "/smdh"
|
|
|
|
#define CACHE_PATH_FORMAT "/3ds/" APP_TITLE "/cache/%" JSON_INTEGER_FORMAT
|
|
|
|
bool themeplaza_browser(EntryMode mode);
|
|
u32 http_get(const char *url, char ** filename, char ** buf, InstallType install_type, const char *mime_type);
|
|
|
|
#endif
|