Exemplo n.º 1
0
XnStatus XnDeviceBase::BatchConfig(const XnPropertySet* pChangeSet)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XN_VALIDATE_INPUT_PTR(pChangeSet);

	// start a transaction
	nRetVal = StartTransaction();
	XN_IS_STATUS_OK(nRetVal);

	for (XnPropertySetData::ConstIterator itModule = pChangeSet->pData->begin(); itModule != pChangeSet->pData->end(); ++itModule)
	{
		// find this module
		XnDeviceModule* pModule = NULL;
		nRetVal = FindModule(itModule.Key(), &pModule);
		XN_CHECK_RC_ROLLBACK(nRetVal);

		nRetVal = pModule->BatchConfig(*itModule.Value());
		XN_CHECK_RC_ROLLBACK(nRetVal);
	}

	nRetVal = CommitTransaction();
	XN_IS_STATUS_OK(nRetVal);
	
	return (XN_STATUS_OK);
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
// Register the interface to be tested.  This function registers the 
// interface to be tested.  It has to be called right after Init() and
// before any other methods are called
//
// For testing Data Source, DB Session, and Command objects, no properties
// need be specified.  For testing rowset objects, the array of properties
// to be set for the rowset, the IID_Interface in particular, has to be
// specified unless the interface is mandatory.
// 
// @mfunc RegisterInterface
//
// @rdesc Success or Failure
//	@flag TRUE  | The Interface is supported by the provider. 
//	@flag FALSE | he Interface is not supported by the provider.
//
//---------------------------------------------------------------------------
BOOL CTransaction::RegisterInterface(
EINTERFACE	eInterface,		//@parm [in] the ole db object to be tested
IID iid,						//@parm [in] the interface to be tested
ULONG cPropSets,				//@parm[in] the count of DBPROPSET structures to be set
DBPROPSET * rgPropSets			//@parm[in] the array of DBPROPSET structures to be set
)
{
	BOOL fSupported = TRUE;

	// Copy the information about the OLE DB object and interface
	m_eInterface  = eInterface;
	m_iid		  = iid;

	// The interface is not supported if we can not created a transaction that return
	// a pointer to the requested interface
	if (!StartTransaction(SELECT_ALLFROMTBL,NULL,cPropSets,rgPropSets))
	{
		// Reset m_iid to IID_IUnknown as a flag
		m_iid=IID_IUnknown;
		odtLog<<wszInterfaceNotSupported;
		fSupported=FALSE;
	}

	CleanUpTransaction(S_OK);

	return fSupported;
}
Exemplo n.º 3
0
void ezQtPropertyAnimAssetDocumentWindow::onRebindSelectedItems()
{
  auto pDoc = GetPropertyAnimDocument();
  auto pHistory = pDoc->GetCommandHistory();

  ezHybridArray<ezUuid, 16> rebindTracks;

  for (ezInt32 iTrack : m_MapSelectionToTrack)
  {
    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", iTrack);

    if (trackGuid.IsValid())
      rebindTracks.PushBack(trackGuid.Get<ezUuid>());
  }

  if (m_iMapGradientToTrack >= 0)
  {
    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", m_iMapGradientToTrack);

    if (trackGuid.IsValid())
      rebindTracks.PushBack(trackGuid.Get<ezUuid>());
  }

  bool ok = false;
  QString result = QInputDialog::getText(this, "Change Animation Binding", "New Binding Path:", QLineEdit::Normal, "", &ok);

  if (!ok)
    return;

  m_pSelectionModel->clear();

  ezStringBuilder path = result.toUtf8().data();
  ;
  path.MakeCleanPath();
  const ezVariant varRes = path.GetData();

  pHistory->StartTransaction("Rebind Tracks");

  for (const ezUuid guid : rebindTracks)
  {
    ezSetObjectPropertyCommand cmdSet;
    cmdSet.m_Object = guid;

    cmdSet.m_sProperty = "ObjectPath";
    cmdSet.m_NewValue = varRes;
    pDoc->GetCommandHistory()->AddCommand(cmdSet);
  }

  pHistory->FinishTransaction();
}
Exemplo n.º 4
0
void ezQtPropertyAnimAssetDocumentWindow::onDeleteSelectedItems()
{
  auto pDoc = GetPropertyAnimDocument();
  auto pHistory = pDoc->GetCommandHistory();

  pHistory->StartTransaction("Delete Tracks");

  m_pGradientToDisplay = nullptr;
  m_CurvesToDisplay.Clear();

  // delete the tracks with the highest index first, otherwise the lower indices become invalid
  // do this before modifying anything, as m_MapSelectionToTrack will change once the remove commands are executed
  ezHybridArray<ezInt32, 16> sortedTrackIDs;
  {
    for (ezInt32 iTrack : m_MapSelectionToTrack)
    {
      sortedTrackIDs.PushBack(iTrack);
    }

    if (m_iMapGradientToTrack >= 0)
    {
      sortedTrackIDs.PushBack(m_iMapGradientToTrack);
    }

    sortedTrackIDs.Sort();
  }

  for (ezUInt32 i = sortedTrackIDs.GetCount(); i > 0; --i)
  {
    const ezInt32 iTrack = sortedTrackIDs[i - 1];

    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", iTrack);

    if (trackGuid.IsValid())
    {
      ezRemoveObjectCommand cmd;
      cmd.m_Object = trackGuid.Get<ezUuid>();

      pHistory->AddCommand(cmd);
    }
  }

  m_MapSelectionToTrack.Clear();
  m_iMapGradientToTrack = -1;

  pHistory->FinishTransaction();
}
Exemplo n.º 5
0
boolean CDWHCIDevice::TransferStageAsync (CUSBRequest *pURB, boolean bIn, boolean bStatusStage)
{
	assert (pURB != 0);
	
	unsigned nChannel = AllocateChannel ();
	if (nChannel >= m_nChannels)
	{
		return FALSE;
	}
	
	CDWHCITransferStageData *pStageData =
		new CDWHCITransferStageData (nChannel, pURB, bIn, bStatusStage);
	assert (pStageData != 0);

	assert (m_pStageData[nChannel] == 0);
	m_pStageData[nChannel] = pStageData;

	EnableChannelInterrupt (nChannel);
	
	if (!pStageData->IsSplit ())
	{
		pStageData->SetState (StageStateNoSplitTransfer);
	}
	else
	{
		if (!pStageData->BeginSplitCycle ())
		{
			DisableChannelInterrupt (nChannel);

			delete pStageData;
			m_pStageData[nChannel] = 0;
			
			FreeChannel (nChannel);
			
			return FALSE;
		}

		pStageData->SetState (StageStateStartSplit);
		pStageData->SetSplitComplete (FALSE);
		pStageData->GetFrameScheduler ()->StartSplit ();
	}

	StartTransaction (pStageData);
	
	return TRUE;
}
void output_ogr(const std::string& filename, const std::string& driver_name, const segvec& removed_segments, const segvec& added_segments) {
    OGRRegisterAll();

    OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name.c_str());
    if (!driver) {
        std::cerr << driver_name << " driver not available.\n";
        exit(return_code_fatal);
    }

    //const char* options[] = { "SPATIALITE=yes", "OGR_SQLITE_SYNCHRONOUS=OFF", "INIT_WITH_EPSG=no", nullptr };
    const char* options[] = { nullptr };
    auto data_source = std::unique_ptr<OGRDataSource, OGRDataSourceDestroyer>(driver->CreateDataSource(filename.c_str(), const_cast<char**>(options)));
    if (!data_source) {
        std::cerr << "Creation of output file failed.\n";
        exit(return_code_fatal);
    }

    SRS srs;
    auto layer = data_source->CreateLayer("changes", srs.out(), wkbLineString, const_cast<char**>(options));
    if (!layer) {
        std::cerr << "Creating layer 'changes' failed.\n";
        exit(return_code_fatal);
    }

    OGRFieldDefn field_change("change", OFTInteger);
    field_change.SetWidth(1);
    if (layer->CreateField(&field_change) != OGRERR_NONE ) {
        std::cerr << "Creating field 'change' on 'changes' layer failed.\n";
        exit(return_code_fatal);
    }

    layer->StartTransaction();

    for (const auto& segment : removed_segments) {
        add_segment(layer, 0, segment);
    }

    for (const auto& segment : added_segments) {
        add_segment(layer, 1, segment);
    }

    layer->CommitTransaction();
}
Exemplo n.º 7
0
void CDWHCIDevice::TimerHandler (CDWHCITransferStageData *pStageData)
{
	DataMemBarrier ();

	assert (pStageData != 0);
	assert (pStageData->GetState () == StageStatePeriodicDelay);

	if (pStageData->IsSplit ())
	{
		pStageData->SetState (StageStateStartSplit);
	
		pStageData->SetSplitComplete (FALSE);
		pStageData->GetFrameScheduler ()->StartSplit ();
	}
	else
	{
		pStageData->SetState (StageStateNoSplitTransfer);
	}

	StartTransaction (pStageData);

	DataMemBarrier ();
}
Exemplo n.º 8
0
void CDWHCIDevice::ChannelInterruptHandler (unsigned nChannel)
{
	CDWHCITransferStageData *pStageData = m_pStageData[nChannel];
	assert (pStageData != 0);
	CUSBRequest *pURB = pStageData->GetURB ();
	assert (pURB != 0);

	switch (pStageData->GetSubState ())
	{
	case StageSubStateWaitForChannelDisable:
		StartChannel (pStageData);
		return;

	case StageSubStateWaitForTransactionComplete: {
		CleanDataCache ();
		InvalidateDataCache ();
		DataMemBarrier ();

		CDWHCIRegister TransferSize (DWHCI_HOST_CHAN_XFER_SIZ (nChannel));
		TransferSize.Read ();

		CDWHCIRegister ChanInterrupt (DWHCI_HOST_CHAN_INT (nChannel));

		assert (   !pStageData->IsPeriodic ()
			||    DWHCI_HOST_CHAN_XFER_SIZ_PID (TransferSize.Get ())
			   != DWHCI_HOST_CHAN_XFER_SIZ_PID_MDATA);

		pStageData->TransactionComplete (ChanInterrupt.Read (),
			DWHCI_HOST_CHAN_XFER_SIZ_PACKETS (TransferSize.Get ()),
			TransferSize.Get () & DWHCI_HOST_CHAN_XFER_SIZ_BYTES__MASK);
		} break;
	
	default:
		assert (0);
		break;
	}
	
	unsigned nStatus;
	
	switch (pStageData->GetState ())
	{
	case StageStateNoSplitTransfer:
		nStatus = pStageData->GetTransactionStatus ();
		if (nStatus & DWHCI_HOST_CHAN_INT_ERROR_MASK)
		{
			CLogger::Get ()->Write (FromDWHCI, LogError,
						"Transaction failed (status 0x%X)", nStatus);

			pURB->SetStatus (0);
		}
		else if (   (nStatus & (DWHCI_HOST_CHAN_INT_NAK | DWHCI_HOST_CHAN_INT_NYET))
			 && pStageData->IsPeriodic ())
		{
			pStageData->SetState (StageStatePeriodicDelay);

			unsigned nInterval = pURB->GetEndpoint ()->GetInterval ();

			m_pTimer->StartKernelTimer (MSEC2HZ (nInterval), TimerStub, pStageData, this);

			break;
		}
		else
		{
			if (!pStageData->IsStatusStage ())
			{
				pURB->SetResultLen (pStageData->GetResultLen ());
			}

			pURB->SetStatus (1);
		}
		
		DisableChannelInterrupt (nChannel);

		delete pStageData;
		m_pStageData[nChannel] = 0;

		FreeChannel (nChannel);

		pURB->CallCompletionRoutine ();
		break;

	case StageStateStartSplit:
		nStatus = pStageData->GetTransactionStatus ();
		if (   (nStatus & DWHCI_HOST_CHAN_INT_ERROR_MASK)
		    || (nStatus & DWHCI_HOST_CHAN_INT_NAK)
		    || (nStatus & DWHCI_HOST_CHAN_INT_NYET))
		{
			CLogger::Get ()->Write (FromDWHCI, LogError,
						"Transaction failed (status 0x%X)", nStatus);

			pURB->SetStatus (0);

			DisableChannelInterrupt (nChannel);

			delete pStageData;
			m_pStageData[nChannel] = 0;

			FreeChannel (nChannel);

			pURB->CallCompletionRoutine ();
			break;
		}

		pStageData->GetFrameScheduler ()->TransactionComplete (nStatus);

		pStageData->SetState (StageStateCompleteSplit);
		pStageData->SetSplitComplete (TRUE);

		if (!pStageData->GetFrameScheduler ()->CompleteSplit ())
		{
			goto LeaveCompleteSplit;
		}
		
		StartTransaction (pStageData);
		break;
		
	case StageStateCompleteSplit:
		nStatus = pStageData->GetTransactionStatus ();
		if (nStatus & DWHCI_HOST_CHAN_INT_ERROR_MASK)
		{
			CLogger::Get ()->Write (FromDWHCI, LogError,
						"Transaction failed (status 0x%X)", nStatus);

			pURB->SetStatus (0);

			DisableChannelInterrupt (nChannel);

			delete pStageData;
			m_pStageData[nChannel] = 0;

			FreeChannel (nChannel);

			pURB->CallCompletionRoutine ();
			break;
		}
		
		pStageData->GetFrameScheduler ()->TransactionComplete (nStatus);

		if (pStageData->GetFrameScheduler ()->CompleteSplit ())
		{
			StartTransaction (pStageData);
			break;
		}

	LeaveCompleteSplit:
		if (!pStageData->IsStageComplete ())
		{
			if (!pStageData->BeginSplitCycle ())
			{
				pURB->SetStatus (0);

				DisableChannelInterrupt (nChannel);

				delete pStageData;
				m_pStageData[nChannel] = 0;

				FreeChannel (nChannel);

				pURB->CallCompletionRoutine ();
				break;
			}

			if (!pStageData->IsPeriodic ())
			{
				pStageData->SetState (StageStateStartSplit);
				pStageData->SetSplitComplete (FALSE);
				pStageData->GetFrameScheduler ()->StartSplit ();

				StartTransaction (pStageData);
			}
			else
			{
				pStageData->SetState (StageStatePeriodicDelay);

				unsigned nInterval = pURB->GetEndpoint ()->GetInterval ();

				m_pTimer->StartKernelTimer (MSEC2HZ (nInterval),
							    TimerStub, pStageData, this);
			}
			break;
		}

		DisableChannelInterrupt (nChannel);

		if (!pStageData->IsStatusStage ())
		{
			pURB->SetResultLen (pStageData->GetResultLen ());
		}
		pURB->SetStatus (1);

		delete pStageData;
		m_pStageData[nChannel] = 0;

		FreeChannel (nChannel);

		pURB->CallCompletionRoutine ();
		break;

	default:
		assert (0);
		break;
	}
}
Exemplo n.º 9
0
OGRLayer *
OGRPGDumpDataSource::CreateLayer( const char * pszLayerNameIn,
                                  OGRSpatialReference *poSRS,
                                  OGRwkbGeometryType eType,
                                  char ** papszOptions )

