Difference between revisions of "MythPlugin Architecture"

From MythTV Official Wiki
Jump to: navigation, search
(Plugin User Interface)
m (Added category to make this page easier (possible?) to find.)
Line 34: Line 34:
 
== Menu Integration ==
 
== Menu Integration ==
 
[todo: add a basic overview of the mythmenu system. perhaps this should be a separate page and cover more than just plugin menu directives?]
 
[todo: add a basic overview of the mythmenu system. perhaps this should be a separate page and cover more than just plugin menu directives?]
 +
 +
 +
[[Category:Developer Documentation]]

Revision as of 00:42, 22 October 2006

Page Purpose

The purpose of this page is to provide general information and tips for someone interested in developing a plugin for myth. This page aims to answer questions a new MythTV Plugins developer may have that are not addressed elsewhere.


Architecture Overview

MythPlugins are written in C++ and are compiled as shared object files. Myth looks for plugins in a specific location relative to its own installation location and invokes them via three methods.

The first of these methods, mythplugin_init, is called whenever mythfrontend is started. This method typically handles upgrading gracefully as it will be the first method called after a new version of the plugin has been installed.

The second of these methods, mythplugin_run, is invoked when the action attribute of a menu item requests it via the PLUGIN directive. This is the method that should be run when the user chooses to enter the plugin from the main menu or the appropriate submenu.

The third of these methods, mythplugin_config, is invoked when the action attribute of a menu item requests tit via the CONFIGPLUGIN directive. This is the method that should be run when the users wishes to configure the plugin.


Development Strategy

The best way to understand the MythTV Plugin Architecture and how to use it is simply to start examining the source code of existing plugins. The MythGame plugin is fairly simple from a user interface standpoint as is the MythMovies plugin currently only available via Trac [1].

Plugin User Interface

MythTV has an internal user interface system that plugins generally use to establish their graphical user interfaces. The user interface parameters are stored in an XML file with a filename ending in "-ui.xml." This file is referenced by the MythThemedDialog class by supplying the portion of the filename prior to "-ui.xml" to its constructor. For example, a plugin which stored its GUI info in helloworld-ui.xml would pass "helloworld" to MythThemedDialog.

A plugin's UI code can then obtain handles to the graphical elements established by MythThemedDialog by executing the appropriate getUI[object type]Type function, passing in the name of the object to get. For example, to obtain a reference to a textbox named "hellobox", the following code could be used:

UITextType *helloBox = getUITextType("hellobox");

One can then interact with the helloBox object using various methods for the purpose of providing the user interface functionality.

[todo: add information about intercepting/processing keypresses]

Saving/Retrieving Settings

[todo: add explanation of gContext->Save/GetSettings]

Menu Integration

[todo: add a basic overview of the mythmenu system. perhaps this should be a separate page and cover more than just plugin menu directives?]