banshee r4309 - in trunk/banshee: . src src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Addins.Gui src/Extensions src/Extensions/Banshee.SqlDebugConsole src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole src/Extensions/Banshee.SqlDebugConsole/Resources src/Extensions/Template src/Libraries/Hyena/Hyena.Data.Sqlite



Author: gburt
Date: Thu Jul 31 01:14:46 2008
New Revision: 4309
URL: http://svn.gnome.org/viewvc/banshee?rev=4309&view=rev

Log:
2008-07-30  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Extensions.mds:
	* src/Extensions/Banshee.SqlDebugConsole/Makefile.am:
	* src/Extensions/Banshee.SqlDebugConsole/Resources/GlobalUI.xml:
	* src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.addin.xml:
	* src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.mdp:
	* src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/SqlActions.cs:
	* src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs: New addin,
	not yet finished or really working, to view SQL queries that are run in
	Banshee, and eventually be able to run them and arbitrary queries in
	Banshee's connection, with an option to run them 50 or whatever times to
	benchmark them.

	* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs: Add a new
	EventArgs subclass for the new CommandExecuted event.  This event is only
	fired if LogAll is true.

	* src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml:
	* src/Extensions/Template/Template.addin.xml:
	* src/create-extension:
	* configure.ac: Clarify and simplify extension creation.



Added:
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/   (props changed)
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.addin.xml
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.mdp
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/SqlActions.cs
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Makefile.am
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Resources/
   trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Resources/GlobalUI.xml
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/configure.ac
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
   trunk/banshee/src/Extensions/Extensions.mds
   trunk/banshee/src/Extensions/Template/Template.addin.xml
   trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
   trunk/banshee/src/create-extension

Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac	(original)
+++ trunk/banshee/configure.ac	Thu Jul 31 01:14:46 2008
@@ -175,6 +175,7 @@
 src/Extensions/Banshee.NowPlaying/Makefile
 src/Extensions/Banshee.PlayQueue/Makefile
 src/Extensions/Banshee.Podcasting/Makefile
