diff options
author | hwspeedy <ns@bigbear.dk> | 2024-03-20 23:04:06 +0100 |
---|---|---|
committer | hwspeedy <ns@bigbear.dk> | 2024-03-20 23:04:06 +0100 |
commit | a966befe362cd5ae11ba43b4c284a6222d5998b8 (patch) | |
tree | eed5c93fb2b4b03f4503fc247f29d9ab7e63affe | |
parent | f7534df1cdb6282cedf5a0c69b9cccda1213645d (diff) |
FIX CLI updated with synchronize features, fix stop benchmark crash, libsoup3 debug fixed+added sync. comm for cli, DOCs updated, LibSoup3 enabled for distros supporting LS3
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | hardinfo2.1 | 30 | ||||
-rw-r--r-- | hardinfo2/hardinfo.c | 18 | ||||
-rw-r--r-- | hardinfo2/util.c | 4 | ||||
-rw-r--r-- | includes/syncmanager.h | 2 | ||||
-rw-r--r-- | modules/benchmark.c | 17 | ||||
-rw-r--r-- | shell/shell.c | 8 | ||||
-rw-r--r-- | shell/syncmanager.c | 182 |
9 files changed, 213 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f4756748..f243d31a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(hardinfo2) set(HARDINFO2_VERSION "2.0.16") option(HARDINFO2_GTK3 "Build for GTK3 (0/off for GTK2)" 1) -option(HARDINFO2_LIBSOUP3 "Build for libsoup-3.0 (0/off for libsoup-2.4)" 0) +option(HARDINFO2_LIBSOUP3 "Build for libsoup-3.0 (0/off for libsoup-2.4)" 1) SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(GNUInstallDirs) @@ -286,7 +286,7 @@ set(MODULE_network_SOURCES modules/network/nfs.c modules/network/samba.c ) -set(MODULE_benchmark_SOURCES_GTKANY +set(MODULE_benchmark_SOURCES modules/benchmark.c modules/benchmark/bench_util.c modules/benchmark/blowfish.c @@ -303,16 +303,9 @@ set(MODULE_benchmark_SOURCES_GTKANY modules/benchmark/zlib.c modules/benchmark/sysbench.c modules/benchmark/iperf3.c -) -set(MODULE_benchmark_SOURCES_GTK2 modules/benchmark/drawing.c modules/benchmark/guibench.c ) -if (HARDINFO2_GTK3) - set(MODULE_benchmark_SOURCES ${MODULE_benchmark_SOURCES_GTKANY}) -else() - set(MODULE_benchmark_SOURCES ${MODULE_benchmark_SOURCES_GTKANY} ${MODULE_benchmark_SOURCES_GTK2}) -endif() set_source_files_properties( modules/benchmark/blowfish.c @@ -19,7 +19,7 @@ Status ------ - Capabilities: Hardinfo2 currently detects most software and hardware detected by the OS. - Features: Online database for exchanging benchmark results. -- Development: Currently done by contributors, hwspeedy maintains +- Development: Currently done by community, hwspeedy maintains Server code can be found here: [https://github.com/hardinfo2/server](https://github.com/hardinfo2/server) @@ -29,13 +29,14 @@ Dependencies - GLib >=2.24 - Zlib - glib JSON -- Libsoup2.4 >=2.42 or Libsoup-3.0 (EXPERIMENTAL) (LS3: cmake -DHARDINFO2_LIBSOUP3=1 ..) +- Libsoup3 >=3.00 or Libsoup24>=2.42 (LS24: cmake -DHARDINFO2_LIBSOUP3=0 ..) Building and installing ----------------------- **Debian/Ubuntu/Mint/PopOS** -- sudo apt install git cmake build-essential gettext +- sudo apt install git cmake build-essential gettext curl - sudo apt install libjson-glib-dev zlib1g-dev libsoup2.4-dev libgtk-3-dev libglib2.0-dev +- sudo apt install libsoup-3.0-dev (might fail if not available on distro - OK) - git clone https://github.com/hardinfo2/hardinfo2 - cd hardinfo2 - ./tools/git_latest_release.sh (Switch to latest stable release, tools/git_unstable_master.sh for developers) @@ -50,8 +51,9 @@ Building and installing **Fedore/Centos/RedHat/Rocky/Alma/Oracle** * NOTE: Centos 7 needs epel-release and cmake3 instead of cmake - use cmake3 instead of cmake - sudo yum install epel-release (only CentOS 7) -- sudo yum install git cmake gcc gcc-c++ gettext rpmdevtools +- sudo yum install git cmake gcc gcc-c++ gettext rpmdevtools curl - sudo yum install json-glib-devel zlib-devel libsoup-devel gtk3-devel +- sudo yum install libsoup3-devel (might fail if not available on distro - OK) - git clone https://github.com/hardinfo2/hardinfo2 - cd hardinfo2 - ./tools/git_latest_release.sh (Switch to latest stable release, tools/git_unstable_master.sh for developers) @@ -63,10 +65,10 @@ Building and installing - sudo yum install lm_sensors sysbench lsscsi glx-utils dmidecode udisks2 xdg-utils iperf3 - hardinfo2 -**openSUSE**: use zypper instead of yum, use libsoup2-devel instead of libsoup-devel +**openSUSE**: use zypper instead of yum, zypper --no-gpg-checks install ./hardinfo2-* **ArchLinux/Garuda/Manjaro - AUR Package** - - git clone https://aur.archlinux.org/hardinfo2.git (hardinfo2-git.git for unstable master only developers) + - git clone https://aur.archlinux.org/hardinfo2 (hardinfo2-git for unstable master for developers) - cd hardinfo2 - makepkg -cis - hardinfo2 @@ -94,7 +96,7 @@ License ------ The Project License has been changed in 2024 from GPL2 to **GPL2 or later** -Because we use LGPL2.1+ and GPL3 code. To future proof the project, lpereira and other developers have agreed to change license of source code also to GPL2+. (https://github.com/lpereira/hardinfo/issues/530) (https://github.com/lpereira/hardinfo/issues/707). +Because we use LGPL2.1+ and GPL3+ code. To future proof the project, lpereira and other developers have agreed to change license of source code also to GPL2+. (https://github.com/lpereira/hardinfo/issues/530) (https://github.com/lpereira/hardinfo/issues/707). It is all about open source and creating together - Read more about GPL license here: https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility diff --git a/hardinfo2.1 b/hardinfo2.1 index e1125e62..094318d4 100644 --- a/hardinfo2.1 +++ b/hardinfo2.1 @@ -1,6 +1,6 @@ .\" Manpage for hardinfo. .\" https://github.com/hwspeedy/hardinfo2/. -.TH HARDINFO "1" "January 2024" "2.0" "User Commands" +.TH HARDINFO "1" "Marts 2024" "2.0" "User Commands" .SH NAME \fBHardinfo2\fR \- System Information and Benchmark for Linux Systems. .SH USAGE @@ -20,11 +20,35 @@ creates a report and prints to standard output \fB\-f\fR, \fB\-\-report\-format\fR chooses a report format (text, html) .TP +\fB\-g\fR, \fB\-\-result\-format\fR +chooses a result format (short, conf, shell) +.TP \fB\-b\fR, \fB\-\-run\-benchmark\fR -run benchmark +run a specific benchmark eg. -b 'FPU FFT' (Default all benchmarks runs when generate report) +.TP +\fB\-s\fR, \fB\-\-skip\-benchmark\fR +Disables all benchmark runs. +.TP +\fB\-u\fR, \fB\-\-user\-note\fR +adds a user note to data send to server. When added eg. -u 1 synchronization is activated. .TP \fB\-v\fR, \fB\-\-version\fR shows program version and quit +.SH EXAMPLES +examples of CLI command usage:\fR +.TP +hardinfo2 -b 'FPU FFT' +runs only FPU FFT benchmark +.TP +hardinfo2 -u 1 +enable updates at startup and starts gui (can also be set in gui) +.TP +hardinfo2 -u SBC-DK -r +updates data from server, generate CLI report and sends benchmark with user-note +.TP +hardinfo2 -r +generates CLI report + .SH COPYRIGHT -\fBHardinfo2\fR its Copyright \(co 2003-2023 L. A. F. Pereira, 2024- Hardinfo2 Project\fR. +\fBHardinfo2\fR is Copyright \(co 2003-2023 L. A. F. Pereira, 2024- Hardinfo2 Project\fR. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 1cf6603a..218b4298 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -59,16 +59,17 @@ int main(int argc, char **argv) g_print(_("Compile-time options:\n" " Release version: %s (%s)\n" + " LibSoup version: %s\n" " BinReloc enabled: %s\n" " Data prefix: %s\n" " Library prefix: %s\n" " Compiled for: %s\n"), - RELEASE ? _("Yes") : "No (" VERSION ")", ARCH, + RELEASE==1 ? "Yes (" VERSION ")" : (RELEASE==0?"No (" VERSION ")":"Debug (" VERSION ")"), ARCH, + HARDINFO2_LIBSOUP3 ? _("3.0") : "2.4", ENABLE_BINRELOC ? _("Yes") : _("No"), PREFIX, LIBPREFIX, PLATFORM); - DEBUG(" Debugging is enabled."); - + return 0; } /* initialize the binreloc library, so we can load program data */ @@ -107,7 +108,7 @@ int main(int argc, char **argv) result = module_call_method_param("benchmark::runBenchmark", params.run_benchmark); if (!result) { - fprintf(stderr, _("Unknown benchmark ``%s''"), params.run_benchmark); + fprintf(stderr, _("Unknown benchmark ``%s''\n"), params.run_benchmark); exit_code = 1; } else { fprintf(stderr, "\n"); @@ -128,6 +129,10 @@ int main(int argc, char **argv) /* generate report */ gchar *report; + if(params.bench_user_note) {//synchronize without sending benchmarks + sync_manager_update_on_startup(0); + } + DEBUG("generating report"); report = report_create_from_module_list_format(modules, @@ -135,6 +140,11 @@ int main(int argc, char **argv) report_format); g_print("%s", report); + if(params.bench_user_note) {//synchronize + if(!params.skip_benchmarks) + sync_manager_update_on_startup(1); + } + g_free(report); } else { g_error(_("Don't know what to do. Exiting.")); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 86f2a4d2..516ddb0c 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -416,13 +416,13 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) .short_name = 'b', .arg = G_OPTION_ARG_STRING, .arg_data = &run_benchmark, - .description = N_("run benchmark eg. -b 'FPU FFT'")}, + .description = N_("run single benchmark eg. -b 'FPU FFT' (Default all Benchmarks runs)")}, { .long_name = "user-note", .short_name = 'u', .arg = G_OPTION_ARG_STRING, .arg_data = &bench_user_note, - .description = N_("note attached to benchmark results")}, + .description = N_("user note attached to benchmark results. (updating/synchronize with server)")}, { .long_name = "result-format", .short_name = 'g', diff --git a/includes/syncmanager.h b/includes/syncmanager.h index c17601da..a385dea0 100644 --- a/includes/syncmanager.h +++ b/includes/syncmanager.h @@ -38,6 +38,6 @@ void sync_manager_clear_entries(void); void sync_manager_show(GtkWidget *parent); gint sync_manager_count_entries(void); -void sync_manager_update_on_startup(void); +void sync_manager_update_on_startup(int send_benchmark); #endif /* __SYNCMANAGER_H__ */ diff --git a/modules/benchmark.c b/modules/benchmark.c index 743441a5..d4a39677 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -603,6 +603,7 @@ do_benchmark_handler(GIOChannel *source, GIOCondition condition, gpointer data) GIOStatus status; gchar *result; bench_value r = EMPTY_BENCH_VALUE; + status = g_io_channel_read_line(source, &result, NULL, NULL, NULL); if (status != G_IO_STATUS_NORMAL) { DEBUG("error while reading benchmark result"); @@ -657,8 +658,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) bench_dialog = gtk_dialog_new_with_buttons ("Benchmarking...", GTK_WINDOW(shell_get_main_shell()->transient_dialog), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - "Stop", - GTK_BUTTONS_CLOSE, + _("Stop"), GTK_RESPONSE_ACCEPT, NULL); gtk_widget_set_sensitive(GTK_WIDGET(shell_get_main_shell()->transient_dialog), FALSE); @@ -670,8 +670,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) #else box = gtk_hbox_new(FALSE, 1); #endif - label = gtk_label_new ("Please do not move your mouse\n" - "or press any keys."); + label = gtk_label_new ("Please do not move your mouse\nor press any keys."); gtk_widget_show (bench_image); @@ -681,11 +680,6 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) gtk_misc_set_alignment(GTK_MISC(bench_image), 0.0, 0.0); #endif - g_signal_connect_swapped (bench_dialog, - "response", - G_CALLBACK (gtk_widget_destroy), - bench_dialog); - gtk_box_pack_start (GTK_BOX(box), bench_image, TRUE, TRUE, 10); gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 10); gtk_container_add (GTK_CONTAINER(content_area), box); @@ -720,16 +714,15 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) switch (gtk_dialog_run(GTK_DIALOG(bench_dialog))) { case GTK_RESPONSE_NONE: DEBUG("benchmark finished"); + bench_results[entry] = benchmark_dialog->r; break; case GTK_RESPONSE_ACCEPT: DEBUG("cancelling benchmark"); - gtk_widget_destroy(bench_dialog); g_source_remove(watch_id); kill(bench_pid, SIGINT); } - bench_results[entry] = benchmark_dialog->r; g_io_channel_unref(channel); shell_view_set_enabled(TRUE); @@ -868,7 +861,7 @@ static gchar *run_benchmark(gchar *name) { int i; - DEBUG("name = %s", name); + DEBUG("run_benchmark = %s", name); for (i = 0; entries[i].name; i++) { if (g_str_equal(entries[i].name, name)) { diff --git a/shell/shell.c b/shell/shell.c index e3f64891..31434c43 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -334,6 +334,7 @@ void shell_do_reload(void) void shell_status_update(const gchar * message) { + DEBUG("Shell_status_update %s",message); if (params.gui_running) { gtk_label_set_markup(GTK_LABEL(shell->status), message); gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); @@ -684,8 +685,9 @@ check_for_updates(void) g_free(conf_path); g_key_file_free(key_file); - if (setting) { - sync_manager_update_on_startup(); + //fetching data -u is used + if (setting || params.bench_user_note) { + sync_manager_update_on_startup(0); } } @@ -1737,6 +1739,7 @@ module_selected_show_info(ShellModuleEntry *entry, gboolean reload) shell_set_note_from_entry(entry); gdk_window_thaw_updates(gdk_window); + } static void info_selected_show_extra(const gchar *tag) @@ -2021,7 +2024,6 @@ static void module_selected(gpointer data) shell_show_detail_view(); } } - current = entry; updating = FALSE; } diff --git a/shell/syncmanager.c b/shell/syncmanager.c index ad2c119a..1558bea5 100644 --- a/shell/syncmanager.c +++ b/shell/syncmanager.c @@ -181,7 +181,20 @@ static SyncNetAction *sync_manager_get_selected_actions(gint *n) return actions; } -#if !SOUP_CHECK_VERSION(3,0,0) +#if SOUP_CHECK_VERSION(3,0,0) +static const char *sync_manager_get_proxy(void) +{ + const gchar *conf; + + if (!(conf = g_getenv("HTTP_PROXY"))) { + if (!(conf = g_getenv("http_proxy"))) { + return NULL; + } + } + + return conf; +} +#else static SoupURI *sync_manager_get_proxy(void) { const gchar *conf; @@ -194,17 +207,18 @@ static SoupURI *sync_manager_get_proxy(void) return soup_uri_new(conf); } + #endif static void ensure_soup_session(void) { if (!session) { #if SOUP_CHECK_VERSION(3,0,0) - session = soup_session_new_with_options("timeout", 10, NULL); + const char *proxy=sync_manager_get_proxy(); + session = soup_session_new_with_options("timeout", 10,"proxy-resolver", proxy, NULL); #else #if SOUP_CHECK_VERSION(2,42,0) SoupURI *proxy = sync_manager_get_proxy(); - session = soup_session_new_with_options( SOUP_SESSION_TIMEOUT, 10, SOUP_SESSION_PROXY_URI, proxy, NULL); #else @@ -233,7 +247,7 @@ static void sync_dialog_start_sync(SyncDialog *sd) fd = open(path,O_RDONLY); } if(fd>=0){ - read(fd,buf,100); + int c=read(fd,buf,100); sscanf(buf,"{\"update-version\":\"%u\",",&our_blobs_update_version); close(fd); } @@ -265,6 +279,53 @@ static void sync_dialog_start_sync(SyncDialog *sd) g_main_loop_unref(loop); } + +static void got_msg(const guint8 *buf,int len, gpointer user_data) +{ + SyncNetAction *sna = user_data; + GInputStream *is; + gchar *path; + int fd,updateversion=0; + gchar buffer[101]; + gsize datawritten; + + if (sna->entry->file_name != NULL) { + //check for missing config dirs + g_mkdir(g_get_user_config_dir(), 0766); + g_mkdir(g_build_filename(g_get_user_config_dir(),"hardinfo2",NULL), 0766); + if(strncmp(sna->entry->file_name,"blobs-update-version.json",25)==0){ + updateversion=1; + } + path = g_build_filename(g_get_user_config_dir(), "hardinfo2", + sna->entry->file_name, NULL); + GFile *file = g_file_new_for_path(path); + GFileOutputStream *output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, + NULL, &sna->error); + + if(buf){ + DEBUG("got file with len: %u", (unsigned int)len); + if(len>0){ + g_output_stream_write_all(G_OUTPUT_STREAM(output),buf,len,&datawritten,NULL,&sna->error); + } + } + + if(updateversion){ + fd = open(path,O_RDONLY); + if(fd){ + int c=read(fd,buffer,100); + sscanf(buffer,"{\"update-version\":\"%u\",",&server_blobs_update_version); + DEBUG("SERVER_BLOBS_UPDATE_VERSION=%u",server_blobs_update_version); + close(fd); + } + } + + g_free(path); + g_object_unref(file); + } + +} + + #if SOUP_CHECK_VERSION(2,42,0) static void got_response(GObject *source, GAsyncResult *res, gpointer user_data) #else @@ -301,9 +362,8 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da path = g_build_filename(g_get_user_config_dir(), "hardinfo2", sna->entry->file_name, NULL); GFile *file = g_file_new_for_path(path); - GFileOutputStream *output = - g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, - NULL, &sna->error); + GFileOutputStream *output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, + NULL, &sna->error); if (output != NULL) { #if SOUP_CHECK_VERSION(2,42,0) @@ -317,7 +377,7 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da DEBUG("got file with len: %u", (unsigned int)len); if(len>0){ g_output_stream_write_all(G_OUTPUT_STREAM(output),buf,len,&datawritten,NULL,&sna->error); - soup_buffer_free(soupmsg); + soup_buffer_free(soupmsg); } } #endif @@ -326,7 +386,7 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da if(updateversion){ fd = open(path,O_RDONLY); if(fd){ - read(fd,buffer,100); + int c=read(fd,buffer,100); sscanf(buffer,"{\"update-version\":\"%u\",",&server_blobs_update_version); DEBUG("SERVER_BLOBS_UPDATE_VERSION=%u",server_blobs_update_version); close(fd); @@ -349,40 +409,79 @@ static gboolean send_request_for_net_action(SyncNetAction *sna) gchar *uri; SoupMessage *msg; guint response_code; + const guint8 *buf=NULL; + gsize len; + gchar *contents=NULL; + gsize size; +#if !SOUP_CHECK_VERSION(3, 0, 0) + SoupBuffer *soupmsg=NULL; +#endif if(!sna->entry->optional || (our_blobs_update_version<server_blobs_update_version)){ if(strncmp(sna->entry->file_name,"blobs-update-version.json",25)==0){ - uri = g_strdup_printf("%s/%s?ver=%s&blobver=%d", API_SERVER_URI, sna->entry->file_name,VERSION,our_blobs_update_version); - }else{ + uri = g_strdup_printf("%s/%s?ver=%s&blobver=%d&rel=%d", API_SERVER_URI, sna->entry->file_name,VERSION,our_blobs_update_version,RELEASE); + } else if(strncmp(sna->entry->file_name,"benchmark.json",14)==0){ + if (sna->entry->generate_contents_for_upload == NULL) {//GET/Fetch + if(params.bench_user_note){ + uri = g_strdup_printf("%s/%s?ver=%s&L=%d&rel=%d&MT=%s&BUN=%s", API_SERVER_URI, + sna->entry->file_name, VERSION, + params.max_bench_results,RELEASE, + module_call_method("computer::getMachineType"), + params.bench_user_note); + } else { + uri = g_strdup_printf("%s/%s?ver=%s&L=%d&rel=%d&&MT=%s", API_SERVER_URI, + sna->entry->file_name, VERSION, + params.max_bench_results, RELEASE, + module_call_method("computer::getMachineType")); + } + } else {//POST/Send + uri = g_strdup_printf("%s/%s?ver=%s&rel=%d", API_SERVER_URI, + sna->entry->file_name, VERSION, RELEASE); + } + } else { uri = g_strdup_printf("%s/%s", API_SERVER_URI, sna->entry->file_name); } if (sna->entry->generate_contents_for_upload == NULL) { msg = soup_message_new("GET", uri); } else { - gsize size; - gchar *contents = sna->entry->generate_contents_for_upload(&size); + contents = sna->entry->generate_contents_for_upload(&size); msg = soup_message_new("POST", uri); #if SOUP_CHECK_VERSION(3, 0, 0) - GBytes *cont = g_bytes_new_static(contents,size); - soup_message_set_request_body_from_bytes(msg, "application/octet-stream", cont); + soup_message_set_request_body_from_bytes(msg, "application/octet-stream", g_bytes_new_static(contents,size)); #else soup_message_set_request(msg, "application/octet-stream", SOUP_MEMORY_TAKE, contents, size); #endif } - + if(params.gui_running){ #if SOUP_CHECK_VERSION(3, 0, 0) - soup_session_send_async(session, msg, G_PRIORITY_DEFAULT, NULL, got_response, sna); + soup_session_send_async(session, msg, G_PRIORITY_DEFAULT, NULL, got_response, sna); #else #if SOUP_CHECK_VERSION(2,42,0) - soup_session_send_async(session, msg, NULL, got_response, sna); + soup_session_send_async(session, msg, NULL, got_response, sna); #else - soup_session_queue_message(session, msg, got_response, sna); + soup_session_queue_message(session, msg, got_response, sna); #endif #endif - g_main_loop_run(loop); + + } else {//Blocking/Sync sending when no gui + +#if SOUP_CHECK_VERSION(3, 0, 0) + buf=g_bytes_unref_to_data(soup_session_send_and_read(session, msg, NULL, NULL), &len); + got_msg(buf,len,sna); +#else + soup_session_send_message(session, msg); + soupmsg=soup_message_body_flatten(msg->response_body); + if(soupmsg){ + soup_buffer_get_data(soupmsg,&buf,&len); + got_msg(buf,len,sna); + } +#endif + } + if(params.gui_running) + g_main_loop_run(loop); g_object_unref(msg); g_free(uri); @@ -725,17 +824,19 @@ static void sync_dialog_destroy(SyncDialog *sd) static gboolean sync_one(gpointer data) { SyncNetAction *sna = data; - - if (sna->entry->generate_contents_for_upload) - goto out; - + if (sna->entry->generate_contents_for_upload){ + if(params.gui_running){ + goto out; + } + } DEBUG("Syncronizing: %s", sna->entry->name); - gchar *msg = g_strdup_printf(_("Synchronizing: %s"), _(sna->entry->name)); - shell_status_update(msg); - shell_status_pulse(); - g_free(msg); - + if(params.gui_running){ + gchar *msg = g_strdup_printf(_("Synchronizing: %s"), _(sna->entry->name)); + shell_status_update(msg); + shell_status_pulse(); + g_free(msg); + } send_request_for_net_action(sna); out: @@ -744,7 +845,7 @@ out: return FALSE; } -void sync_manager_update_on_startup(void) +void sync_manager_update_on_startup(int send_benchmark)//0:normal only get, 1:send benchmark { GSList *entry; gchar *path; @@ -759,7 +860,7 @@ void sync_manager_update_on_startup(void) fd = open(path,O_RDONLY); } if(fd>=0){ - read(fd,buf,100); + int c=read(fd,buf,100); sscanf(buf,"{\"update-version\":\"%u\",",&our_blobs_update_version); close(fd); } @@ -770,12 +871,25 @@ void sync_manager_update_on_startup(void) loop = g_main_loop_new(NULL, FALSE); + if(!params.gui_running) entries=g_slist_reverse(entries);//wrong direction for sync sending for (entry = entries; entry; entry = entry->next) { SyncNetAction *action = g_new0(SyncNetAction, 1); action->entry = entry->data; - loop = g_main_loop_ref(loop); - - g_idle_add(sync_one, action); + if(params.gui_running){ + loop = g_main_loop_ref(loop); + g_idle_add(sync_one, action); + } else { + //if send benchmark - only send benchmark + //if not send benchmark - sync everything else + if( ((strncmp(action->entry->file_name,"benchmark.json",14)==0) && + (action->entry->generate_contents_for_upload) && send_benchmark) || + ((!(strncmp(action->entry->file_name,"benchmark.json",14)==0) || + (!action->entry->generate_contents_for_upload)) && (!send_benchmark)) ){ + loop = g_main_loop_ref(loop); + sync_one(action); + } + } } + if(!params.gui_running) entries=g_slist_reverse(entries);//wrong direction for sync sending } |