예제 #1
0
static updater_quit_t *
updater_connect (updater_t *updater, GMainLoop *ml)
{
	updater_quit_t *quit;
	gchar *path;

	g_return_val_if_fail (updater, NULL);
	g_return_val_if_fail (updater->conn, NULL);
	g_return_val_if_fail (ml, NULL);

	path = getenv ("XMMS_PATH");

	if (!xmmsc_connect (updater->conn, path)) {
		g_warning ("Unable to connect to XMMS2");
		return NULL;
	}

	quit = g_new0 (updater_quit_t, 1);
	quit->updater = updater;
	quit->ml = ml;
	quit->source = xmmsc_mainloop_gmain_init (updater->conn);

	xmmsc_disconnect_callback_set (updater->conn, updater_quit, quit);

	return quit;
}
예제 #2
0
int 
main (int argc, char **argv)
{
	GIOChannel *gio;
	GMainLoop *ml;
	gchar *path;
	gchar *tmp;
	xmmsc_connection_t *conn;
	xmmsc_result_t *res;
	xmonitor_t *mon;
	gint fd;

	conn = xmmsc_init ("xmms-medialib-updater");
	path = getenv ("XMMS_PATH");
	if (!xmmsc_connect (conn, path)) {
		ERR ("Could not connect to xmms2d %s", xmmsc_get_last_error (conn));
		return EXIT_FAILURE;
	}

	ml = g_main_loop_new (NULL, FALSE);
	xmmsc_mainloop_gmain_init (conn);
	xmmsc_disconnect_callback_set (conn, quit, ml);

	mon = g_new0 (xmonitor_t, 1);
	fd = monitor_init (mon);
	mon->conn = conn;

	if (fd == -1) {
		ERR ("Couldn't initalize monitor");
		return EXIT_FAILURE;
	}


	tmp = getenv("XMMS_DEBUG");
	if (!tmp) {
		g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE | G_LOG_FLAG_RECURSION, 
				   message_handler, NULL);
	}

	gio = g_io_channel_unix_new (fd);
	g_io_add_watch (gio, G_IO_IN, s_callback, mon);

	res = xmmsc_configval_register (conn, "mlibupdater.watch_dirs", "");
	xmmsc_result_notifier_set (res, handle_configval, mon);
	xmmsc_result_unref (res);

	res = xmmsc_broadcast_configval_changed (conn);
	xmmsc_result_notifier_set (res, handle_config_changed, mon);
	xmmsc_result_unref (res);

	g_main_loop_run (ml);

	return EXIT_SUCCESS;
}
예제 #3
0
	void
	Client::setDisconnectCallback( const DisconnectCallback::value_type& slot )
	{

		if( !dc_ ) {
			dc_ = new DisconnectCallback;
			xmmsc_disconnect_callback_set( conn_, &disconnect_callback,
			                               static_cast< void* >( dc_ ) );
		}
		dc_->push_back( slot );

	}
예제 #4
0
static gboolean
ol_player_xmms2_connect ()
{
  /* ol_log_func (); */
  if (connection == NULL && connected == FALSE && !ol_player_xmms2_init ())
    return FALSE;
  connected = xmmsc_connect (connection, getenv ("XMMS_PATH"));
  if (connected)
  {
    xmmsc_disconnect_callback_set (connection, disconnect_callback, NULL);
    ol_debugf ("connected");
  }
  return connected;
}
예제 #5
0
/*
 * call-seq:
 *  xc.on_disconnect { } -> self
 *
 * Sets the block that's executed when _xc_ is disconnected from the
 * XMMS2 daemon.
 */
