Skip to content

Commit

Permalink
download library not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Nov 19, 2024
1 parent 9145c22 commit ea362ff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
Binary file modified amprack.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions presets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void load_preset_cb (void * c, void * d) {
void download_cb (void * w, void * d) {
///> TODO:
// clear box before refresh
IN
Presets * presets = (Presets *) d ;
gtk_spinner_start (presets->library_spinner);
std::string lJson = std::string (presets->dir).append ("/").append ("library.json") ;
Expand All @@ -32,6 +33,7 @@ void download_cb (void * w, void * d) {
presets->library_json = filename_to_json (std::string (presets->dir).append("/library.json"));
gtk_adjustment_set_upper (presets->adj, presets->library_json.size() / presets->page_size);
presets->library_load ();
OUT
}

void presets_on_response (GtkNativeDialog *native,
Expand Down
Binary file modified presets.o
Binary file not shown.
Binary file modified sync.o
Binary file not shown.
22 changes: 17 additions & 5 deletions util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void msg (std::string message) {
}

bool download_file (char *name, const char * filename) {
IN
LOGD ("[download] %s -> %s\n", name, filename);
GFile *f = g_file_new_for_uri(name);
GFileInputStream *fis = NULL;
GDataInputStream* dis = NULL;
Expand All @@ -109,20 +111,27 @@ bool download_file (char *name, const char * filename) {

/* get input stream */
fis = g_file_read(f, NULL, &err);
LOGV ("file read ok");

if (err != NULL) {
fprintf(stderr, "ERROR: opening %s\n", name);
LOGD("ERROR: opening %s\n", name);
g_object_unref(f);
OUT
return false;
}

info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (fis),G_FILE_ATTRIBUTE_STANDARD_SIZE,NULL, &err);
if (info)
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE))
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) {
total_size = g_file_info_get_size (info);
printf( "total_size = %d\n", total_size);
LOGD( "total_size = %d\n", total_size);
g_object_unref (info);
} else {
LOGV ("no attribute info on file!");
}
} else {
LOGV ("file input query info failed!");
}

// fill buffer
Expand All @@ -133,18 +142,21 @@ bool download_file (char *name, const char * filename) {
int i = 0 ;
while ((length = g_input_stream_read (G_INPUT_STREAM(fis),
buffer, total_size, NULL, &err)) != -1 && i < total_size) {
//~ printf( "%s\n", buffer);
LOGD( "%s\n", buffer);
fwrite (buffer, length, 1, fd);
//~ printf ("%d/%d\n", i, total_size);
LOGD ("%d/%d\n", i, total_size);
i += length ;
}

fclose (fd);
ret = true;
} else {
LOGV ("error: total size < 0");
}
// close streams
g_object_unref(fis);
g_object_unref(f);
OUT
return ret;
}

Expand Down
Binary file modified util.o
Binary file not shown.
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION 159
#define VERSION 161

0 comments on commit ea362ff

Please sign in to comment.