Hide Disconnect button
Moderators: Hacker, petermad, Stefan2, white
- HomoLogicus
- Junior Member
- Posts: 16
- Joined: 2008-06-12, 14:54 UTC
- Location: Russia
- Contact:
Hide Disconnect button
In my fs-plugin I need to show Disconnect button. When I have called the LogProc function with MSGTYPE_CONNECT as a second parameter the button appears on FTP toolbar. It's OK. I can click the button now, the FsDisconnect function is called and the button disappears. Nice. But if I (without clicking the button) have called the LogProc function with MSGTYPE_DISCONNECT as a second parameter the Disconnect button is still on the screen. Is it a usual behaviour of TC? Or am I doing something wrong?
- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Yes, this is normal. The idea is that the user can see status messages in the log even if the initial connect fails.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
To make the disconnect button visible you need to log a message of kind MSGTYPE_CONNECT:
This is usually done in/triggered by FindFirst, since there is no FsConnect(...) method. (Maybe there is?).
The supplied message at offset 8 is taken as disconnectRoot!
To close it you have to wait till TC decides to invoke your FsDisconnect Method. (This happens eventually after pressing disconnect 2 times!)
There you log a message of kind MSGTYPE_DISCONNECT:
Bebbo
----
typos == entertainment[/quote]
Code: Select all
// connectMsg = "CoNnEcT myId";
connectMsg = "12345678myId"; // your ID starts at offset 8
gLogProc(gPluginNumber, MSGTYPE_CONNECT, connectMsg);
The supplied message at offset 8 is taken as disconnectRoot!
To close it you have to wait till TC decides to invoke your FsDisconnect Method. (This happens eventually after pressing disconnect 2 times!)
There you log a message of kind MSGTYPE_DISCONNECT:
Code: Select all
BOOL __stdcall FsDisconnect(char * disconnectRoot)
{
// !strcmp(disconnectRoot, connectMsg + 8)
if (!strcmp(disconnectRoot, "myId") {
// yes this happens!
gLogProc(gPluginNumber, "buggy TC is here :-)");
return false; // or true? whatever
}
// perform your disconnect
...
// close the log / button
gLogProc(gPluginNumber, MSGTYPE_DISCONNECT, "bye bye");
return true;
}
Bebbo
----
typos == entertainment[/quote]
- HomoLogicus
- Junior Member
- Posts: 16
- Joined: 2008-06-12, 14:54 UTC
- Location: Russia
- Contact:
2bebbo

I have no problem with showing the Disconnect button in my plugin. My question was: is there any way to hide the button from my code by calling LogProc with MSGTYPE_DISCONNECT parameter? Christian said 'no' and I trust himTo make the disconnect button visible you need to log a message of kind MSGTYPE_CONNECT

Hm... My FsDisconnect function is called after first pressing the button. What am I doing wrong?To close it you have to wait till TC decides to invoke your FsDisconnect Method. (This happens eventually after pressing disconnect 2 times!)

- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
The connect root has a different meaning: It's meant for plugins like SFTP which support several servers. So when you connect to server xyz and it's part of the path, send a message of type MSGTYPE_CONNECT with the text
CONNECT \xyz
Now when there are connections to multiple servers open, and the user clicks on "Disconnect" while in \\\pluginname\xyz or a subdir of it, TC will call FsDisconnect with server name "\xyz".
CONNECT \xyz
Now when there are connections to multiple servers open, and the user clicks on "Disconnect" while in \\\pluginname\xyz or a subdir of it, TC will call FsDisconnect with server name "\xyz".
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I only wanted to point out, that the disconnectRoot value is taken from the connect message, starting at offset 8 and the value of the 8 skipped characters have no meaning beside shown in the log.The connect root has a different meaning: It's meant for plugins like SFTP which support several servers. So when you connect to server xyz and it's part of the path, send a message of type MSGTYPE_CONNECT with the text
CONNECT \xyz
I would not bet my last penny on that. IMHO it's very repeatable:Hm... My FsDisconnect function is called after first pressing the button. What am I doing wrong?
- having a FS plugin path --> 1st click changes to a local path, 2nd click closes the connection
- having a local path --> 1st click closes.
Bebbo
- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Actually the 8 skipped characters are exactly the required prefix "CONNECT "!
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- HomoLogicus
- Junior Member
- Posts: 16
- Joined: 2008-06-12, 14:54 UTC
- Location: Russia
- Contact:
Beside the different text inside the log window, any 8 digits seem to workghisler(Author) wrote:Actually the 8 skipped characters are exactly the required prefix "CONNECT "!

And the 9th character MUST be a \ (aka backslash)! If you omitt the backslash FsDisconnect is invoked on 2nd click on disconnect. (Wierd isn't it?)
If it is a requirement to use "CONNECT \foobar", one can conform to it.
But it is unlucky to restrict log messages to predefined texts since I want to log my texts (where is the STOPP sign?). A separate method with a disconnectRoot as parameter would be way better!
Bebbo
[/b]
- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
You can log whatever you want, but just don't do that together with the MSGTYPE_CONNECT value! This one is reserved for the connect message only.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com