comparison libaudacious/beepctrl.c @ 1438:ce0285d8cede trunk

[svn] - make the remote API actually work
author nenolod
date Fri, 28 Jul 2006 00:33:37 -0700
parents dd2b97f79a20
children bd0b46c8a70e
comparison
equal deleted inserted replaced
1437:dd2b97f79a20 1438:ce0285d8cede
36 #include "beepctrl.h" 36 #include "beepctrl.h"
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 static gchar *session_uri = NULL; 41 gchar *audacious_session_uri = NULL;
42 42
43 #ifdef HAVE_UNISTD_H 43 #ifdef HAVE_UNISTD_H
44 #include <unistd.h> 44 #include <unistd.h>
45 #endif 45 #endif
46 46
298 } 298 }
299 299
300 void 300 void
301 audacious_set_session_uri(gchar *uri) 301 audacious_set_session_uri(gchar *uri)
302 { 302 {
303 session_uri = uri; 303 audacious_session_uri = uri;
304 } 304 }
305 305
306 gchar * 306 gchar *
307 audacious_get_session_uri(gint session) 307 audacious_get_session_uri(gint session)
308 { 308 {
309 ConfigDb *db; 309 ConfigDb *db;
310 gchar *value = NULL; 310 gchar *value = NULL;
311 311
312 db = bmp_cfg_db_open(); 312 db = bmp_cfg_db_open();
313 313
314 if (session_uri != NULL) 314 if (audacious_session_uri != NULL)
315 return session_uri; 315 {
316 printf("%p\n", audacious_session_uri);
317 return audacious_session_uri;
318 }
316 319
317 bmp_cfg_db_get_string(db, NULL, "session_uri_base", &value); 320 bmp_cfg_db_get_string(db, NULL, "session_uri_base", &value);
318 321
319 if (value == NULL) 322 if (value == NULL)
320 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(), 323 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(),
342 345
343 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */ 346 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */
344 void 347 void
345 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key) 348 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key)
346 { 349 {
347 gchar *workbuf = NULL, *keybuf = NULL; 350 static gchar workbuf[1024], keybuf[1024];
348 gint iport; 351 gint iport;
349 352
350 /* split out the host/port and key */ 353 /* split out the host/port and key */
351 sscanf(in, "tcp://%s/%s", workbuf, keybuf); 354 sscanf(in, "tcp://%s/%s", workbuf, keybuf);
352 355
368 371
369 /* unix://localhost/tmp/audacious_nenolod.0 */ 372 /* unix://localhost/tmp/audacious_nenolod.0 */
370 void 373 void
371 audacious_decode_unix_uri(gint session, gchar *in, gchar **out) 374 audacious_decode_unix_uri(gint session, gchar *in, gchar **out)
372 { 375 {
373 gchar *workbuf = NULL, *pathbuf = NULL; 376 static gchar workbuf[1024], pathbuf[1024];
374 377
375 /* retrieve the pathbuf */ 378 /* retrieve the pathbuf */
376 sscanf(in, "unix://%s/%s", workbuf, pathbuf); 379 sscanf(in, "unix://%s/%s", workbuf, pathbuf);
377 380
378 *out = pathbuf; 381 *out = pathbuf;