<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.trinitydesktop.net/index.php?action=history&amp;feed=atom&amp;title=KDE_services_%28KDE3_Architecture%29</id>
	<title>KDE services (KDE3 Architecture) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.trinitydesktop.net/index.php?action=history&amp;feed=atom&amp;title=KDE_services_%28KDE3_Architecture%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.trinitydesktop.net/index.php?title=KDE_services_(KDE3_Architecture)&amp;action=history"/>
	<updated>2026-05-24T23:54:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.trinitydesktop.net/index.php?title=KDE_services_(KDE3_Architecture)&amp;diff=2235&amp;oldid=prev</id>
		<title>Blu256: + KDE3, floating TOC</title>
		<link rel="alternate" type="text/html" href="https://wiki.trinitydesktop.net/index.php?title=KDE_services_(KDE3_Architecture)&amp;diff=2235&amp;oldid=prev"/>
		<updated>2022-04-21T16:17:00Z</updated>

		<summary type="html">&lt;p&gt;+ KDE3, floating TOC&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:17, 21 April 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;{{KDE3}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;== What are KDE services? ==&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;&amp;lt;div style=&quot;float:right;&quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;a class=&quot;mw-diff-movedpara-left&quot; title=&quot;Paragraph was moved. Click to jump to new location.&quot; href=&quot;#movedpara_5_1_rhs&quot;&gt;&amp;#x26AB;&lt;/a&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;&lt;a name=&quot;movedpara_4_0_lhs&quot;&gt;&lt;/a&gt;The notion of a &#039;&#039;service&#039;&#039; is a central concept in KDE&#039;s modular architecture.&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;a class=&quot;mw-diff-movedpara-right&quot; title=&quot;Paragraph was moved. Click to jump to old location.&quot; href=&quot;#movedpara_4_0_lhs&quot;&gt;&amp;#x26AB;&lt;/a&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;&lt;a name=&quot;movedpara_5_1_rhs&quot;&gt;&lt;/a&gt;The notion of a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&#039;&lt;/ins&gt;&#039;&#039;service&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&#039;&lt;/ins&gt;&#039;&#039; is a central concept in KDE&#039;s modular architecture.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;There is no strict technical implementation connected with this term - services&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;There is no strict technical implementation connected with this term - services&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;can be plugins in the form of shared libraries, or they can be programs&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;can be plugins in the form of shared libraries, or they can be programs&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;changed without affecting the application. Also, the user can configure which&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;changed without affecting the application. Also, the user can configure which&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;services he prefers for certain features.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;services he prefers for certain features.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;== Examples ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;Some examples:&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;Some examples:&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;*In KDevelop HEAD, most functionality is packaged in plugins with the service type KDevelop/Part. At startup, all services with this type are loaded, such that you can extend the IDE in a very flexible way.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;*In KDevelop HEAD, most functionality is packaged in plugins with the service type KDevelop/Part. At startup, all services with this type are loaded, such that you can extend the IDE in a very flexible way.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;*In the icon view, Konqueror displays - if enabled - thumbnail pictures of images, HTML pages, PDF and text files. This ability can be extended. If you want it to display preview pictures of your own data files with some MIME type, you can implement a service with service type ThumbCreator.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;*In the icon view, Konqueror displays - if enabled - thumbnail pictures of images, HTML pages, PDF and text files. This ability can be extended. If you want it to display preview pictures of your own data files with some MIME type, you can implement a service with service type ThumbCreator.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;== Service properties ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;Obviously, a service is not only characterized by the service types it&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;Obviously, a service is not only characterized by the service types it&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;!-- diff cache key mwdb:diff:wikidiff2:1.12:old-360:rev-2235:1.13.0 --&gt;
&lt;/table&gt;</summary>
		<author><name>Blu256</name></author>
	</entry>
	<entry>
		<id>https://wiki.trinitydesktop.net/index.php?title=KDE_services_(KDE3_Architecture)&amp;diff=360&amp;oldid=prev</id>
		<title>imported&gt;Eliddell: Created page with &quot;== What are KDE services? ==  The notion of a &#039;&#039;service&#039;&#039; is a central concept in KDE&#039;s modular architecture. There is no strict technical implementation connected with this t...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.trinitydesktop.net/index.php?title=KDE_services_(KDE3_Architecture)&amp;diff=360&amp;oldid=prev"/>
		<updated>2014-06-01T22:46:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== What are KDE services? ==  The notion of a &amp;#039;&amp;#039;service&amp;#039;&amp;#039; is a central concept in KDE&amp;#039;s modular architecture. There is no strict technical implementation connected with this t...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== What are KDE services? ==&lt;br /&gt;
&lt;br /&gt;
The notion of a &amp;#039;&amp;#039;service&amp;#039;&amp;#039; is a central concept in KDE&amp;#039;s modular architecture.&lt;br /&gt;
There is no strict technical implementation connected with this term - services&lt;br /&gt;
can be plugins in the form of shared libraries, or they can be programs&lt;br /&gt;
controlled via DCOP. By claiming to be of a certain&lt;br /&gt;
&amp;#039;&amp;#039;service type&amp;#039;&amp;#039;, a service promises to implement certain APIs or features.&lt;br /&gt;
In C++ terms, one can think of a service type as an abstract class, and a service&lt;br /&gt;
as an implementation of that interface.&lt;br /&gt;
&lt;br /&gt;
The advantage of this separation is clear: An application utilizing a service&lt;br /&gt;
type does not have to know about possible implementations of it. It just uses&lt;br /&gt;
the APIs associated with the service type. In this way, the used service can be&lt;br /&gt;
changed without affecting the application. Also, the user can configure which&lt;br /&gt;
services he prefers for certain features.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&lt;br /&gt;
*The HTML rendering engine used in Konqueror is an embedabble component that implements the service types KParts/ReadOnlyPart and Browser/View.&lt;br /&gt;
*In KDevelop HEAD, most functionality is packaged in plugins with the service type KDevelop/Part. At startup, all services with this type are loaded, such that you can extend the IDE in a very flexible way.&lt;br /&gt;
*In the icon view, Konqueror displays - if enabled - thumbnail pictures of images, HTML pages, PDF and text files. This ability can be extended. If you want it to display preview pictures of your own data files with some MIME type, you can implement a service with service type ThumbCreator.&lt;br /&gt;
&lt;br /&gt;
Obviously, a service is not only characterized by the service types it&lt;br /&gt;
implements, but also by some &amp;#039;&amp;#039;properties&amp;#039;&amp;#039;. For example, a ThumbCreator&lt;br /&gt;
does not only claim to implement the C++ class with the ThumbCreator, it&lt;br /&gt;
also has a list of MIME types it is responsible for. Similarly, KDevelop&lt;br /&gt;
parts have the programming language they support as a property. When&lt;br /&gt;
an application requests a service type, it can also list constraints on&lt;br /&gt;
the properties of the service. In the above example, when KDevelop loads&lt;br /&gt;
the plugins for a Java project, it asks only for the plugins which have&lt;br /&gt;
Java as the programming language property. For this purpose, KDE contains&lt;br /&gt;
a full-blown CORBA-like &amp;#039;&amp;#039;trader&amp;#039;&amp;#039; with a complex query language.&lt;br /&gt;
&lt;br /&gt;
== Defining service types ==&lt;br /&gt;
&lt;br /&gt;
New service types are added by installing a description of them&lt;br /&gt;
into the directory KDEDIR/share/servicetypes. In an automake framework,&lt;br /&gt;
this can be done with this Makefile.am snippet:&lt;br /&gt;
&lt;br /&gt;
 kde_servicetypesdir_DATA = kdeveloppart.desktop&lt;br /&gt;
 EXTRA_DIST = $(kde_servicetypesdir_DATA)&lt;br /&gt;
&lt;br /&gt;
The definition kdeveloppart.desktop of a KDevelop part looks as follows:&lt;br /&gt;
&lt;br /&gt;
 [Desktop Entry]&lt;br /&gt;
 Type=ServiceType&lt;br /&gt;
 X-KDE-ServiceType=KDevelop/Part&lt;br /&gt;
 Name=KDevelop Part&lt;br /&gt;
 &lt;br /&gt;
 [PropertyDef::X-KDevelop-Scope]&lt;br /&gt;
 Type=QString&lt;br /&gt;
 &lt;br /&gt;
 [PropertyDef::X-KDevelop-ProgrammingLanguages]&lt;br /&gt;
 Type=QStringList&lt;br /&gt;
 &lt;br /&gt;
 [PropertyDef::X-KDevelop-Args]&lt;br /&gt;
 Type=QString&lt;br /&gt;
&lt;br /&gt;
In addition to the usual entries, this example demonstrates how you declare&lt;br /&gt;
that a service has some properties. Each property definition corresponds&lt;br /&gt;
to a group &amp;lt;tt&amp;gt;[PropertyDef::name]&amp;lt;/tt&amp;gt; in the configuration file. In&lt;br /&gt;
this group, the &amp;lt;tt&amp;gt;Type&amp;lt;/tt&amp;gt; entry declares the type of the property.&lt;br /&gt;
Possible types are everything that can be stored in a &lt;br /&gt;
QVariant.&lt;br /&gt;
&lt;br /&gt;
== Defining shared library services ==&lt;br /&gt;
&lt;br /&gt;
Service definitions are stored in the directory KDEDIR/share/services:&lt;br /&gt;
&lt;br /&gt;
 kde_servicesdir_DATA = kdevdoxygen.desktop&lt;br /&gt;
 EXTRA_DIST = $(kde_servicesdir_DATA)&lt;br /&gt;
&lt;br /&gt;
The content of the following example file kdevdoxygen.desktop defines&lt;br /&gt;
the KDevDoxygen plugin with the service type KDevelop/Part:&lt;br /&gt;
&lt;br /&gt;
 [Desktop Entry]&lt;br /&gt;
 Type=Service&lt;br /&gt;
 Comment=Doxygen&lt;br /&gt;
 Name=KDevDoxygen&lt;br /&gt;
 ServiceTypes=KDevelop/Part&lt;br /&gt;
 X-KDE-Library=libkdevdoxygen&lt;br /&gt;
 X-KDevelop-ProgrammingLanguages=C,C++,Java&lt;br /&gt;
 X-KDevelop-Scope=Project&lt;br /&gt;
&lt;br /&gt;
In addition to the usual declarations, an important entry is&lt;br /&gt;
&amp;lt;tt&amp;gt;X-KDE-Library&amp;lt;/tt&amp;gt;. This contains the name of the libtool library (without &lt;br /&gt;
the &amp;lt;tt&amp;gt;.la&amp;lt;/tt&amp;gt; extension). It also fixes (with the prefix &amp;lt;tt&amp;gt;init_&amp;lt;/tt&amp;gt; &lt;br /&gt;
prepended) the name of the exported symbol in the library which returns an &lt;br /&gt;
object factory. For the above example, the library must contain the following &lt;br /&gt;
function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
extern &amp;quot;C&amp;quot; {&lt;br /&gt;
  void *init_libkdevdoxygen()&lt;br /&gt;
  {&lt;br /&gt;
    return new DoxygenFactory;&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The type of the factory class DoxygenFactory depends on the specific service&lt;br /&gt;
type the service implements. In our example of a KDevelop plugin, the factory&lt;br /&gt;
must be a KDevFactory (which inherits KLibFactory). More common examples are&lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kparts/html/classKParts_1_1Factory.html KParts::Factory]&lt;br /&gt;
which is supposed to produce &lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kparts/html/classKParts_1_1ReadOnlyPart.html KParts::ReadOnlyPart]&lt;br /&gt;
objects or in most cases the generic&lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKLibFactory.html KLibFactory].&lt;br /&gt;
&lt;br /&gt;
== Using shared library services ==&lt;br /&gt;
&lt;br /&gt;
In order to use a shared library service in an application, you need to obtain a&lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kio/kio/html/classKService.html KService] object&lt;br /&gt;
representing it. This is discussed in the &lt;br /&gt;
[[../MIME Types|section about MIME types]] (and in a section about the&lt;br /&gt;
trader to be written :-)&lt;br /&gt;
&lt;br /&gt;
With the KService object at hand, you can very simply load the library and&lt;br /&gt;
get a pointer to its factory object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
KService *service = ...&lt;br /&gt;
QString libName = QFile::encodeName(service-&amp;gt;library());&lt;br /&gt;
KLibFactory *factory = KLibLoader::self()-&amp;gt;factory(libName);&lt;br /&gt;
if (!factory) {&lt;br /&gt;
  QString name = service-&amp;gt;name();&lt;br /&gt;
  QString errorMessage = KLibLoader::self()-&amp;gt;lastErrorMessage();&lt;br /&gt;
  KMessageBox::error(0, i18n(&amp;quot;Error while loading service %1.\n&amp;quot;&lt;br /&gt;
                             &amp;quot;The diagnostics from libtool is:\n%2&amp;quot;)&lt;br /&gt;
                        .arg(name).arg(errorMessage);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point, the further proceeding depends again on the service type. For&lt;br /&gt;
generic plugins, you create objects with the method&lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKLibFactory.html#a2 KLibFactory::create()].&lt;br /&gt;
For KParts, you must cast the factory pointer to the more specific KParts::Factory and use&lt;br /&gt;
its create() method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
if (factory-&amp;gt;inherits(&amp;quot;KParts::Factory&amp;quot;)) {&lt;br /&gt;
  KParts::Factory *partFactory = static_cast&amp;lt;KParts::Factory*&amp;gt;(factory);&lt;br /&gt;
  QObject *obj = partFactory-&amp;gt;createPart(parentWidget, widgetName,&lt;br /&gt;
                                         parent, name,&lt;br /&gt;
                                         &amp;quot;KParts::ReadOnlyPart&amp;quot;);&lt;br /&gt;
  // ...&lt;br /&gt;
} else {&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Service does not implement the right factory&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining DCOP services ==&lt;br /&gt;
&lt;br /&gt;
A DCOP service is usually implemented as a program that is started up when it is&lt;br /&gt;
needed. It then goes into a loop and listens for DCOP connections. The program &lt;br /&gt;
may be an interactive one, but it may also run completely or for a part of its&lt;br /&gt;
lifetime as a daemon in the background without the user noticing it. An example &lt;br /&gt;
for such a daemon is &amp;lt;tt&amp;gt;kio_uiserver&amp;lt;/tt&amp;gt;, which implements user interaction &lt;br /&gt;
such as progress dialog for the KIO library. The advantage of such a centralized &lt;br /&gt;
daemon in this context is that e.g. the download progress for several different &lt;br /&gt;
files can be shown in one window, even if those downloads were initiated from &lt;br /&gt;
different applications.&lt;br /&gt;
&lt;br /&gt;
A DCOP service is defined differently from a shared library service. Of course,&lt;br /&gt;
it doesn&amp;#039;t specify a library, but instead an executable. Also, DCOP services &lt;br /&gt;
do not specify a ServiceType line, because usually they are started by their&lt;br /&gt;
name. As additional properties, it contains two lines: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;X-DCOP-ServiceType&amp;lt;/tt&amp;gt; specifies the way the service is started. The value &lt;br /&gt;
&amp;lt;tt&amp;gt;Unique&amp;lt;/tt&amp;gt; says that the service must not be started more than once. This &lt;br /&gt;
means, if you try to start this service (e.g. via &lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKApplication.html#e5 KApplication::startServiceByName()], KDE looks whether it is already&lt;br /&gt;
registered with DCOP and uses the running service. If it is not registered yet, &lt;br /&gt;
KDE will start it up and wait until is registered. Thus, you can immediately &lt;br /&gt;
send DCOP calls to the service. In such a case, the service should be implemented&lt;br /&gt;
as a &lt;br /&gt;
[http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKUniqueApplication.html KUniqueApplication].&lt;br /&gt;
&lt;br /&gt;
The value &amp;lt;tt&amp;gt;Multi&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;X-DCOP-ServiceType&amp;lt;/tt&amp;gt; says that multiple&lt;br /&gt;
instances of the service can coexist, so every attempt to start the service&lt;br /&gt;
will create another process. As a last possibility the value &amp;lt;tt&amp;gt;None&amp;lt;/tt&amp;gt;&lt;br /&gt;
can be used. In this case, a start of the service will not wait until it&lt;br /&gt;
is registered with DCOP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;X-KDE-StartupNotify&amp;lt;/tt&amp;gt; should normally be set to false. Otherwise, when&lt;br /&gt;
the program is started, the task bar will show a startup notification, or, depending&lt;br /&gt;
on the user&amp;#039;s settings, the cursor will be changed.&lt;br /&gt;
&lt;br /&gt;
Here is the definition of &amp;lt;tt&amp;gt;kio_uiserver&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 [Desktop Entry]&lt;br /&gt;
 Type=Service&lt;br /&gt;
 Name=kio_uiserver&lt;br /&gt;
 Exec=kio_uiserver&lt;br /&gt;
 X-DCOP-ServiceType=Unique&lt;br /&gt;
 X-KDE-StartupNotify=false&lt;br /&gt;
&lt;br /&gt;
== Using DCOP services ==&lt;br /&gt;
&lt;br /&gt;
A DCOP service is started with one of several methods in the KApplication&lt;br /&gt;
class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
DCOPClient *client = kapp-&amp;gt;dcopClient();&lt;br /&gt;
client-&amp;gt;attach();&lt;br /&gt;
if (!client-&amp;gt;isApplicationRegistered(&amp;quot;kio_uiserver&amp;quot;)) {&lt;br /&gt;
  QString error;&lt;br /&gt;
  if (KApplication::startServiceByName(&amp;quot;kio_uiserver&amp;quot;,&lt;br /&gt;
                                       QStringList(), &amp;amp;error))&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Starting kioserver failed with message &amp;quot; &amp;lt;&amp;lt; error &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
// ...&lt;br /&gt;
QByteArray data, replyData;&lt;br /&gt;
QCString replyType;&lt;br /&gt;
QDataStream arg(data, IO_WriteOnly);&lt;br /&gt;
arg &amp;lt;&amp;lt; true;&lt;br /&gt;
if (!client-&amp;gt;call(&amp;quot;kio_uiserver&amp;quot;, &amp;quot;UIServer&amp;quot;, &amp;quot;setListMode(bool)&amp;quot;, &lt;br /&gt;
                  data, replyType, replyData))&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Call to kio_uiserver failed&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the example of a DCOP call given here uses explit marshalling&lt;br /&gt;
of arguments. Often you will want to use a stub generated by dcopidl2cpp&lt;br /&gt;
instead, because it is much simpler and less error prone.&lt;br /&gt;
&lt;br /&gt;
In the example given here, the service was started &amp;quot;by name&amp;quot;, i.e. the&lt;br /&gt;
first argument to KApplication::startServiceByName() is the name is&lt;br /&gt;
appearing in the Name line of the desktop file. An alternative is to&lt;br /&gt;
use KApplication::startServiceByDesktopName(), which takes the file name&lt;br /&gt;
of its desktop file as argument, i.e. in this case &amp;quot;kio_uiserver.desktop&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
All these calls take a list of URLs as a second argument, which is given&lt;br /&gt;
to the service on the command line. The third argument is a pointer to a&lt;br /&gt;
QString. If starting the service fails, this argument is set to a translated&lt;br /&gt;
error message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Initial Author:&amp;#039;&amp;#039; [mailto:bernd@kdevelop.org Bernd Gehrmann]&lt;br /&gt;
&lt;br /&gt;
[[Category:KDE3]]&lt;br /&gt;
[[Category:Architecture]]&lt;br /&gt;
[[Category:Developers]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Eliddell</name></author>
	</entry>
</feed>