Example #1
0
//-----------------------------------------------------------------------------
// <ValueStore::RemoveValue>
// Remove a value from the store
//-----------------------------------------------------------------------------
bool ValueStore::RemoveValue
(
	uint32 const& _key
)
{
	map<uint32,Value*>::iterator it = m_values.find( _key );
	if( it != m_values.end() )
	{
		Value* value = it->second;
		ValueID const& valueId = value->GetID();

		// First notify the watchers
		if( Driver* driver = Manager::Get()->GetDriver( valueId.GetHomeId() ) )
		{
			Notification* notification = new Notification( Notification::Type_ValueRemoved );
			notification->SetValueId( valueId );
			driver->QueueNotification( notification ); 
		}

		// Now release and remove the value from the store
		value->Release();
		m_values.erase( it );

		return true;
	}

	// Value not found in the store
	return false;
}
Example #2
0
//-----------------------------------------------------------------------------
// <Basic::HandleMsg>
// Handle a message from the Z-Wave network
//-----------------------------------------------------------------------------
bool Basic::HandleMsg
(
	uint8 const* _data,
	uint32 const _length,
	uint32 const _instance	// = 1
)
{
	if( BasicCmd_Report == (BasicCmd)_data[0] )
	{
		// Level
		Log::Write( LogLevel_Info, GetNodeId(), "Received Basic report from node %d: level=%d", GetNodeId(), _data[1] );
		if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
		{
			value->OnValueRefreshed( _data[1] );
			value->Release();
		}
		return true;
	}

	if( BasicCmd_Set == (BasicCmd)_data[0] )
	{
		// Commmand received from the node.  Handle as a notification event
		Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d.  Sending event notification.", GetNodeId(), _data[1] );

		Notification* notification = new Notification( Notification::Type_NodeEvent );
		notification->SetHomeNodeIdAndInstance( GetHomeId(), GetNodeId(), _instance );
		notification->SetEvent( _data[1] );
		GetDriver()->QueueNotification( notification );
		return true;
	}

	return false;
}
Example #3
0
//-----------------------------------------------------------------------------
// <ValueStore::AddValue>
// Add a value to the store
//-----------------------------------------------------------------------------
bool ValueStore::AddValue
(
	Value* _value
)
{
	if( !_value )
	{
		return false;
	}

	uint32 key = _value->GetID().GetValueStoreKey();
	map<uint32,Value*>::iterator it = m_values.find( key );
	if( it != m_values.end() )
	{
		// There is already a value in the store with this key, so we give up.
		return false;
	}

	m_values[key] = _value;
	_value->AddRef();

	// Notify the watchers of the new value
	if( Driver* driver = Manager::Get()->GetDriver( _value->GetID().GetHomeId() ) )
	{
		Notification* notification = new Notification( Notification::Type_ValueAdded );
		notification->SetValueId( _value->GetID() );
		driver->QueueNotification( notification );
	}

	return true;
}
void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification notification)
{
    if (notification.type() != Notification::FunctionType)
        LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - notification %s", this, notificationName(notification));

    m_queueMutex.lock();

    // It is important to always process the properties in the order that we are notified,
    // so always go through the queue because notifications happen on different threads.
    m_queuedNotifications.append(notification);

#if OS(WINDOWS)
    bool delayDispatch = true;
#else
    bool delayDispatch = m_delayCallbacks || !isMainThread();
#endif
    if (delayDispatch && !m_mainThreadCallPending) {
        m_mainThreadCallPending = true;
        callOnMainThread(mainThreadCallback, this);
    }

    m_queueMutex.unlock();

    if (delayDispatch) {
        if (notification.type() != Notification::FunctionType)
            LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - early return", this);
        return;
    }

    dispatchNotification();
}
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 #6
0
GrowlBackend::GrowlBackend()
{
    s_instance = this;

    auto func = [](growl_callback_data * data)->void {
        snoreDebug(SNORE_DEBUG) << data->id << QString::fromUtf8(data->reason) << QString::fromUtf8(data->data);
        Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id);
        if (!n.isValid())
        {
            return;
        }
        Notification::CloseReasons r = Notification::NONE;
        std::string reason(data->reason);
        if (reason == "TIMEDOUT")
        {
            r = Notification::TIMED_OUT;
        } else if (reason == "CLOSED")
        {
            r = Notification::DISMISSED;
        } else if (reason == "CLICK")
        {
            r = Notification::ACTIVATED;
            s_instance->slotNotificationActionInvoked(n);
        }
        s_instance->closeNotification(n, r);
    };
    Growl::init((GROWL_CALLBACK)static_cast<void(*)(growl_callback_data *)>(func));
}
Example #7
0
void Bb10Ui::onFullscreen()
{
    qDebug() << "xxxxx Bb10Ui::onFullscreen";
    m_appState = FullScreen;
    Notification* pNotification = new Notification();
    pNotification->clearEffects();
}
Example #8
0
//-----------------------------------------------------------------------------
// <ValueStore::RemoveCommandClassValues>
// Remove all the values associated with a command class from the store
//-----------------------------------------------------------------------------
void ValueStore::RemoveCommandClassValues
(
	uint8 const _commandClassId
)
{
	map<uint32,Value*>::iterator it = m_values.begin();
	while( it != m_values.end() )
	{
		Value* value = it->second;
		ValueID const& valueId = value->GetID();
		if( _commandClassId == valueId.GetCommandClassId() )
		{
			// The value belongs to the specified command class
			
			// First notify the watchers
			if( Driver* driver = Manager::Get()->GetDriver( valueId.GetHomeId() ) )
			{
				Notification* notification = new Notification( Notification::Type_ValueRemoved );
				notification->SetValueId( valueId );
				driver->QueueNotification( notification ); 
			}

			// Now release and remove the value from the store
			value->Release();
			m_values.erase( it++ );
		}
		else
		{
			++it;
		}
	}
}
void NotificationLayout::removeNotification(uint key, uint reason)
{
    Notification *n = m_notifications.take(key);
    if (!n)
    {
        qDebug() << "Oooook! Expecting instance of notification, got:" << key;
        return;
    }

    int ix = m_layout->indexOf(n);
    if (ix == -1)
    {
        qDebug() << "Qooook! Widget not in layout. Impossible!" << n;
        return;
    }

    delete m_layout->takeAt(ix);
    n->deleteLater();
    emit notificationClosed(key, reason);

    if (m_notifications.count() == 0)
        emit allNotificationsClosed();

    checkHeight();
}
Example #10
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;
}
void Ut_WidgetNotificationSink::testUpdateActions()
{
    // Create notification parameters
    Notification notification;
    TestNotificationParameters parameters;
    parameters.add(NotificationWidgetParameterFactory::createActionParameter("content0 0 0 0"));
    notification.setParameters(parameters);

    // Create an info banner with one action
    MBanner infoBanner;
    QAction *action = new QAction(&infoBanner);
    infoBanner.addAction(action);

    // There shouldn't be any MRemoteActions at this point but the action should be added
    QCOMPARE(contents.count(), 0);
    QCOMPARE(actions.count(), 1);
    QCOMPARE(actions[&infoBanner].at(0), action);

    // Update the actions
    m_subject->updateActions(&infoBanner, notification);

    // There should be a MRemoteAction at this point
    QCOMPARE(contents.count(), 1);
    QCOMPARE(contents[0], QString("content0 0 0 0"));
    QCOMPARE(actions.count(), 1);
    QVERIFY(dynamic_cast<MRemoteAction *>(actions[&infoBanner].at(0)) != NULL);
    QCOMPARE(dynamic_cast<MRemoteAction *>(actions[&infoBanner].at(0))->toString(), QString("content0 0 0 0"));
}
const QString NotificationWrapper::title() const
{
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this);
    if (notification)
        return notification->title();
