cvsimport
[beagle.git] / Util / KonqHistoryUtil.cs
blobb9f20fc8b3038d8f46c09228008e2c1a95e7db92
1 //
2 // KonqHistoryUtil.cs
3 //
4 // Copyright (C) 2005 Debajyoti Bera <dbera.web@gmail.com>
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
27 using System;
28 using System.IO;
30 namespace Beagle.Util {
31 public class KonqHistoryUtil {
32 public const string KonqCacheMimeType = "beagle/x-konq-cache";
34 public static bool ShouldIndex (StreamReader reader,
35 out string url,
36 out string creation_date,
37 out string mimetype,
38 out string charset)
40 // format from kdelibs/kioslave/http/http.cc
41 // line-1: Cache revision - mine is 7
42 // FIXME: What happens when cache revision changes ???
43 reader.ReadLine ();
45 // line-2: URL
46 string _url = reader.ReadLine ();
47 url = System.Web.HttpUtility.UrlDecode (_url);
49 // line-3: creation date
50 creation_date = reader.ReadLine ();
52 // line-4: expiry date
53 // dont need
54 reader.ReadLine ();
56 // line-5: ETag
57 // dont need
58 reader.ReadLine ();
60 // line-6: last-modified
61 // dont need
62 reader.ReadLine ();
64 // line-7: mimetype for the data
65 // important stuff
66 // we only index text/plain and text/html - anything else ?
67 mimetype = reader.ReadLine ();
69 // line-8: charset for the rest data
70 // important stuff
71 charset = reader.ReadLine ();
74 Console.WriteLine ("FilterKonqHistory:" +
75 " url=" + url +
76 " date=" + creation_date +
77 " mimetype=" + mimetype +
78 " charset=" + charset);
80 // rest is data ...
81 return (mimetype == "text/html");