1 /*
2  * Example channel manager for contact lists
3  *
4  * Copyright © 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
5  * Copyright © 2007-2009 Nokia Corporation
6  *
7  * Copying and distribution of this file, with or without modification,
8  * are permitted in any medium without royalty provided the copyright
9  * notice and this notice are preserved.
10  */
11 
12 #ifndef __EXAMPLE_CONTACT_LIST_MANAGER_H__
13 #define __EXAMPLE_CONTACT_LIST_MANAGER_H__
14 
15 #include <glib-object.h>
16 
17 #include <telepathy-glib/channel-manager.h>
18 #include <telepathy-glib/handle.h>
19 #include <telepathy-glib/presence-mixin.h>
20 
21 G_BEGIN_DECLS
22 
23 typedef struct _ExampleContactListManager ExampleContactListManager;
24 typedef struct _ExampleContactListManagerClass ExampleContactListManagerClass;
25 typedef struct _ExampleContactListManagerPrivate ExampleContactListManagerPrivate;
26 
27 struct _ExampleContactListManagerClass {
28     GObjectClass parent_class;
29 };
30 
31 struct _ExampleContactListManager {
32     GObject parent;
33 
34     ExampleContactListManagerPrivate *priv;
35 };
36 
37 GType example_contact_list_manager_get_type (void);
38 
39 #define EXAMPLE_TYPE_CONTACT_LIST_MANAGER \
40   (example_contact_list_manager_get_type ())
41 #define EXAMPLE_CONTACT_LIST_MANAGER(obj) \
42   (G_TYPE_CHECK_INSTANCE_CAST((obj), EXAMPLE_TYPE_CONTACT_LIST_MANAGER, \
43                               ExampleContactListManager))
44 #define EXAMPLE_CONTACT_LIST_MANAGER_CLASS(klass) \
45   (G_TYPE_CHECK_CLASS_CAST((klass), EXAMPLE_TYPE_CONTACT_LIST_MANAGER, \
46                            ExampleContactListManagerClass))
47 #define EXAMPLE_IS_CONTACT_LIST_MANAGER(obj) \
48   (G_TYPE_CHECK_INSTANCE_TYPE((obj), EXAMPLE_TYPE_CONTACT_LIST_MANAGER))
49 #define EXAMPLE_IS_CONTACT_LIST_MANAGER_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_TYPE((klass), EXAMPLE_TYPE_CONTACT_LIST_MANAGER))
51 #define EXAMPLE_CONTACT_LIST_MANAGER_GET_CLASS(obj) \
52   (G_TYPE_INSTANCE_GET_CLASS ((obj), EXAMPLE_TYPE_CONTACT_LIST_MANAGER, \
53                               ExampleContactListManagerClass))
54 
55 gboolean example_contact_list_manager_add_to_group (
56     ExampleContactListManager *self, GObject *channel,
57     TpHandle group, TpHandle member, const gchar *message, GError **error);
58 
59 gboolean example_contact_list_manager_remove_from_group (
60     ExampleContactListManager *self, GObject *channel,
61     TpHandle group, TpHandle member, const gchar *message, GError **error);
62 
63 /* elements 1, 2... of this enum must be kept in sync with elements 0, 1...
64  * of the array _contact_lists in contact-list-manager.h */
65 typedef enum {
66     INVALID_EXAMPLE_CONTACT_LIST,
67     EXAMPLE_CONTACT_LIST_SUBSCRIBE = 1,
68     EXAMPLE_CONTACT_LIST_PUBLISH,
69     EXAMPLE_CONTACT_LIST_STORED,
70     EXAMPLE_CONTACT_LIST_DENY,
71     NUM_EXAMPLE_CONTACT_LISTS
72 } ExampleContactListHandle;
73 
74 /* this enum must be kept in sync with the array _statuses in
75  * contact-list-manager.c */
76 typedef enum {
77     EXAMPLE_CONTACT_LIST_PRESENCE_OFFLINE = 0,
78     EXAMPLE_CONTACT_LIST_PRESENCE_UNKNOWN,
79     EXAMPLE_CONTACT_LIST_PRESENCE_ERROR,
80     EXAMPLE_CONTACT_LIST_PRESENCE_AWAY,
81     EXAMPLE_CONTACT_LIST_PRESENCE_AVAILABLE
82 } ExampleContactListPresence;
83 
84 const TpPresenceStatusSpec *example_contact_list_presence_statuses (
85     void);
86 
87 gboolean example_contact_list_manager_add_to_list (
88     ExampleContactListManager *self, GObject *channel,
89     ExampleContactListHandle list, TpHandle member, const gchar *message,
90     GError **error);
91 
92 gboolean example_contact_list_manager_remove_from_list (
93     ExampleContactListManager *self, GObject *channel,
94     ExampleContactListHandle list, TpHandle member, const gchar *message,
95     GError **error);
96 
97 const gchar **example_contact_lists (void);
98 
99 ExampleContactListPresence example_contact_list_manager_get_presence (
100     ExampleContactListManager *self, TpHandle contact);
101 const gchar *example_contact_list_manager_get_alias (
102     ExampleContactListManager *self, TpHandle contact);
103 void example_contact_list_manager_set_alias (
104     ExampleContactListManager *self, TpHandle contact, const gchar *alias);
105 
106 G_END_DECLS
107 
108 #endif
109