Esempio n. 1
0
void DopeApp::SignalOkToConnect(bool ok)
{
    if (ok)
    {
        // use a different handler to register PersistentDataStatus to get the correct registration time.
        Safir::Dob::Typesystem::HandlerId entityHandler(L"DOPE_ENTITY_HANDLER"); 
        
        m_dobConnection.RegisterEntityHandler(Safir::Dob::PersistentDataStatus::ClassTypeId, 
                                              entityHandler,
                                              Safir::Dob::InstanceIdPolicy::HandlerDecidesInstanceId,
                                              this);
        
        Safir::Dob::PersistentDataStatusPtr status = Safir::Dob::PersistentDataStatus::Create();
        status->State().SetVal( Safir::Dob::PersistentDataState::Started);
        m_dobConnection.SetAll(status, m_instanceId, entityHandler);
        
        m_thread.join();
        m_thread = boost::thread();
    }
    else
    {
        m_thread.join();
        m_thread = boost::thread();

        //not ok
        throw StartupError();
    }
}
Esempio n. 2
0
//-------------------------------------------------------
DopeApp::DopeApp():
    m_dispatcher(m_dobConnection, m_ioService),
    m_instanceId(Safir::Dob::ThisNodeParameters::NodeNumber()),
    m_persistenceStarted(false),
    m_persistenceInitialized(false),
    m_keeper(m_dobConnection),
    m_debug(L"DopeApp")
{
    //perform sanity check!
    if (!Safir::Dob::PersistenceParameters::SystemHasPersistence())
    {
        Safir::Logging::SendSystemLog(Safir::Logging::Critical,
                                      L"Configuration error: Dope was started even though Safir.Dob.PersistenceParameters.SystemHasPersistence is set to false!");
        throw StartupError();
    }

    try
    {
        m_dobConnection.Open(L"DOPE", L"0", PERSISTENCE_CONTEXT, this, &m_dispatcher);
        m_debug << "Opened DOB connection"<<std::endl;
    }
    catch (Safir::Dob::NotOpenException e)
    {
        Safir::Logging::SendSystemLog(Safir::Logging::Critical,
                                      L"Failed to connect to Dob. Maybe Dope is already started on this node.");
        throw StartupError();
    }

    Safir::Application::TracerBackdoor::Start(m_dobConnection);
    m_keeper.Start(*this);
    m_debug << "Started keeper"<<std::endl;

    // Start pending registration to try be the active dope.
    m_dobConnection.RegisterEntityHandlerPending(Safir::Dob::PersistentDataStatus::ClassTypeId, 
        m_handlerId,
        Safir::Dob::InstanceIdPolicy::HandlerDecidesInstanceId,
        this);

    // Subscribe to see which dope got the active state.
    m_dobConnection.SubscribeEntity(Safir::Dob::PersistentDataStatus::ClassTypeId, false, false, false, this);


}
Esempio n. 3
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    if( !uistart() )
        StartupError( ERR_WIND_NO_MORE_WINDOWS );

    BIOSKeyboardInit();

    EditVars.WindMaxHeight = LINES;
    EditVars.WindMaxWidth = COLS;
    Scrn = (void *)(UIData->screen.origin);

    EditFlags.Color = true;
    EditFlags.HasSystemMouse = true;

} /* ScreenInit */
Esempio n. 4
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    unsigned short              solvb;
    struct _VIOCONFIGINFO       config;
    struct _VIOMODEINFO         vioMode;
    void * SEG16                ptr;

    /* Set the cb member of VIOMODEINFO/VIOCONFIGINFO to smaller values
     * in order to be backward compatible with old OS/2 versions.
     */
    vioMode.cb = offsetof( VIOMODEINFO, buf_addr );
    if( VioGetMode( &vioMode, 0 ) != 0 ) {
        StartupError( ERR_WIND_INVALID );
    }
    WindMaxWidth = vioMode.col;
    WindMaxHeight = vioMode.row;

    config.cb = offsetof( VIOCONFIGINFO, Configuration );
    if( VioGetConfig( 0, &config, 0 ) != 0 ) {
        StartupError( ERR_WIND_INVALID );
    }
    if( config.display == 3 ) {
        EditFlags.BlackAndWhite = TRUE;
    } else {
        if( config.adapter == 0 ) {
            EditFlags.Monocolor = TRUE;
        } else {
            EditFlags.Color = TRUE;
        }
    }

    VioGetBuf( (PULONG) &ptr, (PUSHORT) &solvb, 0);
    Scrn = ptr;
    ScreenPage( 0 );

} /* ScreenInit */
Esempio n. 5
0
//-------------------------------------------------------
DopeApp::DopeApp():
    m_dispatcher(m_dobConnection, m_ioService),
    m_persistenceStarted(false),
    m_persistenceInitialized(false),
    m_keeper(m_dobConnection),
    m_debug(L"DopeApp")
{
    try
    {
        m_dobConnection.Open(L"DOPE", L"0", PERSISTENCE_CONTEXT, this, &m_dispatcher);
        m_debug << "Opened DOB connection"<<std::endl;
    }
    catch (Safir::Dob::NotOpenException e)
    {
        Safir::Logging::SendSystemLog(Safir::Logging::Critical,
                                      L"Failed to connect to Dob. Maybe Dope is already started on this node.");
        throw StartupError();
    }

    m_instanceId = Safir::Dob::Typesystem::InstanceId
        (Safir::Dob::ConnectionAspectMisc(m_dobConnection).GetNodeId());

    Safir::Application::TracerBackdoor::Start(m_dobConnection);
    m_keeper.Start(*this);
    m_debug << "Started keeper"<<std::endl;

    // Start pending registration to try be the active dope.
    m_dobConnection.RegisterEntityHandlerPending(Safir::Dob::PersistentDataStatus::ClassTypeId,
        m_handlerId,
        Safir::Dob::InstanceIdPolicy::HandlerDecidesInstanceId,
        this);

    // Subscribe to see which dope got the active state.
    m_dobConnection.SubscribeEntity(Safir::Dob::PersistentDataStatus::ClassTypeId, false, false, false, this);


    if (Safir::Dob::PersistenceParameters::StandaloneMode())
    {
        Safir::Logging::SendSystemLog(Safir::Logging::Warning,
                                      L"Dope is running in DEPRECATED Standalone Mode!");
    }
}
//-------------------------------------------------------
void PersistenceHandler::Start(bool restore)
{
    if (m_started)
    {
        m_debug << "Persistence handling already started."<< std::endl;
        return;
    }

    m_debug << "Starting Persistence handling"<< std::endl;

    try
    {
        m_dobConnection.Open(L"DOPE_SUBSCRIBE", L"0", PERSISTENCE_CONTEXT, nullptr, &m_dispatcher);
        m_debug << "Opened DOB connection DOPE_SUBSCRIBE"<<std::endl;
    }
    catch (Safir::Dob::NotOpenException e)
    {
        Safir::Logging::SendSystemLog(Safir::Logging::Critical,
                                      L"PersistenceHandler failed to connect to Dob, Maybe Dope is already running?");
        throw StartupError();
    }

    PerformStartupChecks();

    if (restore)
    {
        // Normal startup
        try
        {
            m_debug << "Restoring all stored entities"<< std::endl;
            RestoreAll();
        }
        catch (const Safir::Dob::AccessDeniedException & e)
        {
            throw Safir::Dob::Typesystem::SoftwareViolationException
                (std::wstring(L"DOSE gave me AccessDeniedException when I was trying to Set persisted data! AccessDeniedException info: ") +
                e.GetExceptionInfo(),__WFILE__,__LINE__);
        }

        StartSubscriptions();
        ReportPersistentDataReady();
    }
    else
    {
        // Failover startup, don't restore anything.

        if (Safir::Dob::PersistenceParameters::StandaloneMode())
        {
            // If standalone mode then clear all before starting subscriptions
            RemoveAll();
        }

        StartSubscriptions();
    }

    // Start timer
    HandleTimeout();

    m_started = true;
    m_debug << "Persistence handling successfully started"<<std::endl;
}