// Loads the default shortcuts from the registry void EventManager::loadAccelerators() { if (_debugMode) { std::cout << "EventManager: Loading accelerators...\n"; } xml::NodeList shortcutSets = GlobalRegistry().findXPath("user/ui/input//shortcuts"); if (_debugMode) { std::cout << "Found " << shortcutSets.size() << " sets.\n"; } // If we have two sets of shortcuts, delete the default ones if (shortcutSets.size() > 1) { GlobalRegistry().deleteXPath("user/ui/input//shortcuts[@name='default']"); } // Find all accelerators xml::NodeList shortcutList = GlobalRegistry().findXPath("user/ui/input/shortcuts//shortcut"); if (shortcutList.size() > 0) { rMessage() << "EventManager: Shortcuts found in Registry: " << static_cast<int>(shortcutList.size()) << std::endl; for (unsigned int i = 0; i < shortcutList.size(); i++) { const std::string key = shortcutList[i].getAttributeValue("key"); if (_debugMode) { std::cout << "Looking up command: " << shortcutList[i].getAttributeValue("command") << "\n"; std::cout << "Key is: >> " << key << " << \n"; } // Try to lookup the command IEventPtr event = findEvent(shortcutList[i].getAttributeValue("command")); // Check for a non-empty key string if (key != "") { // Check for valid command definitions were found if (!event->empty()) { // Get the modifier string (e.g. "SHIFT+ALT") const std::string modifierStr = shortcutList[i].getAttributeValue("modifiers"); if (!duplicateAccelerator(key, modifierStr, event)) { // Create the accelerator object IAccelerator& accelerator = addAccelerator(key, modifierStr); // Connect the newly created accelerator to the command accelerator.connectEvent(event); } } else { rWarning() << "EventManager: Cannot load shortcut definition (command invalid)." << std::endl; } } } } else { // No accelerator definitions found! rWarning() << "EventManager: No shortcut definitions found..." << std::endl; } }
void enableEvent(const std::string& eventName) { IEvent* event = findEvent(eventName); if (event != NULL) { event->setEnabled(true); } }
void addExternalListener(const char *name, int retSize, NetworkAddress *addr) { Event ev; bool isNewEvent = false; lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { extEvent = newEvent(name, retSize); isNewEvent = true; } extEvent->addExternalListener(addr); if(isNewEvent) extEvent->listenerAddr = ev.addListener(name, eventCallback, 0, false, retSize); else { int prevSize = extEvent->retSize; //If ret size larger than previous (singleEvent) retSize, make enough room if(prevSize < retSize) { extEvent->totRetSize = (extEvent->totRetSize/extEvent->retSize)*retSize; extEvent->totRetSize = retSize; } else extEvent->totRetSize += extEvent->retSize; ev.resizeListener(extEvent->listenerAddr, extEvent->totRetSize); } lock.unlock(); }
void ViewSegment::endMarkerTimeChanged(const Segment *segment, bool shorten) { Segment *s = const_cast<Segment *>(segment); Q_ASSERT(s == &m_segment); if (shorten) { m_viewElementList->erase (m_viewElementList->findTime(s->getEndMarkerTime()), m_viewElementList->end()); } else { timeT myLastEltTime = s->getStartTime(); if (m_viewElementList->end() != m_viewElementList->begin()) { ViewElementList::iterator i = m_viewElementList->end(); myLastEltTime = (*--i)->event()->getAbsoluteTime(); } for (Segment::iterator j = s->findTime(myLastEltTime); s->isBeforeEndMarker(j); ++j) { ViewElementList::iterator newi = findEvent(*j); if (newi == m_viewElementList->end()) { if (wrapEvent(*j)) { m_viewElementList->insert(makeViewElement(*j)); } } } } }
void EventManager::setToggled(const std::string& name, const bool toggled) { // Check could be placed here by boost::shared_ptr's dynamic_pointer_cast if (!findEvent(name)->setToggled(toggled)) { rWarning() << "EventManager: Event " << name << " is not a Toggle." << std::endl; } }
void addInternalPending(const char *name, char *buf, int bufSize) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(extEvent) extEvent->addInternalPending(buf, bufSize); lock.unlock(); }
void setToggled(const std::string& name, const bool toggled) { // Try to find the command and see if it's already registered Toggle* foundToggle = dynamic_cast<Toggle*>(findEvent(name)); if (foundToggle != NULL) { if (!foundToggle->setToggled(toggled)) globalErrorStream() << "EventManager: Warning: Event " << name << " is not a Toggle.\n"; } }
bool EventValidator::waitForEvent(const char* szEvent, bool bStrictOrderMatch, int iTimeoutInSecs) { bool bFound = false; OsTime waitTime(iTimeoutInSecs == DEFAULT_TIMEOUT ? m_iDefaultTimeoutInSecs : iTimeoutInSecs, 0); int nMaxLookAhead = bStrictOrderMatch ? 1 : m_iMaxLookAhead; int nActualLookAhead = 0; bool bTimedOut = false; bFound = findEvent(szEvent, nMaxLookAhead, nActualLookAhead); while (!bFound && !bTimedOut && (nActualLookAhead < nMaxLookAhead)) { if (m_semUnprocessed.acquire(waitTime) != OS_SUCCESS) { bTimedOut = true; } bFound = findEvent(szEvent, nMaxLookAhead, nActualLookAhead); } if (!bFound) { m_pUnfoundEvent = new UtlString(szEvent); } if (!bFound) { if (bTimedOut) { m_eErrorType = EVENT_VALIDATOR_ERROR_TIMEOUT; } else { m_eErrorType = EVENT_VALIDATOR_ERROR_MISMATCH; } } // A Bit of a hack: In some of the unit tests, we have a race between the event matcher // and autoXXXX handlers. OsTask::delay(20); return bFound; }
jboolean Java_javax_tv_service_guide_VDRProgramSchedule_fillEventDescription(JNIEnv* env, jobject obj, jobject nativeServiceData, jint eventID, jobject eventObject) { cSchedulesLock lock; const cEvent *event=findEvent(lock, nativeServiceData, eventID); if (event) { JNI::ReturnType value; value.TypeObject = (jstring)JNI::String(event->Description()); eventDescriptionField.SetValue(eventObject, value); return JNI_TRUE; } return JNI_FALSE; }
void sendAsynchEvent(const char *name, char *buf, int bufSize, NetworkManager *msgManager, bool isUdp) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNAL ERROR: received event message with no event structure!!"); } else extEvent->sendAsynchEvent(buf, bufSize, msgManager, isUdp); lock.unlock(); }
void signalExternalTermination(const char *name, unsigned int id, int bufSize, char *buf) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNAL ERROR: received event message with no event structure!!"); } else extEvent->signalExternalTermination(id, bufSize, buf); lock.unlock(); }
// Connects the given accelerator to the given command (identified by the string) void EventManager::connectAccelerator(IAccelerator& accelerator, const std::string& command) { IEventPtr event = findEvent(command); if (!event->empty()) { // Command found, connect it to the accelerator by passing its pointer accelerator.connectEvent(event); } else { // Command NOT found rWarning() << "EventManager: Unable to connect command: " << command << std::endl; } }
int run_test(SaHpiSessionIdT sessionId1, SaHpiSessionIdT sessionId2) { int ret; SaErrorT status; SaHpiBoolT found; status = saHpiEventAdd(sessionId1, &new_event_1); if (status != SA_OK) { e_print(saHpiEventAdd, SA_OK, status); ret = SAF_TEST_UNRESOLVED; } else { status = findEvent(sessionId1, &new_event_1, &found); if (status != SA_OK) { ret = SAF_TEST_UNRESOLVED; } else if (!found) { ret = SAF_TEST_FAIL; m_print("Could not find event in first session!"); } else { status = findEvent(sessionId2, &new_event_1, &found); if (status != SA_OK) { ret = SAF_TEST_UNRESOLVED; } else if (!found) { ret = SAF_TEST_FAIL; m_print ("Could not find event in second session!"); } else { ret = SAF_TEST_PASS; } } //user events should clear the log before exiting status = saHpiEventLogClear(sessionId1, SAHPI_UNSPECIFIED_RESOURCE_ID); if (status != SA_OK) e_print(saHpiEventLogClear, SA_OK, status); } return ret; }
void sendSynchEvent(const char *name, char *buf, int bufSize, bool isCollect, NetworkManager *msgManager, UnnamedSemaphore ** &retSems, unsigned int * &waitIds, int &numSems) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNAL ERROR: received event message with no event structure!!"); } else extEvent->sendSynchEvent(buf, bufSize, isCollect, msgManager, retSems, waitIds, numSems); lock.unlock(); }
// Checks if the eventName is already registered and writes to rMessage, if so bool EventManager::alreadyRegistered(const std::string& eventName) { // Try to find the command and see if it's already registered IEventPtr foundEvent = findEvent(eventName); if (foundEvent->empty()) { return false; } else { rWarning() << "EventManager: Event " << eventName << " already registered!" << std::endl; return true; } }
void collectExternalPendingData(const char *name, unsigned int i, int &retSize, char * &retBuf) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNALE ERROR: received event message with no event structure!!"); } else extEvent->collectExternalPendingData(i, retSize, retBuf); lock.unlock(); }
void removeExternalPending(const char *name, unsigned int id) { lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNALE ERROR: received event message with no event structure!!"); } else extEvent->removeExternalPending(id); lock.unlock(); }
bool isExternalEvent(const char *name, char *buf, int size) { bool isExt = false; lock.lock(); ExternalEvent *extEvent = findEvent(name); if(!extEvent) { printf("INTERNAL ERROR: received event with no event structure!!"); } else isExt = extEvent->isExternalEvent(buf, size); lock.unlock(); return isExt; }
// Connects the given accelerator to the given command (identified by the string) void connectAccelerator(IAccelerator* accelerator, const std::string& command) { // Sanity check if (accelerator != NULL) { IEvent* event = findEvent(command); if (event != NULL) { // Command found, connect it to the accelerator by passing its pointer accelerator->connectEvent(event); } else { // Command NOT found globalOutputStream() << "EventManager: Unable to lookup command: " << command << "\n"; } } }
void MainWindow::createActions() { addEventAction = new QAction(QIcon::fromTheme("add"), tr("&Add"), this); addEventAction->setShortcut(Qt::CTRL + Qt::Key_A); QString hint = tr("Add event to calendar"); addEventAction->setStatusTip(hint); addEventAction->setToolTip(hint); addEventAction->setWhatsThis(hint); connect(addEventAction, SIGNAL(triggered()), SLOT(addEvent())); findEventAction = new QAction(QIcon::fromTheme("find"), tr("&Find"), this); QString findHint = tr("Find event"); findEventAction->setShortcut(QKeySequence::Find); findEventAction->setStatusTip(findHint); findEventAction->setToolTip(findHint); connect(findEventAction, SIGNAL(triggered()), SLOT(findEvent())); }
jboolean Java_javax_tv_service_guide_VDRProgramSchedule_components(JNIEnv* env, jobject obj, jobject nativeServiceData, jint eventID, jobject builder) { cSchedulesLock lock; const cEvent *event=findEvent(lock, nativeServiceData, eventID); if (event) { const cComponents *components=event->Components(); if (components) { printf("Java_javax_tv_service_guide_VDRProgramSchedule_components: componentTag not stored by VDR!\n"); for (int i=0;i<components->NumComponents();i++) { const tComponent *comp=components->Component(i); JNI::ReturnType returnValue; if (!eventComponentListBuilderCallback.CallMethod(builder, returnValue, (jint)0, (jint)comp->stream, (jint)comp->type, (jstring)JNI::String(comp->language), (jstring)JNI::String(comp->description), (jlong)event->Seen())) return JNI_FALSE; } return JNI_TRUE; } } return JNI_FALSE; }
void disconnectAccelerator(const std::string& command) { IEvent* event = findEvent(command); if (event != NULL) { // Cycle through the accelerators and check for matches for (AcceleratorList::iterator i = _accelerators.begin(); i != _accelerators.end(); i++) { if ((*i)->match(event)) { // Connect the accelerator to the empty event (disable the accelerator) (*i)->connectEvent(NULL); (*i)->setKey(0); (*i)->setModifiers(0); } } } else { // Command NOT found globalOutputStream() << "EventManager: Unable to disconnect command: " << command << "\n"; } }
void EventManager::disconnectAccelerator(const std::string& command) { IEventPtr event = findEvent(command); if (!event->empty()) { // Cycle through the accelerators and check for matches for (AcceleratorList::iterator i = _accelerators.begin(); i != _accelerators.end(); i++) { if (i->match(event)) { // Connect the accelerator to the empty event (disable the accelerator) i->connectEvent(_emptyEvent); i->setKey(0); i->setModifiers(0); } } } else { // Command NOT found rWarning() << "EventManager: Unable to disconnect command: " << command << std::endl; } }
IEvent* addRegistryToggle(const std::string& name, const std::string& registryKey) { // Try to find the command and see if it's already registered IEvent* foundEvent = findEvent(name); if (foundEvent == NULL) { // Construct a new command with the given <onToggled> callback RegistryToggle* registryToggle = new RegistryToggle(registryKey); // Add the command to the list (implicitly cast the pointer on IEvent*) _events[name] = registryToggle; // Return the pointer to the newly created event return registryToggle; } else { globalOutputStream() << "EventManager: Warning: Event " << name << " already registered!\n"; return foundEvent; } }
void ViewSegment::eventRemoved(const Segment *t, Event *e) { Profiler profiler("ViewSegment::eventRemoved"); Q_ASSERT(t == &m_segment); (void)t; // avoid warnings // If we have it, lose it ViewElementList::iterator i = findEvent(e); if (i != m_viewElementList->end()) { notifyRemove(*i); m_viewElementList->erase(i); return; } // std::cerr << "Event at " << e->getAbsoluteTime() << ", notation time " << e->getNotationAbsoluteTime() << ", type " << e->getType() // << " not found in ViewSegment" << std::endl; }
IEvent* addKeyEvent(const std::string& name, const Callback& keyUpCallback, const Callback& keyDownCallback) { // Try to find the command and see if it's already registered IEvent* foundEvent = findEvent(name); if (foundEvent == NULL) { // Construct a new keyevent with the given callback KeyEvent* keyevent = new KeyEvent(keyUpCallback, keyDownCallback); // Add the command to the list (implicitly cast the pointer on IEvent*) _events[name] = keyevent; globalOutputStream() << "EventManager: Event " << name << " registered!\n"; // Return the pointer to the newly created event return keyevent; } else { globalOutputStream() << "EventManager: Warning: Event " << name << " already registered!\n"; return foundEvent; } }
void loadAccelerators() { xml::NodeList shortcutSets = GlobalRegistry().findXPath("user/ui/input//shortcuts"); // If we have two sets of shortcuts, delete the default ones if (shortcutSets.size() > 1) { GlobalRegistry().deleteXPath("user/ui/input//shortcuts[@name='default']"); } // Find all accelerators xml::NodeList shortcutList = GlobalRegistry().findXPath("user/ui/input/shortcuts//shortcut"); if (!shortcutList.empty()) { globalOutputStream() << "EventManager: Shortcuts found in Registry: " << shortcutList.size() << "\n"; for (unsigned int i = 0; i < shortcutList.size(); i++) { const std::string key = shortcutList[i].getAttributeValue("key"); const std::string command = shortcutList[i].getAttributeValue("command"); // Try to lookup the command IEvent* event = findEvent(command); // Check if valid key / command definitions were found if (key != "" && event != NULL) { // Get the modifier string (e.g. "SHIFT+ALT") const std::string modifierStr = shortcutList[i].getAttributeValue("modifiers"); if (!duplicateAccelerator(key, modifierStr, event)) { // Create the accelerator object IAccelerator* accelerator = addAccelerator(key, modifierStr); // Connect the newly created accelerator to the command accelerator->connectEvent(event); } } } } else { // No accelerator definitions found! globalOutputStream() << "EventManager: No shortcut definitions found...\n"; } }
// Add the given command to the internal list IEvent* addCommand(const std::string& name, const Callback& callback) { // Try to find the command and see if it's already registered IEvent* foundEvent = findEvent(name); if (foundEvent == NULL) { // Construct a new command with the given callback Command* cmd = new Command(callback); // Add the command to the list (implicitly cast the pointer on IEvent*) _events[name] = cmd; globalOutputStream() << "EventManager: Event " << name << " registered!\n"; // Return the pointer to the newly created event return cmd; } else { globalOutputStream() << "EventManager: Warning: Event " << name << " already registered!\n"; return foundEvent; } }
void EventManager::enableEvent(const std::string& eventName) { findEvent(eventName)->setEnabled(true); }
void EventManager::disableEvent(const std::string& eventName) { findEvent(eventName)->setEnabled(false); }