#endif
    return QString();
}
const QUrl NotificationWrapper::iconUrl() const
{
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this);
    if (notification)
        return notification->iconURL();
#endif
    return QUrl();
}
Notification* Notification::create(ExecutionContext* context, int64_t persistentId, const WebNotificationData& data)
{
    Notification* notification = new Notification(context, data);
    notification->setPersistentId(persistentId);
    notification->setState(NotificationStateShowing);
    notification->suspendIfNeeded();

    return notification;
}
const QString NotificationWrapper::message() const
{
#if ENABLE(NOTIFICATIONS)
    Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this);
    if (notification)
        return notification->contents().body();
#endif
    return QString();
}
void OptionsDialog::showNotification(QVBoxLayout *layout, int position, const QString &text, bool canClose)
{
    Notification* n = new Notification(this);
    n->setText(text);
    n->setClosable(canClose);

    layout->insertWidget(position, n);
    n->show();
}
void NotifierNotificationSink::addNotification(const Notification &notification)
{
    if (!additionsDisabled && notification.type() == Notification::ApplicationEvent && isUnseen(notification)) {
        applicationEventIds.insert(notification.notificationId());
        if(applicationEventIds.count() == 1) {
            setNotifierEnabled(true);
        }
    }
}
Example #18
0
bool dockClickHandler(id self,SEL _cmd,...)
{
    Q_UNUSED(self)
    Q_UNUSED(_cmd)
    Notification *N = Notification::getInstance();
    if (N)
        N->slotShowHide();
    return true;
}
Example #19
0
wxColour
NotificationProperty::getBackgroundColor(AnListClass *obj) const
{
    Notification *notify = dynamic_cast<Notification *>(obj);

    if ((notify != 0) && notify->isAdmin())
        return wxTheColourDatabase->Find(wxT("LIGHT GREY"));
    else
        return (wxNullColour);
}
void HTTPClientConnection::send(Request* request, Response** response) {
  Notification* n = new Notification;
  ResponseCallback* cb = makeCallableOnce(&HTTPClientConnection::receiveInternal,
                                          this,
                                          n,
                                          response);
  asyncSend(request, cb);
  n->wait();
  delete n;
}
Example #21
0
void Application::showUpdateDetails()
{
	Notification *notification = dynamic_cast<Notification*>(sender());

	if (notification)
	{
		UpdateCheckerDialog *dialog = new UpdateCheckerDialog(NULL, notification->getData().value<QList<UpdateInformation> >());
		dialog->show();
	}
}
Example #22
0
	QString NotificationView::ClipboardText(const Notification & n) const
	{
		auto title = n.Title();
		auto text = n.PlainText();
		auto timestamp = locale().toString(n.Timestamp(), QLocale::ShortFormat);

		return title % "  " % timestamp
		     % QStringLiteral("\n")
		     % text;
	}
