Exemplo n.º 1
0
func newEntry(jobID string, ticket *cdd.CloudJobTicket) *entry {
	var state cdd.JobState
	if ticket == nil {
		state.Type = cdd.JobStateDraft
	} else {
		state.Type = cdd.JobStateQueued
	}
	entry := entry{
		jobID:     jobID,
		ticket:    ticket,
		expiresAt: time.Now().Add(jobLifetime),
		state:     state,
	}

	return &entry
}
Exemplo n.º 2
0
func convertJobState(wsStatus uint32) *cdd.JobState {
	var state cdd.JobState

	if wsStatus&(JOB_STATUS_SPOOLING|JOB_STATUS_PRINTING) != 0 {
		state.Type = cdd.JobStateInProgress

	} else if wsStatus&(JOB_STATUS_PRINTED|JOB_STATUS_COMPLETE) != 0 {
		state.Type = cdd.JobStateDone

	} else if wsStatus&JOB_STATUS_PAUSED != 0 || wsStatus == 0 {
		state.Type = cdd.JobStateDone

	} else if wsStatus&JOB_STATUS_ERROR != 0 {
		state.Type = cdd.JobStateAborted
		state.DeviceActionCause = &cdd.DeviceActionCause{cdd.DeviceActionCausePrintFailure}

	} else if wsStatus&(JOB_STATUS_DELETING|JOB_STATUS_DELETED) != 0 {
		state.Type = cdd.JobStateAborted
		state.UserActionCause = &cdd.UserActionCause{cdd.UserActionCauseCanceled}

	} else if wsStatus&(JOB_STATUS_OFFLINE|JOB_STATUS_PAPEROUT|JOB_STATUS_BLOCKED_DEVQ|JOB_STATUS_USER_INTERVENTION) != 0 {
		state.Type = cdd.JobStateStopped
		state.DeviceStateCause = &cdd.DeviceStateCause{cdd.DeviceStateCauseOther}

	} else {
		// Don't know what is going on. Get the job out of our queue.
		state.Type = cdd.JobStateAborted
		state.DeviceActionCause = &cdd.DeviceActionCause{cdd.DeviceActionCauseOther}
	}

	return &state
}