C++, COM tool - Events are not being called - WeOnlyDo Discussion board

C++, COM tool - Events are not being called (wodSFTP / wodSFTP.NET / wodSFTPdll)

by billstamp, Wednesday, August 10, 2005, 22:59 (6838 days ago)

I am using VC 2003, C++, with current eval wodftpdlx.dll, just downloaded again today to make sure its the latest

what i am seeing is that some events never fire, either with blocking on or off

I DO get some, for example;
Connected/Done/FTPReply

I do NOT get
ListItems/Attributes/HostCertificate

I am hooking the sink using the sample code from WithEvents, and the same FtpEventSink.cpp

Any ideas?

Re: C++, COM tool - Events are not being called

by wodSupport, Friday, August 12, 2005, 01:48 (6837 days ago) @ billstamp

Bill,

I just tried that sample with VSNET 2003, and it works correctly for me. I call ListDir from Connected event (making sure blocking is set to false) and EventListItems function is called.

Can you please make sure that your events are defined correctly? These are how my events are defined:
in FtpEventSink.h starting on line 31 [code]void Connected(long ErrorCode, LPCTSTR ErrorText);
void Disconnected();
void StateChange(long OldState);
void HostFingerprint(LPCTSTR Fingerprint, BOOL* Accept);
void HostCertificate(LPDISPATCH Cert, long ErrorCode, LPCTSTR ErrorText, BOOL* Accept);
void Progress(long Position, long Total);
void ListItems(LPCTSTR FileInfo);
void Done(long ErrorCode, LPCTSTR ErrorText);
void Attributes(long Size, long Uid, long Gid, long Permissions, DATE AccessTime, DATE ModificationTime);
void ClientCertRequired();
void FTPReply(LPCTSTR Command, short ReplyCode, LPCTSTR ReplyText);
void PreTranslateCommand(LPCTSTR *Command);
void PreTranslateReply(short *Code, LPCTSTR *Reply);[/code] and their declaration in FtpEventSink.cpp starting on line 56 is like this: [code]DISP_FUNCTION_ID(CEventSink, Connected ,1,Connected,VT_EMPTY,VTS_I4 VTS_BSTR)
DISP_FUNCTION_ID(CEventSink, Disconnected , 2, Disconnected, VT_EMPTY, VTS_NONE)
DISP_FUNCTION_ID(CEventSink, StateChange , 3, StateChange, VT_EMPTY, VTS_I4)
DISP_FUNCTION_ID(CEventSink, HostFingerprint , 4, HostFingerprint, VT_EMPTY, VTS_BSTR VTS_PBOOL)
DISP_FUNCTION_ID(CEventSink, HostCertificate , 5, HostCertificate, VT_EMPTY,VTS_DISPATCH VTS_I4 VTS_PBOOL)
DISP_FUNCTION_ID(CEventSink, Progress , 6, Progress, VT_EMPTY, VTS_I4 VTS_I4)
DISP_FUNCTION_ID(CEventSink, ListItems , 7, ListItems, VT_EMPTY, VTS_BSTR)
DISP_FUNCTION_ID(CEventSink, Done , 8, Done, VT_EMPTY, VTS_I4 VTS_BSTR)
DISP_FUNCTION_ID(CEventSink, Attributes , 9, Attributes, VT_EMPTY, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_DATE VTS_DATE)
DISP_FUNCTION_ID(CEventSink, ClientCertRequired , 10, ClientCertRequired, VT_EMPTY, VTS_NONE)
DISP_FUNCTION_ID(CEventSink, FTPReply , 11, FTPReply, VT_EMPTY, VTS_BSTR VTS_I2 VTS_BSTR)
DISP_FUNCTION_ID(CEventSink, PreTranslateCommand , 12, PreTranslateCommand, VT_EMPTY, VTS_PBSTR)
DISP_FUNCTION_ID(CEventSink, PreTranslateReply , 13, PreTranslateReply, VT_EMPTY, VTS_PI2 VTS_PBSTR)[/code]. Can you please check you have the same?

Re: C++, COM tool - Events are not being called

by billstamp, Monday, August 15, 2005, 20:52 (6833 days ago) @ wodSupport

Thanks for the reply
I do have the same, and the sample works.

I had tried wrapping up the functionality into a simple dll which I can then call from an executable. It seemed simple enough, but I found the behavior very odd - the callbacks worked for connect, but not list dir. Same with blocking (which I would like to use) on.

So, I reworked the dll ino a lib, and linked it in.
Not much different.

In my calling app, there is a modal dialog which is making the calls. The com object seems to be getting confused about the modal dialog message loop.

I will try linking my lib to the sample, and see if I can get that to work.

Re: C++, COM tool - Events are not being called

by wodSupport, Monday, August 15, 2005, 22:25 (6833 days ago) @ billstamp

Bill,

you know, you can always zip your code and send it to techsupport, so we can check it out. But if you can wait and do that after 20th this month, I would appreciate it :)

Kreso

Re: C++, COM tool - Events are not being called

by billstamp, Tuesday, August 16, 2005, 18:28 (6833 days ago) @ wodSupport

Thanks - yes, I will do that after the 20th.
I have put a project together around your example, which wraps the COM object in a DLL. I then call the DLL though exported functions. It exhibits the same behavior - the sink OnConnect gets called, etc, but for instance the sink Attributes does not get called.
I would just go to the LIB, but that would leave me with no compressed FTP for plain FTP, which I need to support. In any case, I am sure once you are back we will crack it. I am going on to other things for a couple days.