summaryrefslogtreecommitdiffabout
path: root/kalarmd
Unidiff
Diffstat (limited to 'kalarmd') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index b3da428..294ce7d 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,187 +1,187 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "simplealarmdaemonimpl.h" 24#include "simplealarmdaemonimpl.h"
25 25
26#include "alarmdialog.h" 26#include "alarmdialog.h"
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qhbox.h> 31#include <qhbox.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qdialog.h> 38#include <qdialog.h>
39#define protected public 39#define protected public
40#include <qspinbox.h> 40#include <qspinbox.h>
41#undef protected 41#undef protected
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qtopia/qcopenvelope_qws.h> 43#include <qtopia/qcopenvelope_qws.h>
44#include <qtopia/alarmserver.h> 44#include <qtopia/alarmserver.h>
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
52 : QLabel( parent ) 52 : QLabel( parent )
53{ 53{
54 mAlarmDialog = new AlarmDialog( 0 ); 54 mAlarmDialog = new AlarmDialog( 0 );
55 mPopUp = new QPopupMenu( this ); 55 mPopUp = new QPopupMenu( this );
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
58 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
59 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); 59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) );
60 mPopUp->insertSeparator(); 60 mPopUp->insertSeparator();
61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); 61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
62 mPopUp->insertSeparator(); 62 mPopUp->insertSeparator();
63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); 66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
67 mPopUp->insertSeparator(); 67 mPopUp->insertSeparator();
68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); 68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
69 mTimerPopUp = new QPopupMenu( this ); 69 mTimerPopUp = new QPopupMenu( this );
70 QFont fon = mTimerPopUp->font(); 70 QFont fon = mTimerPopUp->font();
71 fon.setPointSize( fon.pointSize() *3/2 ); 71 fon.setPointSize( fon.pointSize() *3/2 );
72 mTimerPopUp->setFont( fon ); 72 mTimerPopUp->setFont( fon );
73 mBeepPopUp = new QPopupMenu( this ); 73 mBeepPopUp = new QPopupMenu( this );
74 mSoundPopUp = new QPopupMenu( this ); 74 mSoundPopUp = new QPopupMenu( this );
75 mPausePopUp = new QPopupMenu( this ); 75 mPausePopUp = new QPopupMenu( this );
76 QPopupMenu* savePopUp = new QPopupMenu( this ); 76 QPopupMenu* savePopUp = new QPopupMenu( this );
77 savePopUp->insertItem( "Save", 0 ); 77 savePopUp->insertItem( "Save", 0 );
78 savePopUp->insertItem( "Load", 1 ); 78 savePopUp->insertItem( "Load", 1 );
79 mSoundPopUp->insertItem( "Buzzer", 0 ); 79 mSoundPopUp->insertItem( "Buzzer", 0 );
80 mSoundPopUp->insertItem( "Wav file", 1 ); 80 mSoundPopUp->insertItem( "Wav file", 1 );
81 mPausePopUp->insertItem( " 1 sec", 1 ); 81 mPausePopUp->insertItem( " 1 sec", 1 );
82 mPausePopUp->insertItem( " 2 sec", 2 ); 82 mPausePopUp->insertItem( " 2 sec", 2 );
83 mPausePopUp->insertItem( " 3 sec", 3 ); 83 mPausePopUp->insertItem( " 3 sec", 3 );
84 mPausePopUp->insertItem( " 5 sec", 5 ); 84 mPausePopUp->insertItem( " 5 sec", 5 );
85 mPausePopUp->insertItem( "10 sec", 10 ); 85 mPausePopUp->insertItem( "10 sec", 10 );
86 mPausePopUp->insertItem( "30 sec", 30 ); 86 mPausePopUp->insertItem( "30 sec", 30 );
87 mPausePopUp->insertItem( " 1 min", 60 ); 87 mPausePopUp->insertItem( " 1 min", 60 );
88 mPausePopUp->insertItem( " 5 min", 300 ); 88 mPausePopUp->insertItem( " 5 min", 300 );
89 mPausePopUp->insertItem( "10 min", 600 ); 89 mPausePopUp->insertItem( "10 min", 600 );
90 mSuspendPopUp = new QPopupMenu( this ); 90 mSuspendPopUp = new QPopupMenu( this );
91 mSuspendPopUp->insertItem( "Off", 0 ); 91 mSuspendPopUp->insertItem( "Off", 0 );
92 mSuspendPopUp->insertItem( " 1x", 1 ); 92 mSuspendPopUp->insertItem( " 1x", 1 );
93 mSuspendPopUp->insertItem( " 2x", 2 ); 93 mSuspendPopUp->insertItem( " 2x", 2 );
94 mSuspendPopUp->insertItem( " 3x", 3 ); 94 mSuspendPopUp->insertItem( " 3x", 3 );
95 mSuspendPopUp->insertItem( " 5x", 5 ); 95 mSuspendPopUp->insertItem( " 5x", 5 );
96 mSuspendPopUp->insertItem( "10x", 10 ); 96 mSuspendPopUp->insertItem( "10x", 10 );
97 mSuspendPopUp->insertItem( "20x", 20 ); 97 mSuspendPopUp->insertItem( "20x", 20 );
98 mSuspendPopUp->insertItem( "30x", 30 ); 98 mSuspendPopUp->insertItem( "30x", 30 );
99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
101 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 101 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
102 mBeepPopUp->insertItem( "Config",savePopUp ); 102 mBeepPopUp->insertItem( "Config",savePopUp );
103 mBeepPopUp->insertItem( "300", 300 ); 103 mBeepPopUp->insertItem( "300", 300 );
104 mBeepPopUp->insertItem( "180", 180 ); 104 mBeepPopUp->insertItem( "180", 180 );
105 mBeepPopUp->insertItem( "60", 60 ); 105 mBeepPopUp->insertItem( "60", 60 );
106 mBeepPopUp->insertItem( "30", 30 ); 106 mBeepPopUp->insertItem( "30", 30 );
107 mBeepPopUp->insertItem( "10", 10 ); 107 mBeepPopUp->insertItem( "10", 10 );
108 mBeepPopUp->insertItem( "3", 3 ); 108 mBeepPopUp->insertItem( "3", 3 );
109 mBeepPopUp->insertItem( "1", 1 ); 109 mBeepPopUp->insertItem( "1", 1 );
110 mBeepPopUp->insertItem( "Off", 0 ); 110 mBeepPopUp->insertItem( "Off", 0 );
111 mBeepPopUp->setCheckable( true ); 111 mBeepPopUp->setCheckable( true );
112 mPopUp->insertSeparator(); 112 mPopUp->insertSeparator();
113 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 113 mPopUp->insertItem( "Play beeps", mBeepPopUp );
114 mPopUp->insertSeparator(); 114 mPopUp->insertSeparator();
115 mPopUp->insertItem( "Timer", mTimerPopUp ); 115 mPopUp->insertItem( "Timer", mTimerPopUp );
116 mPopUp->insertSeparator(); 116 mPopUp->insertSeparator();
117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
118 118
119 mPopUp->resize( mPopUp->sizeHint() ); 119 mPopUp->resize( mPopUp->sizeHint() );
120 mPlayBeeps = 60; 120 mPlayBeeps = 60;
121 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 121 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
129 mTimerTime = 0; 129 mTimerTime = 0;
130 mCustomText = "Custom Text"; 130 mCustomText = "Custom Text";
131 mCustomMinutes = 7; 131 mCustomMinutes = 7;
132 mTimerPopupConf = 1; 132 mTimerPopupConf = 1;
133 fillTimerPopUp(); 133 fillTimerPopUp();
134 mPausePlay = 0; 134 mPausePlay = 0;
135 confPause( 1 ); 135 confPause( 1 );
136 mSuspend = 0; 136 mSuspend = 0;
137 confSuspend( 0 ); 137 confSuspend( 0 );
138 if ( QApplication::desktop()->width() < 480 ) { 138 if ( QApplication::desktop()->width() < 480 ) {
139 wavAlarm = false; 139 wavAlarm = false;
140 mSoundPopUp->setItemChecked ( 0, true ); 140 mSoundPopUp->setItemChecked ( 0, true );
141 } 141 }
142 else { 142 else {
143 wavAlarm = true; 143 wavAlarm = true;
144 mSoundPopUp->setItemChecked ( 1, true ); 144 mSoundPopUp->setItemChecked ( 1, true );
145 } 145 }
146 saveSlot( 1 ); 146 saveSlot( 1 );
147} 147}
148 148
149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
150{ 150{
151 //delete mPopUp; 151 //delete mPopUp;
152 delete mAlarmDialog; 152 delete mAlarmDialog;
153} 153}
154void SimpleAlarmDaemonImpl::saveSlot( int load ) 154void SimpleAlarmDaemonImpl::saveSlot( int load )
155{ 155{
156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
157 //qDebug("save %d ", load ); 157 //qDebug("save %d ", load );
158 QFile file( fileName ); 158 QFile file( fileName );
159 if ( load ) { 159 if ( load ) {
160 if( !QFile::exists( fileName) ) 160 if( !QFile::exists( fileName) )
161 return; 161 return;
162 if (!file.open( IO_ReadOnly ) ) { 162 if (!file.open( IO_ReadOnly ) ) {
163 return ; 163 return ;
164 } 164 }
165 QString line; 165 QString line;
166 bool ok; 166 bool ok;
167 int val; 167 int val;
168 int len; 168 int len;
169 while ( file.readLine( line, 1024 ) > 0 ) { 169 while ( file.readLine( line, 1024 ) > 0 ) {
170 //qDebug("read %s ", line.latin1()); 170 //qDebug("read %s ", line.latin1());
171 len = line.length(); 171 len = line.length();
172 if ( line.left(4 ) == "PPAU" ) { 172 if ( line.left(4 ) == "PPAU" ) {
173 val = line.mid( 4,len-5).toInt( &ok ); 173 val = line.mid( 4,len-5).toInt( &ok );
174 if ( ok ) { 174 if ( ok ) {
175 confPause( val ); 175 confPause( val );
176 } 176 }
177 } 177 }
178 if ( line.left(4 ) == "SUCO" ) { 178 if ( line.left(4 ) == "SUCO" ) {
179 val = line.mid( 4,len-5).toInt( &ok ); 179 val = line.mid( 4,len-5).toInt( &ok );
180 if ( ok ) 180 if ( ok )
181 confSuspend ( val ); 181 confSuspend ( val );
182 } 182 }
183 if ( line.left(4 ) == "WAAL" ) { 183 if ( line.left(4 ) == "WAAL" ) {
184 val = line.mid( 4,len-5).toInt( &ok ); 184 val = line.mid( 4,len-5).toInt( &ok );
185 if ( ok ) 185 if ( ok )
186 confSound( val ); 186 confSound( val );
187 187