loudmouth/lm-connection.c
changeset 735 7ae46452fb10
parent 690 7ccf2113ec5f
equal deleted inserted replaced
734:866607b4c186 735:7ae46452fb10
   894 static void
   894 static void
   895 connection_socket_connect_cb (LmOldSocket  *socket,
   895 connection_socket_connect_cb (LmOldSocket  *socket,
   896                               gboolean      result,
   896                               gboolean      result,
   897                               LmConnection *connection)
   897                               LmConnection *connection)
   898 {
   898 {
       
   899     /* FIXME: Set up according to XMPP 1.0 specification */
       
   900     /*        StartTLS and the like */
       
   901     if (result == TRUE && !connection_send (connection,
       
   902                           "<?xml version='1.0' encoding='UTF-8'?>", -1,
       
   903                           NULL)) {
       
   904         lm_verbose ("Failed to send xml version and encoding\n");
       
   905         result = FALSE;
       
   906     }
       
   907 
   899     if (result == FALSE) {
   908     if (result == FALSE) {
   900         connection_do_close (connection);
   909         connection_do_close (connection);
   901 
   910 
   902         if (connection->open_cb) {
   911         if (connection->open_cb) {
   903             LmCallback *cb = connection->open_cb;
   912             LmCallback *cb = connection->open_cb;
   907             (* ((LmResultFunction) cb->func)) (connection, FALSE,
   916             (* ((LmResultFunction) cb->func)) (connection, FALSE,
   908                                                cb->user_data);
   917                                                cb->user_data);
   909             _lm_utils_free_callback (cb);
   918             _lm_utils_free_callback (cb);
   910         }
   919         }
   911 
   920 
   912         return;
   921     } else {
   913     }
   922         connection_send_stream_header (connection);
   914 
   923     }
   915     /* FIXME: Set up according to XMPP 1.0 specification */
       
   916     /*        StartTLS and the like */
       
   917     if (!connection_send (connection,
       
   918                           "<?xml version='1.0' encoding='UTF-8'?>", -1,
       
   919                           NULL)) {
       
   920         lm_verbose ("Failed to send xml version and encoding\n");
       
   921         connection_do_close (connection);
       
   922 
       
   923         return;
       
   924     }
       
   925 
       
   926     connection_send_stream_header (connection);
       
   927 }
   924 }
   928 
   925 
   929 static gboolean
   926 static gboolean
   930 connection_get_server_from_jid (const gchar *jid, gchar **server)
   927 connection_get_server_from_jid (const gchar *jid, gchar **server)
   931 {
   928 {
   967     g_free (server_from_jid);
   964     g_free (server_from_jid);
   968 
   965 
   969     if (!lm_connection_send (connection, m, NULL)) {
   966     if (!lm_connection_send (connection, m, NULL)) {
   970         lm_verbose ("Failed to send stream information\n");
   967         lm_verbose ("Failed to send stream information\n");
   971         connection_do_close (connection);
   968         connection_do_close (connection);
       
   969         connection_signal_disconnect (connection, LM_DISCONNECT_REASON_ERROR);
   972     }
   970     }
   973 
   971 
   974     lm_message_unref (m);
   972     lm_message_unref (m);
   975 }
   973 }
   976 
   974 
  1038 
  1036 
  1039     result = lm_connection_send (connection, m, NULL);
  1037     result = lm_connection_send (connection, m, NULL);
  1040     lm_message_unref (m);
  1038     lm_message_unref (m);
  1041     if (result < 0) {
  1039     if (result < 0) {
  1042         connection_do_close (connection);
  1040         connection_do_close (connection);
  1043     }
  1041         connection_signal_disconnect (connection, LM_DISCONNECT_REASON_ERROR);
  1044 
  1042     } else {
  1045     /* We may finally tell the client they're authorized */
  1043         /* We may finally tell the client they're authorized */
  1046     connection_call_auth_cb (connection, TRUE);
  1044         connection_call_auth_cb (connection, TRUE);
       
  1045     }
  1047 
  1046 
  1048     return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  1047     return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  1049 }
  1048 }
  1050 
  1049 
  1051 static LmHandlerResult
  1050 static LmHandlerResult
  1123 
  1122 
  1124         if (result < 0) {
  1123         if (result < 0) {
  1125             g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
  1124             g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
  1126                    "%s: can't send resource binding request\n", G_STRFUNC);
  1125                    "%s: can't send resource binding request\n", G_STRFUNC);
  1127             connection_do_close (connection);
  1126             connection_do_close (connection);
       
  1127             connection_signal_disconnect (connection,
       
  1128                                           LM_DISCONNECT_REASON_ERROR);
  1128         }
  1129         }
  1129     }
  1130     }
  1130 
  1131 
  1131     old_auth = lm_message_node_find_child (message->node, "auth");
  1132     old_auth = lm_message_node_find_child (message->node, "auth");
  1132 
  1133