--- a/examples/test-lm.c Sun Feb 15 15:30:12 2015 +0100
+++ b/examples/test-lm.c Sat Oct 31 08:37:51 2015 +0100
@@ -38,19 +38,19 @@
static gchar *resource = "test-lm";
static gchar *fingerprint = NULL;
-static GOptionEntry entries[] =
+static GOptionEntry entries[] =
{
- { "server", 's', 0, G_OPTION_ARG_STRING, &server,
+ { "server", 's', 0, G_OPTION_ARG_STRING, &server,
"Server to connect to", NULL },
- { "port", 'P', 0, G_OPTION_ARG_INT, &port,
+ { "port", 'P', 0, G_OPTION_ARG_INT, &port,
"Port to connect to [default=5222]", NULL },
- { "username", 'u', 0, G_OPTION_ARG_STRING, &username,
+ { "username", 'u', 0, G_OPTION_ARG_STRING, &username,
"Username to connect with (user@server.org)", NULL },
- { "password", 'p', 0, G_OPTION_ARG_STRING, &password,
+ { "password", 'p', 0, G_OPTION_ARG_STRING, &password,
"Password to try", NULL },
- { "resource", 'r', 0, G_OPTION_ARG_STRING, &resource,
+ { "resource", 'r', 0, G_OPTION_ARG_STRING, &resource,
"Resource connect with [default=test-lm]", NULL },
- { "fingerprint", 'f', 0, G_OPTION_ARG_STRING, &fingerprint,
+ { "fingerprint", 'f', 0, G_OPTION_ARG_STRING, &fingerprint,
"SSL Fingerprint to use", NULL },
{ NULL }
};
@@ -78,13 +78,13 @@
for (i = 0; i < size-1; i++) {
g_printerr ("%02X:", fpr[i]);
}
-
+
g_printerr ("%02X", fpr[size-1]);
}
static LmSSLResponse
-ssl_cb (LmSSL *ssl,
- LmSSLStatus status,
+ssl_cb (LmSSL *ssl,
+ LmSSLStatus status,
gpointer ud)
{
g_print ("TestLM: SSL status:%d\n", status);
@@ -94,20 +94,20 @@
g_printerr ("TestLM: No certificate found!\n");
break;
case LM_SSL_STATUS_UNTRUSTED_CERT:
- g_printerr ("TestLM: Certificate is not trusted!\n");
+ g_printerr ("TestLM: Certificate is not trusted!\n");
break;
case LM_SSL_STATUS_CERT_EXPIRED:
- g_printerr ("TestLM: Certificate has expired!\n");
+ g_printerr ("TestLM: Certificate has expired!\n");
break;
case LM_SSL_STATUS_CERT_NOT_ACTIVATED:
- g_printerr ("TestLM: Certificate has not been activated!\n");
+ g_printerr ("TestLM: Certificate has not been activated!\n");
break;
case LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH:
- g_printerr ("TestLM: Certificate hostname does not match expected hostname!\n");
+ g_printerr ("TestLM: Certificate hostname does not match expected hostname!\n");
break;
case LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH: {
const char *fpr = lm_ssl_get_fingerprint (ssl);
- g_printerr ("TestLM: Certificate fingerprint does not match expected fingerprint!\n");
+ g_printerr ("TestLM: Certificate fingerprint does not match expected fingerprint!\n");
g_printerr ("TestLM: Remote fingerprint: ");
print_finger (fpr, 16);
@@ -118,7 +118,7 @@
break;
}
case LM_SSL_STATUS_GENERIC_ERROR:
- g_printerr ("TestLM: Generic SSL error!\n");
+ g_printerr ("TestLM: Generic SSL error!\n");
break;
}
@@ -127,12 +127,12 @@
static void
connection_auth_cb (LmConnection *connection,
- gboolean success,
+ gboolean success,
gpointer user_data)
{
if (success) {
LmMessage *m;
-
+
test_success = TRUE;
g_print ("TestLM: Authenticated successfully\n");
@@ -140,7 +140,7 @@
LM_MESSAGE_TYPE_PRESENCE,
LM_MESSAGE_SUB_TYPE_AVAILABLE);
lm_connection_send (connection, m, NULL);
- g_print ("TestLM: Sent presence message:'%s'\n",
+ g_print ("TestLM: Sent presence message:'%s'\n",
lm_message_node_to_string (m->node));
lm_message_unref (m);
@@ -151,7 +151,7 @@
}
static void
-connection_open_cb (LmConnection *connection,
+connection_open_cb (LmConnection *connection,
gboolean success,
gpointer user_data)
{
@@ -159,12 +159,12 @@
gchar *user;
user = get_part_name (username);
- lm_connection_authenticate (connection, user,
+ lm_connection_authenticate (connection, user,
password, resource,
- connection_auth_cb,
+ connection_auth_cb,
NULL, FALSE, NULL);
g_free (user);
-
+
g_print ("TestLM: Sent authentication message\n");
} else {
g_printerr ("TestLM: Failed to connect\n");
@@ -173,12 +173,12 @@
}
static void
-connection_close_cb (LmConnection *connection,
+connection_close_cb (LmConnection *connection,
LmDisconnectReason reason,
gpointer user_data)
{
const char *str;
-
+
switch (reason) {
case LM_DISCONNECT_REASON_OK:
str = "LM_DISCONNECT_REASON_OK";
@@ -213,7 +213,7 @@
return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
-int
+int
main (int argc, char **argv)
{
GOptionContext *context;
@@ -221,12 +221,12 @@
LmMessageHandler *handler;
gboolean result;
GError *error = NULL;
-
+
context = g_option_context_new ("- test Loudmouth");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
-
+
if (!server || !username || !password) {
g_printerr ("For usage, try %s --help\n", argv[0]);
return EXIT_FAILURE;
@@ -247,12 +247,12 @@
lm_connection_set_jid (connection, username);
handler = lm_message_handler_new (handle_messages, NULL, NULL);
- lm_connection_register_message_handler (connection, handler,
- LM_MESSAGE_TYPE_MESSAGE,
+ lm_connection_register_message_handler (connection, handler,
+ LM_MESSAGE_TYPE_MESSAGE,
LM_HANDLER_PRIORITY_NORMAL);
-
+
lm_message_handler_unref (handler);
-
+
lm_connection_set_disconnect_function (connection,
connection_close_cb,
NULL, NULL);
@@ -261,7 +261,7 @@
LmSSL *ssl;
char *p;
int i;
-
+
if (port == LM_CONNECTION_DEFAULT_PORT) {
lm_connection_set_port (connection,
LM_CONNECTION_DEFAULT_PORT_SSL);
@@ -270,13 +270,13 @@
for (i = 0, p = fingerprint; *p && *(p+1); i++, p += 3) {
expected_fingerprint[i] = (unsigned char) g_ascii_strtoull (p, NULL, 16);
}
-
+
ssl = lm_ssl_new (expected_fingerprint,
(LmSSLFunction) ssl_cb,
NULL, NULL);
lm_ssl_use_starttls (ssl, TRUE, FALSE);
-
+
lm_connection_set_ssl (connection, ssl);
lm_ssl_unref (ssl);
}
@@ -286,12 +286,12 @@
NULL, NULL, &error);
if (!result) {
- g_printerr ("TestLM: Opening connection failed, error:%d->'%s'\n",
+ g_printerr ("TestLM: Opening connection failed, error:%d->'%s'\n",
error->code, error->message);
g_free (error);
return EXIT_FAILURE;
}
-
+
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);