63
gchar *Id3tag_Get_Error_Message (ID3_Err error);
64
void Id3tag_Prepare_ID3v1 (ID3Tag *id3_tag);
65
gchar *Id3tag_Rules_For_ISO_Fields (const gchar *string, const gchar *from_codeset, const gchar *to_codeset);
66
gchar *Id3tag_Get_Field (const ID3Frame *id3_frame, ID3_FieldID id3_fieldid);
67
ID3_TextEnc Id3tag_Set_Field (const ID3Frame *id3_frame, ID3_FieldID id3_fieldid, gchar *string);
62
static gchar *Id3tag_Get_Error_Message (ID3_Err error);
63
static void Id3tag_Prepare_ID3v1 (ID3Tag *id3_tag);
64
static gchar *Id3tag_Rules_For_ISO_Fields (const gchar *string,
65
const gchar *from_codeset,
66
const gchar *to_codeset);
67
static gchar *Id3tag_Get_Field (const ID3Frame *id3_frame,
68
ID3_FieldID id3_fieldid);
69
static ID3_TextEnc Id3tag_Set_Field (const ID3Frame *id3_frame,
70
ID3_FieldID id3_fieldid, gchar *string);
69
72
ID3_C_EXPORT size_t ID3Tag_Link_1 (ID3Tag *id3tag, const char *filename);
70
73
ID3_C_EXPORT size_t ID3Field_GetASCII_1 (const ID3Field *field, char *buffer, size_t maxChars, size_t itemNum);
71
74
ID3_C_EXPORT size_t ID3Field_GetUNICODE_1 (const ID3Field *field, unicode_t *buffer, size_t maxChars, size_t itemNum);
73
gboolean Id3tag_Check_If_File_Is_Corrupted (gchar *filename);
76
static gboolean Id3tag_Check_If_File_Is_Corrupted (const gchar *filename);
75
gboolean Id3tag_Check_If_Id3lib_Is_Bugged (void);
78
static gboolean Id3tag_Check_If_Id3lib_Is_Bugged (void);
542
546
if (Id3tag_Read_File_Tag(filename,FileTag_tmp) == TRUE
543
547
&& ET_Detect_Changes_Of_File_Tag(FileTag,FileTag_tmp) == TRUE)
545
GtkWidget *msgbox = NULL;
549
GtkWidget *msgdialog;
548
msg = g_strdup_printf(_("You have tried to save this tag to Unicode "
549
"but it was detected that your version of id3lib is bugged.\n"
550
"If you reload this file, some characters in the tag may be not "
551
"displayed correctly...\nPlease, apply to id3lib the patch "
552
"src/id3lib/patch_id3lib_3.8.3_UTF16_writing_bug.diff\n"
553
"available in EasyTAG package sources.\n"
554
"Note that this message will appear only one time.\n\n"
555
"File : %s"),filename_utf8);
556
551
//Log_Print(LOG_ERROR,msg);
558
msgbox = msg_box_new(_("Error..."),
559
GTK_WINDOW(MainWindow),
561
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
563
GTK_STOCK_DIALOG_ERROR,
564
GTK_STOCK_OK, GTK_RESPONSE_OK,
566
gtk_dialog_run(GTK_DIALOG(msgbox));
567
gtk_widget_destroy(msgbox);
553
msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
554
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
558
_("You have tried to save this tag to Unicode but it was detected that your version of id3lib is buggy"));
559
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msgdialog),
560
_("If you reload this file, some characters in the tag may not be displayed "
561
"correctly. Please, apply the patch "
562
"src/id3lib/patch_id3lib_3.8.3_UTF16_writing_bug.diff to id3lib, which is "
563
"available in the EasyTAG package sources.\nNote that this message will "
564
"appear only once.\n\nFile: %s"),
567
gtk_window_set_title(GTK_WINDOW(msgdialog),_("Buggy id3lib"));
568
gtk_dialog_run(GTK_DIALOG(msgdialog));
569
gtk_widget_destroy(msgdialog);
569
570
flag_id3lib_bugged = FALSE; // To display the message only one time
571
572
ET_Free_File_Tag_Item(FileTag_tmp);
1228
GtkWidget *msgbox = NULL;
1229
GtkWidget *msgdialog;
1230
1230
gchar *basename;
1231
1231
gchar *basename_utf8;
1233
1233
basename = g_path_get_basename(filename);
1234
1234
basename_utf8 = filename_to_display(basename);
1236
msg = g_strdup_printf(_("As the following corrupted file: '%s'\nwill cause "
1237
"an error in id3lib, it will not be processed by the program."),basename_utf8);
1238
msgbox = msg_box_new(_("Corrupted file..."),
1239
GTK_WINDOW(MainWindow),
1241
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1243
GTK_STOCK_DIALOG_ERROR,
1244
GTK_STOCK_OK, GTK_RESPONSE_OK,
1246
gtk_dialog_run(GTK_DIALOG(msgbox));
1247
gtk_widget_destroy(msgbox);
1236
msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
1237
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1240
_("As the following corrupted file '%s' will cause an error in id3lib, it will not be processed"),
1242
gtk_window_set_title(GTK_WINDOW(msgdialog),_("Corrupted file"));
1244
gtk_dialog_run(GTK_DIALOG(msgdialog));
1245
gtk_widget_destroy(msgdialog);
1249
1246
g_free(basename);
1250
1247
g_free(basename_utf8);
1261
1258
gboolean Id3tag_Check_If_Id3lib_Is_Bugged (void)
1264
unsigned char tmp[16] = {0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00,
1265
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1266
0x00, 0x00, 0x00, 0x00};
1261
GFileIOStream *iostream = NULL;
1262
GOutputStream *ostream = NULL;
1263
GError *error = NULL;
1264
guchar tmp[16] = {0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1265
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1267
1266
ID3Tag *id3_tag = NULL;
1269
gchar *filename_tmp;
1270
1268
gchar *result = NULL;
1271
1269
ID3Frame *id3_frame;
1272
1270
gboolean use_unicode;
1278
// Create a temporary file
1279
filename = g_strconcat(HOME_VARIABLE,
1280
HOME_VARIABLE[strlen(HOME_VARIABLE)-1]!=G_DIR_SEPARATOR ? G_DIR_SEPARATOR_S : "",
1281
".easytag" G_DIR_SEPARATOR_S "test_easytag.mp3",
1284
// Must convert to the filesystem encoding (else may cause problem under XP with accounts like "L�o")
1285
filename_tmp = filename;
1286
filename = filename_from_display(filename);
1287
g_free(filename_tmp);
1289
if ( (file=fopen(filename,"w+"))==NULL )
1291
gchar *filename_utf8 = filename_to_display(filename);
1292
Log_Print(LOG_ERROR,_("ERROR while opening file: '%s' (%s)."),filename_utf8,g_strerror(errno));
1293
g_free(filename_utf8);
1296
// Set data in the file
1297
fwrite(&tmp,16,1,file);
1274
/* Create a temporary file. */
1275
file = g_file_new_tmp ("easytagXXXXXX.mp3", &iostream, &error);
1280
Log_Print (LOG_ERROR,
1281
_("Error while creating temporary file: '%s'"),
1283
g_clear_error (&error);
1287
Log_Print (LOG_ERROR, "%s",
1288
_("Error while creating temporary file"));
1294
/* Set data in the file. */
1295
ostream = g_io_stream_get_output_stream (G_IO_STREAM (iostream));
1296
count = g_output_stream_write (G_OUTPUT_STREAM (ostream), tmp,
1297
sizeof (tmp), NULL, &error);
1298
if (count != sizeof (tmp))
1301
gchar *filename_utf8;
1303
filename = g_file_get_path (file);
1304
filename_utf8 = filename_to_display (filename);
1305
Log_Print (LOG_ERROR, _("Error while writing to file: '%s' (%s)"),
1306
filename_utf8, error->message);
1309
g_free (filename_utf8);
1310
g_clear_error (&error);
1311
g_object_unref (file);
1312
g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, NULL);
1317
g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, NULL);
1318
g_object_unref (ostream);
1300
1320
// Save state of switches as we must force to Unicode before writting
1301
1321
use_unicode = FILE_WRITING_ID3V2_USE_UNICODE_CHARACTER_SET;
1302
1322
FILE_WRITING_ID3V2_USE_UNICODE_CHARACTER_SET = TRUE;
1304
1324
id3_tag = ID3Tag_New();
1305
ID3Tag_Link_1(id3_tag,filename);
1325
path = g_file_get_path (file);
1326
ID3Tag_Link_1 (id3_tag, path);
1307
1328
// Create a new 'title' field for testing
1308
1329
id3_frame = ID3Frame_NewID(ID3FID_TITLE);
1309
1330
ID3Tag_AttachFrame(id3_tag,id3_frame);
1310
1331
// Use a Chinese character instead of the latin-1 character as in Id3tag_Set_Field()
1311
1332
// we try to convert the string to ISO-8859-1 even in the Unicode mode.
1312
//Id3tag_Set_Field(id3_frame, ID3FN_TEXT, "é"); // This latin-1 character is written in Unicode as 'E9 FF' instead of 'E9 00' if bugged
1313
Id3tag_Set_Field(id3_frame, ID3FN_TEXT, "�°"); // This Chinese character is written in Unicode as 'FF FE B0 FF' instead of 'FF FE B0 30' if bugged
1333
//Id3tag_Set_Field(id3_frame, ID3FN_TEXT, "\303\251"); // This latin-1 character is written in Unicode as 'E9 FF' instead of 'E9 00' if bugged
1334
Id3tag_Set_Field(id3_frame, ID3FN_TEXT, "\343\302\260"); // This Chinese character is written in Unicode as 'FF FE B0 FF' instead of 'FF FE B0 30' if bugged
1315
1336
// Update the tag
1316
1337
ID3Tag_UpdateByTagType(id3_tag,ID3TT_ID3V2);