mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-28 16:26:21 +00:00
Don't expose upload_processes
That's actually not good practise. Realized this when checking for multiple symbol definition in issue mentioned below. Regards https://github.com/profanity-im/profanity/issues/1314
This commit is contained in:
@@ -65,6 +65,7 @@ struct curl_data_t {
|
|||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GSList *upload_processes = NULL;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
_xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||||
@@ -332,3 +333,23 @@ off_t file_size(const char* const filename)
|
|||||||
stat(filename, &st);
|
stat(filename, &st);
|
||||||
return st.st_size;
|
return st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
http_upload_cancel_processes(ProfWin *window)
|
||||||
|
{
|
||||||
|
GSList *upload_process = upload_processes;
|
||||||
|
while (upload_process) {
|
||||||
|
HTTPUpload *upload = upload_process->data;
|
||||||
|
if (upload->window == window) {
|
||||||
|
upload->cancel = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
upload_process = g_slist_next(upload_process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
http_upload_add_upload(HTTPUpload *upload)
|
||||||
|
{
|
||||||
|
upload_processes = g_slist_append(upload_processes, upload);
|
||||||
|
}
|
||||||
|
|||||||
@@ -57,11 +57,12 @@ typedef struct http_upload_t {
|
|||||||
int cancel;
|
int cancel;
|
||||||
} HTTPUpload;
|
} HTTPUpload;
|
||||||
|
|
||||||
GSList *upload_processes;
|
|
||||||
|
|
||||||
void* http_file_put(void *userdata);
|
void* http_file_put(void *userdata);
|
||||||
|
|
||||||
char* file_mime_type(const char* const file_name);
|
char* file_mime_type(const char* const file_name);
|
||||||
off_t file_size(const char* const file_name);
|
off_t file_size(const char* const file_name);
|
||||||
|
|
||||||
|
void http_upload_cancel_processes(ProfWin *window);
|
||||||
|
void http_upload_add_upload(HTTPUpload *upload);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include "ui/window_list.h"
|
#include "ui/window_list.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
#include "xmpp/roster_list.h"
|
#include "xmpp/roster_list.h"
|
||||||
|
#include "tools/http_upload.h"
|
||||||
|
|
||||||
static GHashTable *windows;
|
static GHashTable *windows;
|
||||||
static int current;
|
static int current;
|
||||||
@@ -519,15 +520,7 @@ wins_close_by_num(int i)
|
|||||||
ProfWin *window = wins_get_by_num(i);
|
ProfWin *window = wins_get_by_num(i);
|
||||||
if (window) {
|
if (window) {
|
||||||
// cancel upload proccesses of this window
|
// cancel upload proccesses of this window
|
||||||
GSList *upload_process = upload_processes;
|
http_upload_cancel_processes(window);
|
||||||
while (upload_process) {
|
|
||||||
HTTPUpload *upload = upload_process->data;
|
|
||||||
if (upload->window == window) {
|
|
||||||
upload->cancel = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
upload_process = g_slist_next(upload_process);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (window->type) {
|
switch (window->type) {
|
||||||
case WIN_CHAT:
|
case WIN_CHAT:
|
||||||
|
|||||||
@@ -2402,7 +2402,7 @@ _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userda
|
|||||||
if (get_url) xmpp_free(ctx, get_url);
|
if (get_url) xmpp_free(ctx, get_url);
|
||||||
|
|
||||||
pthread_create(&(upload->worker), NULL, &http_file_put, upload);
|
pthread_create(&(upload->worker), NULL, &http_file_put, upload);
|
||||||
upload_processes = g_slist_append(upload_processes, upload);
|
http_upload_add_upload(upload);
|
||||||
} else {
|
} else {
|
||||||
log_error("Invalid XML in HTTP Upload slot");
|
log_error("Invalid XML in HTTP Upload slot");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user