{
    CPLString            osCommand;
    const char          *pszGeomType = NULL;
    char                *pszLayerName = NULL;
    const char          *pszTableName = NULL;
    char                *pszSchemaName = NULL;
    int                  nDimension = 3;
    const char          *pszFIDColumn = "OGC_FID";
    int                  bHavePostGIS = TRUE;

    if (pszLayerNameIn == NULL)
        return NULL;

    if (strncmp(pszLayerNameIn, "pg", 2) == 0)
    {
        CPLError(CE_Warning, CPLE_AppDefined,
                 "The layer name should not begin by 'pg' as it is a reserved prefix");
    }
    
    //bHavePostGIS = CSLFetchBoolean(papszOptions,"POSTGIS", TRUE);

    if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) )
    {
        pszLayerName = LaunderName( pszLayerNameIn );
        
    }
    else
        pszLayerName = CPLStrdup( pszLayerNameIn );
    
    int bCreateTable = CSLFetchBoolean(papszOptions,"CREATE_TABLE", TRUE);

    if (eType == wkbNone)
        bHavePostGIS = FALSE;
    else if( wkbFlatten(eType) == eType )
        nDimension = 2;

    if( CSLFetchNameValue( papszOptions, "DIM") != NULL )
        nDimension = atoi(CSLFetchNameValue( papszOptions, "DIM"));

    /* Postgres Schema handling:
       Extract schema name from input layer name or passed with -lco SCHEMA.
       Set layer name to "schema.table" or to "table" if schema == current_schema()
       Usage without schema name is backwards compatible
    */
    pszTableName = strstr(pszLayerName,".");
    if ( pszTableName != NULL )
    {
      int length = pszTableName - pszLayerName;
      pszSchemaName = (char*)CPLMalloc(length+1);
      strncpy(pszSchemaName, pszLayerName, length);
      pszSchemaName[length] = '\0';
      ++pszTableName; //skip "."
    }
    else
    {
      pszSchemaName = NULL;
      pszTableName = pszLayerName;
    }

    Commit();

