2006-08-15: Keith Bennett dixit:
> On Tue, Aug 15, 2006, EV wrote:
> > I have not time now to undo all the work that was included in my
> > lk005-hg98 patch. If you like, what I can do is to send a patch
> > **against changeset 96** which includes:
> >
> > - your tags-libkarma-hg96.patch
> > - your libkarma-hg96-dupes.patch
> > - my error-message mods and other fixes (as in lk005-hg98)
> > - the fix related with tl_file we've just discussed.
> >
> > Should I send it?
>
> My preference is to keep them separate. I find it easier
> reading through patches when they deal with one specific issue.
> Not that I always keep to this rule myself, but since they were
> separate patches to begin with then I would rather that they
> stayed separate.
>
> I'll re-send the tags patch this evening and then all you have
> to do is diff your current tree with the repository.
Here is it, against current repository tip, changelog 99. It
seems to be god, but I haven't done so much testing as before...
Keith, please have a look at the (call to) set_tag_props() to see
if it is OK now.
Best,
EV.
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID bf5ecf7bd4f1709bc3baa5809b8097bbf2d3eaf1
# Parent 440a48ba5c6bacbe790754f3d45421e289644d80
Fixed rio_rw error handling and several other minor bugs
diff -r 440a48ba5c6b -r bf5ecf7bd4f1 ChangeLog
--- a/ChangeLog Tue Aug 15 18:19:52 2006
+++ b/ChangeLog Tue Aug 15 19:03:56 2006
@@ -1,3 +1,8 @@
+0.0.6:
+ * Fixed rio_rw error handling and several other minor bugs
+ * Added lk_rio_update_props_from_tags() to help lkarmafs file upload
+ * Get file type from its contents rather than the suffix.
+ * Use the rid property to (optionally) avoid multiple uploaded copies
0.0.5:
* Return an error during lk_karmaUsb_connect() if essential
directories (fids0 and var) are not found
diff -r 440a48ba5c6b -r bf5ecf7bd4f1 src/errors.c
--- a/src/errors.c Tue Aug 15 18:19:52 2006
+++ b/src/errors.c Tue Aug 15 19:03:56 2006
@@ -36,17 +36,22 @@
/* E_SSDPPARSE 17 */ "* Libkarma warning: ssdp parsing failed",
/* E_MKDIR 18 */ "** Libkarma error: mkdir() failed",
/* E_UTIME 19 */ "** Libkarma error: utime() failed",
- /* E_NODIR 20 */ "** Libkarma error: Unexisting directory",
- /* E_NOPROP 21 */ "* Libkarma warning: Missing fid properties",
- /* E_READ 22 */ "* Libkarma warning: Read error",
- /* E_WRITE 23 */ "** Libkarma error: Write error",
- /* E_DELETE 24 */ "** Libkarma error: Delete error",
- /* E_NODEVSET 25 */ "* Libkarma warning: No device-settings file",
- /* E_UNIMPLEM 26 */ "* Libkarma warning: Unimplemented call",
+ /* E_NODIR 20 */ "** Libkarma error: unexisting directory",
+ /* E_NOPROP 21 */ "* Libkarma warning: missing fid properties",
+ /* E_READ 22 */ "* Libkarma warning: read error",
+ /* E_WRITE 23 */ "** Libkarma error: write error",
+ /* E_DELETE 24 */ "** Libkarma error: delete error",
+ /* E_NODEVSET 25 */ "* Libkarma warning: no device-settings file",
+ /* E_UNIMPLEM 26 */ "* Libkarma warning: unimplemented call",
/* E_MFINDERR 27 */ "* Libkarma warning: mount search error",
/* E_NOMOUNT 28 */ "* Libkarma warning: no mountpoint found",
/* E_MANYMOUNT 29 */ "* Libkarma warning: more than one mountpoints",
- /* E_DUPE 30 */ "* Libkarma warning: file already present"
+ /* E_DUPE 30 */ "* Libkarma warning: tune already present",
+ /* E_PATHCREAT 31 */ "* Libkarma warning: dir access/create failed",
+ /* E_NOHASH 32 */ "** Libkarma error: no hash found",
+ /* E_WRCHUNK 33 */ "** Libkarma error: write_file_chunk() failed",
+ /* E_SMALLMP3 34 */ "** Libkarma error: tune file is too small",
+ /* E_UNSUPTAG 35 */ "* Libkarma warning: unsupported tag type"
};
#define libkarmaErrorString lkerrorList[libkarmaError]
diff -r 440a48ba5c6b -r bf5ecf7bd4f1 src/lkarma.h
--- a/src/lkarma.h Tue Aug 15 18:19:52 2006
+++ b/src/lkarma.h Tue Aug 15 19:03:56 2006
@@ -127,21 +127,26 @@
#define E_MKDIR 18 /* error: mkdir() failed */ /* Sys */
#define E_UTIME 19 /* error: utime() failed */ /* Sys */
-#define E_NODIR 20 /* error: Unexisting directory */ /* USB */
-#define E_NOPROP 21 /* warning: Missing prop file */ /* USB */
-#define E_READ 22 /* error: Read error */ /* USB */
-#define E_WRITE 23 /* error: Write error */ /* USB */
-#define E_DELETE 24 /* warning: Delete error */ /* USB */
-#define E_NODEVSET 25 /* warning: No device-settings file */ /* USB */
-#define E_UNIMPLEM 26 /* warning: Unimplemented call */ /* USB */
+#define E_NODIR 20 /* error: unexisting directory */ /* USB */
+#define E_NOPROP 21 /* warning: missing prop file */ /* USB */
+#define E_READ 22 /* error: read error */ /* USB */
+#define E_WRITE 23 /* error: write error */ /* USB */
+#define E_DELETE 24 /* warning: delete error */ /* USB */
+#define E_NODEVSET 25 /* warning: no device-settings file */ /* USB */
+#define E_UNIMPLEM 26 /* warning: unimplemented call */ /* USB */
#define E_MFINDERR 27 /* warning: mount search error */ /* MFIND */
#define E_NOMOUNT 28 /* warning: no mountpoints found */ /* MFIND */
#define E_MANYMOUNT 29 /* warning: more than 1 mountpoints */ /* MFIND */
-#define E_DUPE 30 /* warning: duplicated file */
-
-#define MAXLKERRORS 30
+#define E_DUPE 30 /* warning: file already present */ /* RIO_RW */
+#define E_PATHCREAT 31 /* warning: dir access/create failed */ /* RIO_RW */
+#define E_NOHASH 32 /* error: no hash found */ /* RIO_RW */
+#define E_WRCHUNK 33 /* error: write_file_chunk() failed */ /* RIO_RW */
+#define E_SMALLMP3 34 /* error: tune file is too small */ /* RIO_RW */
+#define E_UNSUPTAG 35 /* warning: unsupported tag type */ /* RIO_RW */
+
+#define MAXLKERRORS 35
/*
@@ -171,6 +176,7 @@
/*
* rio_rw
*/
+#define MODE_PROPERTY "play_count_limit" /* for taxi files chmod in lkarmafs
*/
int lk_rio_read_playlist(int rio, uint32_t fid, const char * filename);
int lk_rio_read(int rio, uint32_t fid, const char * filename);
diff -r 440a48ba5c6b -r bf5ecf7bd4f1 src/rio_rw.c
--- a/src/rio_rw.c Tue Aug 15 18:19:52 2006
+++ b/src/rio_rw.c Tue Aug 15 19:03:56 2006
@@ -32,7 +32,8 @@
/* #define BLOCKSIZE 32768 */
#define BLOCKSIZE 131072
-#define NOT_TAGGED "[karmalib 0.4]"
+/* #define NOT_TAGGED "[karmalib 0.4]" */
+#define NOT_TAGGED "unTagged" /* something more explicit and readable ... */
enum { TYPE_DATA, TYPE_MP3, TYPE_OGG, TYPE_FLAC, TYPE_WAV, TYPE_WMA };
@@ -74,9 +75,10 @@
if (pl==NULL)
return -1; /* Can't get playlist for this fid */
- if (mk_path(filename))
- fprintf(stderr,
- "** Could not create directory of path: %s\n", filename);
+ if (mk_path(filename)) {
+ lk_errors_set(E_PATHCREAT);
+/* fprintf(stderr,"** Error creating directory of path: %s\n",filename);
*/
+ }
dst=open(filename,
O_CREAT|O_EXCL|O_WRONLY,S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
if(dst==-1)
@@ -96,9 +98,10 @@
char *tmp, *tmp1;
/* dst=creat(filename, O_EXCL); */
- if (mk_path(filename))
- fprintf(stderr,
- "** Could not create directory of path: %s\n", filename);
+ if (mk_path(filename)) {
+ lk_errors_set(E_PATHCREAT);
+/* fprintf(stderr,"** Error creating directory of path: %s\n",filename);
*/
+ }
dst=open(filename,
O_CREAT|O_EXCL|O_WRONLY,S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
if(dst==-1)
@@ -143,7 +146,7 @@
filename = lk_karma_fidToPath(rio, fid);
usb = 1;
} else
- filename = (char*)fname;
+ filename = (char *)fname;
if(lstat(filename, &len)==-1) {
if (usb) {
@@ -165,10 +168,6 @@
fids = lk_properties_andOrSearch(EXACT|ORS, NULL, "rid", rid);
if (fids != NULL) {
- if (usb) {
- unlink(filename);
- free(filename);
- }
free(fids);
lk_errors_set(E_DUPE);
return -1;
@@ -182,7 +181,8 @@
unlink(filename);
free(filename);
}
- printf("huh, no hash found?\n");
+ lk_errors_set(E_NOHASH);
+/* printf("huh, no hash found?\n"); */
return -1;
}
@@ -250,7 +250,8 @@
fid, 0, tmp) != 0)
*/
if(lk_karma_write_file_chunk(rio, offs, got, fid, 0, tmp)!=0) {
- printf("lk_karma_write_file_chunk: %u of %llu\n", got, siz);
+ lk_errors_set(E_WRCHUNK);
+/* printf("lk_karma_write_file_chunk: %u of %llu\n", got, siz); */
lk_properties_del_property(fid);
return -1;
}
@@ -288,8 +289,13 @@
static int get_ogg_props(HASH *p, const char *filename)
{
+ lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "codec", "vorbis");
- lk_properties_set_property_hash(p, "type", "tune");
+
+ /*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "source", NOT_TAGGED);
set_tag_props(p, filename, TagLib_File_OggVorbis);
return 0;
@@ -297,13 +303,17 @@
static int get_flac_props(HASH *p, const char *filename)
{
+ lk_properties_set_property_hash(p, "type", "tune");
+ lk_properties_set_property_hash(p, "codec", "flac");
+
/*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
lk_properties_set_property_hash(p, "source", NOT_TAGGED);
- lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
-
- lk_properties_set_property_hash(p, "codec", "flac");
- lk_properties_set_property_hash(p, "type", "tune");
-
+
+#ifndef TagLib_File_FLAC /* older tag_c libs don't have TagLib_File_FLAC */
+#define TagLib_File_FLAC -1
+#endif
set_tag_props(p, filename, TagLib_File_FLAC);
return 0;
}
@@ -314,7 +324,9 @@
lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "codec", "mp3");
+
/*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
lk_properties_set_property_hash(p, "source", NOT_TAGGED);
@@ -333,10 +345,11 @@
{
lk_properties_set_property_hash(p, "duration", "0");
lk_properties_set_property_hash(p, "offset", "0");
- lk_properties_set_property_hash(p, "bitrate", "fs128");
+/* lk_properties_set_property_hash(p, "bitrate", "fs128"); */ /* unneeded */
lk_properties_set_property_hash(p, "codec", "taxi");
lk_properties_set_property_hash(p, "type", "taxi");
-
+ /* Set read-only access permissions for lkarmafs */
+ lk_properties_set_property_hash(p, MODE_PROPERTY, "33060");
return 0;
}
/*
@@ -356,8 +369,9 @@
lk_properties_set_property_hash(p, "codec", "wave");
lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "bitrate", "fs999");
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", "wave_file");
lk_properties_set_property_hash(p, "source", "wave_file");
- lk_properties_set_property_hash(p, "artist", "wave_file");
lk_properties_set_property_hash(p, "samplerate",
simple_itoa(wh->nSamplesPerSec));
lk_properties_set_property_hash(p, "duration", simple_itoa(1000 *
@@ -375,7 +389,7 @@
if (value[0])
lk_properties_set_property_hash(p, key, value);
- /*printf("Key = %s ; Value = %s\n", key, value);*/
+ /* printf("Key = %s ; Value = %s\n", key, value); */
}
/*** You can use this with all tag-formats, which taglib supports.
@@ -388,10 +402,17 @@
int i;
char bitrate[6];
- tl_file = taglib_file_new_type(filename, type);
+ if (type != -1)
+ tl_file = taglib_file_new_type(filename, type);
+ else
+ tl_file = taglib_file_new(filename);
+ if (! tl_file) {
+ lk_errors_set(E_UNSUPTAG);
+ return;
+ }
+
tl_tag = taglib_file_tag(tl_file);
tl_audio = taglib_file_audioproperties(tl_file);
-
add_tag(p, "title", taglib_tag_title(tl_tag));
add_tag(p, "artist", taglib_tag_artist(tl_tag));
@@ -444,8 +465,8 @@
if (mp3->datasize >= 128) {
if (fseek(mp3->file, -128, SEEK_END )) {
- fprintf(stderr, "ERROR: Couldn't read last 128 bytes of %s.\n",
- mp3->filename);
+ lk_errors_set(E_SMALLMP3);
+/* fprintf(stderr,"read err: last 128 bytes of
%s.\n",mp3->filename);*/
return -1;
} else {
fread(buf, 1, 3, mp3->file);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel