Browse files

initial import

  • Loading branch information...
0 parents commit e5da3ecdb68f293366922b83ba350065d22d59d2 @rodnaph committed Oct 20, 2010
Showing with 24,080 additions and 0 deletions.
  1. +57 −0 HACKING
  2. +340 −0 LICENSE
  3. +4 −0 README
  4. +49 −0 TODO
  5. +444 −0 build.xml
  6. +37 −0 dist-files/README.txt
  7. BIN dist-files/Run Sockso.lnk
  8. +4 −0 dist-files/linux.sh
  9. +8 −0 dist-files/log/default.properties
  10. +16 −0 dist-files/log/dev.properties
  11. +9 −0 dist-files/log/test.properties
  12. +54 −0 dist-files/scripts/init.d/sockso
  13. +8 −0 dist-files/scripts/tools/bash/extractResources.sh
  14. +2 −0 dist-files/scripts/tools/bash/packResources.sh
  15. +6 −0 dist-files/scripts/tools/windows/extractResources.bat
  16. +3 −0 dist-files/scripts/unix/aactag.sh
  17. +3 −0 dist-files/scripts/unix/faadToLame.sh
  18. +3 −0 dist-files/scripts/unix/ffmpegToLame.sh
  19. +2 −0 dist-files/scripts/unix/flacToLame.sh
  20. +2 −0 dist-files/scripts/unix/oggDecToLame.sh
  21. +3 −0 dist-files/scripts/windows/ffmpegToLame.bat
  22. +3 −0 dist-files/scripts/windows/flacToLame.bat
  23. +3 −0 dist-files/scripts/windows/oggDecToLame.bat
  24. BIN dist-files/ssl/keystore
  25. +2 −0 dist-files/windows.bat
  26. BIN lib-dev/JsTestDriver-1.2.jar
  27. BIN lib-dev/ant-googlecode-0.0.1.jar
  28. BIN lib-dev/ant-testability-explorer-1.3.0-r275.jar
  29. BIN lib-dev/easymock-2.4.jar
  30. BIN lib-dev/jamon-anttask-2.3.1.jar
  31. BIN lib-dev/jamon-api-2.3.0.jar
  32. BIN lib-dev/jamon-processor-2.3.2.jar
  33. BIN lib-dev/jarbundler-2.1.0.jar
  34. BIN lib-dev/junit.jar
  35. BIN lib-dev/testability-explorer-1.2.0-r85.jar
  36. BIN lib-opt/activation.jar
  37. BIN lib-opt/mailapi.jar
  38. BIN lib-opt/mysql-connector-java-5.1.6-bin.jar
  39. BIN lib-opt/sbbi-upnplib-1.0.4.jar
  40. BIN lib-opt/smtp.jar
  41. BIN lib-opt/sqlitejdbc-v053.jar
  42. BIN lib/BrowserLauncher2-1_3.jar
  43. BIN lib/forms-1.2.1.jar
  44. BIN lib/hsqldb-1.8.jar
  45. BIN lib/id3v2.jar
  46. BIN lib/jamon-runtime-2.3.1.jar
  47. BIN lib/jdic.jar
  48. BIN lib/jflac-1.3.jar
  49. BIN lib/jogg-0.0.7.jar
  50. BIN lib/jopt-simple-3.1.jar
  51. BIN lib/jorbis-0.0.15.jar
  52. BIN lib/linux/jdic_stub.jar
  53. BIN lib/linux/x86/libtray.so
  54. BIN lib/log4j-1.2.15.jar
  55. BIN lib/looks-2.2.2.jar
  56. BIN lib/systray4j.dll
  57. BIN lib/systray4j.jar
  58. +6 −0 resources/ResourcesAnchor.java
  59. BIN resources/htdocs/flash/flexPlayer/big_xmlPlayer.swf
  60. +8 −0 resources/htdocs/flash/flexPlayer/swfobject.js
  61. BIN resources/htdocs/flash/jwplayer-4.2/player.swf
  62. BIN resources/htdocs/flash/xspf_player.swf
  63. BIN resources/htdocs/flash/xspf_player_slim.swf
  64. +510 −0 resources/htdocs/js/folders.js
  65. +541 −0 resources/htdocs/js/imageflow.js
  66. +89 −0 resources/htdocs/js/init.js
  67. +152 −0 resources/htdocs/js/jquery.corner.js
  68. +4,241 −0 resources/htdocs/js/jquery.js
  69. +110 −0 resources/htdocs/js/share.js
  70. +30 −0 resources/htdocs/js/sockso.Base.js
  71. +60 −0 resources/htdocs/js/sockso.Hashtable.js
  72. +364 −0 resources/htdocs/js/sockso.JSPlayer.js
  73. +48 −0 resources/htdocs/js/sockso.Locale.js
  74. +166 −0 resources/htdocs/js/sockso.Player.js
  75. +461 −0 resources/htdocs/js/sockso.Playlist.js
  76. +13 −0 resources/htdocs/js/sockso.Properties.js
  77. +154 −0 resources/htdocs/js/sockso.RelatedArtists.js
  78. +140 −0 resources/htdocs/js/sockso.SearchBox.js
  79. +73 −0 resources/htdocs/js/sockso.Session.js
  80. +65 −0 resources/htdocs/js/sockso.UploadForm.js
  81. +36 −0 resources/htdocs/js/sockso.User.js
  82. +144 −0 resources/htdocs/js/sockso.js
  83. +8 −0 resources/htdocs/js/swfobject.js
  84. +8 −0 resources/htdocs/skins/bold/README.txt
  85. +308 −0 resources/htdocs/skins/bold/css/default.css
  86. BIN resources/htdocs/skins/bold/images/add.png
  87. BIN resources/htdocs/skins/bold/images/album.png
  88. BIN resources/htdocs/skins/bold/images/artist.png
  89. BIN resources/htdocs/skins/bold/images/audioscrobbler.png
  90. BIN resources/htdocs/skins/bold/images/background.png
  91. BIN resources/htdocs/skins/bold/images/clear.png
  92. BIN resources/htdocs/skins/bold/images/download.png
  93. BIN resources/htdocs/skins/bold/images/embed.png
  94. BIN resources/htdocs/skins/bold/images/favicon.ico
  95. BIN resources/htdocs/skins/bold/images/folder.png
  96. BIN resources/htdocs/skins/bold/images/folder_open.png
  97. BIN resources/htdocs/skins/bold/images/header-bg.png
  98. BIN resources/htdocs/skins/bold/images/imageflow/hide.png
  99. BIN resources/htdocs/skins/bold/images/imageflow/show.png
  100. BIN resources/htdocs/skins/bold/images/img01.gif
  101. BIN resources/htdocs/skins/bold/images/img02.gif
  102. BIN resources/htdocs/skins/bold/images/img04.gif
  103. BIN resources/htdocs/skins/bold/images/img05.gif
  104. BIN resources/htdocs/skins/bold/images/img06.gif
  105. BIN resources/htdocs/skins/bold/images/img07.gif
  106. BIN resources/htdocs/skins/bold/images/img08.gif
  107. BIN resources/htdocs/skins/bold/images/img09.gif
  108. BIN resources/htdocs/skins/bold/images/img11.gif
  109. BIN resources/htdocs/skins/bold/images/img12.gif
  110. BIN resources/htdocs/skins/bold/images/loading.gif
  111. BIN resources/htdocs/skins/bold/images/logo.png
  112. BIN resources/htdocs/skins/bold/images/logout.png
  113. BIN resources/htdocs/skins/bold/images/play.png
  114. BIN resources/htdocs/skins/bold/images/playlist.png
  115. BIN resources/htdocs/skins/bold/images/profile.png
  116. BIN resources/htdocs/skins/bold/images/random_play.png
  117. BIN resources/htdocs/skins/bold/images/remove.png
  118. BIN resources/htdocs/skins/bold/images/save.png
  119. BIN resources/htdocs/skins/bold/images/search.png
  120. BIN resources/htdocs/skins/bold/images/share.png
  121. BIN resources/htdocs/skins/bold/images/slider.png
  122. BIN resources/htdocs/skins/bold/images/spacer.gif
  123. BIN resources/htdocs/skins/bold/images/streamfinder.png
  124. BIN resources/htdocs/skins/bold/images/track.png
  125. BIN resources/htdocs/skins/bold/images/upload.png
  126. +695 −0 resources/htdocs/skins/original/css/default.css
  127. BIN resources/htdocs/skins/original/images/add.png
  128. BIN resources/htdocs/skins/original/images/album.png
  129. BIN resources/htdocs/skins/original/images/artist.png
  130. BIN resources/htdocs/skins/original/images/audioscrobbler.png
  131. BIN resources/htdocs/skins/original/images/clear.png
  132. BIN resources/htdocs/skins/original/images/download.png
  133. BIN resources/htdocs/skins/original/images/embed.png
  134. BIN resources/htdocs/skins/original/images/favicon.ico
  135. BIN resources/htdocs/skins/original/images/folder.png
  136. BIN resources/htdocs/skins/original/images/folder_open.png
  137. BIN resources/htdocs/skins/original/images/imageflow/hide.png
  138. BIN resources/htdocs/skins/original/images/imageflow/show.png
  139. BIN resources/htdocs/skins/original/images/img01.gif
  140. BIN resources/htdocs/skins/original/images/img02.gif
  141. BIN resources/htdocs/skins/original/images/img04.gif
  142. BIN resources/htdocs/skins/original/images/img05.gif
  143. BIN resources/htdocs/skins/original/images/img06.gif
  144. BIN resources/htdocs/skins/original/images/img07.gif
  145. BIN resources/htdocs/skins/original/images/img08.gif
  146. BIN resources/htdocs/skins/original/images/img09.gif
  147. BIN resources/htdocs/skins/original/images/img11.gif
  148. BIN resources/htdocs/skins/original/images/img12.gif
  149. BIN resources/htdocs/skins/original/images/jsplayer/next.png
  150. BIN resources/htdocs/skins/original/images/jsplayer/prev.png
  151. BIN resources/htdocs/skins/original/images/jsplayer/stop.png
  152. BIN resources/htdocs/skins/original/images/loading.gif
  153. BIN resources/htdocs/skins/original/images/logo.png
  154. BIN resources/htdocs/skins/original/images/logout.png
  155. BIN resources/htdocs/skins/original/images/play.png
  156. BIN resources/htdocs/skins/original/images/playlist.png
  157. BIN resources/htdocs/skins/original/images/profile.png
  158. BIN resources/htdocs/skins/original/images/random_play.png
  159. BIN resources/htdocs/skins/original/images/remove.png
  160. BIN resources/htdocs/skins/original/images/save.png
  161. BIN resources/htdocs/skins/original/images/search.png
  162. BIN resources/htdocs/skins/original/images/share.png
  163. BIN resources/htdocs/skins/original/images/slider.png
  164. BIN resources/htdocs/skins/original/images/spacer.gif
  165. BIN resources/htdocs/skins/original/images/streamfinder.png
  166. BIN resources/htdocs/skins/original/images/track.png
  167. BIN resources/htdocs/skins/original/images/upload.png
  168. BIN resources/icons/16x16/add.png
  169. BIN resources/icons/16x16/album.png
  170. BIN resources/icons/16x16/artist.png
  171. BIN resources/icons/16x16/clear.png
  172. BIN resources/icons/16x16/collection.png
  173. BIN resources/icons/16x16/delete.png
  174. BIN resources/icons/16x16/export.png
  175. BIN resources/icons/16x16/import.png
  176. BIN resources/icons/16x16/options.png
  177. BIN resources/icons/16x16/playlists.png
  178. BIN resources/icons/16x16/refresh.png
  179. BIN resources/icons/16x16/remove.png
  180. BIN resources/icons/16x16/rescan.png
  181. BIN resources/icons/16x16/save.png
  182. BIN resources/icons/16x16/sockso.png
  183. BIN resources/icons/16x16/tracks.png
  184. BIN resources/icons/22x22/cancel.png
  185. BIN resources/icons/22x22/collection.png
  186. BIN resources/icons/22x22/console.png
  187. BIN resources/icons/22x22/encoders.png
  188. BIN resources/icons/22x22/execute.png
  189. BIN resources/icons/22x22/exit.png
  190. BIN resources/icons/22x22/general.png
  191. BIN resources/icons/22x22/hide.png
  192. BIN resources/icons/22x22/music.png
  193. BIN resources/icons/22x22/ok.png
  194. BIN resources/icons/22x22/options.png
  195. BIN resources/icons/22x22/port_forward.png
  196. BIN resources/icons/22x22/refresh.png
  197. BIN resources/icons/22x22/reports.png
  198. BIN resources/icons/22x22/save.png
  199. BIN resources/icons/22x22/statistics.png
  200. BIN resources/icons/22x22/users.png
  201. BIN resources/icons/sockso.icns
  202. BIN resources/icons/tray.ico
  203. BIN resources/icons/tray.png
  204. BIN resources/images/splash.png
  205. +285 −0 resources/locales/sockso.de.txt
  206. +301 −0 resources/locales/sockso.en.txt
  207. +226 −0 resources/locales/sockso.es.txt
  208. +282 −0 resources/locales/sockso.fr.txt
  209. +236 −0 resources/locales/sockso.it.txt
  210. +248 −0 resources/locales/sockso.nb.txt
  211. +228 −0 resources/locales/sockso.nl.txt
  212. +53 −0 scripts/check-locales.php
  213. +20 −0 scripts/create-locale-index.php
  214. +71 −0 scripts/create-locale-javascript.php
  215. +736 −0 scripts/lib/php/JavaScriptPacker.class.php
  216. +92 −0 scripts/pack-javascript.php
  217. +25 −0 sockso.properties-sample
  218. +583 −0 src/com/pugh/sockso/Console.java
  219. +139 −0 src/com/pugh/sockso/Constants.java
  220. +161 −0 src/com/pugh/sockso/DBProperties.java
  221. +660 −0 src/com/pugh/sockso/Main.java
  222. +27 −0 src/com/pugh/sockso/Manager.java
  223. +117 −0 src/com/pugh/sockso/Options.java
  224. +162 −0 src/com/pugh/sockso/Properties.java
  225. +23 −0 src/com/pugh/sockso/PropertiesListener.java
  226. +19 −0 src/com/pugh/sockso/Shutdown.java
  227. +264 −0 src/com/pugh/sockso/StringProperties.java
  228. +97 −0 src/com/pugh/sockso/UPNP.java
  229. +600 −0 src/com/pugh/sockso/Utils.java
  230. +149 −0 src/com/pugh/sockso/Validater.java
  231. +25 −0 src/com/pugh/sockso/ValidationException.java
  232. +146 −0 src/com/pugh/sockso/VersionChecker.java
  233. +20 −0 src/com/pugh/sockso/auth/Authenticator.java
  234. +70 −0 src/com/pugh/sockso/auth/DBAuthenticator.java
  235. +12 −0 src/com/pugh/sockso/db/AbstractDatabase.java
  236. +107 −0 src/com/pugh/sockso/db/DBExporter.java
  237. +103 −0 src/com/pugh/sockso/db/Database.java
  238. +21 −0 src/com/pugh/sockso/db/DatabaseConnectionException.java
  239. +706 −0 src/com/pugh/sockso/db/HSQLDatabase.java
  240. +296 −0 src/com/pugh/sockso/db/JDBCDatabase.java
  241. +343 −0 src/com/pugh/sockso/db/MySQLDatabase.java
  242. +225 −0 src/com/pugh/sockso/db/SQLiteDatabase.java
  243. +27 −0 src/com/pugh/sockso/events/LatestVersionEvent.java
  244. +15 −0 src/com/pugh/sockso/events/LatestVersionListener.java
  245. +507 −0 src/com/pugh/sockso/gui/AppFrame.java
  246. +312 −0 src/com/pugh/sockso/gui/CollectionPanel.java
  247. +202 −0 src/com/pugh/sockso/gui/ConsoleFrame.java
  248. +234 −0 src/com/pugh/sockso/gui/CreateUserDialog.java
  249. +265 −0 src/com/pugh/sockso/gui/EncoderPanel.java
  250. +43 −0 src/com/pugh/sockso/gui/EncodersPanel.java
  251. +224 −0 src/com/pugh/sockso/gui/ForwardPortDialog.java
  252. +375 −0 src/com/pugh/sockso/gui/GeneralPanel.java
  253. +83 −0 src/com/pugh/sockso/gui/MusicList.java
  254. +186 −0 src/com/pugh/sockso/gui/MusicPanel.java
  255. +363 −0 src/com/pugh/sockso/gui/MusicTree.java
  256. +96 −0 src/com/pugh/sockso/gui/MusicTreeCellRenderer.java
  257. +22 −0 src/com/pugh/sockso/gui/MusicTreeNode.java
  258. +69 −0 src/com/pugh/sockso/gui/PlaylistFileFilter.java
  259. +76 −0 src/com/pugh/sockso/gui/PlaylistManager.java
  260. +408 −0 src/com/pugh/sockso/gui/PlaylistPanel.java
  261. +175 −0 src/com/pugh/sockso/gui/Playlists.java
  262. +19 −0 src/com/pugh/sockso/gui/SitePlaylists.java
  263. +60 −0 src/com/pugh/sockso/gui/Splash.java
  264. +135 −0 src/com/pugh/sockso/gui/TrayIcon.java
  265. +19 −0 src/com/pugh/sockso/gui/UserPlaylists.java
  266. +267 −0 src/com/pugh/sockso/gui/UsersPanel.java
  267. +200 −0 src/com/pugh/sockso/gui/action/ImportPlaylist.java
  268. +36 −0 src/com/pugh/sockso/gui/controls/BooleanOptionField.java
  269. +80 −0 src/com/pugh/sockso/gui/controls/ComboOptionField.java
  270. +124 −0 src/com/pugh/sockso/gui/controls/DirectoryOptionField.java
  271. +35 −0 src/com/pugh/sockso/gui/controls/NumberOptionField.java
  272. +71 −0 src/com/pugh/sockso/gui/controls/TextOptionField.java
  273. +81 −0 src/com/pugh/sockso/gui/controls/UploadDirectoryOptionField.java
  274. +81 −0 src/com/pugh/sockso/mail/Mailer.java
  275. +46 −0 src/com/pugh/sockso/music/Album.java
  276. +48 −0 src/com/pugh/sockso/music/Artist.java
  277. +34 −0 src/com/pugh/sockso/music/Collection.java
  278. +108 −0 src/com/pugh/sockso/music/CollectionManager.java
  279. +28 −0 src/com/pugh/sockso/music/CollectionManagerListener.java
  280. +1,080 −0 src/com/pugh/sockso/music/DBCollectionManager.java
  281. +57 −0 src/com/pugh/sockso/music/MusicItem.java
  282. +90 −0 src/com/pugh/sockso/music/MusicSearch.java
  283. +71 −0 src/com/pugh/sockso/music/Playlist.java
  284. +258 −0 src/com/pugh/sockso/music/Track.java
