Exemplo n.º 1
0
void W_DragSourceStateHandler(WMDraggingInfo * info, XClientMessageEvent * event)
{
	WMView *view;
	W_DndState *newState;

	if (XDND_SOURCE_VIEW_STORED(info)) {
		if (XDND_SOURCE_STATE(info) != NULL) {
			view = XDND_SOURCE_VIEW(info);
#ifdef XDND_DEBUG

			printf("current source state: %s\n", stateName(XDND_SOURCE_STATE(info)));
#endif

			newState = (W_DndState *) XDND_SOURCE_STATE(info) (view, event, info);

#ifdef XDND_DEBUG

			printf("new source state: %s\n", stateName(newState));
#endif

			if (newState != NULL)
				XDND_SOURCE_STATE(info) = newState;
			/* else drop finished, and info has been flushed */
		}

	} else {
		wwarning("received DnD message without having a target");
	}
}
void TriaxialCompressionEngine::doStateTransition(stateNum nextState){
	if ( /* currentState==STATE_UNINITIALIZED && */ nextState==STATE_ISO_COMPACTION){
		sigma_iso=sigmaIsoCompaction;
		previousSigmaIso=sigma_iso;
	}
	else if(nextState==STATE_TRIAX_LOADING){
		sigma_iso=sigmaLateralConfinement;
		previousSigmaIso=sigma_iso;
		internalCompaction = false;
		if (frictionAngleDegree>0) setContactProperties(frictionAngleDegree);
		height0 = height; depth0 = depth; width0 = width;
		//compressionActivated = true;
		wall_bottom_activated=false; wall_top_activated=false;
		if(currentState==STATE_ISO_UNLOADING && !noFiles){ LOG_INFO("Speres -> /tmp/unloaded.spheres"); Shop::saveSpheresToFile("/tmp/unloaded.spheres"); }
		if(!firstRun && !noFiles) saveSimulation=true; // saving snapshot .xml will actually be done in ::action
		Phase1End = "Unloaded";
	}
	else if(currentState==STATE_ISO_COMPACTION && nextState==STATE_ISO_UNLOADING){
		sigma_iso=sigmaLateralConfinement;
		sigmaIsoCompaction = sigmaLateralConfinement;
		previousSigmaIso=sigma_iso;
		internalCompaction=false; // unloading will not change grain sizes
		if (frictionAngleDegree>0) setContactProperties(frictionAngleDegree);
		if(!firstRun && !noFiles) saveSimulation=true;
		Phase1End = "Compacted";
	}
	else if ((currentState==STATE_ISO_COMPACTION || currentState==STATE_ISO_UNLOADING) && nextState==STATE_LIMBO) {
	//urrentState==STATE_DIE_COMPACTION
		internalCompaction = false;
		if (frictionAngleDegree>0) setContactProperties(frictionAngleDegree);
		height0 = height; depth0 = depth; width0 = width;
		if(!noFiles) saveSimulation=true; // saving snapshot .xml will actually be done in ::action
		// stop simulation here, since nothing will happen from now on
		Phase1End = (currentState==STATE_ISO_COMPACTION ? "compacted" : "unloaded");
		if(!noFiles) Shop::saveSpheresToFile("/tmp/limbo.spheres");
		// Please keep this saving process intact, I'm tired of running 3 days simulations and getting nothing at the end!
		if(!firstRun && !noFiles) saveSimulation=true; // saving snapshot .xml will actually be done in ::action
	}
	else if( nextState==STATE_FIXED_POROSITY_COMPACTION){
		internalCompaction = false;
		wall_bottom_activated=false; wall_top_activated=false;
		wall_front_activated=false; wall_back_activated=false;
		wall_right_activated=false; wall_left_activated=false;
	}
	else { LOG_ERROR("Undefined transition from "<<stateName(currentState)<<" to "<<stateName(nextState)<<"! (ignored)"); return; }

	LOG_INFO("State transition from "<<stateName(currentState)<<" to "<<stateName(nextState)<<" done.");
	currentState=nextState;
	previousState=currentState; // should be always kept in sync, used to track manual changes to the .xml
}
Exemplo n.º 3
0
    void FalagardFrameWindow::render()
    {
        FrameWindow* w = (FrameWindow*)d_window;
        // do not render anything for the rolled-up state.
        if (w->isRolledup())
            return;

        // build state name
        String stateName(w->isDisabled() ? "Disabled" : (w->isActive() ? "Active" : "Inactive"));
        stateName += w->getTitlebar()->isVisible() ? "WithTitle" : "NoTitle";
        stateName += w->isFrameEnabled() ? "WithFrame" : "NoFrame";

        const StateImagery* imagery;

        try
        {
            // get WidgetLookFeel for the assigned look.
            const WidgetLookFeel& wlf = getLookNFeel();
            // try and get imagery for our current state
            imagery = &wlf.getStateImagery(stateName);
        }
        catch (UnknownObjectException&)
        {
            // log error so we know imagery is missing, and then quit.
            return;
        }

        // peform the rendering operation.
        imagery->render(*w);
    }
Exemplo n.º 4
0
void QKineticScrollerPrivate::timerEvent(QTimerEvent *e)
{
    if (e->timerId() != timerId) {
        QObject::timerEvent(e);
        return;
    }

    struct timerevent {
        QKineticScroller::State state;
        typedef void (QKineticScrollerPrivate::*timerhandler_t)();
        timerhandler_t handler;
    };

    timerevent timerevents[] = {
        { QKineticScroller::StateDragging, &QKineticScrollerPrivate::timerEventWhileDragging },
        { QKineticScroller::StateScrolling, &QKineticScrollerPrivate::timerEventWhileScrolling },
    };

    for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) {
        timerevent *te = timerevents + i;

        if (state == te->state) {
            (this->*te->handler)();
            return;
        }
    }

    if (timerId) {
        qWarning() << "Unhandled timer event, while in state " << stateName(state);
        killTimer(timerId);
        timerId = 0;
    }
    // otherwise this is a timer event that was already queued when the
    // timer was killed, so just ignore it
}
Exemplo n.º 5
0
status_t
ScreenSaverSettings::GetModuleState(const char* name, BMessage* stateMsg)
{
	BString stateName("modulesettings_");
	stateName += name;
	return fSettings.FindMessage(stateName.String(), stateMsg);
}
Exemplo n.º 6
0
void BufferQueue::dump(String8& result, const char* prefix,
        char* buffer, size_t SIZE) const
{
    Mutex::Autolock _l(mMutex);

    String8 fifo;
    int fifoSize = 0;
    Fifo::const_iterator i(mQueue.begin());
    while (i != mQueue.end()) {
       snprintf(buffer, SIZE, "%02d ", *i++);
       fifoSize++;
       fifo.append(buffer);
    }

    snprintf(buffer, SIZE,
            "%s-BufferQueue mBufferCount=%d, mSynchronousMode=%d, default-size=[%dx%d], "
            "mPixelFormat=%d, FIFO(%d)={%s}\n",
            prefix, mBufferCount, mSynchronousMode, mDefaultWidth,
            mDefaultHeight, mPixelFormat, fifoSize, fifo.string());
    result.append(buffer);


    struct {
        const char * operator()(int state) const {
            switch (state) {
                case BufferSlot::DEQUEUED: return "DEQUEUED";
                case BufferSlot::QUEUED: return "QUEUED";
                case BufferSlot::FREE: return "FREE";
                case BufferSlot::ACQUIRED: return "ACQUIRED";
                default: return "Unknown";
            }
        }
    } stateName;

    for (int i=0 ; i<mBufferCount ; i++) {
        const BufferSlot& slot(mSlots[i]);
        snprintf(buffer, SIZE,
                "%s%s[%02d] "
                "state=%-8s, crop=[%d,%d,%d,%d], "
                "xform=0x%02x, time=%#llx, scale=%s",
                prefix, (slot.mBufferState == BufferSlot::ACQUIRED)?">":" ", i,
                stateName(slot.mBufferState),
                slot.mCrop.left, slot.mCrop.top, slot.mCrop.right,
                slot.mCrop.bottom, slot.mTransform, slot.mTimestamp,
                scalingModeName(slot.mScalingMode)
        );
        result.append(buffer);

        const sp<GraphicBuffer>& buf(slot.mGraphicBuffer);
        if (buf != NULL) {
            snprintf(buffer, SIZE,
                    ", %p [%4ux%4u:%4u,%3X]",
                    buf->handle, buf->width, buf->height, buf->stride,
                    buf->format);
            result.append(buffer);
        }
        result.append("\n");
    }
}
Exemplo n.º 7
0
void MergeTool::chooseAction()
{
    m_merging = (m_mergeType == NormalMerge);
    if (m_merging)
        return;
    QMessageBox msgBox;
    msgBox.setWindowTitle(tr("Merge Conflict"));
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setStandardButtons(QMessageBox::Abort);
    msgBox.setText(tr("%1 merge conflict for \"%2\"\nLocal: %3\nRemote: %4")
                   .arg(mergeTypeName())
                   .arg(m_fileName)
                   .arg(stateName(m_localState, m_localInfo))
                   .arg(stateName(m_remoteState, m_remoteInfo))
                   );
    switch (m_mergeType) {
    case SubmoduleMerge:
    case SymbolicLinkMerge:
        addButton(&msgBox, tr("&Local"), 'l');
        addButton(&msgBox, tr("&Remote"), 'r');
        break;
    case DeletedMerge:
        if (m_localState == CreatedState || m_remoteState == CreatedState)
            addButton(&msgBox, tr("&Created"), 'c');
        else
            addButton(&msgBox, tr("&Modified"), 'm');
        addButton(&msgBox, tr("&Deleted"), 'd');
        break;
    default:
        break;
    }

    msgBox.exec();
    QByteArray ba;
    QVariant key;
    QAbstractButton *button = msgBox.clickedButton();
    if (button)
        key = button->property("key");
    // either the message box was closed without clicking anything, or abort was clicked
    if (!key.isValid())
        key = QVariant(QLatin1Char('a')); // abort
    ba.append(key.toChar().toLatin1());
    ba.append('\n');
    m_process->write(ba);
    m_process->waitForBytesWritten();
}
Exemplo n.º 8
0
void
ScreenSaverSettings::SetModuleState(const char* name, BMessage* stateMsg)
{
	BString stateName("modulesettings_");
	stateName += name;
	fSettings.RemoveName(stateName.String());
	fSettings.AddMessage(stateName.String(), stateMsg);
}
Exemplo n.º 9
0
void
Work::setState(Work::State st)
{
    auto maxR = getMaxRetries();
    if (st == WORK_FAILURE_RETRY && (mRetries >= maxR))
    {
        CLOG(WARNING, "Work")
            << "Reached retry limit " << maxR << " for " << getUniqueName();
        st = WORK_FAILURE_RAISE;
    }

    if (st != mState)
    {
        CLOG(DEBUG, "Work") << "work " << getUniqueName() << " : "
                            << stateName(mState) << " -> " << stateName(st);
        mState = st;
    }
}
Exemplo n.º 10
0
void MediaSession::setState(State state)
{
    LOG(Media, "MediaSession::setState(%p) - %s", this, stateName(state));

    if (m_state == state)
        return;

    m_state = state;

    client().mediaStateDidChange();
}
Exemplo n.º 11
0
void MediaSession::beginInterruption(InterruptionType type)
{
    LOG(Media, "MediaSession::beginInterruption(%p), state = %s", this, stateName(m_state));

    if (type == EnteringBackground && client().overrideBackgroundPlaybackRestriction())
        return;

    m_stateToRestore = state();
    m_notifyingClient = true;
    client().pausePlayback();
    setState(Interrupted);
    m_notifyingClient = false;
}
Exemplo n.º 12
0
int ICACHE_FLASH_ATTR cgiPropLoadFile(HttpdConnData *connData)
{
    PropellerConnection *connection = &myConnection;
    char fileName[128];
    int fileSize = 0;
    
    // check for the cleanup call
    if (connData->conn == NULL) {
        if (connection->file) {
            roffs_close(connection->file);
            connection->file = NULL;
        }
        return HTTPD_CGI_DONE;
    }

    if (connection->state != stIdle) {
        char buf[128];
        os_sprintf(buf, "Transfer already in progress: state %s\r\n", stateName(connection->state));
        httpdSendResponse(connData, 400, buf, -1);
        return HTTPD_CGI_DONE;
    }
    connData->cgiData = connection;
    connection->connData = connData;
    
    os_timer_setfn(&connection->timer, timerCallback, connection);
    
    if (httpdFindArg(connData->getArgs, "file", fileName, sizeof(fileName)) < 0) {
        httpdSendResponse(connData, 400, "Missing file argument\r\n", -1);
        return HTTPD_CGI_DONE;
    }

    if (!(connection->file = roffs_open(fileName))) {
        httpdSendResponse(connData, 400, "File not found\r\n", -1);
        return HTTPD_CGI_DONE;
    }
    fileSize = roffs_file_size(connection->file);

    if (!getIntArg(connData, "baud-rate", &connection->baudRate))
        connection->baudRate = flashConfig.loader_baud_rate;
    if (!getIntArg(connData, "final-baud-rate", &connection->finalBaudRate))
        connection->finalBaudRate = flashConfig.baud_rate;
    if (!getIntArg(connData, "reset-pin", &connection->resetPin))
        connection->resetPin = flashConfig.reset_pin;
    
    DBG("load-file: file %s, size %d, baud-rate %d, final-baud-rate %d, reset-pin %d\n", fileName, fileSize, connection->baudRate, connection->finalBaudRate, connection->resetPin);

    startLoading(connection, NULL, fileSize);

    return HTTPD_CGI_MORE;
}
Exemplo n.º 13
0
int ICACHE_FLASH_ATTR cgiPropLoad(HttpdConnData *connData)
{
    PropellerConnection *connection = &myConnection;
    
    // check for the cleanup call
    if (connData->conn == NULL)
        return HTTPD_CGI_DONE;

    if (connection->state != stIdle) {
        char buf[128];
        os_sprintf(buf, "Transfer already in progress: state %s\r\n", stateName(connection->state));
        httpdSendResponse(connData, 400, buf, -1);
        return HTTPD_CGI_DONE;
    }
    connData->cgiData = connection;
    connection->connData = connData;

    os_timer_setfn(&connection->timer, timerCallback, connection);
    
    if (connData->post->len == 0) {
        httpdSendResponse(connData, 400, "No data\r\n", -1);
        abortLoading(connection);
        return HTTPD_CGI_DONE;
    }
    else if (connData->post->buffLen != connData->post->len) {
        httpdSendResponse(connData, 400, "Data too large\r\n", -1);
        return HTTPD_CGI_DONE;
    }
    
    if (!getIntArg(connData, "baud-rate", &connection->baudRate))
        connection->baudRate = flashConfig.loader_baud_rate;
    if (!getIntArg(connData, "final-baud-rate", &connection->finalBaudRate))
        connection->finalBaudRate = flashConfig.baud_rate;
    if (!getIntArg(connData, "reset-pin", &connection->resetPin))
        connection->resetPin = flashConfig.reset_pin;
    if (!getIntArg(connData, "response-size", &connection->responseSize))
        connection->responseSize = 0;
    if (!getIntArg(connData, "response-timeout", &connection->responseTimeout))
        connection->responseTimeout = 1000;
    
    DBG("load: size %d, baud-rate %d, final-baud-rate %d, reset-pin %d\n", connData->post->buffLen, connection->baudRate, connection->finalBaudRate, connection->resetPin);
    if (connection->responseSize > 0)
        DBG("  responseSize %d, responseTimeout %d\n", connection->responseSize, connection->responseTimeout);

    connection->file = NULL;
    startLoading(connection, (uint8_t *)connData->post->buff, connData->post->buffLen);

    return HTTPD_CGI_MORE;
}
Exemplo n.º 14
0
//----------------------------------------------------------------------------//
void FalagardMenuItem::render()
{
    MenuItem* w = (MenuItem*)d_window;
    // build name of state we're in
    String stateName(w->isEffectiveDisabled() ? "Disabled" : "Enabled");

    String suffix;

	// only show opened imagery if the menu items popup window is not closing
	// (otherwise it might look odd)
    if (w->isOpened() && !(w->hasAutoPopup() && w->isPopupClosing()))
        suffix = "PopupOpen";
    else if (w->isPushed())
        suffix = w->isHovering() ? "Pushed" : "PushedOff";
    else if (w->isHovering())
        suffix = "Hover";
    else
        suffix = "Normal";

    const StateImagery* imagery;
    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();

    // try and get imagery for our current state
    if (wlf.isStateImageryPresent(stateName + suffix))
    {
        imagery = &wlf.getStateImagery(stateName + suffix);
    }
    else
    {
        imagery = &wlf.getStateImagery(stateName + "Normal");
    }

    // peform the rendering operation.
    imagery->render(*w);

    // only draw popup-open/closed-icon if we have a popup menu, and parent is not a menubar
    Window* parent_window = w->getParent();
    bool not_menubar = (!parent_window) ? true : !dynamic_cast<Menubar*>(parent_window);

    if (w->getPopupMenu() && not_menubar)
    {
        // get imagery for popup open/closed state
        imagery = &wlf.getStateImagery(w->isOpened() ? "PopupOpenIcon" : "PopupClosedIcon");
        // peform the rendering operation.
        imagery->render(*w);
    }
}
Exemplo n.º 15
0
bool MediaSession::clientWillPausePlayback()
{
    LOG(Media, "MediaSession::clientWillPausePlayback(%p)- state = %s", this, stateName(m_state));
    if (state() == Interrupted) {
        if (!m_notifyingClient) {
            m_stateToRestore = Paused;
            LOG(Media, "      setting stateToRestore to \"Paused\"");
        }
        return false;
    }
    
    setState(Paused);
    MediaSessionManager::sharedManager().sessionWillEndPlayback(*this);
    if (!m_clientDataBufferingTimer.isActive())
        m_clientDataBufferingTimer.startOneShot(kClientDataBufferingTimerThrottleDelay);
    return true;
}
Exemplo n.º 16
0
//print the status of all tasks in a table
int statsCmd(char **argv,unsigned short argc){
  extern CTL_TASK_t *ctl_task_list;
  int i;
  CTL_TASK_t *t=ctl_task_list;
  //format string
  const char *fmt="%-10s\t%u\t\t%c%-28s\t%lu\r\n";
  //print out nice header
  printf("\r\nName\t\tPriority\tState\t\t\t\tTime\r\n--------------------------------------------------------------------\r\n");
  //loop through tasks and print out info
  while(t!=NULL){
    printf(fmt,t->name,t->priority,(t==ctl_task_executing)?'*':' ',stateName(t->state),t->execution_time);
    t=t->next;
  }
  //add a blank line after table
  printf("\r\n");
  return 0;
}
Exemplo n.º 17
0
void
Work::scheduleRetry()
{
    if (mScheduled)
    {
        return;
    }

    if (getState() != WORK_FAILURE_RETRY)
    {
        std::string msg = fmt::format("retrying {} in state {}",
                                      getUniqueName(), stateName(getState()));
        CLOG(ERROR, "Work") << msg;
        throw std::runtime_error(msg);
    }

    if (!mRetryTimer)
    {
        mRetryTimer = std::make_unique<VirtualTimer>(mApp.getClock());
    }

    std::weak_ptr<Work> weak(
        std::static_pointer_cast<Work>(shared_from_this()));
    auto t = getRetryDelay();
    mRetryTimer->expires_from_now(t);
    CLOG(WARNING, "Work")
        << "Scheduling retry #" << (mRetries + 1) << "/" << mMaxRetries
        << " in " << std::chrono::duration_cast<std::chrono::seconds>(t).count()
        << " sec, for " << getUniqueName();
    mScheduled = true;
    mRetryTimer->async_wait(
        [weak]() {
            auto self = weak.lock();
            if (!self)
            {
                return;
            }
            self->mScheduled = false;
            self->mRetries++;
            self->reset();
            self->advance();
        },
        VirtualTimer::onFailureNoop);
}
void SurfaceMediaSource::dump(String8& result, const char* prefix,
        char* buffer, size_t SIZE) const
{
    Mutex::Autolock _l(mMutex);
    snprintf(buffer, SIZE,
            "%smBufferCount=%d, mSynchronousMode=%d, default-size=[%dx%d], "
            "mPixelFormat=%d, \n",
            prefix, mBufferCount, mSynchronousMode, mDefaultWidth, mDefaultHeight,
            mPixelFormat);
    result.append(buffer);

    String8 fifo;
    int fifoSize = 0;
    Fifo::const_iterator i(mQueue.begin());
    while (i != mQueue.end()) {
        snprintf(buffer, SIZE, "%02d ", *i++);
        fifoSize++;
        fifo.append(buffer);
    }

    result.append(buffer);

    struct {
        const char * operator()(int state) const {
            switch (state) {
                case BufferSlot::DEQUEUED: return "DEQUEUED";
                case BufferSlot::QUEUED: return "QUEUED";
                case BufferSlot::FREE: return "FREE";
                default: return "Unknown";
            }
        }
    } stateName;

    for (int i = 0; i < mBufferCount; i++) {
        const BufferSlot& slot(mSlots[i]);
        snprintf(buffer, SIZE,
                "%s%s[%02d] state=%-8s, "
                "timestamp=%lld\n",
                prefix, (i==mCurrentSlot)?">":" ", i, stateName(slot.mBufferState),
                slot.mTimestamp
        );
        result.append(buffer);
    }
}
Exemplo n.º 19
0
/*
 * Feed an event to a WTP responder state machine. Handle all errors yourself,
 * do not report them to the caller. Note: Do not put {}s of the else block 
 * inside the macro definition. 
 */
static void wtls_event_handle(WTLSMachine * wtls_machine, WAPEvent * event)
{
     debug("wap.wtls", 0, "WTLS: wtls_machine %ld, state %s, event %s.", 
         wtls_machine->mid, stateName(wtls_machine->state),
	   wap_event_name(event->type));

	/* for T_Unitdata_Ind PDUs */
   if (event->type == T_Unitdata_Ind) {
		/* if encryption: decrypt all pdus in the list */
      if (wtls_machine->encrypted)
         wtls_decrypt_pdu_list(wtls_machine,
                     event->u.T_Unitdata_Ind.pdu_list);
		/* add all handshake data to wtls_machine->handshake_data */
		//add_all_handshake_data(wtls_machine, event->u.T_Unitdata_Ind.pdu_list);
	}
#define STATE_NAME(state)
#define ROW(wtls_state, event_type, condition, action, next_state) \
	     if (wtls_machine->state == wtls_state && \
		event->type == event_type && \
		(condition)) { \
		action \
		wtls_machine->state = next_state; \
		debug("wap.wtls", 0, "WTLS %ld: New state %s", wtls_machine->mid, #next_state); \
	     } else 
#include "wtls_state-decl.h"
	     {
		error(0, "WTLS: handle_event: unhandled event!");
      debug("wap.wtls", 0,
            "WTLS: handle_event: Unhandled event was:");
		wap_event_destroy(event);
		return;
	     }

   if (event)
	wap_event_destroy(event);  

   if (wtls_machine->state == NULL_STATE) {
     	wtls_machine_destroy(wtls_machine);
      wtls_machine = NULL;
   }
}
Exemplo n.º 20
0
bool ofAddon::checkCorrectPlatform(ConfigParseState state){
	switch(state){
	case Meta:
		return true;
	case Common:
		return true;
	case Linux:
	case Linux64:
	case WinCB:
	case VS:
	case LinuxARMv6:
	case LinuxARMv7:
	case AndroidARMv5:
	case AndroidARMv7:
	case iOS:
	case OSX:
		return platform==stateName(state);
	case Unknown:
	default:
		return false;
	}
}
Exemplo n.º 21
0
//-----------------------------------------------------------------------------
// Name:  run
// Desc:  Executes the state with the given address
//-----------------------------------------------------------------------------
void EvidyonClient::run(State state) {
  switch(state) {
    case VCS_STARTUP:       stateStartup(); break;
    case VCS_CONNECT:       stateConnect(); break;
    case VCS_ACCOUNT_LOGIN: stateAccountLogin(); break;
//        case VCS_CREATE_ACCOUNT:stateCreateAccount(); break;
    case VCS_LOGGED_INTO_ACCOUNT:   stateLoggedIntoAccount(); break;
    case VCS_WORLD_MAIN:    stateWorldMain(); break;
    case VCS_NO_CONNECTION: stateNoConnection(); break;
    case VCS_DISCONNECT:    stateDisconnect(); break;
    case VCS_SHUTDOWN:      stateShutdown(); break;
    case VCS_CREATE_CHARACTER: stateCreateCharacter(); break;
    case VCS_LOST_D3DDEVICE: stateLostD3DDevice(); break;
    case VCS_CREDITS: stateCredits(); break;

    // Testing-only states
    case VCS_DEBUGSTATESANDBOX:   debugStateSandbox(); break;

    // Output a warning if we don't know what the state is
    default:
        DEBUG_ERROR("Tried to execute unknown state:  %i (%s)", (int)state, stateName(state));
        break;
  }
}
Exemplo n.º 22
0
int ICACHE_FLASH_ATTR cgiPropReset(HttpdConnData *connData)
{
    PropellerConnection *connection = &myConnection;
    
    // check for the cleanup call
    if (connData->conn == NULL)
        return HTTPD_CGI_DONE;

    if (connection->state != stIdle) {
        char buf[128];
        os_sprintf(buf, "Transfer already in progress: state %s\r\n", stateName(connection->state));
        httpdSendResponse(connData, 400, buf, -1);
        return HTTPD_CGI_DONE;
    }
    connData->cgiData = connection;
    connection->connData = connData;

    // turn off SSCP during loading
    sscp_enable(0);

    os_timer_setfn(&connection->timer, timerCallback, connection);
    
    if (!getIntArg(connData, "reset-pin", &connection->resetPin))
        connection->resetPin = flashConfig.reset_pin;

    DBG("reset: reset-pin %d\n", connection->resetPin);

    connection->image = NULL;

    GPIO_OUTPUT_SET(connection->resetPin, 0);
    connection->state = stReset;
    
    armTimer(connection, RESET_DELAY_1);

    return HTTPD_CGI_MORE;
}
Exemplo n.º 23
0
void PlatformMediaSession::beginInterruption(InterruptionType type)
{
    LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);

    if (++m_interruptionCount > 1)
        return;

    if (client().shouldOverrideBackgroundPlaybackRestriction(type)) {
        LOG(Media, "PlatformMediaSession::beginInterruption(%p), returning early because client says to override interruption", this);
        return;
    }

    m_stateToRestore = state();
    m_notifyingClient = true;
    setState(Interrupted);
    m_interruptionType = type;
    client().suspendPlayback();
    m_notifyingClient = false;
}
Exemplo n.º 24
0
void PlatformMediaSession::setState(State state)
{
    LOG(Media, "PlatformMediaSession::setState(%p) - %s", this, stateName(state));
    m_state = state;
}
Exemplo n.º 25
0
bool PlatformMediaSession::clientWillPausePlayback()
{
    if (m_notifyingClient)
        return true;

    LOG(Media, "PlatformMediaSession::clientWillPausePlayback(%p)- state = %s", this, stateName(m_state));
    if (state() == Interrupted) {
        m_stateToRestore = Paused;
        LOG(Media, "      setting stateToRestore to \"Paused\"");
        return false;
    }
    
    setState(Paused);
    PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this);
    scheduleClientDataBufferingCheck();
    return true;
}
Exemplo n.º 26
0
void PlatformMediaSession::clientWillBeginAutoplaying()
{
    if (m_notifyingClient)
        return;

    LOG(Media, "PlatformMediaSession::clientWillBeginAutoplaying(%p)- state = %s", this, stateName(m_state));
    if (state() == Interrupted) {
        m_stateToRestore = Autoplaying;
        LOG(Media, "      setting stateToRestore to \"Autoplaying\"");
        return;
    }

    setState(Autoplaying);
    updateClientDataBuffering();
}
Exemplo n.º 27
0
void PlatformMediaSession::endInterruption(EndInterruptionFlags flags)
{
    LOG(Media, "PlatformMediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i", this, (int)flags, stateName(m_stateToRestore), m_interruptionCount);

    if (!m_interruptionCount) {
        LOG(Media, "PlatformMediaSession::endInterruption(%p) - !! ignoring spurious interruption end !!", this);
        return;
    }

    if (--m_interruptionCount)
        return;

    State stateToRestore = m_stateToRestore;
    m_stateToRestore = Idle;
    m_interruptionType = NoInterruption;
    setState(stateToRestore);

    if (stateToRestore == Autoplaying)
        client().resumeAutoplaying();

    bool shouldResume = flags & MayResumePlaying && stateToRestore == Playing;
    client().mayResumePlayback(shouldResume);
}
Exemplo n.º 28
0
static void ICACHE_FLASH_ATTR timerCallback(void *data)
{
    PropellerConnection *connection = (PropellerConnection *)data;
    int finished;
    
#ifdef STATE_DEBUG
    DBG("TIMER %s", stateName(connection->state));
#endif

    switch (connection->state) {
    case stIdle:
        // shouldn't happen
        break;
    case stReset:
        GPIO_OUTPUT_SET(connection->resetPin, 1);
        armTimer(connection, RESET_DELAY_2);
        if (connection->image || connection->file) {
            connection->state = stTxHandshake;
            programmingCB = readCallback;
        }
        else {
            httpdSendResponse(connection->connData, 200, "", -1);
            connection->state = stIdle;
        }
        break;
    case stTxHandshake:
        connection->state = stRxHandshakeStart;
        ploadInitiateHandshake(connection);
        armTimer(connection, RX_HANDSHAKE_TIMEOUT);
        break;
    case stRxHandshakeStart:
    case stRxHandshake:
        httpdSendResponse(connection->connData, 400, "RX handshake timeout\r\n", -1);
        abortLoading(connection);
        break;
    case stLoadContinue:
        if (ploadLoadImageContinue(connection, ltDownloadAndRun, &finished) == 0) {
            if (finished) {
                armTimer(connection, connection->retryDelay);
                connection->state = stVerifyChecksum;
            }
            else {
                armTimer(connection, LOAD_SEGMENT_DELAY);
                connection->state = stLoadContinue;
            }
        }
        break;
    case stVerifyChecksum:
        if (connection->retriesRemaining > 0) {
            uart_tx_one_char(UART0, 0xF9);
            armTimer(connection, connection->retryDelay);
            --connection->retriesRemaining;
        }
        else {
            httpdSendResponse(connection->connData, 400, "Checksum timeout\r\n", -1);
            abortLoading(connection);
        }
        break;
    case stStartAck:
        httpdSendResponse(connection->connData, 400, "StartAck timeout\r\n", -1);
        abortLoading(connection);
        break;
    default:
        break;
    }
    
#ifdef STATE_DEBUG
    DBG(" -> %s\n", stateName(connection->state));
#endif
}
Exemplo n.º 29
0
void MediaSession::endInterruption(EndInterruptionFlags flags)
{
    LOG(Media, "MediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s", this, (int)flags, stateName(m_stateToRestore));

    State stateToRestore = m_stateToRestore;
    m_stateToRestore = Idle;
    setState(Paused);

    if (flags & MayResumePlaying && stateToRestore == Playing) {
        LOG(Media, "MediaSession::endInterruption - resuming playback");
        client().resumePlayback();
    }
}
Exemplo n.º 30
0
static void ICACHE_FLASH_ATTR readCallback(char *buf, short length)
{
    PropellerConnection *connection = &myConnection;
    int cnt, version, finished;
    
#ifdef STATE_DEBUG
    DBG("READ: length %d, state %s", length, stateName(connection->state));
#endif

    switch (connection->state) {
    case stIdle:
    case stReset:
    case stTxHandshake:
    case stLoadContinue:
        // just ignore data received when we're not expecting it
        break;
    case stRxHandshakeStart:    // skip junk before handshake
        while (length > 0) {
            if (*buf == 0xEE) {
                connection->state = stRxHandshake;
                break;
            }
            DBG("Ignoring %02x looking for 0xEE\n", *buf);
            --length;
            ++buf;
        }
        if (connection->state == stRxHandshakeStart || length == 0)
            break;
        // fall through
    case stRxHandshake:
    case stStartAck:
        if ((cnt = length) > connection->bytesRemaining)
            cnt = connection->bytesRemaining;
        memcpy(&connection->buffer[connection->bytesReceived], buf, cnt);
        connection->bytesReceived += cnt;
        if ((connection->bytesRemaining -= cnt) == 0) {
            switch (connection->state) {
            case stRxHandshakeStart:
            case stRxHandshake:        
                if (ploadVerifyHandshakeResponse(connection, &version) == 0) {
                    if (ploadLoadImage(connection, ltDownloadAndRun, &finished) == 0) {
                        if (finished) {
                            armTimer(connection, connection->retryDelay);
                            connection->state = stVerifyChecksum;
                        }
                        else {
                            armTimer(connection, LOAD_SEGMENT_DELAY);
                            connection->state = stLoadContinue;
                        }
                    }
                    else {
                        httpdSendResponse(connection->connData, 400, "Load image failed\r\n", -1);
                        abortLoading(connection);
                    }
                }
                else {
                    httpdSendResponse(connection->connData, 400, "RX handshake failed\r\n", -1);
                    abortLoading(connection);
                }
                break;
            case stStartAck:
                httpdSendResponse(connection->connData, 200, (char *)connection->buffer, connection->bytesReceived);
                finishLoading(connection);
                break;
            default:
                break;
            }
        }
        break;
    case stVerifyChecksum:
        if (buf[0] == 0xFE) {
            if ((connection->bytesRemaining = connection->responseSize) > 0) {
                connection->bytesReceived = 0;
                armTimer(connection, connection->responseTimeout);
                connection->state = stStartAck;
            }
            else {
                httpdSendResponse(connection->connData, 200, "", -1);
                finishLoading(connection);
            }
        }
        else {
            httpdSendResponse(connection->connData, 400, "Checksum error\r\n", -1);
            abortLoading(connection);
        }
        break;
    default:
        break;
    }
    
#ifdef STATE_DEBUG
    DBG(" -> %s\n", stateName(connection->state));
#endif
}