/* -------------------------------------------------------------------- */
/*      Set the default schema for the layers.                          */
/* -------------------------------------------------------------------- */
    if( CSLFetchNameValue( papszOptions, "SCHEMA" ) != NULL )
    {
        CPLFree(pszSchemaName);
        pszSchemaName = CPLStrdup(CSLFetchNameValue( papszOptions, "SCHEMA" ));
        osCommand.Printf("CREATE SCHEMA \"%s\"", pszSchemaName);
        Log(osCommand);
    }

    if ( pszSchemaName == NULL)
    {
        pszSchemaName = CPLStrdup("public");
    }

/* -------------------------------------------------------------------- */
/*      Do we already have this layer?                                  */
/* -------------------------------------------------------------------- */
    int iLayer;

    for( iLayer = 0; iLayer < nLayers; iLayer++ )
    {
        if( EQUAL(pszLayerName,papoLayers[iLayer]->GetLayerDefn()->GetName()) )
        {
            CPLError( CE_Failure, CPLE_AppDefined,
                      "Layer %s already exists, CreateLayer failed.\n", 
                      pszLayerName );
            CPLFree( pszLayerName );
            CPLFree( pszSchemaName );
            return NULL;
        }
    }


    if (bCreateTable)
    {
        osCommand.Printf("DROP TABLE \"%s\".\"%s\" CASCADE", pszSchemaName, pszTableName );
        Log(osCommand);
    }
    
