static gboolean reconnect(void) { if(wantconnection && lm_connection_get_state(connection) == LM_CONNECTION_STATE_CLOSED) { xmpp_connect(); } return TRUE; } /* reconnect */
CAResult_t CAStartRA() { if (g_xmppData.handle.abstract_handle) { OIC_LOG(WARNING, RA_ADAPTER_TAG, "RA adapter already started"); return CA_STATUS_OK; } OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Starting RA adapter")); g_raadapterMutex = ca_mutex_new (); if (!g_raadapterMutex) { OIC_LOG (ERROR, RA_ADAPTER_TAG, PCF("Memory allocation for mutex failed.")); return CA_MEMORY_ALLOC_FAILED; } ca_mutex_lock (g_raadapterMutex); xmpp_context_init(&g_xmppData.context); g_xmppData.handle = xmpp_startup(&g_xmppData.context); // Wire up connection callbacks and call API to connect to XMPP server g_xmppData.connection_callback.on_connected = CARAXmppConnectedCB; g_xmppData.connection_callback.on_disconnected = CARAXmppDisonnectedCB; xmpp_error_code_t ret = xmpp_connect(g_xmppData.handle, &g_xmppData.g_host, &g_xmppData.g_identity, g_xmppData.connection_callback); // Destroy host and identity structures as they are only // required to establish initial connection xmpp_identity_destroy(&g_xmppData.g_identity); xmpp_host_destroy(&g_xmppData.g_host); ca_mutex_unlock (g_raadapterMutex); if (XMPP_ERR_OK != ret) { OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "Failed to init XMPP connection status: %d", ret); return CA_STATUS_FAILED; } OIC_LOG(DEBUG, RA_ADAPTER_TAG, "RA adapter started succesfully"); return CA_STATUS_OK; }
void xmpp_init(void) { /* TODO: Maybe we can just get rid of this? */ xmpp_connect(); } /* xmpp_init */