~ps-jenkins/indicator-transfer/ubuntu-vivid-proposed

« back to all changes in this revision

Viewing changes to include/transfer/exporter.h

  • Committer: Charles Kerr
  • Date: 2014-06-17 01:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 2.
  • Revision ID: charles.kerr@canonical.com-20140617013616-7fcd22wh3hbgaovh
code drop

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2014 Canonical Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 3, as published
6
 
 * by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
10
 
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
 
 * PURPOSE.  See the GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License along
14
 
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors:
17
 
 *   Charles Kerr <charles.kerr@canonical.com>
18
 
 */
19
 
 
20
 
#ifndef INDICATOR_TRANSFER_EXPORTER_H
21
 
#define INDICATOR_TRANSFER_EXPORTER_H
22
 
 
23
 
#include <transfer/gactions.h>
24
 
#include <transfer/menu.h>
25
 
 
26
 
#include <core/signal.h>
27
 
 
28
 
#include <gio/gio.h> // GActionGroup
29
 
 
30
 
#include <memory> // std::shared_ptr
31
 
#include <vector>
32
 
 
33
 
namespace unity {
34
 
namespace indicator {
35
 
namespace transfer {
36
 
 
37
 
/**
38
 
 * \brief Exports actions and menus to DBus. 
39
 
 */
40
 
class Exporter
41
 
{
42
 
public:
43
 
    Exporter() =default;
44
 
    ~Exporter();
45
 
 
46
 
    core::Signal<> name_lost;
47
 
 
48
 
    void publish(const std::shared_ptr<GActions>& actions,
49
 
                 const std::vector<std::shared_ptr<Menu>>& menus);
50
 
 
51
 
private:
52
 
    static void on_bus_acquired(GDBusConnection*, const gchar* name, gpointer gthis);
53
 
    void on_bus_acquired(GDBusConnection*, const gchar* name);
54
 
 
55
 
    static void on_name_lost(GDBusConnection*, const gchar* name, gpointer gthis);
56
 
    void on_name_lost(GDBusConnection*, const gchar* name);
57
 
 
58
 
    std::set<guint> m_exported_menu_ids;
59
 
    guint m_own_id = 0;
60
 
    guint m_exported_actions_id = 0;
61
 
    GDBusConnection * m_dbus_connection = nullptr;
62
 
    std::shared_ptr<GActions> m_gactions;
63
 
    std::vector<std::shared_ptr<Menu>> m_menus;
64
 
 
65
 
    // we've got raw pointers and gsignal tags in here, so disable copying
66
 
    Exporter(const Exporter&) =delete;
67
 
    Exporter& operator=(const Exporter&) =delete;
68
 
};
69
 
 
70
 
} // namespace transfer
71
 
} // namespace indicator
72
 
} // namespace unity
73
 
 
74
 
#endif // INDICATOR_TRANSFER_EXPORTER_H