From 6056f3fb4b68baf9519e35515b40731569e97858 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 7 May 2012 19:43:08 +0100 Subject: [PATCH 1/8] Use TP_ERROR, not deprecated TP_ERRORS --- src/idle-connection.c | 12 ++++++------ src/idle-contact-info.c | 4 ++-- src/idle-handles.c | 4 ++-- src/idle-im-manager.c | 4 ++-- src/idle-muc-channel.c | 30 +++++++++++++++--------------- src/idle-muc-manager.c | 6 +++--- src/idle-server-connection.c | 18 +++++++++--------- src/idle-text.c | 4 ++-- src/protocol.c | 4 ++-- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/idle-connection.c b/src/idle-connection.c index d60beef..f18c2b3 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -602,7 +602,7 @@ static void _connection_disconnect_with_gerror(IdleConnection *conn, TpConnectio } else { GHashTable *details = tp_asv_new(key, G_TYPE_STRING, error->message, NULL); - g_assert(error->domain == TP_ERRORS); + g_assert(error->domain == TP_ERROR); tp_base_connection_disconnect_with_dbus_error(TP_BASE_CONNECTION(conn), tp_error_get_dbus_name(error->code), @@ -659,7 +659,7 @@ static gboolean _iface_start_connecting(TpBaseConnection *self, GError **error) if (priv->conn != NULL) { IDLE_DEBUG("conn already open!"); - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "connection already open!"); + g_set_error(error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, "connection already open!"); return FALSE; } @@ -1002,7 +1002,7 @@ static IdleParserHandlerResult _error_handler(IdleParser *parser, IdleParserMess server_msg = g_strndup(begin, length); } - _connection_disconnect_with_error(conn, reason, "server-message", TP_ERRORS, error, (server_msg == NULL) ? "" : server_msg); + _connection_disconnect_with_error(conn, reason, "server-message", TP_ERROR, error, (server_msg == NULL) ? "" : server_msg); g_free(server_msg); return IDLE_PARSER_HANDLER_RESULT_HANDLED; @@ -1322,7 +1322,7 @@ static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBu if (handle == 0) { IDLE_DEBUG("failed to get handle for \"%s\"", nick); - GError error = {TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "Invalid nickname requested"}; + GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Invalid nickname requested"}; dbus_g_method_return_error(context, &error); return FALSE; @@ -1349,7 +1349,7 @@ static void idle_connection_set_aliases(TpSvcConnectionInterfaceAliasing *iface, const gchar *requested_alias = g_hash_table_lookup(aliases, GUINT_TO_POINTER(conn->parent.self_handle)); if ((g_hash_table_size(aliases) != 1) || !requested_alias) { - GError error = {TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "You can only set your own alias in IRC"}; + GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "You can only set your own alias in IRC"}; dbus_g_method_return_error(context, &error); return; @@ -1374,7 +1374,7 @@ static gboolean idle_connection_hton(IdleConnection *obj, const gchar *input, gc if (ret == NULL) { IDLE_DEBUG("g_convert failed: %s", error->message); - g_set_error(_error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "character set conversion failed: %s", error->message); + g_set_error(_error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, "character set conversion failed: %s", error->message); g_error_free(error); *output = NULL; return FALSE; diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index 564800c..b87774c 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -235,7 +235,7 @@ static IdleParserHandlerResult _no_such_server_handler(IdleParser *parser, IdleP if (request == NULL) goto cleanup; - error = g_error_new(TP_ERRORS, TP_ERROR_DOES_NOT_EXIST, "User '%s' unknown; they may have disconnected", server); + error = g_error_new(TP_ERROR, TP_ERROR_DOES_NOT_EXIST, "User '%s' unknown; they may have disconnected", server); dbus_g_method_return_error(request->context, error); g_error_free(error); @@ -269,7 +269,7 @@ static IdleParserHandlerResult _try_again_handler(IdleParser *parser, IdleParser msg = g_value_get_string(g_value_array_get_nth(args, 1)); - error = g_error_new_literal(TP_ERRORS, TP_ERROR_SERVICE_BUSY, msg); + error = g_error_new_literal(TP_ERROR, TP_ERROR_SERVICE_BUSY, msg); dbus_g_method_return_error(request->context, error); g_error_free(error); diff --git a/src/idle-handles.c b/src/idle-handles.c index 8a05028..5e3843e 100644 --- a/src/idle-handles.c +++ b/src/idle-handles.c @@ -130,7 +130,7 @@ static gboolean _channelname_is_valid(const gchar *channel) { gchar *idle_normalize_nickname (const gchar *id, GError **error) { if (!idle_nickname_is_valid(id, FALSE)) { - g_set_error(error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, "invalid nickname"); + g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid nickname"); return NULL; } @@ -145,7 +145,7 @@ static gchar *_nick_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpo static gchar *_channel_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpointer ctx, GError **error) { if (!_channelname_is_valid(id)) { - g_set_error(error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, "invalid channel ID"); + g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid channel ID"); return NULL; } diff --git a/src/idle-im-manager.c b/src/idle-im-manager.c index afb01e8..c6ac712 100644 --- a/src/idle-im-manager.c +++ b/src/idle-im-manager.c @@ -359,7 +359,7 @@ _im_manager_requestotron (IdleIMManager *self, /* Don't support opening a channel to our self handle */ if (handle == base_conn->self_handle) { - g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, + g_set_error (&error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Can't open a text channel to yourself"); goto error; } @@ -374,7 +374,7 @@ _im_manager_requestotron (IdleIMManager *self, if (require_new) { - g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + g_set_error (&error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Already chatting with contact #%u in another channel", handle); goto error; } diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index 5dc569c..187d523 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -1479,7 +1479,7 @@ static gboolean send_invite_request(IdleMUCChannel *obj, TpHandle handle, GError if ((nick == NULL) || (nick[0] == '\0')) { IDLE_DEBUG("invalid handle %u passed", handle); - g_set_error(error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, "invalid handle %u passed", handle); + g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid handle %u passed", handle); return FALSE; } @@ -1507,7 +1507,7 @@ static gboolean send_kick_request(IdleMUCChannel *obj, TpHandle handle, const gc if ((nick == NULL) || (nick[0] == '\0')) { IDLE_DEBUG("invalid handle %u passed", handle); - g_set_error(error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, "invalid handle %u passed", handle); + g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid handle %u passed", handle); return FALSE; } @@ -1531,7 +1531,7 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, if (handle == base_conn->self_handle) { if (tp_handle_set_is_member(obj->group.members, handle) || tp_handle_set_is_member(obj->group.remote_pending, handle)) { - GError *e = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + GError *e = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "we are already a member of or trying to join %s", priv->channel_name); IDLE_DEBUG ("%s", e->message); g_propagate_error (error, e); @@ -1549,7 +1549,7 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, } } else { if (tp_handle_set_is_member(obj->group.members, handle) || tp_handle_set_is_member(obj->group.remote_pending, handle)) { - GError *e = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + GError *e = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "the requested contact (handle %u) to be added " "to the room (%s) is already a member of, or " "has already been invited to join, the room", @@ -1607,7 +1607,7 @@ static gboolean remove_member(GObject *gobj, TpHandle handle, const gchar *messa if (!tp_handle_set_is_member(obj->group.members, handle)) { IDLE_DEBUG("handle %u not a current member!", handle); - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "handle %u is not a current member of the channel", handle); + g_set_error(error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, "handle %u is not a current member of the channel", handle); return FALSE; } @@ -1691,7 +1691,7 @@ static void idle_muc_channel_get_properties (TpSvcPropertiesInterface *iface, co if (prop >= LAST_TP_PROPERTY_ENUM) { IDLE_DEBUG("invalid property id %u", prop); - error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "invalid property id %u", prop); + error = g_error_new(TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "invalid property id %u", prop); dbus_g_method_return_error(context, error); g_error_free(error); @@ -1701,7 +1701,7 @@ static void idle_muc_channel_get_properties (TpSvcPropertiesInterface *iface, co if (!(priv->properties[prop].flags & TP_PROPERTY_FLAG_READ)) { IDLE_DEBUG("not allowed to read property %u", prop); - error = g_error_new(TP_ERRORS, TP_ERROR_PERMISSION_DENIED, "not allowed to read property %u", prop); + error = g_error_new(TP_ERROR, TP_ERROR_PERMISSION_DENIED, "not allowed to read property %u", prop); dbus_g_method_return_error(context, error); g_error_free(error); @@ -1777,7 +1777,7 @@ static void idle_muc_channel_list_properties (TpSvcPropertiesInterface *iface, D default: IDLE_DEBUG("encountered unknown type %s", g_type_name(property_signatures[i].type)); - error = g_error_new(TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "internal error in %s", G_STRFUNC); + error = g_error_new(TP_ERROR, TP_ERROR_NOT_AVAILABLE, "internal error in %s", G_STRFUNC); dbus_g_method_return_error(context, error); g_error_free(error); g_ptr_array_free(ret, TRUE); @@ -1828,7 +1828,7 @@ static void idle_muc_channel_provide_password (TpSvcChannelInterfacePassword *if priv = obj->priv; if (!(priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE) || (priv->passwd_ctx != NULL)) { - GError *error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + GError *error = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "don't need a password now or authentication already " "in progress (%s)", priv->channel_name); IDLE_DEBUG ("%s", error->message); @@ -1858,7 +1858,7 @@ idle_muc_channel_send (GObject *obj, TpMessage *message, TpMessageSendingFlags f TpBaseConnection *base_conn = tp_base_channel_get_connection (base); if ((priv->mode_state.flags & MODE_FLAG_MODERATED) && !(priv->mode_state.flags & (MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE | MODE_FLAG_VOICE_PRIVILEGE))) { - GError error = { TP_ERRORS, TP_ERROR_PERMISSION_DENIED, "Channel is moderated" }; + GError error = { TP_ERROR, TP_ERROR_PERMISSION_DENIED, "Channel is moderated" }; IDLE_DEBUG("Channel is moderated"); tp_message_mixin_sent (obj, message, 0, NULL, &error); @@ -2080,7 +2080,7 @@ static void idle_muc_channel_set_properties (TpSvcPropertiesInterface *iface, co if (prop_id >= LAST_TP_PROPERTY_ENUM) { IDLE_DEBUG("invalid property id %u", prop_id); - error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "invalid property id %u", prop_id); + error = g_error_new(TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "invalid property id %u", prop_id); dbus_g_method_return_error(context, error); g_error_free(error); g_ptr_array_free(to_change, TRUE); @@ -2091,7 +2091,7 @@ static void idle_muc_channel_set_properties (TpSvcPropertiesInterface *iface, co if ((priv->properties[prop_id].flags & TP_PROPERTY_FLAG_WRITE) == 0) { IDLE_DEBUG("not allowed to set property with id %u", prop_id); - error = g_error_new(TP_ERRORS, TP_ERROR_PERMISSION_DENIED, "not allowed to set property with id %u", prop_id); + error = g_error_new(TP_ERROR, TP_ERROR_PERMISSION_DENIED, "not allowed to set property with id %u", prop_id); dbus_g_method_return_error(context, error); g_error_free(error); g_ptr_array_free(to_change, TRUE); @@ -2102,7 +2102,7 @@ static void idle_muc_channel_set_properties (TpSvcPropertiesInterface *iface, co if (!g_value_type_compatible(G_VALUE_TYPE(prop_val), property_signatures[prop_id].type)) { IDLE_DEBUG("incompatible value type %s for prop_id %u", g_type_name(G_VALUE_TYPE(prop_val)), prop_id); - error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "incompatible value type %s for prop_id %u", g_type_name(G_VALUE_TYPE(prop_val)), prop_id); + error = g_error_new(TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "incompatible value type %s for prop_id %u", g_type_name(G_VALUE_TYPE(prop_val)), prop_id); dbus_g_method_return_error(context, error); g_error_free(error); g_ptr_array_free(to_change, TRUE); @@ -2133,7 +2133,7 @@ idle_muc_channel_set_subject ( if (priv->state != MUC_STATE_JOINED) { - GError *error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + GError *error = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Can't set subject: not in the room (state=%s)", ascii_muc_states[priv->state]); dbus_g_method_return_error (context, error); @@ -2141,7 +2141,7 @@ idle_muc_channel_set_subject ( } else if (!priv->can_set_topic) { - GError error = { TP_ERRORS, TP_ERROR_PERMISSION_DENIED, + GError error = { TP_ERROR, TP_ERROR_PERMISSION_DENIED, "The channel's +t and you're not an op" }; dbus_g_method_return_error (context, &error); } diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c index 682dba2..684d4eb 100644 --- a/src/idle-muc-manager.c +++ b/src/idle-muc-manager.c @@ -669,7 +669,7 @@ static void _channel_closed_cb(IdleMUCChannel *chan, gpointer user_data) { * didn't finish before we killed the channel. */ for (GSList *l = reqs; l != NULL; l = l->next) { - tp_channel_manager_emit_request_failed(manager, l->data, TP_ERRORS, + tp_channel_manager_emit_request_failed(manager, l->data, TP_ERROR, TP_ERROR_DISCONNECTED, "Unable to complete this channel request, we're disconnecting!"); } @@ -721,7 +721,7 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use } for (GSList *l = reqs; reqs != NULL; reqs = reqs->next) { - tp_channel_manager_emit_request_failed(manager, l->data, TP_ERRORS, err_code, err_msg); + tp_channel_manager_emit_request_failed(manager, l->data, TP_ERROR, err_code, err_msg); } if (priv->channels) @@ -809,7 +809,7 @@ _muc_manager_request (IdleMUCManager *self, { if (require_new) { - g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + g_set_error (&error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, "That channel has already been created (or requested)"); goto error; } diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c index 930a242..43e81f3 100644 --- a/src/idle-server-connection.c +++ b/src/idle-server-connection.c @@ -268,7 +268,7 @@ static void _connect_to_host_ready(GObject *source_object, GAsyncResult *res, gp socket_connection = g_socket_client_connect_to_host_finish(socket_client, res, &error); if (socket_connection == NULL) { IDLE_DEBUG("g_socket_client_connect_to_host failed: %s", error->message); - g_simple_async_result_set_error(result, TP_ERRORS, TP_ERROR_NETWORK_ERROR, "%s", error->message); + g_simple_async_result_set_error(result, TP_ERROR, TP_ERROR_NETWORK_ERROR, "%s", error->message); g_error_free(error); change_state(conn, SERVER_CONNECTION_STATE_NOT_CONNECTED, SERVER_CONNECTION_STATE_REASON_ERROR); g_object_unref(conn); @@ -302,7 +302,7 @@ void idle_server_connection_connect_async(IdleServerConnection *conn, GCancellab IDLE_DEBUG("already connecting or connected!"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "already connecting or connected!"); return; } @@ -311,7 +311,7 @@ void idle_server_connection_connect_async(IdleServerConnection *conn, GCancellab IDLE_DEBUG("host not set!"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "host not set!"); return; } @@ -320,7 +320,7 @@ void idle_server_connection_connect_async(IdleServerConnection *conn, GCancellab IDLE_DEBUG("port not set!"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "port not set!"); return; } @@ -347,7 +347,7 @@ static void _close_ready(GObject *source_object, GAsyncResult *res, gpointer use if (!g_io_stream_close_finish(io_stream, res, &error)) { IDLE_DEBUG("g_io_stream_close failed: %s", error->message); - g_simple_async_result_set_error(result, TP_ERRORS, TP_ERROR_NETWORK_ERROR, "%s", error->message); + g_simple_async_result_set_error(result, TP_ERROR, TP_ERROR_NETWORK_ERROR, "%s", error->message); g_error_free(error); } @@ -373,7 +373,7 @@ void idle_server_connection_disconnect_full_async(IdleServerConnection *conn, gu IDLE_DEBUG("the connection was not open"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "the connection was not open"); return; } @@ -382,7 +382,7 @@ void idle_server_connection_disconnect_full_async(IdleServerConnection *conn, gu IDLE_DEBUG("We were exploding anyway"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "We were exploding anyway"); return; } @@ -413,7 +413,7 @@ static void _write_ready(GObject *source_object, GAsyncResult *res, gpointer use nwrite = g_output_stream_write_finish(output_stream, res, &error); if (nwrite == -1) { IDLE_DEBUG("g_output_stream_write failed : %s", error->message); - g_simple_async_result_set_error(result, TP_ERRORS, TP_ERROR_NETWORK_ERROR, "%s", error->message); + g_simple_async_result_set_error(result, TP_ERROR, TP_ERROR_NETWORK_ERROR, "%s", error->message); g_error_free(error); goto cleanup; } @@ -443,7 +443,7 @@ void idle_server_connection_send_async(IdleServerConnection *conn, const gchar * IDLE_DEBUG("connection was not open!"); g_simple_async_report_error_in_idle(G_OBJECT(conn), callback, user_data, - TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + TP_ERROR, TP_ERROR_NOT_AVAILABLE, "connection was not open!"); return; } diff --git a/src/idle-text.c b/src/idle-text.c index 25ee678..4b439a4 100644 --- a/src/idle-text.c +++ b/src/idle-text.c @@ -95,7 +95,7 @@ idle_text_encode_and_split(TpChannelTextMessageType type, break; default: IDLE_DEBUG("unsupported message type %u", type); - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, "unsupported message type %u", type); + g_set_error(error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "unsupported message type %u", type); return NULL; } @@ -163,7 +163,7 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag #define INVALID_ARGUMENT(msg, ...) \ G_STMT_START { \ IDLE_DEBUG (msg , ## __VA_ARGS__); \ - g_set_error (&error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, \ + g_set_error (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, \ msg , ## __VA_ARGS__); \ goto failed; \ } G_STMT_END diff --git a/src/protocol.c b/src/protocol.c index 49cf468..4a67fe1 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -52,7 +52,7 @@ filter_nick (const TpCMParamSpec *paramspec, if (!idle_nickname_is_valid (nick, TRUE)) { - g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "Invalid account name '%s'", nick); return FALSE; } @@ -79,7 +79,7 @@ filter_username (const TpCMParamSpec *paramspec, if (ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '@') { - g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Invalid user name '%s'", username); return FALSE; } -- 1.7.10