application/upload.h

Wed, 27 Nov 2024 17:14:57 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 27 Nov 2024 17:14:57 +0100
changeset 94
7fdf1489b82f
parent 87
5360027fb282
child 95
e92c72705da4
permissions
-rw-r--r--

move app settings to separate source file

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2024 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef UPLOAD_H
#define UPLOAD_H

#include "application.h"
#include "davcontroller.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct DavFileUpload {
    DavBrowser *browser;
    DavSession *sn;
    UiFileList files;
    char *base_path;
    UiThreadpool *queue;

    TransferProgress progress;
    DavBool upload_file;

    char *current_file_name;

    UiObject *dialog;
    UiDouble *progressbar;
    UiString *label_top_left;
    UiString *label_top_right;
    UiString *label_bottom_left;
    UiString *label_bottom_right;

    // The collection, the files are uploaded to
    // It is only safe to access the collection ptr, if
    // collection == browser->current && collection_ctn == browser->res_counter
    // and obviously it can only be accessed from the UI thread
    DavResource *collection;

    // copy of browser->res_counter, used for integrity check
    int64_t collection_ctn;

    // current uploaded resource, created as part of the browser session
    // only if collection == browser->current && collection_ctn == browser->res_counter
    DavResource *current_resource;
    
    DavBool cancel;
} DavFileUpload;

typedef struct DUFile {
    FILE *fd;
    char *path;
    char *upload_path;
    size_t bytes;
    DavBool isdirectory;
    DavFileUpload *upload;
    DavError error;
} DUFile;

DavFileUpload* dav_upload_create(DavBrowser *browser, UiObject *obj, UiFileList files);

void dav_upload_start(DavFileUpload *upload);

void action_upload_cancel(UiEvent *event, void *data);

#ifdef __cplusplus
}
#endif

#endif /* UPLOAD_H */

mercurial