summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-12 13:17:48 (UTC)
committer zecke <zecke>2003-05-12 13:17:48 (UTC)
commitd6e4c1a54185b1aa4443cb79a36acc637acf84ac (patch) (unidiff)
treebff7f62a0a06cbcd3d1492b37c297e9133dacff4
parentabfe4c66be60075a518d4918d603bb8033bc5ac4 (diff)
downloadopie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.zip
opie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.tar.gz
opie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.tar.bz2
Add handling of alarm() message
play and killAlarm... added as well
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimmainwindow.cpp36
-rw-r--r--libopie/pim/opimmainwindow.h18
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp36
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.h18
4 files changed, 98 insertions, 10 deletions
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
index d1eec19..4044bc1 100644
--- a/libopie/pim/opimmainwindow.cpp
+++ b/libopie/pim/opimmainwindow.cpp
@@ -1,4 +1,6 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qdatetime.h>
2#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
3 4
5#include <qpe/sound.h>
4#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
@@ -19,2 +21,4 @@ OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
19 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 21 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
22 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ),
23 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
20 24
@@ -52,3 +56,3 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
52 }else if ( cmd == "beam(int)" ) { 56 }else if ( cmd == "beam(int)" ) {
53 int uid, trans; 57 int uid;
54 stream >> uid; 58 stream >> uid;
@@ -72,2 +76,12 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
72 delete m_fallBack; 76 delete m_fallBack;
77 }else if ( cmd == "alarm(QDateTime,int)" ) {
78 QDateTime dt; int uid;
79 stream >> dt;
80 stream >> uid;
81 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
82 QDateTime current = QDateTime::currentDateTime();
83 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
84 return;
85 doAlarm( dt, uid );
86
73 } 87 }
@@ -104 +118,21 @@ int OPimMainWindow::service() {
104} 118}
119void OPimMainWindow::doAlarm( const QDateTime&, int ) {
120
121}
122void OPimMainWindow::startAlarm(int count ) {
123 m_alarmCount = count;
124 m_playedCount = 0;
125 Sound::soundAlarm();
126 m_timerId = startTimer( 5000 );
127}
128void OPimMainWindow::killAlarm() {
129 killTimer( m_timerId );
130}
131void OPimMainWindow::timerEvent( QTimerEvent* e) {
132 if ( m_playedCount <m_alarmCount ) {
133 m_playedCount++;
134 Sound::soundAlarm();
135 }else {
136 killTimer( e->timerId() );
137 }
138}
diff --git a/libopie/pim/opimmainwindow.h b/libopie/pim/opimmainwindow.h
index dca3c82..855d364 100644
--- a/libopie/pim/opimmainwindow.h
+++ b/libopie/pim/opimmainwindow.h
@@ -22,2 +22,3 @@
22class QCopChannel; 22class QCopChannel;
23class QDateTime;
23class OPimMainWindow : public QMainWindow { 24class OPimMainWindow : public QMainWindow {
@@ -58,2 +59,3 @@ protected slots:
58 59
60 virtual void doAlarm( const QDateTime&, int uid );
59 61
@@ -61,2 +63,11 @@ protected slots:
61 63
64protected:
65 /**
66 * start to play soundAlarm()
67 * @param count How many times the alarm is played
68 */
69 void startAlarm(int count = 10);
70 void killAlarm();
71 void timerEvent( QTimerEvent* );
72
62private slots: 73private slots:
@@ -75,3 +86,5 @@ private:
75 OPimRecord* m_fallBack; 86 OPimRecord* m_fallBack;
76 87 int m_alarmCount;
88 int m_playedCount;
89 int m_timerId;
77 /* I would love to do this as a template 90 /* I would love to do this as a template
@@ -80,5 +93,2 @@ private:
80 */ 93 */
81 /*
82 * the only pointer in the whole PIM API :(
83 */
84 virtual OPimRecord* record( int rtti, const QByteArray& ) ; 94 virtual OPimRecord* record( int rtti, const QByteArray& ) ;
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index d1eec19..4044bc1 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,4 +1,6 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qdatetime.h>
2#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
3 4
5#include <qpe/sound.h>
4#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
@@ -19,2 +21,4 @@ OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
19 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 21 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
22 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ),
23 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
20 24
@@ -52,3 +56,3 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
52 }else if ( cmd == "beam(int)" ) { 56 }else if ( cmd == "beam(int)" ) {
53 int uid, trans; 57 int uid;
54 stream >> uid; 58 stream >> uid;
@@ -72,2 +76,12 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
72 delete m_fallBack; 76 delete m_fallBack;
77 }else if ( cmd == "alarm(QDateTime,int)" ) {
78 QDateTime dt; int uid;
79 stream >> dt;
80 stream >> uid;
81 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
82 QDateTime current = QDateTime::currentDateTime();
83 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
84 return;
85 doAlarm( dt, uid );
86
73 } 87 }
@@ -104 +118,21 @@ int OPimMainWindow::service() {
104} 118}
119void OPimMainWindow::doAlarm( const QDateTime&, int ) {
120
121}
122void OPimMainWindow::startAlarm(int count ) {
123 m_alarmCount = count;
124 m_playedCount = 0;
125 Sound::soundAlarm();
126 m_timerId = startTimer( 5000 );
127}
128void OPimMainWindow::killAlarm() {
129 killTimer( m_timerId );
130}
131void OPimMainWindow::timerEvent( QTimerEvent* e) {
132 if ( m_playedCount <m_alarmCount ) {
133 m_playedCount++;
134 Sound::soundAlarm();
135 }else {
136 killTimer( e->timerId() );
137 }
138}
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h
index dca3c82..855d364 100644
--- a/libopie2/opiepim/ui/opimmainwindow.h
+++ b/libopie2/opiepim/ui/opimmainwindow.h
@@ -22,2 +22,3 @@
22class QCopChannel; 22class QCopChannel;
23class QDateTime;
23class OPimMainWindow : public QMainWindow { 24class OPimMainWindow : public QMainWindow {
@@ -58,2 +59,3 @@ protected slots:
58 59
60 virtual void doAlarm( const QDateTime&, int uid );
59 61
@@ -61,2 +63,11 @@ protected slots:
61 63
64protected:
65 /**
66 * start to play soundAlarm()
67 * @param count How many times the alarm is played
68 */
69 void startAlarm(int count = 10);
70 void killAlarm();
71 void timerEvent( QTimerEvent* );
72
62private slots: 73private slots:
@@ -75,3 +86,5 @@ private:
75 OPimRecord* m_fallBack; 86 OPimRecord* m_fallBack;
76 87 int m_alarmCount;
88 int m_playedCount;
89 int m_timerId;
77 /* I would love to do this as a template 90 /* I would love to do this as a template
@@ -80,5 +93,2 @@ private:
80 */ 93 */
81 /*
82 * the only pointer in the whole PIM API :(
83 */
84 virtual OPimRecord* record( int rtti, const QByteArray& ) ; 94 virtual OPimRecord* record( int rtti, const QByteArray& ) ;