It is currently Thu Jun 20, 2013 10:23 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 336 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 23  Next
Author Message
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Fri Aug 11, 2006 8:07 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
@gnozal: Is there a way to get the entire e-mail into memory? At the moment
if I use PurePOP3_GetMessageTextInMemory() it only gets the body, and I
have to use PurePOP3_GetMessageInfo() to get the rest. It doesn't look like
PurePOP3_RetrieveMessage() gets it all into memory, or can it? Because that
is what I'm after, without having to save it to a file. :)


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Fri Aug 11, 2006 8:21 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
PB wrote:
@gnozal: Is there a way to get the entire e-mail into memory? At the moment
if I use PurePOP3_GetMessageTextInMemory() it only gets the body, and I
have to use PurePOP3_GetMessageInfo() to get the rest. It doesn't look like
PurePOP3_RetrieveMessage() gets all into memory, or can it? Thanks!
PurePOP3_RetrieveMessage() get all the message in memory (as you can see if you use PurePOP3_Trace(#True) : have a look at the PurePOP3-DEBUG* files). I could add a function to retrieve the memory address <PurePOP3_MessageBuffer>. Would this help ?

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Fri Aug 11, 2006 8:28 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
Yes please. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 9:39 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Micro update (both libs)

- added PurePOP3_GetMessageBufferAddress() function [3 lines of code, not tested]

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 11:46 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
Thank you gnozal, I can confirm it works great! :D


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 15, 2006 12:58 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Update (both libs)

What's new :
- new function PurePOP3_SetRetrieveCallback(*ProcedureAddress) : set the progression callback address for PurePOP3_RetrieveMessage() ; usefull to indicate the progress when a big file is retrieved.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 8:27 am 
Offline
User
User
User avatar

Joined: Sat Sep 25, 2004 2:02 pm
Posts: 53
Location: Netherlands (Nijmegen)
@Gnozal

I have this email check program, but occasionally (most of the time when having > 15 messages) I get a memory access error.
The error occurs in PurePOP3_GetMessageTextInMemory()

Thanks,
Rob.

Code:
Enumeration
  #Window_0
  #Listview_0
EndEnumeration

Global Server.s, Port.l, User.s, Pwd.s, Messages.l, Message.l, MessageCounter.l, TmpString.s, Inhoud.s, Afzender.s, Onderwerp.s, Ontvangen.s
Global nEmailnr.l, aantalgewist.l, StartOutlook.l, Spam.l

Server.s = "pop.hccnet.nl"
Port.l   = 110
User.s   = "myName"
Pwd.s    = "MyPwd"

Declare Open_Window_0()

Procedure GetThem()
 
  If Messages
    ;Debug "Message(s) total size : " + Str(PurePOP3_GetMessagesTotalSize()) + " bytes"
    For MessageCounter = 1 To Messages
      ;Debug "Email " + Str(MessageCounter) + " size : " + Str(PurePOP3_GetMessageSize(MessageCounter)) + " bytes"
      If PurePOP3_RetrieveMessage(MessageCounter) > 0

        ;Debug "--------------------------"
        ;Debug "Email info : " + PurePOP3_GetMessageInfo()
        ;Debug "Email " + Str(MessageCounter)
        ;MailInfo.s = ""
        ; het splitsen van de email:
        For k=1 To 3 ; 5 geeft ook aantal attachments en de lengte van de email
          TmpString.s = StringField(PurePOP3_GetMessageInfo(), k, Chr(9))
          Select k
          Case 1  ; delivery date
            Ontvangen.s = Mid(TmpString.s,15,Len(TmpString)-14)
          Case 2  ; subject
            Onderwerp.s = Mid(TmpString.s,9,Len(TmpString)-8)
          Case 3  ; from
            Afzender.s = Mid(TmpString.s,6,Len(TmpString)-5)
          EndSelect 
        Next
        ;Debug "EMAIL " + Str(MessageCounter) + " " + MailInfo.s
       
        If PurePOP3_IsMessageHTML() 
           *Message = PurePOP3_GetMessageTextInMemory(1)
        Else
           *Message = PurePOP3_GetMessageTextInMemory()
        EndIf
        If *Message
          Inhoud.s = PeekS(*Message)
          Inhoud.s = LCase(Inhoud.s)
          ;Debug "*INHOUD*:" + Inhoud.s
        EndIf
       
        AddGadgetItem (#Listview_0, -1, "Email "+Str(MessageCounter)+" Van: "  + Afzender.s +"  Onderwerp: " + Onderwerp.s+"  Ontvangen: " + Ontvangen.s)
        If FindString(Afzender,"0451.com",1) Or FindString(Inhoud, "watches", 1) Or FindString(Inhoud, "replica", 1) Or FindString(Inhoud, "poor health", 1) Or FindString(Inhoud, "medication", 1) Or FindString(Inhoud, "stamina", 1) Or FindString(Inhoud, "erecti", 1) Or FindString(Inhoud, "orgasm", 1) Or FindString(Inhoud, "corkpencills", 1) Or FindString(Inhoud, "dating", 1)
          SetGadgetItemState(#Listview_0, MessageCounter-1, #PB_ListIcon_Checked)
        EndIf
 
      EndIf

    Next ; MessageCounter
   
    FreeMemory(*Message)
   
  EndIf
 
EndProcedure

Procedure Pop3Stuff()

If PurePOP3_OpenPOP3Connection(Server, Port, User, Pwd) = #PurePOP3_Ok
 
  Messages = PurePOP3_CountMessages()
  If Messages = 0
     PurePOP3_ClosePOP3Connection()
     PlaySound_("d:\checkmail\lonely.wav",0,0)
  Else
    PlaySound_("c:\windows\media\notify.wav",0,0)
    Open_Window_0()
    SetGadgetState(9, 1)  ; outlook opstarten aangevinkt
  EndIf
 
 
Else
    MessageRequester("PROBLEEM MET DE SERVER","SERVER ONBEREIKBAAR FOUTCODE "+ PurePOP3_GetLastServerMessage())
EndIf

EndProcedure

Procedure DoIt()

    nEmailNr.l   = 0
    aantalgewist = 0
    For I = 0 To CountGadgetItems(#Listview_0) - 1
      nEmailNr.l = nEmailNr.l + 1
      If GetGadgetItemState(#Listview_0, I) = #PB_ListIcon_Checked
        If PurePOP3_DeleteMessage(nEmailNr)
          aantalgewist = aantalgewist + 1
        Else
          MessageRequester("PROBLEEM","DEZE EMAIL NIET KUNNEN VERWIJDEREN" + Chr(10) + "FOUTMELDING: " + PurePOP3_GetLastServerMessage()  + Chr(10) + "EMAIL "+Str(nEmailNr.l)+" NIET GEWIST: " ,#MB_ICONWARNING)
        EndIf
      EndIf
    Next
    If nEmailNr - aantalgewist > 0
      SetGadgetState(9, 1)
    Else
      SetGadgetState(9, 0)
    EndIf
    If aantalgewist > 0
      AddGadgetItem (#Listview_0, -1, Str(aantalgewist)+" email(s) werd(en) verwijderd...")
      ;MessageRequester("Aantal verwijderde emails",Str(aantalgewist)+" email(s) werd(en) verwijderd...",#PB_MessageRequester_Ok)
    EndIf
   
EndProcedure

 
Procedure Open_Window_0()

;  If OpenWindow(#Window_0, 0, 0,  950,520, "CheckMail voor Eus",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
  If OpenWindow(#Window_0, 0, 0,  950,520, "CheckMail 150806",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
 
    AddKeyboardShortcut(0, #PB_Shortcut_Escape, 99)

    If CreateGadgetList(WindowID(#Window_0))
   
      ListViewGadget(#Listview_0, 20, 20, 900, 370)
 
      ListIconGadget(#Listview_0, 25, 25,  890,360, "Wis   Informatie", 890, #PB_ListIcon_CheckBoxes  | #PB_ListIcon_FullRowSelect | #PB_ListIcon_MultiSelect | #PB_ListIcon_AlwaysShowSelection  | #PB_ListIcon_GridLines)
      ;ListIconGadget(#Listview_0, 25, 25, 470, 490, "Wis   Informatie", 490)
      ;AddGadgetColumn(#Listview_0, 50, "Informatie", 490)

      ;ListIconGadget(#Listview_0, 50, 25, 425, 490, "Informatie", 490)
     
      ;TextGadget(4, 20, 10, 180, 24, "Select a DBF-file:")
      ;TextGadget(5, 240, 60, 180, 24, "Selected:")
      ;TextGadget(6, 240, 90, 180, 24, "")
     
      ButtonGadget(7, 440, 400, 80, 30, "Verwijder", #PB_Button_Default   )
      ButtonGadget(8, 440, 440, 80, 30, "Einde"    , #PB_Button_Default   )
 
      CheckBoxGadget(9, 440, 470, 200, 30, "OUTLOOK OPSTARTEN")
     
    EndIf
    If CreateStatusBar(0, WindowID(#Window_0))
      StatusBarText(0, 0, "Esc - Einde", 0)
    EndIf

    SetGadgetState(9, 1)
    GetThem() ; Haal emails op...
   
    Repeat
 
      WEvent = WaitWindowEvent()
      Select WEvent
        Case #PB_Event_CloseWindow
          Quit = #True
        Case #PB_Event_Gadget

          Select EventGadget()
            Case 7  ; button VERWIJDEREN
              DoIt()
            Case 8  ; button exit
              Quit = #True
            Case 9  ;
          EndSelect
         
        Case #PB_Event_Menu
          EventMenu = EventMenu()
          Select EventMenu
            Case 99
              Quit = #True
            Default
          EndSelect
        Default
 
      EndSelect
 
    Until WEvent = #PB_Event_CloseWindow Or Quit
  EndIf
 
  PurePOP3_ClosePOP3Connection() ; close the connection...
   
  StartOutlook.l    = GetGadgetState(9)
 
  If StartOutlook
     Result = RunProgram("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE" )
  EndIf
 
EndProcedure

FontResult1 =  LoadFont(#PB_Any,"Arial",14)
SetGadgetFont(#PB_Default,FontResult1)

Pop3Stuff()  ; kijk of er emails zijn...

End 


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 11:42 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Cannot test it until the weekend, but :
- I have tested the lib with > 100 messages with/without attachments and without problems
- In GetThem(), you should FreeMemory(*Message) at the end of the < If *Message / Endif > block
Code:
        If *Message
          Inhoud.s = PeekS(*Message)
          Inhoud.s = LCase(Inhoud.s)
          ;Debug "*INHOUD*:" + Inhoud.s
          FreeMemory(*Message) ; <---------------
        EndIf
- if this does not help, you could activate the trace mode [PurePOP3_Trace(#True)] and have a look at the PurePOP3-DEBUG*.txt files to help debugging : you can see all the communications and eventually where the crash occurs.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 12:04 pm 
Offline
User
User
User avatar

Joined: Sat Sep 25, 2004 2:02 pm
Posts: 53
Location: Netherlands (Nijmegen)
Thank you Gnozal!

I will try what you suggest and report it back.


Rob.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 7:56 am 
Offline
User
User
User avatar

Joined: Sat Sep 25, 2004 2:02 pm
Posts: 53
Location: Netherlands (Nijmegen)
@Gnozal,

Your solution worked fine, Thanks again!

Rob.


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Sat Aug 26, 2006 9:59 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
Hi gnozal, I just noticed that if I turn on "Create threadsafe executable" for
PureBasic v4.00 then I get this error when using your lib:

Code:
---------------------------
PureBasic - Linker error
---------------------------
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK: fatal error: 1 unresolved external(s).
---------------------------
OK   
---------------------------

If I remove your lib, or turn off threadsafe, then my app compiles fine.
Don't know if it's a PureBasic bug or something with your lib? I'm using
the latest version of the lib: installer exe of size 88.1 KB (90,275 bytes).


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Sat Aug 26, 2006 10:50 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
PB wrote:
Hi gnozal, I just noticed that if I turn on "Create threadsafe executable" for
PureBasic v4.00 then I get this error when using your lib:

I assume you use the PB IDE.
Did you enable the UserLibThreadSafe subsystem ?
Quote:
The library exists in two versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the
subsystem 'UserLibThreadSafe' in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the
PBCompiler arguments. In jaPBe, do nothing : it will automatically enable the 'UserLibThreadSafe'
subsystem to use the threadsafe versions of the installed userlibraries.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Sat Aug 26, 2006 11:01 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
> In order to use this library in thread-safe mode (compiler option /THREAD),
> you have to enable the subsystem 'UserLibThreadSafe' in the PB IDE

I've never heard of this before, and can't find it in the PB IDE options anywhere.
Where do I find it? I checked the entire "Compiler Options" but there's nothing
there that says UserLibThreadSafe at all.

Edit: Never mind, I just realised to put "UserLibThreadSafe" (no quotes) in
the "Library subsystem" field and it now compiles. Newbies will have fun! :)


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Sat Aug 26, 2006 11:11 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
PB wrote:
> In order to use this library in thread-safe mode (compiler option /THREAD),
> you have to enable the subsystem 'UserLibThreadSafe' in the PB IDE

I've never heard of this before, and can't find it in the PB IDE options anywhere.
Where do I find it? I checked the entire "Compiler Options" but there's nothing
there that says UserLibThreadSafe at all.
The %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ directory is created by my library installer. The library in this directory is compiled with my custom Tailbite version with option /THRD. This is the way I use to make thread safe libs [ http://www.purebasic.fr/english/viewtop ... &start=392 ].
It should work (not tested for PurePOP3, but works for PureZIP) with thread safe executables.
You have to enable the subsystem just like you would do it for NT4 or OpenGL. I don't use the PB IDE, sorry.
An easier way to test : replace PurePOP3 from %Purebasic%\PureLibraries\UserLibraries\ with PurePOP3 from %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ and compile in thread safe mode.
PB wrote:
Edit: Never mind, I just realised to put "UserLibThreadSafe" (no quotes) in the "Library subsystem" field and it now compiles. Newbies will have fun!
In jaPBe, it's automatic !

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PurePOP3 library : POP3 functions
PostPosted: Sat Aug 26, 2006 1:01 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6566
> An easier way to test [snip]

Yep, that works better (don't need to specify a subsystem anymore). Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 336 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 23  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye