示例#1
0
// After loading an ABC and inserting scripts into the verify queue,
// process the work queues until they are empty.
void BaseExecMgr::verifyEarly(Toplevel* toplevel, AbcEnv* abc_env)
{
    GCList<MethodInfo> verifyQueue2(core->GetGC(), kListInitialCapacity);
    int verified;
    do {
        verified = 0;
        while (!verifyTraitsQueue.isEmpty()) {
            Traits* t = verifyTraitsQueue.removeFirst();
            t->resolveSignatures(toplevel);
            TraitsBindingsp td = t->getTraitsBindings();
            enqFunction(t->init);
            for (int i=0, n=td->methodCount; i < n; i++)
                enqFunction(td->getMethod(i));
        }
        while (!verifyFunctionQueue.isEmpty()) {
            MethodInfo* f = verifyFunctionQueue.removeLast();
            if (!isVerified(f)) {
                if (f->declaringTraits()->init != f && f->declaringScope() == NULL) {
                    verifyQueue2.add(f);
                    continue;
                }
                verified++;
                //console << "pre verify " << f << "\n";
                verifyMethod(f, toplevel, abc_env);
                setVerified(f);
                if (config.verifyonly)
                    f->_invoker = verifyOnlyInvoker;
            }
        }
        while (!verifyQueue2.isEmpty())
            verifyFunctionQueue.add(verifyQueue2.removeLast());
    } while (verified > 0);
}
示例#2
0
// Add a function to the verify queue if not already queued or verified.
void BaseExecMgr::enqFunction(MethodInfo* f)
{
    if (f != NULL && !isVerified(f) && !isVerifyPending(f)) {
        setVerifyPending(f);
        verifyFunctionQueue.add(f);
    }
}
示例#3
0
bool ZDvidSynapse::isProtocolVerified(const ZDvidTarget &target) const
{
  if (!isVerified()) {
    return false;
  }

  bool v = true;

  if (getKind() == EKind::KIND_PRE_SYN) {
    std::vector<ZIntPoint> psdArray = getPartners();
    if (!psdArray.empty()) {
      ZDvidReader reader;
      if (reader.open(target)) {
        for (std::vector<ZIntPoint>::const_iterator iter = psdArray.begin();
             iter != psdArray.end(); ++iter) {
          const ZIntPoint &pt = *iter;
          ZDvidSynapse synapse =
              reader.readSynapse(pt, flyem::EDvidAnnotationLoadMode::NO_PARTNER);
          if (!synapse.isVerified()) {
            v = false;
            break;
          }
        }
      }
    }
  } else {
    v = false;
  }

  return v;
}
示例#4
0
void
mail (struct client *client, struct email *msg)
{
// VERIFICATION HOOK
  int verificationHook_isVerified = isVerified (msg);
// VERIFICATION HOOK END
  original (client, msg);
}
bool OtrInternal::isVerified(const QString& account,
                             const QString& contact)
{
    ConnContext* context;
    context = otrl_context_find(m_userstate, contact.toUtf8().constData(),
                                account.toUtf8().constData(),
                                OTR_PROTOCOL_STRING,
#if (OTRL_VERSION_MAJOR >= 4)
                                OTRL_INSTAG_BEST,
#endif
                                false, NULL, NULL, NULL);

    return isVerified(context);
}
bool EncryptedCertificate::checkSignature(const RawData& signedData, const RawData& signature) const{
	if(!isVerified()) return false;
	QByteArray srdash = decryptedCertificate->rsaPublicKey.perform(signature);
	QByteArray hdash = srdash.mid(107, 20);
	if(!checkSha1(signedData, hdash)) return false;
	const unsigned char der[] = { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b,
			0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 };
	for(int j = 0; j < 15; ++j)
		if((unsigned char)srdash.at(92 + j) != der[j]) return false;
	for(int j = 1; j < 91; ++j)
		if((unsigned char)srdash.at(j) != 0xff) return false;
	//not checking the first two, l207 p.251 says 0x00, 0x01,
	//but the files actually contain 0x01, 0xff
	return true;
}
示例#7
0
void ZDvidSynapse::display(ZPainter &painter, int slice, EDisplayStyle option,
                           neutube::EAxis sliceAxis) const
{
  bool visible = true;
  int z = painter.getZ(slice);

  if (slice < 0) {
    visible = isProjectionVisible();
  } else {
    visible = isSliceVisible(z, sliceAxis);
  }

  double radius = getRadius(z, sliceAxis);

  ZIntPoint center = m_position;
  center.shiftSliceAxis(sliceAxis);

  bool isFocused = (z == center.getZ());


  if (visible) {
    QPen pen;

    QColor color = getColor();

    double alpha = 1.0;
    if (option == SKELETON) {
      alpha = 0.1;
    }

    if (!isFocused) {
      alpha *= radius / m_radius;
      alpha *= alpha * 0.5;
      alpha += 0.1;  
    }
    color.setAlphaF(alpha * color.alphaF());

    pen.setColor(color);

    painter.setPen(pen);

    painter.setBrush(Qt::NoBrush);
    if (isFocused) {
      int x = center.getX();
      int y = center.getY();
      painter.drawLine(QPointF(x - 1, y), QPointF(x + 1, y));
      painter.drawLine(QPointF(x, y - 1), QPointF(x, y + 1));

      if (getStatus() == STATUS_DUPLICATED) {
        painter.drawEllipse(
              QPointF(center.getX(), center.getY()), 1, 1);
      }
    }
    if (radius > 0.0) {
      double oldWidth = pen.widthF();
      QColor oldColor = pen.color();
      if (getKind() == EKind::KIND_POST_SYN) {
        if (option != SKELETON) {
          pen.setWidthF(oldWidth + 1.0);
        }
        if (isSelected()) {
          pen.setColor(QColor(255, 0, 255, oldColor.alpha()));
        }
      } else {
        if (isSelected()) {
          pen.setWidthF(pen.widthF() + 1.0);
        }
      }

      painter.setPen(pen);
      painter.drawEllipse(QPointF(center.getX(), center.getY()),
                          radius, radius);
      pen.setWidthF(oldWidth);
      pen.setColor(oldColor);
    }
//    QString decorationText;

    if (isVerified()) {
      //        decorationText = "U";
      color.setRgb(0, 0, 0);

      if (isSelected()) {
        if (getKind() == EKind::KIND_PRE_SYN) {
          color.setRgb(0, 255, 0);
          size_t index = 0;
          for (std::vector<bool>::const_iterator iter = m_isPartnerVerified.begin();
               iter != m_isPartnerVerified.end(); ++iter, ++index) {
            bool verified = *iter;
            if (m_partnerKind[index] == EKind::KIND_POST_SYN) {
              if (!verified) {
                color.setRgb(0, 0, 0);
                break;
              }
            }
          }
        }
      }

      color.setAlphaF(alpha);
      pen.setColor(color);
      pen.setWidthF(pen.widthF() + 0.5);
      painter.setPen(pen);
      double margin = 0.5;
      painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
                       QPointF(center.getX() + radius - margin, center.getY()));
      painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
                       QPointF(center.getX() - radius + margin, center.getY()));
    }


    double conf  = getConfidence();
    if (conf < 1.0) {
//      double lineWidth = radius * conf * 0.5 + 1.0;
      double lineWidth = radius * 0.5;
      double red = 1.0 - conf;
      double green = conf;
      QColor color;
      color.setRedF(red);
      if (getKind() == ZDvidAnnotation::EKind::KIND_POST_SYN) {
        color.setBlueF(green);
      } else {
        color.setGreenF(green);
      }
      color.setAlphaF(alpha);
      painter.setPen(color);
      double x = center.getX();
      double y = center.getY();
      /*
      painter.drawLine(QPointF(x - lineWidth, y),
                       QPointF(x + lineWidth, y));
                       */
      int startAngle = 0;
      int spanAngle = iround((1.0 - conf) * 180) * 16;
      painter.drawArc(QRectF(QPointF(x - lineWidth, y - lineWidth),
                             QPointF(x + lineWidth, y + lineWidth)),
                      startAngle, spanAngle);
//      painter.drawEllipse(QPointF(x, y), lineWidth, lineWidth);

//      decorationText += QString(".%1").arg(iround(conf * 10.0));
    }

