author | Mikael Berthe <mikael@lilotux.net> |
Sat, 10 Jul 2021 09:37:34 +0200 | |
changeset 743 | 9098ee1972df |
parent 739 | 4a32df98ff8c |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
425 | 2 |
/* |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
3 |
* Copyright (C) 2008 Imendio AB |
425 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
|
7 |
* published by the Free Software Foundation; either version 2 of the |
|
8 |
* License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
* Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
690
7ccf2113ec5f
Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents:
624
diff
changeset
|
16 |
* License along with this program; if not, see <https://www.gnu.org/licenses> |
425 | 17 |
*/ |
18 |
||
19 |
#include <config.h> |
|
20 |
||
21 |
#include "lm-marshal.h" |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
22 |
#include "lm-xmpp-writer.h" |
425 | 23 |
#include "lm-simple-io.h" |
24 |
||
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
25 |
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_SIMPLE_IO, LmSimpleIOPrivate)) |
425 | 26 |
|
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
27 |
typedef struct LmSimpleIOPrivate LmSimpleIOPrivate; |
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
28 |
struct LmSimpleIOPrivate { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
29 |
gint my_prop; |
425 | 30 |
}; |
31 |
||
32 |
static void simple_io_finalize (GObject *object); |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
33 |
static void simple_io_writer_iface_init (LmXmppWriterIface *iface); |
425 | 34 |
static void simple_io_get_property (GObject *object, |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
35 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
36 |
GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
37 |
GParamSpec *pspec); |
425 | 38 |
static void simple_io_set_property (GObject *object, |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
39 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
40 |
const GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
41 |
GParamSpec *pspec); |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
42 |
static void simple_io_send_message (LmXmppWriter *writer, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
43 |
LmMessage *message); |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
44 |
static void simple_io_send_text (LmXmppWriter *writer, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
45 |
const gchar *buf, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
46 |
gsize len); |
425 | 47 |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
48 |
G_DEFINE_TYPE_WITH_CODE (LmSimpleIO, lm_simple_io, G_TYPE_OBJECT, |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
49 |
G_ADD_PRIVATE (LmSimpleIO) |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
50 |
G_IMPLEMENT_INTERFACE (LM_TYPE_XMPP_WRITER, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
51 |
simple_io_writer_iface_init)) |
425 | 52 |
|
53 |
enum { |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
54 |
PROP_0, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
55 |
PROP_MY_PROP |
425 | 56 |
}; |
57 |
||
58 |
static void |
|
59 |
lm_simple_io_class_init (LmSimpleIOClass *class) |
|
60 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
61 |
GObjectClass *object_class = G_OBJECT_CLASS (class); |
425 | 62 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
63 |
object_class->finalize = simple_io_finalize; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
64 |
object_class->get_property = simple_io_get_property; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
65 |
object_class->set_property = simple_io_set_property; |
425 | 66 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
67 |
g_object_class_install_property (object_class, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
68 |
PROP_MY_PROP, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
69 |
g_param_spec_string ("my-prop", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
70 |
"My Prop", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
71 |
"My Property", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
72 |
NULL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
73 |
G_PARAM_READWRITE)); |
425 | 74 |
} |
75 |
||
76 |
static void |
|
77 |
lm_simple_io_init (LmSimpleIO *simple_io) |
|
78 |
{ |
|
624 | 79 |
(void) GET_PRIV (simple_io); |
425 | 80 |
} |
81 |
||
82 |
static void |
|
83 |
simple_io_finalize (GObject *object) |
|
84 |
{ |
|
624 | 85 |
(void) GET_PRIV (object); |
425 | 86 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
87 |
(G_OBJECT_CLASS (lm_simple_io_parent_class)->finalize) (object); |
425 | 88 |
} |
89 |
||
90 |
static void |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
91 |
simple_io_writer_iface_init (LmXmppWriterIface *iface) |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
92 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
93 |
iface->send_message = simple_io_send_message; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
94 |
iface->send_text = simple_io_send_text; |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
95 |
} |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
96 |
|
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
97 |
static void |
425 | 98 |
simple_io_get_property (GObject *object, |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
99 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
100 |
GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
101 |
GParamSpec *pspec) |
425 | 102 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
103 |
LmSimpleIOPrivate *priv; |
425 | 104 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
105 |
priv = GET_PRIV (object); |
425 | 106 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
107 |
switch (param_id) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
108 |
case PROP_MY_PROP: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
109 |
g_value_set_int (value, priv->my_prop); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
110 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
111 |
default: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
112 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
113 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
114 |
}; |
425 | 115 |
} |
116 |
||
117 |
static void |
|
118 |
simple_io_set_property (GObject *object, |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
119 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
120 |
const GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
121 |
GParamSpec *pspec) |
425 | 122 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
690
diff
changeset
|
123 |
LmSimpleIOPrivate *priv; |
425 | 124 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
125 |
priv = GET_PRIV (object); |
425 | 126 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
127 |
switch (param_id) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
128 |
case PROP_MY_PROP: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
129 |
priv->my_prop = g_value_get_int (value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
130 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
131 |
default: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
132 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
133 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
134 |
}; |
425 | 135 |
} |
136 |
||
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
137 |
static void |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
138 |
simple_io_send_message (LmXmppWriter *writer, LmMessage *message) |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
139 |
{ |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
140 |
} |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
141 |
|
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
142 |
static void |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
143 |
simple_io_send_text (LmXmppWriter *writer, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
144 |
const gchar *buf, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
145 |
gsize len) |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
146 |
{ |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
147 |
} |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
148 |