Logo Search packages:      
Sourcecode: obexd version File versions  Download package

gboolean gw_obex_xfer_close ( GwObexXfer xfer,
gint *  error 
)

Close an ongoing transfer

You still need to call gw_obex_xfer_free after this to free the actual memory allocated for the GwObexXfer object.

Parameters:
xfer Pointer returned by gw_obex_put_async or gw_obex_get_async
error Place to store error code on failure (NULL if not interested)
Returns:
TRUE on success, FALSE on failure

Definition at line 433 of file obex-xfer.c.

References GW_OBEX_ERROR_ABORT.

Referenced by gw_obex_close(), gw_obex_xfer_abort(), and gw_obex_xfer_free().

                                                         {
    gboolean ret = TRUE;
    struct gw_obex *ctx = xfer->ctx;

    /* If previous close() failed, just signal success so caller can continue */
    if (!ctx)
        return TRUE;

    GW_OBEX_LOCK(ctx);

    xfer->close = TRUE;

    if (ctx->obex_op == OBEX_CMD_GET && !ctx->done)
        gw_obex_xfer_do_abort(xfer);

    if (ctx->obex_op == OBEX_CMD_PUT) {
        if (xfer->object) {
            if (OBEX_Request(ctx->handle, xfer->object) < 0) {
                debug("OBEX_Request() failed\n");
                ctx->done = TRUE;
            }
            xfer->object = NULL;
        }
        else {
            debug("OBEX_ResumeRequest at %s:%d (%s)\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
            OBEX_ResumeRequest(ctx->handle);
        }
    }

    while (!ctx->done) {
        if (!handle_input(ctx, err)) {
            ret = FALSE;
            break;
        }
    }

    /* Check for error but ignore ERROR_ABORT since we can still do a proper
     * xfer_close() in that case */
    if (gw_obex_set_error(ctx) && ctx->error != GW_OBEX_ERROR_ABORT) {
        gw_obex_get_error(ctx, err);
        ret = FALSE;
    }

    /* Remove the idle function related to this transfer (if there is one) */
    if (xfer->idle_source) {
        g_source_destroy(xfer->idle_source);
        xfer->idle_source = NULL;
    }

    /* Disassociate from the GwObex object */
    ctx->xfer = NULL;
    xfer->ctx = NULL;

    GW_OBEX_UNLOCK(ctx);

    return ret;
}


Generated by  Doxygen 1.6.0   Back to index