From 6cd6b35c737e0e4042a8fd79af1decc9f10ed84b Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Mon, 1 Oct 2012 12:43:05 +1000 Subject: Heimdall 1.4 RC1: - Massive refactoring. - Support for Qualcomm based devices. - Print PIT from file. - Use partition names as arguments e.g. --HIDDEN, --KERNEL, --MOVINAND etc. - Heimdall Frontend UI improvements. - And much more... --- heimdall/source/Interface.h | 281 +++++--------------------------------------- 1 file changed, 30 insertions(+), 251 deletions(-) (limited to 'heimdall/source/Interface.h') diff --git a/heimdall/source/Interface.h b/heimdall/source/Interface.h index ddb7f55..ab4b538 100644 --- a/heimdall/source/Interface.h +++ b/heimdall/source/Interface.h @@ -28,276 +28,55 @@ // libpit #include "libpit.h" +// Heimdall +#include "Heimdall.h" + using namespace std; using namespace libpit; namespace Heimdall { - struct Action + namespace Interface { - public: - - string name; - - string *valueArguments; - string *valueShortArguments; - unsigned int valueArgumentCount; + typedef int (*ActionExecuteFunction)(int, char **); - string *valuelessArguments; - string *valuelessShortArguments; - unsigned int valuelessArgumentCount; + typedef struct ActionInfo + { + ActionExecuteFunction executeFunction; + const char *usage; - Action(const char *name, string *valueArguments, string *valueShortArguments, unsigned int valueArgumentCount, - string *valuelessArguments, string *valuelessShortArguments, unsigned int valuelessArgumentCount) + ActionInfo() { - this->name = name; - - this->valueArguments = valueArguments; - this->valueShortArguments = valueShortArguments; - this->valueArgumentCount = valueArgumentCount; - - this->valuelessArguments = valuelessArguments; - this->valuelessShortArguments = valuelessShortArguments; - this->valuelessArgumentCount = valuelessArgumentCount; + executeFunction = nullptr; + usage = nullptr; } - }; - - class Interface - { - public: - - // Actions - enum - { - kActionFlash = 0, - kActionClosePcScreen, - kActionDump, - kActionPrintPit, - kActionVersion, - kActionHelp, - kActionDetect, - kActionDownloadPit, - kActionInfo, - kActionCount - }; - // Flash value arguments - enum + ActionInfo(ActionExecuteFunction executeFunction, const char *usage) { - kFlashValueArgPit, - kFlashValueArgFactoryFs, - kFlashValueArgCache, - kFlashValueArgDatabaseData, - kFlashValueArgPrimaryBootloader, - kFlashValueArgSecondaryBootloader, - kFlashValueArgSecondaryBootloaderBackup, - kFlashValueArgParam, - kFlashValueArgKernel, - kFlashValueArgRecovery, - kFlashValueArgEfs, - kFlashValueArgModem, - - kFlashValueArgNormalBoot, - kFlashValueArgSystem, - kFlashValueArgUserData, - kFlashValueArgFota, - kFlashValueArgHidden, - kFlashValueArgMovinand, - kFlashValueArgData, - kFlashValueArgUms, - kFlashValueArgEmmc, - - kFlashValueArgPartitionIndex, - - kFlashValueArgCount - }; - - // Flash valueless arguments - enum - { - kFlashValuelessArgRepartition = 0, - - kFlashValuelessArgCount - }; - - // Close PC Screen value arguments - enum - { - kClosePcScreenValueArgCount = 0 - }; - - // Close PC Screen valueless arguments - enum - { - kClosePcScreenValuelessArgCount = 0 - }; - - // Dump value arguments - enum - { - kDumpValueArgChipType = 0, - kDumpValueArgChipId, - kDumpValueArgOutput, - - kDumpValueArgCount - }; - - // Dump valueless arguments - enum - { - kDumpValuelessArgCount = 0 - }; - - // Print PIT value arguments - enum - { - kPrintPitValueArgCount = 0 - }; - - // Print PIT valueless arguments - enum - { - kPrintPitValuelessArgCount = 0 - }; - - // Version value arguments - enum - { - kVersionValueArgCount = 0 - }; - - // Version valueless arguments - enum - { - kVersionValuelessArgCount = 0 - }; - - // Help value arguments - enum - { - kHelpValueArgCount = 0 - }; - - // Help valueless arguments - enum - { - kHelpValuelessArgCount = 0 - }; - - // Info value arguments - enum - { - kInfoValueArgCount = 0 - }; - - // Info valueless arguments - enum - { - kInfoValuelessArgCount = 0 - }; - - // Detect value arguments - enum - { - kDetectValueArgCount = 0 - }; - - // Detect valueless arguments - enum - { - kDetectValuelessArgCount = 0 - }; - - // Download PIT value arguments - enum - { - kDownloadPitValueArgOutput = 0, - kDownloadPitValueArgCount - }; - - // Download PIT valueless arguments - enum - { - kDownloadPitValuelessArgCount = 0 - }; - - // Common value arguments - enum - { - kCommonValueArgDelay = 0, - - kCommonValueArgCount - }; - - // Comon valueless arguments - enum - { - kCommonValuelessArgVerbose = 0, - kCommonValuelessArgNoReboot, - kCommonValuelessArgStdoutErrors, - - kCommonValuelessArgCount - }; - - private: - - static bool stdoutErrors; - - static const char *version; - static const char *usage; - static const char *releaseInfo; - static const char *extraInfo; - - // Flash arguments - static string flashValueArguments[kFlashValueArgCount]; - static string flashValueShortArguments[kFlashValueArgCount]; - - static string flashValuelessArguments[kFlashValuelessArgCount]; - static string flashValuelessShortArguments[kFlashValuelessArgCount]; - - // Download PIT arguments - static string downloadPitValueArguments[kDownloadPitValueArgCount]; - static string downloadPitValueShortArguments[kDownloadPitValueArgCount]; - - // Dump arguments - static string dumpValueArguments[kDumpValueArgCount]; - static string dumpValueShortArguments[kDumpValueArgCount]; - - public: - - // Common arguments - static string commonValueArguments[kCommonValueArgCount]; - static string commonValueShortArguments[kCommonValueArgCount]; - - static string commonValuelessArguments[kCommonValuelessArgCount]; - static string commonValuelessShortArguments[kCommonValuelessArgCount]; - - static Action actions[kActionCount]; + this->executeFunction = executeFunction; + this->usage = usage; + } - static bool GetArguments(int argc, char **argv, map& argumentMap, int *actionIndex); + } ActionInfo; - static void Print(const char *format, ...); - static void PrintError(const char *format, ...); - static void PrintErrorSameLine(const char *format, ...); + const map& GetActionMap(void); - static void PrintVersion(void); - static void PrintUsage(void); - static void PrintReleaseInfo(void); - static void PrintFullInfo(void); + void Print(const char *format, ...); + void PrintWarning(const char *format, ...); + void PrintWarningSameLine(const char *format, ...); + void PrintError(const char *format, ...); + void PrintErrorSameLine(const char *format, ...); - static void PrintDeviceDetectionFailed(void); + void PrintVersion(void); + void PrintUsage(void); + void PrintReleaseInfo(void); + void PrintFullInfo(void); - static void PrintPit(const PitData *pitData); + void PrintDeviceDetectionFailed(void); - static string& GetPitArgument(void) - { - return (flashValueArguments[kFlashValueArgPit]); - } + void PrintPit(const PitData *pitData); - static void SetStdoutErrors(bool enabled) - { - stdoutErrors = enabled; - } + void SetStdoutErrors(bool enabled); }; } -- cgit v1.1