Re: Internet Access

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:

> Besides, this approach can be a single function
> that then calls whatever your idea is of the proper
> interface.

Yeah, I think the best plan would be to supply a set of bricks and let
people write their own specialized routines.

> Well, before the webget, the app can store/read the
> ini file, doesn't matter to me, just seems the read/write
> to the hd will take unnecessary time, all it will be good
> for is saving defaults and/or last known state.

You're right. It would be better to leave this sort of thing out, and let
people add it themselves if it was appropriate to the application. I sort of
liked the INI file that Rebol has, but it would mean writing a specialized
routine to read and write ini files, and would have dubious value for most
users.

> Right, coordination so the function names are the same and do the
> same.

Please bear with me if the proposed functions seem a bit naive; I bow to
your expertise.

> I already have read_http.

No point in coding it, then. I'll assume that you can pretty much code
everything on the Windows side, and will ask for others more qualified for
help on other bits.

> >    net_read( "http://www.rapideuphoria.com/contrib.htm")
>
> But you didn't spec what to do with the page. What if the page is
> on a puter on your intranet? Rewrite the ini file, make sure it is
> written, then call the net_read()?

Shame on me. I was thinking of returning a sequence containing the result
(binary file), or a -1 if there was a failure. This matches the way gets()
works:

   object result
   result = net_read( http://www")
   if integer( result ) then
      -- there's been an error
   end if

> >    net_idle( routine_id( <callback name>) )
>
> I haven't tried to code any routine_id().

The idea was that Euphoria doesn't support threading. So the best that can
be offered is, between packets, the routine could trigger and check to see
if the user wants to abort, or it displays an update to the screen status,
or something like that.


Anyhoo, here's my proposal. Anyone, feel free to hack it to bits:

[general]

   the prefix net_ is used on routines.
  the prefix NET_ is used on constants.

[setup]

   i have to defer to your expertise when it comes to anything more than
trivial settings.

   net_domain( "user at domain.dom" )
   net_smtp_server( "mail.server.dom" )
   net_pop_server( "pop.server.dom" )
   net_proxy_server( "proxy.server.dom", 1080 ) -- i'm already out of my
depth here!

[sending email]

  the recipient and cc can either be a single item, or a sequence of items.

  net_subject( "this is the header line" )
  net_recipient( nowhere.man at dev.null" )
  net_cc( robert.craig at euphoria.com" )
  net_content( "this is the body of the message" )
  result = net_email()

[reading email]

  i'm assuming that you want to support more than one mailbox being open
  at a time. so net_open_mailbox returns the id of the requested mailbox,
  and net_close_mailbox is used to close an open mailbox.
  net_read_mail is used to examine the contents of the mailbox, and
  net_remove_mail is used to remove contents of a mailbox.

  should blind cc be included as well?

  -- these are used to index the sequence returned by net_read_mail
  NET_DATE = 1,
  NET_SUBJECT = 2,
  NET_RECIPENT = 3,
  NET_CC = 4,
  NET_CONTENT = 5

  -- these can be used instead of an index in net_read_mailbox
  -- i.e.: message = read_mailbox( myMailbox, NET_FIRST_MESSAGE )
  NET_FIRST_MESSAGE = -1  -- first message in mailbox
  NET_NEXT_MESSAGE = -2, -- next message in mailbox
  NET_PRIOR_MESSAGE = -3, -- previous message in mailbox
  NET_LAST_MESSAGE = -4 -- final message in mailbox

   mailbox = net_open_mailbox( "pop://orson:rosebud at mail.yoda.dom" )
   index = net_count_mail( mailbox )
   message = net_read_mail( mailbox, index )
   net_ remove_mail( mailbox, index )
   net_close_mailbox( mailbox )

[ network read/write ]

  the type of operation (http/https/ftp) should be determined from the
  text of the url. for example:

      net_read( "ftp://ftp.site.com/something.txt" )

  is obviously going to use ftp. results of the read are returned as
  a sequence on success, or a -1 on failure.

  i think the simplest way to specify flags is akin to how euphoria
  does it with files:

   -- read in binary mode
   result = net_read( "http://www.mysite.com/file.zip", "b" )

   -- write in binary mode, append
   net_write( "myfile.zip", "ftp://www.mysite.com/file.zip, "ba" )

  net_dir is used to get file information. it returns a sequence with
  file information in it, similar to euphoria's dir.

   NET_NAME = 1, -- file name
   NET_SIZE = 2, -- file size
   NET_DATE = 3, -- file create date
   NET_MODIFIED = 4, -- file modified date
   NET_DIR = 5 -- true if file is a directory

  result = net_read( url, flags )
  result = net_write( "filename", url, flags )
  net_ftp_user( "whoami" )
  net_ftp_password( "secret" )
  net_dir( url )
  net_make_dir( url, dir )
  net_delete( url )
  net_rename( url, new name )

[tcp]

  i defer to your knowledge here.

Comments, anyone?

-- david cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu