Exemple #1
0
	Delete(port_entry& port)
		:
		fID(port.id)
	{
		Initialized();
	}
void ReliabilityHandlerComponent::Initialize()
{
	SetActive(true);
	Initialized();
	State = Handler::Component::State::Initialized;
}
bool VlcVideoWidget::OpenSource(const QString &videoUrl) 
{
    if (!Initialized())
        return false;

    // We need to prepend file:// if this is a path on disk.
    QString source = videoUrl;
    AssetAPI::AssetRefType sourceType = AssetAPI::ParseAssetRef(source);
    if ((sourceType == AssetAPI::AssetRefLocalPath || sourceType == AssetAPI::AssetRefLocalUrl))
    {
        if (source.startsWith("file://", Qt::CaseInsensitive))
            source = source.mid(7);
        vlcMedia_ = libvlc_media_new_path(vlcInstance_, source.toUtf8().constData());
    }
    else
        vlcMedia_ = libvlc_media_new_location(vlcInstance_, source.toUtf8().constData());

    if (vlcMedia_ == 0)
    {
        LogError("VlcVideoWidget: Could not load media from '" + videoUrl + "'");
        return false;
    }

    libvlc_event_manager_t *em = libvlc_media_event_manager(vlcMedia_);
    libvlc_event_attach(em, libvlc_MediaMetaChanged, &VlcEventHandler, this);
    libvlc_event_attach(em, libvlc_MediaSubItemAdded, &VlcEventHandler, this);
    libvlc_event_attach(em, libvlc_MediaDurationChanged, &VlcEventHandler, this);
    libvlc_event_attach(em, libvlc_MediaParsedChanged, &VlcEventHandler, this);
    libvlc_event_attach(em, libvlc_MediaFreed, &VlcEventHandler, this);
    libvlc_event_attach(em, libvlc_MediaStateChanged, &VlcEventHandler, this);

    libvlc_state_t state = libvlc_media_get_state(vlcMedia_);

    if (state != libvlc_Error)
    {
        // Reset playback
        Stop();
        hasVideoOut_ = false;

        libvlc_media_player_set_media(vlcPlayer_, vlcMedia_);      

        statusAccess.lock();
        status.Reset();
        status.source = videoUrl;
        status.change = PlayerStatus::MediaSource;
        statusAccess.unlock();

        return true;
    }
    else
    {
        std::string err = "Unknown error";
        if (libvlc_errmsg())
        {
            err = libvlc_errmsg();
            libvlc_clearerr();
        }
        LogError("VlcVideoWidget: " + err);
    }
    return false;
}
		TracingLogStartEntry()
		{
			Initialized();
		}
MOboolean
moResourceManager::Init(
    const moText& p_apppath,
    const moText& p_datapath,
    moConfig&  p_consoleconfig,
    MOint p_render_to_texture_mode,
    MOint p_screen_width,
    MOint p_screen_height,
    MOint p_render_width,
    MOint p_render_height,
    MO_HANDLE p_OpWindowHandle,
    MO_DISPLAY p_Display) {

    if ( GetResourceByType( MO_RESOURCETYPE_DEBUG ) == NULL )
        AddResource( new moDebugManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_NET ) == NULL )
        AddResource( new moNetManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FILE ) == NULL )
        AddResource( new moFileManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FILTER ) == NULL )
        AddResource( new moFilterManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_TIME ) == NULL )
        AddResource( new moTimeManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_DATA ) == NULL )
        AddResource( new moDataManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_MATH ) == NULL )
        AddResource( new moMathManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SHADER ) == NULL )
        AddResource( new moShaderManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FB )==NULL )
        AddResource( new moFBManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_GL )==NULL )
        AddResource( new moGLManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_DECODER )==NULL )
        AddResource( new moDecoderManager() );


    if ( GetResourceByType( MO_RESOURCETYPE_RENDER )==NULL )
        AddResource( new moRenderManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_TEXTURE )==NULL )
        AddResource( new moTextureManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SOUND )==NULL )
        AddResource( new moSoundManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_VIDEO )==NULL )
        AddResource( new moVideoManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_MODEL )==NULL )
        AddResource( new mo3dModelManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FONT )==NULL )
        AddResource( new moFontManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_GUI )==NULL )
        AddResource( new moGUIManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SCRIPT )==NULL )
        AddResource( new moScriptManager() );

    ///Asigna configname, y labelname a los recursos PREDETERMINADOS en caso de encontrarse en el config
    moText resname;
    moText cfname;
    moText lblname;

    ///TODO: chequear errores...
    moParam& presources(p_consoleconfig.GetParam(moText("resources")));

    presources.FirstValue();

    for(MOuint r=0; r<presources.GetValuesCount(); r++) {

        moResource* pResource = NULL;

        resname = presources[MO_SELECTED][MO_CFG_RESOURCE].Text();
        cfname = presources[MO_SELECTED][MO_CFG_RESOURCE_CONFIG].Text();
        lblname = presources[MO_SELECTED][MO_CFG_RESOURCE_LABEL].Text();

        MOint rid = GetResourceIndex( lblname );

        if(rid>-1) pResource = GetResource(rid);

        if (pResource) {
            pResource->SetConfigName(cfname);
            pResource->SetLabelName(lblname);
            pResource->SetConsoleParamIndex( presources.GetParamDefinition().GetIndex() );
            pResource->SetConsoleValueIndex( r );
        }
        presources.NextValue();
    }

    if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Embedded Resources."));
    MODebugMan = (moDebugManager*) GetResourceByType( MO_RESOURCETYPE_DEBUG );
    if (MODebugMan) {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Debug Man Resource."));
        if (!MODebugMan->Init())
            MODebug2->Error(moText("moResourceManager:: Debug Man. Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Debug Man. Creation Error."));
    }

    MONetMan = (moNetManager*) GetResourceByType( MO_RESOURCETYPE_NET );
    if (MONetMan) {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Net Man Resource."));
        if (!MONetMan->Init())
            MODebug2->Error(moText("moResourceManager:: Net Man. Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Net Man. Creation Error."));
    }

    MOFileMan = (moFileManager*) GetResourceByType( MO_RESOURCETYPE_FILE );
    if (MOFileMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing File Man Resource."));
        if (!MOFileMan->Init())
            MODebug2->Error(moText("moResourceManager:: File Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: File Man Creation Error."));
    }


    MODataMan = (moDataManager*) GetResourceByType( MO_RESOURCETYPE_DATA );
    if (MODataMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Data Man Resource."));
        if (!MODataMan->Init( p_apppath, p_datapath, p_consoleconfig.GetName()))
            MODebug2->Error(moText("moResourceManager:: Data Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Data Man Creation Error."));
    }

    MOFilterMan = (moFilterManager*) GetResourceByType( MO_RESOURCETYPE_FILTER );
    if (MOFilterMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Filter Man Resource."));
        if (!MOFilterMan->Init())
            MODebug2->Error(moText("moResourceManager:: Filter Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Filter Man Creation Error."));
    }

    MOTimeMan = (moTimeManager*) GetResourceByType( MO_RESOURCETYPE_TIME );
    if (MOTimeMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Time Man Resource."));
        if (!MOTimeMan->Init())
            MODebug2->Error(moText("moResourceManager:: Time Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Time Man Creation Error."));
    }

    MOGLMan = (moGLManager*) GetResourceByType( MO_RESOURCETYPE_GL );
    if (MOGLMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing GL Man Resource."));
        if (!MOGLMan->Init())
            MODebug2->Error(moText("moResourceManager:: GL Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: GL Man Creation Error."));
    }

    MOFBMan = (moFBManager*) GetResourceByType( MO_RESOURCETYPE_FB );
    if (MOFBMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing FrameBuffer Man Resource."));
        if (!MOFBMan->Init())
            MODebug2->Error(moText("moResourceManager:: FrameBuffer Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: FrameBuffer Man Creation Error."));
    }

    MOTextureMan = (moTextureManager*)  GetResourceByType( MO_RESOURCETYPE_TEXTURE );
    if (MOTextureMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Texture Man Resource."));
        if (!MOTextureMan->Init())
            MODebug2->Error(moText("moResourceManager:: Texture Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Texture Man Creation Error."));
    }

    MODecoderMan = (moDecoderManager*)  GetResourceByType( MO_RESOURCETYPE_DECODER );
    if (MODecoderMan)  {
        if (MODebug2) MODebug2->Message(moText("moDecoderMan:: Initializing Decoder Manager Resource."));
        if (!MODecoderMan->Init())
            MODebug2->Error(moText("moDecoderMan:: Decoder Manager Initialization Error."));
    } else {
        MODebug2->Error(moText("moDecoderMan:: Decoder Manager Creation Error."));
    }


    MORenderMan = (moRenderManager*) GetResourceByType( MO_RESOURCETYPE_RENDER );
    if (MORenderMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Render Man Resource."));
        if (!MORenderMan->Init( (moRenderManagerMode)p_render_to_texture_mode, p_screen_width, p_screen_height, p_render_width, p_render_height ))
            MODebug2->Error(moText("moResourceManager:: Render Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Render Man Creation Error."));
    }

    MOMathMan = (moMathManager*) GetResourceByType( MO_RESOURCETYPE_MATH );
    if (MOMathMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Math Man Resource."));
        if (!MOMathMan->Init())
            MODebug2->Error(moText("moResourceManager:: Math Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Math Man Creation Error."));
    }

    MOShaderMan = (moShaderManager*) GetResourceByType( MO_RESOURCETYPE_SHADER );
    if (MOShaderMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Shsder Man Resource."));
        if (!MOShaderMan->Init())
            MODebug2->Error(moText("moResourceManager:: Shader Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Shader Man Creation Error."));
    }

    MOFontMan = (moFontManager*) GetResourceByType( MO_RESOURCETYPE_FONT );
    if (MOFontMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Font Man Resource."));
        if (!MOFontMan->Init())
            MODebug2->Error(moText("moResourceManager:: Font Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Font Man Creation Error."));
    }

    MOGuiMan = (moGUIManager*)  GetResourceByType( MO_RESOURCETYPE_GUI );
    if (MOGuiMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing GUI Man Resource."));
        if (!MOGuiMan->Init( p_OpWindowHandle, p_Display ))
            MODebug2->Error(moText("moResourceManager:: GUI Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: GUI Man Creation Error."));
    }

    MOSoundMan = (moSoundManager*)  GetResourceByType( MO_RESOURCETYPE_SOUND );
    if (MOSoundMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Sound Man Resource."));
        if (!MOSoundMan->Init())
            MODebug2->Error(moText("moResourceManager:: Sound Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Sound Man Creation Error."));
    }

    MOVideoMan = (moVideoManager*)  GetResourceByType( MO_RESOURCETYPE_VIDEO );
    if (MOVideoMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Video Man Resource."));
        if (!MOVideoMan->Init()) {
            MODebug2->Error(moText("moResourceManager:: Video Man Initialization Error."));
        }
    } else {
        MODebug2->Error(moText("moResourceManager:: Video Man Creation Error."));
    }

    MOModelMan = (mo3dModelManager*)  GetResourceByType( MO_RESOURCETYPE_MODEL );
    if (MOModelMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Model Man Resource."));
        if (!MOModelMan->Init())
            MODebug2->Error(moText("moResourceManager:: Model Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Model Man Creation Error."));
    }

    MOScriptMan = (moScriptManager*)  GetResourceByType( MO_RESOURCETYPE_SCRIPT );
    if (MOScriptMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Script Man Resource."));
        if (!MOScriptMan->Init()) {
            MODebug2->Error(moText("moResourceManager:: Script Man Initialization Error."));
        }
    } else {
        MODebug2->Error(moText("moResourceManager:: Script Man Creation Error."));
    }

    m_Plugins.Init( 0, NULL);

    m_bInitialized = true;

    if (MODebug2) MODebug2->Message(moText("moResourceManager:: Embedded Resources Ready."));

    return Initialized();
}
Exemple #6
0
double *c_natgridd(int n, double x[], double y[], double z[],
                   int nxi, int nyi, double xi[], double yi[], int *ier)
{
    double **data_out=NULL, *rtrn_val=NULL;
    double *x_sav, *y_sav, *z_sav, *darray;
    int n_sav,i;
    *ier = 0;

    /*
     *  Check for duplicate input values.  Duplicate triples will be
     *  culled, but duplicate coordinates with different data values
     *  will produce an error.
     */
    if (single_point == 0)
    {
        n_sav = n;
        x_sav = (double *) malloc(n*sizeof(double));
        y_sav = (double *) malloc(n*sizeof(double));
        z_sav = (double *) malloc(n*sizeof(double));
        memcpy((void *)x_sav, (void *)x, n*sizeof(double));
        memcpy((void *)y_sav, (void *)y, n*sizeof(double));
        memcpy((void *)z_sav, (void *)z, n*sizeof(double));

        darray = (double *) malloc(3*n*sizeof(double));
        for (i = 0; i < n; i++) {
            darray[3*i  ] = x[i];
            darray[3*i+1] = y[i];
            darray[3*i+2] = z[i];
        }

        qsort( (void *)darray, n, 3*sizeof(double), comp_dtriples);
        n = cull_dtriples(n_sav, darray);

        for (i = 0; i < n; i++) {
            x[i] = darray[3*i  ];
            y[i] = darray[3*i+1];
            z[i] = darray[3*i+2];
        }
        free(darray);
    }

    if (single_point == 0)
    {
        asflag = 1;
        Initialized(n, x, y, nxi, nyi, xi, yi);

        if (ReadDatad(n,x,y,z) != 0)
        {
            *ier = error_status;
            return ( (double *) NULL);
        }
    }

    if (adf)
    {
        CircOut();
        if (error_status)
        {
            *ier = error_status;
            return ( (double *) NULL);
        }
    }
    if (igrad)
    {
        Gradient();
        if (error_status)
        {
            *ier = error_status;
            return ( (double *) NULL);
        }
    }

    data_out = MakeGridd(nxi, nyi, xi, yi);
    if (error_status)
    {
        if((data_out !=NULL)&&(data_out[0]!=NULL)) {
            free(data_out[0]);
            free(data_out);
        }
        *ier = error_status;
        return ( (double *) NULL);
    }

    if (single_point == 0)
    {
        Terminate();
    }

    horilap = -1.;
    vertlap = -1.;

    rtrn_val = data_out[0];
    free(data_out);
    if (single_point == 0)
    {
        memcpy((void *)x, (void *)x_sav, n_sav*sizeof(double));
        memcpy((void *)y, (void *)y_sav, n_sav*sizeof(double));
        memcpy((void *)z, (void *)z_sav, n_sav*sizeof(double));
        free(x_sav);
        free(y_sav);
        free(z_sav);
    }
    return (rtrn_val);
}
Exemple #7
0
		RestartSyscall()
		{
			Initialized();
		}
