2 * Copyright (C) 2007-2008 Guillaume Desmottes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Guillaume Desmottes <gdesmott@gnome.org>
22 #include "tpaw-irc-server.h"
24 #include "empathy-utils.h"
26 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcServer)
50 static guint signals[LAST_SIGNAL] = {0};
52 G_DEFINE_TYPE (TpawIrcServer, tpaw_irc_server, G_TYPE_OBJECT);
55 tpaw_irc_server_get_property (GObject *object,
60 TpawIrcServer *self = TPAW_IRC_SERVER (object);
61 TpawIrcServerPriv *priv = GET_PRIV (self);
66 g_value_set_string (value, priv->address);
69 g_value_set_uint (value, priv->port);
72 g_value_set_boolean (value, priv->ssl);
75 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
81 tpaw_irc_server_set_property (GObject *object,
86 TpawIrcServer *self = TPAW_IRC_SERVER (object);
87 TpawIrcServerPriv *priv = GET_PRIV (self);
92 if (tp_strdiff (priv->address, g_value_get_string (value)))
94 g_free (priv->address);
95 priv->address = g_value_dup_string (value);
96 g_signal_emit (object, signals[MODIFIED], 0);
100 if (priv->port != g_value_get_uint (value))
102 priv->port = g_value_get_uint (value);
103 g_signal_emit (object, signals[MODIFIED], 0);
107 if (priv->ssl != g_value_get_boolean (value))
109 priv->ssl = g_value_get_boolean (value);
110 g_signal_emit (object, signals[MODIFIED], 0);
114 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
120 tpaw_irc_server_finalize (GObject *object)
122 TpawIrcServer *self = TPAW_IRC_SERVER (object);
123 TpawIrcServerPriv *priv = GET_PRIV (self);
125 g_free (priv->address);
127 G_OBJECT_CLASS (tpaw_irc_server_parent_class)->finalize (object);
131 tpaw_irc_server_init (TpawIrcServer *self)
133 TpawIrcServerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
134 TPAW_TYPE_IRC_SERVER, TpawIrcServerPriv);
140 tpaw_irc_server_class_init (TpawIrcServerClass *klass)
142 GObjectClass *object_class = G_OBJECT_CLASS (klass);
143 GParamSpec *param_spec;
145 object_class->get_property = tpaw_irc_server_get_property;
146 object_class->set_property = tpaw_irc_server_set_property;
148 g_type_class_add_private (object_class, sizeof (TpawIrcServerPriv));
150 object_class->finalize = tpaw_irc_server_finalize;
152 param_spec = g_param_spec_string (
155 "The address of this server",
158 G_PARAM_STATIC_NAME |
159 G_PARAM_STATIC_NICK |
160 G_PARAM_STATIC_BLURB);
161 g_object_class_install_property (object_class, PROP_ADDRESS, param_spec);
163 param_spec = g_param_spec_uint (
166 "The port to use to connect on this server",
167 1, G_MAXUINT16, 6667,
169 G_PARAM_STATIC_NAME |
170 G_PARAM_STATIC_NICK |
171 G_PARAM_STATIC_BLURB);
172 g_object_class_install_property (object_class, PROP_PORT, param_spec);
174 param_spec = g_param_spec_boolean (
177 "If this server needs SSL connection",
180 G_PARAM_STATIC_NAME |
181 G_PARAM_STATIC_NICK |
182 G_PARAM_STATIC_BLURB);
183 g_object_class_install_property (object_class, PROP_SSL, param_spec);
186 * TpawIrcServer::modified:
187 * @server: the object that received the signal
189 * Emitted when a property of the server is modified.
192 signals[MODIFIED] = g_signal_new (
194 G_OBJECT_CLASS_TYPE (object_class),
195 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
198 g_cclosure_marshal_generic,
203 * tpaw_irc_server_new:
204 * @address: the address
206 * @ssl: %TRUE if the server needs a SSL connection
208 * Creates a new #TpawIrcServer
210 * Returns: a new #TpawIrcServer
213 tpaw_irc_server_new (const gchar *address,
217 return g_object_new (TPAW_TYPE_IRC_SERVER,