~vcs-imports/gnome-media/main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
/*
 * cddb-slave-client.c: Client side wrapper for accessing CDDBSlave really
 *                      easily.
 *
 * Copyright (C) 2001-2002 Iain Holmes
 *
 *
 * Authors: Iain Holmes  <iain@ximian.com>
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <bonobo-activation/bonobo-activation.h>

#include "GNOME_Media_CDDBSlave2.h"
#include "cddb-slave-private.h"			/* cs_debug */
#include "cddb-slave-client.h"

#include <bonobo/bonobo-listener.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-exception.h>

#define CDDB_SLAVE_IID "OAFIID:GNOME_Media_CDDBSlave2"

#define PARENT_TYPE G_TYPE_OBJECT
static GObjectClass *parent_class = NULL;

struct _CDDBSlaveClientPrivate {
	GNOME_Media_CDDBSlave2 objref;
};

static void
finalize (GObject *object)
{
	CDDBSlaveClient *client;

	cs_debug ("cddb-slave-client.c: finalize");
	client = CDDB_SLAVE_CLIENT (object);
	if (client->priv == NULL)
		return;

	if (client->priv->objref != CORBA_OBJECT_NIL) {
		bonobo_object_release_unref (client->priv->objref, NULL);
		client->priv->objref = CORBA_OBJECT_NIL;
	}

	g_free (client->priv);
	client->priv = NULL;

	G_OBJECT_CLASS (parent_class)->finalize (object);
}

static void
class_init (CDDBSlaveClientClass *klass)
{
	GObjectClass *object_class;

	object_class = G_OBJECT_CLASS (klass);
	object_class->finalize = finalize;

	parent_class = g_type_class_peek_parent (klass);
}

static void
init (CDDBSlaveClient *client)
{
	client->priv = g_new (CDDBSlaveClientPrivate, 1);
}

/* Standard functions */
GType
cddb_slave_client_get_type (void)
{
	static GType client_type = 0;

	if (!client_type) {
		GTypeInfo client_info = {
			sizeof (CDDBSlaveClientClass),
			NULL, NULL, (GClassInitFunc) class_init, NULL, NULL,
			sizeof (CDDBSlaveClient), 0,
			(GInstanceInitFunc) init,
		};

		client_type = g_type_register_static (PARENT_TYPE, "CDDBSlaveClient", &client_info, 0);
	}

	return client_type;
}

/*** Public API ***/
/**
 * cddb_slave_client_construct:
 * @client: The CDDBSlaveClient to construct.
 * @corba_object: The CORBA_Object to construct it from.
 *
 * Constructs @client from @corba_object.
 */
void
cddb_slave_client_construct (CDDBSlaveClient *client,
			     CORBA_Object corba_object)
{
	g_return_if_fail (client != NULL);
	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));
	g_return_if_fail (corba_object != CORBA_OBJECT_NIL);

	client->priv->objref = corba_object;
}

/**
 * cddb_slave_client_new_from_id:
 * @id: The oafiid of the component to make a client for.
 *
 * Makes a client for the object returned by activating @id.
 *
 * Returns: A newly created CDDBSlaveClient or NULL on error.
 */
CDDBSlaveClient *
cddb_slave_client_new_from_id (const char *id)
{
	CDDBSlaveClient *client;
	CORBA_Environment ev;
	CORBA_Object objref;

	g_return_val_if_fail (id != NULL, NULL);

	CORBA_exception_init (&ev);
	objref = bonobo_activation_activate_from_id ((char *) id, 0, NULL, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Could no activate %s.\n%s", id,
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}

	CORBA_exception_free (&ev);
	if (objref == CORBA_OBJECT_NIL) {
		g_warning ("Could not start component %s.", id);
		return NULL;
	}

	client = g_object_new (cddb_slave_client_get_type (), NULL);
	cddb_slave_client_construct (client, objref);

	return client;
}

/**
 * cddb_slave_client_new:
 *
 * Creates a new CDDBSlaveClient, using the default CDDBSlave component.
 *
 * Returns: A newly created CDDBSlaveClient or NULL on error.
 */
CDDBSlaveClient *
cddb_slave_client_new (void)
{
	return cddb_slave_client_new_from_id (CDDB_SLAVE_IID);
}

