Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2008-01-18 Thread Arno Garrels
DZ-Jay wrote:
> Can you post some code so that we know how you tried to fix it?

The bug I found is the "Special processing for Quit" below.

procedure TCustomPop3Cli.TriggerRequestDone(Error: Word);
begin
==> (*  
{ Special processing for Quit (Roger Morton 24-12-99) }
if FRequestType = pop3Quit then begin
if FWaitingOnQuit then
{ When the second RqDone arrives (from WSocketSessionClosed),   }
{ treat it as a normal event by setting a zero Error code   }
Error := 0
else begin
{ When the first RqDone arrives, set the FWaitingOnQuit flag so }
{ we're ready to handle a second RqDone.}
{ Take no other action (in particular, we don't advise the user }
{ that the first RqDone has happened)   }
FWaitingOnQuit := True;
Exit;
end;
{ Fall down here for all normal RqDone, and after the second RqDone }
{ following a Quit  }
FWaitingOnQuit := False;
end;
==> *)

This code prevents that RequestDone fires in case the server doesn't
send a response to the Quit command, and thus the Pop3State is never reset
properly.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html





-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2008-01-18 Thread DZ-Jay

On Jan 17, 2008, at 07:34, [EMAIL PROTECTED] wrote:

> it didnt fix the issue, got a pop3 not ready exception today.

Can you post some code so that we know how you tried to fix it?

dZ.

-- 
DZ-Jay [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2008-01-17 Thread Arno Garrels
[EMAIL PROTECTED] wrote:
> AG> It helps alot to post a short message when you either think
> AG> the problem is resolved or not. Thanks.
> 
> it didnt fix the issue, got a pop3 not ready exception today.

You did not provide any further information, "not ready exceptions"
may happen, i.e. due to incorrect component use. So I'm helpless.
I use TPop3Cli in an NT service application that checks for and
downloads mails in intervals since several years now w/o any problem.
However I'm starting a new session by calling Abort (to work around
the bug I mentioned), this works very reliable though it's not nice.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


> 
> 
> 
> AG> --
> AG> Arno Garrels [TeamICS]
> AG> http://www.overbyte.be/eng/overbyte/teamics.html
> 
> 
> 
>>> 
>>> i also hope that the bug gets eliminated in the next release by
>>> FPIETTE.
>>> i don't really like using custom-patched components.
> 
> 
> 
> --
> Mit freundlichen Grüßen
> [EMAIL PROTECTED]
> mailto:[EMAIL PROTECTED]
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2008-01-17 Thread retnyg

AG> It helps alot to post a short message when you either think
AG> the problem is resolved or not. Thanks.

it didnt fix the issue, got a pop3 not ready exception today.



AG> --
AG> Arno Garrels [TeamICS]
AG> http://www.overbyte.be/eng/overbyte/teamics.html



>> 
>> i also hope that the bug gets eliminated in the next release by
>> FPIETTE.
>> i don't really like using custom-patched components.



-- 
Mit freundlichen Grüßen
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2007-12-12 Thread Arno Garrels
[EMAIL PROTECTED] wrote:
> thanks arno and dz-jay, i hope that'll fix it.

It helps alot to post a short message when you either think
the problem is resolved or not. Thanks.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html



> 
> i also hope that the bug gets eliminated in the next release by
> FPIETTE.
> i don't really like using custom-patched components.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2007-12-12 Thread retnyg
thanks arno and dz-jay, i hope that'll fix it.

i also hope that the bug gets eliminated in the next release by
FPIETTE.
i don't really like using custom-patched components.

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready - Bug in TPop3Cli

2007-12-12 Thread Arno Garrels
[EMAIL PROTECTED] wrote:

> as you see, the pop component is not connected when i do the connect
> cmd. that's the strange thing, the connection is closed but the
> component is not in a ready state.

Sorry, now I recall that there is a BUG in the component since a long
time!! I fighted for getting this fixed, however the bug is still present.
 
What happens in your case is that GMX doesn't send a response to the
QUIT command but closes the connection at once. 

The bug is the "Special processing for Quit" below, comment that out
and rebuild all. 

procedure TCustomPop3Cli.TriggerRequestDone(Error: Word);
begin
==> (*  
{ Special processing for Quit (Roger Morton 24-12-99) }
if FRequestType = pop3Quit then begin
if FWaitingOnQuit then
{ When the second RqDone arrives (from WSocketSessionClosed),   }
{ treat it as a normal event by setting a zero Error code   }
Error := 0
else begin
{ When the first RqDone arrives, set the FWaitingOnQuit flag so }
{ we're ready to handle a second RqDone.}
{ Take no other action (in particular, we don't advise the user }
{ that the first RqDone has happened)   }
FWaitingOnQuit := True;
Exit;
end;
{ Fall down here for all normal RqDone, and after the second RqDone }
{ following a Quit  }
FWaitingOnQuit := False;
end;
==> *)

This code prevents that RequestDone fires in case the server doesn't
send a response on the Quit command, and thus the Pop3State is never reset
properly.  

After you outcommented this code try the little test program below, don't
run it w/o a break point since it would reconnect in a loop infinitely.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Pop3Prot, StdCtrls;

const
  WM_RECONNECT = WM_USER + 1;

type
  TForm1 = class(TForm)
Button1: TButton;
Pop3Cli1: TPop3Cli;
procedure Pop3Cli1RequestDone(Sender: TObject; RqType: TPop3Request;
  Error: Word);
procedure Button1Click(Sender: TObject);
  protected
procedure WmReconnect(var Msg: TMessage); Message WM_RECONNECT;
  public
{ Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Pop3Cli1.Connect;
end;

procedure TForm1.WmReconnect(var Msg: TMessage);
begin
Pop3Cli1.Connect;
end;

procedure TForm1.Pop3Cli1RequestDone(Sender: TObject; RqType: TPop3Request;
  Error: Word);
begin
case RqType of
pop3Connect : 
if (Error = 0) then
TPop3Cli(Sender).Quit;

pop3Quit :
begin
{ Regardless of Error or not Error }
if TPop3Cli(Sender).Connected then
TPop3Cli(Sender).Abort // No problem here since the server 
sent the response
else // Post a custom message if you want to reconnect
PostMessage(Handle, WM_RECONNECT, 0, 0);
end;
end;
end;

end.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html




> 
> 
> 
> AG> [EMAIL PROTECTED] wrote:
>>> procedure TMailAlert.Pop3ClientRequestDone;
>>> begin
>>>   if (FPop.connected) and (CheckError) then begin
>>> FPop.quit;
>>> exit;
>>>   end;
>>> 
>>> ...
>>> 
>>> what could be the cause that the component is not ready after the
>>> error ?
> 
> AG> After sending command Quit you should receive a server response.
> AG> When it's received you may either close or abort the connection
> AG> yourself or wait until the server drops the connection.
> AG> Anyway start next connection attempt only when you are not
> connected, 
> AG> means after SessionClosed fired.
> 
> AG> --
> AG> Arno Garrels
> 
> 
> 
> 
> --
> Mit freundlichen Grüßen
> [EMAIL PROTECTED]
> mailto:[EMAIL PROTECTED]
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-12 Thread [EMAIL PROTECTED]
Hello:
   If I understand correctly, you send the Quit()
command after a failure and then try CheckNewMail()
again?  You must wait for the Quit() command to
complete, it will trigger OnRequestDone with an error
code.  You should try something like this instead:

(Mind you, this is out of the top of my head, so I
can't guarantee it will compile or that its the best
way; it is just intended to offer an idea on how to
handle the errors.)

Procedure TMailAlert.Pop3ClientRequestDone;
Begin
  // NOTE:
  // ErrorCode and ReqType are params
  // of the OnRequestDone event.

  // No error, send the next cmd.
  If (ErrorCode <> 0) Then Begin
Case ReqType Of
  pop3Connect : FPop.User;
  pop3User: FPop.Pass;
  pop3Pass: FPop.Uidl;
  // ...
End;

  // There was an error, try to
  // fail gracefully.
  End Else Begin
// If the failure was during Quit,
// we need to abort to reset the
// component.
If (ReqType = pop3Quit) Then
  FPop.Abort

// Otherwise, quit gracefully if
// still connected.
Else If (FPop.Connected) Then
  FPop.Quit;
  End;
End;




>--- Original Message ---
>From: [EMAIL PROTECTED]:[EMAIL PROTECTED]
>Sent: 12/12/2007 12:21:45 PM
>To  : twsocket@elists.org
>Cc      : 
>Subject : RE: Re: [twsocket] pop3 component not ready
>
 >procedure TMailAlert.CheckNewMail;
begin
   with FPop do
   if not Connected then
   begin
 Fbusy := true;
 ClearErrorMessage;
 Connect;
   end;
end;

as you see, the pop component is not connected when i
do the connect
cmd. that's the strange thing, the connection is
closed but the
component is not in a ready state.


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-12 Thread retnyg
procedure TMailAlert.CheckNewMail;
begin
   with FPop do
   if not Connected then
   begin
 Fbusy := true;
 ClearErrorMessage;
 Connect;
   end;
end;

as you see, the pop component is not connected when i do the connect
cmd. that's the strange thing, the connection is closed but the
component is not in a ready state.



AG> [EMAIL PROTECTED] wrote:
>> procedure TMailAlert.Pop3ClientRequestDone;
>> begin
>>   if (FPop.connected) and (CheckError) then begin
>> FPop.quit;
>> exit;
>>   end;
>> 
>> ...
>> 
>> what could be the cause that the component is not ready after the
>> error ?

AG> After sending command Quit you should receive a server response.
AG> When it's received you may either close or abort the connection 
AG> yourself or wait until the server drops the connection.
AG> Anyway start next connection attempt only when you are not connected,
AG> means after SessionClosed fired.

AG> --
AG> Arno Garrels 




-- 
Mit freundlichen Grüßen
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-12 Thread Dod
When doing POP3 you must send a QUIT command to server or all email
marked for deletion (DELE command) will not be deleted.

>> whats the proper command to close the connection
dcn> gracefully ?

dcn> The command is "Quit".  On a pinch, you could use
dcn> "Abort", which will close the socket connection
dcn> abruptly if it is opened, but "Quit" will send the
dcn> "QUIT" POP3 command to the server and wait for it to
dcn> close the connection.

dcn> -dZ.

dcn> -- 
dcn> DZ-Jay - [TeamICS]
dcn> http://www.overbyte.be/eng/overbyte/teamics.html

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-12 Thread [EMAIL PROTECTED]
> whats the proper command to close the connection
gracefully ?

The command is "Quit".  On a pinch, you could use
"Abort", which will close the socket connection
abruptly if it is opened, but "Quit" will send the
"QUIT" POP3 command to the server and wait for it to
close the connection.

-dZ.

-- 
DZ-Jay - [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-12 Thread retnyg
whats the proper command to close the connection gracefully ?

AG> [EMAIL PROTECTED] wrote:
>> procedure TMailAlert.Pop3ClientRequestDone;
>> begin
>>   if (FPop.connected) and (CheckError) then begin
>> FPop.quit;
>> exit;
>>   end;
>> 
>> ...
>> 
>> what could be the cause that the component is not ready after the
>> error ?

AG> After sending command Quit you should receive a server response.
AG> When it's received you may either close or abort the connection 
AG> yourself or wait until the server drops the connection.
AG> Anyway start next connection attempt only when you are not connected,
AG> means after SessionClosed fired.

AG> --
AG> Arno Garrels 




-- 
Mit freundlichen Grüßen
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] pop3 component not ready

2007-12-11 Thread Arno Garrels
[EMAIL PROTECTED] wrote:
> procedure TMailAlert.Pop3ClientRequestDone;
> begin
>   if (FPop.connected) and (CheckError) then begin
> FPop.quit;
> exit;
>   end;
> 
> ...
> 
> what could be the cause that the component is not ready after the
> error ?

After sending command Quit you should receive a server response.
When it's received you may either close or abort the connection 
yourself or wait until the server drops the connection.
Anyway start next connection attempt only when you are not connected,
means after SessionClosed fired.

--
Arno Garrels 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] pop3 component not ready

2007-12-11 Thread retnyg
hi, i use a custom pop3 component in my program, and frome time to
time i get this errormessage from the server:

-ERR System temporarily unavailable, please try again later.

on the next connect try i get the "pop3 component not ready" exception,
even if i check for connected:

function TMailAlert.CheckError:boolean;
begin
  result := false;
  with fpop do
   if (errormessage <> '') then begin
 if assigned(FOnError)  then
   FOnError(ErrorMessage);
 ClearErrorMessage;
 result := true;
   end;
end;

procedure TMailAlert.CheckNewMail;
begin
   with FPop do
   if not Connected then
   begin
 Fbusy := true;
 ClearErrorMessage;
 Connect;
   end;
end;

procedure TMailAlert.Pop3ClientRequestDone;
begin
  if (FPop.connected) and (CheckError) then begin
FPop.quit;
exit;
  end;  

...

what could be the cause that the component is not ready after the
error ?

TIA, retnyg


ps. pop3prot.pas Version:  2.27

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be