From 4fa6500b5107f9d300a6ab7b6f011fb19621b05c Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 28 Oct 2010 18:09:09 -0400 Subject: STORM-480 remove unused "wrap" parameter from LLDir::getNetFileInDir --HG-- branch : storm-102 --- indra/linux_updater/linux_updater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/linux_updater') diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp index be4d810860..23c34e52e7 100644 --- a/indra/linux_updater/linux_updater.cpp +++ b/indra/linux_updater/linux_updater.cpp @@ -216,7 +216,7 @@ gboolean rotate_image_cb(gpointer data) std::string next_image_filename(std::string& image_path) { std::string image_filename; - gDirUtilp->getNextFileInDir(image_path, "/*.jpg", image_filename, true); + gDirUtilp->getNextFileInDir(image_path, "/*.jpg", image_filename); return image_path + "/" + image_filename; } -- cgit v1.2.3 From 35fc90e8aaebc10a5a01c58247c29c8103220578 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Mon, 15 Nov 2010 14:37:32 -0800 Subject: CHOP-179 Added --file option to linux-updater for local install --- indra/linux_updater/linux_updater.cpp | 149 +++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 67 deletions(-) (limited to 'indra/linux_updater') diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp index be4d810860..16660de6bb 100644 --- a/indra/linux_updater/linux_updater.cpp +++ b/indra/linux_updater/linux_updater.cpp @@ -49,6 +49,7 @@ const guint ROTATE_IMAGE_TIMEOUT = 8000; typedef struct _updater_app_state { std::string app_name; std::string url; + std::string file; std::string image_dir; std::string dest_dir; std::string strings_dirs; @@ -266,85 +267,95 @@ gpointer worker_thread_cb(gpointer data) CURLcode result; FILE *package_file; GError *error = NULL; - char *tmp_filename = NULL; int fd; //g_return_val_if_fail (data != NULL, NULL); app_state = (UpdaterAppState *) data; try { - // create temporary file to store the package. - fd = g_file_open_tmp - ("secondlife-update-XXXXXX", &tmp_filename, &error); - if (error != NULL) - { - llerrs << "Unable to create temporary file: " - << error->message - << llendl; - g_error_free(error); - throw 0; - } - - package_file = fdopen(fd, "wb"); - if (package_file == NULL) + if(!app_state->url.empty()) { - llerrs << "Failed to create temporary file: " - << tmp_filename - << llendl; + char* tmp_local_filename = NULL; + // create temporary file to store the package. + fd = g_file_open_tmp + ("secondlife-update-XXXXXX", &tmp_local_filename, &error); + if (error != NULL) + { + llerrs << "Unable to create temporary file: " + << error->message + << llendl; - gdk_threads_enter(); - display_error(app_state->window, - LLTrans::getString("UpdaterFailDownloadTitle"), - LLTrans::getString("UpdaterFailUpdateDescriptive")); - gdk_threads_leave(); - throw 0; - } + g_error_free(error); + throw 0; + } + + if(tmp_local_filename != NULL) + { + app_state->file = tmp_local_filename; + g_free(tmp_local_filename); + } - // initialize curl and start downloading the package - llinfos << "Downloading package: " << app_state->url << llendl; + package_file = fdopen(fd, "wb"); + if (package_file == NULL) + { + llerrs << "Failed to create temporary file: " + << app_state->file.c_str() + << llendl; + + gdk_threads_enter(); + display_error(app_state->window, + LLTrans::getString("UpdaterFailDownloadTitle"), + LLTrans::getString("UpdaterFailUpdateDescriptive")); + gdk_threads_leave(); + throw 0; + } - curl = curl_easy_init(); - if (curl == NULL) - { - llerrs << "Failed to initialize libcurl" << llendl; + // initialize curl and start downloading the package + llinfos << "Downloading package: " << app_state->url << llendl; - gdk_threads_enter(); - display_error(app_state->window, - LLTrans::getString("UpdaterFailDownloadTitle"), - LLTrans::getString("UpdaterFailUpdateDescriptive")); - gdk_threads_leave(); - throw 0; - } + curl = curl_easy_init(); + if (curl == NULL) + { + llerrs << "Failed to initialize libcurl" << llendl; + + gdk_threads_enter(); + display_error(app_state->window, + LLTrans::getString("UpdaterFailDownloadTitle"), + LLTrans::getString("UpdaterFailUpdateDescriptive")); + gdk_threads_leave(); + throw 0; + } - curl_easy_setopt(curl, CURLOPT_URL, app_state->url.c_str()); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, TRUE); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, package_file); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, - &download_progress_cb); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, app_state); + curl_easy_setopt(curl, CURLOPT_URL, app_state->url.c_str()); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, TRUE); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, package_file); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, + &download_progress_cb); + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, app_state); - result = curl_easy_perform(curl); - fclose(package_file); - curl_easy_cleanup(curl); + result = curl_easy_perform(curl); + fclose(package_file); + curl_easy_cleanup(curl); - if (result) - { - llerrs << "Failed to download update: " - << app_state->url - << llendl; + if (result) + { + llerrs << "Failed to download update: " + << app_state->url + << llendl; - gdk_threads_enter(); - display_error(app_state->window, - LLTrans::getString("UpdaterFailDownloadTitle"), - LLTrans::getString("UpdaterFailUpdateDescriptive")); - gdk_threads_leave(); + gdk_threads_enter(); + display_error(app_state->window, + LLTrans::getString("UpdaterFailDownloadTitle"), + LLTrans::getString("UpdaterFailUpdateDescriptive")); + gdk_threads_leave(); - throw 0; + throw 0; + } } - + // now pulse the progres bar back and forth while the package is // being unpacked gdk_threads_enter(); @@ -357,7 +368,7 @@ gpointer worker_thread_cb(gpointer data) // *TODO: if the destination is not writable, terminate this // thread and show file chooser? - if (!install_package(tmp_filename, app_state->dest_dir)) + if (!install_package(app_state->file.c_str(), app_state->dest_dir)) { llwarns << "Failed to install package to destination: " << app_state->dest_dir @@ -393,11 +404,11 @@ gpointer worker_thread_cb(gpointer data) } // FIXME: delete package file also if delete-event is raised on window - if (tmp_filename != NULL) + if(!app_state->url.empty() && !app_state->file.empty()) { - if (gDirUtilp->fileExists(tmp_filename)) + if (gDirUtilp->fileExists(app_state->file)) { - LLFile::remove(tmp_filename); + LLFile::remove(app_state->file); } } @@ -712,7 +723,7 @@ BOOL spawn_viewer(UpdaterAppState *app_state) void show_usage_and_exit() { - std::cout << "Usage: linux-updater --url URL --name NAME --dest PATH --stringsdir PATH1,PATH2 --stringsfile FILE" + std::cout << "Usage: linux-updater <--url URL | --file FILE> --name NAME --dest PATH --stringsdir PATH1,PATH2 --stringsfile FILE" << "[--image-dir PATH]" << std::endl; exit(1); @@ -728,6 +739,10 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state) { app_state->url = argv[i]; } + else if ((!strcmp(argv[i], "--file")) && (++i < argc)) + { + app_state->file = argv[i]; + } else if ((!strcmp(argv[i], "--name")) && (++i < argc)) { app_state->app_name = argv[i]; @@ -756,7 +771,7 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state) } if (app_state->app_name.empty() - || app_state->url.empty() + || (app_state->url.empty() && app_state->file.empty()) || app_state->dest_dir.empty()) { show_usage_and_exit(); -- cgit v1.2.3 From dd6213abf4f70cfb9d221572f9dc4d597d8fa0dc Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Tue, 16 Nov 2010 18:34:58 -0800 Subject: CHOP-209 Added marker creation, fixed updater crash bug --- indra/linux_updater/linux_updater.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'indra/linux_updater') diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp index 16660de6bb..a7f886b389 100644 --- a/indra/linux_updater/linux_updater.cpp +++ b/indra/linux_updater/linux_updater.cpp @@ -114,7 +114,7 @@ BOOL install_package(std::string package_file, std::string destination); BOOL spawn_viewer(UpdaterAppState *app_state); extern "C" { - void on_window_closed(GtkWidget *sender, gpointer state); + void on_window_closed(GtkWidget *sender, GdkEvent *event, gpointer state); gpointer worker_thread_cb(gpointer *data); int download_progress_cb(gpointer data, double t, double d, double utotal, double ulnow); gboolean rotate_image_cb(gpointer data); @@ -221,7 +221,7 @@ std::string next_image_filename(std::string& image_path) return image_path + "/" + image_filename; } -void on_window_closed(GtkWidget *sender, gpointer data) +void on_window_closed(GtkWidget *sender, GdkEvent* event, gpointer data) { UpdaterAppState *app_state; @@ -786,10 +786,10 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state) int main(int argc, char **argv) { - UpdaterAppState app_state; + UpdaterAppState* app_state = new UpdaterAppState; GThread *worker_thread; - parse_args_and_init(argc, argv, &app_state); + parse_args_and_init(argc, argv, app_state); // Initialize logger, and rename old log file gDirUtilp->initAppDirs("SecondLife"); @@ -812,17 +812,20 @@ int main(int argc, char **argv) gtk_init(&argc, &argv); // create UI - updater_app_ui_init(&app_state); + updater_app_ui_init(app_state); //llinfos << "SAMPLE TRANSLATION IS: " << LLTrans::getString("LoginInProgress") << llendl; // create download thread worker_thread = g_thread_create - (GThreadFunc(worker_thread_cb), &app_state, FALSE, NULL); + (GThreadFunc(worker_thread_cb), app_state, FALSE, NULL); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); - return (app_state.failure == FALSE) ? 0 : 1; + bool success = app_state->failure != FALSE; + delete app_state; + return success ? 0 : 1; } + -- cgit v1.2.3 From 8e0e5e0bd9fd3e699a36b6babfacab3c0f61935b Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Wed, 17 Nov 2010 15:20:53 -0800 Subject: CHOP-203 Deleting the update file after installer run. --- indra/linux_updater/linux_updater.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/linux_updater') diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp index a7f886b389..cbdb3ddfe0 100644 --- a/indra/linux_updater/linux_updater.cpp +++ b/indra/linux_updater/linux_updater.cpp @@ -403,15 +403,6 @@ gpointer worker_thread_cb(gpointer data) app_state->failure = TRUE; } - // FIXME: delete package file also if delete-event is raised on window - if(!app_state->url.empty() && !app_state->file.empty()) - { - if (gDirUtilp->fileExists(app_state->file)) - { - LLFile::remove(app_state->file); - } - } - gdk_threads_enter(); updater_app_quit(app_state); gdk_threads_leave(); @@ -824,6 +815,15 @@ int main(int argc, char **argv) gtk_main(); gdk_threads_leave(); + // Delete the file only if created from url download. + if(!app_state->url.empty() && !app_state->file.empty()) + { + if (gDirUtilp->fileExists(app_state->file)) + { + LLFile::remove(app_state->file); + } + } + bool success = app_state->failure != FALSE; delete app_state; return success ? 0 : 1; -- cgit v1.2.3 From a5e3ac21b4f0764a9fdb51537abecd265764b4b9 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Thu, 18 Nov 2010 14:49:03 -0800 Subject: CHOP-187 Fixed linux updater return code to return 0 on success --- indra/linux_updater/linux_updater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/linux_updater') diff --git a/indra/linux_updater/linux_updater.cpp b/indra/linux_updater/linux_updater.cpp index cbdb3ddfe0..8aabb5ca60 100644 --- a/indra/linux_updater/linux_updater.cpp +++ b/indra/linux_updater/linux_updater.cpp @@ -824,7 +824,7 @@ int main(int argc, char **argv) } } - bool success = app_state->failure != FALSE; + bool success = !app_state->failure; delete app_state; return success ? 0 : 1; } -- cgit v1.2.3