You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.6 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "XSubCore.h"
#include <QCoreApplication>
#include <QString>
#include <QMap>
#include "XGlobal.h"
#include "URIReg.h"
#include "XHttpManager.h"
#include "XDefine.h"
#include "XTask.h"
XSubCore XSubCore::instance;
XSubCore::XSubCore()
{
}
XSubCore::~XSubCore() {
}
XSubCore* XSubCore::getInstance() {
return &instance;
}
bool XSubCore::init(const char* protocolName, ISubCoreCallback* callback /* = nullptr */) {
if (nullptr == protocolName)
return false;
XTask::getInstance().setCallback(callback);
XGlobal::getInstance().setCallback(callback);
QStringList args = QCoreApplication::arguments();
if (args.size() < 2)
return false;
if (!URIReg::getInstance().reg(protocolName)) {
XGlobal::getInstance().onError(ISubCoreCallback::ERR_T_REG_URL, QStringLiteral("×¢²áURLЭÒéʧ°Ü"));
return false;
}
return true;
}
void XSubCore::release() {
XHttpManager::getInstance().release();
}
bool XSubCore::getByHttp(const char* id, const char* baseUrl, const char* token, const char* params) {
return XHttpManager::getInstance().getByHttp(id, baseUrl, token, params);
}
bool XSubCore::postByHttp(const char* id, const char* baseUrl, const char* token, const char* jsonData) {
return XHttpManager::getInstance().postByHttp(id, baseUrl, token, jsonData);
}
bool XSubCore::beginTask(unsigned int taskId, const char* path) {
return XTask::getInstance().init(taskId, path);
}
bool XSubCore::execTask() {
return true;
}
void XSubCore::endTask() {
}
void XSubCore::onTaskEventCheck(const char* name, const char* value, const char* value2/* = nullptr*/) {
XTask::getInstance().onTaskEventCheck(name, value, value2);
}