Esempio n. 1
0
/*
 * cmyth_recorder_check_channel()
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Request that the recorder 'rec' check the validity of the channel
 * specified by 'channame'.
 *
 * Return Value:
 *
 * Check the validity of a channel name.
 * Success: 1 - valid channel, 0 - invalid channel
 *
 * Failure: -(ERRNO)
 */
int
cmyth_recorder_check_channel(cmyth_recorder_t rec,
                             char *channame)
{
	int err;
	int ret = -1;
	char msg[256];

	if (!rec || !channame) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: invalid args "
			  "rec = %p, channame = %p\n",
			  __FUNCTION__, rec, channame);
		return -EINVAL;
	}

	pthread_mutex_lock(&mutex);

	snprintf(msg, sizeof(msg),
		 "QUERY_RECORDER %"PRIu32"[]:[]CHECK_CHANNEL[]:[]%s",
		 rec->rec_id, channame);

	if ((err=cmyth_send_message(rec->rec_conn, msg)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_send_message() failed (%d)\n",
			  __FUNCTION__, err);
		goto fail;
	}

	if ((err=cmyth_rcv_feedback(rec->rec_conn, "1")) < 0) {
		ret = 0;
		goto fail;
	}

	ret = 1;

    fail:
	pthread_mutex_unlock(&mutex);

	return ret;
}
Esempio n. 2
0
/*
 * cmyth_conn_reschedule_recordings(cmyth_conn_t rec, int recordid)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Issues a run of the re-scheduler.
 * Takes an optional recordid, or -1 performs a full run.
 *
 * Return Value:
 *
 * Success: 0
 *
 * Failure: -(ERRNO)
 */
int
cmyth_conn_reschedule_recordings(cmyth_conn_t conn, int recordid)
{
	int err = 0;
	int id;
	char msg[256];

	if (conn->conn_version < 15) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: protocol version doesn't support RESCHEDULE_RECORDINGS\n",
			  __FUNCTION__);
		return -1;
	}

	/*
	 * RESCHEDULE_RECORDINGS changed in protocol version 73:
	 *
	 * MATCH reschedule requests should be used when the guide data or a
	 * specific recording rule is changed. The syntax is as follows.
	 *
	 *    MATCH <recordid> <sourceid> <mplexid> <maxstarttime> <reason>
	 *
	 * CHECK reschedule requests should be used when the status of a
	 * specific episode is affected such as when "never record" or "allow
	 * re-record" are selected or a recording finishes or is deleted. The
	 * syntax is as follows.
	 *
	 *    CHECK <recstatus> <recordid> <findid> <reason>
	 *    <title>
	 *    <subtitle>
	 *    <description>
	 *    <programid>
	 */
	if (conn->conn_version < 73) {
		id = (recordid > 0 ? recordid : -1);
		snprintf(msg, sizeof(msg), "RESCHEDULE_RECORDINGS %i", id);
	} else {
		if (recordid == 0) {
			strncpy(msg, "RESCHEDULE_RECORDINGS []:[]CHECK 0 0 0 cmyth[]:[][]:[][]:[][]:[]**any**", sizeof(msg));
		} else {
			id = (recordid > 0 ? recordid : 0);
			snprintf(msg, sizeof(msg), "RESCHEDULE_RECORDINGS []:[]MATCH %i 0 0 - cmyth", id);
		}
	}

	pthread_mutex_lock(&mutex);

	if ((err = cmyth_send_message(conn, msg)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_send_message() failed (%d)\n",
			  __FUNCTION__, err);
		goto out;
	}

	if ((err=cmyth_rcv_feedback(conn, "1")) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_rcv_feedback() failed (%d)\n",
			  __FUNCTION__, err);
		goto out;
	}

out:
	pthread_mutex_unlock(&mutex);
	return err;
}