PushHandler.cpp Example File
pushCollector/10.0/pushCollector/src/service/PushHandler.cpp
#include "PushHandler.hpp"
#include <QDebug>
PushHandler::PushHandler()
{
}
PushHandler::~PushHandler()
{
}
bool PushHandler::checkForDuplicate(const PushHistoryItem &pushHistoryItem)
{
if (pushHistoryItem.itemId().isEmpty()) {
return false;
}
if (!m_pushHistoryDAO.createPushHistoryTable()) {
return false;
}
const PushHistoryItem storedPushHistoryItem = m_pushHistoryDAO.pushHistoryItem(pushHistoryItem.itemId());
if (storedPushHistoryItem.seqNum() > -1) {
return true;
}
if (!m_pushHistoryDAO.add(pushHistoryItem)) {
return false;
}
if (m_pushHistoryDAO.pushHistoryCount() > 10) {
m_pushHistoryDAO.removeOldest();
}
return false;
}
int PushHandler::save(const Push &push)
{
if (!m_pushDAO.createPushTable()) {
return -1;
}
return m_pushDAO.add(push);
}
Push PushHandler::push(int pushSeqNum)
{
return m_pushDAO.push(pushSeqNum);
}
QVariantList PushHandler::pushes()
{
return m_pushDAO.pushes();
}
bool PushHandler::remove(int pushSeqNum)
{
return m_pushDAO.remove(pushSeqNum);
}
bool PushHandler::removeAll()
{
return m_pushDAO.removeAll();
}
bool PushHandler::removeAllPushHistory()
{
return m_pushHistoryDAO.removeAll();
}
bool PushHandler::markAsRead(int pushSeqNum)
{
return m_pushDAO.markAsRead(pushSeqNum);
}
bool PushHandler::markAllAsRead()
{
return m_pushDAO.markAllAsRead();
}