1 /*
2  * tp-handle-repo-static.h - mechanism to store and retrieve handles on
3  * a connection - implementation for static list of supported handle
4  * types (currently used for LIST handles)
5  *
6  * Copyright (C) 2005, 2007 Collabora Ltd.
7  * Copyright (C) 2005, 2007 Nokia Corp.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  */
23 
24 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
25 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
26 #endif
27 
28 #ifndef __TP_HANDLE_REPO_STATIC_H__
29 #define __TP_HANDLE_REPO_STATIC_H__
30 
31 #include <telepathy-glib/handle-repo.h>
32 
33 G_BEGIN_DECLS
34 
35 
36 /**
37  * TpStaticHandleRepo:
38  *
39  * A static handle repository contains a fixed set of handles.
40  *
41  * As well as setting the #TpHandleRepoIface:handle-type property, code
42  * which creates a static handle repository must set the
43  * #TpStaticHandleRepo:handle-names construction property to a strv of
44  * valid handle names. All of these are preallocated; no more may be
45  * created, and attempts to do so will fail.
46  *
47  * Handles in this repository are 1 more than the index in the string
48  * vector of the handle's name, so the first name in the vector has
49  * handle 1 and so on. Connection managers which use a static repository
50  * may assume this to be true, and use an enumeration starting at 1, in the
51  * same order as the string vector, to avoid having to look up handles
52  * internally.
53  *
54  * This is intended for handles of type %TP_HANDLE_TYPE_LIST,
55  * for which the connection manager should only accept a static list of
56  * supported handle names.
57  *
58  * All structure fields are private.
59  */
60 
61 typedef struct _TpStaticHandleRepo TpStaticHandleRepo;
62 
63 /**
64  * TpStaticHandleRepoClass:
65  *
66  * The class of a TpStaticHandleRepo. All fields are private.
67  */
68 
69 typedef struct _TpStaticHandleRepoClass TpStaticHandleRepoClass;
70 GType tp_static_handle_repo_get_type (void);
71 
72 #define TP_TYPE_STATIC_HANDLE_REPO \
73   (tp_static_handle_repo_get_type ())
74 #define TP_STATIC_HANDLE_REPO(obj) \
75   (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TYPE_STATIC_HANDLE_REPO,\
76   TpStaticHandleRepo))
77 #define TP_STATIC_HANDLE_REPO_CLASS(klass) \
78   (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TYPE_STATIC_HANDLE_REPO,\
79   TpStaticHandleRepo))
80 #define TP_IS_STATIC_HANDLE_REPO(obj) \
81   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TYPE_STATIC_HANDLE_REPO))
82 #define TP_IS_STATIC_HANDLE_REPO_CLASS(klass) \
83   (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TYPE_STATIC_HANDLE_REPO))
84 #define TP_STATIC_HANDLE_REPO_GET_CLASS(obj) \
85   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_STATIC_HANDLE_REPO,\
86   TpStaticHandleRepoClass))
87 
88 /**
89  * tp_static_handle_repo_new:
90  * @handle_type: The type of handle to store in the
91  *  new repository
92  * @handle_names: Same as #TpStaticHandleRepo:handle-names
93  *
94  * <!---->
95  *
96  * Returns: a new static handle repository
97  */
98 static inline
99 /* spacer so gtkdoc documents this function as though not static */
100 TpHandleRepoIface *tp_static_handle_repo_new (TpHandleType handle_type,
101     const gchar **handle_names);
102 
103 static inline TpHandleRepoIface *
tp_static_handle_repo_new(TpHandleType handle_type,const gchar ** handle_names)104 tp_static_handle_repo_new (TpHandleType handle_type,
105                            const gchar **handle_names)
106 {
107   return (TpHandleRepoIface *) g_object_new (TP_TYPE_STATIC_HANDLE_REPO,
108       "handle-type", (guint)handle_type,
109       "handle-names", handle_names,
110       NULL);
111 }
112 
113 G_END_DECLS
114 
115 #endif
116 
117