2 * Copyright (C) 2012 Intel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #ifndef INCL_SYNCEVO_DBUS_SERVER_FULL_VIEW
21 #define INCL_SYNCEVO_DBUS_SERVER_FULL_VIEW
25 #include <syncevo/declarations.h>
29 * The view which takes input directly from IndividualAggregator
30 * and maintains a sorted set of contacts as result.
32 class FullView : public IndividualView
34 FolksIndividualAggregatorCXX m_folks;
35 boost::shared_ptr<LocaleFactory> m_locale;
37 boost::weak_ptr<FullView> m_self;
38 Timeout m_waitForIdle;
39 std::set<FolksIndividualCXX> m_pendingModifications;
40 Timeout m_quiescenceDelay;
43 * Sorted vector. Sort order is maintained by this class.
45 typedef boost::ptr_vector<IndividualData> Entries_t;
49 * The sort object to be used.
51 boost::shared_ptr<IndividualCompare> m_compare;
53 FullView(const FolksIndividualAggregatorCXX &folks,
54 const boost::shared_ptr<LocaleFactory> &locale);
55 void init(const boost::shared_ptr<FullView> &self);
58 * Run via m_waitForIdle if (and only if) something
64 * Ensure that onIdle() gets invoked.
69 * Adds the new individual to m_entries, transfers ownership
70 * (data == NULL afterwards).
72 void doAddIndividual(Entries_t::auto_type &data);
76 * @param folks the aggregator to use
78 static boost::shared_ptr<FullView> create(const FolksIndividualAggregatorCXX &folks,
79 const boost::shared_ptr<LocaleFactory> &locale);
81 /** FolksIndividualAggregator "individuals-changed" slot */
82 void individualsChanged(GeeSet *added,
86 FolksGroupDetailsChangeReason reason = FOLKS_GROUP_DETAILS_CHANGE_REASON_NONE);
88 /** GObject "notify" slot */
89 void individualModified(gpointer gobject,
93 * FolksIndividualAggregator "is-quiescent" property change slot.
95 * It turned out that "quiescence" is only set to true once in
96 * FolksIndividualAggregator. The code which watches that signal
97 * is still in place, but it will only get invoked once.
99 * Therefore the main mechanism for emitting m_quiescenceSignal in
100 * FullView is an idle callback which gets invoked each time the
101 * daemon has nothing to do, which implies that (at least for now)
102 * libfolks has no pending work to do.
104 void quiescenceChanged();
107 * Mirrors the FolksIndividualAggregator "is-quiesent" state:
108 * false initially, then true for the rest of the run.
110 virtual bool isQuiescent() const { return m_isQuiescent; }
113 * Add a FolksIndividual. Starts monitoring it for changes.
115 void addIndividual(FolksIndividual *individual);
118 * Deal with FolksIndividual modification.
120 void modifyIndividual(FolksIndividual *individual);
123 * Remove a FolksIndividual.
125 void removeIndividual(FolksIndividual *individual);
128 * Set new sort method. Reorders current set of entries on the
129 * fly. Default is lexicographical comparison of the single-string
132 * @param compare the new ordering or NULL for the builtin default (last/first with ASCII lexicographic comparison)
134 void setCompare(const boost::shared_ptr<IndividualCompare> &compare);
136 // from IndividualView
137 virtual void doStart();
138 virtual int size() const { return (int)m_entries.size(); }
139 virtual const IndividualData *getContact(int index) { return (index >= 0 && (unsigned)index < m_entries.size()) ? &m_entries[index] : NULL; }
144 #endif // INCL_SYNCEVO_DBUS_SERVER_PIM_FULL_VIEW