Example #1
0
void
jabber_process_events(void)
{
    int reconnect_sec;

    switch (jabber_conn.conn_status)
    {
        case JABBER_CONNECTED:
        case JABBER_CONNECTING:
        case JABBER_DISCONNECTING:
            xmpp_run_once(jabber_conn.ctx, 10);
            break;
        case JABBER_DISCONNECTED:
            reconnect_sec = prefs_get_reconnect();
            if ((reconnect_sec != 0) && reconnect_timer) {
                int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
                if (elapsed_sec > reconnect_sec) {
                    _jabber_reconnect();
                }
            }
            break;
        default:
            break;
    }
}
Example #2
0
    int
xmppipe_presence_init(xmppipe_state_t *state)
{
    xmpp_stanza_t *presence = NULL;

    /* Send initial <presence/> so that we appear online to contacts */
    presence = xmppipe_stanza_new(state->ctx);
    xmppipe_stanza_set_name(presence, "presence");
    xmppipe_send(state, presence);
    (void)xmpp_stanza_release(presence);

    if (!(state->opt & XMPPIPE_OPT_GROUPCHAT))
      xmppipe_next_state(state, XMPPIPE_S_READY_AVAIL);

    if ( (state->opt & XMPPIPE_OPT_GROUPCHAT) && state->out) {
        xmppipe_muc_join(state);
        xmppipe_muc_unlock(state);
        xmppipe_next_state(state, XMPPIPE_S_MUC_WAITJOIN);
    }

    for ( ; ; ) {
        xmpp_run_once(state->ctx, state->poll);
        switch (state->status) {
            case XMPPIPE_S_READY:
            case XMPPIPE_S_READY_AVAIL:
            case XMPPIPE_S_READY_EMPTY:
                return 0;
            default:
                break;
        }
    }
}
Example #3
0
void main_loop(xmpp_conn_t * const conn, xmpp_ctx_t *ctx, char *jid_to)
{
    /* enter the event loop -
       our connect handler will trigger an exit */
    while (1) {
        xmpp_run_once(ctx, DEFAULT_TIMEOUT);
        send_stdin_once(conn, ctx, jid_to);
    }
}
Example #4
0
/** Start the event loop.
 *  This function continuously calls xmpp_run_once and does not return
 *  until xmpp_stop has been called.
 *
 *  @param ctx a Strophe context object
 *
 *  @ingroup EventLoop
 */
void xmpp_run(xmpp_ctx_t *ctx)
{
    if (ctx->loop_status != XMPP_LOOP_NOTSTARTED) return;

    ctx->loop_status = XMPP_LOOP_RUNNING;
    while (ctx->loop_status == XMPP_LOOP_RUNNING) {
	xmpp_run_once(ctx, DEFAULT_TIMEOUT);
    }

    xmpp_debug(ctx, "event", "Event loop completed.");
}
Example #5
0
    int
xmppipe_connect_init(xmppipe_state_t *state)
{
    for ( ; ; ) {
        xmpp_run_once(state->ctx, state->poll);
        switch (state->status) {
            case XMPPIPE_S_CONNECTED:
                return 0;
            case XMPPIPE_S_CONNECTING:
                break;
            default:
                return -1;
        }
    }
}
Example #6
0
int sdvp_ConnectionCreate(sdvp_config_t *sdvpConfig) {
	xmpp_conn_t *conn;

#ifdef MEMWATCH
	/* memwatch setup */
    mwStatistics( 2 );
    TRACE("Watching libsdvp!\n");
#endif

	if (sdvpConfig->debug == SDVP_DEBUG_ENABLED) {
		debugIsEnabled = true;
	}
	if (!sdvpIsInitialised) {
		if (debugIsEnabled) {
			sdvp_InitialiseWithDebug();
		} else {
			sdvp_Initialise();
		}
	}

// create a connection
	conn = xmpp_conn_new(ctx);
	xmpp_conn_set_jid(conn, sdvpConfig->user);
	xmpp_conn_set_pass(conn, sdvpConfig->password);
	xmpp_connect_client(conn, sdvpConfig->host, 0, sdvp_HandleConnection, ctx);
//	callback = sdvpConfig->callback;
	callbackOnConnectionChange = sdvpConfig->callbackOnConnectionChange;

	//Event loop
	sdvpIsRunning = true;
	while(sdvpIsRunning) {
		xmpp_run_once(ctx,1);

		if (sdvpIdleCounter > IDLE_COUNT_MAX)
			sdvpSendPing(conn, ctx);

		if (sdvpPingsSent > MAX_PINGS)
			sdvp_ConnectionStop(sdvpConfig);

		sdvpIdleCounter++;
	}

	xmpp_conn_release(conn);

	return 0;
}
Example #7
0
static void
_jabber_process_events(void)
{
    // run xmpp event loop if connected, connecting or disconnecting
    if (jabber_conn.conn_status == JABBER_CONNECTED
            || jabber_conn.conn_status == JABBER_CONNECTING
            || jabber_conn.conn_status == JABBER_DISCONNECTING) {
        xmpp_run_once(jabber_conn.ctx, 10);

    // check timer and reconnect if disconnected and timer set
    } else if (prefs_get_reconnect() != 0) {
        if ((jabber_conn.conn_status == JABBER_DISCONNECTED) &&
            (reconnect_timer != NULL)) {
            if (g_timer_elapsed(reconnect_timer, NULL) > prefs_get_reconnect()) {
                _jabber_reconnect();
            }
        }
    }

}
Example #8
0
void
connection_check_events(void)
{
    xmpp_run_once(conn.xmpp_ctx, 10);
}
Example #9
0
void CALLBACK TimerProc( HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
{
    xmpp_run_once(ctx, 1);
}