+ * \sa com_cpsi().
+ */
+enum cpsi_flags {
+ /** Whether the lyrics id should be copied. */
+ CPSI_FLAG_COPY_LYRICS_ID = 1,
+ /** Whether the image id should be copied. */
+ CPSI_FLAG_COPY_IMAGE_ID = 2,
+ /** Whether the lastplayed time should be copied. */
+ CPSI_FLAG_COPY_LASTPLAYED = 4,
+ /** Whether the numplayed count should be copied. */
+ CPSI_FLAG_COPY_NUMPLAYED = 8,
+ /** Whether the attributes should be copied. */
+ CPSI_FLAG_COPY_ATTRIBUTES = 16,
+ /** Activates verbose mode. */
+ CPSI_FLAG_VERBOSE = 32,
+};
+
+/** Data passed to the action handler of com_cpsi(). */
+struct cpsi_action_data {
+ /** command line flags (see \ref cpsi_flags). */
+ unsigned flags;
+ /** Number of audio files changed. */
+ unsigned num_copied;
+ /** Message buffer. */
+ struct para_buffer pb;
+ /** Values are copied from here. */
+ struct afs_info source_afsi;
+};
+
+static int copy_selector_info(__a_unused struct osl_table *table,
+ struct osl_row *row, const char *name, void *data)
+{
+ struct cpsi_action_data *cad = data;
+ struct osl_object target_afsi_obj;
+ int ret;
+ struct afs_info old_afsi, target_afsi;
+ struct afsi_change_event_data aced;
+
+ ret = get_afsi_object_of_row(row, &target_afsi_obj);
+ if (ret < 0)
+ return ret;
+ load_afsi(&target_afsi, &target_afsi_obj);
+ old_afsi = target_afsi;
+ if (cad->flags & CPSI_FLAG_COPY_LYRICS_ID)
+ target_afsi.lyrics_id = cad->source_afsi.lyrics_id;
+ if (cad->flags & CPSI_FLAG_COPY_IMAGE_ID)
+ target_afsi.image_id = cad->source_afsi.image_id;
+ if (cad->flags & CPSI_FLAG_COPY_LASTPLAYED)
+ target_afsi.last_played = cad->source_afsi.last_played;
+ if (cad->flags & CPSI_FLAG_COPY_NUMPLAYED)
+ target_afsi.num_played = cad->source_afsi.num_played;
+ if (cad->flags & CPSI_FLAG_COPY_ATTRIBUTES)
+ target_afsi.attributes = cad->source_afsi.attributes;
+ save_afsi(&target_afsi, &target_afsi_obj); /* in-place update */
+ cad->num_copied++;
+ if (cad->flags & CPSI_FLAG_VERBOSE)
+ para_printf(&cad->pb, "copied afsi to %s\n", name);
+ aced.aft_row = row;
+ aced.old_afsi = &old_afsi;
+ afs_event(AFSI_CHANGE, &cad->pb, &aced);
+ return 1;
+}