equal
deleted
inserted
replaced
53 { "fingerprint", 'f', 0, G_OPTION_ARG_STRING, &fingerprint, |
53 { "fingerprint", 'f', 0, G_OPTION_ARG_STRING, &fingerprint, |
54 "SSL Fingerprint to use", NULL }, |
54 "SSL Fingerprint to use", NULL }, |
55 { NULL } |
55 { NULL } |
56 }; |
56 }; |
57 |
57 |
|
58 static gchar * |
|
59 get_part_name (const gchar *username) |
|
60 { |
|
61 const gchar *ch; |
|
62 |
|
63 g_return_val_if_fail (username != NULL, NULL); |
|
64 |
|
65 ch = strchr (username, '@'); |
|
66 if (!ch) { |
|
67 return NULL; |
|
68 } |
|
69 |
|
70 return g_strndup (username, ch - username); |
|
71 } |
|
72 |
58 static void |
73 static void |
59 print_finger (const char *fpr, |
74 print_finger (const char *fpr, |
60 unsigned int size) |
75 unsigned int size) |
61 { |
76 { |
62 gint i; |
77 gint i; |
139 connection_open_cb (LmConnection *connection, |
154 connection_open_cb (LmConnection *connection, |
140 gboolean success, |
155 gboolean success, |
141 gpointer user_data) |
156 gpointer user_data) |
142 { |
157 { |
143 if (success) { |
158 if (success) { |
144 lm_connection_authenticate (connection, username, |
159 gchar *user; |
|
160 |
|
161 user = get_part_name (username); |
|
162 lm_connection_authenticate (connection, user, |
145 password, resource, |
163 password, resource, |
146 connection_auth_cb, |
164 connection_auth_cb, |
147 NULL, FALSE, NULL); |
165 NULL, FALSE, NULL); |
|
166 g_free (user); |
148 |
167 |
149 g_print ("TestLM: Sent authentication message\n"); |
168 g_print ("TestLM: Sent authentication message\n"); |
150 } else { |
169 } else { |
151 g_printerr ("TestLM: Failed to connect\n"); |
170 g_printerr ("TestLM: Failed to connect\n"); |
152 g_main_loop_quit (main_loop); |
171 g_main_loop_quit (main_loop); |
216 if (fingerprint && !lm_ssl_is_supported ()) { |
235 if (fingerprint && !lm_ssl_is_supported ()) { |
217 g_printerr ("TestLM: SSL is not supported in this build\n"); |
236 g_printerr ("TestLM: SSL is not supported in this build\n"); |
218 return EXIT_FAILURE; |
237 return EXIT_FAILURE; |
219 } |
238 } |
220 |
239 |
|
240 if (username && strchr (username, '@') == NULL) { |
|
241 g_printerr ("TestLM: Username must have an '@' included\n"); |
|
242 return EXIT_FAILURE; |
|
243 } |
|
244 |
221 connection = lm_connection_new (server); |
245 connection = lm_connection_new (server); |
222 lm_connection_set_port (connection, port); |
246 lm_connection_set_port (connection, port); |
|
247 lm_connection_set_jid (connection, username); |
223 |
248 |
224 handler = lm_message_handler_new (handle_messages, NULL, NULL); |
249 handler = lm_message_handler_new (handle_messages, NULL, NULL); |
225 lm_connection_register_message_handler (connection, handler, |
250 lm_connection_register_message_handler (connection, handler, |
226 LM_MESSAGE_TYPE_MESSAGE, |
251 LM_MESSAGE_TYPE_MESSAGE, |
227 LM_HANDLER_PRIORITY_NORMAL); |
252 LM_HANDLER_PRIORITY_NORMAL); |