Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 69dc1fb6 authored by Laurent Montel's avatar Laurent Montel 😁

Fix send recurent mail

parent 7393c3d5
......@@ -39,30 +39,38 @@ bool SendLater::SendLaterUtil::compareSendLaterInfo(SendLater::SendLaterInfo *le
void SendLater::SendLaterUtil::changeRecurrentDate(SendLater::SendLaterInfo *info)
{
if (info && info->isRecurrence()) {
//qDebug()<<" SendLater::SendLaterUtil::changeRecurrentDate "<<info->dateTime().toString();
qDebug()<<"BEFORE SendLater::SendLaterUtil::changeRecurrentDate "<<info->dateTime().toString();
QDateTime newInfoDateTime = info->dateTime();
while (newInfoDateTime < QDateTime::currentDateTime()) {
switch(info->recurrenceUnit()) {
case SendLater::SendLaterInfo::Days:
newInfoDateTime = newInfoDateTime.addDays(info->recurrenceEachValue());
break;
case SendLater::SendLaterInfo::Weeks:
newInfoDateTime = newInfoDateTime.addDays(info->recurrenceEachValue()*7);
break;
case SendLater::SendLaterInfo::Months:
newInfoDateTime = newInfoDateTime.addMonths(info->recurrenceEachValue());
break;
case SendLater::SendLaterInfo::Years:
newInfoDateTime = newInfoDateTime.addYears(info->recurrenceEachValue());
break;
}
newInfoDateTime = updateRecurence(info, newInfoDateTime);
qDebug()<<" QDateTime::currentDateTime()"<<QDateTime::currentDateTime().toString();
while (newInfoDateTime <= QDateTime::currentDateTime()) {
newInfoDateTime = updateRecurence(info, newInfoDateTime);
}
info->setDateTime(newInfoDateTime);
qDebug()<<"AFTER SendLater::SendLaterUtil::changeRecurrentDate "<<info->dateTime().toString()<<" info"<<info;
qDebug()<<"AFTER SendLater::SendLaterUtil::changeRecurrentDate "<<info->dateTime().toString()<<" info"<<info << "New date"<<newInfoDateTime;
writeSendLaterInfo(defaultConfig(), info, true);
}
}
QDateTime SendLater::SendLaterUtil::updateRecurence(SendLater::SendLaterInfo *info, QDateTime dateTime)
{
switch(info->recurrenceUnit()) {
case SendLater::SendLaterInfo::Days:
dateTime = dateTime.addDays(info->recurrenceEachValue());
break;
case SendLater::SendLaterInfo::Weeks:
dateTime = dateTime.addDays(info->recurrenceEachValue()*7);
break;
case SendLater::SendLaterInfo::Months:
dateTime = dateTime.addMonths(info->recurrenceEachValue());
break;
case SendLater::SendLaterInfo::Years:
dateTime = dateTime.addYears(info->recurrenceEachValue());
break;
}
return dateTime;
}
KSharedConfig::Ptr SendLater::SendLaterUtil::defaultConfig()
{
return KSharedConfig::openConfig( QLatin1String("akonadi_sendlater_agentrc") );
......
......@@ -40,6 +40,7 @@ namespace SendLaterUtil
SENDLATER_EXPORT void changeRecurrentDate(SendLater::SendLaterInfo *info);
SENDLATER_EXPORT void forceReparseConfiguration();
QDateTime updateRecurence(SendLater::SendLaterInfo *info, QDateTime dateTime);
static QString sendLaterPattern = QLatin1String("SendLaterItem %1");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment