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-marshal.h"
30 #include "empathy-irc-server.h"
31 #include "empathy-utils.h"
33 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcServer)
39 } EmpathyIrcServerPriv
;
57 static guint signals
[LAST_SIGNAL
] = {0};
59 G_DEFINE_TYPE (EmpathyIrcServer
, empathy_irc_server
, G_TYPE_OBJECT
);
62 empathy_irc_server_get_property (GObject
*object
,
67 EmpathyIrcServer
*self
= EMPATHY_IRC_SERVER (object
);
68 EmpathyIrcServerPriv
*priv
= GET_PRIV (self
);
73 g_value_set_string (value
, priv
->address
);
76 g_value_set_uint (value
, priv
->port
);
79 g_value_set_boolean (value
, priv
->ssl
);
82 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
88 empathy_irc_server_set_property (GObject
*object
,
93 EmpathyIrcServer
*self
= EMPATHY_IRC_SERVER (object
);
94 EmpathyIrcServerPriv
*priv
= GET_PRIV (self
);
99 if (tp_strdiff (priv
->address
, g_value_get_string (value
)))
101 g_free (priv
->address
);
102 priv
->address
= g_value_dup_string (value
);
103 g_signal_emit (object
, signals
[MODIFIED
], 0);
107 if (priv
->port
!= g_value_get_uint (value
))
109 priv
->port
= g_value_get_uint (value
);
110 g_signal_emit (object
, signals
[MODIFIED
], 0);
114 if (priv
->ssl
!= g_value_get_boolean (value
))
116 priv
->ssl
= g_value_get_boolean (value
);
117 g_signal_emit (object
, signals
[MODIFIED
], 0);
121 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
127 empathy_irc_server_finalize (GObject
*object
)
129 EmpathyIrcServer
*self
= EMPATHY_IRC_SERVER (object
);
130 EmpathyIrcServerPriv
*priv
= GET_PRIV (self
);
132 g_free (priv
->address
);
134 G_OBJECT_CLASS (empathy_irc_server_parent_class
)->finalize (object
);
138 empathy_irc_server_init (EmpathyIrcServer
*self
)
140 EmpathyIrcServerPriv
*priv
= G_TYPE_INSTANCE_GET_PRIVATE (self
,
141 EMPATHY_TYPE_IRC_SERVER
, EmpathyIrcServerPriv
);
147 empathy_irc_server_class_init (EmpathyIrcServerClass
*klass
)
149 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
150 GParamSpec
*param_spec
;
152 object_class
->get_property
= empathy_irc_server_get_property
;
153 object_class
->set_property
= empathy_irc_server_set_property
;
155 g_type_class_add_private (object_class
, sizeof (EmpathyIrcServerPriv
));
157 object_class
->finalize
= empathy_irc_server_finalize
;
159 param_spec
= g_param_spec_string (
162 "The address of this server",
165 G_PARAM_STATIC_NAME
|
166 G_PARAM_STATIC_NICK
|
167 G_PARAM_STATIC_BLURB
);
168 g_object_class_install_property (object_class
, PROP_ADDRESS
, param_spec
);
170 param_spec
= g_param_spec_uint (
173 "The port to use to connect on this server",
174 1, G_MAXUINT16
, 6667,
176 G_PARAM_STATIC_NAME
|
177 G_PARAM_STATIC_NICK
|
178 G_PARAM_STATIC_BLURB
);
179 g_object_class_install_property (object_class
, PROP_PORT
, param_spec
);
181 param_spec
= g_param_spec_boolean (
184 "If this server needs SSL connection",
187 G_PARAM_STATIC_NAME
|
188 G_PARAM_STATIC_NICK
|
189 G_PARAM_STATIC_BLURB
);
190 g_object_class_install_property (object_class
, PROP_SSL
, param_spec
);
193 * EmpathyIrcServer::modified:
194 * @server: the object that received the signal
196 * Emitted when a property of the server is modified.
199 signals
[MODIFIED
] = g_signal_new (
201 G_OBJECT_CLASS_TYPE (object_class
),
202 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
205 g_cclosure_marshal_VOID__VOID
,
210 * empathy_irc_server_new:
211 * @address: the address
213 * @ssl: %TRUE if the server needs a SSL connection
215 * Creates a new #EmpathyIrcServer
217 * Returns: a new #EmpathyIrcServer
220 empathy_irc_server_new (const gchar
*address
,
224 return g_object_new (EMPATHY_TYPE_IRC_SERVER
,