summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/alarmserver.cpp60
-rw-r--r--library/dummy_api_docu.cpp58
2 files changed, 118 insertions, 0 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index a75fc7e..6f6f32d 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -271,109 +271,169 @@ void TimerReceiverObject::resetTimer()
// Qt timers (does the actual alarm)
// from now in milliseconds
//
qDebug("AlarmServer waiting %d seconds", secs);
startTimer( 1000 * secs + 500 );
}
void TimerReceiverObject::timerEvent( QTimerEvent * )
{
bool needSave = FALSE;
killTimers();
if (nearestTimerEvent) {
if ( nearestTimerEvent->UTCtime
<= TimeConversion::toUTC(QDateTime::currentDateTime()) ) {
#ifndef QT_NO_COP
QCopEnvelope e( nearestTimerEvent->channel,
nearestTimerEvent->message );
e << TimeConversion::fromUTC( nearestTimerEvent->UTCtime )
<< nearestTimerEvent->data;
#endif
timerEventList.remove( nearestTimerEvent );
needSave = TRUE;
}
setNearestTimerEvent();
}
else {
resetTimer();
}
if ( needSave )
saveState();
}
/*!
\class AlarmServer alarmserver.h
\brief The AlarmServer class allows alarms to be scheduled and unscheduled.
Applications can schedule alarms with addAlarm() and can
unschedule alarms with deleteAlarm(). When the time for an alarm
to go off is reached the specified \link qcop.html QCop\endlink
message is sent on the specified channel (optionally with
additional data).
Scheduling an alarm using this class is important (rather just using
a QTimer) since the machine may be asleep and needs to get woken up using
the Linux kernel which implements this at the kernel level to minimize
battery usage while asleep.
+ A small example on how to use AlarmServer.
+
+ First we need to connect a slot the AppMessage QCOP call. appMessage
+ will be emitted if QPE/Application/appname gets called.
+
+ \code
+ TestApp::TestApp(QWidget *parent, const char* name, WFlags fl )
+ : QMainWindow(parent,name,fl){
+ connect(qApp,SIGNAL(appMessage(const QCString&,const QByteArray&)),
+ this,SLOT(slotAppMessage(const QCString&,const QByteArray&)));
+ }
+ \endcode
+
+ To add / delete an alarm, you can use the static method AlarmServer::addAlarm and
+ AlarmServer::deleteAlarm. Note that an old (expired) alarm will automatically be deleted
+ from the alarmserver list, but a change in timing will have the effect, that both
+ alarms will be emitted. So if you change an Alarm be sure to delete the old one!
+ @see addAlarm
+
+ \code
+ QDateTime oldDt = oldAlarmDateTime();
+ QPEApplication::execDialog(ourDlg);
+ QDateTime newDt = ourDlg->dateTime();
+ if(newDt == oldDt ) return;
+ @slash* code is missing for unsetting an alarm *@slash
+
+ AlarmServer::deleteAlarm(oldDt,"QPE/Application/appname","checkAlarm(QDateTime,int)",0);
+ AlarmServer::addAlarm( newDt,"QPE/AlarmServer/appname","checkAlarm(QDateTime,int)",0);
+
+ \endcode
+
+ Now once the Alarm is emitted you need to check the appMessage and then do what you want.
+ \code
+ void TestApp::slotAppMessage(const QCString& str, const QByteArray& ar ){
+ QDataStream stream(ar,IO_ReadOnly);
+ if(str == "checkAlarm(QDateTime,int)" ){
+ QDateTime dt;
+ int a;
+ stream >> dt >> a;
+ // fire up alarm
+ }
+ }
+ \endcode
+
\ingroup qtopiaemb
\sa QCopEnvelope
+ @see QPEApplication::appMessage(const QCString&,const QByteArray&)
+ @see OPimMainWindow
+ @see ODevice::alarmSound()
+ @see Sound::soundAlarm()
*/
/*!
Schedules an alarm to go off at (or soon after) time \a when. When
the alarm goes off, the \link qcop.html QCop\endlink \a message will
be sent to \a channel, with \a data as a parameter.
If this function is called with exactly the same data as a previous
call the subsequent call is ignored, so there is only ever one alarm
with a given set of parameters.
+ Once an alarm is emitted. The \a channel with a \a message will be emitted
+ and data will be send.
+ The QDateTime and int are the two parameters included in the QCOP message.
+ You can specify channel, message and the integer parameter. QDateTime will be
+ the datetime of the QCop call.
+
+ @param when The QDateTime of the alarm
+ @param channel The channel which gets called once the alarm is emitted
+ @param message The message to be send to the channel
+ @param data Additional data as integer
+
+ @see QCopChannel
\sa deleteAlarm()
*/
void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
const QCString& message, int data)
{
if ( qApp->type() == QApplication::GuiServer ) {
bool needSave = FALSE;
// Here we are the server so either it has been directly called from
// within the server or it has been sent to us from a client via QCop
if (!timerEventReceiver)
timerEventReceiver = new TimerReceiverObject;
timerEventItem *newTimerEventItem = new timerEventItem;
newTimerEventItem->UTCtime = TimeConversion::toUTC( when );
newTimerEventItem->channel = channel;
newTimerEventItem->message = message;
newTimerEventItem->data = data;
// explore the case of already having the event in here...
QListIterator<timerEventItem> it( timerEventList );
for ( ; *it; ++it )
if ( *(*it) == *newTimerEventItem )
return ;
// if we made it here, it is okay to add the item...
timerEventList.append( newTimerEventItem );
needSave = TRUE;
// quicker than using setNearestTimerEvent()
if ( nearestTimerEvent ) {
if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) {
nearestTimerEvent = newTimerEventItem;
timerEventReceiver->killTimers();
timerEventReceiver->resetTimer();
}
}
else {
nearestTimerEvent = newTimerEventItem;
timerEventReceiver->resetTimer();
}
if ( needSave )
saveState();
}
else {
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" );
e << when << channel << message << data;
#endif
}
}
diff --git a/library/dummy_api_docu.cpp b/library/dummy_api_docu.cpp
index 6b76401..f2153df 100644
--- a/library/dummy_api_docu.cpp
+++ b/library/dummy_api_docu.cpp
@@ -264,48 +264,106 @@
/**
* \class StyleInterface
* \brief StyleInterface base class
*
* Opie styles should implement StyleExtendedInterface.
* StyleInterface is only for compability reasons present and should
* not be used for new styles.
*
* Styles need to be put into OPIEDIR/plugins/styles
*/
/**
* \class StyleExtendedInterface
* \brief The Plugin Interface for all Opie styles
*
* If you want to create a new QStyle for Opie use this class.
*
* key(ushort,ushort,ushort,bool,bool)
*/
/*
* Taskbar Applets
*/
/**
* \class TaskbarAppletInterface
*
* This is the base class of all Applets shown in the taskbar
* An applets need to provide a position and a widget.
*
* Applets need to be put into OPIEDIR/plugins/applets
*
*/
/**
* \fn QWidget* TaskbarAppletInterface::applet( QWidget* parent )
* \brief return the new Applet Widget
*
* @param parent The parent of the Applet normally the taskbar
*/
/**
* \fn int TaskbarAppletInterface::position()const;
* \brief the wished position
*
* From left to right. 0 is left. The clock uses 10
*/
+
+
+/**
+ * \class WindowDecorationInterface
+ *
+ * Interface class for Window Decorations. Yu need to implement
+ * metric and drawing functions.
+ */
+
+/**
+ * \class WindowDecorationInterface::WindowData
+ *
+ * Window informations like the QRect, Palette, Caption
+ * and flag
+ */
+
+/**
+ * \fn int WindowDecorationInterface::metric(Metric m,const WindowData* )
+ *
+ * Return the width for the item out of Metric.
+ * Normally you will case Metric and default: should call the interface
+ * method. Also return 0
+ */
+
+/**
+ * \fn void WindowDecorationInterface::drawArea( Area a, QPainter* , const WindowData* )const
+ *
+ * draw the Area specefic in a to the QPainter
+ */
+
+/**
+ * \fn void WindowDecorationInterface::drawButton(Button b,QPainter*p ,const WindowData* d, int x, int y, int w,int h, QWSButton::State s)const
+ *
+ * @param b The Button to be drawn
+ * @param p The painter to draw at
+ * @param d The Window Data
+ * @param x The X position of the button
+ * @param y The Y position of the button
+ * @param w The width of the button
+ * @param h The height of the button
+ * @param s The state of the button
+ */
+
+/**
+ * \fn QRegion WindowDecorationInterface::mask( const WindowData* )const
+ *
+ * The mask of the Decoration.
+ *
+ * \code
+ * int th = metric(TitleHeight,wd);
+ * QRect rect( wd->rect );
+ * QRect r(rect.left() - metric(LeftBorder,wd),
+ * rect.top() - th - metric(TopBorder,wd),
+ * rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd),
+ * rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd));
+ * return QRegion(r) - rect;
+ * \endcode
+ */