From f60025a7be613a43ebdbcc55bc5ce80478667edb Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Fri, 25 Jan 2008 12:51:05 -0800 Subject: [PATCH] bug 412788 - add a way for crash report server to tell client to stop sending reports. r=bsmedberg --- .../crashreporter/client/crashreporter.cpp | 36 +++++++++++++++++++ toolkit/crashreporter/client/crashreporter.h | 1 + 2 files changed, 37 insertions(+) diff --git a/toolkit/crashreporter/client/crashreporter.cpp b/toolkit/crashreporter/client/crashreporter.cpp index 68734d031baa..0dc1ee365968 100644 --- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -287,6 +287,21 @@ static bool AddSubmittedReport(const string& serverResponse) istringstream in(serverResponse); ReadStrings(in, responseItems, false); + if (responseItems.find("StopSendingReportsFor") != responseItems.end()) { + // server wants to tell us to stop sending reports for a certain version + string reportPath = + gSettingsPath + UI_DIR_SEPARATOR + "EndOfLife" + + responseItems["StopSendingReportsFor"]; + + ofstream* reportFile = UIOpenWrite(reportPath); + if (reportFile->is_open()) { + // don't really care about the contents + *reportFile << 1 << "\n"; + reportFile->close(); + } + delete reportFile; + } + if (responseItems.find("CrashID") == responseItems.end()) return false; @@ -385,6 +400,19 @@ void RewriteStrings(StringTable& queryParameters) gStrings[ST_RESTART].c_str(), product.c_str()); gStrings[ST_RESTART] = buf; + + + UI_SNPRINTF(buf, sizeof(buf), + gStrings[ST_ERROR_ENDOFLIFE].c_str(), + product.c_str()); + gStrings[ST_ERROR_ENDOFLIFE] = buf; +} + +bool CheckEndOfLifed(string version) +{ + string reportPath = + gSettingsPath + UI_DIR_SEPARATOR + "EndOfLife" + version; + return UIFileExists(reportPath); } int main(int argc, char** argv) @@ -512,6 +540,14 @@ int main(int argc, char** argv) sendURL = urlEnv; } + // see if this version has been end-of-lifed + if (queryParameters.find("Version") != queryParameters.end() && + CheckEndOfLifed(queryParameters["Version"])) { + UIError(gStrings[ST_ERROR_ENDOFLIFE]); + DeleteDump(); + return 0; + } + if (!UIShowCrashUI(gDumpFile, queryParameters, sendURL, restartArgs)) DeleteDump(); } diff --git a/toolkit/crashreporter/client/crashreporter.h b/toolkit/crashreporter/client/crashreporter.h index 357849f8d448..c4085cc2966b 100644 --- a/toolkit/crashreporter/client/crashreporter.h +++ b/toolkit/crashreporter/client/crashreporter.h @@ -69,6 +69,7 @@ typedef std::map StringTable; #define ST_ERROR_NOSERVERURL "ErrorNoServerURL" #define ST_ERROR_NOSETTINGSPATH "ErrorNoSettingsPath" #define ST_ERROR_CREATEDUMPDIR "ErrorCreateDumpDir" +#define ST_ERROR_ENDOFLIFE "ErrorEndOfLife" //============================================================================= // implemented in crashreporter.cpp