void EventPlugin::onDbEvent(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload) { qfLogFuncFrame() << "name:" << name << "source:" << source << "payload:" << payload; if(name == QLatin1String(DBEVENT_NOTIFY_NAME)) { if(source == QSqlDriver::OtherSource) { QJsonDocument jsd = QJsonDocument::fromJson(payload.toString().toUtf8()); QVariantMap m = jsd.toVariant().toMap(); QString domain = m.value(QStringLiteral("domain")).toString(); if(domain.isEmpty()) { qfWarning() << "DbNotify with invalid domain, payload:" << payload.toString(); return; } QString event_name = m.value(QStringLiteral("event")).toString(); if(event_name.isEmpty()) { qfWarning() << "DbNotify with invalid event name, payload:" << payload.toString(); return; } if(event_name == eventName()) { QVariant pl = m.value(QStringLiteral("payload")); qfDebug() << "emitting domain:" << domain << "payload:" << pl; emit dbEventNotify(domain, pl); } } else { //qfDebug() << "self db notify"; } } }
void EventPlugin::loadCurrentStageId() { int stage_id = 0; if(!eventName().isEmpty()) stage_id = eventConfig()->currentStageId(); setCurrentStageId(stage_id); }
void EventPlugin::emitDbEvent(const QString &domain, const QVariant &payload, bool loopback) { qfLogFuncFrame() << "domain:" << domain << "payload:" << payload; if(loopback) { // emit queued //emit dbEventNotify(domain, payload); QMetaObject::invokeMethod(this, "dbEventNotify", Qt::QueuedConnection, Q_ARG(QString, domain), Q_ARG(QVariant, payload)); } if(connectionType() == ConnectionType::SingleFile) return; //QVariantMap m; QJsonObject jso; jso[QLatin1String("event")] = eventName(); jso[QLatin1String("domain")] = domain; jso[QLatin1String("payload")] = QJsonValue::fromVariant(payload); QJsonDocument jsd(jso); QString payload_str = QString::fromUtf8(jsd.toJson(QJsonDocument::Compact)); payload_str = qf::core::sql::Connection::escapeJsonForSql(payload_str); qf::core::sql::Connection conn = qf::core::sql::Connection::forName(); QString qs = QString("NOTIFY ") + DBEVENT_NOTIFY_NAME + ", '" + payload_str + "'"; qfDebug() << conn.driver() << "executing SQL:" << qs; QSqlQuery q(conn); if(!q.exec(qs)) { qfError() << "emitDbEventNotify Error:" << qs << q.lastError().text(); } }
QString sJarvisNodeComponent::signalName(jarvisEvents e) { QString result = ":"; result.append(eventName(e)); result.append("()"); return result; }
void operator()(CComVariant &aCookie) { ATLASSERT(aCookie.vt == VT_DISPATCH); CComBSTR eventName(L"cookies.onChanged"); service.invokeEventObjectInAllExtensionsWithIDispatchArgument(eventName, aCookie.pdispVal); ATLTRACE("NOTIFICATION "); }
bool EventPlugin::closeEvent() { qfLogFuncFrame(); m_classNameCache.clear(); setEventName(QString()); QF_SAFE_DELETE(m_eventConfig); emit eventOpened(eventName()); //comment it till QE can load event with invalid name return true; }
void dumpEvent (FILE *out, const EVENT *eventPtr) { fprintf (out, "%4u/%02u/%02u: %s\n", eventPtr->year_index, eventPtr->month_index, eventPtr->day_index, eventName (eventPtr->func_index)); }
UtlBoolean SipSubscribeServer::enableEventType(const char* eventTypeToken, SipUserAgent* userAgent, SipPublishContentMgr* contentMgr, SipSubscribeServerEventHandler* eventHandler, SipSubscriptionMgr* subscriptionMgr) { UtlBoolean addedEvent = FALSE; UtlString eventName(eventTypeToken ? eventTypeToken : ""); lockForWrite(); // Only add the event support if it does not already exist; SubscribeServerEventData* eventData = (SubscribeServerEventData*) mEventDefinitions.find(&eventName); if(!eventData) { addedEvent = TRUE; eventData = new SubscribeServerEventData(); *((UtlString*)eventData) = eventName; eventData->mpEventSpecificUserAgent = userAgent ? userAgent : mpDefaultUserAgent; eventData->mpEventSpecificContentMgr = contentMgr ? contentMgr : mpDefaultContentMgr; eventData->mpEventSpecificHandler = eventHandler ? eventHandler : mpDefaultEventHandler; eventData->mpEventSpecificSubscriptionMgr = subscriptionMgr ? subscriptionMgr : mpDefaultSubscriptionMgr; mEventDefinitions.insert(eventData); // Register an interest in SUBSCRIBE requests and NOTIFY responses // for this event type eventData->mpEventSpecificUserAgent->addMessageObserver(*(getMessageQueue()), SIP_SUBSCRIBE_METHOD, TRUE, // requests FALSE, // not reponses TRUE, // incoming FALSE, // no outgoing eventName, NULL, NULL); eventData->mpEventSpecificUserAgent->addMessageObserver(*(getMessageQueue()), SIP_NOTIFY_METHOD, FALSE, // no requests TRUE, // reponses TRUE, // incoming FALSE, // no outgoing eventName, NULL, NULL); // Register the callback for changes that occur in the // publish content manager eventData->mpEventSpecificContentMgr->setContentChangeObserver(eventName, this, contentChangeCallback); } unlockForWrite(); return(addedEvent); }
void KEventObject::_RemoveEventListener(const ValueList& args, KValueRef result) { args.VerifyException("removeEventListener", "s n|m"); std::string eventName(args.GetString(0)); if (args.at(1)->IsMethod()) { this->RemoveEventListener(eventName, args.GetMethod(1)); } else { this->RemoveEventListener(eventName, args.GetInt(1)); } }
// event checkBoxCheckedChanged(checkBoxName) bool OnCheckboxCheckStateChanged(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("checkBoxCheckedChanged"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pEvents->Call(eventName, &pArguments, pScript); return true; }
// event buttonClick(buttonName, bState) // TODO: remove it. We have better alternative guiClick (OnClick) for any gui element bool OnButtonClick(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("buttonClick"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pArguments.push(0); // FIXME or what? pEvents->Call(eventName, &pArguments, pScript); return true; }
// event guiMouseLeave(guiName) bool OnMouseLeaves(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("guiMouseLeave"); if(!pEvents->IsEventRegistered(eventName)) return false; const CEGUI::MouseEventArgs eArgs = static_cast<const CEGUI::MouseEventArgs&>(eventArgs); CEGUI::Window * pWindow = eArgs.window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pEvents->Call(eventName, &pArguments, pScript); return true; }
void EventPlugin::editEvent() { qfLogFuncFrame(); qff::MainWindow *fwk = qff::MainWindow::frameWork(); qfd::Dialog dlg(fwk); dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); EventDialogWidget *event_w = new EventDialogWidget(); event_w->setEventId(eventName()); event_w->setEventIdEditable(false); event_w->loadParams(eventConfig()->value("event").toMap()); dlg.setCentralWidget(event_w); if(!dlg.exec()) return; eventConfig()->setValue("event", event_w->saveParams()); eventConfig()->save("event"); }
UtlBoolean SipSubscribeServer::disableEventType(const char* eventTypeToken, SipUserAgent*& userAgent, SipPublishContentMgr*& contentMgr, SipSubscribeServerEventHandler*& eventHandler, SipSubscriptionMgr*& subscriptionMgr) { UtlBoolean removedEvent = FALSE; UtlString eventName(eventTypeToken ? eventTypeToken : ""); lockForWrite(); // Only add the event support if it does not already exist; SubscribeServerEventData* eventData = (SubscribeServerEventData*) mEventDefinitions.remove(&eventName); if(eventData) { removedEvent = TRUE; userAgent = eventData->mpEventSpecificUserAgent == mpDefaultUserAgent ? NULL : eventData->mpEventSpecificUserAgent; contentMgr = eventData->mpEventSpecificContentMgr == mpDefaultContentMgr ? NULL : eventData->mpEventSpecificContentMgr; eventHandler = eventData->mpEventSpecificHandler == mpDefaultEventHandler ? NULL : eventData->mpEventSpecificHandler; subscriptionMgr = eventData->mpEventSpecificSubscriptionMgr == mpDefaultSubscriptionMgr ? NULL : eventData->mpEventSpecificSubscriptionMgr; // Unregister interest in SUBSCRIBE requests and NOTIFY // responses for this event type eventData->mpEventSpecificUserAgent->removeMessageObserver(*(getMessageQueue())); delete eventData; eventData = NULL; } else { userAgent = NULL; contentMgr = NULL; eventHandler = NULL; subscriptionMgr = NULL; } unlockForWrite(); return(removedEvent); }
void KEventObject::_AddEventListener(const ValueList& args, KValueRef result) { unsigned int listenerId; if (args.size() > 1 && args.at(0)->IsString() && args.at(1)->IsMethod()) { std::string eventName(args.GetString(0)); listenerId = this->AddEventListener(eventName, args.GetMethod(1)); } else if (args.size() > 0 && args.at(0)->IsMethod()) { listenerId = this->AddEventListenerForAllEvents(args.GetMethod(0)); } else { throw ValueException::FromString("Incorrect arguments passed to addEventListener"); } result->SetDouble((double) listenerId); }
UtlBoolean SipPublishServer::disableEventType(const char* eventType) { UtlString eventName(eventType); lockForWrite(); PublishServerEventData* eventData = dynamic_cast <PublishServerEventData*> (mEventDefinitions.remove(&eventName)); if (eventData) { // Unregister interest in PUBLISH requests for this event type eventData->mpEventSpecificUserAgent->removeMessageObserver(*(getMessageQueue())); delete eventData; } unlockForWrite(); return eventData != NULL; }
// event guiKeyPress(string guiName, string key, string keyState) bool OnKeyPress(const CEGUI::KeyEventArgs &eArgs, String keyState) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("guiKeyPress"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = eArgs.window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CEGUI::Key::Scan keyCode = eArgs.scancode; CSquirrelArguments pArguments; pArguments.push(eArgs.window->getName().c_str()); pArguments.push(GetKeyNameByScan(eArgs.scancode)); pArguments.push(keyState); CSquirrelArgument pReturn = pEvents->Call(eventName, &pArguments, pScript); return pReturn.GetBool(); }
void Gear::updateState() { bool needChange = false; std::string eventName(""); if (event != stateMachine->action_undefined) { eventName = stateMachine->eventName[event]; } switch (state) { case ACTORSTATE::IDLE: if (canFindOpponent()) { if (waitTimeOut) { event = stateMachine->findEventVal("EVENT_CANATTACK"); needChange = true; } } break; case ACTORSTATE::ATTACK: if (armature->getAnimation()->isComplete()) { event = stateMachine->findEventVal("EVENT_ACTIONOVER"); needChange = true; } break; default: break; } if(event == stateMachine->action_undefined){ needChange = false; return; } if (needChange) { switch2NextState(state, event); needChange = false; event = StateMachine::action_undefined; } }
void xf86HandlePMEvents(int fd, void *data) { pmEvent events[MAX_NO_EVENTS]; int i, n; Bool wait = FALSE; if (!xf86PMGetEventFromOs) return; if ((n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS))) { do { for (i = 0; i < n; i++) { const char *str = NULL; int verb = eventName(events[i], &str); xf86MsgVerb(X_INFO, verb, "PM Event received: %s\n", str); DoApmEvent(events[i], FALSE); switch (xf86PMConfirmEventToOs(fd, events[i])) { case PM_WAIT: wait = TRUE; break; case PM_CONTINUE: wait = FALSE; break; case PM_FAILED: DoApmEvent(events[i], TRUE); wait = FALSE; break; default: break; } } if (wait) n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS); else break; } while (1); } }
UtlBoolean SipSubscribeServer::disableEventType(const char* eventType) { // :TODO: We should terminate all subscriptions for this event type. UtlString eventName(eventType); lockForWrite(); SubscribeServerEventData* eventData = dynamic_cast <SubscribeServerEventData*> (mEventDefinitions.remove(&eventName)); if (eventData) { // Unregister interest in SUBSCRIBE requests and NOTIFY // responses for this event type eventData->mpEventSpecificUserAgent->removeMessageObserver(*(getMessageQueue())); delete eventData; } unlockForWrite(); return eventData != NULL; }
UtlBoolean SipPublishServer::disableEventType(const char* eventTypeToken, SipUserAgent*& userAgent, SipPublishServerEventStateMgr*& eventStateMgr, SipPublishServerEventStateCompositor*& eventStateCompositor) { UtlBoolean removedEvent = FALSE; UtlString eventName(eventTypeToken ? eventTypeToken : ""); lockForWrite(); // Only add the event support if it does not already exist; PublishServerEventData* eventData = (PublishServerEventData*) mEventDefinitions.remove(&eventName); if(eventData) { removedEvent = TRUE; userAgent = eventData->mpEventSpecificUserAgent == mpDefaultUserAgent ? NULL : eventData->mpEventSpecificUserAgent; eventStateCompositor = eventData->mpEventSpecificStateCompositor == mpDefaultCompositor ? NULL : eventData->mpEventSpecificStateCompositor; eventStateMgr = eventData->mpEventSpecificStateMgr == mpDefaultEventStateMgr ? NULL : eventData->mpEventSpecificStateMgr; // Unregister interest in PUBLISH requests for this event type eventData->mpEventSpecificUserAgent->removeMessageObserver(*(getMessageQueue())); delete eventData; eventData = NULL; } else { userAgent = NULL; eventStateCompositor = NULL; eventStateMgr = NULL; } unlockForWrite(); return(removedEvent); }
// event windowClose(windowName) bool OnWindowClose(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("windowClose"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); // Event handler must return 1 to close window, otherwise, 0. CSquirrelArgument pReturn = pEvents->Call(eventName, &pArguments, pScript); if(pReturn.GetInteger()) pWindow->hide(); return true; }
UtlBoolean SipPublishServer::enableEventType(const char* eventTypeToken, SipUserAgent* userAgent, SipPublishServerEventStateMgr* eventStateMgr, SipPublishServerEventStateCompositor* eventStateCompositor) { UtlBoolean addedEvent = FALSE; UtlString eventName(eventTypeToken ? eventTypeToken : ""); lockForWrite(); // Only add the event support if it does not already exist; PublishServerEventData* eventData = (PublishServerEventData*) mEventDefinitions.find(&eventName); if(!eventData) { addedEvent = TRUE; eventData = new PublishServerEventData(); *((UtlString*)eventData) = eventName; eventData->mpEventSpecificUserAgent = userAgent ? userAgent : mpDefaultUserAgent; eventData->mpEventSpecificStateCompositor = eventStateCompositor ? eventStateCompositor : mpDefaultCompositor; eventData->mpEventSpecificStateMgr = eventStateMgr ? eventStateMgr : mpDefaultEventStateMgr; mEventDefinitions.insert(eventData); // Register an interest in PUBLISH requests for this event type eventData->mpEventSpecificUserAgent->addMessageObserver(*(getMessageQueue()), SIP_PUBLISH_METHOD, TRUE, // requests FALSE, // not reponses TRUE, // incoming FALSE, // no outgoing eventName, NULL, NULL); } unlockForWrite(); return(addedEvent); }
UtlBoolean SipSubscribeServer::notifySubscribers(const char* resourceId, const char* eventTypeKey, const char* eventType, UtlBoolean isDefaultContent) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers resourceId '%s', eventTypeKey '%s', eventType '%s', isDefaultContent %d", resourceId, eventTypeKey, eventType, isDefaultContent); UtlBoolean notifiedSubscribers = FALSE; UtlString eventName(eventType ? eventType : ""); lockForRead(); SubscribeServerEventData* eventData = (SubscribeServerEventData*) mEventDefinitions.find(&eventName); // Get the event specific info to find subscriptions interested in // this content if(eventData) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers received the request for sending out the notification for resourceId '%s', event type '%s'", resourceId, eventType); int numSubscriptions = 0; SipMessage** notifyArray = NULL; UtlString** acceptHeaderValuesArray = NULL; eventData->mpEventSpecificSubscriptionMgr-> createNotifiesDialogInfo(resourceId, eventTypeKey, numSubscriptions, acceptHeaderValuesArray, notifyArray); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers numSubscriptions for %s = %d", resourceId, numSubscriptions); // Setup and send a NOTIFY for each subscription interested in // this resourcesId and eventTypeKey SipMessage* notify = NULL; for(int notifyIndex = 0; notifyArray != NULL && notifyIndex < numSubscriptions && notifyArray[notifyIndex] != NULL; notifyIndex++) { notify = notifyArray[notifyIndex]; // Fill in the NOTIFY request body/content eventData->mpEventSpecificHandler-> getNotifyContent(resourceId, eventTypeKey, eventType, *(eventData->mpEventSpecificContentMgr), *(acceptHeaderValuesArray[notifyIndex]), *notify); // Send the NOTIFY request eventData->mpEventSpecificUserAgent->send(*notify); } // Free up the NOTIFY requests and accept header field values eventData->mpEventSpecificSubscriptionMgr-> freeNotifies(numSubscriptions, acceptHeaderValuesArray, notifyArray); } // event type not enabled else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscribeServer::notifySubscribers event type: %s not enabled", eventName.data()); } unlockForRead(); return(notifiedSubscribers); }
int EventPlugin::stageCount() { if(eventName().isEmpty()) return 0; return eventConfig()->stageCount(); }
bool EventPlugin::openEvent(const QString &_event_name) { closeEvent(); //return true; qff::MainWindow *fwk = qff::MainWindow::frameWork(); QString event_name = _event_name; ConnectionSettings connection_settings; ConnectionType connection_type = connection_settings.connectionType(); //console.debug("openEvent()", "event_name:", event_name, "connection_type:", connection_type); bool ok = false; if(connection_type == ConnectionType::SqlServer) { //console.debug(db); QStringList event_names = existingSqlEventNames(); if(!event_names.contains(event_name)) event_name = QString(); ok = !event_name.isEmpty(); if(!ok) { event_name = QInputDialog::getItem(fwk, tr("Query"), tr("Open event"), event_names, 0, false, &ok); } //Log.info(event_name, typeof event_name, (event_name)? "T": "F"); ok = ok && !event_name.isEmpty(); if(ok) { qfs::Connection conn(QSqlDatabase::database()); if(conn.setCurrentSchema(event_name)) { ConnectionSettings settings; settings.setEventName(event_name); ok = true; } } } else if(connection_type == ConnectionType::SingleFile) { QString event_fn; if(!event_name.isEmpty()) { event_fn = eventNameToFileName(event_name); if(!QFile::exists(event_fn)) { event_fn = event_name = QString(); } } if(event_name.isEmpty()) { QStringList event_names = existingFileEventNames(connection_settings.singleWorkingDir()); event_name = QInputDialog::getItem(fwk, tr("Query"), tr("Open event"), event_names, 0, false, &ok); //event_fn = qfd::FileDialog::getOpenFileName(fwk, tr("Select event"), connection_settings.singleWorkingDir(), tr("Quick Event files (*%1)").arg(qbe_ext)); if(ok && !event_name.isEmpty()) { event_fn = eventNameToFileName(event_name); } } //Log.info(event_name, typeof event_name, (event_name)? "T": "F"); { QString conn_name; { qfs::Connection conn(QSqlDatabase::database()); conn_name = conn.connectionName(); conn.close(); } qfInfo() << "removing database:" << conn_name; QSqlDatabase::removeDatabase(conn_name); QSqlDatabase::addDatabase("QSQLITE"); } if(event_fn.isEmpty()) { ok = false; } else { if(QFile::exists(event_fn)) { qfs::Connection conn(QSqlDatabase::database()); conn.setDatabaseName(event_fn); qfInfo() << "Opening database file" << event_fn; if(conn.open()) { qfs::Query q(conn); ok = q.exec("PRAGMA foreign_keys=ON"); } else { qfd::MessageBox::showError(fwk, tr("Open Database Error: %1").arg(conn.errorString())); } } else { qfd::MessageBox::showError(fwk, tr("Database file %1 doesn't exist.").arg(event_fn)); } } } else { qfError() << "Invalid connection type:" << static_cast<int>(connection_type); } if(ok) { eventConfig(true); connection_settings.setEventName(event_name); setEventName(event_name); emit eventOpened(eventName()); //emit reloadDataRequest(); } return ok; }
bool Workspace::x11Event( XEvent *event ) { //bool dumpWindows = false; //bool reportNextUpdate = false; static int debugs = 0; qDebug() << ++debugs << __PRETTY_FUNCTION__ << "got event" << eventName(event->type); switch ( event->type ) { case CreateNotify: createNotifyEvent( &event->xcreatewindow ); //std::cout << "window " << std::hex << event->xcreatewindow.window << " created\n"; //dumpWindows = true; break; case DestroyNotify: remove( event->xdestroywindow.window ); //std::cout << "window " << std::hex << event->xdestroywindow.window << " destroyed\n"; //dumpWindows = true; break; case ConfigureNotify: configureNotifyEvent( &event->xconfigure ); //std::cout << "window " << std::hex << event->xconfigure.window << " configured\n"; break; case MapNotify: if ( Client *client = find( event->xmap.window ) ) client->show(); //dumpWindows = true; //std::cout << "window " << std::hex << event->xmap.window << " mapped\n"; break; case UnmapNotify: if ( Client *client = find( event->xunmap.window ) ) client->hide(); //dumpWindows = true; //std::cout << "window " << std::hex << event->xunmap.window << " unmapped\n"; break; case ReparentNotify: reparentNotifyEvent( &event->xreparent ); //dumpWindows = true; break; case CirculateNotify: circulateNotifyEvent( &event->xcirculate ); //std::cout << "circulate event\n"; break; case Expose: exposeEvent( &event->xexpose ); break; case PropertyNotify: propertyNotifyEvent( &event->xproperty ); break; default: if ( event->type == Extensions::damageEvent(XDamageNotify) ) damageNotifyEvent( reinterpret_cast< XDamageNotifyEvent * >( event ) ); else if ( event->type == Extensions::shapeEvent(ShapeNotify )) shapeNotifyEvent( reinterpret_cast< XShapeEvent * >( event ) ); } /* if ( dumpWindows ) { std::cout << "===Clients===\n"; ClientList::ConstIterator end = mList.constEnd(); for (ClientList::ConstIterator it = mList.constBegin(); it != end; ++it) { Client *client = *it; //if (!client->isVisible() || client->width() <= 10 || client->height() <= 10) // continue; Window target = XmuClientWindow( dpy, client->winId() ); XTextProperty tp; XGetWMName( dpy, target, &tp ); std::cout << std::hex << client->winId() << " " << (client->isVisible() ? "(mapped)" : "(not mapped)") << " " << std::dec << client->width() << "x" << client->height() << ": "; for (uint i = 0; i < tp.nitems; i++) std::cout << (char)tp.value[i]; std::cout << std::endl; } //std::cout << "=============\n"; std::cout << std::endl; } */ // Update the root window if there's damage and there are no more events pending if ( mDamage && QLength( dpy ) == 0 ) { if ( mWaitForClients && !allVisibleClientsPainted() ) { //std::cout << "delaying update.\n."; } else { mWaitForClients = false; repaint(); } // Helps to accumulate more events XSync( dpy, false ); } return false; }
HRESULT nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { FUNCDESC *pFuncDesc = NULL; HRESULT hr = S_OK; CComBSTR bstrName; // Must search and compare each member to the dispid... if (m_spEventSinkTypeInfo) { HRESULT hr = S_OK; TYPEATTR* pAttr; hr = m_spEventSinkTypeInfo->GetTypeAttr(&pAttr); if (pAttr) { int i; for (i = 0; i < pAttr->cFuncs;i++) { hr = m_spEventSinkTypeInfo->GetFuncDesc(i, &pFuncDesc); if (FAILED(hr)) return hr; if (pFuncDesc->memid == dispIdMember) { UINT cNames = 0; m_spEventSinkTypeInfo->GetNames(dispIdMember, &bstrName, 1, &cNames); break; } m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc); pFuncDesc = NULL; } m_spEventSinkTypeInfo->ReleaseTypeAttr(pAttr); } } if (!pFuncDesc) { // Return return S_OK; } #ifdef DEBUG { // Dump out some info to look at ATLTRACE(_T("Invoke(%d)\n"), (int) dispIdMember); ATLTRACE(_T(" ")); /* Return code */ switch (pFuncDesc->elemdescFunc.tdesc.vt) { case VT_HRESULT: ATLTRACE(_T("HRESULT")); break; case VT_VOID: ATLTRACE(_T("void")); break; default: ATLTRACE(_T("void /* vt = %d */"), pFuncDesc->elemdescFunc.tdesc.vt); break; } /* Function name */ ATLTRACE(_T(" %S("), SUCCEEDED(hr) ? bstrName.m_str : L"?unknown?"); /* Parameters */ for (int i = 0; i < pFuncDesc->cParams; i++) { USHORT paramFlags = pFuncDesc->lprgelemdescParam[i].paramdesc.wParamFlags; ATLTRACE("["); BOOL addComma = FALSE; if (paramFlags & PARAMFLAG_FIN) { ATLTRACE(_T("in")); addComma = TRUE; } if (paramFlags & PARAMFLAG_FOUT) { ATLTRACE(addComma ? _T(",out") : _T("out")); addComma = TRUE; } if (paramFlags & PARAMFLAG_FRETVAL) { ATLTRACE(addComma ? _T(",retval") : _T("retval")); addComma = TRUE; } ATLTRACE("] "); VARTYPE vt = pFuncDesc->lprgelemdescParam[i].tdesc.vt; switch (vt) { case VT_HRESULT: ATLTRACE(_T("HRESULT")); break; case VT_VARIANT: ATLTRACE(_T("VARIANT")); break; case VT_I2: ATLTRACE(_T("short")); break; case VT_I4: ATLTRACE(_T("long")); break; case VT_R8: ATLTRACE(_T("double")); break; case VT_BOOL: ATLTRACE(_T("VARIANT_BOOL")); break; case VT_BSTR: ATLTRACE(_T("BSTR")); break; case VT_DISPATCH: ATLTRACE(_T("IDispatch *")); break; case VT_UNKNOWN: ATLTRACE(_T("IUnknown *")); break; case VT_USERDEFINED: ATLTRACE(_T("/* Userdefined */")); break; case VT_PTR: ATLTRACE(_T("void *")); break; case VT_VOID: ATLTRACE(_T("void")); break; // More could be added... default: ATLTRACE(_T("/* vt = %d */"), vt); break; } if (i + 1 < pFuncDesc->cParams) { ATLTRACE(_T(", ")); } } ATLTRACE(_T(");\n")); } #endif m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc); pFuncDesc = NULL; nsCOMPtr<nsIDOMElement> element; NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMElement, static_cast<nsIDOMElement **>(getter_AddRefs(element))); if (!element) { NS_ERROR("can't get the object element"); return S_OK; } nsAutoString id; if (NS_FAILED(element->GetAttribute(NS_LITERAL_STRING("id"), id)) || id.IsEmpty()) { // Object has no name so it can't fire events return S_OK; } nsDependentString eventName(bstrName.m_str); // Fire the script event handler... nsCOMPtr<nsIDOMWindow> window; NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMWindow, static_cast<nsIDOMWindow **>(getter_AddRefs(window))); nsCOMPtr<nsIScriptEventManager> eventManager(do_GetInterface(window)); if (!eventManager) return S_OK; nsCOMPtr<nsISupports> handler; eventManager->FindEventHandler(id, eventName, pDispParams->cArgs, getter_AddRefs(handler)); if (!handler) { return S_OK; } // Create a list of arguments to pass along // // This array is created on the stack if the number of arguments // less than kMaxArgsOnStack. Otherwise, the array is heap // allocated. // const int kMaxArgsOnStack = 10; PRUint32 argc = pDispParams->cArgs; jsval *args = nsnull; jsval stackArgs[kMaxArgsOnStack]; // Heap allocate the jsval array if it is too big to fit on // the stack (ie. more than kMaxArgsOnStack arguments) if (argc > kMaxArgsOnStack) { args = new jsval[argc]; if (!args) return S_OK; } else if (argc) { // Use the jsval array on the stack... args = stackArgs; } if (argc) { nsCOMPtr<nsIDispatchSupport> disp(do_GetService("@mozilla.org/nsdispatchsupport;1")); for (UINT i = 0; i < argc; i++) { // Arguments are listed backwards, intentionally, in rgvarg disp->COMVariant2JSVal(&pDispParams->rgvarg[argc - 1 - i], &args[i]); } } // Fire the Event. eventManager->InvokeEventHandler(handler, element, args, argc); // Free the jsvals if they were heap allocated... if (args != stackArgs) { delete [] args; } // TODO Turn js objects for out params back into VARIANTS // TODO Turn js return code into VARIANT // TODO handle js exception and fill in exception info (do we care?) if (pExcepInfo) { pExcepInfo->wCode = 0; } return S_OK; }
// Send a NOTIFY to all subscribers to the given resourceId and eventTypeKey. UtlBoolean SipSubscribeServer::notifySubscribers(const char* resourceId, const char* eventTypeKey, const char* eventType, const char* reason) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers resourceId '%s', eventTypeKey '%s', eventType '%s', reason '%s'", resourceId, eventTypeKey, eventType, reason ? reason : "[null]"); UtlBoolean notifiedSubscribers = FALSE; UtlString eventName(eventType); lockForRead(); SubscribeServerEventData* eventData = dynamic_cast <SubscribeServerEventData*> (mEventDefinitions.find(&eventName)); // Get the event-specific info to find subscriptions interested in // this content. if (eventData) { int numSubscriptions = 0; SipMessage** notifyArray = NULL; UtlString** acceptHeaderValuesArray = NULL; // Select the subscriptionChange value to describe what we're doing // with the subscriptions. enum SipSubscriptionMgr::subscriptionChange change; { // Select the correct format for generating the Subscription-State value. UtlString* formatp = NULL; // We may need a temp UtlString. const char* format; if (reason == NULL) { format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionContinues; } else if (strcmp(reason, terminationReasonSilent) == 0) { // Do not admit that the subscription is ending. format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionTerminatedSilently; } else if (strcmp(reason, terminationReasonNone) == 0) { format = "terminated"; change = SipSubscriptionMgr::subscriptionTerminated; } else { // Allocate a UtlString and assemble the Subscription-State format in it. formatp = new UtlString(); formatp->append("terminated;reason="); formatp->append(reason); format = formatp->data(); change = SipSubscriptionMgr::subscriptionTerminated; } // Construct a NOTIFY (without body) for each subscription, containing // the dialog-related information about each subscription. eventData->mpEventSpecificSubscriptionMgr-> createNotifiesDialogInfo(resourceId, eventTypeKey, format, numSubscriptions, acceptHeaderValuesArray, notifyArray); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers numSubscriptions for '%s' = %d", resourceId, numSubscriptions); // Free the temporary UtlString, if necessary. if (formatp) { delete formatp; } } // For each NOTIFY, add the subscription-related information and then // send it. for (int notifyIndex = 0; notifyIndex < numSubscriptions; notifyIndex++) { SipMessage* notify = notifyArray[notifyIndex]; // Check to see if the dialog information could be added. // (The subscription might have been destroyed between when // it was decided to respond to it, and when the dialog information // was retrieved.) UtlString callId; notify->getCallIdField(&callId); if (!callId.isNull()) { if (change != SipSubscriptionMgr::subscriptionTerminatedSilently) { // Fill in the NOTIFY request body/content eventData->mpEventSpecificHandler-> getNotifyContent(resourceId, eventTypeKey, eventType, *(eventData->mpEventSpecificContentMgr), *(acceptHeaderValuesArray[notifyIndex]), *notify, eventData->mEventSpecificFullState, NULL); // Call the application callback to edit the NOTIFY // content if that is required for this event type. // Also gets 'version' (if relevant) and 'savedEventTypeKey'. int version; UtlString savedEventTypeKey; eventData->mpEventSpecificSubscriptionMgr-> updateNotifyVersion(eventData->mpEventSpecificContentVersionCallback, *notify, version, savedEventTypeKey); // Update the saved record of the NOTIFY CSeq and the // XML version number for the specified savedEventTypeKey, // as needed by the subscription manager. // In practice, this is only used by SipPersistentSubscriptionMgr // to write the NOTIFY Cseq and XML version into the IMDB. eventData->mpEventSpecificSubscriptionMgr-> updateVersion(*notify, version, savedEventTypeKey); // Set the Contact header. setContact(notify); // Send the NOTIFY request. eventData->mpEventSpecificUserAgent->send(*notify); } if (change != SipSubscriptionMgr::subscriptionContinues) { // Remove the record of the subscription. UtlString dialogHandle; notify->getDialogHandle(dialogHandle); eventData->mpEventSpecificSubscriptionMgr-> endSubscription(dialogHandle, change); } } } // Free the NOTIFY requests and accept header field values. eventData->mpEventSpecificSubscriptionMgr-> freeNotifies(numSubscriptions, acceptHeaderValuesArray, notifyArray); } // event type not enabled else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscribeServer::notifySubscribers " "event type: %s not enabled - " "Why are we seeing a callback for this?", eventName.data()); } unlockForRead(); return notifiedSubscribers; }