From 6054521e117539d2a5d16f08a6b107e13c9dc370 Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Thu, 14 Oct 2010 15:47:04 +0200 Subject: Cleaned --- ac/allison crowe/01 - Northern Lights.mp3 | Bin 3644552 -> 0 bytes ac/allison crowe/02 - Angels.mp3 | Bin 4988418 -> 0 bytes ac/allison crowe/03 - Disease (08 03 08).mp3 | Bin 10424149 -> 0 bytes ac/allison crowe/04 - Little Light.mp3 | Bin 3990623 -> 0 bytes ac/allison crowe/05 - Happy People.mp3 | Bin 3760791 -> 0 bytes ac/allison crowe/06 - Hold Back.mp3 | Bin 3487965 -> 0 bytes ac/allison crowe/07 - Choose to Be.mp3 | Bin 4132180 -> 0 bytes ac/allison crowe/08 - Wedding Song.mp3 | Bin 3345972 -> 0 bytes ac/allison crowe/License.txt | 12 - ac/allison crowe/Readme - www.jamendo.com .txt | 254 --------------------- ...r] Allison Crowe - Little Light (originals).jpg | Bin 3157 -> 0 bytes server/cldb.erl | 11 + 12 files changed, 11 insertions(+), 266 deletions(-) delete mode 100644 ac/allison crowe/01 - Northern Lights.mp3 delete mode 100644 ac/allison crowe/02 - Angels.mp3 delete mode 100644 ac/allison crowe/03 - Disease (08 03 08).mp3 delete mode 100644 ac/allison crowe/04 - Little Light.mp3 delete mode 100644 ac/allison crowe/05 - Happy People.mp3 delete mode 100644 ac/allison crowe/06 - Hold Back.mp3 delete mode 100644 ac/allison crowe/07 - Choose to Be.mp3 delete mode 100644 ac/allison crowe/08 - Wedding Song.mp3 delete mode 100644 ac/allison crowe/License.txt delete mode 100644 ac/allison crowe/Readme - www.jamendo.com .txt delete mode 100644 ac/allison crowe/[cover] Allison Crowe - Little Light (originals).jpg diff --git a/ac/allison crowe/01 - Northern Lights.mp3 b/ac/allison crowe/01 - Northern Lights.mp3 deleted file mode 100644 index fc79340..0000000 Binary files a/ac/allison crowe/01 - Northern Lights.mp3 and /dev/null differ diff --git a/ac/allison crowe/02 - Angels.mp3 b/ac/allison crowe/02 - Angels.mp3 deleted file mode 100644 index e1011b2..0000000 Binary files a/ac/allison crowe/02 - Angels.mp3 and /dev/null differ diff --git a/ac/allison crowe/03 - Disease (08 03 08).mp3 b/ac/allison crowe/03 - Disease (08 03 08).mp3 deleted file mode 100644 index 25886e2..0000000 Binary files a/ac/allison crowe/03 - Disease (08 03 08).mp3 and /dev/null differ diff --git a/ac/allison crowe/04 - Little Light.mp3 b/ac/allison crowe/04 - Little Light.mp3 deleted file mode 100644 index 2dd8cff..0000000 Binary files a/ac/allison crowe/04 - Little Light.mp3 and /dev/null differ diff --git a/ac/allison crowe/05 - Happy People.mp3 b/ac/allison crowe/05 - Happy People.mp3 deleted file mode 100644 index b379be5..0000000 Binary files a/ac/allison crowe/05 - Happy People.mp3 and /dev/null differ diff --git a/ac/allison crowe/06 - Hold Back.mp3 b/ac/allison crowe/06 - Hold Back.mp3 deleted file mode 100644 index f3c0697..0000000 Binary files a/ac/allison crowe/06 - Hold Back.mp3 and /dev/null differ diff --git a/ac/allison crowe/07 - Choose to Be.mp3 b/ac/allison crowe/07 - Choose to Be.mp3 deleted file mode 100644 index d9bd188..0000000 Binary files a/ac/allison crowe/07 - Choose to Be.mp3 and /dev/null differ diff --git a/ac/allison crowe/08 - Wedding Song.mp3 b/ac/allison crowe/08 - Wedding Song.mp3 deleted file mode 100644 index 017e2e0..0000000 Binary files a/ac/allison crowe/08 - Wedding Song.mp3 and /dev/null differ diff --git a/ac/allison crowe/License.txt b/ac/allison crowe/License.txt deleted file mode 100644 index 040e8da..0000000 --- a/ac/allison crowe/License.txt +++ /dev/null @@ -1,12 +0,0 @@ - -Track | License URL ----------------------------------------------- - 01 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 02 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 03 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 04 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 05 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 06 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 07 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - 08 | http://creativecommons.org/licenses/by-nc-sa/3.0/ - artwork | http://creativecommons.org/licenses/by-nc-sa/3.0/ \ No newline at end of file diff --git a/ac/allison crowe/Readme - www.jamendo.com .txt b/ac/allison crowe/Readme - www.jamendo.com .txt deleted file mode 100644 index 8126e88..0000000 --- a/ac/allison crowe/Readme - www.jamendo.com .txt +++ /dev/null @@ -1,254 +0,0 @@ -This 'Readme' file is available below in: English, Français, Italiano, Español, Deutsch, Polski, Русский, Português. - - - - - -Thank you for downloading this album! - -It’s FREE and LEGAL distribution by Jamendo: - -http://www.jamendo.com/ - -On the website you'll be able to: - - - Write a review about the album and check out other reviews already written by members of our community. - - - Obtain more information about the artist and/or album. - - - Download other quality music for FREE. - - - Learn more about Jamendo. Sign up and post messages in our forums. - - - Make a donation to the artist to support them. - - -Visit Jamendo and help us promote FREE music! - -Thanks again, we hope you enjoy listening to this album. - ---- -The Jamendo team. - - - -------------------- - - - -Merci d'avoir téléchargé cet album ! - -Sa diffusion gratuite et légale est assurée par jamendo : - -http://www.jamendo.com/ - -Sur ce site, vous pourrez, entre autres : - - - Déposer une critique sur cet album, et consulter les nombreuses critiques déjà présentes. - - - Obtenir plus d'informations sur l'artiste auteur de cet album. - - - Télécharger d'autres albums de qualité, complets et gratuits. - - - Vous informer sur la contribution de jamendo en faveur d'une musique gratuite et légale, et participer au forum de jamendo. - - - Rejoindre son fan-club pour être tenu au courant des prochains concerts, sorties d'albums, ... c'est en même temps un petit geste de soutien ! - - -Alors n'hésitez pas à nous rendre visite, pour apporter votre soutien à notre action et nous aider à prouver qu'une autre musique est possible, une musique libre ! - - -Merci, et bonne écoute ! - ---- -L'équipe de jamendo. - - - -------------------- - - - -Grazie per avere scaricato questo album! - -La sua distribuzione legale e veloce è fatta da jamendo: - -http://www.jamendo.com/ - -Tramite questo sito sarai in grado di: - - - scrivere una recensione su questo album e leggere le altre recensioni già scritte dagli altri membri della nostra comunità; - - - ottenere maggiori informazioni su questo album/artista; - - - scaricare altri album interi di qualità, gratuitamente; - - - saperne di più su jamendo, registrarti, inserire messaggi nei nostri forum. - - - fare una donazione a questo artista per supportare il suo album. - -Quindi visita liberamente jamendo e aiutaci a promuovere la musica libera! Grazie ancora! - ----- -Il team di jamendo. - - - -------------------- - - - -Gracias por descargar este álbum ! - -Su distribución gratis y legal es realizada por jamendo : - -http://www.jamendo.com/ - -En el sitio web, podrás : - - - Escribir tu opinión sobre este álbum, y checar todas las opiniones ya escritas por miembros de la comunidad jamendo. - - - Obtener mayor información sobre este artista/álbum. - - - Descargar otros álbumes de calidad, gratis. - - - Aprender más sobre jamendo, escribir un mensaje en los foros. - - - Hacer una donación a este artista para apoyarlo. - - -No dudes en visitar jamendo, y ayúdanos a promover música gratis y de buena calidad ! - -Gracias otra vez, que pases un buen rato oyendo este álbum ! - ---- -El equipo de jamendo. - - - -------------------- - - - -Vielen Dank für den Download dieses Albums! - -Die freie und legale Distribution wird von Jamendo gewährleistet: - -http://www.jamendo.com - -Auf dieser Webseite kannst du auch: - - - eine Rezension zu diesem Album schreiben und die zahlreichen anderen Rezensionen lesen. - - - mehr Informationen zu diesem Album und dem/den Künstler/n einsehen. - - - kostenlos weitere komplette Alben herunterladen. - - - mehr über Jamendo und dessen Unterstützung einer kostenlosen und legalen Verbreitung von Musik erfahren und an unseren Foren teilnehmen. - - - dem Fanclub des Künstlers beitreten, um Infos über Konzerte und neue Alben zu erhalten - und ihn damit auch zu unterstützen! - - -Besuche Jamendo jederzeit und unterstütze unsere Aktion: Denn wir suchen nach einer anderen Musik, nämlich freie Musik! - -Nochmals vielen Dank und viel Spaß beim Hören dieses Albums! - ---- -Das Jamendo-Team - - - -------------------- - - - -Dziękujemy za pobranie tego albumu! - -Jego darmowa i legalna dystrybucja odbywa się przez jamendo: - -http://www.jamendo.com/ - -Na stronie tej możesz: - - - Napisać opinię o tym albumie oraz sprawdzić opinie napisane już przez innych użytkowników. - - - Zdobyć więcej informacji o tym artyście/albumie. - - - Pobrać inne albumy w dobrej jakości, za darmo. - - - Dowiedzieć się więcej o jamendo, zarejestrować, wysyłać wiadomości na nasze fora. - - - Wpłacić pieniądze dla artysty, aby go wesprzeć. - -Nie wahaj się więc odwiedzić jamendo i pomóż nam promować wolną muzykę! - -Jeszcze raz dzięki, życzymy miłego czasu spędzonego przy słuchaniu albumu! - ---- -Zespół jamendo. - - - -------------------- - - - -Спасибо за скачивание этого альбома! -Это бесплатно, и он легально распространяется Jamendo: - -http://www.jamendo.com/ - - -На этом сайте вы сможете: -- Написать рецензию на этот альбом, и просмотреть все остальные рецензии, уже написанные членами нашего сообщества. -- Получить больше информации о данном исполнителе/альбоме. -- Скачать бесплатно другие качественные полные альбомы. -- Узнать больше о Jamendo, зарегистрироваться, оставлять сообщения на наших форумах. -- Сделать пожертвование этому исполнителю для его поддержки - -Поэтому, не стесняйтесь, заходите на Jamendo и помогайте нам нести в массы бесплатную музыку! - -Еще раз спасибо, желаем Вам отличного прослушивания этого альбома! - --- -Команда Jamendo. - - - -------------------- - - - -Obrigado por baixar esta álbum! - -Sua distribuição gratuita e legal é assegurada pelo Jamendo: - -http://www.jamendo.com/ - -Sobre o site, você pode também: - - - Fazer críticas aos álbuns e consultas críticas já feitas. - - - Obter mais informações sobre o artista autor deste álbum. - - - Baixar outros álbuns de qualidade, completos e gratuitos. - - - Se informar sobre a contribuição do Jamendo em favor da música gratuita e legal, além de participar do fórum do Jamendo. - - - Participar de seu fã-club para ficar por dentro de seus shows, lançamento de álbuns, etc... E fazer doações ao artista! - - -Não deixe de nos fazer uma visita e ajudar a promover a música livre! - - -Obrigado, e boa música! - ---- -Equipe do Jamendo. - - - -------------------- - - - diff --git a/ac/allison crowe/[cover] Allison Crowe - Little Light (originals).jpg b/ac/allison crowe/[cover] Allison Crowe - Little Light (originals).jpg deleted file mode 100644 index 90091ae..0000000 Binary files a/ac/allison crowe/[cover] Allison Crowe - Little Light (originals).jpg and /dev/null differ diff --git a/server/cldb.erl b/server/cldb.erl index 0f9f407..9aad688 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -10,3 +10,14 @@ init() -> mnesia:create_table(track, [{attributes, record_info(fields, track)}]), io:format("Userdb up and running \n"). + +ask(User, Pwd) -> + F = fun() -> + mnesia:match_object({user, User, Pwd, _}), + end, + + + +login(User, Pwd) -> + {_, Reason} = ask(User, Pwd), + Reason. -- cgit v1.2.3 From e25c2d52d30bc1c0c68612ff48a2cd889631f937 Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Thu, 14 Oct 2010 15:48:48 +0200 Subject: maaaaaan fertig werden --- server/media.erl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/media.erl b/server/media.erl index fbdaa7e..561a2c7 100644 --- a/server/media.erl +++ b/server/media.erl @@ -1,5 +1,5 @@ -module(media). --export([init/0,insert/3, ask/2, all/0, play/3, vote/2, devote/2, lock_process/2]). +-export([init/0,insert/3, ask/2, all/0, play/2, vote/2, devote/2, lock_process/2]). -define(TESTPATTERN, "../ac/*.mp3"). -define(TIMEOUT, 100000000). @@ -68,7 +68,7 @@ search_best([], _, Track) -> {Track#track.artist, Track#track.title}. % if nothing is playable anymore just reset them and start playing again... -reset_all([Head|Rest) -> +reset_all([Head|Rest]) -> unlock(Head#track.artist, Head#track.title), reset_all(Rest); reset_all([]) -> ok. @@ -100,7 +100,7 @@ play(Artist, Title) -> {_, Title, Artist, _, _, Fp} = Head, Port = erlang:open_port({spawn_executable, "/usr/bin/mplayer"}, [{args, [Fp]}, exit_status]), reset_votes(Artist, Title), - lock_process(Artist, Title), + spawn(media, lock_process, [Artist, Title]), io:format("playing: ~s, Artist: ~s~n", [Title, Artist]), receive @@ -143,8 +143,7 @@ reset_votes(Artist, Title) -> lock(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), - Votes = Head#track.lock = true, - New = Head#track{lock = Votes}, + New = Head#track{locked = true}, mnesia:write(New) end, mnesia:transaction(F). @@ -152,8 +151,7 @@ lock(Artist, Title) -> unlock(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), - Votes = Head#track.lock = false, - New = Head#track{lock = Votes}, + New = Head#track{locked = false}, mnesia:write(New) end, mnesia:transaction(F). -- cgit v1.2.3 From be34a99dbb4e516d7592d6a19d0c662b6d81ab17 Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Thu, 14 Oct 2010 15:52:57 +0200 Subject: Blub --- server/cldb.erl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/cldb.erl b/server/cldb.erl index 9aad688..6f6f4d2 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -2,22 +2,31 @@ -module(cldb). -export([init/0]). --record(user, {name, passwd, votes}). +-record(user, {name, passwd, votes, rights}). init() -> mnesia:create_schema([node()]), mnesia:start(), - mnesia:create_table(track, [{attributes, record_info(fields, track)}]), + mnesia:create_table(user, [{attributes, record_info(fields, user)}]), io:format("Userdb up and running \n"). - ask(User, Pwd) -> F = fun() -> - mnesia:match_object({user, User, Pwd, _}), + mnesia:match_object({user, User, Pwd, '_'}) end, + mnesia:transaction(F). login(User, Pwd) -> {_, Reason} = ask(User, Pwd), Reason. + +register(User, Pwd, Root) -> + F = fun() -> + mnesia:write(#user{name = User, passwd = Pwd, votes = 5, rights = Root}) + end, + {_, Reason} = mnesia:transaction(F), + Reason. + + -- cgit v1.2.3 From 4ce4e290a0557e616650ddb004f70cff2082e757 Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Thu, 14 Oct 2010 15:59:37 +0200 Subject: next one --- server/media.erl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/media.erl b/server/media.erl index 561a2c7..165338b 100644 --- a/server/media.erl +++ b/server/media.erl @@ -55,7 +55,11 @@ insert(Artist, Title, Filepath) -> end, mnesia:transaction(F). -% search the track with the highest votes and return {Artist, Title} +% Of course we need a query to find out whats actually the most wished for track. +% We will do it by requesting all the records from the database and then iteramte over just taking a look at the vote +% variable, so it is like list of integers. In case no tracks were voted for we just take the first track we find and play it. +% Of course it is locked afterwards so another will be choosen. + search_best([Head|Rest], Max_Votes, Track) -> if @@ -107,11 +111,7 @@ play(Artist, Title) -> {Port, {exit_status, 0}} -> start_playing(); {Port, {exit_status, S}} -> throw({commandfailed, S}) end. - - -% Of course we need a query to find out whats actually the most wished for track. -% We will do it by requesting all the records from the database and then iteramte over just taking a look at the vote -% variable, so it is like list of integers. In case no tracks were voted for we just take the first track we find and play it. Of course it is locked afterwards so another will be choosen. +%Increase the vote in the database so it will hopefully be played in the future vote(Artist, Title) -> F = fun() -> @@ -122,6 +122,8 @@ vote(Artist, Title) -> end, mnesia:transaction(F). +% decrease votes in database + devote(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), @@ -131,6 +133,8 @@ devote(Artist, Title) -> end, mnesia:transaction(F). +% Reset votes to zero in database + reset_votes(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), @@ -139,6 +143,7 @@ reset_votes(Artist, Title) -> end, mnesia:transaction(F). +% Lock a song lock(Artist, Title) -> F = fun() -> @@ -148,6 +153,8 @@ lock(Artist, Title) -> end, mnesia:transaction(F). +% Unlock a song... + unlock(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), @@ -156,6 +163,9 @@ unlock(Artist, Title) -> end, mnesia:transaction(F). +% Lock a song if it was just played, after a Timeout it will be unlocked automaticly +% If all songs are locked, all will be unlocked. + lock_process(Artist, Title) -> lock(Artist, Title), receive -- cgit v1.2.3 From d4974ca3ef2f4e664a78912837989762997d14dd Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Thu, 14 Oct 2010 16:03:19 +0200 Subject: Finished --- server/cldb.erl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/cldb.erl b/server/cldb.erl index 6f6f4d2..3886685 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -29,4 +29,22 @@ register(User, Pwd, Root) -> {_, Reason} = mnesia:transaction(F), Reason. +decVote(User, Pwd) -> + F = fun() -> + [Head|_] = ask(User, Pwd), + Votes = Head#user.votes - 1, + New = Head#user{votes = Votes}, + mnesia:write(New) + end, + mnesia:transaction(F). + +incVote(User, Pwd) -> + F = fun() -> + [Head|_] = ask(User, Pwd), + Votes = Head#user.votes + 1, + New = Head#user{votes = Votes}, + mnesia:write(New) + end, + mnesia:transaction(F). + -- cgit v1.2.3 From cfa125e96062c4ccabc155f68c36bc8bcf754b61 Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Thu, 14 Oct 2010 16:04:26 +0200 Subject: ... --- server/cldb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/cldb.erl b/server/cldb.erl index 3886685..176576c 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -1,7 +1,7 @@ % The clientdatabase -module(cldb). --export([init/0]). +-export([init/0, ask/2, login/2, decVote/2, incVote/2, register/3]). -record(user, {name, passwd, votes, rights}). init() -> -- cgit v1.2.3 From 8ee69a40c7782a69d44b9be08538cbe17531420b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 14 Oct 2010 16:05:14 +0200 Subject: code cleanup, added comments --- client/client.erl | 51 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/client/client.erl b/client/client.erl index 46ef59f..0e2fada 100644 --- a/client/client.erl +++ b/client/client.erl @@ -1,19 +1,15 @@ -module(client). -export([register/3, login/3, list/0, handle/2, getVotes/0, vote/2, devote/2]). -contains([], _) -> - false; -contains([H|_], H) -> - true; -contains([_|T], Search) -> - contains(T, Search). - checkLogin(Value) -> - checkLogin(Value, contains(registered(), cli)). -checkLogin(Value, Value) -> - true; -checkLogin(_, _) -> - throw({error, login_state}). + %% check if user meets the requirements to be locked in or not by + %% locking in to the registered processes and check if the cli + %% process is registered + LoggedIn = lists:member(cli, registered()), + if LoggedIn == Value -> + true; + true -> throw({error, login_state}) + end. buildNode(Server) -> list_to_atom("distributed_music_system_main_node@" ++ Server). @@ -82,33 +78,26 @@ handle({change_state, NewState}, _) -> handle(Cmd, Server) -> {{error, {unknown_command, Cmd}}, Server}. -%queries the server for the current votes this client possesses -getVotes() -> +try_logged_in_rpc(Rpc) -> + %% tries to execute an rpc for logged in user and returns error + %% message if user is not logged in try checkLogin(true) of _ -> - server:rpc(cli, get_votes) + server:rpc(cli, Rpc) catch {error, login_state} -> {error, not_logged_in} end. -%positive vote, increments the votes for {Artist, Title} by one +getVotes() -> + %% queries the server for the current votes this client possesses + try_logged_in_rpc(get_votes). + vote(Artist, Title) -> - try checkLogin(true) of - _ -> - server:rpc(cli, {vote, Artist, Title}) - catch - {error, login_state} -> - {error, not_logged_in} - end. + %% positive vote, increments the votes for {Artist, Title} by one + try_logged_in_rpc({vote, Artist, Title}). -%negative vote, decrements the votes for {Artist, Title} by one devote(Artist, Title) -> - try checkLogin(true) of - _ -> - server:rpc(cli, {devote, Artist, Title}) - catch - {error, login_state} -> - {error, not_logged_in} - end. + %% negative vote, decrements the votes for {Artist, Title} by one + try_logged_in_rpc({devote, Artist, Title}). -- cgit v1.2.3 From bde55a9f9456b7ab38b8ae35a3dc65cf4044aabe Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Thu, 14 Oct 2010 16:14:18 +0200 Subject: Rights Check --- server/cldb.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/cldb.erl b/server/cldb.erl index 176576c..982aafc 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -1,7 +1,7 @@ % The clientdatabase -module(cldb). --export([init/0, ask/2, login/2, decVote/2, incVote/2, register/3]). +-export([init/0, ask/2, login/2, decVote/2, incVote/2, register/3, check_rights/2]). -record(user, {name, passwd, votes, rights}). init() -> @@ -47,4 +47,7 @@ incVote(User, Pwd) -> end, mnesia:transaction(F). +check_rights(User, Name) -> + {_, _, Rights} = ask(User, Name), + Rights. -- cgit v1.2.3