From f4da8086b4ab698510290f92aa679a305a537a27 Mon Sep 17 00:00:00 2001 From: Robert Förster Date: Tue, 16 Sep 2008 11:43:31 +0000 Subject: pop in some EOL and svn properties fixes. - all textfiles were converted to unix line endings - svn:eol-style native has been set on that files so noone has to care about it again, now the svn client does take care of that, a checkout on unix will get unix lineendings, a checkout on windows will get windows lineendings - svn:executable fixup (some file had the executable bit set were they shouldn't) - svn:mime-type fixes for most of the files, which will probaly only affect trac in viewing that files - some typo fixup, the manpage seems to need some love, though. this will be pushed to the branches once i get to it today. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2469 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/objects/class_http.cpp | 298 ++++++++++++++++++------------------- 1 file changed, 149 insertions(+), 149 deletions(-) (limited to 'src/modules/objects/class_http.cpp') diff --git a/src/modules/objects/class_http.cpp b/src/modules/objects/class_http.cpp index 5978cef1d..6bbd8f1b1 100644 --- a/src/modules/objects/class_http.cpp +++ b/src/modules/objects/class_http.cpp @@ -26,35 +26,35 @@ #include "class_http.h" #include #include -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_OPENSSL #include const char * const ssl_errors_tbl[] = { - "NoError", - "UnableToGetIssuerCertificate", - "UnableToDecryptCertificateSignature", - "UnableToDecodeIssuerPublicKey", - "CertificateSignatureFailed", - "CertificateNotYetValid", - "CertificateExpired", - "InvalidNotBeforeField", - "InvalidNotAfterField", - "SelfSignedCertificate", - "SelfSignedCertificateInChain", - "UnableToGetLocalIssuerCertificate", - "UnableToVerifyFirstCertificate", - "CertificateRevoked", - "InvalidCaCertificate", - "PathLengthExceeded", - "InvalidPurpose", - "CertificateUntrusted", - "CertificateRejected", - "SubjectIssuerMismatch", - "AuthorityIssuerSerialNumberMismatch", - "NoPeerCertificate", - "HostNameMismatch", - "UnspecifiedError", + "NoError", + "UnableToGetIssuerCertificate", + "UnableToDecryptCertificateSignature", + "UnableToDecodeIssuerPublicKey", + "CertificateSignatureFailed", + "CertificateNotYetValid", + "CertificateExpired", + "InvalidNotBeforeField", + "InvalidNotAfterField", + "SelfSignedCertificate", + "SelfSignedCertificateInChain", + "UnableToGetLocalIssuerCertificate", + "UnableToVerifyFirstCertificate", + "CertificateRevoked", + "InvalidCaCertificate", + "PathLengthExceeded", + "InvalidPurpose", + "CertificateUntrusted", + "CertificateRejected", + "SubjectIssuerMismatch", + "AuthorityIssuerSerialNumberMismatch", + "NoPeerCertificate", + "HostNameMismatch", + "UnspecifiedError", "NoSslSupport" }; @@ -118,7 +118,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_http,"http","object") KVSO_REGISTER_HANDLER(KviKvsObject_http,"errorString",functionErrorString) KVSO_REGISTER_HANDLER(KviKvsObject_http,"setFollowRedirect",functionFollowRedirect) - #ifndef QT_NO_OPENSSL + #ifndef QT_NO_OPENSSL KVSO_REGISTER_HANDLER(KviKvsObject_http,"ignoreSSlErrors",functionIgnoreSslErrors) #endif // events @@ -130,7 +130,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_http,"http","object") KVSO_REGISTER_HANDLER(KviKvsObject_http,"dataSendProgressEvent",functionDataSendProgressEvent) KVSO_REGISTER_HANDLER(KviKvsObject_http,"stateChangedEvent",functionStateChangedEvent) KVSO_REGISTER_HANDLER(KviKvsObject_http,"readyReadEvent",functionReadyReadEvent) - #ifndef QT_NO_OPENSSL + #ifndef QT_NO_OPENSSL KVSO_REGISTER_HANDLER(KviKvsObject_http,"sslErrorsEvent",functionSslErrorsEvent) #endif @@ -157,19 +157,19 @@ KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_http,KviKvsObject) KVSO_END_CONSTRUCTOR(KviKvsObject_http) KVSO_BEGIN_DESTRUCTOR(KviKvsObject_http) - QHashIterator t(getDict); -/* - - while (t.hasNext()) - { - t.next(); - int key=t.key(); - QFile *pFile=getDict.value(key); - pFile->close(); - delete pFile; - } -*/ - delete m_pHttp; + QHashIterator t(getDict); +/* + + while (t.hasNext()) + { + t.next(); + int key=t.key(); + QFile *pFile=getDict.value(key); + pFile->close(); + delete pFile; + } +*/ + delete m_pHttp; getDict.clear(); KVSO_END_DESTRUCTOR(KviKvsObject_http) @@ -311,159 +311,159 @@ bool KviKvsObject_http::functionRequestFinishedEvent(KviKvsObjectFunctionCall *c return true; } -void KviKvsObject_http::slotRequestFinished ( int id, bool error ) -{ - - if (m_bAbort) - { - m_bAbort=false; - QHashIterator t(getDict); - while (t.hasNext()) - { - t.next(); - int key=t.key(); - QFile *pFile=getDict.value(key); - pFile->close(); - delete pFile; - } - getDict.clear(); - return; - } - QFile *pFile=getDict.value(id); - if (pFile) - { - QString name=pFile->fileName(); - pFile->close(); - getDict.remove(id); - int res=m_pHttp->lastResponse().statusCode(); - if ((m_pHttp->lastResponse().statusCode()==301 || m_pHttp->lastResponse().statusCode()==302 || m_pHttp->lastResponse().statusCode()==307) && m_bEnableForceRedirect) - redirect(name,m_pHttp->lastResponse()); - delete pFile; - } - callFunction(this,"requestFinishedEvent",0,new KviKvsVariantList(new KviKvsVariant((kvs_int_t) id),new KviKvsVariant(error))); - -} - +void KviKvsObject_http::slotRequestFinished ( int id, bool error ) +{ + + if (m_bAbort) + { + m_bAbort=false; + QHashIterator t(getDict); + while (t.hasNext()) + { + t.next(); + int key=t.key(); + QFile *pFile=getDict.value(key); + pFile->close(); + delete pFile; + } + getDict.clear(); + return; + } + QFile *pFile=getDict.value(id); + if (pFile) + { + QString name=pFile->fileName(); + pFile->close(); + getDict.remove(id); + int res=m_pHttp->lastResponse().statusCode(); + if ((m_pHttp->lastResponse().statusCode()==301 || m_pHttp->lastResponse().statusCode()==302 || m_pHttp->lastResponse().statusCode()==307) && m_bEnableForceRedirect) + redirect(name,m_pHttp->lastResponse()); + delete pFile; + } + callFunction(this,"requestFinishedEvent",0,new KviKvsVariantList(new KviKvsVariant((kvs_int_t) id),new KviKvsVariant(error))); + +} + bool KviKvsObject_http::functionRequestStartedEvent(KviKvsObjectFunctionCall *c) { emitSignal("requestStarted",c,c->params()); return true; -} -void KviKvsObject_http::slotRequestStarted ( int id ) -{ - callFunction(this,"requestStartedEvent",0,new KviKvsVariantList(new KviKvsVariant((kvs_int_t) id))); -} - -void KviKvsObject_http::slotDataReadProgress ( int done,int total ) -{ +} +void KviKvsObject_http::slotRequestStarted ( int id ) +{ + callFunction(this,"requestStartedEvent",0,new KviKvsVariantList(new KviKvsVariant((kvs_int_t) id))); +} + +void KviKvsObject_http::slotDataReadProgress ( int done,int total ) +{ callFunction(this,"dataReadProgressEvent",0,new KviKvsVariantList( - new KviKvsVariant((kvs_int_t)done),new KviKvsVariant((kvs_int_t)total))); -} + new KviKvsVariant((kvs_int_t)done),new KviKvsVariant((kvs_int_t)total))); +} bool KviKvsObject_http::functionDataReadProgressEvent(KviKvsObjectFunctionCall *c) { emitSignal("dataReadProgress",c,c->params()); return true; -} -void KviKvsObject_http::slotDataSendProgress ( int done,int total ) -{ +} +void KviKvsObject_http::slotDataSendProgress ( int done,int total ) +{ callFunction(this,"dataSendProgressEvent",0,new KviKvsVariantList( - new KviKvsVariant((kvs_int_t)done),new KviKvsVariant((kvs_int_t)total))); -} + new KviKvsVariant((kvs_int_t)done),new KviKvsVariant((kvs_int_t)total))); +} bool KviKvsObject_http::functionDataSendProgressEvent(KviKvsObjectFunctionCall *c) { emitSignal("dataSendProgress",c,c->params()); return true; -} -bool KviKvsObject_http::functionDoneEvent(KviKvsObjectFunctionCall *c) -{ +} +bool KviKvsObject_http::functionDoneEvent(KviKvsObjectFunctionCall *c) +{ emitSignal("done",c,c->params()); return true; -} -void KviKvsObject_http::slotDone ( bool error ) -{ - callFunction(this,"doneEvent",0,new KviKvsVariantList(new KviKvsVariant(error))); - -} - +} +void KviKvsObject_http::slotDone ( bool error ) +{ + callFunction(this,"doneEvent",0,new KviKvsVariantList(new KviKvsVariant(error))); + +} + bool KviKvsObject_http::functionResponseHeaderReceivedEvent(KviKvsObjectFunctionCall *c) { emitSignal("responseHeaderReceived",c,c->params()); return true; -} +} bool KviKvsObject_http::functionReadyReadEvent(KviKvsObjectFunctionCall *c) { emitSignal("readyRead",c,c->params()); return true; -} -void KviKvsObject_http::redirect(QString &file,const QHttpResponseHeader &r) -{ - QUrl url(r.value("location")); - m_pHttp->setHost(url.host()); +} +void KviKvsObject_http::redirect(QString &file,const QHttpResponseHeader &r) +{ + QUrl url(r.value("location")); + m_pHttp->setHost(url.host()); QFile *pFile=0; pFile=new QFile(file); pFile->open(QIODevice::WriteOnly); int id=m_pHttp->get(url.path(),pFile); getDict[id]=pFile; - debug("exit redirect"); -} - + debug("exit redirect"); +} + void KviKvsObject_http::slotResponseHeaderReceived(const QHttpResponseHeader &r) { QString szResponse; - switch (r.statusCode()) { - case 200: szResponse="Ok" ;break; - case 301: szResponse="Moved Permanently" ;break; - case 302: szResponse="Found" ;break; - case 303: szResponse="See Other" ;break; - case 307: szResponse="Temporary Redirect" ;break; + switch (r.statusCode()) { + case 200: szResponse="Ok" ;break; + case 301: szResponse="Moved Permanently" ;break; + case 302: szResponse="Found" ;break; + case 303: szResponse="See Other" ;break; + case 307: szResponse="Temporary Redirect" ;break; default: szResponse=r.reasonPhrase(); m_bAbort=true; } callFunction(this,"responseHeaderReceivedEvent",0,new KviKvsVariantList( - new KviKvsVariant(szResponse))); - -} + new KviKvsVariant(szResponse))); + +} void KviKvsObject_http::slotReadyRead(const QHttpResponseHeader &r) { QString szResponse; - switch (r.statusCode()) { - case 200: szResponse="Ok" ;break; - case 301: szResponse="Moved Permanently" ;break; - case 302: szResponse="Found" ;break; - case 303: szResponse="See Other" ;break; - case 307: szResponse="Temporary Redirect" ;break; + switch (r.statusCode()) { + case 200: szResponse="Ok" ;break; + case 301: szResponse="Moved Permanently" ;break; + case 302: szResponse="Found" ;break; + case 303: szResponse="See Other" ;break; + case 307: szResponse="Temporary Redirect" ;break; default: szResponse=r.reasonPhrase(); m_bAbort=true; } callFunction(this,"readyReadEvent",0,new KviKvsVariantList( - new KviKvsVariant(szResponse))); -} - - - - -void KviKvsObject_http::slotStateChanged ( int state) -{ - QString szState=""; - if (state==QHttp::Unconnected) szState="Unconnected"; - else if (state==QHttp::HostLookup) szState="HostLookup"; - else if (state==QHttp::Connecting) szState="Connecting"; - else if (state==QHttp::Connected) szState="Connected"; - else if (state==QHttp::Sending) szState="Sending"; - else if (state==QHttp::Reading) szState="Reading"; - - else if (state==QHttp::Closing) szState="Closing"; + new KviKvsVariant(szResponse))); +} + + + + +void KviKvsObject_http::slotStateChanged ( int state) +{ + QString szState=""; + if (state==QHttp::Unconnected) szState="Unconnected"; + else if (state==QHttp::HostLookup) szState="HostLookup"; + else if (state==QHttp::Connecting) szState="Connecting"; + else if (state==QHttp::Connected) szState="Connected"; + else if (state==QHttp::Sending) szState="Sending"; + else if (state==QHttp::Reading) szState="Reading"; + + else if (state==QHttp::Closing) szState="Closing"; callFunction(this,"stateChangedEvent",0,new KviKvsVariantList( - new KviKvsVariant(szState))); -} + new KviKvsVariant(szState))); +} bool KviKvsObject_http::functionStateChangedEvent(KviKvsObjectFunctionCall *c) { emitSignal("stateChanged",c,c->params()); return true; -} - -#ifndef QT_NO_OPENSSL +} + +#ifndef QT_NO_OPENSSL bool KviKvsObject_http::functionIgnoreSslErrors(KviKvsObjectFunctionCall *c) { @@ -478,16 +478,16 @@ void KviKvsObject_http::slotSslErrors(QList sslerrors) { pArray->set(i,new KviKvsVariant(ssl_errors_tbl[sslerrors.at(i).error()])); } - callFunction(this,"sslErrorsEvent",0,new KviKvsVariantList(new KviKvsVariant(pArray))); -} - + callFunction(this,"sslErrorsEvent",0,new KviKvsVariantList(new KviKvsVariant(pArray))); +} + bool KviKvsObject_http::functionSslErrorsEvent(KviKvsObjectFunctionCall *c) { emitSignal("sslErrors",c,c->params()); return true; -} -#endif +} +#endif #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "m_class_http.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES -- cgit v1.3.1-10-gc9f91