GObexPacket *req, *rsp;
GError *err = NULL;
gssize ret;
+ guint8 op;
g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id);
return ret;
}
- req = g_obex_packet_new(G_OBEX_RSP_INTERNAL_SERVER_ERROR, TRUE,
- G_OBEX_HDR_INVALID);
+ op = g_obex_errno_to_rsp(ret);
+
+ req = g_obex_packet_new(op, TRUE, G_OBEX_HDR_INVALID);
g_obex_send(transfer->obex, req, NULL);
err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
return g_obex_send_req(obex, req, -1, func, user_data, err);
}
+
+guint8 g_obex_errno_to_rsp(int err)
+{
+ switch (err) {
+ case 0:
+ return G_OBEX_RSP_SUCCESS;
+ case -EPERM:
+ case -EACCES:
+ return G_OBEX_RSP_FORBIDDEN;
+ case -ENOENT:
+ return G_OBEX_RSP_NOT_FOUND;
+ case -EBADR:
+ return G_OBEX_RSP_BAD_REQUEST;
+ case -EFAULT:
+ return G_OBEX_RSP_SERVICE_UNAVAILABLE;
+ case -EINVAL:
+ return G_OBEX_RSP_NOT_IMPLEMENTED;
+ case -ENOTEMPTY:
+ case -EEXIST:
+ return G_OBEX_RSP_PRECONDITION_FAILED;
+ default:
+ return G_OBEX_RSP_INTERNAL_SERVER_ERROR;
+ }
+}
gboolean g_obex_cancel_transfer(guint id);
const char *g_obex_strerror(guint8 err_code);
+guint8 g_obex_errno_to_rsp(int err);
#endif /* __GOBEX_H */