Question about COM, WinInet and FTP 
Author Message
 Question about COM, WinInet and FTP

Hi,

I am after some clarification whether this is possible or not and if I
am going about this the right way. What I want to do is get a "submit"
button on a web page to take some some filename information from an
HTML form and then FTP it to a specified server.

I want to wrap all this up in COM using wininet. I have got as far as
creating a the COM interface and implmenting a couple of methods to
connect to the FTP server and actually managed to call FTPPutFile
fine.

I want to make the whole process better though...

When control moves into the COM method the browser locks up (whilst
the transfer is in progress) and only unfreezes when the transfer is
finished. So I moved the FTPPutFile into another thread and everything
works great. But I really want some sort of progress indicator on the
client browser. I have been looking at the async communication and
callbacks. Can this be used to do what I need? I know I could get the
status of the transfer from the callback function at each stage and
somehow return that to the browser to let the user know what's going
on, but I'm a bit lost about how to do it. How can my COM object
return this status to the browser? Surely I would have to call the
method from the web page to get some status value from the object?

I am also having problems getting the InternetSetStatusCallback
function working!
I am calling InternetOpen then using the handle returned by that
method in the InternetSetStatusCallback call. This too succeeds but I
don't think I am waiting correctly for the handle or something. To be
honest I am having trouble debugging the COM methods so any help here
would be much appreciated!! By the way, I am using ATL and VC++.

thanks,
Andy



Wed, 05 May 2004 06:38:59 GMT  
 Question about COM, WinInet and FTP
Enter callback interfaces and connection points. These are best described
in the literature, but the idea is simple - you call through an interface
which the caller passed to you prior to the asynchronous operation to
indicate its progress. The simpler (and more to the point) callback
approach will involve the client passing an interface pointer to the
callback object when initiating the async operation. The server object
AddRef-s the callback interface pointer and calls through it later. The
more generic connection points (less useful here, but much simpler in
a browser with scripts due to the ready support for connection points)
involvesthe object publishing its outgoing interface in the type library
and providing the appropriate interfaces: IConnectionPointContainer
and IConnectionPoint (on a separate object). ATL has ready support
for connection points too.

Check out these sources:
"Inside OLE" by Kraig Brosckschmidt, MSDN Library under \Books
"Beginning ATL3 COM Programming" By Dr Richard Grimes, Wrox Press
"Professional ATL COM Programming" By Dr Richard Grimes, Wrox Press

The first describes what Connectable Objects (AKA conection points)
really are. The other two describe the ATL support. (I think either will
do.) At any rate, any decent ATL book describes that...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Hi,

> I am after some clarification whether this is possible or not and if I
> am going about this the right way. What I want to do is get a "submit"
> button on a web page to take some some filename information from an
> HTML form and then FTP it to a specified server.

> I want to wrap all this up in COM using wininet. I have got as far as
> creating a the COM interface and implmenting a couple of methods to
> connect to the FTP server and actually managed to call FTPPutFile
> fine.

> I want to make the whole process better though...

> When control moves into the COM method the browser locks up (whilst
> the transfer is in progress) and only unfreezes when the transfer is
> finished. So I moved the FTPPutFile into another thread and everything
> works great. But I really want some sort of progress indicator on the
> client browser. I have been looking at the async communication and
> callbacks. Can this be used to do what I need? I know I could get the
> status of the transfer from the callback function at each stage and
> somehow return that to the browser to let the user know what's going
> on, but I'm a bit lost about how to do it. How can my COM object
> return this status to the browser? Surely I would have to call the
> method from the web page to get some status value from the object?

> I am also having problems getting the InternetSetStatusCallback
> function working!
> I am calling InternetOpen then using the handle returned by that
> method in the InternetSetStatusCallback call. This too succeeds but I
> don't think I am waiting correctly for the handle or something. To be
> honest I am having trouble debugging the COM methods so any help here
> would be much appreciated!! By the way, I am using ATL and VC++.

> thanks,
> Andy



Sun, 16 May 2004 03:51:18 GMT  
 Question about COM, WinInet and FTP
Forgot to mention in my other post - you must fire the events from
the correct apartment. Check item 1 in the COM/ATL FAQ in my
signature for the available approaches and links to some solutions
in case your component is apartment-threaded.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Hi,

> I am after some clarification whether this is possible or not and if I
> am going about this the right way. What I want to do is get a "submit"
> button on a web page to take some some filename information from an
> HTML form and then FTP it to a specified server.

> I want to wrap all this up in COM using wininet. I have got as far as
> creating a the COM interface and implmenting a couple of methods to
> connect to the FTP server and actually managed to call FTPPutFile
> fine.

> I want to make the whole process better though...

> When control moves into the COM method the browser locks up (whilst
> the transfer is in progress) and only unfreezes when the transfer is
> finished. So I moved the FTPPutFile into another thread and everything
> works great. But I really want some sort of progress indicator on the
> client browser. I have been looking at the async communication and
> callbacks. Can this be used to do what I need? I know I could get the
> status of the transfer from the callback function at each stage and
> somehow return that to the browser to let the user know what's going
> on, but I'm a bit lost about how to do it. How can my COM object
> return this status to the browser? Surely I would have to call the
> method from the web page to get some status value from the object?

> I am also having problems getting the InternetSetStatusCallback
> function working!
> I am calling InternetOpen then using the handle returned by that
> method in the InternetSetStatusCallback call. This too succeeds but I
> don't think I am waiting correctly for the handle or something. To be
> honest I am having trouble debugging the COM methods so any help here
> would be much appreciated!! By the way, I am using ATL and VC++.

> thanks,
> Andy



Sun, 16 May 2004 03:52:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. wininet, FTP, SSL questions

2. FTP - wininet - UNIX - file date/time

3. hostname not resolved using ftp and wininet.dll

4. Wininet/FTP Problems

5. WinInet-FTP Command...

6. FTP and sockets (not using WinInet)?

7. WinInet and FTP

8. Help: Using Wininet with an FTP Proxy that requires Authentication

9. WinInet-FTP Command...

10. FTP and sockets (not using WinInet)?

11. WinInet API/MFC FTP via Proxy Server (Help!)

12. Wininet/FTP Problems

 

 
Powered by phpBB® Forum Software