コード例 #1
0
		////////////////////////////////////

		private Tile HitToTile (Hit hit)
		{
			Tile t = null;

			// FIXME: We don't want to allow heterogenous containers.

			switch (hit.Type) {

			case "Contact":
				t = new Tile ("contact.html", hit);
				break;

			case "File":
				t = new Tile ("file-generic.html", hit);
				break;

			case "IMLog":
				t = new Tile ("im-log.html", hit);
				break;

			case "MailMessage":
				string icon = "mail.png";
				if (hit ["_IsAnswered"] != null)
					icon = "mail-replied.png";
				else if (hit ["_IsSeen"] != null)
					icon = "mail-read.png";
				hit ["mail:Icon"] = icon;

				if (hit ["_IsSent"] != null)
					t = new Tile ("email-sent.html", hit);
				else
					t = new Tile ("email.html", hit);
				break;

			case "WebHistory":
				t = new Tile ("web-history.html", hit);
				break;

			case "WebLink":
				if (hit.Source == "Google")
					t = new Tile ("google.html", hit);
				break;
			}

			return t;
		}
コード例 #2
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
			public ReqContext2(BeagleWebService wsp, ArrayList nwHits, BT.TileHitCollection thc)
			{
				this._thc = thc;				
				this._wsp = wsp;
				this._nwHits = nwHits;
			}
コード例 #3
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		private bool tenHits = false;		//Flag to do Prefetch check only every 10 hits
		
		private void PrefetchSnippetsForNetworkHits(BT.TileHitCollection thc) 
		{		
			int lastDisplayed = 0;
			
			if (maxDisplayed != 0)
				lastDisplayed = thc.LastDisplayed + 1;
			
			//We have cached snippets for network hits upto maxDisplayed
			if (lastDisplayed < maxDisplayed)	
				return;

			maxDisplayed = thc.LastDisplayed + 1;
			
			//Do Prefetch check once every ten hits
			tenHits = !tenHits;
			if (!tenHits)					
				return; 
				
			if (lastDisplayed < thc.NumResults) {
			
				int limit = 0;
				ArrayList networkHits = new ArrayList();				
				
				if ((thc.NumResults - lastDisplayed) > MAX_HITS_AHEAD)
					limit = lastDisplayed + MAX_HITS_AHEAD;
				else
					limit = thc.NumResults;

				ArrayList hits = _rp.hitsCopy;
				lock (hits.SyncRoot) {
				
					if (limit > hits.Count)
						limit = hits.Count;

					log.Debug("PrefetchSnippets: Scanning result set for Network Hits from {0} to {1}", lastDisplayed, limit); 					
							
					//Get all NetworkHits with snippets field not initialized:
					for (int si = lastDisplayed;  si < limit ; si++)
					{
						if ((hits[si] is NetworkHit) && (((NetworkHit)hits[si]).snippet == null)) 
							networkHits.Add((NetworkHit)hits[si]);
					}
				}

				log.Debug("PrefetchSnippets: Found {0} NetworkHits without snippets", networkHits.Count);
				 
				while (networkHits.Count > 0) {
				
					ArrayList nwHitsPerNode = new ArrayList();
					string hostnamePort = GetHostnamePort((NetworkHit)networkHits[0]);
					
					//Gather NetworkHits from a specific target Networked Beagle
					foreach	(NetworkHit nh in networkHits) 
					{
						string hnp = GetHostnamePort(nh);
						if (hnp == null)
							continue;
							
						if (hnp.Equals(hostnamePort)) {

							if (nwHitsPerNode.Count < MAX_HIT_IDS_PER_REQ)
								nwHitsPerNode.Add(nh);
							else
								break;
						}
					}
											
					//Remove NetworkHits for this Networked Beagle	
					int i = networkHits.Count;
					while (--i >= 0) { 

						string hnp = GetHostnamePort((NetworkHit)networkHits[i]);							
						if ((hnp == null) || hnp.Equals(hostnamePort))
							networkHits.RemoveAt(i);
					}
			
					if (nwHitsPerNode.Count > 0)
					{
						string[] f3 = hostnamePort.Split(':');
						if (f3.Length < 2)
						{
							log.Warn("PrefetchSnippets: Invalid format netBeagle URI in NetworkHit");
							continue; 
						}
						BeagleWebService wsp = new BeagleWebService(f3[0], f3[1]);
							
						string searchToken = GetSearchToken((NetworkHit)nwHitsPerNode[0]);
						
						if (searchToken.Equals("beagle"))  //Check if it is Older version of Beagle networking
							searchToken = null;
							 			
						if (searchToken != null) {
						
							int[] hitHashCodes = new int [nwHitsPerNode.Count];
							for (int j = 0; j < hitHashCodes.Length; j++)
								hitHashCodes[j] = ((NetContext) ((NetworkHit)nwHitsPerNode[j]).context).hashCode;
							
							log.Debug("PrefetchSnippets: Invoking GetSnippets on {0} for {1} hits", wsp.Hostname, nwHitsPerNode.Count);
					
							GetSnippetsRequest sreq = new GetSnippetsRequest();
							sreq.searchToken = searchToken;
							sreq.hitHashCodes = hitHashCodes;
											
							ReqContext2 rc = new ReqContext2(wsp, nwHitsPerNode, thc);
							wsp.BeginGetSnippets(sreq, PrefetchSnippetsResponseHandler, rc);
						}	
						
						//Signal change in TileHitCollection due to addition of snippets:
						//_rp.rootTile.HitCollection.ClearSources(null);										
					}
				} //end while								
			} //end if 
		} 
