2
Functions related to the communication with jukebox hardware
3
using the libnjb library.
4
Copyright (C) 2001-2003 Linus Walleij
6
This file is part of the GNOMAD package.
8
GNOMAD is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2, or (at your option)
13
You should have received a copy of the GNU General Public License
14
along with GNOMAD; see the file COPYING. If not, write to
15
the Free Software Foundation, 59 Temple Place - Suite 330,
16
Boston, MA 02111-1307, USA.
3
* Functions related to the communication with jukebox hardware
4
* using the libnjb library.
5
* Copyright (C) 2001-2003 Linus Walleij
7
* This file is part of the GNOMAD package.
9
* GNOMAD is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2, or (at your option)
14
* You should have received a copy of the GNU General Public License
15
* along with GNOMAD; see the file COPYING. If not, write to
16
* the Free Software Foundation, 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
21
22
#include "common.h"
111
118
static void refresh_id(void)
120
if (!use_mtp && pdedevice != NULL) {
118
125
/* Returns the unique jukebox ID */
119
126
static gchar *jukebox_get_idstring(void)
125
if (NJB_Get_SDMI_ID(njb, (u_int8_t *) &sdmiid) == 0) {
126
return g_strdup_printf("%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
127
sdmiid[0], sdmiid[1], sdmiid[2], sdmiid[3], sdmiid[4],
128
sdmiid[5], sdmiid[6], sdmiid[7], sdmiid[8], sdmiid[9],
129
sdmiid[10], sdmiid[11], sdmiid[12], sdmiid[13], sdmiid[14],
130
return LIBMTP_Get_Serialnumber(mtpdevice);
135
if (pdedevice != NULL) {
139
if (NJB_Get_SDMI_ID(pdedevice, (u_int8_t *) &sdmiid) == 0) {
140
return g_strdup_printf("%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
141
sdmiid[0], sdmiid[1], sdmiid[2], sdmiid[3], sdmiid[4],
142
sdmiid[5], sdmiid[6], sdmiid[7], sdmiid[8], sdmiid[9],
143
sdmiid[10], sdmiid[11], sdmiid[12], sdmiid[13], sdmiid[14],
139
154
/* Returns a string representing the firmware revision */
140
155
static gchar *jukebox_get_firmware(void)
143
if (jukebox_firmware == NULL) {
144
u_int8_t major, minor, release;
146
if (NJB_Get_Firmware_Revision(njb, &major, &minor, &release) == -1) {
149
if (njb->device_type == NJB_DEVICE_NJB1) {
150
jukebox_firmware = g_strdup_printf("%u.%u", major, minor);
152
jukebox_firmware = g_strdup_printf("%u.%u.%u", major, minor, release);
159
return LIBMTP_Get_Deviceversion(mtpdevice);
164
if (pdedevice != NULL) {
165
if (jukebox_firmware == NULL) {
166
u_int8_t major, minor, release;
168
if (NJB_Get_Firmware_Revision(pdedevice, &major, &minor, &release) == -1) {
171
if (pdedevice->device_type == NJB_DEVICE_NJB1) {
172
jukebox_firmware = g_strdup_printf("%u.%u", major, minor);
174
jukebox_firmware = g_strdup_printf("%u.%u.%u", major, minor, release);
177
return jukebox_firmware;
155
return jukebox_firmware;
161
184
/* Returns a string representing the hardware revision */
162
185
static gchar *jukebox_get_hardware(void)
165
if (jukebox_hardware == NULL) {
166
u_int8_t major, minor, release;
168
if (NJB_Get_Hardware_Revision(njb, &major, &minor, &release) == -1) {
189
return LIBMTP_Get_Deviceversion(mtpdevice);
194
if (pdedevice != NULL) {
195
if (jukebox_hardware == NULL) {
196
u_int8_t major, minor, release;
198
if (NJB_Get_Hardware_Revision(pdedevice, &major, &minor, &release) == -1) {
201
jukebox_hardware = g_strdup_printf("%u.%u.%u", major, minor, release);
171
jukebox_hardware = g_strdup_printf("%u.%u.%u", major, minor, release);
203
return jukebox_hardware;
173
return jukebox_hardware;
179
210
/* Returns the product name */
180
211
static gchar *jukebox_get_prodname(void)
183
return (gchar *) NJB_Get_Device_Name(njb, 1);
215
return LIBMTP_Get_Modelname(mtpdevice);
220
if (pdedevice != NULL) {
221
return (gchar *) NJB_Get_Device_Name(pdedevice, 1);
189
228
/* Returns data about if the power cord is connected */
190
229
static gboolean jukebox_get_power(void)
193
int powerstat = NJB_Get_Auxpower(njb);
194
if (powerstat == 1) {
232
// Not supported yet.
235
if (pdedevice != NULL) {
236
int powerstat = NJB_Get_Auxpower(pdedevice);
237
if (powerstat == 1) {
204
248
/* Returns data about if the power cord is connected */
205
249
static gboolean jukebox_get_charging(void)
208
int chargestat = NJB_Get_Battery_Charging(njb);
209
if (chargestat == 1) {
252
// Not supported yet.
255
if (pdedevice != NULL) {
256
int chargestat = NJB_Get_Battery_Charging(pdedevice);
257
if (chargestat == 1) {
219
268
/* Returns the battery level in percent */
220
269
static guint jukebox_get_battery_level(void)
223
return NJB_Get_Battery_Level(njb);
273
uint8_t max, current;
276
ret = LIBMTP_Get_Batterylevel(mtpdevice, &max, ¤t);
278
// Adjust to a scale between 0 and 100, linear interpolation
279
gfloat percentage = ((gfloat) current) / ((gfloat) max);
280
return (guint) (percentage * (gfloat) 100);
288
if (pdedevice != NULL) {
289
return NJB_Get_Battery_Level(pdedevice);
464
540
gtk_widget_show(label);
465
541
add_to_dialog(dialog, hbox);
466
542
gtk_widget_show (hbox);
471
546
gchar *jukebox_get_time(void)
473
548
njb_time_t *time;
476
time = NJB_Get_Time(njb);
552
return g_strdup("Not implemented");
554
if (pdedevice != NULL) {
555
time = NJB_Get_Time(pdedevice);
557
if (jukebox_timestring != NULL) {
558
g_free(jukebox_timestring);
559
jukebox_timestring = NULL;
561
jukebox_timestring = g_strdup_printf("%u-%.2u-%.2u %.2u:%.2u:%.2u",
562
time->year, time->month, time->day,
563
time->hours, time->minutes,
478
568
if (jukebox_timestring != NULL) {
479
569
g_free(jukebox_timestring);
480
jukebox_timestring = NULL;
482
jukebox_timestring = g_strdup_printf("%u-%.2u-%.2u %.2u:%.2u:%.2u",
483
time->year, time->month, time->day,
484
time->hours, time->minutes,
489
if (jukebox_timestring != NULL) {
490
g_free(jukebox_timestring);
492
jukebox_timestring = NULL;
571
jukebox_timestring = NULL;
573
return jukebox_timestring;
494
return jukebox_timestring;
581
662
/* Also test with NJB_UC_8859 */
582
663
NJB_Set_Unicode(NJB_UC_UTF8);
584
if ( NJB_Discover(njbs, 0, &jukeboxcount) == -1 ) {
665
if ( NJB_Discover(pde_devices, 0, &PDE_device_count) == -1 ) {
585
666
create_error_dialog(_("Could not try to locate jukeboxes\nUSB error?"));
672
mtpdevice = LIBMTP_Get_First_Device();
673
if (mtpdevice != NULL) {
674
MTP_device_count = 1;
678
device_count = PDE_device_count + MTP_device_count;
589
if ( jukeboxcount == 0 ) {
680
if ( device_count == 0 ) {
590
681
create_error_dialog(_("No jukeboxes found on USB bus"));
594
685
// Add a nice selection dialog here njb->device_type tells the type,
595
686
// and owner string is useful too.
596
if ( jukeboxcount >= 1) {
687
if ( device_count >= 1) {
599
690
// Space for jukebox strings.
600
retarray = g_malloc((jukeboxcount+1) * sizeof(gchar *));
601
for (i = 0; i < jukeboxcount; i++) {
603
switch (njb->device_type)
605
/* Put in hack to display D.A.P. Jukebox in europe? */
606
case NJB_DEVICE_NJB1:
607
retarray[i] = g_strdup_printf("Nomad Jukebox 1 (D.A.P.)");
609
case NJB_DEVICE_NJB2:
610
retarray[i] = g_strdup_printf("Nomad Jukebox 2");
612
case NJB_DEVICE_NJB3:
613
retarray[i] = g_strdup_printf("Nomad Jukebox 3");
615
case NJB_DEVICE_NJBZEN:
616
retarray[i] = g_strdup_printf("Nomad Jukebox Zen");
618
case NJB_DEVICE_NJBZEN2:
619
retarray[i] = g_strdup_printf("Nomad Jukebox Zen USB 2.0");
621
case NJB_DEVICE_NJBZENNX:
622
retarray[i] = g_strdup_printf("Nomad Jukebox Zen NX");
624
case NJB_DEVICE_NJBZENXTRA:
625
retarray[i] = g_strdup_printf("Nomad Jukebox Zen Xtra");
627
case NJB_DEVICE_DELLDJ:
628
retarray[i] = g_strdup_printf("Dell Digital Jukebox");
630
case NJB_DEVICE_NJBZENTOUCH:
631
retarray[i] = g_strdup_printf("Nomad Jukebox Zen Touch");
633
case NJB_DEVICE_NJBZENMICRO:
634
retarray[i] = g_strdup_printf("Nomad Jukebox Zen Micro");
636
case NJB_DEVICE_DELLDJ2:
637
retarray[i] = g_strdup_printf("Second Generation Dell DJ");
639
case NJB_DEVICE_POCKETDJ:
640
retarray[i] = g_strdup_printf("Dell Pocket DJ");
643
retarray[i] = g_strdup_printf(_("Unknown jukebox type"));
647
retarray[jukeboxcount] = NULL;
691
retarray = g_malloc((device_count+1) * sizeof(gchar *));
692
for (i = 0; i < PDE_device_count; i++) {
693
pdedevice = &pde_devices[i];
694
// This function may be called prior to opening the jukebox
695
// if parameterized with type 0.
696
retarray[i] = g_strdup(NJB_Get_Device_Name(pdedevice, 0));
700
// Replace with for() statement once libmtp support multiple devices
701
if (MTP_device_count > 0) {
704
retarray[i] = g_strdup(LIBMTP_Get_Modelname(mtpdevice));
705
g_print("Queried %s\n", retarray[i]);
707
// Should not happen but to be certain ...
711
retarray[device_count] = NULL;
655
718
// This selects a certain jukebox for use and sets the
656
719
// global njb variable to point to thus jukebox.
657
720
gboolean jukebox_select(gint i) {
722
if (i < PDE_device_count) {
723
g_print("This is a PDE device\n");
724
pdedevice = &pde_devices[i];
660
if (NJB_Open(njb) == -1) {
661
display_njberror(njb, _("Could not open jukebox:\n"));
666
* Causing problems. Removing for now. 2004-04-12
667
if ((njbid = NJB_Ping(njb)) == NULL) {
668
create_error_dialog(_("Could not ping jukebox"));
669
NJB_Error_Dump(stderr);
675
if (NJB_Capture(njb) == -1) {
676
display_njberror(njb, _("Could not capture jukebox:\n"));
680
njb_connected = TRUE;
726
if (NJB_Open(pdedevice) == -1) {
727
display_njberror(pdedevice, _("Could not open jukebox:\n"));
732
* Causing problems. Removing for now. 2004-04-12
733
if ((njbid = NJB_Ping(njb)) == NULL) {
734
create_error_dialog(_("Could not ping jukebox"));
735
NJB_Error_Dump(stderr);
741
if (NJB_Capture(pdedevice) == -1) {
742
display_njberror(pdedevice, _("Could not capture jukebox:\n"));
743
NJB_Close(pdedevice);
747
/* Set turbo mode according to preferences */
748
if (get_prefs_turbo_mode()) {
749
NJB_Set_Turbo_Mode(pdedevice, NJB_TURBO_ON);
751
NJB_Set_Turbo_Mode(pdedevice, NJB_TURBO_OFF);
760
// Else try to connect to the MTP device
761
else if (MTP_device_count > 0) {
762
g_print("This is an MTP device\n");
764
// This is implicitly connected to in the first library call.
765
// Set njb to NULL to be certain this is the only device used.
769
// Else we have no devices
771
g_print("We have no devices!\n");
780
device_connected = TRUE;
684
784
// Check if a jukebox has been selected.
685
785
gboolean jukebox_selected(void)
688
// g_print("njb was null.\n");
789
if (mtpdevice == NULL) {
790
g_print("MTP device NULL.\n");
797
if (pdedevice == NULL) {
798
g_print("PDE device NULL.\n");
691
if (!njb_connected) {
692
// g_print("njb was not connected.\n");
803
if (!device_connected) {
804
g_print("Device was not connected.\n");
710
832
* drop down is then built from */
711
833
static void build_playlist_list()
713
njb_playlist_t *playlist;
715
if (jukebox_playlist != NULL) {
716
GList *tmplist = jukebox_playlist;
839
njb_playlist_t *playlist;
719
if (tmplist->data != NULL)
720
g_free(tmplist->data);
721
tmplist = tmplist->next;
722
tmplist = tmplist->next;
724
g_list_free(jukebox_playlist);
725
jukebox_playlist = NULL;
727
NJB_Reset_Get_Playlist(njb);
728
while (playlist = NJB_Get_Playlist(njb)) {
730
jukebox_playlist = g_list_append(jukebox_playlist, g_strdup(playlist->name));
731
jukebox_playlist = g_list_append(jukebox_playlist, GUINT_TO_POINTER(playlist->plid));
733
NJB_Playlist_Destroy(playlist);
841
if (jukebox_playlist != NULL) {
842
GList *tmplist = jukebox_playlist;
845
if (tmplist->data != NULL)
846
g_free(tmplist->data);
847
tmplist = tmplist->next;
848
tmplist = tmplist->next;
850
g_list_free(jukebox_playlist);
851
jukebox_playlist = NULL;
853
NJB_Reset_Get_Playlist(pdedevice);
854
while (playlist = NJB_Get_Playlist(pdedevice)) {
856
jukebox_playlist = g_list_append(jukebox_playlist, g_strdup(playlist->name));
857
jukebox_playlist = g_list_append(jukebox_playlist, GUINT_TO_POINTER(playlist->plid));
859
NJB_Playlist_Destroy(playlist);
738
865
static void create_tree_structure()
740
njb_playlist_t *playlist;
742
/* This is for the actual playlist tree scan */
743
NJB_Reset_Get_Playlist(njb);
744
while (playlist = NJB_Get_Playlist(njb)) {
745
njb_playlist_track_t *track;
746
gnomadplaylist_entry_t *entry;
750
entry = (gnomadplaylist_entry_t *) g_malloc(sizeof(gnomadplaylist_entry_t));
753
entry->tracklist = NULL;
754
entry->name = g_strdup(playlist->name);
755
tmp = g_strdup_printf("%lu", playlist->plid);
757
NJB_Playlist_Reset_Gettrack(playlist);
758
while (track = NJB_Playlist_Gettrack(playlist)) {
759
entry->tracklist = g_slist_append(entry->tracklist,
760
GUINT_TO_POINTER(track->trackid));
762
NJB_Playlist_Destroy(playlist);
763
playlistlist = g_slist_append(playlistlist, (gpointer) entry);
764
if (cancel_jukebox_operation)
767
if ( NJB_Error_Pending(njb) ) {
768
NJB_Error_Dump(njb,stderr);
868
// Not implemented yet.
872
njb_playlist_t *playlist;
874
/* This is for the actual playlist tree scan */
875
NJB_Reset_Get_Playlist(pdedevice);
876
while (playlist = NJB_Get_Playlist(pdedevice)) {
877
njb_playlist_track_t *track;
878
gnomadplaylist_entry_t *entry;
882
entry = (gnomadplaylist_entry_t *) g_malloc(sizeof(gnomadplaylist_entry_t));
885
entry->tracklist = NULL;
886
entry->name = g_strdup(playlist->name);
887
tmp = g_strdup_printf("%lu", playlist->plid);
889
NJB_Playlist_Reset_Gettrack(playlist);
890
while (track = NJB_Playlist_Gettrack(playlist)) {
891
entry->tracklist = g_slist_append(entry->tracklist,
892
GUINT_TO_POINTER(track->trackid));
894
NJB_Playlist_Destroy(playlist);
895
playlistlist = g_slist_append(playlistlist, (gpointer) entry);
896
if (cancel_jukebox_operation)
899
if ( NJB_Error_Pending(pdedevice) ) {
900
NJB_Error_Dump(pdedevice,stderr);
867
1000
static void add_to_playlist(guint playlistid, GList *metalist,
868
1001
GtkTreeStore *pltreestore, gboolean threaded)
870
njb_playlist_track_t *pl_track;
871
njb_playlist_t *playlist;
872
GList *tmplist = metalist;
873
gboolean found = FALSE;
1004
// Not implemented yet.
877
NJB_Reset_Get_Playlist(njb);
878
while (playlist = NJB_Get_Playlist(njb)) {
879
/* g_print("Is it %lu?\n", playlist->plid); */
880
if (playlist->plid == playlistid) {
881
/* g_print("YES!\n"); */
885
/* g_print("NO.\n"); */
886
NJB_Playlist_Destroy(playlist);
891
create_error_dialog(_("Could not find playlist"));
894
} else if (tmplist) {
899
meta = (metadata_t *) tmplist->data;
900
id = string_to_guint(meta->path);
901
/* g_print("Adding track %lu to playlist %lu\n", id, playlistid); */
902
pl_track = NJB_Playlist_Track_New(id);
903
NJB_Playlist_Addtrack(playlist, pl_track, NJB_PL_END);
904
tmplist = g_list_next(tmplist);
906
if (NJB_Update_Playlist(njb, playlist) == -1)
907
NJB_Error_Dump(njb, stderr);
908
NJB_Playlist_Destroy(playlist);
910
/* Rebuild the tree afterwards */
911
build_playlist_tree(pltreestore, threaded);
1007
njb_playlist_track_t *pl_track;
1008
njb_playlist_t *playlist;
1009
GList *tmplist = metalist;
1010
gboolean found = FALSE;
1014
NJB_Reset_Get_Playlist(pdedevice);
1015
while (playlist = NJB_Get_Playlist(pdedevice)) {
1016
/* g_print("Is it %lu?\n", playlist->plid); */
1017
if (playlist->plid == playlistid) {
1018
/* g_print("YES!\n"); */
1022
/* g_print("NO.\n"); */
1023
NJB_Playlist_Destroy(playlist);
1027
gdk_threads_enter();
1028
create_error_dialog(_("Could not find playlist"));
1030
gdk_threads_leave();
1031
} else if (tmplist) {
1036
meta = (metadata_t *) tmplist->data;
1037
id = string_to_guint(meta->path);
1038
/* g_print("Adding track %lu to playlist %lu\n", id, playlistid); */
1039
pl_track = NJB_Playlist_Track_New(id);
1040
NJB_Playlist_Addtrack(playlist, pl_track, NJB_PL_END);
1041
tmplist = g_list_next(tmplist);
1043
if (NJB_Update_Playlist(pdedevice, playlist) == -1)
1044
NJB_Error_Dump(pdedevice, stderr);
1045
NJB_Playlist_Destroy(playlist);
1047
/* Rebuild the tree afterwards */
1048
build_playlist_tree(pltreestore, threaded);
914
1052
/* Update the usage information */
1091
1275
gtk_label_set_text(GTK_LABEL(args->label), scan_songs);
1093
1277
gdk_threads_leave();
1094
1279
/* If it has already been read, free the old string */
1095
1280
if (jukebox_ownerstring != NULL)
1096
1281
g_free(jukebox_ownerstring);
1097
jukebox_ownerstring = g_strdup(NJB_Get_Owner_String (njb));
1284
jukebox_ownerstring = LIBMTP_Get_Ownername(mtpdevice);
1285
g_print("Owner name: %s\n", jukebox_ownerstring);
1287
jukebox_ownerstring = NULL;
1290
jukebox_ownerstring = g_strdup(NJB_Get_Owner_String (pdedevice));
1294
songhash = g_hash_table_new(NULL, NULL);
1296
// Activate extended metadata mode if desired
1297
// FIXME: Modify metadata editor to reflect this.
1298
if (get_prefs_extended_metadata()) {
1299
NJB_Get_Extended_Tags(pdedevice, 1);
1301
NJB_Get_Extended_Tags(pdedevice, 0);
1100
1305
/* Next retrieve the track listing */
1101
songhash = g_hash_table_new(NULL, NULL);
1102
/* Activate extended metadata mode if desired */
1103
// FIXME: Add preset. Modify metadata editor to reflect this.
1104
if (get_prefs_extended_metadata()) {
1105
NJB_Get_Extended_Tags(njb, 1);
1308
mtptracks = LIBMTP_Get_Tracklisting(mtpdevice);
1309
mtptrack = mtptracks;
1310
if (mtptrack == NULL) {
1107
NJB_Get_Extended_Tags(njb, 0);
1317
NJB_Reset_Get_Track_Tag(pdedevice);
1318
songtag = NJB_Get_Track_Tag(pdedevice);
1319
if (songtag == NULL) {
1109
NJB_Reset_Get_Track_Tag(njb);
1110
/* FIXME/IMPROVEMENT: If jukebox_songs != 0 start displaying progress bar? */
1112
while (songtag = NJB_Get_Track_Tag(njb)) {
1324
* FIXME/IMPROVEMENT: If jukebox_songs != 0 start displaying progress bar?
1325
* series 3 devices can actually report the number of songs. However it
1326
* is so fast anyway, so who'd want it? Most time is spent updating the
1327
* widget, not communicating with the device.
1330
while (!last_item) {
1114
1332
metadata_t *meta;
1115
njb_songid_frame_t *frame;
1116
1333
gchar *scanstring;
1118
1335
jukebox_songs++;
1119
1336
/* Number of songs scanned during scan. */
1120
1338
scanstring = g_strdup_printf(_("%u songs scanned"), jukebox_songs);
1121
1339
gdk_threads_enter();
1122
1340
gtk_label_set_text(GTK_LABEL(args->label), scanstring);
1123
1341
gdk_threads_leave();
1124
1342
g_free(scanstring);
1126
NJB_Songid_Reset_Getframe(songtag);
1127
/* Create a structure to hold the data in the columns */
1344
// Create a structure to hold the data in the columns
1128
1345
meta = new_metadata_t();
1129
meta->path = g_strdup_printf("%lu", songtag->trid);
1131
/* Loop through the song tags */
1132
while(frame = NJB_Songid_Getframe(songtag)){
1133
// FIXME: add progress bar for scanning?
1135
if (!strcmp(frame->label, FR_ARTIST)) {
1136
meta->artist = g_strdup(frame->data.strval);
1137
} else if (!strcmp(frame->label, FR_TITLE)) {
1138
meta->title = g_strdup(frame->data.strval);
1139
} else if (!strcmp(frame->label, FR_ALBUM)) {
1140
meta->album = g_strdup(frame->data.strval);
1141
} else if (!strcmp(frame->label, FR_GENRE)) {
1142
meta->genre = g_strdup(frame->data.strval);
1143
} else if (!strcmp(frame->label, FR_LENGTH)) {
1144
meta->length = seconds_to_mmss((guint) frame->data.u_int16_val);
1145
} else if (!strcmp(frame->label, FR_SIZE)) {
1146
meta->size = frame->data.u_int32_val;
1147
} else if (!strcmp(frame->label, FR_CODEC)) {
1148
// Uppercaseify it. Work in all GTK+ >= 2.0?
1149
meta->codec = g_ascii_strup(frame->data.strval, -1);
1150
} else if (!strcmp(frame->label, FR_TRACK)) {
1151
meta->trackno = (guint) frame->data.u_int16_val;
1152
} else if (!strcmp(frame->label, FR_YEAR)) {
1153
meta->year = (guint) frame->data.u_int16_val;
1154
} else if (!strcmp(frame->label, FR_FNAME)) {
1155
meta->filename = g_strdup(frame->data.strval);
1156
} else if (!strcmp(frame->label, FR_FOLDER)) {
1157
meta->folder = g_strdup(frame->data.strval);
1158
} else if (!strcmp(frame->label, FR_PROTECTED)) {
1159
meta->protect = TRUE;
1161
g_print("Unknown frame type %s\n", frame->label);
1349
LIBMTP_track_t *tmp;
1352
// Add to metadata holder
1353
meta->path = g_strdup_printf("%lu", mtptrack->item_id);
1354
meta->artist = g_strdup(mtptrack->artist);
1355
meta->title = g_strdup(mtptrack->title);
1356
meta->genre = g_strdup(mtptrack->genre);
1357
meta->album = g_strdup(mtptrack->album);
1358
meta->length = seconds_to_mmss((guint) (mtptrack->duration/1000));
1359
meta->size = (guint32) mtptrack->filesize;
1360
switch (mtptrack->codec) {
1361
case LIBMTP_CODEC_WAV:
1362
meta->codec = g_strdup("WAV");
1364
case LIBMTP_CODEC_MP3:
1365
meta->codec = g_strdup("MP3");
1367
case LIBMTP_CODEC_WMA:
1368
meta->codec = g_strdup("WMA");
1371
meta->codec = g_strdup("N/A");
1373
meta->trackno = (guint) mtptrack->tracknumber;
1374
// TODO: Complicated. Fix later.
1375
tmpyear = g_strdup(mtptrack->date);
1376
if (tmpyear != NULL && strlen(tmpyear) > 4) {
1377
// Terminate after the year
1379
// Convert to a figure.
1380
meta->year = string_to_guint(tmpyear);
1382
if (tmpyear != NULL) {
1385
meta->filename = g_strdup(mtptrack->filename);
1386
// These two are not supported yet.
1387
meta->folder = NULL;
1388
meta->protect = FALSE;
1391
mtptrack = mtptrack->next;
1392
LIBMTP_destroy_track_t(tmp);
1393
if (mtptrack == NULL) {
1400
njb_songid_frame_t *frame;
1402
NJB_Songid_Reset_Getframe(songtag);
1403
meta->path = g_strdup_printf("%lu", songtag->trid);
1405
/* Loop through the song tags */
1406
while(frame = NJB_Songid_Getframe(songtag)){
1407
// FIXME: add progress bar for scanning?
1409
if (!strcmp(frame->label, FR_ARTIST)) {
1410
meta->artist = g_strdup(frame->data.strval);
1411
} else if (!strcmp(frame->label, FR_TITLE)) {
1412
meta->title = g_strdup(frame->data.strval);
1413
} else if (!strcmp(frame->label, FR_ALBUM)) {
1414
meta->album = g_strdup(frame->data.strval);
1415
} else if (!strcmp(frame->label, FR_GENRE)) {
1416
meta->genre = g_strdup(frame->data.strval);
1417
} else if (!strcmp(frame->label, FR_LENGTH)) {
1418
meta->length = seconds_to_mmss((guint) frame->data.u_int16_val);
1419
} else if (!strcmp(frame->label, FR_SIZE)) {
1420
meta->size = frame->data.u_int32_val;
1421
} else if (!strcmp(frame->label, FR_CODEC)) {
1422
// Uppercaseify it. Work in all GTK+ >= 2.0?
1423
meta->codec = g_ascii_strup(frame->data.strval, -1);
1424
} else if (!strcmp(frame->label, FR_TRACK)) {
1425
meta->trackno = (guint) frame->data.u_int16_val;
1426
} else if (!strcmp(frame->label, FR_YEAR)) {
1427
meta->year = (guint) frame->data.u_int16_val;
1428
} else if (!strcmp(frame->label, FR_FNAME)) {
1429
meta->filename = g_strdup(frame->data.strval);
1430
} else if (!strcmp(frame->label, FR_FOLDER)) {
1431
meta->folder = g_strdup(frame->data.strval);
1432
} else if (!strcmp(frame->label, FR_PROTECTED)) {
1433
meta->protect = TRUE;
1435
g_print("Unknown frame type %s\n", frame->label);
1438
NJB_Songid_Destroy(songtag);
1439
songtag = NJB_Get_Track_Tag(pdedevice);
1440
if (songtag == NULL) {
1164
/* Compensate for missing tag information */
1444
// Compensate for missing tag information
1165
1445
if (!meta->artist)
1166
1446
meta->artist = g_strdup("<Unknown>");
1167
1447
if (!meta->title)
1172
1452
meta->genre = g_strdup("<Unknown>");
1173
1453
if (!meta->length)
1174
1454
meta->length = g_strdup("0:00");
1456
if (gnomad_debug != 0) {
1457
g_print("Adding song \"%s\" to songhash...\n", meta->title);
1458
dump_metadata_t(meta);
1176
1460
g_hash_table_insert(songhash,
1177
1461
GUINT_TO_POINTER(string_to_guint(meta->path)),
1178
1462
(gpointer) meta);
1179
NJB_Songid_Destroy(songtag);
1180
1463
if (cancel_jukebox_operation)
1183
1467
/* Build songlist from hash */
1469
if (gnomad_debug != 0) {
1470
g_print("Building songlist from hash...\n");
1184
1472
jblist_from_songhash(TRUE);
1186
/* Fill in the list of data files */
1187
NJB_Reset_Get_Datafile_Tag(njb);
1475
// TODO: when libmtp can do this, rewrite this to support datafile
1476
// scanning in a nice way.
1478
// Not yet implemented
1480
/* Fill in the list of data files */
1481
NJB_Reset_Get_Datafile_Tag(pdedevice);
1188
1485
gdk_threads_enter();
1189
1486
gtk_label_set_text(GTK_LABEL(args->label), scan_datafiles);
1487
gdk_threads_leave();
1191
1490
/* Destroy the old datafile list */
1192
1491
destroy_datafile_list();
1194
gdk_threads_leave();
1195
while (datatag = NJB_Get_Datafile_Tag (njb)) {
1201
jukebox_datafiles++;
1202
scanstring = g_strdup_printf(_("%u data files scanned"), jukebox_datafiles);
1203
gdk_threads_enter();
1204
gtk_label_set_text(GTK_LABEL(args->label), scanstring);
1205
gdk_threads_leave();
1208
meta = new_metadata_t();
1209
/* g_print("Scan: filename %s, size %d\n", datatag->filename, strlen(datatag->filename)); */
1210
/* Convert filesize from 64 bit unsigned integer value */
1211
filesize = (u_int64_t) datatag->filesize;
1212
/* FIXME: here we loos all the 64-bit quality, because meta->size is 32-bit ... */
1213
meta->size = (guint) filesize;
1214
meta->folder = g_strdup(datatag->folder);
1215
if (datatag->filesize == 0) {
1216
gchar **tmp = g_strsplit(datatag->folder, "\\", 0);
1217
gint veclen = vectorlength(tmp);
1219
gchar *basename = tmp[veclen-2];
1220
meta->filename = g_strdup(basename);
1494
// Not yet implemented
1496
while (datatag = NJB_Get_Datafile_Tag (pdedevice)) {
1502
jukebox_datafiles++;
1505
scanstring = g_strdup_printf(_("%u data files scanned"), jukebox_datafiles);
1506
gdk_threads_enter();
1507
gtk_label_set_text(GTK_LABEL(args->label), scanstring);
1508
gdk_threads_leave();
1512
meta = new_metadata_t();
1513
/* g_print("Scan: filename %s, size %d\n", datatag->filename, strlen(datatag->filename)); */
1514
/* Convert filesize from 64 bit unsigned integer value */
1515
filesize = (u_int64_t) datatag->filesize;
1516
/* FIXME: here we loos all the 64-bit quality, because meta->size is 32-bit ... */
1517
meta->size = (guint) filesize;
1518
meta->folder = g_strdup(datatag->folder);
1519
if (datatag->filesize == 0) {
1520
gchar **tmp = g_strsplit(datatag->folder, "\\", 0);
1521
gint veclen = vectorlength(tmp);
1523
gchar *basename = tmp[veclen-2];
1524
meta->filename = g_strdup(basename);
1526
/* This should not happen */
1527
meta->filename = g_strdup("Erroneous folder");
1222
/* This should not happen */
1223
meta->filename = g_strdup("Erroneous folder");
1531
meta->filename = g_strdup(datatag->filename);
1227
meta->filename = g_strdup(datatag->filename);
1534
meta->path = g_strdup_printf("%lu", datatag->dfid);
1535
datafilelist = g_slist_append(datafilelist, (gpointer) meta);
1536
// destroy_metadata_t(meta);
1537
NJB_Datafile_Destroy (datatag);
1538
if (cancel_jukebox_operation)
1230
meta->path = g_strdup_printf("%lu", datatag->dfid);
1231
datafilelist = g_slist_append(datafilelist, (gpointer) meta);
1232
// destroy_metadata_t(meta);
1233
NJB_Datafile_Destroy (datatag);
1234
if (cancel_jukebox_operation)
1238
gdk_threads_enter();
1239
/* Then refill and sort everything */
1240
rebuild_datafile_list("\\");
1241
gtk_label_set_text(GTK_LABEL(args->label), scan_playlists);
1242
gdk_threads_leave();
1542
/* Then refill and sort everything */
1544
gdk_threads_enter();
1545
rebuild_datafile_list("\\");
1546
gtk_label_set_text(GTK_LABEL(args->label), scan_playlists);
1547
gdk_threads_leave();
1551
// The refresh the playlist tree
1552
if (gnomad_debug != 0) {
1553
g_print("Building playlist tree...\n");
1243
1556
build_playlist_tree(args->pltreestore, TRUE);
1245
1557
gdk_threads_enter();
1246
1558
gtk_widget_destroy(args->dialog);
1247
1559
gdk_threads_leave();
1561
// This will call all widget rebuilding from within the main
1562
// loop instead on Windows.
1563
g_idle_add(call_build_all, (gpointer) args->pltreestore);
1564
gtk_widget_destroy(args->dialog);
1248
1567
jukebox_locked = FALSE;
1252
* Progression callback for transfer both back and forth to the
1255
static int progress (u_int64_t sent, u_int64_t total, const char* buf, unsigned len, void *data)
1570
static set_progress_fraction(guint64 const sent, guint64 const total)
1257
1572
gdouble fraction;
1259
1574
fraction = ((gdouble) sent / (gdouble) total);
1260
1575
gdk_threads_enter();
1261
// gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), percentage);
1262
1576
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), fraction);
1263
1577
gdk_threads_leave();
1581
* Progression callback for transfer both back and forth to the
1584
static NJB_Xfer_Callback pde_progress;
1585
static int pde_progress (u_int64_t sent, u_int64_t total, const char* buf, unsigned len, void *data)
1587
set_progress_fraction(sent, total);
1264
1588
/* This cancels any jukebox operation */
1265
1589
if (cancel_jukebox_operation)
1595
* Same thing but for MTP.
1598
static LIBMTP_progressfunc_t mtp_progress;
1599
static int mtp_progress (uint64_t const sent, uint64_t const total,
1600
void const * const data)
1602
set_progress_fraction(sent, total);
1603
// TODO: cancellation
1608
// Windows don't like it when other threads write to the GUI
1609
// so we do it here from the main loop instead.
1610
gboolean call_fill_in_dir(gpointer data)
1612
guint what = (guint) data;
1614
fill_in_dir(what, get_current_dir());
1271
1619
/***********************************************************************************/
1272
1620
/* Transferring music from jukebox thread */
1432
1828
gdk_threads_leave();
1433
1829
length = mmss_to_seconds(hdmeta->length);
1434
1830
protectint = hdmeta->protect ? 1 : 0;
1435
songid = NJB_Songid_New();
1436
frame = NJB_Songid_Frame_New_Codec(hdmeta->codec);
1437
NJB_Songid_Addframe(songid, frame);
1438
// libnjb will add this if not added by hand
1439
// frame = NJB_Songid_Frame_New_Filesize(filesize);
1440
// NJB_Songid_Addframe(songid, frame);
1441
frame = NJB_Songid_Frame_New_Title(hdmeta->title);
1442
NJB_Songid_Addframe(songid, frame);
1443
frame = NJB_Songid_Frame_New_Album(hdmeta->album);
1444
NJB_Songid_Addframe(songid, frame);
1445
frame = NJB_Songid_Frame_New_Artist(hdmeta->artist);
1446
NJB_Songid_Addframe(songid, frame);
1447
frame = NJB_Songid_Frame_New_Genre(hdmeta->genre);
1448
NJB_Songid_Addframe(songid, frame);
1449
frame = NJB_Songid_Frame_New_Year(hdmeta->year);
1450
NJB_Songid_Addframe(songid, frame);
1451
frame = NJB_Songid_Frame_New_Tracknum(hdmeta->trackno);
1452
NJB_Songid_Addframe(songid, frame);
1453
frame = NJB_Songid_Frame_New_Length(length);
1454
NJB_Songid_Addframe(songid, frame);
1455
frame = NJB_Songid_Frame_New_Filename(hdmeta->filename);
1456
NJB_Songid_Addframe(songid, frame);
1457
if (hdmeta->protect) {
1458
frame = NJB_Songid_Frame_New_Protected(1);
1459
NJB_Songid_Addframe(songid, frame);
1462
/* Optionally remove ID3 tag */
1463
if (get_prefs_id3remove() && !strcmp(hdmeta->codec, "MP3")) {
1465
tmpfname8 = g_build_filename(tmpdirname, hdmeta->filename, NULL);
1466
tmpfname = filename_fromutf8(tmpfname8);
1468
/* Call the filesystem to clone the file and remove the tag */
1469
if (clone_and_strip_id3(hdmeta->path, tmpfname8)) {
1470
// g_print("Transferring track.\n");
1471
if (NJB_Send_Track (njb, tmpfname, songid,
1474
NJB_Error_Dump(njb, stderr);
1477
/* Afterwards delete the tempfile */
1834
LIBMTP_track_t *trackmeta = LIBMTP_new_track_t();
1837
// This will be filled in, dummy set to 0.
1838
trackmeta->item_id = 0;
1839
trackmeta->title = g_strdup(hdmeta->title);
1840
trackmeta->album = g_strdup(hdmeta->album);
1841
trackmeta->artist = g_strdup(hdmeta->artist);
1842
trackmeta->genre = g_strdup(hdmeta->genre);
1843
trackmeta->date = g_strdup_printf("%4d0101T0000.0", hdmeta->year);
1844
trackmeta->filename = g_strdup(hdmeta->filename);
1845
trackmeta->tracknumber = hdmeta->trackno;
1846
// This need to be in milliseconds
1847
trackmeta->duration = length * 1000;
1848
trackmeta->filesize = get_64bit_file_size(tmpfname);
1849
if (!strcmp(hdmeta->codec, "WAV")) {
1850
trackmeta->codec = LIBMTP_CODEC_WAV;
1851
} else if (!strcmp(hdmeta->codec, "MP3")) {
1852
trackmeta->codec = LIBMTP_CODEC_MP3;
1853
} else if (!strcmp(hdmeta->codec, "WMA")) {
1854
trackmeta->codec = LIBMTP_CODEC_WMA;
1856
trackmeta->codec = LIBMTP_CODEC_UNKNOWN;
1858
// TODO: Discarding return value as for now
1859
g_print("Transferring MTP track...\n");
1860
ret = LIBMTP_Send_Track_From_File(mtpdevice, tmpfname, trackmeta,
1861
mtp_progress, NULL);
1863
g_print("Error sending file \"%s\" to MTP device!\n", tmpfname);
1866
// Fetch new track ID.
1867
id = trackmeta->item_id;
1868
LIBMTP_destroy_track_t(trackmeta);
1482
tmpfname = filename_fromutf8(hdmeta->path);
1483
if (NJB_Send_Track (njb, tmpfname, songid,
1871
njb_songid_t *songid;
1872
njb_songid_frame_t *frame;
1874
songid = NJB_Songid_New();
1875
frame = NJB_Songid_Frame_New_Codec(hdmeta->codec);
1876
NJB_Songid_Addframe(songid, frame);
1877
// libnjb will add this if not added by hand
1878
// frame = NJB_Songid_Frame_New_Filesize(filesize);
1879
// NJB_Songid_Addframe(songid, frame);
1880
frame = NJB_Songid_Frame_New_Title(hdmeta->title);
1881
NJB_Songid_Addframe(songid, frame);
1882
frame = NJB_Songid_Frame_New_Album(hdmeta->album);
1883
NJB_Songid_Addframe(songid, frame);
1884
frame = NJB_Songid_Frame_New_Artist(hdmeta->artist);
1885
NJB_Songid_Addframe(songid, frame);
1886
frame = NJB_Songid_Frame_New_Genre(hdmeta->genre);
1887
NJB_Songid_Addframe(songid, frame);
1888
frame = NJB_Songid_Frame_New_Year(hdmeta->year);
1889
NJB_Songid_Addframe(songid, frame);
1890
frame = NJB_Songid_Frame_New_Tracknum(hdmeta->trackno);
1891
NJB_Songid_Addframe(songid, frame);
1892
frame = NJB_Songid_Frame_New_Length(length);
1893
NJB_Songid_Addframe(songid, frame);
1894
frame = NJB_Songid_Frame_New_Filename(hdmeta->filename);
1895
NJB_Songid_Addframe(songid, frame);
1896
if (hdmeta->protect) {
1897
frame = NJB_Songid_Frame_New_Protected(1);
1898
NJB_Songid_Addframe(songid, frame);
1901
// g_print("Transferring track.\n");
1902
if (NJB_Send_Track (pdedevice, tmpfname, songid,
1486
NJB_Error_Dump(njb, stderr);
1905
NJB_Error_Dump(pdedevice, stderr);
1487
1906
goto hd2jb_cleanup;
1908
// FIXME: do we need to destroy songid? Memleak?
1909
/* g_print("%s stored on jukebox with ID: %lu\n", file, id); */
1490
/* g_print("%s stored on jukebox with ID: %lu\n", file, id); */
1492
1912
jukebox_songs++;
1493
1913
/* Add to disk listbox and re-sort */
1494
1914
/* Add correct trackid in col 7, add the row */
1621
2062
meta = (metadata_t *) tmplist->data;
1622
2063
id = string_to_guint(meta->path);
1623
NJB_Reset_Get_Playlist(njb);
1625
while (playlist = NJB_Get_Playlist(njb)) {
1626
NJB_Playlist_Deltrack_TrackID(playlist, id);
1627
/* If the playlist changed, update it */
1628
if (playlist->_state == NJB_PL_CHTRACKS) {
1629
if (NJB_Update_Playlist(njb, playlist) == -1)
1630
NJB_Error_Dump(njb, stderr);
1632
NJB_Playlist_Destroy(playlist);
1634
if (NJB_Error_Pending(njb)) {
1635
NJB_Error_Dump(njb, stderr);
2066
// Not implemented yet
2068
NJB_Reset_Get_Playlist(pdedevice);
2070
while (playlist = NJB_Get_Playlist(pdedevice)) {
2071
NJB_Playlist_Deltrack_TrackID(playlist, id);
2072
/* If the playlist changed, update it */
2073
if (playlist->_state == NJB_PL_CHTRACKS) {
2074
if (NJB_Update_Playlist(pdedevice, playlist) == -1)
2075
NJB_Error_Dump(pdedevice, stderr);
2077
NJB_Playlist_Destroy(playlist);
2079
if (NJB_Error_Pending(pdedevice)) {
2080
NJB_Error_Dump(pdedevice, stderr);
1637
2083
tmplist = g_list_next(tmplist);
1741
songid = NJB_Songid_New();
1742
/* On NJB1 incremental update is not possible! */
1743
if (njb->device_type == NJB_DEVICE_NJB1) {
1744
// Sometimes it fails with old codec names.
1745
gchar *tmpcodec = g_ascii_strup(meta->codec, -1);
1747
frame = NJB_Songid_Frame_New_Codec(tmpcodec);
1749
NJB_Songid_Addframe(songid, frame);
1750
frame = NJB_Songid_Frame_New_Filesize(meta->size);
1751
NJB_Songid_Addframe(songid, frame);
1753
/* Ultimately only send altered fields to NJB series 3 */
1754
frame = NJB_Songid_Frame_New_Title(meta->title);
1755
NJB_Songid_Addframe(songid, frame);
1756
frame = NJB_Songid_Frame_New_Album(meta->album);
1757
NJB_Songid_Addframe(songid, frame);
1758
frame = NJB_Songid_Frame_New_Artist(meta->artist);
1759
NJB_Songid_Addframe(songid, frame);
1760
frame = NJB_Songid_Frame_New_Genre(meta->genre);
1761
NJB_Songid_Addframe(songid, frame);
1762
frame = NJB_Songid_Frame_New_Year(meta->year);
1763
NJB_Songid_Addframe(songid, frame);
1764
frame = NJB_Songid_Frame_New_Tracknum(meta->trackno);
1765
NJB_Songid_Addframe(songid, frame);
1766
frame = NJB_Songid_Frame_New_Length(length);
1767
NJB_Songid_Addframe(songid, frame);
1769
* These will only be set if the jukebox has retrieved
1770
* extended metadata so that the user has a chance of modifying
1771
* an existing tag, not just overwrite what is already there.
1773
if (get_prefs_extended_metadata()) {
1774
if (meta->filename != NULL) {
1775
frame = NJB_Songid_Frame_New_Filename(meta->filename);
1776
NJB_Songid_Addframe(songid, frame);
1778
if (meta->folder != NULL) {
1779
frame = NJB_Songid_Frame_New_Folder(meta->folder);
1780
NJB_Songid_Addframe(songid, frame);
1783
if (meta->protect) {
1784
frame = NJB_Songid_Frame_New_Protected(1);
1785
NJB_Songid_Addframe(songid, frame);
1788
if (NJB_Replace_Track_Tag(njb, id, songid) == -1) {
1789
NJB_Error_Dump(njb, stderr);
2200
LIBMTP_track_t *trackmeta = LIBMTP_new_track_t();
2203
trackmeta->item_id = id;
2204
trackmeta->title = g_strdup(meta->title);
2205
trackmeta->album = g_strdup(meta->album);
2206
trackmeta->artist = g_strdup(meta->artist);
2207
trackmeta->genre = g_strdup(meta->genre);
2208
trackmeta->date = g_strdup_printf("%4d0101T0000.0", meta->year);
2209
// This cannot be set this way but send it anyway
2210
trackmeta->filename = g_strdup(meta->filename);
2211
trackmeta->tracknumber = meta->trackno;
2212
// This need to be in milliseconds
2213
trackmeta->duration = length * 1000;
2214
// This cannot be set this way but send it anyway
2215
trackmeta->filesize = (uint64_t) meta->size;
2216
if (!strcmp(meta->codec, "WAV")) {
2217
trackmeta->codec = LIBMTP_CODEC_WAV;
2218
} else if (!strcmp(meta->codec, "MP3")) {
2219
trackmeta->codec = LIBMTP_CODEC_MP3;
2220
} else if (!strcmp(meta->codec, "WMA")) {
2221
trackmeta->codec = LIBMTP_CODEC_WMA;
2223
trackmeta->codec = LIBMTP_CODEC_UNKNOWN;
2225
// TODO: Discarding return value as for now
2226
ret = LIBMTP_Update_Track_Metadata(mtpdevice, trackmeta);
2227
LIBMTP_destroy_track_t(trackmeta);
2230
njb_songid_t *songid;
2231
njb_songid_frame_t *frame;
2233
songid = NJB_Songid_New();
2234
/* On NJB1 incremental update is not possible! */
2235
if (pdedevice->device_type == NJB_DEVICE_NJB1) {
2236
// Sometimes it fails with old codec names.
2237
gchar *tmpcodec = g_ascii_strup(meta->codec, -1);
2239
frame = NJB_Songid_Frame_New_Codec(tmpcodec);
2241
NJB_Songid_Addframe(songid, frame);
2242
frame = NJB_Songid_Frame_New_Filesize(meta->size);
2243
NJB_Songid_Addframe(songid, frame);
2245
/* Ultimately only send altered fields to NJB series 3 */
2246
frame = NJB_Songid_Frame_New_Title(meta->title);
2247
NJB_Songid_Addframe(songid, frame);
2248
frame = NJB_Songid_Frame_New_Album(meta->album);
2249
NJB_Songid_Addframe(songid, frame);
2250
frame = NJB_Songid_Frame_New_Artist(meta->artist);
2251
NJB_Songid_Addframe(songid, frame);
2252
frame = NJB_Songid_Frame_New_Genre(meta->genre);
2253
NJB_Songid_Addframe(songid, frame);
2254
frame = NJB_Songid_Frame_New_Year(meta->year);
2255
NJB_Songid_Addframe(songid, frame);
2256
frame = NJB_Songid_Frame_New_Tracknum(meta->trackno);
2257
NJB_Songid_Addframe(songid, frame);
2258
frame = NJB_Songid_Frame_New_Length(length);
2259
NJB_Songid_Addframe(songid, frame);
2261
* These will only be set if the jukebox has retrieved
2262
* extended metadata so that the user has a chance of modifying
2263
* an existing tag, not just overwrite what is already there.
2265
if (get_prefs_extended_metadata()) {
2266
if (meta->filename != NULL) {
2267
frame = NJB_Songid_Frame_New_Filename(meta->filename);
2268
NJB_Songid_Addframe(songid, frame);
2270
if (meta->folder != NULL) {
2271
frame = NJB_Songid_Frame_New_Folder(meta->folder);
2272
NJB_Songid_Addframe(songid, frame);
2275
if (meta->protect) {
2276
frame = NJB_Songid_Frame_New_Protected(1);
2277
NJB_Songid_Addframe(songid, frame);
2280
if (NJB_Replace_Track_Tag(pdedevice, id, songid) == -1) {
2281
NJB_Error_Dump(pdedevice, stderr);
1791
2285
/* Replace the data in the hash table */
1792
2286
tmpmeta = (metadata_t *) g_hash_table_lookup(songhash,
1793
2287
GUINT_TO_POINTER(id));