From: <ny...@us...> - 2006-03-18 03:34:19
|
Revision: 4 Author: nyaochi Date: 2006-03-17 19:34:03 -0800 (Fri, 17 Mar 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=4&view=rev Log Message: ----------- - iRiver H10 UMS 5/6GB 2.52 support. - Showing all filenames when obtaining the media information. - Added the field for storing the timestamp when an music file is added. Modified Paths: -------------- trunk/frontend/easypmp/common/database.c trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc trunk/frontend/easypmp/win32gui/preference.h trunk/frontend/easypmp/win32gui/progress_with_caption.h trunk/include/pmp.h trunk/lib/pmp_portalplayer1/hdr_template.h trunk/lib/pmp_portalplayer1/model_iriver_h10.c trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/frontend/easypmp/common/database.c =================================================================== --- trunk/frontend/easypmp/common/database.c 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/frontend/easypmp/common/database.c 2006-03-18 03:34:03 UTC (rev 4) @@ -29,6 +29,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include <filepath.h> #include <pmp.h> @@ -41,6 +42,11 @@ #define COMP_STR(x, y) ucs2cmp(x, y) #endif +static uint32_t get_current_time() +{ + return (uint32_t)time(NULL); +} + static int comp_filename(const pmp_record_t *x, const pmp_record_t *y) { return COMP_STR(x->filename, y->filename); @@ -99,6 +105,7 @@ pmp_record_t* records = NULL; pmp_record_t* old_records = NULL; uint32_t num_old_records = 0, num_obtained = 0; + uint32_t ts_import = get_current_time(); if (progress(instance, EASYPMPDBP_START, 0, 0, NULL) != 0) { return EASYPMPE_CANCEL; @@ -236,6 +243,7 @@ } else { } record->timestamp = timestamp; + record->ts_import = ts_import; } } if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { Modified: trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc =================================================================== --- trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-03-18 03:34:03 UTC (rev 4) @@ -42,6 +42,17 @@ #pragma code_page(1252) #endif //_WIN32 +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\easypmp_win32gui.ico" +IDI_PROCESSING ICON "res\\processing.ico" +IDI_QUEUING ICON "res\\icon1.ico" + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // @@ -70,17 +81,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\easypmp_win32gui.ico" -IDI_PROCESSING ICON "res\\processing.ico" -IDI_QUEUING ICON "res\\icon1.ico" - -///////////////////////////////////////////////////////////////////////////// -// // Dialog // @@ -211,8 +211,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,8,0,2 - PRODUCTVERSION 0,8,0,2 + FILEVERSION 0,9,0,2 + PRODUCTVERSION 0,9,0,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -228,12 +228,12 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "EasyPMP [Win32 GUI] application" - VALUE "FileVersion", "0, 8, 0, 2" + VALUE "FileVersion", "0, 9, 0, 2" VALUE "InternalName", "easypmp_win32gui" VALUE "LegalCopyright", "Copyright 2005-2006 Nyaochi" VALUE "OriginalFilename", "easypmp_win32gui.exe" VALUE "ProductName", "EasyPMP [Win32 GUI]" - VALUE "ProductVersion", "0, 8, 0, 2" + VALUE "ProductVersion", "0, 9, 0, 2" END END BLOCK "VarFileInfo" Modified: trunk/frontend/easypmp/win32gui/preference.h =================================================================== --- trunk/frontend/easypmp/win32gui/preference.h 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/frontend/easypmp/win32gui/preference.h 2006-03-18 03:34:03 UTC (rev 4) @@ -188,13 +188,22 @@ { USES_CONVERSION; - strPlayerLocation = W2CT(pmp->env.path_to_root); - strPlayerIdentifier = A2CT(pmp->env.id); - strPlayerDescription = A2CT(pmp->env.name); - strPlayerDescription += _T(""); - if (*pmp->env.version) { - strPlayerDescription += _T(" "); - strPlayerDescription += A2CT(pmp->env.version); + if (pmp) { + strPlayerLocation = W2CT(pmp->env.path_to_root); + strPlayerIdentifier = A2CT(pmp->env.id); + strPlayerDescription = A2CT(pmp->env.name); + strPlayerDescription += _T(""); + if (*pmp->env.version) { + strPlayerDescription += _T(" "); + strPlayerDescription += A2CT(pmp->env.version); + } + if (*pmp->env.mode) { + strPlayerDescription += _T(" "); + strPlayerDescription += A2CT(pmp->env.mode); + } + } else { + strPlayerIdentifier = _T(""); + strPlayerDescription = _T(""); } } @@ -214,8 +223,10 @@ setPlayerInformation(pmp); pmp->release(pmp); return TRUE; + } else { + setPlayerInformation(NULL); + return FALSE; } - return FALSE; } int findPlayerLocation(pmphelp_t* pmphelp) Modified: trunk/frontend/easypmp/win32gui/progress_with_caption.h =================================================================== --- trunk/frontend/easypmp/win32gui/progress_with_caption.h 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/frontend/easypmp/win32gui/progress_with_caption.h 2006-03-18 03:34:03 UTC (rev 4) @@ -59,5 +59,6 @@ void SetText(LPCTSTR szText) { m_strText = szText; + InvalidateRect(NULL); } }; Modified: trunk/include/pmp.h =================================================================== --- trunk/include/pmp.h 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/include/pmp.h 2006-03-18 03:34:03 UTC (rev 4) @@ -98,6 +98,7 @@ uint32_t rating; uint32_t play_count; uint32_t recent_play; + uint32_t ts_import; }; typedef struct tag_pmp_record_t pmp_record_t; Modified: trunk/lib/pmp_portalplayer1/hdr_template.h =================================================================== --- trunk/lib/pmp_portalplayer1/hdr_template.h 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/lib/pmp_portalplayer1/hdr_template.h 2006-03-18 03:34:03 UTC (rev 4) @@ -59,7 +59,7 @@ int apply_template(hdr_t* hdr, const hdr_template_t* tmpl); int compare_version(const char *x, const char *y); -int hdr_init_h10_5gb_ums_0205_0251(hdr_t* hdr); +int hdr_init_h10_5gb_ums_0205_0252(hdr_t* hdr); int hdr_init_h10_5gb_mtp_0203_0210(hdr_t* hdr); int hdr_init_h10_5gb_mtp_0251(hdr_t* hdr); int hdr_init_h10_20gb_mtp_0100_0102(hdr_t* hdr); Modified: trunk/lib/pmp_portalplayer1/model_iriver_h10.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_iriver_h10.c 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/lib/pmp_portalplayer1/model_iriver_h10.c 2006-03-18 03:34:03 UTC (rev 4) @@ -272,17 +272,17 @@ {8, 12, 268, 524, 528, 608, 688, 768, 808, 812, 816, 820, 824, 828, 832, 836, 840, 844, 848, 852, 932, 936}; -/********** H10 5GB/6GB UMS firmware 2.05-2.51 **********/ -static hdr_template_t hdrtmpl_h10_5gb_ums_0205_0251 = { +/********** H10 5GB/6GB UMS firmware 2.05-2.52 **********/ +static hdr_template_t hdrtmpl_h10_5gb_ums_0205_0252 = { 0, 0, "System\\DATA\\H10DB.dat", 1, "System\\DATA\\H10DB.hdr", 0x00000428, 0, 0, 22, hdrtmpl_fd_h10_ums, hdrtmpl_max_dat_field_size_h10_ums, 0, 0, {206148, 22, 4000, 1032, 0, iriver_h10_dat_repr, iriver_h10_dat_set, iriver_h10_dat_get}, }; -int hdr_init_h10_5gb_ums_0205_0251(hdr_t* hdr) +int hdr_init_h10_5gb_ums_0205_0252(hdr_t* hdr) { - return apply_template(hdr, &hdrtmpl_h10_5gb_ums_0205_0251); + return apply_template(hdr, &hdrtmpl_h10_5gb_ums_0205_0252); } Modified: trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-02-26 10:21:16 UTC (rev 3) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-03-18 03:34:03 UTC (rev 4) @@ -61,12 +61,12 @@ static const pp1model_descriptor_t g_model_descriptions[] = { { - "iriver_h10_5/6gb_ums_2.04-2.51", "H10 5GB/6GB UMS", + "iriver_h10_5/6gb_ums_2.04-2.52", "H10 5GB/6GB UMS", 5, "UM", - "2.04", "2.51", + "2.04", "2.52", "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", ".plp", - hdr_init_h10_5gb_ums_0205_0251, iriver_h10_parse_model + hdr_init_h10_5gb_ums_0205_0252, iriver_h10_parse_model }, { "iriver_h10pure_5/6gb_ums_2.04-2.51", "H10Pure 5GB/6GB UMS", @@ -74,7 +74,7 @@ "2.04", "2.51", "System\\H10_5GP.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", ".plp", - hdr_init_h10_5gb_ums_0205_0251, iriver_h10_parse_model + hdr_init_h10_5gb_ums_0205_0252, iriver_h10_parse_model }, { "iriver_h10_5/6gb_mtp_2.03-2.10", "H10 5GB/6GB MTP", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-03-31 05:41:59
|
Revision: 5 Author: nyaochi Date: 2006-03-30 21:41:31 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=5&view=rev Log Message: ----------- Incremental commit: - clean-up an unused field in pmp.h - export added timestamp for JSPL Modified Paths: -------------- trunk/frontend/easypmp/common/database.c trunk/include/pmp.h trunk/lib/playlist/jspl.c trunk/lib/pmp_iriverplus2/ip2db.c trunk/lib/pmp_irivnavi/pmp_irivnavi.c trunk/lib/pmp_portalplayer1/model_iriver_h10.c trunk/lib/pmp_portalplayer1/model_medion_mdjuke220.c trunk/lib/pmp_portalplayer1/model_medion_mdjuke440.c trunk/lib/pmp_portalplayer1/model_sirius_s50.c Modified: trunk/frontend/easypmp/common/database.c =================================================================== --- trunk/frontend/easypmp/common/database.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/frontend/easypmp/common/database.c 2006-03-31 05:41:31 UTC (rev 5) @@ -228,7 +228,7 @@ if (find_mediafile(old_records, num_old_records, filename, &begin, &end)) { if (begin + 1 == end) { // If the time stamps are identical, let us skip this file. - if (old_records[begin].timestamp == timestamp) { + if (old_records[begin].ts_update == timestamp) { pmp_record_copy(record, &old_records[begin]); is_skipping = 1; } @@ -242,7 +242,7 @@ ++num_obtained; } else { } - record->timestamp = timestamp; + record->ts_update = timestamp; record->ts_import = ts_import; } } Modified: trunk/include/pmp.h =================================================================== --- trunk/include/pmp.h 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/include/pmp.h 2006-03-31 05:41:31 UTC (rev 5) @@ -79,26 +79,28 @@ const ucs2char_t* playlist_ext; } pmp_environment_t; +/** + * Structure of media record. + */ struct tag_pmp_record_t { - uint32_t unique_id; - ucs2char_t *filename; - ucs2char_t *title; - ucs2char_t *artist; - ucs2char_t *composer; - ucs2char_t *album; - ucs2char_t *genre; - ucs2char_t *date; - uint32_t codec; - uint32_t track_number; - uint32_t sample_rate; - uint32_t bitrate; - uint32_t duration; - uint32_t filesize; - uint32_t timestamp; - uint32_t rating; - uint32_t play_count; - uint32_t recent_play; - uint32_t ts_import; + ucs2char_t *filename; /**< Filename. */ + ucs2char_t *title; /**< Track title. */ + ucs2char_t *artist; /**< Artist name. */ + ucs2char_t *composer; /**< Composer name. */ + ucs2char_t *album; /**< Album name. */ + ucs2char_t *genre; /**< Genre name. */ + ucs2char_t *date; /**< Date. */ + uint32_t codec; /**< Codec FourCC. */ + uint32_t track_number; /**< Track number. */ + uint32_t sample_rate; /**< Sample rate in kHz. */ + uint32_t bitrate; /**< Bitrate in bps. */ + uint32_t duration; /**< Duration in seconds. */ + uint32_t filesize; /**< File size in bytes. */ + uint32_t ts_update; /**< Last update. */ + uint32_t rating; /**< Rating of the track. */ + uint32_t play_count; /**< The number of playback of the track. */ + uint32_t ts_playback; /**< Date/time of recent playback of the track. */ + uint32_t ts_import; /**< Date/time when the track was imported. */ }; typedef struct tag_pmp_record_t pmp_record_t; Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/playlist/jspl.c 2006-03-31 05:41:31 UTC (rev 5) @@ -272,10 +272,11 @@ set_property_int(jspl, obj, "sample_rate", (int)record->sample_rate); set_property_int(jspl, obj, "bitrate", (int)record->bitrate); set_property_int(jspl, obj, "duration", (int)record->duration); - set_property_int(jspl, obj, "timestamp", (int)record->timestamp); + set_property_int(jspl, obj, "update_timestamp", (int)record->ts_update); set_property_int(jspl, obj, "rating", (int)record->rating); set_property_int(jspl, obj, "play_count", (int)record->play_count); - set_property_int(jspl, obj, "recent_play", (int)record->recent_play); + set_property_int(jspl, obj, "playback_timestamp", (int)record->ts_playback); + set_property_int(jspl, obj, "import_timestamp", (int)record->ts_import); /* Register the object pointer to the record array. */ jspl->records[i] = obj; Modified: trunk/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/lib/pmp_iriverplus2/ip2db.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_iriverplus2/ip2db.c 2006-03-31 05:41:31 UTC (rev 5) @@ -203,7 +203,7 @@ dst->genre = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); dst->rating = src->rating; dst->play_count = src->play_count; - dst->recent_play = src->recent_play; + dst->recent_play = src->ts_playback; dst->track_number = src->track_number; if (src->date) { dst->year = ucs2toi(src->date); @@ -212,7 +212,7 @@ dst->duration = src->duration; dst->sample_rate = src->sample_rate; dst->bitrate = src->bitrate; - dst->timestamp = src->timestamp; + dst->timestamp = src->ts_update; ++j; } @@ -265,8 +265,6 @@ ip2db_get_record(db, i, &src); - dst->unique_id = j; - length = ucs2len(path_to_root); length += ucs2len(src.pathname); length += ucs2len(src.filename); @@ -295,10 +293,10 @@ dst->bitrate = src.bitrate; dst->duration = src.duration; dst->filesize = src.filesize; - dst->timestamp = src.timestamp; + dst->ts_update = src.timestamp; dst->rating = src.rating; dst->play_count = src.play_count; - dst->recent_play = src.recent_play; + dst->ts_playback = src.recent_play; ++j; } Modified: trunk/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/lib/pmp_irivnavi/pmp_irivnavi.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_irivnavi/pmp_irivnavi.c 2006-03-31 05:41:31 UTC (rev 5) @@ -473,7 +473,7 @@ dst->artist = ucs2dupmbs(src->artist ? src->artist : ucs2cs_unknown); dst->album = ucs2dupmbs(src->album ? src->album : ucs2cs_unknown); dst->genre = ucs2dupmbs(src->genre ? src->genre : ucs2cs_unknown); - dst->timestamp = src->timestamp; + dst->timestamp = src->ts_update; ++j; } @@ -512,8 +512,6 @@ pmp_record_init(dst); - dst->unique_id = j; - tmp = mbsdupucs2(src->filename); length = ucs2len(path_to_root); length += ucs2len(tmp); @@ -537,7 +535,7 @@ dst->codec = PMPCODEC_WAV; } - dst->timestamp = src->timestamp; + dst->ts_update = src->timestamp; ucs2free(tmp); ++j; Modified: trunk/lib/pmp_portalplayer1/model_iriver_h10.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_iriver_h10.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_portalplayer1/model_iriver_h10.c 2006-03-31 05:41:31 UTC (rev 5) @@ -109,7 +109,7 @@ dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); dst->fields[PP1DB_DATFIELD_RATING].value.dword = src->rating; dst->fields[PP1DB_DATFIELD_PLAYCOUNT].value.dword = src->play_count; - dst->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword = src->recent_play; + dst->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword = src->ts_playback; dst->fields[PP1DB_DATFIELD_UNKNOWN3].value.dword = 0; dst->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword = src->track_number; if (src->date) { @@ -121,7 +121,7 @@ dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate; dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = 0; dst->fields[PP1DB_DATFIELD_UNKNOWN5].value.str = ucs2dup(ucs2cs_empty); - dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword = src->timestamp; + dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword = src->ts_update; dst->fields[PP1DB_DATFIELD_UNKNOWN7].value.str = ucs2dup(ucs2cs_empty); return 0; } @@ -134,8 +134,6 @@ ucs2char_t tmp[128]; size_t length = 0; - dst->unique_id = 0; - length = ucs2len(path_to_root); length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); @@ -169,10 +167,10 @@ dst->bitrate = src->fields[PP1DB_DATFIELD_BITRATE].value.dword; dst->duration = src->fields[PP1DB_DATFIELD_DURATION].value.dword; dst->filesize = src->fields[PP1DB_DATFIELD_FILESIZE].value.dword; - dst->timestamp = src->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword; + dst->ts_update = src->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword; dst->rating = src->fields[PP1DB_DATFIELD_RATING].value.dword; dst->play_count = src->fields[PP1DB_DATFIELD_PLAYCOUNT].value.dword; - dst->recent_play = src->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword; + dst->ts_playback = src->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword; return 0; } Modified: trunk/lib/pmp_portalplayer1/model_medion_mdjuke220.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2006-03-31 05:41:31 UTC (rev 5) @@ -117,8 +117,6 @@ ucs2char_t tmp[128]; size_t length = 0; - dst->unique_id = 0; - length = ucs2len(path_to_root); length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); Modified: trunk/lib/pmp_portalplayer1/model_medion_mdjuke440.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_medion_mdjuke440.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_portalplayer1/model_medion_mdjuke440.c 2006-03-31 05:41:31 UTC (rev 5) @@ -98,8 +98,6 @@ static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; size_t length = 0; - dst->unique_id = 0; - length = ucs2len(path_to_root); length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); Modified: trunk/lib/pmp_portalplayer1/model_sirius_s50.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_sirius_s50.c 2006-03-18 03:34:03 UTC (rev 4) +++ trunk/lib/pmp_portalplayer1/model_sirius_s50.c 2006-03-31 05:41:31 UTC (rev 5) @@ -143,8 +143,6 @@ static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; size_t length = 0; - dst->unique_id = 0; - length = ucs2len(path_to_root); length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-04-04 06:32:34
|
Revision: 6 Author: nyaochi Date: 2006-04-03 23:32:21 -0700 (Mon, 03 Apr 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=6&view=rev Log Message: ----------- Revised the JSPL specification. - JavaScript playlist must have one main() function - The main() function must return either an array of tracks or a JavaScript object with multiple playlists whose names are represented in attributes of the object and values store arrays of tracks. - Previous specification (i.e., match and comapre functions) was discarded. Modified Paths: -------------- trunk/include/playlist.h trunk/lib/playlist/jspl.c Modified: trunk/include/playlist.h =================================================================== --- trunk/include/playlist.h 2006-03-31 05:41:31 UTC (rev 5) +++ trunk/include/playlist.h 2006-04-04 06:32:21 UTC (rev 6) @@ -42,6 +42,22 @@ PLCALLBACK_JSPL_ERROR, }; +enum { + PLAYLIST_SUCCESS = 0, + PLAYLIST_E_FAIL = 0x80000000, + PLAYLIST_E_OUTOFMEMORY, + PLAYLIST_E_JSINITENGINE, + PLAYLIST_E_JSINITMEDIA, + PLAYLIST_E_JSEVALSCRIPT, + PLAYLIST_E_JSMAINNOTFOUND, + PLAYLIST_E_JSCALLMAIN, + PLAYLIST_E_JSINVALIDARRAY, + PLAYLIST_E_JSINVALIDCAST, + PLAYLIST_E_JSINVALIDOBJECT, + PLAYLIST_E_JSINVALIDTRACK, +}; + + typedef void (*playlist_callback_t)(void *instance, int level, ucs2char_t* message); struct tag_playlist_entry { Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-03-31 05:41:31 UTC (rev 5) +++ trunk/lib/playlist/jspl.c 2006-04-04 06:32:21 UTC (rev 6) @@ -50,25 +50,26 @@ int num_records; JSObject **records; + JSObject *tracks; void *instance; playlist_callback_t callback; }; typedef struct tag_jspl jspl_t; -static jschar* JS_ucstrdup(JSContext *cx, ucs2char_t* src, size_t* ptr_length) +static jschar* JS_ucstrdup(JSContext *cx, const ucs2char_t* src, size_t* ptr_length) { - int i; - size_t length = ucs2len(src); + size_t i, length = ucs2len(src); jschar* dst = JS_malloc(cx, length * sizeof(jschar)); - for (i = 0;i < length;++i) { - dst[i] = src[i]; + if (dst) { + for (i = 0;i < length;++i) { + dst[i] = src[i]; + } + if (ptr_length) { + *ptr_length = length; + } } - - if (ptr_length) { - *ptr_length = length; - } return dst; } @@ -239,6 +240,21 @@ { int i; + /* Allocate a JavaScript array object. + * According to the notes for JS_NewArrayObject() function in the + * reference document, we should create an empty array, store the + * returned object in a GC root, populate its element, and then + * drop the root object to avoid unrooted jsvals in vector from + * being subject to garbage collection until the new object has + * been populated + */ + jspl->tracks = JS_NewArrayObject(jspl->context, 0, NULL); + + /* */ + if (!JS_AddRoot(jspl->context, &jspl->tracks)) { + return 1; + } + /* Allocate a records array. */ free(jspl->records); jspl->records = (JSObject**)calloc(num_records, sizeof(JSObject*)); @@ -246,6 +262,7 @@ for (i = 0;i < num_records;++i) { const pmp_record_t* record = &records[i]; JSObject* obj = NULL; + jsval jsval_obj; /* Create a JavaScript object. */ obj = JS_NewObject( @@ -259,7 +276,7 @@ } /* Attach properties to the object. */ - set_property_int(jspl, obj, "index", i); + set_property_int(jspl, obj, "id", i); set_property_string(jspl, obj, "filename", record->filename); set_property_string(jspl, obj, "title", record->title); set_property_string(jspl, obj, "artist", record->artist); @@ -280,9 +297,18 @@ /* Register the object pointer to the record array. */ jspl->records[i] = obj; + + jsval_obj = OBJECT_TO_JSVAL(obj); + if (!JS_SetElement(jspl->context, jspl->tracks, i, &jsval_obj)) { + return 1; + } } jspl->num_records = num_records; + if (!JS_RemoveRoot(jspl->context, &jspl->tracks)) { + return 1; + } + return 0; } @@ -364,37 +390,45 @@ #endif } -typedef struct { - jspl_t *jspl; - int index; -} sortitem_t; - -static int comp_order(const void* _x, const void* _y) +static int generate_playlist( + jspl_t* jspl, + playlists_t* pls, + JSObject* jsobj_array, + const ucs2char_t* name + ) { - jsval argv[2], retval; - const sortitem_t* x = (const sortitem_t*)_x; - const sortitem_t* y = (const sortitem_t*)_y; - jspl_t* jspl = x->jspl; - int ret = COMP(x->index, y->index); - - /* Call match() function. */ - argv[0] = OBJECT_TO_JSVAL(jspl->records[x->index]); - argv[1] = OBJECT_TO_JSVAL(jspl->records[y->index]); - if (JS_CallFunctionName(jspl->context, jspl->global, "compare", 2, argv, &retval)) { - if (JSVAL_IS_INT(retval)) { - ret = JSVAL_TO_INT(retval); - } else if (JSVAL_IS_DOUBLE(retval)) { - jsdouble* d = JSVAL_TO_DOUBLE(retval); - if (*d == 0) { - ret = 0; - } else { - ret = *d < 0 ? -1 : 1; + int ipl = playlist_add_playlist(pls, name); + if (ipl >= 0) { + playlist_t* pl = &pls->playlists[ipl]; + jsuint i, length; + + if (JS_HasArrayLength(jspl->context, jsobj_array, &length)) { + for (i = 0;i < length;++i) { + jsval jsval_element; + if (JS_GetElement(jspl->context, jsobj_array, (jsint)i, &jsval_element)) { + JSObject* jsobj_element = JSVAL_TO_OBJECT(jsval_element); + jsval jsval_filename; + if (JS_GetProperty(jspl->context, jsobj_element, "filename", &jsval_filename)) { + ucs2char_t* filename = JSString_to_ucs2(JSVAL_TO_STRING(jsval_filename)); + playlist_append(pl, filename, i); + } else { + return PLAYLIST_E_JSINVALIDTRACK; + } + } else { + return PLAYLIST_E_JSINVALIDARRAY; + } } + } else { + return PLAYLIST_E_JSINVALIDARRAY; } + } else { + return PLAYLIST_E_OUTOFMEMORY; } - return ret; + + return 0; } + int playlist_jspl_read( playlists_t* pls, const ucs2char_t *filename, @@ -404,16 +438,17 @@ void *instance ) { - int i, j, ret = 0; + int ret = 0; jspl_t* jspl = NULL; ucs2char_t name[MAX_PATH]; JSString* jstr_name = NULL; size_t length = 0; jschar* js_name = NULL; + jsval argv[2], retval; /* Intialize JavaScript engine. */ if (jspl_init(&jspl) != 0) { - ret = 1; + ret = PLAYLIST_E_JSINITENGINE; goto error_exit; } @@ -422,13 +457,13 @@ /* Create JavaScript objects represent media information of the records. */ if (jspl_set(jspl, records, num_records) != 0) { - ret = 1; + ret = PLAYLIST_E_JSINITMEDIA; goto error_exit; } /* Load the script. */ if (jspl_load_script(jspl, filename) != 0) { - ret = 1; + ret = PLAYLIST_E_JSEVALSCRIPT; goto error_exit; } @@ -439,68 +474,79 @@ /* Convert the type of the playlist name to JavaScript string. */ js_name = JS_ucstrdup(jspl->context, name, &length); if (!js_name) { - ret = 1; + ret = PLAYLIST_E_OUTOFMEMORY; goto error_exit; } jstr_name = JS_NewUCString(jspl->context, js_name, length); if (!jstr_name) { - ret = 1; + ret = PLAYLIST_E_OUTOFMEMORY; goto error_exit; } - if (!function_exists(jspl, "match")) { - ret = 1; + /* Check if main() function exists. */ + if (!function_exists(jspl, "main")) { + ret = PLAYLIST_E_JSMAINNOTFOUND; goto error_exit; } - /* Generate playlist(s) by applying match() function. */ - for (i = 0;i < jspl->num_records;++i) { - jsval argv[2], retval; + /* Call main() function. */ + argv[0] = OBJECT_TO_JSVAL(jspl->tracks); + argv[1] = STRING_TO_JSVAL(jstr_name); + if (!JS_CallFunctionName(jspl->context, jspl->global, "main", 2, argv, &retval)) { + ret = PLAYLIST_E_JSCALLMAIN; + goto error_exit; + } - /* Call match() function. */ - argv[0] = OBJECT_TO_JSVAL(jspl->records[i]); - argv[1] = STRING_TO_JSVAL(jstr_name); - if (!JS_CallFunctionName(jspl->context, jspl->global, "match", 2, argv, &retval)) { - continue; + /* Check if the returned value is a JavaScript object. */ + if (JSVAL_IS_OBJECT(retval) && !JSVAL_IS_PRIMITIVE(retval)) { + /* Convert the return value to JSObject. */ + JSObject* jsobj = JSVAL_TO_OBJECT(retval); + if (!jsobj) { + ret = PLAYLIST_E_JSINVALIDCAST; + goto error_exit; } - if (JSVAL_IS_BOOLEAN(retval) && JSVAL_TO_BOOLEAN(retval)) { - /* Add this media file to the default playlist. */ - int index = playlist_add_playlist(pls, name); - if (index >= 0) { - playlist_t* pl = &pls->playlists[index]; - playlist_append(pl, records[i].filename, i); + if (JS_IsArrayObject(jspl->context, jsobj)) { + /* Single playlist when the returned value is JavaScript array. */ + ret = generate_playlist(jspl, pls, jsobj, name); + if (ret != 0) { + goto error_exit; } - } else if (JSVAL_IS_STRING(retval)) { - /* Add this media file to a playlist named as the retval. */ - ucs2char_t* thisname = JSString_to_ucs2(JSVAL_TO_STRING(retval)); - int index = playlist_add_playlist(pls, thisname); - if (index >= 0) { - playlist_t* pl = &pls->playlists[index]; - playlist_append(pl, records[i].filename, i); + } else { + /* Multiple playlists when the returned value is JavaScript object with attributes. */ + jsint n; + JSIdArray* keys = JS_Enumerate(jspl->context, jsobj); + if (!keys) { + ret = PLAYLIST_E_JSINVALIDOBJECT; + goto error_exit; } - ucs2free(thisname); - } - } - /* Sort the playlist(s). */ - if (function_exists(jspl, "compare")) { - for (i = 0;i < pls->num_playlists;++i) { - playlist_t* pl = &pls->playlists[i]; - sortitem_t* sis = calloc(pl->num_entries, sizeof(sortitem_t)); - - for (j = 0;j < pl->num_entries;++j) { - sis[j].jspl = jspl; - sis[j].index = pl->entries[j].order; + /* Loop over attributes to enumerate all playlist names. */ + for (n = 0;n < keys->length;++n) { + /* Obtain the playlist name. */ + jsval jsval_name; + if (JS_IdToValue(jspl->context, keys->vector[n], &jsval_name)) { + jsval jsval_obj; + JSString* jsstr_name = JSVAL_TO_STRING(jsval_name); + + /* Obtain the attribute value for the playlist name. */ + if (JS_LookupUCProperty(jspl->context, jsobj, JS_GetStringChars(jsstr_name), JS_GetStringLength(jsstr_name), &jsval_obj)) { + if (JSVAL_IS_OBJECT(jsval_obj) && !JSVAL_IS_PRIMITIVE(jsval_obj)) { + JSObject* jsobj = JSVAL_TO_OBJECT(jsval_obj); + if (jsobj && JS_IsArrayObject(jspl->context, jsobj)) { + ucs2char_t* thisname = JSString_to_ucs2(jsstr_name); + ret = generate_playlist(jspl, pls, jsobj, thisname); + if (ret != 0) { + goto error_exit; + } + } + } + } + } } - - qsort(sis, pl->num_entries, sizeof(sortitem_t), comp_order); - - for (j = 0;j < pl->num_entries;++j) { - int index = sis[j].index; - ucs2cpy(pl->entries[j].filename, records[index].filename); - } } + } else { + /* Does nothing when main() function returns a non-object. */ } error_exit: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-07-10 18:32:49
|
Revision: 128 Author: nyaochi Date: 2006-07-10 11:32:34 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=128&view=rev Log Message: ----------- Improved error messages when JavaScript errors occur. Modified Paths: -------------- trunk/frontend/easypmp/common/easypmp.h trunk/frontend/easypmp/common/playlist.c trunk/frontend/easypmp/cui/main.c trunk/include/playlist.h trunk/lib/playlist/jspl.c Modified: trunk/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/frontend/easypmp/common/easypmp.h 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/common/easypmp.h 2006-07-10 18:32:34 UTC (rev 128) @@ -31,26 +31,28 @@ #endif/*__cplusplus*/ enum { - EASYPMPDBP_START = 0x00010000, - EASYPMPDBP_READ = 0x00020000, - EASYPMPDBP_GMI = 0x00030000, - EASYPMPDBP_UPDATE = 0x00040000, - EASYPMPDBP_WRITE = 0x00050000, - EASYPMPDBP_END = 0x00060000, + EASYPMPDBP_START = 0x00010000, + EASYPMPDBP_READ = 0x00020000, + EASYPMPDBP_GMI = 0x00030000, + EASYPMPDBP_UPDATE = 0x00040000, + EASYPMPDBP_WRITE = 0x00050000, + EASYPMPDBP_END = 0x00060000, - EASYPMPPLP_START = 0x01000000, - EASYPMPPLP_CONVERT = 0x02000000, - EASYPMPPLP_END = 0x03000000, + EASYPMPPLP_START = 0x01000000, + EASYPMPPLP_CONVERT = 0x02000000, + EASYPMPPLP_END = 0x03000000, - EASYPMPSP_START = 0x00000001, - EASYPMPSP_PROGRESS = 0x00000002, - EASYPMPSP_SKIPPED = 0x00000003, - EASYPMPSP_WARN_PLAYLIST = 0x00000004, - EASYPMPSP_SKIP_PLAYLIST = 0x00000005, - EASYPMPSP_MISSING_MEDIA = 0x00000006, - EASYPMPSP_JSPL_ERROR = 0x00000007, - EASYPMPSP_JSPL_OUTPUT = 0x00000008, - EASYPMPSP_END = 0x00000009, + EASYPMPSP_START = 0x00000001, + EASYPMPSP_PROGRESS = 0x00000002, + EASYPMPSP_SKIPPED = 0x00000003, + EASYPMPSP_WARN_PLAYLIST = 0x00000004, + EASYPMPSP_SKIP_PLAYLIST = 0x00000005, + EASYPMPSP_MISSING_MEDIA = 0x00000006, + EASYPMPSP_JSPL_ERROR = 0x00000007, + EASYPMPSP_JSPL_ERROR_POS = 0x00000008, + EASYPMPSP_JSPL_ERROR_LINE = 0x00000009, + EASYPMPSP_JSPL_OUTPUT = 0x0000000A, + EASYPMPSP_END = 0x0000000B, }; enum { Modified: trunk/frontend/easypmp/common/playlist.c =================================================================== --- trunk/frontend/easypmp/common/playlist.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/common/playlist.c 2006-07-10 18:32:34 UTC (rev 128) @@ -47,9 +47,11 @@ callback_data_t* cd = (callback_data_t*)instance; switch (level) { - case PLCALLBACK_JSPL_MESSAGE: phase |= EASYPMPSP_JSPL_OUTPUT; break; - case PLCALLBACK_JSPL_ERROR: phase |= EASYPMPSP_JSPL_ERROR; break; - default: phase |= EASYPMPSP_PROGRESS; break; + case PLCALLBACK_JSPL_MESSAGE: phase |= EASYPMPSP_JSPL_OUTPUT; break; + case PLCALLBACK_JSPL_ERROR: phase |= EASYPMPSP_JSPL_ERROR; break; + case PLCALLBACK_JSPL_ERROR_POS: phase |= EASYPMPSP_JSPL_ERROR_POS; break; + case PLCALLBACK_JSPL_ERROR_LINE: phase |= EASYPMPSP_JSPL_ERROR_LINE; break; + default: phase |= EASYPMPSP_PROGRESS; break; } cd->progress(cd->instance, phase, 0, 0, message); Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/cui/main.c 2006-07-10 18:32:34 UTC (rev 128) @@ -151,6 +151,12 @@ case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR: fprints(fpe, " JSPL(ERROR): %s\n", param_str); break; + case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_POS: + fprints(fpe, " at: %s\n", param_str); + break; + case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: + fprints(fpe, " line: %s\n", param_str); + break; case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_OUTPUT: fprints(fpe, " JSPL: %s\n", param_str); break; Modified: trunk/include/playlist.h =================================================================== --- trunk/include/playlist.h 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/include/playlist.h 2006-07-10 18:32:34 UTC (rev 128) @@ -45,6 +45,8 @@ PLCALLBACK_NONE, PLCALLBACK_JSPL_MESSAGE, PLCALLBACK_JSPL_ERROR, + PLCALLBACK_JSPL_ERROR_POS, + PLCALLBACK_JSPL_ERROR_LINE, }; enum { Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/lib/playlist/jspl.c 2006-07-10 18:32:34 UTC (rev 128) @@ -93,9 +93,25 @@ static void error_handler(JSContext *cx, const char *message, JSErrorReport *report) { jspl_t* jspl = (jspl_t*)JS_GetContextPrivate(cx); - ucs2char_t* ucs2 = mbsdupucs2(message); + ucs2char_t* ucs2 = NULL; + char *pos = alloca(strlen(report->filename) + 64); /* extra 64 bytes for line numbers. */ + + ucs2 = mbsdupucs2(message); jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR, ucs2); ucs2free(ucs2); + + sprintf(pos, "lines %d in %s", report->lineno, report->filename); + ucs2 = mbsdupucs2(pos); + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_POS, ucs2); + ucs2free(ucs2); + + if (report->uclinebuf) { + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_LINE, (ucs2char_t*)report->uclinebuf); + } else { + ucs2 = mbsdupucs2(report->linebuf); + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_LINE, ucs2); + ucs2free(ucs2); + } } static int function_exists(jspl_t* jspl, const char *funcname) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-07-29 16:05:34
|
Revision: 145 Author: nyaochi Date: 2006-07-29 09:05:24 -0700 (Sat, 29 Jul 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=145&view=rev Log Message: ----------- Reduce a warning. Modified Paths: -------------- trunk/include/pmp.h trunk/lib/pmp_iriverplus2/ip2db.h trunk/lib/pmp_iriverplus2/playlist.c trunk/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/lib/pmp_irivnavi/irivnavi.h trunk/lib/pmp_irivnavi/playlist.c trunk/lib/pmp_irivnavi/pmp_irivnavi.c trunk/lib/pmp_portalplayer1/playlist.c trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/lib/pmp_portalplayer1/pp1db.h Modified: trunk/include/pmp.h =================================================================== --- trunk/include/pmp.h 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/include/pmp.h 2006-07-29 16:05:24 UTC (rev 145) @@ -162,7 +162,7 @@ uint32_t (*add_ref)(pmppl_t* pmppl); uint32_t (*release)(pmppl_t* pmppl); - result_t (*write)(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t** files, uint32_t num_files); + result_t (*write)(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t * const files[], uint32_t num_files); }; typedef result_t (*pmp_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); Modified: trunk/lib/pmp_iriverplus2/ip2db.h =================================================================== --- trunk/lib/pmp_iriverplus2/ip2db.h 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_iriverplus2/ip2db.h 2006-07-29 16:05:24 UTC (rev 145) @@ -278,7 +278,7 @@ int ip2db_playlist_write( ip2db_t* db, const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ); Modified: trunk/lib/pmp_iriverplus2/playlist.c =================================================================== --- trunk/lib/pmp_iriverplus2/playlist.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_iriverplus2/playlist.c 2006-07-29 16:05:24 UTC (rev 145) @@ -93,7 +93,7 @@ int ip2db_playlist_write( ip2db_t* db, const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ) Modified: trunk/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/lib/pmp_iriverplus2/pmp_iriverplus2.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_iriverplus2/pmp_iriverplus2.c 2006-07-29 16:05:24 UTC (rev 145) @@ -130,7 +130,7 @@ static uint32_t pmppl_add_ref(pmppl_t* pmppl); static uint32_t pmppl_release(pmppl_t* pmppl); -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files); +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files); static void set_environment( @@ -539,7 +539,7 @@ return count; } -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files) +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) { pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; Modified: trunk/lib/pmp_irivnavi/irivnavi.h =================================================================== --- trunk/lib/pmp_irivnavi/irivnavi.h 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_irivnavi/irivnavi.h 2006-07-29 16:05:24 UTC (rev 145) @@ -70,7 +70,7 @@ int playlist_write( const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ); Modified: trunk/lib/pmp_irivnavi/playlist.c =================================================================== --- trunk/lib/pmp_irivnavi/playlist.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_irivnavi/playlist.c 2006-07-29 16:05:24 UTC (rev 145) @@ -44,7 +44,7 @@ int playlist_write( const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ) Modified: trunk/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/lib/pmp_irivnavi/pmp_irivnavi.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_irivnavi/pmp_irivnavi.c 2006-07-29 16:05:24 UTC (rev 145) @@ -102,7 +102,7 @@ static uint32_t pmppl_add_ref(pmppl_t* pmppl); static uint32_t pmppl_release(pmppl_t* pmppl); -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files); +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files); int exists_sysfile(const ucs2char_t* path_to_device, const ucs2char_t* sysfilename) { @@ -582,7 +582,7 @@ return count; } -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files) +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) { pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; if (playlist_write(filename, files, num_files, pmpi->env.path_to_root) != 0) { Modified: trunk/lib/pmp_portalplayer1/playlist.c =================================================================== --- trunk/lib/pmp_portalplayer1/playlist.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_portalplayer1/playlist.c 2006-07-29 16:05:24 UTC (rev 145) @@ -52,7 +52,7 @@ int playlist_write( const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ) Modified: trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-07-29 16:05:24 UTC (rev 145) @@ -225,7 +225,7 @@ static uint32_t pmppl_add_ref(pmppl_t* pmppl); static uint32_t pmppl_release(pmppl_t* pmppl); -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files); +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files); @@ -570,7 +570,7 @@ return count; } -static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, const ucs2char_t* files[], uint32_t num_files) +static result_t pmppl_write(pmppl_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) { pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; if (playlist_write(filename, files, num_files, pmpi->env.path_to_root) != 0) { Modified: trunk/lib/pmp_portalplayer1/pp1db.h =================================================================== --- trunk/lib/pmp_portalplayer1/pp1db.h 2006-07-29 15:41:31 UTC (rev 144) +++ trunk/lib/pmp_portalplayer1/pp1db.h 2006-07-29 16:05:24 UTC (rev 145) @@ -151,7 +151,7 @@ // playlist.c int playlist_write( const ucs2char_t *filename, - const ucs2char_t *mediafiles[], + ucs2char_t* const mediafiles[], int num_mediafiles, const ucs2char_t *path_to_root ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-04-05 13:58:16
|
Revision: 8 Author: nyaochi Date: 2006-04-05 06:57:51 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=8&view=rev Log Message: ----------- More JSPL related work. Modified Paths: -------------- trunk/frontend/easypmp/common/easypmp.h trunk/frontend/easypmp/common/playlist.c trunk/frontend/easypmp/cui/main.c trunk/frontend/easypmp/cui/option.c trunk/include/playlist.h trunk/lib/playlist/jspl.c trunk/lib/playlist/playlist.c Modified: trunk/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/frontend/easypmp/common/easypmp.h 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/frontend/easypmp/common/easypmp.h 2006-04-05 13:57:51 UTC (rev 8) @@ -84,6 +84,7 @@ uint32_t media_info_source; int repr_level; ucs2char_t path_to_root[MAX_PATH]; + ucs2char_t path_to_include[MAX_PATH]; char model[128]; char *system_encoding; char *music_encoding; Modified: trunk/frontend/easypmp/common/playlist.c =================================================================== --- trunk/frontend/easypmp/common/playlist.c 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/frontend/easypmp/common/playlist.c 2006-04-05 13:57:51 UTC (rev 8) @@ -131,7 +131,7 @@ // Read the source playlist playlist_init(&pls); - if (playlist_read(&pls, src, records, num_records, callback_from_playlist, &cd) != 0) { + if (playlist_read(&pls, src, opt->path_to_include, records, num_records, callback_from_playlist, &cd) != 0) { result = EASYPMPE_PLAYLIST_READ; goto error_exit; } Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/frontend/easypmp/cui/main.c 2006-04-05 13:57:51 UTC (rev 8) @@ -49,7 +49,7 @@ #endif #define APPLICATION_S "EasyPMP [CUI]" -#define VERSION_S "0.8 alpha" +#define VERSION_S "0.9 alpha" #define COPYRIGHT_S "Copyright (c) 2005-2006 Nyaochi" int database_dump(pmp_t* pmp, FILE *fpo, int level); Modified: trunk/frontend/easypmp/cui/option.c =================================================================== --- trunk/frontend/easypmp/cui/option.c 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/frontend/easypmp/cui/option.c 2006-04-05 13:57:51 UTC (rev 8) @@ -29,6 +29,10 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#ifdef _MSC_VER +#include <direct.h> /* getcwd() */ +#endif/*_MSC_VER*/ + #include <ucs2char.h> #include <filepath.h> #include <gmi.h> @@ -94,6 +98,19 @@ opt->media_info_source |= GMIF_TAG; + if (!opt->path_to_include[0]) { + char pwd[MAX_PATH+1]; + ucs2char_t ucs2pwd[MAX_PATH+1]; + ucs2char_t ucs2argv0[MAX_PATH+1]; + + getcwd(pwd, MAX_PATH); + mbstoucs2(ucs2pwd, MAX_PATH, pwd, strlen(pwd)+1); + mbstoucs2(ucs2argv0, MAX_PATH, argv[0], strlen(argv[0])+1); + filepath_relative_to_absolute(opt->path_to_include, ucs2pwd, ucs2argv0); + + filepath_remove_filespec(opt->path_to_include); + } + /* Parse the command-line arguments. */ for (;;) { int this_option_optind = optind ? optind : 1; Modified: trunk/include/playlist.h =================================================================== --- trunk/include/playlist.h 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/include/playlist.h 2006-04-05 13:57:51 UTC (rev 8) @@ -102,6 +102,7 @@ playlist_read( playlists_t* pls, const ucs2char_t* filename, + const ucs2char_t* path_to_include, pmp_record_t* records, int num_records, playlist_callback_t callback, Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/lib/playlist/jspl.c 2006-04-05 13:57:51 UTC (rev 8) @@ -40,13 +40,17 @@ #define XP_WIN #include <js/jsapi.h> -#define COMP(a, b) ((a)>(b))-((a)<(b)) +#define MAX_SOURCE_DEPTH 64 struct tag_jspl { JSRuntime *runtime; JSContext *context; JSObject *global; + const ucs2char_t *path_to_include; + const ucs2char_t path_to_source[MAX_PATH][MAX_SOURCE_DEPTH]; + int source_depth; + int num_records; JSObject **records; JSObject *tracks; @@ -56,6 +60,9 @@ }; typedef struct tag_jspl jspl_t; +static int jspl_load_script(jspl_t* jspl, const ucs2char_t* filename); + + static jschar* JS_ucstrdup(JSContext *cx, const ucs2char_t* src, size_t* ptr_length) { size_t i, length = ucs2len(src); @@ -105,6 +112,12 @@ return 0; } +static int object_is_array(JSContext* cx, JSObject* obj) +{ + jsuint length; + return JS_HasArrayLength(cx, obj, &length) ? 1 : 0; +} + static JSBool js_print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { @@ -136,8 +149,32 @@ return JS_TRUE; } +static JSBool +js_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + uintN i, n; + jspl_t* jspl = (jspl_t*)JS_GetContextPrivate(cx); + + for (i = 0, n = 0; i < argc; i++) { + ucs2char_t* ucs2 = NULL; + ucs2char_t filename[MAX_PATH+1]; + JSString *str = JS_ValueToString(cx, argv[i]); + if (!str) { + return JS_FALSE; + } + + ucs2 = JSString_to_ucs2(str); + + filepath_combinepath(filename, MAX_PATH, jspl->path_to_include, ucs2); + jspl_load_script(jspl, filename); + } + + return JS_TRUE; +} + static JSFunctionSpec g_global_functions[] = { - {"print", js_print, 0}, + {"print", js_print, 0}, + {"include", js_include, 0}, {0} }; @@ -311,6 +348,25 @@ return 0; } +static int jspl_init_script(jspl_t* jspl) +{ + static const char *script = + "Math.cmp = function(x, y)\n" + "{\n" + " return ((x)>(y))-((x)<(y));\n" + "};\n" + "\n"; + + static const char *_script = "function dummy() {}\n"; + + jsval retval; + int ret = JS_EvaluateScript(jspl->context, jspl->global, script, strlen(script), "easypmp.js", 1, &retval); + if (!ret) { + return -1; + } + return 0; +} + static int jspl_load_script(jspl_t* jspl, const ucs2char_t* filename) { #if 1 @@ -431,6 +487,7 @@ int playlist_jspl_read( playlists_t* pls, const ucs2char_t *filename, + const ucs2char_t *path_to_include, pmp_record_t* records, int num_records, playlist_callback_t callback, @@ -451,6 +508,8 @@ goto error_exit; } + /* Initialize other fields. */ + jspl->path_to_include = path_to_include; jspl->callback = callback; jspl->instance = instance; @@ -505,7 +564,7 @@ goto error_exit; } - if (JS_IsArrayObject(jspl->context, jsobj)) { + if (object_is_array(jspl->context, jsobj)) { /* Single playlist when the returned value is JavaScript array. */ ret = generate_playlist(jspl, pls, jsobj, name); if (ret != 0) { @@ -532,7 +591,7 @@ if (JS_LookupUCProperty(jspl->context, jsobj, JS_GetStringChars(jsstr_name), JS_GetStringLength(jsstr_name), &jsval_obj)) { if (JSVAL_IS_OBJECT(jsval_obj) && !JSVAL_IS_PRIMITIVE(jsval_obj)) { JSObject* jsobj = JSVAL_TO_OBJECT(jsval_obj); - if (jsobj && JS_IsArrayObject(jspl->context, jsobj)) { + if (jsobj && object_is_array(jspl->context, jsobj)) { ucs2char_t* thisname = JSString_to_ucs2(jsstr_name); ret = generate_playlist(jspl, pls, jsobj, thisname); if (ret != 0) { Modified: trunk/lib/playlist/playlist.c =================================================================== --- trunk/lib/playlist/playlist.c 2006-04-04 06:49:42 UTC (rev 7) +++ trunk/lib/playlist/playlist.c 2006-04-05 13:57:51 UTC (rev 8) @@ -44,6 +44,7 @@ int playlist_jspl_read( playlists_t* pls, const ucs2char_t *filename, + const ucs2char_t *path_to_include, pmp_record_t* records, int num_records, playlist_callback_t callback, @@ -67,6 +68,7 @@ int playlist_read( playlists_t* pls, const ucs2char_t* filename, + const ucs2char_t* path_to_include, pmp_record_t* records, int num_records, playlist_callback_t callback, @@ -80,7 +82,7 @@ } else if (filepath_hasext(filename, ucs2cs_pls)) { return playlist_pls_read(pls, filename); } else if (filepath_hasext(filename, ucs2cs_jspl)) { - return playlist_jspl_read(pls, filename, records, num_records, callback, instance); + return playlist_jspl_read(pls, filename, path_to_include, records, num_records, callback, instance); } else { return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-04-16 14:48:43
|
Revision: 9 Author: nyaochi Date: 2006-04-16 07:47:55 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=9&view=rev Log Message: ----------- Added an option to enable JSPL. Read the media database automatically when JSPL is enabled. Modified Paths: -------------- trunk/frontend/easypmp/common/database.c trunk/frontend/easypmp/common/easypmp.h trunk/frontend/easypmp/common/enumerate.c trunk/frontend/easypmp/common/playlist.c trunk/frontend/easypmp/cui/main.c trunk/frontend/easypmp/cui/option.c trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc trunk/frontend/easypmp/win32gui/maindlg.h trunk/frontend/easypmp/win32gui/preference.h trunk/frontend/easypmp/win32gui/processingdlg.h trunk/frontend/easypmp/win32gui/resource.h trunk/include/playlist.h trunk/lib/playlist/playlist.c Modified: trunk/frontend/easypmp/common/database.c =================================================================== --- trunk/frontend/easypmp/common/database.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/common/database.c 2006-04-16 14:47:55 UTC (rev 9) @@ -115,60 +115,8 @@ * Read the existing database for update processing mode. */ if (opt->verb & MODE_DATABASE_UPDATE) { - // Create a database engine. - res = pmp->create_instance_db(pmp, &pmpdb); - if (!pmpdb) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } - - // Start reading a database. - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - - // Read the existing database. - res = pmpdb->read(pmpdb); - if (res != 0) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } - - // Obtain the number of records in the database. - res = pmpdb->get(pmpdb, NULL, &num_old_records); - if (res != 0) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } - - // Allocate an array for the records. - old_records = malloc(sizeof(pmp_record_t) * num_old_records); - if (!old_records) { - result = EASYPMPE_INSUFFICIENT_MEMORY; - goto error_exit; - } - - // Obtain the records from the database. - res = pmpdb->get(pmpdb, old_records, &num_old_records); - if (res != 0) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } - - // Sort the records for binary search. - qsort(old_records, num_old_records, sizeof(pmp_record_t), comp_filename); - - // Release the database instance. - if (pmpdb) { - pmpdb->release(pmpdb); - pmpdb = NULL; - } - - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_END, num_old_records, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } + // + easypmp_database_read(pmp, opt, &old_records, &num_old_records, progress, instance); } else { if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_SKIPPED, 0, 0, NULL) != 0) { result = EASYPMPE_CANCEL; @@ -319,6 +267,98 @@ return result; } + + +int +easypmp_database_read( + pmp_t* pmp, + const option_t* opt, + pmp_record_t** ptr_records, + uint32_t* ptr_num_records, + easypmp_progress_t progress, + void *instance +) +{ + int result = 0; + result_t res = 0; + pmpdb_t* pmpdb = NULL; + + /* + * Read the existing database for update processing mode. + */ + // Create a database engine. + res = pmp->create_instance_db(pmp, &pmpdb); + if (!pmpdb) { + result = MAKE_PMP_ERROR(res); + goto error_exit; + } + + // Start reading a database. + if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_START, 0, 0, NULL) != 0) { + result = EASYPMPE_CANCEL; + goto error_exit; + } + + // Read the existing database. + res = pmpdb->read(pmpdb); + if (res != 0) { + result = MAKE_PMP_ERROR(res); + goto error_exit; + } + + // Obtain the number of records in the database. + res = pmpdb->get(pmpdb, NULL, ptr_num_records); + if (res != 0) { + result = MAKE_PMP_ERROR(res); + goto error_exit; + } + + // Allocate an array for the records. + (*ptr_records) = malloc(sizeof(pmp_record_t) * (*ptr_num_records)); + if (!(*ptr_records)) { + result = EASYPMPE_INSUFFICIENT_MEMORY; + goto error_exit; + } + + // Obtain the records from the database. + res = pmpdb->get(pmpdb, *ptr_records, ptr_num_records); + if (res != 0) { + result = MAKE_PMP_ERROR(res); + goto error_exit; + } + + // Sort the records for binary search. + qsort(*ptr_records, *ptr_num_records, sizeof(pmp_record_t), comp_filename); + + // Release the database instance. + if (pmpdb) { + pmpdb->release(pmpdb); + pmpdb = NULL; + } + + if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_END, *ptr_num_records, 0, NULL) != 0) { + result = EASYPMPE_CANCEL; + goto error_exit; + } + + return result; + +error_exit: + /* + * Free allocated memory. + */ + if ((*ptr_records)) { + uint32_t i; + for (i = 0;i < *ptr_num_records;++i) { + pmp_record_finish(&((*ptr_records)[i])); + } + free((*ptr_records)); + } + return result; +} + + + int database_dump(pmp_t* pmp, FILE *fp, int level) { pmpdb_t* pmpdb = NULL; Modified: trunk/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/frontend/easypmp/common/easypmp.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/common/easypmp.h 2006-04-16 14:47:55 UTC (rev 9) @@ -74,6 +74,7 @@ MODE_PLAYLIST_RECONVERT = 0x00000100, MODE_PLAYLIST_FIND = 0x00000200, MODE_PLAYLIST_SKIP = 0x00000400, + MODE_PLAYLIST_JSPL = 0x00000800, MODE_LIST_DEVICES = 0x00001000, MODE_HELP = 0x00010000, MODE_VERSION = 0x00020000, @@ -140,6 +141,16 @@ ); int +easypmp_database_read( + pmp_t* pmp, + const option_t* opt, + pmp_record_t** ptr_records, + uint32_t* ptr_num_records, + easypmp_progress_t progress, + void *instance +); + +int easypmp_playlist( const easypmp_filelist_t* playlists, const easypmp_filelist_t* musics, Modified: trunk/frontend/easypmp/common/enumerate.c =================================================================== --- trunk/frontend/easypmp/common/enumerate.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/common/enumerate.c 2006-04-16 14:47:55 UTC (rev 9) @@ -37,6 +37,7 @@ #include <easypmp.h> typedef struct { + const option_t* opt; easypmp_filelist_t* fl; pmp_t* pmp; easypmp_enumerate_progress_t proc; @@ -94,6 +95,7 @@ fl->elements = NULL; memset(&ed, 0, sizeof(ed)); + ed.opt = opt; ed.fl = fl; ed.pmp = pmp; ed.proc = proc; @@ -107,8 +109,9 @@ enumerate_dat_t* ed = (enumerate_dat_t*)instance; pmp_t* pmp = ed->pmp; easypmp_filelist_t* fl = ed->fl; + int flag = (ed->opt->verb & MODE_PLAYLIST_JSPL) ? PLAYLIST_JSPL : 0; - if (playlist_is_supported(found_file)) { + if (playlist_is_supported(found_file, flag)) { // Supported music file. easypmp_filename_t* new_filename = NULL; @@ -154,6 +157,7 @@ fl->elements = NULL; memset(&ed, 0, sizeof(ed)); + ed.opt = opt; ed.fl = fl; ed.pmp = pmp; ed.proc = proc; Modified: trunk/frontend/easypmp/common/playlist.c =================================================================== --- trunk/frontend/easypmp/common/playlist.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/common/playlist.c 2006-04-16 14:47:55 UTC (rev 9) @@ -106,7 +106,7 @@ playlist_normalize_prepare(mediafiles, musics->num_elements); // Start playlist conversion. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_START, musics->num_elements, 0, NULL) != 0) { + if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_START, playlists->num_elements, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -128,10 +128,19 @@ goto error_exit; } - // Read the source playlist + // Initialize playlist(s) instance. playlist_init(&pls); - if (playlist_read(&pls, src, opt->path_to_include, records, num_records, callback_from_playlist, &cd) != 0) { + // Read the source playlist. + if (playlist_read( + &pls, + src, + opt->path_to_include, + opt->verb & MODE_PLAYLIST_JSPL ? records : NULL, + num_records, + callback_from_playlist, + &cd + ) != 0) { result = EASYPMPE_PLAYLIST_READ; goto error_exit; } Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/cui/main.c 2006-04-16 14:47:55 UTC (rev 9) @@ -306,6 +306,10 @@ easypmp_database(&musics, pmp, &opt, &records, &num_records, easypmp_progress, NULL); } if (opt.verb & MODE_PLAYLIST) { + // Read the database for JSPL. + if ((opt.verb & MODE_PLAYLIST_JSPL) && (!records)) { + easypmp_database_read(pmp, &opt, &records, &num_records, easypmp_progress, NULL); + } easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, NULL); } if (opt.verb & MODE_DATABASE_REPR) { Modified: trunk/frontend/easypmp/cui/option.c =================================================================== --- trunk/frontend/easypmp/cui/option.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/cui/option.c 2006-04-16 14:47:55 UTC (rev 9) @@ -74,6 +74,7 @@ fprintf(fp, " -r, --reconvert Discard the existing playlist files and reconvert\n"); fprintf(fp, " -f, --find-missing Correct playlists with corrupt references to media files\n"); fprintf(fp, " -s, --skip-missing Continue a conversion even if a media file is missing\n"); + fprintf(fp, " -j, --jspl Enable JavaScript playlist (JSPL)\n"); fprintf(fp, "\n"); fprintf(fp, "Player options:\n"); fprintf(fp, " -L, --list-device Show the list of supported devices and exit\n"); @@ -126,6 +127,7 @@ {"reconvert", no_argument, 0, 'r'}, {"find-missing", no_argument, 0, 'f'}, {"skip-missing", no_argument, 0, 's'}, + {"jspl", no_argument, 0, 'j'}, {"list-device", no_argument, 0, 'L'}, {"device", required_argument, 0, 'd'}, #ifndef _WIN32 @@ -137,9 +139,9 @@ {NULL, 0, 0, 0} }; #ifndef _WIN32 - int c = getopt_long(argc, argv, "DuzRl:PMrfsLd:e:w:Vh", long_options, &option_index); + int c = getopt_long(argc, argv, "DuzRl:PMrfsjLd:e:w:Vh", long_options, &option_index); #else - int c = getopt_long(argc, argv, "DuzRl:PMrfsLd:Vh", long_options, &option_index); + int c = getopt_long(argc, argv, "DuzRl:PMrfsjLd:Vh", long_options, &option_index); #endif/*_WIN32*/ if (c == -1) { break; @@ -188,6 +190,9 @@ case 's': opt->verb |= MODE_PLAYLIST_SKIP; break; + case 'j': + opt->verb |= MODE_PLAYLIST_JSPL; + break; case 'L': opt->verb |= MODE_LIST_DEVICES; break; Modified: trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc =================================================================== --- trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-04-16 14:47:55 UTC (rev 9) @@ -84,73 +84,75 @@ // Dialog // -IDD_PREFERENCE DIALOGEX 0, 0, 263, 234 +IDD_PREFERENCE DIALOGEX 0, 0, 263, 246 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU CAPTION "EasyPMP [Win32 GUI]" FONT 8, "MS Shell Dlg", 400, 0, 0x80 BEGIN - DEFPUSHBUTTON "OK",IDOK,144,210,48,12 - PUSHBUTTON "Cancel",IDCANCEL,204,210,48,12 + DEFPUSHBUTTON "OK",IDOK,144,222,48,12 + PUSHBUTTON "Cancel",IDCANCEL,204,222,48,12 GROUPBOX "Media database",IDC_STATIC,12,12,240,48 CONTROL "&None",IDC_RADIO_DATABASE,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,24,25,72,8 - CONTROL "&Update",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,96,25, + WS_GROUP,24,24,72,8 + CONTROL "&Update",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,96,24, 72,8 - CONTROL "&Rebuild",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,168,25, + CONTROL "&Rebuild",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,168,24, 72,8 - GROUPBOX "Playlist conversion",IDC_STATIC,12,66,240,59 + GROUPBOX "Playlist conversion",IDC_STATIC,12,66,240,72 CONTROL "N&one",IDC_RADIO_PLAYLIST,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,24,79,72,8 - CONTROL "&Update",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON,96,79, + WS_GROUP,24,78,72,8 + CONTROL "&Update",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON,96,78, 72,8 CONTROL "Re&convert",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON,168, - 79,72,8 - LTEXT "Playlist folder(s):",IDC_STATIC,24,95,72,8 + 78,72,8 + LTEXT "Playlist folder(s):",IDC_STATIC,24,96,72,8 CONTROL "&Music",IDC_CHECK_PL_MUSIC,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,96,95,72,8 + WS_TABSTOP,96,96,72,8 CONTROL "&Playlist",IDC_CHECK_PL_PLAYLIST,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,168,95,72,8 - LTEXT "Conversion option:",IDC_STATIC,24,106,72,8 + BS_AUTOCHECKBOX | WS_TABSTOP,168,96,72,8 + LTEXT "Conversion option:",IDC_STATIC,24,108,72,8 CONTROL "&Find missing",IDC_CHECK_PL_FIND,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,96,106,72,8 + BS_AUTOCHECKBOX | WS_TABSTOP,96,108,72,8 CONTROL "&Skip missing",IDC_CHECK_PL_SKIP,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,168,106,72,8 - GROUPBOX "Portable Player Device",IDC_STATIC,12,130,240,72 - LTEXT "&Location:",IDC_STATIC,24,143,42,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_DEVICE_LOCATION,78,143,42,36,CBS_DROPDOWNLIST | + BS_AUTOCHECKBOX | WS_TABSTOP,168,108,72,8 + GROUPBOX "Portable Player Device",IDC_STATIC,12,144,240,72 + LTEXT "&Location:",IDC_STATIC,24,156,42,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_DEVICE_LOCATION,78,156,42,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "&Identifier:",IDC_STATIC,24,162,42,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_DEVICE_ID,78,162,162,36,CBS_DROPDOWNLIST | + LTEXT "&Identifier:",IDC_STATIC,24,174,42,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_DEVICE_ID,78,174,162,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Description:",IDC_STATIC,24,180,42,12,SS_CENTERIMAGE + LTEXT "Description:",IDC_STATIC,24,192,42,12,SS_CENTERIMAGE CONTROL "E&ject the player on completion",IDC_CHECK_SAFEREMOVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,210,120,12 - LTEXT "\x83X\x83^\x83e\x83B\x83b\x83N",IDC_STATIC_PLAYER_DESCRIPTION,78,178,162, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,222,120,12 + LTEXT "\x83X\x83^\x83e\x83B\x83b\x83N",IDC_STATIC_PLAYER_DESCRIPTION,78,192,162, 12,0,WS_EX_CLIENTEDGE CONTROL "Sa&ve log",IDC_CHECK_SAVE_LOG,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,168,143,66,12 + WS_TABSTOP,168,156,66,12 LTEXT "Source of media information (&z):",IDC_STATIC,24,42,108, 12 COMBOBOX IDC_COMBO_MEDIAINFO_SOURCE,138,42,102,36, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Use &JavaScript playlist (JSPL)",IDC_CHECK_PL_JSPL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,120,144,8 END -IDD_PROCESSING DIALOGEX 0, 0, 263, 234 +IDD_PROCESSING DIALOGEX 0, 0, 263, 246 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU CAPTION "EasyPMP [Win32 GUI]" FONT 8, "MS Shell Dlg", 400, 0, 0x80 BEGIN - DEFPUSHBUTTON "OK",IDOK,144,210,48,12,NOT WS_VISIBLE - PUSHBUTTON "Cancel",IDCANCEL,204,210,48,12 + DEFPUSHBUTTON "OK",IDOK,144,222,48,12,NOT WS_VISIBLE + PUSHBUTTON "Cancel",IDCANCEL,204,222,48,12 CONTROL "",IDC_LIST_PROGRESS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | - WS_BORDER,12,12,240,78 - EDITTEXT IDC_EDIT_LOG,12,90,240,114,ES_MULTILINE | ES_AUTOHSCROLL | + WS_BORDER,12,12,240,84 + EDITTEXT IDC_EDIT_LOG,12,96,240,120,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL CONTROL "E&ject the player on completion",IDC_CHECK_SAFEREMOVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,210,120,12 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,222,120,12 CONTROL "Don't &close",IDC_CHECK_DONT_CLOSE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,144,210,48,12 + BS_AUTOCHECKBOX | WS_TABSTOP,144,222,48,12 END @@ -167,7 +169,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 256 TOPMARGIN, 7 - BOTTOMMARGIN, 227 + BOTTOMMARGIN, 239 END IDD_PROCESSING, DIALOG @@ -175,7 +177,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 256 TOPMARGIN, 7 - BOTTOMMARGIN, 227 + BOTTOMMARGIN, 239 END END #endif // APSTUDIO_INVOKED Modified: trunk/frontend/easypmp/win32gui/maindlg.h =================================================================== --- trunk/frontend/easypmp/win32gui/maindlg.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/win32gui/maindlg.h 2006-04-16 14:47:55 UTC (rev 9) @@ -70,6 +70,7 @@ DDX_CHECK(IDC_CHECK_PL_MUSIC, m_setting.bConvertInMusic) DDX_CHECK(IDC_CHECK_PL_FIND, m_setting.bSearchMissing) DDX_CHECK(IDC_CHECK_PL_SKIP, m_setting.bSkipMissing) + DDX_CHECK(IDC_CHECK_PL_JSPL, m_setting.bJSPL) DDX_CHECK(IDC_CHECK_SAVE_LOG, m_setting.bSaveLog) DDX_CHECK(IDC_CHECK_SAFEREMOVE, m_setting.bSafelyRemove) END_DDX_MAP() Modified: trunk/frontend/easypmp/win32gui/preference.h =================================================================== --- trunk/frontend/easypmp/win32gui/preference.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/win32gui/preference.h 2006-04-16 14:47:55 UTC (rev 9) @@ -33,6 +33,7 @@ BOOL bConvertInMusic; BOOL bSearchMissing; BOOL bSkipMissing; + BOOL bJSPL; CString strPlayerLocation; CString strPlayerIdentifier; CString strPlayerDescription; @@ -50,6 +51,7 @@ bConvertInMusic = TRUE; bSearchMissing = TRUE; bSkipMissing = FALSE; + bJSPL = FALSE; strPlayerLocation = _T(""); // Initialize empty. strPlayerIdentifier = _T(""); // Initialize empty. strPlayerDescription = _T(""); // Initialize empty. @@ -100,6 +102,7 @@ persistBool(bConvertInMusic, _T("Playlist"), _T("ConvertMusic"), szSettingFile, storing); persistBool(bSearchMissing, _T("Playlist"), _T("SearchMissing"), szSettingFile, storing); persistBool(bSkipMissing, _T("Playlist"), _T("SkipMissing"), szSettingFile, storing); + persistBool(bJSPL, _T("Playlist"), _T("JSPL"), szSettingFile, storing); persistString(strPlayerLocation, _T("Player"), _T("Location"), szSettingFile, storing); persistString(strPlayerIdentifier, _T("Player"), _T("Identifier"), szSettingFile, storing); persistBool(bSafelyRemove, _T("General"), _T("SafelyRemove"), szSettingFile, storing); Modified: trunk/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/frontend/easypmp/win32gui/processingdlg.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/win32gui/processingdlg.h 2006-04-16 14:47:55 UTC (rev 9) @@ -275,11 +275,16 @@ if (m_preference.bConvertInPlaylist) opt.verb |= MODE_PLAYLIST_PLAYLIST; if (m_preference.bSearchMissing) opt.verb |= MODE_PLAYLIST_FIND; if (m_preference.bSkipMissing) opt.verb |= MODE_PLAYLIST_SKIP; + if (m_preference.bJSPL) opt.verb |= MODE_PLAYLIST_JSPL; // Set path to the root folder. m_preference.GetPathToPlayerRoot(str); ucs2cpy(opt.path_to_root, T2CW(str)); + // Set path to the include folder. + ::GetModuleFileNameW(_Module.GetModuleInstance(), opt.path_to_include, MAX_PATH); + ::PathRemoveFileSpecW(opt.path_to_include); + // Set model if (!m_preference.strPlayerIdentifier.IsEmpty()) { strcpy(opt.model, T2CA(m_preference.strPlayerIdentifier)); @@ -365,6 +370,11 @@ } } if (opt.verb & MODE_PLAYLIST) { + if ((opt.verb & MODE_PLAYLIST_JSPL) && (!records)) { + setState(PHASE_DATABASE_READ, STATE_PROCESSING); + easypmp_database_read(pmp, &opt, &records, &num_records, easypmp_progress, this); + setState(PHASE_DATABASE_READ, STATE_DONE); + } result = easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, this); if (result != 0) { goto error_exit; Modified: trunk/frontend/easypmp/win32gui/resource.h =================================================================== --- trunk/frontend/easypmp/win32gui/resource.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/frontend/easypmp/win32gui/resource.h 2006-04-16 14:47:55 UTC (rev 9) @@ -24,6 +24,8 @@ #define IDC_CHECK_SAVE_LOG 1012 #define IDC_COMBO_DEVICE_ID2 1013 #define IDC_COMBO_MEDIAINFO_SOURCE 1013 +#define IDC_CHECK_PL_FIND2 1014 +#define IDC_CHECK_PL_JSPL 1014 #define IDC_EDIT_LOG 1019 #define IDC_CHECK_SAFEREMOVE 1020 #define IDC_STATIC_PLAYER_DESCRIPTION 1021 Modified: trunk/include/playlist.h =================================================================== --- trunk/include/playlist.h 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/include/playlist.h 2006-04-16 14:47:55 UTC (rev 9) @@ -37,6 +37,11 @@ struct tag_pmp_record_t; typedef struct tag_pmp_record_t pmp_record_t; enum { + PLAYLIST_NONE = 0, + PLAYLIST_JSPL = 1, +}; + +enum { PLCALLBACK_NONE, PLCALLBACK_JSPL_MESSAGE, PLCALLBACK_JSPL_ERROR, @@ -134,7 +139,8 @@ PLAYLISTAPI int playlist_is_supported( - const ucs2char_t* filename + const ucs2char_t* filename, + int flag ); PLAYLISTAPI Modified: trunk/lib/playlist/playlist.c =================================================================== --- trunk/lib/playlist/playlist.c 2006-04-05 13:57:51 UTC (rev 8) +++ trunk/lib/playlist/playlist.c 2006-04-16 14:47:55 UTC (rev 9) @@ -81,7 +81,7 @@ return playlist_m3u_read(pls, filename, 1); } else if (filepath_hasext(filename, ucs2cs_pls)) { return playlist_pls_read(pls, filename); - } else if (filepath_hasext(filename, ucs2cs_jspl)) { + } else if (records && filepath_hasext(filename, ucs2cs_jspl)) { return playlist_jspl_read(pls, filename, path_to_include, records, num_records, callback, instance); } else { return -1; @@ -129,13 +129,15 @@ return 0; } -int playlist_is_supported(const ucs2char_t* filename) +int playlist_is_supported(const ucs2char_t* filename, int flag) { int ret = 0; ret |= filepath_hasext(filename, ucs2cs_m3u); ret |= filepath_hasext(filename, ucs2cs_m3u8); ret |= filepath_hasext(filename, ucs2cs_pls); - ret |= filepath_hasext(filename, ucs2cs_jspl); + if (flag & PLAYLIST_JSPL) { + ret |= filepath_hasext(filename, ucs2cs_jspl); + } return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |