view src/services/services.cpp @ 75:d3e9310598b1

*: refactor some stuff text: "TextParagraph"s are now called sections, because that's the actual word for it :P text: new classes: Line and OneLineSection, solves many problems with paragraphs that are only one line long (ex. going out of bounds) http: reworked http stuff to allow threaded get requests, also moved it to its own file to (hopefully) remove clutter eventually I'll make a threaded post request method and use that in the "basic" function
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:42:30 -0400
parents 3d2decf093bb
children
line wrap: on
line source

#include "services/services.h"
#include "core/session.h"
#include "gui/dialog/settings.h"
#include "services/anilist.h"
#include <QMessageBox>

namespace Services {

void Synchronize() {
	switch (session.config.service) {
		case Anime::Services::ANILIST: AniList::GetAnimeList(); break;
		default: {
			QMessageBox msg;
			msg.setInformativeText("It seems you haven't yet selected a service to use.");
			msg.setText("Would you like to select one now?");
			msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
			msg.setDefaultButton(QMessageBox::Yes);
			int ret = msg.exec();
			if (ret == QMessageBox::Yes) {
				SettingsDialog dialog;
				dialog.exec();
			}
			break;
		}
	}
}

void UpdateAnimeEntry(int id) {
	switch (session.config.service) {
		case Anime::Services::ANILIST: AniList::UpdateAnimeEntry(id); break;
		default: break;
	}
}

bool Authorize() {
	switch (session.config.service) {
		case Anime::Services::ANILIST: return AniList::AuthorizeUser();
		default: return true;
	}
}

}; // namespace Services