/**
 * cddb_slave_client_query:
 * @client: The CDDBSlaveClient to perform the query.
 * @discid: The ID of the CD to be searched for.
 * @ntrks: The number of tracks on the CD.
 * @offsets: A string of all the frame offsets to the starting location of
 *           each track, seperated by spaces.
 * @nsecs: Total playing length of the CD in seconds.
 * @name: The name of the the program performing the query. eg. GTCD.
 * @version: The version of the program performing the query.
 *
 * Asks the CDDBSlave that @client is a client for to perform a query on the
 * CDDB server that it is set up to connect to.
 * The @name string will be sent as "@name (CDDBSlave 2)",
 * eg. "GTCD (CDDBSlave 2)"
 *
 * Returns: A boolean indicating if there was an error in sending the query to
 *          the CDDBSlave
 */
gboolean
cddb_slave_client_query (CDDBSlaveClient *client,
			 const char *discid,
			 int ntrks,
			 const char *offsets,
			 int nsecs,
			 const char *name,
			 const char *version)
{
	GNOME_Media_CDDBSlave2 cddb;
	CORBA_Environment ev;
	gboolean result;

	g_return_val_if_fail (client != NULL, FALSE);
	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), FALSE);
	g_return_val_if_fail (discid != NULL, FALSE);
	g_return_val_if_fail (ntrks > 0, FALSE);
	g_return_val_if_fail (offsets != NULL, FALSE);
	g_return_val_if_fail (nsecs > 0, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	g_return_val_if_fail (version != NULL, FALSE);

	CORBA_exception_init (&ev);
	cddb = client->priv->objref;
	GNOME_Media_CDDBSlave2_query (cddb, discid, ntrks, offsets, nsecs,
				      name, version, &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		g_warning ("Error sending request: %s", CORBA_exception_id (&ev));
		result = FALSE;
	} else {
		result = TRUE;
	}

	CORBA_exception_free (&ev);
	return result;
}

void
cddb_slave_client_save (CDDBSlaveClient *client,
			const char *discid)
{
	GNOME_Media_CDDBSlave2 cddb;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));
	g_return_if_fail (discid != NULL);

	CORBA_exception_init (&ev);
	cddb = client->priv->objref;
	GNOME_Media_CDDBSlave2_save (cddb, discid, &ev);

	if (BONOBO_EX (&ev)) {
		g_warning ("Could not save %s\n%s", discid, CORBA_exception_id (&ev));
	}

	CORBA_exception_free (&ev);
}

/**
 * cddb_slave_client_add_listener:
 * @client: Client of the CDDBSlave to add a listener to.
 * @listener: BonoboListener to add.
 *
 * Adds a listener to the CDDBSlave that belongs to @client.
 */
void
cddb_slave_client_add_listener (CDDBSlaveClient *client,
				BonoboListener *listener)
{
	CORBA_Object client_objref, listener_objref;
	CORBA_Object event_source;
	CORBA_Environment ev;

	g_return_if_fail (client != NULL);
	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));
	g_return_if_fail (listener != NULL);
	g_return_if_fail (BONOBO_IS_LISTENER (listener));

	cs_debug ("adding listener to client %p", client);

	client_objref = client->priv->objref;
	listener_objref = bonobo_object_corba_objref (BONOBO_OBJECT (listener));

	CORBA_exception_init (&ev);
	event_source = Bonobo_Unknown_queryInterface (client_objref,
						      "IDL:Bonobo/EventSource:1.0", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error doing QI for event source\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return;
	}

	/* Add the listener */
	cs_debug ("cddb_slave_client: adding event source %p", event_source);
	Bonobo_EventSource_addListener (event_source, listener_objref, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error adding listener\n%s", CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return;
	}

	bonobo_object_release_unref (event_source, NULL);
	CORBA_exception_free (&ev);
	return;
}

/**
 * cddb_slave_client_remove_listener:
 * @client: Client of the CDDBSlave to remove a listener from.
 * @listener: The listener to remove.
 *
 * Removes a listener from the CDDBSlave that belongs to @client.
 */
