author | Frank Zschockelt <lm@freakysoft.de> |
Sat, 11 May 2019 22:15:56 +0200 | |
changeset 736 | 97f3ff94976f |
parent 690 | 7ccf2113ec5f |
child 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 |
||
428
a2e6e58c38b8
Fixed a left over DUMMY -> SIMPLE_IO
Mikael Hallendal <micke@imendio.com>
parents:
426
diff
changeset
|
25 |
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_SIMPLE_IO, LmSimpleIOPriv)) |
425 | 26 |
|
27 |
typedef struct LmSimpleIOPriv LmSimpleIOPriv; |
|
28 |
struct LmSimpleIOPriv { |
|
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, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
49 |
G_IMPLEMENT_INTERFACE (LM_TYPE_XMPP_WRITER, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
50 |
simple_io_writer_iface_init)) |
425 | 51 |
|
52 |
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
|
53 |
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
|
54 |
PROP_MY_PROP |
425 | 55 |
}; |
56 |
||
57 |
static void |
|
58 |
lm_simple_io_class_init (LmSimpleIOClass *class) |
|
59 |
{ |
|
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
|
60 |
GObjectClass *object_class = G_OBJECT_CLASS (class); |
425 | 61 |
|
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
|
62 |
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
|
63 |
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
|
64 |
object_class->set_property = simple_io_set_property; |
425 | 65 |
|
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
"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 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
|
71 |
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
|
72 |
G_PARAM_READWRITE)); |
607 | 73 |
|
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
|
74 |
g_type_class_add_private (object_class, sizeof (LmSimpleIOPriv)); |
425 | 75 |
} |
76 |
||
77 |
static void |
|
78 |
lm_simple_io_init (LmSimpleIO *simple_io) |
|
79 |
{ |
|
624 | 80 |
(void) GET_PRIV (simple_io); |
425 | 81 |
} |
82 |
||
83 |
static void |
|
84 |
simple_io_finalize (GObject *object) |
|
85 |
{ |
|
624 | 86 |
(void) GET_PRIV (object); |
425 | 87 |
|
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
|
88 |
(G_OBJECT_CLASS (lm_simple_io_parent_class)->finalize) (object); |
425 | 89 |
} |
90 |
||
91 |
static void |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
92 |
simple_io_writer_iface_init (LmXmppWriterIface *iface) |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
93 |
{ |
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
|
94 |
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
|
95 |
iface->send_text = simple_io_send_text; |
426
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 |
|
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
98 |
static void |
425 | 99 |
simple_io_get_property (GObject *object, |
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
100 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
101 |
GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
102 |
GParamSpec *pspec) |
425 | 103 |
{ |
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
|
104 |
LmSimpleIOPriv *priv; |
425 | 105 |
|
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
|
106 |
priv = GET_PRIV (object); |
425 | 107 |
|
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
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
}; |
425 | 116 |
} |
117 |
||
118 |
static void |
|
119 |
simple_io_set_property (GObject *object, |
|
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
120 |
guint param_id, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
121 |
const GValue *value, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
122 |
GParamSpec *pspec) |
425 | 123 |
{ |
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
|
124 |
LmSimpleIOPriv *priv; |
425 | 125 |
|
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
|
126 |
priv = GET_PRIV (object); |
425 | 127 |
|
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
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
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
|
133 |
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
|
134 |
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
|
135 |
}; |
425 | 136 |
} |
137 |
||
426
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
138 |
static void |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
139 |
simple_io_send_message (LmXmppWriter *writer, LmMessage *message) |
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 |
|
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
143 |
static void |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
144 |
simple_io_send_text (LmXmppWriter *writer, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
145 |
const gchar *buf, |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
146 |
gsize len) |
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 |
} |
ab47db6da589
LmSimpleIO now implements the LmXmppWriter interface.
Mikael Hallendal <micke@imendio.com>
parents:
425
diff
changeset
|
149 |