Hide Disconnect button

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
HomoLogicus
Junior Member
Junior Member
Posts: 16
Joined: 2008-06-12, 14:54 UTC
Location: Russia
Contact:

Hide Disconnect button

Post by *HomoLogicus »

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?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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
bebbo
Junior Member
Junior Member
Posts: 53
Joined: 2009-06-24, 08:22 UTC

Post by *bebbo »

To make the disconnect button visible you need to log a message of kind MSGTYPE_CONNECT:

Code: Select all

    // connectMsg = "CoNnEcT myId";
    connectMsg = "12345678myId"; // your ID starts at offset 8
    gLogProc(gPluginNumber, MSGTYPE_CONNECT, connectMsg);
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:

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]
User avatar
HomoLogicus
Junior Member
Junior Member
Posts: 16
Joined: 2008-06-12, 14:54 UTC
Location: Russia
Contact:

Post by *HomoLogicus »

2bebbo
To make the disconnect button visible you need to log a message of kind MSGTYPE_CONNECT
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 him :)
To close it you have to wait till TC decides to invoke your FsDisconnect Method. (This happens eventually after pressing disconnect 2 times!)
Hm... My FsDisconnect function is called after first pressing the button. What am I doing wrong? :wink:
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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".
Author of Total Commander
https://www.ghisler.com
bebbo
Junior Member
Junior Member
Posts: 53
Joined: 2009-06-24, 08:22 UTC

Post by *bebbo »

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 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.
Hm... My FsDisconnect function is called after first pressing the button. What am I doing wrong? :wink:
I would not bet my last penny on that. IMHO it's very repeatable:

- 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
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Actually the 8 skipped characters are exactly the required prefix "CONNECT "!
Author of Total Commander
https://www.ghisler.com
User avatar
HomoLogicus
Junior Member
Junior Member
Posts: 16
Joined: 2008-06-12, 14:54 UTC
Location: Russia
Contact:

Post by *HomoLogicus »

- having a FS plugin path --> 1st click changes to a local path, 2nd click closes the connection
- having a local path --> 1st click closes.
I had the same problem until I give a wrong Root to LocProc when connecting. Check your code.
bebbo
Junior Member
Junior Member
Posts: 53
Joined: 2009-06-24, 08:22 UTC

Post by *bebbo »

ghisler(Author) wrote:Actually the 8 skipped characters are exactly the required prefix "CONNECT "!
Beside the different text inside the log window, any 8 digits seem to work :)
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]
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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
Post Reply