Diffstat (limited to 'libopie2/opiepim/core/opimnotifymanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 573340a..0f863aa 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -1,81 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
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 | 29 | ||
30 | #include "opimnotifymanager.h" | 30 | #include "opimnotifymanager.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimdateconversion.h> | 33 | #include <opie2/opimdateconversion.h> |
34 | #include <opie2/odebug.h> | ||
34 | 35 | ||
35 | /* QT */ | 36 | /* QT */ |
36 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
37 | 38 | ||
38 | namespace Opie | 39 | namespace Opie |
39 | { | 40 | { |
40 | 41 | ||
41 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) | 42 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) |
42 | : m_rem( rem ), m_al( al ) | 43 | : m_rem( rem ), m_al( al ) |
43 | {} | 44 | {} |
44 | 45 | ||
45 | 46 | ||
46 | OPimNotifyManager::~OPimNotifyManager() | 47 | OPimNotifyManager::~OPimNotifyManager() |
47 | {} | 48 | {} |
48 | 49 | ||
49 | 50 | ||
50 | /* use static_cast and type instead of dynamic... */ | 51 | /* use static_cast and type instead of dynamic... */ |
51 | void OPimNotifyManager::add( const OPimNotify& noti ) | 52 | void OPimNotifyManager::add( const OPimNotify& noti ) |
52 | { | 53 | { |
53 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | 54 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) |
54 | { | 55 | { |
55 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); | 56 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); |
56 | m_rem.append( rem ); | 57 | m_rem.append( rem ); |
57 | } | 58 | } |
58 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) | 59 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) |
59 | { | 60 | { |
60 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); | 61 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); |
61 | m_al.append( al ); | 62 | m_al.append( al ); |
62 | } | 63 | } |
63 | } | 64 | } |
64 | 65 | ||
65 | 66 | ||
66 | void OPimNotifyManager::remove( const OPimNotify& noti ) | 67 | void OPimNotifyManager::remove( const OPimNotify& noti ) |
67 | { | 68 | { |
68 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | 69 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) |
69 | { | 70 | { |
70 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); | 71 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); |
71 | m_rem.remove( rem ); | 72 | m_rem.remove( rem ); |
72 | } | 73 | } |
73 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) | 74 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) |
74 | { | 75 | { |
75 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); | 76 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); |
76 | m_al.remove( al ); | 77 | m_al.remove( al ); |
77 | } | 78 | } |
78 | } | 79 | } |
79 | 80 | ||
80 | 81 | ||
81 | void OPimNotifyManager::replace( const OPimNotify& noti ) | 82 | void OPimNotifyManager::replace( const OPimNotify& noti ) |
@@ -118,132 +119,132 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found | |||
118 | return ( *it ); | 119 | return ( *it ); |
119 | } | 120 | } |
120 | 121 | ||
121 | // Fall through if nothing could be found | 122 | // Fall through if nothing could be found |
122 | found = false; | 123 | found = false; |
123 | OPimAlarm empty; | 124 | OPimAlarm empty; |
124 | return empty; | 125 | return empty; |
125 | } | 126 | } |
126 | 127 | ||
127 | 128 | ||
128 | void OPimNotifyManager::setAlarms( const Alarms& al ) | 129 | void OPimNotifyManager::setAlarms( const Alarms& al ) |
129 | { | 130 | { |
130 | m_al = al; | 131 | m_al = al; |
131 | } | 132 | } |
132 | 133 | ||
133 | 134 | ||
134 | void OPimNotifyManager::setReminders( const Reminders& rem ) | 135 | void OPimNotifyManager::setReminders( const Reminders& rem ) |
135 | { | 136 | { |
136 | m_rem = rem; | 137 | m_rem = rem; |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | /* FIXME!!! */ | 141 | /* FIXME!!! */ |
141 | /** | 142 | /** |
142 | * The idea is to check if the provider for our service | 143 | * The idea is to check if the provider for our service |
143 | * is online | 144 | * is online |
144 | * if it is we will use QCOP | 145 | * if it is we will use QCOP |
145 | * if not the Factory to get the backend... | 146 | * if not the Factory to get the backend... |
146 | * Qtopia1.6 services would be kewl to have here.... | 147 | * Qtopia1.6 services would be kewl to have here.... |
147 | */ | 148 | */ |
148 | void OPimNotifyManager::registerNotify( const OPimNotify& ) | 149 | void OPimNotifyManager::registerNotify( const OPimNotify& ) |
149 | { | 150 | { |
150 | } | 151 | } |
151 | 152 | ||
152 | 153 | ||
153 | /* FIXME!!! */ | 154 | /* FIXME!!! */ |
154 | /** | 155 | /** |
155 | * same as above... | 156 | * same as above... |
156 | * Also implement Url model | 157 | * Also implement Url model |
157 | * have a MainWindow.... | 158 | * have a MainWindow.... |
158 | */ | 159 | */ |
159 | void OPimNotifyManager::deregister( const OPimNotify& ) | 160 | void OPimNotifyManager::deregister( const OPimNotify& ) |
160 | { | 161 | { |
161 | } | 162 | } |
162 | 163 | ||
163 | 164 | ||
164 | bool OPimNotifyManager::isEmpty() const | 165 | bool OPimNotifyManager::isEmpty() const |
165 | { | 166 | { |
166 | qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | 167 | owarn << "is Empty called on OPimNotifyManager " << m_rem.count() << " " << m_al.count() << "" << oendl; |
167 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | 168 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; |
168 | else return false; | 169 | else return false; |
169 | } | 170 | } |
170 | 171 | ||
171 | 172 | ||
172 | // Taken from otodoaccessxml.. code duplication bad. any alternative? | 173 | // Taken from otodoaccessxml.. code duplication bad. any alternative? |
173 | QString OPimNotifyManager::alarmsToString() const | 174 | QString OPimNotifyManager::alarmsToString() const |
174 | { | 175 | { |
175 | QString str; | 176 | QString str; |
176 | 177 | ||
177 | OPimNotifyManager::Alarms alarms = m_al; | 178 | OPimNotifyManager::Alarms alarms = m_al; |
178 | if ( !alarms.isEmpty() ) | 179 | if ( !alarms.isEmpty() ) |
179 | { | 180 | { |
180 | QStringList als; | 181 | QStringList als; |
181 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 182 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
182 | for ( ; it != alarms.end(); ++it ) | 183 | for ( ; it != alarms.end(); ++it ) |
183 | { | 184 | { |
184 | /* only if time is valid */ | 185 | /* only if time is valid */ |
185 | if ( ( *it ).dateTime().isValid() ) | 186 | if ( ( *it ).dateTime().isValid() ) |
186 | { | 187 | { |
187 | als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() ) | 188 | als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() ) |
188 | + ":" + QString::number( ( *it ).duration() ) | 189 | + ":" + QString::number( ( *it ).duration() ) |
189 | + ":" + QString::number( ( *it ).sound() ) | 190 | + ":" + QString::number( ( *it ).sound() ) |
190 | + ":"; | 191 | + ":"; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | // now write the list | 194 | // now write the list |
194 | qWarning( "als: %s", als.join( "____________" ).latin1() ); | 195 | owarn << "als: " << als.join( "____________" ) << "" << oendl; |
195 | str = als.join( ";" ); | 196 | str = als.join( ";" ); |
196 | } | 197 | } |
197 | 198 | ||
198 | return str; | 199 | return str; |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
202 | QString OPimNotifyManager::remindersToString() const | 203 | QString OPimNotifyManager::remindersToString() const |
203 | { | 204 | { |
204 | QString str; | 205 | QString str; |
205 | 206 | ||
206 | OPimNotifyManager::Reminders reminders = m_rem; | 207 | OPimNotifyManager::Reminders reminders = m_rem; |
207 | if ( !reminders.isEmpty() ) | 208 | if ( !reminders.isEmpty() ) |
208 | { | 209 | { |
209 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 210 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
210 | QStringList records; | 211 | QStringList records; |
211 | for ( ; it != reminders.end(); ++it ) | 212 | for ( ; it != reminders.end(); ++it ) |
212 | { | 213 | { |
213 | records << QString::number( ( *it ).recordUid() ); | 214 | records << QString::number( ( *it ).recordUid() ); |
214 | } | 215 | } |
215 | str = records.join( ";" ); | 216 | str = records.join( ";" ); |
216 | } | 217 | } |
217 | 218 | ||
218 | return str; | 219 | return str; |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | void OPimNotifyManager::alarmsFromString( const QString& str ) | 223 | void OPimNotifyManager::alarmsFromString( const QString& str ) |
223 | { | 224 | { |
224 | QStringList als = QStringList::split( ";", str ); | 225 | QStringList als = QStringList::split( ";", str ); |
225 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) | 226 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) |
226 | { | 227 | { |
227 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty | 228 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty |
228 | qWarning( "alarm: %s", alarm.join( "___" ).latin1() ); | 229 | owarn << "alarm: " << alarm.join( "___" ) << "" << oendl; |
229 | qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), | 230 | qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), |
230 | OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); | 231 | OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); |
231 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), | 232 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), |
232 | alarm[ 1 ].toInt() ); | 233 | alarm[ 1 ].toInt() ); |
233 | add( al ); | 234 | add( al ); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | void OPimNotifyManager::remindersFromString( const QString& str ) | 239 | void OPimNotifyManager::remindersFromString( const QString& str ) |
239 | { | 240 | { |
240 | 241 | ||
241 | QStringList rems = QStringList::split( ";", str ); | 242 | QStringList rems = QStringList::split( ";", str ); |
242 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) | 243 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) |
243 | { | 244 | { |
244 | OPimReminder rem( ( *it ).toInt() ); | 245 | OPimReminder rem( ( *it ).toInt() ); |
245 | add( rem ); | 246 | add( rem ); |
246 | } | 247 | } |
247 | 248 | ||
248 | } | 249 | } |
249 | } | 250 | } |