static VALUE
c_on_disconnect (VALUE self)
{
	RbXmmsClient *xmms = NULL;

	if (!rb_block_given_p ())
		return Qnil;

	Data_Get_Struct (self, RbXmmsClient, xmms);

	CHECK_DELETED (xmms);

	xmms->disconnect_cb = rb_block_proc ();

	xmmsc_disconnect_callback_set (xmms->real,
	                               on_disconnect, (void *) self);

	return self;
}
예제 #6
0
int
main (int argc, char **argv)
{
    xmmsc_connection_t *conn;
    gchar *path;
    gchar *gp = NULL;
    gchar **s;
    gchar **ipcsplit;
    guint port;
    int i;

    printf ("Starting XMMS2 mDNS Agent...\n");

    path = getenv ("XMMS_PATH_FULL");
    if (!path) {
        printf ("Sorry you need XMMS_PATH_FULL set\n");
        exit (1);
    }

    ipcsplit = g_strsplit (path, ";", 0);
    for (i = 0; ipcsplit[i]; i++) {
        if (g_ascii_strncasecmp (ipcsplit[i], "tcp://", 6) == 0) {
            gp = ipcsplit[i];
        }
    }

    if (!gp) {
        printf ("Need to have a socket listening to TCP before we can do that!");
        exit (1);
    }

    s = g_strsplit (gp, ":", 0);
    if (s && s[2]) {
        port = strtol (s[2], NULL, 10);
    } else {
        port = XMMS_DEFAULT_TCP_PORT;
    }

    conn = xmmsc_init ("xmms2-mdns");

    if (!conn) {
        printf ("Could not init xmmsc_connection!\n");
        exit (1);
    }

    if (!xmmsc_connect (conn, gp)) {
        printf ("Could not connect to xmms2d: %s\n", xmmsc_get_last_error (conn));
        exit (1);
    }

    ml = g_main_loop_new (NULL, FALSE);

    XMMS_CALLBACK_SET (conn, xmmsc_broadcast_quit, handle_quit, ml);
    xmmsc_disconnect_callback_set (conn, disconnected, NULL);

    register_service (port);

    xmmsc_mainloop_gmain_init (conn);

    g_main_loop_run (ml);

    DNSServiceRefDeallocate (g_sdref);

    xmmsc_unref (conn);
    printf ("XMMS2-mDNS shutting down...\n");

    return 0;
}
예제 #7
0
gboolean
cli_context_connect (cli_context_t *ctx, gboolean autostart)
{
	gchar *path;
	xmmsc_result_t *res;

	/* Open Async connection first */
	ctx->conn = xmmsc_init (CLI_CLIENTNAME);
	if (!ctx->conn) {
		g_printf (_("Could not init connection!\n"));
		return FALSE;
	}

	path = configuration_get_string (ctx->config, "ipcpath");

	if (!xmmsc_connect (ctx->conn, path)) {
		if (!autostart) {
			/* Failed to connect, but don't autostart */
			xmmsc_unref (ctx->conn);
			ctx->conn = NULL;
			return FALSE;
		} else if (!cli_context_autostart (ctx, path)) {
			/* Autostart failed, abort now */
			if (path) {
				g_printf (_("Could not connect to server at '%s'!\n"), path);
			} else {
				g_printf (_("Could not connect to server at default path!\n"));
			}
			xmmsc_unref (ctx->conn);
			ctx->conn = NULL;
			return FALSE;
		}
	}

	/* Sync connection */
	ctx->sync = xmmsc_init (CLI_CLIENTNAME "-sync");
	if (!ctx->sync) {
		g_printf (_("Could not init sync connection!\n"));
		return FALSE;
	}

	if (!xmmsc_connect (ctx->sync, path)) {
		if (path) {
			g_printf (_("Could not connect to server at '%s'!\n"), path);
		} else {
			g_printf (_("Could not connect to server at default path!\n"));
		}

		xmmsc_unref (ctx->conn);
		xmmsc_unref (ctx->sync);

		ctx->conn = NULL;
		ctx->sync = NULL;

		return FALSE;
	}

	/* Reset the connection state on server quit */
	res = xmmsc_broadcast_quit (ctx->conn);
	xmmsc_disconnect_callback_set (ctx->conn, disconnect_callback, ctx);
	xmmsc_result_notifier_set (res, &cli_context_disconnect_callback, ctx);
	xmmsc_result_unref (res);

	cli_cache_start (ctx->cache, ctx->conn);

	return TRUE;
}
예제 #8
0
int
main (int argc, char **argv)
{
	xmmsc_connection_t *conn;
	GMainLoop *ml;
	gchar *path;

	printf ("Starting XMMS2 phone home agent...\n");

	path = getenv ("XMMS_PATH");

	conn = xmmsc_init ("xmms2-et");

	if (!conn) {
		printf ("Could not init xmmsc_connection!\n");
		exit (1);
	}

	if (!xmmsc_connect (conn, path)) {
		printf ("Could not connect to xmms2d: %s\n", xmmsc_get_last_error (conn));
		exit (1);
	}

	output_plugin = g_strdup ("unknown");

	get_systemname ();

	send_socket = socket (PF_INET, SOCK_DGRAM, 0);

	ml = g_main_loop_new (NULL, FALSE);

	memset (&dest_addr, 0, sizeof (dest_addr));
	dest_addr.sin_family = AF_INET;
	dest_addr.sin_port = htons (DEST_PORT);
	inet_aton (DEST_IP, &dest_addr.sin_addr);

	start_time = time (NULL);

	XMMS_CALLBACK_SET (conn, xmmsc_broadcast_playback_current_id, handle_current_id, conn);
	XMMS_CALLBACK_SET (conn, xmmsc_main_stats, handle_stats, NULL);
	XMMS_CALLBACK_SET (conn, xmmsc_broadcast_config_value_changed, handle_config, NULL);
	XMMS_CALLBACK_SET (conn, xmmsc_broadcast_quit, handle_quit, ml);

	XMMS_CALLBACK_SET (conn, xmmsc_signal_mediainfo_reader_unindexed, handle_mediainfo_reader, NULL);

	{
		xmmsc_result_t *res;
		res = xmmsc_config_get_value (conn, "output.plugin");
		xmmsc_result_notifier_set (res, handle_config_val, NULL);
		xmmsc_result_unref (res);
	}

	xmmsc_disconnect_callback_set (conn, disconnected, NULL);

	xmmsc_mainloop_gmain_init (conn);

	g_main_loop_run (ml);

	xmmsc_unref (conn);

	printf ("XMMS2-ET shutting down...\n");
	send_msg ("Clean shutdown", NULL);

	return 0;
}