summaryrefslogtreecommitdiff
path: root/telepathy-glib/presence-mixin.h
blob: 4a7b549953f534224ca75883b6fe940727517bef (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * presence-mixin.h - Header for TpPresenceMixin
 * Copyright (C) 2007 Collabora Ltd.
 * Copyright (C) 2007 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
 */

#if !defined (_TP_GLIB_H_INSIDE) && !defined (_TP_COMPILATION)
#error "Only <telepathy-glib/telepathy-glib.h> can be included directly."
#endif

#ifndef __TP_PRESENCE_MIXIN_H__
#define __TP_PRESENCE_MIXIN_H__

#include <telepathy-glib/enums.h>
#include <telepathy-glib/handle.h>
#include <telepathy-glib/base-connection.h>
#include "util.h"

G_BEGIN_DECLS

/* -- TpPresenceStatusSpec -- */

typedef struct _TpPresenceStatusSpec TpPresenceStatusSpec;
typedef struct _TpPresenceStatusSpecPrivate TpPresenceStatusSpecPrivate;

struct _TpPresenceStatusSpec {
    const gchar *name;
    TpConnectionPresenceType presence_type;
    gboolean self;
    gboolean has_message;

    /*<private>*/
    GCallback _future[10];
    TpPresenceStatusSpecPrivate *priv;
};

_TP_AVAILABLE_IN_1_0
TpConnectionPresenceType tp_presence_status_spec_get_presence_type (
    const TpPresenceStatusSpec *self);

_TP_AVAILABLE_IN_1_0
const gchar *tp_presence_status_spec_get_name (
    const TpPresenceStatusSpec *self);

_TP_AVAILABLE_IN_1_0
gboolean tp_presence_status_spec_can_set_on_self (
    const TpPresenceStatusSpec *self);

_TP_AVAILABLE_IN_1_0
gboolean tp_presence_status_spec_has_message (
    const TpPresenceStatusSpec *self);

_TP_AVAILABLE_IN_1_0
GType tp_presence_status_spec_get_type (void);

_TP_AVAILABLE_IN_1_0
TpPresenceStatusSpec *tp_presence_status_spec_new (const gchar *name,
    TpConnectionPresenceType type,
    gboolean can_set_on_self,
    gboolean has_message);

_TP_AVAILABLE_IN_1_0
TpPresenceStatusSpec *tp_presence_status_spec_copy (
    const TpPresenceStatusSpec *self);

_TP_AVAILABLE_IN_1_0
void tp_presence_status_spec_free (TpPresenceStatusSpec *self);

/* -- TpPresenceStatus -- */


typedef struct _TpPresenceStatus TpPresenceStatus;

struct _TpPresenceStatus {
    guint index;
    gchar *message;

    /*<private>*/
    gpointer _future[6];
};

TpPresenceStatus *tp_presence_status_new (guint which,
    const gchar *message) G_GNUC_WARN_UNUSED_RESULT;
void tp_presence_status_free (TpPresenceStatus *status);

/* -- TpPresenceMixinInterface -- */

#define TP_TYPE_PRESENCE_MIXIN \
  (tp_presence_mixin_get_type ())

#define TP_PRESENCE_MIXIN(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
  TP_TYPE_PRESENCE_MIXIN, TpPresenceMixin))

#define TP_IS_PRESENCE_MIXIN(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
  TP_TYPE_PRESENCE_MIXIN))

#define TP_PRESENCE_MIXIN_GET_INTERFACE(obj) \
  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
  TP_TYPE_PRESENCE_MIXIN, TpPresenceMixinInterface))

typedef struct _TpPresenceMixinInterface TpPresenceMixinInterface;
typedef struct _TpPresenceMixin TpPresenceMixin;

typedef gboolean (*TpPresenceMixinStatusAvailableFunc) (TpPresenceMixin *self,
    guint which);

typedef TpPresenceStatus *(*TpPresenceMixinGetContactStatusFunc) (
    TpPresenceMixin *self,
    TpHandle contact);

typedef gboolean (*TpPresenceMixinSetOwnStatusFunc) (TpPresenceMixin *self,
    const TpPresenceStatus *status,
    GError **error);

typedef guint (*TpPresenceMixinGetMaximumStatusMessageLengthFunc) (
    TpPresenceMixin *self);

struct _TpPresenceMixinInterface {
  GTypeInterface parent;

  TpPresenceMixinStatusAvailableFunc status_available;
  TpPresenceMixinGetContactStatusFunc get_contact_status;
  TpPresenceMixinSetOwnStatusFunc set_own_status;
  TpPresenceMixinGetMaximumStatusMessageLengthFunc
      get_maximum_status_message_length;

  const TpPresenceStatusSpec *statuses;
};

GType tp_presence_mixin_get_type (void) G_GNUC_CONST;

void tp_presence_mixin_emit_presence_update (TpPresenceMixin *self,
    GHashTable *contact_presences);
void tp_presence_mixin_emit_one_presence_update (TpPresenceMixin *self,
    TpHandle handle,
    const TpPresenceStatus *status);

void tp_presence_mixin_init (TpPresenceMixin *self);
gboolean tp_presence_mixin_fill_contact_attributes (TpPresenceMixin *self,
    const gchar *dbus_interface,
    TpHandle contact,
    GVariantDict *attributes);

G_END_DECLS

#endif /* #ifndef __TP_PRESENCE_MIXIN_H__ */