static void update_unread (ChatWindow* self) { guint unread_count = 0; GtkWidget* page = NULL; GtkWidget* hbox = NULL; GtkWidget* label = NULL; gchar *info = NULL; for (gint ii = 0; ii < gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook)) ; ii++) { page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), ii); hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (self->priv->notebook), page); label = (GtkWidget*)g_object_get_data (G_OBJECT (hbox), "label-widget"); unread_count = unread_count + GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (label), "unread-count")); } g_signal_emit (self, signals[UNREAD_COUNT], 0, unread_count); if (unread_count > 0) { info = g_strdup_printf (ngettext ("You have %d unread text message", "You have %d unread text messages", unread_count), unread_count); boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Warning, info, "", _("Read"), boost::bind (show_chat_window_cb, self))); self->priv->notification_core->push_notification (notif); g_free (info); } }
DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoInit() { switch(m_state) { case StNotStarted: return StNotStarted; case StRunning: // FIXME: assumes it goes first through idle state. Could we get back to init from running directly? return StRunning; case StReady: return StReady; case StIdle: case StError: break; } if (m_deviceSampleSink == 0) { return gotoError("DSPDeviceSinkEngine::gotoInit: No sample source configured"); } // init: pass sample rate and center frequency to all sample rate and/or center frequency dependent sinks and wait for completion m_deviceDescription = m_deviceSampleSink->getDeviceDescription(); m_centerFrequency = m_deviceSampleSink->getCenterFrequency(); m_sampleRate = m_deviceSampleSink->getSampleRate(); qDebug() << "DSPDeviceSinkEngine::gotoInit: " << " m_deviceDescription: " << m_deviceDescription.toStdString().c_str() << " sampleRate: " << m_sampleRate << " centerFrequency: " << m_centerFrequency; DSPSignalNotification notif(m_sampleRate, m_centerFrequency); for (BasebandSampleSources::const_iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it) { qDebug() << "DSPDeviceSinkEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str(); (*it)->handleMessage(notif); } for (ThreadedBasebandSampleSources::const_iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it) { qDebug() << "DSPDeviceSinkEngine::gotoInit: initializing ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() << ")"; (*it)->handleSourceMessage(notif); } if (m_spectrumSink) { m_spectrumSink->handleMessage(notif); } // pass data to listeners if (m_deviceSampleSink->getMessageQueueToGUI()) { DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy for the output queue m_deviceSampleSink->getMessageQueueToGUI()->push(rep); } return StReady; }
void AsynchronousTrigger::addVariable(shared_ptr<Variable> var){ if(var == NULL){ mwarning(M_PARADIGM_MESSAGE_DOMAIN, "Attempt to add a notification to a null variable"); return; } shared_ptr<AsynchronousTriggerNotification> notif( new AsynchronousTriggerNotification(this)); var->addNotification(notif); notifications->addReference(notif); }
bool NE500PumpNetworkDevice::initialize() { mprintf(M_IODEVICE_MESSAGE_DOMAIN, "Connecting to NE500 Pump Network..."); if (!connection->connect()) { return false; } const auto sendFunc = getSendFunction(); for (auto &channel : pumps) { if (!channel->initialize(sendFunc)) { return false; } shared_ptr<Variable> var = channel->getVariable(); shared_ptr<NE500PumpNetworkDevice> shared_self_ref(component_shared_from_this<NE500PumpNetworkDevice>()); shared_ptr<VariableNotification> notif(new NE500DeviceOutputNotification(shared_self_ref, channel)); var->addNotification(notif); } return true; }
void NotificationManager::notify(const char *tag, int id, const char *title, const char *text) { std::shared_ptr<AttachedJENV> jenv(new AttachedJENV()); if (!jenv->attached()) { LOG(ANDROID_LOG_ERROR, "Unable to get VM"); return; } if (!initializeStatics(jenv)) { LOG(ANDROID_LOG_ERROR, "Unable to init internal objects"); return; } std::shared_ptr<JavaObject> nb = jenv->createJO(notificationBuilder_->get(), &JavaObjects::NotificationBuilder_Desc); nb->call("setAutoCancel", (jboolean)JNI_TRUE); nb->call("setContentTitle", jenv->env()->NewStringUTF(title)); nb->call("setContentText", jenv->env()->NewStringUTF(text)); nb->call("setSmallIcon", getIconIndex(jenv)); jvalue notification = nb->call("getNotification"); if (notification.l) { std::shared_ptr<JavaLocalRef<jobject> > notif(jenv->createRef(notification.l)); std::shared_ptr<JavaObject> nm = jenv->createJO(notificationManager_->get(), &JavaObjects::NotificationManager_Desc); nm->call("notify_0", jenv->env()->NewStringUTF(tag), id, notif->get()); LOG(ANDROID_LOG_INFO, "Notification created succesfully"); } else { LOG(ANDROID_LOG_ERROR, "Unable to create Notification object"); } }
void DSPDeviceSinkEngine::handleSynchronousMessages() { Message *message = m_syncMessenger.getMessage(); qDebug() << "DSPDeviceSinkEngine::handleSynchronousMessages: " << message->getIdentifier(); if (DSPGenerationInit::match(*message)) { m_state = gotoIdle(); if(m_state == StIdle) { m_state = gotoInit(); // State goes ready if init is performed } } else if (DSPGenerationStart::match(*message)) { if(m_state == StReady) { m_state = gotoRunning(); } } else if (DSPGenerationStop::match(*message)) { m_state = gotoIdle(); } else if (DSPGetSinkDeviceDescription::match(*message)) { ((DSPGetSinkDeviceDescription*) message)->setDeviceDescription(m_deviceDescription); } else if (DSPGetErrorMessage::match(*message)) { ((DSPGetErrorMessage*) message)->setErrorMessage(m_errorMessage); } else if (DSPSetSink::match(*message)) { handleSetSink(((DSPSetSink*) message)->getSampleSink()); } else if (DSPAddSpectrumSink::match(*message)) { m_spectrumSink = ((DSPAddSpectrumSink*) message)->getSampleSink(); } else if (DSPRemoveSpectrumSink::match(*message)) { BasebandSampleSink* spectrumSink = ((DSPRemoveSpectrumSink*) message)->getSampleSink(); if(m_state == StRunning) { spectrumSink->stop(); } m_spectrumSink = 0; } else if (DSPAddBasebandSampleSource::match(*message)) { BasebandSampleSource* source = ((DSPAddBasebandSampleSource*) message)->getSampleSource(); m_basebandSampleSources.push_back(source); DSPSignalNotification notif(m_sampleRate, m_centerFrequency); source->handleMessage(notif); checkNumberOfBasebandSources(); if (m_state == StRunning) { source->start(); } } else if (DSPRemoveBasebandSampleSource::match(*message)) { BasebandSampleSource* source = ((DSPRemoveBasebandSampleSource*) message)->getSampleSource(); if(m_state == StRunning) { source->stop(); } m_basebandSampleSources.remove(source); checkNumberOfBasebandSources(); } else if (DSPAddThreadedBasebandSampleSource::match(*message)) { ThreadedBasebandSampleSource *threadedSource = ((DSPAddThreadedBasebandSampleSource*) message)->getThreadedSampleSource(); m_threadedBasebandSampleSources.push_back(threadedSource); DSPSignalNotification notif(m_sampleRate, m_centerFrequency); threadedSource->handleSourceMessage(notif); checkNumberOfBasebandSources(); if (m_state == StRunning) { threadedSource->start(); } } else if (DSPRemoveThreadedBasebandSampleSource::match(*message)) { ThreadedBasebandSampleSource* threadedSource = ((DSPRemoveThreadedBasebandSampleSource*) message)->getThreadedSampleSource(); if (m_state == StRunning) { threadedSource->stop(); } m_threadedBasebandSampleSources.remove(threadedSource); checkNumberOfBasebandSources(); } m_syncMessenger.done(m_state); }