#if 0
    int height = iround(getRadius() * 1.5);
    int width = decorationText.size() * height;

    if (decorationText !=   m_textDecoration.text()) {
      m_textDecoration.setText(decorationText);
      m_textDecoration.setTextWidth(width);
    }

    if (!decorationText.isEmpty()) {
      QFont font;
      font.setPixelSize(height);
      font.setWeight(QFont::Light);
      font.setStyleStrategy(QFont::PreferMatch);
      painter.setFont(font);

      QColor oldColor = painter.getPen().color();
      QColor color = QColor(0, 0, 0);
      color.setAlphaF(alpha);
      QPen pen = painter.getPen();
      pen.setColor(color);
      painter.setPen(pen);
      painter.drawStaticText(center.getX() - height / 2, center.getY(),
                             m_textDecoration);
//      painter.drawText(center.getX() - height / 2, center.getY(), width, height,
//                       Qt::AlignLeft, decorationText);
      painter.setPen(oldColor);
    }
#endif
  }


  QPen pen;
  pen.setCosmetic(m_usingCosmeticPen);

  bool drawingBoundBox = false;
  bool drawingArrow = false;
  if (isSelected()) {
    if (visible) {
      drawingBoundBox = true;
    } else {
      drawingArrow = true;
    }

    QColor color;
    color.setRgb(255, 255, 0, 255);
    pen.setColor(color);
    pen.setCosmetic(true);
  } else if (hasVisualEffect(neutube::display::Sphere::VE_BOUND_BOX)) {
    drawingBoundBox = true;
    pen.setStyle(Qt::SolidLine);
    pen.setCosmetic(m_usingCosmeticPen);
  }

  if (drawingBoundBox) {
    QRectF rect;
    double halfSize = m_radius;
    if (m_usingCosmeticPen) {
      halfSize += 0.5;
    }
    rect.setLeft(center.getX() - halfSize);
    rect.setTop(center.getY() - halfSize);
    rect.setWidth(halfSize * 2);
    rect.setHeight(halfSize * 2);

    painter.setBrush(Qt::NoBrush);
    pen.setWidthF(pen.widthF() * 0.5);
    if (visible) {
      pen.setStyle(Qt::SolidLine);
    } else {
      pen.setStyle(Qt::DotLine);
    }
    painter.setPen(pen);
    painter.drawRect(rect);
  }

  if (drawingArrow) {
    painter.setPen(pen);
    QRectF rect(center.getX() - m_radius, center.getY() - m_radius,
                m_radius + m_radius, m_radius + m_radius);

//    pen.setStyle(Qt::SolidLine);
//    pen.setColor(GetArrowColor(isVerified()));
//    painter.setPen(pen);
    QPointF ptArray[4];
    //      double s = 5.0;
    if (z > center.getZ()) {
      ZFlyEmMisc::MakeTriangle(rect, ptArray, neutube::ECardinalDirection::NORTH);
      /*
        pt[0] = QPointF(rect.center().x() - rect.width() / s,
                        rect.top() + rect.height() / s);
        pt[1] = QPointF(rect.center().x(),
                        rect.top() - rect.height() / s);
        pt[2] = QPointF(rect.center().x() + rect.width() / s,
                        rect.top() + rect.height() / s);
*/
    } else {
      ZFlyEmMisc::MakeTriangle(rect, ptArray, neutube::ECardinalDirection::SOUTH);
      /*
        pt[0] = QPointF(rect.center().x() - rect.width() / s,
                        rect.bottom() - rect.height() / s);
        pt[1] = QPointF(rect.center().x(),
                        rect.bottom() + rect.height() / s);
        pt[2] = QPointF(rect.center().x() + rect.width() / s,
                        rect.bottom() - rect.height() / s);
                        */
    }
    painter.drawPolyline(ptArray, 4);
//      painter.drawLine(pt[0], pt[1]);
//      painter.drawLine(pt[1], pt[2]);
//      painter.drawLine(pt[0], pt[2]);
  }

  if (isSelected()) {
    pen.setStyle(Qt::SolidLine);

    size_t index = 0;
    if (m_isPartnerVerified.size() == m_partnerHint.size()) {
      for (std::vector<ZIntPoint>::const_iterator iter = m_partnerHint.begin();
           iter != m_partnerHint.end(); ++iter, ++index) {
        pen.setColor(GetArrowColor(m_isPartnerVerified[index]));
        painter.setPen(pen);

        const ZIntPoint &partner = *iter;
        double len = 0.0;
        if (partner.getZ() < z && getPosition().getZ() < z) {
          len = -1.0;
        } else if (partner.getZ() > z && getPosition().getZ() > z) {
          len = 1.0;
        }

        if (len != 0.0) {
          QPointF pt[3];
          pt[0].setX(partner.getX() - len);
          pt[0].setY(partner.getY() - len);

          pt[1].setX(partner.getX() + len);
          pt[1].setY(partner.getY() - len);

          pt[2].setX(partner.getX());
          pt[2].setY(partner.getY() + len);


          painter.drawLine(pt[0], pt[1]);
          painter.drawLine(pt[1], pt[2]);
          painter.drawLine(pt[0], pt[2]);
        }

        if (m_partnerKind[index] == EKind::KIND_POST_SYN) {
          ZDvidSynapse partnerSynapse;
          partnerSynapse.setKind(EKind::KIND_POST_SYN);
          partnerSynapse.setStatus(m_partnerStatus[index]);
          partnerSynapse.setPosition(partner);
          partnerSynapse.setDefaultColor();
          partnerSynapse.setDefaultRadius();
          painter.save();
          partnerSynapse.display(painter, slice, ZStackObject::NORMAL, sliceAxis);
          painter.restore();
        }
      }
    }

    index = 0;
    for (std::vector<ZIntPoint>::const_iterator iter = m_partnerHint.begin();
         iter != m_partnerHint.end(); ++iter, ++index) {
      ZLineSegmentObject line;
      line.setStartPoint(getPosition());
      line.setEndPoint(*iter);
      if (getKind() == EKind::KIND_PRE_SYN && m_partnerKind[index] == EKind::KIND_PRE_SYN) {
        line.setColor(QColor(0, 255, 255));
        line.setFocusColor(QColor(0, 255, 255));
      } else if (m_partnerKind[index] == EKind::KIND_UNKNOWN) {
        line.setColor(QColor(164, 0, 0));
        line.setFocusColor(QColor(255, 0, 0));
      } else {
        line.setColor(QColor(255, 255, 0));
        line.setFocusColor(QColor(255, 0, 255));
      }

      line.setVisualEffect(neutube::display::Line::VE_LINE_PROJ);
      line.display(painter, slice, option, sliceAxis);

      /*
      ZIntPoint pos = *iter;
      painter.drawLine(getPosition().getX(), getPosition().getY(),
                       pos.getX(), pos.getY());
                       */
    }
  }
}