--- mozilla/toolkit/mozapps/update/src/updater/updater.cpp Mon Sep 10 17:04:55 2007 +++ mozilla/toolkit/mozapps/update/src/updater/updater.cpp Mon Sep 10 16:20:35 2007 @@ -1013,12 +1013,79 @@ PatchFile::Finish(status); } -//----------------------------------------------------------------------------- #ifdef XP_WIN #include "nsWindowsRestart.cpp" #endif + +class CustomAction : public Action +{ +public: + CustomAction() : mFile(NULL) { } + + virtual int Parse(char *line); + virtual int Prepare(); + virtual int Execute(); + virtual void Finish(int status); + +private: + const char *mFile; +}; + +int +CustomAction::Parse(char *line) +{ + // format "" + + mFile = mstrtok(kQuote, &line); + if (!mFile) + return PARSE_ERROR; + + return OK; +} + +int +CustomAction::Prepare() +{ + LOG(("PREPARE CUSTOMACTION %s\n", mFile)); + + return OK; +} + +int +CustomAction::Execute() +{ + LOG(("EXECUTE CUSTOMACTION %s\n", mFile)); + + static int argc = 1; + static char **argv = (char**) malloc(sizeof(char*) * (argc + 1)); + argv[0] = (char*) mFile; + argv[2] = "\0"; + + // Note: currently ignoring the retval from the launched exe. +#if defined(USE_EXECV) + execv(argv[0], argv); +#elif defined(XP_MACOSX) + LaunchChild(argc, argv); +#elif defined(XP_WIN) + WinLaunchChild(argv[0], argc, argv, 1); // 1 == need priv elevation +#else +# warning "Need implementaton of CustomAction::Execute" +#endif + + free(argv); + return OK; +} + +void +CustomAction::Finish(int status) +{ + LOG(("FINISH CUSTOMACTION %s\n", mFile)); +} + +//----------------------------------------------------------------------------- + static void LaunchCallbackApp(const char *workingDir, int argc, char **argv) { @@ -1326,6 +1393,9 @@ } else if (strcmp(token, "patch-if") == 0) { action = new PatchIfFile(); + } + else if (strcmp(token, "customaction") == 0) { + action = new CustomAction(); } else { return PARSE_ERROR;