コード例 #4
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		override public void Tile (BT.Tile tile)
		{
			tileTable [tile.UniqueKey] = tile;

			if (!renderStylesDone) {			
	//KNV: Using static_stylesheet for now. Replace with TileCanvas logic later:
				Write(static_stylesheet);
/*
				Write ("<style type=\"text/css\" media=\"screen\">");
				TileCanvas.RenderStyles (this);
				Write ("</style>");
*/
				renderStylesDone = true;				
			}
				
			if (tile != null) {
			
				if (tile is BT.TileHitCollection) 
					PrefetchSnippetsForNetworkHits((BT.TileHitCollection)tile);
					
				tile.Render (this);
			}
		}
コード例 #5
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		override public void Link (string label, 
					   BT.TileActionHandler handler)
		{
		       	string key = AddAction (handler);
				Write ("<a href=\"{0}\">{1}</a>", key, label);
		}
コード例 #6
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		private string AddAction (BT.TileActionHandler handler)
		{
			if (handler == null)
				return "dynaction:NULL";
			string key = "dynaction:" + actionId.ToString ();
			++actionId;
			actionTable [key] = handler;
			return key;
		}
コード例 #7
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		public ResultPair(BT.SimpleRootTile rootTile) {
			this._rootTile = rootTile;
			_hitsCopy = ArrayList.Synchronized(new ArrayList());
		}
コード例 #8
0
ファイル: WebBackEnd.cs プロジェクト: ArsenShnurkov/beagle-1
		private string getResultsLabel(BT.SimpleRootTile root)
		{
			string label;
			if (root.HitCollection.NumResults == 0)
				label = NO_RESULTS;
			else if (root.HitCollection.FirstDisplayed == 0) 
				label = String.Format ("<b>{0} results of {1}</b> are shown.", 
						       root.HitCollection.LastDisplayed + 1,
						       root.HitCollection.NumResults);
			else 
				label = String.Format ("Results <b>{0} through {1} of {2}</b> are shown.",
						       root.HitCollection.FirstDisplayed + 1, 
						       root.HitCollection.LastDisplayed + 1,
						       root.HitCollection.NumResults);	
			return label;
		}