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>
25 #include <glib/gi18n-lib.h>
27 #include <telepathy-glib/util.h>
29 #include "empathy-irc-server.h"
30 #include "empathy-utils.h"
32 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcServer)
38 } EmpathyIrcServerPriv;
56 static guint signals[LAST_SIGNAL] = {0};
58 G_DEFINE_TYPE (EmpathyIrcServer, empathy_irc_server, G_TYPE_OBJECT);
61 empathy_irc_server_get_property (GObject *object,
66 EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
67 EmpathyIrcServerPriv *priv = GET_PRIV (self);
72 g_value_set_string (value, priv->address);
75 g_value_set_uint (value, priv->port);
78 g_value_set_boolean (value, priv->ssl);
81 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
87 empathy_irc_server_set_property (GObject *object,
92 EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
93 EmpathyIrcServerPriv *priv = GET_PRIV (self);
98 if (tp_strdiff (priv->address, g_value_get_string (value)))
100 g_free (priv->address);
101 priv->address = g_value_dup_string (value);
102 g_signal_emit (object, signals[MODIFIED], 0);
106 if (priv->port != g_value_get_uint (value))
108 priv->port = g_value_get_uint (value);
109 g_signal_emit (object, signals[MODIFIED], 0);
113 if (priv->ssl != g_value_get_boolean (value))
115 priv->ssl = g_value_get_boolean (value);
116 g_signal_emit (object, signals[MODIFIED], 0);
120 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
126 empathy_irc_server_finalize (GObject *object)
128 EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
129 EmpathyIrcServerPriv *priv = GET_PRIV (self);
131 g_free (priv->address);
133 G_OBJECT_CLASS (empathy_irc_server_parent_class)->finalize (object);
137 empathy_irc_server_init (EmpathyIrcServer *self)
139 EmpathyIrcServerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
140 EMPATHY_TYPE_IRC_SERVER, EmpathyIrcServerPriv);
146 empathy_irc_server_class_init (EmpathyIrcServerClass *klass)
148 GObjectClass *object_class = G_OBJECT_CLASS (klass);
149 GParamSpec *param_spec;
151 object_class->get_property = empathy_irc_server_get_property;
152 object_class->set_property = empathy_irc_server_set_property;
154 g_type_class_add_private (object_class, sizeof (EmpathyIrcServerPriv));
156 object_class->finalize = empathy_irc_server_finalize;
158 param_spec = g_param_spec_string (
161 "The address of this server",
164 G_PARAM_STATIC_NAME |
165 G_PARAM_STATIC_NICK |
166 G_PARAM_STATIC_BLURB);
167 g_object_class_install_property (object_class, PROP_ADDRESS, param_spec);
169 param_spec = g_param_spec_uint (
172 "The port to use to connect on this server",
173 1, G_MAXUINT16, 6667,
175 G_PARAM_STATIC_NAME |
176 G_PARAM_STATIC_NICK |
177 G_PARAM_STATIC_BLURB);
178 g_object_class_install_property (object_class, PROP_PORT, param_spec);
180 param_spec = g_param_spec_boolean (
183 "If this server needs SSL connection",
186 G_PARAM_STATIC_NAME |
187 G_PARAM_STATIC_NICK |
188 G_PARAM_STATIC_BLURB);
189 g_object_class_install_property (object_class, PROP_SSL, param_spec);
192 * EmpathyIrcServer::modified:
193 * @server: the object that received the signal
195 * Emitted when a property of the server is modified.
198 signals[MODIFIED] = g_signal_new (
200 G_OBJECT_CLASS_TYPE (object_class),
201 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
204 g_cclosure_marshal_generic,
209 * empathy_irc_server_new:
210 * @address: the address
212 * @ssl: %TRUE if the server needs a SSL connection
214 * Creates a new #EmpathyIrcServer
216 * Returns: a new #EmpathyIrcServer
219 empathy_irc_server_new (const gchar *address,
223 return g_object_new (EMPATHY_TYPE_IRC_SERVER,