Beispiel #1
0
void
ImportLoader::Open()
{
  AutoError ae(this, false);
  // Imports should obey to the master documents CSP.
  nsCOMPtr<nsIDocument> master = mImportParent->MasterDocument();
  nsIPrincipal* principal = Principal();

  int16_t shouldLoad = nsIContentPolicy::ACCEPT;
  nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SUBDOCUMENT,
                                          mURI,
                                          principal,
                                          mImportParent,
                                          NS_LITERAL_CSTRING("text/html"),
                                          /* extra = */ nullptr,
                                          &shouldLoad,
                                          nsContentUtils::GetContentPolicy(),
                                          nsContentUtils::GetSecurityManager());
  if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
    NS_WARN_IF_FALSE(NS_CP_ACCEPTED(shouldLoad), "ImportLoader rejected by CSP");
    return;
  }

  nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
  rv = secMan->CheckLoadURIWithPrincipal(principal, mURI,
                                         nsIScriptSecurityManager::STANDARD);
  NS_ENSURE_SUCCESS_VOID(rv);

  nsCOMPtr<nsILoadGroup> loadGroup = master->GetDocumentLoadGroup();
  nsCOMPtr<nsIChannel> channel;
  rv = NS_NewChannel(getter_AddRefs(channel),
                     mURI,
                     mImportParent,
                     nsILoadInfo::SEC_NORMAL,
                     nsIContentPolicy::TYPE_SUBDOCUMENT,
                     loadGroup,
                     nullptr,  // aCallbacks
                     nsIRequest::LOAD_BACKGROUND);

  NS_ENSURE_SUCCESS_VOID(rv);

  // Init CORSListenerProxy and omit credentials.
  nsRefPtr<nsCORSListenerProxy> corsListener =
    new nsCORSListenerProxy(this, principal,
                            /* aWithCredentials */ false);
  rv = corsListener->Init(channel, true);
  NS_ENSURE_SUCCESS_VOID(rv);

  rv = channel->AsyncOpen(corsListener, nullptr);
  NS_ENSURE_SUCCESS_VOID(rv);

  BlockScripts();
  ae.Pass();
}
const URLInfo&
DocInfo::PrincipalURL() const
{
  if (!URL().InheritsPrincipal() ||
      !(Principal() && Principal()->GetIsCodebasePrincipal())) {
    return URL();
  }

  if (mPrincipalURL.isNothing()) {
    nsIPrincipal* prin = Principal();
    nsCOMPtr<nsIURI> uri;
    if (NS_SUCCEEDED(prin->GetURI(getter_AddRefs(uri)))) {
      MOZ_DIAGNOSTIC_ASSERT(uri);
      mPrincipalURL.emplace(uri);
    } else {
      mPrincipalURL.emplace(URL());
    }
  }

  return mPrincipalURL.ref();
}
Beispiel #3
0
int main(int argc, char const *argv[])
{
	
	int ruta[11][2]= {0};
	Datos datos = {0,0};
	datos.num_ciudades=11;
	CargaMatrizAdyacencia(&datos);
	Principal(&datos, ruta);
	ImprimirRuta(ruta, datos.num_ciudades);
	system("pause");
	return 0;
	return 0;
}
Beispiel #4
0
pandasoft::pandasoft(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::pandasoft)
{
    ui->setupUi(this);

    this->setWindowTitle("Acceso al Sistema - Pandasoft");
    ui->pandasoftstackedWidget->setCurrentIndex(0);
    ui->error->hide();
    ui->error0->hide();
    sucursalmodel = new QSqlRelationalTableModel();
    sucursalmodel->setTable("sucursal");
    sucursalmodel->select();

    ui->sucursalcombo->setModel(sucursalmodel);
    ui->sucursalcombo->setModelColumn(4);
    connect( ui->aceptar, SIGNAL(clicked()), this, SLOT(Principal()) );
    connect( ui->cancelar, SIGNAL(clicked()), this, SLOT(close()) );
    connect( ui->salir, SIGNAL(clicked()), this, SLOT(close()) );




    //principal
    ui->imagelabel->setPixmap(QPixmap(":/images/pandasoft2.png"));

    connect( ui->action_Salir, SIGNAL(triggered()), this, SLOT(close()) );
    connect( ui->actionAcerca_de_Pandasoft, SIGNAL(triggered()), this, SLOT(aboutpandasoft()) );
    connect( ui->actionGestionar_Almacen, SIGNAL(triggered()), this, SLOT(GAlmacen()) );
    connect( ui->actionGestionar_Empleado, SIGNAL(triggered()), this, SLOT(GEmpleado()) );
    connect( ui->actionGestionar_Productos, SIGNAL(triggered()), this, SLOT(GProductos()) );
    connect( ui->actionGestionar_Reportes, SIGNAL(triggered()), this, SLOT(GReportes()) );
    connect( ui->actionGestion_de_Sucursal, SIGNAL(triggered()), this, SLOT(GSucursal()) );
    connect( ui->actionGestionar_Usuarios, SIGNAL(triggered()), this, SLOT(GUsuarios()) );
    connect( ui->actionGestionar_Ventas, SIGNAL(triggered()), this, SLOT(GVentas()) );
    connect( ui->actionGestionar_Zona, SIGNAL(triggered()), this, SLOT(GZona()) );
    connect( ui->actionGestionar_Consignatario, SIGNAL(triggered()), this, SLOT(GConsignatario()));
    connect( ui->actionGestionar_Consignacion, SIGNAL(triggered()), this, SLOT(GConsignaciones()));

    ui->menubar->hide();

}
// Action_Vector::DoAction()
Action::RetType Action_Vector::DoAction(int frameNum, Frame* currentFrame, Frame** frameAddress) {
    switch ( mode_ ) {
    case MASK        :
        Mask(*currentFrame);
        break;
    case CENTER      :
        Vec_->AddVxyz( currentFrame->VCenterOfMass(mask_) );
        break;
    case DIPOLE      :
        Dipole(*currentFrame);
        break;
    case PRINCIPAL_X :
    case PRINCIPAL_Y :
    case PRINCIPAL_Z :
        Principal(*currentFrame);
        break;
    case CORRPLANE   :
        CorrPlane(*currentFrame);
        break;
    case BOX         :
        Vec_->AddVxyz( currentFrame->BoxCrd().Lengths() );
        break;
    case BOX_X       :
    case BOX_Y       :
    case BOX_Z       :
    case BOX_CTR     :
        UnitCell( currentFrame->BoxCrd() );
        break;
    case MINIMAGE    :
        MinImage( *currentFrame );
        break;
    default          :
        return Action::ERR; // NO_OP
    } // END switch over vectorMode
    if (Magnitude_ != 0) {
        float mag = (float)(sqrt(Vec_->Back().Magnitude2()));
        Magnitude_->Add(frameNum, &mag);
    }
    return Action::OK;
}
NS_IMETHODIMP
ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
{
  AutoError ae(this);
  nsIPrincipal* principal = Principal();

  nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
  if (!channel) {
    return NS_ERROR_DOM_ABORT_ERR;
  }

  if (nsContentUtils::IsSystemPrincipal(principal)) {
    // We should never import non-system documents and run their scripts with system principal!
    nsCOMPtr<nsIPrincipal> channelPrincipal;
    nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(channel,
                                                                    getter_AddRefs(channelPrincipal));
    if (!nsContentUtils::IsSystemPrincipal(channelPrincipal)) {
      return NS_ERROR_FAILURE;
    }
  }
  channel->SetOwner(principal);

  nsAutoCString type;
  channel->GetContentType(type);
  if (!type.EqualsLiteral("text/html")) {
    NS_WARNING("ImportLoader wrong content type");
    return NS_ERROR_DOM_ABORT_ERR;
  }

  // The scope object is same for all the imports in an import tree,
  // let's get it form the import parent.
  nsCOMPtr<nsIGlobalObject> global = mImportParent->GetScopeObject();
  nsCOMPtr<nsIDOMDocument> importDoc;
  nsCOMPtr<nsIURI> baseURI = mImportParent->GetBaseURI();
  const nsAString& emptyStr = EmptyString();
  nsresult rv = NS_NewDOMDocument(getter_AddRefs(importDoc),
                                  emptyStr, emptyStr, nullptr, mURI,
                                  baseURI, principal, false, global,
                                  DocumentFlavorHTML);
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);

  // The imported document must know which master document it belongs to.
  mDocument = do_QueryInterface(importDoc);
  nsCOMPtr<nsIDocument> master = mImportParent->MasterDocument();
  mDocument->SetMasterDocument(master);

  // We want to inherit the sandbox flags and fullscreen enabled flag
  // from the master document.
  mDocument->SetSandboxFlags(master->GetSandboxFlags());

  // We have to connect the blank document we created with the channel we opened,
  // and create its own LoadGroup for it.
  nsCOMPtr<nsIStreamListener> listener;
  nsCOMPtr<nsILoadGroup> loadGroup;
  channel->GetLoadGroup(getter_AddRefs(loadGroup));
  nsCOMPtr<nsILoadGroup> newLoadGroup = do_CreateInstance(NS_LOADGROUP_CONTRACTID);
  NS_ENSURE_TRUE(newLoadGroup, NS_ERROR_OUT_OF_MEMORY);
  newLoadGroup->SetLoadGroup(loadGroup);
  rv = mDocument->StartDocumentLoad("import", channel, newLoadGroup,
                                    nullptr, getter_AddRefs(listener),
                                    true);
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);

  nsCOMPtr<nsIURI> originalURI;
  rv = channel->GetOriginalURI(getter_AddRefs(originalURI));
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);

  nsCOMPtr<nsIURI> URI;
  rv = channel->GetURI(getter_AddRefs(URI));
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);
  MOZ_ASSERT(URI, "URI of a channel should never be null");

  bool equals;
  rv = URI->Equals(originalURI, &equals);
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);

  if (!equals) {
    // In case of a redirection we must add the new URI to the import map.
    Manager()->AddLoaderWithNewURI(this, URI);
  }

  // Let's start the parser.
  mParserStreamListener = listener;
  rv = listener->OnStartRequest(aRequest, aContext);
  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR);

  ae.Pass();
  return NS_OK;
}
already_AddRefed<nsIVariant>
DataTransferItem::Data(nsIPrincipal* aPrincipal, ErrorResult& aRv)
{
  MOZ_ASSERT(aPrincipal);

  nsCOMPtr<nsIVariant> variant = DataNoSecurityCheck();

  // If the inbound principal is system, we can skip the below checks, as
  // they will trivially succeed.
  if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
    return variant.forget();
  }

  MOZ_ASSERT(!ChromeOnly(), "Non-chrome code shouldn't see a ChromeOnly DataTransferItem");
  if (ChromeOnly()) {
    aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
    return nullptr;
  }

  bool checkItemPrincipal = mDataTransfer->IsCrossDomainSubFrameDrop() ||
    (mDataTransfer->GetEventMessage() != eDrop &&
     mDataTransfer->GetEventMessage() != ePaste);

  // Check if the caller is allowed to access the drag data. Callers with
  // chrome privileges can always read the data. During the
  // drop event, allow retrieving the data except in the case where the
  // source of the drag is in a child frame of the caller. In that case,
  // we only allow access to data of the same principal. During other events,
  // only allow access to the data with the same principal.
  if (Principal() && checkItemPrincipal &&
      !aPrincipal->Subsumes(Principal())) {
    aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
    return nullptr;
  }

  if (!variant) {
    return nullptr;
  }

  nsCOMPtr<nsISupports> data;
  nsresult rv = variant->GetAsISupports(getter_AddRefs(data));
  if (NS_SUCCEEDED(rv) && data) {
    nsCOMPtr<EventTarget> pt = do_QueryInterface(data);
    if (pt) {
      nsIScriptContext* c = pt->GetContextForEventHandlers(&rv);
      if (NS_WARN_IF(NS_FAILED(rv) || !c)) {
        aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
        return nullptr;
      }

      nsIGlobalObject* go = c->GetGlobalObject();
      if (NS_WARN_IF(!go)) {
        aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
        return nullptr;
      }

      nsCOMPtr<nsIScriptObjectPrincipal> sp = do_QueryInterface(go);
      MOZ_ASSERT(sp, "This cannot fail on the main thread.");

      nsIPrincipal* dataPrincipal = sp->GetPrincipal();
      if (NS_WARN_IF(!dataPrincipal || !aPrincipal->Equals(dataPrincipal))) {
        aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
        return nullptr;
      }
    }
  }

  return variant.forget();
}