void SmsDialog::initUI() { setCaption( i18n( "SMS text" ) ); setButtons( Ok | Cancel ); setDefaultButton( Ok ); showButtonSeparator( true ); QWidget *page = new QWidget( this ); setMainWidget( page ); page->setFixedWidth( 300 ); QVBoxLayout *topLayout = new QVBoxLayout( page ); topLayout->setSpacing( spacingHint() ); topLayout->setMargin( 0 ); QLabel *label = new QLabel( i18n( "Please insert SMS text for an SMS to the following number: %1", mNumber ), page ); topLayout->addWidget( label ); label->setWordWrap( true ); mSmsTextEdit = new KTextEdit( page ); mSmsTextEdit->setAcceptRichText( false ); label->setBuddy( mSmsTextEdit ); topLayout->addWidget( mSmsTextEdit ); connect( mSmsTextEdit, SIGNAL(textChanged()), SLOT(updateCounter()) ); mLengthLabel = new QLabel( QLatin1String( "-" ) , page ); topLayout->addWidget( mLengthLabel ); mSmsTextEdit->setFocus(); updateCounter(); }
void QXmppIncomingClient::onDigestReply() { QXmppPasswordReply *reply = qobject_cast<QXmppPasswordReply *> (sender()); if (!reply) return; reply->deleteLater(); if (reply->error() == QXmppPasswordReply::TemporaryError) { warning (QString ("Temporary authentication failure for '%1' from %2").arg (d->saslServer->username(), d->origin())); updateCounter ("incoming-client.auth.temporary-auth-failure"); sendPacket (QXmppSaslFailure ("temporary-auth-failure")); disconnectFromHost(); return; } QByteArray challenge; d->saslServer->setPasswordDigest (reply->digest()); QXmppSaslServer::Response result = d->saslServer->respond (reply->property ("__sasl_raw").toByteArray(), challenge); if (result != QXmppSaslServer::Challenge) { warning (QString ("Authentication failed for '%1' from %2").arg (d->saslServer->username(), d->origin())); updateCounter ("incoming-client.auth.not-authorized"); sendPacket (QXmppSaslFailure ("not-authorized")); disconnectFromHost(); return; } // send new challenge sendPacket (QXmppSaslChallenge (challenge)); }
void physx::PhysXIndicator::setIsGpu(bool isGpu) { if(!mPhysXDataPtr) return; updateCounter(-1); mIsGpu = isGpu; updateCounter(1); }
StickersBox::CounterWidget::CounterWidget(QWidget *parent) : TWidget(parent) { setAttribute(Qt::WA_TransparentForMouseEvents); _st.sizeId = Dialogs::Layout::UnreadBadgeInStickersBox; _st.textTop = st::stickersFeaturedBadgeTextTop; _st.size = st::stickersFeaturedBadgeSize; _st.padding = st::stickersFeaturedBadgePadding; _st.font = st::stickersFeaturedBadgeFont; subscribe(Global::RefFeaturedStickerSetsUnreadCountChanged(), [this] { updateCounter(); }); updateCounter(); }
void SearchTrackWidget::selectedEntries( const QModelIndex &/*index*/, int key ) { QStringList entries; switch( key ) { case 0: /* right mouse button */ case Qt::Key_Return: case Qt::Key_Enter: case Qt::Key_Delete: mpResults->removeSelectedItems( &entries ); updateCounter(); if( key != Qt::Key_Delete ) { emit requestAdd( entries ); } break; case Qt::Key_Escape: mpResults->clear(); mpFound->setHidden( true ); mpInput->setFocus(); mpInput->selectAll(); break; default: break; } }
void XmppServerProxy65::slotPairFinished() { QTcpSocketPair *pair = qobject_cast<QTcpSocketPair*>(sender()); if (!pair) return; info(QString("Data transfered for %1 %2").arg(pair->key, QString::number(pair->transfer))); // update totals updateCounter("proxy65.bytes", pair->transfer); updateCounter("proxy65.transfers"); // remove socket pair d->pairs.remove(pair->key); pair->deleteLater(); }
// Scope-based to indicate to NV driver that CPU PhysX is happening physx::PhysXIndicator::PhysXIndicator(bool isGpu) : mPhysXDataPtr(0), mFileHandle(0), mIsGpu(isGpu) { // Get the windows version (we can only create Global\\ namespace objects in XP) /** Operating system Version number ---------------- -------------- Windows 7 6.1 Windows Server 2008 R2 6.1 Windows Server 2008 6.0 Windows Vista 6.0 Windows Server 2003 R2 5.2 Windows Server 2003 5.2 Windows XP 5.1 Windows 2000 5.0 **/ char configName[128]; #if _MSC_VER >= 1800 if (!IsWindowsVistaOrGreater()) #else OSVERSIONINFOEX windowsVersionInfo; windowsVersionInfo.dwOSVersionInfoSize = sizeof (windowsVersionInfo); GetVersionEx((LPOSVERSIONINFO)&windowsVersionInfo); if (windowsVersionInfo.dwMajorVersion < 6) #endif NvPhysXToDrv_Build_SectionNameXP(GetCurrentProcessId(), configName); else NvPhysXToDrv_Build_SectionName(GetCurrentProcessId(), configName); mFileHandle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(NvPhysXToDrv_Data_V1), configName); if (!mFileHandle || mFileHandle == INVALID_HANDLE_VALUE) return; bool alreadyExists = ERROR_ALREADY_EXISTS == GetLastError(); mPhysXDataPtr = (physx::NvPhysXToDrv_Data_V1*)MapViewOfFile(mFileHandle, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(NvPhysXToDrv_Data_V1)); if(!mPhysXDataPtr) return; if (!alreadyExists) { mPhysXDataPtr->bCpuPhysicsPresent = 0; mPhysXDataPtr->bGpuPhysicsPresent = 0; } updateCounter(1); // init header last to prevent race conditions // this must be done because the driver may have already created the shared memory block, // thus alreadyExists may be true, even if PhysX hasn't been initialized NvPhysXToDrv_Header_Init(mPhysXDataPtr->header); }
void TitleWidget::updateAdaptiveLayout() { updateControlsVisibility(); if (Adaptive::OneColumn()) { updateCounter(); } if (_hider) { _hider->setVisible(!Adaptive::OneColumn()); } }
int main() { CYBLE_API_RESULT_T apiResult; uint32 count = 0; uint8 triggerNotification = 0; // Enable global interrupts CyGlobalIntEnable; // Initialize the watchdog timer CySysWdtSetIsrCallback(CY_SYS_WDT_COUNTER0, Watchdog0_cb); // Initialize the BLE device. apiResult = CyBle_Start(StackEventHandler); // Validate BLE stack initialization successed CYASSERT(apiResult == CYBLE_ERROR_OK); for (;;) { // Service all the BLE stack events. // Must be called at least once in a BLE connection interval CyBle_ProcessEvents(); if (deviceConnected) { if (counterCccDescriptor.dirty) { // Update Counter CCCD updateCounterCccDescriptor(); } else if (triggerNotification) { // Send notification if required if (enableCounterNotification) { sendCounterNotification(count); } triggerNotification = 0; } else if (triggerUpdateCounter) { // Update counter value count++; updateCounter(count); triggerNotification = ((count & 0x0000000F) == 0); triggerUpdateCounter = 0; } } // Scan update queue if (rgbDescriptor.dirty) { // Update RGB Descriptor updateRgbDescriptor(); } // Enter to deep sleep mode { CYBLE_LP_MODE_T state; state = CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP); if (state == CYBLE_BLESS_DEEPSLEEP) { CySysPmDeepSleep(); } } } }
//------------------------------------------------------------------------------ void MainWindow::timeout() { QTime current_time = QTime::currentTime(); updateCounter(current_time, s_previousTime); updateClock(current_time); s_previousTime = current_time; }
void PacketCounters::incOutBytes(const int cnt) { if (!runCounters) return; updateCounter(PacketCounters::mOutCurrentSec, PacketCounters::mOutBytesCalc, PacketCounters::mOutBytes); PacketCounters::mOutBytes += cnt; }
tree majorityPlusConsensus(){ tree ret; int sum[numTaxas+5]; memset(sum,0,sizeof(sum)); for(int i=0;i<numTrees;++i){ if(!i){ ret = T[i]; for(int j=0;j<ret.cnt;++j) ret.goodLabel[j] = 1; } else{ updateCounter(ret,T[i]); ret = majorityPlusMerge(T[i],ret); } } for(int i=0;i<ret.cnt;++i) ret.goodLabel[i] = 0; for(int i=0;i<numTrees;++i) updateCounter(ret,T[i]); ret = majContract(ret); return ret; }
void PacketCounters::incInPackets() { if (!runCounters) return; updateCounter(PacketCounters::mInCurrentSec, PacketCounters::mInPacketsCalc, PacketCounters::mInPackets); PacketCounters::mInPackets ++; }
physx::PhysXIndicator::~PhysXIndicator() { if(mPhysXDataPtr) { updateCounter(-1); UnmapViewOfFile(mPhysXDataPtr); } if(mFileHandle && mFileHandle != INVALID_HANDLE_VALUE) CloseHandle(mFileHandle); }
void TitleWidget::updateWideMode() { updateBackButton(); if (!cWideMode()) { updateCounter(); } if (hider) { if (cWideMode()) { hider->show(); } else { hider->hide(); } } }
void TitleWidget::updateAdaptiveLayout() { updateBackButton(); if (Adaptive::OneColumn()) { updateCounter(); } if (hider) { if (Adaptive::OneColumn()) { hider->hide(); } else { hider->show(); } } }
void SmsDialog::gatewayActivated(int index) { QString id = ProviderComboBox->itemData(index).toString(); const SmsGateway &gateway = m_smsGatewayManager->byId(id); MaxLength = gateway.maxLength(); if (0 == MaxLength) MaxLengthSuffixText.clear(); else MaxLengthSuffixText = QString(" / %1").arg(gateway.maxLength()); updateCounter(); }
void QXmppIncomingClient::onPasswordReply() { QXmppPasswordReply *reply = qobject_cast<QXmppPasswordReply *> (sender()); if (!reply) return; reply->deleteLater(); const QString jid = QString ("%1@%2").arg (d->saslServer->username(), d->domain); switch (reply->error()) { case QXmppPasswordReply::NoError: d->jid = jid; info (QString ("Authentication succeeded for '%1' from %2").arg (d->jid, d->origin())); updateCounter ("incoming-client.auth.success"); sendPacket (QXmppSaslSuccess()); handleStart(); break; case QXmppPasswordReply::AuthorizationError: warning (QString ("Authentication failed for '%1' from %2").arg (jid, d->origin())); updateCounter ("incoming-client.auth.not-authorized"); sendPacket (QXmppSaslFailure ("not-authorized")); disconnectFromHost(); break; case QXmppPasswordReply::TemporaryError: warning (QString ("Temporary authentication failure for '%1' from %2").arg (jid, d->origin())); updateCounter ("incoming-client.auth.temporary-auth-failure"); sendPacket (QXmppSaslFailure ("temporary-auth-failure")); disconnectFromHost(); break; } }
/* * Checks if the colck has moved forward (modolo max UINT32) for gInterval, * and updates the couter and the 7-segments device. */ void checkClock() { UINT32 currentClock = clockGetTime(); //check if the clock started another cycle or not if ( //no clock overlap ((currentClock > gLastClockReading) && (currentClock - gLastClockReading >= gInterval)) || //clock overlaps ((gLastClockReading > currentClock) && (currentClock + (MAX_UINT32 - gLastClockReading) >= gInterval)) ) { updateCounter(); gLastClockReading = currentClock; } }
void adc_main(void){ #else void main(void){ #endif JOYSTICK_DIRECTION joystickDirection = CENTRED; INT8 adc_value; UINT8 potVoltage = 0; BOOL updateLCD = TRUE; initAdc(); while( !stopApplication() ){ ADC_ENABLE_CHANNEL(7); ADC_SINGLE_CONVERSION(ADC_REF_AVDD | ADC_8_BIT | ADC_AIN7); ADC_SAMPLE_SINGLE(); while(!ADC_SAMPLE_READY()); ADC_DISABLE_CHANNEL(7); adc_value = ADCH; if (potVoltage != scaleValue(adc_value)){ //potVoltage changed since last sample potVoltage = scaleValue(adc_value); updateLCD = TRUE; } if (joystickDirection != getJoystickDirection()){ //joystickDirection change since last sample joystickDirection = getJoystickDirection(); updateLCD = TRUE; } if (updateLCD){ updateVoltageLCD(potVoltage, adc_value); updateJoystickDirectionLCD(joystickDirection); updateLCD = FALSE; } updateCounter(adc_value); } LED1 = LED3 = LED_OFF; return; }
SearchTrackWidget::SearchTrackWidget( Database *database, QWidget *parent ) : QWidget( parent ) , mpDatabase( database ) , mpParent( parent ) , mpResults( new PlaylistContentWidget( database, false, this ) ) , mpInput( new SearchLineEdit( this ) ) , mpFound( new QLabel( this ) ) { QVBoxLayout *mainLayout = new QVBoxLayout( this ); QHBoxLayout *lineLayout = new QHBoxLayout; mainLayout->setContentsMargins( 1, 1, 1, 1 ); lineLayout->setContentsMargins( 0, 0, 0, 0 ); lineLayout->addWidget( mpInput ); lineLayout->addWidget( mpFound ); mpFound->setHidden( true ); mainLayout->setSpacing( 2 ); mainLayout->addWidget( mpResults ); mainLayout->addLayout( lineLayout ); setLayout( mainLayout ); mpInput->setMouseTracking( true ); connect( mpInput, SIGNAL(returnPressed()), this, SLOT(search()) ); connect( mpResults, SIGNAL(context(QModelIndex,int)), this, SLOT(selectedEntries(QModelIndex,int)) ); connect( mpFound, SIGNAL(customContextMenuRequested(QPoint)), mpInput, SLOT(clear()) ); connect( mpResults, SIGNAL(dataRemoved()), this, SLOT(updateCounter()) ); mpInput->setText( Settings::value( Settings::PartymanSearch ) ); Settings::setValue( Settings::PartymanSearch, QString() ); mpInput->selectAll(); mpInput->setFocus(); }
medSaveModifiedDialog::medSaveModifiedDialog(QWidget *parent) : QDialog(parent), d (new medSaveModifiedDialogPrivate) { QLabel *label = new QLabel(this); label->setText(tr("The following datasets have been created. Do you want to save them ?")); d->saveQuitButton = new QPushButton(tr("Save and Quit"),this); d->cancelButton = new QPushButton(tr("Cancel"),this); d->quitButton = new QPushButton(tr("Quit without saving"),this); d->treeWidget = new QTreeWidget(this); d->treeWidget->setColumnCount(6); d->quitRequested = false; QStringList headers; headers << tr("Select") <<tr("Thumbnail") << tr("Name") << tr("Study") << tr("Series") << tr("File"); d->treeWidget->setHeaderLabels(headers); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addWidget(d->saveQuitButton); hlayout->addWidget(d->cancelButton); hlayout->addWidget(d->quitButton); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(label); layout->addWidget(d->treeWidget); layout->addLayout(hlayout); //TODO a little bit ugly the way medSaveModifiedDialogCheckListItem are parented no ? foreach(medDatabaseNonPersistentItem *item, medDatabaseNonPersistentController::instance()->items()) { if ((item->studyName() != "") && (item->seriesName() != "")) new medSaveModifiedDialogCheckListItem(d->treeWidget->invisibleRootItem(), item->index(), item->name(), item->studyName(), item->seriesName(), item->file(), item->thumb()); } d->treeWidget->resizeColumnToContents(0); connect (d->saveQuitButton, SIGNAL(clicked()), this, SLOT(saveAndQuit())); connect (d->cancelButton,SIGNAL(clicked()), this, SLOT(reject())); connect (d->quitButton,SIGNAL(clicked()), this, SLOT(accept())); connect (medDataManager::instance(), SIGNAL(dataImported(medDataIndex,QUuid)),this, SLOT(updateCounter())); setModal(true); }
bool StopSpam::incomingStanza(int account, const QDomElement& stanza) { if (enabled) { if(stanza.tagName() == "iq") { QDomElement query = stanza.firstChildElement("query"); if(!Unblocked.isEmpty() && !query.isNull() && query.attribute("xmlns") == "jabber:iq:roster") { QStringList Roster = accInfoHost->getRoster(account); QStringList UnblockedList = Unblocked.split("\n"); while(!Roster.isEmpty()) { QString jid = Roster.takeFirst(); UnblockedList.removeOne(jid); } Unblocked = ""; while(!UnblockedList.isEmpty()) { QString jid = UnblockedList.takeFirst(); if(jid != "") { Unblocked += jid + "\n"; } } psiOptions->setPluginOption(constUnblocked, QVariant(Unblocked)); } } QString from = stanza.attribute("from"); QString to = stanza.attribute("to"); QString valF = from.split("/").takeFirst(); QString valT = to.split("/").takeFirst(); if(valF.toLower() == valT.toLower() || valF.toLower() == accInfoHost->getJid(account).toLower()) return false; if(!from.contains("@")) return false; // Нам необходимо сделать эту проверку здесь, // иначе мы рискуем вообще ее не сделать if (stanza.tagName() == "message") { bool findInvite = false; QString invFrom; QDomElement x = stanza.firstChildElement("x"); while(!x.isNull()) { QDomElement invite = x.firstChildElement("invite"); if(!invite.isNull()) { findInvite = true; invFrom = invite.attribute("from"); break; } x = x.nextSiblingElement("x"); } if(findInvite) { // invite to MUC QStringList r = accInfoHost->getRoster(account); if(r.contains(invFrom.split("/").first(), Qt::CaseInsensitive)) return false; else { bool findRule = false; for(int i = 0; i < Jids.size(); i++) { QString jid_ = Jids.at(i); if(jid_.isEmpty()) continue; if(invFrom.contains(jid_, Qt::CaseInsensitive)) { findRule = true; if(!selected[i].toBool()) return false; break; } } if(!findRule && DefaultAct) return false; else { updateCounter(stanza, false); return true; } } } } if(contactInfo->isConference(account, valF) || contactInfo->isPrivate(account, from) || findMucNS(stanza)) { if(UseMuc) return processMuc(account, stanza); else return false; } QStringList Roster = accInfoHost->getRoster(account); if(Roster.isEmpty() || Roster.contains("-1")) return false; if(Roster.contains(valF, Qt::CaseInsensitive)) return false; QStringList UnblockedJids = Unblocked.split("\n"); if(UnblockedJids.contains(valF, Qt::CaseInsensitive)) return false; bool findRule = false; for(int i = 0; i < Jids.size(); i++) { QString jid_ = Jids.at(i); if(jid_.isEmpty()) continue; if(from.contains(jid_, Qt::CaseInsensitive)) { findRule = true; if(!selected[i].toBool()) return false; break; } } if(!findRule && DefaultAct) return false; if (stanza.tagName() == "message") { QString subj = stanza.firstChildElement("subject").text(); QString type = ""; type = stanza.attribute("type"); if(type == "error" && subj == "StopSpam Question") { updateCounter(stanza, false); return true; } if (subj == "AutoReply" || subj == "StopSpam" || subj == "StopSpam Question") return false; if(type == "groupchat" || type == "error") return false; QDomElement captcha = stanza.firstChildElement("captcha"); if(!captcha.isNull() && captcha.attribute("xmlns") == "urn:xmpp:captcha") return false; // CAPTCHA QDomElement Body = stanza.firstChildElement("body"); if(!Body.isNull()) { QString BodyText = Body.text(); if(BodyText == Answer) { Unblocked += valF + "\n"; psiOptions->setPluginOption(constUnblocked, QVariant(Unblocked)); psiOptions->setPluginOption(constLastUnblock, QVariant(QDate::currentDate().toString("yyyyMMdd"))); stanzaHost->sendMessage(account, from, Congratulation, "StopSpam", "chat"); updateCounter(stanza, true); if(LogHistory) logHistory(stanza); return true; } else { int i = BlockedJids.size(); if(findAcc(account, valF, i)) { Blocked &B = BlockedJids[i]; if(B.count < Times) { stanzaHost->sendMessage(account, from, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); if(LogHistory) logHistory(stanza); B.count++; B.LastMes = QDateTime::currentDateTime(); return true; } else { if(QDateTime::currentDateTime().secsTo(B.LastMes) >= -ResetTime*60) { updateCounter(stanza, false); if(LogHistory) logHistory(stanza); return true; } else { B.count = 1; B.LastMes = QDateTime::currentDateTime(); stanzaHost->sendMessage(account, from, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); if(LogHistory) logHistory(stanza); return true; } } } else { Blocked B = { account, valF, 1, QDateTime::currentDateTime() }; BlockedJids << B; stanzaHost->sendMessage(account, from, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); if(LogHistory) logHistory(stanza); return true; } } } updateCounter(stanza, false); return true; } if (stanza.tagName() == "presence") { QString type = stanza.attribute("type"); if(type == "subscribe") { stanzaHost->sendMessage(account, from, Question, "StopSpam Question", "chat"); stanzaHost->sendStanza(account, "<presence type=\"unsubscribed\" to=\"" + valF + "\" />"); updateCounter(stanza, false); if(LogHistory) logHistory(stanza); return true; } else return false; } if (stanza.tagName() == "iq" && stanza.attribute("type") == "set") { QString msg = QString("<iq type=\"error\" id=\"%1\" ").arg(stanza.attribute("id")); if(!from.isEmpty()) msg += QString("to=\"%1\"").arg(from); msg += " />"; stanzaHost->sendStanza(account, msg); updateCounter(stanza, false); return true; } return false; } return false; }
CodeEditor::CodeEditor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); setTabStopWidth(40); SHL = new SyntaxHL(this); //Adding syntax highlighter. //Auto-complete setup: compList << "add" << "addu" << "sub" << "subu" << "and" << "or" << "xor" << "srlv" << "sllv" << "srav" << "slt" << "sltu" << "addi" << "addiu" << "andi" << "ori" << "nori" << "xori" << "srl" << "sll" << "sra" << "slti" << "sltiu" << "beq" << "bne" << "lui" << "sb" << "lb" << "lbu" << "sh" << "lh" << "lhu" << "sw" << "lw" << "lwl" << "lwr" << "swl" << "swr" <<"ll" << "sc" << "jr" << "jalr" << "mfhi" << "mflo" << "mthi" << "mtlo" << "mult" << "multu" << "div" << "divu" << "j" << "jal" << "syscall" << "nop"; //for (int i = 0; i < 32; i++) compList.append(QString("$" + QString::number(i))); compList << "$0" << "$zero" << "$at" << "$v0" << "$v1" <<"$a0" << "$a1" << "$a2" << "$a3" << "$t0" << "$t1" << "$t2" << "$t3" << "$t4" << "$t5" << "$t6" << "$t7" << "$s0" << "$s1" << "$s2" << "$s3" << "$s4" << "$s5" << "$s6" << "$s7" << "$t8" << "$t9" << "$gp" << "$fp" << "$ra" << "$sp"; compList << "blt" << "bgt" << "ble" << "bge" << "bltu" << "bgtu" << "bleu" << "bgeu" << "blti" << "bgti" << "blei" << "bgei" << "bltiu" << "bgtiu" << "bleiu" << "bgeiu" << "beqz" << "bnez" << "bltz" << "bgtz" << "blez" << "bgez" << "li" << "ror" << "rol" << "not" << "neg" << "move" << "abs" << "mul" << "div" << "rem" << "clear" << "subi" << "la" << ".align" << ".ascii" << ".asciiz" << ".byte" << ".double" <<".float" << ".half" << ".space" << ".word"; lCounter = NULL; model = new QStringListModel(compList, this); codeCompleter = new QCompleter(model, this); codeCompleter->setCompletionMode(QCompleter::PopupCompletion); CompleterList *cl = new CompleterList(this); codeCompleter->setPopup(cl); codeCompleter->setCaseSensitivity(Qt::CaseInsensitive); codeCompleter->setWidget(this); QObject::connect(codeCompleter, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString))); QObject::connect(this, SIGNAL(textChanged()), this, SLOT(updateCounter())); QObject::connect(this, SIGNAL(textChanged()), this, SLOT(refreshScroll())); QObject::connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(refreshScroll())); QObject::connect(this, SIGNAL(textChanged()), this, SLOT(completerPop())); QObject::connect(this, SIGNAL(selectionChanged()), this, SLOT(highlightLine())); QObject::connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightLine())); QObject::connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateCounterFormat())); QObject::connect(this, SIGNAL(textChanged()), this, SLOT(updateCounterFormat())); selectionStart = selectionEnd = 0; }
bool StopSpam::processMuc(int account, const QDomElement& stanza) { if(stanza.tagName() == "presence") { QStringList jidList = stanza.attribute("from").split("/"); int i = mucUsers_.size(); if(findMuc(jidList.first(),jidList.last(), i)) { MucUser &mu = mucUsers_[i]; QDomNodeList nodeList = stanza.elementsByTagName("x"); for(int i = nodeList.size(); i> 0;) { QDomNode node = nodeList.at(--i).firstChild(); while(!node.isNull()) { QDomElement item = node.toElement(); if(item.tagName() == "item") { mu.affiliation = item.attribute("affiliation"); mu.role = item.attribute("role"); mu.jid = item.attribute("jid"); break; } node = node.nextSibling(); } } } else { MucUser mu; mu.mucJid = jidList.first(); mu.nick = jidList.last(); QDomNodeList nodeList = stanza.elementsByTagName("x"); for(int i = nodeList.size(); i> 0;) { QDomNode node = nodeList.at(--i).firstChild(); while(!node.isNull()) { QDomElement item = node.toElement(); if(item.tagName() == "item") { mu.affiliation = item.attribute("affiliation"); mu.role = item.attribute("role"); mu.jid = item.attribute("jid"); break; } node = node.nextSibling(); } } mucUsers_ << mu; } } else if(stanza.tagName() == "message" && stanza.attribute("type") == "chat") { QDomElement subj = stanza.firstChildElement("subject"); if (subj.text() == "StopSpam" || subj.text() == "StopSpam Question") return false; QString valF = stanza.attribute("from"); if (contactInfo->isConference(account, valF)) return false; MucUser mu; QStringList jidList = valF.split("/"); int i = mucUsers_.size(); if(findMuc(jidList.first(),jidList.last(), i)) { mu = mucUsers_[i]; } else { mu.affiliation = ""; mu.jid = ""; mu.mucJid = ""; mu.nick = ""; mu.role = ""; } bool find = false; if(mu.affiliation == "owner" && !Owner) find = true; else if( mu.affiliation == "admin" && !Admin) find = true; else if(mu.affiliation == "none" && !None) find = true; else if(mu.affiliation == "member" && !Member) find = true; if(find) return false; if(mu.role == "moderator" && !Moder) find = true; else if(mu.role == "participant" && !Participant) find = true; else if(mu.role == "visitor" && !Visitor) find = true; if(find) return false; QStringList UnblockedJids = Unblocked.split("\n"); if(UnblockedJids.contains(valF, Qt::CaseInsensitive)) return false; for(int i = 0; i < Jids.size(); i++) { QString jid_ = Jids.at(i); if(jid_.isEmpty()) continue; if(mu.jid.contains(jid_, Qt::CaseInsensitive) || mu.nick.contains(jid_, Qt::CaseInsensitive) || mu.mucJid.contains(jid_, Qt::CaseInsensitive)) { if(!selected[i].toBool()) return false; break; } } QDomElement Body = stanza.firstChildElement("body"); if(Body.isNull()) return false; if(BlockAll) { updateCounter(stanza, false); if(EnableBlockAllMes) stanzaHost->sendMessage(account, valF, BlockAllMes, "StopSpam", "chat"); return true; } QString BodyText = Body.text(); if(BodyText == Answer) { Unblocked += valF + "\n"; QVariant vUnblocked(Unblocked); psiOptions->setPluginOption(constUnblocked, vUnblocked); psiOptions->setPluginOption(constLastUnblock, QVariant(QDate::currentDate().toString("yyyyMMdd"))); stanzaHost->sendMessage(account, valF, Congratulation, "StopSpam", "chat"); updateCounter(stanza, true); return true; } else { int i = BlockedJids.size(); if(findAcc(account, valF, i)) { Blocked &B = BlockedJids[i]; if(B.count < Times) { stanzaHost->sendMessage(account, valF, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); B.count++; B.LastMes = QDateTime::currentDateTime(); return true; } else { if(QDateTime::currentDateTime().secsTo(B.LastMes) >= -ResetTime*60) { updateCounter(stanza, false); return true; } else { B.count = 1; B.LastMes = QDateTime::currentDateTime(); stanzaHost->sendMessage(account, valF, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); return true; } } } else { Blocked B = { account, valF, 1, QDateTime::currentDateTime() }; BlockedJids << B; stanzaHost->sendMessage(account, valF, Question, "StopSpam Question", "chat"); updateCounter(stanza, false); return true; } } } return false; }
void QXmppIncomingClient::handleStanza (const QDomElement &nodeRecv) { const QString ns = nodeRecv.namespaceURI(); if (d->idleTimer->interval()) d->idleTimer->start(); if (ns == ns_tls && nodeRecv.tagName() == QLatin1String ("starttls")) { sendData ("<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"); socket()->flush(); socket()->startServerEncryption(); return; } else if (ns == ns_sasl) { if (!d->passwordChecker) { warning ("Cannot perform authentication, no password checker"); sendPacket (QXmppSaslFailure ("temporary-auth-failure")); disconnectFromHost(); return; } if (nodeRecv.tagName() == QLatin1String ("auth")) { QXmppSaslAuth auth; auth.parse (nodeRecv); d->saslServer = QXmppSaslServer::create (auth.mechanism(), this); if (!d->saslServer) { sendPacket (QXmppSaslFailure ("invalid-mechanism")); disconnectFromHost(); return; } d->saslServer->setRealm (d->domain.toUtf8()); QByteArray challenge; QXmppSaslServer::Response result = d->saslServer->respond (auth.value(), challenge); if (result == QXmppSaslServer::InputNeeded) { // check credentials d->checkCredentials (auth.value()); } else if (result == QXmppSaslServer::Challenge) sendPacket (QXmppSaslChallenge (challenge)); else { // FIXME: what condition? sendPacket (QXmppSaslFailure()); disconnectFromHost(); return; } } else if (nodeRecv.tagName() == QLatin1String ("response")) { QXmppSaslResponse response; response.parse (nodeRecv); if (!d->saslServer) { warning ("SASL response received, but no mechanism selected"); sendPacket (QXmppSaslFailure()); disconnectFromHost(); return; } QByteArray challenge; QXmppSaslServer::Response result = d->saslServer->respond (response.value(), challenge); if (result == QXmppSaslServer::InputNeeded) { // check credentials d->checkCredentials (response.value()); } else if (result == QXmppSaslServer::Succeeded) { // authentication succeeded d->jid = QString ("%1@%2").arg (d->saslServer->username(), d->domain); info (QString ("Authentication succeeded for '%1' from %2").arg (d->jid, d->origin())); updateCounter ("incoming-client.auth.success"); sendPacket (QXmppSaslSuccess()); handleStart(); } else { // FIXME: what condition? sendPacket (QXmppSaslFailure()); disconnectFromHost(); } } } else if (ns == ns_client) { if (nodeRecv.tagName() == QLatin1String ("iq")) { const QString type = nodeRecv.attribute ("type"); if (QXmppBindIq::isBindIq (nodeRecv) && type == QLatin1String ("set")) { QXmppBindIq bindSet; bindSet.parse (nodeRecv); d->resource = bindSet.resource().trimmed(); if (d->resource.isEmpty()) d->resource = QXmppUtils::generateStanzaHash(); d->jid = QString ("%1/%2").arg (QXmppUtils::jidToBareJid (d->jid), d->resource); QXmppBindIq bindResult; bindResult.setType (QXmppIq::Result); bindResult.setId (bindSet.id()); bindResult.setJid (d->jid); sendPacket (bindResult); // bound emit connected(); return; } else if (QXmppSessionIq::isSessionIq (nodeRecv) && type == QLatin1String ("set")) { QXmppSessionIq sessionSet; sessionSet.parse (nodeRecv); QXmppIq sessionResult; sessionResult.setType (QXmppIq::Result); sessionResult.setId (sessionSet.id()); sessionResult.setTo (d->jid); sendPacket (sessionResult); return; } } // check the sender is legitimate const QString from = nodeRecv.attribute ("from"); if (!from.isEmpty() && from != d->jid && from != QXmppUtils::jidToBareJid (d->jid)) { warning (QString ("Received a stanza from unexpected JID %1").arg (from)); return; } // process unhandled stanzas if (nodeRecv.tagName() == QLatin1String ("iq") || nodeRecv.tagName() == QLatin1String ("message") || nodeRecv.tagName() == QLatin1String ("presence")) { QDomElement nodeFull (nodeRecv); // if the sender is empty, set it to the appropriate JID if (nodeFull.attribute ("from").isEmpty()) { if (nodeFull.tagName() == QLatin1String ("presence") && (nodeFull.attribute ("type") == QLatin1String ("subscribe") || nodeFull.attribute ("type") == QLatin1String ("subscribed"))) nodeFull.setAttribute ("from", QXmppUtils::jidToBareJid (d->jid)); else nodeFull.setAttribute ("from", d->jid); } // if the recipient is empty, set it to the local domain if (nodeFull.attribute ("to").isEmpty()) nodeFull.setAttribute ("to", d->domain); // emit stanza for processing by server emit elementReceived (nodeFull); } } }
void OukBoard::vMakeMove(const Move& move, BoardTransition* transition) { MakrukBoard::vMakeMove(move, transition); updateCounter(move, +1); }
int main(int argc, char **argv) { int threadsLimit = 0; int c; while ((c = getopt (argc, argv, "n:t")) != -1) { switch (c) { case 'n': threadsLimit = atoi(optarg); break; case 't': benchmark = true; break; default: ; } } if (threadsLimit) { omp_set_dynamic(0); omp_set_num_threads(threadsLimit); } clock_t start; start = clock(); bool *locks = (bool *)malloc((SIZEX + 2) * sizeof(bool)); for (int i = 0; i < SIZEX + 2; i++) locks[i] = false; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); initRandom(0, rank); Entity **matrix_a = createMatrix(SIZEX + 2, SIZEY + 2); Entity **matrix_b = createMatrix(SIZEX + 2, SIZEY + 2); initMatrix(matrix_a, SIZEX, SIZEY); MPI_Type_contiguous(sizeof(Entity), MPI_BYTE, &cell_t); MPI_Type_commit(&cell_t); MPI_Type_vector(SIZEX + 2, 1, 1, cell_t, &row_t); MPI_Type_commit(&row_t); MPI_Type_contiguous(sizeof(Counter), MPI_BYTE, &counter_t); MPI_Type_commit(&counter_t); Entity * northBuffer = (Entity *) malloc((SIZEX + 2) * sizeof(Entity)); Entity * southBuffer = (Entity *) malloc((SIZEX + 2) * sizeof(Entity)); if (!benchmark) { // update local counter and sync updateCounter(matrix_a); syncCounter(); printHeader(rank); printCSV(0, rank); } for (int n = 0; n < STEPS; n++) { // set adjacent borders if (rank == NORTH) { MPI_Recv(northBuffer, 1, row_t, SOUTH, TAG, MPI_COMM_WORLD, &status); setBorder(northBuffer, matrix_a, SIZEY+1); setBuffer(matrix_a, northBuffer, SIZEY); MPI_Send(northBuffer, 1, row_t, SOUTH, TAG, MPI_COMM_WORLD); } if (rank == SOUTH) { setBuffer(matrix_a, southBuffer, 1); MPI_Send(southBuffer, 1, row_t, NORTH, TAG, MPI_COMM_WORLD); MPI_Recv(southBuffer, 1, row_t, NORTH, TAG, MPI_COMM_WORLD, &status); setBorder(southBuffer, matrix_a, 0); } #pragma omp parallel for default(none) shared(matrix_a, matrix_b, n, locks) schedule(static, SIZEX/omp_get_max_threads()) for (int i = 1; i <= SIZEX; i++) { lock(i, locks); #pragma omp parallel for for (int j = 1; j <= SIZEY; j++) process(matrix_a, matrix_b, i, j); unlock(i, locks); } // merge adjacent border if (rank == NORTH) { MPI_Recv(northBuffer, 1, row_t, SOUTH, TAG, MPI_COMM_WORLD, &status); mergeGhost(northBuffer, matrix_b, SIZEY); setGhost(matrix_b, northBuffer, SIZEY+1); MPI_Send(northBuffer, 1, row_t, SOUTH, TAG, MPI_COMM_WORLD); } if (rank == SOUTH) { setGhost(matrix_b, southBuffer, 0); MPI_Send(southBuffer, 1, row_t, NORTH, TAG, MPI_COMM_WORLD); MPI_Recv(southBuffer, 1, row_t, NORTH, TAG, MPI_COMM_WORLD, &status); mergeGhost(southBuffer, matrix_b, 1); } // clear original adjacent border in matrix_a for (int i = 0; i < SIZEX + 2; i++) clearEntity(&matrix_a[i][rank == NORTH ? SIZEY + 1 : 0]); //some times it can not move back, then stay in the border transferInBorder(matrix_a, matrix_b); moveBackInBorder(matrix_b); // swap matrixes Entity **matrix_t = matrix_a; matrix_a = matrix_b; matrix_b = matrix_t; if (!benchmark) { updateCounter(matrix_a); syncCounter(); printCSV(n+1, rank); } } if (benchmark) printf("Thread: %d, Time: %f sec\n", omp_get_max_threads(), (double)(clock() - start) / CLOCKS_PER_SEC); destroyMatrix(matrix_a); destroyMatrix(matrix_b); free(northBuffer); free(southBuffer); MPI_Finalize(); return 0; }
void OukBoard::vUndoMove(const Move& move) { updateCounter(move, -1); MakrukBoard::vUndoMove(move); }
void SmsDialog::createGui() { QVBoxLayout *mainLayout = new QVBoxLayout(this); QWidget *formWidget = new QWidget(this); mainLayout->addWidget(formWidget); QFormLayout *formLayout = new QFormLayout(formWidget); QWidget *recipientWidget = new QWidget(this); QHBoxLayout *recipientLayout = new QHBoxLayout(recipientWidget); recipientLayout->setContentsMargins(0, 0, 0, 0); RecipientEdit = new QLineEdit(this); RecipientEdit->setMinimumWidth(140); connect(RecipientEdit, SIGNAL(textChanged(QString)), this, SLOT(recipientNumberChanged(QString))); connect(RecipientEdit, SIGNAL(returnPressed()), this, SLOT(editReturnPressed())); connect(RecipientEdit, SIGNAL(textChanged(QString)), this, SLOT(validate())); recipientLayout->addWidget(RecipientEdit); RecipientComboBox = m_pluginInjectedFactory->makeInjected<SelectTalkableComboBox>(this); RecipientComboBox->addBeforeAction(new QAction(tr(" - Select recipient - "), RecipientComboBox)); auto buddyListModel = m_pluginInjectedFactory->makeInjected<BuddyListModel>(RecipientComboBox); m_pluginInjectedFactory->makeInjected<BuddyManagerAdapter>(buddyListModel); RecipientComboBox->setBaseModel(buddyListModel); RecipientComboBox->addFilter(new MobileTalkableFilter(RecipientComboBox)); connect(RecipientComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(recipientBuddyChanged())); recipientLayout->addWidget(RecipientComboBox); formLayout->addRow(tr("Recipient") + ':', recipientWidget); ProviderComboBox = new QComboBox(this); ProviderComboBox->addItem(tr("Select automatically"), QString()); for (auto gateway : m_smsGatewayManager->items()) ProviderComboBox->addItem(gateway.name(), gateway.id()); connect(ProviderComboBox, SIGNAL(activated(int)), this, SLOT(gatewayActivated(int))); formLayout->addRow(tr("GSM provider") + ':', ProviderComboBox); ContentEdit = new QTextEdit(this); ContentEdit->setAcceptRichText(false); ContentEdit->setLineWrapMode(QTextEdit::WidgetWidth); ContentEdit->setTabChangesFocus(true); connect(ContentEdit, SIGNAL(textChanged()), this, SLOT(updateCounter())); formLayout->addRow(tr("Content") + ':', ContentEdit); LengthLabel = new QLabel("0", this); formLayout->addRow(0, LengthLabel); SignatureEdit = new QLineEdit(m_configuration->deprecatedApi()->readEntry("SMS", "SmsNick"), this); connect(SignatureEdit, SIGNAL(returnPressed()), this, SLOT(editReturnPressed())); formLayout->addRow(tr("Signature") + ':', SignatureEdit); SaveInHistoryCheckBox = new QCheckBox(tr("Save SMS in history"), this); SaveInHistoryCheckBox->setChecked(true); formLayout->addRow(0, SaveInHistoryCheckBox); QDialogButtonBox *buttons = new QDialogButtonBox(this); mainLayout->addSpacing(16); mainLayout->addWidget(buttons); SendButton = new QPushButton(this); SendButton->setIcon(m_iconsManager->iconByPath(KaduIcon("go-next"))); SendButton->setText(tr("&Send")); SendButton->setDefault(true); SendButton->setMaximumWidth(200); connect(SendButton, SIGNAL(clicked()), this, SLOT(editReturnPressed())); QPushButton *closeButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Close")); connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(close())); QPushButton *clearButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogResetButton), tr("Clear")); connect(clearButton, SIGNAL(clicked(bool)), this, SLOT(clear())); buttons->addButton(SendButton, QDialogButtonBox::ApplyRole); buttons->addButton(closeButton, QDialogButtonBox::RejectRole); buttons->addButton(clearButton, QDialogButtonBox::DestructiveRole); resize(400, 250); }