/* provide.h: provide status infos. Copyright (C) 2009 AVM This file is part of davfs2. davfs2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. davfs2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with davfs2; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DAV_PROVIDE_H #define DAV_PROVIDE_H #include /* Provided info types. */ #define DIRTY_FILES 1 #define RUNNING_UPLOADS 2 #define RUNNING_DOWNLOADS 3 #define FINISHED_UPLOADS 4 #define FAILED_UPLOADS 5 #define FINISHED_DOWNLOADS 6 #define FAILED_DOWNLOADS 7 #define AVG_UPLOAD_SPEED 8 #define AVG_DOWNLOAD_SPEED 9 #define SIZE_UPLOADS 10 #define SIZE_DOWNLOADS 11 #define UPLOAD_FILES 12 #define DOWNLOAD_FILES 13 #define CONNECTION_STATE 14 #define CACHE_SPEED 15 #define CACHE_STORAGE_AVAIL 16 #define CACHE_STORAGE_USED 17 #define SUM_FAILED_UPLOADS 18 /* Quota infos, retrieved from connected webdav servers. * Some values are only provided by servers of UI. */ typedef struct { uint64_t storage_available; /* Available bytes. */ uint64_t storage_used; /* Used bytes. */ uint32_t storage_filecount; /* Number files in online storage */ uint64_t upload_avail; /* traffic quotas, special infos provided by UI */ uint64_t upload_used; uint64_t download_avail; uint64_t download_used; uint64_t traffic_avail; uint64_t traffic_used; uint64_t max_filesize; uint32_t max_filecount; uint32_t max_filesperfolder; uint32_t max_filenamelength; time_t update_time; /* timestamp of the last PROPFIND/USERINFO call */ int update_ret; /* return value of the last PROPFIND/USERINFO call */ } quota_context; enum { TRANSFER_UPLOAD = 1, TRANSFER_DOWNLOAD }; /* Create shared memory to provide status infos to other processes. * The infos includes the count of dirty file, average download speed .. * debug : Debug-Flag. * return value : 0 on success; -1 if an error occurred. */ int provide_init(int debug); /* Destroy shared memory if the client will be stopped.*/ void provide_destroy(void); /* Set new values of the storage and traffic quota, provided by the connected webdav server. * value : quota infos, determined with PROPFIND or USERINFO. */ void provide_set_quota(quota_context value); /* Get values of the storage and traffic quota, stored in shared mem. * value : pointer to allocated quota_context struct */ void provide_get_quota(quota_context *quotas); /* Set new uint values. * type : The type of the value, e.g. "count of dirty files". * value : The new value for the shared memory. * op : Integer-Operation for the given and stored value, e.g. "+". */ void provide_set_uint(int type, unsigned int value, const char op); /* Set new uint64 values. * type : The type of the value, e.g. "count of dirty files". * value : The new value for the shared memory. * op : Integer-Operation for the given and stored value, e.g. "+". */ void provide_set_uint64(int type, uint64_t value, const char op); /* Set new string values for uploading/downloading files. * type : The type of the values, e.g. "name of currently uploading files ". * file1 : Filename for the shared memory. * file2 : Filename for the shared memory. */ void provide_set_files(int type, const char* file1, const char* file2); void provide_set_string(int type, const char* value); void provide_set_transfer_speed(int type, uint64_t bytes, uint64_t duration); /* Print all current infos of the shared memory. */ void provide_print(void); /* Update average upload and download speed of the last five minutes. */ void provide_update_avg_speed(void); /* Clear filecounter, including finished and failed downloads, filenames and * up/download speeds, if a new transfer session is started with FTP or Samba. */ void provide_clear_transfervalues(void); void provide_update_alivetime(void); /** * Read values from USB configuration. * * @param debug_val enable/disable debug output * @param [in,out] args configuration values * * @retval 0 on success * @retval -1 on failure */ int provide_get_usb_cfg_infos(int debug_val, dav_args *args); /** * AVM provide_system_no_sh * Execute a programm with the given parameters. * Safer replacement of system() without a shell. * * @param prg programm to execute * @param para1 parameter for the programm, set NULL if not used * @param para2 parameter for the programm, set NULL if not used * @param para3 parameter for the programm, set NULL if not used * * @retval 0 success * @retval >0 child/execvp returned with an error (child exit with 1) * @retval -1 failure * - if prg is NULL or empty * - on fork() failure * - waitpid() failed * @retval -2 child/prg was killed by a signal * @retval -3 child/prg was stopped by a signal (should not happen) * @retval -4 child/prg was continued by a signal (should not happen) */ int provide_system_no_sh(const char *prg, const char * para1, const char * para2, const char * para3); #endif /* DAV_PROVIDE_H */