Plasma/ShareLikeConnect: Difference between revisions

From KDE Community Wiki
(Created page with "= Share Like Connect = == Story == A very useful feature in many applications is sharing their content with a Web service. Many of them implement this feature, but with a diff...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Share Like Connect =
= Share Like Connect =
== Story ==
== Use scenario ==
A very useful feature in many applications is sharing their content with a Web service.
A very useful feature in many applications is sharing their content with a Web service.
Many of them implement this feature, but with a different implementation, a different set of services and a different user interface.
Many of them implement this feature, but with a different implementation, a different set of services and a different user interface.
Line 11: Line 11:


=== DBus ===
=== DBus ===
Share Like Connect knows what resource the user wants to share thanks to a DBus interface, registered on the bus name
org.kde.kactivitymanagerd
on the object
SLC/org.kde.ActivityManager.SLC
with the methods focussedResourceURI, focussedResourceMimeType, focussedResourceTitle to set the current focused uri, its mime type and its user-readable name. The resource that will be shared is always the currently focused one.


==== Exposing your application to SLC  with KActivities ====
==== Exposing your application to SLC  with KActivities ====
You don't have to use directly DBus, use instead the KActivities::ResourceInstance class coming from the '''kactivities''' library ([http://api.kde.org/4.x-api/kdelibs-apidocs/kactivities/html/classKActivities_1_1ResourceInstance.html API doc]).


=== Plasma Applet ===
=== Plasma Applet ===
The Share, Like and Connect actions are shown by a Plasma applet, positioned by default in the panel.
Each of those 3 actions will be represented by an icon, "active" only if there is a "current URI" advertised by the focused window and there is at least one plugin that supports the action for the current URI.


=== Plasma DataEngine ===
=== Plasma DataEngine ===
The Plasma Share Like Connect DataEngine is identified by the plugin name '''org.kde.sharelikeconnect'''.
It has 4 sources:
* '''Current Content''': It identifies the current content exposed by the focused window, it has 4 keys:
** ''Title'' : User readable name for the exposed resource
** ''Mime Type'': mime type of the exposed resource
** ''URI'': uri of the exposed resource, such as a file path or an Http URL
** ''Window ID'': id of the currently focused window
* ''Share'': It has a key for each provider plugin that supports the share action, the name as the plugin name of the provider. The value is an hash itself, with 2 keys:
** ''providerId'': plugin name of the provider, same as the key value.
** ''name'': user readable name for the provider plugin.
* ''Like'': It has a key for each provider plugin that supports the like action, same structure as Share
* ''Connect'': It has a key for each provider plugin that supports the connect action, same structure as Share
=== Plasma Service ===
The ''Share'', ''Like'' and ''Connect'' sources have an associated Service: it supports a singleoperation:
''executeAction'', which has 3 parameters:
* ''ActionName'': valid only ''Share'', ''Like'' or ''Connect''
* ''Comment'': optional comment string inserted by the user: not all the providers will use it
* ''Targets'': optional list of urls, may be used as a list of activities, tags, or any other meaning the provider will assign to it


=== Dataengine Plugins ===
=== Provider Plugins ===


=== Public API ===
=== Public API ===

Latest revision as of 20:30, 7 January 2013

Share Like Connect

Use scenario

A very useful feature in many applications is sharing their content with a Web service. Many of them implement this feature, but with a different implementation, a different set of services and a different user interface. A similar problem is connecting Application content to the activities, assigning tags or rating files.

Solution: a common user interface that lives right in the workspace, that is shared between all applications that want to share something on the web or connect items to activities.

Architecture

The Share Like Connect framework is composed of many parts:

DBus

Share Like Connect knows what resource the user wants to share thanks to a DBus interface, registered on the bus name

org.kde.kactivitymanagerd

on the object

SLC/org.kde.ActivityManager.SLC

with the methods focussedResourceURI, focussedResourceMimeType, focussedResourceTitle to set the current focused uri, its mime type and its user-readable name. The resource that will be shared is always the currently focused one.

Exposing your application to SLC with KActivities

You don't have to use directly DBus, use instead the KActivities::ResourceInstance class coming from the kactivities library (API doc).

Plasma Applet

The Share, Like and Connect actions are shown by a Plasma applet, positioned by default in the panel. Each of those 3 actions will be represented by an icon, "active" only if there is a "current URI" advertised by the focused window and there is at least one plugin that supports the action for the current URI.

Plasma DataEngine

The Plasma Share Like Connect DataEngine is identified by the plugin name org.kde.sharelikeconnect. It has 4 sources:

  • Current Content: It identifies the current content exposed by the focused window, it has 4 keys:
    • Title : User readable name for the exposed resource
    • Mime Type: mime type of the exposed resource
    • URI: uri of the exposed resource, such as a file path or an Http URL
    • Window ID: id of the currently focused window
  • Share: It has a key for each provider plugin that supports the share action, the name as the plugin name of the provider. The value is an hash itself, with 2 keys:
    • providerId: plugin name of the provider, same as the key value.
    • name: user readable name for the provider plugin.
  • Like: It has a key for each provider plugin that supports the like action, same structure as Share
  • Connect: It has a key for each provider plugin that supports the connect action, same structure as Share

Plasma Service

The Share, Like and Connect sources have an associated Service: it supports a singleoperation: executeAction, which has 3 parameters:

  • ActionName: valid only Share, Like or Connect
  • Comment: optional comment string inserted by the user: not all the providers will use it
  • Targets: optional list of urls, may be used as a list of activities, tags, or any other meaning the provider will assign to it

Provider Plugins

Public API

Writing a plugin

C++

JavaScript