/* -------------------------------------------------------------------- */
/*      Handle the GEOM_TYPE option.                                    */
/* -------------------------------------------------------------------- */
    pszGeomType = CSLFetchNameValue( papszOptions, "GEOM_TYPE" );
    if( pszGeomType == NULL )
    {
        pszGeomType = "geometry";
    }

    if( !EQUAL(pszGeomType,"geometry") && !EQUAL(pszGeomType, "geography"))
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                    "GEOM_TYPE in PostGIS enabled databases must be 'geometry' or 'geography'.\n"
                    "Creation of layer %s with GEOM_TYPE %s has failed.",
                    pszLayerName, pszGeomType );
        CPLFree( pszLayerName );
        CPLFree( pszSchemaName );
        return NULL;
    }

/* -------------------------------------------------------------------- */
/*      Try to get the SRS Id of this spatial reference system,         */
/*      adding tot the srs table if needed.                             */
/* -------------------------------------------------------------------- */
    int nSRSId = -1;

    if( CSLFetchNameValue( papszOptions, "SRID") != NULL )
        nSRSId = atoi(CSLFetchNameValue( papszOptions, "SRID"));
    else
    {
        if (poSRS)
        {
            const char* pszAuthorityName = poSRS->GetAuthorityName(NULL);
            if( pszAuthorityName != NULL && EQUAL( pszAuthorityName, "EPSG" ) )
            {
                /* Assume the EPSG Id is the SRS ID. Might be a wrong guess ! */
                nSRSId = atoi( poSRS->GetAuthorityCode(NULL) );
            }
            else
            {
                const char* pszGeogCSName = poSRS->GetAttrValue("GEOGCS");
                if (pszGeogCSName != NULL && EQUAL(pszGeogCSName, "GCS_WGS_1984"))
                    nSRSId = 4326;
            }
        }
    }

    const char *pszGeometryType = OGRToOGCGeomType(eType);

    const char *pszGFldName = NULL;
    if( bHavePostGIS && !EQUAL(pszGeomType, "geography"))
    {
        if( CSLFetchNameValue( papszOptions, "GEOMETRY_NAME") != NULL )
            pszGFldName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME");
        else
            pszGFldName = "wkb_geometry";

        /* Sometimes there is an old cruft entry in the geometry_columns
        * table if things were not properly cleaned up before.  We make
        * an effort to clean out such cruft.
        */
        osCommand.Printf(
                "DELETE FROM geometry_columns WHERE f_table_name = '%s' AND f_table_schema = '%s'",
                pszTableName, pszSchemaName );
        if (bCreateTable)
            Log(osCommand);
    }


    StartTransaction();

