Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index a18a5b4..f6aab0c 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -32,2 +32,4 @@ #include <opie2/odebug.h> +#include <opie2/oholidaypluginif.h> +#include <opie2/oholidayplugin.h> @@ -51,2 +53,4 @@ #include <qwidgetstack.h> +#include <qdir.h> +#include <qtopia/qlibrary.h> @@ -75,2 +79,4 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) odebug << "loading db t=" << t.elapsed() << oendl; + db_holiday = new DateBookHoliday(); + loadSettings(); @@ -227,2 +233,3 @@ DateBook::~DateBook() { + delete db_holiday; } @@ -514,3 +521,3 @@ void DateBook::initDay() if ( !dayView ) { - dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); + dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); views->addWidget( dayView, DAY ); @@ -1075 +1082,70 @@ Event DateBookDBHack::eventByUID(int uid) { } + +DateBookHoliday::DateBookHoliday() +{ + _pluginlist.clear(); + init(); +} + +DateBookHoliday::~DateBookHoliday() +{ + deinit(); +} + +void DateBookHoliday::deinit() +{ + QValueList<HPlugin*>::Iterator it; + for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { + HPlugin*_pl = *it; + // destructs itself? + _pl->_if->release(); + _pl->_lib->unload(); + delete _pl->_lib; + delete _pl; + } + _pluginlist.clear(); +} + +void DateBookHoliday::init() +{ + deinit(); + QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday"; + QDir dir( path, "lib*.so" ); + QStringList list = dir.entryList(); + QStringList::Iterator it; + for (it=list.begin();it!=list.end();++it) { + Opie::Datebook::HolidayPluginIf*hif = 0; + QLibrary*lib=new QLibrary(path+"/"+*it); + if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) { + Opie::Datebook::HolidayPlugin*pl = hif->plugin(); + if (pl) { + HPlugin*_pl=new HPlugin; + _pl->_plugin = pl; + odebug << "Found holiday " << pl->description()<<oendl; + _pl->_lib = lib; + _pl->_if = hif; + _pluginlist.append(_pl); + } else { + } + } else { + delete lib; + } + } +} + +QStringList DateBookHoliday::holidaylist(const QDate&aDate) +{ + QStringList ret; + QValueList<HPlugin*>::Iterator it; + for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { + HPlugin*_pl = *it; + ret+=_pl->_plugin->entries(aDate); + } + return ret; +} + +QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) +{ + return holidaylist(QDate(year,month,day)); +} + |