From 5620458e8c15b3ecfe3204c952aa00f090bfbbac Mon Sep 17 00:00:00 2001 From: "alfred.peng@sun.com" Date: Tue, 29 Apr 2008 00:37:12 -0700 Subject: [PATCH] Bug 385280. should send proxy settings to the breakpad reporter(For Linux/Solaris). r=ted.mielczarek,a=dsicore. --- toolkit/crashreporter/client/Makefile.in | 8 +-- .../client/crashreporter_linux.cpp | 53 ++++++++++++++++++- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/toolkit/crashreporter/client/Makefile.in b/toolkit/crashreporter/client/Makefile.in index 211692e8ae9..71c323d1222 100644 --- a/toolkit/crashreporter/client/Makefile.in +++ b/toolkit/crashreporter/client/Makefile.in @@ -83,8 +83,8 @@ LIBS += \ $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/linux/$(LIB_PREFIX)breakpad_linux_common_s.$(LIB_SUFFIX) \ $(NULL) LOCAL_INCLUDES += -I$(srcdir) -OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GTHREAD_CFLAGS) -OS_LIBS += $(MOZ_GTK2_LIBS) $(MOZ_GTHREAD_LIBS) +OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GCONF_CFLAGS) $(MOZ_GTHREAD_CFLAGS) +OS_LIBS += $(MOZ_GTK2_LIBS) $(MOZ_GCONF_LIBS) $(MOZ_GTHREAD_LIBS) CPPSRCS += http_upload.cc FORCE_USE_PIC=1 endif @@ -95,8 +95,8 @@ LIBS += \ $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/solaris/$(LIB_PREFIX)breakpad_solaris_common_s.$(LIB_SUFFIX) \ $(NULL) LOCAL_INCLUDES += -I$(srcdir) -OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GTHREAD_CFLAGS) -OS_LIBS += $(MOZ_GTK2_LIBS) $(MOZ_GTHREAD_LIBS) +OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GCONF_CFLAGS) $(MOZ_GTHREAD_CFLAGS) +OS_LIBS += $(MOZ_GTK2_LIBS) $(MOZ_GCONF_LIBS) $(MOZ_GTHREAD_LIBS) CPPSRCS += http_upload.cc FORCE_USE_PIC=1 endif diff --git a/toolkit/crashreporter/client/crashreporter_linux.cpp b/toolkit/crashreporter/client/crashreporter_linux.cpp index 21d5261cbf9..36fea49b52f 100644 --- a/toolkit/crashreporter/client/crashreporter_linux.cpp +++ b/toolkit/crashreporter/client/crashreporter_linux.cpp @@ -50,6 +50,7 @@ #include +#include #include #include #include @@ -78,6 +79,8 @@ static bool gDidTrySend = false; static string gDumpFile; static StringTable gQueryParameters; static string gSendURL; +static string gHttpProxy; +static string gAuth; static vector gRestartArgs; static string gURLParameter; @@ -93,6 +96,8 @@ static void* gnomeuiLib = NULL; static const char kIniFile[] = "crashreporter.ini"; +#define HTTP_PROXY_DIR "/system/http_proxy" + static void LoadSettings() { StringTable settings; @@ -188,15 +193,61 @@ static gboolean ReportCompleted(gpointer success) return FALSE; } +static void LoadProxyinfo() +{ + GConfClient *conf = gconf_client_get_default(); + + if (!getenv ("http_proxy") && + gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_http_proxy", NULL)) { + gint port; + gchar *host = NULL, *httpproxy = NULL; + + host = gconf_client_get_string(conf, HTTP_PROXY_DIR "/host", NULL); + port = gconf_client_get_int(conf, HTTP_PROXY_DIR "/port", NULL); + + if (port && host && host != '\0') { + httpproxy = g_strdup_printf("http://%s:%d/", host, port); + gHttpProxy = httpproxy; + } + + g_free(host); + g_free(httpproxy); + + if(gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_authentication", NULL)) { + gchar *user, *password, *auth; + + user = gconf_client_get_string(conf, + HTTP_PROXY_DIR "/authentication_user", + NULL); + password = gconf_client_get_string(conf, + HTTP_PROXY_DIR + "/authentication_password", + NULL); + + if (user != "\0") { + auth = g_strdup_printf("%s:%s", user, password); + gAuth = auth; + } + + g_free(user); + g_free(password); + g_free(auth); + } + } + + g_object_unref(conf); +} + static gpointer SendThread(gpointer args) { string response, error; + LoadProxyinfo(); bool success = google_breakpad::HTTPUpload::SendRequest (gSendURL, gQueryParameters, gDumpFile, "upload_file_minidump", - "", "", + gHttpProxy, gAuth, &response, &error); if (success) {