Exemple #8
0
void CScreenSaver::GetInfo(SCR_INFO *info)
{
  // get info from screensaver
  if (Initialized()) m_pStruct->GetInfo(info);
}
 void Application::OnInitialized( EventArgs& e )
 {
     Initialized( e );
 }
Exemple #10
0
		HandleSignals(uint32 signals)
			:
			fSignals(signals)
		{
			Initialized();
		}
VlcVideoWidget::~VlcVideoWidget() 
{
    if (Initialized())
        ShutDown();
}
void VlcVideoWidget::paintEvent(QPaintEvent *e) 
{
    if (!Initialized())
        return;

    statusAccess.lock();
    bool stopped = status.stopped;
    bool paused = status.paused;
    bool buffering = status.buffering;
    statusAccess.unlock();

    QSize widgetSize = size();
    QRect targetRect = rect();

    QPainter p(this);

    if (!stopped)
    {
        // Playing/paused/buffering state, try to get a lock, but skip if cant.
        // This lock might fail occasionally, this is when we lose a frame in the 2D preview widget.
        if (onScreenPixmapMutex_.tryLock())
        {
            QSize videoSize = (hasVideoOut_ ? onScreenPixmap_.size() : audioLogo_.size());

            double sourceAspectRatio = double(videoSize.height()) / videoSize.width();
            double displayAspectRatio = double(widgetSize.height()) / widgetSize.width();

            QSize scaled = videoSize;
            scaled.scale(widgetSize, Qt::KeepAspectRatio);

            if (displayAspectRatio >= sourceAspectRatio)
                targetRect = QRect(0, (widgetSize.height() - scaled.height()) / 2, widgetSize.width(), scaled.height());
            else
                targetRect = QRect((widgetSize.width() - scaled.width()) / 2, 0, scaled.width(), widgetSize.height());

            // Render audio logo for non video sources, the video image for others.
            if (hasVideoOut_)
                p.drawPixmap(targetRect, onScreenPixmap_, onScreenPixmap_.rect());
            else
                p.drawPixmap(targetRect, QPixmap::fromImage(audioLogo_), audioLogo_.rect());

            // Add some eye candy for paused and buffering states
            if (paused)
                p.drawPixmap(QPoint(10,10), pausePixmap_, pausePixmap_.rect());
            if (buffering)
                p.drawPixmap(QPoint(10,10), bufferingPixmap_, bufferingPixmap_.rect());

            onScreenPixmapMutex_.unlock();
        }
    }
    else
    {
        // Stopped state, render the default idle state logo
        QSize videoSize = idleLogo_.size();

        double sourceAspectRatio = double(videoSize.height()) / videoSize.width();
        double displayAspectRatio = double(widgetSize.height()) / widgetSize.width();

        QSize scaled = videoSize;
        scaled.scale(widgetSize, Qt::KeepAspectRatio);

        if (displayAspectRatio >= sourceAspectRatio)
            targetRect = QRect(0, (widgetSize.height() - scaled.height()) / 2, widgetSize.width(), scaled.height());
        else
            targetRect = QRect((widgetSize.width() - scaled.width()) / 2, 0, scaled.width(), widgetSize.height());

        p.drawPixmap(targetRect, QPixmap::fromImage(idleLogo_), idleLogo_.rect());
    }

    p.end();
}
libvlc_state_t VlcVideoWidget::GetMediaState() const
{
    if (!Initialized() || !vlcMedia_)
        return libvlc_Error;
    return libvlc_media_get_state(vlcMedia_);
}
Exemple #14
0
void CScreenSaver::Start()
{
  // notify screen saver that they should start
  if (Initialized()) m_pStruct->Start();
}
CImageEncoder::~CImageEncoder()
{
  if (m_image && Initialized())
    m_pStruct->Close(m_image);
}
Exemple #16
0
void CScreenSaver::Render()
{
  // ask screensaver to render itself
  if (Initialized()) m_pStruct->Render();
}
Exemple #17
0
void MainLoop()
{
	int attemptCount = 1;

	// OK, let's get down to business
	do
	{
		LogMessage(_("Creating primary connection"), LOG_DEBUG);
		DBconn *serviceConn = DBconn::InitConnection(connectString);

		if (serviceConn && serviceConn->IsValid())
		{
			serviceDBname = serviceConn->GetDBname();

			// Basic sanity check, and a chance to get the serviceConn's PID
			LogMessage(_("Database sanity check"), LOG_DEBUG);
			DBresult *res = serviceConn->Execute(wxT("SELECT count(*) As count, pg_backend_pid() AS pid FROM pg_class cl JOIN pg_namespace ns ON ns.oid=relnamespace WHERE relname='pga_job' AND nspname='pgagent'"));
			if (res)
			{
				wxString val = res->GetString(wxT("count"));

				if (val == wxT("0"))
					LogMessage(_("Could not find the table 'pgagent.pga_job'. Have you run pgagent.sql on this database?"), LOG_ERROR);

				backendPid = res->GetString(wxT("pid"));

				delete res;
				res = NULL;
			}

			// Check for particular version

			bool hasSchemaVerFunc = false;
			wxString sqlCheckSchemaVersion
			= wxT("SELECT COUNT(*)                                            ")\
			  wxT("FROM pg_proc                                               ")\
			  wxT("WHERE proname = 'pgagent_schema_version' AND               ")\
			  wxT("      pronamespace = (SELECT oid                           ")\
			  wxT("                      FROM pg_namespace                    ")\
			  wxT("                      WHERE nspname = 'pgagent') AND       ")\
			  wxT("      prorettype = (SELECT oid                             ")\
			  wxT("                    FROM pg_type                           ")\
			  wxT("                    WHERE typname = 'int2') AND            ")\
			  wxT("      proargtypes = ''                                     ");

			res = serviceConn->Execute(sqlCheckSchemaVersion);

			if (res)
			{
				if (res->IsValid() && res->GetString(0) == wxT("1"))
					hasSchemaVerFunc = true;
				delete res;
				res = NULL;
			}

			if (!hasSchemaVerFunc)
			{
				LogMessage(_("Couldn't find the function 'pgagent_schema_version' - please run pgagent_upgrade.sql."), LOG_ERROR);
			}

			wxString strPgAgentSchemaVer = serviceConn->ExecuteScalar(wxT("SELECT pgagent.pgagent_schema_version()"));
			wxString currentPgAgentVersion;
			currentPgAgentVersion.Printf(_("%d"), PGAGENT_VERSION_MAJOR);
			if (strPgAgentSchemaVer != currentPgAgentVersion)
			{
				wxString strSchemaVerMisMatch;
				strSchemaVerMisMatch.Printf(_("Unsupported schema version: %s. Version %s is required - please run pgagent_upgrade.sql."), strPgAgentSchemaVer.c_str(), currentPgAgentVersion.c_str());
				LogMessage(strSchemaVerMisMatch, LOG_ERROR);
			}

#ifdef WIN32
			Initialized();
#endif
			MainRestartLoop(serviceConn);
		}

		LogMessage(wxString::Format(_("Couldn't create the primary connection (attempt %d): %s"), attemptCount, serviceConn->GetLastError().c_str()), LOG_STARTUP);
		DBconn::ClearConnections(true);

		// Try establishing primary connection upto MAXATTEMPTS times
		if (attemptCount++ >= (int)MAXATTEMPTS)
		{
			LogMessage(wxString::Format(_("Stopping pgAgent: Couldn't establish the primary connection with the database server.")), LOG_ERROR);
		}
		WaitAWhile();
	}
	while (1);
}
Exemple #18
0
		Delete(ObjectCache* cache)
			:
			ObjectCacheTraceEntry(cache)
		{
			Initialized();
		}
/**----------------------------------------------------------------------------
\brief

\param
\return
\code

\endcode
-----------------------------------------------------------------------------*/
DTSTATUS
FileIoHelper::FIOReference(
IN BOOL ReadOnly,
IN LARGE_INTEGER Offset,
IN DWORD Size,
IN OUT PUCHAR& ReferencedPointer
)
{
	if (TRUE != Initialized()) return DTS_INVALID_OBJECT_STATUS;
	if (TRUE == IsReadOnly())
	{
		if (TRUE != ReadOnly)
		{
				return DTS_INVALID_PARAMETER;
		}
	}

	_ASSERTE(NULL == mFileView);
	FIOUnreference();

	if (Offset.QuadPart + Size > mFileSize.QuadPart)
	{
			return DTS_INVALID_PARAMETER;
	}

	//
	// MapViewOfFile() 함수의 dwFileOffsetLow 파라미터는 
	// SYSTEM_INFO::dwAllocationGranularity 값의 배수이어야 한다.
	// 
	static DWORD AllocationGranularity = 0;
	if (0 == AllocationGranularity)
	{
		SYSTEM_INFO si = { 0 };
		GetSystemInfo(&si);
		AllocationGranularity = si.dwAllocationGranularity;
	}

	DWORD AdjustMask = AllocationGranularity - 1;
	LARGE_INTEGER AdjustOffset = { 0 };
	AdjustOffset.HighPart = Offset.HighPart;

	// AllocationGranularity 이하의 값을 버림
	// 
	AdjustOffset.LowPart = (Offset.LowPart & ~AdjustMask);

	// 버려진 값만큼 매핑할 사이즈를 증가
	// 
	DWORD BytesToMap = (Offset.LowPart & AdjustMask) + Size;

	mFileView = (PUCHAR)MapViewOfFile(
		mFileMap,
		(TRUE == ReadOnly) ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE,
		AdjustOffset.HighPart,
		AdjustOffset.LowPart,
		BytesToMap
		);
	if (NULL == mFileView)
	{
			return DTS_WINAPI_FAILED;
	}

	ReferencedPointer = &mFileView[Offset.LowPart & AdjustMask];
	return DTS_SUCCESS;
}
bool LSelectServer::Initialize(t_Select_Server_Params& tssp)
{
	if (tssp.pszIp == NULL)
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, tssp.pszIp == NULL\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (tssp.usPort == 0)
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, tssp.usPort == 0\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	m_SelectServerSessionManager.SetSelectServer(this);
	if (!m_SelectServerSessionManager.Initialize(tssp))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_SelectServerSessionManager.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}

	if (!m_FixLenCircleBufForRecvedPacket.Initialize(sizeof(t_Recved_Packet), tssp.unRecvedPacketQueueSize))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_FixLenCircleBufForRecvedPacket.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!m_FixLenCircleBufForCloseSession.Initialize(sizeof(unsigned int), tssp.unCloseWorkItemQueueSize))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_FixLenCircleBufForCloseSession.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!m_RecvPacketPoolManager.Initialize(tssp.pppdForRecv, tssp.usppdForRecvSize))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_RecvPacketPoolManager.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!m_FixLenCircleBufForSendPacketForMainLogic.Initialize(sizeof(t_Send_Packet), tssp.unSendPacketSizeForMainLogic))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_FixLenCircleBufForSendPacketForMainLogic.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!m_FixLenCircleBufForSendPacket.Initialize(sizeof(t_Send_Packet), tssp.unSendPacketSizeForSendThread))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_FixLenCircleBufForSendPacket.Initialize\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!m_SendPacketPoolManager.Initialize(tssp.pppdForSend, tssp.usppdForSendSize))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !m_SendPacketPoolManager.Initialize\n"); 		 g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!InitializeConnectWorkManagerThreadManager(tssp.unConnectWorkItemCountForCircleBufLen))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, InitializeConnectWorkManagerThreadManager Failed \n"); 	
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!Initialized(tssp.pszIp, tssp.usPort))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !Initialized(tssp.pszIp, tssp.usPort)\n"); 
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	if (!Listen(tssp.usListenListSize))
	{
		char szError[512];
		sprintf(szError, "LSelectServer::Initialize, !Listen(tssp.usListenListSize)\n");
		g_ErrorWriter.WriteError(szError, strlen(szError));
		return false;
	}
	return true;
}
/**----------------------------------------------------------------------------
\brief  파일 IO 를 위해 파일을 오픈한다.

\param
\return
\code

\endcode
-----------------------------------------------------------------------------*/
DTSTATUS
FileIoHelper::FIOpenForRead(
IN std::wstring FilePath
)
{
	if (TRUE == Initialized()) { FIOClose(); }

	mReadOnly = TRUE;
	if (TRUE != is_file_existsW(FilePath.c_str()))
	{
			return DTS_NO_FILE_EXIST;
	}

#pragma warning(disable: 4127)
	DTSTATUS status = DTS_WINAPI_FAILED;
	do
	{
		mFileHandle = CreateFileW(
			FilePath.c_str(),
			GENERIC_READ,
			NULL,
			NULL,
			OPEN_EXISTING,
			FILE_ATTRIBUTE_NORMAL,
			NULL
			);
		if (INVALID_HANDLE_VALUE == mFileHandle)
		{
				break;
		}

		// check file size 
		// 
		if (TRUE != GetFileSizeEx(mFileHandle, &mFileSize))
		{
				break;
		}

		mFileMap = CreateFileMapping(
			mFileHandle,
			NULL,
			PAGE_READONLY,
			0,
			0,
			NULL
			);
		if (NULL == mFileMap)
		{
				break;
		}

		status = DTS_SUCCESS;
	} while (FALSE);
#pragma warning(default: 4127)

	if (TRUE != DT_SUCCEEDED(status))
	{
		if (INVALID_HANDLE_VALUE != mFileHandle)
		{
			CloseHandle(mFileHandle);
			mFileHandle = INVALID_HANDLE_VALUE;
		}
		if (NULL != mFileMap) CloseHandle(mFileMap);
	}

	return status;
}
Exemple #22
0
/**----------------------------------------------------------------------------
\brief		FileSize 바이트 짜리 파일을 생성한다.

\param
\return
\code

\endcode
-----------------------------------------------------------------------------*/
DTSTATUS
FileIoHelper::FIOCreateFile(
IN std::wstring FilePath,
IN LARGE_INTEGER FileSize
)
{
	if (TRUE == Initialized()) { FIOClose(); }
	if (FileSize.QuadPart == 0) return DTS_INVALID_PARAMETER;

	mReadOnly = FALSE;

#pragma warning(disable: 4127)
	DTSTATUS status = DTS_WINAPI_FAILED;
	do
	{
		mFileSize = FileSize;

		mFileHandle = CreateFileW(
			FilePath.c_str(),
			GENERIC_READ | GENERIC_WRITE,
			FILE_SHARE_READ,		// write 도중 다른 프로세스에서 읽기가 가능
			NULL,
			CREATE_ALWAYS,
			FILE_ATTRIBUTE_NORMAL,
			NULL
			);
		if (INVALID_HANDLE_VALUE == mFileHandle)
		{
			printf(
				"CreateFile(%ws) failed, gle=0x%08x",
				FilePath.c_str(),
				GetLastError()
				);
			break;
		}

		// increase file size
		// 
		if (TRUE != SetFilePointerEx(mFileHandle, mFileSize, NULL, FILE_BEGIN))
		{
			printf(
				"SetFilePointerEx( move to %I64d ) failed, gle=0x%08x",
				FileSize.QuadPart, GetLastError()
				);
			break;
		}

		if (TRUE != SetEndOfFile(mFileHandle))
		{
			printf("SetEndOfFile( ) failed, gle=0x%08x", GetLastError());
			break;
		}

		mFileMap = CreateFileMapping(
			mFileHandle,
			NULL,
			PAGE_READWRITE,
			0,
			0,
			NULL
			);
		if (NULL == mFileMap)
		{
			printf(
				"CreateFileMapping(%ws) failed, gle=0x%08x",
				FilePath.c_str(),
				GetLastError()
				);
			break;
		}

		status = DTS_SUCCESS;
	} while (FALSE);
#pragma warning(default: 4127)

	if (TRUE != DT_SUCCEEDED(status))
	{
		if (INVALID_HANDLE_VALUE != mFileHandle)
		{
			CloseHandle(mFileHandle);
			mFileHandle = INVALID_HANDLE_VALUE;
		}
		if (NULL != mFileMap) CloseHandle(mFileMap);
	}

	return status;
}
      //
      // Request
      //
      // Request sound effect data from the cache
      //
      Item * Request(Record *record)
      {
        ASSERT(Initialized());
        ASSERT(record);
        ASSERT(record->valid);
        ASSERT(record->fastFind);

        // Is this effect too large for the cache
        if (record->fastFind->Size() > maxCacheSize)
        {
          LOG_WARN(("File '%s' is too large for the cache", record->Name()));
          record->valid = FALSE;
          return (NULL);      
        }

        // Record if first time being played
        if (!record->freq)
        {
          actuallyUsed++;
        }

        // Increment the frequency of this effect
        record->freq++;

        // Step through each cache item
        for (NList<Item>::Iterator i(&items); *i; i++)
        {
          // Is this the one we're after
          if ((*i)->record == record)
          {
            cacheHits++;
            return (*i);
          }
        }

        // Record a cache miss
        cacheMisses++;
 
        // Make space for this new effect (will also shrink cache if max size decreased)
        while (items.GetCount() && (maxCacheSize - curCacheSize < record->fastFind->Size()))
        {
          // Try and remove a sound effect out of the cache
          if (!FlushItem())
          {
            // Unable to remove any effects
            return (NULL);
          }
        }

        ASSERT(maxCacheSize - curCacheSize >= record->fastFind->Size());

        // Open the file
        FileSys::DataFile *dFile = FileSys::Open(record->fastFind);

        // Should be found since already checked
        if (!dFile)
        {
          LOG_WARN(("File '%s' has vanished!", record->Name()));
          record->valid = FALSE;
          return (NULL);
        }

        // Let's just be extra careful, someone might swap data files on a server
        if (dFile->Size() != record->fastFind->Size())
        {
          LOG_WARN(("File '%s' has changed size!", record->Name()));
          record->valid = FALSE;
          return (NULL);
        }
  
        // Allocate memory for file data
        void *data = AIL_mem_alloc_lock(record->fastFind->Size());

        if (!data)
        {
          return (NULL);
        }

        // Read the data from disk
        if (dFile->Read(data, record->fastFind->Size()) != record->fastFind->Size())
        {
          // Free the memory we just allocated
          AIL_mem_free_lock(data);

          // Close the file
          FileSys::Close(dFile);

          // We won't try this one again
          record->valid = FALSE;

          LOG_WARN(("Error reading effect '%s' into cache", record->Name()));
          return (NULL);
        }

        // Close the file
        FileSys::Close(dFile);

        // Return a new cache item
        return (new Item(record, data));
      }