-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trans): Change network requester to curl
Signed-off-by: Hakusai Zhang <xm1994@gmail.com>
- Loading branch information
1 parent
84021e0
commit 68d7a96
Showing
9 changed files
with
90 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
QCprManager | ||
Copyright (C) 2019-2024 Yibai Zhang | ||
|
||
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 2 | ||
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 <https://www.gnu.org/licenses/> | ||
*/ | ||
|
||
#include "QCprManager.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "QCprManager.h" | ||
|
||
QCprManager::QCprManager(cpr::AsyncResponse&& fr, QObject *parent): QThread(parent), fr(std::move(fr)) { | ||
} | ||
|
||
|
||
void QCprManager::run() { | ||
fr.wait(); // This waits until the request is complete | ||
cpr::Response r = fr.get(); // Since the request is complete, this returns immediately | ||
emit resultReady(r); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef _QCPR_MANAGER_H_ | ||
#define _QCPR_MANAGER_H_ | ||
|
||
#include <QThread> | ||
#include <cpr/cpr.h> | ||
|
||
|
||
class QCprManager: public QThread { | ||
Q_OBJECT | ||
|
||
public: | ||
QCprManager(cpr::AsyncResponse&& fr, QObject *parent = nullptr); | ||
|
||
private: | ||
void run() override; | ||
cpr::AsyncResponse fr; | ||
|
||
signals: | ||
void resultReady(const cpr::Response r); | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters