summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimnotify.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimnotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp251
1 files changed, 186 insertions, 65 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp
index c61f9da..43858f0 100644
--- a/libopie2/opiepim/core/opimnotify.cpp
+++ b/libopie2/opiepim/core/opimnotify.cpp
@@ -23,236 +23,357 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qshared.h>
30 29
31#include <opie2/opimnotify.h> 30#include "opimnotify.h"
32 31
33namespace Opie { 32/* QT */
33#include <qshared.h>
34 34
35struct OPimNotify::Data : public QShared { 35namespace Opie
36 Data() : QShared(),dur(-1),parent(0) { 36{
37 37
38struct OPimNotify::Data : public QShared
39{
40 Data() : QShared(), dur( -1 ), parent( 0 )
41 {
38 } 42 }
39 QDateTime start; 43 QDateTime start;
40 int dur; 44 int dur;
41 QString application; 45 QString application;
42 int parent; 46 int parent;
43}; 47};
44 48
45OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { 49OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent )
50{
46 data = new Data; 51 data = new Data;
47 data->start = start; 52 data->start = start;
48 data->dur = duration; 53 data->dur = duration;
49 data->parent = parent; 54 data->parent = parent;
50} 55}
51OPimNotify::OPimNotify( const OPimNotify& noti) 56
52 : data( noti.data ) 57
58OPimNotify::OPimNotify( const OPimNotify& noti )
59 : data( noti.data )
53{ 60{
54 data->ref(); 61 data->ref();
55} 62}
56OPimNotify::~OPimNotify() { 63
57 if ( data->deref() ) { 64
65OPimNotify::~OPimNotify()
66{
67 if ( data->deref() )
68 {
58 delete data; 69 delete data;
59 data = 0l; 70 data = 0l;
60 } 71 }
61} 72}
62 73
63OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { 74
75OPimNotify &OPimNotify::operator=( const OPimNotify& noti )
76{
64 noti.data->ref(); 77 noti.data->ref();
65 deref(); 78 deref();
66 data = noti.data; 79 data = noti.data;
67 80
68 return *this; 81 return *this;
69} 82}
70bool OPimNotify::operator==( const OPimNotify& noti ) { 83
84
85bool OPimNotify::operator==( const OPimNotify& noti )
86{
71 if ( data == noti.data ) return true; 87 if ( data == noti.data ) return true;
72 if ( data->dur != noti.data->dur ) return false; 88 if ( data->dur != noti.data->dur ) return false;
73 if ( data->parent != noti.data->parent ) return false; 89 if ( data->parent != noti.data->parent ) return false;
74 if ( data->application != noti.data->application ) return false; 90 if ( data->application != noti.data->application ) return false;
75 if ( data->start != noti.data->start ) return false; 91 if ( data->start != noti.data->start ) return false;
76 92
77 return true; 93 return true;
78} 94}
79QDateTime OPimNotify::dateTime()const { 95
96
97QDateTime OPimNotify::dateTime() const
98{
80 return data->start; 99 return data->start;
81} 100}
82QString OPimNotify::service()const { 101
102
103QString OPimNotify::service() const
104{
83 return data->application; 105 return data->application;
84} 106}
85int OPimNotify::parent()const { 107
108
109int OPimNotify::parent() const
110{
86 return data->parent; 111 return data->parent;
87} 112}
88int OPimNotify::duration()const { 113
114
115int OPimNotify::duration() const
116{
89 return data->dur; 117 return data->dur;
90} 118}
91QDateTime OPimNotify::endTime()const { 119
92 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); 120
121QDateTime OPimNotify::endTime() const
122{
123 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) );
93} 124}
94void OPimNotify::setDateTime( const QDateTime& time ) { 125
126
127void OPimNotify::setDateTime( const QDateTime& time )
128{
95 copyIntern(); 129 copyIntern();
96 data->start = time; 130 data->start = time;
97} 131}
98void OPimNotify::setDuration( int dur ) { 132
133
134void OPimNotify::setDuration( int dur )
135{
99 copyIntern(); 136 copyIntern();
100 data->dur = dur; 137 data->dur = dur;
101} 138}
102void OPimNotify::setParent( int uid ) { 139
140
141void OPimNotify::setParent( int uid )
142{
103 copyIntern(); 143 copyIntern();
104 data->parent = uid; 144 data->parent = uid;
105} 145}
106void OPimNotify::setService( const QString& str ) { 146
147
148void OPimNotify::setService( const QString& str )
149{
107 copyIntern(); 150 copyIntern();
108 data->application = str; 151 data->application = str;
109} 152}
110void OPimNotify::copyIntern() { 153
111 if ( data->count != 1 ) { 154
155void OPimNotify::copyIntern()
156{
157 if ( data->count != 1 )
158 {
112 data->deref(); 159 data->deref();
113 Data* dat = new Data; 160 Data* dat = new Data;
114 dat->start = data->start; 161 dat->start = data->start;
115 dat->dur = data->dur; 162 dat->dur = data->dur;
116 dat->application = data->application; 163 dat->application = data->application;
117 dat->parent = data->parent; 164 dat->parent = data->parent;
118 data = dat; 165 data = dat;
119 } 166 }
120} 167}
121void OPimNotify::deref() { 168
122 if ( data->deref() ) { 169
170void OPimNotify::deref()
171{
172 if ( data->deref() )
173 {
123 delete data; 174 delete data;
124 data = 0; 175 data = 0;
125 } 176 }
126} 177}
127 178
179
128/***********************************************************/ 180/***********************************************************/
129struct OPimAlarm::Data : public QShared { 181struct OPimAlarm::Data : public QShared
130 Data() : QShared() { 182{
183 Data() : QShared()
184 {
131 sound = 1; 185 sound = 1;
132 } 186 }
133 int sound; 187 int sound;
134 QString file; 188 QString file;
135}; 189};
190
191
136OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) 192OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
137 : OPimNotify( start, duration, parent ) 193 : OPimNotify( start, duration, parent )
138{ 194{
139 data = new Data; 195 data = new Data;
140 data->sound = sound; 196 data->sound = sound;
141} 197}
142OPimAlarm::OPimAlarm( const OPimAlarm& al) 198
143 : OPimNotify(al), data( al.data ) 199
200OPimAlarm::OPimAlarm( const OPimAlarm& al )
201 : OPimNotify( al ), data( al.data )
144{ 202{
145 data->ref(); 203 data->ref();
146} 204}
147OPimAlarm::~OPimAlarm() { 205
148 if ( data->deref() ) { 206
207OPimAlarm::~OPimAlarm()
208{
209 if ( data->deref() )
210 {
149 delete data; 211 delete data;
150 data = 0l; 212 data = 0l;
151 } 213 }
152} 214}
153OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) 215
216
217OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al )
154{ 218{
155 OPimNotify::operator=( al ); 219 OPimNotify::operator=( al );
156 deref(); 220 deref();
157 al.data->ref(); 221 al.data->ref();
158 222
159 data = al.data; 223 data = al.data;
160 224
161 225
162 return *this; 226 return *this;
163} 227}
164bool OPimAlarm::operator==( const OPimAlarm& al) { 228
229
230bool OPimAlarm::operator==( const OPimAlarm& al )
231{
165 if ( data->sound != al.data->sound ) return false; 232 if ( data->sound != al.data->sound ) return false;
166 else if ( data->sound == Custom && data->file != al.data->file ) 233 else if ( data->sound == Custom && data->file != al.data->file )
167 return false; 234 return false;
168 235
169 return OPimNotify::operator==( al ); 236 return OPimNotify::operator==( al );
170} 237}
171QString OPimAlarm::type()const { 238
172 return QString::fromLatin1("OPimAlarm"); 239
240QString OPimAlarm::type() const
241{
242 return QString::fromLatin1( "OPimAlarm" );
173} 243}
174int OPimAlarm::sound()const { 244
245
246int OPimAlarm::sound() const
247{
175 return data->sound; 248 return data->sound;
176} 249}
177QString OPimAlarm::file()const { 250
251
252QString OPimAlarm::file() const
253{
178 return data->file; 254 return data->file;
179} 255}
180void OPimAlarm::setSound( int snd) { 256
257
258void OPimAlarm::setSound( int snd )
259{
181 copyIntern(); 260 copyIntern();
182 data->sound = snd; 261 data->sound = snd;
183} 262}
184void OPimAlarm::setFile( const QString& sound ) { 263
264
265void OPimAlarm::setFile( const QString& sound )
266{
185 copyIntern(); 267 copyIntern();
186 data->file = sound; 268 data->file = sound;
187} 269}
188void OPimAlarm::deref() { 270
189 if ( data->deref() ) { 271
272void OPimAlarm::deref()
273{
274 if ( data->deref() )
275 {
190 delete data; 276 delete data;
191 data = 0l; 277 data = 0l;
192 } 278 }
193} 279}
194void OPimAlarm::copyIntern() { 280
195 if ( data->count != 1 ) { 281
282void OPimAlarm::copyIntern()
283{
284 if ( data->count != 1 )
285 {
196 data->deref(); 286 data->deref();
197 Data *newDat = new Data; 287 Data *newDat = new Data;
198 newDat->sound = data->sound; 288 newDat->sound = data->sound;
199 newDat->file = data->file; 289 newDat->file = data->file;
200 data = newDat; 290 data = newDat;
201 } 291 }
202} 292}
293
294
203/************************/ 295/************************/
204struct OPimReminder::Data : public QShared { 296struct OPimReminder::Data : public QShared
205 Data() : QShared(), record( 0) { 297{
206 } 298 Data() : QShared(), record( 0 )
299 {}
207 int record; 300 int record;
208 301
209}; 302};
210OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) 303
211 : OPimNotify( start, dur, parent ) 304
305OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
306 : OPimNotify( start, dur, parent )
212{ 307{
213 data = new Data; 308 data = new Data;
214 data->record = uid; 309 data->record = uid;
215} 310}
311
312
216OPimReminder::OPimReminder( const OPimReminder& rem ) 313OPimReminder::OPimReminder( const OPimReminder& rem )
217 : OPimNotify( rem ), data( rem.data ) 314 : OPimNotify( rem ), data( rem.data )
218{ 315{
219 data->ref(); 316 data->ref();
220} 317}
221OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { 318
222 OPimNotify::operator=(rem ); 319
320OPimReminder& OPimReminder::operator=( const OPimReminder& rem )
321{
322 OPimNotify::operator=( rem );
223 323
224 deref(); 324 deref();
225 rem.data->ref(); 325 rem.data->ref();
226 data = rem.data; 326 data = rem.data;
227 327
228 return *this; 328 return *this;
229} 329}
230bool OPimReminder::operator==( const OPimReminder& rem) { 330
331
332bool OPimReminder::operator==( const OPimReminder& rem )
333{
231 if ( data->record != rem.data->record ) return false; 334 if ( data->record != rem.data->record ) return false;
232 335
233 return OPimNotify::operator==( rem ); 336 return OPimNotify::operator==( rem );
234} 337}
235QString OPimReminder::type()const { 338
236 return QString::fromLatin1("OPimReminder"); 339
340QString OPimReminder::type() const
341{
342 return QString::fromLatin1( "OPimReminder" );
237} 343}
238int OPimReminder::recordUid()const { 344
345
346int OPimReminder::recordUid() const
347{
239 return data->record; 348 return data->record;
240} 349}
241void OPimReminder::setRecordUid( int uid ) { 350
351
352void OPimReminder::setRecordUid( int uid )
353{
242 copyIntern(); 354 copyIntern();
243 data->record = uid; 355 data->record = uid;
244} 356}
245void OPimReminder::deref() { 357
246 if ( data->deref() ) { 358
359void OPimReminder::deref()
360{
361 if ( data->deref() )
362 {
247 delete data; 363 delete data;
248 data = 0l; 364 data = 0l;
249 } 365 }
250} 366}
251void OPimReminder::copyIntern() { 367
252 if ( data->count != 1 ) { 368
253 Data* da = new Data; 369void OPimReminder::copyIntern()
370{
371 if ( data->count != 1 )
372 {
373 Data * da = new Data;
254 da->record = data->record; 374 da->record = data->record;
255 data = da; 375 data = da;
256 } 376 }
257} 377}
378
258} 379}