Added a new "--add-job <src_file> <out_file> <template>" command-line option. Also the old "--file" option has been deprecated in favor of "--add-file".

This commit is contained in:
LoRd_MuldeR 2014-01-20 22:02:53 +01:00
parent 02dd413577
commit a32c5443ae
4 changed files with 86 additions and 31 deletions

View File

@ -1352,32 +1352,29 @@ static bool x264_event_filter(void *message, long *result)
*/
static bool x264_process_is_elevated(bool *bIsUacEnabled = NULL)
{
typedef enum { x264_token_elevationType_class = 18, x264_token_elevation_class = 20 } X264_TOKEN_INFORMATION_CLASS;
typedef enum { x264_elevationType_default = 1, x264_elevationType_full, x264_elevationType_limited } X264_TOKEN_ELEVATION_TYPE;
bool bIsProcessElevated = false;
if(bIsUacEnabled) *bIsUacEnabled = false;
HANDLE hToken = NULL;
if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
X264_TOKEN_ELEVATION_TYPE tokenElevationType;
TOKEN_ELEVATION_TYPE tokenElevationType;
DWORD returnLength;
if(GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS) x264_token_elevationType_class, &tokenElevationType, sizeof(X264_TOKEN_ELEVATION_TYPE), &returnLength))
if(GetTokenInformation(hToken, TokenElevationType, &tokenElevationType, sizeof(TOKEN_ELEVATION_TYPE), &returnLength))
{
if(returnLength == sizeof(X264_TOKEN_ELEVATION_TYPE))
if(returnLength == sizeof(TOKEN_ELEVATION_TYPE))
{
switch(tokenElevationType)
{
case x264_elevationType_default:
case TokenElevationTypeDefault:
qDebug("Process token elevation type: Default -> UAC is disabled.\n");
break;
case x264_elevationType_full:
case TokenElevationTypeFull:
qWarning("Process token elevation type: Full -> potential security risk!\n");
bIsProcessElevated = true;
if(bIsUacEnabled) *bIsUacEnabled = true;
break;
case x264_elevationType_limited:
case TokenElevationTypeLimited:
qDebug("Process token elevation type: Limited -> not elevated.\n");
if(bIsUacEnabled) *bIsUacEnabled = true;
break;
@ -1386,6 +1383,10 @@ static bool x264_process_is_elevated(bool *bIsUacEnabled = NULL)
break;
}
}
else
{
qWarning("GetTokenInformation() return an unexpected size!");
}
}
CloseHandle(hToken);
}
@ -1471,7 +1472,7 @@ bool x264_user_is_admin(void)
}
//If not elevated and UAC is not available -> user must be in admin group!
if(isAdmin)
if(!isAdmin)
{
qDebug("UAC is disabled/unavailable -> checking for Administrators group");
isAdmin = x264_user_is_admin_helper();

View File

@ -25,8 +25,8 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 2
#define VER_X264_PATCH 8
#define VER_X264_BUILD 723
#define VER_X264_PATCH 9
#define VER_X264_BUILD 726
#define VER_X264_MINIMUM_REV 2363
#define VER_X264_CURRENT_API 140

View File

@ -909,25 +909,7 @@ void MainWindow::init(void)
}
//Add files from command-line
bool bAddFile = false;
QStringList files, args = qApp->arguments();
while(!args.isEmpty())
{
QString current = args.takeFirst();
if(!bAddFile)
{
bAddFile = (current.compare("--add", Qt::CaseInsensitive) == 0);
continue;
}
if((!current.startsWith("--")) && QFileInfo(current).exists() && QFileInfo(current).isFile())
{
files << QFileInfo(current).canonicalFilePath();
}
}
if(files.count() > 0)
{
createJobMultiple(files);
}
parseCommandLineArgs();
}
/*
@ -1381,3 +1363,73 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon);
}
/*
* Parse command-line arguments
*/
void MainWindow::parseCommandLineArgs(void)
{
QStringList files, args = qApp->arguments();
while(!args.isEmpty())
{
QString current = args.takeFirst();
if((current.compare("--add", Qt::CaseInsensitive) == 0) || (current.compare("--add-file", Qt::CaseInsensitive) == 0))
{
if(!args.isEmpty())
{
current = args.takeFirst();
if(QFileInfo(current).exists() && QFileInfo(current).isFile())
{
files << QFileInfo(current).canonicalFilePath();
}
else
{
qWarning("File '%s' not found!", current.toUtf8().constData());
}
}
else
{
qWarning("Argument for '--add-file' is missing!");
}
}
else if(current.compare("--add-job", Qt::CaseInsensitive) == 0)
{
if(args.size() >= 3)
{
const QString fileSrc = args.takeFirst();
const QString fileOut = args.takeFirst();
const QString templId = args.takeFirst();
if(QFileInfo(fileSrc).exists() && QFileInfo(fileSrc).isFile())
{
OptionsModel options;
if(!(templId.isEmpty() || (templId.compare("-", Qt::CaseInsensitive) == 0)))
{
if(!OptionsModel::loadTemplate(&options, templId.trimmed()))
{
qWarning("Template '%s' could not be found -> using defaults!", templId.trimmed().toUtf8().constData());
}
}
appendJob(fileSrc, fileOut, &options, true);
}
else
{
qWarning("Source file '%s' not found!", fileSrc.toUtf8().constData());
}
}
else
{
qWarning("Argument(s) for '--add-job' are missing!");
args.clear();
}
}
else
{
qWarning("Unknown argument: %s", current.toUtf8().constData());
}
}
if(files.count() > 0)
{
createJobMultiple(files);
}
}

View File

@ -90,6 +90,8 @@ private:
unsigned int countPendingJobs(void);
unsigned int countRunningJobs(void);
void parseCommandLineArgs(void);
private slots:
void addButtonPressed();
void openActionTriggered();