LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IInfo Class Referenceabstract

Required interface for every plugin. More...

#include "iinfo.h"

Public Member Functions

virtual void Init (ICoreProxy_ptr proxy)=0
 Initializes the plugin. More...
 
virtual void SecondInit ()=0
 Performs second stage of initialization. More...
 
virtual QByteArray GetUniqueID () const =0
 Returns the unique ID of the plugin. More...
 
virtual QString GetName () const =0
 Returns the name of the plugin. More...
 
virtual QString GetInfo () const =0
 Returns the information string about the plugin. More...
 
virtual QStringList Provides () const
 Returns the list of provided features. More...
 
virtual QStringList Needs () const
 Returns the list of needed features. More...
 
virtual QStringList Uses () const
 Returns the list of used features. More...
 
virtual void SetProvider (QObject *object, const QString &feature)
 Sets the provider plugin for a given feature. More...
 
virtual void Release ()=0
 Destroys the plugin. More...
 
virtual QIcon GetIcon () const =0
 Returns the plugin icon. More...
 
virtual ~IInfo ()
 Virtual destructor. More...
 
virtual void gotEntity (const LC::Entity &entity)
 
virtual void SetProxy (ICoreProxy_ptr)=0
 

Detailed Description

Required interface for every plugin.

This interface is a base for all plugins loadable by LeechCraft. If a plugin doesn't provide this interface (qobject_cast<IInfo*> to it fails), it would be considered as a malformed one and would be unloaded.

The initialization of plugins is split into two stages: Init() and SecondInit().

In the first one plugins ought to initialize their data structures, allocate memory and perform other initializations that don't depend depend on other plugins. After the first stage (after Init()) the plugin should be in a usable state: no call shall fail because required data hasn't been initialized.

In the second stage, SecondInit(), plugins can fill the data that depends on other plugins. For example, in SecondInit() the Tab++ plugin, which shows a fancy tab tree, queries the MainWindow about existing tabs and about plugins that can open tabs and connects to their respective signals.

So, as the rule of thumb, if the action required to initialize your plugin depends on others - move it to SecondInit(), leaving in Init() only basic initialization/allocation stuff like allocation memory for the objects.

Definition at line 47 of file iinfo.h.

Constructor & Destructor Documentation

◆ ~IInfo()

virtual IInfo::~IInfo ( )
inlinevirtual

Virtual destructor.

Definition at line 250 of file iinfo.h.

Member Function Documentation

◆ GetIcon()

virtual QIcon IInfo::GetIcon ( ) const
pure virtual

Returns the plugin icon.

The icon is used only in GUI stuff.

Note
This function should be able to work before Init() is called.
Returns
Icon object.
See also
GetName
GetInfo

◆ GetInfo()

virtual QString IInfo::GetInfo ( ) const
pure virtual

Returns the information string about the plugin.

Information string is only used to describe the plugin to the user.

Note
This function should be able to work before Init() is called.
See also
GetName
GetInfo

◆ GetName()

virtual QString IInfo::GetName ( ) const
pure virtual

Returns the name of the plugin.

This name is used only for the UI, internal communication is done through pointers to QObjects representing plugin instance objects.

Note
This function should be able to work before Init() is called.
See also
GetInfo
GetIcon

◆ GetUniqueID()

virtual QByteArray IInfo::GetUniqueID ( ) const
pure virtual

Returns the unique ID of the plugin.

The ID should never change, event between different versions of the plugin and between renames of the plugin. It should be unique among all other plugins, thus the Vendor.AppName form is suggested. For example, Poshuku Browser plugin would return an ID like "org.LeechCraft.Poshuku", and Poshuku CleanWeb, which is Poshuku plugin, would return "org.LeechCraft.Poshuku.CleanWeb".

The ID is allowed to consist of upper- and lowercase latin letters, numbers, dots¸ plus and minus sign.

Returns
Unique and persistent ID of the plugin.

◆ gotEntity()

virtual void IInfo::gotEntity ( const LC::Entity entity)
inlinevirtual

Definition at line 252 of file iinfo.h.

◆ Init()

virtual void IInfo::Init ( ICoreProxy_ptr  proxy)
pure virtual

Initializes the plugin.

Init is called by the LeechCraft when it has finished initializing its core and is ready to initialize plugins. Generally, all initialization code should be placed into this method instead of plugin's instance object's constructor.

After this call plugin should be in a usable state. That means that all data members should be initialized, callable from other plugins etc. That also means that in this function you can't rely on other plugins being initialized.

Parameters
[in]proxyThe pointer to proxy to LeechCraft.
See also
Release
SecondInit

◆ Needs()

virtual QStringList IInfo::Needs ( ) const
inlinevirtual

Returns the list of needed features.

The return value is used by LeechCraft to calculate the dependencies between plugins and link them together by passing object pointers to SetProvider().

If not all requirements are satisfied, LeechCraft would mark the plugin as unusable and would not make it active or use its features returned by Provides() in dependency calculations. So, the returned list should mention those features that plugin can't live without and would not work at all.

The default implementation returns an empty list.

Note
This function should be able to work before Init() is called.
Returns
List of needed features.
See also
Provides
Uses
SetProvider

Definition at line 167 of file iinfo.h.

◆ Provides()

virtual QStringList IInfo::Provides ( ) const
inlinevirtual

Returns the list of provided features.

The return value is used by LeechCraft to calculate the dependencies between plugins and link them together by passing object pointers to SetProvider().

The default implementation returns an empty list.

Note
This function should be able to work before Init() is called.
Returns
List of provided features.
See also
Needs
Uses
SetProvider

Definition at line 139 of file iinfo.h.

◆ Release()

virtual void IInfo::Release ( )
pure virtual

Destroys the plugin.

This function is called to notify that the plugin would be unloaded soon - either the application is closing down or the plugin is unloaded for some reason. Plugin should free its resources and especially all the GUI stuff in this function instead of plugin instance's destructor.

See also
Init

◆ SecondInit()

virtual void IInfo::SecondInit ( )
pure virtual

Performs second stage of initialization.

This function is called when all the plugins are initialized by IInfo::Init() and may now communicate with others with no fear of getting init-order bugs.

See also
Init

◆ SetProvider()

virtual void IInfo::SetProvider ( QObject *  object,
const QString &  feature 
)
inlinevirtual

Sets the provider plugin for a given feature.

This function is called by LeechCraft after dependency calculations to inform plugin about other plugins which provide the required features.

Note
This function should be able to work before Init() is called.
Parameters
[in]objectPointer to plugin instance of feature provider.
[in]featureThe feature which this object provides.
See also
Provides
Needs
Uses

Definition at line 215 of file iinfo.h.

◆ SetProxy()

virtual void IInfo::SetProxy ( ICoreProxy_ptr  )
pure virtual

◆ Uses()

virtual QStringList IInfo::Uses ( ) const
inlinevirtual

Returns the list of used features.

The return value is used by LeechCraft to calculate the dependencies between plugins and link them together by passing object pointers to SetProvider().

If not all requirements are satisfied, LeechCraft would still consider the plugin as usable and functional, make it available to user and use the features returned by Provides() in dependency calculations. So, the return list should mention those features that plugin can use but which are not required to start it and do some basic work.

Note
This function should be able to work before Init() is called.
Returns
List of used features.
See also
Provides
Uses
SetProvider

Definition at line 194 of file iinfo.h.


The documentation for this class was generated from the following file: