desktop: made it possible to run Detect() multiple times in EvoSources
[barry/progweb.git] / desktop / src / EvoSources.h
blobc65daefe2d3e69801feffc8e0efa8b6046f23c0d
1 ///
2 /// \file EvoSources.h
3 /// A class that creates a list of Evolution data sources.
4 ///
6 /*
7 Copyright (C) 2011, Net Direct Inc. (http://www.netdirect.ca/)
8 Based on evolution2_sync.h and list_sources.c from evolution opensync plugin
9 by Ian Martin
10 Copyright (C) 2009, Ian Martin, licensed under LGPL 2.1
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU General Public License in the COPYING file at the
22 root directory of this project for more details.
25 #ifndef __BARRY_EVO_SOURCES_H__
26 #define __BARRY_EVO_SOURCES_H__
28 #include <vector>
29 #include <string>
30 #include <memory>
31 //#include "dlopen.h"
33 struct EvoSource
35 std::string m_GroupName;
36 std::string m_SourceName;
37 std::string m_SourcePath;
40 struct EvoFunctions;
43 // EvoSources
45 /// Instatiating this class does the work of filling the list. Just
46 /// probe the data with the member functions as needed.
47 ///
48 class EvoSources //: public DlOpen
50 public:
51 typedef std::vector<EvoSource> List;
53 private:
54 std::auto_ptr<EvoFunctions> m_funcs;
55 bool m_supported;
57 List m_addressbook;
58 List m_events;
59 List m_tasks;
60 List m_memos;
62 protected:
63 void LoadBaseSyms();
64 bool LoadEbookLib();
65 bool LoadEcalLib();
66 void GuessPaths();
67 void Clear();
69 public:
70 EvoSources();
72 /// This is automatically run from inside the constructor.
73 /// It can be called again to retry detection with the same instance,
74 /// but note that any previous results will be Clear()'d.
75 void Detect();
77 /// Returns true if this class has built-in support for talking
78 /// to the Evolution data server. False if a dummy wrapper was
79 /// built at compile time due to lack of proper libraries.
80 bool IsSupported() const;
82 const List& GetAddressBook() const { return m_addressbook; }
83 const List& GetEvents() const { return m_events; }
84 const List& GetTasks() const { return m_tasks; }
85 const List& GetMemos() const { return m_memos; }
88 #endif