void TimeSignature::readFromXmlStream(QXmlStreamReader *reader) { int beatCount = 0; int beatUnit = 0; while (reader->readNext()) { if (reader->isStartElement()) { if (reader->name() == "BEATCOUNT") { QString beatCountText = QString().append(reader->readElementText()); beatCount = beatCountText.toInt(); } else if (reader->name() == "BEATUNIT") { QString beatUnitText = QString().append(reader->readElementText()); beatUnit = beatUnitText.toInt(); } else break; } if (reader->isEndElement()) { if (reader->name() == s_xmlTagName || (beatCount != 0 && beatUnit != 0)) break; } if (reader->hasError()) break; } if (beatCount != 0 && beatUnit != 0) { setSignature(beatCount, beatUnit); } }
void calcSignatures(int col) { //generate neighbours for each row in each col int col_neighbours[4400][200]; int exist_neighbours = 0; for (int row = 0; row < 4400; row++) { col_neighbours[row][0] = -2; int index = 0; for (int x = row + 1; x < 4400; x++) { if (isNeighbour(row, x, col) == 1) { col_neighbours[row][index] = x; index += 1; } } if (index < 3) { col_neighbours[row][0] = -2; } else { col_neighbours[row][index] = -2; col_neighbours[row][index + 1] = -2; col_neighbours[row][index + 2] = -2; exist_neighbours = 1; fprintf(log_txt, "Col %d row %d find neighbour number %d\n", col, row, index); } } int index = 0; if (exist_neighbours == 1) { total_col_has_neighbours += 1; for (int row = 0; row < 4400; row++) { if (col_neighbours[row][0] >= 0) { for (int x = 0; col_neighbours[row][x] > 0; x++) { for (int y = x + 1; col_neighbours[row][y] > 0; y++) { for (int z = y + 1; col_neighbours[row][z] > 0; z++) { long signature = getOneSignature(row, col_neighbours[row][x], col_neighbours[row][y], col_neighbours[row][z]); setSignature(col, -1, signature, row, col_neighbours[row][x], col_neighbours[row][y], col_neighbours[row][z]); index += 1; total_block_number += 1; } } } } } printf("Col %d has blocks %d\n", col, index); fprintf(log_txt, "Col %d has blocks %d\n", col, index); } signature_number[col] = index; }
void DigestSha256Signature::set(const struct ndn_Signature& signatureStruct) { // The caller should already have checked the type, but check again. if (signatureStruct.type != ndn_SignatureType_DigestSha256Signature) throw runtime_error("signatureStruct is not the expected type DigestSha256Signature"); setSignature(Blob(signatureStruct.signature)); }
void Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct) { digestAlgorithm_ = Blob(signatureStruct.digestAlgorithm); witness_ = Blob(signatureStruct.witness); setSignature(Blob(signatureStruct.signature)); publisherPublicKeyDigest_.get().set(signatureStruct.publisherPublicKeyDigest); keyLocator_.get().set(signatureStruct.keyLocator); }
void DigestSha256Signature::set(const SignatureLite& signatureLite) { // The caller should already have checked the type, but check again. if (signatureLite.getType() != ndn_SignatureType_DigestSha256Signature) throw runtime_error("signatureLite is not the expected type DigestSha256Signature"); setSignature(Blob(signatureLite.getSignature())); }
char * gdbMemoryDump::setConfigWithSignature(char * byte_ptr) { char * data_ptr = byte_ptr; data_ptr = setSignature(data_ptr); data_ptr = setPhasesPerRevolution(data_ptr); data_ptr = setArmHomePosition(data_ptr); data_ptr = setArmClockwiseExtent(data_ptr); data_ptr = setArmAntiClockwiseExtent(data_ptr); printConfigWithSignature(); return data_ptr; }
void Sha256WithEcdsaSignature::set(const struct ndn_Signature& signatureStruct) { // The caller should already have checked the type, but check again. if (signatureStruct.type != ndn_SignatureType_Sha256WithEcdsaSignature) throw runtime_error("signatureStruct is not the expected type Sha256WithEcdsaSignature"); setSignature(Blob(signatureStruct.signature)); keyLocator_.get().set(signatureStruct.keyLocator); }
static shared_ptr<Data> makeData(const Name& name) { auto data = make_shared<Data>(name); ndn::SignatureSha256WithRsa fakeSignature; fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue)); data->setSignature(fakeSignature); data->wireEncode(); return data; }
void SenderIdentity::setUseDefaultSignature(const bool shouldUse) { if (shouldUse == m_useDefaultSignature) { return; } if (shouldUse) { setSignature(getDefaultSignature()); } m_useDefaultSignature = shouldUse; emit dataChanged(); }
void Sha256WithEcdsaSignature::set(const SignatureLite& signatureLite) { // The caller should already have checked the type, but check again. if (signatureLite.getType() != ndn_SignatureType_Sha256WithEcdsaSignature) throw runtime_error("signatureLite is not the expected type Sha256WithEcdsaSignature"); setSignature(Blob(signatureLite.getSignature())); keyLocator_.get().set(signatureLite.getKeyLocator()); validityPeriod_.get().set(signatureLite.getValidityPeriod()); }
RandomInt::RandomInt(std::string ns) : Function("RandomInt", ns) { std::vector<ScribbleCore::TypeReference> refs; refs.push_back( ScribbleCore::makeTypeReference( ScribbleCore::getTypeManager().getType(ScribbleCore::Int))); ScribbleCore::TypeReference returnType = ScribbleCore::makeTypeReference( ScribbleCore::getTypeManager().getType(ScribbleCore::Int)); setSignature(ScribbleCore::FunctionSignature(refs, returnType)); }
void OAuthParameters::sign() { QStringList baseItems; baseItems.append(HttpMethod); baseItems.append(Url.toLocal8Bit().toPercentEncoding()); baseItems.append(toSignatureBase()); QByteArray key; key += Consumer.consumerSecret(); key += '&'; key += Token.tokenSecret(); QCA::MessageAuthenticationCode hmac("hmac(sha1)", QCA::SymmetricKey(key)); QCA::SecureArray array(baseItems.join("&").toLocal8Bit()); QByteArray digest = hmac.process(array).toByteArray().toBase64(); setSignature(digest); }
bool ButtonMachine::handleSignature() { uint32_t bt; bt = button(); if (m_ledPipe) // if ledpipe, grab frame, but don't flush { cam_getFrameChirpFlags(CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT, g_chirpUsb, 0); ledPipe(); } else if (m_goto!=0) // else grab frame and flush cam_getFrameChirpFlags(CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT, g_chirpUsb); switch(m_goto) { case 0: // wait for button press if (bt) { setTimer(&m_timer); led_setMaxCurrent(g_ledBrightness); // restore default brightness m_goto = 1; led_set(0); } break; case 1: // wait for button timeout if (!bt) m_goto = 0; else if (getTimer(m_timer)>BT_INITIAL_BUTTON_TIMEOUT) { if (cam_getAWB()) m_index = 1; else m_index = 0; setTimer(&m_timer); setLED(); m_goto = 2; } break; case 2: // wait and increment index if (!bt) { flashLED(3); setTimer(&m_timer); if (m_index==0) cam_setAWB(1); else m_ledPipe = true; m_goto = 3; } else if (getTimer(m_timer)>BT_INDEX_CYCLE_TIMEOUT) { setTimer(&m_timer); m_index++; if (m_index==CL_NUM_SIGNATURES+1) m_index = 0; setLED(); } break; case 3: // wait for button down if (bt) { setTimer(&m_timer); m_goto = 4; } else if (getTimer(m_timer)>BT_LIGHTPIPE_TIMEOUT) // abort reset(); break; case 4: // wait for button up if (!bt) { if (m_index==0) { cam_setAWB(0); flashLED(4); } else setSignature(); reset(); // done } else if (getTimer(m_timer)>BT_INITIAL_BUTTON_TIMEOUT) { if (m_index==0) cam_setAWB(0); reset(); m_goto = 5; } break; case 5: // wait for button up only if (!bt) reset(); break; default: reset(); } return m_goto!=0; }
git_signature* GitRepository::signature() { if (!m_signature) { setSignature(); } return m_signature; }
void Signature::setAsciiDetatchedSignature(const QString &signature) { setSignature(signature.toAscii(), AsciiDetached); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { unsigned int sig = 123456; unsigned int port = 54545; std::string addressString = "255.255.255.255"; bool noconfig = false; try { TCLAP::CmdLine cmd("iyptclock", ' ', "0.9"); TCLAP::ValueArg<unsigned int> portArg("p", "port","Port to listen on", false, 54545, "unsigned integer"); TCLAP::ValueArg<unsigned int> sigArg("s", "signature","Signature to use", false, 123456 , "unsigned integer"); TCLAP::ValueArg<std::string> bcastArg("b", "broadcast","Broadcast address to send packets to", false, "255.255.255.255", "ip address"); TCLAP::SwitchArg noconfigArg("n", "noconfig", "disable configuration", false); cmd.add( portArg ); cmd.add( sigArg ); cmd.add( bcastArg ); cmd.add( noconfigArg ); cmd.parse( QApplication::argc(), QApplication::argv() ); port = portArg.getValue(); sig = sigArg.getValue(); addressString = bcastArg.getValue(); noconfig = noconfigArg.getValue(); } catch (TCLAP::ArgException &e) { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; } ui->setupUi(this); connect(ui->idButton, SIGNAL(clicked()), this, SLOT(triggerId())); connect(ui->portButton, SIGNAL(clicked()), this, SLOT(triggerPort())); connect(ui->startstop, SIGNAL(clicked()), this, SLOT(toggleStartPause())); connect(ui->delButton, SIGNAL(clicked()), this, SLOT(triggerDel())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveStages())); ad = new AboutDialog(); connect(ui->actionAbout_IYPTClock, SIGNAL(triggered()), ad, SLOT(exec())); timer = new QTimer(); connect(timer, SIGNAL(timeout()), ui->graphicsView, SLOT(act())); timer->start(30); thc = new ThemeClock(); connect(thc, SIGNAL(timeUpdate(int)), ui->graphicsView, SLOT(setTime(int))); connect(thc, SIGNAL(timeUpdate(int)), this, SLOT(setLcdWidthForTime(int))); connect(thc, SIGNAL(allowedTimeChanged(int)), ui->graphicsView, SLOT(setAllowedTime(int))); connect(thc, SIGNAL(started(int)), ui->graphicsView, SLOT(setTime(int))); connect(thc, SIGNAL(paused(int)), ui->graphicsView, SLOT(setTime(int))); connect(thc, SIGNAL(restarted(int)), ui->graphicsView, SLOT(setTime(int))); connect(thc, SIGNAL(stopped(int)), ui->graphicsView, SLOT(setTime(int))); connect(ui->startstop, SIGNAL(clicked()), thc, SLOT(startorpause())); connect(ui->resetButton, SIGNAL(clicked()), thc, SLOT(reset())); connect(ui->setTimeButton, SIGNAL(clicked()), this, SLOT(setTime())); ui->setTimeComboBox->addItem(tr("last saved time"), QVariant(TIME_SAVED)); ui->setTimeComboBox->addItem(tr("elapsed time"), QVariant(TIME_ELAPSED)); ui->setTimeComboBox->addItem(tr("remaining time"), QVariant(TIME_LEFT)); connect(thc, SIGNAL(timeUpdate(QString)), ui->lcdNumber, SLOT(display(QString))); lc = new ListController(); connect(ui->ffwd, SIGNAL(clicked()), lc, SLOT(forward())); connect(ui->bwd, SIGNAL(clicked()), lc, SLOT(backward())); connect(ui->addButton, SIGNAL(clicked()), lc, SLOT(add())); connect(thc, SIGNAL(started(int)), lc, SLOT(checkAutoStart())); connect(this, SIGNAL(itemShouldBeDeleted(QModelIndex)), lc, SLOT(del(QModelIndex))); connect(lc, SIGNAL(allowedTimeChanged(int)), thc, SLOT(setAllowedTime(int))); connect(lc, SIGNAL(roomClockChanged(bool)), ui->graphicsView, SLOT(setRoomclock(bool))); connect(lc, SIGNAL(resetTime()), thc, SLOT(reset())); connect(lc, SIGNAL(endOfStage()), thc, SLOT(stop())); connect(lc, SIGNAL(stageNameChanged(QString)), ui->stageLabel, SLOT(setText(QString))); connect(lc, SIGNAL(modelChanged(QAbstractTableModel*)), this, SLOT(propagateModel(QAbstractTableModel*))); ui->portBox->setValue(port); ui->idBox->setValue(sig); bs = new BroadcastServer(this, QHostAddress(addressString.c_str()), port, sig); connect(thc, SIGNAL(timeUpdate(int)), bs, SLOT(updateTime(int))); connect(thc, SIGNAL(restarted(int)), bs, SLOT(updateTime(int))); connect(thc, SIGNAL(stopped(int)), bs, SLOT(updateTime(int))); connect(thc, SIGNAL(allowedTimeChanged(int)), bs, SLOT(setAllowedTime(int))); connect(lc, SIGNAL(roomClockChanged(bool)), bs, SLOT(setRoomclock(bool))); connect(lc, SIGNAL(stageNameChanged(QString)), bs, SLOT(setStageName(QString))); connect(this, SIGNAL(newPort(uint)), bs, SLOT(setBroadcastPort(uint))); connect(this, SIGNAL(newID(uint)), bs, SLOT(setSignature(uint))); connect(lc, SIGNAL(overTimeChanged(int)), thc, SLOT(setOverTime(int))); connect(thc, SIGNAL(overtimed(int)), lc, SLOT(handleOvertime(int))); connect(lc, SIGNAL(elapsedTimeChanged(int)), thc, SLOT(setElapsedTime(int))); connect(lc, SIGNAL(elapsedTimeChanged(int)), ui->graphicsView, SLOT(setTime(int))); connect(lc, SIGNAL(elapsedTimeChanged(int)), bs, SLOT(updateTime(int))); connect(lc, SIGNAL(getElapsedOverTime()), thc, SLOT(getElapsedOverTime())); connect(thc, SIGNAL(elapsedOverTime(int)), lc, SLOT(setElapsedOverTime(int))); if (noconfig) { ui->tabWidget->setTabEnabled(1,false); } if (QFile("stages.txt").exists()){ lc->loadListFromFile("stages.txt"); } else if (QFile("/usr/share/iyptclock/stages.txt").exists()){ lc->loadListFromFile("/usr/share/iyptclock/stages.txt"); } else { lc->loadListFromFile(""); } thc->stop(); timer2 = new QTimer(); connect(timer2, SIGNAL(timeout()), this, SLOT(toggleStartPause())); connect(timer2, SIGNAL(timeout()), this, SLOT(toggleTimeSpinBox())); timer2->start(100); savefile = QString("/var/run/iyptclock/autosave_"); savefile += QString::number(sig); as = new AutoSave(this,savefile,this); as->load(); timer3 = new QTimer(); connect(timer3, SIGNAL(timeout()),as,SLOT(save())); timer3->start(1000); }