libstrophe authenticates automatically when necessary. This happens inside xmpp_run(). The credentials it uses are set using these lines:
/* setup authentication information */
xmpp_conn_set_jid(conn, argv[1]);
xmpp_conn_set_pass(conn, argv[2]);
The jid
is your address (such as "user@jabber.org", "user@gmail.com", "user@dukgo.com", etc.), and pass
is your password.
Your example is missing your conn_handler
function, which is where authentication errors will be delivered to.
Your conn_handler
function should have a signature like this:
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
const int error, xmpp_stream_error_t * const stream_error,
void * const userdata)
The parameters are:
conn
- Your connection object.
status
- One of XMPP_CONN_CONNECT
, XMPP_CONN_DISCONNECT
or XMPP_CONN_FAIL
. When your connection handler function is called, this parameter tells you why it was called.
error
- when disconnected (XMPP_CONN_FAIL), this contains the socket-level error code from the OS (otherwise it is 0).
stream_error
- one of the possible stream errors, listed at strophe.h:171, and their meaning documented in RFC6120 section 4.9.3.
userdata
- This contains whatever you passed as the userdata
parameter to xmpp_connect_client()
. It is useful if you have some per-connection state to keep, and you don't want to use global variables or have multiple connections.
Finally, you shouldn't have to specify "talk.google.com"
in xmpp_connect_client()
, I recommend passing NULL instead.