예제 #1
0
static void on_uploaded(struct afb_req *prequest, int status)
{
    struct afb_req request = afb_req_unstore(prequest);
    struct afb_arg argfile = afb_req_get(request, "file-upload");
    char *file = renamed_filename(argfile);
    if (file != NULL)
        unlink(file);
    free(file);
    if (status)
        afb_req_fail (request, "failed", "expected file not received");
    else
        afb_req_success_f (request, NULL, "uploaded file %s", argfile.value);
   afb_req_unref(request);
}
예제 #2
0
static void call_appid_callback(int status, struct json_object *obj, struct memo *memo)
{
	if (afb_interface->verbosity)
		fprintf(stderr, "(afm-main-plugin) %s -> %s\n", memo->method, 
			obj ? json_object_to_json_string(obj) : "NULL");
	if (obj == NULL) {
		afb_req_fail(memo->request, "failed", "framework daemon failure");
	} else {
		obj = json_object_get(obj);
		afb_req_success(memo->request, obj, NULL);
	}
	afb_req_unref(memo->request);
	free(memo);
}
예제 #3
0
static void upload (struct afb_req request) { /* AFB_SESSION_CHECK */

    mediaCtxHandleT *ctx = afb_req_context_get(request);
    struct afb_req *prequest;
    struct afb_arg argfile;
    char *path;

    /* check that context is initialized */
    if (ctx == NULL) {
      afb_req_fail (request, "failed", "uninitialized");
      return;
    }

    /* get the file */
    argfile = afb_req_get(request, "file-upload");
    if (!argfile.value || !argfile.path) {
        afb_req_fail (request, "failed", "expected file not received");
        return;
    }

    /* rename the file */
    path = renamed_filename(argfile);
    if (path == NULL) {
        afb_req_fail (request, "failed", "out of memory");
        return;
    }
    if (rename(argfile.path, path) != 0) {
        free(path);
        afb_req_fail (request, "failed", "system error");
        return;
    }

    /* for asynchronous processing */
    prequest = afb_req_store(request);
    if (path == NULL) {
        unlink(path);
        afb_req_fail (request, "failed", "out of memory");
    }
    else if (!_rygel_upload (ctx, path, (void*)on_uploaded, prequest)) {
        afb_req_unref(afb_req_unstore(prequest));
        unlink(path);
        afb_req_fail (request, "failed", "Error when uploading file to media server... could not complete");
    }
    free(path);
}
예제 #4
0
/* free and release the memorizing data */
static void api_dbus_client_free_memo(struct dbus_memo *memo)
{
	afb_req_unref(memo->req);
	free(memo);
}