summaryrefslogtreecommitdiff
path: root/salut/plugin.h
blob: 975446c676941b83d9c0e0605bbdb2db402b87a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * plugin.h — plugin API for telepathy-salut plugins
 * Copyright © 2009-2011 Collabora Ltd.
 * Copyright © 2009 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef SALUT_PLUGINS_PLUGIN_H
#define SALUT_PLUGINS_PLUGIN_H

#include <glib-object.h>

#include <telepathy-glib/base-connection-manager.h>
#include <telepathy-glib/base-connection.h>

G_BEGIN_DECLS

#define SALUT_TYPE_PLUGIN (salut_plugin_get_type ())
#define SALUT_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SALUT_TYPE_PLUGIN, SalutPlugin))
#define SALUT_IS_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SALUT_TYPE_PLUGIN))
#define SALUT_PLUGIN_GET_INTERFACE(obj) \
    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SALUT_TYPE_PLUGIN, \
        SalutPluginInterface))

typedef struct _SalutPlugin SalutPlugin;
typedef struct _SalutPluginInterface SalutPluginInterface;

/* The caller of this function takes ownership of the returned
 * GPtrArray and the channel managers inside the array. This has the
 * same semantics as TpBaseConnectionCreateChannelManagersImpl. */
typedef GPtrArray * (*SalutPluginCreateChannelManagersImpl) (
    SalutPlugin *plugin,
    TpBaseConnection *connection);

typedef void (*SalutPluginInitializeImpl) (
    SalutPlugin *plugin,
    TpBaseConnectionManager *connection_manager);

#define SALUT_PLUGIN_CURRENT_VERSION 1

struct _SalutPluginInterface
{
  GTypeInterface parent;

  /**
   * The version of the SalutPluginInterface struct design. The
   * current version is at %SALUT_PLUGIN_CURRENT_VERSION.
   */
  guint api_version;

  /**
   * An arbitrary human-readable name identifying this plugin.
   */
  const gchar *name;

  /**
   * The plugin's version, conventionally a "."-separated sequence of
   * numbers.
   */
  const gchar *version;

  /**
   * An implementation of salut_plugin_initialize().
   */
  SalutPluginInitializeImpl initialize;

  /**
   * An implementation of salut_plugin_create_channel_managers().
   */
  SalutPluginCreateChannelManagersImpl create_channel_managers;

  GCallback _padding[7];
};

GType salut_plugin_get_type (void);

const gchar * salut_plugin_get_name (
    SalutPlugin *plugin);
const gchar * salut_plugin_get_version (
    SalutPlugin *plugin);

void salut_plugin_initialize (
    SalutPlugin *plugin,
    TpBaseConnectionManager *connection_manager);

GPtrArray * salut_plugin_create_channel_managers (
    SalutPlugin *plugin,
    TpBaseConnection *connection);

/**
 * salut_plugin_create:
 *
 * Prototype for the plugin entry point.
 *
 * Returns: a new instance of this plugin, which must not be %NULL.
 */
SalutPlugin * salut_plugin_create (void);

typedef SalutPlugin * (*SalutPluginCreateImpl) (void);

G_END_DECLS

#endif