~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-proposed

« back to all changes in this revision

Viewing changes to tests/lib/textchan-group.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2011-06-22 16:29:01 UTC
  • mfrom: (1.6.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20110622162901-tc492ifcn229lmkh
Tags: 0.15.2-2
Cherry-pick upstream fix to increase timeout of the contact-lists
test on slower architectures like armel, mips, and mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <telepathy-glib/svc-generic.h>
21
21
 
22
22
static void text_iface_init (gpointer iface, gpointer data);
 
23
static void password_iface_init (gpointer iface, gpointer data);
23
24
 
24
25
G_DEFINE_TYPE_WITH_CODE (TpTestsTextChannelGroup,
25
26
    tp_tests_text_channel_group, TP_TYPE_BASE_CHANNEL,
26
27
    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_TEXT, text_iface_init);
27
28
    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP,
28
29
      tp_group_mixin_iface_init);
 
30
    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_PASSWORD,
 
31
      password_iface_init);
29
32
    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
30
33
      tp_dbus_properties_mixin_iface_init))
31
34
 
32
35
static const char *text_channel_group_interfaces[] = {
33
36
    TP_IFACE_CHANNEL_INTERFACE_GROUP,
 
37
    TP_IFACE_CHANNEL_INTERFACE_PASSWORD,
34
38
    NULL
35
39
};
36
40
 
50
54
 
51
55
  gboolean closed;
52
56
  gboolean disposed;
 
57
 
 
58
  gchar *password;
53
59
};
54
60
 
55
61
 
215
221
static void
216
222
finalize (GObject *object)
217
223
{
 
224
  TpTestsTextChannelGroup *self = TP_TESTS_TEXT_CHANNEL_GROUP (object);
 
225
 
218
226
  tp_text_mixin_finalize (object);
219
227
  tp_group_mixin_finalize (object);
220
228
 
 
229
  tp_clear_pointer (&self->priv->password, g_free);
 
230
 
221
231
  ((GObjectClass *) tp_tests_text_channel_group_parent_class)->finalize (object);
222
232
}
223
233
 
321
331
  tp_intset_destroy (add);
322
332
  tp_intset_destroy (empty);
323
333
}
 
334
 
 
335
void
 
336
tp_tests_text_channel_set_password (TpTestsTextChannelGroup *self,
 
337
    const gchar *password)
 
338
{
 
339
  gboolean pass_was_needed, pass_needed;
 
340
 
 
341
  pass_was_needed = (self->priv->password != NULL);
 
342
 
 
343
  tp_clear_pointer (&self->priv->password, g_free);
 
344
 
 
345
  self->priv->password = g_strdup (password);
 
346
 
 
347
  pass_needed = (self->priv->password != NULL);
 
348
 
 
349
  if (pass_needed == pass_was_needed)
 
350
    return;
 
351
 
 
352
  if (pass_needed)
 
353
    tp_svc_channel_interface_password_emit_password_flags_changed (self,
 
354
        TP_CHANNEL_PASSWORD_FLAG_PROVIDE, 0);
 
355
  else
 
356
    tp_svc_channel_interface_password_emit_password_flags_changed (self,
 
357
        0, TP_CHANNEL_PASSWORD_FLAG_PROVIDE);
 
358
}
 
359
 
 
360
static void
 
361
password_get_password_flags (TpSvcChannelInterfacePassword *chan,
 
362
    DBusGMethodInvocation *context)
 
363
{
 
364
  TpTestsTextChannelGroup *self = (TpTestsTextChannelGroup *) chan;
 
365
  TpChannelPasswordFlags flags = 0;
 
366
 
 
367
  if (self->priv->password != NULL)
 
368
    flags |= TP_CHANNEL_PASSWORD_FLAG_PROVIDE;
 
369
 
 
370
  tp_svc_channel_interface_password_return_from_get_password_flags (context,
 
371
      flags);
 
372
}
 
373
 
 
374
static void
 
375
password_provide_password (TpSvcChannelInterfacePassword *chan,
 
376
    const gchar *password,
 
377
    DBusGMethodInvocation *context)
 
378
{
 
379
  TpTestsTextChannelGroup *self = (TpTestsTextChannelGroup *) chan;
 
380
 
 
381
  tp_svc_channel_interface_password_return_from_provide_password (context,
 
382
      !tp_strdiff (password, self->priv->password));
 
383
}
 
384
 
 
385
static void
 
386
password_iface_init (gpointer iface, gpointer data)
 
387
{
 
388
  TpSvcChannelInterfacePasswordClass *klass = iface;
 
389
 
 
390
#define IMPLEMENT(x) tp_svc_channel_interface_password_implement_##x (klass, password_##x)
 
391
  IMPLEMENT (get_password_flags);
 
392
  IMPLEMENT (provide_password);
 
393
#undef IMPLEMENT
 
394
}