From: Isaac Jurado Date: Tue, 1 May 2018 11:08:29 +0000 (+0200) Subject: Remove PurpleConnection from ChimeConnection. X-Git-Tag: v0.91~11 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c26b691c59fc93e22f76802dd3be4a287411cdf1;p=pidgin-chime.git Remove PurpleConnection from ChimeConnection. This commit efectively completes the decoupling of libpurple specific glue code from the self contained Chime client code. Fixes #2. --- diff --git a/chime-get-token.c b/chime-get-token.c index 758d052..921e3d7 100644 --- a/chime-get-token.c +++ b/chime-get-token.c @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) loop = g_main_loop_new(NULL, FALSE); status = EXIT_SUCCESS; - conn = chime_connection_new(NULL, account, NULL, "foo", NULL); + conn = chime_connection_new(account, NULL, "foo", NULL); g_signal_connect(conn, "authenticate", G_CALLBACK(authenticate), NULL); diff --git a/chime/chime-connection.c b/chime/chime-connection.c index 02eb7cd..e48506c 100644 --- a/chime/chime-connection.c +++ b/chime/chime-connection.c @@ -24,7 +24,6 @@ enum { PROP_0, - PROP_PURPLE_CONNECTION, PROP_SESSION_TOKEN, PROP_DEVICE_TOKEN, PROP_SERVER, @@ -107,8 +106,6 @@ chime_connection_disconnect(ChimeConnection *self) priv->msgs_queued = NULL; } - self->prpl_conn = NULL; - if (priv->state != CHIME_STATE_DISCONNECTED) g_signal_emit(self, signals[DISCONNECTED], 0, NULL); priv->state = CHIME_STATE_DISCONNECTED; @@ -138,9 +135,6 @@ chime_connection_get_property(GObject *object, ChimeConnectionPrivate *priv = CHIME_CONNECTION_GET_PRIVATE (self); switch (prop_id) { - case PROP_PURPLE_CONNECTION: - g_value_set_pointer(value, self->prpl_conn); - break; case PROP_SESSION_TOKEN: g_value_set_string(value, priv->session_token); break; @@ -169,9 +163,6 @@ chime_connection_set_property(GObject *object, ChimeConnectionPrivate *priv = CHIME_CONNECTION_GET_PRIVATE (self); switch (prop_id) { - case PROP_PURPLE_CONNECTION: - self->prpl_conn = g_value_get_pointer(value); - break; case PROP_SESSION_TOKEN: priv->session_token = g_value_dup_string(value); break; @@ -213,14 +204,6 @@ chime_connection_class_init(ChimeConnectionClass *klass) object_class->get_property = chime_connection_get_property; object_class->set_property = chime_connection_set_property; - props[PROP_PURPLE_CONNECTION] = - g_param_spec_pointer("purple-connection", - "purple connection", - "purple connection", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - props[PROP_SESSION_TOKEN] = g_param_spec_string("session-token", "session token", @@ -358,14 +341,13 @@ chime_connection_init(ChimeConnection *self) #define SIGNIN_DEFAULT "https://signin.id.ue1.app.chime.aws/" ChimeConnection * -chime_connection_new(void *prpl_conn, const gchar *email, const gchar *server, +chime_connection_new(const gchar *email, const gchar *server, const gchar *device_token, const gchar *session_token) { if (!server || !*server) server = SIGNIN_DEFAULT; return g_object_new (CHIME_TYPE_CONNECTION, - "purple-connection", prpl_conn, "account-email", email, "server", server ? server : SIGNIN_DEFAULT, "device-token", device_token, diff --git a/chime/chime-connection.h b/chime/chime-connection.h index 1361f5f..b56a825 100644 --- a/chime/chime-connection.h +++ b/chime/chime-connection.h @@ -29,8 +29,6 @@ G_DECLARE_FINAL_TYPE (ChimeConnection, chime_connection, CHIME, CONNECTION, GObj struct _ChimeConnection { GObject parent_instance; - - void *prpl_conn; }; #define CHIME_ERROR (chime_error_quark()) @@ -57,8 +55,7 @@ typedef void (*ChimeSoupMessageCallback)(ChimeConnection *cxn, JsonNode *node, gpointer cb_data); -ChimeConnection *chime_connection_new (void *prpl_conn, - const gchar *email, +ChimeConnection *chime_connection_new (const gchar *email, const gchar *server, const gchar *device_token, const gchar *session_token); diff --git a/chime/chime-signin.c b/chime/chime-signin.c index 6c8dcba..7d5bf1a 100644 --- a/chime/chime-signin.c +++ b/chime/chime-signin.c @@ -186,11 +186,6 @@ static void cancel_signin(struct signin *state) _("Sign-in canceled by the user"))); } -static void cancel_signin_cb(SoupSession *session, SoupMessage *msg, gpointer data) -{ - cancel_signin(data); -} - /* * XPath helpers to simplify querying the DOM of a parsed HTML response. */ diff --git a/prpl/chime.c b/prpl/chime.c index e6a7b23..8d27edd 100644 --- a/prpl/chime.c +++ b/prpl/chime.c @@ -230,7 +230,7 @@ static void chime_purple_login(PurpleAccount *account) purple_chime_init_chats(conn); purple_chime_init_messages(conn); - pc->cxn = chime_connection_new(conn, purple_account_get_username(account), + pc->cxn = chime_connection_new(purple_account_get_username(account), server, devtoken, token); g_signal_connect(pc->cxn, "notify::session-token",