~tiagosh/telepathy-qt/group-chat2

« back to all changes in this revision

Viewing changes to tests/lib/glib/call/call-content.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-06 04:56:14 UTC
  • Revision ID: package-import@ubuntu.com-20130606045614-inpxexo6765rnmp1
Tags: upstream-0.9.3
Import upstream version 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * call-content.c - a content in a call.
 
3
 *
 
4
 * Copyright © 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
 
5
 * Copyright © 2007-2009 Nokia Corporation
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2.1 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 */
 
21
 
 
22
#include "call-content.h"
 
23
 
 
24
#include <telepathy-glib/base-connection.h>
 
25
#include <telepathy-glib/telepathy-glib.h>
 
26
#include <telepathy-glib/svc-call.h>
 
27
 
 
28
G_DEFINE_TYPE (ExampleCallContent,
 
29
    example_call_content,
 
30
    TP_TYPE_BASE_MEDIA_CALL_CONTENT)
 
31
 
 
32
struct _ExampleCallContentPrivate
 
33
{
 
34
  ExampleCallStream *stream;
 
35
};
 
36
 
 
37
static void
 
38
example_call_content_init (ExampleCallContent *self)
 
39
{
 
40
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
 
41
      EXAMPLE_TYPE_CALL_CONTENT,
 
42
      ExampleCallContentPrivate);
 
43
}
 
44
 
 
45
static void
 
46
dispose (GObject *object)
 
47
{
 
48
  ExampleCallContent *self = EXAMPLE_CALL_CONTENT (object);
 
49
 
 
50
  g_clear_object (&self->priv->stream);
 
51
 
 
52
  ((GObjectClass *) example_call_content_parent_class)->dispose (object);
 
53
}
 
54
 
 
55
static void
 
56
example_call_content_class_init (ExampleCallContentClass *klass)
 
57
{
 
58
  GObjectClass *object_class = (GObjectClass *) klass;
 
59
 
 
60
  g_type_class_add_private (klass,
 
61
      sizeof (ExampleCallContentPrivate));
 
62
 
 
63
  object_class->dispose = dispose;
 
64
}
 
65
 
 
66
ExampleCallStream *
 
67
example_call_content_get_stream (ExampleCallContent *self)
 
68
{
 
69
  g_return_val_if_fail (EXAMPLE_IS_CALL_CONTENT (self), NULL);
 
70
 
 
71
  return self->priv->stream;
 
72
}
 
73
 
 
74
void
 
75
example_call_content_add_stream (ExampleCallContent *self,
 
76
    ExampleCallStream *stream)
 
77
{
 
78
  g_return_if_fail (EXAMPLE_IS_CALL_CONTENT (self));
 
79
  g_return_if_fail (EXAMPLE_IS_CALL_STREAM (stream));
 
80
  g_return_if_fail (self->priv->stream == NULL);
 
81
 
 
82
  self->priv->stream = g_object_ref (stream);
 
83
 
 
84
  tp_base_call_content_add_stream ((TpBaseCallContent *) self,
 
85
      (TpBaseCallStream *) stream);
 
86
}
 
87
 
 
88
void
 
89
example_call_content_remove_stream (ExampleCallContent *self)
 
90
{
 
91
  TpBaseCallStream *stream;
 
92
 
 
93
  g_return_if_fail (EXAMPLE_IS_CALL_CONTENT (self));
 
94
  g_return_if_fail (self->priv->stream != NULL);
 
95
 
 
96
  stream = (TpBaseCallStream *) self->priv->stream;
 
97
  self->priv->stream = NULL;
 
98
 
 
99
  tp_base_call_content_remove_stream ((TpBaseCallContent *) self, stream,
 
100
      0, TP_CALL_STATE_CHANGE_REASON_UNKNOWN, "", "");
 
101
 
 
102
  g_object_unref (stream);
 
103
}