void
cddb_slave_client_remove_listener (CDDBSlaveClient *client,
				   BonoboListener *listener)
{
	CORBA_Object client_objref;
	CORBA_Object event_source;
	CORBA_Object listener_objref;
	CORBA_Environment ev;

	g_return_if_fail (client != NULL);
	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));
	g_return_if_fail (BONOBO_IS_LISTENER (listener));

	client_objref = client->priv->objref;
	listener_objref = bonobo_object_corba_objref (BONOBO_OBJECT (listener));

	CORBA_exception_init (&ev);
	event_source = Bonobo_Unknown_queryInterface (client_objref,
						      "IDL:Bonobo/EventSource:1.0", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error doing QI for event source\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return;
	}

	/* Remove the listener */
	cs_debug ("cddb_slave_client: removing event source %p", event_source);
	Bonobo_EventSource_removeListener (event_source, listener_objref, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error removing listener\n%s", CORBA_exception_id (&ev));
	}

	bonobo_object_release_unref (event_source, NULL);
	CORBA_exception_free (&ev);

	return;
}

/**
 * cddb_slave_client_is_valid:
 *
 * Checks if an entry is marked as valid in the CDDB slave cache.
 *
 * Returns: %TRUE if the given discid is a valid entry in the cache.
 */
gboolean
cddb_slave_client_is_valid (CDDBSlaveClient *client,
                            const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_boolean ret;

	g_return_val_if_fail (client != NULL, FALSE);
	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), FALSE);
	g_return_val_if_fail (discid != NULL, FALSE);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	ret = GNOME_Media_CDDBSlave2_isValid (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error checking if the discid is a valid entry\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return FALSE;
	}

	CORBA_exception_free (&ev);
	return ret;
}

/**
 * cddb_slave_client_get_disc_title:
 *
 */
char *
cddb_slave_client_get_disc_title (CDDBSlaveClient *client,
				  const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_char *ret;

	g_return_val_if_fail (client != NULL, NULL);
	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), NULL);
	g_return_val_if_fail (discid != NULL, NULL);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	ret = GNOME_Media_CDDBSlave2_getDiscTitle (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting disc title\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}

	CORBA_exception_free (&ev);
	return g_strdup (ret);
}

/**
 * cddb_slave_client_set_disc_title:
 *
 */
void
cddb_slave_client_set_disc_title (CDDBSlaveClient *client,
				  const char *discid,
				  const char *title)
{
	CORBA_Object objref;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	GNOME_Media_CDDBSlave2_setDiscTitle (objref, discid,
					     title ? title : "", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting disc title\n%s",
			   CORBA_exception_id (&ev));
	}

	CORBA_exception_free (&ev);
}

char *
cddb_slave_client_get_artist (CDDBSlaveClient *client,
			      const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_char *ret;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), NULL);
	g_return_val_if_fail (discid != NULL, NULL);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	ret = GNOME_Media_CDDBSlave2_getArtist (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting artist\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}

	CORBA_exception_free (&ev);
	return g_strdup (ret);
}

void
cddb_slave_client_set_artist (CDDBSlaveClient *client,
			      const char *discid,
			      const char *artist)
{
	CORBA_Object objref;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	GNOME_Media_CDDBSlave2_setArtist (objref, discid,
					  artist ? artist : "", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting artist\n%s",
			   CORBA_exception_id (&ev));
	}

	CORBA_exception_free (&ev);
}

int
cddb_slave_client_get_ntrks (CDDBSlaveClient *client,
			     const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_short ret;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), -1);
	g_return_val_if_fail (discid != NULL, -1);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	ret = GNOME_Media_CDDBSlave2_getNTrks (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting ntrks\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return -1;
	}

	CORBA_exception_free (&ev);
	return ret;
}

CDDBSlaveClientTrackInfo **
cddb_slave_client_get_tracks (CDDBSlaveClient *client,
			      const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	GNOME_Media_CDDBSlave2_TrackList *list;
	CDDBSlaveClientTrackInfo **ret;
	int i;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), NULL);
	g_return_val_if_fail (discid != NULL, NULL);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);

	GNOME_Media_CDDBSlave2_getAllTracks (objref, discid, &list, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting tracks\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}
	CORBA_exception_free (&ev);

	ret = g_new (CDDBSlaveClientTrackInfo *, list->_length + 1);
	for (i = 0; i < list->_length; i++) {
		ret[i] = g_new (CDDBSlaveClientTrackInfo, 1);
		ret[i]->name = g_strdup (list->_buffer[i].name);
		ret[i]->length = list->_buffer[i].length;
		ret[i]->comment = g_strdup (list->_buffer[i].comment);
	}

	/* NULL terminator */
	ret[i] = NULL;

	CORBA_free (list);
	return ret;
}

