diff options
| author | 2010-12-30 02:02:11 +0000 | |
|---|---|---|
| committer | 2010-12-30 02:02:11 +0000 | |
| commit | 6b09d84c225324d7fb47f6ed564fef2262a451ba (patch) | |
| tree | f2f1ece38ca8750421f96bc7688eb8fa05bf4a80 | |
| parent | updated docs (diff) | |
| download | KVIrc-6b09d84c225324d7fb47f6ed564fef2262a451ba.tar.gz KVIrc-6b09d84c225324d7fb47f6ed564fef2262a451ba.tar.bz2 KVIrc-6b09d84c225324d7fb47f6ed564fef2262a451ba.zip | |
reworder KviError stuff
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5266 17fca916-40b9-46aa-a4ea-0a15b648b75c
| -rw-r--r-- | doc/TODO-docs | 2 | ||||
| -rw-r--r-- | src/kvilib/core/KviError.cpp | 72 | ||||
| -rw-r--r-- | src/kvilib/core/KviError.h | 288 | ||||
| -rw-r--r-- | src/kvilib/net/KviDnsResolver.cpp | 63 | ||||
| -rw-r--r-- | src/kvilib/net/KviDnsResolver.h | 32 | ||||
| -rw-r--r-- | src/kvilib/net/KviHttpRequest.cpp | 3 | ||||
| -rw-r--r-- | src/kvilib/net/KviHttpRequestThread.cpp | 11 | ||||
| -rw-r--r-- | src/kvilib/system/KviThread.cpp | 3 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp | 14 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviIrcContext.cpp | 10 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviIrcLink.cpp | 10 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviIrcSocket.cpp | 136 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviIrcSocket.h | 13 | ||||
| -rw-r--r-- | src/modules/dcc/chat.cpp | 42 | ||||
| -rw-r--r-- | src/modules/dcc/chat.h | 3 | ||||
| -rw-r--r-- | src/modules/dcc/marshal.cpp | 73 | ||||
| -rw-r--r-- | src/modules/dcc/marshal.h | 5 | ||||
| -rw-r--r-- | src/modules/dcc/send.cpp | 76 | ||||
| -rw-r--r-- | src/modules/dcc/send.h | 2 | ||||
| -rw-r--r-- | src/modules/dcc/thread.cpp | 2 | ||||
| -rw-r--r-- | src/modules/dcc/voice.cpp | 21 | ||||
| -rw-r--r-- | src/modules/dcc/voice.h | 3 | ||||
| -rw-r--r-- | src/modules/objects/class_socket.cpp | 12 |
23 files changed, 446 insertions, 450 deletions
diff --git a/doc/TODO-docs b/doc/TODO-docs index ae7bb9c3d..5a7937828 100644 --- a/doc/TODO-docs +++ b/doc/TODO-docs @@ -1,7 +1,7 @@ ################################################################## # In this file, there are all files which have to be documented. # # # -# Documenting these files involves two steps: +# Documenting these files involves two steps: # # 1. port the files to the Hungarian Notation # # http://en.wikipedia.org/wiki/Hungarian_notation # # 2. adding Doxygen documentation using its special comments to # diff --git a/src/kvilib/core/KviError.cpp b/src/kvilib/core/KviError.cpp index 462e3bed5..e2f45b943 100644 --- a/src/kvilib/core/KviError.cpp +++ b/src/kvilib/core/KviError.cpp @@ -145,7 +145,6 @@ const char * g_errorTable[KVI_NUM_ERRORS]= __tr_no_lookup("Missing popup name"), __tr_no_lookup("'item', 'popup', 'label' or 'separator' keyword expected"), __tr_no_lookup("Self modification not allowed"), - __tr_no_lookup("UNUSED"), __tr_no_lookup("Feature not available"), __tr_no_lookup("Unexpected characters in array index"), __tr_no_lookup("Unexpected end in expression"), @@ -172,62 +171,63 @@ const char * g_errorTable[KVI_NUM_ERRORS]= namespace KviError { - const char * getUntranslatedDescription(int iErrorCode) + const char * getUntranslatedDescription(KviError::Code eError) { - if((iErrorCode < KVI_NUM_ERRORS) && (iErrorCode >= 0)) - return g_errorTable[iErrorCode]; + if((eError < KVI_NUM_ERRORS) && (eError >= 0)) + return g_errorTable[eError]; #ifdef HAVE_STRERROR - if(iErrorCode < 0)return strerror(-iErrorCode); + if(eError < 0) + return strerror(-eError); #endif - return g_errorTable[KviError_unknownError]; + return g_errorTable[KviError::UnknownError]; } - QString getDescription(int iErrorCode) + QString getDescription(KviError::Code eError) { - return __tr2qs_no_xgettext(getUntranslatedDescription(iErrorCode)); + return __tr2qs_no_xgettext(getUntranslatedDescription(eError)); } - int translateSystemError(int iErrNo) + KviError::Code translateSystemError(int iErrNo) { #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) switch(iErrNo) { - case EBADF: return KviError_badFileDescriptor; break; + case EBADF: return KviError::BadFileDescriptor; break; case WSAEINVAL: case WSAEFAULT: - case EFAULT: return KviError_outOfAddressSpace; break; - case WSAECONNREFUSED: return KviError_connectionRefused; break; - case WSAENOTSOCK: return KviError_kernelNetworkingPanic; break; - case WSAETIMEDOUT: return KviError_connectionTimedOut; break; - case WSAENETUNREACH: return KviError_networkUnreachable; break; - case EPIPE: return KviError_brokenPipe; break; - case WSAENOTCONN: return KviError_socketNotConnected; break; - case WSAEACCES: return KviError_accessDenied; break; - case WSAEADDRINUSE: return KviError_addressAlreadyInUse; break; - case WSAEADDRNOTAVAIL: return KviError_cantAssignRequestedAddress; break; - case WSAEAFNOSUPPORT: return KviError_unsupportedAddressFamily; break; - case WSAECONNRESET: return KviError_connectionResetByPeer; break; - case WSAEHOSTUNREACH: return KviError_hostUnreachable; break; + case EFAULT: return KviError::OutOfAddressSpace; break; + case WSAECONNREFUSED: return KviError::ConnectionRefused; break; + case WSAENOTSOCK: return KviError::KernelNetworkingPanic; break; + case WSAETIMEDOUT: return KviError::ConnectionTimedOut; break; + case WSAENETUNREACH: return KviError::NetworkUnreachable; break; + case EPIPE: return KviError::BrokenPipe; break; + case WSAENOTCONN: return KviError::SocketNotConnected; break; + case WSAEACCES: return KviError::AccessDenied; break; + case WSAEADDRINUSE: return KviError::AddressAlreadyInUse; break; + case WSAEADDRNOTAVAIL: return KviError::CantAssignRequestedAddress; break; + case WSAEAFNOSUPPORT: return KviError::UnsupportedAddressFamily; break; + case WSAECONNRESET: return KviError::ConnectionResetByPeer; break; + case WSAEHOSTUNREACH: return KviError::HostUnreachable; break; - //case ENOBUFS: return KviError_insufficientResources; break; + //case ENOBUFS: return KviError::InsufficientResources; break; // Unhandled error...pass errno to the strerror function - default: return -iErrNo; break; + default: return KviError::UnknownError; break; } #else switch(iErrNo) { - case EBADF: return KviError_badFileDescriptor; break; - case EFAULT: return KviError_outOfAddressSpace; break; - case ECONNREFUSED: return KviError_connectionRefused; break; - case ENOTSOCK: return KviError_kernelNetworkingPanic; break; - case ETIMEDOUT: return KviError_connectionTimedOut; break; - case ENETUNREACH: return KviError_networkUnreachable; break; - case EPIPE: return KviError_brokenPipe; break; - case ENOTCONN: return KviError_socketNotConnected; break; - case ENOBUFS: return KviError_insufficientResources; break; - case EHOSTUNREACH: return KviError_hostUnreachable; break; + case EBADF: return KviError::BadFileDescriptor; break; + case EFAULT: return KviError::OutOfAddressSpace; break; + case ECONNREFUSED: return KviError::ConnectionRefused; break; + case ENOTSOCK: return KviError::KernelNetworkingPanic; break; + case ETIMEDOUT: return KviError::ConnectionTimedOut; break; + case ENETUNREACH: return KviError::NetworkUnreachable; break; + case EPIPE: return KviError::BrokenPipe; break; + case ENOTCONN: return KviError::SocketNotConnected; break; + case ENOBUFS: return KviError::InsufficientResources; break; + case EHOSTUNREACH: return KviError::HostUnreachable; break; // Unhandled error...pass errno to the strerror function - default: return -iErrNo; break; + default: return KviError::UnknownError; break; } #endif } diff --git a/src/kvilib/core/KviError.h b/src/kvilib/core/KviError.h index f3779cf7b..4a0dd1dfc 100644 --- a/src/kvilib/core/KviError.h +++ b/src/kvilib/core/KviError.h @@ -33,156 +33,7 @@ #include "kvi_settings.h" #include "KviQString.h" -#define KviError_success 0 -#define KviError_unknownError 1 -#define KviError_internalError 2 -#define KviError_unknownCommand 3 -#define KviError_missingClosingBrace 4 -#define KviError_unexpectedEndInString 5 -#define KviError_unexpectedEndInDictionaryKey 6 -#define KviError_switchDashWithoutSwitchLetter 7 -#define KviError_unknownFunction 8 -#define KviError_unexpectedEndInParenthesis 9 -#define KviError_unexpectedEndInFunctionParams 10 -#define KviError_missingVariableName 11 -#define KviError_variableOrIdentifierExpected 12 -#define KviError_leftOperandIsNotANumber 13 -#define KviError_multipleOpsNotSupportedForOperator 14 -#define KviError_divisionByZero 15 -#define KviError_moduloByZero 16 -#define KviError_rightOperandIsNotANumber 17 -#define KviError_unterminatedExpression 18 -#define KviError_unterminatedSubexpression 19 -#define KviError_unexpectedCharacter 20 -#define KviError_unknownOperator 21 - -#define KviError_noHostToResolve 22 -#define KviError_unsupportedAddressFamily 23 -#define KviError_validNameButNoIpAddress 24 -#define KviError_unrecoverableNameserverError 25 -#define KviError_dnsTemporaneousFault 26 -#define KviError_dnsInternalErrorBadFlags 27 -#define KviError_dnsInternalErrorOutOfMemory 28 -#define KviError_dnsInternalErrorServiceNotSupported 29 -#define KviError_dnsNoName 30 -#define KviError_dnsInternalErrorUnsupportedSocketType 31 -#define KviError_dnsQueryFailed 32 -#define KviError_noIPv6Support 33 -#define KviError_hostNotFound 34 -#define KviError_dnsInternalIPCFailure 35 - -#define KviError_anotherConnectionInProgress 36 -#define KviError_invalidIpAddress 37 -#define KviError_socketCreationFailed 38 -#define KviError_asyncSocketFailed 39 -#define KviError_badFileDescriptor 40 -#define KviError_outOfAddressSpace 41 -#define KviError_connectionRefused 42 -#define KviError_kernelNetworkingPanic 43 -#define KviError_connectionTimedOut 44 -#define KviError_networkUnreachable 45 -#define KviError_brokenPipe 46 -#define KviError_invalidProxyAddress 47 -#define KviError_remoteEndClosedConnection 48 - -#define KviError_invalidIrcContextId 49 -#define KviError_errorInLoadingModule 50 -#define KviError_noSuchModuleCommand 51 -#define KviError_noSuchModuleFunction 52 - -#define KviError_leftOperandIsNotADictionaryReference 53 -#define KviError_rightOperandIsNotADictionaryReference 54 - -#define KviError_missingObjectClassName 55 -#define KviError_noSuchObjectClass 56 -#define KviError_noSuchObject 57 -#define KviError_noSuchObjectFunction 58 - -#define KviError_invalidLeftOperand 59 - -#define KviError_notEnoughParameters 60 -#define KviError_integerParameterExpected 61 -#define KviError_invalidParameter 62 - -#define KviError_noSuchFile 63 - -#define KviError_openParenthesisExpected 64 -#define KviError_openBraceExpected 65 - -#define KviError_cantKillABuiltinClass 66 -#define KviError_socksV4LacksIPv6Support 67 -#define KviError_unrecognizedProxyReply 68 -#define KviError_proxyAuthFailed 69 -#define KviError_proxyNoAcceptableAuthMethod 70 - -#define KviError_proxyReply91RequestFailed 71 -#define KviError_proxyReply92IdentFailed 72 -#define KviError_proxyReply93IdentNotMatching 73 -#define KviError_proxyReply01GeneralSOCKSFailure 74 -#define KviError_proxyReply02ConnectionNotAllowed 75 -#define KviError_proxyReply03NetworkUnreachable 76 -#define KviError_proxyReply04HostUnreachable 77 -#define KviError_proxyReply05ConnectionRefused 78 -#define KviError_proxyReply06TTLExpired 79 -#define KviError_proxyReply07CommandNotSupported 80 -#define KviError_proxyReply08AddressTypeNotSupported 81 -#define KviError_proxyReply09InvalidAddress 82 - -#define KviError_invalidPortNumber 83 -#define KviError_socketNotConnected 84 -#define KviError_insufficientResources 85 -#define KviError_bindFailed 86 -#define KviError_cantResolveLocalhost 87 - -#define KviError_unsupportedImageFormat 88 - -#define KviError_cantOpenFileForAppending 89 -#define KviError_cantOpenFileForWriting 90 -#define KviError_fileIOError 91 -#define KviError_acknowledgeError 92 -#define KviError_cantOpenFileForReading 93 -#define KviError_cantSendAZeroSizeFile 94 - -#define KviError_missingPopupName 95 -#define KviError_itemPopupOrSeparatorExpected 96 -#define KviError_selfModificationNotAllowed 97 - -//#define KviError_recursionTooDeep 98 -#define KviError_featureNotAvailable 99 - -#define KviError_unexpectedCharactersInArrayIndex 100 -#define KviError_unexpectedEndInExpression 101 -#define KviError_unexpectedEndInArrayIndex 102 - -#define KviError_proxyHttpFailure 103 -#define KviError_caseMatchRegexpDefaultOrBreakExpected 104 - - -#define KviError_accessDenied 105 -#define KviError_addressAlreadyInUse 106 -#define KviError_cantAssignRequestedAddress 107 -#define KviError_connectionResetByPeer 108 -#define KviError_hostUnreachable 109 - -#define KviError_variableExpected 110 -#define KviError_invalidArrayIndex 111 - -#define KviError_listenFailed 112 - -#define KviError_noSSLSupport 113 -#define KviError_SSLError 114 - -#define KviError_slashCharacterExpected 115 -#define KviError_unknownStringManipulationOperator 116 - -#define KviError_operationAborted 117 - -#define KviError_unexpectedToken 118 - -#define KviError_scopeObjectAlreadyDefined 119 -#define KviError_noThisObject 120 - -#define KVI_NUM_ERRORS 121 +#define KVI_NUM_ERRORS 120 /** * \namespace KviError @@ -191,25 +42,152 @@ namespace KviError { /** + * \enum Code + * \brief Contains all error codes + */ + enum Code { + Success = 0, + UnknownError = 1, + InternalError = 2, + UnknownCommand = 3, + MissingClosingBrace = 4, + UnexpectedEndInString = 5, + UnexpectedEndInDictionaryKey = 6, + SwitchDashWithoutSwitchLetter = 7, + UnknownFunction = 8, + UnexpectedEndInParenthesis = 9, + UnexpectedEndInFunctionParams = 10, + MissingVariableName = 11, + VariableOrIdentifierExpected = 12, + LeftOperandIsNotANumber = 13, + MultipleOpsNotSupportedForOperator = 14, + DivisionByZero = 15, + ModuloByZero = 16, + RightOperandIsNotANumber = 17, + UnterminatedExpression = 18, + UnterminatedSubexpression = 19, + UnexpectedCharacter = 20, + UnknownOperator = 21, + NoHostToResolve = 22, + UnsupportedAddressFamily = 23, + ValidNameButNoIpAddress = 24, + UnrecoverableNameserverError = 25, + DNSTemporaneousFault = 26, + DNSInternalErrorBadFlags = 27, + DNSInternalErrorOutOfMemory = 28, + DNSInternalErrorServiceNotSupported = 29, + DNSNoName = 30, + DNSInternalErrorUnsupportedSocketType = 31, + DNSQueryFailed = 32, + NoIPv6Support = 33, + HostNotFound = 34, + DNSInternalIPCFailure = 35, + AnotherConnectionInProgress = 36, + InvalidIpAddress = 37, + SocketCreationFailed = 38, + AsyncSocketFailed = 39, + BadFileDescriptor = 40, + OutOfAddressSpace = 41, + ConnectionRefused = 42, + KernelNetworkingPanic = 43, + ConnectionTimedOut = 44, + NetworkUnreachable = 45, + BrokenPipe = 46, + InvalidProxyAddress = 47, + RemoteEndClosedConnection = 48, + InvalidIrcContextId = 49, + ErrorInLoadingModule = 50, + NoSuchModuleCommand = 51, + NoSuchModuleFunction = 52, + LeftOperandIsNotADictionaryReference = 53, + RightOperandIsNotADictionaryReference = 54, + MissingObjectClassName = 55, + NoSuchObjectClass = 56, + NoSuchObject = 57, + NoSuchObjectFunction = 58, + InvalidLeftOperand = 59, + NotEnoughParameters = 60, + IntegerParameterExpected = 61, + InvalidParameter = 62, + NoSuchFile = 63, + OpenParenthesisExpected = 64, + OpenBraceExpected = 65, + CantKillABuiltinClass = 66, + SocksV4LacksIPv6Support = 67, + UnrecognizedProxyReply = 68, + ProxyAuthFailed = 69, + ProxyNoAcceptableAuthMethod = 70, + ProxyReply91RequestFailed = 71, + ProxyReply92IdentFailed = 72, + ProxyReply93IdentNotMatching = 73, + ProxyReply01GeneralSOCKSFailure = 74, + ProxyReply02ConnectionNotAllowed = 75, + ProxyReply03NetworkUnreachable = 76, + ProxyReply04HostUnreachable = 77, + ProxyReply05ConnectionRefused = 78, + ProxyReply06TTLExpired = 79, + ProxyReply07CommandNotSupported = 80, + ProxyReply08AddressTypeNotSupported = 81, + ProxyReply09InvalidAddress = 82, + InvalidPortNumber = 83, + SocketNotConnected = 84, + InsufficientResources = 85, + BindFailed = 86, + CantResolveLocalhost = 87, + UnsupportedImageFormat = 88, + CantOpenFileForAppending = 89, + CantOpenFileForWriting = 90, + FileIOError = 91, + AcknowledgeError = 92, + CantOpenFileForReading = 93, + CantSendAZeroSizeFile = 94, + MissingPopupName = 95, + ItemPopupOrSeparatorExpected = 96, + SelfModificationNotAllowed = 97, + FeatureNotAvailable = 98, + UnexpectedCharactersInArrayIndex = 99, + UnexpectedEndInExpression = 100, + UnexpectedEndInArrayIndex = 101, + ProxyHttpFailure = 102, + CaseMatchRegexpDefaultOrBreakExpected = 103, + AccessDenied = 104, + AddressAlreadyInUse = 105, + CantAssignRequestedAddress = 106, + ConnectionResetByPeer = 107, + HostUnreachable = 108, + VariableExpected = 109, + InvalidArrayIndex = 110, + ListenFailed = 111, + NoSSLSupport = 112, + SSLError = 113, + SlashCharacterExpected = 114, + UnknownStringManipulationOperator = 115, + OperationAborted = 116, + UnexpectedToken = 117, + ScopeObjectAlreadyDefined = 118, + NoThisObject = 119 + }; + + /** * \brief Returns the description of the error - * \param iErrorCode The code number of the error + * \param error The code number of the error * \return QString */ - KVILIB_API QString getDescription(int iErrorCode); + KVILIB_API QString getDescription(KviError::Code eError); /** * \brief Returns an untranslated description of the error - * \param iErrorCode The code number of the error + * \param error The code number of the error * \return const char * */ - KVILIB_API const char * getUntranslatedDescription(int iErrorCode); + KVILIB_API const char * getUntranslatedDescription(KviError::Code eError); /** * \brief Gets system errors and returns their code number * \param iErrNo The code number of the system error * \return int */ - KVILIB_API int translateSystemError(int iErrNo); + KVILIB_API KviError::Code translateSystemError(int iErrNo); } #endif //_KVI_ERROR_H_ diff --git a/src/kvilib/net/KviDnsResolver.cpp b/src/kvilib/net/KviDnsResolver.cpp index 9c69dfb8f..6d4f48170 100644 --- a/src/kvilib/net/KviDnsResolver.cpp +++ b/src/kvilib/net/KviDnsResolver.cpp @@ -58,7 +58,7 @@ KviDnsResolverResult::KviDnsResolverResult() { - m_iError = KviError_success; + m_eError = KviError::Success; m_pHostnameList = new KviPointerList<QString>; m_pHostnameList->setAutoDelete(true); m_pIpAddressList = new KviPointerList<QString>; @@ -94,47 +94,47 @@ KviDnsResolverThread::~KviDnsResolverThread() { } -int KviDnsResolverThread::translateDnsError(int iErr) +KviError::Code KviDnsResolverThread::translateDnsError(int iErr) { #if defined(COMPILE_IPV6_SUPPORT) || (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) switch(iErr) { - case EAI_FAMILY: return KviError_unsupportedAddressFamily; break; + case EAI_FAMILY: return KviError::UnsupportedAddressFamily; break; #if (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) && defined(EAI_ADDRFAMILY) && (EAI_ADDRFAMILY != EAI_FAMILY) - case EAI_ADDRFAMILY: return KviError_unsupportedAddressFamily; break; + case EAI_ADDRFAMILY: return KviError::UnsupportedAddressFamily; break; #endif // NOT FreeBSD ARE WE? #if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME) // YARR - case EAI_NODATA: return KviError_validNameButNoIpAddress; break; + case EAI_NODATA: return KviError::ValidNameButNoIpAddress; break; #endif - case EAI_FAIL: return KviError_unrecoverableNameserverError; break; - case EAI_AGAIN: return KviError_dnsTemporaneousFault; break; + case EAI_FAIL: return KviError::UnrecoverableNameserverError; break; + case EAI_AGAIN: return KviError::DNSTemporaneousFault; break; // this should never happen - case EAI_BADFLAGS: return KviError_dnsInternalErrorBadFlags; break; - case EAI_MEMORY: return KviError_dnsInternalErrorOutOfMemory; break; + case EAI_BADFLAGS: return KviError::DNSInternalErrorBadFlags; break; + case EAI_MEMORY: return KviError::DNSInternalErrorOutOfMemory; break; // got this when experimenting with protocols - case EAI_SERVICE: return KviError_dnsInternalErrorServiceNotSupported; break; + case EAI_SERVICE: return KviError::DNSInternalErrorServiceNotSupported; break; #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) - case EAI_NONAME: return KviError_dnsNoName; break; + case EAI_NONAME: return KviError::DNSNoName; break; #endif // got this when experimenting with protocols - case EAI_SOCKTYPE: return KviError_dnsInternalErrorUnsupportedSocketType; break; + case EAI_SOCKTYPE: return KviError::DNSInternalErrorUnsupportedSocketType; break; #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) - case EAI_SYSTEM: return -errno; + case EAI_SYSTEM: return KviError::DNSQueryFailed; #endif } #endif - return KviError_dnsQueryFailed; + return KviError::DNSQueryFailed; } -void KviDnsResolverThread::postDnsError(KviDnsResolverResult * dns,int iErr) +void KviDnsResolverThread::postDnsError(KviDnsResolverResult * pDns, KviError::Code error) { - dns->setError(iErr); + pDns->setError(error); KviThreadDataEvent<KviDnsResolverResult> * e = new KviThreadDataEvent<KviDnsResolverResult>(KVI_DNS_THREAD_EVENT_DATA); - e->setData(dns); + e->setData(pDns); postEvent(m_pParentDns,e); } @@ -146,7 +146,7 @@ void KviDnsResolverThread::run() if(m_szQuery.isEmpty()) { - postDnsError(dns,KviError_noHostToResolve); + postDnsError(dns,KviError::NoHostToResolve); return; } @@ -155,7 +155,7 @@ void KviDnsResolverThread::run() { if(m_queryType == KviDnsResolver::IPv6) { - postDnsError(dns,KviError_noIPv6Support); + postDnsError(dns,KviError::NoIPv6Support); return; } m_queryType = KviDnsResolver::IPv4; @@ -166,7 +166,7 @@ void KviDnsResolverThread::run() if(m_queryType == KviDnsResolver::IPv6) { - postDnsError(dns,KviError_noIPv6Support); + postDnsError(dns,KviError::NoIPv6Support); return; } @@ -188,11 +188,11 @@ void KviDnsResolverThread::run() { switch(h_errno) { - case HOST_NOT_FOUND: dns->setError(KviError_hostNotFound); break; - case NO_ADDRESS: dns->setError(KviError_validNameButNoIpAddress); break; - case NO_RECOVERY: dns->setError(KviError_unrecoverableNameserverError); break; - case TRY_AGAIN: dns->setError(KviError_dnsTemporaneousFault); break; - default: dns->setError(KviError_dnsQueryFailed); break; + case HOST_NOT_FOUND: dns->setError(KviError::HostNotFound); break; + case NO_ADDRESS: dns->setError(KviError::ValidNameButNoIpAddress); break; + case NO_RECOVERY: dns->setError(KviError::UnrecoverableNameserverError); break; + case TRY_AGAIN: dns->setError(KviError::DNSTemporaneousFault); break; + default: dns->setError(KviError::DNSQueryFailed); break; } } else { dns->appendHostname(pHostEntry->h_name); @@ -370,22 +370,25 @@ bool KviDnsResolver::isRunning() const bool KviDnsResolver::lookup(const QString &query,QueryType type) { - if(m_state == Busy)return false; + if(m_state == Busy) + return false; m_pSlaveThread->setQuery(KviQString::trimmed(query),type); bool bStarted = m_pSlaveThread->start(); m_state = bStarted ? Busy : Failure; return bStarted; } -int KviDnsResolver::error() +KviError::Code KviDnsResolver::error() { - if(!m_pDnsResult)return KviError_dnsQueryFailed; + if(!m_pDnsResult) + return KviError::DNSQueryFailed; return m_pDnsResult->error(); } KviDnsResolverResult * KviDnsResolver::result() { - if(!m_pDnsResult)m_pDnsResult = new KviDnsResolverResult(); + if(!m_pDnsResult) + m_pDnsResult = new KviDnsResolverResult(); return m_pDnsResult; } @@ -436,7 +439,7 @@ bool KviDnsResolver::event(QEvent *e) { if(m_pDnsResult)delete m_pDnsResult; m_pDnsResult = ((KviThreadDataEvent<KviDnsResolverResult> *)e)->getData(); - m_state = (m_pDnsResult->error() == KviError_success) ? Success : Failure; + m_state = (m_pDnsResult->error() == KviError::Success) ? Success : Failure; emit lookupDone(this); return true; } // else ops... unknown thread event ? diff --git a/src/kvilib/net/KviDnsResolver.h b/src/kvilib/net/KviDnsResolver.h index 6d47862b2..d8f43648c 100644 --- a/src/kvilib/net/KviDnsResolver.h +++ b/src/kvilib/net/KviDnsResolver.h @@ -29,10 +29,10 @@ #include "KviHeapObject.h" #include "KviThread.h" #include "KviQString.h" +#include "KviError.h" class KviDnsResolverThread; - class KVILIB_API KviDnsResolverResult : public KviHeapObject { friend class KviDnsResolver; @@ -42,14 +42,14 @@ protected: public: ~KviDnsResolverResult(); protected: - int m_iError; + KviError::Code m_eError; KviPointerList<QString> * m_pHostnameList; KviPointerList<QString> * m_pIpAddressList; QString m_szQuery; public: - int error() + KviError::Code error() { - return m_iError; + return m_eError; } // never store nor delete these pointers! @@ -70,18 +70,18 @@ public: } protected: - void setError(int iError) + void setError(KviError::Code eError) { - m_iError = iError; + m_eError = eError; } - void setQuery(const QString &query) + void setQuery(const QString & szQuery) { - m_szQuery = query; + m_szQuery = szQuery; } - void appendHostname(const QString &host); - void appendAddress(const QString &addr); + void appendHostname(const QString & szHost); + void appendAddress(const QString & szAddr); }; @@ -108,13 +108,13 @@ public: // // Lookup start - bool lookup(const QString &szQuery,QueryType type); + bool lookup(const QString & szQuery, QueryType type); // Current object state State state(){ return m_state; }; // Results (return always non null-data..but valid results only if state() == Success or Failure) - int error(); + KviError::Code error(); const QString & firstHostname(); const QString & firstIpAddress(); int hostnameCount(); @@ -150,15 +150,15 @@ protected: KviDnsResolverThread(KviDnsResolver * pDns); virtual ~KviDnsResolverThread(); protected: - QString m_szQuery; + QString m_szQuery; KviDnsResolver::QueryType m_queryType; KviDnsResolver * m_pParentDns; public: - void setQuery(const QString &query,KviDnsResolver::QueryType type){ m_szQuery = query; m_queryType = type; }; + void setQuery(const QString & szQuery, KviDnsResolver::QueryType type){ m_szQuery = szQuery; m_queryType = type; }; protected: virtual void run(); - int translateDnsError(int iErr); - void postDnsError(KviDnsResolverResult * dns,int iErr); + KviError::Code translateDnsError(int iErr); + void postDnsError(KviDnsResolverResult * pDns, KviError::Code error); }; diff --git a/src/kvilib/net/KviHttpRequest.cpp b/src/kvilib/net/KviHttpRequest.cpp index 30f97887d..4f605d6c5 100644 --- a/src/kvilib/net/KviHttpRequest.cpp +++ b/src/kvilib/net/KviHttpRequest.cpp @@ -204,9 +204,8 @@ void KviHttpRequest::dnsLookupDone(KviDnsResolver *d) emit status(tmp); haveServerIp(); } else { - int iErr = d->error(); resetInternalStatus(); - m_szLastError = KviError::getDescription(iErr); + m_szLastError = KviError::getDescription(d->error()); emit terminated(false); } } diff --git a/src/kvilib/net/KviHttpRequestThread.cpp b/src/kvilib/net/KviHttpRequestThread.cpp index 21e1d2a9e..88258dde5 100644 --- a/src/kvilib/net/KviHttpRequestThread.cpp +++ b/src/kvilib/net/KviHttpRequestThread.cpp @@ -210,14 +210,17 @@ bool KviHttpRequestThread::connectToRemoteHost() return false; int sockError; - int iSize=sizeof(sockError); + int iSize = sizeof(sockError); if(!kvi_socket_getsockopt(m_sock,SOL_SOCKET,SO_ERROR,(void *)&sockError,&iSize))sockError = -1; if(sockError != 0) { //failed - if(sockError > 0)sockError = KviError::translateSystemError(sockError); - else sockError = KviError_unknownError; - return failure(KviError::getUntranslatedDescription(sockError)); + KviError::Code eError; + if(sockError > 0) + eError = KviError::translateSystemError(sockError); + else + eError = KviError::UnknownError; + return failure(KviError::getUntranslatedDescription(eError)); } #ifdef COMPILE_SSL_SUPPORT diff --git a/src/kvilib/system/KviThread.cpp b/src/kvilib/system/KviThread.cpp index 5187e717c..5ab839e74 100644 --- a/src/kvilib/system/KviThread.cpp +++ b/src/kvilib/system/KviThread.cpp @@ -164,7 +164,7 @@ void KviThreadManager::globalInit() void KviThreadManager::globalDestroy() { delete g_pThreadManager; - g_pThreadManager = 0; + g_pThreadManager = 0; } KviThreadManager::KviThreadManager() @@ -172,7 +172,6 @@ KviThreadManager::KviThreadManager() { if(g_pThreadManager)qDebug("Hey...what are ya doing ?"); - m_pMutex = new KviMutex(); m_pThreadList = new KviPointerList<KviThread>; m_pThreadList->setAutoDelete(false); diff --git a/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp b/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp index 385cfc597..abf384ae7 100644 --- a/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp +++ b/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp @@ -73,7 +73,7 @@ KviIrcConnectionTargetResolver::KviIrcConnectionTargetResolver(KviIrcConnection m_eState = Idle; m_eStatus = Success; - m_iLastError = KviError_success; + m_iLastError = KviError::Success; } KviIrcConnectionTargetResolver::~KviIrcConnectionTargetResolver() @@ -144,7 +144,7 @@ void KviIrcConnectionTargetResolver::abort() if(m_eState == Terminated)return; m_pConsole->outputNoFmt(KVI_OUT_SYSTEMERROR,__tr2qs("Hostname resolution aborted")); - terminate(Error,KviError_operationAborted); + terminate(Error,KviError::OperationAborted); } void KviIrcConnectionTargetResolver::asyncStartResolve() @@ -199,7 +199,7 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() if(m_pTarget->proxy()->protocol() != KviProxy::Http && m_pTarget->proxy()->protocol() != KviProxy::Socks5) lookupServerHostname(); - else terminate(Success,KviError_success); + else terminate(Success,KviError::Success); } else { #ifdef COMPILE_IPV6_SUPPORT if(m_pTarget->proxy()->isIPv6()) @@ -219,7 +219,7 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() { lookupServerHostname(); } else { - terminate(Success,KviError_success); + terminate(Success,KviError::Success); } } else { @@ -296,7 +296,7 @@ void KviIrcConnectionTargetResolver::proxyLookupTerminated(KviDnsResolver *) if(m_pTarget->proxy()->protocol() == KviProxy::Http || m_pTarget->proxy()->protocol() == KviProxy::Socks5) { - terminate(Success,KviError_success); + terminate(Success,KviError::Success); return; } } @@ -355,7 +355,7 @@ void KviIrcConnectionTargetResolver::lookupServerHostname() { m_pConsole->outputNoFmt(KVI_OUT_SYSTEMERROR, __tr2qs("Unable to look up the server hostname: Can't start the DNS slave")); - terminate(Error,KviError_internalError); + terminate(Error,KviError::InternalError); } else { if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, @@ -570,7 +570,7 @@ void KviIrcConnectionTargetResolver::haveServerIp() } m_pTarget->setBindAddress(bindAddress); - terminate(Success,KviError_success); + terminate(Success,KviError::Success); } void KviIrcConnectionTargetResolver::terminate(Status s,int iLastError) diff --git a/src/kvirc/kernel/KviIrcContext.cpp b/src/kvirc/kernel/KviIrcContext.cpp index 338df1534..5066a2119 100644 --- a/src/kvirc/kernel/KviIrcContext.cpp +++ b/src/kvirc/kernel/KviIrcContext.cpp @@ -597,7 +597,7 @@ void KviIrcContext::connectionFailed(int iError) m_pConnection->target()->server()->m_szHostname.toUtf8().data()); // if the connection has been aborted by the user then just go idle - if(iError == KviError_operationAborted) + if(iError == KviError::OperationAborted) goto enter_idle_state; // FIXME: this should stop on critical errors ! @@ -655,10 +655,10 @@ void KviIrcContext::connectionFailed(int iError) if(connection()->target()->server()->cacheIp()) { - if((((int)iError) == KviError_connectionTimedOut) || - (((int)iError) == KviError_connectionRefused) || - (((int)iError) == KviError_networkUnreachable) || - (((int)iError) == KviError_hostUnreachable)) + if((((int)iError) == KviError::ConnectionTimedOut) || + (((int)iError) == KviError::ConnectionRefused) || + (((int)iError) == KviError::NetworkUnreachable) || + (((int)iError) == KviError::HostUnreachable)) { m_pConsole->output(KVI_OUT_SYSTEMWARNING,__tr2qs("The connection attempt failed while using a cached IP address for the current server")); m_pConsole->output(KVI_OUT_SYSTEMWARNING,__tr2qs("The problem *might* be caused by an updated DNS entry")); diff --git a/src/kvirc/kernel/KviIrcLink.cpp b/src/kvirc/kernel/KviIrcLink.cpp index 3e17fb0f5..5f515fc4d 100644 --- a/src/kvirc/kernel/KviIrcLink.cpp +++ b/src/kvirc/kernel/KviIrcLink.cpp @@ -195,19 +195,19 @@ void KviIrcLink::resolverTerminated() createSocket(m_pTarget->server()->linkFilter()); - int iErr = m_pSocket->startConnection(m_pTarget->server(),m_pTarget->proxy(), + KviError::Code eError = m_pSocket->startConnection(m_pTarget->server(),m_pTarget->proxy(), m_pTarget->bindAddress().isEmpty() ? 0 : m_pTarget->bindAddress().toUtf8().data()); - if(iErr != KviError_success) + if(eError != KviError::Success) { - QString szStrDescription(KviError::getDescription(iErr)); + QString szStrDescription(KviError::getDescription(eError)); m_pConsole->output(KVI_OUT_SYSTEMERROR, __tr2qs("Failed to start the connection: %Q"), &szStrDescription); -// &(KviError::getDescription(iErr))); +// &(KviError::getDescription(eError))); m_eState = Idle; - m_pConnection->linkAttemptFailed(iErr); + m_pConnection->linkAttemptFailed(eError); } } diff --git a/src/kvirc/kernel/KviIrcSocket.cpp b/src/kvirc/kernel/KviIrcSocket.cpp index 3d50ddd3c..d791b63ce 100644 --- a/src/kvirc/kernel/KviIrcSocket.cpp +++ b/src/kvirc/kernel/KviIrcSocket.cpp @@ -29,7 +29,6 @@ #include "KviProxyDataBase.h" #include "KviNetUtils.h" #include "kvi_settings.h" -#include "KviError.h" #include "KviLocale.h" #include "KviMemory.h" #include "kvi_debug.h" @@ -87,7 +86,7 @@ KviIrcSocket::KviIrcSocket(KviIrcLink * pLink) m_pSendQueueHead = 0; // data queue m_pSendQueueTail = 0; // - m_iLastError = KviError_success; + m_eLastError = KviError::Success; #ifdef COMPILE_SSL_SUPPORT m_pSSL = 0; @@ -241,24 +240,24 @@ void KviIrcSocket::setState(SocketState state) } } -void KviIrcSocket::raiseError(int iError) +void KviIrcSocket::raiseError(KviError::Code eError) { - m_iLastError = iError; + m_eLastError = eError; //m_pConsole->socketError(iError); - if((m_iLastError == KviError_remoteEndClosedConnection) && - ( m_state == ProxyHttpError)) - outputSocketMessage(KviError::getDescription(iError)); + if((m_eLastError == KviError::RemoteEndClosedConnection) && + (m_state == ProxyHttpError)) + outputSocketMessage(KviError::getDescription(eError)); else - outputSocketError(KviError::getDescription(iError)); + outputSocketError(KviError::getDescription(eError)); } -int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, const char * pcBindAddress) +KviError::Code KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, const char * pcBindAddress) { // Attempts to estabilish an IRC connection // to the server specified by *srv. // Uses the proxy *prx if not 0 if(m_state != Idle) - return KviError_anotherConnectionInProgress; + return KviError::AnotherConnectionInProgress; // Coherent state, thnx. reset(); @@ -266,7 +265,7 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con if(pServer->useSSL()) { #ifndef COMPILE_SSL_SUPPORT - return KviError_noSSLSupport; + return KviError::NoSSLSupport; #endif //COMPILE_SSL_SUPPORT } @@ -294,17 +293,17 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con #ifdef COMPILE_IPV6_SUPPORT bTargetIPv6 = true; if(!KviNetUtils::isValidStringIPv6(m_pProxy->ip())) - return KviError_invalidProxyAddress; + return KviError::InvalidProxyAddress; // SOCKSv4 does not support IPv6 addresses if(m_pProxy->protocol() == KviProxy::Socks4) - return KviError_socksV4LacksIPv6Support; + return KviError::SocksV4LacksIPv6Support; #else - return KviError_noIPv6Support; + return KviError::NoIPv6Support; #endif } else { // IPv4 proxy if(!KviNetUtils::isValidStringIp(m_pProxy->ip())) - return KviError_invalidProxyAddress; + return KviError::InvalidProxyAddress; } } @@ -316,14 +315,14 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con { // We have an IPv6 server host (Interesting if proxy is IPv4) if( !KviNetUtils::isValidStringIPv6(m_pIrcServer->ip()) ) - return KviError_invalidIpAddress; + return KviError::InvalidIpAddress; if(!m_pProxy) bTargetIPv6 = true; // otherwise the proxy rules } else { #endif // We have an IPv4 server host if(!KviNetUtils::isValidStringIp(m_pIrcServer->ip())) - return KviError_invalidIpAddress; + return KviError::InvalidIpAddress; #ifdef COMPILE_IPV6_SUPPORT } #endif @@ -332,7 +331,7 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con KviSockaddr sa(pProxy ? m_pProxy->ip().toUtf8().data() : m_pIrcServer->ip().toUtf8().data(), pProxy ? m_pProxy->port() : m_pIrcServer->port(),bTargetIPv6); if(!sa.socketAddress()) - return KviError_invalidIpAddress; + return KviError::InvalidIpAddress; // create the socket #ifdef COMPILE_IPV6_SUPPORT @@ -342,7 +341,7 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con #endif if(m_sock < 0) - return KviError_socketCreationFailed; + return KviError::SocketCreationFailed; if(pcBindAddress) { @@ -372,7 +371,7 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con if(!kvi_socket_setNonBlocking(m_sock)) { reset(); - return KviError_asyncSocketFailed; + return KviError::AsyncSocketFailed; } if(!kvi_socket_connect(m_sock,sa.socketAddress(),((int)(sa.addressLength())))) @@ -396,7 +395,7 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con // And declare problems :) if(iSockError) return KviError::translateSystemError(iSockError); - else return KviError_unknownError; //Error 0 ? + else return KviError::UnknownError; //Error 0 ? } } @@ -418,13 +417,13 @@ int KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * pProxy, con // and wait for connect setState(Connecting); - return KviError_success; + return KviError::Success; } void KviIrcSocket::connectionTimedOut() { // the m_pTimeoutTimer fired :( - raiseError(KviError_connectionTimedOut); + raiseError(KviError::ConnectionTimedOut); reset(); } @@ -447,11 +446,12 @@ void KviIrcSocket::writeNotifierFired(int) if(iSockError != 0) { //failed + KviError::Code eError; if(iSockError > 0) - iSockError = KviError::translateSystemError(iSockError); - else iSockError = KviError_unknownError; //Error 0 ? + eError = KviError::translateSystemError(iSockError); + else eError = KviError::UnknownError; //Error 0 ? - raiseError(iSockError); + raiseError(eError); reset(); return; } @@ -545,7 +545,7 @@ void KviIrcSocket::enterSSLMode() if(!m_pSSL) { raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; } @@ -583,7 +583,7 @@ void KviIrcSocket::readProxyData(int) if(iE != 0) { raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; } @@ -591,12 +591,12 @@ void KviIrcSocket::readProxyData(int) break; case KviSSL::SSLError: raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; default: - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; @@ -628,7 +628,7 @@ void KviIrcSocket::readProxyData(int) // - remote host is not a SOCKS/HTTP server // Anyway....it is always a meaningless reply // better to try again later :) - raiseError(KviError_unrecognizedProxyReply); + raiseError(KviError::UnrecognizedProxyReply); reset(); return; } @@ -659,7 +659,7 @@ void KviIrcSocket::readProxyData(int) break; default: // what ? - raiseError(KviError_unrecognizedProxyReply); + raiseError(KviError::UnrecognizedProxyReply); reset(); break; } @@ -1026,7 +1026,7 @@ void KviIrcSocket::proxyHandleV5AuthReply(unsigned char cReply) proxySendTargetDataV5(); return; } - raiseError(KviError_proxyAuthFailed); + raiseError(KviError::ProxyAuthFailed); reset(); } @@ -1073,11 +1073,11 @@ void KviIrcSocket::proxyHandleV5MethodReply(unsigned char cReply) //Request rejected if(cReply == 0xFF) { - raiseError(KviError_proxyNoAcceptableAuthMethod); + raiseError(KviError::ProxyNoAcceptableAuthMethod); reset(); } else { // unrecognized... - raiseError(KviError_unrecognizedProxyReply); + raiseError(KviError::UnrecognizedProxyReply); reset(); } } @@ -1126,21 +1126,21 @@ void KviIrcSocket::proxyHandleV5FinalReply(unsigned char cReply) connectedToIrcServer(); } else { //Request rejected - int iErr; + KviError::Code eError; switch(cReply) { - case 1: iErr = KviError_proxyReply01GeneralSOCKSFailure; break; - case 2: iErr = KviError_proxyReply02ConnectionNotAllowed; break; - case 3: iErr = KviError_proxyReply03NetworkUnreachable; break; - case 4: iErr = KviError_proxyReply04HostUnreachable; break; - case 5: iErr = KviError_proxyReply05ConnectionRefused; break; - case 6: iErr = KviError_proxyReply06TTLExpired; break; - case 7: iErr = KviError_proxyReply07CommandNotSupported; break; - case 8: iErr = KviError_proxyReply08AddressTypeNotSupported; break; - case 9: iErr = KviError_proxyReply09InvalidAddress; break; - default: iErr = KviError_unrecognizedProxyReply; break; + case 1: eError = KviError::ProxyReply01GeneralSOCKSFailure; break; + case 2: eError = KviError::ProxyReply02ConnectionNotAllowed; break; + case 3: eError = KviError::ProxyReply03NetworkUnreachable; break; + case 4: eError = KviError::ProxyReply04HostUnreachable; break; + case 5: eError = KviError::ProxyReply05ConnectionRefused; break; + case 6: eError = KviError::ProxyReply06TTLExpired; break; + case 7: eError = KviError::ProxyReply07CommandNotSupported; break; + case 8: eError = KviError::ProxyReply08AddressTypeNotSupported; break; + case 9: eError = KviError::ProxyReply09InvalidAddress; break; + default: eError = KviError::UnrecognizedProxyReply; break; } - raiseError(iErr); + raiseError(eError); reset(); } } @@ -1183,15 +1183,15 @@ void KviIrcSocket::proxyHandleV4FinalReply(unsigned char cReply) connectedToIrcServer(); } else { //Request rejected - int iErr; + KviError::Code eError; switch(cReply) { - case 91: iErr = KviError_proxyReply91RequestFailed; break; - case 92: iErr = KviError_proxyReply92IdentFailed; break; - case 93: iErr = KviError_proxyReply93IdentNotMatching; break; - default: iErr = KviError_unrecognizedProxyReply; break; + case 91: eError = KviError::ProxyReply91RequestFailed; break; + case 92: eError = KviError::ProxyReply92IdentFailed; break; + case 93: eError = KviError::ProxyReply93IdentNotMatching; break; + default: eError = KviError::UnrecognizedProxyReply; break; } - raiseError(iErr); + raiseError(eError); reset(); } // Just looked out of the window... @@ -1252,7 +1252,7 @@ void KviIrcSocket::proxyHandleHttpFinalReply(const char * pcBuffer, int) setState(ProxyHttpError); - //raiseError(KviError_proxyHttpFailure); + //raiseError(KviError::ProxyHttpFailure); //reset(); } @@ -1345,12 +1345,12 @@ void KviIrcSocket::doSSLHandshake(int) m_pWsn->setEnabled(true); break; case KviSSL::RemoteEndClosedConnection: - raiseError(KviError_remoteEndClosedConnection); + raiseError(KviError::RemoteEndClosedConnection); // reset(); break; case KviSSL::SSLError: raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); // reset(); break; case KviSSL::SyscallError: @@ -1360,7 +1360,7 @@ void KviIrcSocket::doSSLHandshake(int) if(!kvi_socket_recoverableError(iErr)) { // Declare problems :) - raiseError((iErr ? KviError::translateSystemError(iErr) : KviError_unknownError)); + raiseError((iErr ? KviError::translateSystemError(iErr) : KviError::UnknownError)); } else { // can recover ? (EAGAIN, EINTR ?) m_pWsn = new QSocketNotifier((int)m_sock,QSocketNotifier::Write); @@ -1372,7 +1372,7 @@ void KviIrcSocket::doSSLHandshake(int) } break; default: - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); // reset(); break; } @@ -1443,7 +1443,7 @@ void KviIrcSocket::readData(int) if(iE != 0) { raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; } @@ -1451,12 +1451,12 @@ void KviIrcSocket::readData(int) break; case KviSSL::SSLError: raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; default: - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; @@ -1630,7 +1630,7 @@ void KviIrcSocket::abort() if(m_state == Connected) flushSendQueue(); if(m_state != Idle) - raiseError(KviError_operationAborted); + raiseError(KviError::OperationAborted); // and reset reset(); } @@ -1640,7 +1640,7 @@ void KviIrcSocket::handleInvalidSocketRead(int iReadLength) KVI_ASSERT(iReadLength <= 0); if(iReadLength == 0) { - raiseError(KviError_remoteEndClosedConnection); + raiseError(KviError::RemoteEndClosedConnection); reset(); } else { //check for transmission errors @@ -1654,7 +1654,7 @@ void KviIrcSocket::handleInvalidSocketRead(int iReadLength) if(iErr > 0) raiseError((KviError::translateSystemError(iErr))); else - raiseError(KviError_remoteEndClosedConnection); + raiseError(KviError::RemoteEndClosedConnection); reset(); } //else transient error...wait again... } @@ -1816,7 +1816,7 @@ void KviIrcSocket::flushSendQueue() if(iResult == 0) { raiseSSLError(); - raiseError(KviError_remoteEndClosedConnection); + raiseError(KviError::RemoteEndClosedConnection); reset(); return; } else { @@ -1824,7 +1824,7 @@ void KviIrcSocket::flushSendQueue() if(iSSLErr != 0) { raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; } else { @@ -1834,12 +1834,12 @@ void KviIrcSocket::flushSendQueue() break; case KviSSL::SSLError: raiseSSLError(); - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; default: - raiseError(KviError_SSLError); + raiseError(KviError::SSLError); reset(); return; break; diff --git a/src/kvirc/kernel/KviIrcSocket.h b/src/kvirc/kernel/KviIrcSocket.h index 8adda5d98..e9e25f60d 100644 --- a/src/kvirc/kernel/KviIrcSocket.h +++ b/src/kvirc/kernel/KviIrcSocket.h @@ -35,6 +35,7 @@ #include "kvi_sockettype.h" #include "KviTimeUtils.h" #include "KviPointerList.h" +#include "KviError.h" #include <QObject> @@ -102,17 +103,17 @@ public: protected: unsigned int m_uId; KviIrcLink * m_pLink; - KviConsoleWindow * m_pConsole; + KviConsoleWindow * m_pConsole; kvi_socket_t m_sock; SocketState m_state; QSocketNotifier * m_pWsn; QSocketNotifier * m_pRsn; - KviIrcServer * m_pIrcServer; + KviIrcServer * m_pIrcServer; KviProxy * m_pProxy; QTimer * m_pTimeoutTimer; unsigned int m_uReadBytes; unsigned int m_uSentBytes; - int m_iLastError; + KviError::Code m_eLastError; unsigned int m_uSentPackets; KviIrcSocketMsgEntry * m_pSendQueueHead; KviIrcSocketMsgEntry * m_pSendQueueTail; @@ -145,7 +146,7 @@ public: * \brief Returns the last error * \return int */ - int lastError(){ return m_iLastError; }; + int lastError(){ return m_eLastError; }; /** * \brief Returns the id of the socket @@ -195,7 +196,7 @@ public: * \param pcBindAddress The address to bind the connection to * \return int */ - int startConnection(KviIrcServer * pServer, KviProxy * pProxy = 0, const char * pcBindAddress = 0); + KviError::Code startConnection(KviIrcServer * pServer, KviProxy * pProxy = 0, const char * pcBindAddress = 0); #ifdef COMPILE_SSL_SUPPORT /** @@ -268,7 +269,7 @@ protected: * \param iError The error to raise * \return void */ - void raiseError(int iError); + void raiseError(KviError::Code eError); /** * \brief Called when the connection has been estabilished diff --git a/src/modules/dcc/chat.cpp b/src/modules/dcc/chat.cpp index bac2496f3..a882c569f 100644 --- a/src/modules/dcc/chat.cpp +++ b/src/modules/dcc/chat.cpp @@ -37,7 +37,6 @@ #include "KviIrcView.h" #include "KviIconManager.h" #include "KviLocale.h" -#include "KviError.h" #include "kvi_out.h" #include "KviNetUtils.h" #include "KviConsoleWindow.h" @@ -160,20 +159,22 @@ void KviDccChat::startConnection() // PASSIVE CONNECTION output(KVI_OUT_DCCMSG,__tr2qs_ctx("Attempting a passive DCC %s connection","dcc"),m_pDescriptor->szType.toUtf8().data()); #ifdef COMPILE_SSL_SUPPORT - int ret = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); + KviError::Code eError = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); #else - int ret = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); + KviError::Code eError = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); #endif - if(ret != KviError_success)handleMarshalError(ret); + if(eError != KviError::Success) + handleMarshalError(eError); } else { // ACTIVE CONNECTION output(KVI_OUT_DCCMSG,__tr2qs_ctx("Attempting an active DCC %s connection","dcc"),m_pDescriptor->szType.toUtf8().data()); #ifdef COMPILE_SSL_SUPPORT - int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); + KviError::Code eError = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); #else - int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); + KviError::Code eError = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); #endif - if(ret != KviError_success)handleMarshalError(ret); + if(eError != KviError::Success) + handleMarshalError(eError); } } @@ -392,7 +393,8 @@ void KviDccChat::ownAction(const QString &text) QByteArray szData = encodeText(szTmpBuffer); const char * d = szData.data(); - if(!d)return; + if(!d) + return; KviCString buf(KviCString::Format,"%cACTION %s%c\r\n",0x01,d,0x01); m_pSlaveThread->sendRawData(buf.ptr(),buf.len()); output(KVI_OUT_ACTION,"%Q %Q",&(m_pDescriptor->szLocalNick),&szTmpBuffer); @@ -409,12 +411,12 @@ bool KviDccChat::event(QEvent *e) { case KVI_DCC_THREAD_EVENT_ERROR: { - int * err = ((KviThreadDataEvent<int> *)e)->getData(); - QString szErr = KviError::getDescription(*err); + KviError::Code * pError = ((KviThreadDataEvent<KviError::Code> *)e)->getData(); + QString szErr = KviError::getDescription(*pError); if(!KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnDCCChatError,this,szErr,m_pDescriptor->idString())) output(KVI_OUT_DCCERROR,__tr2qs_ctx("ERROR: %Q","dcc"),&szErr); KVS_TRIGGER_EVENT_1(KviEvent_OnDCCChatDisconnected,this,m_pDescriptor->idString()); - delete err; + delete pError; return true; } break; @@ -528,9 +530,9 @@ QSize KviDccChat::sizeHint() const return ret; } -void KviDccChat::handleMarshalError(int err) +void KviDccChat::handleMarshalError(KviError::Code eError) { - QString szErr = KviError::getDescription(err); + QString szErr = KviError::getDescription(eError); if(!KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnDCCChatError,this,szErr,m_pDescriptor->idString())) output(KVI_OUT_DCCERROR,__tr2qs_ctx("DCC %Q failed: %Q","dcc"),&(m_pDescriptor->szType),&szErr); } @@ -666,7 +668,7 @@ void KviDccChatThread::run() if(iE != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto out_of_the_loop; } } @@ -674,13 +676,13 @@ void KviDccChatThread::run() case KviSSL::SSLError: { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto out_of_the_loop; } break; default: // Raise unknown SSL ERROR - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto out_of_the_loop; break; } @@ -833,7 +835,7 @@ bool KviDccChatThread::tryFlushOutBuffers() if(sentLen == 0) { raiseSSLError(); - postErrorEvent(KviError_remoteEndClosedConnection); + postErrorEvent(KviError::RemoteEndClosedConnection); bRet = false; goto out_of_the_loop; } else { @@ -841,7 +843,7 @@ bool KviDccChatThread::tryFlushOutBuffers() if(iSSLErr != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); bRet = false; goto out_of_the_loop; } else { @@ -851,12 +853,12 @@ bool KviDccChatThread::tryFlushOutBuffers() break; case KviSSL::SSLError: raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); bRet = false; goto out_of_the_loop; break; default: - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); bRet = false; goto out_of_the_loop; break; diff --git a/src/modules/dcc/chat.h b/src/modules/dcc/chat.h index 09834d89a..dddf0a6ba 100644 --- a/src/modules/dcc/chat.h +++ b/src/modules/dcc/chat.h @@ -33,6 +33,7 @@ #include "KviThemedLabel.h" #include "KviCString.h" #include "KviWindow.h" +#include "KviError.h" #ifdef COMPILE_SSL_SUPPORT class KviSSL; @@ -94,7 +95,7 @@ protected: void startConnection(); virtual KviDccThread * getSlaveThread() { return m_pSlaveThread; }; protected slots: - void handleMarshalError(int err); + void handleMarshalError(KviError::Code eError); void connected(); void sslError(const char * msg); void connectionInProgress(); diff --git a/src/modules/dcc/marshal.cpp b/src/modules/dcc/marshal.cpp index b74b34008..b2bbda32f 100644 --- a/src/modules/dcc/marshal.cpp +++ b/src/modules/dcc/marshal.cpp @@ -26,7 +26,6 @@ #include "kvi_settings.h" #include "KviNetUtils.h" -#include "KviError.h" #include "KviOptions.h" #include "KviLocale.h" #include "KviMemory.h" @@ -105,9 +104,10 @@ void KviDccMarshal::reset() m_bIPv6 = false; } -int KviDccMarshal::dccListen(const QString &ip,const QString &port,bool bUseTimeout,bool bUseSSL) +KviError::Code KviDccMarshal::dccListen(const QString &ip,const QString &port,bool bUseTimeout,bool bUseSSL) { - if(m_fd != KVI_INVALID_SOCKET)return KviError_anotherConnectionInProgress; + if(m_fd != KVI_INVALID_SOCKET) + return KviError::AnotherConnectionInProgress; m_szIp = ip; m_szPort = port; @@ -125,11 +125,12 @@ int KviDccMarshal::dccListen(const QString &ip,const QString &port,bool bUseTime #ifdef COMPILE_SSL_SUPPORT m_bUseSSL = bUseSSL; #else - if(bUseSSL)return KviError_noSSLSupport; + if(bUseSSL) + return KviError::NoSSLSupport; #endif QTimer::singleShot(100, this, SLOT(doListen())); - return KviError_success; + return KviError::Success; } void KviDccMarshal::doListen() @@ -140,11 +141,11 @@ void KviDccMarshal::doListen() #ifdef COMPILE_IPV6_SUPPORT if(!KviNetUtils::isValidStringIPv6(m_szIp)) { - emit error(KviError_invalidIpAddress); + emit error(KviError::InvalidIpAddress); return; } else m_bIPv6 = true; #else - emit error(KviError_invalidIpAddress); + emit error(KviError::InvalidIpAddress); return; #endif } @@ -153,14 +154,14 @@ void KviDccMarshal::doListen() m_uPort = m_szPort.toUInt(&bOk); if(!bOk) { - emit error(KviError_invalidPortNumber); + emit error(KviError::InvalidPortNumber); return; } #ifndef COMPILE_IPV6_SUPPORT if(m_bIPv6) { - emit error(KviError_noIPv6Support); + emit error(KviError::NoIPv6Support); return; } #endif @@ -175,7 +176,7 @@ void KviDccMarshal::doListen() if(m_fd == KVI_INVALID_SOCKET) { - emit error(KviError_socketCreationFailed); + emit error(KviError::SocketCreationFailed); return; } @@ -190,14 +191,14 @@ void KviDccMarshal::doListen() if(!sa.socketAddress()) { reset(); - emit error(KviError_bindFailed); + emit error(KviError::BindFailed); return; } if(!kvi_socket_bind(m_fd,sa.socketAddress(),sa.addressLength())) { reset(); - emit error(KviError_bindFailed); + emit error(KviError::BindFailed); return; } @@ -214,7 +215,7 @@ void KviDccMarshal::doListen() if(!sa.socketAddress()) { reset(); - emit error(KviError_bindFailed); + emit error(KviError::BindFailed); return; } @@ -225,7 +226,7 @@ void KviDccMarshal::doListen() if(m_uPort == 65535) { reset(); - emit error(KviError_bindFailed); + emit error(KviError::BindFailed); return; } m_uPort++; @@ -236,7 +237,7 @@ void KviDccMarshal::doListen() if(!bBindSuccess) { reset(); - emit error(KviError_bindFailed); + emit error(KviError::BindFailed); return; } @@ -245,7 +246,7 @@ void KviDccMarshal::doListen() if(!kvi_socket_listen(m_fd,1)) { reset(); - emit error(KviError_listenFailed); + emit error(KviError::ListenFailed); return; } @@ -299,9 +300,10 @@ void KviDccMarshal::doListen() emit inProgress(); } -int KviDccMarshal::dccConnect(const char * ip,const char * port,bool bUseTimeout,bool bUseSSL) +KviError::Code KviDccMarshal::dccConnect(const char * ip,const char * port,bool bUseTimeout,bool bUseSSL) { - if(m_fd != KVI_INVALID_SOCKET)return KviError_anotherConnectionInProgress; + if(m_fd != KVI_INVALID_SOCKET) + return KviError::AnotherConnectionInProgress; m_bUseTimeout = bUseTimeout; m_szIp = ip; @@ -311,11 +313,12 @@ int KviDccMarshal::dccConnect(const char * ip,const char * port,bool bUseTimeout #ifdef COMPILE_SSL_SUPPORT m_bUseSSL = bUseSSL; #else - if(bUseSSL)return KviError_noSSLSupport; + if(bUseSSL) + return KviError::NoSSLSupport; #endif QTimer::singleShot(100, this, SLOT(doConnect())); - return KviError_success; + return KviError::Success; } void KviDccMarshal::doConnect() @@ -331,11 +334,11 @@ void KviDccMarshal::doConnect() #ifdef COMPILE_IPV6_SUPPORT if(!KviNetUtils::isValidStringIPv6(m_szIp)) { - emit error(KviError_invalidIpAddress); + emit error(KviError::InvalidIpAddress); return; } else m_bIPv6 = true; #else - emit error(KviError_invalidIpAddress); + emit error(KviError::InvalidIpAddress); return; #endif } @@ -344,7 +347,7 @@ void KviDccMarshal::doConnect() m_uPort = m_szPort.toUInt(&bOk); if(!bOk) { - emit error(KviError_invalidPortNumber); + emit error(KviError::InvalidPortNumber); return; } @@ -359,7 +362,7 @@ void KviDccMarshal::doConnect() #endif if(m_fd == KVI_INVALID_SOCKET) { - emit error(KviError_socketCreationFailed); + emit error(KviError::SocketCreationFailed); return; } @@ -367,7 +370,7 @@ void KviDccMarshal::doConnect() if(!kvi_socket_setNonBlocking(m_fd)) { reset(); - emit error(KviError_asyncSocketFailed); + emit error(KviError::AsyncSocketFailed); return; } @@ -383,7 +386,7 @@ void KviDccMarshal::doConnect() if(!sa.socketAddress()) { reset(); - emit error(KviError_socketCreationFailed); + emit error(KviError::SocketCreationFailed); return; } @@ -406,7 +409,7 @@ void KviDccMarshal::doConnect() reset(); // And declare problems :) if(sockError)emit error(KviError::translateSystemError(sockError)); - else emit error(KviError_unknownError); //Error 0 ? + else emit error(KviError::UnknownError); //Error 0 ? return; } } @@ -475,7 +478,7 @@ void KviDccMarshal::snActivated(int) { //failed if(sockError > 0)sockError = KviError::translateSystemError(sockError); - else sockError = KviError_unknownError; //Error 0 ? + else sockError = KviError::UnknownError; //Error 0 ? reset(); emit error(sockError); return; @@ -531,7 +534,7 @@ void KviDccMarshal::snActivated(int) if(!kvi_socket_setNonBlocking(m_fd)) { reset(); - emit error(KviError_asyncSocketFailed); + emit error(KviError::AsyncSocketFailed); return; } @@ -553,7 +556,7 @@ void KviDccMarshal::snActivated(int) doSSLHandshake(0); } else { reset(); - emit error(KviError_SSLError); + emit error(KviError::SSLError); } return; } @@ -576,7 +579,7 @@ void KviDccMarshal::doSSLHandshake(int) { qDebug("Ops... I've lost the SSL class ?"); reset(); - emit error(KviError_internalError); + emit error(KviError::InternalError); return; // ops ? } @@ -602,7 +605,7 @@ void KviDccMarshal::doSSLHandshake(int) break; case KviSSL::RemoteEndClosedConnection: reset(); - emit error(KviError_remoteEndClosedConnection); + emit error(KviError::RemoteEndClosedConnection); break; case KviSSL::SyscallError: { @@ -618,7 +621,7 @@ void KviDccMarshal::doSSLHandshake(int) } else { // Declare problems :) reset(); - emit error(err ? KviError::translateSystemError(err) : KviError_unknownError); + emit error(err ? KviError::translateSystemError(err) : KviError::UnknownError); } } break; @@ -627,7 +630,7 @@ void KviDccMarshal::doSSLHandshake(int) KviCString buffer; while(m_pSSL->getLastErrorString(buffer))emit sslError(buffer.ptr()); reset(); - emit error(KviError_SSLError); + emit error(KviError::SSLError); } break; } @@ -645,7 +648,7 @@ void KviDccMarshal::abort() void KviDccMarshal::connectionTimedOut() { reset(); - emit error(KviError_connectionTimedOut); + emit error(KviError::ConnectionTimedOut); } diff --git a/src/modules/dcc/marshal.h b/src/modules/dcc/marshal.h index cf0fd11af..aec02107e 100644 --- a/src/modules/dcc/marshal.h +++ b/src/modules/dcc/marshal.h @@ -25,6 +25,7 @@ //============================================================================= #include "KviCString.h" +#include "KviError.h" #include "kvi_sockettype.h" #include "kvi_inttypes.h" @@ -84,8 +85,8 @@ public: const QString & localPort() const { return m_bOutgoing ? m_szSecondaryPort : m_szPort; }; const QString & remoteIp() const { return m_bOutgoing ? m_szIp : m_szSecondaryIp; }; const QString & remotePort() const { return m_bOutgoing ? m_szPort : m_szSecondaryPort; }; - int dccListen(const QString &ip,const QString &port,bool bUseTimeout,bool bUseSSL = false); - int dccConnect(const char * ip,const char * port,bool bUseTimeout,bool bUseSSL = false); + KviError::Code dccListen(const QString &ip,const QString &port,bool bUseTimeout,bool bUseSSL = false); + KviError::Code dccConnect(const char * ip,const char * port,bool bUseTimeout,bool bUseSSL = false); kvi_socket_t releaseSocket(); #ifdef COMPILE_SSL_SUPPORT KviSSL * releaseSSL(); diff --git a/src/modules/dcc/send.cpp b/src/modules/dcc/send.cpp index 6d9ccbbef..b4c1f0cde 100644 --- a/src/modules/dcc/send.cpp +++ b/src/modules/dcc/send.cpp @@ -130,7 +130,7 @@ bool KviDccRecvThread::sendAck(int filePos) if(iRet != 4) { - postErrorEvent(KviError_acknowledgeError); + postErrorEvent(KviError::AcknowledgeError); return false; } return true; @@ -206,13 +206,13 @@ void KviDccRecvThread::run() { if(!m_pFile->open(QIODevice::WriteOnly | QIODevice::Append)) { - postErrorEvent(KviError_cantOpenFileForAppending); + postErrorEvent(KviError::CantOpenFileForAppending); goto exit_dcc; } // else pFile is already at end } else { if(!m_pFile->open(QIODevice::WriteOnly)) { - postErrorEvent(KviError_cantOpenFileForWriting); + postErrorEvent(KviError::CantOpenFileForWriting); goto exit_dcc; } } @@ -283,14 +283,14 @@ void KviDccRecvThread::run() if(readLen > 0) { if(m_pFile->write(buffer,readLen) != readLen) - postErrorEvent(KviError_fileIOError); + postErrorEvent(KviError::FileIOError); } break; } else { if(m_pFile->write(buffer,readLen) != readLen) { - postErrorEvent(KviError_fileIOError); + postErrorEvent(KviError::FileIOError); break; } } @@ -358,7 +358,7 @@ void KviDccRecvThread::run() if(iE != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } } @@ -366,13 +366,13 @@ void KviDccRecvThread::run() case KviSSL::SSLError: { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } break; default: // Raise unknown SSL ERROR - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; break; } @@ -568,13 +568,13 @@ void KviDccSendThread::run() if(!pFile->open(QIODevice::ReadOnly)) { - postErrorEvent(KviError_cantOpenFileForReading); + postErrorEvent(KviError::CantOpenFileForReading); goto exit_dcc; } if(pFile->size() < 1) { - postErrorEvent(KviError_cantSendAZeroSizeFile); + postErrorEvent(KviError::CantSendAZeroSizeFile); goto exit_dcc; } @@ -589,7 +589,7 @@ void KviDccSendThread::run() // seek if(!(pFile->seek(m_pOpt->uStartPosition))) { - postErrorEvent(KviError_fileIOError); + postErrorEvent(KviError::FileIOError); goto exit_dcc; } } @@ -645,7 +645,7 @@ void KviDccSendThread::run() if(iNewAck > pFile->pos()) { // the peer is drunk or is trying to fool us - postErrorEvent(KviError_acknowledgeError); + postErrorEvent(KviError::AcknowledgeError); break; } if(iNewAck < uLastAck) @@ -656,7 +656,7 @@ void KviDccSendThread::run() iAckHackRounds++; } else { // the peer is drunk or is trying to fool us - postErrorEvent(KviError_acknowledgeError); + postErrorEvent(KviError::AcknowledgeError); break; } } @@ -690,7 +690,7 @@ void KviDccSendThread::run() if(iE != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } } @@ -698,13 +698,13 @@ void KviDccSendThread::run() case KviSSL::SSLError: { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } break; default: // Raise unknown SSL ERROR - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; break; } @@ -773,7 +773,7 @@ void KviDccSendThread::run() if(iE != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } } @@ -781,13 +781,13 @@ void KviDccSendThread::run() case KviSSL::SSLError: { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } break; default: // Raise unknown SSL ERROR - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; break; } @@ -832,7 +832,7 @@ void KviDccSendThread::run() int readed = pFile->read(buffer,toRead); if(readed < toRead) { - postErrorEvent(KviError_fileIOError); + postErrorEvent(KviError::FileIOError); break; } // send it out @@ -867,14 +867,14 @@ void KviDccSendThread::run() if(written == 0) { raiseSSLError(); - postErrorEvent(KviError_remoteEndClosedConnection); + postErrorEvent(KviError::RemoteEndClosedConnection); goto exit_dcc; } else { int iSSLErr = m_pSSL->getLastError(true); if(iSSLErr != 0) { raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; } else { goto handle_system_error; @@ -883,11 +883,11 @@ void KviDccSendThread::run() break; case KviSSL::SSLError: raiseSSLError(); - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; break; default: - postErrorEvent(KviError_SSLError); + postErrorEvent(KviError::SSLError); goto exit_dcc; break; } @@ -1144,18 +1144,20 @@ void KviDccFileTransfer::listenOrConnect() if(!(m_pDescriptor->bActive)) { #ifdef COMPILE_SSL_SUPPORT - int ret = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); + KviError::Code eError = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); #else - int ret = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); + KviError::Code eError = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); #endif - if(ret != KviError_success)handleMarshalError(ret); + if(eError != KviError::Success) + handleMarshalError(eError); } else { #ifdef COMPILE_SSL_SUPPORT - int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); + KviError::Code eError = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout,m_pDescriptor->bIsSSL); #else - int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); + KviError::Code eError = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); #endif - if(ret != KviError_success)handleMarshalError(ret); + if(eError != KviError::Success) + handleMarshalError(eError); } displayUpdate(); @@ -1168,7 +1170,7 @@ void KviDccFileTransfer::resumeTimedOut() delete m_pResumeTimer; m_pResumeTimer = 0; } - handleMarshalError(KviError_connectionTimedOut); + handleMarshalError(KviError::ConnectionTimedOut); } KviWindow * KviDccFileTransfer::dccMarshalOutputWindow() @@ -1869,9 +1871,9 @@ bool KviDccFileTransfer::event(QEvent *e) { case KVI_DCC_THREAD_EVENT_ERROR: { - int * err = ((KviThreadDataEvent<int> *)e)->getData(); - QString szErrorString = KviError::getDescription(*err); - delete err; + KviError::Code * pError = ((KviThreadDataEvent<KviError::Code> *)e)->getData(); + QString szErrorString = KviError::getDescription(*pError); + delete pError; if(m_pDescriptor->bRecvFile) g_pApp->fileDownloadTerminated(false,m_pDescriptor->szFileName.toUtf8().data(),m_pDescriptor->szLocalFileName.toUtf8().data(),m_pDescriptor->szNick.toUtf8().data(),szErrorString.toUtf8().data()); @@ -1950,9 +1952,9 @@ bool KviDccFileTransfer::event(QEvent *e) return KviFileTransfer::event(e); } -void KviDccFileTransfer::handleMarshalError(int err) +void KviDccFileTransfer::handleMarshalError(KviError::Code eError) { - QString szErr = KviError::getDescription(err); + QString szErr = KviError::getDescription(eError); m_eGeneralStatus = Failure; m_szStatusString = __tr2qs_ctx("Transfer failed: ","dcc"); m_szStatusString += szErr; @@ -2057,7 +2059,7 @@ bool KviDccFileTransfer::resumeAccepted(const char *filename,const char *port,co int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(), m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); - if(ret != KviError_success)handleMarshalError(ret); + if(ret != KviError::Success)handleMarshalError(ret); else { m_szStatusString = __tr2qs_ctx("Contacting host %1 on port %2","dcc").arg(m_pDescriptor->szIp, m_pDescriptor->szPort); outputAndLog(m_szStatusString); diff --git a/src/modules/dcc/send.h b/src/modules/dcc/send.h index 6fd393a39..b4f5eb467 100644 --- a/src/modules/dcc/send.h +++ b/src/modules/dcc/send.h @@ -241,7 +241,7 @@ protected slots: void connectionInProgress(); void sslError(const char * msg); void startingSSLHandshake(); - void handleMarshalError(int err); + void handleMarshalError(KviError::Code); void connected(); void bandwidthDialogDestroyed(); void configureBandwidth(); diff --git a/src/modules/dcc/thread.cpp b/src/modules/dcc/thread.cpp index 3d7f38983..9930866df 100644 --- a/src/modules/dcc/thread.cpp +++ b/src/modules/dcc/thread.cpp @@ -73,7 +73,7 @@ bool KviDccThread::handleInvalidSocketRead(int readLen) if(readLen == 0) { // connection closed - postErrorEvent(KviError_remoteEndClosedConnection); + postErrorEvent(KviError::RemoteEndClosedConnection); return false; } else { // error ? diff --git a/src/modules/dcc/voice.cpp b/src/modules/dcc/voice.cpp index a85d9b85b..d78cdfa0a 100644 --- a/src/modules/dcc/voice.cpp +++ b/src/modules/dcc/voice.cpp @@ -33,7 +33,6 @@ #include "KviIrcView.h" #include "KviLocale.h" #include "kvi_out.h" -#include "KviError.h" #include "KviNetUtils.h" #include "KviOptions.h" #include "KviConsoleWindow.h" @@ -738,13 +737,15 @@ void KviDccVoice::startConnection() { // PASSIVE CONNECTION output(KVI_OUT_DCCMSG,__tr2qs_ctx("Attempting a passive DCC VOICE connection","dcc")); - int ret = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); - if(ret != KviError_success)handleMarshalError(ret); + KviError::Code eError = m_pMarshal->dccListen(m_pDescriptor->szListenIp,m_pDescriptor->szListenPort,m_pDescriptor->bDoTimeout); + if(eError != KviError::Success) + handleMarshalError(eError); } else { // ACTIVE CONNECTION output(KVI_OUT_DCCMSG,__tr2qs_ctx("Attempting an active DCC VOICE connection","dcc")); - int ret = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); - if(ret != KviError_success)handleMarshalError(ret); + KviError::Code eError = m_pMarshal->dccConnect(m_pDescriptor->szIp.toUtf8().data(),m_pDescriptor->szPort.toUtf8().data(),m_pDescriptor->bDoTimeout); + if(eError != KviError::Success) + handleMarshalError(eError); } } @@ -813,10 +814,10 @@ bool KviDccVoice::event(QEvent *e) { case KVI_DCC_THREAD_EVENT_ERROR: { - int * err = ((KviThreadDataEvent<int> *)e)->getData(); - QString ssss = KviError::getDescription(*err); + KviError::Code * pError = ((KviThreadDataEvent<KviError::Code> *)e)->getData(); + QString ssss = KviError::getDescription(*pError); output(KVI_OUT_DCCERROR,__tr2qs_ctx("ERROR: %Q","dcc"),&(ssss)); - delete err; + delete pError; m_pUpdateTimer->stop(); updateInfo(); m_pTalkButton->setEnabled(false); @@ -895,9 +896,9 @@ QSize KviDccVoice::sizeHint() const return ret; } -void KviDccVoice::handleMarshalError(int err) +void KviDccVoice::handleMarshalError(KviError::Code eError) { - QString ssss = KviError::getDescription(err); + QString ssss = KviError::getDescription(eError); output(KVI_OUT_DCCERROR,__tr2qs_ctx("DCC Failed: %Q","dcc"),&ssss); m_pTalkButton->setEnabled(false); m_pTalkButton->setChecked(false); diff --git a/src/modules/dcc/voice.h b/src/modules/dcc/voice.h index 001a2a718..5f6ec6bff 100644 --- a/src/modules/dcc/voice.h +++ b/src/modules/dcc/voice.h @@ -33,6 +33,7 @@ #include "KviDataBuffer.h" #include "kvi_sockettype.h" #include "KviTalHBox.h" +#include "KviError.h" #include <QLabel> #include <QToolButton> @@ -133,7 +134,7 @@ protected: void startConnection(); int getMixerVolume(void) const; protected slots: - void handleMarshalError(int err); + void handleMarshalError(KviError::Code eError); void connected(); void updateInfo(); void startOrStopTalking(bool bStart); diff --git a/src/modules/objects/class_socket.cpp b/src/modules/objects/class_socket.cpp index 78c22aa38..9195f044e 100644 --- a/src/modules/objects/class_socket.cpp +++ b/src/modules/objects/class_socket.cpp @@ -1057,11 +1057,14 @@ void KviKvsObject_socket::writeNotifierFired(int) { //qDebug("Failed here %d",sockError); //failed - if(sockError > 0)sockError = KviError::translateSystemError(sockError); - else sockError = KviError_unknownError; //Error 0 ? + KviError::Code eError; + if(sockError > 0) + eError = KviError::translateSystemError(sockError); + else + eError = KviError::UnknownError; //Error 0 ? unsigned int uOldConnectionId = m_uConnectionId; KviKvsVariantList lParams; - lParams.append(new KviKvsVariant(KviError::getDescription(sockError))); + lParams.append(new KviKvsVariant(KviError::getDescription(eError))); callFunction(this,"connectFailedEvent",&lParams); if(m_uConnectionId == uOldConnectionId)reset(); // else it has already been called! @@ -1126,7 +1129,6 @@ void KviKvsObject_socket::readNotifierFired(int) { unsigned int uOldConnectionId = m_uConnectionId; if(err > 0) - { // QString error=KviError::translateSystemError(err); KviKvsVariantList lParams; @@ -1134,7 +1136,7 @@ void KviKvsObject_socket::readNotifierFired(int) callFunction(this,"disconnectEvent",&lParams); } else { KviKvsVariantList lParams; - lParams.append(new KviKvsVariant(KviError::getDescription(KviError_remoteEndClosedConnection))); + lParams.append(new KviKvsVariant(KviError::getDescription(KviError::RemoteEndClosedConnection))); callFunction(this,"disconnectEvent",&lParams); } |
