Community
    • Login

    New built-in Plugin Admin (Plugin Manager) is ready

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    117 Posts 22 Posters 94.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • donhoD
      donho @Hsilgos
      last edited by

      @Hsilgos

      Are you sure you did your last changes to both versions of GUP and Android++?
      For me seems that x64 works with new scheme, but x86 works with old

      Because you use Android++ instead of Notepad++.

      HsilgosH 1 Reply Last reply Reply Quote 0
      • HsilgosH
        Hsilgos @donho
        last edited by

        @donho Yes, Notepad++ for sure =D
        The rest of message should be correct

        1 Reply Last reply Reply Quote 0
        • donhoD
          donho @dinkumoil
          last edited by donho

          @dinkumoil Sorry, I didn’t read your description attentively. The correct info about packaging is following:

          1. The plugin DLL file should be placed at the root level of the ZIP file.
          2. The root level of the ZIP file can also contain additional files (DLL files or data files needed by the plugin) and folders which will be copied to the users harddisk as well.
          3. Everything what gets copied from the ZIP file will be stored under <Npp-installation-folder>\plugins<plugin-name>.

          The other DLLs can be at the root level with plugins DLL because Notepad++ will load only the dll has the same name as its containing folder. The other DLLs are just ignored.

          1 Reply Last reply Reply Quote 1
          • chcgC
            chcg
            last edited by chcg

            Having a hash of the main plugin dll might be still of interest, if you want to provide a “safe” mode with just starting plugin dlls with correct sha-256 hash.

            1 Reply Last reply Reply Quote 0
            • pnedevP
              pnedev
              last edited by

              @donho ,

              I just noticed that when testing the NppGTags x86 plugin installation it was put in C:\Users\me\AppData\Local\Notepad++\plugins\NppGTags instead of C:\Program Files (x86)\Notepad++\plugins\NppGTags. It is working fine but I didn’t get the impression that it would be installed there.
              Is that the intended behavior?

              donhoD 1 Reply Last reply Reply Quote 1
              • dinkumoilD
                dinkumoil
                last edited by dinkumoil

                @pnedev said:

                it was put in C:\Users\me\AppData\Local\Notepad++\plugins\NppGTags instead of C:\Program Files (x86)\Notepad++\plugins\NppGTags

                I did my previous test with portable installations of NPP, with a local installation I can confirm this behaviour. My plugins partially fail to work correctly, they don’t find their own DLL (required for extracting version information for the About box) and their documentation file anymore.

                The current behaviour is caused by the fact that it was intentional to provide a method of plugin installation which requires no restart of Npp. Thus the plugin installer can’t copy the plugin files to the installation folder of Npp because usually this is a protected location and would require admin rights to do so.

                Since we already discovered that there is a high risc that a restart-free plugin installation will cause problems with certain plugins (NppFTP seems to be one of these) @donho stated here that this behaviour will be changed. Thus in the future the installation folder should be <Npp-installation folder>\plugins\<plugin-name> again.

                donhoD 1 Reply Last reply Reply Quote 0
                • donhoD
                  donho @pnedev
                  last edited by donho

                  @pnedev

                  Is that the intended behavior?

                  Yes, I confirm it.
                  From now on all plugins will be placed in its folder which has the same name, so that any data or dll that plugin needs can be placed arbitrarily in this folder.

                  I invite you to check the guide for being included in plugins list, it’ll be updated as soon as there’s any change of specs.

                  1 Reply Last reply Reply Quote 0
                  • donhoD
                    donho @dinkumoil
                    last edited by

                    @dinkumoil

                    @donho stated here that this behaviour will be changed. Thus in the future the installation folder should be <Npp-installation folder>\plugins<plugin-name> again.

                    Not sure about the point you’re talking about. Could you elaborate it?

                    1 Reply Last reply Reply Quote 0
                    • dinkumoilD
                      dinkumoil
                      last edited by dinkumoil

                      @donho said:

                      @dinkumoil
                      Not sure about the point you’re talking about. Could you elaborate it?

                      In this comment I stated:

                      2.After plugin installation Notepad++ is not restarted. That seems to be nice at first glance but causes serious problems.

                      Your answer in this comment was:

                      The 2nd point you mentioned is a bug, will be fixed in the future.

                      I interpreted this in that sense that in the future after plugin installation Npp will be restarted again to avoid problems with plugins which need this behaviour. We have seen that sending a NPPM_READY message to plugins after installation is not sufficient because @chcg reported in this comment that NppFTP still isn’t initialized correctly:

                      @chcg said

                      For NppFTP the NPPN_READY doesn’t solve it completely. Now the docking and the message window are constructed/ visible, but the content is still not there. Maybe there is another difference to the start of n++ itself.


                      The thing @pnedev and I wanted to point out is that with a local installation (performed by installer exe) the plugins currently are not installed under C:\Program Files\Notepad++\plugins but under C:\Users\<user-name>\AppData\Local\Notepad++\plugins. This difference causes problems since it is only possible to query the installation folder of Npp but not the storage location of the plugin itself.

                      My current algorithm to get the storage location of my plugin DLL file and its documentation file is as follows (if this algorithm is wrong please point me to the correct method to do that):

                      1. Send NPPM_GETNPPDIRECTORY to Npp to query the installation folder of Npp.
                      2. Append plugins.
                      3. Append the plugin name.

                      This would result in e.g. C:\Program Files\Notepad++\plugins\AutoCodepage. But currently there is no folder of this path since the plugin gets installed under C:\Users\<user-name>\AppData\Local\Notepad++\plugins\AutoCodepage.

                      donhoD 1 Reply Last reply Reply Quote 3
                      • donhoD
                        donho @dinkumoil
                        last edited by

                        @dinkumoil

                        The thing @pnedev and I wanted to point out is that with a local installation (performed by installer exe) the plugins currently are not installed under C:\Program Files\Notepad++\plugins but under C:\Users<user-name>\AppData\Local\Notepad++\plugins.

                        Damn! I miss again!
                        https://pbs.twimg.com/media/ChxfvQVVEAEQvXH.jpg

                        I interpreted this in that sense that in the future after plugin installation Npp will be restarted again to avoid problems with plugins which need this behaviour.

                        No, it’s not what I wanna do. I have added NPPN_READY, obviously it’s not enough, there is (are) other notification(s) missing we just need to add it (them).

                        1 Reply Last reply Reply Quote 2
                        • dinkumoilD
                          dinkumoil
                          last edited by

                          @donho said:

                          No, it’s not what I wanna do. I have added NPPN_READY, obviously it’s not enough, there is (are) other notification(s) missing we just need to add it (them).

                          Why do you want to make life difficult for you (and plugin developers which have to assist you to find the required notifications)? When plugins get updated or uninstalled a restart of Npp happens (currently) anyway.

                          Revert the installation path for portable and local Npp installations to the same location and restart Npp to perform actual plugin installation in admin mode - you (and we plugin authors) would be ready. That’s also KISS.

                          1 Reply Last reply Reply Quote 0
                          • chcgC
                            chcg
                            last edited by

                            Some points from PluginManager feature requests:

                            • https://github.com/bruderstein/nppPluginManager/issues/33
                              Feature Request: UDL repository -> update not just plugins, but also UDLs and maybe themes

                            • https://github.com/bruderstein/nppPluginManager/issues/119
                              Disable Plugin updates -> meaning no automatic check for updates + specific right on user\plugin base

                            • https://github.com/bruderstein/nppPluginManager/issues/133
                              Import/export installed plugins -> restore/sync current plugin constellation on a different computer/with a different user

                            • https://github.com/bruderstein/nppPluginManager/issues/42
                              Find dead links -> Create a script to check if the provided list is still consistent and all plugins\links from the list still exist

                            1 Reply Last reply Reply Quote 0
                            • pnedevP
                              pnedev
                              last edited by

                              @donho ,

                              I second what @dinkumoil said:

                              The installation path for plugins should be $Notepad++_Install_folder\plugins mainly because of the portable version of Notepad++.

                              If you decide to keep the installation destination as it is now (C:\Users<user-name>\AppData\Local\Notepad++\plugins) then perhaps the user should be asked if the plugin is to be installed only for him/her or for anyone using the computer.

                              @dinkumoil ,

                              The Notepad++ restart upon plugin installation is not very elegant since this is just a DLL being plugged into the editor and all it needs to work properly is the right sequence of notifications. Now, I don’t address here the permissions problem to install the plugin in a place needing an elevated rights - I’m not quite aware of that issue at the moment.

                              If you need to get the real plugin DLL installation path here is what I do:

                              TCHAR gDllPath[MAX_PATH];

                              BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reasonForCall, LPVOID )
                              {
                              switch (reasonForCall)
                              {
                              case DLL_PROCESS_ATTACH:
                              ::GetModuleFileName((HMODULE)hModule, gDllPath, MAX_PATH);

                              Don,

                              AFAIK, what a plugin needs to initialize properly is loading its main DLL (LoadLibrary() - this will also trigger DLL_PROCESS_ATTACH) then call getName() and getFuncsArray() and setInfo() and last send NPPN_READY notification. That should make it fully functional (unless I’m missing something).

                              In the case of updating a plugin, the plugin has to properly unregister itself with Notepad++ on DLL_PROCESS_DETACH so there are no conflicts in the consequent plugin reload.

                              donhoD 1 Reply Last reply Reply Quote 2
                              • donhoD
                                donho @pnedev
                                last edited by donho

                                @pnedev

                                The installation path for plugins should be $Notepad++_Install_folder\plugins mainly because of the portable version of Notepad++.

                                If Notepad++ is not installed in “Program Files” and doLocalConf.xml is present, Plugins Admin will install plugins into “$Notepad++_Install_folder\plugins” - is it not the case for you?

                                Edit: I just checked in current official released packages, GUP.exe, which is needed by Plugins Admin, is not available in any zip packages (and it should not be, since GUP.exe will get installer EXE and execute it - that’s not the expected behaviour of portable version). I have no (yet) a perfect solution for it. So both GUP.exe and nppPluginList.dll will only be included in installer in the next release.

                                The Notepad++ restart upon plugin installation is not very elegant since this is just a DLL being plugged into the editor and all it needs to work properly is the right sequence of notifications.

                                I couldn’t agree more.

                                AFAIK, what a plugin needs to initialize properly is loading its main DLL (LoadLibrary() - this will also trigger DLL_PROCESS_ATTACH) then call getName() and getFuncsArray() and setInfo() and last send NPPN_READY notification. That should make it fully functional (unless I’m missing something).
                                In the case of updating a plugin, the plugin has to properly unregister itself with Notepad++ on DLL_PROCESS_DETACH so there are no conflicts in the consequent plugin reload.

                                Yes, that’s my point. The process to load a just installed plugin is the same as the one which is loaded from the startup of Notepad++.
                                Is there any other plugin doesn’t work after its installation by Plugins Admin?

                                1 Reply Last reply Reply Quote 2
                                • dinkumoilD
                                  dinkumoil
                                  last edited by

                                  @pnedev
                                  Thank you for your code snippet. I had this method not in mind because in Delphi the DLL entry function is hidden in the RTL. It is only possible to install a hook function with the following signature DllMain(DWORD reasonForCall). The DLL instance handle has to be obtained from a global variable called HInstance.

                                  @pnedev said:

                                  The Notepad++ restart upon plugin installation is not very elegant since this is just a DLL being plugged into the editor and all it needs to work properly is the right sequence of notifications.

                                  what a plugin needs to initialize properly is loading its main DLL (LoadLibrary() - this will also trigger DLL_PROCESS_ATTACH) then call getName() and getFuncsArray() and setInfo() and last send NPPN_READY notification.

                                  Yes, this should do the thing but NppFTP seems to be an example where this sequence isn’t sufficient. Maybe there are other plugins where it is the same (Wild guessing: There could be required some WM_XXX messages, in the worst case this may be plugin dependent).

                                  My point is the following:

                                  • Plugin installation happens only one times, also uninstallation. In contrast updating a plugin happens more frequently.
                                  • Performing plugin updates restart-free is (as far as I know) a complicated thing, at all it makes no sense (see below).
                                  • If it is not possible to update plugins restart-free why there should be invested effort to make installations restart-free?

                                  Why do I think restart-free plugin updates are complicated?

                                  Plugins can manipulate the UI of Npp in various ways:

                                  1. Inserting icons into the toolbar.
                                  2. Inserting icons into menus (Menu Icons plugin).
                                  3. Manipulating the whole toolbar (Customize Toolbar plugin).
                                  4. Adding an entry to the Plugins menu including a submenu.
                                  5. Adding other menu entries in arbitrary menus of Npp (ToolBucket plugin) or even adding a new menu in the menu bar (TextFX plugin).
                                  6. Opening (docked) windows and modeless dialogs.
                                  7. Inserting new windows in Npp’s UI (e.g. HEX editor’s address bar above the hex data).

                                  All these manipulations have to be reverted when updating a plugin before Npp unloads its DLL and this case should be distinguishable from simply terminating Npp, thus it can’t be done in DllMain as a reaction to a DLL_PROCESS_DETACH call - there has to be a new Npp notification to inform plugins that they are about to be uninstalled (updating is a sequence of uninstall - install).

                                  Furthermore, currently there is only a NPPM_ADDTOOLBARICON and no NPPM_REMOVETOOLBARICON (see 1.); there is only a method to add entries to the plugin’s submenu in the Plugins menu and no method to remove them (see 4.); the other points (2., 3., 5., 6. and 7.) are based solely on plugin code and require more or less effort to revert them.

                                  Why do I think restart-free plugin updates make no sense?

                                  There are two categories of plugins:

                                  • Stateless plugins
                                  • Stateful plugins

                                  Stateless plugins perform simple actions, e.g. my AutoCodepage plugin (it monitors user actions and switches the document encoding scheme if neccessary) or @donho 's PorkToSausage (works only on-demand). These plugins are not critical for restart-free plugin updates.

                                  Stateful plugins create a state by themself, e.g. NppFTP, @pnedev 's Compare plugin, scripting plugins with debugging capabilities (e.g. CS-Script) or the HEX editor plugin. These plugins are critical for restart-free plugin updates.

                                  A state includes:

                                  • open windows (all plugins mentioned above)
                                  • open network connections (NppFTP)
                                  • set path for FTP session (NppFTP)
                                  • processing data and displaying results (Compare)
                                  • state of a debug session (CS-Script)
                                  • maybe more that I’m not aware of at the moment

                                  To restore this state after a plugin update requires much effort, I guess that nobody wants to do that, maybe its even impossible. Thus restart-free updating makes no sense - after updating users would have to restore the desired state by themself, there would be no benefit compared to the current situation.

                                  1 Reply Last reply Reply Quote 1
                                  • pnedevP
                                    pnedev
                                    last edited by

                                    @donho ,

                                    If Notepad++ is not installed in “Program Files” and doLocalConf.xml is present, Plugins Admin will install plugins into “$Notepad++_Install_folder\plugins” - is it not the case for you?

                                    I haven’t tried with portable Notepad++ yet. I just have Notepad++ installed in Program Files (x86) and after installing NppGTags plugin via Plugins Admin it is put in C:\Users\<user-name>\AppData\Local\Notepad++\plugins.

                                    Is there any other plugin doesn’t work after its installation by Plugins Admin?

                                    Yes, NppGTags is also not functional after installation via Plugins Admin. After Notepad++ restart everything is working as expected.

                                    @dinkumoil ,

                                    Maybe there are other plugins where it is the same

                                    You are correct - NppGTags is also not working without Notepad++ restart at the moment.

                                    There could be required some WM_XXX messages, in the worst case this may be plugin dependent

                                    Hm, those messages should be a consequence of loading a plugin so they should be there.

                                    You have provided a very thorough description of the plugin update problem, good points there.

                                    Well, I agree that if updating a plugin is such a pain then it is not worth the work to make it restart-free so basically I agree with you.

                                    Just as a note about the Plugins menu - I suppose Notepad++ knows which menu entries are connected to which plugin (it has some internal ID) and will remove them on plugin’s behalf when unloading it.

                                    1 Reply Last reply Reply Quote 1
                                    • chcgC
                                      chcg
                                      last edited by

                                      Maybe an additional flag “RestartRequired” in the json could do the magic to distinguish between plugins updateable on-the-fly and the ones which are not.

                                      1 Reply Last reply Reply Quote 0
                                      • donhoD
                                        donho
                                        last edited by

                                        @dinkumoil

                                        Good point.
                                        The installation will follow update behaviour - ie. quit Notepad++, install the plugins then restart Notepad++.
                                        All the binaries are updated in the following link:
                                        https://notepad-plus-plus.org/pluginListTestTools/

                                        1 Reply Last reply Reply Quote 3
                                        • dinkumoilD
                                          dinkumoil
                                          last edited by

                                          @donho

                                          I’ve tested the new binaries. Here are the results.

                                          1. If the SHA-256 hash of a plugin ZIP file is provided with uppercase letters plugin installation fails, saying that the hash value is wrong and the plugin is about to be deleted. Wouldn’t it be better to check hashes case insensitive?
                                          2. If the download URL for a plugin ZIP file is wrong plugin installation fails, saying that the hash value is wrong and the plugin is about to be deleted. There should be a better error message pointing to the actual cause of the error.
                                          3. Portable installations of Npp install plugins under <folder-of-portable-Npp>\plugins\<plugin-name> whereas local installations of Npp install them under <Userprofile>\AppData\Local\Notepad++\plugins\<plugin-name>. The plugins which are packaged with Npp installer are always stored under <Npp-folder>\plugins\<plugin-name>. This is confusing and additionally there is a pitfall when upgrading from Npp 32 bit to Npp 64 bit (local installations) - the plugins for both architectures are stored in the same location (<Userprofile>\AppData\Local\Notepad++\plugins\<plugin-name>) thus at first start of newly installed 64 bit Npp users will be confrontated with a bunch of alert boxes stating that plugin XYZ is not suitable for the current version of Npp.
                                          4. In these alert boxes users can choose to remove the plugin in question to avoid the same error message at next start of Npp. But the plugin gets not deleted.
                                          5. In the 32 bit version of the plugin list (pl.x86.json) currently is a syntax error. You left a semicolon instead of a comma before the block of the NppSaveAsAdmin plugin.

                                          Points 3. and 4. make me to ask again if it wouldn’t be better to install plugins in all cases under <Npp-folder>\plugins\<plugin-name>. Plugin installations are performed with a restart now. I guess GUP is actually doing the job to copy plugin files, it would be easy to start it with admin rights (ShellExecute with verb runas) so it is able to copy files even to a subfolder of C:\Program Files.

                                          To cope with the current situation I had to reimplement the function to get the plugin DLL path (which is now identical with the path for all companion files of the plugin, e.g documentation, help files), a code change which has to be done for many other plugins too (with all the problems caused by that fact I already mentioned).

                                          1 Reply Last reply Reply Quote 4
                                          • donhoD
                                            donho
                                            last edited by donho

                                            @dinkumoil

                                            Thank you for your tests and pertinent suggestions.

                                            Wouldn’t it be better to check hashes case insensitive?

                                            Done. Both 32/64 bits of GUP.exe are updated and available to download now.

                                            In the 32 bit version of the plugin list (pl.x86.json) currently is a syntax error. You left a semicolon instead of a comma before the block of the NppSaveAsAdmin plugin.

                                            Fixed and committed.

                                            Points 3. and 4. make me to ask again if it wouldn’t be better to install plugins in all cases under <Npp-folder>\plugins<plugin-name>.

                                            The reason of installation to <Userprofile>\AppData\Local\Notepad++\plugins\<plugin-name> is Microsoft’s Universal Windows Platform. A UWP package is immutable so there’s no way to install plugins into Notepad++ installation directory. That says, in the next release while Notepad++ installation if the installation destination is in “Program files”, Notepad++ installer will install the default plugins into <Userprofile>\AppData\Local\Notepad++\plugins\<plugin-name> and Notepad++ loads the plugins only from <Userprofile>\AppData\Local\Notepad++\plugins\<plugin-name>.

                                            1 Reply Last reply Reply Quote 5
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors