Logo Search packages:      
Sourcecode: libmpdclient version File versions  Download package

bool mpd_send_idle_mask ( struct mpd_connection connection,
enum mpd_idle  mask 
)

Same as mpd_send_idle(), but listen only on specific events.

Parameters:
connection the connection to MPD
mask a bit mask of idle events; must not be 0
Returns:
a positive job id on success, 0 on error

Definition at line 142 of file idle.c.

References mpd_connection::error, MPD_ERROR_ARGUMENT, mpd_send_command(), and mpd_send_idle_mask().

Referenced by mpd_run_idle_mask(), and mpd_send_idle_mask().

{
      /* this buffer is large enough even for the full mask */
      char buffer[128] = "idle";

      assert(mask != 0);

      if (mpd_error_is_defined(&connection->error))
            return false;

      for (unsigned i = 0; idle_names[i] != NULL; ++i) {
            if (mask & (1 << i)) {
                  mask &= ~(1 << i);
                  strcat(buffer, " ");
                  strcat(buffer, idle_names[i]);
            }
      }

      if (mask != 0) {
            /* the client expects that all flags are supported,
               because he might block forever if an event is not
               delivered as expected */
            mpd_error_code(&connection->error, MPD_ERROR_ARGUMENT);
            mpd_error_printf(&connection->error,
                         "Unsupported idle flags: 0x%x", mask);
            return false;
      }

      return mpd_send_command(connection, buffer, NULL);
}


Generated by  Doxygen 1.6.0   Back to index