void NotificationManager::syncNotifications()
{
    QList<PersonalNotification*> pnList;
    QMap<int,int> typeCounts;
    QList<QObject*> notifications = Notification::notifications();

    foreach (QObject *o, notifications) {
        Notification *n = static_cast<Notification*>(o);

        if (n->previewBody().isEmpty() && !n->body().isEmpty() && n->hintValue("x-commhistoryd-data").isNull()) {
            NotificationGroup *group = new NotificationGroup(n, this);
            if (m_Groups.contains(group->type())) {
                group->removeGroup();
                delete group;
                continue;
            }

            m_Groups.insert(group->type(), group);
        } else {
            PersonalNotification *pn = new PersonalNotification(this);
            if (!pn->restore(n)) {
                delete pn;
                n->close();
                delete n;
                continue;
            }

            typeCounts[pn->eventType()]++;
            pnList.append(pn);
        }
    }
Example #2
0
bool
NotificationManager::replaceActive(Notification* notification)
{
    ILOG_TRACE_F(ILX_NOTIFICATIONMAN);
    if (notification->tag().empty())
        return false;
    pthread_mutex_lock(&_activeMutex);
    NotificationList::iterator it = _active.begin();
    while (it != _active.end())
    {
        Notification* old = ((Notification*) *it);
        if (old->tag() == notification->tag())
        {
            it = _active.erase(it);
            _active.insert(it, notification);
            notification->setGeometry(old->surfaceGeometry());
            old->close();
            _compositor->removeWidget(old);
            notification->show();
            pthread_mutex_unlock(&_activeMutex);
            return true;
        }
        ++it;
    }
    pthread_mutex_unlock(&_activeMutex);
    return false;
}