/* -------------------------------------------------------------------- */
/*      Create a basic table with the FID.  Also include the            */
/*      geometry if this is not a PostGIS enabled table.                */
/* -------------------------------------------------------------------- */
    
    CPLString osCreateTable;
    int bTemporary = CSLFetchNameValue( papszOptions, "TEMPORARY" ) != NULL &&
                     CSLTestBoolean(CSLFetchNameValue( papszOptions, "TEMPORARY" ));
    if (bTemporary)
    {
        CPLFree(pszSchemaName);
        pszSchemaName = CPLStrdup("pg_temp_1");
        osCreateTable.Printf("CREATE TEMPORARY TABLE \"%s\"", pszTableName);
    }
    else
        osCreateTable.Printf("CREATE TABLE \"%s\".\"%s\"", pszSchemaName, pszTableName);

    if( !bHavePostGIS )
    {
        if (eType == wkbNone)
            osCommand.Printf(
                    "%s ( "
                    "   %s SERIAL, "
                    "   CONSTRAINT \"%s_pk\" PRIMARY KEY (%s) )",
                    osCreateTable.c_str(), pszFIDColumn, pszTableName, pszFIDColumn );
        else
            osCommand.Printf(
                    "%s ( "
                    "   %s SERIAL, "
                    "   WKB_GEOMETRY %s, "
                    "   CONSTRAINT \"%s_pk\" PRIMARY KEY (%s) )",
                    osCreateTable.c_str(), pszFIDColumn, pszGeomType, pszTableName, pszFIDColumn );
    }
    else if ( EQUAL(pszGeomType, "geography") )
    {
        if( CSLFetchNameValue( papszOptions, "GEOMETRY_NAME") != NULL )
            pszGFldName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME");
        else
            pszGFldName = "the_geog";

        if (nSRSId)
            osCommand.Printf(
                     "%s ( %s SERIAL, \"%s\" geography(%s%s,%d), CONSTRAINT \"%s_pk\" PRIMARY KEY (%s) )",
                     osCreateTable.c_str(), pszFIDColumn, pszGFldName, pszGeometryType, nDimension == 2 ? "" : "Z", nSRSId, pszTableName, pszFIDColumn );
        else
            osCommand.Printf(
                     "%s ( %s SERIAL, \"%s\" geography(%s%s), CONSTRAINT \"%s_pk\" PRIMARY KEY (%s) )",
                     osCreateTable.c_str(), pszFIDColumn, pszGFldName, pszGeometryType, nDimension == 2 ? "" : "Z", pszTableName, pszFIDColumn );
    }
    else
    {
        osCommand.Printf(
                 "%s ( %s SERIAL, CONSTRAINT \"%s_pk\" PRIMARY KEY (%s) )",
                 osCreateTable.c_str(), pszFIDColumn, pszTableName, pszFIDColumn );
    }

    if (bCreateTable)
        Log(osCommand);

