LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
iinfo.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <memory>
12 #include <QString>
13 #include <QStringList>
14 #include <QtPlugin>
15 #include "structures.h"
16 
17 class ICoreProxy;
18 typedef std::shared_ptr<ICoreProxy> ICoreProxy_ptr;
19 
47 class Q_DECL_EXPORT IInfo
48 {
49 public:
67  virtual void Init (ICoreProxy_ptr proxy) = 0;
68 
77  virtual void SecondInit () = 0;
78 
93  virtual QByteArray GetUniqueID () const = 0;
94 
107  virtual QString GetName () const = 0;
108 
120  virtual QString GetInfo () const = 0;
121 
139  virtual QStringList Provides () const
140  {
141  return QStringList ();
142  }
143 
167  virtual QStringList Needs () const
168  {
169  return QStringList ();
170  }
171 
194  virtual QStringList Uses () const
195  {
196  return QStringList ();
197  }
198 
215  virtual void SetProvider (QObject* object,
216  const QString& feature)
217  {
218  Q_UNUSED (object);
219  Q_UNUSED (feature);
220  }
221 
232  virtual void Release () = 0;
233 
246  virtual QIcon GetIcon () const = 0;
247 
250  virtual ~IInfo () {}
251 
252  virtual void gotEntity (const LC::Entity& entity)
253  {
254  Q_UNUSED (entity);
255  }
256 
257  // implementation details
258  virtual void SetProxy (ICoreProxy_ptr) = 0;
259 };
260 
261 Q_DECLARE_INTERFACE (IInfo, "org.Deviant.LeechCraft.IInfo/1.0")
262 
263 #define CURRENT_API_LEVEL 20
264 
265 #define LC_EXPORT_PLUGIN(file,klass) \
266  ICoreProxy_ptr klass::S_Proxy_; \
267  const ICoreProxy_ptr& GetProxyHolder () { return klass::S_Proxy_; } \
268  \
269  extern "C"\
270  {\
271  Q_DECL_EXPORT quint64 GetAPILevels () { return CURRENT_API_LEVEL; } \
272  }
273 
275 
276 #ifdef __clang__
277 #define LC_PUSH_OVERRIDE_WARNING \
278  _Pragma("clang diagnostic push") \
279  _Pragma("clang diagnostic ignored \"-Winconsistent-missing-override\"")
280 #define LC_POP_OVERRIDE_WARNING \
281  _Pragma("clang diagnostic pop")
282 #else
283 #define LC_PUSH_OVERRIDE_WARNING
284 #define LC_POP_OVERRIDE_WARNING
285 #endif
286 
287 #define DEFINE_PROXY \
288  static ICoreProxy_ptr S_Proxy_; \
289  LC_PUSH_OVERRIDE_WARNING \
290  void SetProxy (ICoreProxy_ptr proxy) { S_Proxy_ = std::move (proxy); } \
291  LC_POP_OVERRIDE_WARNING \
292  friend const ICoreProxy_ptr& ::GetProxyHolder ();
293 
294 #define LC_PLUGIN_METADATA(id) \
295  Q_PLUGIN_METADATA (IID id) \
296  DEFINE_PROXY
IInfo
Required interface for every plugin.
Definition: iinfo.h:47
ICoreProxy
Proxy class for the communication with LeechCraft.
Definition: icoreproxy.h:46
IInfo::gotEntity
virtual void gotEntity(const LC::Entity &entity)
Definition: iinfo.h:252
LC::Entity
A message used for inter-plugin communication.
Definition: structures.h:95
structures.h
IInfo::Provides
virtual QStringList Provides() const
Returns the list of provided features.
Definition: iinfo.h:139
IInfo::Needs
virtual QStringList Needs() const
Returns the list of needed features.
Definition: iinfo.h:167
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: iinfo.h:17
IInfo::~IInfo
virtual ~IInfo()
Virtual destructor.
Definition: iinfo.h:250
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
GetProxyHolder
const ICoreProxy_ptr & GetProxyHolder()
IInfo::SetProvider
virtual void SetProvider(QObject *object, const QString &feature)
Sets the provider plugin for a given feature.
Definition: iinfo.h:215
IInfo::Uses
virtual QStringList Uses() const
Returns the list of used features.
Definition: iinfo.h:194