gobjectification: 54a3f6c2: Emit the gobject signals for connection.
sadrul at pidgin.im
sadrul at pidgin.im
Mon Jun 23 19:05:40 EDT 2008
-----------------------------------------------------------------
Revision: 54a3f6c27532f476dfd8b1725f7166ba84ff2fce
Ancestor: 8d875af10dd8f4f2c454da9707727c6a7d79bbd2
Author: sadrul at pidgin.im
Date: 2008-06-23T22:53:21
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/54a3f6c27532f476dfd8b1725f7166ba84ff2fce
Modified files:
libpurple/connection.c libpurple/connection.h
ChangeLog:
Emit the gobject signals for connection.
-------------- next part --------------
============================================================
--- libpurple/connection.c 7fba96f87072746b6e07ad5b253f5fc314a30188
+++ libpurple/connection.c be22ae1feda2f9bc87be406c41f5dd88b9604986
@@ -89,6 +89,7 @@ enum
SIG_SIGNING_OFF,
SIG_SIGNED_OFF,
SIG_DISCONNECTED,
+ SIG_ERROR,
SIG_LAST
};
@@ -206,9 +207,7 @@ purple_connection_new(PurpleAccount *acc
gc->priv->password = g_strdup(password);
-#if 0
- purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
-#endif
+ g_signal_emit(G_OBJECT(gc), signals[SIG_SIGNING_ON], 0);
if (regist)
{
@@ -265,23 +264,21 @@ purple_connection_new_unregister(PurpleA
"a password.\n", purple_account_get_username(account));
return;
}
-
+
gc = g_new0(PurpleConnection, 1);
PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
-
+
gc->priv->prpl = prpl;
gc->priv->password = g_strdup(password);
purple_connection_set_account(gc, account);
purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTING);
connections = g_list_append(connections, gc);
purple_account_set_connection(account, gc);
-
-#if 0
- purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
-#endif
-
+
+ g_signal_emit(gc, signals[SIG_SIGNING_ON], 0);
+
purple_debug_info("connection", "Unregistering. gc = %p\n", gc);
-
+
prpl_info->unregister_user(account, cb, user_data);
}
@@ -357,8 +354,8 @@ purple_connection_set_state(PurpleConnec
if (ops != NULL && ops->connected != NULL)
ops->connected(gc);
- purple_signal_emit(purple_connections_get_handle(), "signed-on", gc);
#endif
+ g_signal_emit(G_OBJECT(gc), signals[SIG_SIGNED_ON], 0);
serv_set_permit_deny(gc);
@@ -579,10 +576,8 @@ purple_connection_error_reason (PurpleCo
if (ops->report_disconnect != NULL)
ops->report_disconnect (gc, description);
}
-
- purple_signal_emit(purple_connections_get_handle(), "connection-error",
- gc, reason, description);
#endif
+ g_signal_emit(G_OBJECT(gc), signals[SIG_ERROR], 0, reason, description);
gc->priv->disconnect_timeout = purple_timeout_add(0, purple_connection_disconnect_cb,
purple_connection_get_account(gc));
@@ -740,11 +735,8 @@ purple_connection_dispose(GObject *obj)
purple_debug_info("connection", "Disconnecting connection %p\n", pc);
+ g_signal_emit(G_OBJECT(pc), signals[SIG_SIGNING_OFF], 0);
-#if 0
- purple_signal_emit(purple_connections_get_handle(), "signing-off", pc);
-#endif
-
while (pc->priv->buddy_chats)
{
PurpleConversation *b = pc->priv->buddy_chats->data;
@@ -789,9 +781,7 @@ purple_connection_finalize(GObject *obj)
if (remove)
purple_blist_remove_account(account);
-#if 0
- purple_signal_emit(purple_connections_get_handle(), "signed-off", pc);
-#endif
+ g_signal_emit(G_OBJECT(pc), signals[SIG_SIGNED_OFF], 0);
purple_account_request_close_with_account(account);
purple_request_close_with_handle(pc);
@@ -902,7 +892,7 @@ purple_connection_class_init(PurpleConne
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PurpleConnectionClass, signing_on),
NULL, NULL,
- purple_smarshal_VOID__OBJECT,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
@@ -912,7 +902,7 @@ purple_connection_class_init(PurpleConne
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PurpleConnectionClass, signed_on),
NULL, NULL,
- purple_smarshal_VOID__OBJECT,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
@@ -922,7 +912,7 @@ purple_connection_class_init(PurpleConne
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PurpleConnectionClass, signing_off),
NULL, NULL,
- purple_smarshal_VOID__OBJECT,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
@@ -932,7 +922,7 @@ purple_connection_class_init(PurpleConne
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PurpleConnectionClass, signed_off),
NULL, NULL,
- purple_smarshal_VOID__OBJECT,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
@@ -942,9 +932,19 @@ purple_connection_class_init(PurpleConne
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PurpleConnectionClass, disconnected),
NULL, NULL,
- purple_smarshal_VOID__OBJECT,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+ signals[SIG_ERROR] =
+ g_signal_new("connection-error",
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(PurpleConnectionClass, disconnected),
+ NULL, NULL,
+ purple_smarshal_VOID__ENUM_STRING,
+ G_TYPE_NONE,
+ 2, PURPLE_TYPE_CONNECTION_ERROR, G_TYPE_STRING);
}
/******************************************************************************
@@ -1022,11 +1022,9 @@ purple_connection_state_get_gtype(void)
if(type == 0) {
static const GEnumValue values[] = {
- { PURPLE_CONNECTION_STATE_DISCONNECTED, "Disconnected",
- "Disconnected"
- },
- { PURPLE_CONNECTION_STATE_CONNECTING, "Connecting", "Connecting" },
- { PURPLE_CONNECTION_STATE_CONNECTED, "Connected", "Connected" },
+ { PURPLE_CONNECTION_STATE_DISCONNECTED, "Disconnected", "Disconnected"},
+ { PURPLE_CONNECTION_STATE_CONNECTING, "Connecting", "Connecting"},
+ { PURPLE_CONNECTION_STATE_CONNECTED, "Connected", "Connected"},
{ 0, NULL, NULL },
};
@@ -1036,6 +1034,42 @@ purple_connection_state_get_gtype(void)
return type;
}
+/******************************************************************************
+ * PurpleConnectionError API
+ *****************************************************************************/
+GType
+purple_connection_error_get_gtype(void)
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GEnumValue values[] = {
+ {PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "Network error", ""},
+ {PURPLE_CONNECTION_ERROR_INVALID_USERNAME, "Invalid username", ""},
+ {PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, "Authentication failed", ""},
+ {PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Authentication impossible", ""},
+ {PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, "No SSL support", ""},
+ {PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, "Encryption error", ""},
+ {PURPLE_CONNECTION_ERROR_NAME_IN_USE, "Name already in use", ""},
+ {PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, "Invalid settings", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED, "SSL certificate unavailable", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED, "SSL certificate could not be trusted", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_EXPIRED, "SSL certificate expired", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED, "SSL certificate is not yet valid", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH, "SSL certificate did not match its hostname", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH, "SSL certificate fingerprint mismatch", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED, "SSL certificate is self-signed", ""},
+ {PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR, "Other SSL error", ""},
+ {PURPLE_CONNECTION_ERROR_OTHER_ERROR, "Unknown error", ""},
+ { 0, NULL, NULL },
+ };
+
+ type = g_enum_register_static("PurpleConnectionError", values);
+ }
+
+ return type;
+}
+
/***
* These should move to PurpleConnectionManager
*/
============================================================
--- libpurple/connection.h 1c9725dfdb069474afc6842a19fa1bac5bd70081
+++ libpurple/connection.h 4ec3ea688ece60d5282012b6f856f8cf9c43dbb6
@@ -146,6 +146,8 @@ typedef enum
PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16
} PurpleConnectionError;
+#define PURPLE_TYPE_CONNECTION_ERROR (purple_connection_error_get_gtype())
+
/** Holds the type of an error along with its description. */
typedef struct
{
@@ -583,6 +585,7 @@ GType purple_connection_state_get_gtype(
GType purple_connection_get_gtype(void);
GType purple_connection_flags_get_gtype(void);
GType purple_connection_state_get_gtype(void);
+GType purple_connection_error_get_gtype(void);
G_END_DECLS
More information about the Commits
mailing list