summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginimpl.cpp1
-rw-r--r--core/pim/today/today.cpp12
2 files changed, 7 insertions, 6 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginimpl.cpp b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp
index 4159b49..45736bb 100644
--- a/core/pim/today/plugins/datebook/datebookpluginimpl.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp
@@ -1,42 +1,43 @@
1/* 1/*
2 * datebookpluginimpl.cpp 2 * datebookpluginimpl.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "datebookplugin.h" 17#include "datebookplugin.h"
18#include "datebookpluginimpl.h" 18#include "datebookpluginimpl.h"
19 19
20DatebookPluginImpl::DatebookPluginImpl() { 20DatebookPluginImpl::DatebookPluginImpl() {
21 datebookPlugin = new DatebookPlugin(); 21 datebookPlugin = new DatebookPlugin();
22} 22}
23 23
24DatebookPluginImpl::~DatebookPluginImpl() { 24DatebookPluginImpl::~DatebookPluginImpl() {
25 delete datebookPlugin;
25} 26}
26 27
27TodayPluginObject* DatebookPluginImpl::guiPart() { 28TodayPluginObject* DatebookPluginImpl::guiPart() {
28 return datebookPlugin; 29 return datebookPlugin;
29} 30}
30 31
31QRESULT DatebookPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) { 32QRESULT DatebookPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
32 *iface = 0; 33 *iface = 0;
33 if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) { 34 if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) {
34 *iface = this, (*iface)->addRef(); 35 *iface = this, (*iface)->addRef();
35 } 36 }
36 return QS_OK; 37 return QS_OK;
37 38
38} 39}
39 40
40Q_EXPORT_INTERFACE() { 41Q_EXPORT_INTERFACE() {
41 Q_CREATE_INSTANCE( DatebookPluginImpl ); 42 Q_CREATE_INSTANCE( DatebookPluginImpl );
42} 43}
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 01ef02d..1b31cfd 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,91 +1,92 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18#include "today.h" 18#include "today.h"
19#include <opie/todayconfigwidget.h> 19#include <opie/todayconfigwidget.h>
20 20
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/contact.h> 26#include <qpe/contact.h>
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qpixmap.h> 33#include <qpixmap.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <opie/otabwidget.h> 36#include <opie/otabwidget.h>
37#include <qdialog.h> 37#include <qdialog.h>
38#include <qwhatsthis.h> 38#include <qwhatsthis.h>
39 39
40 40
41struct TodayPlugin { 41struct TodayPlugin {
42 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
42 QLibrary *library; 43 QLibrary *library;
43 TodayPluginInterface *iface; 44 QInterfacePtr<TodayPluginInterface> iface;
44 TodayPluginObject *guiPart; 45 TodayPluginObject *guiPart;
45 QWidget *guiBox; 46 QWidget *guiBox;
46 QString name; 47 QString name;
47 bool active; 48 bool active;
48 bool excludeRefresh; 49 bool excludeRefresh;
49 int pos; 50 int pos;
50}; 51};
51 52
52static QValueList<TodayPlugin> pluginList; 53static QValueList<TodayPlugin> pluginList;
53 54
54Today::Today( QWidget* parent, const char* name, WFlags fl ) 55Today::Today( QWidget* parent, const char* name, WFlags fl )
55 : TodayBase( parent, name, fl ) { 56 : TodayBase( parent, name, fl ) {
56 57
57 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 58 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
58 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 59 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
59 60
60#if defined(Q_WS_QWS) 61#if defined(Q_WS_QWS)
61#if !defined(QT_NO_COP) 62#if !defined(QT_NO_COP)
62 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 63 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
63 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 64 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
64 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 65 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
65#endif 66#endif
66#endif 67#endif
67 68
68 setOwnerField(); 69 setOwnerField();
69 m_refreshTimer = new QTimer( this ); 70 m_refreshTimer = new QTimer( this );
70 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 71 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
71 m_refreshTimer->start( 15000 ); 72 m_refreshTimer->start( 15000 );
72 refresh(); 73 refresh();
73 showMaximized(); 74 showMaximized();
74} 75}
75 76
76/** 77/**
77 * Qcop receive method. 78 * Qcop receive method.
78 */ 79 */
79void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 80void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
80 QDataStream stream( data, IO_ReadOnly ); 81 QDataStream stream( data, IO_ReadOnly );
81 if ( msg == "message(QString)" ) { 82 if ( msg == "message(QString)" ) {
82 QString message; 83 QString message;
83 stream >> message; 84 stream >> message;
84 setOwnerField( message ); 85 setOwnerField( message );
85 } 86 }
86} 87}
87 88
88void Today::setRefreshTimer( int interval ) { 89void Today::setRefreshTimer( int interval ) {
89 90
90 91
91 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 92 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
@@ -116,179 +117,178 @@ void Today::setOwnerField() {
116 * Set the owner field with a given QString, for example per qcop. 117 * Set the owner field with a given QString, for example per qcop.
117 */ 118 */
118void Today::setOwnerField( QString &message ) { 119void Today::setOwnerField( QString &message ) {
119 if ( !message.isEmpty() ) { 120 if ( !message.isEmpty() ) {
120 OwnerField->setText( "<b>" + message + "</b>" ); 121 OwnerField->setText( "<b>" + message + "</b>" );
121 } 122 }
122} 123}
123 124
124 125
125/** 126/**
126 * Init stuff needed for today. Reads the config file. 127 * Init stuff needed for today. Reads the config file.
127 */ 128 */
128void Today::init() { 129void Today::init() {
129 // read config 130 // read config
130 Config cfg( "today" ); 131 Config cfg( "today" );
131 132
132 cfg.setGroup( "Plugins" ); 133 cfg.setGroup( "Plugins" );
133 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
134 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 135 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
135 136
136 cfg.setGroup( "General" ); 137 cfg.setGroup( "General" );
137 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 138 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
138 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 139 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
139} 140}
140 141
141 142
142/** 143/**
143 * Load the plugins 144 * Load the plugins
144 */ 145 */
145void Today::loadPlugins() { 146void Today::loadPlugins() {
146 147
147 // extra list for plugins that exclude themself from periodic refresh 148 // extra list for plugins that exclude themself from periodic refresh
148 QMap<QString, TodayPlugin> pluginListRefreshExclude; 149 QMap<QString, TodayPlugin> pluginListRefreshExclude;
149 150
150 QValueList<TodayPlugin>::Iterator tit; 151 QValueList<TodayPlugin>::Iterator tit;
151 if ( !pluginList.isEmpty() ) { 152 if ( !pluginList.isEmpty() ) {
152 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 153 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
153 if ( (*tit).excludeRefresh ) { 154 if ( (*tit).excludeRefresh ) {
154 pluginListRefreshExclude.insert( (*tit).name , (*tit) ); 155 pluginListRefreshExclude.insert( (*tit).name , (*tit) );
155 qDebug( "Found an plugin that does not want refresh feature" ); 156 qDebug( "Found an plugin that does not want refresh feature" );
156 } else { 157 } else {
157 (*tit).library->unload(); 158 (*tit).library->unload();
158 delete (*tit).library; 159 delete (*tit).library;
159 } 160 }
160 } 161 }
161 pluginList.clear(); 162 pluginList.clear();
162 } 163 }
163 164
164
165 QString path = QPEApplication::qpeDir() + "/plugins/today"; 165 QString path = QPEApplication::qpeDir() + "/plugins/today";
166 QDir dir( path, "lib*.so" ); 166 QDir dir( path, "lib*.so" );
167 167
168 QStringList list = dir.entryList(); 168 QStringList list = dir.entryList();
169 QStringList::Iterator it; 169 QStringList::Iterator it;
170 170
171 QMap<QString, TodayPlugin> tempList; 171 QMap<QString, TodayPlugin> tempList;
172 172
173 for ( it = list.begin(); it != list.end(); ++it ) { 173 for ( it = list.begin(); it != list.end(); ++it ) {
174 TodayPluginInterface *iface = 0; 174 //TodayPluginInterface *iface = 0;
175 QLibrary *lib = new QLibrary( path + "/" + *it ); 175 QInterfacePtr<TodayPluginInterface> iface;
176 QLibrary *lib = new QLibrary( path + "/" + *it );
176 177
177 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 178 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
178 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 179 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
179 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 180 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
180 qDebug( QString(*it) ); 181 qDebug( QString(*it) );
181 182
182 // If plugin is exludes from refresh, get it in the list again here. 183 // If plugin is exludes from refresh, get it in the list again here.
183 184
184 if ( pluginListRefreshExclude.contains( (*it) ) ) { 185 if ( pluginListRefreshExclude.contains( (*it) ) ) {
185
186 // if its not in allApplets list, add it to a layout 186 // if its not in allApplets list, add it to a layout
187 if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) { 187 if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) {
188 qDebug( "NUGASDA" ); 188 qDebug( "NUGASDA" );
189 layout->addWidget( pluginListRefreshExclude[(*it)].guiBox ); 189 layout->addWidget( pluginListRefreshExclude[(*it)].guiBox );
190 pluginList.append( pluginListRefreshExclude[(*it)] ); 190 pluginList.append( pluginListRefreshExclude[(*it)] );
191 } else { 191 } else {
192 tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); 192 tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] );
193 qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); 193 qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name );
194 } 194 }
195 } else { 195 } else {
196 196
197 TodayPlugin plugin; 197 TodayPlugin plugin;
198 plugin.library = lib; 198 plugin.library = lib;
199 plugin.iface = iface; 199 plugin.iface = iface;
200 plugin.name = QString(*it); 200 plugin.name = QString(*it);
201 201
202 // find out if plugins should be shown 202 // find out if plugins should be shown
203 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 203 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
204 plugin.active = true; 204 plugin.active = true;
205 } else { 205 } else {
206 plugin.active = false; 206 plugin.active = false;
207 } 207 }
208 208
209 plugin.guiPart = plugin.iface->guiPart(); 209 plugin.guiPart = plugin.iface->guiPart();
210 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 210 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
211 211
212 // package the whole thing into a qwidget so it can be shown and hidden 212 // package the whole thing into a qwidget so it can be shown and hidden
213 plugin.guiBox = new QWidget( this ); 213 plugin.guiBox = new QWidget( this );
214 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 214 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
215 QPixmap plugPix; 215 QPixmap plugPix;
216 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 216 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
217 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 217 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
218 plugIcon->setPixmap( plugPix ); 218 plugIcon->setPixmap( plugPix );
219 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 219 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
220 plugIcon->setName( plugin.guiPart->appName() ); 220 plugIcon->setName( plugin.guiPart->appName() );
221 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 221 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
222 // a scrollview for each plugin 222 // a scrollview for each plugin
223 QScrollView* sv = new QScrollView( plugin.guiBox ); 223 QScrollView* sv = new QScrollView( plugin.guiBox );
224 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 224 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
225 // not sure if that is good .-) 225 // not sure if that is good .-)
226 sv->setMinimumHeight( 10 ); 226 sv->setMinimumHeight( 10 );
227 sv->setResizePolicy( QScrollView::AutoOneFit ); 227 sv->setResizePolicy( QScrollView::AutoOneFit );
228 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 228 sv->setHScrollBarMode( QScrollView::AlwaysOff );
229 sv->setFrameShape( QFrame::NoFrame ); 229 sv->setFrameShape( QFrame::NoFrame );
230 sv->addChild( plugWidget ); 230 sv->addChild( plugWidget );
231 // make sure the icon is on the top alligned 231 // make sure the icon is on the top alligned
232 boxLayout->addWidget( plugIcon, 0, AlignTop ); 232 boxLayout->addWidget( plugIcon, 0, AlignTop );
233 boxLayout->addWidget( sv, 0, AlignTop ); 233 boxLayout->addWidget( sv, 0, AlignTop );
234 boxLayout->setStretchFactor( plugIcon, 1 ); 234 boxLayout->setStretchFactor( plugIcon, 1 );
235 boxLayout->setStretchFactor( sv, 9 ); 235 boxLayout->setStretchFactor( sv, 9 );
236 // "prebuffer" it in one more list, to get the sorting done 236 // "prebuffer" it in one more list, to get the sorting done
237 tempList.insert( plugin.name, plugin ); 237 tempList.insert( plugin.name, plugin );
238 238
239 // on first start the list is off course empty 239 // on first start the list is off course empty
240 if ( m_allApplets.isEmpty() ) { 240 if ( m_allApplets.isEmpty() ) {
241 layout->addWidget( plugin.guiBox ); 241 layout->addWidget( plugin.guiBox );
242 pluginList.append( plugin ); 242 pluginList.append( plugin );
243 } 243 }
244 244
245 // if plugin is not yet in the list, add it to the layout too 245 // if plugin is not yet in the list, add it to the layout too
246 if ( !m_allApplets.contains( plugin.name ) ) { 246 else if ( !m_allApplets.contains( plugin.name ) ) {
247 layout->addWidget( plugin.guiBox ); 247 layout->addWidget( plugin.guiBox );
248 pluginList.append( plugin ); 248 pluginList.append( plugin );
249 } 249 }
250 } 250 }
251 } else { 251 } else {
252 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 252 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
253 delete lib; 253 delete lib;
254 } 254 }
255 } 255 }
256 256
257 if ( !m_allApplets.isEmpty() ) { 257 if ( !m_allApplets.isEmpty() ) {
258 TodayPlugin tempPlugin; 258 TodayPlugin tempPlugin;
259 QStringList::Iterator stringit; 259 QStringList::Iterator stringit;
260 260
261 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 261 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
262 tempPlugin = ( tempList.find( *stringit ) ).data(); 262 tempPlugin = ( tempList.find( *stringit ) ).data();
263 if ( !( (tempPlugin.name).isEmpty() ) ) { 263 if ( !( (tempPlugin.name).isEmpty() ) ) {
264 layout->addWidget( tempPlugin.guiBox ); 264 layout->addWidget( tempPlugin.guiBox );
265 pluginList.append( tempPlugin ); 265 pluginList.append( tempPlugin );
266 } 266 }
267 } 267 }
268 } 268 }
269} 269}
270 270
271 271
272/** 272/**
273 * Repaint method. Reread all fields. 273 * Repaint method. Reread all fields.
274 */ 274 */
275void Today::draw() { 275void Today::draw() {
276 276
277 if ( pluginList.count() == 0 ) { 277 if ( pluginList.count() == 0 ) {
278 QLabel *noPlugins = new QLabel( this ); 278 QLabel *noPlugins = new QLabel( this );
279 noPlugins->setText( tr( "No plugins found" ) ); 279 noPlugins->setText( tr( "No plugins found" ) );
280 layout->addWidget( noPlugins ); 280 layout->addWidget( noPlugins );
281 return; 281 return;
282 } 282 }
283 283
284 uint count = 0; 284 uint count = 0;
285 TodayPlugin plugin; 285 TodayPlugin plugin;
286 for ( uint i = 0; i < pluginList.count(); i++ ) { 286 for ( uint i = 0; i < pluginList.count(); i++ ) {
287 plugin = pluginList[i]; 287 plugin = pluginList[i];
288 288
289 if ( plugin.active ) { 289 if ( plugin.active ) {
290 // qDebug( plugin.name + " is ACTIVE " ); 290 // qDebug( plugin.name + " is ACTIVE " );
291 plugin.guiBox->show(); 291 plugin.guiBox->show();
292 } else { 292 } else {
293 // qDebug( plugin.name + " is INACTIVE" ); 293 // qDebug( plugin.name + " is INACTIVE" );
294 plugin.guiBox->hide(); 294 plugin.guiBox->hide();