Background sync changes

This commit is contained in:
LubuWest 2024-04-22 22:01:01 +02:00
commit b59513ab91
13 changed files with 122 additions and 89 deletions

View file

@ -52,6 +52,39 @@ void ALARM::setAlarm(int interval)
int intDisable = processDisable.execute("systemctl", QStringList() <<"--user"<<"disable"<<"--now"<<"friendiqa-sync.timer");
qDebug() << " intEnable "<<intDisable;
}else{
QString path = QDir::homePath() + "/.config/systemd/user/";
QDir dir(path);
if(!dir.exists()) {
dir.mkpath(path);
}
QString nameService ="friendiqa-sync.service";
QFile fileService(path+nameService);
fileService.remove();
if (fileService.open(QIODevice::ReadWrite)) {
QTextStream stream(&fileService);
stream << "[Unit]" << Qt::endl;
stream << "Description=Run friendiqa background sync" << Qt::endl << Qt::endl;
stream << "[Service]" << Qt::endl;
stream << "Type=oneshot" << Qt::endl;
stream << "ExecStart=/usr/bin/friendiqa -service" << Qt::endl;
}
QString nameTimer ="friendiqa-sync.timer";
QFile fileTimer(path+nameTimer);
fileTimer.remove();
if (fileTimer.open(QIODevice::ReadWrite)) {
QTextStream stream(&fileTimer);
stream << "[Unit]" << Qt::endl;
stream << "Description=Run background sync for Friendiqa periodically" << Qt::endl << Qt::endl;
stream << "[Timer]" << Qt::endl;
stream << "Unit=friendiqa-sync.service" << Qt::endl;
stream << "OnBootSec=10min" << Qt::endl;
stream << "OnUnitActiveSec=15min" << Qt::endl << Qt::endl;
stream << "[Install]" << Qt::endl;
stream << "WantedBy=timers.target" << Qt::endl;
}
QProcess processReload;
int intReload = processReload.execute("systemctl", QStringList()<<"--user"<<"daemon-reload");
QProcess processEnable;