Mercurial > audlegacy
comparison libaudacious/beepctrl.c @ 1456:6fe7ba6e5489 trunk
[svn] - Don't poll the config database if not using TCP sockets.
author | nhjm449 |
---|---|
date | Mon, 31 Jul 2006 17:06:44 -0700 |
parents | 9bb6d5ce6d95 |
children | f12d7e208b43 |
comparison
equal
deleted
inserted
replaced
1455:04730ff1693d | 1456:6fe7ba6e5489 |
---|---|
37 #include "audacious/controlsocket.h" | 37 #include "audacious/controlsocket.h" |
38 #include "libaudacious/configdb.h" | 38 #include "libaudacious/configdb.h" |
39 | 39 |
40 /* overrides audacious_get_session_uri(). */ | 40 /* overrides audacious_get_session_uri(). */ |
41 gchar *audacious_session_uri = NULL; | 41 gchar *audacious_session_uri = NULL; |
42 gint *audacious_session_type = NULL; | |
42 | 43 |
43 #ifdef HAVE_UNISTD_H | 44 #ifdef HAVE_UNISTD_H |
44 #include <unistd.h> | 45 #include <unistd.h> |
45 #endif | 46 #endif |
46 | 47 |
312 if (audacious_session_uri != NULL) | 313 if (audacious_session_uri != NULL) |
313 { | 314 { |
314 return audacious_session_uri; | 315 return audacious_session_uri; |
315 } | 316 } |
316 | 317 |
317 db = bmp_cfg_db_open(); | 318 if (audacious_session_type != AUDACIOUS_TYPE_UNIX) |
318 | 319 { |
319 bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value); | 320 db = bmp_cfg_db_open(); |
320 | 321 |
321 bmp_cfg_db_close(db); | 322 bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value); |
323 | |
324 bmp_cfg_db_close(db); | |
325 } | |
322 | 326 |
323 if (value == NULL) | 327 if (value == NULL) |
324 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(), | 328 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(), |
325 CTRLSOCKET_NAME, g_get_user_name(), session); | 329 CTRLSOCKET_NAME, g_get_user_name(), session); |
326 | 330 |
327 audacious_session_uri = value; | 331 audacious_session_uri = value; |
328 | 332 |
329 return value; | 333 return value; |
330 } | 334 } |
331 | 335 |
332 gint | 336 void |
337 audacious_set_session_type(gint *type) | |
338 { | |
339 audacious_session_type = type; | |
340 } | |
341 | |
342 gint * | |
333 audacious_determine_session_type(gint session) | 343 audacious_determine_session_type(gint session) |
334 { | 344 { |
335 gchar *uri; | 345 gchar *uri; |
336 | 346 |
347 if (audacious_session_type != NULL) | |
348 { | |
349 return audacious_session_type; | |
350 } | |
351 | |
337 uri = audacious_get_session_uri(session); | 352 uri = audacious_get_session_uri(session); |
338 | 353 |
339 if (!g_strncasecmp(uri, "tcp://", 6)) | 354 if (!g_strncasecmp(uri, "tcp://", 6)) |
340 return AUDACIOUS_TYPE_TCP; | 355 audacious_session_type = (gint *) AUDACIOUS_TYPE_TCP; |
341 else | 356 else |
342 return AUDACIOUS_TYPE_UNIX; | 357 audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX; |
343 | 358 |
344 return AUDACIOUS_TYPE_UNIX; | 359 if (audacious_session_type == NULL) |
360 audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX; | |
361 | |
362 return audacious_session_type; | |
345 } | 363 } |
346 | 364 |
347 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */ | 365 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */ |
348 void | 366 void |
349 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key) | 367 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key) |
398 | 416 |
399 gint | 417 gint |
400 xmms_connect_to_session(gint session) | 418 xmms_connect_to_session(gint session) |
401 { | 419 { |
402 gint fd; | 420 gint fd; |
403 gint type = audacious_determine_session_type(session); | 421 gint *type = audacious_determine_session_type(session); |
404 gchar *uri = audacious_get_session_uri(session); | 422 gchar *uri = audacious_get_session_uri(session); |
405 | 423 |
406 if (type == AUDACIOUS_TYPE_UNIX) | 424 if (type == AUDACIOUS_TYPE_UNIX) |
407 { | 425 { |
408 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) | 426 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) |