bug 412788 - add a way for crash report server to tell client to stop sending reports. r=bsmedberg
authorted.mielczarek@gmail.com
Fri, 25 Jan 2008 12:51:05 -0800
changeset 10680 500f5a773ffde192ece10dd2e88492aa35502b82
parent 10679 864173b3197842a8a2dfe2d7cd88dd1d23d6195d
child 10681 a80fb81f3aa96fbb545faa71977e69a2a1eec687
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs412788
milestone1.9b3pre
bug 412788 - add a way for crash report server to tell client to stop sending reports. r=bsmedberg
toolkit/crashreporter/client/crashreporter.cpp
toolkit/crashreporter/client/crashreporter.h
--- a/toolkit/crashreporter/client/crashreporter.cpp
+++ b/toolkit/crashreporter/client/crashreporter.cpp
@@ -282,16 +282,31 @@ static bool MoveCrashData(const string& 
 }
 
 static bool AddSubmittedReport(const string& serverResponse)
 {
   StringTable responseItems;
   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;
 
   string submittedDir =
     gSettingsPath + UI_DIR_SEPARATOR + "submitted";
   if (!UIEnsurePathExists(submittedDir)) {
     return false;
   }
@@ -380,16 +395,29 @@ void RewriteStrings(StringTable& queryPa
               gStrings[ST_CHECKSUBMIT].c_str(),
               vendor.c_str());
   gStrings[ST_CHECKSUBMIT] = buf;
 
   UI_SNPRINTF(buf, sizeof(buf),
               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)
 {
   gArgc = argc;
   gArgv = argv;
 
   if (!ReadConfig()) {
@@ -507,16 +535,24 @@ int main(int argc, char** argv)
     // allow override of the server url via environment variable
     //XXX: remove this in the far future when our robot
     // masters force everyone to use XULRunner
     char* urlEnv = getenv("MOZ_CRASHREPORTER_URL");
     if (urlEnv && *urlEnv) {
       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();
   }
 
   UIShutdown();
 
   return 0;
 }
--- a/toolkit/crashreporter/client/crashreporter.h
+++ b/toolkit/crashreporter/client/crashreporter.h
@@ -64,16 +64,17 @@ typedef std::map<std::string, std::strin
 #define ST_ERROR_EXTRAFILEREAD       "ErrorExtraFileRead"
 #define ST_ERROR_EXTRAFILEMOVE       "ErrorExtraFileMove"
 #define ST_ERROR_DUMPFILEEXISTS      "ErrorDumpFileExists"
 #define ST_ERROR_DUMPFILEMOVE        "ErrorDumpFileMove"
 #define ST_ERROR_NOPRODUCTNAME       "ErrorNoProductName"
 #define ST_ERROR_NOSERVERURL         "ErrorNoServerURL"
 #define ST_ERROR_NOSETTINGSPATH      "ErrorNoSettingsPath"
 #define ST_ERROR_CREATEDUMPDIR       "ErrorCreateDumpDir"
+#define ST_ERROR_ENDOFLIFE           "ErrorEndOfLife"
 
 //=============================================================================
 // implemented in crashreporter.cpp
 //=============================================================================
 
 namespace CrashReporter {
   extern StringTable  gStrings;
   extern std::string  gSettingsPath;