From 57268e4f932e3a013bcb7d7f4280e8049c112a4c Mon Sep 17 00:00:00 2001 From: Lorenzo Fiorini Date: Thu, 24 Apr 2008 10:58:26 +0000 Subject: [PATCH] --- harbour/ChangeLog | 10 ++++ harbour/contrib/hbgd/gdimage.prg | 5 +- harbour/contrib/hbtip/sendmail.prg | 89 +++++++++++++++++++----------- harbour/contrib/hbtip/smtpcln.prg | 4 +- 4 files changed, 69 insertions(+), 39 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 93c37522f6..2014d0e09c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-04-24 13:00 UTC+0100 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com) + * contrib/hbgd/gdimage.prg + * removed two method that simply call public function + * renamed GetTrueColorPixel back to GetTrueColor + * contrib/hbtip/sendmail.prg + * contrib/hbtip/smtpcln.prg + * added support for smtp with authentication + * added timeout parameter + * borrowed from xHarbour + 2008-04-24 11:03 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/rtl/achoice.prg ! Fixed to abort (rather than crash), when user callback diff --git a/harbour/contrib/hbgd/gdimage.prg b/harbour/contrib/hbgd/gdimage.prg index 14ba85f8df..8ca08fe8f8 100644 --- a/harbour/contrib/hbgd/gdimage.prg +++ b/harbour/contrib/hbgd/gdimage.prg @@ -214,7 +214,7 @@ CLASS GDImage METHOD CreatePaletteFromTrueColor( lDither, nColorsWanted ) ; INLINE gdImageCreatePaletteFromTrueColor( ::pImage, lDither, nColorsWanted ) METHOD GetPalette( x, y ) INLINE gdImagePalettePixel( ::pImage, x, y ) - METHOD GetTrueColorPixel( x, y ) INLINE gdImageTrueColorPixel( ::pImage, x, y ) + METHOD GetTrueColor( x, y ) INLINE gdImageTrueColorPixel( ::pImage, x, y ) METHOD GetThickness() INLINE gdImageGetThickness( ::pImage ) /* FONTS AND TEXT-HANDLING FUNCTIONS */ @@ -268,9 +268,6 @@ CLASS GDImage METHOD SetInterlaceOn() INLINE gdImageInterlace( ::pImage, TRUE ) METHOD SetInterlaceOff() INLINE gdImageInterlace( ::pImage, FALSE ) - METHOD GetTrueColor( r, g, b ) INLINE gdTrueColor( r, g, b ) - METHOD GetTrueColorAlpha( r, g, b, a ) INLINE gdTrueColorAlpha( r, g, b, a ) - /* COPY AND RESIZING FUNCTIONS */ METHOD Copy() METHOD CopyResized() diff --git a/harbour/contrib/hbtip/sendmail.prg b/harbour/contrib/hbtip/sendmail.prg index 3991400bd5..a92a11d654 100644 --- a/harbour/contrib/hbtip/sendmail.prg +++ b/harbour/contrib/hbtip/sendmail.prg @@ -58,8 +58,7 @@ #translate ( LIKE ) => ( HB_REGEXLIKE( (), () ) ) -FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, lTrace, lPopAuth) - +FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, lTrace, lPopAuth, lNoAuth, nTimeOut) /* cServer -> Required. IP or domain name of the mail server nPort -> Optional. Port used my email server @@ -76,6 +75,8 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF nPriority -> Optional. Email priority: 1=High, 3=Normal (Standard), 5=Low lRead -> Optional. If set to .T., a confirmation request is send. Standard setting is .F. lTrace -> Optional. If set to .T., a log file is created (sendmail.log). Standard setting is .F. + lNoAuth -> Optional. Disable Autentication methods + nTimeOut -> Optional. Number os ms to wait default 20000 (20s) */ LOCAL oInMail, cBodyTemp, oUrl, oMail, oAttach, aThisFile, cFile, cFname, cFext, cData, oUrl1 @@ -91,8 +92,7 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF LOCAL lAuthLogin := .F. LOCAL lAuthPlain := .F. LOCAL lConnect := .T. - local oPop - + LOCAL oPop DEFAULT cUser TO "" DEFAULT cPass TO "" DEFAULT nPort TO 25 @@ -101,6 +101,8 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF DEFAULT lRead TO .F. DEFAULT lTrace TO .F. DEFAULT lPopAuth to .T. + DEFAULT lNoAuth TO .F. + DEFAULT nTimeOut to 100 cUser := StrTran( cUser, "@", "&at;" ) @@ -185,7 +187,7 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF ENDIF oUrl:nPort := nPort - oUrl:cUserid := cUser + oUrl:cUserid := Strtran( cUser, "&at;", "@" ) oMail := tipMail():new() oAttach := tipMail():new() @@ -195,7 +197,8 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF cMimeText := "text/html ; charset=ISO-8859-1" oAttach:hHeaders[ "Content-Type" ] := cMimeText cBodyTemp := cBody - cBody := MemoRead( cBodyTemp ) + cBody := MemoRead( cBodyTemp ) + chr( 13 ) + chr( 10 ) + ELSE oMail:hHeaders[ "Content-Type" ] := "text/plain; charset=iso8851" ENDIF @@ -206,6 +209,7 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF oMail:hHeaders[ "Date" ] := tip_Timestamp() oMail:hHeaders[ "From" ] := cFrom + IF !Empty(cCC) oMail:hHeaders[ "Cc" ] := cCC ENDIF @@ -223,49 +227,68 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF RETURN .F. ENDIF - oInmail:nConnTimeout:=20000 + oInmail:nConnTimeout:= nTimeOut - IF oInMail:Opensecure() + IF !lNoAuth - WHILE .T. - oInMail:GetOk() - IF oInMail:cReply == NIL - EXIT - ELSEIF "LOGIN" $ oInMail:cReply - lAuthLogin := .T. - ELSEIF "PLAIN" $ oInMail:cReply - lAuthPlain := .T. + IF oInMail:Opensecure() + + WHILE .T. + oInMail:GetOk() + IF oInMail:cReply == NIL + EXIT + ELSEIF "LOGIN" $ oInMail:cReply + lAuthLogin := .T. + ELSEIF "PLAIN" $ oInMail:cReply + lAuthPlain := .T. + ENDIF + ENDDO + + IF lAuthLogin + IF !oInMail:Auth( cUser, cPass ) + lConnect := .F. + ELSE + lConnectPlain := .T. + ENDIF ENDIF - ENDDO - IF lAuthLogin - IF !oInMail:Auth( cUser, cPass ) - lConnect := .F. + IF lAuthPlain .AND. !lConnect + IF !oInMail:AuthPlain( cUser, cPass ) + lConnect := .F. + ENDIF ELSE - lConnectPlain := .T. + IF !lConnectPlain + oInmail:Getok() + lConnect := .F. + ENDIF ENDIF - ENDIF - IF lAuthPlain .AND. !lConnect - IF !oInMail:AuthPlain( cUser, cPass ) - lConnect := .F. - ENDIF ELSE - IF !lConnectPlain - oInmail:Getok() - lConnect := .F. - ENDIF + + lConnect := .F. + ENDIF ELSE - lConnect := .F. + lConnect := .F. ENDIF IF !lConnect + if !lNoAuth oInMail:Close() + endif + + BEGIN SEQUENCE + oInmail := tIPClientsmtp():New( oUrl, lTrace) + RECOVER + lReturn := .F. + END + + oInmail:nConnTimeout:=nTimeOut + IF !oInMail:Open() lConnect := .F. @@ -290,10 +313,10 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF IF Valtype( aThisFile ) == "C" cFile := aThisFile - cData := Memoread( cFile ) + cData := Memoread( cFile ) + chr( 13 ) + chr( 10 ) ELSEIF Valtype( aThisFile ) == "A" .AND. Len( aThisFile ) >= 2 cFile := aThisFile[ 1 ] - cData := aThisFile[ 2 ] + cData := aThisFile[ 2 ] + chr( 13 ) + chr( 10 ) ELSE lReturn := .F. EXIT diff --git a/harbour/contrib/hbtip/smtpcln.prg b/harbour/contrib/hbtip/smtpcln.prg index 92d7a9edf1..bc230f349c 100644 --- a/harbour/contrib/hbtip/smtpcln.prg +++ b/harbour/contrib/hbtip/smtpcln.prg @@ -98,10 +98,10 @@ local n:=1 if !file("sendmail.log") ::nHandle := fcreate("sendmail.log") else - while file(cFile+alltrim(str(n,2))+".log") + while file(cFile+alltrim(str(n,4))+".log") n++ enddo - ::nHandle := fcreate(cFile+alltrim(str(n,2))+".log") + ::nHandle := fcreate(cFile+alltrim(str(n,4))+".log") endif endif RETURN Self