void
cddb_slave_client_free_track_info (CDDBSlaveClientTrackInfo **track_info)
{
	int i;
	for (i = 0; track_info[i] != NULL; i++) {
		g_free (track_info[i]->name);
		g_free (track_info[i]->comment);
		g_free (track_info[i]);
	}

	g_free (track_info);
}

void
cddb_slave_client_set_tracks (CDDBSlaveClient *client,
			      const char *discid,
			      CDDBSlaveClientTrackInfo **track_info)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	GNOME_Media_CDDBSlave2_TrackList *list;
	int i;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	for (i = 0; track_info[i] != NULL; i++) {
		; /* Count the number of tracks */
	}

	list = GNOME_Media_CDDBSlave2_TrackList__alloc ();
	list->_length = i;
	list->_maximum = i;
	list->_buffer = CORBA_sequence_GNOME_Media_CDDBSlave2_TrackInfo_allocbuf (i);

	for (i = 0; track_info[i] != NULL; i++) {
		list->_buffer[i].name = CORBA_string_dup (track_info[i]->name ? track_info[i]->name : "");
		list->_buffer[i].length = 0; /* We can't change the length of a track :) */
		list->_buffer[i].comment = CORBA_string_dup (track_info[i]->comment ?
							     track_info[i]->comment : "");
	}

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	GNOME_Media_CDDBSlave2_setAllTracks (objref, discid, list, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting all tracks\n%s", CORBA_exception_id (&ev));
	}

	CORBA_exception_free (&ev);
	CORBA_free (list);
}

char *
cddb_slave_client_get_comment (CDDBSlaveClient *client,
			       const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_char *ret;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), NULL);
	g_return_val_if_fail (discid != NULL, NULL);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);

	ret = GNOME_Media_CDDBSlave2_getComment (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting comment\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}

	CORBA_exception_free (&ev);
	return g_strdup (ret);
}

void
cddb_slave_client_set_comment (CDDBSlaveClient *client,
			       const char *discid,
			       const char *comment)
{
	CORBA_Object objref;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	objref = client->priv->objref;

	CORBA_exception_init (&ev);

	GNOME_Media_CDDBSlave2_setComment (objref, discid,
					   comment ? comment : "", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting comment\n%s", CORBA_exception_id (&ev));
	}
	CORBA_exception_free (&ev);
}

int
cddb_slave_client_get_year (CDDBSlaveClient *client,
			    const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_short ret;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), -1);
	g_return_val_if_fail (discid != NULL, -1);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);

	ret = GNOME_Media_CDDBSlave2_getYear (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting year\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return -1;
	}

	CORBA_exception_free (&ev);
	return ret;
}

void
cddb_slave_client_set_year (CDDBSlaveClient *client,
			    const char *discid,
			    int year)
{
	CORBA_Object objref;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	GNOME_Media_CDDBSlave2_setYear (objref, discid, year, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting year\n%s", CORBA_exception_id (&ev));
	}
	CORBA_exception_free (&ev);
}

char *
cddb_slave_client_get_genre (CDDBSlaveClient *client,
			     const char *discid)
{
	CORBA_Object objref;
	CORBA_Environment ev;
	CORBA_char *ret;

	g_return_val_if_fail (IS_CDDB_SLAVE_CLIENT (client), NULL);
	g_return_val_if_fail (discid != NULL, NULL);

	objref = client->priv->objref;

	CORBA_exception_init (&ev);

	ret = GNOME_Media_CDDBSlave2_getGenre (objref, discid, &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error getting genre\n%s",
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return NULL;
	}

	CORBA_exception_free (&ev);
	return g_strdup (ret);
}

void
cddb_slave_client_set_genre (CDDBSlaveClient *client,
			     const char *discid,
			     const char *genre)
{
	CORBA_Object objref;
	CORBA_Environment ev;

	g_return_if_fail (IS_CDDB_SLAVE_CLIENT (client));

	objref = client->priv->objref;

	CORBA_exception_init (&ev);
	GNOME_Media_CDDBSlave2_setGenre (objref, discid,
					 genre ? genre : "", &ev);
	if (BONOBO_EX (&ev)) {
		g_warning ("Error setting genre\n%s",
			   CORBA_exception_id (&ev));
	}
	CORBA_exception_free (&ev);
}