File indexing completed on 2025-01-19 03:55:39
0001 0002 #include "o2reply.h" 0003 0004 O2Reply::O2Reply(QNetworkReply *r, int timeOut, QObject *parent): QTimer(parent), reply(r) { 0005 setSingleShot(true); 0006 #if QT_VERSION < 0x051500 0007 connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(error(QNetworkReply::NetworkError)), Qt::QueuedConnection); 0008 #else 0009 connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), Qt::QueuedConnection); 0010 #endif 0011 connect(this, SIGNAL(timeout()), this, SLOT(onTimeOut()), Qt::QueuedConnection); 0012 start(timeOut); 0013 } 0014 0015 void O2Reply::onTimeOut() { 0016 Q_EMIT error(QNetworkReply::TimeoutError); 0017 } 0018 0019 O2ReplyList::~O2ReplyList() { 0020 foreach (O2Reply *timedReply, replies_) { 0021 delete timedReply; 0022 } 0023 } 0024 0025 void O2ReplyList::add(QNetworkReply *reply) { 0026 if (reply && ignoreSslErrors()) 0027 reply->ignoreSslErrors(); 0028 add(new O2Reply(reply)); 0029 } 0030 0031 void O2ReplyList::add(O2Reply *reply) { 0032 replies_.append(reply); 0033 } 0034 0035 void O2ReplyList::remove(QNetworkReply *reply) { 0036 O2Reply *o2Reply = find(reply); 0037 if (o2Reply) { 0038 o2Reply->stop(); 0039 (void)replies_.removeOne(o2Reply); 0040 } 0041 } 0042 0043 O2Reply *O2ReplyList::find(QNetworkReply *reply) { 0044 foreach (O2Reply *timedReply, replies_) { 0045 if (timedReply->reply == reply) { 0046 return timedReply; 0047 } 0048 } 0049 return 0; 0050 } 0051 0052 bool O2ReplyList::ignoreSslErrors() 0053 { 0054 return ignoreSslErrors_; 0055 } 0056 0057 void O2ReplyList::setIgnoreSslErrors(bool ignoreSslErrors) 0058 { 0059 ignoreSslErrors_ = ignoreSslErrors; 0060 } 0061 0062 #include "moc_o2reply.cpp"