summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-16 21:15:03 (UTC)
committer zecke <zecke>2003-02-16 21:15:03 (UTC)
commit73aed6b9a34330b31f05864746269017cd53017d (patch) (unidiff)
tree46871140a505ab3a98afab9d10072816568fe909
parent892a453a931b41967c7dca72097da9c5be7f84d6 (diff)
downloadopie-73aed6b9a34330b31f05864746269017cd53017d.zip
opie-73aed6b9a34330b31f05864746269017cd53017d.tar.gz
opie-73aed6b9a34330b31f05864746269017cd53017d.tar.bz2
stoned coding should be prohibited in Australia..
The comment nicely says year month day Z hour minute secons and it was year month year so what is wrong ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/event.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/backend/event.cpp b/library/backend/event.cpp
index 2d02a34..eb238a4 100644
--- a/library/backend/event.cpp
+++ b/library/backend/event.cpp
@@ -987,262 +987,262 @@ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
987} 987}
988 988
989/*! 989/*!
990 \internal 990 \internal
991*/ 991*/
992bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 992bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
993{ 993{
994 return ( mDate == e.date() 994 return ( mDate == e.date()
995 && mStart == e.start() 995 && mStart == e.start()
996 && mEnd == e.end() 996 && mEnd == e.end()
997 && mEvent == e.event() ); 997 && mEvent == e.event() );
998} 998}
999 999
1000/*! 1000/*!
1001 \internal 1001 \internal
1002*/ 1002*/
1003bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const 1003bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
1004{ 1004{
1005 return !(*this == e); 1005 return !(*this == e);
1006} 1006}
1007 1007
1008/*! 1008/*!
1009 \internal 1009 \internal
1010*/ 1010*/
1011bool EffectiveEvent::operator>( const EffectiveEvent &e ) const 1011bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
1012{ 1012{
1013 return !(*this <= e ); 1013 return !(*this <= e );
1014} 1014}
1015 1015
1016/*! 1016/*!
1017 \internal 1017 \internal
1018*/ 1018*/
1019bool EffectiveEvent::operator>=(const EffectiveEvent &e) const 1019bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
1020{ 1020{
1021 return !(*this < e); 1021 return !(*this < e);
1022} 1022}
1023 1023
1024/*! 1024/*!
1025 \internal 1025 \internal
1026*/ 1026*/
1027void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) 1027void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
1028{ 1028{
1029 if ( !from.isValid() ) { 1029 if ( !from.isValid() ) {
1030 delete d; 1030 delete d;
1031 d = 0; 1031 d = 0;
1032 return; 1032 return;
1033 } 1033 }
1034 if ( !d ) 1034 if ( !d )
1035 d = new EffectiveEventPrivate; 1035 d = new EffectiveEventPrivate;
1036 d->startDate = from; 1036 d->startDate = from;
1037 d->endDate = to; 1037 d->endDate = to;
1038} 1038}
1039 1039
1040/*! 1040/*!
1041 \internal 1041 \internal
1042*/ 1042*/
1043QDate EffectiveEvent::startDate() const 1043QDate EffectiveEvent::startDate() const
1044{ 1044{
1045 if ( d ) 1045 if ( d )
1046 return d->startDate; 1046 return d->startDate;
1047 else if ( mEvent.hasRepeat() ) 1047 else if ( mEvent.hasRepeat() )
1048 return mDate; // single day, since multi-day should have a d pointer 1048 return mDate; // single day, since multi-day should have a d pointer
1049 else 1049 else
1050 return mEvent.start().date(); 1050 return mEvent.start().date();
1051} 1051}
1052 1052
1053/*! 1053/*!
1054 \internal 1054 \internal
1055*/ 1055*/
1056QDate EffectiveEvent::endDate() const 1056QDate EffectiveEvent::endDate() const
1057{ 1057{
1058 if ( d ) 1058 if ( d )
1059 return d->endDate; 1059 return d->endDate;
1060 else if ( mEvent.hasRepeat() ) 1060 else if ( mEvent.hasRepeat() )
1061 return mDate; // single day, since multi-day should have a d pointer 1061 return mDate; // single day, since multi-day should have a d pointer
1062 else 1062 else
1063 return mEvent.end().date(); 1063 return mEvent.end().date();
1064} 1064}
1065 1065
1066/*! 1066/*!
1067 \internal 1067 \internal
1068*/ 1068*/
1069int EffectiveEvent::size() const 1069int EffectiveEvent::size() const
1070{ 1070{
1071 return ( mEnd.hour() - mStart.hour() ) * 3600 1071 return ( mEnd.hour() - mStart.hour() ) * 3600
1072 + (mEnd.minute() - mStart.minute() * 60 1072 + (mEnd.minute() - mStart.minute() * 60
1073 + mEnd.second() - mStart.second() ); 1073 + mEnd.second() - mStart.second() );
1074} 1074}
1075 1075
1076 1076
1077// vcal conversion code 1077// vcal conversion code
1078static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 1078static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
1079{ 1079{
1080 VObject *ret = 0; 1080 VObject *ret = 0;
1081 if ( o && !value.isEmpty() ) 1081 if ( o && !value.isEmpty() )
1082 ret = addPropValue( o, prop, value.latin1() ); 1082 ret = addPropValue( o, prop, value.latin1() );
1083 return ret; 1083 return ret;
1084} 1084}
1085 1085
1086static inline VObject *safeAddProp( VObject *o, const char *prop) 1086static inline VObject *safeAddProp( VObject *o, const char *prop)
1087{ 1087{
1088 VObject *ret = 0; 1088 VObject *ret = 0;
1089 if ( o ) 1089 if ( o )
1090 ret = addProp( o, prop ); 1090 ret = addProp( o, prop );
1091 return ret; 1091 return ret;
1092} 1092}
1093 1093
1094/* 1094/*
1095 * Until we support vCal/iCal right 1095 * Until we support vCal/iCal right
1096 * we will make DTSTART and other things 1096 * we will make DTSTART and other things
1097 * be floating in the sense of 1097 * be floating in the sense of
1098 * RFC 2445 1098 * RFC 2445
1099 */ 1099 */
1100namespace { 1100namespace {
1101/* 1101/*
1102 * Convert QDateTime to iso8601 but take 1102 * Convert QDateTime to iso8601 but take
1103 * local time and do not use the Z at the end 1103 * local time and do not use the Z at the end
1104 * 1104 *
1105 */ 1105 */
1106 QCString toISOLocal( const QDateTime& dt ) { 1106 QCString toISOLocal( const QDateTime& dt ) {
1107 QCString str; 1107 QCString str;
1108 /* 1108 /*
1109 * year month day T Hour Minute Second 1109 * year month day T Hour Minute Second
1110 * 4 2 2 2 2 2 digits 1110 * 4 2 2 2 2 2 digits
1111 */ 1111 */
1112 str.sprintf("%04d%02d%02dT%02d%02d%02d", 1112 str.sprintf("%04d%02d%02dT%02d%02d%02d",
1113 dt.date().year(), 1113 dt.date().year(),
1114 dt.date().month(), 1114 dt.date().month(),
1115 dt.date().year(), 1115 dt.date().day(),
1116 dt.time().hour(), 1116 dt.time().hour(),
1117 dt.time().minute(), 1117 dt.time().minute(),
1118 dt.time().second() ); 1118 dt.time().second() );
1119 1119
1120 1120 qWarning("Str ist %s", str.data() );
1121 1121
1122 return str; 1122 return str;
1123 } 1123 }
1124 1124
1125 1125
1126}; 1126};
1127 1127
1128static VObject *createVObject( const Event &e ) 1128static VObject *createVObject( const Event &e )
1129{ 1129{
1130 VObject *vcal = newVObject( VCCalProp ); 1130 VObject *vcal = newVObject( VCCalProp );
1131 safeAddPropValue( vcal, VCVersionProp, "1.0" ); 1131 safeAddPropValue( vcal, VCVersionProp, "1.0" );
1132 VObject *event = safeAddProp( vcal, VCEventProp ); 1132 VObject *event = safeAddProp( vcal, VCEventProp );
1133 1133
1134 safeAddPropValue( event, VCDTstartProp, toISOLocal( e.start() ) ); 1134 safeAddPropValue( event, VCDTstartProp, toISOLocal( e.start() ) );
1135 safeAddPropValue( event, VCDTendProp, toISOLocal( e.end() ) ); 1135 safeAddPropValue( event, VCDTendProp, toISOLocal( e.end() ) );
1136 safeAddPropValue( event, "X-Qtopia-NOTES", e.description() ); 1136 safeAddPropValue( event, "X-Qtopia-NOTES", e.description() );
1137 safeAddPropValue( event, VCDescriptionProp, e.description() ); 1137 safeAddPropValue( event, VCDescriptionProp, e.description() );
1138 safeAddPropValue( event, VCLocationProp, e.location() ); 1138 safeAddPropValue( event, VCLocationProp, e.location() );
1139 1139
1140 if ( e.hasAlarm() ) { 1140 if ( e.hasAlarm() ) {
1141 VObject *alarm = safeAddProp( event, VCAAlarmProp ); 1141 VObject *alarm = safeAddProp( event, VCAAlarmProp );
1142 QDateTime dt = e.start(); 1142 QDateTime dt = e.start();
1143 dt = dt.addSecs( -e.alarmTime()*60 ); 1143 dt = dt.addSecs( -e.alarmTime()*60 );
1144 safeAddPropValue( alarm, VCRunTimeProp, toISOLocal( dt ) ); 1144 safeAddPropValue( alarm, VCRunTimeProp, toISOLocal( dt ) );
1145 safeAddPropValue( alarm, VCAudioContentProp, 1145 safeAddPropValue( alarm, VCAudioContentProp,
1146 (e.alarmSound() == Event::Silent ? "silent" : "alarm" ) ); 1146 (e.alarmSound() == Event::Silent ? "silent" : "alarm" ) );
1147 } 1147 }
1148 1148
1149 safeAddPropValue( event, "X-Qtopia-TIMEZONE", e.timeZone() ); 1149 safeAddPropValue( event, "X-Qtopia-TIMEZONE", e.timeZone() );
1150 1150
1151 if ( e.type() == Event::AllDay ) 1151 if ( e.type() == Event::AllDay )
1152 safeAddPropValue( event, "X-Qtopia-AllDay", e.timeZone() ); 1152 safeAddPropValue( event, "X-Qtopia-AllDay", e.timeZone() );
1153 1153
1154 // ### repeat missing 1154 // ### repeat missing
1155 1155
1156 // ### categories missing 1156 // ### categories missing
1157 1157
1158 return vcal; 1158 return vcal;
1159} 1159}
1160 1160
1161 1161
1162static Event parseVObject( VObject *obj ) 1162static Event parseVObject( VObject *obj )
1163{ 1163{
1164 Event e; 1164 Event e;
1165 1165
1166 bool haveAlarm = FALSE; 1166 bool haveAlarm = FALSE;
1167 bool haveStart = FALSE; 1167 bool haveStart = FALSE;
1168 bool haveEnd = FALSE; 1168 bool haveEnd = FALSE;
1169 QDateTime alarmTime; 1169 QDateTime alarmTime;
1170 Event::SoundTypeChoice soundType = Event::Silent; 1170 Event::SoundTypeChoice soundType = Event::Silent;
1171 1171
1172 VObjectIterator it; 1172 VObjectIterator it;
1173 initPropIterator( &it, obj ); 1173 initPropIterator( &it, obj );
1174 while( moreIteration( &it ) ) { 1174 while( moreIteration( &it ) ) {
1175 VObject *o = nextVObject( &it ); 1175 VObject *o = nextVObject( &it );
1176 QCString name = vObjectName( o ); 1176 QCString name = vObjectName( o );
1177 QCString value = vObjectStringZValue( o ); 1177 QCString value = vObjectStringZValue( o );
1178 if ( name == VCDTstartProp ) { 1178 if ( name == VCDTstartProp ) {
1179 e.setStart( TimeConversion::fromISO8601( value ) ); 1179 e.setStart( TimeConversion::fromISO8601( value ) );
1180 haveStart = TRUE; 1180 haveStart = TRUE;
1181 } 1181 }
1182 else if ( name == VCDTendProp ) { 1182 else if ( name == VCDTendProp ) {
1183 e.setEnd( TimeConversion::fromISO8601( value ) ); 1183 e.setEnd( TimeConversion::fromISO8601( value ) );
1184 haveEnd = TRUE; 1184 haveEnd = TRUE;
1185 } 1185 }
1186 else if ( name == "X-Qtopia-NOTES" ) { 1186 else if ( name == "X-Qtopia-NOTES" ) {
1187 e.setNotes( value ); 1187 e.setNotes( value );
1188 } 1188 }
1189 else if ( name == VCDescriptionProp ) { 1189 else if ( name == VCDescriptionProp ) {
1190 e.setDescription( value ); 1190 e.setDescription( value );
1191 } 1191 }
1192 else if ( name == VCLocationProp ) { 1192 else if ( name == VCLocationProp ) {
1193 e.setLocation( value ); 1193 e.setLocation( value );
1194 } 1194 }
1195 else if ( name == VCAudioContentProp ) { 1195 else if ( name == VCAudioContentProp ) {
1196 haveAlarm = TRUE; 1196 haveAlarm = TRUE;
1197 VObjectIterator nit; 1197 VObjectIterator nit;
1198 initPropIterator( &nit, o ); 1198 initPropIterator( &nit, o );
1199 while( moreIteration( &nit ) ) { 1199 while( moreIteration( &nit ) ) {
1200 VObject *o = nextVObject( &nit ); 1200 VObject *o = nextVObject( &nit );
1201 QCString name = vObjectName( o ); 1201 QCString name = vObjectName( o );
1202 QCString value = vObjectStringZValue( o ); 1202 QCString value = vObjectStringZValue( o );
1203 if ( name == VCRunTimeProp ) 1203 if ( name == VCRunTimeProp )
1204 alarmTime = TimeConversion::fromISO8601( value ); 1204 alarmTime = TimeConversion::fromISO8601( value );
1205 else if ( name == VCAudioContentProp ) { 1205 else if ( name == VCAudioContentProp ) {
1206 if ( value == "silent" ) 1206 if ( value == "silent" )
1207 soundType = Event::Silent; 1207 soundType = Event::Silent;
1208 else 1208 else
1209 soundType = Event::Loud; 1209 soundType = Event::Loud;
1210 } 1210 }
1211 } 1211 }
1212 } 1212 }
1213 else if ( name == "X-Qtopia-TIMEZONE") { 1213 else if ( name == "X-Qtopia-TIMEZONE") {
1214 e.setTimeZone( value ); 1214 e.setTimeZone( value );
1215 } 1215 }
1216 else if ( name == "X-Qtopia-AllDay" ) { 1216 else if ( name == "X-Qtopia-AllDay" ) {
1217 e.setType( Event::AllDay ); 1217 e.setType( Event::AllDay );
1218 } 1218 }
1219#if 0 1219#if 0
1220 else { 1220 else {
1221 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1221 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1222 VObjectIterator nit; 1222 VObjectIterator nit;
1223 initPropIterator( &nit, o ); 1223 initPropIterator( &nit, o );
1224 while( moreIteration( &nit ) ) { 1224 while( moreIteration( &nit ) ) {
1225 VObject *o = nextVObject( &nit ); 1225 VObject *o = nextVObject( &nit );
1226 QCString name = vObjectName( o ); 1226 QCString name = vObjectName( o );
1227 QString value = vObjectStringZValue( o ); 1227 QString value = vObjectStringZValue( o );
1228 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1228 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1229 } 1229 }
1230 } 1230 }
1231#endif 1231#endif
1232 } 1232 }
1233 1233
1234 if ( !haveStart && !haveEnd ) 1234 if ( !haveStart && !haveEnd )
1235 e.setStart( QDateTime::currentDateTime() ); 1235 e.setStart( QDateTime::currentDateTime() );
1236 1236
1237 if ( !haveEnd ) { 1237 if ( !haveEnd ) {
1238 e.setType( Event::AllDay ); 1238 e.setType( Event::AllDay );
1239 e.setEnd( e.start() ); 1239 e.setEnd( e.start() );
1240 } 1240 }
1241 1241
1242 if ( haveAlarm ) { 1242 if ( haveAlarm ) {
1243 int minutes = alarmTime.secsTo( e.start() ) / 60; 1243 int minutes = alarmTime.secsTo( e.start() ) / 60;
1244 e.setAlarm( TRUE, minutes, soundType ); 1244 e.setAlarm( TRUE, minutes, soundType );
1245 } 1245 }
1246 return e; 1246 return e;
1247} 1247}
1248 1248