bool IOBSDConsole::start(IOService * provider) { OSObject * notify; if (!super::start(provider)) return false; notify = addNotification( gIOPublishNotification, serviceMatching("IOHIKeyboard"), (IOServiceNotificationHandler) &IOBSDConsole::publishNotificationHandler, this, 0 ); assert( notify ); notify = addNotification( gIOPublishNotification, serviceMatching("IODisplayWrangler"), (IOServiceNotificationHandler) &IOBSDConsole::publishNotificationHandler, this, 0 ); assert( notify ); notify = addNotification( gIOPublishNotification, serviceMatching("IOAudioStream"), (IOServiceNotificationHandler) &IOBSDConsole::publishNotificationHandler, this, this ); assert( notify ); return( true ); }
/** * Adds a block to the block list. If a block with the same name * exists already, the given block will be deleted if the blocklist * owns the blocks. * * @param notify true if you want listeners to be notified. * * @return false: block already existed and was deleted. */ bool RS_BlockList::add(RS_Block* block, bool notify) { RS_DEBUG->print("RS_BlockList::add()"); if (!block) { return false; } // check if block already exists: RS_Block* b = find(block->getName()); if (!b) { blocks.append(block); if (notify) { addNotification(); } setModified(true); return true; } else { if (owner) { delete block; block = nullptr; } return false; } }
void ServerController::sendComments(sf::Packet &packet, sf::TcpSocket &client) { std::string username, conference, subTitle, newComment; packet >> username >> conference >> subTitle >> newComment; int subIndex = -1; for (int i = 0; i < (int)data.submissions.size(); i++) { if (data.submissions[i].getConference() == conference) { if (data.submissions[i].getTitle() == subTitle) { if (data.submissions[i].hasReviewer(username)) { data.submissions[i].addComment(username, newComment); subIndex = i; } } } } if (subIndex != -1) { std::vector<std::string> revList; data.submissions[subIndex].getReviewerList(revList); for (int r = 0; r < (int)revList.size(); ++r) { if (revList[r] != username) { addNotification(revList[r], username + " has commented for Paper " + subTitle); } } } data.saveSubmissions(); }
void ServerController::addMember(sf::Packet &packet, sf::TcpSocket &client, Account::AccessLevel level) { sf::Packet response; std::string username, conference, targetUser; packet >> username >> conference >> targetUser; bool success = false; int findIndex = checkAccount(username); int targetIndex = checkAccount(targetUser); int confIndex = checkConference(conference); if (findIndex == -1 || targetIndex == -1 || confIndex == -1) { success = false; response << success; client.send(response); return; } // add access to the conference in the target user's accessmap data.accounts[targetIndex].addAccess(conference, level); if (level == Account::Access_Reviewer) { data.conferences[confIndex].addReviewer(targetUser); } // add welcome notification to the user addNotification(targetUser, "Welcome to " + conference + "!"); success = true; response << success; client.send(response); data.saveAccounts(); data.saveConferences(); }
void ServerController::paperSubmission(sf::Packet &packet, sf::TcpSocket &client) { sf::Packet response; Submission sub; bool exists = false; std::string username, conference, title; packet >> username; int findIndex = checkAccount(username); //get Account index if (findIndex == -1) { return; // ignore request if user is not found } packet >> sub; conference = sub.getConference(); title = sub.getTitle(); int confIndex = checkConference(conference); if (confIndex == -1) { return; // ignore request if conference is not found } if (data.accounts[findIndex].getAccess(conference) < Account::Access_Author) { return; // ignore request if user is not at least an author of that conference } // check conference is in submission phase if (data.conferences[confIndex].getCurrentPhase() != "Submission") { return; // ignore request if conference is not accepting submissions } // check that the paper does not already exist if (checkSubmission(title, conference) == -1) { // set the papers university to the submitting author sub.setUniversity(data.accounts[findIndex].getUniversity()); // add the submitting author as an author std::string firstname = data.accounts[findIndex].getFirstName(); std::string lastname = data.accounts[findIndex].getLastName(); sub.addAuthor(firstname, lastname); data.submissions.push_back(sub); data.saveSubmissions(); data.addLog("Paper was submitted: " + title + " by " + username + " for conference " + conference); addNotification(username, "You submitted a paper '" + title + "' to " + conference); notifyConference(conference, username + " submitted a paper '" + title + "' to " + conference, Account::Access_Chairman); } else { exists = true; } response << exists; client.send(response); }
void parent_sighdlr(int sig) { switch(sig) { case SIGTERM: addNotification(g_parent_sig_pipe, CODE_SIGTERM); break; case SIGINT: addNotification(g_parent_sig_pipe, CODE_SIGINT); break; case SIGUSR1: addNotification(g_parent_sig_pipe, CODE_SIGUSR1); break; case SIGCHLD: addNotification(g_parent_sig_pipe, CODE_SIGCHLD); break; } }
void LogUI::push(Type type, const char* message) { Lumix::MT::SpinLock lock(m_guard); ++m_new_message_count[type]; m_messages[type].push(Lumix::string(message, m_allocator)); if (type == Error || type == Warning) { addNotification(message); } }
void Ut_DBusInterfaceNotificationSink::init() { qDBusConnectionConnectService.clear(); qDBusConnectionConnectPath.clear(); qDBusConnectionConnectInterface.clear(); qDBusConnectionConnectName.clear(); qDBusConnectionConnectReceiver.clear(); qDBusConnectionConnectSlot.clear(); manager = new NotificationManager; sink = new DBusInterfaceNotificationSink(manager); connect(this, SIGNAL(addNotification(Notification)), sink, SLOT(addNotification(Notification))); connect(this, SIGNAL(addGroup(uint,NotificationParameters)), sink, SLOT(addGroup(uint,NotificationParameters))); connect(this, SIGNAL(removeNotification(uint)), sink, SLOT(removeNotification(uint))); connect(this, SIGNAL(removeGroup(uint)), sink, SLOT(removeGroup(uint))); gNotificationManagerStub->stubReset(); gNotificationGroupStub->stubReset(); gNotificationGroupStub->stubSetReturnValue<const NotificationParameters&>("parameters", fakeParams); }
//==================================================================================================== // IOHIDEventService::start //==================================================================================================== bool IOHIDEventSystem::start(IOService * provider) { if ( super::start(provider) == false ) return false; _workLoop = IOHIDWorkLoop::workLoop(); _commandGate = IOCommandGate::commandGate(this); if ( !_workLoop || !_commandGate ) return false; if ( _workLoop->addEventSource(_commandGate) != kIOReturnSuccess ) return false; _publishNotify = addNotification( gIOPublishNotification, serviceMatching("IOHIDEventService"), OSMemberFunctionCast(IOServiceNotificationHandler, this, &IOHIDEventSystem::notificationHandler), this, (void *)OSMemberFunctionCast(IOCommandGate::Action, this, &IOHIDEventSystem::handleServicePublicationGated) ); _terminateNotify = addNotification( gIOTerminatedNotification, serviceMatching("IOHIDEventService"), OSMemberFunctionCast(IOServiceNotificationHandler, this, &IOHIDEventSystem::notificationHandler), this, (void *)OSMemberFunctionCast(IOCommandGate::Action, this, &IOHIDEventSystem::handleServiceTerminationGated) ); if (!_publishNotify || !_terminateNotify) return false; _eventsOpen = true; registerService(); return true; }
void Ut_DBusInterfaceNotificationSink::testNothingCalledWhenNothingRegistered() { Notification n; NotificationParameters np; emit addNotification(n); emit addGroup(0, np); emit removeNotification(0); emit removeGroup(0); QCOMPARE(gAddNotificationProxies.count(), 0); QCOMPARE(gAddGroupProxies.count(), 0); QCOMPARE(gRemoveNotificationProxies.count(), 0); QCOMPARE(gRemoveGroupProxies.count(), 0); }
void Ut_DBusInterfaceNotificationSink::testRegisteringTwoDifferentServicesCallsBoth() { Notification n; sink->registerSink("service1", "path"); QCOMPARE(gNewSinkProxies.count(), 1); sink->registerSink("service2", "path"); QCOMPARE(gNewSinkProxies.count(), 2); emit addNotification(n); QCOMPARE(gAddNotificationProxies.count(), 2); QVERIFY(gAddNotificationProxies.contains(gNewSinkProxies.at(0))); QVERIFY(gAddNotificationProxies.contains(gNewSinkProxies.at(1))); }
void Ut_DBusInterfaceNotificationSink::testRegisteringSameServiceAndPathReplacesPrevious() { Notification n; sink->registerSink("service1", "path"); QCOMPARE(gNewSinkProxies.count(), 1); sink->registerSink("service1", "path"); QCOMPARE(gNewSinkProxies.count(), 2); emit addNotification(n); QCOMPARE(gAddNotificationProxies.count(), 1); QCOMPARE(gAddNotificationProxies.at(0), gNewSinkProxies.at(1)); }
void Ut_DBusInterfaceNotificationSink::testUnregistering() { Notification n; sink->registerSink("service1", "path"); QCOMPARE(gNewSinkProxies.count(), 1); sink->registerSink("service2", "path"); QCOMPARE(gNewSinkProxies.count(), 2); sink->unregisterSink("service1", "path"); emit addNotification(n); QCOMPARE(gAddNotificationProxies.count(), 1); QCOMPARE(gAddNotificationProxies.at(0), gNewSinkProxies.at(1)); }
void Ut_DBusInterfaceNotificationSink::testProxyCalledWhenServiceRegistered() { Notification n; NotificationParameters np; sink->registerSink("service1", "path"); QCOMPARE(gNewSinkProxies.count(), 1); emit addNotification(n); emit addGroup(0, np); emit removeNotification(0); emit removeGroup(0); QCOMPARE(gAddNotificationProxies.count(), 1); QCOMPARE(gAddNotificationProxies.at(0), gNewSinkProxies.at(0)); QCOMPARE(gAddGroupProxies.count(), 1); QCOMPARE(gAddGroupProxies.at(0), gNewSinkProxies.at(0)); QCOMPARE(gRemoveNotificationProxies.count(), 1); QCOMPARE(gRemoveNotificationProxies.at(0), gNewSinkProxies.at(0)); QCOMPARE(gRemoveGroupProxies.count(), 1); QCOMPARE(gRemoveGroupProxies.at(0), gNewSinkProxies.at(0)); }
NotificationPreviewPresenter::NotificationPreviewPresenter(QObject *parent) : QObject(parent), window(0), currentNotification(0), notificationFeedbackPlayer(new NotificationFeedbackPlayer(this)), locks(new MeeGo::QmLocks(this)), displayState(new MeeGo::QmDisplayState(this)) { connect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), this, SLOT(updateNotification(uint))); connect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), this, SLOT(removeNotification(uint))); connect(this, SIGNAL(notificationPresented(uint)), notificationFeedbackPlayer, SLOT(addNotification(uint))); QTimer::singleShot(0, this, SLOT(createWindowIfNecessary())); }
bool AppleNForceATARoot::start( IOService * provider ) { OSDictionary * match; if (super::start(provider) != true) return false; fProvider = OSDynamicCast( IOPCIDevice, provider ); if (fProvider == 0) return false; fProvider->retain(); // Enable bus master. fProvider->setBusMasterEnable( true ); // Allocate a mutex to serialize access to PCI config space between // the primary and secondary ATA channels. fPCILock = IOLockAlloc(); if (fPCILock == 0) return false; fIsSATA = (getProperty(kSerialATAKey) == kOSBooleanTrue); fChannels = createATAChannels(); if (fChannels == 0) return false; fOpenChannels = OSSet::withCapacity( fChannels->getCount() ); if (fOpenChannels == 0) return false; if (fIsSATA) { // Register SATA channels without delay. fHardwareType = PCI_HW_SATA; fHardwareFlags = 0; applyToClients( registerClientApplier, 0 ); } else if ((match = OSDynamicCast(OSDictionary, getProperty(kISABridgeMatchingKey)))) { match->retain(); // remove notification will consume a reference // Provider's PCI device ID does not tell us the hardware features // of the ATA controller. We need to locate the PCI-ISA bridge and // lookup a table before registering the channel nub(s). If bridge // is absent, we're in trouble. fISABridgeNotifier = addNotification( /* type */ gIOFirstPublishNotification, /* match */ match, /* handler */ isaBridgePublished, /* target */ this, /* refcon */ 0 ); if (fISABridgeNotifier == 0) { match->release(); return false; } } else { return false; } return true; }
void Ut_NotificationPreviewPresenter::testSignalConnections() { NotificationPreviewPresenter presenter; QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), &presenter, SLOT(updateNotification(uint))), true); QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), &presenter, SLOT(removeNotification(uint))), true); QCOMPARE(disconnect(&presenter, SIGNAL(notificationPresented(uint)), presenter.notificationFeedbackPlayer, SLOT(addNotification(uint))), true); }
void sigchild_handler(int sig) { addNotification(g_signotify_pipe, CODE_SIGCHLD); }
void sigint_handler(int sig) { addNotification(g_signotify_pipe, CODE_SIGINT); }
void sigterm_handler(int sig) { addNotification(g_signotify_pipe, CODE_SIGTERM); }