Sorry, we could not display the entire diff because too many files (710) changed.
57 HACKING
@@ -0,0 +1,57 @@
+
+HACKING
+=======
+
+This file contains some basic information on how to set up a Sockso development
+environment. So basically, what you'll need...
+
+Essentials
+----------
+
+1) JDK 1.5+ (http://java.sun.com)
+Sockso (and some of it's libraries) require atleast JDK 1.5. The official
+releases are compiled with this.
+
+2) Apache Ant (http://ant.apache.org)
+All of the compiling, running, packaging and testing of Sockso is done with Ant,
+so it's an essential really (unless ur mental and want to do things on your own)
+
+3) PHP 4+ (http://www.php.net)
+Some of the build process uses PHP scripts to do some stuff, so you'll need this
+installed to or you won't get far (again, unless ur mental)
+
+4) Bazaar (http://bazaar-vcs.org)
+You should already have this is you're reading this file, but just incase you
+got this code some other way, go get Bazaar right now.
+
+Optional
+--------
+
+1) IDE
+Some people love them, others (mentalists) hate them, but I'd reccomend using
+Netbeans (http://netbeans.org). There are lots of others to but I find this
+one pretty good.
+
+Configuration
+-------------
+
+First make a copy of the file "sockso.properties-sample" and rename it to just
+"sockso.properties". Then, as long as you're using Ant, pretty much everything
+should be ready to go. If you're using an IDE then you'll probably need to
+point it to all the Jar files in the "lib", "lib-dev" and "lib-opt" directories or it'll
+complain about all the imports. Otherwise try some of these useful Ant tasks...
+
+1) run - Builds a working Sockso distribution in the "dist" folder, and runs it.
+2) package - Makes nice packages for Sockso.
+3) test-all - Run all the unit tests
+4) test-single -Dclass=CLASSNAME - Run a specific class's tests
+
+Further Help
+------------
+
+If any of this doesn't make sense, or you're stuck, or you just feel like it,
+come to the forums and talk about Sockso at:
+
+http://forums.pu-gh.com
+
+END.
340 LICENSE
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
+
4 README
@@ -0,0 +1,4 @@
+See the Sockso website for information about developing Sockso.
+
+http://sockso.pu-gh.com
+
49 TODO
@@ -0,0 +1,49 @@
+
+1 - BUGS
+--------
+
+* lame ignoring bitrate
+* scrobble log - dates of songs played are wrong?
+* safari gzip bug
+* to specify ssl keystore password need to pass in via arg,
+ this can be stolen, chnage to read in from stdin
+* too much CPU usage when streaming
+* ssl not working
+* port field needs type checking
+
+2 - FEATURES
+------------
+
+* complete streamfinder impl
+* user comments
+* browse A-Z by artist/album/genre/etc...
+* windows installer
+* cover manager
+* UPNP server
+* DAAP server
+* provide album/artist information from wikipedia
+* use other artist information as andreones suggestion
+* provide different authentication methods?
+* turn off tag browsing
+* make playlists editable in web interface
+* allow preserving of folder structure on disk when downloading
+* indexing and streaming videos
+* more advanced user controls (what they can access, etc...)
+* better user profiles (like changing own password, stats, etc...)
+* store genre info for tracks, then in user prefs allow selecting
+ genres to limit on when viewing music.
+* postgres support
+* editing playlist in flash players dynamically
+* tag editing (maybe on scan alert when no tag?)
+* bandwidth limiting for downloads
+* support for AAC files
+* remote administration, or admin when running as daemon
+* rescan command line argument (prob mysql only...)
+* allow uploading zip files with multiple tracks
+
+3 - MANUAL
+----------
+
+* improve "artwork" page
+* add page about the "API"
+
444 build.xml
@@ -0,0 +1,444 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="sockso" default="run" basedir=".">
+
+ <description>Builds, runs and packages Sockso</description>
+
+ <!--
+ #############
+ INIT/PROPS
+ #############
+ -->
+
+ <property file="sockso.properties" />
+
+ <property name="sockso.version" value="1.2.4" />
+
+ <property name="dir.build" value="build/app" />
+ <property name="dir.build.test" value="build/test" />
+ <property name="dir.dist" value="dist" />
+ <property name="dir.docs" value="docs" />
+ <property name="dir.docs.junit" value="${dir.docs}/junit" />
+ <property name="dir.src" value="src" />
+ <property name="dir.src.test" value="test" />
+ <property name="dir.lib" value="lib" />
+ <property name="dir.lib-dev" value="lib-dev" />
+ <property name="dir.lib-opt" value="lib-opt" />
+ <property name="dir.temp" value="ant-temp-dir" />
+ <property name="dir.resources" value="resources" />
+ <property name="dir.packages" value="packages" />
+ <property name="dir.scripts" value="scripts" />
+ <property name="dir.javadocs" value="${dir.docs}/javadocs" />
+ <property name="dir.www" value="www" />
+
+ <!-- set classpaths for jars -->
+ <fileset id="sockso.jars" dir=".">
+ <include name="${dir.lib}/*.jar" />
+ </fileset>
+ <pathconvert pathsep=":" property="app.classpath" refid="sockso.jars">
+ <map from="${basedir}/" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar.classpath" refid="sockso.jars">
+ <map from="${basedir}/" to=" "/>
+ </pathconvert>
+
+ <!-- classpath for dev jars -->
+ <fileset id="sockso-dev.jars" dir=".">
+ <include name="${dir.lib-dev}/*.jar" />
+ </fileset>
+ <pathconvert pathsep=":" property="dev.classpath" refid="sockso-dev.jars">
+ <map from="${basedir}/" to=""/>
+ </pathconvert>
+
+ <!-- classpath for optional jars -->
+ <fileset id="sockso-opt.jars" dir=".">
+ <include name="${dir.lib-opt}/*.jar" />
+ </fileset>
+ <pathconvert pathsep=":" property="opt.classpath" refid="sockso-opt.jars">
+ <map from="${basedir}/" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar-opt.classpath" refid="sockso-opt.jars">
+ <map from="${basedir}/" to=" "/>
+ </pathconvert>
+
+ <property name="junit.classpath" value="${dir.build}:${dir.build.test}:${app.classpath}:${dev.classpath}:${opt.classpath}" />
+
+ <taskdef name="jamon"
+ classname="org.jamon.ant.JamonTask"
+ classpath="${dir.lib}/jamon-runtime-2.3.1.jar:${dir.lib-dev}/jamon-api-2.3.0.jar:${dir.lib-dev}/jamon-processor-2.3.2.jar:${dir.lib-dev}/jamon-anttask-2.3.1.jar" />
+
+ <taskdef name="jarbundler"
+ classname="net.sourceforge.jarbundler.JarBundler"
+ classpath="${dir.lib-dev}/jarbundler-2.1.0.jar" />
+
+ <taskdef name="testability"
+ classname="com.google.ant.TestabilityTask"
+ classpath="${dev.classpath}" />
+
+ <target name="init">
+ <mkdir dir="${dir.dist}" />
+ <mkdir dir="${dir.build}" />
+ <mkdir dir="${dir.build.test}" />
+ <mkdir dir="${dir.packages}" />
+ </target>
+
+ <!--
+ ################
+ COMPILE/BUILD
+ ################
+ -->
+
+ <!-- compile jamon source files to java classes -->
+ <target name="compile-templates" depends="init">
+ <delete dir="${dir.src}/com/pugh/mymusic/tmpl" />
+ <jamon destdir="${dir.src}" srcdir="templates" />
+ </target>
+
+ <!-- creates a file with some properties info -->
+ <target name="create-properties">
+ <!-- write app properties file -->
+ <echo file="src/com/pugh/sockso/Sockso.java">
+package com.pugh.sockso;
+public class Sockso {
+ public static final String VERSION = "${sockso.version}";
+}
+ </echo>
+ </target>
+
+ <!-- compiles the project to build/ -->
+ <target name="compile" depends="create-properties,compile-templates">
+ <!-- then do compile -->
+ <javac srcdir="${dir.src}"
+ destdir="${dir.build}"
+ classpath="${app.classpath}:${opt.classpath}"
+ target="1.5"
+ debug="${debug}">
+ <compilerarg value="-Xlint:unchecked" />
+ <compilerarg value="-Xlint:deprecation" />
+ </javac>
+ </target>
+
+ <!-- builds resources -->
+ <target name="resources" depends="init">
+ <!-- compile stub file -->
+ <javac srcdir="${dir.resources}" destdir="${dir.resources}" />
+ <!-- remove locale javascript files, we don't want to pack them -->
+ <delete>
+ <fileset dir="${dir.resources}/htdocs/js" includes="locale*.js" />
+ </delete>
+ <!-- pack javascript -->
+ <exec executable="${php.exe}">
+ <arg value="${dir.scripts}/pack-javascript.php" />
+ <arg value="${sockso.version}" />
+ </exec>
+ <!-- create locale javascript files -->
+ <exec executable="${php.exe}">
+ <arg value="${dir.scripts}/create-locale-javascript.php" />
+ <arg value="${sockso.version}" />
+ </exec>
+ <!-- create locale index file -->
+ <exec executable="${php.exe}">
+ <arg value="${dir.scripts}/create-locale-index.php" />
+ <arg value="${sockso.version}" />
+ </exec>
+ <!-- build jar -->
+ <jar basedir="${dir.resources}" destfile="${dir.dist}/resources.jar">
+ <fileset dir="${dir.resources}">
+ <exclude name="**/*.java" />
+ <!-- TODO: exclude all javascript but the packed javascript file -->
+ </fileset>
+ </jar>
+ <!-- copy files to dist dir -->
+ <copy todir="${dir.dist}/resources">
+ <fileset dir="resources" />
+ </copy>
+ </target>
+
+ <!-- puts the dist together -->
+ <target name="dist" depends="jars">
+ <copy todir="${dir.dist}">
+ <fileset dir="dist-files" />
+ </copy>
+ <copy todir="${dir.dist}/lib">
+ <fileset dir="${dir.lib}" />
+ </copy>
+ <!-- windows tray icon -->
+ <mkdir dir="${dir.dist}/icons" />
+ <copy file="${dir.resources}/icons/tray.ico" todir="${dir.dist}/icons" />
+ </target>
+
+ <!-- creates all the main sockso jar files -->
+ <target name="jars" depends="jar,resources" />
+
+ <!-- cleans any compiles tests -->
+ <target name="clean-tests">
+ <delete dir="${dir.build.test}" />
+ </target>
+
+ <!-- cleans the dist build -->
+ <target name="clean" depends="clean-tests">
+ <delete dir="${dir.build}" />
+ <delete dir="${dir.dist}" />
+ <delete dir="${dir.src}/com/pugh/sockso/templates" />
+ <delete dir="${dir.packages}" />
+ </target>
+
+ <!-- build the main jar file -->
+ <target name="jar" depends="compile">
+ <jar file="${dir.dist}/sockso.jar" basedir="${dir.build}">
+ <include name="**/*.class" />
+ <manifest>
+ <attribute name="Built-By" value="${developer.name}" />
+ <attribute name="Main-class" value="com.pugh.sockso.Main" />
+ <attribute name="Class-Path" value="resources.jar ${jar.classpath} ${jar-opt.classpath}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <!--
+ #####################
+ DOCS/PACKAGING
+ #####################
+ -->
+
+ <target name="javadocs">
+ <javadoc sourcepath="${dir.src}" destdir="${dir.javadocs}" />
+ </target>
+
+ <!-- make packages from dist -->
+ <target name="package" depends="clean,dist,website">
+
+ <mkdir dir="${dir.temp}" />
+ <move file="${dir.dist}" tofile="${dir.temp}/sockso-${sockso.version}" />
+
+ <!-- OSX.
+ 1. create .app folder -->
+ <jarbundler dir="${dir.packages}"
+ name="sockso-${sockso.version}"
+ shortname="Sockso"
+ mainclass="com.pugh.sockso.Main"
+ icon="${dir.resources}/icons/sockso.icns"
+ version="${sockso.version}"
+ infostring="Sockso - Personal Music Server"
+ arguments="--resourcestype=jar"
+ jvmversion="1.5+">
+ <jarfileset dir="${dir.temp}">
+ <include name="**/*.jar" />
+ </jarfileset>
+ </jarbundler>
+ <!-- 2. create dmg's from .app folder -->
+ <exec executable="hdiutil">
+ <arg line="create -srcfolder ${dir.packages}/sockso-${sockso.version}.app ${dir.packages}/sockso-${sockso.version}.dmg"/>
+ </exec>
+ <copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-latest.dmg" />
+ <copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-dev.dmg" />
+ <!-- 3. remove .app folder -->
+ <delete dir="${dir.packages}/sockso-${sockso.version}.app" />
+
+ <!-- we need the resources.jar files for the mac bundle, but not other packages -->
+ <delete file="${dir.temp}/sockso-${sockso.version}/resources.jar" />
+ <delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.class" />
+ <delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.java" />
+
+ <!-- make standard packages -->
+ <zip destfile="${dir.packages}/sockso-dev.zip" basedir="${dir.temp}" />
+ <zip destfile="${dir.packages}/sockso-latest.zip" basedir="${dir.temp}" />
+ <zip destfile="${dir.packages}/sockso-${sockso.version}.zip" basedir="${dir.temp}" />
+
+ <!-- done, cleanup! -->
+ <move file="${dir.temp}/sockso-${sockso.version}" tofile="${dir.dist}" />
+ <delete dir="${dir.temp}" />
+
+ <!-- build optionals package -->
+ <zip destfile="${dir.packages}/sockso-optionals.zip" basedir="${dir.lib-opt}" />
+
+ </target>
+
+ <!-- updates the website with information like current version -->
+ <target name="website">
+ <echo file="www/application/views/version/latest.tpl">${sockso.version}</echo>
+ </target>
+
+ <!-- includes optional components into the distribution -->
+ <target name="optionals">
+ <copy todir="${dir.dist}/lib-opt">
+ <fileset dir="${dir.lib-opt}" />
+ </copy>
+ </target>
+
+ <!--
+ ##################
+ RUN/DEBUG
+ ##################
+ -->
+
+ <!-- runs the project -->
+ <target name="run" depends="dist,optionals">
+ <java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
+ <arg value="--logtype=${run.arg.logtype}" />
+ <arg value="--resourcestype=${run.arg.resourcestype}" />
+ <arg value="--dbtype=${run.arg.dbtype}" />
+ <arg value="--dbhost=${run.arg.dbhost}" />
+ <arg value="--dbuser=${run.arg.dbuser}" />
+ <arg value="--dbpass=${run.arg.dbpass}" />
+ <arg value="--dbname=${run.arg.dbname}" />
+ </java>
+ </target>
+
+ <!-- starts a project in debug mode -->
+ <target name="debug" depends="clean,dist,optionals" if="netbeans.home">
+ <java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
+ <arg value="--logtype=${run.arg.logtype}" />
+ <arg value="--resourcestype=${run.arg.resourcestype}" />
+ <arg value="--dbtype=${run.arg.dbtype}" />
+ <arg value="--dbhost=${run.arg.dbhost}" />
+ <arg value="--dbuser=${run.arg.dbuser}" />
+ <arg value="--dbpass=${run.arg.dbpass}" />
+ <arg value="--dbname=${run.arg.dbname}" />
+ <jvmarg value="-Xdebug" />
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n" />
+ </java>
+ </target>
+
+ <target name="profile" depends="dist,optionals" if="netbeans.home">
+ <nbprofiledirect>
+ </nbprofiledirect>
+ <java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
+ <arg value="--logtype=${run.arg.logtype}" />
+ <arg value="--resourcestype=${run.arg.resourcestype}" />
+ <arg value="--dbtype=${run.arg.dbtype}" />
+ <arg value="--dbhost=${run.arg.dbhost}" />
+ <arg value="--dbuser=${run.arg.dbuser}" />
+ <arg value="--dbpass=${run.arg.dbpass}" />
+ <arg value="--dbname=${run.arg.dbname}" />
+ <jvmarg value="${profiler.info.jvmargs.agent}" />
+ </java>
+ </target>
+
+ <!--
+ ##################
+ TESTING
+ ##################
+ -->
+
+ <!-- compile test cases -->
+ <target name="compile-tests">
+ <javac srcdir="${dir.src.test}"
+ destdir="${dir.build.test}"
+ classpath="${dir.build}:${app.classpath}:${dev.classpath}"
+ target="1.5"
+ debug="on">
+ <compilerarg value="-Xlint:unchecked" />
+ <compilerarg value="-Xlint:deprecation" />
+ </javac>
+ </target>
+
+ <!-- init before we do tests -->
+ <target name="init-tests">
+ <!-- create mysql test database -->
+ <sql driver="com.mysql.jdbc.Driver"
+ url="jdbc:mysql://${mysql.host}"
+ userid="${mysql.user}"
+ password="${mysql.pass}"
+ classpath="${opt.classpath}"
+ onerror="continue">
+ <transaction src="test-data/mysql/drop.sql"/>
+ <transaction src="test-data/mysql/create.sql"/>
+ </sql>
+ </target>
+
+ <!-- tests a particular class -->
+ <!-- the class to test needs to be specified on the command line by using:
+ -Dclass=FULL_CLASSNAME -->
+ <target name="test-single" depends="compile,compile-tests,init-tests">
+ <fail unless="class">Must set property 'class'</fail>
+ <junit haltonfailure="true">
+ <classpath path="${junit.classpath}" />
+ <formatter type="plain" usefile="false" />
+ <test name="${class}" />
+ </junit>
+ </target>
+
+ <!-- run all tests and generate reports -->
+ <target name="test" depends="clean,compile,compile-tests,init-tests">
+
+ <delete dir="${dir.docs.junit}" />
+ <mkdir dir="${dir.docs.junit}" />
+ <mkdir dir="${dir.docs.junit}/html" />
+ <mkdir dir="${dir.docs.junit}/results" />
+
+ <junit haltonfailure="true" dir=".">
+ <classpath path="${junit.classpath}" />
+ <formatter type="plain" usefile="false" />
+ <formatter type="xml" />
+ <batchtest fork="yes" todir="${dir.docs.junit}/results">
+ <fileset dir="${dir.build.test}">
+ <include name="**/*Test.class" />
+ </fileset>
+ </batchtest>
+ </junit>
+
+ <junitreport todir="${dir.docs.junit}">
+ <fileset dir="${dir.docs.junit}/results">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="${dir.docs.junit}/html"/>
+ </junitreport>
+
+ </target>
+
+ <!-- runs the testability reports -->
+ <target name="testability" depends="clean,dist">
+ <testability
+ filter=""
+ resultfile="${dir.docs}/testability.result.html"
+ errorfile="${dir.docs}/testability.err.txt"
+ printdepth="2"
+ print="html"
+ mincost="1"
+ maxexcellentcost="50"
+ maxacceptablecost="100"
+ worstoffendercount="25"
+ whitelist="com.pugh.sockso."
+ cyclomatic="1"
+ global="10"
+ failproperty="testability.failproperty">
+ <classpath>
+ <fileset dir="${dir.dist}">
+ <include name="sockso.jar"/>
+ </fileset>
+ </classpath>
+ </testability>
+ </target>
+
+ <target name="test-all" depends="test,test-js" />
+
+ <!-- starts the js test server -->
+ <target name="test-js-server">
+ <java jar="lib-dev/JsTestDriver-${jstestdriver.version}.jar" fork="true">
+ <arg value="--port" />
+ <arg value="${jstestdriver.port}" />
+ <arg value="--browser" />
+ <arg value="open" />
+ </java>
+ </target>
+
+ <!-- runs the js tests -->
+ <target name="test-js">
+ <waitfor maxwait="1" maxwaitunit="second">
+ <socket server="localhost" port="${jstestdriver.port}"/>
+ </waitfor>
+ <!--
+ <condition property="tests" value="${tests}" else="all">
+ <isset property="tests" />
+ </condition>
+ -->
+ <java jar="lib-dev/JsTestDriver-${jstestdriver.version}.jar" fork="true">
+ <arg value="--config" />
+ <arg value="test/js/jsTestDriver.conf" />
+ <arg value="--tests" />
+ <arg value="all" />
+ </java>
+ </target>
+
+</project>
37 dist-files/README.txt
@@ -0,0 +1,37 @@
+
+Sockso - Personal Music Server
+------------------------------
+
+Sockso is a personal music server written in Java. It's
+designed to be as easy to use as possible, so your friends
+can quickly and easily listen to your music online.
+
+Requirements
+------------
+
+Sockso should come packaged with everything it needs to run,
+all you have to do is have Java installed on your computer.
+You can download the latest Java version for free from
+the Sun website at: http://www.java.com
+
+Running Sockso - Microsoft Windows
+----------------------------------
+
+To run Sockso under Windows just double click "Run Sockso".
+Easy!
+
+"Linux"
+-------
+
+If you're running Linux or something similiar then you may
+just be able to double click the "linux.sh" shell script.
+If this doesn't work for you then you can run this script
+from a terminal with:
+
+$> sh linux.sh
+
+Feedback
+--------
+
+If you've used Sockso then I'd love to hear what you think, so
+please send me some email at: rod@pu-gh.com
BIN dist-files/Run Sockso.lnk
Binary file not shown.
4 dist-files/linux.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd `dirname "$0"`
+java -jar sockso.jar "$@"
8 dist-files/log/default.properties
@@ -0,0 +1,8 @@
+#
+# default logging level for dist systems
+#
+log4j.rootLogger=INFO, A1
+
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%C{1}: %m%n
16 dist-files/log/dev.properties
@@ -0,0 +1,16 @@
+#
+# more fine grained control for development purposes
+#
+
+log4j.rootLogger=DEBUG, A1, A2
+
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%l: %m%n
+
+log4j.appender.A2=org.apache.log4j.RollingFileAppender
+log4j.appender.A2.File=sockso.log
+log4j.appender.A2.MaxFileSize=100KB
+log4j.appender.A2.MaxBackupIndex=1
+log4j.appender.A2.layout=org.apache.log4j.PatternLayout
+log4j.appender.A2.layout.ConversionPattern=%p %t %c - %m%n
9 dist-files/log/test.properties
@@ -0,0 +1,9 @@
+#
+# more fine grained control for development purposes
+#
+
+log4j.rootLogger=INFO, A1
+
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%l: %m%n
54 dist-files/scripts/init.d/sockso
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+###########################################################
+###########################################################
+#
+# Edit this constant to point to your Sockso directory
+#
+
+use constant SOCKSO_DIR => "../../";
+
+#
+###########################################################
+###########################################################
+
+use strict;
+
+my $cmd = shift();
+
+if ( $cmd eq "start" ) { start(); }
+elsif ( $cmd eq "stop" ) { stop(); }
+elsif ( $cmd eq "restart" ) { restart(); }
+else { usage(); }
+
+sub start {
+
+ chdir( SOCKSO_DIR );
+ system( 'sh linux.sh --nogui > /dev/null 2>&1 &' );
+
+}
+
+sub stop {
+
+ my $pid = `ps x | grep sockso.jar | grep -v grep`;
+ $pid =~ s/^\s*(\d+) .*/$1/;
+
+ if ( $pid ) {
+ `kill -9 $pid`;
+ }
+
+}
+
+sub restart {
+ stop();
+ sleep( 2 );
+ start();
+}
+
+sub usage {
+ print <<EOF;
+
+Usage: sockso (start|stop|restart)
+
+EOF
+}
8 dist-files/scripts/tools/bash/extractResources.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set RESOURCES_DIR="../../../resources"
+
+mkdir ../../../resources
+cd ../../../resources
+
+jar xf ../resources.jar
2 dist-files/scripts/tools/bash/packResources.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+
6 dist-files/scripts/tools/windows/extractResources.bat
@@ -0,0 +1,6 @@
+@echo off
+
+mkdir ../../../resources
+cd ../../../resources
+
+jar xf ../resources.jar
3 dist-files/scripts/unix/aactag.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+faad -i "$1"
3 dist-files/scripts/unix/faadToLame.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+faad -q -f 2 -w "$1" | lame --silent -r -f -V 4 -
3 dist-files/scripts/unix/ffmpegToLame.sh
@@ -0,0 +1,3 @@
+ #!/bin/sh
+
+ffmpeg -i "$1" -vn -f wav - | lame --silent -f -V 4 -
2 dist-files/scripts/unix/flacToLame.sh
@@ -0,0 +1,2 @@
+
+flac -d -c "$1" - | lame --silent -
2 dist-files/scripts/unix/oggDecToLame.sh
@@ -0,0 +1,2 @@
+
+oggdec --quiet -o - "$1" | lame --silent -
3 dist-files/scripts/windows/ffmpegToLame.bat
@@ -0,0 +1,3 @@
+@echo off
+
+ffmpeg -i %1 -vn -f wav - | lame --silent -f -V 4 -
3 dist-files/scripts/windows/flacToLame.bat
@@ -0,0 +1,3 @@
+@echo off
+
+flac -d -c %1 - | lame --silent -
3 dist-files/scripts/windows/oggDecToLame.bat
@@ -0,0 +1,3 @@
+@echo off
+
+oggdec --quiet -o - %1 | lame --silent -
BIN dist-files/ssl/keystore
Binary file not shown.
2 dist-files/windows.bat
@@ -0,0 +1,2 @@
+
+start javaw -Djava.library.path="lib" -jar sockso.jar %1 %2 %3 %4 %5
BIN lib-dev/JsTestDriver-1.2.jar
Binary file not shown.
BIN lib-dev/ant-googlecode-0.0.1.jar
Binary file not shown.
BIN lib-dev/ant-testability-explorer-1.3.0-r275.jar
Binary file not shown.
BIN lib-dev/easymock-2.4.jar
Binary file not shown.
BIN lib-dev/jamon-anttask-2.3.1.jar
Binary file not shown.
BIN lib-dev/jamon-api-2.3.0.jar
Binary file not shown.
BIN lib-dev/jamon-processor-2.3.2.jar
Binary file not shown.
BIN lib-dev/jarbundler-2.1.0.jar
Binary file not shown.
BIN lib-dev/junit.jar
Binary file not shown.
BIN lib-dev/testability-explorer-1.2.0-r85.jar
Binary file not shown.
BIN lib-opt/activation.jar
Binary file not shown.
BIN lib-opt/mailapi.jar
Binary file not shown.
BIN lib-opt/mysql-connector-java-5.1.6-bin.jar
Binary file not shown.
BIN lib-opt/sbbi-upnplib-1.0.4.jar
Binary file not shown.
BIN lib-opt/smtp.jar
Binary file not shown.
BIN lib-opt/sqlitejdbc-v053.jar
Binary file not shown.
BIN lib/BrowserLauncher2-1_3.jar
Binary file not shown.
BIN lib/forms-1.2.1.jar
Binary file not shown.
BIN lib/hsqldb-1.8.jar
Binary file not shown.
BIN lib/id3v2.jar
Binary file not shown.
BIN lib/jamon-runtime-2.3.1.jar
Binary file not shown.
BIN lib/jdic.jar
Binary file not shown.
BIN lib/jflac-1.3.jar
Binary file not shown.
BIN lib/jogg-0.0.7.jar
Binary file not shown.
BIN lib/jopt-simple-3.1.jar
Binary file not shown.
BIN lib/jorbis-0.0.15.jar
Binary file not shown.
BIN lib/linux/jdic_stub.jar
Binary file not shown.
BIN lib/linux/x86/libtray.so
Binary file not shown.
BIN lib/log4j-1.2.15.jar
Binary file not shown.
BIN lib/looks-2.2.2.jar
Binary file not shown.
BIN lib/systray4j.dll
Binary file not shown.
BIN lib/systray4j.jar
Binary file not shown.
6 resources/ResourcesAnchor.java
@@ -0,0 +1,6 @@
+/**
+ * stub class for locating the resources jar
+ *
+ */
+
+class ResourcesAnchor {}
BIN resources/htdocs/flash/flexPlayer/big_xmlPlayer.swf
Binary file not shown.
8 resources/htdocs/flash/flexPlayer/swfobject.js
@@ -0,0 +1,8 @@
+/**
+ * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
+ *
+ * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
BIN resources/htdocs/flash/jwplayer-4.2/player.swf
Binary file not shown.
BIN resources/htdocs/flash/xspf_player.swf
Binary file not shown.
BIN resources/htdocs/flash/xspf_player_slim.swf
Binary file not shown.
510 resources/htdocs/js/folders.js
@@ -0,0 +1,510 @@
+
+/**
+ * represents a folder. the name should have unicode entity encoded, and
+ * the path should be URL encoded.
+ *
+ */
+
+function Folder( name, path ) {
+ this.name = name;
+ this.path = decodeURIComponent(path);
+ this.isFolder = true;
+};
+
+/**
+ * represents a file. the name should have unicode entity encoded, and
+ * the path should be URL encoded.
+ *
+ */
+
+function File( name, path ) {
+ this.name = name;
+ this.path = decodeURIComponent(path).replace( /\\/g, '/' );
+ this.isFolder = false;
+};
+
+$(function() {
+
+ /**
+ * takes a string with encoded named entities (eg. &amp;) and turns
+ * them back into their normal characters
+ *
+ * @param str
+ *
+ */
+
+ function decodeEntities( str ) {
+
+ var entities = new Array(
+ '&amp;', '&',
+ '&lt;', '<',
+ '&gt;', '>',
+ '&quot;', '"',
+ '&apos;', "'"
+ );
+
+ for ( var i=0; i<entities.length; i+=2 )
+ str = str.replace( eval('/'+entities[i]+'/g'), entities[i+1] );
+
+ return str;
+
+ };
+
+ /**
+ * traverses up the DOM to work out our current path, the path returned
+ * already has it's components properly URI encoded.
+ *
+ */
+
+ function getPath( folder ) {
+
+ if ( !folder.hasClass('folder') )
+ return getPath( folder.parent() );
+
+ var link = $( 'span a', folder );
+ var id = folder.attr( 'id' );
+ var name = encodeURIComponent(decodeEntities( link.html() ));
+
+ if ( !id ) id = '';
+
+ return id.match( /^collection-\d+$/ )
+ ? ''
+ : getPath(folder.parent()) + '/' + name;
+
+ };
+
+ /**
+ * traverses up the DOM to find the collection we're in
+ *
+ * @param elem current element
+ *
+ */
+
+ function getCollectionId( elem ) {
+
+ var id = elem.attr( 'id' );
+ var matches = id != null
+ ? id.match( /^collection-(\d+)$/ )
+ : null;
+
+ return ( matches )
+ ? matches[ 1 ]
+ : getCollectionId( elem.parent() );
+
+ };
+
+ /**
+ * plays a file for a path
+ *
+ * @param path path of file to play
+ *
+ */
+
+ function playFile( path ) {
+ resolvePath(
+ path,
+ function( responseText ) {
+ eval( 'var track = ' +responseText );
+ player.play( 'tr' +track['id'] );
+ },
+ Locale.getString('www.error.trackNotFound')
+ );
+ };
+
+ /**
+ * makes an ajax call to resolve a path to a track id and then passes
+ * control to the specified handler function
+ *
+ * @param path
+ * @param handler
+ * @param errorMessage
+ *
+ */
+
+ function resolvePath( path, handler, errorMessage ) {
+ $.ajax({
+ type: 'POST',
+ url: '/json/resolvePath',
+ data: {
+ path: path
+ },
+ success: handler,
+ error: function(){ alert(errorMessage); }
+ });
+ };
+
+ /**
+ * tries to resolve a path to a track then add it to the playlist
+ *
+ * @param path
+ *
+ */
+
+ function addFileToPlaylist( path ) {
+ resolvePath(
+ path,
+ function( responseText ) {
+ eval( 'var track = ' +responseText );
+ addToPlaylist( 'tr' +track['id'], track['name'] );
+ },
+ Locale.getString('www.error.trackNotFound')
+ );
+ };
+
+ /**
+ * looks at a files path and decides if this is a media file (mp3,
+ * ogg or wma)
+ *
+ * @param file File object
+ *
+ * @return boolean
+ *
+ */
+
+ function isMediaFile( file ) {
+
+ var exts = new Array( 'mp3', 'ogg', 'wma' );
+ var ext = file.path.toLowerCase().substring( file.path.length - 3 );
+
+ for ( var i=0; i<exts.length; i++ )
+ if ( exts[i] == ext )
+ return true;
+
+ return false;
+
+ };
+
+ /**
+ * creates a folder node for the tree
+ *
+ * @param folder folder object
+ *
+ */
+
+ function getFolderItem( folder ) {
+
+ var link = $( '<a></a>' )
+ .attr({
+ href: 'javascript:;'
+ })
+ .click( toggleFolder )
+ .html( folder.name );
+
+ var play = getTrackAction( 'play', function() {
+ getTracksForFolder( folder, playFolder );
+ }, 'Play folder' );
+
+ var download = null;
+ if ( Properties.get('www.disableDownloads') != 'yes' )
+ download = getTrackAction( 'download', function() {
+ getTracksForFolder( folder, downloadFolder );
+ }, 'Download folder' );
+
+ var actions = $( '<span></span>' )
+ .addClass( 'actions' )
+ .append( play )
+ .append( download );
+
+ var links = $( '<span></span>' )
+ .addClass( 'links' )
+ .append( link )
+ .append( actions );
+
+ return $( '<li></li>' )
+ .addClass( 'folder' )
+ .append( links )
+ .append( $('<ul></ul>') );
+
+ };
+
+ /**
+ * creates an image wrapped in an anchor for use when playing tracks
+ *
+ * @param icon
+ * @param action
+ * @param title
+ *
+ */
+
+ function getTrackAction( icon, action, title ) {
+
+ var skin = Properties.get( "www.skin", "original" );
+
+ return $( '<a></a>' )
+ .attr({
+ href: 'javascript:;',
+ title: title
+ })
+ .click( action )
+ .append( $('<img />').attr('src','/file/skins/' +skin+ '/images/' + icon +'.png') )
+ .append( '<span>&nbsp;</span>' );
+
+ };
+
+ /**
+ * tries to resolve a path to a tarck and then download it
+ *
+ * @param path
+ *
+ */
+
+ function downloadFile( path ) {
+ resolvePath( path, function( responseText ) {
+ eval( 'var track = ' +responseText );
+ self.location.href = '/download/tr' +track['id'];
+ });
+ }
+
+ /**
+ * creates a track node for a file (assumed to be a media file)
+ *
+ * @param file
+ *
+ * @return LI
+ *
+ */
+
+ function getTrackItem( file ) {
+
+ var play = getTrackAction( 'play', function() {
+ playFile( file.path );
+ }, file.name );
+
+ var playlist = getTrackAction( 'add', function() {
+ addFileToPlaylist( file.path );
+ }, file.name );
+
+ var download = null;
+ if ( Properties.get('www.disableDownloads') != 'yes' )
+ download = getTrackAction( 'download', function() {
+ downloadFile( file.path );
+ }, 'Download: ' +file.name );
+
+ return $( '<li></li>' )
+ .addClass( 'audioFile' )
+ .append( play )
+ .append( playlist )
+ .append( download )
+ .append( file.name );
+
+ };
+
+ /**
+ * works out the path and collection for a folder and makes an ajax request
+ * to find the tracks in it to play
+ *
+ * the playUrlAction should be a function to handle the play url that will
+ * be constructed from the data in the response
+ *
+ * @param folder
+ * @param handler
+ *
+ */
+
+ function getTracksForFolder( folder, handler ) {
+
+ var url = '/json/tracksForPath?path=' +encodeURIComponent(folder.path);
+
+ $.ajax({
+ url: url,
+ success: function( responseText ) {
+ eval( 'var tracks = ' +responseText );
+ var playUrl = '';
+ $.each( tracks, function(i,track) {
+ playUrl += 'tr' +track+ '/';
+ });
+ handler( playUrl );
+ }
+ });
+
+ };
+
+ /**
+ * takes a play url to play
+ *
+ * @param playUrl
+ *
+ */
+
+ function playFolder( playUrl ) {
+ player.play( playUrl );
+ };
+
+ /**
+ * takes a play url to download
+ *
+ * @param playUrl
+ *
+ */
+
+ function downloadFolder( playUrl ) {
+ self.location.href = '/download/' +playUrl;
+ };
+
+ /**
+ * given an array of files and folders, will return just the files that
+ * look like media files
+ *
+ * @param results array of File and Folder objects
+ *
+ * @return Array
+ *
+ */
+
+ function getTracks( results ) {
+ var files = new Array();
+ $.each( results, function(i,result){
+ if ( !result.isFolder && isMediaFile(result) )
+ files.push( result );
+ });
+ return files;
+ };
+
+ /**
+ * given an array of files and folders, will return just the folders
+ *
+ * @param results array of File and Folder objects
+ *
+ * @return Array
+ *
+ */
+
+ function getFolders( results ) {
+ var folders = new Array();
+ $.each( results, function(i,result){
+ if ( result.isFolder )
+ folders.push( result );
+ });
+ return folders;
+ };
+
+ /**
+ * handles the return of the query to load a folder
+ *
+ * @param folder the element we're loading
+ * @param responseText
+ *
+ */
+
+ function handleLoadFolder( folder, responseText ) {
+
+ eval( 'var results = ' + responseText );
+
+ var children = $( $('ul',folder)[0] );
+ var tracks = getTracks( results );
+ var folders = getFolders( results );
+
+ children.empty();
+
+ // add files and folders if we have them
+ if ( (tracks.length + folders.length) > 0 ) {
+
+ // add sub folders, then files
+ $.each( folders, function(i,subFolder) {
+ children.append( getFolderItem(subFolder) );
+ });
+ $.each( tracks, function(i,track) {
+ children.append( getTrackItem(track) );
+ });
+
+ }
+ // otherwise mark as empty
+ else children.append( $('<li></li>').addClass('empty').html('...') );
+
+
+ folder.addClass( 'loaded folderOpen' );
+
+ };
+
+ /**
+ * loads a folder with it's contents
+ *
+ * @param folder the element to load
+ *
+ */
+
+ function loadFolder( folder ) {
+
+ var skin = Properties.get( "www.skin", "original" );
+ var path = getPath( folder );
+ var collectionId = getCollectionId( folder );
+ var url = '/json/folder' +
+ path+ // already URI encoded
+ '?collectionId=' +encodeURIComponent(collectionId);
+
+ // show loading gif
+ $( 'ul', folder ).append(
+ $( '<img />' )
+ .attr({ src: '/file/skins/' +skin+ '/images/loading.gif' })
+ );
+
+ // set a small timeout so the page can refresh with the loading
+ // gif before we make the ajax request (which could take a lil bit)
+ setTimeout( function() {
+ $.ajax({
+ url: url,
+ success: function( responseText ) {
+ handleLoadFolder( folder, responseText )
+ }
+ });
+ }, 100 );
+
+ };
+
+ /**
+ * toggles a folders expanded/collapses state, loading it's
+ * children if it needs it.
+ *
+ */
+
+ function toggleFolder() {
+
+ var elem = $( this );
+ var folder = elem.parent();
+
+ // if we're on a folder node we need to go
+ // up another level in the DOM
+ if ( folder.hasClass('links') )
+ folder = folder.parent();
+
+ if ( !folder.hasClass('loaded') )
+ loadFolder( folder );
+
+ else {
+ var children = $( 'ul', folder )[ 0 ];