This patch makes sure taxi files and playlists are excluded from the
list returned by GetSongs in karma-sharp.
--
Bob Copeland %% www.bobcopeland.com
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID ff44fc20e588eb3927e27ce4ee9b2e21b1b5dcba
# Parent c8215fe90df96779fe333ee3d6f3d279fd0f97ce
Only return songs in GetSongs
diff -r c8215fe90df9 -r ff44fc20e588 karma-sharp/Device.cs
--- a/karma-sharp/Device.cs Tue Jul 25 22:34:05 2006 -0400
+++ b/karma-sharp/Device.cs Sat Jul 29 16:14:01 2006 -0400
@@ -46,17 +46,19 @@ namespace Karma {
[DllImport ("karma")]
private static extern int lk_karma_delete_file(int rio, int fid);
+ [DllImport ("karma")]
+ private static extern int lk_karma_request_io_lock(int rio, int type);
+
+ [DllImport ("karma")]
+ private static extern int lk_karma_release_io_lock(int rio);
+
public event OnUploadHandler ProgressChanged;
public Device(string ipHostOrPath) {
- Console.WriteLine("In karma sharp device");
- Console.WriteLine("The path is: " + ipHostOrPath);
-
rio_id = lk_karma_connect(ipHostOrPath);
if (rio_id < 0)
throw new ApplicationException("Failed to connect");
- Console.WriteLine("connected");
lk_karma_use_smalldb();
lk_karma_load_database(rio_id);
}
@@ -80,7 +82,8 @@ namespace Karma {
return details;
}
- public ICollection GetSongs() {
+ public ICollection GetSongs()
+ {
ArrayList songs = new ArrayList();
IntPtr fids = lk_properties_andOrSearch(0, IntPtr.Zero, "fid", "");
@@ -89,9 +92,10 @@ namespace Karma {
int offset=0;
int fid;
- while ((fid = Marshal.ReadInt32(fids, offset)) != 0)
- {
- songs.Add(new Song(fid));
+ while ((fid = Marshal.ReadInt32(fids, offset)) != 0) {
+ Song tmp = new Song(fid);
+ if (tmp.Type.Equals("tune"))
+ songs.Add(tmp);
offset += 4;
}
return songs;
@@ -104,13 +108,14 @@ namespace Karma {
public void DeleteSong(int id)
{
+ lk_karma_request_io_lock(rio_id, 1);
lk_karma_delete_file(rio_id, id);
+ lk_karma_release_io_lock(rio_id);
}
public void Save()
{
- // lk_karma_request_io_lock()
- // lk_synchronize_necessary()
+ lk_karma_request_io_lock(rio_id, 1);
foreach (string filename in filesToAdd) {
int fid = lk_rio_write(rio_id, filename);
@@ -119,7 +124,7 @@ namespace Karma {
}
}
filesToAdd.Clear();
- // lk_karma_release_io_lock()
+ lk_karma_release_io_lock(rio_id);
lk_karma_write_smalldb();
}
}
diff -r c8215fe90df9 -r ff44fc20e588 karma-sharp/Song.cs
--- a/karma-sharp/Song.cs Tue Jul 25 22:34:05 2006 -0400
+++ b/karma-sharp/Song.cs Sat Jul 29 16:14:01 2006 -0400
@@ -62,6 +62,10 @@ namespace Karma {
get { return GetString("title"); }
}
+ public string Type {
+ get { return GetString("type"); }
+ }
+
public uint TrackNumber {
get { return (uint) GetInt("tracknr"); }
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel