|
|
#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);
|
|
|
} |