+src/Extensions/Banshee.SqlDebugConsole/Makefile
 src/Extensions/Banshee.Sample/Makefile
 ])
 

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs	Thu Jul 31 01:14:46 2008
@@ -56,7 +56,8 @@
         {
             foreach (Addin addin in AddinManager.Registry.GetAddins ()) {
                 if (addin.Name != addin.Id && addin.Description != null && 
-                    addin.Description.Category != null && !addin.Description.Category.StartsWith ("required:")) {
+                    addin.Description.Category != null && !addin.Description.Category.StartsWith ("required:") &&
+                    (!addin.Description.Category.Contains ("Debug") || Banshee.Base.ApplicationContext.Debugging)) {
                     AppendAddin (addin);
                 }
             }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml	Thu Jul 31 01:14:46 2008
@@ -19,13 +19,13 @@
   </Extension>
 
   <ExtensionPoint path="/Banshee/ThickClient/ActionGroup">
-    <Description>Defines a new action group, possibly in conjunction with a Source extension.</Description>
+    <Description>Defines a new GTK+ action group, possibly in conjunction with a Source extension.</Description>
     <ExtensionNode name="ActionGroup"/>
   </ExtensionPoint>
 
   <ExtensionPoint path="/Banshee/ThickClient/SourceView">
-    <Description>Defines a new action group, possibly in conjunction with a Source extension.</Description>
-    <ExtensionNode name="ActionGroup"/>
+    <Description>Defines a new GTK+ source view, possibly in conjunction with a Source extension.</Description>
+    <ExtensionNode name="SourceView"/>
   </ExtensionPoint>
   
 </Addin>

Added: trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.addin.xml	Thu Jul 31 01:14:46 2008
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin 
+    id="Banshee.SqlDebugConsole"
+    version="1.0"
+    compatVersion="1.0"
+    copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
+    name="SQL Debug Console"
+    category="Debug"
+    description="Provides a UI for monitoring Banshee's SQL usage, and running queries."
+    author="Gabriel Burt"
+    url="http://banshee-project.org/";
+    defaultEnabled="false">
+
+  <Dependencies>
+    <Addin id="Banshee.Services" version="1.0"/>
+    <Addin id="Banshee.ThickClient" version="1.0"/>
+  </Dependencies>
+
+  <!--<Extension path="/Banshee/ServiceManager/Service">
+    <Service class="Banshee.SqlDebugConsole.SqlMonitor"/>
+</Extension>-->
+
+  <Extension path="/Banshee/ServiceManager/Service">
+    <Service class="Banshee.SqlDebugConsole.SqlActions"/>
+  </Extension>
+
+</Addin>

Added: trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.mdp
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.mdp	Thu Jul 31 01:14:46 2008
@@ -0,0 +1,28 @@
+<Project name="Banshee.SqlDebugConsole" fileversion="2.0" UseParentDirectoryAsNamespace="True" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.SqlDebugConsole" />
+      <Build debugmode="True" target="Library" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="Banshee.SqlDebugConsole.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
+  </Contents>
+  <References>
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
+    <ProjectReference type="Project" localcopy="True" refto="Hyena" />
+    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  </References>
+  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
+    <BuildFilesVar Sync="True" Name="SOURCES" />
+    <DeployFilesVar />
+    <ResourcesVar Sync="True" Name="RESOURCES" />
+    <OthersVar />
+    <GacRefVar />
+    <AsmRefVar />
+    <ProjectRefVar />
+  </MonoDevelop.Autotools.MakefileInfo>
+</Project>

Added: trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/SqlActions.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/SqlActions.cs	Thu Jul 31 01:14:46 2008
@@ -0,0 +1,143 @@
+//
+// SqlActions.cs
+//
+// Authors:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+using Mono.Unix;
+
+using Hyena.Data.Sqlite;
+
+using Banshee.Base;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+using Banshee.Gui;
+
+using Browser = Banshee.Web.Browser;
+
+namespace Banshee.SqlDebugConsole
+{
+    public class SqlActions : BansheeActionGroup, IExtensionService, IDisposable
+    {
+        private uint actions_id;
+
+        public SqlActions () : base (ServiceManager.Get<InterfaceActionService> (), "SqlDebugActions")
+        {
+        }
+
+        public void Initialize ()
+        {
+            Add (new ActionEntry [] {
+                new ActionEntry (
+                    "ShowConsoleAction", null,
+                     Catalog.GetString ("Show SQL Console"),
+                     null, String.Empty, OnShowConsole
+                ),
+                new ActionEntry (
+                    "StartSqlMonitoringAction", "gtk-start",
+                    Catalog.GetString ("Start SQL Monitoring"),
+                    null, String.Empty, OnStartSqlMonitoring
+                ),
+                new ActionEntry (
+                    "StopSqlMonitoringAction", "gtk-stop",
+                    Catalog.GetString ("Stop SQL Monitoring"),
+                    null, String.Empty, OnStopSqlMonitoring
+                )
+            });
+
+            actions_id = Actions.UIManager.AddUiFromResource ("GlobalUI.xml");
+            Actions.AddActionGroup (this);
+
+            UpdateActions ();
+        }
+
+        public override void Dispose ()
+        {
+            Actions.UIManager.RemoveUi (actions_id);
+            Actions.RemoveActionGroup (this);
+            base.Dispose ();
+        }
+
+#region Action Handlers 
+
+        private void OnShowConsole (object sender, EventArgs args)
+        {
+            // The idea is this would open a non-modal dialog with a TreeView
+            // showing the queries that were executed, their run time, etc.  And
+            // there would be a text entry box where you could run queries, with
+            // Run Once, Run [n] Times buttons.
+            Console.WriteLine ("console start requested");
+        }
+
+        private void OnStartSqlMonitoring (object sender, EventArgs args)
+        {
+            LoggingSql = true;
+        }
+
+        private void OnStopSqlMonitoring (object sender, EventArgs args)
+        {
+            LoggingSql = false;
+        }
+
+#endregion
+
+        private bool LoggingSql {
+            get { return Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll; }
+            set {
+                if (value == LoggingSql) {
+                    return;
+                }
+
+                if (value) {
+                    HyenaSqliteCommand.CommandExecuted += OnCommandExecuted;
+                } else {
+                    HyenaSqliteCommand.CommandExecuted -= OnCommandExecuted;
+                }
+
+                HyenaSqliteCommand.LogAll = value;
+                UpdateActions ();
+            }
+        }
+
+        private void OnCommandExecuted (object o, CommandExecutedArgs args)
+        {
+            Hyena.Log.DebugFormat ("in {0}ms executed {1}", args.Ms, args.SqlWithValues);
+        }
+
+        private void UpdateActions ()
+        {
+            this["StartSqlMonitoringAction"].Sensitive = !LoggingSql;
+            this["StopSqlMonitoringAction"].Sensitive = LoggingSql;
+        }
+
+        string IService.ServiceName {
+            get { return "SqlDebuggerActions"; }
+        }
+    }
+}

Added: trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Makefile.am	Thu Jul 31 01:14:46 2008
@@ -0,0 +1,12 @@
+ASSEMBLY = Banshee.SqlDebugConsole
+TARGET = library
+LINK = $(LINK_BANSHEE_THICKCLIENT_DEPS)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = Banshee.SqlDebugConsole/SqlActions.cs
+
+RESOURCES =  \
+	Banshee.SqlDebugConsole.addin.xml \
+	Resources/GlobalUI.xml
+
+include $(top_srcdir)/build/build.mk

Added: trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Resources/GlobalUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.SqlDebugConsole/Resources/GlobalUI.xml	Thu Jul 31 01:14:46 2008
@@ -0,0 +1,11 @@
+<ui>
+  <menubar name="MainMenu" action="MainMenuAction">
+    <menu name="ToolsMenu" action="ToolsMenuAction">
+      <separator/>
+      <menuitem name="ShowConsole" action="ShowConsoleAction"/>
+      <menuitem name="StartSqlMonitoring" action="StartSqlMonitoringAction"/>
+      <menuitem name="StopSqlMonitoring" action="StopSqlMonitoringAction"/>
+      <separator/>
+    </menu>
+  </menubar>
+</ui>

Modified: trunk/banshee/src/Extensions/Extensions.mds
==============================================================================
--- trunk/banshee/src/Extensions/Extensions.mds	(original)
+++ trunk/banshee/src/Extensions/Extensions.mds	Thu Jul 31 01:14:46 2008
@@ -16,6 +16,7 @@
       <Entry build="True" name="Banshee.CoverArt" configuration="Debug" />
       <Entry build="True" name="Banshee.FileSystemQueue" configuration="Debug" />
       <Entry build="True" name="Banshee.InternetRadio" configuration="Debug" />
+      <Entry build="True" name="Banshee.SqlDebugConsole" configuration="Debug" />
     </Configuration>
   </Configurations>
   <StartMode startupentry="Banshee.Daap" single="True">
@@ -34,6 +35,7 @@
     <Execute type="None" entry="Banshee.CoverArt" />
     <Execute type="None" entry="Banshee.FileSystemQueue" />
     <Execute type="None" entry="Banshee.InternetRadio" />
+    <Execute type="None" entry="Banshee.SqlDebugConsole" />
   </StartMode>
   <Entries>
     <Entry filename="Banshee.Daap/Banshee.Daap.mdp" />
@@ -51,5 +53,6 @@
     <Entry filename="Banshee.CoverArt/Banshee.CoverArt.mdp" />
     <Entry filename="Banshee.FileSystemQueue/Banshee.FileSystemQueue.mdp" />
     <Entry filename="Banshee.InternetRadio/Banshee.InternetRadio.mdp" />
+    <Entry filename="Banshee.SqlDebugConsole/Banshee.SqlDebugConsole.mdp" />
   </Entries>
-</Combine>
\ No newline at end of file
+</Combine>

Modified: trunk/banshee/src/Extensions/Template/Template.addin.xml
==============================================================================
--- trunk/banshee/src/Extensions/Template/Template.addin.xml	(original)
+++ trunk/banshee/src/Extensions/Template/Template.addin.xml	Thu Jul 31 01:14:46 2008
@@ -4,7 +4,7 @@
     version="1.0"
     compatVersion="1.0"
     copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
-    name=""
+    name="@EXTENSION_NAME@"
     category=""
     description=""
     author=""

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs	Thu Jul 31 01:14:46 2008
@@ -40,6 +40,22 @@
 
 namespace Hyena.Data.Sqlite
 {
+    public class CommandExecutedArgs : EventArgs
+    {
+        public CommandExecutedArgs (string sql, string sqlWithValues, string stackTrace, long ms)
+        {
+            Sql = sql;
+            SqlWithValues = sqlWithValues;
+            StackTrace = stackTrace;
+            Ms = ms;
+        }
+        
+        public string Sql;
+        public string SqlWithValues;
+        public string StackTrace;
+        public long Ms;
+    }
+    
     public class HyenaSqliteCommand
     {
         protected object result = null;
@@ -60,6 +76,9 @@
             get { return log_all; }
             set { log_all = value; }
         }
+        
+        public delegate void CommandExecutedHandler (object o, CommandExecutedArgs args);
+        public static event CommandExecutedHandler CommandExecuted;
 
         public string Text {
             get { return command; }
@@ -118,8 +137,13 @@
                         break;
                 }
 
-                if (log_all)
-                    Log.DebugFormat ("Executed SQL in {0} ms: {1}", System.Environment.TickCount - ticks, sql_command.CommandText);
+                if (log_all) {
+                    Log.DebugFormat ("Executed in {0}ms {1}", System.Environment.TickCount - ticks, sql_command.CommandText);
+                    CommandExecutedHandler handler = CommandExecuted;
+                    if (handler != null) {
+                        handler (this, new CommandExecutedArgs (Text, sql_command.CommandText, null, System.Environment.TickCount - ticks));
+                    }
+                }
             } catch (Exception e) {
                 Log.DebugFormat (String.Format ("Exception executing command: {0}", sql_command.CommandText), e.ToString ()); 
                 execution_exception = e;

Modified: trunk/banshee/src/create-extension
==============================================================================
--- trunk/banshee/src/create-extension	(original)
+++ trunk/banshee/src/create-extension	Thu Jul 31 01:14:46 2008
@@ -129,4 +129,6 @@
 popd &>/dev/null
 
 echo "Done."
+echo "You will need to fix the generated Makefile.am, .addins.xml file, "
+echo "and add an entry to ../configure.ac, then run autogen.sh again."
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]