f-spot r4236 - in trunk/dpap-sharp: . DPAPService dpap-client dpap-server lib
- From: apart svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4236 - in trunk/dpap-sharp: . DPAPService dpap-client dpap-server lib
- Date: Mon, 11 Aug 2008 12:11:12 +0000 (UTC)
Author: apart
Date: Mon Aug 11 12:11:12 2008
New Revision: 4236
URL: http://svn.gnome.org/viewvc/f-spot?rev=4236&view=rev
Log:
Coding guidelines compatibility
Modified:
trunk/dpap-sharp/ChangeLog
trunk/dpap-sharp/DPAPService/DPAPService.cs
trunk/dpap-sharp/dpap-client/Main.cs
trunk/dpap-sharp/dpap-client/dpap-client.mdp
trunk/dpap-sharp/dpap-server/dpap-server.mdp
trunk/dpap-sharp/lib/Album.cs
trunk/dpap-sharp/lib/AssemblyInfo.cs
trunk/dpap-sharp/lib/BrokenMD5.cs
trunk/dpap-sharp/lib/Client.cs
trunk/dpap-sharp/lib/ContentCodeBag.cs
trunk/dpap-sharp/lib/ContentFetcher.cs
trunk/dpap-sharp/lib/ContentParser.cs
trunk/dpap-sharp/lib/ContentWriter.cs
trunk/dpap-sharp/lib/Database.cs
trunk/dpap-sharp/lib/Discovery.cs
trunk/dpap-sharp/lib/Hasher.cs
trunk/dpap-sharp/lib/Photo.cs
trunk/dpap-sharp/lib/Server.cs
trunk/dpap-sharp/lib/ServerInfo.cs
Modified: trunk/dpap-sharp/DPAPService/DPAPService.cs
==============================================================================
--- trunk/dpap-sharp/DPAPService/DPAPService.cs (original)
+++ trunk/dpap-sharp/DPAPService/DPAPService.cs Mon Aug 11 12:11:12 2008
@@ -25,6 +25,7 @@
using FSpot.Extensions;
using FSpot.Utils;
using FSpot.Widgets;
+
using System.IO;
using DPAP;
using Gtk;
@@ -37,7 +38,7 @@
ServiceDiscovery sd;
Client client;
- public DPAPPageWidget()
+ public DPAPPageWidget ()
{
Console.WriteLine ("DPAP Page widget ctor!");
tree = new TreeView ();
@@ -48,22 +49,22 @@
Gtk.CellRendererText artistNameCell = new Gtk.CellRendererText ();
artistNameCell.Visible = true;
artistColumn.PackStart (artistNameCell,false);
- tree.AppendColumn(artistColumn);
+ tree.AppendColumn (artistColumn);
//tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
- list = new TreeStore (typeof(string));
+ list = new TreeStore (typeof (string));
tree.Model = list;
artistColumn.AddAttribute (artistNameCell, "text", 0);
- //list.AppendValues("test");
+ //list.AppendValues ("test");
tree.Selection.Changed += OnSelectionChanged;
- // tree.ShowNow();
- // ShowAll();
- sd = new DPAP.ServiceDiscovery();
+ // tree.ShowNow ();
+ // ShowAll ();
+ sd = new DPAP.ServiceDiscovery ();
sd.Found += OnServiceFound;
- sd.Start();
+ sd.Start ();
}
private void OnSelectionChanged (object o, EventArgs args)
@@ -77,7 +78,7 @@
model.GetValue (iter, 0, ref val);
data = (string) val.Val;
- if ( list.IterDepth (iter) == 0 )
+ if (list.IterDepth (iter) == 0)
Connect (data);
else
ViewAlbum (data);
@@ -89,50 +90,67 @@
private void ViewAlbum (string name)
{
Console.WriteLine ("View Album !");
- Database d = client.Databases[0];
- Directory.CreateDirectory ("/tmp/" + client.Databases[0].Name);
- foreach (DPAP.Photo ph in d.Photos)
+ Database d = client.Databases [0];
+
+ Directory.CreateDirectory ("/tmp/" + client.Databases [0].Name);
+ //Console.WriteLine ("Looking for album '" + name + "'");
+ foreach (DPAP.Album alb in d.Albums)
+ {
+ //Console.WriteLine ("\t -- album '" + alb.Name + "'");
+ if (!alb.Name.Equals (name))
+ continue;
+
+ Directory.CreateDirectory ("/tmp/" + client.Databases [0].Name + "/" + alb.Name);
+ foreach (DPAP.Photo ph in alb.Photos)
{
- if(ph != null)
+ if (ph != null)
{
- Console.WriteLine ("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
- d.DownloadPhoto (ph,"/tmp/" + client.Databases[0].Name + "/" + ph.FileName);
+ // Console.WriteLine ("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
+ d.DownloadPhoto (ph,"/tmp/" + client.Databases [0].Name + "/" + alb.Name + "/" + ph.FileName);
+ //FSpot.JpegFile = new JpegFile ("file:///tmp/" + client.Databases [0].Name + "/" + ph.FileName);
}
}
+ FSpot.Core.FindInstance ().View ("file:///tmp/" + client.Databases [0].Name + "/" + alb.Name);
+ break;
+ }
+
+
}
private void Connect (string svcName)
{
- Service service = sd.ServiceByName(svcName);
- System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
+ Service service = sd.ServiceByName (svcName);
+ System.Console.WriteLine ("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
- client = new Client( service );
+ client = new Client (service);
TreeIter iter;
- //list.GetIterFromString( out iter, svcName);
- list.GetIterFirst ( out iter );
+ //list.GetIterFromString (out iter, svcName);
+ list.GetIterFirst (out iter);
foreach (Database d in client.Databases){
- // list.AppendValues(iter,d.Name);
- Console.WriteLine("Database " + d.Name);
+ // list.AppendValues (iter,d.Name);
+ Console.WriteLine ("Database " + d.Name);
foreach (Album alb in d.Albums)
- list.AppendValues (iter, alb.Name);
- //Console.WriteLine("\tAlbum: "+alb.Name + ", id=" + alb.getId() + " number of items:" + alb.Photos.Count);
- // Console.WriteLine(d.Photos[0].FileName);
+ list.AppendValues (iter, alb.Name);
+
+ // Console.WriteLine ("\tAlbum: "+alb.Name + ", id=" + alb.getId () + " number of items:" + alb.Photos.Count);
+ // Console.WriteLine (d.Photos [0].FileName);
}
}
- private void OnServiceFound(object o, ServiceArgs args)
+ private void OnServiceFound (object o, ServiceArgs args)
{
Service service = args.Service;
- Console.WriteLine("ServiceFound " + service.Name);
- if(service.Name.Equals("f-spot photos")) return;
- list.AppendValues(service.Name);
-/* System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
+ Console.WriteLine ("ServiceFound " + service.Name);
+ if (service.Name.Equals ("f-spot photos")) return;
+ list.AppendValues (service.Name);
+
+/* System.Console.WriteLine ("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
- //client.Logout();
- //Console.WriteLine("Press <enter> to exit...");
+ //client.Logout ();
+ //Console.WriteLine ("Press <enter> to exit...");
*/
}
@@ -143,9 +161,9 @@
{
//public DPAPPage () { }
private static DPAPPageWidget widget;
- public DPAPPage() : base (new DPAPPageWidget(), "Shared items", "gtk-new")
+ public DPAPPage () : base (new DPAPPageWidget (), "Shared items", "gtk-new")
{
- Console.WriteLine("Starting DPAP client...");
+ Console.WriteLine ("Starting DPAP client...");
widget = (DPAPPageWidget)SidebarWidget;
}
@@ -158,12 +176,12 @@
static ServiceDiscovery sd;
public bool Start ()
{
- Console.WriteLine("Starting DPAP!");
+ Console.WriteLine ("Starting DPAP!");
uint timer = Log.InformationTimerStart ("Starting DPAP");
- // sd = new ServiceDiscovery();
+ // sd = new ServiceDiscovery ();
// sd.Found += OnServiceFound;
- // sd.Start();
- StartServer();
+ // sd.Start ();
+ StartServer ();
/* try {
@@ -176,10 +194,10 @@
}
private void StartServer ()
{
- Console.WriteLine("Starting DPAP server");
+ Console.WriteLine ("Starting DPAP server");
- DPAP.Database database = new DPAP.Database("DPAP");
- DPAP.Server server = new Server("f-spot photos");
+ DPAP.Database database = new DPAP.Database ("DPAP");
+ DPAP.Server server = new Server ("f-spot photos");
server.Port = 8770;
server.AuthenticationMethod = AuthenticationMethod.None;
int collision_count = 0;
@@ -188,58 +206,58 @@
};
- //FSpot.Photo photo = (FSpot.Photo) Core.Database.Photos.Get(1);
+ //FSpot.Photo photo = (FSpot.Photo) Core.Database.Photos.Get (1);
- Album a = new Album("test album");
- Tag t = Core.Database.Tags.GetTagByName("Shared items");
+ Album a = new Album ("test album");
+ Tag t = Core.Database.Tags.GetTagByName ("Shared items");
Tag []tags = {t};
- FSpot.Photo [] photos = Core.Database.Photos.Query(tags);
+ FSpot.Photo [] photos = Core.Database.Photos.Query (tags);
int i=0;
- foreach(FSpot.Photo photo in photos)
+ foreach (FSpot.Photo photo in photos)
{
string thumbnail_path = ThumbnailGenerator.ThumbnailPath (photo.DefaultVersionUri);
- FileInfo f = new FileInfo(thumbnail_path);
+ FileInfo f = new FileInfo (thumbnail_path);
- DPAP.Photo p = new DPAP.Photo();
+ DPAP.Photo p = new DPAP.Photo ();
p.FileName = photo.Name;
p.Thumbnail = thumbnail_path;
p.ThumbSize = (int)f.Length;
- p.Path = photo.DefaultVersionUri.ToString().Substring(7);
- f = new FileInfo(photo.DefaultVersionUri.ToString().Substring(7));
- if(!f.Exists)
+ p.Path = photo.DefaultVersionUri.ToString ().Substring (7);
+ f = new FileInfo (photo.DefaultVersionUri.ToString ().Substring (7));
+ if (!f.Exists)
continue;
- //if(++i > 2) break;
- Console.WriteLine("Found photo " + p.Path + ", thumb " + thumbnail_path);
+ //if (++i > 2) break;
+ Console.WriteLine ("Found photo " + p.Path + ", thumb " + thumbnail_path);
p.Title = f.Name;
p.Size = (int)f.Length;
p.Format = "JPEG";
- database.AddPhoto(p);
- a.AddPhoto(p);
+ database.AddPhoto (p);
+ a.AddPhoto (p);
}
- database.AddAlbum(a);
- Console.WriteLine("Album count is now " + database.Albums.Count);
-// Console.WriteLine("Photo name is " + database.Photos[0].FileName);
- server.AddDatabase(database);
+ database.AddAlbum (a);
+ Console.WriteLine ("Album count is now " + database.Albums.Count);
+// Console.WriteLine ("Photo name is " + database.Photos [0].FileName);
+ server.AddDatabase (database);
- //server.GetServerInfoNode();
+ //server.GetServerInfoNode ();
try {
- server.Start();
+ server.Start ();
} catch (System.Net.Sockets.SocketException) {
- Console.WriteLine("Server socket exception!");
+ Console.WriteLine ("Server socket exception!");
server.Port = 0;
- server.Start();
+ server.Start ();
}
- //DaapPlugin.ServerEnabledSchema.Set(true);
+ //DaapPlugin.ServerEnabledSchema.Set (true);
- // if(!initial_db_committed) {
- server.Commit();
+ // if (!initial_db_committed) {
+ server.Commit ();
// initial_db_committed = true;
// }
@@ -247,8 +265,8 @@
public bool Stop ()
{
uint timer = Log.InformationTimerStart ("Stopping DPAP");
- if(sd != null) {
- sd.Stop();
+ if (sd != null) {
+ sd.Stop ();
sd.Found -= OnServiceFound;
//locator.Removed -= OnServiceRemoved;
sd = null;
@@ -257,36 +275,36 @@
return true;
}
- private static void OnServiceFound(object o, ServiceArgs args)
+ private static void OnServiceFound (object o, ServiceArgs args)
{
Service service = args.Service;
Client client;
-// ThreadAssist.Spawn(delegate {
+// ThreadAssist.Spawn (delegate {
// try {
- System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
- client = new Client( service );
+ System.Console.WriteLine ("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
+ client = new Client (service);
foreach (Database d in client.Databases){
- Console.WriteLine("Database " + d.Name);
+ Console.WriteLine ("Database " + d.Name);
foreach (Album alb in d.Albums)
- Console.WriteLine("\tAlbum: "+alb.Name + ", id=" + alb.getId() + " number of items:" + alb.Photos.Count);
- Console.WriteLine(d.Photos[0].FileName);
+ Console.WriteLine ("\tAlbum: "+alb.Name + ", id=" + alb.getId () + " number of items:" + alb.Photos.Count);
+ Console.WriteLine (d.Photos [0].FileName);
foreach (DPAP.Photo ph in d.Photos)
{
- if(ph != null)
+ if (ph != null)
{
- Console.WriteLine("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
- d.DownloadPhoto(ph,"./"+ph.Title);
+ Console.WriteLine ("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
+ d.DownloadPhoto (ph,"./"+ph.Title);
}
}
}
- //client.Logout();
- // Console.WriteLine("Press <enter> to exit...");
+ //client.Logout ();
+ // Console.WriteLine ("Press <enter> to exit...");
}
/*private void HandleDbItemsChanged (object sender, DbItemEventArgs args)
Modified: trunk/dpap-sharp/dpap-client/Main.cs
==============================================================================
--- trunk/dpap-sharp/dpap-client/Main.cs (original)
+++ trunk/dpap-sharp/dpap-client/Main.cs Mon Aug 11 12:11:12 2008
@@ -36,54 +36,54 @@
class MainClass
{
- public static void Main(string[] args)
+ public static void Main (string [] args)
{
- ServiceDiscovery sd = new ServiceDiscovery();
+ ServiceDiscovery sd = new ServiceDiscovery ();
sd.Found += OnServiceFound;
- sd.Start();
+ sd.Start ();
-// sd.Services[0];
- Console.ReadLine();
- if(sd != null) {
- sd.Stop();
+// sd.Services [0];
+ Console.ReadLine ();
+ if (sd != null) {
+ sd.Stop ();
sd.Found -= OnServiceFound;
//locator.Removed -= OnServiceRemoved;
sd = null;
}
}
- private static void OnServiceFound(object o, ServiceArgs args)
+ private static void OnServiceFound (object o, ServiceArgs args)
{
Service service = args.Service;
Client client;
-// ThreadAssist.Spawn(delegate {
+// ThreadAssist.Spawn (delegate {
// try {
- System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
- client = new Client( service );
+ System.Console.WriteLine ("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
+ client = new Client (service);
foreach (Database d in client.Databases){
- Console.WriteLine("Database " + d.Name);
+ Console.WriteLine ("Database " + d.Name);
foreach (Album alb in d.Albums)
- Console.WriteLine("\tAlbum: "+alb.Name + ", id=" + alb.getId() + " number of items:" + alb.Photos.Count);
- Console.WriteLine(d.Photos[0].FileName);
+ Console.WriteLine ("\tAlbum: "+alb.Name + ", id=" + alb.getId () + " number of items:" + alb.Photos.Count);
+ Console.WriteLine (d.Photos [0].FileName);
foreach (Photo ph in d.Photos)
{
- if(ph != null)
+ if (ph != null)
{
- Console.WriteLine("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
- d.DownloadPhoto(ph,"./"+ph.Title);
+ Console.WriteLine ("\t\tFile: " + ph.Title + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
+ d.DownloadPhoto (ph,"./"+ph.Title);
}
}
}
- //client.Logout();
- //Console.WriteLine("Press <enter> to exit...");
+ //client.Logout ();
+ //Console.WriteLine ("Press <enter> to exit...");
}
Modified: trunk/dpap-sharp/dpap-client/dpap-client.mdp
==============================================================================
--- trunk/dpap-sharp/dpap-client/dpap-client.mdp (original)
+++ trunk/dpap-sharp/dpap-client/dpap-client.mdp Mon Aug 11 12:11:12 2008
@@ -18,8 +18,6 @@
<File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
- <ProjectReference type="Gac" localcopy="True" refto="Banshee.Core, Version=1.0.0.38867, Culture=neutral" />
- <ProjectReference type="Gac" localcopy="True" refto="Banshee.Services, Version=1.0.0.38868, Culture=neutral" />
<ProjectReference type="Assembly" localcopy="True" refto="../lib/dpap-sharp.dll" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../..">
Modified: trunk/dpap-sharp/dpap-server/dpap-server.mdp
==============================================================================
--- trunk/dpap-sharp/dpap-server/dpap-server.mdp (original)
+++ trunk/dpap-sharp/dpap-server/dpap-server.mdp Mon Aug 11 12:11:12 2008
@@ -18,8 +18,6 @@
<File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
- <ProjectReference type="Gac" localcopy="True" refto="Banshee.Core, Version=1.0.0.38867, Culture=neutral" />
- <ProjectReference type="Gac" localcopy="True" refto="Banshee.Services, Version=1.0.0.38868, Culture=neutral" />
<ProjectReference type="Project" localcopy="True" refto="dpap-sharp" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am" ExecuteTargetName="run" IsAutotoolsProject="True" RelativeConfigureInPath="../..">
Modified: trunk/dpap-sharp/lib/Album.cs
==============================================================================
--- trunk/dpap-sharp/lib/Album.cs (original)
+++ trunk/dpap-sharp/lib/Album.cs Mon Aug 11 12:11:12 2008
@@ -39,20 +39,20 @@
private int id;
private string name = String.Empty;
private List<Photo> photos = new List<Photo> ();
- private List<int> containerIds = new List<int> ();
+ private List<int> container_ids = new List<int> ();
public event AlbumPhotoHandler PhotoAdded;
public event AlbumPhotoHandler PhotoRemoved;
public event EventHandler NameChanged;
- public Photo this[int index] {
+ public Photo this [int index] {
get {
if (photos.Count > index)
- return photos[index];
+ return photos [index];
else
return null;
}
- set { photos[index] = value; }
+ set { photos [index] = value; }
}
public IList<Photo> Photos {
@@ -87,7 +87,7 @@
internal void InsertPhoto (int index, Photo photo, int id) {
photos.Insert (index, photo);
- containerIds.Insert (index, id);
+ container_ids.Insert (index, id);
if (PhotoAdded != null)
PhotoAdded (this, index, photo);
@@ -103,16 +103,16 @@
internal void AddPhoto (Photo photo, int id) {
photos.Add (photo);
- containerIds.Add (id);
+ container_ids.Add (id);
if (PhotoAdded != null)
PhotoAdded (this, photos.Count - 1, photo);
}
public void RemoveAt (int index) {
- Photo photo = (Photo) photos[index];
+ Photo photo = (Photo) photos [index];
photos.RemoveAt (index);
- containerIds.RemoveAt (index);
+ container_ids.RemoveAt (index);
if (PhotoRemoved != null)
PhotoRemoved (this, index, photo);
@@ -122,7 +122,7 @@
int index;
bool ret = false;
- while ((index = IndexOf (photo)) >= 0) {
+ while ( (index = IndexOf (photo)) >= 0) {
ret = true;
RemoveAt (index);
}
@@ -135,16 +135,16 @@
}
internal int GetContainerId (int index) {
- return (int) containerIds[index];
+ return (int) container_ids [index];
}
- internal ContentNode ToPhotosNode (string[] fields) {
- ArrayList photoNodes = new ArrayList ();
+ internal ContentNode ToPhotosNode (string [] fields) {
+ ArrayList photo_nodes = new ArrayList ();
for (int i = 0; i < photos.Count; i++) {
- Photo photo = photos[i] as Photo;
- photoNodes.Add (photo.ToAlbumNode(fields));
- //photoNodes.Add (photo.ToAlbumsNode ((int) containerIds[i]));
+ Photo photo = photos [i] as Photo;
+ photo_nodes.Add (photo.ToAlbumNode (fields));
+ //photo_nodes.Add (photo.ToAlbumsNode ( (int) container_ids [i]));
}
/*ArrayList deletedNodes = null;
@@ -161,7 +161,7 @@
children.Add (new ContentNode ("dmap.updatetype", (byte) 0));
children.Add (new ContentNode ("dmap.specifiedtotalcount", photos.Count));
children.Add (new ContentNode ("dmap.returnedcount", photos.Count));
- children.Add (new ContentNode ("dmap.listing", photoNodes));
+ children.Add (new ContentNode ("dmap.listing", photo_nodes));
// if (deletedNodes != null)
// children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
@@ -187,7 +187,7 @@
internal static Album FromNode (ContentNode node) {
Album pl = new Album ();
- foreach (ContentNode child in (ContentNode[]) node.Value) {
+ foreach (ContentNode child in (ContentNode []) node.Value) {
switch (child.Name) {
case "dpap.baseplaylist":
return null;
@@ -213,10 +213,10 @@
}
internal int LookupIndexByContainerId (int id) {
- return containerIds.IndexOf (id);
+ return container_ids.IndexOf (id);
}
- public int getId() {
+ public int getId () {
return Id;
}
}
Modified: trunk/dpap-sharp/lib/AssemblyInfo.cs
==============================================================================
--- trunk/dpap-sharp/lib/AssemblyInfo.cs (original)
+++ trunk/dpap-sharp/lib/AssemblyInfo.cs Mon Aug 11 12:11:12 2008
@@ -9,22 +9,22 @@
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
-[assembly: AssemblyTitle("dpap-sharp")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+ [assembly: AssemblyTitle ("dpap-sharp")]
+ [assembly: AssemblyDescription ("")]
+ [assembly: AssemblyConfiguration ("")]
+ [assembly: AssemblyCompany ("")]
+ [assembly: AssemblyProduct ("")]
+ [assembly: AssemblyCopyright ("")]
+ [assembly: AssemblyTrademark ("")]
+ [assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// If the build and revision are set to '*' they will be updated automatically.
-[assembly: AssemblyVersion("1.0.*.*")]
+ [assembly: AssemblyVersion ("1.0.*.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
+ [assembly: AssemblyDelaySign (false)]
+ [assembly: AssemblyKeyFile ("")]
Modified: trunk/dpap-sharp/lib/BrokenMD5.cs
==============================================================================
--- trunk/dpap-sharp/lib/BrokenMD5.cs (original)
+++ trunk/dpap-sharp/lib/BrokenMD5.cs Mon Aug 11 12:11:12 2008
@@ -59,21 +59,21 @@
internal class BrokenMD5 : MD5 {
private const int BLOCK_SIZE_BYTES = 64;
private const int HASH_SIZE_BYTES = 16;
- private uint[] _H;
- private uint[] buff;
+ private uint [] _H;
+ private uint [] buff;
private ulong count;
- private byte[] _ProcessingBuffer; // Used to start data when passed less than a block worth.
+ private byte [] _ProcessingBuffer; // Used to start data when passed less than a block worth.
private int _ProcessingBufferCount; // Counts how much data we have stored that still needs processed.
private int _version;
public BrokenMD5 ( int version )
{
- _H = new uint[4];
- buff = new uint[16];
+ _H = new uint [4];
+ buff = new uint [16];
_ProcessingBuffer = new byte [BLOCK_SIZE_BYTES];
_version = version;
- Initialize();
+ Initialize ();
}
~BrokenMD5 ()
@@ -97,7 +97,7 @@
}
}
- protected override void HashCore (byte[] rgb, int start, int size)
+ protected override void HashCore (byte [] rgb, int start, int size)
{
int i;
State = 1;
@@ -128,16 +128,16 @@
}
}
- protected override byte[] HashFinal ()
+ protected override byte [] HashFinal ()
{
- byte[] hash = new byte[16];
+ byte [] hash = new byte [16];
int i, j;
ProcessFinalBlock (_ProcessingBuffer, 0, _ProcessingBufferCount);
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
- hash[i*4+j] = (byte)(_H[i] >> j*8);
+ hash [i*4+j] = (byte) (_H [i] >> j*8);
}
}
@@ -149,13 +149,13 @@
count = 0;
_ProcessingBufferCount = 0;
- _H[0] = 0x67452301;
- _H[1] = 0xefcdab89;
- _H[2] = 0x98badcfe;
- _H[3] = 0x10325476;
+ _H [0] = 0x67452301;
+ _H [1] = 0xefcdab89;
+ _H [2] = 0x98badcfe;
+ _H [3] = 0x10325476;
}
- private void ProcessBlock (byte[] inputBuffer, int inputOffset)
+ private void ProcessBlock (byte [] inputBuffer, int inputOffset)
{
uint a, b, c, d;
int i;
@@ -163,159 +163,159 @@
count += BLOCK_SIZE_BYTES;
for (i=0; i<16; i++) {
- buff[i] = (uint)(inputBuffer[inputOffset+4*i])
- | (((uint)(inputBuffer[inputOffset+4*i+1])) << 8)
- | (((uint)(inputBuffer[inputOffset+4*i+2])) << 16)
- | (((uint)(inputBuffer[inputOffset+4*i+3])) << 24);
+ buff [i] = (uint) (inputBuffer [inputOffset+4*i])
+ | ( ( (uint) (inputBuffer [inputOffset+4*i+1])) << 8)
+ | ( ( (uint) (inputBuffer [inputOffset+4*i+2])) << 16)
+ | ( ( (uint) (inputBuffer [inputOffset+4*i+3])) << 24);
}
- a = _H[0];
- b = _H[1];
- c = _H[2];
- d = _H[3];
+ a = _H [0];
+ b = _H [1];
+ c = _H [2];
+ d = _H [3];
// This function was unrolled because it seems to be doubling our performance with current compiler/VM.
// Possibly roll up if this changes.
// ---- Round 1 --------
- a += (((c ^ d) & b) ^ d) + (uint) K [0] + buff [0];
+ a += ( ( (c ^ d) & b) ^ d) + (uint) K [0] + buff [0];
a = (a << 7) | (a >> 25);
a += b;
- d += (((b ^ c) & a) ^ c) + (uint) K [1] + buff [1];
+ d += ( ( (b ^ c) & a) ^ c) + (uint) K [1] + buff [1];
d = (d << 12) | (d >> 20);
d += a;
- c += (((a ^ b) & d) ^ b) + (uint) K [2] + buff [2];
+ c += ( ( (a ^ b) & d) ^ b) + (uint) K [2] + buff [2];
c = (c << 17) | (c >> 15);
c += d;
- b += (((d ^ a) & c) ^ a) + (uint) K [3] + buff [3];
+ b += ( ( (d ^ a) & c) ^ a) + (uint) K [3] + buff [3];
b = (b << 22) | (b >> 10);
b += c;
- a += (((c ^ d) & b) ^ d) + (uint) K [4] + buff [4];
+ a += ( ( (c ^ d) & b) ^ d) + (uint) K [4] + buff [4];
a = (a << 7) | (a >> 25);
a += b;
- d += (((b ^ c) & a) ^ c) + (uint) K [5] + buff [5];
+ d += ( ( (b ^ c) & a) ^ c) + (uint) K [5] + buff [5];
d = (d << 12) | (d >> 20);
d += a;
- c += (((a ^ b) & d) ^ b) + (uint) K [6] + buff [6];
+ c += ( ( (a ^ b) & d) ^ b) + (uint) K [6] + buff [6];
c = (c << 17) | (c >> 15);
c += d;
- b += (((d ^ a) & c) ^ a) + (uint) K [7] + buff [7];
+ b += ( ( (d ^ a) & c) ^ a) + (uint) K [7] + buff [7];
b = (b << 22) | (b >> 10);
b += c;
- a += (((c ^ d) & b) ^ d) + (uint) K [8] + buff [8];
+ a += ( ( (c ^ d) & b) ^ d) + (uint) K [8] + buff [8];
a = (a << 7) | (a >> 25);
a += b;
- d += (((b ^ c) & a) ^ c) + (uint) K [9] + buff [9];
+ d += ( ( (b ^ c) & a) ^ c) + (uint) K [9] + buff [9];
d = (d << 12) | (d >> 20);
d += a;
- c += (((a ^ b) & d) ^ b) + (uint) K [10] + buff [10];
+ c += ( ( (a ^ b) & d) ^ b) + (uint) K [10] + buff [10];
c = (c << 17) | (c >> 15);
c += d;
- b += (((d ^ a) & c) ^ a) + (uint) K [11] + buff [11];
+ b += ( ( (d ^ a) & c) ^ a) + (uint) K [11] + buff [11];
b = (b << 22) | (b >> 10);
b += c;
- a += (((c ^ d) & b) ^ d) + (uint) K [12] + buff [12];
+ a += ( ( (c ^ d) & b) ^ d) + (uint) K [12] + buff [12];
a = (a << 7) | (a >> 25);
a += b;
- d += (((b ^ c) & a) ^ c) + (uint) K [13] + buff [13];
+ d += ( ( (b ^ c) & a) ^ c) + (uint) K [13] + buff [13];
d = (d << 12) | (d >> 20);
d += a;
- c += (((a ^ b) & d) ^ b) + (uint) K [14] + buff [14];
+ c += ( ( (a ^ b) & d) ^ b) + (uint) K [14] + buff [14];
c = (c << 17) | (c >> 15);
c += d;
- b += (((d ^ a) & c) ^ a) + (uint) K [15] + buff [15];
+ b += ( ( (d ^ a) & c) ^ a) + (uint) K [15] + buff [15];
b = (b << 22) | (b >> 10);
b += c;
// ---- Round 2 --------
- a += (((b ^ c) & d) ^ c) + (uint) K [16] + buff [1];
+ a += ( ( (b ^ c) & d) ^ c) + (uint) K [16] + buff [1];
a = (a << 5) | (a >> 27);
a += b;
- d += (((a ^ b) & c) ^ b) + (uint) K [17] + buff [6];
+ d += ( ( (a ^ b) & c) ^ b) + (uint) K [17] + buff [6];
d = (d << 9) | (d >> 23);
d += a;
- c += (((d ^ a) & b) ^ a) + (uint) K [18] + buff [11];
+ c += ( ( (d ^ a) & b) ^ a) + (uint) K [18] + buff [11];
c = (c << 14) | (c >> 18);
c += d;
- b += (((c ^ d) & a) ^ d) + (uint) K [19] + buff [0];
+ b += ( ( (c ^ d) & a) ^ d) + (uint) K [19] + buff [0];
b = (b << 20) | (b >> 12);
b += c;
- a += (((b ^ c) & d) ^ c) + (uint) K [20] + buff [5];
+ a += ( ( (b ^ c) & d) ^ c) + (uint) K [20] + buff [5];
a = (a << 5) | (a >> 27);
a += b;
- d += (((a ^ b) & c) ^ b) + (uint) K [21] + buff [10];
+ d += ( ( (a ^ b) & c) ^ b) + (uint) K [21] + buff [10];
d = (d << 9) | (d >> 23);
d += a;
- c += (((d ^ a) & b) ^ a) + (uint) K [22] + buff [15];
+ c += ( ( (d ^ a) & b) ^ a) + (uint) K [22] + buff [15];
c = (c << 14) | (c >> 18);
c += d;
- b += (((c ^ d) & a) ^ d) + (uint) K [23] + buff [4];
+ b += ( ( (c ^ d) & a) ^ d) + (uint) K [23] + buff [4];
b = (b << 20) | (b >> 12);
b += c;
- a += (((b ^ c) & d) ^ c) + (uint) K [24] + buff [9];
+ a += ( ( (b ^ c) & d) ^ c) + (uint) K [24] + buff [9];
a = (a << 5) | (a >> 27);
a += b;
- d += (((a ^ b) & c) ^ b) + (uint) K [25] + buff [14];
+ d += ( ( (a ^ b) & c) ^ b) + (uint) K [25] + buff [14];
d = (d << 9) | (d >> 23);
d += a;
- c += (((d ^ a) & b) ^ a) + (uint) K [26] + buff [3];
+ c += ( ( (d ^ a) & b) ^ a) + (uint) K [26] + buff [3];
c = (c << 14) | (c >> 18);
c += d;
- if( _version == 1 )
+ if ( _version == 1 )
{
- b += (((c ^ d) & a) ^ d) + (uint) 0x445a14ed + buff [8];
+ b += ( ( (c ^ d) & a) ^ d) + (uint) 0x445a14ed + buff [8];
b = (b << 20) | (b >> 12);
b += c;
}
else
{
- b += (((c ^ d) & a) ^ d) + (uint) K [27] + buff [8];
+ b += ( ( (c ^ d) & a) ^ d) + (uint) K [27] + buff [8];
b = (b << 20) | (b >> 12);
b += c;
}
- a += (((b ^ c) & d) ^ c) + (uint) K [28] + buff [13];
+ a += ( ( (b ^ c) & d) ^ c) + (uint) K [28] + buff [13];
a = (a << 5) | (a >> 27);
a += b;
- d += (((a ^ b) & c) ^ b) + (uint) K [29] + buff [2];
+ d += ( ( (a ^ b) & c) ^ b) + (uint) K [29] + buff [2];
d = (d << 9) | (d >> 23);
d += a;
- c += (((d ^ a) & b) ^ a) + (uint) K [30] + buff [7];
+ c += ( ( (d ^ a) & b) ^ a) + (uint) K [30] + buff [7];
c = (c << 14) | (c >> 18);
c += d;
- b += (((c ^ d) & a) ^ d) + (uint) K [31] + buff [12];
+ b += ( ( (c ^ d) & a) ^ d) + (uint) K [31] + buff [12];
b = (b << 20) | (b >> 12);
b += c;
@@ -389,67 +389,67 @@
// ---- Round 4 --------
- a += (((~d) | b) ^ c) + (uint) K [48] + buff [0];
+ a += ( ( (~d) | b) ^ c) + (uint) K [48] + buff [0];
a = (a << 6) | (a >> 26);
a += b;
- d += (((~c) | a) ^ b) + (uint) K [49] + buff [7];
+ d += ( ( (~c) | a) ^ b) + (uint) K [49] + buff [7];
d = (d << 10) | (d >> 22);
d += a;
- c += (((~b) | d) ^ a) + (uint) K [50] + buff [14];
+ c += ( ( (~b) | d) ^ a) + (uint) K [50] + buff [14];
c = (c << 15) | (c >> 17);
c += d;
- b += (((~a) | c) ^ d) + (uint) K [51] + buff [5];
+ b += ( ( (~a) | c) ^ d) + (uint) K [51] + buff [5];
b = (b << 21) | (b >> 11);
b += c;
- a += (((~d) | b) ^ c) + (uint) K [52] + buff [12];
+ a += ( ( (~d) | b) ^ c) + (uint) K [52] + buff [12];
a = (a << 6) | (a >> 26);
a += b;
- d += (((~c) | a) ^ b) + (uint) K [53] + buff [3];
+ d += ( ( (~c) | a) ^ b) + (uint) K [53] + buff [3];
d = (d << 10) | (d >> 22);
d += a;
- c += (((~b) | d) ^ a) + (uint) K [54] + buff [10];
+ c += ( ( (~b) | d) ^ a) + (uint) K [54] + buff [10];
c = (c << 15) | (c >> 17);
c += d;
- b += (((~a) | c) ^ d) + (uint) K [55] + buff [1];
+ b += ( ( (~a) | c) ^ d) + (uint) K [55] + buff [1];
b = (b << 21) | (b >> 11);
b += c;
- a += (((~d) | b) ^ c) + (uint) K [56] + buff [8];
+ a += ( ( (~d) | b) ^ c) + (uint) K [56] + buff [8];
a = (a << 6) | (a >> 26);
a += b;
- d += (((~c) | a) ^ b) + (uint) K [57] + buff [15];
+ d += ( ( (~c) | a) ^ b) + (uint) K [57] + buff [15];
d = (d << 10) | (d >> 22);
d += a;
- c += (((~b) | d) ^ a) + (uint) K [58] + buff [6];
+ c += ( ( (~b) | d) ^ a) + (uint) K [58] + buff [6];
c = (c << 15) | (c >> 17);
c += d;
- b += (((~a) | c) ^ d) + (uint) K [59] + buff [13];
+ b += ( ( (~a) | c) ^ d) + (uint) K [59] + buff [13];
b = (b << 21) | (b >> 11);
b += c;
- a += (((~d) | b) ^ c) + (uint) K [60] + buff [4];
+ a += ( ( (~d) | b) ^ c) + (uint) K [60] + buff [4];
a = (a << 6) | (a >> 26);
a += b;
- d += (((~c) | a) ^ b) + (uint) K [61] + buff [11];
+ d += ( ( (~c) | a) ^ b) + (uint) K [61] + buff [11];
d = (d << 10) | (d >> 22);
d += a;
- c += (((~b) | d) ^ a) + (uint) K [62] + buff [2];
+ c += ( ( (~b) | d) ^ a) + (uint) K [62] + buff [2];
c = (c << 15) | (c >> 17);
c += d;
- b += (((~a) | c) ^ d) + (uint) K [63] + buff [9];
+ b += ( ( (~a) | c) ^ d) + (uint) K [63] + buff [9];
b = (b << 21) | (b >> 11);
b += c;
@@ -459,23 +459,23 @@
_H [3] += d;
}
- private void ProcessFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount)
+ private void ProcessFinalBlock (byte [] inputBuffer, int inputOffset, int inputCount)
{
ulong total = count + (ulong)inputCount;
- int paddingSize = (int)(56 - total % BLOCK_SIZE_BYTES);
+ int paddingSize = (int) (56 - total % BLOCK_SIZE_BYTES);
if (paddingSize < 1)
paddingSize += BLOCK_SIZE_BYTES;
- byte[] fooBuffer = new byte [inputCount+paddingSize+8];
+ byte [] fooBuffer = new byte [inputCount+paddingSize+8];
for (int i=0; i<inputCount; i++) {
- fooBuffer[i] = inputBuffer[i+inputOffset];
+ fooBuffer [i] = inputBuffer [i+inputOffset];
}
- fooBuffer[inputCount] = 0x80;
+ fooBuffer [inputCount] = 0x80;
for (int i=inputCount+1; i<inputCount+paddingSize; i++) {
- fooBuffer[i] = 0x00;
+ fooBuffer [i] = 0x00;
}
// I deal in bytes. The algorithm deals in bits.
@@ -484,23 +484,23 @@
ProcessBlock (fooBuffer, 0);
if (inputCount+paddingSize+8 == 128) {
- ProcessBlock(fooBuffer, 64);
+ ProcessBlock (fooBuffer, 64);
}
}
- internal void AddLength (ulong length, byte[] buffer, int position)
+ internal void AddLength (ulong length, byte [] buffer, int position)
{
- buffer [position++] = (byte)(length);
- buffer [position++] = (byte)(length >> 8);
- buffer [position++] = (byte)(length >> 16);
- buffer [position++] = (byte)(length >> 24);
- buffer [position++] = (byte)(length >> 32);
- buffer [position++] = (byte)(length >> 40);
- buffer [position++] = (byte)(length >> 48);
- buffer [position] = (byte)(length >> 56);
+ buffer [position++] = (byte) (length);
+ buffer [position++] = (byte) (length >> 8);
+ buffer [position++] = (byte) (length >> 16);
+ buffer [position++] = (byte) (length >> 24);
+ buffer [position++] = (byte) (length >> 32);
+ buffer [position++] = (byte) (length >> 40);
+ buffer [position++] = (byte) (length >> 48);
+ buffer [position] = (byte) (length >> 56);
}
- private readonly static uint[] K = {
+ private readonly static uint [] K = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
Modified: trunk/dpap-sharp/lib/Client.cs
==============================================================================
--- trunk/dpap-sharp/lib/Client.cs (original)
+++ trunk/dpap-sharp/lib/Client.cs Mon Aug 11 12:11:12 2008
@@ -46,11 +46,11 @@
private IPAddress address;
private UInt16 port;
private ContentCodeBag bag;
- private ServerInfo serverInfo;
+ private ServerInfo server_info;
private List<Database> databases = new List<Database> ();
private ContentFetcher fetcher;
private int revision;
- private bool updateRunning;
+ private bool update_running;
public event EventHandler Updated;
@@ -59,7 +59,7 @@
}
public string Name {
- get { return serverInfo.Name; }
+ get { return server_info.Name; }
}
public IPAddress Address {
@@ -71,7 +71,7 @@
}
public AuthenticationMethod AuthenticationMethod {
- get { return serverInfo.AuthenticationMethod; }
+ get { return server_info.AuthenticationMethod; }
}
public IList<Database> Databases {
@@ -89,7 +89,7 @@
public Client (Service service) : this (service.Address, service.Port) {
}
- public Client (string host, UInt16 port) : this (Dns.GetHostEntry (host).AddressList[0], port) {
+ public Client (string host, UInt16 port) : this (Dns.GetHostEntry (host).AddressList [0], port) {
}
public Client (IPAddress address, UInt16 port) {
@@ -97,12 +97,8 @@
this.port = port;
fetcher = new ContentFetcher (address, port);
- Login(null,null);
- //byte[] resp= fetcher.Fetch("/server-info");
- //resp= fetcher.Fetch("/login");
- // ContentNode node = ContentParser.Parse (ContentCodeBag.Default, fetcher.Fetch ("/server-info"));
- // Console.WriteLine("Odczytalem {0}, {1}", node.Name, node.Value);
- // serverInfo = ServerInfo.FromNode (node);
+ Login (null,null);
+
}
~Client () {
@@ -110,7 +106,7 @@
}
public void Dispose () {
- updateRunning = false;
+ update_running = false;
if (fetcher != null) {
fetcher.Dispose ();
@@ -136,19 +132,15 @@
try {
bag = ContentCodeBag.ParseCodes (fetcher.Fetch ("/content-codes"));
- // ContentNode n = bag.ToNode();
- // n.Dump();
+
ContentNode node = ContentParser.Parse (bag, fetcher.Fetch ("/login"));
ParseSessionId (node);
- //byte[] db_reply = fetcher.Fetch ("/databases");
-
- //Console.Write(BitConverter.ToString(db_reply));
- // ContentNode dbnode = ContentParser.Parse (bag, fetcher.Fetch ("/databases"));
+
FetchDatabases ();
Refresh ();
-
- /* if (serverInfo.SupportsUpdate) {
- updateRunning = true;
+ // FIXME - the update handling mechanism is currently disabled
+ /* if (server_info.SupportsUpdate) {
+ update_running = true;
Thread thread = new Thread (UpdateLoop);
thread.IsBackground = true;
thread.Start ();
@@ -165,7 +157,7 @@
public void Logout () {
try {
- updateRunning = false;
+ update_running = false;
fetcher.KillAll ();
fetcher.Fetch ("/logout");
} catch (WebException) {
@@ -178,38 +170,39 @@
private void FetchDatabases () {
ContentNode dbnode = ContentParser.Parse (bag, fetcher.Fetch ("/databases"));
// DEBUG
- //dbnode.Dump();
- foreach (ContentNode child in (ContentNode[]) dbnode.Value) {
+ //dbnode.Dump ();
+
+ foreach (ContentNode child in (ContentNode []) dbnode.Value) {
if (child.Name != "dmap.listing")
continue;
- foreach (ContentNode item in (ContentNode[]) child.Value) {
+ foreach (ContentNode item in (ContentNode []) child.Value) {
// DEBUG
- //item.Dump();
+ //item.Dump ();
Database db = new Database (this, item);
- Console.WriteLine("Adding database {0} with id={1} and album count={2}." , db.Name,db.Id,db.Albums.Count);
- //Console.WriteLine("Photo " + db.Photos[0].FileName);
+ Console.WriteLine ("Adding database {0} with id={1} and album count={2}." , db.Name,db.Id,db.Albums.Count);
+ //Console.WriteLine ("Photo " + db.Photos [0].FileName);
databases.Add (db);
}
}
}
private int GetCurrentRevision () {
- ContentNode revNode = ContentParser.Parse (bag, fetcher.Fetch ("/update"), "dmap.serverrevision");
- return (int) revNode.Value;
+ ContentNode rev_node = ContentParser.Parse (bag, fetcher.Fetch ("/update"), "dmap.serverrevision");
+ return (int) rev_node.Value;
}
private int WaitForRevision (int currentRevision) {
- ContentNode revNode = ContentParser.Parse (bag, fetcher.Fetch ("/update",
+ ContentNode rev_node = ContentParser.Parse (bag, fetcher.Fetch ("/update",
"revision-number=" + currentRevision));
- return (int) revNode.GetChild ("dmap.serverrevision").Value;
+ return (int) rev_node.GetChild ("dmap.serverrevision").Value;
}
private void Refresh () {
int newrev = 0;
- /* if (serverInfo.SupportsUpdate) {
+ /* if (server_info.SupportsUpdate) {
if (revision == 0)
newrev = GetCurrentRevision ();
else
@@ -232,19 +225,19 @@
private void UpdateLoop () {
while (true) {
try {
- if (!updateRunning)
+ if (!update_running)
break;
Refresh ();
} catch (WebException) {
- if (!updateRunning)
+ if (!update_running)
break;
// chill out for a while, maybe the server went down
// temporarily or something.
Thread.Sleep (UpdateSleepInterval);
} catch (Exception e) {
- if (!updateRunning)
+ if (!update_running)
break;
Console.Error.WriteLine ("Exception in update loop: " + e);
Modified: trunk/dpap-sharp/lib/ContentCodeBag.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentCodeBag.cs (original)
+++ trunk/dpap-sharp/lib/ContentCodeBag.cs Mon Aug 11 12:11:12 2008
@@ -56,34 +56,35 @@
private const int ChunkLength = 8192;
- private static ContentCodeBag defaultBag;
+ private static ContentCodeBag default_bag;
private Hashtable codes = new Hashtable ();
public static ContentCodeBag Default {
get {
- Console.WriteLine("getting default content codebag");
- if (defaultBag == null) {
+ Console.WriteLine ("getting default content codebag");
+ if (default_bag == null) {
// this is crappy
- foreach (string name in Assembly.GetExecutingAssembly().GetManifestResourceNames()) {
- Console.WriteLine("resource " +name);
- using (BinaryReader reader = new BinaryReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(name))) {
- MemoryStream buf = new MemoryStream();
- byte[] bytes = null;
+ foreach (string name in Assembly.GetExecutingAssembly ().GetManifestResourceNames ()) {
+ Console.WriteLine ("resource " +name);
+ using (BinaryReader reader = new BinaryReader (Assembly.GetExecutingAssembly ().GetManifestResourceStream (name))) {
+ MemoryStream buf = new MemoryStream ();
+ byte [] bytes = null;
do {
- bytes = reader.ReadBytes(ChunkLength);
- buf.Write(bytes, 0, bytes.Length);
+ bytes = reader.ReadBytes (ChunkLength);
+ buf.Write (bytes, 0, bytes.Length);
} while (bytes.Length == ChunkLength);
- defaultBag = ContentCodeBag.ParseCodes(buf.GetBuffer());
- // this is crappy too... this should be in the content-codes file...
- defaultBag.AddCode ("aply", "dpap.databasecontainers", ContentType.Container);
+ default_bag = ContentCodeBag.ParseCodes (buf.GetBuffer ());
+
+ // FIXME this shouldn't be here, should work from the content-codes file, but doesn't
+ default_bag.AddCode ("aply", "dpap.databasecontainers", ContentType.Container);
}
}
}
- return defaultBag;
+ return default_bag;
}
}
@@ -92,7 +93,7 @@
public ContentCode Lookup (int number) {
if (codes.ContainsKey (number))
- return (ContentCode) codes[number];
+ return (ContentCode) codes [number];
else
return ContentCode.Zero;
}
@@ -115,23 +116,19 @@
}
private void AddCode (string num, string name, ContentType type) {
-// Console.WriteLine("Entering ContentCodeBag AddCode(string,string,ContentType)");
ContentCode code = new ContentCode ();
code.Number = GetIntFormat (num);
code.Name = name;
code.Type = type;
- //Console.Write(name + ' ');
- codes[code.Number] = code;
- // Console.WriteLine("Leaving ContentCodeBag AddCode(string,string,ContentType)");
+ codes [code.Number] = code;
}
internal ContentNode ToNode () {
- // Console.WriteLine("Entering ContentCodeBag ToNode()");
ArrayList nodes = new ArrayList ();
foreach (int number in codes.Keys) {
- ContentCode code = (ContentCode) codes[number];
+ ContentCode code = (ContentCode) codes [number];
ArrayList contents = new ArrayList ();
contents.Add (new ContentNode ("dmap.contentcodesnumber", code.Number));
@@ -143,12 +140,10 @@
}
ContentNode status = new ContentNode ("dmap.status", 200);
- //Console.WriteLine("Leaving ContentCodeBag ToNode()");
return new ContentNode ("dmap.contentcodesresponse", status, nodes);
}
- public static ContentCodeBag ParseCodes (byte[] buffer) {
- //Console.WriteLine("Entering ContentCodeBag ParseCodes(byte[])");
+ public static ContentCodeBag ParseCodes (byte [] buffer) {
ContentCodeBag bag = new ContentCodeBag ();
// add some codes to bootstrap us
@@ -160,7 +155,7 @@
bag.AddCode ("mstt", "dmap.status", ContentType.Long);
// some photo-specific codes
- // shouldn't those be automatically added when /content-codes is requested ?
+ // shouldn't be needed now
bag.AddCode ("ppro", "dpap.protocolversion", ContentType.Long);
bag.AddCode ("pret", "dpap.blah", ContentType.Container);
bag.AddCode ("avdb", "dpap.serverdatabases", ContentType.Container);
@@ -184,15 +179,14 @@
ContentNode node = ContentParser.Parse (bag, buffer);
- foreach (ContentNode dictNode in (node.Value as ContentNode[])) {
- // Console.Write(node.Name + ' ' + node.Value + ' ');
+ foreach (ContentNode dictNode in (node.Value as ContentNode [])) {
if (dictNode.Name != "dmap.dictionary") {
continue;
}
ContentCode code = new ContentCode ();
- foreach (ContentNode item in (dictNode.Value as ContentNode[])) {
+ foreach (ContentNode item in (dictNode.Value as ContentNode [])) {
switch (item.Name) {
case "dmap.contentcodesnumber":
code.Number = (int) item.Value;
@@ -206,9 +200,8 @@
}
}
- bag.codes[code.Number] = code;
+ bag.codes [code.Number] = code;
}
- // Console.WriteLine("Leaving ContentCodeBag ParseCodes(byte[])");
return bag;
}
}
Modified: trunk/dpap-sharp/lib/ContentFetcher.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentFetcher.cs (original)
+++ trunk/dpap-sharp/lib/ContentFetcher.cs Mon Aug 11 12:11:12 2008
@@ -38,8 +38,8 @@
internal class ContentFetcher : IDisposable {
private IPAddress address;
private UInt16 port;
- private int sessionId;
- private int requestId = 10;
+ private int session_id;
+ private int request_id = 10;
private DAAPCredentials creds = new DAAPCredentials ();
private List<WebRequest> requests = new List<WebRequest> ();
@@ -55,8 +55,8 @@
}
public int SessionId {
- get { return sessionId; }
- set { sessionId = value; }
+ get { return session_id; }
+ set { session_id = value; }
}
public ContentFetcher (IPAddress address, UInt16 port) {
@@ -78,18 +78,18 @@
}
}
- public byte[] Fetch (string path) {
+ public byte [] Fetch (string path) {
return Fetch (path, null, null, 0);
}
- public byte[] Fetch (string path, string query) {
+ public byte [] Fetch (string path, string query) {
return Fetch (path, query, null, 0);
}
- public byte[] Fetch (string path, string query, WebHeaderCollection extraHeaders,
- int requestId) {
+ public byte [] Fetch (string path, string query, WebHeaderCollection extraHeaders,
+ int request_id) {
- HttpWebResponse response = FetchResponse (path, -1, query, extraHeaders, requestId, false);
+ HttpWebResponse response = FetchResponse (path, -1, query, extraHeaders, request_id, false);
MemoryStream data = new MemoryStream ();
BinaryReader reader = new BinaryReader (GetResponseStream (response));
@@ -97,14 +97,14 @@
if (response.ContentLength < 0)
return null;
- byte[] buf;
+ byte [] buf;
while (true) {
buf = reader.ReadBytes (8192);
if (buf.Length == 0)
break;
data.Write (buf, 0, buf.Length);
- //Console.Write(buf.);
+ //Console.Write (buf.);
}
data.Flush ();
@@ -117,22 +117,22 @@
}
public HttpWebResponse FetchResponse (string path, string query, WebHeaderCollection headers) {
- return FetchResponse (path, -1, query, headers, ++requestId, false);
+ return FetchResponse (path, -1, query, headers, ++request_id, false);
}
public HttpWebResponse FetchFile (string path, long offset) {
- return FetchResponse (path, offset, null, null, ++requestId, true);
+ return FetchResponse (path, offset, null, null, ++request_id, true);
}
public HttpWebResponse FetchResponse (string path, long offset, string query,
WebHeaderCollection extraHeaders,
- int requestId, bool disableKeepalive) {
+ int request_id, bool disableKeepalive) {
UriBuilder builder = new UriBuilder ("http", address.ToString ());
builder.Port = port;
builder.Path = path;
- if (sessionId != 0)
- query = String.Format ("session-id={0}&", sessionId) + query;
+ if (session_id != 0)
+ query = String.Format ("session-id={0}&", session_id) + query;
if (query != null)
builder.Query += query;
@@ -155,7 +155,7 @@
request.KeepAlive = !disableKeepalive;
- string hash = Hasher.GenerateHash (3, builder.Uri.PathAndQuery, 2, requestId);
+ string hash = Hasher.GenerateHash (3, builder.Uri.PathAndQuery, 2, request_id);
request.UserAgent = "iPhoto/5.0.2 (Macintosh; PPC)";
request.Headers.Set ("Client-DMAP-Version", "1.0");
@@ -164,11 +164,11 @@
request.Headers.Set ("Client-DPAP-Access-Index", "2");
*/
// DEBUG data
- Console.Write(path + "?"+query);
- Console.Write(request.Headers);
+ Console.Write (path + "?"+query);
+ Console.Write (request.Headers);
- if (requestId >= 0)
- request.Headers.Set ("Client-DPAP-Request-ID", requestId.ToString ());
+ if (request_id >= 0)
+ request.Headers.Set ("Client-DPAP-Request-ID", request_id.ToString ());
request.Credentials = creds;
request.PreAuthenticate = true;
@@ -178,8 +178,8 @@
requests.Add (request);
}
HttpWebResponse response = (HttpWebResponse) request.GetResponse ();
- //if(!response.StatusCode.Equals("OK"))
- // Console.Write(response.StatusCode);
+ //if (!response.StatusCode.Equals ("OK"))
+ // Console.Write (response.StatusCode);
return response;
} finally {
lock (requests) {
Modified: trunk/dpap-sharp/lib/ContentParser.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentParser.cs (original)
+++ trunk/dpap-sharp/lib/ContentParser.cs Mon Aug 11 12:11:12 2008
@@ -43,20 +43,20 @@
public ContentNode () {
}
- public ContentNode (string name, params object[] values) {
+ public ContentNode (string name, params object [] values) {
this.Name = name;
ArrayList vals = new ArrayList ();
foreach (object v in values) {
if (v is ICollection) {
- vals.AddRange ((ICollection) v);
+ vals.AddRange ( (ICollection) v);
} else {
vals.Add (v);
}
}
- if (vals.Count == 1 && vals[0].GetType () != typeof (ContentNode))
- this.Value = vals[0];
+ if (vals.Count == 1 && vals [0].GetType () != typeof (ContentNode))
+ this.Value = vals [0];
else
this.Value = (object) vals.ToArray (typeof (ContentNode));
}
@@ -68,8 +68,8 @@
private void Dump (int level) {
Console.WriteLine ("{0}Name: {1}", String.Empty.PadRight (level * 4), Name);
- if (Value is ContentNode[]) {
- foreach (ContentNode child in (Value as ContentNode[])) {
+ if (Value is ContentNode []) {
+ foreach (ContentNode child in (Value as ContentNode [])) {
child.Dump (level + 1);
}
} else {
@@ -83,7 +83,7 @@
if (name == this.Name)
return this;
- ContentNode[] children = Value as ContentNode[];
+ ContentNode [] children = Value as ContentNode [];
if (children == null)
return null;
@@ -99,7 +99,7 @@
internal class ContentParser {
- private static ContentNode[] ParseChildren (ContentCodeBag bag, byte[] buffer,
+ private static ContentNode [] ParseChildren (ContentCodeBag bag, byte [] buffer,
int offset, int length) {
ArrayList children = new ArrayList ();
@@ -109,32 +109,32 @@
children.Add (Parse (bag, buffer, null, ref position));
}
- return (ContentNode[]) children.ToArray (typeof (ContentNode));
+ return (ContentNode []) children.ToArray (typeof (ContentNode));
}
- public static ContentNode Parse (ContentCodeBag bag, byte[] buffer, string root,
+ public static ContentNode Parse (ContentCodeBag bag, byte [] buffer, string root,
ref int offset) {
ContentNode node = new ContentNode ();
int num = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset));
ContentCode code;
// This is a fix for iPhoto '08 which gives wrong content-type for dpap.databasecontainers (aply)
- if(num == 1634757753)
- {
- code = new ContentCode();
+ if (num == 1634757753) {
+ code = new ContentCode ();
code.Name = "dpap.databasecontainers";
code.Type = ContentType.Container;
}
else
code = bag.Lookup (num);
- if(code.Name.Equals("dpap.filedata"))
+
+ if (code.Name.Equals ("dpap.filedata"))
code.Type = ContentType.FileData;
if (code.Equals (ContentCode.Zero)) {
// probably a buggy server. fallback to our internal code bag
- Console.WriteLine("fallback to internal code bag");
- Console.WriteLine("Code number: "+num);
- throw new Exception("Content code not found!");
+ Console.WriteLine ("fallback to internal code bag");
+ Console.WriteLine ("Code number: "+num);
+ throw new Exception ("Content code not found!");
}
int length = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 4));
@@ -146,65 +146,65 @@
node.Name = code.Name;
- Console.WriteLine("name = " + node.Name + "Code=" +code.Type.ToString() + " num=" +num);
- switch (code.Type) {
- case ContentType.Char:
- node.Value = (byte) buffer[offset + 8];
- break;
- case ContentType.Short:
- node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt16 (buffer, offset + 8));
- break;
- case ContentType.SignedLong:
- case ContentType.Long:
- node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 8));
- break;
- case ContentType.LongLong:
- node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt64 (buffer, offset + 8));
- break;
- case ContentType.String:
- node.Value = Encoding.UTF8.GetString (buffer, offset + 8, length);
- break;
- case ContentType.Date:
- node.Value = Utility.ToDateTime (IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 8)));
- break;
- case ContentType.Version:
- int major = IPAddress.NetworkToHostOrder (BitConverter.ToInt16 (buffer, offset + 8));
- int minor = (int) buffer[offset + 10];
- int micro = (int) buffer[offset + 11];
-
- node.Value = new Version (major, minor, micro);
- break;
- case ContentType.Container:
- node.Value = ParseChildren (bag, buffer, offset + 8, length);
- break;
- case ContentType.FileData:
- node.Value = offset+8;
- break;
- default:
- throw new ContentException (String.Format ("Unknown content type '{0}' for '{1}'",
- code.Type, code.Name));
+ Console.WriteLine ("name = " + node.Name + "Code=" +code.Type.ToString () + " num=" +num);
+
+ switch (code.Type) {
+ case ContentType.Char:
+ node.Value = (byte) buffer [offset + 8];
+ break;
+ case ContentType.Short:
+ node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt16 (buffer, offset + 8));
+ break;
+ case ContentType.SignedLong:
+ case ContentType.Long:
+ node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 8));
+ break;
+ case ContentType.LongLong:
+ node.Value = IPAddress.NetworkToHostOrder (BitConverter.ToInt64 (buffer, offset + 8));
+ break;
+ case ContentType.String:
+ node.Value = Encoding.UTF8.GetString (buffer, offset + 8, length);
+ break;
+ case ContentType.Date:
+ node.Value = Utility.ToDateTime (IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 8)));
+ break;
+ case ContentType.Version:
+ int major = IPAddress.NetworkToHostOrder (BitConverter.ToInt16 (buffer, offset + 8));
+ int minor = (int) buffer [offset + 10];
+ int micro = (int) buffer [offset + 11];
+
+ node.Value = new Version (major, minor, micro);
+ break;
+ case ContentType.Container:
+ node.Value = ParseChildren (bag, buffer, offset + 8, length);
+ break;
+ case ContentType.FileData:
+ node.Value = offset+8;
+ break;
+ default:
+ throw new ContentException (String.Format ("Unknown content type '{0}' for '{1}'",
+ code.Type, code.Name));
}
offset += length + 8;
if (root != null) {
- ContentNode rootNode = node.GetChild (root);
+ ContentNode root_node = node.GetChild (root);
- if (rootNode == null)
+ if (root_node == null)
throw new ContentException (String.Format ("Could not find root node '{0}'", root));
- return rootNode;
- } else {
- return node;
- }
+ return root_node;
+ } else
+ return node;
}
- public static ContentNode Parse (ContentCodeBag bag, byte[] buffer, string root) {
+ public static ContentNode Parse (ContentCodeBag bag, byte [] buffer, string root) {
int offset = 0;
return Parse (bag, buffer, root, ref offset);
}
- public static ContentNode Parse (ContentCodeBag bag, byte[] buffer) {
+ public static ContentNode Parse (ContentCodeBag bag, byte [] buffer) {
return Parse (bag, buffer, null);
}
}
Modified: trunk/dpap-sharp/lib/ContentWriter.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentWriter.cs (original)
+++ trunk/dpap-sharp/lib/ContentWriter.cs Mon Aug 11 12:11:12 2008
@@ -45,52 +45,51 @@
switch (code.Type) {
case ContentType.Char:
writer.Write (IPAddress.HostToNetworkOrder (1));
- writer.Write ((byte) node.Value);
+ writer.Write ( (byte) node.Value);
break;
case ContentType.Short:
writer.Write (IPAddress.HostToNetworkOrder (2));
- writer.Write (IPAddress.HostToNetworkOrder ((short) node.Value));
+ writer.Write (IPAddress.HostToNetworkOrder ( (short) node.Value));
break;
case ContentType.SignedLong:
case ContentType.Long:
writer.Write (IPAddress.HostToNetworkOrder (4));
- writer.Write (IPAddress.HostToNetworkOrder ((int) node.Value));
+ writer.Write (IPAddress.HostToNetworkOrder ( (int) node.Value));
break;
case ContentType.LongLong:
writer.Write (IPAddress.HostToNetworkOrder (8));
- writer.Write (IPAddress.HostToNetworkOrder ((long) node.Value));
+ writer.Write (IPAddress.HostToNetworkOrder ( (long) node.Value));
break;
case ContentType.String:
- byte[] data = Encoding.UTF8.GetBytes ((string) node.Value);
+ byte [] data = Encoding.UTF8.GetBytes ( (string) node.Value);
writer.Write (IPAddress.HostToNetworkOrder (data.Length));
writer.Write (data);
break;
case ContentType.Date:
writer.Write (IPAddress.HostToNetworkOrder (4));
- writer.Write (IPAddress.HostToNetworkOrder (Utility.FromDateTime ((DateTime) node.Value)));
+ writer.Write (IPAddress.HostToNetworkOrder (Utility.FromDateTime ( (DateTime) node.Value)));
break;
case ContentType.Version:
Version version = (Version) node.Value;
writer.Write (IPAddress.HostToNetworkOrder (4));
- writer.Write ((short) IPAddress.HostToNetworkOrder ((short) version.Major));
- writer.Write ((byte) version.Minor);
- writer.Write ((byte) version.Build);
+ writer.Write ( (short) IPAddress.HostToNetworkOrder ( (short) version.Major));
+ writer.Write ( (byte) version.Minor);
+ writer.Write ( (byte) version.Build);
break;
case ContentType.FileData:
// after "pfdt" we should send the file size and then immediately the file's contents
+ // DEBUG
+ //Console.WriteLine ("ContentWriter FileData!");
+ ContentNode [] nodes = (ContentNode []) node.Value;
- Console.WriteLine("ContentWriter FileData!");
- ContentNode[] nodes = (ContentNode[]) node.Value;
-
- Console.WriteLine(nodes[0].Value);
- writer.Write(IPAddress.HostToNetworkOrder ((int)nodes[0].Value));
- FileInfo info = new FileInfo ((string)nodes[1].Value);
- Console.WriteLine("reading file " + nodes[1].Value + ", length=" +info.Length);
+ //Console.WriteLine (nodes [0].Value);
+ writer.Write (IPAddress.HostToNetworkOrder ( (int)nodes [0].Value));
+ FileInfo info = new FileInfo ( (string)nodes [1].Value);
+ //Console.WriteLine ("reading file " + nodes [1].Value + ", length=" +info.Length);
- FileStream stream = info.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
- //writer.Write (client, stream, info.Length, offset);
+ FileStream stream = info.Open (FileMode.Open, FileAccess.Read, FileShare.Read);
int offset = -1;
using (BinaryReader reader = new BinaryReader (stream)) {
if (offset > 0) {
@@ -100,7 +99,7 @@
long count = 0;
long len = info.Length;
while (count < len) {
- byte[] buf = reader.ReadBytes (Math.Min (8192, (int) len - (int) count));
+ byte [] buf = reader.ReadBytes (Math.Min (8192, (int) len - (int) count));
if (buf.Length == 0) {
break;
}
@@ -111,39 +110,38 @@
}
break;
case ContentType.Container:
- MemoryStream childStream = new MemoryStream ();
- BinaryWriter childWriter = new BinaryWriter (childStream);
+ MemoryStream child_stream = new MemoryStream ();
+ BinaryWriter child_writer = new BinaryWriter (child_stream);
- foreach (ContentNode child in (ContentNode[]) node.Value) {
- Write (bag, child, childWriter);
+ foreach (ContentNode child in (ContentNode []) node.Value) {
+ Write (bag, child, child_writer);
}
- childWriter.Flush ();
- byte[] bytes = childStream.GetBuffer ();
- int len = (int) childStream.Length;
+ child_writer.Flush ();
+ byte [] bytes = child_stream.GetBuffer ();
+ int len = (int) child_stream.Length;
writer.Write (IPAddress.HostToNetworkOrder (len));
writer.Write (bytes, 0, len);
- childWriter.Close ();
+ child_writer.Close ();
break;
-
default:
Console.Error.WriteLine ("Cannot write node of type: " + code.Type);
break;
}
}
- public static byte[] Write (ContentCodeBag bag, ContentNode node) {
+ public static byte [] Write (ContentCodeBag bag, ContentNode node) {
MemoryStream stream = new MemoryStream ();
BinaryWriter writer = new BinaryWriter (stream);
Write (bag, node, writer);
writer.Flush ();
- byte[] buf = stream.GetBuffer ();
+ byte [] buf = stream.GetBuffer ();
long len = stream.Length;
writer.Close ();
- byte[] ret = new byte[len];
+ byte [] ret = new byte [len];
Array.Copy (buf, ret, len);
return ret;
}
Modified: trunk/dpap-sharp/lib/Database.cs
==============================================================================
--- trunk/dpap-sharp/lib/Database.cs (original)
+++ trunk/dpap-sharp/lib/Database.cs Mon Aug 11 12:11:12 2008
@@ -63,9 +63,9 @@
public class Database : ICloneable {
- private const int ChunkLength = 8192;
+ private const int chunk_length = 8192;
- private const string PhotoQuery = "meta=dpap.aspectratio,dmap.itemid,dmap.itemname,dpap.imagefilename," +
+ private const string photo_query = "meta=dpap.aspectratio,dmap.itemid,dmap.itemname,dpap.imagefilename," +
"dpap.imagefilesize,dpap.creationdate,dpap.imagepixelwidth," +
"dpap.imagepixelheight,dpap.imageformat,dpap.imagerating," +
"dpap.imagecomments,dpap.imagelargefilesize,dpap.filedata&type=photo";
@@ -74,13 +74,13 @@
private static int nextid = 1;
private Client client;
private int id;
- private long persistentId;
+ private long persistent_id;
private string name;
private List<Photo> photos = new List<Photo> ();
private List<Album> albums = new List<Album> ();
- private Album baseAlbum = new Album ();
- private int nextPhotoId = 1;
+ private Album base_album = new Album ();
+ private int next_photo_id = 1;
public event PhotoHandler PhotoAdded;
public event PhotoHandler PhotoRemoved;
@@ -95,7 +95,7 @@
get { return name; }
set {
name = value;
- baseAlbum.Name = value;
+ base_album.Name = value;
}
}
@@ -109,9 +109,9 @@
get { return photos.Count; }
}
- public Photo PhotoAt(int index)
+ public Photo PhotoAt (int index)
{
- return photos[index] as Photo;
+ return photos [index] as Photo;
}
public IList<Album> Albums {
@@ -139,14 +139,14 @@
}
private void Parse (ContentNode dbNode) {
- foreach (ContentNode item in (ContentNode[]) dbNode.Value) {
+ foreach (ContentNode item in (ContentNode []) dbNode.Value) {
switch (item.Name) {
case "dmap.itemid":
id = (int) item.Value;
break;
case "dmap.persistentid":
- persistentId = (long) item.Value;
+ persistent_id = (long) item.Value;
break;
case "dmap.itemname":
name = (string) item.Value;
@@ -167,8 +167,8 @@
}
public Album LookupAlbumById (int id) {
- if (id == baseAlbum.Id)
- return baseAlbum;
+ if (id == base_album.Id)
+ return base_album;
foreach (Album pl in albums) {
if (pl.Id == id)
@@ -178,32 +178,32 @@
return null;
}
- internal ContentNode ToPhotosNode (string[] fields, int[] deletedIds) {
+ internal ContentNode ToPhotosNode (string [] fields, int [] deleted_ids) {
- ArrayList photoNodes = new ArrayList ();
+ ArrayList photo_nodes = new ArrayList ();
foreach (Photo photo in photos) {
- photoNodes.Add (photo.ToNode (fields));
+ photo_nodes.Add (photo.ToNode (fields));
}
- ArrayList deletedNodes = null;
+ ArrayList deleted_nodes = null;
- if (deletedIds.Length > 0) {
- deletedNodes = new ArrayList ();
+ if (deleted_ids.Length > 0) {
+ deleted_nodes = new ArrayList ();
- foreach (int id in deletedIds) {
- deletedNodes.Add (new ContentNode ("dmap.itemid", id));
+ foreach (int id in deleted_ids) {
+ deleted_nodes.Add (new ContentNode ("dmap.itemid", id));
}
}
ArrayList children = new ArrayList ();
children.Add (new ContentNode ("dmap.status", 200));
- children.Add (new ContentNode ("dmap.updatetype", deletedNodes == null ? (byte) 0 : (byte) 1));
+ children.Add (new ContentNode ("dmap.updatetype", deleted_nodes == null ? (byte) 0 : (byte) 1));
children.Add (new ContentNode ("dmap.specifiedtotalcount", photos.Count));
children.Add (new ContentNode ("dmap.returnedcount", photos.Count));
- children.Add (new ContentNode ("dmap.listing", photoNodes));
+ children.Add (new ContentNode ("dmap.listing", photo_nodes));
- if (deletedNodes != null) {
- children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
+ if (deleted_nodes != null) {
+ children.Add (new ContentNode ("dmap.deletedidlisting", deleted_nodes));
}
return new ContentNode ("dpap.databasesongs", children);
@@ -212,7 +212,7 @@
internal ContentNode ToAlbumsNode () {
ArrayList nodes = new ArrayList ();
- nodes.Add (baseAlbum.ToNode (true));
+ nodes.Add (base_album.ToNode (true));
foreach (Album pl in albums) {
nodes.Add (pl.ToNode (false));
@@ -260,30 +260,30 @@
}
private void RefreshAlbums (string revquery) {
- byte[] albumsData;
+ byte [] albums_data;
try {
- albumsData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers", id, revquery));
+ albums_data = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers", id, revquery));
} catch (WebException) {
return;
}
- ContentNode albumsNode = ContentParser.Parse (client.Bag, albumsData);
+ ContentNode albums_node = ContentParser.Parse (client.Bag, albums_data);
// DEBUG data
- albumsNode.Dump();
- Console.WriteLine("after dump!");
+ albums_node.Dump ();
+ Console.WriteLine ("after dump!");
- if (IsUpdateResponse (albumsNode))
+ if (IsUpdateResponse (albums_node))
return;
// handle album additions/changes
ArrayList plids = new ArrayList ();
- if(albumsNode.GetChild("dmap.listing")==null) return;
+ if (albums_node.GetChild ("dmap.listing")==null) return;
- foreach (ContentNode albumNode in (ContentNode[]) albumsNode.GetChild ("dmap.listing").Value) {
+ foreach (ContentNode albumNode in (ContentNode []) albums_node.GetChild ("dmap.listing").Value) {
// DEBUG
- Console.WriteLine("foreach loop");
+ Console.WriteLine ("foreach loop");
Album pl = Album.FromNode (albumNode);
if (pl != null) {
plids.Add (pl.Id);
@@ -297,7 +297,7 @@
}
}
// DEBUG
- Console.WriteLine("delete albums that don't exist");
+ Console.WriteLine ("delete albums that don't exist");
// delete albums that no longer exist
foreach (Album pl in new List<Album> (albums)) {
if (!plids.Contains (pl.Id)) {
@@ -307,24 +307,24 @@
plids = null;
// DEBUG
- Console.WriteLine("Add/remove photos in the albums");
+ Console.WriteLine ("Add/remove photos in the albums");
// add/remove photos in the albums
foreach (Album pl in albums) {
- byte[] albumPhotosData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items",
+ byte [] album_photos_data = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items",
id, pl.Id), revquery);
- ContentNode albumPhotosNode = ContentParser.Parse (client.Bag, albumPhotosData);
+ ContentNode album_photos_node = ContentParser.Parse (client.Bag, album_photos_data);
- if (IsUpdateResponse (albumPhotosNode))
+ if (IsUpdateResponse (album_photos_node))
return;
- if ((byte) albumPhotosNode.GetChild ("dmap.updatetype").Value == 1) {
+ if ( (byte) album_photos_node.GetChild ("dmap.updatetype").Value == 1) {
// handle album photo deletions
- ContentNode deleteList = albumPhotosNode.GetChild ("dmap.deletedidlisting");
+ ContentNode delete_list = album_photos_node.GetChild ("dmap.deletedidlisting");
- if (deleteList != null) {
- foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
- int index = pl.LookupIndexByContainerId ((int) deleted.Value);
+ if (delete_list != null) {
+ foreach (ContentNode deleted in (ContentNode []) delete_list.Value) {
+ int index = pl.LookupIndexByContainerId ( (int) deleted.Value);
if (index < 0)
continue;
@@ -337,16 +337,16 @@
// add new photos, or reorder existing ones
int plindex = 0;
- foreach (ContentNode plPhotoNode in (ContentNode[]) albumPhotosNode.GetChild ("dmap.listing").Value) {
+ foreach (ContentNode pl_photo_node in (ContentNode []) album_photos_node.GetChild ("dmap.listing").Value) {
Photo plphoto = null;
- int containerId = 0;
- Photo.FromAlbumNode (this, plPhotoNode, out plphoto, out containerId);
+ int container_id = 0;
+ Photo.FromAlbumNode (this, pl_photo_node, out plphoto, out container_id);
- if (pl[plindex] != null && pl.GetContainerId (plindex) != containerId) {
+ if (pl [plindex] != null && pl.GetContainerId (plindex) != container_id) {
pl.RemoveAt (plindex);
- pl.InsertPhoto (plindex, plphoto, containerId);
- } else if (pl[plindex] == null) {
- pl.InsertPhoto (plindex, plphoto, containerId);
+ pl.InsertPhoto (plindex, plphoto, container_id);
+ } else if (pl [plindex] == null) {
+ pl.InsertPhoto (plindex, plphoto, container_id);
}
plindex++;
@@ -356,40 +356,42 @@
private void RefreshPhotos (string revquery) {
foreach (Album pl in albums){
- byte[] photosData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items", id,pl.getId()),
- PhotoQuery);
- ContentNode photosNode = ContentParser.Parse (client.Bag, photosData);
-
- if (IsUpdateResponse (photosNode))
- return;
+ //Console.WriteLine ("Refreshing photos in album " + pl.Name);
+ byte [] photos_data = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items", id,pl.getId ()),
+ photo_query);
+ ContentNode photos_node = ContentParser.Parse (client.Bag, photos_data);
+ //photos_node.Dump ();
+ //if (IsUpdateResponse (photos_node))
+ // return;
// handle photo additions/changes
- foreach (ContentNode photoNode in (ContentNode[]) photosNode.GetChild ("dmap.listing").Value) {
+ foreach (ContentNode photoNode in (ContentNode []) photos_node.GetChild ("dmap.listing").Value) {
// DEBUG data
- //photoNode.Dump();
+ //photoNode.Dump ();
Photo photo = Photo.FromNode (photoNode);
Photo existing = LookupPhotoById (photo.Id);
-
+ pl.AddPhoto (photo);
if (existing == null){
- // Console.WriteLine("adding " + photo.Title);
+ // Console.WriteLine ("adding " + photo.Title + " to album " +pl.Name);
+
AddPhoto (photo);
}
else
{
- // Console.WriteLine("updating " + existing.Title);
+ // Console.WriteLine ("updating " + existing.Title);
existing.Update (photo);
}
}
- if ((byte) photosNode.GetChild ("dmap.updatetype").Value == 1) {
+ if ( (byte) photos_node.GetChild ("dmap.updatetype").Value == 1) {
// handle photo deletions
- ContentNode deleteList = photosNode.GetChild ("dmap.deletedidlisting");
+ ContentNode delete_list = photos_node.GetChild ("dmap.deletedidlisting");
- if (deleteList != null) {
- foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
- Photo photo = LookupPhotoById ((int) deleted.Value);
+ if (delete_list != null) {
+ foreach (ContentNode deleted in (ContentNode []) delete_list.Value) {
+ Photo photo = LookupPhotoById ( (int) deleted.Value);
if (photo != null)
RemovePhoto (photo);
@@ -414,7 +416,7 @@
private HttpWebResponse FetchPhoto (Photo photo, long offset) {
return client.Fetcher.FetchResponse (String.Format ("/databases/{0}/items",id), offset,
- String.Format("meta=dpap.filedata&query=('dmap.itemid:{0}')",photo.Id),
+ String.Format ("meta=dpap.filedata&query= ('dmap.itemid:{0}')",photo.Id),
null, 1, true);
}
@@ -437,13 +439,13 @@
long len;
using (BinaryReader reader = new BinaryReader (StreamPhoto (photo, out len))) {
int count = 0;
- byte[] buf = new byte[ChunkLength];
+ byte [] buf = new byte [chunk_length];
// Skip the header
- //count = reader.Read(buf,0,89);
+ //count = reader.Read (buf,0,89);
- //if(count < 89)
- // count+=reader.Read(buf,0,89-count);
+ //if (count < 89)
+ // count+=reader.Read (buf,0,89-count);
while (true) {
buf = reader.ReadBytes (8192);
@@ -451,20 +453,20 @@
break;
data.Write (buf, 0, buf.Length);
- //Console.Write(buf.);
+ //Console.Write (buf.);
}
*/
/* do {
- count = reader.Read (buf, 0, ChunkLength);
+ count = reader.Read (buf, 0, chunk_length);
writer.Write (buf, 0, count);
data.Write (buf, 0, count);
} while (count != 0);
*/
- /*data.Flush();
+ /*data.Flush ();
- ContentNode node = ContentParser.Parse(client.Bag, data.GetBuffer());
- node.Dump();
+ ContentNode node = ContentParser.Parse (client.Bag, data.GetBuffer ());
+ node.Dump ();
reader.Close ();
}
@@ -474,38 +476,35 @@
writer.Close ();
}*/
// maybe use FetchResponse to get a stream and feed it to pixbuf?
- byte[] photosData = client.Fetcher.Fetch (String.Format ("/databases/{0}/items",id),
- String.Format("meta=dpap.filedata&query=('dmap.itemid:{0}')",photo.Id));
- ContentNode node = ContentParser.Parse(client.Bag, photosData);
+ byte [] photos_data = client.Fetcher.Fetch (String.Format ("/databases/{0}/items",id),
+ String.Format ("meta=dpap.filedata&query= ('dmap.itemid:{0}')",photo.Id));
+ ContentNode node = ContentParser.Parse (client.Bag, photos_data);
// DEBUG
- Console.WriteLine("About to dump the photo!");
- node.Dump();
- ContentNode fileDataNode = node.GetChild("dpap.filedata");
- Console.WriteLine("Photo starts at index " + fileDataNode.Value);
+ Console.WriteLine ("About to dump the photo!");
+ node.Dump ();
+ ContentNode filedata_node = node.GetChild ("dpap.filedata");
+ Console.WriteLine ("Photo starts at index " + filedata_node.Value);
BinaryWriter writer = new BinaryWriter (File.Open (dest, FileMode.Create));
int count = 0;
- int off = System.Int32.Parse(fileDataNode.Value.ToString());
- byte[] photoBuf;
+ int off = System.Int32.Parse (filedata_node.Value.ToString ());
+ byte [] photo_buf;
MemoryStream data = new MemoryStream ();
- //while ( count < photosData.Length - fileDataNode.Value)
- data.Write(photosData, (int)off, (int)photosData.Length-off);
+ //while (count < photos_data.Length - fileDataNode.Value)
+ writer.Write (photos_data, (int)off, (int)photos_data.Length-off);
data.Position = 0;
-// Gdk.Pixbuf pb = new Gdk.Pixbuf(data);
- data.Close();
-
-
-
- Console.Write("Written " + count + " out of " + (photosData.Length-off));
+// Gdk.Pixbuf pb = new Gdk.Pixbuf (data);
+ data.Close ();
+ Console.Write ("Written " + count + " out of " + (photos_data.Length-off));
}
public void AddPhoto (Photo photo) {
if (photo.Id == 0)
- photo.SetId (nextPhotoId++);
+ photo.SetId (next_photo_id++);
photos.Add (photo);
- baseAlbum.AddPhoto (photo);
+ base_album.AddPhoto (photo);
if (PhotoAdded != null)
PhotoAdded (this, new PhotoArgs (photo));
@@ -513,7 +512,7 @@
public void RemovePhoto (Photo photo) {
photos.Remove (photo);
- baseAlbum.RemovePhoto (photo);
+ base_album.RemovePhoto (photo);
foreach (Album pl in albums) {
pl.RemovePhoto (photo);
@@ -524,8 +523,9 @@
}
public void AddAlbum (Album pl) {
- albums.Add (pl);
-
+ // DEBUG
+ Console.WriteLine ("Adding album " + pl.Name);
+ albums.Add (pl);
if (AlbumAdded != null)
AlbumAdded (this, new AlbumArgs (pl));
}
@@ -538,36 +538,36 @@
}
private Album CloneAlbum (Database db, Album pl) {
- Album clonePl = new Album (pl.Name);
- clonePl.Id = pl.Id;
+ Album clone_pl = new Album (pl.Name);
+ clone_pl.Id = pl.Id;
IList<Photo> plphotos = pl.Photos;
for (int i = 0; i < plphotos.Count; i++) {
- clonePl.AddPhoto (db.LookupPhotoById (plphotos[i].Id), pl.GetContainerId (i));
+ clone_pl.AddPhoto (db.LookupPhotoById (plphotos [i].Id), pl.GetContainerId (i));
}
- return clonePl;
+ return clone_pl;
}
public object Clone () {
Database db = new Database (this.name);
db.id = id;
- db.persistentId = persistentId;
+ db.persistent_id = persistent_id;
- List<Photo> clonePhotos = new List<Photo> ();
+ List<Photo> clone_photos = new List<Photo> ();
foreach (Photo photo in photos) {
- clonePhotos.Add ((Photo) photo.Clone ());
+ clone_photos.Add ( (Photo) photo.Clone ());
}
- db.photos = clonePhotos;
+ db.photos = clone_photos;
- List<Album> cloneAlbums = new List<Album> ();
+ List<Album> clone_albums = new List<Album> ();
foreach (Album pl in albums) {
- cloneAlbums.Add (CloneAlbum (db, pl));
+ clone_albums.Add (CloneAlbum (db, pl));
}
- db.albums = cloneAlbums;
- db.baseAlbum = CloneAlbum (db, baseAlbum);
+ db.albums = clone_albums;
+ db.base_album = CloneAlbum (db, base_album);
return db;
}
}
Modified: trunk/dpap-sharp/lib/Discovery.cs
==============================================================================
--- trunk/dpap-sharp/lib/Discovery.cs (original)
+++ trunk/dpap-sharp/lib/Discovery.cs Mon Aug 11 12:11:12 2008
@@ -52,7 +52,7 @@
private ushort port;
private string name;
private bool isprotected;
- private string machineId;
+ private string machine_id;
public IPAddress Address {
get { return address; }
@@ -71,20 +71,20 @@
}
public string MachineId {
- get { return machineId; }
+ get { return machine_id; }
}
- public Service (IPAddress address, ushort port, string name, bool isprotected, string machineId) {
+ public Service (IPAddress address, ushort port, string name, bool isprotected, string machine_id) {
this.address = address;
this.port = port;
this.name = name;
this.isprotected = isprotected;
- this.machineId = machineId;
+ this.machine_id = machine_id;
}
- public override string ToString()
+ public override string ToString ()
{
- return String.Format("{0}:{1} ({2})", Address, Port, Name);
+ return String.Format ("{0}:{1} ({2})", Address, Port, Name);
}
}
@@ -106,9 +106,9 @@
//
public void Start () {
- browser = new ServiceBrowser();
+ browser = new ServiceBrowser ();
browser.ServiceAdded += OnServiceAdded;
- browser.Browse("_dpap._tcp","local");
+ browser.Browse ("_dpap._tcp","local");
}
public void Stop () {
@@ -117,47 +117,47 @@
services.Clear ();
}
- private void OnServiceAdded(object o, ServiceBrowseEventArgs args){
- Console.WriteLine("Found Service: {0}", args.Service.Name);
+ private void OnServiceAdded (object o, ServiceBrowseEventArgs args){
+ Console.WriteLine ("Found Service: {0}", args.Service.Name);
args.Service.Resolved += OnServiceResolved;
args.Service.Resolve ();
}
- public Service ServiceByName(string svcName)
+ public Service ServiceByName (string svcName)
{
- return (Service)services[svcName];
+ return (Service)services [svcName];
}
- private void OnServiceResolved(object o, ServiceResolvedEventArgs args){
+ private void OnServiceResolved (object o, ServiceResolvedEventArgs args){
IResolvableService s = (IResolvableService)args.Service;
string name = s.Name;
- string machineId = null;
+ string machine_id = null;
bool pwRequired = false;
- Console.WriteLine("Resolved Service: {0} - {1}:{2} ({3} TXT record entries)",
- s.FullName, s.HostEntry.AddressList[0], s.Port, s.TxtRecord.Count);
+ Console.WriteLine ("Resolved Service: {0} - {1}:{2} ({3} TXT record entries)",
+ s.FullName, s.HostEntry.AddressList [0], s.Port, s.TxtRecord.Count);
if (name.EndsWith ("_PW")) {
name = name.Substring (0, name.Length - 3);
pwRequired = true;
}
- foreach(TxtRecordItem item in s.TxtRecord) {
- if(item.Key.ToLower () == "password") {
+ foreach (TxtRecordItem item in s.TxtRecord) {
+ if (item.Key.ToLower () == "password") {
pwRequired = item.ValueString.ToLower () == "true";
} else if (item.Key.ToLower () == "machine name") {
name = item.ValueString;
} else if (item.Key.ToLower () == "machine id") {
- machineId = item.ValueString;
+ machine_id = item.ValueString;
}
}
- DPAP.Service svc = new DPAP.Service (s.HostEntry.AddressList[0], (ushort)s.Port,
- name, pwRequired, machineId);
+ DPAP.Service svc = new DPAP.Service (s.HostEntry.AddressList [0], (ushort)s.Port,
+ name, pwRequired, machine_id);
- services[svc.Name] = svc;
+ services [svc.Name] = svc;
if (Found != null)
Found (this, new ServiceArgs (svc));
Modified: trunk/dpap-sharp/lib/Hasher.cs
==============================================================================
--- trunk/dpap-sharp/lib/Hasher.cs (original)
+++ trunk/dpap-sharp/lib/Hasher.cs Mon Aug 11 12:11:12 2008
@@ -54,169 +54,169 @@
private static byte [] _hasht45 = null;
private static byte [] _hexchars =
- Encoding.ASCII.GetBytes( "0123456789ABCDEF" );
- private static byte [] _copyright = Convert.FromBase64String(
+ Encoding.ASCII.GetBytes ( "0123456789ABCDEF" );
+ private static byte [] _copyright = Convert.FromBase64String (
"Q29weXJpZ2h0IDIwMDMgQXBwbGUgQ29tcHV0ZXIsIEluYy4=" );
- private static void HashToString( byte [] hash, byte [] str, int offset )
+ private static void HashToString ( byte [] hash, byte [] str, int offset )
{
- for( int i = 0; i < hash.Length; i++ )
+ for ( int i = 0; i < hash.Length; i++ )
{
- byte tmp = hash[ i ];
- str[ i * 2 + 1 + offset ] = _hexchars[ tmp & 0xF ];
- str[ i * 2 + 0 + offset ] = _hexchars[ (tmp >> 4) & 0xF ];
+ byte tmp = hash [ i ];
+ str [ i * 2 + 1 + offset ] = _hexchars [ tmp & 0xF ];
+ str [ i * 2 + 0 + offset ] = _hexchars [ (tmp >> 4) & 0xF ];
}
}
- private static void TransformString( BrokenMD5 md5, string str, bool final )
+ private static void TransformString ( BrokenMD5 md5, string str, bool final )
{
- byte [] tmp = Encoding.ASCII.GetBytes( str );
+ byte [] tmp = Encoding.ASCII.GetBytes ( str );
- if( final )
- md5.TransformFinalBlock( tmp, 0, tmp.Length );
+ if ( final )
+ md5.TransformFinalBlock ( tmp, 0, tmp.Length );
else
- md5.TransformBlock( tmp, 0, tmp.Length, tmp, 0 );
+ md5.TransformBlock ( tmp, 0, tmp.Length, tmp, 0 );
}
- private static void GenerateTable42()
+ private static void GenerateTable42 ()
{
int i;
- _hasht42 = new byte[ 256 * 32 ];
+ _hasht42 = new byte [ 256 * 32 ];
- for( i = 0; i < 256; i++ )
+ for ( i = 0; i < 256; i++ )
{
- BrokenMD5 md5 = new BrokenMD5( 0 );
+ BrokenMD5 md5 = new BrokenMD5 ( 0 );
- if( ( i & 0x80 ) != 0 )
- TransformString( md5, "Accept-Language", false );
+ if ( ( i & 0x80 ) != 0 )
+ TransformString ( md5, "Accept-Language", false );
else
- TransformString( md5, "user-agent", false );
+ TransformString ( md5, "user-agent", false );
- if( ( i & 0x40 ) != 0 )
- TransformString( md5, "max-age", false );
+ if ( ( i & 0x40 ) != 0 )
+ TransformString ( md5, "max-age", false );
else
- TransformString( md5, "Authorization", false );
+ TransformString ( md5, "Authorization", false );
- if( ( i & 0x20 ) != 0 )
- TransformString( md5, "Client-DAAP-Version", false );
+ if ( ( i & 0x20 ) != 0 )
+ TransformString ( md5, "Client-DAAP-Version", false );
else
- TransformString( md5, "Accept-Encoding", false );
+ TransformString ( md5, "Accept-Encoding", false );
- if( ( i & 0x10 ) != 0 )
- TransformString( md5, "daap.protocolversion", false );
+ if ( ( i & 0x10 ) != 0 )
+ TransformString ( md5, "daap.protocolversion", false );
else
- TransformString( md5, "daap.songartist", false );
+ TransformString ( md5, "daap.songartist", false );
- if( ( i & 0x08 ) != 0 )
- TransformString( md5, "daap.songcomposer", false );
+ if ( ( i & 0x08 ) != 0 )
+ TransformString ( md5, "daap.songcomposer", false );
else
- TransformString( md5, "daap.songdatemodified", false );
+ TransformString ( md5, "daap.songdatemodified", false );
- if( ( i & 0x04 ) != 0 )
- TransformString( md5, "daap.songdiscnumber", false );
+ if ( ( i & 0x04 ) != 0 )
+ TransformString ( md5, "daap.songdiscnumber", false );
else
- TransformString( md5, "daap.songdisabled", false );
+ TransformString ( md5, "daap.songdisabled", false );
- if( ( i & 0x02 ) != 0 )
- TransformString( md5, "playlist-item-spec", false );
+ if ( ( i & 0x02 ) != 0 )
+ TransformString ( md5, "playlist-item-spec", false );
else
- TransformString( md5, "revision-number", false );
+ TransformString ( md5, "revision-number", false );
- if( ( i & 0x01 ) != 0 )
- TransformString( md5, "session-id", true );
+ if ( ( i & 0x01 ) != 0 )
+ TransformString ( md5, "session-id", true );
else
- TransformString( md5, "content-codes", true );
+ TransformString ( md5, "content-codes", true );
- HashToString( md5.Hash, _hasht42, i * 32 );
+ HashToString ( md5.Hash, _hasht42, i * 32 );
}
}
- private static void GenerateTable45()
+ private static void GenerateTable45 ()
{
int i;
- _hasht45 = new byte[ 256 * 32 ];
+ _hasht45 = new byte [ 256 * 32 ];
- for( i = 0; i < 256; i++ )
+ for ( i = 0; i < 256; i++ )
{
- BrokenMD5 md5 = new BrokenMD5( 1 );
+ BrokenMD5 md5 = new BrokenMD5 ( 1 );
- if( ( i & 0x40 ) != 0 )
- TransformString( md5, "eqwsdxcqwesdc", false );
+ if ( ( i & 0x40 ) != 0 )
+ TransformString ( md5, "eqwsdxcqwesdc", false );
else
- TransformString( md5, "op[;lm,piojkmn", false );
+ TransformString ( md5, "op [;lm,piojkmn", false );
- if( ( i & 0x20 ) != 0 )
- TransformString( md5, "876trfvb 34rtgbvc", false );
+ if ( ( i & 0x20 ) != 0 )
+ TransformString ( md5, "876trfvb 34rtgbvc", false );
else
- TransformString( md5, "=-0ol.,m3ewrdfv", false );
+ TransformString ( md5, "=-0ol.,m3ewrdfv", false );
- if( ( i & 0x10 ) != 0 )
- TransformString( md5, "87654323e4rgbv ", false );
+ if ( ( i & 0x10 ) != 0 )
+ TransformString ( md5, "87654323e4rgbv ", false );
else
- TransformString( md5, "1535753690868867974342659792", false );
+ TransformString ( md5, "1535753690868867974342659792", false );
- if( ( i & 0x08 ) != 0 )
- TransformString( md5, "Song Name", false );
+ if ( ( i & 0x08 ) != 0 )
+ TransformString ( md5, "Song Name", false );
else
- TransformString( md5, "DAAP-CLIENT-ID:", false );
+ TransformString ( md5, "DAAP-CLIENT-ID:", false );
- if( ( i & 0x04 ) != 0 )
- TransformString( md5, "111222333444555", false );
+ if ( ( i & 0x04 ) != 0 )
+ TransformString ( md5, "111222333444555", false );
else
- TransformString( md5, "4089961010", false );
+ TransformString ( md5, "4089961010", false );
- if( ( i & 0x02 ) != 0 )
- TransformString( md5, "playlist-item-spec", false );
+ if ( ( i & 0x02 ) != 0 )
+ TransformString ( md5, "playlist-item-spec", false );
else
- TransformString( md5, "revision-number", false );
+ TransformString ( md5, "revision-number", false );
- if( ( i & 0x01 ) != 0 )
- TransformString( md5, "session-id", false );
+ if ( ( i & 0x01 ) != 0 )
+ TransformString ( md5, "session-id", false );
else
- TransformString( md5, "content-codes", false );
+ TransformString ( md5, "content-codes", false );
- if( ( i & 0x80 ) != 0 )
- TransformString( md5, "IUYHGFDCXWEDFGHN", true );
+ if ( ( i & 0x80 ) != 0 )
+ TransformString ( md5, "IUYHGFDCXWEDFGHN", true );
else
- TransformString( md5, "iuytgfdxwerfghjm", true );
+ TransformString ( md5, "iuytgfdxwerfghjm", true );
- HashToString( md5.Hash, _hasht45, i * 32 );
+ HashToString ( md5.Hash, _hasht45, i * 32 );
}
}
- public static string GenerateHash(int version_major, string url,
+ public static string GenerateHash (int version_major, string url,
int hash_select, int request_id )
{
- if( _hasht42 == null )
- GenerateTable42();
- if( _hasht45 == null )
- GenerateTable45();
+ if ( _hasht42 == null )
+ GenerateTable42 ();
+ if ( _hasht45 == null )
+ GenerateTable45 ();
byte [] hashtable = (version_major == 3) ? _hasht45 : _hasht42;
- BrokenMD5 md5 = new BrokenMD5( (version_major == 3) ? 1 : 0 );
- byte [] hash = new byte[ 32 ];
+ BrokenMD5 md5 = new BrokenMD5 ( (version_major == 3) ? 1 : 0 );
+ byte [] hash = new byte [ 32 ];
- byte [] tmp = Encoding.ASCII.GetBytes( url );
- md5.TransformBlock( tmp, 0, tmp.Length, tmp, 0 );
- md5.TransformBlock( _copyright, 0, _copyright.Length, _copyright, 0 );
+ byte [] tmp = Encoding.ASCII.GetBytes ( url );
+ md5.TransformBlock ( tmp, 0, tmp.Length, tmp, 0 );
+ md5.TransformBlock ( _copyright, 0, _copyright.Length, _copyright, 0 );
- if( request_id > 0 && version_major == 3 )
+ if ( request_id > 0 && version_major == 3 )
{
- md5.TransformBlock( hashtable, hash_select * 32, 32,
+ md5.TransformBlock ( hashtable, hash_select * 32, 32,
hashtable, hash_select * 32 );
- tmp = Encoding.ASCII.GetBytes( request_id.ToString() );
- md5.TransformFinalBlock( tmp, 0, tmp.Length );
+ tmp = Encoding.ASCII.GetBytes ( request_id.ToString () );
+ md5.TransformFinalBlock ( tmp, 0, tmp.Length );
}
else
{
- md5.TransformFinalBlock( hashtable, hash_select * 32, 32 );
+ md5.TransformFinalBlock ( hashtable, hash_select * 32, 32 );
}
- HashToString( md5.Hash, hash, 0 );
+ HashToString ( md5.Hash, hash, 0 );
- return Encoding.ASCII.GetString( hash );
+ return Encoding.ASCII.GetString ( hash );
}
}
}
Modified: trunk/dpap-sharp/lib/Photo.cs
==============================================================================
--- trunk/dpap-sharp/lib/Photo.cs (original)
+++ trunk/dpap-sharp/lib/Photo.cs Mon Aug 11 12:11:12 2008
@@ -42,14 +42,14 @@
private int width;
private int height;
private string genre;
- private int photoNumber;
- private int photoCount;
- private string fileName;
+ private int photo_number;
+ private int photo_count;
+ private string filename;
private string thumbnail;
private string path;
private int thumbsize;
- private DateTime dateAdded = DateTime.Now;
- private DateTime dateModified = DateTime.Now;
+ private DateTime date_added = DateTime.Now;
+ private DateTime date_modified = DateTime.Now;
private short bitrate;
public event EventHandler Updated;
@@ -115,9 +115,9 @@
}
public string FileName {
- get { return fileName; }
+ get { return filename; }
set {
- fileName = value;
+ filename = value;
EmitUpdated ();
}
}
@@ -163,17 +163,17 @@
}
public DateTime DateAdded {
- get { return dateAdded; }
+ get { return date_added; }
set {
- dateAdded = value;
+ date_added = value;
EmitUpdated ();
}
}
public DateTime DateModified {
- get { return dateModified; }
+ get { return date_modified; }
set {
- dateModified = value;
+ date_modified = value;
EmitUpdated ();
}
}
@@ -189,17 +189,17 @@
photo.duration = duration;
photo.id = id;
photo.size = size;
- photo.fileName = fileName;
+ photo.filename = filename;
photo.thumbnail = thumbnail;
photo.thumbsize = thumbsize;
- photo.dateAdded = dateAdded;
- photo.dateModified = dateModified;
+ photo.date_added = date_added;
+ photo.date_modified = date_modified;
photo.path = path;
return photo;
}
public override string ToString () {
- return String.Format ("fname={0}, title={1}, format={2}, id={3}, path={4}", fileName, title, format, id, path);
+ return String.Format ("fname={0}, title={1}, format={2}, id={3}, path={4}", filename, title, format, id, path);
}
internal void SetId (int id) {
@@ -208,7 +208,7 @@
internal ContentNode ToFileData (bool thumb) {
ArrayList nodes = new ArrayList ();
- Console.WriteLine("Requested "+ ((thumb)?"thumb":"file") +", thumbnail=" + thumbnail + ", hires=" + path);
+ Console.WriteLine ("Requested "+ ( (thumb)?"thumb":"file") +", thumbnail=" + thumbnail + ", hires=" + path);
nodes.Add (new ContentNode ("dmap.itemkind", (byte)3));
nodes.Add (new ContentNode ("dmap.itemid", id));
@@ -218,12 +218,12 @@
nodes.Add (new ContentNode ("dpap.filedata",
new ContentNode ("dpap.imagefilesize", (thumb)?thumbsize:size),
new ContentNode ("dpap.imagefilename", (thumb)?thumbnail:path),
- new ContentNode ("dpap.imagefilename", (thumb)?thumbnail:fileName)));
+ new ContentNode ("dpap.imagefilename", (thumb)?thumbnail:filename)));
- return (new ContentNode("dmap.listingitem", nodes));
+ return (new ContentNode ("dmap.listingitem", nodes));
}
- internal ContentNode ToNode (string[] fields) {
+ internal ContentNode ToNode (string [] fields) {
ArrayList nodes = new ArrayList ();
@@ -255,7 +255,7 @@
val = format;
break;
case "dpap.imagefilename":
- val = fileName;
+ val = filename;
break;
case "dpap.imagefilesize":
val = thumbsize;
@@ -298,7 +298,7 @@
internal static Photo FromNode (ContentNode node) {
Photo photo = new Photo ();
- foreach (ContentNode field in (ContentNode[]) node.Value) {
+ foreach (ContentNode field in (ContentNode []) node.Value) {
switch (field.Name) {
case "dmap.itemid":
photo.id = (int) field.Value;
@@ -310,7 +310,7 @@
photo.format = (string) field.Value;
break;
case "dpap.imagefilename":
- photo.fileName = (string) field.Value;
+ photo.filename = (string) field.Value;
break;
/* case "dpap.imagefilesize":
photo.size = (int) field.Value;
@@ -329,8 +329,8 @@
return photo;
}
- internal ContentNode ToAlbumNode (string[] fields) {
-ArrayList nodes = new ArrayList ();
+ internal ContentNode ToAlbumNode (string [] fields) {
+ ArrayList nodes = new ArrayList ();
foreach (string field in fields) {
object val = null;
@@ -360,7 +360,7 @@
val = format;
break;
case "dpap.imagefilename":
- val = fileName;
+ val = filename;
break;
case "dpap.imagefilesize":
val = thumbsize;
@@ -401,7 +401,7 @@
return new ContentNode ("dmap.listingitem",
new ContentNode ("dmap.itemkind", (byte) 3),
nodes);
- /* new ContentNode ("dpap.imagefilename", fileName),
+ /* new ContentNode ("dpap.imagefilename", filename),
new ContentNode ("dmap.itemid", Id),
//new ContentNode ("dmap.containeritemid", containerId),
new ContentNode ("dmap.itemname", Title == null ? String.Empty : Title));
@@ -412,10 +412,10 @@
photo = null;
containerId = 0;
- foreach (ContentNode field in (ContentNode[]) node.Value) {
+ foreach (ContentNode field in (ContentNode []) node.Value) {
switch (field.Name) {
case "dmap.itemid":
- photo = db.LookupPhotoById ((int) field.Value);
+ photo = db.LookupPhotoById ( (int) field.Value);
break;
case "dmap.containeritemid":
containerId = (int) field.Value;
@@ -433,8 +433,8 @@
year == photo.Year &&
format == photo.Format &&
size == photo.Size &&
- dateAdded == photo.DateAdded &&
- dateModified == photo.DateModified;
+ date_added == photo.DateAdded &&
+ date_modified == photo.DateModified;
}
internal void Update (Photo photo) {
@@ -447,8 +447,8 @@
year = photo.Year;
format = photo.Format;
size = photo.Size;
- dateAdded = photo.DateAdded;
- dateModified = photo.DateModified;
+ date_added = photo.DateAdded;
+ date_modified = photo.DateModified;
EmitUpdated ();
}
Modified: trunk/dpap-sharp/lib/Server.cs
==============================================================================
--- trunk/dpap-sharp/lib/Server.cs (original)
+++ trunk/dpap-sharp/lib/Server.cs Mon Aug 11 12:11:12 2008
@@ -53,7 +53,7 @@
private List<NetworkCredential> creds = new List<NetworkCredential> ();
private ArrayList clients = new ArrayList ();
private string realm;
- private AuthenticationMethod authMethod = AuthenticationMethod.None;
+ private AuthenticationMethod auth_method = AuthenticationMethod.None;
public ushort RequestedPort {
get { return port; }
@@ -69,8 +69,8 @@
}
public AuthenticationMethod AuthenticationMethod {
- get { return authMethod; }
- set { authMethod = value; }
+ get { return auth_method; }
+ set { auth_method = value; }
}
public string Realm {
@@ -125,7 +125,7 @@
WriteResponse (client, code, Encoding.UTF8.GetBytes (body));
}
- public void WriteResponse (Socket client, HttpStatusCode code, byte[] body) {
+ public void WriteResponse (Socket client, HttpStatusCode code, byte [] body) {
if (!client.Connected)
return;
@@ -141,10 +141,10 @@
public void WriteResponseFile (Socket client, string file, long offset) {
// DEBUG data
- Console.WriteLine("WriteResponseFile!!");
+ Console.WriteLine ("WriteResponseFile!!");
FileInfo info = new FileInfo (file);
- FileStream stream = info.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
+ FileStream stream = info.Open (FileMode.Open, FileAccess.Read, FileShare.Read);
WriteResponseStream (client, stream, info.Length, offset);
}
@@ -175,7 +175,7 @@
long count = 0;
while (count < len) {
- byte[] buf = reader.ReadBytes (Math.Min (ChunkLength, (int) len - (int) count));
+ byte [] buf = reader.ReadBytes (Math.Min (ChunkLength, (int) len - (int) count));
if (buf.Length == 0) {
break;
}
@@ -202,12 +202,12 @@
}
private bool IsValidAuth (string user, string pass) {
- if (authMethod == AuthenticationMethod.None)
+ if (auth_method == AuthenticationMethod.None)
return true;
foreach (NetworkCredential cred in creds) {
- if ((authMethod != AuthenticationMethod.UserAndPassword || cred.UserName == user) &&
+ if ( (auth_method != AuthenticationMethod.UserAndPassword || cred.UserName == user) &&
cred.Password == pass)
return true;
}
@@ -240,24 +240,24 @@
if (line == "Connection: close") {
ret = false;
} else if (line != null && line.StartsWith ("Authorization: Basic")) {
- string[] splitLine = line.Split (' ');
+ string [] splitLine = line.Split (' ');
if (splitLine.Length != 3)
continue;
- string userpass = Encoding.UTF8.GetString (Convert.FromBase64String (splitLine[2]));
+ string userpass = Encoding.UTF8.GetString (Convert.FromBase64String (splitLine [2]));
- string[] splitUserPass = userpass.Split (new char[] {':'}, 2);
- user = splitUserPass[0];
- password = splitUserPass[1];
+ string [] splitUserPass = userpass.Split (new char [] {':'}, 2);
+ user = splitUserPass [0];
+ password = splitUserPass [1];
} else if (line != null && line.StartsWith ("Range: ")) {
// we currently expect 'Range: bytes=<offset>-'
- string[] splitLine = line.Split ('=');
+ string [] splitLine = line.Split ('=');
if (splitLine.Length != 2)
continue;
- string rangestr = splitLine[1];
+ string rangestr = splitLine [1];
if (!rangestr.EndsWith ("-"))
continue;
@@ -269,14 +269,14 @@
} while (line != String.Empty && line != null);
- string[] splitRequest = request.Split ();
+ string [] splitRequest = request.Split ();
if (splitRequest.Length < 3) {
WriteResponse (client, HttpStatusCode.BadRequest, "Bad Request");
} else {
try {
- string path = splitRequest[1];
+ string path = splitRequest [1];
if (!path.StartsWith ("dpap://")) {
- Console.WriteLine("Path is not correct - " + path);
+ Console.WriteLine ("Path is not correct - " + path);
path = String.Format ("dpap://localhost{0}", path);
}
@@ -284,18 +284,18 @@
NameValueCollection query = new NameValueCollection ();
if (uri.Query != null && uri.Query != String.Empty) {
- string[] splitquery = uri.Query.Substring (1).Split ('&');
+ string [] splitquery = uri.Query.Substring (1).Split ('&');
foreach (string queryItem in splitquery) {
if (queryItem == String.Empty)
continue;
- string[] splitQueryItem = queryItem.Split ('=');
- query[splitQueryItem[0]] = splitQueryItem[1];
+ string [] splitQueryItem = queryItem.Split ('=');
+ query [splitQueryItem [0]] = splitQueryItem [1];
}
}
- if (authMethod != AuthenticationMethod.None && uri.AbsolutePath == "/login" &&
+ if (auth_method != AuthenticationMethod.None && uri.AbsolutePath == "/login" &&
!IsValidAuth (user, password)) {
WriteAccessDenied (client);
return true;
@@ -306,7 +306,7 @@
ret = false;
} catch (Exception e) {
ret = false;
- Console.Error.WriteLine ("Trouble handling request {0}: {1}", splitRequest[1], e);
+ Console.Error.WriteLine ("Trouble handling request {0}: {1}", splitRequest [1], e);
}
}
}
@@ -361,7 +361,7 @@
}
public void AddRevision (List<Database> databases) {
- revisions[++current] = databases;
+ revisions [++current] = databases;
if (revisions.Keys.Count > limit) {
// remove the oldest
@@ -383,9 +383,9 @@
public List<Database> GetRevision (int rev) {
if (rev == 0)
- return revisions[current];
+ return revisions [current];
else
- return revisions[rev];
+ return revisions [rev];
}
public Database GetDatabase (int rev, int id) {
@@ -440,11 +440,11 @@
internal static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes (30);
- private static Regex dbItemsRegex = new Regex ("/databases/([0-9]*?)/items$");
- private static Regex dbPhotoRegex0 = new Regex ("/databases/([0-9]*?)/items$");
- private static Regex dbPhotoRegex = new Regex (".*'dmap.itemid:([0-9]*)'.*");
- private static Regex dbContainersRegex = new Regex ("/databases/([0-9]*?)/containers$");
- private static Regex dbContainerItemsRegex = new Regex ("/databases/([0-9]*?)/containers/([0-9]*?)/items$");
+ private static Regex dbItemsRegex = new Regex ("/databases/ ( [0-9]*?)/items$");
+ private static Regex dbPhotoRegex0 = new Regex ("/databases/ ( [0-9]*?)/items$");
+ private static Regex dbPhotoRegex = new Regex (".*'dmap.itemid: ( [0-9]*)'.*");
+ private static Regex dbContainersRegex = new Regex ("/databases/ ( [0-9]*?)/containers$");
+ private static Regex dbContainerItemsRegex = new Regex ("/databases/ ( [0-9]*?)/containers/ ( [0-9]*?)/items$");
private WebServer ws;
private ArrayList databases = new ArrayList ();
@@ -577,7 +577,7 @@
public void Commit () {
List<Database> clones = new List<Database> ();
foreach (Database db in databases) {
- clones.Add ((Database) db.Clone ());
+ clones.Add ( (Database) db.Clone ());
}
lock (revmgr) {
@@ -597,7 +597,7 @@
zc_service = new RegisterService ();
zc_service.Name = serverInfo.Name;
zc_service.RegType = "_dpap._tcp";
- zc_service.Port = 8770; //(short)ws.BoundPort;
+ zc_service.Port = 8770; // (short)ws.BoundPort;
zc_service.TxtRecord = new TxtRecord ();
zc_service.TxtRecord.Add ("Password", auth);
zc_service.TxtRecord.Add ("Machine Name", serverInfo.Name);
@@ -637,7 +637,7 @@
private void ExpireSessions () {
lock (sessions) {
foreach (int s in new List<int> (sessions.Keys)) {
- User user = sessions[s];
+ User user = sessions [s];
if (DateTime.Now - user.LastActionTime > DefaultTimeout) {
sessions.Remove (s);
@@ -671,14 +671,14 @@
internal bool OnHandleRequest (Socket client, string username, string path, NameValueCollection query, int range) {
string photoQuery;
- if(query["query"] != null)
- photoQuery = query["query"];
+ if (query ["query"] != null)
+ photoQuery = query ["query"];
else
photoQuery = "";
int session = 0;
- if (query["session-id"] != null) {
- session = Int32.Parse (query["session-id"]);
+ if (query ["session-id"] != null) {
+ session = Int32.Parse (query ["session-id"]);
}
/* if (!sessions.ContainsKey (session) && path != "/server-info" && path != "/content-codes" &&
@@ -688,21 +688,21 @@
}
*/
if (session != 0) {
- sessions[session].LastActionTime = DateTime.Now;
+ sessions [session].LastActionTime = DateTime.Now;
}
int clientRev = 0;
- if (query["revision-number"] != null) {
- clientRev = Int32.Parse (query["revision-number"]);
+ if (query ["revision-number"] != null) {
+ clientRev = Int32.Parse (query ["revision-number"]);
}
int delta = 0;
- if (query["delta"] != null) {
- delta = Int32.Parse (query["delta"]);
+ if (query ["delta"] != null) {
+ delta = Int32.Parse (query ["delta"]);
}
// DEBUG data
- Console.WriteLine("Before returning resources for path " + path + ", meta " + query["meta"] + " query " + photoQuery);
- if(dbItemsRegex.IsMatch (path)) //&& photoQuery.Length==0
+ Console.WriteLine ("Before returning resources for path " + path + ", meta " + query ["meta"] + " query " + photoQuery);
+ if (dbItemsRegex.IsMatch (path)) //&& photoQuery.Length==0
Console.WriteLine ("\tThis is a database/items request!");
if (path == "/server-info") {
@@ -721,28 +721,28 @@
User user = new User (DateTime.Now, (client.RemoteEndPoint as IPEndPoint).Address, username);
lock (sessions) {
- sessions[session] = user;
+ sessions [session] = user;
}
ws.WriteResponse (client, GetLoginNode (session));
OnUserLogin (user);
} else if (path == "/logout") {
- User user = sessions[session];
+ User user = sessions [session];
lock (sessions) {
sessions.Remove (session);
}
- ws.WriteResponse (client, HttpStatusCode.OK, new byte[0]);
+ ws.WriteResponse (client, HttpStatusCode.OK, new byte [0]);
OnUserLogout (user);
return false;
} else if (path == "/databases") {
- Console.WriteLine("path==/databases");
+ Console.WriteLine ("path==/databases");
ws.WriteResponse (client, GetDatabasesNode ());
- } else if (dbItemsRegex.IsMatch (path) && photoQuery.Length==0 ){ //&& !dbPhotoRegex.IsMatch(query["query"])) {
- Console.WriteLine("dbItemsRegex, query=" + query["query"] + " meta=" + query["meta"]);
- int dbid = Int32.Parse (dbItemsRegex.Match (path).Groups[1].Value);
+ } else if (dbItemsRegex.IsMatch (path) && photoQuery.Length==0 ){ //&& !dbPhotoRegex.IsMatch (query ["query"])) {
+ Console.WriteLine ("dbItemsRegex, query=" + query ["query"] + " meta=" + query ["meta"]);
+ int dbid = Int32.Parse (dbItemsRegex.Match (path).Groups [1].Value);
Database curdb = revmgr.GetDatabase (clientRev, dbid);
@@ -764,35 +764,35 @@
}
}
- ContentNode node = curdb.ToPhotosNode (query["meta"].Split (','),
- (int[]) deletedIds.ToArray (typeof (int)));
+ ContentNode node = curdb.ToPhotosNode (query ["meta"].Split (','),
+ (int []) deletedIds.ToArray (typeof (int)));
ws.WriteResponse (client, node);
} else if (dbPhotoRegex.IsMatch (photoQuery)) {
- Console.WriteLine("dbPhotoRegex");
- Console.WriteLine("dbPhotosRegex, query=" + query["query"] + " meta=" + query["meta"]);
- string[] photoIds = query["query"].Split (',');
- Match match = dbPhotoRegex0.Match(path);
- int dbid = Int32.Parse (match.Groups[1].Value);
+ Console.WriteLine ("dbPhotoRegex");
+ Console.WriteLine ("dbPhotosRegex, query=" + query ["query"] + " meta=" + query ["meta"]);
+ string [] photoIds = query ["query"].Split (',');
+ Match match = dbPhotoRegex0.Match (path);
+ int dbid = Int32.Parse (match.Groups [1].Value);
int photoid = 0;
- //match = dbPhotoRegex.Match(photoQuery);
+ //match = dbPhotoRegex.Match (photoQuery);
Database db = revmgr.GetDatabase (clientRev, dbid);
if (db == null) {
ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid database id");
return true;
}
- ArrayList photoNodes = new ArrayList();
+ ArrayList photoNodes = new ArrayList ();
Photo photo = db.LookupPhotoById (1);
foreach (string photoId in photoIds)
{
match = dbPhotoRegex.Match (photoId);
- photoid = Int32.Parse (match.Groups[1].Value);
- Console.WriteLine("Requested photo id=" + photoid);
+ photoid = Int32.Parse (match.Groups [1].Value);
+ Console.WriteLine ("Requested photo id=" + photoid);
photo = db.LookupPhotoById (photoid);
- photoNodes.Add(photo.ToFileData(query["meta"].Contains("dpap.thumb")));
+ photoNodes.Add (photo.ToFileData (query ["meta"].Contains ("dpap.thumb")));
}
ArrayList children = new ArrayList ();
@@ -803,7 +803,7 @@
children.Add (new ContentNode ("dmap.listing", photoNodes));
ContentNode dbsongs = new ContentNode ("dpap.databasesongs", children);
- Console.WriteLine("Photo tostring: " + photo.ToString());
+ Console.WriteLine ("Photo tostring: " + photo.ToString ());
if (photo == null) {
ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid photo id");
return true;
@@ -818,13 +818,13 @@
} catch {}
if (photo.FileName != null) {
- Console.WriteLine("photo.Filename != null" + query["meta"].Split (',')[0]);
- //ContentNode node = photo.ToFileData();
- //node.Dump();
+ Console.WriteLine ("photo.Filename != null" + query ["meta"].Split (',') [0]);
+ //ContentNode node = photo.ToFileData ();
+ //node.Dump ();
ws.WriteResponse (client, dbsongs);
// ws.WriteResponseFile (client, photo.FileName, range);
} else if (db.Client != null) {
- Console.WriteLine("db.Client != null");
+ Console.WriteLine ("db.Client != null");
long photoLength = 0;
Stream photoStream = db.StreamPhoto (photo, out photoLength);
@@ -833,14 +833,14 @@
} catch (IOException) {
}
} else {
- Console.WriteLine("Else - internal error");
+ Console.WriteLine ("Else - internal error");
ws.WriteResponse (client, HttpStatusCode.InternalServerError, "no file");
}
} finally {
client.Close ();
}
} else if (dbContainersRegex.IsMatch (path)) {
- int dbid = Int32.Parse (dbContainersRegex.Match (path).Groups[1].Value);
+ int dbid = Int32.Parse (dbContainersRegex.Match (path).Groups [1].Value);
Database db = revmgr.GetDatabase (clientRev, dbid);
if (db == null) {
@@ -851,10 +851,10 @@
ws.WriteResponse (client, db.ToAlbumsNode ());
} else if (dbContainerItemsRegex.IsMatch (path)) {
// DEBUG
- Console.WriteLine("ContainerItems !");
+ Console.WriteLine ("ContainerItems !");
Match match = dbContainerItemsRegex.Match (path);
- int dbid = Int32.Parse (match.Groups[1].Value);
- int plid = Int32.Parse (match.Groups[2].Value);
+ int dbid = Int32.Parse (match.Groups [1].Value);
+ int plid = Int32.Parse (match.Groups [2].Value);
Database curdb = revmgr.GetDatabase (clientRev, dbid);
if (curdb == null) {
@@ -886,9 +886,9 @@
}
}
}
- curpl.ToPhotosNode (query["meta"].Split (',')).Dump();
- ws.WriteResponse (client, curpl.ToPhotosNode (query["meta"].Split (',')));
- //, (int[]) deletedIds.ToArray (typeof (int))));
+ curpl.ToPhotosNode (query ["meta"].Split (',')).Dump ();
+ ws.WriteResponse (client, curpl.ToPhotosNode (query ["meta"].Split (',')));
+ //, (int []) deletedIds.ToArray (typeof (int))));
} else if (path == "/update") {
int retrev;
@@ -921,7 +921,7 @@
private ContentNode GetServerInfoNode () {
- return serverInfo.ToNode(databases.Count);
+ return serverInfo.ToNode (databases.Count);
}
private ContentNode GetDatabasesNode () {
Modified: trunk/dpap-sharp/lib/ServerInfo.cs
==============================================================================
--- trunk/dpap-sharp/lib/ServerInfo.cs (original)
+++ trunk/dpap-sharp/lib/ServerInfo.cs Mon Aug 11 12:11:12 2008
@@ -39,8 +39,8 @@
internal class ServerInfo {
private string name;
- private AuthenticationMethod authMethod;
- private bool supportsUpdate;
+ private AuthenticationMethod auth_method;
+ private bool supports_update;
public string Name {
get { return name; }
@@ -48,13 +48,13 @@
}
public AuthenticationMethod AuthenticationMethod {
- get { return authMethod; }
- set { authMethod = value; }
+ get { return auth_method; }
+ set { auth_method = value; }
}
public bool SupportsUpdate {
- get { return supportsUpdate; }
- set { supportsUpdate = value; }
+ get { return supports_update; }
+ set { supports_update = value; }
}
internal static ServerInfo FromNode (ContentNode node) {
@@ -63,7 +63,7 @@
if (node.Name != "dmap.serverinforesponse")
return null;
- foreach (ContentNode child in (node.Value as ContentNode[])) {
+ foreach (ContentNode child in (node.Value as ContentNode [])) {
switch (child.Name) {
case "dmap.itemname":
info.Name = (string) child.Value;
@@ -84,13 +84,12 @@
return new ContentNode ("dmap.serverinforesponse",
new ContentNode ("dmap.status", 200),
new ContentNode ("dmap.protocolversion", new Version (2, 0, 0)),
- new ContentNode ("dpap.protocolversion", new Version (1, 0, 1)),
-
+ new ContentNode ("dpap.protocolversion", new Version (1, 0, 1)),
new ContentNode ("dmap.itemname", "photos"),
new ContentNode ("dmap.loginrequired", (byte) 1),
- // new ContentNode ("dmap.authenticationmethod", (byte) authMethod),
- new ContentNode ("dmap.timeoutinterval", (int) Server.DefaultTimeout.TotalSeconds),
- new ContentNode ("dmap.supportsautologout", (byte) 1),
+ // new ContentNode ("dmap.authenticationmethod", (byte) auth_method),
+ new ContentNode ("dmap.timeoutinterval", (int) Server.DefaultTimeout.TotalSeconds),
+ new ContentNode ("dmap.supportsautologout", (byte) 1),
// new ContentNode ("dmap.supportsupdate", (byte) 1),
// new ContentNode ("dmap.supportspersistentids", (byte) 1),
// new ContentNode ("dmap.supportsextensions", (byte) 1),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]