Example #23
0
void NotifyWidget::display(const Notification &notification)
{
    qCDebug(SNORE) << m_id << notification.id() << m_window->isVisible();
    m_notification = notification;
    QColor color;
    QVariant vcolor = notification.application().constHints().privateValue(parent(), "backgroundColor");
    if (vcolor.isValid()) {
        color = vcolor.value<QColor>();
    } else {
        color = computeBackgrondColor(notification.application().icon().pixmap(QSize(20, 20)).toImage());
        notification.application().hints().setPrivateValue(parent(), "backgroundColor", color);
    }
    m_appIcon = QUrl::fromLocalFile(notification.application().icon().localUrl(QSize(m_appIconSize, m_appIconSize)));
    emit appIconChanged();

    m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize)));
    emit imageChanged();

    m_title = notification.title(Utils::AllMarkup);
    emit titleChanged();
    m_body = notification.text(Utils::AllMarkup);
    emit bodyChanged();

    if (!notification.isUpdate()) {
        syncSettings();
        m_color = color;
        m_textColor = compueTextColor(color);
        emit colorChanged();
        emit textColorChanged();
        m_window->show();
        Utils::raiseWindowToFront(m_window);
    }
}
Example #24
0
void MainWindow::handleAddContactRequest(Packet &pkt)
{
    quint32 reqId;
    QString name;
    QString email;
    pkt >> reqId >> name >> email;

    Notification* notif = new Notification(_contactForm->getNotificationWidget(), NOTIF_CONTACT_REQUEST, "New contact request from " + name + " (" + email + ")", reqId);
    notif->setTextInfo(name + " (" + email + ")");
    _contactForm->addNotification(notif);
}
void KVService::connect(const string& host,
                        int port,
			KVClientConnection** conn) {
  Notification n;
  KVConnectCallback* cb = makeCallableOnce(&KVService::connectInternal,
                                            this,
					    &n,
					    conn);
  asyncConnect(host, port, cb);
  n.wait();
}
void LEDNotificationSink::addNotification(const Notification &notification)
{
    if (canAddNotification(notification) && !notificationsId.contains(notification.notificationId())) {
        if (checkIfAcceptable(notification.parameters())) {
            notificationsId.append(notification.notificationId());

            if (notificationsId.size() == 1)
                setNotifierEnabled(true);
        }
    }    
}
void
ClientMessageHandleJob::handleQueryError(RescheduleCallback& cb,
                                         Notification<scidb::Exception>::MessageTypePtr errPtr)
{
    assert(!dynamic_cast<const scidb::ClientMessageHandleJob::CancelChunkFetchException*>(errPtr.get()));
    assert(cb);
    if (errPtr->getQueryId() != _query->getQueryID()) {
        return;
    }
    cb(errPtr.get());
}
const QByteArray NotificationWrapper::iconData() const
{
    QByteArray iconData;
#if ENABLE(NOTIFICATIONS)
    Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this);
    if (notification) {
        if (notification->iconData())
            iconData = QByteArray::fromRawData(notification->iconData()->data(), notification->iconData()->size());
    }
#endif
    return iconData;
}
const QUrl NotificationWrapper::openerPageUrl() const
{
    QUrl url;
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this);
    if (notification) {
        if (notification->scriptExecutionContext()) 
            url = static_cast<Document*>(notification->scriptExecutionContext())->page()->mainFrame()->document()->url();
    }
#endif
    return url;
}
bool NotificationAction::execute(Rule *rule)
{
    Q_D(NotificationAction);
    Q_UNUSED(rule);

    Notification *notification = new Notification(this);
    notification->setTimestamp(QDateTime::currentDateTime());
    notification->setSummary(d->summary);
    notification->publish();
    notification->deleteLater();
    return true;
}