summaryrefslogtreecommitdiff
path: root/tests/lib/broken-client-types-conn.c
blob: 1c6f3aff1ce3b66920d653c7803170aacf47675e (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
/*
 * broken-client-types-conn.c - a connection with a broken client
 *   types implementation which inexplicably returns presence information!
 *
 * Copyright © 2011 Collabora Ltd. <http://www.collabora.co.uk/>
 *
 * Copying and distribution of this file, with or without modification,
 * are permitted in any medium without royalty provided the copyright
 * notice and this notice are preserved.
 */

#include "config.h"

#include "broken-client-types-conn.h"

#include <telepathy-glib/telepathy-glib.h>
#include <telepathy-glib/telepathy-glib-dbus.h>

G_DEFINE_TYPE_WITH_CODE (TpTestsBrokenClientTypesConnection,
    tp_tests_broken_client_types_connection,
    TP_TESTS_TYPE_CONTACTS_CONNECTION,
    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES,
        NULL);
    );

static void
tp_tests_broken_client_types_connection_init (
    TpTestsBrokenClientTypesConnection *self)
{
}

static void
broken_fill_client_types (
    GObject *object,
    const GArray *contacts,
    GHashTable *attributes)
{
  guint i;
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  GType type = G_TYPE_VALUE_ARRAY;
  G_GNUC_END_IGNORE_DEPRECATIONS

  for (i = 0; i < contacts->len; i++)
    {
      TpHandle handle = g_array_index (contacts, guint, i);
      /* Muahaha. Actually we add SimplePresence information. */
      GValueArray *presence = tp_value_array_build (3,
          G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
          G_TYPE_STRING, "available",
          G_TYPE_STRING, "hi mum!",
          G_TYPE_INVALID);

      tp_contacts_mixin_set_contact_attribute (attributes,
          handle,
          TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE,
          tp_g_value_slice_new_take_boxed (type, presence));
    }
}

static void
tp_tests_broken_client_types_connection_class_init (
    TpTestsBrokenClientTypesConnectionClass *klass)
{
  TpTestsContactsConnectionClass *cc_class =
      TP_TESTS_CONTACTS_CONNECTION_CLASS (klass);

  cc_class->fill_client_types = broken_fill_client_types;
}