From 6d9340ebbb5b942b0996053b0479827c1cf81b5a Mon Sep 17 00:00:00 2001
From: necoro <>
Date: Sat, 7 Jul 2007 08:50:33 +0000
Subject: some more documentation
---
doc/Hooks | 40 ++++++++++++++++++++++++++++++++++++
doc/Howto_Write_Plugins | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
create mode 100644 doc/Hooks
create mode 100644 doc/Howto_Write_Plugins
(limited to 'doc')
diff --git a/doc/Hooks b/doc/Hooks
new file mode 100644
index 0000000..58dabd7
--- /dev/null
+++ b/doc/Hooks
@@ -0,0 +1,40 @@
+List of hooks currently being supported by Portato
+==================================================
+
+am_i_root
+---------
+Called: When checking whether the current user is root (ie. uid == 0).
+Parameters: None
+Return if override: Boolean signaling whether we are root.
+
+
+emerge:
+-------
+Called: When emerge or every other command given by e.g. the synccmd preference is being called.
+Parameters:
+ - string[] packages: Packages to emerge (includes "world", "system").
+ - string[] command: The exact command to execute.
+ - portato.gui.wrapper.Console console: The console the output will be written to.
+
+Return if override: Nothing
+
+
+after_emerge:
+-------------
+Called: When the emerge process (or other - see emerge hook) is finished.
+Parameters:
+ - string[] packages: The list of cpv's (plus "world", "system") which have been emerged. (Or not if it failed.)
+ - int retcode: The return code of the command.
+
+Return if override: Nothing
+Comment: This uses an extra hook as emerge is started in an extra thread and thus all plugins being wanting to come "after" will be called while emerge is still running.
+
+open_ebuild:
+------------
+Called: When an ebuild window is opened.
+Parameters:
+ - portato.backend.Package package: The current package whose is going to be displayed.
+ - Window parent: The parent window. Exact type depends on the frontend.
+
+Return if override: Window-object which can be called by the frontends. Please see the explicit code to see what is expected.
+Comment: If you want to override - do this only for ONE specific frontend.
diff --git a/doc/Howto_Write_Plugins b/doc/Howto_Write_Plugins
new file mode 100644
index 0000000..660b45b
--- /dev/null
+++ b/doc/Howto_Write_Plugins
@@ -0,0 +1,54 @@
+HowTo Write A Plugin For Portato
+=================================
+
+(NOTE: The XML schema is likely to change in the future.)
+
+Writing a plugin is (quite) simple. You have to provide a XML file which tells portato how to communicate with the plugin and in most cases a Python module doing the actual work. This howto is not going to cover the writing of the plugin, but only the XML.
+
+General
+-------
+
+So - how is a plugin is working in general? Portato defines a set of hooks (see the Hooks file for a complete list) to which your plugin can connect. For each hook you have three choices: To connect before, after or instead of the function being hooked. (Of course you can connect several times to one hook ...) The latter one should be used only if you really know what you are doing as it is likely that Portato won't work any longer after this. Also have in mind, that only one plugin can override. Thus: if several plugins want to override one hook, a randomly chosen one will get the allowance.
+
+For each of the "before" and "after" mode a queue exists, holding the plugins to execute. A plugin is allowed to state another plugin which should be executed after (in "before" mode) or before (in "after" mode) your plugin. The star * exists to note that this should be applied to ALL other plugins. Portato TRIES to satisfy your request...
+
+When you now have chosen the connect(s) to chose you write an appropriate function (or better: a Python callable) which will be given in the XML-definition to be called by Portato with the hook's arguments. (Hint: All arguments will be passed as keyword parameters. So you can easily pick the ones you need and add a "**kwargs" argument, which will take the rest. As a nice side effect you do not have to reflect any API changes which will come with additional parameters :)).
+
+Finally: Add an import tag stating the module to import to execute the function(s) given - and you are done.
+
+Sample XML
+----------
+
+At the point of writing this, there is no XSD or DTD - so you cannot validate the file. But this will change at some point of time ;).
+
+
+