From 954092e015c34ea0848f41d8acb7b957b12d6384 Mon Sep 17 00:00:00 2001 From: alwin Date: Wed, 16 Mar 2005 10:05:50 +0000 Subject: first shot of a generic interface for holiday plugin in datebook --- (limited to 'libopie2/opiepim') diff --git a/libopie2/opiepim/ui/oholidayplugin.h b/libopie2/opiepim/ui/oholidayplugin.h new file mode 100644 index 0000000..f4958c8 --- a/dev/null +++ b/libopie2/opiepim/ui/oholidayplugin.h @@ -0,0 +1,24 @@ +#ifndef _HOLIDAY_PLUGIN_H +#define _HOLIDAY_PLUGIN_H + +namespace Opie { +namespace Datebook { + +#include +#include +#include + +class HolidayPlugin +{ +public: + HolidayPlugin(){}; + virtual ~HolidayPlugin(){}; + virtual QString description()=0; + virtual QStringList entries(const QDate&)=0; + virtual QStringList entries(unsigned year, unsigned month, unsigned day)=0; +}; + +} +} +#endif + diff --git a/libopie2/opiepim/ui/oholidaypluginif.h b/libopie2/opiepim/ui/oholidaypluginif.h new file mode 100644 index 0000000..6d36f08 --- a/dev/null +++ b/libopie2/opiepim/ui/oholidaypluginif.h @@ -0,0 +1,64 @@ +#ifndef _O_HOLIDAY_PLUGIN_IF_H +#define _O_HOLIDAY_PLUGIN_IF_H + +#include + +#include + +#ifndef QT_NO_COMPONENT +//"b981b4e9-6d5d-4ee0-a193-f8d0e443809b" +#define IID_HOLIDAY_PLUGIN QUuid(0xb981b4e9, 0x6d5d, 0x4ee0 0xa1, 0x93,0xf8, 0xd0, 0xe4, 0x43, 0x80, 0x9b) +#endif + +namespace Opie { +namespace Datebook { + +class HolidayPlugin; + +class HolidayPluginIf:public QUnknownInterface +{ +public: + HolidayPluginIf():QUnknownInterface(){} + virtual ~HolidayPluginIf(){} + + virtual HolidayPlugin*plugin()=0; +}; + +templateHolidayPluginWrapper:public HolidayPluginIf +{ +public: + HolidayPluginWrapper():HolidayPluginIf(),_plugin(0){} + virtual ~HolidayPluginWrapper(){if (_plugin) delete _plugin;} + + QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) { + odebug << "HolidayPluginWrapper::queryInterface()" << oendl; + *iface = 0; + if (uuid==IID_HOLIDAY_PLUGIN||uuid==IID_QUnknown) { + *iface = this; + } else { + return QS_FALSE; + } + if (*iface) *iface->addRef(); + return QS_OK; + } + + // from qcom + Q_REFCOUNT + + virtual T*plugin() { + if (!_plugin) {_plugin = new T();} + return _plugin; + } +protected: + T*_plugin; +}; + +#define EXPORT_HOLIDAY_PLUGIN( Plugin ) \ + Q_EXPORT_INTERFACE() { \ + Q_CREATE_INSTANCE( Opie::Datebook::HolidayPluginWrapper ) \ + } + +} +} +#endif + -- cgit v0.9.0.2