/* -------------------------------------------------------------------- */
/*      Eventually we should be adding this table to a table of         */
/*      "geometric layers", capturing the WKT projection, and           */
/*      perhaps some other housekeeping.                                */
/* -------------------------------------------------------------------- */
    if( bCreateTable && bHavePostGIS && !EQUAL(pszGeomType, "geography"))
    {
        osCommand.Printf(
                "SELECT AddGeometryColumn('%s','%s','%s',%d,'%s',%d)",
                pszSchemaName, pszTableName, pszGFldName,
                nSRSId, pszGeometryType, nDimension );
        Log(osCommand);
    }

    if( bCreateTable && bHavePostGIS )
    {
/* -------------------------------------------------------------------- */
/*      Create the spatial index.                                       */
/*                                                                      */
/*      We're doing this before we add geometry and record to the table */
/*      so this may not be exactly the best way to do it.               */
/* -------------------------------------------------------------------- */
        const char *pszSI = CSLFetchNameValue( papszOptions, "SPATIAL_INDEX" );
        if( pszSI == NULL || CSLTestBoolean(pszSI) )
        {
            osCommand.Printf("CREATE INDEX \"%s_geom_idx\" "
                            "ON \"%s\".\"%s\" "
                            "USING GIST (\"%s\")",
                    pszTableName, pszSchemaName, pszTableName, pszGFldName);

            Log(osCommand);
        }
    }

