mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-10-22 22:53:24 +00:00
66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#include "refreshservice.h"
|
|
|
|
#include <QGuiApplication>
|
|
|
|
RefreshService *RefreshService::svc = nullptr;
|
|
|
|
|
|
void RefreshService::startService()
|
|
{
|
|
if(svc != nullptr)
|
|
return;
|
|
|
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
svc = new RefreshService();
|
|
}
|
|
|
|
void RefreshService::stopService()
|
|
{
|
|
if(svc != nullptr)
|
|
svc->deleteLater();
|
|
|
|
QGuiApplication::setQuitOnLastWindowClosed(true);
|
|
|
|
svc = nullptr;
|
|
}
|
|
|
|
void RefreshService::connectedToWebSocket()
|
|
{
|
|
mNotifsHelper.getNewNotificationsNumbers();
|
|
}
|
|
|
|
void RefreshService::onNewNumberNotifications(NotificationsNumber numbers)
|
|
{
|
|
mNumbers = numbers;
|
|
|
|
mTrayIcon.onNewNumber(numbers);
|
|
}
|
|
|
|
void RefreshService::onNewNeumberUnreadNotifs(int num)
|
|
{
|
|
mNumbers.setNewNotifs(num);
|
|
mTrayIcon.onNewNumber(mNumbers);
|
|
}
|
|
|
|
void RefreshService::onNewNeumberUnreadConvs(int num)
|
|
{
|
|
mNumbers.setUnreadConversations(num);
|
|
mTrayIcon.onNewNumber(mNumbers);
|
|
}
|
|
|
|
RefreshService::RefreshService()
|
|
{
|
|
qDebug("Start refresh service");
|
|
|
|
connect(&mWsClient, &WsClient::connected, this, &RefreshService::connectedToWebSocket);
|
|
connect(&mNotifsHelper, &NotificationsHelper::onNewNumber, this, &RefreshService::onNewNumberNotifications);
|
|
connect(&mWsClient, &WsClient::newNumberNotifs, this, &RefreshService::onNewNeumberUnreadNotifs);
|
|
connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs);
|
|
}
|
|
|
|
RefreshService::~RefreshService()
|
|
{
|
|
qDebug("Stop refresh service");
|
|
}
|