2 // EvolutionDataServerQueryable.cs
4 // Copyright (C) 2004 Novell, Inc.
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.
29 using System
.Collections
;
30 using System
.Globalization
;
32 using System
.Threading
;
40 namespace Beagle
.Daemon
.EvolutionDataServerQueryable
{
42 [QueryableFlavor (Name
="EvolutionDataServer", Domain
=QueryDomain
.Local
, RequireInotify
=false)]
43 public class EvolutionDataServerQueryable
: LuceneQueryable
{
44 //private Scheduler.Priority priority = Scheduler.Priority.Immediate;
45 private Scheduler
.Priority priority
= Scheduler
.Priority
.Delayed
;
47 private string photo_dir
;
48 private DateTime start_time
;
51 // 1: Original version
52 // 2: Updated URI scheme for Evolution 2.4/EDS 1.4
53 private const int INDEX_VERSION
= 2;
55 public EvolutionDataServerQueryable () : base ("EvolutionDataServerIndex", INDEX_VERSION
)
57 photo_dir
= Path
.Combine (Driver
.TopDirectory
, "Photos");
58 System
.IO
.Directory
.CreateDirectory (photo_dir
);
61 public string PhotoDir
{
62 get { return photo_dir; }
65 public override void Start ()
69 Logger
.Log
.Info ("Scanning addressbooks and calendars");
70 Stopwatch timer
= new Stopwatch ();
73 start_time
= DateTime
.Now
;
74 State
= QueryableState
.Crawling
;
78 // This is the first code which tries to open the
79 // evolution-data-server APIs. Try to catch
80 // DllNotFoundException and bail out if things go
83 new SourcesHandler ("/apps/evolution/addressbook/sources", typeof (BookContainer
), this, Driver
.Fingerprint
);
84 new SourcesHandler ("/apps/evolution/calendar/sources", typeof (CalContainer
), this, Driver
.Fingerprint
);
86 } catch (DllNotFoundException ex
) {
87 Logger
.Log
.Error ("Unable to start EvolutionDataServer backend: Unable to find or open {0}", ex
.Message
);
89 State
= QueryableState
.Idle
;
94 Logger
.Log
.Info ("Scanned addressbooks and calendars in {0}", timer
);
97 public void AddIndexable (Indexable indexable
, Scheduler
.Priority priority
)
100 task
= NewAddTask (indexable
);
101 task
.Priority
= priority
;
102 ThisScheduler
.Add (task
);
105 public void RemoveIndexable (Uri uri
)
108 task
= NewRemoveTask (uri
);
109 task
.Priority
= Scheduler
.Priority
.Immediate
;
110 ThisScheduler
.Add (task
);
113 public void RemovePropertyIndexable (Property prop
)
116 task
= NewRemoveByPropertyTask (prop
);
117 task
.Priority
= Scheduler
.Priority
.Immediate
;
118 ThisScheduler
.Add (task
);