/* -------------------------------------------------------------------- */
/*      Create the layer object.                                        */
/* -------------------------------------------------------------------- */
    OGRPGDumpLayer     *poLayer;

    int bWriteAsHex = !CSLFetchBoolean(papszOptions,"WRITE_EWKT_GEOM",FALSE);

    poLayer = new OGRPGDumpLayer( this, pszSchemaName, pszLayerName, pszGFldName,
                                  pszFIDColumn, nDimension, nSRSId, bWriteAsHex, bCreateTable );
    poLayer->SetLaunderFlag( CSLFetchBoolean(papszOptions,"LAUNDER",TRUE) );
    poLayer->SetPrecisionFlag( CSLFetchBoolean(papszOptions,"PRECISION",TRUE));

/* -------------------------------------------------------------------- */
/*      Add layer to data source layer list.                            */
/* -------------------------------------------------------------------- */
    papoLayers = (OGRPGDumpLayer **)
        CPLRealloc( papoLayers,  sizeof(OGRPGDumpLayer *) * (nLayers+1) );

    papoLayers[nLayers++] = poLayer;

    CPLFree( pszLayerName );
    CPLFree( pszSchemaName );

    return poLayer;
}
Exemplo n.º 10
0
/*
 *	StartTransactionCommand
 */
void
StartTransactionCommand(void)
{
	TransactionState s = CurrentTransactionState;

	switch (s->blockState)
	{
			/*
			 * if we aren't in a transaction block, we just do our usual
			 * start transaction.
			 */
		case TBLOCK_DEFAULT:
			StartTransaction();
			break;

			/*
			 * We should never experience this -- if we do it means the
			 * BEGIN state was not changed in the previous
			 * CommitTransactionCommand().	If we get it, we print a
			 * warning and change to the in-progress state.
			 */
		case TBLOCK_BEGIN:
			elog(WARNING, "StartTransactionCommand: unexpected TBLOCK_BEGIN");
			s->blockState = TBLOCK_INPROGRESS;
			break;

			/*
			 * This is the case when are somewhere in a transaction block
			 * and about to start a new command.  For now we do nothing
			 * but someday we may do command-local resource
			 * initialization.
			 */
		case TBLOCK_INPROGRESS:
			break;

			/*
			 * As with BEGIN, we should never experience this if we do it
			 * means the END state was not changed in the previous
			 * CommitTransactionCommand().	If we get it, we print a
			 * warning, commit the transaction, start a new transaction
			 * and change to the default state.
			 */
		case TBLOCK_END:
			elog(WARNING, "StartTransactionCommand: unexpected TBLOCK_END");
			s->blockState = TBLOCK_DEFAULT;
			CommitTransaction();
			StartTransaction();
			break;

			/*
			 * Here we are in the middle of a transaction block but one of
			 * the commands caused an abort so we do nothing but remain in
			 * the abort state.  Eventually we will get to the "END
			 * TRANSACTION" which will set things straight.
			 */
		case TBLOCK_ABORT:
			break;

			/*
			 * This means we somehow aborted and the last call to
			 * CommitTransactionCommand() didn't clear the state so we
			 * remain in the ENDABORT state and maybe next time we get to
			 * CommitTransactionCommand() the state will get reset to
			 * default.
			 */
		case TBLOCK_ENDABORT:
			elog(WARNING, "StartTransactionCommand: unexpected TBLOCK_ENDABORT");
			break;
	}

	/*
	 * We must switch to TopTransactionContext before returning. This is
	 * already done if we called StartTransaction, otherwise not.
	 */
	Assert(TopTransactionContext != NULL);
	MemoryContextSwitchTo(TopTransactionContext);
}
TInt CIdWsfAuthenticationServiceClient::ValidateL(
                                    CIdWsfServiceSession &aSession,
                                    const TDesC8& /*authnContext*/,
                                    MSenRemoteServiceConsumer& aRemoteConsumer)
    {
    CSLOG_L(aRemoteConsumer.ConnectionId(), KMinLogLevel ,"CIdWsfAuthenticationServiceClient::ValidateL(..)");
    // keep this as first line
    iServedConsumer = &aRemoteConsumer;

    if(!ipAccount)
        {
        return KErrSenNoEndpoint; 
        }

    TInt retVal(KErrNone);          // for returning error codes
    iCState = EAuthServiceClient;   // set state
    iDsSession = &aSession;         // save session
    CSLOG_L(aRemoteConsumer.ConnectionId(), KMinLogLevel ,"- starting transaction.");
    StartTransaction();

    TPtrC8 mechanismNames =
                        Framework().Manager().SenSecurityMechanismNames8L();

    CIdWsfSaslMessage* pInitMessage =
        CIdWsfSaslMessage::NewL(Framework().Manager(),
                                KSaslXmlns,
                                KSaslRequestName,
                                KSaslRequestQName);
    CleanupStack::PushL(pInitMessage); // push pInitMessage

    CSLOG_L(aRemoteConsumer.ConnectionId(), KMinLogLevel ,"- constructing initial request.");
    pInitMessage->ConstructInitRequestFromL(mechanismNames, *ipAccount);

    HBufC8* pInitRequest8 = pInitMessage->AsXmlL();
    CleanupStack::PushL(pInitRequest8); // push pInitRequest

    if(iService)
        {
        HBufC8* pResponse8 = NULL;

        HBufC8* pNextMessage = NULL;

#ifdef _SENDEBUG
        TPtr8 initRequest = pInitRequest8->Des();
//wslog        FILELOGALL(_L("SenCoreServiceManager"), _L("AS_init_req.xml"), initRequest);
#endif // _SENDEBUG

        retVal = iService->SubmitL(*pInitRequest8, KNullDesC8, *this, pResponse8);
        aRemoteConsumer.SetDataTrafficDetails(iAuthDetails); 
        CleanupStack::PushL(pResponse8); // pResponse8

        if(retVal == KErrNone && pResponse8)
            {
#ifdef _SENDEBUG
            TPtr8 initResponse = pResponse8->Des();
//wslog            FILELOGALL(_L("SenCoreServiceManager"), _L("AS_init_rsp.xml"), initResponse);
#endif // _SENDEBUG
            retVal = ParseResponseL(*pResponse8, pNextMessage);
            }
#ifdef _SENDEBUG
        else
            {
            CSLOG_L(aRemoteConsumer.ConnectionId(), KMinLogLevel ,"CIdWsfAuthenticationServiceClient::ValidateL:");
            CSLOG_FORMAT((aRemoteConsumer.ConnectionId(), KMinLogLevel , _L8("- SubmitL failed: %d"), retVal));
            }
#endif // _SENDEBUG

        CleanupStack::PopAndDestroy(1); // pResponse8

        while ( pNextMessage )
            {
#ifdef _SENDEBUG
            TPtr8 authRequest = pNextMessage->Des();
//wslog            FILELOGALL(_L("SenCoreServiceManager"), _L("AS_req.xml"), authRequest);
#endif // _SENDEBUG
            CleanupStack::PushL(pNextMessage); // pNextMessage
            retVal = iService->SubmitL(*pNextMessage, KNullDesC8, *this, pResponse8); 
            aRemoteConsumer.SetDataTrafficDetails(iAuthDetails); 	
            CleanupStack::PopAndDestroy(); // pNextMessage
            pNextMessage = NULL;

            if (retVal == KErrNone && pResponse8)
                {
                CleanupStack::PushL(pResponse8); // pResponse8
#ifdef _SENDEBUG
                TPtr8 authResponse = pResponse8->Des();
//wslog                FILELOGALL(_L("WsLog"), _L("AS_rsp.xml"), authResponse);
#endif // _SENDEBUG
                retVal = ParseResponseL(*pResponse8, pNextMessage);
                CleanupStack::PopAndDestroy(); // pResponse8
                }
            }
        }
    CleanupStack::PopAndDestroy(2); // pInitRequest8, pInitMessage
    
    if ((retVal == KErrNone) && iDsSession->IsReadyL())
        {
         CSLOG_L(aRemoteConsumer.ConnectionId(), KMinLogLevel ,"- starting transaction.");
        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel ,"- setting validator for DS session.");

        iDsSession->SetValidator(this);
        }

    return retVal;
    }