Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <loudmouth/loudmouth.h>
  3.  
  4. int connect() {
  5.   LmConnection *connection = NULL;
  6.   GError *error = NULL;
  7.   char* server = "server";
  8.   char* username = "moi";
  9.   char* password = "coincoin";
  10.   char* ressource = "test";
  11.  
  12.   connection = lm_connection_new(server);
  13.   if (!lm_connection_open_and_block (connection, &error)) {
  14.     g_print ("Couldn't open connection to '%s'\n%s\n",
  15.          server, error->message);
  16.     return -1;
  17.   }
  18.   if (!lm_connection_authenticate_and_block (connection, username, password,
  19.                          ressource, &error)) {
  20.     g_print ("Couldn't authenticate with '%s' '%s':\n%s\n",
  21.          username, password, error->message);
  22.     return -1;
  23.     }
  24.   printf("Account %s@%s is connected\n", username, server);
  25.   lm_connection_close (connection, NULL);
  26.   lm_connection_unref (connection);
  27.   return 0;
  28. }
  29. int main()
  30. {
  31.   return connect();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement