LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LeechCraft::Entity Struct Reference

Describes parameters of an entity. More...

#include "structures.h"

Public Member Functions

 Entity ()
 

Public Attributes

QVariant Entity_
 The entity that this object represents. More...
 
QString Location_
 Source or destination. More...
 
QString Mime_
 MIME type of the entity. More...
 
TaskParameters Parameters_
 Parameters of this task. More...
 
QMap< QString, QVariant > Additional_
 Additional parameters. More...
 

Detailed Description

Describes parameters of an entity.

This struct is used both for addition of new download tasks and for announcing about finished/available entities, so its members are context-dependent.

This is generally used for communications between different plugins. So, it can be thought as a general packet or message.

There are two kinds of messages: notifications and delegation requests.

First ones are asynchronous. They are used by plugins to notify Core and other plugins about events like download completion. In this case plugin that emits this notification doesn't care what happens next. For example, a bittorrent client that just finished downloading some files would emit a notification about those files.

For notification messages the following signal is used: gotEntity (const LeechCraft::Entity& entity).

The second type of messages, delegation requests, is used by plugins to delegate a given task to other plugins. For example, an RSS feed reader uses this kind of messages to delegate the downloading of the feeds via HTTP to a plugin that can handle HTTP. The signal that is used to emit this messages obviously blocks. After emitting the signal one could get the id and pointer to object that handles the request.

For delegation requests the following signal is used: delegateEntity (const LeechCraft::Entity& entity, int *id, QObject **object);

There is also a third signal related to messaging: couldHandle (const LeechCraft::Entity& entity, bool *could);

It queries whether there are plugins that could handle the given entity. It also blocks. After emitting this signal the could variable would be set up accordingly.

See also
LeechCraft::TaskParameter

Definition at line 156 of file structures.h.

Constructor & Destructor Documentation

LeechCraft::Entity::Entity ( )
inline

Definition at line 227 of file structures.h.

Member Data Documentation

QMap<QString, QVariant> LeechCraft::Entity::Additional_

Additional parameters.

Some predefined or commonly used ones:

  • "UserVisibleName" A QString with some text that would make sense when showed to the user. For example, if the entity is binary, this could be used to describe the entity.
  • " Tags" QStringList with IDs of tags of the entity.

Definition at line 225 of file structures.h.

Referenced by LeechCraft::Util::NotificationActionHandler::AddFunction(), LeechCraft::Util::GetPersistentData(), LeechCraft::Util::GetUserText(), LeechCraft::Util::MakeANCancel(), LeechCraft::Util::MakeANRule(), LeechCraft::Util::MakeNotification(), LeechCraft::Util::NotificationActionHandler::NotificationActionHandler(), operator<<(), LeechCraft::operator==(), operator>>(), LeechCraft::Util::ShortcutManager::RegisterGlobalShortcut(), and LeechCraft::Util::SavePassword().

QVariant LeechCraft::Entity::Entity_

The entity that this object represents.

In the context of entity delegation it represents the entity that should be downloaded or handled. For example, contents of a torrent file, a magnet link, an RSS document.

Here are some rules:

  • Local files should be a QUrl (QUrl::fromLocalFile).
  • URLs should be a QUrl as well.
  • Anything binary like contents of a torrent file should be a QByteArray.

In the context of announcing about a finished entity, it could contain previously mentioned entities as well.

Definition at line 173 of file structures.h.

Referenced by LeechCraft::Util::GetUserText(), LeechCraft::Util::MakeANCancel(), LeechCraft::Util::MakeEntity(), operator<<(), LeechCraft::operator==(), and operator>>().

QString LeechCraft::Entity::Location_

Source or destination.

In the context of entity delegation this parameter represents where the other plugin wants this job to be downloaded.

In the context of entity announce this represents from where this entity came - original URL, for example.

Definition at line 183 of file structures.h.

Referenced by LeechCraft::Util::MakeEntity(), LeechCraft::operator<(), operator<<(), LeechCraft::operator==(), and operator>>().

QString LeechCraft::Entity::Mime_

MIME type of the entity.

An empty mime is considered to be no mime.

Some predefined or commonly used ones:

  • x-leechcraft/notification A notification item. It should have a "Priority" Additional_ member with int values of enum Priority, Entity_ is expected to be a QString with notification header and Additional_ ["Text"] is expected to be the notification text. Additional_ ["NotificationActions"] may have user-readable QStringList of actions to be available in the notification, In this case, Additional_ ["HandlingObject"] must be a QObject* pointing to the handling object. This object must have the slot notificationActionTriggered(int) which would be called with the index of the selected action, if any. The index corresponds to the position in NotificationActions list.
  • x-leechcraft/plain-text-document A plaintext document. Entity_ contains the contents of the document in this case, and Additional_ ["Language"] may contain the language of this document (like C++/JS/whatever).

Definition at line 209 of file structures.h.

Referenced by LeechCraft::Util::GetUserText(), LeechCraft::Util::MakeEntity(), LeechCraft::operator<(), operator<<(), LeechCraft::operator==(), and operator>>().

TaskParameters LeechCraft::Entity::Parameters_

Parameters of this task.

Definition at line 213 of file structures.h.

Referenced by LeechCraft::Util::MakeEntity(), LeechCraft::operator<(), operator<<(), LeechCraft::operator==(), and operator>>().


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