<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Audacious: playlist-utils.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Audacious <span id="projectnumber">$Id:Doxyfile42802007-03-2104:39:00Znenolod$</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>playlist-utils.c</h1> </div> </div> <div class="contents"> <a href="playlist-utils_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * playlist-utils.c</span> <a name="l00003"></a>00003 <span class="comment"> * Copyright 2009-2010 John Lindgren</span> <a name="l00004"></a>00004 <span class="comment"> *</span> <a name="l00005"></a>00005 <span class="comment"> * This file is part of Audacious.</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Audacious is free software: you can redistribute it and/or modify it under</span> <a name="l00008"></a>00008 <span class="comment"> * the terms of the GNU General Public License as published by the Free Software</span> <a name="l00009"></a>00009 <span class="comment"> * Foundation, version 2 or version 3 of the License.</span> <a name="l00010"></a>00010 <span class="comment"> *</span> <a name="l00011"></a>00011 <span class="comment"> * Audacious is distributed in the hope that it will be useful, but WITHOUT ANY</span> <a name="l00012"></a>00012 <span class="comment"> * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR</span> <a name="l00013"></a>00013 <span class="comment"> * A PARTICULAR PURPOSE. See the GNU General Public License for more details.</span> <a name="l00014"></a>00014 <span class="comment"> *</span> <a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU General Public License along with</span> <a name="l00016"></a>00016 <span class="comment"> * Audacious. If not, see <http://www.gnu.org/licenses/>.</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> * The Audacious team does not consider modular code linking to Audacious or</span> <a name="l00019"></a>00019 <span class="comment"> * using our public API to be a derived work.</span> <a name="l00020"></a>00020 <span class="comment"> */</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include <glib.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <regex.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <string.h></span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="preprocessor">#include <libaudcore/audstrings.h></span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="audconfig_8h.html">audconfig.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="main_8h.html">main.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="misc_8h.html">misc.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="playlist_8h.html">playlist.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="playlist__container_8h.html">playlist_container.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="playlist-utils_8h.html">playlist-utils.h</a>"</span> <a name="l00034"></a>00034 <a name="l00035"></a><a class="code" href="playlist-utils_8c.html#a70fafa721f436e96edac9e94d0284a57">00035</a> <span class="keyword">static</span> <span class="keyword">const</span> gchar * <a class="code" href="playlist-utils_8c.html#a70fafa721f436e96edac9e94d0284a57">aud_titlestring_presets</a>[] = <a name="l00036"></a>00036 { <a name="l00037"></a>00037 <span class="stringliteral">"${title}"</span>, <a name="l00038"></a>00038 <span class="stringliteral">"${?artist:${artist} - }${title}"</span>, <a name="l00039"></a>00039 <span class="stringliteral">"${?artist:${artist} - }${?album:${album} - }${title}"</span>, <a name="l00040"></a>00040 <span class="stringliteral">"${?artist:${artist} - }${?album:${album} - }"</span> <a name="l00041"></a>00041 <span class="stringliteral">"${?track-number:${track-number}. }${title}"</span>, <a name="l00042"></a>00042 <span class="stringliteral">"${?artist:${artist} }${?album:[ ${album} ] }${?artist:- }"</span> <a name="l00043"></a>00043 <span class="stringliteral">"${?track-number:${track-number}. }${title}"</span>, <a name="l00044"></a>00044 <span class="stringliteral">"${?album:${album} - }${title}"</span>, <a name="l00045"></a>00045 }; <a name="l00046"></a>00046 <a name="l00047"></a><a class="code" href="playlist-utils_8h.html#a21a5a2d0ce4d45474e846e0e6db30baa">00047</a> <span class="keyword">const</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a21a5a2d0ce4d45474e846e0e6db30baa">n_titlestring_presets</a> = G_N_ELEMENTS (<a class="code" href="playlist-utils_8c.html#a70fafa721f436e96edac9e94d0284a57">aud_titlestring_presets</a>); <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="playlist-utils_8c.html#ae4a0d683e354804fe1d221e123fa5478">00049</a> <span class="keyword">static</span> <span class="keyword">const</span> gchar * <a class="code" href="playlist-utils_8c.html#ae4a0d683e354804fe1d221e123fa5478">get_basename</a> (<span class="keyword">const</span> gchar * <a class="code" href="misc-api_8h.html#a820d8643bcfa9e2641dd6377f804de20">filename</a>) <a name="l00050"></a>00050 { <a name="l00051"></a>00051 <span class="keyword">const</span> gchar * slash = strrchr (filename, <span class="charliteral">'/'</span>); <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="keywordflow">return</span> (slash == NULL) ? filename : slash + 1; <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a><a class="code" href="playlist-utils_8c.html#a16c455a940fbce76423bc6633a18150a">00056</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a16c455a940fbce76423bc6633a18150a">filename_compare_basename</a> (<span class="keyword">const</span> gchar * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> gchar * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00057"></a>00057 { <a name="l00058"></a>00058 <span class="keywordflow">return</span> <a class="code" href="audstrings_8c.html#ade32b444526787b1b8ead08fd6384908">string_compare_encoded</a> (<a class="code" href="playlist-utils_8c.html#ae4a0d683e354804fe1d221e123fa5478">get_basename</a> (a), <a class="code" href="playlist-utils_8c.html#ae4a0d683e354804fe1d221e123fa5478">get_basename</a> (b)); <a name="l00059"></a>00059 } <a name="l00060"></a>00060 <a name="l00061"></a><a class="code" href="playlist-utils_8c.html#a4e6a24ad61177239b69e950313367938">00061</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a4e6a24ad61177239b69e950313367938">tuple_compare_string</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> field) <a name="l00062"></a>00062 { <a name="l00063"></a>00063 <span class="keyword">const</span> gchar * string_a = <a class="code" href="tuple_8c.html#a7a653c534853fc3bd9afd9b6be96e25a" title="Returns pointer to a string associated to Tuple field.">tuple_get_string</a> (a, field, NULL); <a name="l00064"></a>00064 <span class="keyword">const</span> gchar * string_b = <a class="code" href="tuple_8c.html#a7a653c534853fc3bd9afd9b6be96e25a" title="Returns pointer to a string associated to Tuple field.">tuple_get_string</a> (b, field, NULL); <a name="l00065"></a>00065 <a name="l00066"></a>00066 <span class="keywordflow">if</span> (string_a == NULL) <a name="l00067"></a>00067 <span class="keywordflow">return</span> (string_b == NULL) ? 0 : -1; <a name="l00068"></a>00068 <span class="keywordflow">if</span> (string_b == NULL) <a name="l00069"></a>00069 <span class="keywordflow">return</span> 1; <a name="l00070"></a>00070 <a name="l00071"></a>00071 <span class="keywordflow">return</span> <a class="code" href="audstrings_8c.html#ad231ea56209961d4ee4b9b13d18c6fa9">string_compare</a> (string_a, string_b); <a name="l00072"></a>00072 } <a name="l00073"></a>00073 <a name="l00074"></a><a class="code" href="playlist-utils_8c.html#a63326126d74afb08fc71bf619de835a2">00074</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a63326126d74afb08fc71bf619de835a2">tuple_compare_int</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> field) <a name="l00075"></a>00075 { <a name="l00076"></a>00076 <span class="keywordflow">if</span> (<a class="code" href="tuple_8c.html#a5f7f6ce621bc1bf67a4a93a0877e8dc6" title="Returns TupleValueType of given Tuple field.">tuple_get_value_type</a> (a, field, NULL) != <a class="code" href="tuple_8h.html#a7c30590e28255832d324bbeccc6a7b93ad691daf1df77095c1e19fe30b6cea5b4">TUPLE_INT</a>) <a name="l00077"></a>00077 <span class="keywordflow">return</span> (<a class="code" href="tuple_8c.html#a5f7f6ce621bc1bf67a4a93a0877e8dc6" title="Returns TupleValueType of given Tuple field.">tuple_get_value_type</a> (b, field, NULL) != <a class="code" href="tuple_8h.html#a7c30590e28255832d324bbeccc6a7b93ad691daf1df77095c1e19fe30b6cea5b4">TUPLE_INT</a>) ? 0 : -1; <a name="l00078"></a>00078 <span class="keywordflow">if</span> (<a class="code" href="tuple_8c.html#a5f7f6ce621bc1bf67a4a93a0877e8dc6" title="Returns TupleValueType of given Tuple field.">tuple_get_value_type</a> (b, field, NULL) != <a class="code" href="tuple_8h.html#a7c30590e28255832d324bbeccc6a7b93ad691daf1df77095c1e19fe30b6cea5b4">TUPLE_INT</a>) <a name="l00079"></a>00079 <span class="keywordflow">return</span> 1; <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> int_a = <a class="code" href="tuple_8c.html#a5a0ca1037b697bb8d8e2cb866dcd5531" title="Returns integer associated to Tuple field.">tuple_get_int</a> (a, field, NULL); <a name="l00082"></a>00082 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> int_b = <a class="code" href="tuple_8c.html#a5a0ca1037b697bb8d8e2cb866dcd5531" title="Returns integer associated to Tuple field.">tuple_get_int</a> (b, field, NULL); <a name="l00083"></a>00083 <a name="l00084"></a>00084 <span class="keywordflow">return</span> (int_a < int_b) ? -1 : (int_a > int_b); <a name="l00085"></a>00085 } <a name="l00086"></a>00086 <a name="l00087"></a><a class="code" href="playlist-utils_8c.html#a08bdb8236db8eb50bdd6e0c90de635a6">00087</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a08bdb8236db8eb50bdd6e0c90de635a6">tuple_compare_title</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00088"></a>00088 { <a name="l00089"></a>00089 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a4e6a24ad61177239b69e950313367938">tuple_compare_string</a> (a, b, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a727c26f90a9365dd893a81545c30cca1" title="Song title.">FIELD_TITLE</a>); <a name="l00090"></a>00090 } <a name="l00091"></a>00091 <a name="l00092"></a><a class="code" href="playlist-utils_8c.html#ae344bfa3d95050b940273223abe09fd1">00092</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#ae344bfa3d95050b940273223abe09fd1">tuple_compare_album</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00093"></a>00093 { <a name="l00094"></a>00094 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a4e6a24ad61177239b69e950313367938">tuple_compare_string</a> (a, b, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5af5b3b577baf586bb01c61a79ce07e9d7" title="Album name.">FIELD_ALBUM</a>); <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a><a class="code" href="playlist-utils_8c.html#a46c2fbdd3f62ddf96041705303d5a121">00097</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a46c2fbdd3f62ddf96041705303d5a121">tuple_compare_artist</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a4e6a24ad61177239b69e950313367938">tuple_compare_string</a> (a, b, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a959c0cc336f4e5fd9c64caac6f64dd8b">FIELD_ARTIST</a>); <a name="l00100"></a>00100 } <a name="l00101"></a>00101 <a name="l00102"></a><a class="code" href="playlist-utils_8c.html#a287280e198a6c59e24f5642e8a01e890">00102</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a287280e198a6c59e24f5642e8a01e890">tuple_compare_date</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00103"></a>00103 { <a name="l00104"></a>00104 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a63326126d74afb08fc71bf619de835a2">tuple_compare_int</a> (a, b, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a11fd28a7c08106ed251cd155189c4ea7" title="Year of production/performance/etc.">FIELD_YEAR</a>); <a name="l00105"></a>00105 } <a name="l00106"></a>00106 <a name="l00107"></a><a class="code" href="playlist-utils_8c.html#a64aba3a90bdd2bc123f14bebbe69cde9">00107</a> <span class="keyword">static</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-utils_8c.html#a64aba3a90bdd2bc123f14bebbe69cde9">tuple_compare_track</a> (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) <a name="l00108"></a>00108 { <a name="l00109"></a>00109 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a63326126d74afb08fc71bf619de835a2">tuple_compare_int</a> (a, b, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a6506fca6230e3f48b0203f9e6c4ca6fb">FIELD_TRACK_NUMBER</a>); <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00112"></a><a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">00112</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="playlist_8h.html#ad11ecbac9334a50d8d662b44da51984d">PlaylistFilenameCompareFunc</a> <a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[] = { <a name="l00113"></a>00113 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a00047fe481cf1b73eeda4137e8e6af4b">PLAYLIST_SORT_PATH</a>] = <a class="code" href="audstrings_8c.html#ade32b444526787b1b8ead08fd6384908">string_compare_encoded</a>, <a name="l00114"></a>00114 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a925759e3829ad51609e3fae150b593fb">PLAYLIST_SORT_FILENAME</a>] = <a class="code" href="playlist-utils_8c.html#a16c455a940fbce76423bc6633a18150a">filename_compare_basename</a>, <a name="l00115"></a>00115 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8ab3421a1c09de0ecb078caf92cc6c2cb6">PLAYLIST_SORT_TITLE</a>] = NULL, <a name="l00116"></a>00116 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a24bbf1c41f36873d7ca218e82931649d">PLAYLIST_SORT_ALBUM</a>] = NULL, <a name="l00117"></a>00117 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8affb4df0106b7353d92ce310ce45e5e3c">PLAYLIST_SORT_ARTIST</a>] = NULL, <a name="l00118"></a>00118 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a396a0d1b36ae2bf04841c36dc994c418">PLAYLIST_SORT_DATE</a>] = NULL, <a name="l00119"></a>00119 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a550b87b7cdb08d01f461ef03e80547b5">PLAYLIST_SORT_TRACK</a>] = NULL}; <a name="l00120"></a>00120 <a name="l00121"></a><a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">00121</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="playlist_8h.html#aff628dd2312c4b7ae6a1e5ed2dba1eb5">PlaylistTupleCompareFunc</a> <a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[] = { <a name="l00122"></a>00122 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a00047fe481cf1b73eeda4137e8e6af4b">PLAYLIST_SORT_PATH</a>] = NULL, <a name="l00123"></a>00123 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a925759e3829ad51609e3fae150b593fb">PLAYLIST_SORT_FILENAME</a>] = NULL, <a name="l00124"></a>00124 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8ab3421a1c09de0ecb078caf92cc6c2cb6">PLAYLIST_SORT_TITLE</a>] = <a class="code" href="playlist-utils_8c.html#a08bdb8236db8eb50bdd6e0c90de635a6">tuple_compare_title</a>, <a name="l00125"></a>00125 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a24bbf1c41f36873d7ca218e82931649d">PLAYLIST_SORT_ALBUM</a>] = <a class="code" href="playlist-utils_8c.html#ae344bfa3d95050b940273223abe09fd1">tuple_compare_album</a>, <a name="l00126"></a>00126 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8affb4df0106b7353d92ce310ce45e5e3c">PLAYLIST_SORT_ARTIST</a>] = <a class="code" href="playlist-utils_8c.html#a46c2fbdd3f62ddf96041705303d5a121">tuple_compare_artist</a>, <a name="l00127"></a>00127 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a396a0d1b36ae2bf04841c36dc994c418">PLAYLIST_SORT_DATE</a>] = <a class="code" href="playlist-utils_8c.html#a287280e198a6c59e24f5642e8a01e890">tuple_compare_date</a>, <a name="l00128"></a>00128 [<a class="code" href="playlist_8h.html#ac36f475ca5b446f4fde4c9b90bec77c8a550b87b7cdb08d01f461ef03e80547b5">PLAYLIST_SORT_TRACK</a>] = <a class="code" href="playlist-utils_8c.html#a64aba3a90bdd2bc123f14bebbe69cde9">tuple_compare_track</a>}; <a name="l00129"></a>00129 <a name="l00130"></a><a class="code" href="playlist-utils_8c.html#ad92e302987c4d38af791b5ad026ac3c9">00130</a> <span class="keyword">const</span> gchar * <a class="code" href="playlist-utils_8c.html#ad92e302987c4d38af791b5ad026ac3c9">get_gentitle_format</a> (<span class="keywordtype">void</span>) <a name="l00131"></a>00131 { <a name="l00132"></a>00132 <span class="keywordflow">if</span> (<a class="code" href="audconfig_8c.html#a98bd56a064259046a6cc6b1a620badf8">cfg</a>.titlestring_preset >= 0 && <a class="code" href="audconfig_8c.html#a98bd56a064259046a6cc6b1a620badf8">cfg</a>.titlestring_preset < <a name="l00133"></a>00133 <a class="code" href="playlist-utils_8c.html#a21a5a2d0ce4d45474e846e0e6db30baa">n_titlestring_presets</a>) <a name="l00134"></a>00134 <span class="keywordflow">return</span> <a class="code" href="playlist-utils_8c.html#a70fafa721f436e96edac9e94d0284a57">aud_titlestring_presets</a>[<a class="code" href="audconfig_8c.html#a98bd56a064259046a6cc6b1a620badf8">cfg</a>.titlestring_preset]; <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="keywordflow">return</span> <a class="code" href="audconfig_8c.html#a98bd56a064259046a6cc6b1a620badf8">cfg</a>.gentitle_format; <a name="l00137"></a>00137 } <a name="l00138"></a>00138 <a name="l00139"></a><a class="code" href="playlist-utils_8c.html#adab776e8d21c508e8690f362fc8a237a">00139</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#adab776e8d21c508e8690f362fc8a237a">playlist_sort_by_scheme</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> scheme) <a name="l00140"></a>00140 { <a name="l00141"></a>00141 <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme] != NULL) <a name="l00142"></a>00142 <a class="code" href="playlist-api_8h.html#a8367d612eadee0f577710d8eb4eaf70b">playlist_sort_by_filename</a> (playlist, <a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme]); <a name="l00143"></a>00143 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme] != NULL) <a name="l00144"></a>00144 <a class="code" href="playlist-new_8c.html#aac81a288edc2c7bfb34c59af693d22bb">playlist_sort_by_tuple</a> (playlist, <a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme]); <a name="l00145"></a>00145 } <a name="l00146"></a>00146 <a name="l00147"></a><a class="code" href="playlist-utils_8c.html#a9204dbf277d278bc71a14c0d26210da7">00147</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#a9204dbf277d278bc71a14c0d26210da7">playlist_sort_selected_by_scheme</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> scheme) <a name="l00148"></a>00148 { <a name="l00149"></a>00149 <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme] != NULL) <a name="l00150"></a>00150 <a class="code" href="playlist-api_8h.html#af2fc29bc3c4805b54af5060b12c6b62a">playlist_sort_selected_by_filename</a> (playlist, <a name="l00151"></a>00151 <a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme]); <a name="l00152"></a>00152 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme] != NULL) <a name="l00153"></a>00153 <a class="code" href="playlist-new_8c.html#a076b88a6ca52b328245f064611cb83f9">playlist_sort_selected_by_tuple</a> (playlist, <a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme]); <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="comment">/* Fix me: This considers empty fields as duplicates. */</span> <a name="l00157"></a><a class="code" href="playlist-utils_8c.html#a6ddf6891e1a26df215e53ab457a030da">00157</a> <span class="keywordtype">void</span> <a class="code" href="playlist-api_8h.html#abdebb29c13752c7e21566fe9231c7fa5">playlist_remove_duplicates_by_scheme</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> scheme) <a name="l00158"></a>00158 { <a name="l00159"></a>00159 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> entries = <a class="code" href="playlist-new_8c.html#af64b7c6ea43b1b56f85c348ddaf39bae">playlist_entry_count</a> (playlist); <a name="l00160"></a>00160 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="misc-api_8h.html#ac0c64a48f21e0d91f7340acdb9cc6409">count</a>; <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="keywordflow">if</span> (entries < 1) <a name="l00163"></a>00163 <span class="keywordflow">return</span>; <a name="l00164"></a>00164 <a name="l00165"></a>00165 <a class="code" href="playlist-new_8c.html#ae0e8e2b5a19fc1f5587a9ad20f59b4fa">playlist_select_all</a> (playlist, FALSE); <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme] != NULL) <a name="l00168"></a>00168 { <a name="l00169"></a>00169 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> (* compare) (<span class="keyword">const</span> gchar * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> gchar * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) = <a name="l00170"></a>00170 <a class="code" href="playlist-utils_8c.html#af8b52cd69799105806f0854a1387fcd5">filename_comparisons</a>[scheme]; <a name="l00171"></a>00171 <span class="keyword">const</span> gchar * last, * current; <a name="l00172"></a>00172 <a name="l00173"></a>00173 <a class="code" href="playlist-api_8h.html#a8367d612eadee0f577710d8eb4eaf70b">playlist_sort_by_filename</a> (playlist, compare); <a name="l00174"></a>00174 last = <a class="code" href="playlist-new_8c.html#a87cc5b5c9270aefb2c09712afbb8d1e2">playlist_entry_get_filename</a> (playlist, 0); <a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="keywordflow">for</span> (count = 1; count < entries; count ++) <a name="l00177"></a>00177 { <a name="l00178"></a>00178 current = <a class="code" href="playlist-new_8c.html#a87cc5b5c9270aefb2c09712afbb8d1e2">playlist_entry_get_filename</a> (playlist, count); <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordflow">if</span> (compare (last, current) == 0) <a name="l00181"></a>00181 <a class="code" href="playlist-new_8c.html#ab77f4d2fab83d7ed537edfbe546c4353">playlist_entry_set_selected</a> (playlist, count, TRUE); <a name="l00182"></a>00182 <a name="l00183"></a>00183 last = current; <a name="l00184"></a>00184 } <a name="l00185"></a>00185 } <a name="l00186"></a>00186 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme] != NULL) <a name="l00187"></a>00187 { <a name="l00188"></a>00188 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> (* compare) (<span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a21329274c21b67fc478d38001a78d392">a</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="equalizer_8c.html#a68195c8196bba3c211db7cdcef429181">b</a>) = <a name="l00189"></a>00189 <a class="code" href="playlist-utils_8c.html#a19972e2fe38d64b383c81d4348dc5641">tuple_comparisons</a>[scheme]; <a name="l00190"></a>00190 <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * last, * current; <a name="l00191"></a>00191 <a name="l00192"></a>00192 <a class="code" href="playlist-new_8c.html#aac81a288edc2c7bfb34c59af693d22bb">playlist_sort_by_tuple</a> (playlist, compare); <a name="l00193"></a>00193 last = <a class="code" href="playlist-api_8h.html#a46d5502818b491357ef13a2a03fdcfd3">playlist_entry_get_tuple</a> (playlist, 0, FALSE); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="keywordflow">for</span> (count = 1; count < entries; count ++) <a name="l00196"></a>00196 { <a name="l00197"></a>00197 current = <a class="code" href="playlist-api_8h.html#a46d5502818b491357ef13a2a03fdcfd3">playlist_entry_get_tuple</a> (playlist, count, FALSE); <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="keywordflow">if</span> (last != NULL && current != NULL && compare (last, current) == 0) <a name="l00200"></a>00200 <a class="code" href="playlist-new_8c.html#ab77f4d2fab83d7ed537edfbe546c4353">playlist_entry_set_selected</a> (playlist, count, TRUE); <a name="l00201"></a>00201 <a name="l00202"></a>00202 last = current; <a name="l00203"></a>00203 } <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <a name="l00206"></a>00206 <a class="code" href="playlist-new_8c.html#af4b2e3cba915e549c9672f40e18b5510">playlist_delete_selected</a> (playlist); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <a name="l00209"></a><a class="code" href="playlist-utils_8c.html#a1c47a9edec5ef71cc8643f964491a5b8">00209</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#a1c47a9edec5ef71cc8643f964491a5b8">playlist_remove_failed</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>) <a name="l00210"></a>00210 { <a name="l00211"></a>00211 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> entries = <a class="code" href="playlist-new_8c.html#af64b7c6ea43b1b56f85c348ddaf39bae">playlist_entry_count</a> (playlist); <a name="l00212"></a>00212 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="misc-api_8h.html#ac0c64a48f21e0d91f7340acdb9cc6409">count</a>; <a name="l00213"></a>00213 <a name="l00214"></a>00214 <a class="code" href="playlist-new_8c.html#a746e55b3693a30e0c00f6f24495e5956">playlist_rescan</a> (playlist); <a name="l00215"></a>00215 <a class="code" href="playlist-new_8c.html#ae0e8e2b5a19fc1f5587a9ad20f59b4fa">playlist_select_all</a> (playlist, FALSE); <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keywordflow">for</span> (count = 0; count < entries; count ++) <a name="l00218"></a>00218 { <a name="l00219"></a>00219 <span class="keywordflow">if</span> (<a class="code" href="playlist-new_8c.html#ad436674bf3d7e427864a03d1b61d5931">playlist_entry_get_decoder</a> (playlist, count) == NULL || <a name="l00220"></a>00220 <a class="code" href="playlist-api_8h.html#a46d5502818b491357ef13a2a03fdcfd3">playlist_entry_get_tuple</a> (playlist, count, FALSE) == NULL) <a name="l00221"></a>00221 <a class="code" href="playlist-new_8c.html#ab77f4d2fab83d7ed537edfbe546c4353">playlist_entry_set_selected</a> (playlist, count, TRUE); <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <a name="l00224"></a>00224 <a class="code" href="playlist-new_8c.html#af4b2e3cba915e549c9672f40e18b5510">playlist_delete_selected</a> (playlist); <a name="l00225"></a>00225 } <a name="l00226"></a>00226 <a name="l00227"></a><a class="code" href="playlist-utils_8c.html#a9682ea792876caf54c6509b2d8dd4e8a">00227</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#a9682ea792876caf54c6509b2d8dd4e8a">playlist_select_by_patterns</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * patterns) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 <span class="keyword">const</span> <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> fields[] = {<a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a727c26f90a9365dd893a81545c30cca1" title="Song title.">FIELD_TITLE</a>, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5af5b3b577baf586bb01c61a79ce07e9d7" title="Album name.">FIELD_ALBUM</a>, <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a959c0cc336f4e5fd9c64caac6f64dd8b">FIELD_ARTIST</a>, <a name="l00230"></a>00230 <a class="code" href="tuple_8h.html#a99fb83031ce9923c84392b4e92f956b5a58e826cdedbcc5ba2429834c72e4256b" title="File name part of the location URI.">FIELD_FILE_NAME</a>}; <a name="l00231"></a>00231 <a name="l00232"></a>00232 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> entries = <a class="code" href="playlist-new_8c.html#af64b7c6ea43b1b56f85c348ddaf39bae">playlist_entry_count</a> (playlist); <a name="l00233"></a>00233 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> field, <a class="code" href="playlist-api_8h.html#abaa108414cc2c74407885fb19e375eb7">entry</a>; <a name="l00234"></a>00234 <a name="l00235"></a>00235 <a class="code" href="playlist-new_8c.html#ae0e8e2b5a19fc1f5587a9ad20f59b4fa">playlist_select_all</a> (playlist, TRUE); <a name="l00236"></a>00236 <a name="l00237"></a>00237 <span class="keywordflow">for</span> (field = 0; field < G_N_ELEMENTS (fields); field ++) <a name="l00238"></a>00238 { <a name="l00239"></a>00239 <span class="keyword">const</span> gchar * pattern = <a class="code" href="tuple_8c.html#a7a653c534853fc3bd9afd9b6be96e25a" title="Returns pointer to a string associated to Tuple field.">tuple_get_string</a> ((<a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> *) patterns, <a name="l00240"></a>00240 fields[field], NULL); <a name="l00241"></a>00241 regex_t regex; <a name="l00242"></a>00242 <a name="l00243"></a>00243 <span class="keywordflow">if</span> (pattern == NULL || pattern[0] == 0) <a name="l00244"></a>00244 <span class="keywordflow">continue</span>; <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="keywordflow">if</span> (regcomp (& regex, pattern, REG_ICASE) != 0) <a name="l00247"></a>00247 <span class="keywordflow">continue</span>; <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keywordflow">for</span> (entry = 0; entry < entries; entry ++) <a name="l00250"></a>00250 { <a name="l00251"></a>00251 <span class="keyword">const</span> <a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> * <a class="code" href="structentry.html#a9be264183f58a31bee4750a00c81f06e">tuple</a>; <a name="l00252"></a>00252 <span class="keyword">const</span> gchar * string; <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keywordflow">if</span> (! <a class="code" href="playlist-new_8c.html#a3f4152458824146bcd7411c827f2b99b">playlist_entry_get_selected</a> (playlist, entry)) <a name="l00255"></a>00255 <span class="keywordflow">continue</span>; <a name="l00256"></a>00256 <a name="l00257"></a>00257 tuple = <a class="code" href="playlist-api_8h.html#a46d5502818b491357ef13a2a03fdcfd3">playlist_entry_get_tuple</a> (playlist, entry, FALSE); <a name="l00258"></a>00258 <a name="l00259"></a>00259 <span class="keywordflow">if</span> (tuple == NULL) <a name="l00260"></a>00260 <span class="keywordflow">goto</span> NO_MATCH; <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="keywordtype">string</span> = <a class="code" href="tuple_8c.html#a7a653c534853fc3bd9afd9b6be96e25a" title="Returns pointer to a string associated to Tuple field.">tuple_get_string</a> ((<a class="code" href="structTuple.html" title="Structure for holding and passing around miscellaneous track metadata.">Tuple</a> *) tuple, fields[field], NULL); <a name="l00263"></a>00263 <a name="l00264"></a>00264 <span class="keywordflow">if</span> (<span class="keywordtype">string</span> == NULL) <a name="l00265"></a>00265 <span class="keywordflow">goto</span> NO_MATCH; <a name="l00266"></a>00266 <a name="l00267"></a>00267 <span class="keywordflow">if</span> (regexec (& regex, <span class="keywordtype">string</span>, 0, NULL, 0) == 0) <a name="l00268"></a>00268 <span class="keywordflow">continue</span>; <a name="l00269"></a>00269 <a name="l00270"></a>00270 NO_MATCH: <a name="l00271"></a>00271 <a class="code" href="playlist-new_8c.html#ab77f4d2fab83d7ed537edfbe546c4353">playlist_entry_set_selected</a> (playlist, entry, FALSE); <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <a name="l00274"></a>00274 regfree (& regex); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 } <a name="l00277"></a>00277 <a name="l00278"></a><a class="code" href="playlist-utils_8c.html#aceb2432d2d85f17ae4c770eed0dcd4aa">00278</a> <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a> <a class="code" href="playlist-utils_8c.html#aceb2432d2d85f17ae4c770eed0dcd4aa">filename_is_playlist</a> (<span class="keyword">const</span> gchar * <a class="code" href="misc-api_8h.html#a820d8643bcfa9e2641dd6377f804de20">filename</a>) <a name="l00279"></a>00279 { <a name="l00280"></a>00280 <span class="keyword">const</span> gchar * period = strrchr (filename, <span class="charliteral">'.'</span>); <a name="l00281"></a>00281 <a name="l00282"></a>00282 <span class="keywordflow">return</span> (period != NULL && <a class="code" href="playlist__container_8c.html#a8c10a45232f31e02e734d4023b8396fd">playlist_container_find</a> ((gchar *) period + 1) != <a name="l00283"></a>00283 NULL); <a name="l00284"></a>00284 } <a name="l00285"></a>00285 <a name="l00286"></a><a class="code" href="playlist-utils_8c.html#af32c44be5c73342062fb5e25becd0269">00286</a> <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a> <a class="code" href="playlist-api_8h.html#a10834e1b204827d4ea161ff4ee83ff77">playlist_insert_playlist</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-api_8h.html#af5e8b5caf7672073a7b6cc7131d1d809">at</a>, <span class="keyword">const</span> gchar * <a name="l00287"></a>00287 <a class="code" href="misc-api_8h.html#a820d8643bcfa9e2641dd6377f804de20">filename</a>) <a name="l00288"></a>00288 { <a name="l00289"></a>00289 <span class="keyword">const</span> gchar * period = strrchr (filename, <span class="charliteral">'.'</span>); <a name="l00290"></a>00290 <a class="code" href="structPlaylistContainer.html">PlaylistContainer</a> * container; <a name="l00291"></a>00291 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> last; <a name="l00292"></a>00292 <a name="l00293"></a>00293 <span class="keywordflow">if</span> (period == NULL) <a name="l00294"></a>00294 <span class="keywordflow">return</span> FALSE; <a name="l00295"></a>00295 <a name="l00296"></a>00296 container = <a class="code" href="playlist__container_8c.html#a8c10a45232f31e02e734d4023b8396fd">playlist_container_find</a> ((gchar *) period + 1); <a name="l00297"></a>00297 <a name="l00298"></a>00298 <span class="keywordflow">if</span> (container == NULL || container-><a class="code" href="structPlaylistContainer.html#a5f4d3dd04198764f4cf6f33a604b1f0f">plc_read</a> == NULL) <a name="l00299"></a>00299 <span class="keywordflow">return</span> FALSE; <a name="l00300"></a>00300 <a name="l00301"></a>00301 last = <a class="code" href="playlist-new_8c.html#a32abcfcf28e68da7c91b21db688e85f3">playlist_get_active</a> (); <a name="l00302"></a>00302 <a class="code" href="playlist-new_8c.html#af34d9eaa4d82c7878e86c8db6e69c7d7">playlist_set_active</a> (playlist); <a name="l00303"></a>00303 container-><a class="code" href="structPlaylistContainer.html#a5f4d3dd04198764f4cf6f33a604b1f0f">plc_read</a> (filename, at); <a name="l00304"></a>00304 <a class="code" href="playlist-new_8c.html#af34d9eaa4d82c7878e86c8db6e69c7d7">playlist_set_active</a> (last); <a name="l00305"></a>00305 <span class="keywordflow">return</span> TRUE; <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <a name="l00308"></a><a class="code" href="playlist-utils_8c.html#ab9c0f1427f5f2ffe844e91e1df32665a">00308</a> <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a> <a class="code" href="playlist-utils_8c.html#ab9c0f1427f5f2ffe844e91e1df32665a">playlist_save</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>, <span class="keyword">const</span> gchar * <a class="code" href="misc-api_8h.html#a820d8643bcfa9e2641dd6377f804de20">filename</a>) <a name="l00309"></a>00309 { <a name="l00310"></a>00310 <span class="keyword">const</span> gchar * period = strrchr (filename, <span class="charliteral">'.'</span>); <a name="l00311"></a>00311 <a class="code" href="structPlaylistContainer.html">PlaylistContainer</a> * container; <a name="l00312"></a>00312 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> last; <a name="l00313"></a>00313 <a name="l00314"></a>00314 <span class="keywordflow">if</span> (period == NULL) <a name="l00315"></a>00315 <span class="keywordflow">return</span> FALSE; <a name="l00316"></a>00316 <a name="l00317"></a>00317 container = <a class="code" href="playlist__container_8c.html#a8c10a45232f31e02e734d4023b8396fd">playlist_container_find</a> ((gchar *) period + 1); <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="keywordflow">if</span> (container == NULL || container-><a class="code" href="structPlaylistContainer.html#ad3891865bc54d406a58e4dbf5dc36361">plc_write</a> == NULL) <a name="l00320"></a>00320 <span class="keywordflow">return</span> FALSE; <a name="l00321"></a>00321 <a name="l00322"></a>00322 last = <a class="code" href="playlist-new_8c.html#a32abcfcf28e68da7c91b21db688e85f3">playlist_get_active</a> (); <a name="l00323"></a>00323 <a class="code" href="playlist-new_8c.html#af34d9eaa4d82c7878e86c8db6e69c7d7">playlist_set_active</a> (playlist); <a name="l00324"></a>00324 container-><a class="code" href="structPlaylistContainer.html#ad3891865bc54d406a58e4dbf5dc36361">plc_write</a> (filename, 0); <a name="l00325"></a>00325 <a class="code" href="playlist-new_8c.html#af34d9eaa4d82c7878e86c8db6e69c7d7">playlist_set_active</a> (last); <a name="l00326"></a>00326 <span class="keywordflow">return</span> TRUE; <a name="l00327"></a>00327 } <a name="l00328"></a>00328 <a name="l00329"></a>00329 <span class="comment">/* The algorithm is a bit quirky for historical reasons. -jlindgren */</span> <a name="l00330"></a><a class="code" href="playlist-utils_8c.html#a8187170f8c3e498817909947c57a6f5a">00330</a> <span class="keyword">static</span> gchar * <a class="code" href="playlist-utils_8c.html#a8187170f8c3e498817909947c57a6f5a">make_playlist_path</a> (<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="structplaylist.html">playlist</a>) <a name="l00331"></a>00331 { <a name="l00332"></a>00332 <span class="keywordflow">if</span> (! playlist) <a name="l00333"></a>00333 <span class="keywordflow">return</span> g_strdup (<a class="code" href="main_8c.html#a3712c2260dd091b528739d8e96ecf052">aud_paths</a>[<a class="code" href="main_8h.html#ab04a0655cd1e3bcac5e8f48c18df1a57ad8da550d335c4cdedfe1e09035e07a5f">BMP_PATH_PLAYLIST_FILE</a>]); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordflow">return</span> g_strdup_printf (<span class="stringliteral">"%s/playlist_%02d.xspf"</span>, <a name="l00336"></a>00336 <a class="code" href="main_8c.html#a3712c2260dd091b528739d8e96ecf052">aud_paths</a>[<a class="code" href="main_8h.html#ab04a0655cd1e3bcac5e8f48c18df1a57a7c3216234deac2d5687e6f428d7c61f8">BMP_PATH_PLAYLISTS_DIR</a>], 1 + playlist); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a><a class="code" href="playlist-utils_8c.html#a890096289752a4db38ee1b34b5fa73fb">00339</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#a890096289752a4db38ee1b34b5fa73fb">load_playlists</a> (<span class="keywordtype">void</span>) <a name="l00340"></a>00340 { <a name="l00341"></a>00341 <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a> done = FALSE; <a name="l00342"></a>00342 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="misc-api_8h.html#ac0c64a48f21e0d91f7340acdb9cc6409">count</a>; <a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="keywordflow">for</span> (count = 0; ! done; count ++) <a name="l00345"></a>00345 { <a name="l00346"></a>00346 gchar * <a class="code" href="plugins-api_8h.html#aed23534511ec9dec0630ca4854c4552b">path</a> = <a class="code" href="playlist-utils_8c.html#a8187170f8c3e498817909947c57a6f5a">make_playlist_path</a> (count); <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="keywordflow">if</span> (g_file_test (path, G_FILE_TEST_EXISTS)) <a name="l00349"></a>00349 { <a name="l00350"></a>00350 gchar * uri = <a class="code" href="audstrings_8c.html#acec0c761485a85a3c39807b72b1ab5c9">filename_to_uri</a> (path); <a name="l00351"></a>00351 <a name="l00352"></a>00352 <span class="keywordflow">if</span> (count) <a name="l00353"></a>00353 <a class="code" href="playlist-new_8c.html#aafa0be01562188eeaa58139dba11a48f">playlist_insert</a> (count); <a name="l00354"></a>00354 <a name="l00355"></a>00355 <a class="code" href="playlist-api_8h.html#a10834e1b204827d4ea161ff4ee83ff77">playlist_insert_playlist</a> (count, 0, uri); <a name="l00356"></a>00356 g_free (uri); <a name="l00357"></a>00357 } <a name="l00358"></a>00358 <span class="keywordflow">else</span> <a name="l00359"></a>00359 done = TRUE; <a name="l00360"></a>00360 <a name="l00361"></a>00361 g_free (path); <a name="l00362"></a>00362 } <a name="l00363"></a>00363 <a name="l00364"></a>00364 <a class="code" href="playlist-new_8c.html#af9ca285c9583c9311b47fa7bb2383626">playlist_load_state</a> (); <a name="l00365"></a>00365 } <a name="l00366"></a>00366 <a name="l00367"></a><a class="code" href="playlist-utils_8c.html#a484912e1818dc0cbacc7d5f73672e9db">00367</a> <span class="keywordtype">void</span> <a class="code" href="playlist-utils_8c.html#a484912e1818dc0cbacc7d5f73672e9db">save_playlists</a> (<span class="keywordtype">void</span>) <a name="l00368"></a>00368 { <a name="l00369"></a>00369 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="playlist-new_8c.html#ae9bb6d03717891be4859bb35adcea142">playlists</a> = <a class="code" href="playlist-new_8c.html#afe6f4255fa895b81dfc74ed09440a954">playlist_count</a> (); <a name="l00370"></a>00370 <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a> done = FALSE; <a name="l00371"></a>00371 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> <a class="code" href="misc-api_8h.html#ac0c64a48f21e0d91f7340acdb9cc6409">count</a>; <a name="l00372"></a>00372 <a name="l00373"></a>00373 <span class="keywordflow">for</span> (count = 0; ! done; count ++) <a name="l00374"></a>00374 { <a name="l00375"></a>00375 gchar * <a class="code" href="plugins-api_8h.html#aed23534511ec9dec0630ca4854c4552b">path</a> = <a class="code" href="playlist-utils_8c.html#a8187170f8c3e498817909947c57a6f5a">make_playlist_path</a> (count); <a name="l00376"></a>00376 <a name="l00377"></a>00377 <span class="keywordflow">if</span> (count < playlists) <a name="l00378"></a>00378 { <a name="l00379"></a>00379 gchar * uri = <a class="code" href="audstrings_8c.html#acec0c761485a85a3c39807b72b1ab5c9">filename_to_uri</a> (path); <a name="l00380"></a>00380 <a name="l00381"></a>00381 <a class="code" href="playlist-utils_8c.html#ab9c0f1427f5f2ffe844e91e1df32665a">playlist_save</a> (count, uri); <a name="l00382"></a>00382 g_free (uri); <a name="l00383"></a>00383 } <a name="l00384"></a>00384 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (g_file_test (path, G_FILE_TEST_EXISTS)) <a name="l00385"></a>00385 <span class="keyword">remove</span> (<a class="code" href="plugins-api_8h.html#aed23534511ec9dec0630ca4854c4552b">path</a>); <a name="l00386"></a>00386 <span class="keywordflow">else</span> <a name="l00387"></a>00387 done = TRUE; <a name="l00388"></a>00388 <a name="l00389"></a>00389 g_free (path); <a name="l00390"></a>00390 } <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a class="code" href="playlist-new_8c.html#aa028044c2951163d333f246f5b146623">playlist_save_state</a> (); <a name="l00393"></a>00393 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Sun Apr 17 2011 for Audacious by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address> </body> </html>