Add KAddressBook files.
[beagle.git] / Filters / FilterKAddressBook.cs
bloba5e8adc713f2997a1cff42d5f586be345a2d7b36
1 //
2 // FilterKAddressBook.cs
3 //
4 // Copyright (C) 2006 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.
28 using System;
29 using System.Collections;
30 using System.IO;
31 using System.Text;
33 using Beagle.Daemon;
34 using Beagle.Util;
36 namespace Beagle.Filters {
38 public class FilterKAddressBook : Beagle.Filters.FilterKCal {
40 public FilterKAddressBook ()
42 AddSupportedFlavor (FilterFlavor.NewFromMimeType (ICalParser.KabcMimeType));
43 if (vCard_property_mapping == null)
44 SetupPropertyMapping ();
47 private static Hashtable vCard_property_mapping = null;
48 override protected Hashtable KCalPropertyMapping {
49 get { return vCard_property_mapping; }
52 private void SetupPropertyMapping () {
53 vCard_property_mapping = new Hashtable ();
54 vCard_property_mapping ["FN"] = new KCalProperty ("vCard:FN", false, false, KCalType.Text);
55 vCard_property_mapping ["NICKNAME"] = new KCalProperty ("vCard:NICKNAME", true, false,KCalType.Text);
56 vCard_property_mapping ["BDAY"] = new KCalProperty ("vCard:BDAY", true, false, KCalType.Date);
57 vCard_property_mapping ["TITLE"] = new KCalProperty ("vCard:TITLE", false, false, KCalType.Text);
58 vCard_property_mapping ["ROLE"] = new KCalProperty ("vCard:ROLE", false, false, KCalType.Text);
59 vCard_property_mapping ["CATEGORIES"] = new KCalProperty ("vCard:CATEGORIES", false, false, KCalType.Text);
60 vCard_property_mapping ["NAME"] = new KCalProperty ("vCard:NAME", false, false, KCalType.Text);
61 vCard_property_mapping ["NOTE"] = new KCalProperty ("vCard:NOTE", false, false, KCalType.Text);
62 vCard_property_mapping ["REV"] = new KCalProperty ("dc:date", true, false, KCalType.Date);
63 vCard_property_mapping ["CLASS"] = new KCalProperty ("vCard:CLASS", false, true, KCalType.Text);
64 vCard_property_mapping ["UID"] = new KCalProperty ("vCard:UID", false, true, KCalType.Text);
65 vCard_property_mapping ["TEL"] = new KCalProperty ("vCard:TEL", false, true, KCalType.Text);
66 vCard_property_mapping ["URL"] = new KCalProperty ("vCard:URL", false, true,KCalType.Text);
69 override protected string GetPropertyName (string prop_name, ArrayList paramlist)
71 string mapped_prop_name =
72 ((KCalProperty)vCard_property_mapping [prop_name]).property_name;
74 switch (prop_name) {
75 case "TEL":
76 foreach (KCalPropertyParameter vcpp in paramlist) {
77 if (vcpp.param_name == "TYPE") {
78 if (vcpp.param_value == "WORK")
79 return mapped_prop_name + ":WORK";
80 else if (vcpp.param_value == "HOME")
81 return mapped_prop_name + ":HOME";
84 break;
87 return mapped_prop_name;