commit 0eea575a3cc68873de42e46ed2963bde3d046425
Author: Panagiotis Kanavos <pkanavos@gmail.com>
Date:   Mon Aug 22 18:00:07 2011 +0300

    Added hammock project to debug streaming issues
    Added latest Castle Activerecord version to target ClientProfile
    Modified StatusKeeper.cs to overcome SQLite synch issues. Now only a single thread makes changes to the database

diff --git a/trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs b/trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs
index 4bd6526..1874ae0 100644
--- a/trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs
+++ b/trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs
@@ -25,7 +25,10 @@ namespace Pithos.ShellExtensions.Overlays
 
         public IconOverlayBase(string iconName)
         {
-            Trace.Write("Icon Overlay Instance created");
+            if (String.IsNullOrWhiteSpace(iconName))
+                throw new ArgumentNullException("iconName","Empty iconName");
+
+            Debug.WriteLine("Icon Overlay Instance created", LogCategories.ShellOverlays);
             IoC.Current.Compose(this);
             
 
@@ -46,16 +49,16 @@ namespace Pithos.ShellExtensions.Overlays
         public int IsMemberOf(string path, uint attributes)
         {
             if (String.IsNullOrWhiteSpace(path))
-                throw new ArgumentNullException("Empty path");
+                throw new ArgumentNullException("path","Empty path");
 
-            Trace.Write(String.Format("ICON Status check for {0} - {1}",path,GetType().Name));
+            Debug.WriteLine(String.Format("ICON Status check for {0} - {1}", path, GetType().Name), LogCategories.ShellOverlays);
             
             if (!path.StartsWith(Settings.PithosPath,true,null))
                 return WinError.S_FALSE;
 
             var status=StatusChecker.GetFileOverlayStatus(path);
             var isMember = (PithosPrefix + status == OverlayName);
-            Trace.Write(String.Format("Status check for {0} is {1}",path,isMember));
+            Debug.WriteLine(String.Format("[STATUS] Was {0}, expected {1} for {2}", status, OverlayName,path ), LogCategories.ShellOverlays);
             return isMember ? WinError.S_OK : WinError.S_FALSE;
         }
 
@@ -65,13 +68,18 @@ namespace Pithos.ShellExtensions.Overlays
             out int iconIndex,
             out uint flags)
         {
-            Trace.Write("Looking for icons");
-
-            Trace.WriteLine(string.Format("ICON file {0}", IconPath));
+            Contract.Requires(iconFileBuffer!=IntPtr.Zero);
+            Contract.Requires(iconFileBufferSize>0);
+
+            if (iconFileBuffer == IntPtr.Zero)
+                throw new ArgumentNullException("iconFileBuffer","iconFileBuffer not initialized");
+            if (iconFileBufferSize<=0)
+                throw new ArgumentException("iconFileBufferSize", "iconFileBufferSize must be greatere than 0");
+            Debug.WriteLine("Looking for icons", LogCategories.ShellOverlays);
+            Debug.WriteLine(string.Format("ICON file {0}", IconPath), LogCategories.ShellOverlays);
             
             int bytesCount = System.Text.Encoding.Unicode.GetByteCount(IconPath);
-
-            Trace.WriteLine(string.Format(" GetOverlayInfo::{0}",bytesCount));
+            Debug.WriteLine(string.Format(" GetOverlayInfo::{0}", bytesCount), LogCategories.ShellOverlays);
 
             MarshalHelpers.CopyToBuffer(IconPath, iconFileBuffer, iconFileBufferSize);
 
@@ -82,42 +90,58 @@ namespace Pithos.ShellExtensions.Overlays
 
         public int  GetPriority(out int priority)
         {
-            Trace.Write("Checking for priority");
+            Debug.WriteLine("Checking for priority");
             priority = 0;
             return WinError.S_OK;
         }
 
         
-        public static void RegisterOverlay(Type t,string iconName)
+        public static void RegisterOverlay(Type type,string iconName)
         {
+            Contract.Requires(type != null);
+            Contract.Requires(!String.IsNullOrWhiteSpace(iconName));
+
+            if (type == null)
+                throw new ArgumentNullException("type", "type can't be null");
+            if (String.IsNullOrWhiteSpace(iconName))
+                throw new ArgumentNullException("iconName", "iconName can't be null");
+
             try
             {
                 
-                ShellExtReg.RegisterIconOverlayIdentifier(t.GUID, iconName);
+                ShellExtReg.RegisterIconOverlayIdentifier(type.GUID, iconName);
 
                 NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_IDLIST,
                                              IntPtr.Zero, IntPtr.Zero);
-                Trace.Write("Registered icon handler");
+                Debug.WriteLine("Registered icon handler");
             }
             catch (Exception ex)
             {
-                Trace.WriteLine(ex.Message); // Log the error
+                Debug.WriteLine(ex.Message); // Log the error
                 throw;  // Re-throw the exception
             }
         }
 
         
-        public static void UnregisterOverlay(Type t,string iconName)
+        public static void UnregisterOverlay(Type type,string iconName)
         {
+            Contract.Requires(type!=null);
+            Contract.Requires(!String.IsNullOrWhiteSpace(iconName));
+
+            if (type==null)
+                throw new ArgumentNullException("type","type can't be null");
+            if (String.IsNullOrWhiteSpace(iconName))
+                throw new ArgumentNullException("iconName","iconName can't be null");
             try
             {                
-                ShellExtReg.UnregisterIconOverlayIdentifier(t.GUID, iconName);
-                Trace.Write("UnRegistered icon handler");
+                ShellExtReg.UnregisterIconOverlayIdentifier(type.GUID, iconName);
+                Debug.WriteLine(String.Format("UnRegistered icon handler {0}:{1}",iconName,type.GUID), LogCategories.ShellOverlays);
             }
             catch (Exception ex)
             {
-                Trace.WriteLine(ex.Message); // Log the error
-                throw;  // Re-throw the exception
+                //Log and rethrow
+                Trace.TraceError("Failed to unregister overlay {0}:{1} with error {2}",iconName,type.GUID,ex.Message); 
+                throw;  
             }
         }
     }
