Re: Roadmap for the future.
- From: dave <davidr sucs org>
- To: Nat Friedman <nat nat org>
- Cc: "dashboard-hackers gnome org" <dashboard-hackers gnome org>
- Subject: Re: Roadmap for the future.
- Date: Fri, 20 Feb 2004 11:56:57 +0000
On Fri, 2004-02-20 at 04:14, Nat Friedman wrote:
> Cool, if you come up with a new patch, I'll put it in.
Splendid. I've cleaned up the previous patch, and made it work correctly
with multiple wildcards.
Cheers,
dave
diff -Naur --exclude-from=exclude dashboard-orig/engine/CluePacketManager.cs dashboard/engine/CluePacketManager.cs
--- dashboard-orig/engine/CluePacketManager.cs 2004-02-20 02:34:16.000000000 +0000
+++ dashboard/engine/CluePacketManager.cs 2004-02-20 11:52:43.708451279 +0000
@@ -141,6 +141,68 @@
this.dashboard = dashboard;
}
+ // this function takes a cluepacket and generates a list of cluepackets
+ // where any wildcard clues have been rewritten
+ private ArrayList RewriteWildcardClues (ArrayList packets, BackendResult parent) {
+ Clue wildClue = null;
+ CluePacket wildPacket = null;
+ /* check for wildcard clues */
+ foreach (CluePacket p in packets) {
+ foreach (Clue clue in p.Clues)
+ if (clue.Type == "*") {
+ wildClue = clue;
+ break;
+ }
+ if (wildClue != null) {
+ wildPacket = p;
+ break;
+ }
+ }
+
+ // if there are no wildcard clues remaining return the list
+ if (wildClue == null)
+ return packets;
+
+ // else rewrite the first wildcard clue in the first wildcard packet
+ // and recurse to handle any remaining wildcards
+
+ // generate list of types to rewrite this clue into
+ ArrayList types = new ArrayList();
+ foreach (Backend backend in dashboard.backends) {
+ if (! backend.Initialized)
+ continue;
+ // Don't send chained cluepackets to the backend
+ // that generated the chained clues.
+ if (parent != null && parent.Backend == backend)
+ continue;
+ if (! backend.AcceptCluePacket (wildPacket))
+ continue;
+ if (backend.SubscribedClues == null)
+ continue;
+ foreach (String type in backend.SubscribedClues)
+ if (!types.Contains (type))
+ types.Add (type);
+ }
+
+ // rewrite the first wildcard clue
+ foreach (String type in types) {
+ CluePacket newPacket = (CluePacket) wildPacket.Clone ();
+ if (wildClue.TriggeringMatch == null)
+ newPacket.Clues[newPacket.Clues.IndexOf (wildClue)] =
+ new Clue (type, wildClue.Text, wildClue.Relevance, null);
+ else
+ newPacket.Clues[newPacket.Clues.IndexOf (wildClue)] =
+ new Clue (type, wildClue.Text, wildClue.Relevance, (Match) wildClue.TriggeringMatch.Clone ());
+ packets.Add (newPacket);
+ }
+
+ // remove the original packet
+ packets.Remove (wildPacket);
+
+ // recurse to handle any remaining wildcards
+ return RewriteWildcardClues (packets, parent);
+ }
+
// This function gets called whenever a cluepacket enters the system
public void ProcessCluePacket (CluePacket cp, BackendResult parent)
{
@@ -150,31 +212,37 @@
if (! cp.Focused)
return;
- lock (dashboard.backends) {
- foreach (Backend backend in dashboard.backends) {
- if (! backend.Initialized)
- continue;
-
- // Don't send chained cluepackets to the backend
- // that generated the chained clues.
- if (parent != null && parent.Backend == backend)
- continue;
-
- if (! backend.AcceptCluePacket (cp))
- continue;
-
- Console.WriteLine ("--sending--> " + backend.Name);
-
- // Process each of the backends in a new thread
- BackendWorker worker = new BackendWorker (backend, cp, parent, new BackendWorkerCallback (BackendWorkerDone));
- Thread worker_thread = new Thread (new ThreadStart (worker.QueryBackend));
- lock (this.backend_workers) {
- backend_workers.Add (new ActiveBackendWorker (worker_thread, backend));
- }
- worker_thread.Start ();
- }
- }
- }
+ ArrayList packets = new ArrayList ();
+ packets.Add (cp);
+ packets = RewriteWildcardClues (packets, parent);
+
+ foreach (CluePacket p in packets) {
+ lock (dashboard.backends) {
+ foreach (Backend backend in dashboard.backends) {
+ if (! backend.Initialized)
+ continue;
+
+ // Don't send chained cluepackets to the backend
+ // that generated the chained clues.
+ if (parent != null && parent.Backend == backend)
+ continue;
+
+ if (! backend.AcceptCluePacket (p))
+ continue;
+
+ Console.WriteLine ("--sending--> " + backend.Name);
+
+ // Process each of the backends in a new thread
+ BackendWorker worker = new BackendWorker (backend, p, parent, new BackendWorkerCallback (BackendWorkerDone));
+ Thread worker_thread = new Thread (new ThreadStart (worker.QueryBackend));
+ lock (this.backend_workers) {
+ backend_workers.Add (new ActiveBackendWorker (worker_thread, backend));
+ }
+ worker_thread.Start ();
+ }
+ }
+ }
+ }
// Called when a backend thread finishes
void BackendWorkerDone (BackendWorkerResult res)
diff -Naur --exclude-from=exclude dashboard-orig/engine/dashboard.cs dashboard/engine/dashboard.cs
--- dashboard-orig/engine/dashboard.cs 2004-02-20 01:44:01.000000000 +0000
+++ dashboard/engine/dashboard.cs 2004-02-20 11:32:21.000000000 +0000
@@ -292,7 +292,7 @@
private void SendQuery (object o, EventArgs e) {
CluePacket cp = new CluePacket ("Dashboard", "Default", true);
- cp.Clues.Add (new Clue ("aim_name", this.window.QueryEntry.Text, 10));
+ cp.Clues.Add (new Clue ("*", this.window.QueryEntry.Text, 10));
CluePacketNotifyCallback(cp);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]