Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
2006-04-17 Aaron Bockover <aaron@abock.org>
Browse files Browse the repository at this point in the history
    * src/NjbTest.cs: Added --hal-fdi-dump to generate HAL FDI entries for
    all devices listed in DeviceId

    * src/DeviceId.cs: Added support for storing input/output formats


svn path=/trunk/njb-sharp/; revision=59542
  • Loading branch information
abock committed Apr 17, 2006
1 parent 05fb2c3 commit 45b2475
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 35 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2006-04-17 Aaron Bockover <aaron@abock.org>

* src/NjbTest.cs: Added --hal-fdi-dump to generate HAL FDI entries for
all devices listed in DeviceId

* src/DeviceId.cs: Added support for storing input/output formats

2006-04-13 Aaron Bockover <aaron@abock.org>

* configure.ac: Bump to 0.3.0
Expand Down
71 changes: 38 additions & 33 deletions src/DeviceId.cs
Expand Up @@ -2,8 +2,8 @@
/***************************************************************************
* DeviceId.cs
*
* Copyright (C) 2005 Novell
* Written by Aaron Bockover (aaron@aaronbock.net)
* Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/

/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
Expand Down Expand Up @@ -32,27 +32,27 @@ namespace Njb
public class DeviceId
{
private static DeviceId [] device_id_list = {
// Full Device Name Display/Short Name Vendor ID Product ID
new DeviceId("Creative Nomad Jukebox", "Nomad Jukebox", 0x0471, 0x0222),
new DeviceId("Creative Nomad Jukebox 2", "Nomad Jukebox", 0x041e, 0x4100),
new DeviceId("Creative Nomad Jukebox 3", "Nomad Jukebox", 0x041e, 0x4101),
new DeviceId("Creative Nomad Jukebox Zen", "Zen Jukebox", 0x041e, 0x4108),
new DeviceId("Creative Nomad Jukebox Zen USB 2.0", "Zen Jukebox", 0x041e, 0x410b),
new DeviceId("Creative Nomad Jukebox Zen NX", "Zen NX Jukebox", 0x041e, 0x4109),
new DeviceId("Creative Nomad Jukebox Zen Xtra", "Zen Xtra Jukebox", 0x041e, 0x4110),
new DeviceId("Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4111),
new DeviceId("Creative Nomad Jukebox Zen Touch", "Nomad Jukebox", 0x041e, 0x411b),
new DeviceId("Creative Zen (Zen Micro variant)", "Zen Micro", 0x041e, 0x411d),
new DeviceId("Creative Nomad Jukebox Zen Micro", "Zen Micro", 0x041e, 0x411e),
new DeviceId("Second Generation Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4126),
new DeviceId("Dell Pocket DJ", "Dell Pocket DJ", 0x041e, 0x4127),
new DeviceId("Creative Zen Sleek", "Zen Sleek", 0x041e, 0x4136)
// Full Device Name Display/Short Name Vendor ID Product ID Output formats Input Formats
new DeviceId("Creative Nomad Jukebox", "Nomad Jukebox", 0x0471, 0x0222, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox 2", "Nomad Jukebox", 0x041e, 0x4100, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox 3", "Nomad Jukebox", 0x041e, 0x4101, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen", "Zen Jukebox", 0x041e, 0x4108, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen USB 2.0", "Zen Jukebox", 0x041e, 0x410b, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen NX", "Zen NX Jukebox", 0x041e, 0x4109, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen Xtra", "Zen Xtra Jukebox", 0x041e, 0x4110, new string [] { "audio/mpeg" }, null),
new DeviceId("Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4111, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen Touch", "Nomad Jukebox", 0x041e, 0x411b, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Zen (Zen Micro variant)", "Zen Micro", 0x041e, 0x411d, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Nomad Jukebox Zen Micro", "Zen Micro", 0x041e, 0x411e, new string [] { "audio/mpeg" }, null),
new DeviceId("Second Generation Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4126, new string [] { "audio/mpeg" }, null),
new DeviceId("Dell Pocket DJ", "Dell Pocket DJ", 0x041e, 0x4127, new string [] { "audio/mpeg" }, null),
new DeviceId("Creative Zen Sleek", "Zen Sleek", 0x041e, 0x4136, new string [] { "audio/mpeg" }, null)
};

private static string [] EmptyArray = new string [] { };

public static DeviceId [] ListAll {
get {
return device_id_list;
}
get { return device_id_list; }
}

public static bool IsNjbDevice(short vendorId, short productId)
Expand All @@ -75,37 +75,42 @@ public static DeviceId GetDeviceId(short vendorId, short productId)
private string display_name;
private short vendor_id;
private short product_id;
private string [] output_formats;
private string [] input_formats;

private DeviceId(string name, string displayName, short vendorId, short productId)
private DeviceId(string name, string displayName, short vendorId, short productId,
string [] outputFormats, string [] inputFormats)
{
this.name = name;
this.display_name = displayName;
this.vendor_id = vendorId;
this.product_id = productId;
this.output_formats = outputFormats;
this.input_formats = inputFormats;
}

public string Name {
get {
return name;
}
get { return name; }
}

public string DisplayName {
get {
return display_name;
}
get { return display_name; }
}

public short VendorId {
get {
return vendor_id;
}
get { return vendor_id; }
}

public short ProductId {
get {
return product_id;
}
get { return product_id; }
}

public string [] OutputFormats {
get { return output_formats == null ? EmptyArray : output_formats; }
}

public string [] InputFormats {
get { return input_formats == null ? EmptyArray : input_formats; }
}
}
}
39 changes: 37 additions & 2 deletions src/NjbTest.cs
Expand Up @@ -32,6 +32,36 @@

public class Test
{
public static void HalFdiDump()
{
Console.WriteLine(" <match key=\"info.bus\" string=\"usb\">\n\n");
Console.WriteLine(" <!-- Begin NJB devices (generated by njb-sharp for libnjb compatible devices) -->\n");
foreach(DeviceId device in DeviceId.ListAll) {
Console.WriteLine(" <!-- {0} -->", device.Name);
Console.WriteLine(" <match key=\"usb.vendor_id\" int=\"0x{0:x4}\">", device.VendorId);
Console.WriteLine(" <match key=\"usb.product_id\" int=\"0x{0:x4}\">", device.ProductId);
Console.WriteLine(" <append key=\"info.capabilities\" type=\"strlist\">portable_audio_player</append>");
Console.WriteLine(" <merge key=\"info.category\" type=\"string\">portable_audio_player</merge>");
Console.WriteLine(" <merge key=\"portable_audio_player.type\" type=\"string\">njb</merge>");
Console.WriteLine(" <merge key=\"portable_audio_player.access_method\" type=\"string\">user</merge>");

foreach(string output_format in device.OutputFormats) {
Console.WriteLine(" <append key=\"portable_audio_player.output_formats\" type=\"strlist\">{0}</append>", output_format);
}

foreach(string input_format in device.InputFormats) {
Console.WriteLine(" <append key=\"portable_audio_player.input_formats\" type=\"strlist\">{0}</append>", input_format);
}

Console.WriteLine(" </match>");
Console.WriteLine(" </match>\n");
}

Console.WriteLine(" <!-- End NJB devices -->");

Console.WriteLine("\n\n </match>");
}

public static void Assert(bool assert, string msg)
{
if(!assert) {
Expand All @@ -41,6 +71,11 @@ public static void Assert(bool assert, string msg)

public static void Main(string [] args)
{
if(args[0] == "--hal-fdi-dump") {
HalFdiDump();
return;
}

Discoverer discoverer = new Discoverer();
//Global.Debug = Global.DebugFlags.ALL;

Expand Down Expand Up @@ -85,9 +120,9 @@ public static void Main(string [] args)
string filename = song.TrackNumber.ToString("00") + ". " + song.Artist
+ " - " + song.Title + "." + song.Codec.ToLower();

device.ReadProgressChanged += OnProgress;
device.ProgressChanged += OnProgress;
device.ReadSong(song, filename);
device.ReadProgressChanged -= OnProgress;
device.ProgressChanged -= OnProgress;

Console.WriteLine("");
}
Expand Down

0 comments on commit 45b2475

Please sign in to comment.