Barry debian version 0.18.5-1
[barry.git] / desktop / src / EvoSources.h
blobd73c903266774b3040177a338b46edacf50d64d5
1 ///
2 /// \file EvoSources.h
3 /// A class that creates a list of Evolution data sources.
4 ///
6 /*
7 Copyright (C) 2011-2013, 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 std::string m_error_msg;
64 protected:
65 void LoadBaseSyms();
66 bool LoadEbookLib();
67 bool LoadEcalLib();
68 void GuessPaths();
69 void Clear();
71 public:
72 /// Generally always succeeds, in some manner, but if you were
73 /// expecting a different result than you got, check GetErrorMsg();
74 EvoSources();
76 const std::string& GetErrorMsg() const { return m_error_msg; }
78 /// This is automatically run from inside the constructor.
79 /// It can be called again to retry detection with the same instance,
80 /// but note that any previous results will be Clear()'d.
81 void Detect();
83 /// Returns true if this class has built-in support for talking
84 /// to the Evolution data server. False if a dummy wrapper was
85 /// built at compile time due to lack of proper libraries.
86 bool IsSupported() const;
88 /// Returns true if all list are empty
89 bool IsEmpty() const;
91 /// Returns true if minimum 3 paths are available, and if there is
92 /// only 1 path in each list.
93 bool IsDefaultable() const;
95 const List& GetAddressBook() const { return m_addressbook; }
96 const List& GetEvents() const { return m_events; }
97 const List& GetTasks() const { return m_tasks; }
98 const List& GetMemos() const { return m_memos; }
100 static bool PathExists(const std::string &path);
103 #endif