From f090e652cdc952e9e967554c508905f6c17c7625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Fri, 13 Mar 2015 18:56:10 +0100 Subject: [PATCH] =?UTF-8?q?2015-03-13=2018:56=20UTC+0100=20Przemyslaw=20Cz?= =?UTF-8?q?erpak=20(druzus/at/poczta.onet.pl)=20=20=20*=20contrib/hbwin/wi?= =?UTF-8?q?n=5Fbmp.c=20=20=20=20=20!=20fixed=20copy=20and=20past=20typo=20?= =?UTF-8?q?in=20my=20last=20modification=20-=20thanks=20to=20=20=20=20=20?= =?UTF-8?q?=20=20Juan=20Francolino=20for=20reporting=20the=20problem=20and?= =?UTF-8?q?=20to=20Alexander=20=20=20=20=20=20=20Czjczy=C5=84ski=20for=20l?= =?UTF-8?q?ocating=20the=20reason.=20It=20closes=20issue=20#91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * contrib/hbtip/smtpcli.prg * be sure that server answer after HELO command (:open() method) is fully consumed * contrib/hbtip/sendmail.prg ! removed redundant waiting for sever answer after opening connection without authentication - it fixes timeout delay in such case ! do not create TIPClientSMTP() object twice when it's not necessary % small code simplification --- ChangeLog.txt | 16 ++++++++++++ contrib/hbtip/sendmail.prg | 51 ++++++++++++++------------------------ contrib/hbtip/smtpcli.prg | 11 +++++++- contrib/hbwin/win_bmp.c | 2 +- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e1006e6671..6407f66126 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-03-13 18:56 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbwin/win_bmp.c + ! fixed copy and past typo in my last modification - thanks to + Juan Francolino for reporting the problem and to Alexander + CzjczyƄski for locating the reason. It closes issue #91. + + * contrib/hbtip/smtpcli.prg + * be sure that server answer after HELO command (:open() method) is + fully consumed + + * contrib/hbtip/sendmail.prg + ! removed redundant waiting for sever answer after opening connection + without authentication - it fixes timeout delay in such case + ! do not create TIPClientSMTP() object twice when it's not necessary + % small code simplification + 2015-03-12 09:41 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbtip/sendmail.prg ! fixed wrong login conditions - AICS it's old problem which had existed diff --git a/contrib/hbtip/sendmail.prg b/contrib/hbtip/sendmail.prg index 3e8c217b4a..48be7d710e 100644 --- a/contrib/hbtip/sendmail.prg +++ b/contrib/hbtip/sendmail.prg @@ -94,7 +94,7 @@ FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ; LOCAL oUrl1 LOCAL lAuthTLS := .F. - LOCAL lConnect := .T. + LOCAL lConnect := .F. LOCAL oPop /* consider any empty values invalid */ @@ -210,48 +210,33 @@ FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ; oInmail:nConnTimeout := nTimeOut - IF ! lNoAuth .AND. oInMail:OpenSecure( , lSSL ) + IF ! lNoAuth + IF oInMail:OpenSecure( , lSSL ) - lAuthTLS := oInMail:lTLS + lAuthTLS := oInMail:lTLS - IF ! ( oInMail:lAuthLogin .AND. oInMail:Auth( cUser, cSMTPPass ) ) .AND. ; - ! ( oInMail:lAuthPlain .AND. oInMail:AuthPlain( cUser, cSMTPPass ) ) - lConnect := .F. + IF ( oInMail:lAuthLogin .AND. oInMail:Auth( cUser, cSMTPPass ) ) .OR. ; + ( oInMail:lAuthPlain .AND. oInMail:AuthPlain( cUser, cSMTPPass ) ) + lConnect := .T. + ENDIF + ENDIF + IF ! lConnect + oInMail:Close() + BEGIN SEQUENCE WITH __BreakBlock() + oInmail := TIPClientSMTP():New( oUrl, xTrace,, cClientHost ) + RECOVER + RETURN .F. + END SEQUENCE + + oInmail:nConnTimeout := nTimeOut ENDIF - ELSE - lConnect := .F. ENDIF IF ! lConnect - - IF ! lNoAuth - oInMail:Close() - ENDIF - - BEGIN SEQUENCE WITH __BreakBlock() - oInmail := TIPClientSMTP():New( oUrl, xTrace,, cClientHost ) - RECOVER - RETURN .F. - END SEQUENCE - - oInmail:nConnTimeout := nTimeOut - IF ! oInMail:Open( NIL, lAuthTLS ) oInmail:Close() RETURN .F. ENDIF - - DO WHILE .T. - IF ! oInMail:GetOk() - EXIT - ENDIF - IF oInMail:cReply == NIL - EXIT - ENDIF - IF hb_LeftEq( oInMail:cReply, "250 " ) - EXIT - ENDIF - ENDDO ENDIF oInMail:oUrl:cUserid := tip_GetRawEmail( cFrom ) diff --git a/contrib/hbtip/smtpcli.prg b/contrib/hbtip/smtpcli.prg index 514f0d8f84..c9c51e4174 100644 --- a/contrib/hbtip/smtpcli.prg +++ b/contrib/hbtip/smtpcli.prg @@ -104,6 +104,8 @@ METHOD New( oUrl, xTrace, oCredentials, cClientHost ) CLASS TIPClientSMTP METHOD Open( cUrl, lSSL ) CLASS TIPClientSMTP + LOCAL lOk + IF ! ::super:Open( cUrl ) RETURN .F. ENDIF @@ -120,7 +122,14 @@ METHOD Open( cUrl, lSSL ) CLASS TIPClientSMTP ::inetSendAll( ::SocketCon, "HELO " + iif( Empty( ::cClientHost ), "TIPClientSMTP", ::cClientHost ) + ::cCRLF ) - RETURN ::GetOk() + DO WHILE .T. + IF !( lOk := ::GetOk() ) .OR. ::cReply == NIL .OR. ; + hb_LeftEq( ::cReply, "250 " ) + EXIT + ENDIF + ENDDO + + RETURN lOk METHOD OpenSecure( cUrl, lSSL ) CLASS TIPClientSMTP diff --git a/contrib/hbwin/win_bmp.c b/contrib/hbwin/win_bmp.c index 6e8c906d5b..53190d10fe 100644 --- a/contrib/hbwin/win_bmp.c +++ b/contrib/hbwin/win_bmp.c @@ -105,7 +105,7 @@ HB_FUNC( WIN_LOADBITMAPFILE ) [vszakats] */ if( nSize > 2 && nSize <= HB_MAX_BMP_SIZE ) { - char * pBuffer = ( char * ) hb_xgrab( nSize + 1 ); + pBuffer = ( char * ) hb_xgrab( nSize + 1 ); if( hb_fileReadAt( pFile, pBuffer, nSize, 0 ) != nSize || hbwin_bitmapType( pBuffer, nSize ) == HB_WIN_BITMAP_UNKNOWN )