]> www.infradead.org Git - pidgin-chime.git/commitdiff
Remove PurpleConnection from ChimeConnection.
authorIsaac Jurado <ijurado@amazon.com>
Tue, 1 May 2018 11:08:29 +0000 (13:08 +0200)
committerIsaac Jurado <ijurado@amazon.com>
Tue, 1 May 2018 14:56:29 +0000 (16:56 +0200)
This commit efectively completes the decoupling of libpurple specific glue code
from the self contained Chime client code.  Fixes #2.

chime-get-token.c
chime/chime-connection.c
chime/chime-connection.h
chime/chime-signin.c
prpl/chime.c

index 758d0522615137e77ef84b2bc29b0f7163a654f2..921e3d7a3da6b71c1220c71356d57fc4155428bd 100644 (file)
@@ -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);
index 02eb7cd195ea2f42055144687a2afbe24b3b9d1f..e48506c7e108928fd106290ea98709465abc81f9 100644 (file)
@@ -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,
index 1361f5f3c789669249f78be90e4620a6b846f400..b56a825a61456c025a1300691a6f1fabe63f01ff 100644 (file)
@@ -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);
index 6c8dcba4dc44d890437ac7bc9074e1df8c9da60c..7d5bf1ae85caca3b63a98cbe23478d21112353ed 100644 (file)
@@ -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.
  */
index e6a7b235bbdcf8fe7419307651197f8d36ed6f82..8d27edd08e447d3d210929d09fb465fce36540d2 100644 (file)
@@ -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",