源url连通性检测
This commit is contained in:
parent
f3dc14698d
commit
35dd8cb465
3
res.qrc
3
res.qrc
@ -2,6 +2,9 @@
|
|||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>res/img/btn/btn_setting.png</file>
|
<file>res/img/btn/btn_setting.png</file>
|
||||||
<file>res/img/btn/btn_about.png</file>
|
<file>res/img/btn/btn_about.png</file>
|
||||||
|
<file>res/img/btn/net_ok.png</file>
|
||||||
|
<file>res/img/btn/net_error.png</file>
|
||||||
|
<file>res/img/btn/net_wait.png</file>
|
||||||
<file>res/img/xsteam.ico</file>
|
<file>res/img/xsteam.ico</file>
|
||||||
<file>res/img/xsteam.png</file>
|
<file>res/img/xsteam.png</file>
|
||||||
<file>res/bin/luapacka.exe</file>
|
<file>res/bin/luapacka.exe</file>
|
||||||
|
BIN
res/img/btn/net_error.png
Normal file
BIN
res/img/btn/net_error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
res/img/btn/net_ok.png
Normal file
BIN
res/img/btn/net_ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
res/img/btn/net_wait.png
Normal file
BIN
res/img/btn/net_wait.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@ -7,8 +7,10 @@ xsteam_curl::xsteam_curl()
|
|||||||
xsteam_curl::~xsteam_curl()
|
xsteam_curl::~xsteam_curl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void xsteam_curl::init_curl(){
|
void xsteam_curl::init_curl()
|
||||||
if(curl!=nullptr){
|
{
|
||||||
|
if (curl != nullptr)
|
||||||
|
{
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
curl = nullptr;
|
curl = nullptr;
|
||||||
}
|
}
|
||||||
@ -84,7 +86,8 @@ bool xsteam_curl::get_steam_header_ico(std::string logo_url,std::string _c_uid)
|
|||||||
QDir dir(QString::fromStdString(base_str + "/save/img"));
|
QDir dir(QString::fromStdString(base_str + "/save/img"));
|
||||||
std::string u_str = logo_url + _c_uid + "/header.jpg";
|
std::string u_str = logo_url + _c_uid + "/header.jpg";
|
||||||
std::string s_str = base_str + "/save/img/" + _c_uid + ".jpg";
|
std::string s_str = base_str + "/save/img/" + _c_uid + ".jpg";
|
||||||
if(!dir.exists()){
|
if (!dir.exists())
|
||||||
|
{
|
||||||
QDir().mkpath(QString::fromStdString(base_str + "/save/img"));
|
QDir().mkpath(QString::fromStdString(base_str + "/save/img"));
|
||||||
}
|
}
|
||||||
init_curl();
|
init_curl();
|
||||||
@ -122,3 +125,43 @@ bool xsteam_curl::get_steam_header_ico(std::string logo_url,std::string _c_uid)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool xsteam_curl::get_url_state(std::string url)
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res;
|
||||||
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
curl = curl_easy_init();
|
||||||
|
std::string strTmpStr;
|
||||||
|
std::string strRsp;
|
||||||
|
int retry = 3;
|
||||||
|
if (curl)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strTmpStr);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (strTmpStr.data() == nullptr)
|
||||||
|
{
|
||||||
|
if (retry == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
retry--;
|
||||||
|
}
|
||||||
|
if (QString::fromStdString(strTmpStr).contains(QStringLiteral("404"), Qt::CaseSensitive) ||
|
||||||
|
QString::fromStdString(strTmpStr).contains(QStringLiteral("500"), Qt::CaseSensitive) ||
|
||||||
|
QString::fromStdString(strTmpStr).contains(QStringLiteral("403"), Qt::CaseSensitive) ||
|
||||||
|
QString::fromStdString(strTmpStr).contains(QStringLiteral("502"), Qt::CaseSensitive) ||
|
||||||
|
res == CURLE_QUOTE_ERROR)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
curl_global_cleanup();
|
||||||
|
return false;
|
||||||
|
}
|
@ -20,6 +20,7 @@ public:
|
|||||||
~xsteam_curl();
|
~xsteam_curl();
|
||||||
std::string get_steam_id_info(std::string,std::string _c_uid);
|
std::string get_steam_id_info(std::string,std::string _c_uid);
|
||||||
bool get_steam_header_ico(std::string,std::string _c_uid);
|
bool get_steam_header_ico(std::string,std::string _c_uid);
|
||||||
|
bool get_url_state(std::string url);
|
||||||
private:
|
private:
|
||||||
void init_curl();
|
void init_curl();
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
|
@ -49,6 +49,7 @@ void xsteam_ui::xsteam_init_mind_layout()
|
|||||||
server_tag = new QLabel(tr("源数据:"));
|
server_tag = new QLabel(tr("源数据:"));
|
||||||
server_tag->setObjectName("SRC_SERVER");
|
server_tag->setObjectName("SRC_SERVER");
|
||||||
server_txt = new QComboBox();
|
server_txt = new QComboBox();
|
||||||
|
server_state=new QLabel();
|
||||||
btn_server_edit = new QPushButton(tr("编辑源"));
|
btn_server_edit = new QPushButton(tr("编辑源"));
|
||||||
btn_server_edit->setObjectName("EDIT");
|
btn_server_edit->setObjectName("EDIT");
|
||||||
btn_fetch_src_data = new QPushButton(tr("拉取"));
|
btn_fetch_src_data = new QPushButton(tr("拉取"));
|
||||||
@ -64,6 +65,7 @@ void xsteam_ui::xsteam_init_mind_layout()
|
|||||||
|
|
||||||
server_layout->addWidget(server_tag);
|
server_layout->addWidget(server_tag);
|
||||||
server_layout->addWidget(server_txt);
|
server_layout->addWidget(server_txt);
|
||||||
|
server_layout->addWidget(server_state);
|
||||||
server_layout->addWidget(btn_fetch_src_data);
|
server_layout->addWidget(btn_fetch_src_data);
|
||||||
server_layout->addWidget(btn_server_edit);
|
server_layout->addWidget(btn_server_edit);
|
||||||
server_layout->addWidget(btn_run_steam);
|
server_layout->addWidget(btn_run_steam);
|
||||||
@ -201,6 +203,38 @@ void xsteam_ui::xsteam_init_connect()
|
|||||||
connect(ip_in_dlc_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint)));
|
connect(ip_in_dlc_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint)));
|
||||||
connect(btn_dlc_push, SIGNAL(clicked()), this, SLOT(slots_get_uid_dlcs()));
|
connect(btn_dlc_push, SIGNAL(clicked()), this, SLOT(slots_get_uid_dlcs()));
|
||||||
connect(btn_push_manifest, SIGNAL(clicked()), this, SLOT(slots_push_manifest()));
|
connect(btn_push_manifest, SIGNAL(clicked()), this, SLOT(slots_push_manifest()));
|
||||||
|
connect(server_txt, SIGNAL(currentIndexChanged(int)), this, SLOT(slots_change_src_state(int)));
|
||||||
|
}
|
||||||
|
void xsteam_ui::slots_change_src_state(int index)
|
||||||
|
{
|
||||||
|
QPixmap xs_pixmap;
|
||||||
|
std::string url;
|
||||||
|
xs_pixmap.load(":res/img/btn/net_wait.png");
|
||||||
|
xs_pixmap = xs_pixmap.scaled(25,25,Qt::KeepAspectRatio);
|
||||||
|
server_state->setPixmap(xs_pixmap);
|
||||||
|
for (auto &i : _data.s_data)
|
||||||
|
{
|
||||||
|
if (i.src_name == server_txt->itemText(index))
|
||||||
|
{
|
||||||
|
url = i.src_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (url != "")
|
||||||
|
{
|
||||||
|
QFuture<void> future = QtConcurrent::run([=](std::string _url,QPixmap _pixmap) {
|
||||||
|
xsteam_curl* xs_curl=new xsteam_curl();
|
||||||
|
if(xs_curl->get_url_state(_url)){
|
||||||
|
_pixmap.load(":/res/img/btn/net_ok.png");
|
||||||
|
}else{
|
||||||
|
_pixmap.load(":/res/img/btn/net_error.png");
|
||||||
|
}
|
||||||
|
_pixmap=_pixmap.scaled(25,25,Qt::KeepAspectRatio);
|
||||||
|
server_state->setPixmap(_pixmap);
|
||||||
|
delete xs_curl;
|
||||||
|
xs_curl=nullptr;
|
||||||
|
},url,xs_pixmap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void xsteam_ui::slots_get_uid_dlcs()
|
void xsteam_ui::slots_get_uid_dlcs()
|
||||||
{
|
{
|
||||||
@ -440,7 +474,8 @@ void xsteam_ui::slots_run_steam_steamtools()
|
|||||||
xsteam_run_steam_steamtools(RUN_MODE::STEAMTOOLS);
|
xsteam_run_steam_steamtools(RUN_MODE::STEAMTOOLS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void xsteam_ui::slots_push_manifest(){
|
void xsteam_ui::slots_push_manifest()
|
||||||
|
{
|
||||||
xs_push_manifest = xsteam_push_manifest::Instance();
|
xs_push_manifest = xsteam_push_manifest::Instance();
|
||||||
xs_push_manifest->setMaximumSize(((QWidget *)this->parent())->width(), ((QWidget *)this->parent())->height() - 25);
|
xs_push_manifest->setMaximumSize(((QWidget *)this->parent())->width(), ((QWidget *)this->parent())->height() - 25);
|
||||||
xs_push_manifest->setGeometry(((QWidget *)this->parent())->geometry());
|
xs_push_manifest->setGeometry(((QWidget *)this->parent())->geometry());
|
||||||
|
@ -41,6 +41,7 @@ private:
|
|||||||
QHBoxLayout* server_layout;
|
QHBoxLayout* server_layout;
|
||||||
QLabel* server_tag;
|
QLabel* server_tag;
|
||||||
QComboBox* server_txt;
|
QComboBox* server_txt;
|
||||||
|
QLabel* server_state;
|
||||||
QPushButton* btn_server_edit;
|
QPushButton* btn_server_edit;
|
||||||
QPushButton* btn_fetch_src_data;
|
QPushButton* btn_fetch_src_data;
|
||||||
QPushButton* btn_run_steam;
|
QPushButton* btn_run_steam;
|
||||||
@ -106,6 +107,7 @@ private slots:
|
|||||||
void slots_in_dlc_delete();
|
void slots_in_dlc_delete();
|
||||||
void slots_in_dlc_add();
|
void slots_in_dlc_add();
|
||||||
void slots_imput_update_uid_push();
|
void slots_imput_update_uid_push();
|
||||||
|
void slots_change_src_state(int);
|
||||||
signals:
|
signals:
|
||||||
void signals_src_combobox_update();
|
void signals_src_combobox_update();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user