Window plugin showing up as process (1 Viewer)

Hesse

Portal Pro
August 8, 2006
110
0
I'm almost ready to release my very first plugin (and C# program) for MediaPortal. It is an importer for extreme movie manager. The last issue I have is that my plugin shows up in the process plugins section when I thought it should show up in the Windows plugins section.

I followed the directions on the wiki and my definition for the class that interacts with MP is:

Code:
public class XMMImporterPlugin : GUIWindow, ISetupForm

However, it shows up in process plugins even though I put the dll in the windows plugins directory. Does anyone have any suggestions on what's going on? I'd like to be able to fix so I can release the first version.

Actually, the plugin doesn't have any GUI code in it right now. Its only to import information outside of mediaPortal. Is that why its showing up as a process plugin?

Thanks

Jesse
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
If its suppose to be a window plugin, you need a valid windowID (use one that's below 10000, and not currently used - see the enumeration in GUIWindow.cs for the currently allocated ones) and you also need to make sure the GetHome function in the ISetupForm interface returns values, e.g.

bool MediaPortal.GUI.Library.ISetupForm.GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
{
strButtonText = "Multi Thread Demo";
strButtonImage = "";
strButtonImageFocus = "";
strPictureImage = "";

return true;

}

I think you also need to implement the IShowPlugin interface.

Sam
 

Hesse

Portal Pro
August 8, 2006
110
0
I haven't seen anyone else using the IShowPlugin interface.

I added return values to the GetHome function and also return true now, but it is still showing up as a process plugin. I looked in the GUIWindow.cs file and I didn't see a list of plugin IDs in the enumeration section. There really wasn't a whole lot there. Is it maybe in a different file?

Here's the whole code in case someone sees something I missed.

Jesse


Code:
#region Copyright (C) 2006 Team MediaPortal

/* 
 *      Copyright (C) 2006 Team MediaPortal
 *      https://www.team-mediaportal.com
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#endregion

#region XMMImporter: Version History

/*
 *     XMM Importer
 * 
 *     Plugin to allow converting Extreme Movie Manager (XMM) databases to
 *     MediaPortal.
 * 
 * 060827 - JBL - 0.0.0.1
 * Started 060819.
 * 
 * This is my first attempt at a C# program and plugin for MediaPortal.  This first
 * version of XMM Importer is capable of reading Extreme Movie Manager v5 database
 * files and converting the video data into a MediaPortal video database.
 * 
 * Current Version Features:
 * + Configuration control through a MediaPortal plugin interface and a
 *   windows form.
 * + Capable of reading XMM v5 database files.
 * + Automatically copies cover files to specified MediaPortal thumbnail directory.
 * 
 * Future Work:
 * + Auto detect MediaPortal directories and database files
 * + Save settings to XML or SQLite database to retain settings between uses.
 * + Allow for importing multiple databases by allowing multiple settings in configuration
 *   file
 * + Add more control over import information
 * + Relook over SQLite.NET and other MP database code to see if it would work better
 *   than the current method of working with SQLite databases
 * + Clean up and add more comments to code for next version
 * 
 * Known Issues:
 * + The method of access the MP databases probably isn't optimal.  It is currently done
 *   using the alternative SQLite interface and a data reader has to be generated each
 *   time a query needs to be made.  It seems there should be a better way, but seems to
 *   work OK for now.
 * + There are no warnings before clearing the data in the video database.  The next
 *   version should include a warning and even backup the MP video database before working
 *   on it.
 * + Only tried on US English version of Windows.  May not be compatable with different
 *   character sets, but remains to be seen.
 * 
 */
#endregion


using System;
using System.Collections.Generic;
using System.Text;
//using System.ComponentModel;
using System.Windows.Forms;
using MediaPortal.GUI.Library;


namespace GUIXMM
{ 
  /// <summary>
  /// CLASS: XMMImporterPlugin
  /// This is the main plugin interface to MediaPortal.
  /// </summary>
  public class XMMImporterPlugin : GUIWindow, ISetupForm
  {
    public XMMImporterPlugin()
    {
    }

    #region ISetupForm Members
    
    //Returns the name of the plugin which is shown in the plugin menu
    public string PluginName()
    {
      return "XMMImporter";
    }
    //Returns the description of the plugin is shown in the plugin menu
    public string Description()
    {
      return "Imports XMM Libraries into the MediaPortal database";
    }
    // Returns the author of the plugin which is shown in the plugin menu
    public string Author()
    {
      return "Hesse";
    }
    // Show the setup dialog
    public void ShowPlugin()
    {
      //MessageBox.Show("Nothing to do now");
      XMMImportForm myXMMImporterForm = new XMMImportForm();
      myXMMImporterForm.Show();
    }
    //Indicates whether plugin can be enabled/disabled
    public bool CanEnable()
    {
      return true;
    }
    // Indicates if a plugin is enabled by default
    public bool DefaultEnabled()
    {
      return false;
    }
    // get ID Of windowplugin belonging to this setup
    public int GetWindowId()
    {
      return 4444;
    }
    // Indicates if a plugin has its own setup screen
    public bool HasSetup()
    {
      return true;
    }

    /// <summary>
    /// If the plugin should have its own button on the main menu of Media Portal then it
    /// should return true to this method, otherwise if it should not be on home
    /// it should return false
    /// </summary>
    /// <param name="strButtonText">text the button should have</param>
    /// <param name="strButtonImage">image for the button, or empty for default</param>
    /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    /// <returns>true : plugin needs its own button on home
    ///          false : plugin does not need its own button on home</returns>

    public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
    {
      strButtonText = "XMMImporter";
      strButtonImage = "";
      strButtonImageFocus = "";
      strPictureImage = "";
      return true;
    }
    #endregion

  }
}
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
Ok, I've just looked through the configuration source code, and it seems like you need to ensure that the GetWindowID method from ISetupForm returns a windowID that corresponds to one of the classes in your plugin that inherits from GUIWindow.

Make sure you override the GetID method in the class that inherits from GUIWindow so that it returns a correct WindowID. Different windows should have different WindowIDs, but the one returned from the GetWindowID ISetupForm method has to match one of the windows.

Sam
 

Hesse

Portal Pro
August 8, 2006
110
0
samuel337,

You lost me a bit there, sorry. This is my first attempt at any real program, so please forgive my ignorance.

I have the GetWindowId method in the code I showed a few posts back that is part of the class that is associated with GUIWindow. I don't have any other classes at this time that are associated with GUIWindow. Are you saying there needs to be another class that is associated with GUIWindow that has a method GetID that returns the same number as the main class? Can you tell I'm confused?
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
Ok, I'll use your previous code example to demo what I mean. See the stuff in bold.

Code:
#region Copyright (C) 2006 Team MediaPortal

/* 
 *      Copyright (C) 2006 Team MediaPortal
 *      https://www.team-mediaportal.com
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#endregion

#region XMMImporter: Version History

/*
 *     XMM Importer
 * 
 *     Plugin to allow converting Extreme Movie Manager (XMM) databases to
 *     MediaPortal.
 * 
 * 060827 - JBL - 0.0.0.1
 * Started 060819.
 * 
 * This is my first attempt at a C# program and plugin for MediaPortal.  This first
 * version of XMM Importer is capable of reading Extreme Movie Manager v5 database
 * files and converting the video data into a MediaPortal video database.
 * 
 * Current Version Features:
 * + Configuration control through a MediaPortal plugin interface and a
 *   windows form.
 * + Capable of reading XMM v5 database files.
 * + Automatically copies cover files to specified MediaPortal thumbnail directory.
 * 
 * Future Work:
 * + Auto detect MediaPortal directories and database files
 * + Save settings to XML or SQLite database to retain settings between uses.
 * + Allow for importing multiple databases by allowing multiple settings in configuration
 *   file
 * + Add more control over import information
 * + Relook over SQLite.NET and other MP database code to see if it would work better
 *   than the current method of working with SQLite databases
 * + Clean up and add more comments to code for next version
 * 
 * Known Issues:
 * + The method of access the MP databases probably isn't optimal.  It is currently done
 *   using the alternative SQLite interface and a data reader has to be generated each
 *   time a query needs to be made.  It seems there should be a better way, but seems to
 *   work OK for now.
 * + There are no warnings before clearing the data in the video database.  The next
 *   version should include a warning and even backup the MP video database before working
 *   on it.
 * + Only tried on US English version of Windows.  May not be compatable with different
 *   character sets, but remains to be seen.
 * 
 */
#endregion


using System;
using System.Collections.Generic;
using System.Text;
//using System.ComponentModel;
using System.Windows.Forms;
using MediaPortal.GUI.Library;


namespace GUIXMM
{ 
  /// <summary>
  /// CLASS: XMMImporterPlugin
  /// This is the main plugin interface to MediaPortal.
  /// </summary>
  public class XMMImporterPlugin : GUIWindow, ISetupForm
  {
    public XMMImporterPlugin()
    {
            [b]
   //as you have inherited from GUIWindow in this class, you need to specify a windowId for this window. To do this, do the following:

             GetID=(int)4444;

   // GetID is a property in the GUIWindow class.
[/b]
    }

    #region ISetupForm Members
    
    //Returns the name of the plugin which is shown in the plugin menu
    public string PluginName()
    {
      return "XMMImporter";
    }
    //Returns the description of the plugin is shown in the plugin menu
    public string Description()
    {
      return "Imports XMM Libraries into the MediaPortal database";
    }
    // Returns the author of the plugin which is shown in the plugin menu
    public string Author()
    {
      return "Hesse";
    }
    // Show the setup dialog
    public void ShowPlugin()
    {
      //MessageBox.Show("Nothing to do now");
      XMMImportForm myXMMImporterForm = new XMMImportForm();
      myXMMImporterForm.Show();
    }
    //Indicates whether plugin can be enabled/disabled
    public bool CanEnable()
    {
      return true;
    }
    // Indicates if a plugin is enabled by default
    public bool DefaultEnabled()
    {
      return false;
    }
    // get ID Of windowplugin belonging to this setup
    public int GetWindowId()
    {
      [b]return 4444;  //this window ID has to be *one* of the window ids of your windows - a window is defined as a class that has inherited from GUIWindow.[/b]
    }
    // Indicates if a plugin has its own setup screen
    public bool HasSetup()
    {
      return true;
    }

    /// <summary>
    /// If the plugin should have its own button on the main menu of Media Portal then it
    /// should return true to this method, otherwise if it should not be on home
    /// it should return false
    /// </summary>
    /// <param name="strButtonText">text the button should have</param>
    /// <param name="strButtonImage">image for the button, or empty for default</param>
    /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    /// <returns>true : plugin needs its own button on home
    ///          false : plugin does not need its own button on home</returns>

    public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
    {
      strButtonText = "XMMImporter";
      strButtonImage = "";
      strButtonImageFocus = "";
      strPictureImage = "";
      return true;
    }
    #endregion

  }

   
}

That should fix it.

BTW, when you inherited from GUIWindow, you should also override the following methods to do things like load the skin, capture actions/messages etc. Here's the overrides you should do:

Code:
            #region Overrides

            public override bool Init()
            {
                return Load(MediaPortal.GUI.Library.GUIGraphicsContext.Skin + @"\threaddemo.xml");
            }

        public override void OnAction(MediaPortal.GUI.Library.Action action)
            {
                switch (action.wID)
                {
                    case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU:
                        {
                            MediaPortal.GUI.Library.GUIWindowManager.ShowPreviousWindow();
                            return;
                        }
                }

                base.OnAction(action);
            }

            public override bool OnMessage(MediaPortal.GUI.Library.GUIMessage message)
            {
                switch (message.Message)
                {

                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
                        {
                            base.OnMessage(message);
                            
//code here runs every time the window is displayed
MediaPortal.GUI.Library.GUIPropertyManager.SetProperty("#currentmodule", "Plugin Name");
                            
                            break;
                        }
                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_CLICKED:
                        {

                            break;
                        }

                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
                        {

                        }
                        break;

                }
                return base.OnMessage(message);

            }
            #endregion

HTH

Sam
 

Hesse

Portal Pro
August 8, 2006
110
0
sam,

I will try it. You have always been very helpful, thanks so much.

Jesse
 

Users who are viewing this thread

Top Bottom